[FFmpeg-cvslog] avformat/matroskadec: only use the track duration if it exists

Steve Lhomme git at videolan.org
Fri Nov 20 17:02:20 EET 2020


ffmpeg | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Sun Nov 15 10:00:35 2020 +0100| [5bd870a2123915bdf63d57f468b0ef3c7b6823ea] | committer: Anton Khirnov

avformat/matroskadec: only use the track duration if it exists

No need to multiplying/dividing when we know it's zero.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5bd870a2123915bdf63d57f468b0ef3c7b6823ea
---

 libavformat/matroskadec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 137674c068..44db2c8358 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -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)



More information about the ffmpeg-cvslog mailing list