[FFmpeg-cvslog] hevcdsp_template: Templatize IDCT

Mickaël Raulet git at videolan.org
Tue Jan 31 17:05:22 EET 2017


ffmpeg | branch: master | Mickaël Raulet <mraulet at insa-rennes.fr> | Mon Jul  4 15:31:16 2016 +0200| [4f247de3b797cdc9d243d26534412f81c306e5b5] | committer: Luca Barbato

hevcdsp_template: Templatize IDCT

Integrated to Libav by Josh de Kock <josh at itanimul.li>.

Signed-off-by: Alexandra Hájková <alexandra at khirnov.net>

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

 libavcodec/hevcdsp_template.c | 108 ++++++++++++------------------------------
 1 file changed, 30 insertions(+), 78 deletions(-)

diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index b4816db..2cde5a8 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -154,26 +154,6 @@ static void FUNC(transform_4x4_luma)(int16_t *coeffs)
         assign(dst[3 * dstep], e0 - o0);                                \
     } while (0)
 
-static void FUNC(idct_4x4)(int16_t *coeffs)
-{
-    int i;
-    int shift    = 7;
-    int add      = 1 << (shift - 1);
-    int16_t *src = coeffs;
-
-    for (i = 0; i < 4; i++) {
-        TR_4(src, src, 4, 4, SCALE);
-        src++;
-    }
-
-    shift = 20 - BIT_DEPTH;
-    add   = 1 << (shift - 1);
-    for (i = 0; i < 4; i++) {
-        TR_4(coeffs, coeffs, 1, 1, SCALE);
-        coeffs += 4;
-    }
-}
-
 #define TR_8(dst, src, dstep, sstep, assign)                      \
     do {                                                          \
         int i, j;                                                 \
@@ -222,67 +202,39 @@ static void FUNC(idct_4x4)(int16_t *coeffs)
         }                                                         \
     } while (0)
 
-
-
-static void FUNC(idct_8x8)(int16_t *coeffs)
-{
-    int i;
-    int shift    = 7;
-    int add      = 1 << (shift - 1);
-    int16_t *src = coeffs;
-
-    for (i = 0; i < 8; i++) {
-        TR_8(src, src, 8, 8, SCALE);
-        src++;
-    }
-
-    shift = 20 - BIT_DEPTH;
-    add   = 1 << (shift - 1);
-    for (i = 0; i < 8; i++) {
-        TR_8(coeffs, coeffs, 1, 1, SCALE);
-        coeffs += 8;
-    }
-}
-
-static void FUNC(idct_16x16)(int16_t *coeffs)
-{
-    int i;
-    int shift    = 7;
-    int add      = 1 << (shift - 1);
-    int16_t *src = coeffs;
-
-    for (i = 0; i < 16; i++) {
-        TR_16(src, src, 16, 16, SCALE);
-        src++;
-    }
-
-    shift = 20 - BIT_DEPTH;
-    add   = 1 << (shift - 1);
-    for (i = 0; i < 16; i++) {
-        TR_16(coeffs, coeffs, 1, 1, SCALE);
-        coeffs += 16;
-    }
+#define IDCT(H)                                                   \
+static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs)          \
+{                                                                 \
+    int i;                                                        \
+    int      shift = 7;                                           \
+    int      add   = 1 << (shift - 1);                            \
+    int16_t *src   = coeffs;                                      \
+                                                                  \
+    for (i = 0; i < H; i++) {                                     \
+        TR_ ## H(src, src, H, H, SCALE);                          \
+        src++;                                                    \
+    }                                                             \
+                                                                  \
+    shift = 20 - BIT_DEPTH;                                       \
+    add   = 1 << (shift - 1);                                     \
+    for (i = 0; i < H; i++) {                                     \
+        TR_ ## H(coeffs, coeffs, 1, 1, SCALE);                    \
+        coeffs += H;                                              \
+    }                                                             \
 }
 
-static void FUNC(idct_32x32)(int16_t *coeffs)
-{
-    int i;
-    int shift    = 7;
-    int add      = 1 << (shift - 1);
-    int16_t *src = coeffs;
+IDCT( 4)
+IDCT( 8)
+IDCT(16)
+IDCT(32)
+#undef TR_4
+#undef TR_8
+#undef TR_16
+#undef TR_32
 
-    for (i = 0; i < 32; i++) {
-        TR_32(src, src, 32, 32, SCALE);
-        src++;
-    }
-    src   = coeffs;
-    shift = 20 - BIT_DEPTH;
-    add   = 1 << (shift - 1);
-    for (i = 0; i < 32; i++) {
-        TR_32(coeffs, coeffs, 1, 1, SCALE);
-        coeffs += 32;
-    }
-}
+#undef SET
+#undef SCALE
+#undef ADD_AND_SCALE
 
 static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
                                   ptrdiff_t stride, SAOParams *sao,



More information about the ffmpeg-cvslog mailing list