[FFmpeg-cvslog] idctdsp: Add global function pointers for {add|put}_pixels_clamped functions

Diego Biurrun git at videolan.org
Wed Sep 3 03:32:26 CEST 2014


ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Sun Aug 31 11:45:15 2014 -0700| [95c0cec03acec0a80cc1c7db48f3b2355d9e767b] | committer: Diego Biurrun

idctdsp: Add global function pointers for {add|put}_pixels_clamped functions

These function pointers already existed in the ARM code. Adding them globally
allows calls to the function pointers to access arch-optimized versions of the
functions transparently.

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

 libavcodec/arm/idctdsp_init_arm.c |    7 -------
 libavcodec/dct.h                  |    2 ++
 libavcodec/idctdsp.c              |   22 ++++++++--------------
 libavcodec/idctdsp.h              |    3 +++
 libavcodec/jrevdct.c              |   14 ++++++++++++++
 libavcodec/x86/simple_idct.c      |    7 +++++--
 6 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/libavcodec/arm/idctdsp_init_arm.c b/libavcodec/arm/idctdsp_init_arm.c
index 0b32df0..8207c31 100644
--- a/libavcodec/arm/idctdsp_init_arm.c
+++ b/libavcodec/arm/idctdsp_init_arm.c
@@ -29,10 +29,6 @@
 #include "idct.h"
 #include "idctdsp_arm.h"
 
-/* XXX: local hack */
-static void (*ff_put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
-static void (*ff_add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
-
 void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest,
                                int line_size);
 
@@ -67,9 +63,6 @@ av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
 {
     int cpu_flags = av_get_cpu_flags();
 
-    ff_put_pixels_clamped = c->put_pixels_clamped;
-    ff_add_pixels_clamped = c->add_pixels_clamped;
-
     if (!high_bit_depth) {
         if (avctx->idct_algo == FF_IDCT_AUTO ||
             avctx->idct_algo == FF_IDCT_ARM) {
diff --git a/libavcodec/dct.h b/libavcodec/dct.h
index 3fd4e27..4a31f54 100644
--- a/libavcodec/dct.h
+++ b/libavcodec/dct.h
@@ -59,5 +59,7 @@ void ff_fdct248_islow_8(int16_t *data);
 void ff_fdct248_islow_10(int16_t *data);
 
 void ff_j_rev_dct(int16_t *data);
+void ff_jref_idct_put(uint8_t *dest, int line_size, int16_t *block);
+void ff_jref_idct_add(uint8_t *dest, int line_size, int16_t *block);
 
 #endif /* AVCODEC_DCT_H */
diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c
index 6beb2b2..2a979bc 100644
--- a/libavcodec/idctdsp.c
+++ b/libavcodec/idctdsp.c
@@ -79,6 +79,9 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
     }
 }
 
+void (*ff_put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
+void (*ff_add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
+
 static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
                                  int line_size)
 {
@@ -141,18 +144,6 @@ static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
     }
 }
 
-static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
-{
-    ff_j_rev_dct(block);
-    put_pixels_clamped_c(block, dest, line_size);
-}
-
-static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
-{
-    ff_j_rev_dct(block);
-    add_pixels_clamped_c(block, dest, line_size);
-}
-
 av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
 {
     const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
@@ -163,8 +154,8 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
         c->idct      = ff_simple_idct_10;
         c->perm_type = FF_IDCT_PERM_NONE;
     } else if (avctx->idct_algo == FF_IDCT_INT) {
-        c->idct_put  = jref_idct_put;
-        c->idct_add  = jref_idct_add;
+        c->idct_put  = ff_jref_idct_put;
+        c->idct_add  = ff_jref_idct_add;
         c->idct      = ff_j_rev_dct;
         c->perm_type = FF_IDCT_PERM_LIBMPEG2;
     } else if (avctx->idct_algo == FF_IDCT_FAAN) {
@@ -183,6 +174,9 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
     c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
     c->add_pixels_clamped        = add_pixels_clamped_c;
 
+    ff_put_pixels_clamped = c->put_pixels_clamped;
+    ff_add_pixels_clamped = c->add_pixels_clamped;
+
     if (ARCH_ARM)
         ff_idctdsp_init_arm(c, avctx, high_bit_depth);
     if (ARCH_PPC)
diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h
index b88cc82..c49a4ca 100644
--- a/libavcodec/idctdsp.h
+++ b/libavcodec/idctdsp.h
@@ -95,6 +95,9 @@ typedef struct IDCTDSPContext {
     enum idct_permutation_type perm_type;
 } IDCTDSPContext;
 
+extern void (*ff_put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
+extern void (*ff_add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
+
 void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx);
 
 void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
diff --git a/libavcodec/jrevdct.c b/libavcodec/jrevdct.c
index e6846a1..8261269 100644
--- a/libavcodec/jrevdct.c
+++ b/libavcodec/jrevdct.c
@@ -63,7 +63,9 @@
  */
 
 #include "libavutil/common.h"
+
 #include "dct.h"
+#include "idctdsp.h"
 
 #define EIGHT_BIT_SAMPLES
 
@@ -940,3 +942,15 @@ void ff_j_rev_dct(DCTBLOCK data)
     dataptr++;                  /* advance pointer to next column */
   }
 }
+
+void ff_jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
+{
+    ff_j_rev_dct(block);
+    ff_put_pixels_clamped(block, dest, line_size);
+}
+
+void ff_jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
+{
+    ff_j_rev_dct(block);
+    ff_add_pixels_clamped(block, dest, line_size);
+}
diff --git a/libavcodec/x86/simple_idct.c b/libavcodec/x86/simple_idct.c
index 1002a78..71763db 100644
--- a/libavcodec/x86/simple_idct.c
+++ b/libavcodec/x86/simple_idct.c
@@ -23,6 +23,9 @@
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
+
+#include "libavcodec/idctdsp.h"
+
 #include "idctdsp.h"
 #include "simple_idct.h"
 
@@ -1159,12 +1162,12 @@ void ff_simple_idct_mmx(int16_t *block)
 void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block)
 {
     idct(block);
-    ff_put_pixels_clamped_mmx(block, dest, line_size);
+    ff_put_pixels_clamped(block, dest, line_size);
 }
 void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block)
 {
     idct(block);
-    ff_add_pixels_clamped_mmx(block, dest, line_size);
+    ff_add_pixels_clamped(block, dest, line_size);
 }
 
 #endif /* HAVE_INLINE_ASM */



More information about the ffmpeg-cvslog mailing list