From 44ca80df3445a59bc065924d8c6110fa10367d01 Mon Sep 17 00:00:00 2001 From: Oskar Arvidsson Date: Tue, 29 Mar 2011 17:48:56 +0200 Subject: Make the h264 loop filter bit depth aware. Preparatory patch for high bit depth h264 decoding support. Signed-off-by: Ronald S. Bultje --- libavcodec/h264_loopfilter.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'libavcodec/h264_loopfilter.c') diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 35630658b5..a08ff69931 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -101,9 +101,10 @@ static const uint8_t tc0_table[52*3][4] = { }; static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) { - const unsigned int index_a = qp + h->slice_alpha_c0_offset; + const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp + h->slice_beta_offset]; + const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -118,9 +119,10 @@ static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t } } static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { - const unsigned int index_a = qp + h->slice_alpha_c0_offset; + const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp + h->slice_beta_offset]; + const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -136,9 +138,10 @@ static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t } static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) { - int index_a = qp + h->slice_alpha_c0_offset; + const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; - int beta = beta_table[qp + h->slice_beta_offset]; + int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -153,9 +156,10 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int } } static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) { - int index_a = qp + h->slice_alpha_c0_offset; + const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; - int beta = beta_table[qp + h->slice_beta_offset]; + int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -171,9 +175,10 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in } static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { - const unsigned int index_a = qp + h->slice_alpha_c0_offset; + const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp + h->slice_beta_offset]; + const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -189,9 +194,10 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t } static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { - const unsigned int index_a = qp + h->slice_alpha_c0_offset; + const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = beta_table[qp + h->slice_beta_offset]; + const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { -- cgit v1.2.3