From patchwork Thu Jan 28 16:26:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 25237 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 1D03944BC03 for ; Thu, 28 Jan 2021 18:27:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01EFA68A753; Thu, 28 Jan 2021 18:27:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA16268A711 for ; Thu, 28 Jan 2021 18:27:33 +0200 (EET) Received: by mail-ej1-f51.google.com with SMTP id w1so8633173ejf.11 for ; Thu, 28 Jan 2021 08:27:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fIo/c8sFaniRpiQze2B7booumo98KwzYw/DQJGjMHHw=; b=PWwfsZ8f01jQYXh3ezBMsIAdbFr5hdp6NZ8Wpo1e3Bz3vwydRWxJj4Kc/vCKRPI0tL Imns9HMRWYoOMd9oacBYctnUIZNbl8eGKxX3H1qU+EoAIplndUveNBmGSxG1l7BKJfKd HbbLkZnVsYGAyT5lxnY/eJjL/Zo5nIcEUItIJUHcqXhyTiqVPJyBeft83xyMVXEuPLlW LjsCDxfAyKc/MAaMoiPD9mb+lDlZ3yKcYx6h6hwz7muzE5wE221M40XmbzOpYwsl0am+ imYuZ20LM1Q9eA+Trx7Sfkl3xLbw7OzMkfdtj5WZQkjxI99LvgUp3ldPgIgSEmbSae40 +yuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fIo/c8sFaniRpiQze2B7booumo98KwzYw/DQJGjMHHw=; b=evlJI5pi3XLQvcCwJ3Md0AK8vrGNaxkk5YhzcQWucREEZk8C6t8i+SBkEGQxAUEl6W eXICxB+Bq0/LTSydVKcds2l68RgRexWMJySIez8nRYbGpewBYtW0HLHNboCZ9fl16/xK /eY2NSx94aGoQCEIEhwcwtEE1qYB8TGIRdvIxfWupH2x5M2JBM7JkEsduWNY01ijm/+M 9sgzju4xdrTMTa9qApqAqFsHLVqWMxLBhb/nWXpnJZwyFuYFZITrucTdb54dB1NrZ86q AB2uQrWVXKKWjUYk1256D1jVWWHTG27M+b9ahiHNtq1I7F90jSnVGvkfiFl5guFbIH8G cucA== X-Gm-Message-State: AOAM533Fa5I5XnBS41ddKa3sR/5yyBdK7JzHEEG/TIwWTjJsTbBZ4o2s 5m34EhyjPNnxyUwSfqhZnzs/snxGMfo= X-Google-Smtp-Source: ABdhPJzk2X7qqGWKDLUCyUz6oWZqgv7SvLn5WSOPNvoSNjkECRJluQzLhCGV/U0MpbEQkFpnRv9ryg== X-Received: by 2002:a17:906:5fc6:: with SMTP id k6mr194082ejv.252.1611851252859; Thu, 28 Jan 2021 08:27:32 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id dj25sm3185288edb.5.2021.01.28.08.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 08:27:32 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Jan 2021 17:26:43 +0100 Message-Id: <20210128162646.2811269-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128162646.2811269-1-andreas.rheinhardt@gmail.com> References: <20210128162646.2811269-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] avcodec/aacdec_fixed: Move fixed-point sinewin tables to its only user 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The fixed-point AAC decoder is the only user of the fixed-point sinewin tables from sinewin; and it only uses a few of them (about 10% when counting by size). This means that guarding initializing these tables by an AVOnce (as done in 3719122065863f701026632f610175980d42b05a) is unnecessary for them. Furthermore the array of pointers to the individual arrays is also unneeded. Therefore this commit moves these tables directly into aacdec_fixed.c; this is done by ridding the original sinewin.h and sinewin_tablegen.h headers completely of any fixed-point code at the cost of a bit of duplicated code (the alternative is an ugly ifdef-mess). This saves about 58KB from the binary when using hardcoded tables (as these tables are hardcoded in this scenario); when not using hardcoded tables, most of these savings only affect the .bss segment, but the rest (< 1KB) contains relocations (i.e. savings in .data.rel.ro). Signed-off-by: Andreas Rheinhardt --- configure | 2 +- libavcodec/Makefile | 4 +- libavcodec/aacdec_fixed.c | 2 +- libavcodec/aacdec_template.c | 27 +++++------ libavcodec/sinewin.c | 1 - libavcodec/sinewin.h | 13 ++--- libavcodec/sinewin_fixed.c | 21 -------- libavcodec/sinewin_fixed_tablegen.c | 22 ++++++++- libavcodec/sinewin_fixed_tablegen.h | 67 ++++++++++++++++++++++++++ libavcodec/sinewin_tablegen.c | 25 +++++++++- libavcodec/sinewin_tablegen.h | 33 +++++-------- libavcodec/sinewin_tablegen_template.c | 55 --------------------- 12 files changed, 143 insertions(+), 129 deletions(-) delete mode 100644 libavcodec/sinewin_fixed.c create mode 100644 libavcodec/sinewin_fixed_tablegen.h delete mode 100644 libavcodec/sinewin_tablegen_template.c diff --git a/configure b/configure index df298b4b9b..4ab3c1ea76 100755 --- a/configure +++ b/configure @@ -2652,7 +2652,7 @@ rdft_select="fft" # decoders / encoders aac_decoder_select="adts_header mdct15 mdct sinewin" -aac_fixed_decoder_select="adts_header mdct sinewin" +aac_fixed_decoder_select="adts_header mdct" aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index e2cd18632f..49955fd02a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -141,7 +141,7 @@ OBJS-$(CONFIG_RANGECODER) += rangecoder.o OBJS-$(CONFIG_RDFT) += rdft.o OBJS-$(CONFIG_RV34DSP) += rv34dsp.o OBJS-$(CONFIG_SHARED) += log2_tab.o reverse.o -OBJS-$(CONFIG_SINEWIN) += sinewin.o sinewin_fixed.o +OBJS-$(CONFIG_SINEWIN) += sinewin.o OBJS-$(CONFIG_SNAPPY) += snappy.o OBJS-$(CONFIG_STARTCODE) += startcode.o OBJS-$(CONFIG_TEXTUREDSP) += texturedsp.o @@ -1279,6 +1279,7 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) ifdef CONFIG_HARDCODED_TABLES $(SUBDIR)cbrt_data.o: $(SUBDIR)cbrt_tables.h $(SUBDIR)cbrt_data_fixed.o: $(SUBDIR)cbrt_fixed_tables.h +$(SUBDIR)aacdec_fixed.o: $(SUBDIR)sinewin_fixed_tables.h $(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h $(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h $(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h @@ -1290,5 +1291,4 @@ $(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h $(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h -$(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h endif diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index e555dac362..c5d923a8b4 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -70,7 +70,7 @@ #include "fft.h" #include "lpc.h" #include "kbdwin.h" -#include "sinewin.h" +#include "sinewin_fixed_tablegen.h" #include "aac.h" #include "aactab.h" diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index ea39f547b0..e5d311141f 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1235,14 +1235,13 @@ static av_cold void aac_static_table_init(void) AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120); AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960); AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120); + AAC_RENAME(ff_init_ff_sine_windows)(9); ff_aac_float_common_init(); #else AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024); AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128); - AAC_RENAME(ff_init_ff_sine_windows)(10); - AAC_RENAME(ff_init_ff_sine_windows)( 7); + init_sine_windows_fixed(); #endif - AAC_RENAME(ff_init_ff_sine_windows)( 9); AAC_RENAME(ff_cbrt_tableinit)(); } @@ -2644,10 +2643,10 @@ static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns, static void windowing_and_mdct_ltp(AACContext *ac, INTFLOAT *out, INTFLOAT *in, IndividualChannelStream *ics) { - const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); - const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME(ff_sine_128); - const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); - const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128); if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024); @@ -2704,8 +2703,8 @@ static void update_ltp(AACContext *ac, SingleChannelElement *sce) IndividualChannelStream *ics = &sce->ics; INTFLOAT *saved = sce->saved; INTFLOAT *saved_ltp = sce->coeffs; - const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); - const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128); int i; if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { @@ -2743,9 +2742,9 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) INTFLOAT *in = sce->coeffs; INTFLOAT *out = sce->ret; INTFLOAT *saved = sce->saved; - const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME(ff_sine_128); - const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); - const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128); INTFLOAT *buf = ac->buf_mdct; INTFLOAT *temp = ac->temp; int i; @@ -2891,10 +2890,10 @@ static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) if (ics->use_kb_window[1]) { // AAC LD uses a low overlap sine window instead of a KBD window memcpy(out, saved, 192 * sizeof(*out)); - ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, AAC_RENAME(ff_sine_128), 64); + ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, AAC_RENAME2(sine_128), 64); memcpy( out + 320, buf + 64, 192 * sizeof(*out)); } else { - ac->fdsp->vector_fmul_window(out, saved, buf, AAC_RENAME(ff_sine_512), 256); + ac->fdsp->vector_fmul_window(out, saved, buf, AAC_RENAME2(sine_512), 256); } // buffer update diff --git a/libavcodec/sinewin.c b/libavcodec/sinewin.c index 4532dc7354..1fa0e953f0 100644 --- a/libavcodec/sinewin.c +++ b/libavcodec/sinewin.c @@ -16,6 +16,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define USE_FIXED 0 #include "sinewin.h" #include "sinewin_tablegen.h" diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h index e6de4dfe7b..fc4e69a58f 100644 --- a/libavcodec/sinewin.h +++ b/libavcodec/sinewin.h @@ -23,7 +23,6 @@ #include "config.h" #include "libavutil/mem_internal.h" -#include "libavcodec/aac_defines.h" #if CONFIG_HARDCODED_TABLES # define SINETABLE_CONST const @@ -31,24 +30,20 @@ # define SINETABLE_CONST #endif -#ifndef USE_FIXED -#define USE_FIXED 0 -#endif - #define SINETABLE(size) \ - SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size] + SINETABLE_CONST DECLARE_ALIGNED(32, float, ff_sine_##size)[size] /** * Generate a sine window. * @param window pointer to half window * @param n size of half window */ -void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n); +void ff_sine_window_init(float *window, int n); /** * initialize the specified entry of ff_sine_windows */ -void AAC_RENAME(ff_init_ff_sine_windows)(int index); +void ff_init_ff_sine_windows(int index); extern SINETABLE( 32); extern SINETABLE( 64); @@ -60,6 +55,6 @@ extern SINETABLE(2048); extern SINETABLE(4096); extern SINETABLE(8192); -extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[]; +extern SINETABLE_CONST float *const ff_sine_windows[]; #endif /* AVCODEC_SINEWIN_H */ diff --git a/libavcodec/sinewin_fixed.c b/libavcodec/sinewin_fixed.c deleted file mode 100644 index 27ead29e8e..0000000000 --- a/libavcodec/sinewin_fixed.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define USE_FIXED 1 -#include "sinewin.h" -#include "sinewin_tablegen.h" diff --git a/libavcodec/sinewin_fixed_tablegen.c b/libavcodec/sinewin_fixed_tablegen.c index 977e6f3cbf..61e5274afa 100644 --- a/libavcodec/sinewin_fixed_tablegen.c +++ b/libavcodec/sinewin_fixed_tablegen.c @@ -20,5 +20,23 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define USE_FIXED 1 -#include "sinewin_tablegen_template.c" +#include "tableprint.h" + +#define BUILD_TABLES +#define CONFIG_HARDCODED_TABLES 0 +#include "sinewin_fixed_tablegen.h" + +int main(void) +{ + write_fileheader(); + + init_sine_windows_fixed(); +#define PRINT_TABLE(size) \ + printf("SINETABLE("#size") = {\n"); \ + write_int32_t_array(sine_ ## size ## _fixed, size); \ + printf("};\n") + PRINT_TABLE(128); + PRINT_TABLE(512); + PRINT_TABLE(1024); + return 0; +} diff --git a/libavcodec/sinewin_fixed_tablegen.h b/libavcodec/sinewin_fixed_tablegen.h new file mode 100644 index 0000000000..c52c90bed7 --- /dev/null +++ b/libavcodec/sinewin_fixed_tablegen.h @@ -0,0 +1,67 @@ +/* + * Header file for hardcoded sine windows + * + * Copyright (c) 2009 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_SINEWIN_FIXED_TABLEGEN_H +#define AVCODEC_SINEWIN_FIXED_TABLEGEN_H + +#ifdef BUILD_TABLES +#undef DECLARE_ALIGNED +#define DECLARE_ALIGNED(align, type, name) type name +#else +#include "libavutil/mem_internal.h" +#endif + +#define SINETABLE(size) \ + static SINETABLE_CONST DECLARE_ALIGNED(32, int, sine_##size##_fixed)[size] + +#if CONFIG_HARDCODED_TABLES +#define init_sine_windows_fixed() +#define SINETABLE_CONST const +#include "libavcodec/sinewin_fixed_tables.h" +#else +// do not use libavutil/libm.h since this is compiled both +// for the host and the target and config.h is only valid for the target +#include +#include "libavutil/attributes.h" + +#define SINETABLE_CONST +SINETABLE( 128); +SINETABLE( 512); +SINETABLE(1024); + +#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5) + +// Generate a sine window. +static av_cold void sine_window_init_fixed(int *window, int n) +{ + for (int i = 0; i < n; i++) + window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n)))); +} + +static av_cold void init_sine_windows_fixed(void) +{ + sine_window_init_fixed(sine_128_fixed, 128); + sine_window_init_fixed(sine_512_fixed, 512); + sine_window_init_fixed(sine_1024_fixed, 1024); +} +#endif /* CONFIG_HARDCODED_TABLES */ +#endif /* AVCODEC_SINEWIN_FIXED_TABLEGEN_H */ diff --git a/libavcodec/sinewin_tablegen.c b/libavcodec/sinewin_tablegen.c index dd602668ee..438030ea83 100644 --- a/libavcodec/sinewin_tablegen.c +++ b/libavcodec/sinewin_tablegen.c @@ -20,5 +20,26 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define USE_FIXED 0 -#include "sinewin_tablegen_template.c" +#define CONFIG_HARDCODED_TABLES 0 +#define BUILD_TABLES + +#define SINETABLE_CONST +#define SINETABLE(size) \ + float ff_sine_##size[size] +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#include "sinewin_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + write_fileheader(); + + for (int i = 5; i <= 13; i++) { + ff_init_ff_sine_windows(i); + printf("SINETABLE(%4i) = {\n", 1 << i); + write_float_array(ff_sine_windows[i], 1 << i); + printf("};\n"); + } + + return 0; +} diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h index ced3b7874c..6887d59cfe 100644 --- a/libavcodec/sinewin_tablegen.h +++ b/libavcodec/sinewin_tablegen.h @@ -27,7 +27,6 @@ // do not use libavutil/libm.h since this is compiled both // for the host and the target and config.h is only valid for the target #include -#include "libavcodec/aac_defines.h" #include "libavutil/attributes.h" #include "libavutil/common.h" @@ -46,38 +45,29 @@ SINETABLE(2048); SINETABLE(4096); SINETABLE(8192); #else -#if USE_FIXED -#include "libavcodec/sinewin_fixed_tables.h" -#else #include "libavcodec/sinewin_tables.h" #endif -#endif - -#if USE_FIXED -#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5) -#else -#define SIN_FIX(a) a -#endif -SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = { +SINETABLE_CONST float *const ff_sine_windows[] = { NULL, NULL, NULL, NULL, NULL, // unused - AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128), - AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024), - AAC_RENAME(ff_sine_2048), AAC_RENAME(ff_sine_4096), AAC_RENAME(ff_sine_8192), + ff_sine_32, ff_sine_64, ff_sine_128, + ff_sine_256, ff_sine_512, ff_sine_1024, + ff_sine_2048, ff_sine_4096, ff_sine_8192, }; // Generate a sine window. -av_cold void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n) { +av_cold void ff_sine_window_init(float *window, int n) +{ int i; for(i = 0; i < n; i++) - window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n)))); + window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); } #if !CONFIG_HARDCODED_TABLES && !defined(BUILD_TABLES) #define INIT_FF_SINE_WINDOW_INIT_FUNC(index) \ static void init_ff_sine_window_ ## index(void) \ { \ - AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index);\ + ff_sine_window_init(ff_sine_windows[index], 1 << index);\ } INIT_FF_SINE_WINDOW_INIT_FUNC(5) @@ -108,11 +98,12 @@ static AVOnce init_sine_window_once[9] = { }; #endif -av_cold void AAC_RENAME(ff_init_ff_sine_windows)(int index) { - assert(index >= 5 && index < FF_ARRAY_ELEMS(AAC_RENAME(ff_sine_windows))); +av_cold void ff_init_ff_sine_windows(int index) +{ + assert(index >= 5 && index < FF_ARRAY_ELEMS(ff_sine_windows)); #if !CONFIG_HARDCODED_TABLES #ifdef BUILD_TABLES - AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index); + ff_sine_window_init(ff_sine_windows[index], 1 << index); #else ff_thread_once(&init_sine_window_once[index - 5], sine_window_init_func_array[index - 5]); #endif diff --git a/libavcodec/sinewin_tablegen_template.c b/libavcodec/sinewin_tablegen_template.c deleted file mode 100644 index 7c3c1d8af2..0000000000 --- a/libavcodec/sinewin_tablegen_template.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generate a header file for hardcoded sine windows - * - * Copyright (c) 2009 Reimar Döffinger - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "libavcodec/aac_defines.h" -#define CONFIG_HARDCODED_TABLES 0 -#define BUILD_TABLES - -#if USE_FIXED -#define WRITE_FUNC write_int32_t_array -#else -#define WRITE_FUNC write_float_array -#endif - -#define SINETABLE_CONST -#define SINETABLE(size) \ - INTFLOAT AAC_RENAME(ff_sine_##size)[size] -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) -#include "sinewin_tablegen.h" -#include "tableprint.h" - -int main(void) -{ - int i; - - write_fileheader(); - - for (i = 5; i <= 13; i++) { - AAC_RENAME(ff_init_ff_sine_windows)(i); - printf("SINETABLE(%4i) = {\n", 1 << i); - WRITE_FUNC(AAC_RENAME(ff_sine_windows)[i], 1 << i); - printf("};\n"); - } - - return 0; -}