aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-07-21 02:31:57 +0100
committerMans Rullgard <mans@mansr.com>2011-07-21 18:10:58 +0100
commit874f1a901d9f2d1d6825be309ed046abc7672b03 (patch)
tree7638258077e3888e35e86ed7f8242ae2e9cc77a4
parent5cc2600964c72dad995efb18c918a63e0965f8db (diff)
downloadffmpeg-874f1a901d9f2d1d6825be309ed046abc7672b03.tar.gz
dsputil: template get_pixels() for different bit depths
Signed-off-by: Mans Rullgard <mans@mansr.com>
-rw-r--r--libavcodec/alpha/dsputil_alpha.c3
-rw-r--r--libavcodec/arm/dsputil_init_armv6.c3
-rw-r--r--libavcodec/bfin/dsputil_bfin.c2
-rw-r--r--libavcodec/dsputil.c21
-rw-r--r--libavcodec/dsputil_template.c23
-rw-r--r--libavcodec/mlib/dsputil_mlib.c3
-rw-r--r--libavcodec/ppc/dsputil_altivec.c5
-rw-r--r--libavcodec/ps2/dsputil_mmi.c2
-rw-r--r--libavcodec/x86/dsputilenc_mmx.c7
9 files changed, 39 insertions, 30 deletions
diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c
index 039608b9ed..3efcf096b4 100644
--- a/libavcodec/alpha/dsputil_alpha.c
+++ b/libavcodec/alpha/dsputil_alpha.c
@@ -321,7 +321,8 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
c->put_pixels_clamped = put_pixels_clamped_mvi_asm;
c->add_pixels_clamped = add_pixels_clamped_mvi_asm;
- c->get_pixels = get_pixels_mvi;
+ if (!high_bit_depth)
+ c->get_pixels = get_pixels_mvi;
c->diff_pixels = diff_pixels_mvi;
c->sad[0] = pix_abs16x16_mvi_asm;
c->sad[1] = pix_abs8x8_mvi;
diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c
index d442415aec..07124c2773 100644
--- a/libavcodec/arm/dsputil_init_armv6.c
+++ b/libavcodec/arm/dsputil_init_armv6.c
@@ -106,8 +106,9 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6;
}
+ if (!high_bit_depth)
+ c->get_pixels = ff_get_pixels_armv6;
c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
- c->get_pixels = ff_get_pixels_armv6;
c->diff_pixels = ff_diff_pixels_armv6;
c->pix_abs[0][0] = ff_pix_abs16_armv6;
diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c
index 691c060733..f88ae66b15 100644
--- a/libavcodec/bfin/dsputil_bfin.c
+++ b/libavcodec/bfin/dsputil_bfin.c
@@ -199,12 +199,12 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
{
const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
- c->get_pixels = ff_bfin_get_pixels;
c->diff_pixels = ff_bfin_diff_pixels;
c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
if (!high_bit_depth)
+ c->get_pixels = ff_bfin_get_pixels;
c->clear_blocks = bfin_clear_blocks;
c->pix_sum = ff_bfin_pix_sum;
c->pix_norm1 = ff_bfin_pix_norm1;
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index b18164065d..09e58f46d2 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -307,25 +307,6 @@ static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
return s;
}
-static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
-{
- int i;
-
- /* read the pixels */
- for(i=0;i<8;i++) {
- block[0] = pixels[0];
- block[1] = pixels[1];
- block[2] = pixels[2];
- block[3] = pixels[3];
- block[4] = pixels[4];
- block[5] = pixels[5];
- block[6] = pixels[6];
- block[7] = pixels[7];
- pixels += line_size;
- block += 8;
- }
-}
-
static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1,
const uint8_t *s2, int stride){
int i;
@@ -2927,7 +2908,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
}
}
- c->get_pixels = get_pixels_c;
c->diff_pixels = diff_pixels_c;
c->put_pixels_clamped = ff_put_pixels_clamped_c;
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c;
@@ -3160,6 +3140,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
#define BIT_DEPTH_FUNCS(depth, dct)\
+ c->get_pixels = FUNCC(get_pixels ## dct , depth);\
c->draw_edges = FUNCC(draw_edges , depth);\
c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\
c->clear_block = FUNCC(clear_block ## dct , depth);\
diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c
index 5863275c00..72ed6bfd2a 100644
--- a/libavcodec/dsputil_template.c
+++ b/libavcodec/dsputil_template.c
@@ -193,6 +193,29 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, i
}
#define DCTELEM_FUNCS(dctcoef, suffix) \
+static void FUNCC(get_pixels ## suffix)(DCTELEM *restrict _block, \
+ const uint8_t *_pixels, \
+ int line_size) \
+{ \
+ const pixel *pixels = (const pixel *) _pixels; \
+ dctcoef *restrict block = (dctcoef *) _block; \
+ int i; \
+ \
+ /* read the pixels */ \
+ for(i=0;i<8;i++) { \
+ block[0] = pixels[0]; \
+ block[1] = pixels[1]; \
+ block[2] = pixels[2]; \
+ block[3] = pixels[3]; \
+ block[4] = pixels[4]; \
+ block[5] = pixels[5]; \
+ block[6] = pixels[6]; \
+ block[7] = pixels[7]; \
+ pixels += line_size / sizeof(pixel); \
+ block += 8; \
+ } \
+} \
+ \
static void FUNCC(add_pixels8 ## suffix)(uint8_t *restrict _pixels, \
DCTELEM *_block, \
int line_size) \
diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c
index c0f2c036c6..b915ffeb20 100644
--- a/libavcodec/mlib/dsputil_mlib.c
+++ b/libavcodec/mlib/dsputil_mlib.c
@@ -423,11 +423,12 @@ void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
- c->get_pixels = get_pixels_mlib;
c->diff_pixels = diff_pixels_mlib;
c->add_pixels_clamped = add_pixels_clamped_mlib;
if (!high_bit_depth) {
+ c->get_pixels = get_pixels_mlib;
+
c->put_pixels_tab[0][0] = put_pixels16_mlib;
c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;
c->put_pixels_tab[0][2] = put_pixels16_y2_mlib;
diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c
index 7bdd5705b9..f0526722d6 100644
--- a/libavcodec/ppc/dsputil_altivec.c
+++ b/libavcodec/ppc/dsputil_altivec.c
@@ -1387,11 +1387,10 @@ void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx)
c->sse[0]= sse16_altivec;
c->pix_sum = pix_sum_altivec;
c->diff_pixels = diff_pixels_altivec;
- c->get_pixels = get_pixels_altivec;
- if (!high_bit_depth)
- c->clear_block = clear_block_altivec;
c->add_bytes= add_bytes_altivec;
if (!high_bit_depth) {
+ c->get_pixels = get_pixels_altivec;
+ c->clear_block = clear_block_altivec;
c->put_pixels_tab[0][0] = put_pixels16_altivec;
/* the two functions do the same thing, so use the same code */
c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec;
diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c
index 585709679b..94a5a8cb48 100644
--- a/libavcodec/ps2/dsputil_mmi.c
+++ b/libavcodec/ps2/dsputil_mmi.c
@@ -152,9 +152,9 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
c->put_pixels_tab[0][0] = put_pixels16_mmi;
c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
- }
c->get_pixels = get_pixels_mmi;
+ }
if (avctx->bits_per_raw_sample <= 8 &&
(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2)) {
diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c
index ea03e9232f..7362234c86 100644
--- a/libavcodec/x86/dsputilenc_mmx.c
+++ b/libavcodec/x86/dsputilenc_mmx.c
@@ -1098,6 +1098,7 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
int mm_flags = av_get_cpu_flags();
+ int bit_depth = avctx->bits_per_raw_sample;
if (mm_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = avctx->dct_algo;
@@ -1112,7 +1113,8 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
}
}
- c->get_pixels = get_pixels_mmx;
+ if (bit_depth <= 8)
+ c->get_pixels = get_pixels_mmx;
c->diff_pixels = diff_pixels_mmx;
c->pix_sum = pix_sum16_mmx;
@@ -1159,7 +1161,8 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
}
if(mm_flags & AV_CPU_FLAG_SSE2){
- c->get_pixels = get_pixels_sse2;
+ if (bit_depth <= 8)
+ c->get_pixels = get_pixels_sse2;
c->sum_abs_dctelem= sum_abs_dctelem_sse2;
#if HAVE_YASM && HAVE_ALIGNED_STACK
c->hadamard8_diff[0]= ff_hadamard8_diff16_sse2;