[FFmpeg-cvslog] lavc/dsd_tablegen: speed up table generation

Ganesh Ajjanagadde git at videolan.org
Wed Dec 30 17:47:48 CET 2015


ffmpeg | branch: master | Ganesh Ajjanagadde <gajjanagadde at gmail.com> | Tue Dec 29 08:18:44 2015 -0800| [b272c3a5aabeafb37d5aeecc4524e8a8aeecf9da] | committer: Ganesh Ajjanagadde

lavc/dsd_tablegen: speed up table generation

Tables are bit identical.
Sample benchmark (Haswell, GNU/Linux+gcc):
old:
 814485 decicycles in dsd_ctables_tableinit,     512 runs,      0 skips

new:
 356808 decicycles in dsd_ctable_tableinit,     512 runs,      0 skips

Binary size should essentially be identical, and is in fact identical on
the configuration I tested on.

Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b272c3a5aabeafb37d5aeecc4524e8a8aeecf9da
---

 libavcodec/dsd_tablegen.h |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/libavcodec/dsd_tablegen.h b/libavcodec/dsd_tablegen.h
index 6afb416..d4ef302 100644
--- a/libavcodec/dsd_tablegen.h
+++ b/libavcodec/dsd_tablegen.h
@@ -78,16 +78,17 @@ static float ctables[CTABLES][256];
 
 static av_cold void dsd_ctables_tableinit(void)
 {
-    int t, e, m, k;
-    double acc;
-    for (t = 0; t < CTABLES; ++t) {
-        k = FFMIN(HTAPS - t * 8, 8);
-        for (e = 0; e < 256; ++e) {
-            acc = 0.0;
-            for (m = 0; m < k; ++m)
-                acc += (((e >> (7 - m)) & 1) * 2 - 1) * htaps[t * 8 + m];
-            ctables[CTABLES - 1 - t][e] = (float)acc;
+    int t, e, m, sign;
+    double acc[CTABLES];
+    for (e = 0; e < 256; ++e) {
+        memset(acc, 0, sizeof(acc));
+        for (m = 0; m < 8; ++m) {
+            sign = (((e >> (7 - m)) & 1) * 2 - 1);
+            for (t = 0; t < CTABLES; ++t)
+                acc[t] += sign * htaps[t * 8 + m];
         }
+        for (t = 0; t < CTABLES; ++t)
+            ctables[CTABLES - 1 - t][e] = acc[t];
     }
 }
 #endif /* CONFIG_HARDCODED_TABLES */



More information about the ffmpeg-cvslog mailing list