# HG changeset patch # User reimar # Date 1263043684 0 # Node ID 3d011a01a6a013db7f1973748d386ae5106f361c # Parent 59c35482189ed79377adbcb4888656c4cbb31a1b Add support for hard-coded MDCT-related ff_sine_windows tables. diff -r 59c35482189e -r 3d011a01a6a0 Makefile --- a/Makefile Sat Jan 09 07:57:26 2010 +0000 +++ b/Makefile Sat Jan 09 13:28:04 2010 +0000 @@ -697,6 +697,7 @@ ./$< > $@ ifdef CONFIG_HARDCODED_TABLES +$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h $(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h endif diff -r 59c35482189e -r 3d011a01a6a0 aac.c --- a/aac.c Sat Jan 09 07:57:26 2010 +0000 +++ b/aac.c Sat Jan 09 13:28:04 2010 +0000 @@ -552,8 +552,8 @@ // window initialization ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); - ff_sine_window_init(ff_sine_1024, 1024); - ff_sine_window_init(ff_sine_128, 128); + ff_init_ff_sine_windows(10); + ff_init_ff_sine_windows( 7); return 0; } diff -r 59c35482189e -r 3d011a01a6a0 aacenc.c --- a/aacenc.c Sat Jan 09 07:57:26 2010 +0000 +++ b/aacenc.c Sat Jan 09 13:28:04 2010 +0000 @@ -178,8 +178,8 @@ // window init ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); - ff_sine_window_init(ff_sine_1024, 1024); - ff_sine_window_init(ff_sine_128, 128); + ff_init_ff_sine_windows(10); + ff_init_ff_sine_windows(7); s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0])); s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]); diff -r 59c35482189e -r 3d011a01a6a0 atrac1.c --- a/atrac1.c Sat Jan 09 07:57:26 2010 +0000 +++ b/atrac1.c Sat Jan 09 13:28:04 2010 +0000 @@ -339,7 +339,7 @@ ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15)); ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)); - ff_sine_window_init(ff_sine_32, 32); + ff_init_ff_sine_windows(5); atrac_generate_tables(); diff -r 59c35482189e -r 3d011a01a6a0 dsputil.h --- a/dsputil.h Sat Jan 09 07:57:26 2010 +0000 +++ b/dsputil.h Sat Jan 09 13:28:04 2010 +0000 @@ -741,15 +741,19 @@ #if CONFIG_HARDCODED_TABLES #define COSTABLE_CONST const #define SINTABLE_CONST const +#define SINETABLE_CONST const #else #define COSTABLE_CONST #define SINTABLE_CONST +#define SINETABLE_CONST #endif #define COSTABLE(size) \ COSTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]) #define SINTABLE(size) \ SINTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_sin_##size[size/2]) +#define SINETABLE(size) \ + SINETABLE_CONST DECLARE_ALIGNED_16(float, ff_sine_##size[size]) extern COSTABLE(16); extern COSTABLE(32); extern COSTABLE(64); @@ -846,15 +850,19 @@ * @param n size of half window */ void ff_sine_window_init(float *window, int n); -extern float ff_sine_32 [ 32]; -extern float ff_sine_64 [ 64]; -extern float ff_sine_128 [ 128]; -extern float ff_sine_256 [ 256]; -extern float ff_sine_512 [ 512]; -extern float ff_sine_1024[1024]; -extern float ff_sine_2048[2048]; -extern float ff_sine_4096[4096]; -extern float * const ff_sine_windows[13]; +/** + * initialize the specified entry of ff_sine_windows + */ +void ff_init_ff_sine_windows(int index); +extern SINETABLE( 32); +extern SINETABLE( 64); +extern SINETABLE( 128); +extern SINETABLE( 256); +extern SINETABLE( 512); +extern SINETABLE(1024); +extern SINETABLE(2048); +extern SINETABLE(4096); +extern SINETABLE_CONST float * const ff_sine_windows[13]; int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); diff -r 59c35482189e -r 3d011a01a6a0 mdct.c --- a/mdct.c Sat Jan 09 07:57:26 2010 +0000 +++ b/mdct.c Sat Jan 09 13:28:04 2010 +0000 @@ -48,26 +48,7 @@ window[i] = sqrt(local_window[i] / sum); } -DECLARE_ALIGNED(16, float, ff_sine_32 [ 32]); -DECLARE_ALIGNED(16, float, ff_sine_64 [ 64]); -DECLARE_ALIGNED(16, float, ff_sine_128 [ 128]); -DECLARE_ALIGNED(16, float, ff_sine_256 [ 256]); -DECLARE_ALIGNED(16, float, ff_sine_512 [ 512]); -DECLARE_ALIGNED(16, float, ff_sine_1024[1024]); -DECLARE_ALIGNED(16, float, ff_sine_2048[2048]); -DECLARE_ALIGNED(16, float, ff_sine_4096[4096]); -float * const ff_sine_windows[] = { - NULL, NULL, NULL, NULL, NULL, // unused - ff_sine_32 , ff_sine_64 , - ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096 -}; - -// Generate a sine window. -av_cold void ff_sine_window_init(float *window, int n) { - int i; - for(i = 0; i < n; i++) - window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); -} +#include "mdct_tablegen.h" /** * init MDCT or IMDCT computation. diff -r 59c35482189e -r 3d011a01a6a0 mdct_tablegen.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdct_tablegen.c Sat Jan 09 13:28:04 2010 +0000 @@ -0,0 +1,61 @@ +/* + * Generate a header file for hardcoded MDCT tables + * + * 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 +#define CONFIG_HARDCODED_TABLES 0 +#define av_cold +#define SINETABLE_CONST +#define SINETABLE(size) \ + float ff_sine_##size[size] +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +#include "mdct_tablegen.h" +#include "tableprint.h" + +void tableinit(void) +{ + int i; + for (i = 5; i <= 12; i++) + ff_init_ff_sine_windows(i); +} + +#define SINE_TABLE_DEF(size) \ + { \ + "SINETABLE("#size")", \ + write_float_array, \ + ff_sine_##size, \ + size \ + }, + +const struct tabledef tables[] = { + SINE_TABLE_DEF( 32) + SINE_TABLE_DEF( 64) + SINE_TABLE_DEF( 128) + SINE_TABLE_DEF( 256) + SINE_TABLE_DEF( 512) + SINE_TABLE_DEF(1024) + SINE_TABLE_DEF(2048) + SINE_TABLE_DEF(4096) + { NULL } +}; diff -r 59c35482189e -r 3d011a01a6a0 mdct_tablegen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdct_tablegen.h Sat Jan 09 13:28:04 2010 +0000 @@ -0,0 +1,59 @@ +/* + * Header file for hardcoded MDCT tables + * + * 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 +// do not use libavutil/mathematics.h since this is compiled both +// for the host and the target and config.h is only valid for the target +#include + +#if !CONFIG_HARDCODED_TABLES +SINETABLE( 32); +SINETABLE( 64); +SINETABLE( 128); +SINETABLE( 256); +SINETABLE( 512); +SINETABLE(1024); +SINETABLE(2048); +SINETABLE(4096); +#else +#include "mdct_tables.h" +#endif + +SINETABLE_CONST float * const ff_sine_windows[] = { + NULL, NULL, NULL, NULL, NULL, // unused + ff_sine_32 , ff_sine_64 , + ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096 +}; + +// Generate a sine window. +av_cold void ff_sine_window_init(float *window, int n) { + int i; + for(i = 0; i < n; i++) + window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); +} + +av_cold void ff_init_ff_sine_windows(int index) { + assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); +#if !CONFIG_HARDCODED_TABLES + ff_sine_window_init(ff_sine_windows[index], 1 << index); +#endif +} diff -r 59c35482189e -r 3d011a01a6a0 nellymoserdec.c --- a/nellymoserdec.c Sat Jan 09 07:57:26 2010 +0000 +++ b/nellymoserdec.c Sat Jan 09 13:28:04 2010 +0000 @@ -144,7 +144,7 @@ /* Generate overlap window */ if (!ff_sine_128[127]) - ff_sine_window_init(ff_sine_128, 128); + ff_init_ff_sine_windows(7); avctx->sample_fmt = SAMPLE_FMT_S16; avctx->channel_layout = CH_LAYOUT_MONO; diff -r 59c35482189e -r 3d011a01a6a0 tableprint.c --- a/tableprint.c Sat Jan 09 07:57:26 2010 +0000 +++ b/tableprint.c Sat Jan 09 13:28:04 2010 +0000 @@ -39,6 +39,7 @@ WRITE_1D_FUNC(int8, int8_t, "%3"PRIi8, 15) WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7) +WRITE_1D_FUNC(float, float, "%.18e", 3) #define WRITE_2D_FUNC(name, type)\ void write_##name##_2d_array(const void *arg, int len, int len2)\ diff -r 59c35482189e -r 3d011a01a6a0 tableprint.h --- a/tableprint.h Sat Jan 09 07:57:26 2010 +0000 +++ b/tableprint.h Sat Jan 09 13:28:04 2010 +0000 @@ -32,6 +32,7 @@ */ void write_int8_array (const void *, int, int); void write_uint32_array (const void *, int, int); +void write_float_array (const void *, int, int); void write_int8_2d_array (const void *, int, int); void write_uint32_2d_array(const void *, int, int); /** \} */ // end of printfuncs group diff -r 59c35482189e -r 3d011a01a6a0 twinvq.c --- a/twinvq.c Sat Jan 09 07:57:26 2010 +0000 +++ b/twinvq.c Sat Jan 09 13:28:04 2010 +0000 @@ -893,9 +893,9 @@ } - ff_sine_window_init(ff_sine_windows[av_log2(size_m) ], size_m ); - ff_sine_window_init(ff_sine_windows[av_log2(size_s/2) ], size_s/2); - ff_sine_window_init(ff_sine_windows[av_log2(mtab->size)], mtab->size); + ff_init_ff_sine_windows(av_log2(size_m)); + ff_init_ff_sine_windows(av_log2(size_s/2)); + ff_init_ff_sine_windows(av_log2(mtab->size)); } /** diff -r 59c35482189e -r 3d011a01a6a0 wma.c --- a/wma.c Sat Jan 09 07:57:26 2010 +0000 +++ b/wma.c Sat Jan 09 13:28:04 2010 +0000 @@ -343,9 +343,7 @@ /* init MDCT windows : simple sinus window */ for (i = 0; i < s->nb_block_sizes; i++) { - int n; - n = 1 << (s->frame_len_bits - i); - ff_sine_window_init(ff_sine_windows[s->frame_len_bits - i], n); + ff_init_ff_sine_windows(s->frame_len_bits - i); s->windows[i] = ff_sine_windows[s->frame_len_bits - i]; } diff -r 59c35482189e -r 3d011a01a6a0 wmaprodec.c --- a/wmaprodec.c Sat Jan 09 07:57:26 2010 +0000 +++ b/wmaprodec.c Sat Jan 09 13:28:04 2010 +0000 @@ -425,9 +425,8 @@ /** init MDCT windows: simple sinus window */ for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) { - const int n = 1 << (WMAPRO_BLOCK_MAX_BITS - i); const int win_idx = WMAPRO_BLOCK_MAX_BITS - i; - ff_sine_window_init(ff_sine_windows[win_idx], n); + ff_init_ff_sine_windows(win_idx); s->windows[WMAPRO_BLOCK_SIZES - i - 1] = ff_sine_windows[win_idx]; }