From patchwork Sun Nov 15 09:00:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Lhomme X-Patchwork-Id: 23648 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9C45F44AB38 for ; Sun, 15 Nov 2020 11:00:43 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8472468B796; Sun, 15 Nov 2020 11:00:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8BA568AAFD for ; Sun, 15 Nov 2020 11:00:41 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4CYmQ12dZgzQkZy for ; Sun, 15 Nov 2020 10:00:41 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id Os2ujir9khSj for ; Sun, 15 Nov 2020 10:00:38 +0100 (CET) From: Steve Lhomme To: ffmpeg-devel@ffmpeg.org Date: Sun, 15 Nov 2020 10:00:35 +0100 Message-Id: <20201115090035.26159-1-robux4@ycbcr.xyz> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.10 / 15.00 / 15.00 X-Rspamd-Queue-Id: 556161704 X-Rspamd-UID: ee6584 Subject: [FFmpeg-devel] [PATCH] avformat/matroskadec: only use the track duration if it exists X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" No need to multiplying/dividing when we know it's zero. --- libavformat/matroskadec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4ff472005e..25b22afebe 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)