[FFmpeg-devel] [PATCH] lavc/aacenc_quantization: use cbrt table

Ganesh Ajjanagadde gajjanag at gmail.com
Mon Mar 14 02:30:21 CET 2016


There is no reason for computing cbrtf at runtime; we have a table for
this.

Yields a negligible speedup.

Signed-off-by: Ganesh Ajjanagadde <gajjanag at gmail.com>
---
 libavcodec/aacenc.c              | 2 ++
 libavcodec/aacenc_quantization.h | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 023260a..11c9272 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -45,6 +45,7 @@
 #include "aacenc.h"
 #include "aacenctab.h"
 #include "aacenc_utils.h"
+#include "cbrt_data.h"
 
 #include "psymodel.h"
 
@@ -897,6 +898,7 @@ alloc_fail:
 static av_cold void aac_encode_init_tables(void)
 {
     ff_aac_tableinit();
+    ff_cbrt_tableinit();
 }
 
 static av_cold int aac_encode_init(AVCodecContext *avctx)
diff --git a/libavcodec/aacenc_quantization.h b/libavcodec/aacenc_quantization.h
index 4250407..29b3c97 100644
--- a/libavcodec/aacenc_quantization.h
+++ b/libavcodec/aacenc_quantization.h
@@ -32,6 +32,7 @@
 #include "aacenc.h"
 #include "aacenctab.h"
 #include "aacenc_utils.h"
+#include "cbrt_data.h"
 
 /**
  * Calculate rate distortion cost for quantizing with given codebook
@@ -105,7 +106,7 @@ static av_always_inline float quantize_and_encode_band_cost_template(
                         curbits += 21;
                     } else {
                         int c = av_clip_uintp2(quant(t, Q, ROUNDING), 13);
-                        quantized = c*cbrtf(c)*IQ;
+                        quantized = av_int2float(ff_cbrt_tab[c])*IQ;
                         curbits += av_log2(c)*2 - 4 + 1;
                     }
                 } else {
-- 
2.7.3



More information about the ffmpeg-devel mailing list