From dd561441b1e849df7d8681c6f32af82d4088dafd Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 9 May 2011 09:48:21 -0400 Subject: h264: DSP'ize MBAFF loopfilter. --- libavcodec/h264dsp.c | 56 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'libavcodec/h264dsp.c') diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index 85dbb8f2e5..1ef6a26db4 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -99,15 +99,15 @@ H264_WEIGHT(2,2) #undef op_scale2 #undef H264_WEIGHT -static av_always_inline av_flatten void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0) +static av_always_inline av_flatten void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) { int i, d; for( i = 0; i < 4; i++ ) { if( tc0[i] < 0 ) { - pix += 4*ystride; + pix += inner_iters*ystride; continue; } - for( d = 0; d < 4; d++ ) { + for( d = 0; d < inner_iters; d++ ) { const int p0 = pix[-1*xstride]; const int p1 = pix[-2*xstride]; const int p2 = pix[-3*xstride]; @@ -143,17 +143,21 @@ static av_always_inline av_flatten void h264_loop_filter_luma_c(uint8_t *pix, in } static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_luma_c(pix, stride, 1, alpha, beta, tc0); + h264_loop_filter_luma_c(pix, stride, 1, 4, alpha, beta, tc0); } static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_luma_c(pix, 1, stride, alpha, beta, tc0); + h264_loop_filter_luma_c(pix, 1, stride, 4, alpha, beta, tc0); +} +static void h264_h_loop_filter_luma_mbaff_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_luma_c(pix, 1, stride, 2, alpha, beta, tc0); } -static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta) +static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta) { int d; - for( d = 0; d < 16; d++ ) { + for( d = 0; d < 4 * inner_iters; d++ ) { const int p2 = pix[-3*xstride]; const int p1 = pix[-2*xstride]; const int p0 = pix[-1*xstride]; @@ -200,23 +204,27 @@ static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *p } static void h264_v_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_luma_intra_c(pix, stride, 1, alpha, beta); + h264_loop_filter_luma_intra_c(pix, stride, 1, 4, alpha, beta); } static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta); + h264_loop_filter_luma_intra_c(pix, 1, stride, 4, alpha, beta); +} +static void h264_h_loop_filter_luma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_luma_intra_c(pix, 1, stride, 2, alpha, beta); } -static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0) +static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) { int i, d; for( i = 0; i < 4; i++ ) { const int tc = tc0[i]; if( tc <= 0 ) { - pix += 2*ystride; + pix += inner_iters*ystride; continue; } - for( d = 0; d < 2; d++ ) { + for( d = 0; d < inner_iters; d++ ) { const int p0 = pix[-1*xstride]; const int p1 = pix[-2*xstride]; const int q0 = pix[0]; @@ -237,17 +245,21 @@ static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, } static void h264_v_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_chroma_c(pix, stride, 1, alpha, beta, tc0); + h264_loop_filter_chroma_c(pix, stride, 1, 2, alpha, beta, tc0); } static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_chroma_c(pix, 1, stride, alpha, beta, tc0); + h264_loop_filter_chroma_c(pix, 1, stride, 2, alpha, beta, tc0); +} +static void h264_h_loop_filter_chroma_mbaff_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_chroma_c(pix, 1, stride, 1, alpha, beta, tc0); } -static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta) +static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta) { int d; - for( d = 0; d < 8; d++ ) { + for( d = 0; d < 4 * inner_iters; d++ ) { const int p0 = pix[-1*xstride]; const int p1 = pix[-2*xstride]; const int q0 = pix[0]; @@ -265,11 +277,15 @@ static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t } static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta); + h264_loop_filter_chroma_intra_c(pix, stride, 1, 2, alpha, beta); } static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_chroma_intra_c(pix, 1, stride, alpha, beta); + h264_loop_filter_chroma_intra_c(pix, 1, stride, 2, alpha, beta); +} +static void h264_h_loop_filter_chroma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_chroma_intra_c(pix, 1, stride, 1, alpha, beta); } void ff_h264dsp_init(H264DSPContext *c) @@ -307,12 +323,16 @@ void ff_h264dsp_init(H264DSPContext *c) c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c; c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c; + c->h264_h_loop_filter_luma_mbaff= h264_h_loop_filter_luma_mbaff_c; c->h264_v_loop_filter_luma_intra= h264_v_loop_filter_luma_intra_c; c->h264_h_loop_filter_luma_intra= h264_h_loop_filter_luma_intra_c; + c->h264_h_loop_filter_luma_mbaff_intra= h264_h_loop_filter_luma_mbaff_intra_c; c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c; c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c; + c->h264_h_loop_filter_chroma_mbaff= h264_h_loop_filter_chroma_mbaff_c; c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_c; c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c; + c->h264_h_loop_filter_chroma_mbaff_intra= h264_h_loop_filter_chroma_mbaff_intra_c; c->h264_loop_filter_strength= NULL; if (ARCH_ARM) ff_h264dsp_init_arm(c); -- cgit v1.2.3 From e39e3abad4ce667f06d41097428695a7aad095fb Mon Sep 17 00:00:00 2001 From: Oskar Arvidsson Date: Sun, 10 Apr 2011 22:42:36 +0200 Subject: Choose h264 chroma dc dequant function dynamically. Needed for high bit depth h264 decoding. Signed-off-by: Ronald S. Bultje --- libavcodec/dsputil.h | 1 + libavcodec/h264.c | 29 ++++------------------------- libavcodec/h264dsp.c | 1 + libavcodec/h264dsp.h | 1 + libavcodec/h264idct.c | 22 ++++++++++++++++++++++ 5 files changed, 29 insertions(+), 25 deletions(-) (limited to 'libavcodec/h264dsp.c') diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 8d8bc29dd5..9b4aef758a 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -64,6 +64,7 @@ void ff_h264_idct_add16intra_c(uint8_t *dst, const int *blockoffset, DCTELEM *bl void ff_h264_idct8_add4_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); void ff_h264_idct_add8_c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); +void ff_h264_chroma_dc_dequant_idct_c(DCTELEM *block, int qmul); void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul); void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp); void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 501777049f..142a07807a 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -288,27 +288,6 @@ static void h264_luma_dc_dct_c(DCTELEM *block/*, int qp*/){ #undef xStride #undef stride -static void chroma_dc_dequant_idct_c(DCTELEM *block, int qmul){ - const int stride= 16*2; - const int xStride= 16; - int a,b,c,d,e; - - a= block[stride*0 + xStride*0]; - b= block[stride*0 + xStride*1]; - c= block[stride*1 + xStride*0]; - d= block[stride*1 + xStride*1]; - - e= a-b; - a= a+b; - b= c-d; - c= c+d; - - block[stride*0 + xStride*0]= ((a+c)*qmul) >> 7; - block[stride*0 + xStride*1]= ((e+b)*qmul) >> 7; - block[stride*1 + xStride*0]= ((a-c)*qmul) >> 7; - block[stride*1 + xStride*1]= ((e-b)*qmul) >> 7; -} - #if 0 static void chroma_dc_dct_c(DCTELEM *block){ const int stride= 16*2; @@ -1286,15 +1265,15 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){ }else{ if(is_h264){ if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ]) - chroma_dc_dequant_idct_c(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); + h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ]) - chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); + h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); h->h264dsp.h264_idct_add8(dest, block_offset, h->mb, uvlinesize, h->non_zero_count_cache); }else{ - chroma_dc_dequant_idct_c(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); - chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); + h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); + h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); for(i=16; i<16+8; i++){ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i]; diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index 1ef6a26db4..b555ed343a 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -299,6 +299,7 @@ void ff_h264dsp_init(H264DSPContext *c) c->h264_idct_add8 = ff_h264_idct_add8_c; c->h264_idct_add16intra= ff_h264_idct_add16intra_c; c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_c; + c->h264_chroma_dc_dequant_idct= ff_h264_chroma_dc_dequant_idct_c; c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c; c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c; diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h index 9db4c13784..7eb50be342 100644 --- a/libavcodec/h264dsp.h +++ b/libavcodec/h264dsp.h @@ -72,6 +72,7 @@ typedef struct H264DSPContext{ void (*h264_idct_add8)(uint8_t **dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]); void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]); void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul); + void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); }H264DSPContext; void ff_h264dsp_init(H264DSPContext *c); diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c index ecf669ebd0..790f1883fd 100644 --- a/libavcodec/h264idct.c +++ b/libavcodec/h264idct.c @@ -250,4 +250,26 @@ void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul){ output[stride* 4+offset]= ((((z1 - z2)*qmul + 128 ) >> 8)); output[stride* 5+offset]= ((((z0 - z3)*qmul + 128 ) >> 8)); } +#undef stride +} + +void ff_h264_chroma_dc_dequant_idct_c(DCTELEM *block, int qmul){ + const int stride= 16*2; + const int xStride= 16; + int a,b,c,d,e; + + a= block[stride*0 + xStride*0]; + b= block[stride*0 + xStride*1]; + c= block[stride*1 + xStride*0]; + d= block[stride*1 + xStride*1]; + + e= a-b; + a= a+b; + b= c-d; + c= c+d; + + block[stride*0 + xStride*0]= ((a+c)*qmul) >> 7; + block[stride*0 + xStride*1]= ((e+b)*qmul) >> 7; + block[stride*1 + xStride*0]= ((a-c)*qmul) >> 7; + block[stride*1 + xStride*1]= ((e-b)*qmul) >> 7; } -- cgit v1.2.3 From 563c72dabb7ef34b667836c1b0e2008c08e89fa6 Mon Sep 17 00:00:00 2001 From: Oskar Arvidsson Date: Mon, 9 May 2011 10:58:40 -0400 Subject: Preparatory patch for high bit depth h264 decoding support. Signed-off-by: Ronald S. Bultje --- libavcodec/h264dsp.c | 259 +------------------------------------- libavcodec/h264dsp_template.c | 285 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+), 258 deletions(-) create mode 100644 libavcodec/h264dsp_template.c (limited to 'libavcodec/h264dsp.c') diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index b555ed343a..22b2086243 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -29,264 +29,7 @@ #include "avcodec.h" #include "h264dsp.h" -#define op_scale1(x) block[x] = av_clip_uint8( (block[x]*weight + offset) >> log2_denom ) -#define op_scale2(x) dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1)) -#define H264_WEIGHT(W,H) \ -static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \ - int y; \ - offset <<= log2_denom; \ - if(log2_denom) offset += 1<<(log2_denom-1); \ - for(y=0; y> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] ); - tc++; - } - if( FFABS( q2 - q0 ) < beta ) { - if(tc0[i]) - pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] ); - tc++; - } - - i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); - pix[-xstride] = av_clip_uint8( p0 + i_delta ); /* p0' */ - pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */ - } - pix += ystride; - } - } -} -static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) -{ - h264_loop_filter_luma_c(pix, stride, 1, 4, alpha, beta, tc0); -} -static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) -{ - h264_loop_filter_luma_c(pix, 1, stride, 4, alpha, beta, tc0); -} -static void h264_h_loop_filter_luma_mbaff_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) -{ - h264_loop_filter_luma_c(pix, 1, stride, 2, alpha, beta, tc0); -} - -static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta) -{ - int d; - for( d = 0; d < 4 * inner_iters; d++ ) { - const int p2 = pix[-3*xstride]; - const int p1 = pix[-2*xstride]; - const int p0 = pix[-1*xstride]; - - const int q0 = pix[ 0*xstride]; - const int q1 = pix[ 1*xstride]; - const int q2 = pix[ 2*xstride]; - - if( FFABS( p0 - q0 ) < alpha && - FFABS( p1 - p0 ) < beta && - FFABS( q1 - q0 ) < beta ) { - - if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){ - if( FFABS( p2 - p0 ) < beta) - { - const int p3 = pix[-4*xstride]; - /* p0', p1', p2' */ - pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3; - pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; - pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3; - } else { - /* p0' */ - pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; - } - if( FFABS( q2 - q0 ) < beta) - { - const int q3 = pix[3*xstride]; - /* q0', q1', q2' */ - pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3; - pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; - pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3; - } else { - /* q0' */ - pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2; - } - }else{ - /* p0', q0' */ - pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; - pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2; - } - } - pix += ystride; - } -} -static void h264_v_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) -{ - h264_loop_filter_luma_intra_c(pix, stride, 1, 4, alpha, beta); -} -static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) -{ - h264_loop_filter_luma_intra_c(pix, 1, stride, 4, alpha, beta); -} -static void h264_h_loop_filter_luma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) -{ - h264_loop_filter_luma_intra_c(pix, 1, stride, 2, alpha, beta); -} - -static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) -{ - int i, d; - for( i = 0; i < 4; i++ ) { - const int tc = tc0[i]; - if( tc <= 0 ) { - pix += inner_iters*ystride; - continue; - } - for( d = 0; d < inner_iters; d++ ) { - const int p0 = pix[-1*xstride]; - const int p1 = pix[-2*xstride]; - const int q0 = pix[0]; - const int q1 = pix[1*xstride]; - - if( FFABS( p0 - q0 ) < alpha && - FFABS( p1 - p0 ) < beta && - FFABS( q1 - q0 ) < beta ) { - - int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); - - pix[-xstride] = av_clip_uint8( p0 + delta ); /* p0' */ - pix[0] = av_clip_uint8( q0 - delta ); /* q0' */ - } - pix += ystride; - } - } -} -static void h264_v_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) -{ - h264_loop_filter_chroma_c(pix, stride, 1, 2, alpha, beta, tc0); -} -static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) -{ - h264_loop_filter_chroma_c(pix, 1, stride, 2, alpha, beta, tc0); -} -static void h264_h_loop_filter_chroma_mbaff_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) -{ - h264_loop_filter_chroma_c(pix, 1, stride, 1, alpha, beta, tc0); -} - -static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta) -{ - int d; - for( d = 0; d < 4 * inner_iters; d++ ) { - const int p0 = pix[-1*xstride]; - const int p1 = pix[-2*xstride]; - const int q0 = pix[0]; - const int q1 = pix[1*xstride]; - - if( FFABS( p0 - q0 ) < alpha && - FFABS( p1 - p0 ) < beta && - FFABS( q1 - q0 ) < beta ) { - - pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */ - pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */ - } - pix += ystride; - } -} -static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) -{ - h264_loop_filter_chroma_intra_c(pix, stride, 1, 2, alpha, beta); -} -static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) -{ - h264_loop_filter_chroma_intra_c(pix, 1, stride, 2, alpha, beta); -} -static void h264_h_loop_filter_chroma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) -{ - h264_loop_filter_chroma_intra_c(pix, 1, stride, 1, alpha, beta); -} +#include "h264dsp_template.c" void ff_h264dsp_init(H264DSPContext *c) { diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c new file mode 100644 index 0000000000..2fe09ff56b --- /dev/null +++ b/libavcodec/h264dsp_template.c @@ -0,0 +1,285 @@ +/* + * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder + * Copyright (c) 2003-2010 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * H.264 / AVC / MPEG4 part10 DSP functions. + * @author Michael Niedermayer + */ + +#define op_scale1(x) block[x] = av_clip_uint8( (block[x]*weight + offset) >> log2_denom ) +#define op_scale2(x) dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1)) +#define H264_WEIGHT(W,H) \ +static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \ + int y; \ + offset <<= log2_denom; \ + if(log2_denom) offset += 1<<(log2_denom-1); \ + for(y=0; y> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] ); + tc++; + } + if( FFABS( q2 - q0 ) < beta ) { + if(tc0[i]) + pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] ); + tc++; + } + + i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); + pix[-xstride] = av_clip_uint8( p0 + i_delta ); /* p0' */ + pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */ + } + pix += ystride; + } + } +} +static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_luma_c(pix, stride, 1, 4, alpha, beta, tc0); +} +static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_luma_c(pix, 1, stride, 4, alpha, beta, tc0); +} +static void h264_h_loop_filter_luma_mbaff_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_luma_c(pix, 1, stride, 2, alpha, beta, tc0); +} + +static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta) +{ + int d; + for( d = 0; d < 4 * inner_iters; d++ ) { + const int p2 = pix[-3*xstride]; + const int p1 = pix[-2*xstride]; + const int p0 = pix[-1*xstride]; + + const int q0 = pix[ 0*xstride]; + const int q1 = pix[ 1*xstride]; + const int q2 = pix[ 2*xstride]; + + if( FFABS( p0 - q0 ) < alpha && + FFABS( p1 - p0 ) < beta && + FFABS( q1 - q0 ) < beta ) { + + if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){ + if( FFABS( p2 - p0 ) < beta) + { + const int p3 = pix[-4*xstride]; + /* p0', p1', p2' */ + pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3; + pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; + pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3; + } else { + /* p0' */ + pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; + } + if( FFABS( q2 - q0 ) < beta) + { + const int q3 = pix[3*xstride]; + /* q0', q1', q2' */ + pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3; + pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; + pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3; + } else { + /* q0' */ + pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2; + } + }else{ + /* p0', q0' */ + pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; + pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2; + } + } + pix += ystride; + } +} +static void h264_v_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_luma_intra_c(pix, stride, 1, 4, alpha, beta); +} +static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_luma_intra_c(pix, 1, stride, 4, alpha, beta); +} +static void h264_h_loop_filter_luma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_luma_intra_c(pix, 1, stride, 2, alpha, beta); +} + +static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) +{ + int i, d; + for( i = 0; i < 4; i++ ) { + const int tc = tc0[i]; + if( tc <= 0 ) { + pix += inner_iters*ystride; + continue; + } + for( d = 0; d < inner_iters; d++ ) { + const int p0 = pix[-1*xstride]; + const int p1 = pix[-2*xstride]; + const int q0 = pix[0]; + const int q1 = pix[1*xstride]; + + if( FFABS( p0 - q0 ) < alpha && + FFABS( p1 - p0 ) < beta && + FFABS( q1 - q0 ) < beta ) { + + int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); + + pix[-xstride] = av_clip_uint8( p0 + delta ); /* p0' */ + pix[0] = av_clip_uint8( q0 - delta ); /* q0' */ + } + pix += ystride; + } + } +} +static void h264_v_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_chroma_c(pix, stride, 1, 2, alpha, beta, tc0); +} +static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_chroma_c(pix, 1, stride, 2, alpha, beta, tc0); +} +static void h264_h_loop_filter_chroma_mbaff_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +{ + h264_loop_filter_chroma_c(pix, 1, stride, 1, alpha, beta, tc0); +} + +static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, int ystride, int inner_iters, int alpha, int beta) +{ + int d; + for( d = 0; d < 4 * inner_iters; d++ ) { + const int p0 = pix[-1*xstride]; + const int p1 = pix[-2*xstride]; + const int q0 = pix[0]; + const int q1 = pix[1*xstride]; + + if( FFABS( p0 - q0 ) < alpha && + FFABS( p1 - p0 ) < beta && + FFABS( q1 - q0 ) < beta ) { + + pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */ + pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */ + } + pix += ystride; + } +} +static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_chroma_intra_c(pix, stride, 1, 2, alpha, beta); +} +static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_chroma_intra_c(pix, 1, stride, 2, alpha, beta); +} +static void h264_h_loop_filter_chroma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) +{ + h264_loop_filter_chroma_intra_c(pix, 1, stride, 1, alpha, beta); +} -- cgit v1.2.3 From 19a0729b4cfacfd90b8ee84ab0c093ff7e397e65 Mon Sep 17 00:00:00 2001 From: Oskar Arvidsson Date: Tue, 29 Mar 2011 17:48:59 +0200 Subject: Adds 8-, 9- and 10-bit versions of some of the functions used by the h264 decoder. This patch lets e.g. dsputil_init chose dsp functions with respect to the bit depth to decode. The naming scheme of bit depth dependent functions is _[_] (i.e. the old clear_blocks_c is now named clear_blocks_8_c). Note: Some of the functions for high bit depth is not dependent on the bit depth, but only on the pixel size. This leaves some room for optimizing binary size. Preparatory patch for high bit depth h264 decoding support. Signed-off-by: Ronald S. Bultje --- libavcodec/alpha/dsputil_alpha.c | 4 + libavcodec/arm/dsputil_init_arm.c | 4 + libavcodec/arm/dsputil_init_armv6.c | 4 + libavcodec/arm/dsputil_init_neon.c | 6 + libavcodec/arm/dsputil_iwmmxt.c | 3 + libavcodec/arm/h264dsp_init_arm.c | 8 +- libavcodec/arm/h264pred_init_arm.c | 11 +- libavcodec/bfin/dsputil_bfin.c | 5 + libavcodec/dsputil.c | 282 +++++++++++++++++++++-------------- libavcodec/dsputil.h | 71 ++++++--- libavcodec/dsputil_template.c | 80 +++++++--- libavcodec/h264.c | 22 ++- libavcodec/h264dsp.c | 120 +++++++++------ libavcodec/h264dsp.h | 8 +- libavcodec/h264dsp_template.c | 5 +- libavcodec/h264idct.c | 10 ++ libavcodec/h264idct_template.c | 8 +- libavcodec/h264pred.c | 278 +++++++++++++++++++--------------- libavcodec/h264pred.h | 6 +- libavcodec/h264pred_template.c | 16 +- libavcodec/high_bit_depth.h | 85 +++++++++++ libavcodec/mlib/dsputil_mlib.c | 4 + libavcodec/ppc/dsputil_altivec.c | 5 + libavcodec/ppc/dsputil_ppc.c | 4 + libavcodec/ppc/h264_altivec.c | 7 +- libavcodec/ps2/dsputil_mmi.c | 3 + libavcodec/rv34.c | 2 +- libavcodec/sh4/dsputil_align.c | 8 + libavcodec/sh4/dsputil_sh4.c | 2 + libavcodec/sparc/dsputil_vis.c | 3 + libavcodec/vp8.c | 2 +- libavcodec/x86/dsputil_mmx.c | 32 ++++ libavcodec/x86/h264_intrapred_init.c | 6 +- libavcodec/x86/h264dsp_mmx.c | 4 +- 34 files changed, 753 insertions(+), 365 deletions(-) create mode 100644 libavcodec/high_bit_depth.h (limited to 'libavcodec/h264dsp.c') diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c index 610f92acbb..32bb0fc932 100644 --- a/libavcodec/alpha/dsputil_alpha.c +++ b/libavcodec/alpha/dsputil_alpha.c @@ -270,6 +270,9 @@ static void put_pixels16_axp_asm(uint8_t *block, const uint8_t *pixels, void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + + if (!high_bit_depth) { c->put_pixels_tab[0][0] = put_pixels16_axp_asm; c->put_pixels_tab[0][1] = put_pixels16_x2_axp; c->put_pixels_tab[0][2] = put_pixels16_y2_axp; @@ -311,6 +314,7 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx) c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp; c->clear_blocks = clear_blocks_axp; + } /* amask clears all bits that correspond to present features. */ if (amask(AMASK_MVI) == 0) { diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/dsputil_init_arm.c index 92796c3145..777a2f954e 100644 --- a/libavcodec/arm/dsputil_init_arm.c +++ b/libavcodec/arm/dsputil_init_arm.c @@ -75,6 +75,8 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; @@ -95,6 +97,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) c->add_pixels_clamped = ff_add_pixels_clamped_arm; + if (!high_bit_depth) { c->put_pixels_tab[0][0] = ff_put_pixels16_arm; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_arm; @@ -112,6 +115,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_arm; c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_arm; c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_arm; + } if (HAVE_ARMV5TE) ff_dsputil_init_armv5te(c, avctx); if (HAVE_ARMV6) ff_dsputil_init_armv6(c, avctx); diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c index 362050c6ea..7584aeefc6 100644 --- a/libavcodec/arm/dsputil_init_armv6.c +++ b/libavcodec/arm/dsputil_init_armv6.c @@ -72,6 +72,8 @@ int ff_pix_sum_armv6(uint8_t *pix, int line_size); void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { c->idct_put = ff_simple_idct_put_armv6; @@ -80,6 +82,7 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM; } + if (!high_bit_depth) { c->put_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6; @@ -100,6 +103,7 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) c->avg_pixels_tab[0][0] = ff_avg_pixels16_armv6; c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6; + } c->add_pixels_clamped = ff_add_pixels_clamped_armv6; c->get_pixels = ff_get_pixels_armv6; diff --git a/libavcodec/arm/dsputil_init_neon.c b/libavcodec/arm/dsputil_init_neon.c index cd58011a2c..3bc053c864 100644 --- a/libavcodec/arm/dsputil_init_neon.c +++ b/libavcodec/arm/dsputil_init_neon.c @@ -173,6 +173,8 @@ void ff_apply_window_int16_neon(int16_t *dst, const int16_t *src, void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + if (!avctx->lowres) { if (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLENEON) { @@ -190,6 +192,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) } } + if (!high_bit_depth) { c->clear_block = ff_clear_block_neon; c->clear_blocks = ff_clear_blocks_neon; @@ -213,12 +216,14 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) c->avg_pixels_tab[0][0] = ff_avg_pixels16_neon; c->avg_pixels_tab[1][0] = ff_avg_pixels8_neon; + } c->add_pixels_clamped = ff_add_pixels_clamped_neon; c->put_pixels_clamped = ff_put_pixels_clamped_neon; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon; if (CONFIG_H264_DECODER) { + if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon; c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon; c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_neon; @@ -294,6 +299,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_neon; c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_neon; c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon; + } } if (CONFIG_VP3_DECODER) { diff --git a/libavcodec/arm/dsputil_iwmmxt.c b/libavcodec/arm/dsputil_iwmmxt.c index e83edb5bb8..86f8fddfcf 100644 --- a/libavcodec/arm/dsputil_iwmmxt.c +++ b/libavcodec/arm/dsputil_iwmmxt.c @@ -155,6 +155,7 @@ static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h) void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) { int mm_flags = AV_CPU_FLAG_IWMMXT; /* multimedia extension flags */ + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; if (avctx->dsp_mask) { if (avctx->dsp_mask & AV_CPU_FLAG_FORCE) @@ -167,6 +168,7 @@ void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) c->add_pixels_clamped = add_pixels_clamped_iwmmxt; + if (!high_bit_depth) { c->clear_blocks = clear_blocks_iwmmxt; c->put_pixels_tab[0][0] = put_pixels16_iwmmxt; @@ -204,4 +206,5 @@ void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_iwmmxt; c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_iwmmxt; c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_iwmmxt; + } } diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c index 20f5ac2076..c2399e50ff 100644 --- a/libavcodec/arm/h264dsp_init_arm.c +++ b/libavcodec/arm/h264dsp_init_arm.c @@ -92,8 +92,9 @@ void ff_h264_idct8_add4_neon(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); -static void ff_h264dsp_init_neon(H264DSPContext *c) +static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth) { + if (bit_depth == 8) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; @@ -125,9 +126,10 @@ static void ff_h264dsp_init_neon(H264DSPContext *c) c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; + } } -void ff_h264dsp_init_arm(H264DSPContext *c) +void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth) { - if (HAVE_NEON) ff_h264dsp_init_neon(c); + if (HAVE_NEON) ff_h264dsp_init_neon(c, bit_depth); } diff --git a/libavcodec/arm/h264pred_init_arm.c b/libavcodec/arm/h264pred_init_arm.c index 3f1c5c64fd..cae32d7567 100644 --- a/libavcodec/arm/h264pred_init_arm.c +++ b/libavcodec/arm/h264pred_init_arm.c @@ -42,8 +42,13 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, int stride); void ff_pred8x8_l00_dc_neon(uint8_t *src, int stride); void ff_pred8x8_0l0_dc_neon(uint8_t *src, int stride); -static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id) +static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int bit_depth) { + const int high_depth = bit_depth > 8; + + if (high_depth) + return; + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; if (codec_id != CODEC_ID_VP8) @@ -69,7 +74,7 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id) h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; } -void ff_h264_pred_init_arm(H264PredContext *h, int codec_id) +void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, bit_depth) { - if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id); + if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id, bit_depth); } diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 65d0308018..0db2d8baf8 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -197,11 +197,14 @@ static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_si 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->clear_blocks = bfin_clear_blocks; c->pix_sum = ff_bfin_pix_sum; c->pix_norm1 = ff_bfin_pix_norm1; @@ -228,6 +231,7 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) c->sse[1] = ff_bfin_sse8; c->sse[2] = ff_bfin_sse4; + if (!high_bit_depth) { c->put_pixels_tab[0][0] = bfin_put_pixels16; c->put_pixels_tab[0][1] = bfin_put_pixels16_x2; c->put_pixels_tab[0][2] = bfin_put_pixels16_y2; @@ -247,6 +251,7 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_nornd; c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_nornd; /* c->put_no_rnd_pixels_tab[0][3] = ff_bfin_put_pixels16_xy2_nornd; */ + } if (avctx->dct_algo == FF_DCT_AUTO) c->fdct = ff_bfin_fdct; diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 078e172d00..4389289d82 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -43,6 +43,15 @@ uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; uint32_t ff_squareTbl[512] = {0, }; +#define BIT_DEPTH 9 +#include "dsputil_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 10 +#include "dsputil_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 8 #include "dsputil_template.c" // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size @@ -619,10 +628,10 @@ void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ switch(width){ - case 2: put_pixels2_c (dst, src, stride, height); break; - case 4: put_pixels4_c (dst, src, stride, height); break; - case 8: put_pixels8_c (dst, src, stride, height); break; - case 16:put_pixels16_c(dst, src, stride, height); break; + case 2: put_pixels2_8_c (dst, src, stride, height); break; + case 4: put_pixels4_8_c (dst, src, stride, height); break; + case 8: put_pixels8_8_c (dst, src, stride, height); break; + case 16:put_pixels16_8_c(dst, src, stride, height); break; } } @@ -716,10 +725,10 @@ static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ switch(width){ - case 2: avg_pixels2_c (dst, src, stride, height); break; - case 4: avg_pixels4_c (dst, src, stride, height); break; - case 8: avg_pixels8_c (dst, src, stride, height); break; - case 16:avg_pixels16_c(dst, src, stride, height); break; + case 2: avg_pixels2_8_c (dst, src, stride, height); break; + case 4: avg_pixels4_8_c (dst, src, stride, height); break; + case 8: avg_pixels8_8_c (dst, src, stride, height); break; + case 16:avg_pixels16_8_c(dst, src, stride, height); break; } } @@ -953,7 +962,7 @@ static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dst static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[64];\ put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ - OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8);\ }\ \ static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -963,7 +972,7 @@ static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[64];\ put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ - OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);\ }\ \ static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -971,7 +980,7 @@ static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[64];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\ - OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8);\ }\ \ static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -985,7 +994,7 @@ static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[64];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\ - OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, full+16, half, stride, 16, 8, 8);\ }\ void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -996,7 +1005,7 @@ void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ + OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1004,9 +1013,9 @@ static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[64];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ + put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\ }\ void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1017,7 +1026,7 @@ void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ + OPNAME ## pixels8_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1025,9 +1034,9 @@ static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[64];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ + put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\ }\ void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1038,7 +1047,7 @@ void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ + OPNAME ## pixels8_l4_8(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1046,9 +1055,9 @@ static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[64];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ + put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\ }\ void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1059,7 +1068,7 @@ void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ + OPNAME ## pixels8_l4_8(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1067,23 +1076,23 @@ static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[64];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ + put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfH[72];\ uint8_t halfHV[64];\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfH[72];\ uint8_t halfHV[64];\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\ }\ void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ @@ -1094,14 +1103,14 @@ void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ uint8_t halfH[72];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ + put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\ OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ }\ void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1113,14 +1122,14 @@ void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ + OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\ }\ static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[16*9];\ uint8_t halfH[72];\ copy_block9(full, src, 16, stride, 9);\ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ + put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\ OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ }\ static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1132,7 +1141,7 @@ static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[256];\ put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ - OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16);\ }\ \ static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1142,7 +1151,7 @@ static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[256];\ put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ - OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, src+1, half, stride, stride, 16, 16);\ }\ \ static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1150,7 +1159,7 @@ static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[256];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\ - OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16);\ }\ \ static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1164,7 +1173,7 @@ static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t half[256];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\ - OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, full+24, half, stride, 24, 16, 16);\ }\ void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1175,7 +1184,7 @@ void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ + OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1183,9 +1192,9 @@ static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[256];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ + put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\ }\ void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1196,7 +1205,7 @@ void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ + OPNAME ## pixels16_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1204,9 +1213,9 @@ static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[256];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ + put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\ }\ void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1217,7 +1226,7 @@ void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ + OPNAME ## pixels16_l4_8(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1225,9 +1234,9 @@ static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[256];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ + put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\ }\ void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1238,7 +1247,7 @@ void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ + OPNAME ## pixels16_l4_8(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1246,23 +1255,23 @@ static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfHV[256];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ + put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfH[272];\ uint8_t halfHV[256];\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t halfH[272];\ uint8_t halfHV[256];\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\ }\ void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ @@ -1273,14 +1282,14 @@ void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ uint8_t halfH[272];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ + put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\ OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ }\ void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1292,14 +1301,14 @@ void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ + OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\ }\ static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\ uint8_t full[24*17];\ uint8_t halfH[272];\ copy_block17(full, src, 24, stride, 17);\ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ + put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\ OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ }\ static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ @@ -1327,7 +1336,7 @@ QPEL_MC(0, avg_ , _ , op_avg) #define put_qpel16_mc00_c ff_put_pixels16x16_c #define avg_qpel16_mc00_c ff_avg_pixels16x16_c #define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c -#define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c +#define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_8_c static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; @@ -1349,16 +1358,16 @@ static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int #if CONFIG_RV40_DECODER static void put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){ - put_pixels16_xy2_c(dst, src, stride, 16); + put_pixels16_xy2_8_c(dst, src, stride, 16); } static void avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){ - avg_pixels16_xy2_c(dst, src, stride, 16); + avg_pixels16_xy2_8_c(dst, src, stride, 16); } static void put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){ - put_pixels8_xy2_c(dst, src, stride, 8); + put_pixels8_xy2_8_c(dst, src, stride, 8); } static void avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){ - avg_pixels8_xy2_c(dst, src, stride, 8); + avg_pixels8_xy2_8_c(dst, src, stride, 8); } #endif /* CONFIG_RV40_DECODER */ @@ -1394,7 +1403,7 @@ static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){ uint8_t half[64]; wmv2_mspel8_h_lowpass(half, src, 8, stride, 8); - put_pixels8_l2(dst, src, half, stride, stride, 8, 8); + put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8); } static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){ @@ -1404,7 +1413,7 @@ static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){ static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){ uint8_t half[64]; wmv2_mspel8_h_lowpass(half, src, 8, stride, 8); - put_pixels8_l2(dst, src+1, half, stride, stride, 8, 8); + put_pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8); } static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){ @@ -1418,7 +1427,7 @@ static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){ wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8); wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8); - put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8); + put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); } static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){ uint8_t halfH[88]; @@ -1427,7 +1436,7 @@ static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){ wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8); wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8); - put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8); + put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); } static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){ uint8_t halfH[88]; @@ -2863,8 +2872,24 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->idct_put= ff_jref_idct4_put; c->idct_add= ff_jref_idct4_add; }else{ - c->idct_put= ff_h264_lowres_idct_put_c; - c->idct_add= ff_h264_lowres_idct_add_c; + if (avctx->codec_id != CODEC_ID_H264) { + c->idct_put= ff_h264_lowres_idct_put_8_c; + c->idct_add= ff_h264_lowres_idct_add_8_c; + } else { + switch (avctx->bits_per_raw_sample) { + case 9: + c->idct_put= ff_h264_lowres_idct_put_9_c; + c->idct_add= ff_h264_lowres_idct_add_9_c; + break; + case 10: + c->idct_put= ff_h264_lowres_idct_put_10_c; + c->idct_add= ff_h264_lowres_idct_add_10_c; + break; + default: + c->idct_put= ff_h264_lowres_idct_put_8_c; + c->idct_add= ff_h264_lowres_idct_add_8_c; + } + } } c->idct = j_rev_dct4; c->idct_permutation_type= FF_NO_IDCT_PERM; @@ -2922,14 +2947,9 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c; c->put_pixels_nonclamped = put_pixels_nonclamped_c; c->add_pixels_clamped = ff_add_pixels_clamped_c; - c->add_pixels8 = add_pixels8_c; - c->add_pixels4 = add_pixels4_c; c->sum_abs_dctelem = sum_abs_dctelem_c; - c->emulated_edge_mc = ff_emulated_edge_mc; c->gmc1 = gmc1_c; c->gmc = ff_gmc_c; - c->clear_block = clear_block_c; - c->clear_blocks = clear_blocks_c; c->pix_sum = pix_sum_c; c->pix_norm1 = pix_norm1_c; @@ -2947,30 +2967,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->pix_abs[1][2] = pix_abs8_y2_c; c->pix_abs[1][3] = pix_abs8_xy2_c; -#define dspfunc(PFX, IDX, NUM) \ - c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c; \ - c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c; \ - c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c; \ - c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c - - dspfunc(put, 0, 16); - dspfunc(put_no_rnd, 0, 16); - dspfunc(put, 1, 8); - dspfunc(put_no_rnd, 1, 8); - dspfunc(put, 2, 4); - dspfunc(put, 3, 2); - - dspfunc(avg, 0, 16); - dspfunc(avg_no_rnd, 0, 16); - dspfunc(avg, 1, 8); - dspfunc(avg_no_rnd, 1, 8); - dspfunc(avg, 2, 4); - dspfunc(avg, 3, 2); -#undef dspfunc - - c->put_no_rnd_pixels_l2[0]= put_no_rnd_pixels16_l2_c; - c->put_no_rnd_pixels_l2[1]= put_no_rnd_pixels8_l2_c; - c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c; c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c; c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c; @@ -3021,23 +3017,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) dspfunc(avg_qpel, 1, 8); /* dspfunc(avg_no_rnd_qpel, 1, 8); */ - dspfunc(put_h264_qpel, 0, 16); - dspfunc(put_h264_qpel, 1, 8); - dspfunc(put_h264_qpel, 2, 4); - dspfunc(put_h264_qpel, 3, 2); - dspfunc(avg_h264_qpel, 0, 16); - dspfunc(avg_h264_qpel, 1, 8); - dspfunc(avg_h264_qpel, 2, 4); - #undef dspfunc - c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c; - c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c; - c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c; - c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c; - c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c; - c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c; - - c->draw_edges = draw_edges_c; #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER ff_mlp_init(c, avctx); @@ -3162,6 +3142,92 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab)); memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab)); +#undef FUNC +#undef FUNCC +#define FUNC(f, depth) f ## _ ## depth +#define FUNCC(f, depth) f ## _ ## depth ## _c + +#define dspfunc1(PFX, IDX, NUM, depth)\ + c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\ + c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\ + c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\ + c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth) + +#define dspfunc2(PFX, IDX, NUM, depth)\ + c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\ + c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\ + c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\ + c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\ + c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\ + c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\ + c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\ + c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\ + c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\ + c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\ + c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\ + c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\ + c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\ + c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\ + c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\ + c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth) + + +#define BIT_DEPTH_FUNCS(depth)\ + c->draw_edges = FUNCC(draw_edges , depth);\ + c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\ + c->clear_block = FUNCC(clear_block , depth);\ + c->clear_blocks = FUNCC(clear_blocks , depth);\ + c->add_pixels8 = FUNCC(add_pixels8 , depth);\ + c->add_pixels4 = FUNCC(add_pixels4 , depth);\ + c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\ + c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\ +\ + c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\ + c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\ + c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\ + c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\ + c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\ + c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\ +\ + dspfunc1(put , 0, 16, depth);\ + dspfunc1(put , 1, 8, depth);\ + dspfunc1(put , 2, 4, depth);\ + dspfunc1(put , 3, 2, depth);\ + dspfunc1(put_no_rnd, 0, 16, depth);\ + dspfunc1(put_no_rnd, 1, 8, depth);\ + dspfunc1(avg , 0, 16, depth);\ + dspfunc1(avg , 1, 8, depth);\ + dspfunc1(avg , 2, 4, depth);\ + dspfunc1(avg , 3, 2, depth);\ + dspfunc1(avg_no_rnd, 0, 16, depth);\ + dspfunc1(avg_no_rnd, 1, 8, depth);\ +\ + dspfunc2(put_h264_qpel, 0, 16, depth);\ + dspfunc2(put_h264_qpel, 1, 8, depth);\ + dspfunc2(put_h264_qpel, 2, 4, depth);\ + dspfunc2(put_h264_qpel, 3, 2, depth);\ + dspfunc2(avg_h264_qpel, 0, 16, depth);\ + dspfunc2(avg_h264_qpel, 1, 8, depth);\ + dspfunc2(avg_h264_qpel, 2, 4, depth); + + if (avctx->codec_id != CODEC_ID_H264 || avctx->bits_per_raw_sample == 8) { + BIT_DEPTH_FUNCS(8) + } else { + switch (avctx->bits_per_raw_sample) { + case 9: + BIT_DEPTH_FUNCS(9) + break; + case 10: + BIT_DEPTH_FUNCS(10) + break; + default: + av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample); + BIT_DEPTH_FUNCS(8) + break; + } + } + + if (HAVE_MMX) dsputil_init_mmx (c, avctx); if (ARCH_ARM) dsputil_init_arm (c, avctx); if (CONFIG_MLIB) dsputil_init_mlib (c, avctx); diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 9b4aef758a..78d21527a5 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -53,19 +53,24 @@ void ff_fdct_mmx(DCTELEM *block); void ff_fdct_mmx2(DCTELEM *block); void ff_fdct_sse2(DCTELEM *block); -void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride); -void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride); -void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride); -void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride); -void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block); -void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block); -void ff_h264_idct_add16_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); -void ff_h264_idct_add16intra_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); -void ff_h264_idct8_add4_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); -void ff_h264_idct_add8_c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); - -void ff_h264_chroma_dc_dequant_idct_c(DCTELEM *block, int qmul); -void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul); +#define H264_IDCT(depth) \ +void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ +void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ +void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ +void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ +void ff_h264_lowres_idct_add_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\ +void ff_h264_lowres_idct_put_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\ +void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ +void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ +void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ +void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ +void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(DCTELEM *output, DCTELEM *input, int qmul);\ +void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul); + +H264_IDCT( 8) +H264_IDCT( 9) +H264_IDCT(10) + void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp); void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); @@ -82,10 +87,20 @@ extern const uint8_t ff_zigzag248_direct[64]; extern uint32_t ff_squareTbl[512]; extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP]; -void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride); -void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride); -void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride); -void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride); +#define PUTAVG_PIXELS(depth)\ +void ff_put_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\ +void ff_avg_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\ +void ff_put_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\ +void ff_avg_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride); + +PUTAVG_PIXELS( 8) +PUTAVG_PIXELS( 9) +PUTAVG_PIXELS(10) + +#define ff_put_pixels8x8_c ff_put_pixels8x8_8_c +#define ff_avg_pixels8x8_c ff_avg_pixels8x8_8_c +#define ff_put_pixels16x16_c ff_put_pixels16x16_8_c +#define ff_avg_pixels16x16_c ff_avg_pixels16x16_8_c /* VP3 DSP functions */ void ff_vp3_idct_c(DCTELEM *block/* align 16*/); @@ -187,10 +202,17 @@ typedef struct ScanTable{ void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable); -void ff_emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize, - int block_w, int block_h, +#define EMULATED_EDGE(depth) \ +void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, int linesize,\ + int block_w, int block_h,\ int src_x, int src_y, int w, int h); +EMULATED_EDGE(8) +EMULATED_EDGE(9) +EMULATED_EDGE(10) + +#define ff_emulated_edge_mc ff_emulated_edge_mc_8 + void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize); void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize); void ff_put_signed_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize); @@ -562,6 +584,7 @@ void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scant void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type); #define BYTE_VEC32(c) ((c)*0x01010101UL) +#define BYTE_VEC64(c) ((c)*0x0001000100010001UL) static inline uint32_t rnd_avg32(uint32_t a, uint32_t b) { @@ -573,6 +596,16 @@ static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b) return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); } +static inline uint64_t rnd_avg64(uint64_t a, uint64_t b) +{ + return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1); +} + +static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b) +{ + return (a & b) + (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1); +} + static inline int get_penalty_factor(int lambda, int lambda2, int type){ switch(type&0xFF){ default: diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index f69c4671f9..8ca6d3e414 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -27,25 +27,55 @@ * DSP utils */ -#include "dsputil.h" +#include "high_bit_depth.h" -#define BIT_DEPTH 8 +static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) +{ + int i; + for(i=0; ilist_counts = src->list_counts; dst->s.obmc_scratchpad = NULL; - ff_h264_pred_init(&dst->hpc, src->s.codec_id); + ff_h264_pred_init(&dst->hpc, src->s.codec_id, src->sps.bit_depth_luma); } /** @@ -811,8 +811,8 @@ static av_cold void common_init(H264Context *h){ s->height = s->avctx->height; s->codec_id= s->avctx->codec->id; - ff_h264dsp_init(&h->h264dsp); - ff_h264_pred_init(&h->hpc, s->codec_id); + ff_h264dsp_init(&h->h264dsp, 8); + ff_h264_pred_init(&h->hpc, s->codec_id, 8); h->dequant_coeff_pps= -1; s->unrestricted_mv=1; @@ -895,7 +895,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){ ff_h264_decode_init_vlc(); h->pixel_shift = 0; - h->sps.bit_depth_luma = 8; + h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8; h->thread_context[0] = h; h->outputed_poc = INT_MIN; @@ -2998,6 +2998,20 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ if(avctx->has_b_frames < 2) avctx->has_b_frames= !s->low_delay; + + if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) { + if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) { + avctx->bits_per_raw_sample = h->sps.bit_depth_luma; + h->pixel_shift = h->sps.bit_depth_luma > 8; + + ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma); + ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma); + dsputil_init(&s->dsp, s->avctx); + } else { + av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma); + return -1; + } + } break; case NAL_PPS: init_get_bits(&s->gb, ptr, bit_length); diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index 22b2086243..64f4856189 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -29,57 +29,83 @@ #include "avcodec.h" #include "h264dsp.h" +#define BIT_DEPTH 8 #include "h264dsp_template.c" +#undef BIT_DEPTH -void ff_h264dsp_init(H264DSPContext *c) -{ - c->h264_idct_add= ff_h264_idct_add_c; - c->h264_idct8_add= ff_h264_idct8_add_c; - c->h264_idct_dc_add= ff_h264_idct_dc_add_c; - c->h264_idct8_dc_add= ff_h264_idct8_dc_add_c; - c->h264_idct_add16 = ff_h264_idct_add16_c; - c->h264_idct8_add4 = ff_h264_idct8_add4_c; - c->h264_idct_add8 = ff_h264_idct_add8_c; - c->h264_idct_add16intra= ff_h264_idct_add16intra_c; - c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_c; - c->h264_chroma_dc_dequant_idct= ff_h264_chroma_dc_dequant_idct_c; +#define BIT_DEPTH 9 +#include "h264dsp_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 10 +#include "h264dsp_template.c" +#undef BIT_DEPTH - c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c; - c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c; - c->weight_h264_pixels_tab[2]= weight_h264_pixels8x16_c; - c->weight_h264_pixels_tab[3]= weight_h264_pixels8x8_c; - c->weight_h264_pixels_tab[4]= weight_h264_pixels8x4_c; - c->weight_h264_pixels_tab[5]= weight_h264_pixels4x8_c; - c->weight_h264_pixels_tab[6]= weight_h264_pixels4x4_c; - c->weight_h264_pixels_tab[7]= weight_h264_pixels4x2_c; - c->weight_h264_pixels_tab[8]= weight_h264_pixels2x4_c; - c->weight_h264_pixels_tab[9]= weight_h264_pixels2x2_c; - c->biweight_h264_pixels_tab[0]= biweight_h264_pixels16x16_c; - c->biweight_h264_pixels_tab[1]= biweight_h264_pixels16x8_c; - c->biweight_h264_pixels_tab[2]= biweight_h264_pixels8x16_c; - c->biweight_h264_pixels_tab[3]= biweight_h264_pixels8x8_c; - c->biweight_h264_pixels_tab[4]= biweight_h264_pixels8x4_c; - c->biweight_h264_pixels_tab[5]= biweight_h264_pixels4x8_c; - c->biweight_h264_pixels_tab[6]= biweight_h264_pixels4x4_c; - c->biweight_h264_pixels_tab[7]= biweight_h264_pixels4x2_c; - c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c; - c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c; +void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) +{ +#undef FUNC +#define FUNC(a, depth) a ## _ ## depth ## _c - c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c; - c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c; - c->h264_h_loop_filter_luma_mbaff= h264_h_loop_filter_luma_mbaff_c; - c->h264_v_loop_filter_luma_intra= h264_v_loop_filter_luma_intra_c; - c->h264_h_loop_filter_luma_intra= h264_h_loop_filter_luma_intra_c; - c->h264_h_loop_filter_luma_mbaff_intra= h264_h_loop_filter_luma_mbaff_intra_c; - c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c; - c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c; - c->h264_h_loop_filter_chroma_mbaff= h264_h_loop_filter_chroma_mbaff_c; - c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_c; - c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c; - c->h264_h_loop_filter_chroma_mbaff_intra= h264_h_loop_filter_chroma_mbaff_intra_c; +#define H264_DSP(depth) \ + c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\ + c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\ + c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\ + c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\ + c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\ + c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\ + c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\ + c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\ + c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\ + c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\ +\ + c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\ + c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels16x8, depth);\ + c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels8x16, depth);\ + c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels8x8, depth);\ + c->weight_h264_pixels_tab[4]= FUNC(weight_h264_pixels8x4, depth);\ + c->weight_h264_pixels_tab[5]= FUNC(weight_h264_pixels4x8, depth);\ + c->weight_h264_pixels_tab[6]= FUNC(weight_h264_pixels4x4, depth);\ + c->weight_h264_pixels_tab[7]= FUNC(weight_h264_pixels4x2, depth);\ + c->weight_h264_pixels_tab[8]= FUNC(weight_h264_pixels2x4, depth);\ + c->weight_h264_pixels_tab[9]= FUNC(weight_h264_pixels2x2, depth);\ + c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16x16, depth);\ + c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels16x8, depth);\ + c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels8x16, depth);\ + c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels8x8, depth);\ + c->biweight_h264_pixels_tab[4]= FUNC(biweight_h264_pixels8x4, depth);\ + c->biweight_h264_pixels_tab[5]= FUNC(biweight_h264_pixels4x8, depth);\ + c->biweight_h264_pixels_tab[6]= FUNC(biweight_h264_pixels4x4, depth);\ + c->biweight_h264_pixels_tab[7]= FUNC(biweight_h264_pixels4x2, depth);\ + c->biweight_h264_pixels_tab[8]= FUNC(biweight_h264_pixels2x4, depth);\ + c->biweight_h264_pixels_tab[9]= FUNC(biweight_h264_pixels2x2, depth);\ +\ + c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\ + c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\ + c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\ + c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\ + c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\ + c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\ + c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\ + c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\ + c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\ + c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\ + c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\ + c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\ c->h264_loop_filter_strength= NULL; - if (ARCH_ARM) ff_h264dsp_init_arm(c); - if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c); - if (HAVE_MMX) ff_h264dsp_init_x86(c); + switch (bit_depth) { + case 9: + H264_DSP(9); + break; + case 10: + H264_DSP(10); + break; + default: + H264_DSP(8); + break; + } + + if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth); + if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth); + if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth); } diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h index 7eb50be342..87a1dd9722 100644 --- a/libavcodec/h264dsp.h +++ b/libavcodec/h264dsp.h @@ -75,9 +75,9 @@ typedef struct H264DSPContext{ void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); }H264DSPContext; -void ff_h264dsp_init(H264DSPContext *c); -void ff_h264dsp_init_arm(H264DSPContext *c); -void ff_h264dsp_init_ppc(H264DSPContext *c); -void ff_h264dsp_init_x86(H264DSPContext *c); +void ff_h264dsp_init(H264DSPContext *c, const int bit_depth); +void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth); +void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth); +void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth); #endif /* AVCODEC_H264DSP_H */ diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c index 7190f4d9ca..91162ea900 100644 --- a/libavcodec/h264dsp_template.c +++ b/libavcodec/h264dsp_template.c @@ -25,10 +25,7 @@ * @author Michael Niedermayer */ -#define BIT_DEPTH 8 -#define pixel uint8_t -#define av_clip_pixel av_clip_uint8 -#define FUNCC(a) a ## _c +#include "high_bit_depth.h" #define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom ) #define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1)) diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c index d79777571a..1634a00835 100644 --- a/libavcodec/h264idct.c +++ b/libavcodec/h264idct.c @@ -25,4 +25,14 @@ * @author Michael Niedermayer */ +#define BIT_DEPTH 8 #include "h264idct_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 9 +#include "h264idct_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 10 +#include "h264idct_template.c" +#undef BIT_DEPTH diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index ed1f18c9b6..39c9a1c9eb 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -25,7 +25,7 @@ * @author Michael Niedermayer */ -#include "dsputil.h" +#include "high_bit_depth.h" #ifndef AVCODEC_H264IDCT_INTERNAL_H #define AVCODEC_H264IDCT_INTERNAL_H @@ -42,12 +42,6 @@ static const uint8_t scan8[16 + 2*4]={ }; #endif -#define pixel uint8_t -#define dctcoef DCTELEM -#define INIT_CLIP uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; -#define CLIP(a) cm[a] -#define FUNCC(a) a ## _c - static av_always_inline void FUNCC(idct_internal)(uint8_t *_dst, DCTELEM *_block, int stride, int block_stride, int shift, int add){ int i; INIT_CLIP diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c index 616a7a93b1..b3701ef3b8 100644 --- a/libavcodec/h264pred.c +++ b/libavcodec/h264pred.c @@ -26,7 +26,18 @@ */ #include "h264pred.h" + +#define BIT_DEPTH 8 +#include "h264pred_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 9 #include "h264pred_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 10 +#include "h264pred_template.c" +#undef BIT_DEPTH static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ const int lt= src[-1-1*stride]; @@ -245,11 +256,11 @@ static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ } static void pred16x16_plane_svq3_c(uint8_t *src, int stride){ - pred16x16_plane_compat_c(src, stride, 1, 0); + pred16x16_plane_compat_8_c(src, stride, 1, 0); } static void pred16x16_plane_rv40_c(uint8_t *src, int stride){ - pred16x16_plane_compat_c(src, stride, 0, 1); + pred16x16_plane_compat_8_c(src, stride, 0, 1); } static void pred16x16_tm_vp8_c(uint8_t *src, int stride){ @@ -352,130 +363,149 @@ static void pred8x8_tm_vp8_c(uint8_t *src, int stride){ /** * Set the intra prediction function pointers. */ -void ff_h264_pred_init(H264PredContext *h, int codec_id){ +void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ // MpegEncContext * const s = &h->s; - if(codec_id != CODEC_ID_RV40){ - if(codec_id == CODEC_ID_VP8) { - h->pred4x4[VERT_PRED ]= pred4x4_vertical_vp8_c; - h->pred4x4[HOR_PRED ]= pred4x4_horizontal_vp8_c; - } else { - h->pred4x4[VERT_PRED ]= pred4x4_vertical_c; - h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c; - } - h->pred4x4[DC_PRED ]= pred4x4_dc_c; - if(codec_id == CODEC_ID_SVQ3) - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_svq3_c; - else - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_c; - h->pred4x4[DIAG_DOWN_RIGHT_PRED]= pred4x4_down_right_c; - h->pred4x4[VERT_RIGHT_PRED ]= pred4x4_vertical_right_c; - h->pred4x4[HOR_DOWN_PRED ]= pred4x4_horizontal_down_c; - if (codec_id == CODEC_ID_VP8) { - h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_vp8_c; - } else - h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_c; - h->pred4x4[HOR_UP_PRED ]= pred4x4_horizontal_up_c; - if(codec_id != CODEC_ID_VP8) { - h->pred4x4[LEFT_DC_PRED ]= pred4x4_left_dc_c; - h->pred4x4[TOP_DC_PRED ]= pred4x4_top_dc_c; - h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c; - } else { - h->pred4x4[TM_VP8_PRED ]= pred4x4_tm_vp8_c; - h->pred4x4[DC_127_PRED ]= pred4x4_127_dc_c; - h->pred4x4[DC_129_PRED ]= pred4x4_129_dc_c; - h->pred4x4[VERT_VP8_PRED ]= pred4x4_vertical_c; - h->pred4x4[HOR_VP8_PRED ]= pred4x4_horizontal_c; - } - }else{ - h->pred4x4[VERT_PRED ]= pred4x4_vertical_c; - h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c; - h->pred4x4[DC_PRED ]= pred4x4_dc_c; - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_rv40_c; - h->pred4x4[DIAG_DOWN_RIGHT_PRED]= pred4x4_down_right_c; - h->pred4x4[VERT_RIGHT_PRED ]= pred4x4_vertical_right_c; - h->pred4x4[HOR_DOWN_PRED ]= pred4x4_horizontal_down_c; - h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_rv40_c; - h->pred4x4[HOR_UP_PRED ]= pred4x4_horizontal_up_rv40_c; - h->pred4x4[LEFT_DC_PRED ]= pred4x4_left_dc_c; - h->pred4x4[TOP_DC_PRED ]= pred4x4_top_dc_c; - h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c; - h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= pred4x4_down_left_rv40_nodown_c; - h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= pred4x4_horizontal_up_rv40_nodown_c; - h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= pred4x4_vertical_left_rv40_nodown_c; +#undef FUNC +#undef FUNCC +#define FUNC(a, depth) a ## _ ## depth +#define FUNCC(a, depth) a ## _ ## depth ## _c +#define FUNCD(a) a ## _c + +#define H264_PRED(depth) \ + if(codec_id != CODEC_ID_RV40){\ + if(codec_id == CODEC_ID_VP8) {\ + h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\ + h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\ + } else {\ + h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\ + h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\ + }\ + h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\ + if(codec_id == CODEC_ID_SVQ3)\ + h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_svq3);\ + else\ + h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\ + h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\ + h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\ + h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\ + if (codec_id == CODEC_ID_VP8) {\ + h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_vp8);\ + } else\ + h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\ + h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up , depth);\ + if(codec_id != CODEC_ID_VP8) {\ + h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\ + h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\ + h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\ + } else {\ + h->pred4x4[TM_VP8_PRED ]= FUNCD(pred4x4_tm_vp8);\ + h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\ + h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\ + h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\ + h->pred4x4[HOR_VP8_PRED ]= FUNCC(pred4x4_horizontal , depth);\ + }\ + }else{\ + h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\ + h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\ + h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\ + h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_rv40);\ + h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\ + h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\ + h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\ + h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_rv40);\ + h->pred4x4[HOR_UP_PRED ]= FUNCD(pred4x4_horizontal_up_rv40);\ + h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\ + h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\ + h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\ + h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\ + h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\ + h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\ + }\ +\ + h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\ + h->pred8x8l[HOR_PRED ]= FUNCC(pred8x8l_horizontal , depth);\ + h->pred8x8l[DC_PRED ]= FUNCC(pred8x8l_dc , depth);\ + h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred8x8l_down_left , depth);\ + h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred8x8l_down_right , depth);\ + h->pred8x8l[VERT_RIGHT_PRED ]= FUNCC(pred8x8l_vertical_right , depth);\ + h->pred8x8l[HOR_DOWN_PRED ]= FUNCC(pred8x8l_horizontal_down , depth);\ + h->pred8x8l[VERT_LEFT_PRED ]= FUNCC(pred8x8l_vertical_left , depth);\ + h->pred8x8l[HOR_UP_PRED ]= FUNCC(pred8x8l_horizontal_up , depth);\ + h->pred8x8l[LEFT_DC_PRED ]= FUNCC(pred8x8l_left_dc , depth);\ + h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\ + h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\ +\ + h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\ + h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\ + if (codec_id != CODEC_ID_VP8) {\ + h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\ + } else\ + h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\ + if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\ + h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ + h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ + h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\ + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\ + }else{\ + h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ + h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\ + h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\ + if (codec_id == CODEC_ID_VP8) {\ + h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\ + h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\ + }\ + }\ + h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\ +\ + h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\ + h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\ + h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\ + switch(codec_id){\ + case CODEC_ID_SVQ3:\ + h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_svq3);\ + break;\ + case CODEC_ID_RV40:\ + h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\ + break;\ + case CODEC_ID_VP8:\ + h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\ + h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\ + h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\ + break;\ + default:\ + h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane , depth);\ + break;\ + }\ + h->pred16x16[LEFT_DC_PRED8x8]= FUNCC(pred16x16_left_dc , depth);\ + h->pred16x16[TOP_DC_PRED8x8 ]= FUNCC(pred16x16_top_dc , depth);\ + h->pred16x16[DC_128_PRED8x8 ]= FUNCC(pred16x16_128_dc , depth);\ +\ + /* special lossless h/v prediction for h264 */ \ + h->pred4x4_add [VERT_PRED ]= FUNCC(pred4x4_vertical_add , depth);\ + h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\ + h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\ + h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\ + h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\ + h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\ + h->pred16x16_add[VERT_PRED8x8]= FUNCC(pred16x16_vertical_add , depth);\ + h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\ + + switch (bit_depth) { + case 9: + H264_PRED(9) + break; + case 10: + H264_PRED(10) + break; + default: + H264_PRED(8) + break; } - h->pred8x8l[VERT_PRED ]= pred8x8l_vertical_c; - h->pred8x8l[HOR_PRED ]= pred8x8l_horizontal_c; - h->pred8x8l[DC_PRED ]= pred8x8l_dc_c; - h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= pred8x8l_down_left_c; - h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= pred8x8l_down_right_c; - h->pred8x8l[VERT_RIGHT_PRED ]= pred8x8l_vertical_right_c; - h->pred8x8l[HOR_DOWN_PRED ]= pred8x8l_horizontal_down_c; - h->pred8x8l[VERT_LEFT_PRED ]= pred8x8l_vertical_left_c; - h->pred8x8l[HOR_UP_PRED ]= pred8x8l_horizontal_up_c; - h->pred8x8l[LEFT_DC_PRED ]= pred8x8l_left_dc_c; - h->pred8x8l[TOP_DC_PRED ]= pred8x8l_top_dc_c; - h->pred8x8l[DC_128_PRED ]= pred8x8l_128_dc_c; - - h->pred8x8[VERT_PRED8x8 ]= pred8x8_vertical_c; - h->pred8x8[HOR_PRED8x8 ]= pred8x8_horizontal_c; - if (codec_id != CODEC_ID_VP8) { - h->pred8x8[PLANE_PRED8x8]= pred8x8_plane_c; - } else - h->pred8x8[PLANE_PRED8x8]= pred8x8_tm_vp8_c; - if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){ - h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_c; - h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_c; - h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_c; - h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= pred8x8_mad_cow_dc_l0t; - h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= pred8x8_mad_cow_dc_0lt; - h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= pred8x8_mad_cow_dc_l00; - h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= pred8x8_mad_cow_dc_0l0; - }else{ - h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_rv40_c; - h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_rv40_c; - h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_rv40_c; - if (codec_id == CODEC_ID_VP8) { - h->pred8x8[DC_127_PRED8x8]= pred8x8_127_dc_c; - h->pred8x8[DC_129_PRED8x8]= pred8x8_129_dc_c; - } - } - h->pred8x8[DC_128_PRED8x8 ]= pred8x8_128_dc_c; - - h->pred16x16[DC_PRED8x8 ]= pred16x16_dc_c; - h->pred16x16[VERT_PRED8x8 ]= pred16x16_vertical_c; - h->pred16x16[HOR_PRED8x8 ]= pred16x16_horizontal_c; - switch(codec_id){ - case CODEC_ID_SVQ3: - h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_svq3_c; - break; - case CODEC_ID_RV40: - h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_rv40_c; - break; - case CODEC_ID_VP8: - h->pred16x16[PLANE_PRED8x8 ]= pred16x16_tm_vp8_c; - h->pred16x16[DC_127_PRED8x8]= pred16x16_127_dc_c; - h->pred16x16[DC_129_PRED8x8]= pred16x16_129_dc_c; - break; - default: - h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c; - break; - } - h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c; - h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c; - h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c; - - //special lossless h/v prediction for h264 - h->pred4x4_add [VERT_PRED ]= pred4x4_vertical_add_c; - h->pred4x4_add [ HOR_PRED ]= pred4x4_horizontal_add_c; - h->pred8x8l_add [VERT_PRED ]= pred8x8l_vertical_add_c; - h->pred8x8l_add [ HOR_PRED ]= pred8x8l_horizontal_add_c; - h->pred8x8_add [VERT_PRED8x8]= pred8x8_vertical_add_c; - h->pred8x8_add [ HOR_PRED8x8]= pred8x8_horizontal_add_c; - h->pred16x16_add[VERT_PRED8x8]= pred16x16_vertical_add_c; - h->pred16x16_add[ HOR_PRED8x8]= pred16x16_horizontal_add_c; - - if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id); - if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id); + if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth); + if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth); } diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h index db3f5809f8..34b1e90bbc 100644 --- a/libavcodec/h264pred.h +++ b/libavcodec/h264pred.h @@ -101,8 +101,8 @@ typedef struct H264PredContext{ void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); }H264PredContext; -void ff_h264_pred_init(H264PredContext *h, int codec_id); -void ff_h264_pred_init_arm(H264PredContext *h, int codec_id); -void ff_h264_pred_init_x86(H264PredContext *h, int codec_id); +void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth); +void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth); +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth); #endif /* AVCODEC_H264PRED_H */ diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c index 4bd26e2892..066e837cdf 100644 --- a/libavcodec/h264pred_template.c +++ b/libavcodec/h264pred_template.c @@ -26,21 +26,7 @@ */ #include "mathops.h" -#include "dsputil.h" - -#define BIT_DEPTH 8 - -#define pixel uint8_t -#define pixel4 uint32_t -#define dctcoef DCTELEM - -#define INIT_CLIP uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; -#define CLIP(a) cm[a] -#define FUNC(a) a -#define FUNCC(a) a ## _c -#define PIXEL_SPLAT_X4(x) ((x)*0x01010101U) -#define AV_WN4P AV_WN32 -#define AV_WN4PA AV_WN32A +#include "high_bit_depth.h" static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; diff --git a/libavcodec/high_bit_depth.h b/libavcodec/high_bit_depth.h new file mode 100644 index 0000000000..6f2b6a74f4 --- /dev/null +++ b/libavcodec/high_bit_depth.h @@ -0,0 +1,85 @@ +#include "dsputil.h" + +#ifndef BIT_DEPTH +#define BIT_DEPTH 8 +#endif + +#ifdef AVCODEC_H264_HIGH_DEPTH_H +# undef pixel +# undef pixel2 +# undef pixel4 +# undef dctcoef +# undef INIT_CLIP +# undef no_rnd_avg_pixel4 +# undef rnd_avg_pixel4 +# undef AV_RN2P +# undef AV_RN4P +# undef AV_WN2P +# undef AV_WN4P +# undef AV_WN4PA +# undef CLIP +# undef FUNC +# undef FUNCC +# undef av_clip_pixel +# undef PIXEL_SPLAT_X4 +#else +# define AVCODEC_H264_HIGH_DEPTH_H +# define CLIP_PIXEL(depth)\ + static inline uint16_t av_clip_pixel_ ## depth (int p)\ + {\ + const int pixel_max = (1 << depth)-1;\ + return (p & ~pixel_max) ? (-p)>>31 & pixel_max : p;\ + } + +CLIP_PIXEL( 9) +CLIP_PIXEL(10) +#endif + +#if BIT_DEPTH > 8 +# define pixel uint16_t +# define pixel2 uint32_t +# define pixel4 uint64_t +# define dctcoef int32_t + +# define INIT_CLIP +# define no_rnd_avg_pixel4 no_rnd_avg64 +# define rnd_avg_pixel4 rnd_avg64 +# define AV_RN2P AV_RN32 +# define AV_RN4P AV_RN64 +# define AV_WN2P AV_WN32 +# define AV_WN4P AV_WN64 +# define AV_WN4PA AV_WN64A +# define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL) +#else +# define pixel uint8_t +# define pixel2 uint16_t +# define pixel4 uint32_t +# define dctcoef int16_t + +# define INIT_CLIP uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; +# define no_rnd_avg_pixel4 no_rnd_avg32 +# define rnd_avg_pixel4 rnd_avg32 +# define AV_RN2P AV_RN16 +# define AV_RN4P AV_RN32 +# define AV_WN2P AV_WN16 +# define AV_WN4P AV_WN32 +# define AV_WN4PA AV_WN32A +# define PIXEL_SPLAT_X4(x) ((x)*0x01010101U) +#endif + +#if BIT_DEPTH == 8 +# define av_clip_pixel(a) av_clip_uint8(a) +# define CLIP(a) cm[a] +# define FUNC(a) a ## _8 +# define FUNCC(a) a ## _8_c +#elif BIT_DEPTH == 9 +# define av_clip_pixel(a) av_clip_pixel_9(a) +# define CLIP(a) av_clip_pixel_9(a) +# define FUNC(a) a ## _9 +# define FUNCC(a) a ## _9_c +#elif BIT_DEPTH == 10 +# define av_clip_pixel(a) av_clip_pixel_10(a) +# define CLIP(a) av_clip_pixel_10(a) +# define FUNC(a) a ## _10 +# define FUNCC(a) a ## _10_c +#endif diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c index 9e49c91ddf..c0f2c036c6 100644 --- a/libavcodec/mlib/dsputil_mlib.c +++ b/libavcodec/mlib/dsputil_mlib.c @@ -421,10 +421,13 @@ static void ff_fdct_mlib(DCTELEM *data) 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->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; @@ -445,6 +448,7 @@ void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx) c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mlib; c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mlib; + } c->bswap_buf = bswap_buf_mlib; } diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c index 9111d036a5..adce61b277 100644 --- a/libavcodec/ppc/dsputil_altivec.c +++ b/libavcodec/ppc/dsputil_altivec.c @@ -1384,6 +1384,8 @@ static void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int l void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + c->pix_abs[0][1] = sad16_x2_altivec; c->pix_abs[0][2] = sad16_y2_altivec; c->pix_abs[0][3] = sad16_xy2_altivec; @@ -1397,8 +1399,10 @@ void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) 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->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; @@ -1409,6 +1413,7 @@ void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_altivec; c->put_pixels_tab[0][3] = put_pixels16_xy2_altivec; c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_altivec; + } c->hadamard8_diff[0] = hadamard8_diff16_altivec; c->hadamard8_diff[1] = hadamard8_diff8x8_altivec; diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index c52ea61805..5f131f3196 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -153,8 +153,11 @@ static void prefetch_ppc(void *mem, int stride, int h) void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + // Common optimizations whether AltiVec is available or not c->prefetch = prefetch_ppc; + if (!high_bit_depth) { switch (check_dcbzl_effect()) { case 32: c->clear_blocks = clear_blocks_dcbz32_ppc; @@ -165,6 +168,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) default: break; } + } #if HAVE_ALTIVEC if(CONFIG_H264_DECODER) dsputil_h264_init_ppc(c, avctx); diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c index 02699beef4..fae0674720 100644 --- a/libavcodec/ppc/h264_altivec.c +++ b/libavcodec/ppc/h264_altivec.c @@ -965,8 +965,10 @@ H264_WEIGHT( 8, 8) H264_WEIGHT( 8, 4) void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { + if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec; c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec; @@ -992,11 +994,13 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { dspfunc(avg_h264_qpel, 0, 16); #undef dspfunc } + } } -void ff_h264dsp_init_ppc(H264DSPContext *c) +void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth) { if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { + if (bit_depth == 8) { c->h264_idct_add = ff_h264_idct_add_altivec; c->h264_idct_add8 = ff_h264_idct_add8_altivec; c->h264_idct_add16 = ff_h264_idct_add16_altivec; @@ -1019,4 +1023,5 @@ void ff_h264dsp_init_ppc(H264DSPContext *c) c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels8x8_altivec; c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels8x4_altivec; } + } } diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c index b6096b3b4a..f4503a9030 100644 --- a/libavcodec/ps2/dsputil_mmi.c +++ b/libavcodec/ps2/dsputil_mmi.c @@ -142,7 +142,9 @@ static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_siz void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx) { const int idct_algo= avctx->idct_algo; + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + if (!high_bit_depth) { c->clear_blocks = clear_blocks_mmi; c->put_pixels_tab[1][0] = put_pixels8_mmi; @@ -150,6 +152,7 @@ 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; diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index f3ab979976..b5d314cf0f 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1384,7 +1384,7 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) if (MPV_common_init(s) < 0) return -1; - ff_h264_pred_init(&r->h, CODEC_ID_RV40); + ff_h264_pred_init(&r->h, CODEC_ID_RV40, 8); r->intra_types_stride = 4*s->mb_stride + 4; r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); diff --git a/libavcodec/sh4/dsputil_align.c b/libavcodec/sh4/dsputil_align.c index 7a8d60d73e..db40ece670 100644 --- a/libavcodec/sh4/dsputil_align.c +++ b/libavcodec/sh4/dsputil_align.c @@ -333,6 +333,9 @@ DEFFUNC(avg,no_rnd,xy,16,OP_XY,PACK) void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) { + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; + + if (!high_bit_depth) { c->put_pixels_tab[0][0] = put_rnd_pixels16_o; c->put_pixels_tab[0][1] = put_rnd_pixels16_x; c->put_pixels_tab[0][2] = put_rnd_pixels16_y; @@ -368,6 +371,7 @@ void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x; c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y; c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy; + } #ifdef QPEL @@ -401,20 +405,24 @@ void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) dspfunc(avg_qpel, 1, 8); /* dspfunc(avg_no_rnd_qpel, 1, 8); */ + if (!high_bit_depth) { dspfunc(put_h264_qpel, 0, 16); dspfunc(put_h264_qpel, 1, 8); dspfunc(put_h264_qpel, 2, 4); dspfunc(avg_h264_qpel, 0, 16); dspfunc(avg_h264_qpel, 1, 8); dspfunc(avg_h264_qpel, 2, 4); + } #undef dspfunc + if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4; c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4; c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_sh4; c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_sh4; c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_sh4; c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_sh4; + } c->put_mspel_pixels_tab[0]= put_mspel8_mc00_sh4; c->put_mspel_pixels_tab[1]= put_mspel8_mc10_sh4; diff --git a/libavcodec/sh4/dsputil_sh4.c b/libavcodec/sh4/dsputil_sh4.c index 0c724c346d..9ea48ad4a1 100644 --- a/libavcodec/sh4/dsputil_sh4.c +++ b/libavcodec/sh4/dsputil_sh4.c @@ -92,8 +92,10 @@ static void idct_add(uint8_t *dest, int line_size, DCTELEM *block) void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx) { const int idct_algo= avctx->idct_algo; + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; dsputil_init_align(c,avctx); + if (!high_bit_depth) c->clear_blocks = clear_blocks_sh4; if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){ c->idct_put = idct_put; diff --git a/libavcodec/sparc/dsputil_vis.c b/libavcodec/sparc/dsputil_vis.c index baf555b7f5..ab9258b2b9 100644 --- a/libavcodec/sparc/dsputil_vis.c +++ b/libavcodec/sparc/dsputil_vis.c @@ -3953,6 +3953,7 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) { /* VIS-specific optimizations */ int accel = vis_level (); + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; if (accel & ACCEL_SPARC_VIS) { if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){ @@ -3962,6 +3963,7 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; } + if (!high_bit_depth) { c->put_pixels_tab[0][0] = MC_put_o_16_vis; c->put_pixels_tab[0][1] = MC_put_x_16_vis; c->put_pixels_tab[0][2] = MC_put_y_16_vis; @@ -4001,5 +4003,6 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) c->avg_no_rnd_pixels_tab[1][1] = MC_avg_no_round_x_8_vis; c->avg_no_rnd_pixels_tab[1][2] = MC_avg_no_round_y_8_vis; c->avg_no_rnd_pixels_tab[1][3] = MC_avg_no_round_xy_8_vis; + } } } diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index ea0e911d0b..dc7eb2121a 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -1698,7 +1698,7 @@ static av_cold int vp8_decode_init(AVCodecContext *avctx) avctx->pix_fmt = PIX_FMT_YUV420P; dsputil_init(&s->dsp, avctx); - ff_h264_pred_init(&s->hpc, CODEC_ID_VP8); + ff_h264_pred_init(&s->hpc, CODEC_ID_VP8, 8); ff_vp8dsp_init(&s->vp8dsp); return 0; diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index f98e6ae0fa..a0cb11aa40 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2418,6 +2418,7 @@ float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); + const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8; if (avctx->dsp_mask) { if (avctx->dsp_mask & AV_CPU_FLAG_FORCE) @@ -2499,6 +2500,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->put_pixels_clamped = ff_put_pixels_clamped_mmx; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx; c->add_pixels_clamped = ff_add_pixels_clamped_mmx; + if (!high_bit_depth) { c->clear_block = clear_block_mmx; c->clear_blocks = clear_blocks_mmx; if ((mm_flags & AV_CPU_FLAG_SSE) && @@ -2507,6 +2509,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->clear_block = clear_block_sse; c->clear_blocks = clear_blocks_sse; } + } #define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \ c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \ @@ -2514,6 +2517,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \ c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU + if (!high_bit_depth) { SET_HPEL_FUNCS(put, 0, 16, mmx); SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx); SET_HPEL_FUNCS(avg, 0, 16, mmx); @@ -2522,17 +2526,20 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx); SET_HPEL_FUNCS(avg, 1, 8, mmx); SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx); + } #if ARCH_X86_32 || !HAVE_YASM c->gmc= gmc_mmx; #endif #if ARCH_X86_32 && HAVE_YASM + if (!high_bit_depth) c->emulated_edge_mc = emulated_edge_mc_mmx; #endif c->add_bytes= add_bytes_mmx; c->add_bytes_l2= add_bytes_l2_mmx; + if (!high_bit_depth) c->draw_edges = draw_edges_mmx; if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { @@ -2541,8 +2548,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) } #if HAVE_YASM + if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_mmx_rnd; c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_mmx; + } c->put_rv40_chroma_pixels_tab[0]= ff_put_rv40_chroma_mc8_mmx; c->put_rv40_chroma_pixels_tab[1]= ff_put_rv40_chroma_mc4_mmx; @@ -2551,6 +2560,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) if (mm_flags & AV_CPU_FLAG_MMX2) { c->prefetch = prefetch_mmx2; + if (!high_bit_depth) { c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2; c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2; @@ -2564,14 +2574,17 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->avg_pixels_tab[1][0] = avg_pixels8_mmx2; c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2; c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2; + } if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ + if (!high_bit_depth) { c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2; c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2; c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2; c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2; c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2; c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2; + } if (CONFIG_VP3_DECODER && HAVE_YASM) { c->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx2; @@ -2613,12 +2626,14 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2); + if (!high_bit_depth) { SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2); SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2); + } SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2); @@ -2629,10 +2644,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2; c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_mmx2; + if (!high_bit_depth) { c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_mmx2_rnd; c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_mmx2; c->avg_h264_chroma_pixels_tab[2]= ff_avg_h264_chroma_mc2_mmx2; c->put_h264_chroma_pixels_tab[2]= ff_put_h264_chroma_mc2_mmx2; + } c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_mmx2; #endif @@ -2645,6 +2662,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) } else if (mm_flags & AV_CPU_FLAG_3DNOW) { c->prefetch = prefetch_3dnow; + if (!high_bit_depth) { c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow; c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow; @@ -2667,6 +2685,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow; c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow; } + } if (CONFIG_VP3_DECODER && (avctx->codec_id == CODEC_ID_VP3 || avctx->codec_id == CODEC_ID_THEORA)) { @@ -2681,12 +2700,14 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow); + if (!high_bit_depth) { SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow); SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow); + } SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow); @@ -2694,8 +2715,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow); #if HAVE_YASM + if (!high_bit_depth) { c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_3dnow_rnd; c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_3dnow; + } c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_3dnow; c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_3dnow; @@ -2710,12 +2733,15 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU; if((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW)){ // these functions are slower than mmx on AMD, but faster on Intel + if (!high_bit_depth) { c->put_pixels_tab[0][0] = put_pixels16_sse2; c->put_no_rnd_pixels_tab[0][0] = put_pixels16_sse2; c->avg_pixels_tab[0][0] = avg_pixels16_sse2; H264_QPEL_FUNCS(0, 0, sse2); + } } if(mm_flags & AV_CPU_FLAG_SSE2){ + if (!high_bit_depth) { H264_QPEL_FUNCS(0, 1, sse2); H264_QPEL_FUNCS(0, 2, sse2); H264_QPEL_FUNCS(0, 3, sse2); @@ -2728,9 +2754,11 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 1, sse2); H264_QPEL_FUNCS(3, 2, sse2); H264_QPEL_FUNCS(3, 3, sse2); + } } #if HAVE_SSSE3 if(mm_flags & AV_CPU_FLAG_SSSE3){ + if (!high_bit_depth) { H264_QPEL_FUNCS(1, 0, ssse3); H264_QPEL_FUNCS(1, 1, ssse3); H264_QPEL_FUNCS(1, 2, ssse3); @@ -2743,12 +2771,15 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) H264_QPEL_FUNCS(3, 1, ssse3); H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); + } c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3; #if HAVE_YASM + if (!high_bit_depth) { c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd; c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd; c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_ssse3; c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_ssse3; + } c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_ssse3; if (mm_flags & AV_CPU_FLAG_SSE4) // not really sse4, just slow on Conroe c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_sse4; @@ -2805,6 +2836,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) } } + if (!high_bit_depth) c->emulated_edge_mc = emulated_edge_mc_sse; c->gmc= gmc_sse; #endif diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index 4142cc1edd..9eb752581b 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -95,9 +95,13 @@ void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int s void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride); void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride); -void ff_h264_pred_init_x86(H264PredContext *h, int codec_id) +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth) { int mm_flags = av_get_cpu_flags(); + const int high_depth = bit_depth > 8; + + if (high_depth) + return; #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c index 9f004a5314..b4936a618e 100644 --- a/libavcodec/x86/h264dsp_mmx.c +++ b/libavcodec/x86/h264dsp_mmx.c @@ -285,10 +285,11 @@ H264_BIWEIGHT_MMX ( 4, 8) H264_BIWEIGHT_MMX ( 4, 4) H264_BIWEIGHT_MMX ( 4, 2) -void ff_h264dsp_init_x86(H264DSPContext *c) +void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) { int mm_flags = av_get_cpu_flags(); + if (bit_depth == 8) { if (mm_flags & AV_CPU_FLAG_MMX2) { c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2; } @@ -378,5 +379,6 @@ void ff_h264dsp_init_x86(H264DSPContext *c) } } } + } #endif } -- cgit v1.2.3