On systems having cbrt, there is no reason to use the slow pow function. Sample benchmark (x86-64, Haswell, GNU/Linux): new: 5124920 decicycles in cbrt_tableinit, 1 runs, 0 skips
old: 12321680 decicycles in cbrt_tableinit, 1 runs, 0 skips Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> ------------------------------------------------------------------------------- What I wonder about is why --enable-hardcoded-tables is not the default for FFmpeg. Unless I am missing something, static storage is anyway allocated even if hardcoded tables are not used, and the cost is deferred to runtime instead of build time. Thus binary size should not be affected, but users burn cycles unnecessarily for every codec having these kinds of tables. I have these patches, simply because at the moment users are paying a price for the typical default. --- libavcodec/cbrt_tablegen.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h index 27a3e3a..48d56b3 100644 --- a/libavcodec/cbrt_tablegen.h +++ b/libavcodec/cbrt_tablegen.h @@ -26,10 +26,11 @@ #include <stdint.h> #include <math.h> #include "libavutil/attributes.h" +#include "libavutil/libm.h" #include "libavcodec/aac_defines.h" #if USE_FIXED -#define CBRT(x) (int)floor((x).f * 8192 + 0.5) +#define CBRT(x) lrint((x).f * 8192) #else #define CBRT(x) x.i #endif @@ -49,13 +50,12 @@ static av_cold void AAC_RENAME(cbrt_tableinit)(void) { if (!cbrt_tab[(1<<13) - 1]) { int i; - /* cbrtf() isn't available on all systems, so we use powf(). */ for (i = 0; i < 1<<13; i++) { union { float f; uint32_t i; } f; - f.f = pow(i, 1.0 / 3.0) * i; + f.f = cbrt(i) * i; cbrt_tab[i] = CBRT(f); } } -- 2.6.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel