From patchwork Wed Jan 4 16:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39867 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942102pzb; Wed, 4 Jan 2023 08:45:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtwKZxSE/jr9kf/cbgoyGemAvgsL91OZ88iCcZRD0pN6A6HwHc81y66c7RygE41yCIOnFbr X-Received: by 2002:a17:907:3e0c:b0:7c0:f90f:163d with SMTP id hp12-20020a1709073e0c00b007c0f90f163dmr54748310ejc.11.1672850757742; Wed, 04 Jan 2023 08:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850757; cv=none; d=google.com; s=arc-20160816; b=xs9wLZ48ahVUL/c+p62/01HqDCT4afa7qgAUsQW8anPqtPBZM6h8Maw7p0ssTxIILt mkx3pwe4sOrdJR7pLacUH8jC5p+fsoZ2cKjfHX54ib1K7hdNywgOX6kzvfSKG50O9/1n xVV8L5OjUXMUYZ2atjEk0KADVyxDq4ky71vBL0VzeaHg7MjoBCgbfbM/U6m7aDOU7DkG Z5NaiGzAs666H4yGT+v4FDyORjhkoi5WnM4vFndsHZzaXTcQXGZEea/k4hrOlgM36Dn/ rIXBt+Q7ucdiTeQu9E+grliR0MiWSLVDPUsC3utA2rFgYMZaOutETWp6aRuNEGSgfcO4 3LpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=CWkOkJxj5GJyiYMb16B9F392Yqtnxnjb7W0IM8l0F8U=; b=zhNPj+sul8aQSQePyMii8KvF77gdj9dVOEcSpaZoRlmeEy5gRhFAtDt9qZ5qPXpMk8 IXXqo80FJ+IgzWs10CLxbrko7C7LkmNnyzSLCcVFmFCds8h3rAcbEjvY6V4ZxvALcaQ/ +NZqVM5Lb6+hUUFeuRy4b7eZGie1suEREMntprNUdiryJj3nA2584GxKDZnf3SZdeDMZ fuEYjLlJsb9//bN4/5UhmIztix76JtNWBnnqKwci5CBd7n/AMX8povjpuBVDIFI7gtoF sphWXsmEwTjzkYS2rbzBh3QKkrrDX9oB/g/eRAFYRve2yntD1YgXQvasWXFJrJhnj/7J 8e2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i10-20020a170906264a00b007aea5ae3956si21999322ejc.820.2023.01.04.08.45.57; Wed, 04 Jan 2023 08:45:57 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F55B68BCF7; Wed, 4 Jan 2023 18:45:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A71D68BCCF for ; Wed, 4 Jan 2023 18:45:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0604A240591 for ; Wed, 4 Jan 2023 17:45:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZSJCERcr2Xw9 for ; Wed, 4 Jan 2023 17:45:18 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 8E443240499 for ; Wed, 4 Jan 2023 17:45:18 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 87B053A0344 for ; Wed, 4 Jan 2023 17:45:10 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Jan 2023 17:42:40 +0100 Message-Id: <20230104164246.6133-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230104164246.6133-1-anton@khirnov.net> References: <20230104164246.6133-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: aSc9TNXBUPAJ Use the decoded frame's sample_rate instead, which is the authoritative value. Drop a now-obsolete check validating AVCodecContext.sample_rate. --- fftools/ffmpeg.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 881d6f0af2..2dbfeca020 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2017,11 +2017,6 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, if (ret < 0) *decode_failed = 1; - if (ret >= 0 && avctx->sample_rate <= 0) { - av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate); - ret = AVERROR_INVALIDDATA; - } - if (ret != AVERROR_EOF) check_decode_result(ist, got_output, ret); @@ -2034,9 +2029,9 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, /* increment next_dts to use for the case where the input stream does not have timestamps or there are multiple frames in the packet */ ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / - avctx->sample_rate; + decoded_frame->sample_rate; ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / - avctx->sample_rate; + decoded_frame->sample_rate; if (decoded_frame->pts != AV_NOPTS_VALUE) { decoded_frame_tb = ist->st->time_base; @@ -2054,8 +2049,10 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, ist->prev_pkt_pts = pkt->pts; if (decoded_frame->pts != AV_NOPTS_VALUE) decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, - (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last, - (AVRational){1, avctx->sample_rate}); + (AVRational){1, decoded_frame->sample_rate}, + decoded_frame->nb_samples, + &ist->filter_in_rescale_delta_last, + (AVRational){1, decoded_frame->sample_rate}); ist->nb_samples = decoded_frame->nb_samples; err = send_frame_to_filters(ist, decoded_frame);