]> git.sesse.net Git - ffmpeg/commitdiff
avformat/matroskadec: only use the track duration if it exists
authorSteve Lhomme <robux4@ycbcr.xyz>
Sun, 15 Nov 2020 09:00:35 +0000 (10:00 +0100)
committerAnton Khirnov <anton@khirnov.net>
Fri, 20 Nov 2020 14:20:24 +0000 (15:20 +0100)
No need to multiplying/dividing when we know it's zero.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavformat/matroskadec.c

index 137674c06822520eaab037112e9c0e781c7448a7..44db2c8358e8b38c2cb3b99651f65a749575a54a 100644 (file)
@@ -3547,7 +3547,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 +3615,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)