diff options
author | Oskar Arvidsson <oskar@irock.se> | 2011-05-09 11:18:37 -0400 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-05-10 07:24:27 -0400 |
commit | de3e760720ecc0c755cc2216ef9bf3dba39450a4 (patch) | |
tree | 90d925afd5b1bb536be6aa803d57cef16cb6514b /libavcodec/h264dsp_template.c | |
parent | 325eefa2ca14b487120b164bc232e6c650fb20f3 (diff) | |
download | ffmpeg-de3e760720ecc0c755cc2216ef9bf3dba39450a4.tar.gz |
Preparatory patch for high bit depth h264 decoding support.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/h264dsp_template.c')
-rw-r--r-- | libavcodec/h264dsp_template.c | 119 |
1 files changed, 75 insertions, 44 deletions
diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c index 2fe09ff56b..7190f4d9ca 100644 --- a/libavcodec/h264dsp_template.c +++ b/libavcodec/h264dsp_template.c @@ -25,12 +25,19 @@ * @author Michael Niedermayer <michaelni@gmx.at> */ -#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 BIT_DEPTH 8 +#define pixel uint8_t +#define av_clip_pixel av_clip_uint8 +#define FUNCC(a) a ## _c + +#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)) #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){ \ +static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *_block, int stride, int log2_denom, int weight, int offset){ \ int y; \ - offset <<= log2_denom; \ + pixel *block = (pixel*)_block; \ + stride /= sizeof(pixel); \ + offset <<= (log2_denom + (BIT_DEPTH-8)); \ if(log2_denom) offset += 1<<(log2_denom-1); \ for(y=0; y<H; y++, block += stride){ \ op_scale1(0); \ @@ -54,8 +61,11 @@ static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, op_scale1(15); \ } \ } \ -static void biweight_h264_pixels ## W ## x ## H ## _c(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset){ \ +static void FUNCC(biweight_h264_pixels ## W ## x ## H)(uint8_t *_dst, uint8_t *_src, int stride, int log2_denom, int weightd, int weights, int offset){ \ int y; \ + pixel *dst = (pixel*)_dst; \ + pixel *src = (pixel*)_src; \ + stride /= sizeof(pixel); \ offset = ((offset + 1) | 1) << log2_denom; \ for(y=0; y<H; y++, dst += stride, src += stride){ \ op_scale2(0); \ @@ -95,11 +105,17 @@ 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 inner_iters, int alpha, int beta, int8_t *tc0) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) { + pixel *pix = (pixel*)_pix; int i, d; + xstride /= sizeof(pixel); + ystride /= sizeof(pixel); + alpha <<= BIT_DEPTH - 8; + beta <<= BIT_DEPTH - 8; for( i = 0; i < 4; i++ ) { - if( tc0[i] < 0 ) { + const int tc_orig = tc0[i] << (BIT_DEPTH - 8); + if( tc_orig < 0 ) { pix += inner_iters*ystride; continue; } @@ -115,44 +131,49 @@ static av_always_inline av_flatten void h264_loop_filter_luma_c(uint8_t *pix, in FFABS( p1 - p0 ) < beta && FFABS( q1 - q0 ) < beta ) { - int tc = tc0[i]; + int tc = tc_orig; int i_delta; if( FFABS( p2 - p0 ) < beta ) { - if(tc0[i]) - pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] ); + if(tc_orig) + pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc_orig, tc_orig ); 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] ); + if(tc_orig) + pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc_orig, tc_orig ); 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[-xstride] = av_clip_pixel( p0 + i_delta ); /* p0' */ + pix[0] = av_clip_pixel( 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) +static void FUNCC(h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_luma_c(pix, stride, 1, 4, alpha, beta, tc0); + FUNCC(h264_loop_filter_luma)(pix, stride, sizeof(pixel), 4, alpha, beta, tc0); } -static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +static void FUNCC(h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_luma_c(pix, 1, stride, 4, alpha, beta, tc0); + FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), 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) +static void FUNCC(h264_h_loop_filter_luma_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_luma_c(pix, 1, stride, 2, alpha, beta, tc0); + FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), 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) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) { + pixel *pix = (pixel*)_pix; int d; + xstride /= sizeof(pixel); + ystride /= sizeof(pixel); + alpha <<= BIT_DEPTH - 8; + beta <<= BIT_DEPTH - 8; for( d = 0; d < 4 * inner_iters; d++ ) { const int p2 = pix[-3*xstride]; const int p1 = pix[-2*xstride]; @@ -198,24 +219,29 @@ static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *p pix += ystride; } } -static void h264_v_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +static void FUNCC(h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_luma_intra_c(pix, stride, 1, 4, alpha, beta); + FUNCC(h264_loop_filter_luma_intra)(pix, stride, sizeof(pixel), 4, alpha, beta); } -static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +static void FUNCC(h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_luma_intra_c(pix, 1, stride, 4, alpha, beta); + FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, 4, alpha, beta); } -static void h264_h_loop_filter_luma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) +static void FUNCC(h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_luma_intra_c(pix, 1, stride, 2, alpha, beta); + FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), 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) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0) { + pixel *pix = (pixel*)_pix; int i, d; + xstride /= sizeof(pixel); + ystride /= sizeof(pixel); + alpha <<= BIT_DEPTH - 8; + beta <<= BIT_DEPTH - 8; for( i = 0; i < 4; i++ ) { - const int tc = tc0[i]; + const int tc = ((tc0[i] - 1) << (BIT_DEPTH - 8)) + 1; if( tc <= 0 ) { pix += inner_iters*ystride; continue; @@ -232,29 +258,34 @@ static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, 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[-xstride] = av_clip_pixel( p0 + delta ); /* p0' */ + pix[0] = av_clip_pixel( 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) +static void FUNCC(h264_v_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_chroma_c(pix, stride, 1, 2, alpha, beta, tc0); + FUNCC(h264_loop_filter_chroma)(pix, stride, sizeof(pixel), 2, alpha, beta, tc0); } -static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) +static void FUNCC(h264_h_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_chroma_c(pix, 1, stride, 2, alpha, beta, tc0); + FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), 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) +static void FUNCC(h264_h_loop_filter_chroma_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) { - h264_loop_filter_chroma_c(pix, 1, stride, 1, alpha, beta, tc0); + FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), 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) +static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) { + pixel *pix = (pixel*)_pix; int d; + xstride /= sizeof(pixel); + ystride /= sizeof(pixel); + alpha <<= BIT_DEPTH - 8; + beta <<= BIT_DEPTH - 8; for( d = 0; d < 4 * inner_iters; d++ ) { const int p0 = pix[-1*xstride]; const int p1 = pix[-2*xstride]; @@ -271,15 +302,15 @@ static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t pix += ystride; } } -static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +static void FUNCC(h264_v_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_chroma_intra_c(pix, stride, 1, 2, alpha, beta); + FUNCC(h264_loop_filter_chroma_intra)(pix, stride, sizeof(pixel), 2, alpha, beta); } -static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta) +static void FUNCC(h264_h_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_chroma_intra_c(pix, 1, stride, 2, alpha, beta); + FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta); } -static void h264_h_loop_filter_chroma_mbaff_intra_c(uint8_t *pix, int stride, int alpha, int beta) +static void FUNCC(h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta) { - h264_loop_filter_chroma_intra_c(pix, 1, stride, 1, alpha, beta); + FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 1, alpha, beta); } |