[FFmpeg-devel] [PATCH 3/3] lavc/cbrt_tablegen: unroll table generation loop

Ganesh Ajjanagadde gajjanagadde at gmail.com
Thu Dec 31 17:39:22 CET 2015


This patch does not seem to have measurable impact, at least on x86-64, though
there could be benefits for less than stellar branch predictors.

As such, the least useful of the series.

Tested with FATE.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 libavcodec/cbrt_tablegen.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h
index d3614d8..78a6b1f 100644
--- a/libavcodec/cbrt_tablegen.h
+++ b/libavcodec/cbrt_tablegen.h
@@ -45,11 +45,15 @@ static av_cold void AAC_RENAME(cbrt_tableinit)(void)
     if (!cbrt_tab[(1<<13) - 1].i) {
         cbrt_tab[0].f = 0;
         int i;
-        for (i = 0; i < 1<<13; i++) {
-            if (!(i & 7))
-                cbrt_tab[i].f = 16 * cbrt_tab[i>>3].f;
-            else
-                cbrt_tab[i].f = i * cbrt(i);
+        for (i = 0; i < 1<<13; i+=8) {
+            cbrt_tab[i].f = 16 * cbrt_tab[i>>3].f;
+            cbrt_tab[i+1].f = (i+1) * cbrt(i+1);
+            cbrt_tab[i+2].f = (i+2) * cbrt(i+2);
+            cbrt_tab[i+3].f = (i+3) * cbrt(i+3);
+            cbrt_tab[i+4].f = (i+4) * cbrt(i+4);
+            cbrt_tab[i+5].f = (i+5) * cbrt(i+5);
+            cbrt_tab[i+6].f = (i+6) * cbrt(i+6);
+            cbrt_tab[i+7].f = (i+7) * cbrt(i+7);
         }
 #if USE_FIXED
         for (i = 0; i < 1<<13; i++) {
-- 
2.6.4



More information about the ffmpeg-devel mailing list