]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mpegts.c
mov: do not misreport empty stts
[ffmpeg] / libavformat / mpegts.c
index 2bc66ac6859d29caede56d98b0c1cd5b5962ba2b..c625552600d9a2526309c5bb5cf125d4d0a74919 100644 (file)
@@ -628,7 +628,7 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt)
 
     if(pes->total_size != MAX_PES_PAYLOAD &&
        pes->pes_header_size + pes->data_index != pes->total_size + 6) {
-        av_log(pes->ts, AV_LOG_WARNING, "PES packet size mismatch\n");
+        av_log(pes->stream, AV_LOG_WARNING, "PES packet size mismatch\n");
         pes->flags |= AV_PKT_FLAG_CORRUPT;
     }
     memset(pkt->data+pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
@@ -886,9 +886,8 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
         avio_r8(&pb);
         len = ff_mp4_read_descr(s, &pb, &tag);
         if (tag == MP4ESDescrTag) {
-            *es_id = avio_rb16(&pb); /* ES_ID */
+            ff_mp4_parse_es_descr(&pb, es_id);
             av_dlog(s, "ES_ID %#x\n", *es_id);
-            avio_r8(&pb); /* priority */
             len = ff_mp4_read_descr(s, &pb, &tag);
             if (tag == MP4DecConfigDescrTag) {
                 *dec_config_descr = av_malloc(len);
@@ -1293,7 +1292,9 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
 
     tss->last_cc = cc;
     if (!cc_ok) {
-        av_log(ts, AV_LOG_WARNING, "Continuity Check Failed\n");
+        av_log(ts->stream, AV_LOG_WARNING,
+               "Continuity check failed for pid %d expected %d got %d\n",
+               pid, expected_cc, cc);
         if(tss->type == MPEGTS_PES) {
             PESContext *pc = tss->u.pes_filter.opaque;
             pc->flags |= AV_PKT_FLAG_CORRUPT;
@@ -1408,15 +1409,17 @@ static int handle_packets(MpegTSContext *ts, int nb_packets)
 
     if (avio_tell(s->pb) != ts->last_pos) {
         int i;
-        av_dlog("Skipping after seek\n");
+        av_dlog(ts->stream, "Skipping after seek\n");
         /* seek detected, flush pes buffer */
         for (i = 0; i < NB_PID_MAX; i++) {
-            if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) {
-                PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
-                av_freep(&pes->buffer);
+            if (ts->pids[i]) {
+                if (ts->pids[i]->type == MPEGTS_PES) {
+                   PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
+                   av_freep(&pes->buffer);
+                   pes->data_index = 0;
+                   pes->state = MPEGTS_SKIP; /* skip until pes header */
+                }
                 ts->pids[i]->last_cc = -1;
-                pes->data_index = 0;
-                pes->state = MPEGTS_SKIP; /* skip until pes header */
             }
         }
     }
@@ -1508,13 +1511,6 @@ static int mpegts_read_header(AVFormatContext *s,
     int len;
     int64_t pos;
 
-#if FF_API_FORMAT_PARAMETERS
-    if (ap) {
-        if (ap->mpeg2ts_compute_pcr)
-            ts->mpeg2ts_compute_pcr = ap->mpeg2ts_compute_pcr;
-    }
-#endif
-
     /* read the first 1024 bytes to get packet size */
     pos = avio_tell(pb);
     len = avio_read(pb, buf, sizeof(buf));