On Sun, Mar 13, 2016 at 05:53:10PM +0100, Reimar Döffinger wrote: > On Sun, Mar 13, 2016 at 05:50:17PM +0100, Hendrik Leppkes wrote: > > On Sun, Mar 13, 2016 at 5:24 PM, Ganesh Ajjanagadde <gajja...@gmail.com> > > wrote: > > >> @@ -75,9 +66,8 @@ static av_cold void AAC_RENAME(cbrt_tableinit)(void) > > >> } > > >> > > >> for (i = 0; i < 1<<13; i++) > > >> - cbrt_tab[i] = CBRT(cbrt_tab_dbl[i]); > > >> + AAC_RENAME(ff_cbrt_tab)[i] = CBRT(cbrt_tab_dbl[i]); > > >> } > > >> } > > > > > > Note that cbrt_tab_dbl is really intended to be shared by both the > > > fixed/floating table inits. This was another thing my patch achieved: > > > only doing the more expensive double table init once across > > > float/fixed, and then doing the cheap conversion to uint32_t via > > > av_float2int or lrint(x*8192). Please change; it could go into a > > > separate patch if you prefer. > > > > > > > Having both float and fixed decoders used at the same time seems like > > a rather unlikely use-case, so if such an optimization takes rather > > high complexity, its probably not worth going, IMHO. > > Nah, it should be done separately because it needs some > code reshuffling that easily gets confusing, but I don't > think it will be hard.
Wasn't (though I haven't tested properly), see attached, still don't think it is a good idea though.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6bb1af1..ec46d22 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -140,7 +140,7 @@ OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float sbrdsp.o aacpsdsp_float.o cbrt_data.o OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \ aacadtsdec.o mpeg4audio.o kbdwin.o \ - sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o + sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \ aacpsy.o aactab.o \ aacenc_is.o \ @@ -1017,8 +1017,7 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) $(M)./$< > $@ ifdef CONFIG_HARDCODED_TABLES -$(SUBDIR)cbrt_data.o: $(SUBDIR)cbrt_tables.h -$(SUBDIR)cbrt_data_fixed.o: $(SUBDIR)cbrt_fixed_tables.h +$(SUBDIR)cbrt_data.o: $(SUBDIR)cbrt_tables.h $(SUBDIR)cbrt_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 diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 883ed52..8554149 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1103,8 +1103,7 @@ static av_cold void aac_static_table_init(void) AAC_RENAME(ff_init_ff_sine_windows)(10); AAC_RENAME(ff_init_ff_sine_windows)( 9); AAC_RENAME(ff_init_ff_sine_windows)( 7); - - AAC_RENAME(ff_cbrt_tableinit)(); + ff_cbrt_tableinit(); } static AVOnce aac_table_init = AV_ONCE_INIT; diff --git a/libavcodec/cbrt_data.c b/libavcodec/cbrt_data.c index f5d9778..962fc65 100644 --- a/libavcodec/cbrt_data.c +++ b/libavcodec/cbrt_data.c @@ -22,7 +22,12 @@ #include "cbrt_data.h" #if CONFIG_HARDCODED_TABLES +#if CONFIG_AAC_DECODER || CONFIG_AAC_ENCODER #include "libavcodec/cbrt_tables.h" +#endif +#if CONFIG_AAC_FIXED_DECODER +#include "libavcodec/cbrt_fixed_tables.h" +#endif #else #include "cbrt_tablegen.h" #endif diff --git a/libavcodec/cbrt_data.h b/libavcodec/cbrt_data.h index 232f74f..a3da456 100644 --- a/libavcodec/cbrt_data.h +++ b/libavcodec/cbrt_data.h @@ -24,13 +24,11 @@ #include <stdint.h> #if CONFIG_HARDCODED_TABLES -#define ff_cbrt_tableinit_fixed() #define ff_cbrt_tableinit() extern const uint32_t ff_cbrt_tab[1 << 13]; extern const uint32_t ff_cbrt_tab_fixed[1 << 13]; #else void ff_cbrt_tableinit(void); -void ff_cbrt_tableinit_fixed(void); extern uint32_t ff_cbrt_tab[1 << 13]; extern uint32_t ff_cbrt_tab_fixed[1 << 13]; #endif diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h index 9af18d8..328c851 100644 --- a/libavcodec/cbrt_tablegen.h +++ b/libavcodec/cbrt_tablegen.h @@ -27,20 +27,22 @@ #include <math.h> #include "libavutil/attributes.h" #include "libavutil/intfloat.h" -#include "libavcodec/aac_defines.h" -#if USE_FIXED -#define CBRT(x) lrint((x) * 8192) -#else -#define CBRT(x) av_float2int((float)(x)) +#if CONFIG_AAC_DECODER || CONFIG_AAC_ENCODER +uint32_t ff_cbrt_tab[1 << 13]; +#endif +#if CONFIG_AAC_FIXED_DECODER +uint32_t ff_cbrt_tab_fixed[1 << 13]; #endif -uint32_t AAC_RENAME(ff_cbrt_tab)[1 << 13]; - -av_cold void AAC_RENAME(ff_cbrt_tableinit)(void) +av_cold void ff_cbrt_tableinit(void) { static double cbrt_tab_dbl[1 << 13]; - if (!AAC_RENAME(ff_cbrt_tab)[(1<<13) - 1]) { +#if CONFIG_AAC_FIXED_DECODER + if (!ff_cbrt_tab_fixed[(1<<13) - 1]) { +#else + if (!ff_cbrt_tab[(1<<13) - 1]) { +#endif int i, j, k; double cbrt_val; @@ -65,8 +67,14 @@ av_cold void AAC_RENAME(ff_cbrt_tableinit)(void) } } - for (i = 0; i < 1<<13; i++) - AAC_RENAME(ff_cbrt_tab)[i] = CBRT(cbrt_tab_dbl[i]); + for (i = 0; i < 1<<13; i++) { +#if CONFIG_AAC_DECODER || CONFIG_AAC_ENCODER + ff_cbrt_tab[i] = av_float2int((float)cbrt_tab_dbl[i]); +#endif +#if CONFIG_AAC_FIXED_DECODER + ff_cbrt_tab_fixed[i] = lrint(cbrt_tab_dbl[i] * 8192); +#endif + } } } diff --git a/libavcodec/cbrt_tablegen_template.c b/libavcodec/cbrt_tablegen_template.c index 21ed2a6..6800890 100644 --- a/libavcodec/cbrt_tablegen_template.c +++ b/libavcodec/cbrt_tablegen_template.c @@ -22,13 +22,16 @@ #include <stdlib.h> #define CONFIG_HARDCODED_TABLES 0 +#define CONFIG_AAC_DECODER 1 +#define CONFIG_AAC_FIXED_DECODER 1 +#define CONFIG_AAC_ENCODER 1 #include "libavutil/tablegen.h" #include "cbrt_tablegen.h" #include "tableprint.h" int main(void) { - AAC_RENAME(ff_cbrt_tableinit)(); + ff_cbrt_tableinit(); write_fileheader();
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel