changeset 4915:26708ee9a51d libavformat

ensure first pts is set, according to specs
author bcoudurier
date Sun, 10 May 2009 01:57:21 +0000
parents 75a9c3042800
children ac72eb0a95a7
files mpegtsenc.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mpegtsenc.c	Sun May 10 01:41:35 2009 +0000
+++ b/mpegtsenc.c	Sun May 10 01:57:21 2009 +0000
@@ -173,6 +173,7 @@
     int pid; /* stream associated pid */
     int cc;
     int payload_index;
+    int first_pts_check; ///< first pts check needed
     int64_t payload_pts;
     int64_t payload_dts;
     uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE];
@@ -419,6 +420,7 @@
         ts_st->pid = DEFAULT_START_PID + i;
         ts_st->payload_pts = AV_NOPTS_VALUE;
         ts_st->payload_dts = AV_NOPTS_VALUE;
+        ts_st->first_pts_check = 1;
         /* update PCR pid by using the first video stream */
         if (st->codec->codec_type == CODEC_TYPE_VIDEO &&
             service->pcr_pid == 0x1fff)
@@ -701,6 +703,12 @@
     if (pkt->dts != AV_NOPTS_VALUE)
         dts = pkt->dts + delay;
 
+    if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
+        av_log(s, AV_LOG_ERROR, "first pts value must set\n");
+        return -1;
+    }
+    ts_st->first_pts_check = 0;
+
     if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
         /* for subtitle, a single PES packet must be generated */
         mpegts_write_pes(s, st, buf, size, pts, AV_NOPTS_VALUE);