]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/matroskadec.c
avformat/libsrt: fix race condition with libsrt_network_wait_fd and epoll
[ffmpeg] / libavformat / matroskadec.c
index 137674c06822520eaab037112e9c0e781c7448a7..374831baa32acc10b60f943c29e974d51b70684e 100644 (file)
@@ -2318,6 +2318,15 @@ static int matroska_parse_tracks(AVFormatContext *s)
         if (!track->codec_id)
             continue;
 
+        if (   track->type == MATROSKA_TRACK_TYPE_AUDIO && track->codec_id[0] != 'A'
+            || track->type == MATROSKA_TRACK_TYPE_VIDEO && track->codec_id[0] != 'V'
+            || track->type == MATROSKA_TRACK_TYPE_SUBTITLE && track->codec_id[0] != 'D' && track->codec_id[0] != 'S'
+            || track->type == MATROSKA_TRACK_TYPE_METADATA && track->codec_id[0] != 'D' && track->codec_id[0] != 'S'
+        ) {
+            av_log(matroska->ctx, AV_LOG_INFO, "Inconsistent track type\n");
+            continue;
+        }
+
         if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX ||
             isnan(track->audio.samplerate)) {
             av_log(matroska->ctx, AV_LOG_WARNING,
@@ -3547,7 +3556,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
     uint32_t lace_size[256];
     int n, flags, laces = 0;
     uint64_t num;
-    int trust_default_duration = 1;
+    int trust_default_duration;
 
     ffio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL);
 
@@ -3615,7 +3624,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
         return res;
     }
 
-    if (track->audio.samplerate == 8000) {
+    trust_default_duration = track->default_duration != 0;
+    if (track->audio.samplerate == 8000 && trust_default_duration) {
         // If this is needed for more codecs, then add them here
         if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
             if (track->audio.samplerate != st->codecpar->sample_rate || !st->codecpar->frame_size)