From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 19DF14B843 for ; Sun, 26 Jan 2025 19:55:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F24368B47F; Sun, 26 Jan 2025 21:55:38 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBEDA68A1CE for ; Sun, 26 Jan 2025 21:55:31 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D37B9EB98A for ; Sun, 26 Jan 2025 20:56:08 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X-A5eew9Eb5x for ; Sun, 26 Jan 2025 20:56:07 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 0CDFEEB987 for ; Sun, 26 Jan 2025 20:56:07 +0100 (CET) Date: Sun, 26 Jan 2025 20:56:06 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20250126141353.790684-1-viraajraulgkar@gmail.com> Message-ID: <35e51114-c1f3-0c06-2f70-b5eb2d3c1b75@passwd.hu> References: <20250126141353.790684-1-viraajraulgkar@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2] avformat/riffdec: warn on invalid sample rate 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, 26 Jan 2025, Viraaj Raulgaonkar wrote: > Instead of returning an error for invalid sample rates, warn the user > and set sample_rate to INT_MAX. This allows the sample rate to be > decoded in certain cases. > > Fixes Trac Ticket #11361. > --- > libavformat/riffdec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c > index b7a85a6ab2..c8b50d5f35 100644 > --- a/libavformat/riffdec.c > +++ b/libavformat/riffdec.c > @@ -180,9 +180,9 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb, > par->bit_rate = bitrate; > > if (par->sample_rate <= 0) { > - av_log(logctx, AV_LOG_ERROR, > + av_log(logctx, AV_LOG_WARNING, > "Invalid sample rate: %d\n", par->sample_rate); > - return AVERROR_INVALIDDATA; > + par->sample_rate = INT_MAX; Making up a false sample rate is not acceptable. You should set it to 0 instead, at least that can be interpreted as unknown. Also you should check AVFormatContext strict_std_compliance and reject or allow based on that: Something like: int strict = logctx->strict_std_compliance >= FF_COMPLIANCE_STRICT; av_log(s, strict ? AV_LOG_ERROR : AV_LOG_WARNING, "Invalid sample rate: %d\n", par->sample_rate) if (strict) return AVERROR_INVALIDDATA; par->sample_rate = 0; logctx should be an AVFormatContext, so you should change the type from void* to that. Thanks, Marton > } > if (par->codec_id == AV_CODEC_ID_AAC_LATM) { > /* Channels and sample_rate values are those prior to applying SBR > -- > 2.39.5 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".