dsputil: template get_pixels() for different bit depths
Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
5cc2600964
commit
874f1a901d
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);\
|
||||
|
@ -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) \
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user