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 ESMTP id CFF2E43FD4 for ; Tue, 23 Aug 2022 22:49:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 25CA168B9D0; Wed, 24 Aug 2022 01:49:39 +0300 (EEST) Received: from nupi.pair.com (nupi.pair.com [209.68.5.149]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3BEA68B78D for ; Wed, 24 Aug 2022 01:49:31 +0300 (EEST) Received: from nupi.pair.com (localhost [127.0.0.1]) by nupi.pair.com (Postfix) with ESMTP id 9BE384B204; Tue, 23 Aug 2022 18:49:29 -0400 (EDT) Received: from [192.168.0.2] (pool-108-45-159-176.washdc.fios.verizon.net [108.45.159.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by nupi.pair.com (Postfix) with ESMTPSA id 7E5564B20D; Tue, 23 Aug 2022 18:49:29 -0400 (EDT) Message-ID: <78a0e04c-79e4-df98-c744-e6e759f2b64e@flaterco.com> Date: Tue, 23 Aug 2022 18:49:29 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-US From: David Flater To: ffmpeg-devel@ffmpeg.org References: <80c09a85-3421-1526-ab7c-b0b3b14f9996@flaterco.com> In-Reply-To: <80c09a85-3421-1526-ab7c-b0b3b14f9996@flaterco.com> X-Scanned-By: mailmunge 3.09 on 209.68.5.149 Subject: Re: [FFmpeg-devel] [PATCH] avfilter/af_alimiter: fix misbehavior when nb_channels != 2 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This is a friendly reminder. Cc: Paul B Mahol On 2022-08-14 21:53, David Flater wrote: > Some code in alimiter assumes that there are 2 channels, resulting in > clipping if the loudest channel is 3 or above and an out-of-bounds read if > the input is monophonic. Fix that in 2 places. > > Signed-off-by: David Flater > --- > libavfilter/af_alimiter.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > diff --git a/libavfilter/af_alimiter.c b/libavfilter/af_alimiter.c > index 622dc66324..c683c4bcf4 100644 > --- a/libavfilter/af_alimiter.c > +++ b/libavfilter/af_alimiter.c > @@ -194,10 +194,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) > } else { > for (i = s->nextiter; i < s->nextiter + s->nextlen; i++) { > int j = i % buffer_size; > - double ppeak, pdelta; > + double ppeak = 0, pdelta; > > - ppeak = fabs(buffer[nextpos[j]]) > fabs(buffer[nextpos[j] + 1]) ? > - fabs(buffer[nextpos[j]]) : fabs(buffer[nextpos[j] + 1]); > + for (c = 0; c < channels; c++) { > + ppeak = FFMAX(ppeak, fabs(buffer[nextpos[j] + c])); > + } > pdelta = (limit / peak - limit / ppeak) / (((buffer_size - nextpos[j] + s->pos) % buffer_size) / channels); > if (pdelta < nextdelta[j]) { > nextdelta[j] = pdelta; > @@ -241,14 +242,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) > s->delta = get_rdelta(s, release, inlink->sample_rate, > peak, limit, s->att, 1); > if (s->nextlen > 1) { > + double ppeak = 0, pdelta; > int pnextpos = nextpos[(s->nextiter + 1) % buffer_size]; > - double ppeak = fabs(buffer[pnextpos]) > fabs(buffer[pnextpos + 1]) ? > - fabs(buffer[pnextpos]) : > - fabs(buffer[pnextpos + 1]); > - double pdelta = (limit / ppeak - s->att) / > - (((buffer_size + pnextpos - > - ((s->pos + channels) % buffer_size)) % > - buffer_size) / channels); > + > + for (c = 0; c < channels; c++) { > + ppeak = FFMAX(ppeak, fabs(buffer[pnextpos + c])); > + } > + pdelta = (limit / ppeak - s->att) / > + (((buffer_size + pnextpos - > + ((s->pos + channels) % buffer_size)) % > + buffer_size) / channels); > if (pdelta < s->delta) > s->delta = pdelta; > } _______________________________________________ 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".