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 B330246754 for ; Fri, 16 Jun 2023 23:17:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E08CA68C19B; Sat, 17 Jun 2023 02:17:56 +0300 (EEST) Received: from mail-02-2.mymagenta.at (mail-02-2.mymagenta.at [80.109.253.249]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A541768BF73 for ; Sat, 17 Jun 2023 02:17:50 +0300 (EEST) Received: from [192.168.232.136] (helo=ren-mail-psmtp-mg02.) by mail-02.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1qAHoX-00Fbvp-92 for ffmpeg-devel@ffmpeg.org; Sat, 17 Jun 2023 00:21:05 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg02. with ESMTP id AHoYqebx5bZLDAHoYqtm6J; Sat, 17 Jun 2023 00:21:06 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=648ce052 a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ezWIuvjslLAyMOsoAWUA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 17 Jun 2023 00:20:46 +0200 Message-Id: <20230616222048.6562-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230616222048.6562-1-michael@niedermayer.cc> References: <20230616222048.6562-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4xfCAT7N5wgBO4c9DxY5d39U++tGHNrkiTqhLtZEA5CURkVpHzL2/pZDtnPtfMpk8zkAN/9T2Lv8EGCzCIzs4slj+1ig6/KF0b9v32NFgrh5sh9Xel0iUA YFvuAJfK2b2MiWQ6r9Ps/nHQCArx8jeZvJTdvqvxWrj3tabNiSayNElowaZ59DH9IMSYNqDmRFZ7JQ== Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/kbdwin: Support arbitrary sized windows 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 MIME-Version: 1.0 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: Signed-off-by: Michael Niedermayer --- libavcodec/kbdwin.c | 22 ++++++++++++++-------- libavcodec/kbdwin.h | 8 +++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c index 163f9d5251..82755874d4 100644 --- a/libavcodec/kbdwin.c +++ b/libavcodec/kbdwin.c @@ -19,20 +19,23 @@ #include "libavutil/avassert.h" #include "libavutil/mathematics.h" #include "libavutil/attributes.h" +#include "libavutil/mem.h" #include "kbdwin.h" -av_cold static void kbd_window_init(float *float_window, int *int_window, float alpha, int n) +av_cold static int kbd_window_init(float *float_window, int *int_window, float alpha, int n) { int i; double sum = 0.0, tmp; double scale = 0.0; - double temp[FF_KBD_WINDOW_MAX / 2 + 1]; + double temp_small[FF_KBD_WINDOW_MAX / 2 + 1]; + double *temp= n<=FF_KBD_WINDOW_MAX ? temp_small : av_malloc((n/2+1) * sizeof(*temp)); double alpha2 = 4 * (alpha * M_PI / n) * (alpha * M_PI / n); - av_assert0(n <= FF_KBD_WINDOW_MAX); + if (!temp) + return AVERROR(ENOMEM); for (i = 0; i <= n / 2; i++) { - tmp = i * (n - i) * alpha2; + tmp = alpha2 * i * (n - i); temp[i] = av_bessel_i0(sqrt(tmp)); scale += temp[i] * (1 + (i && i