diff options
Diffstat (limited to 'common/ih264_ihadamard_scaling.c')
-rw-r--r-- | common/ih264_ihadamard_scaling.c | 280 |
1 files changed, 164 insertions, 116 deletions
diff --git a/common/ih264_ihadamard_scaling.c b/common/ih264_ihadamard_scaling.c index e4729c8..0e265f7 100644 --- a/common/ih264_ihadamard_scaling.c +++ b/common/ih264_ihadamard_scaling.c @@ -17,74 +17,82 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ + /** - ******************************************************************************* - * @file - * ih264_ihadamard_scaling.c - * - * @brief - * Contains definition of functions for h264 inverse hadamard 4x4 transform and scaling - * - * @author - * Mohit - * - * @par List of Functions: - * - ih264_ihadamard_scaling_4x4() - * - * @remarks - * - ******************************************************************************* - */ +******************************************************************************* +* @file +* ih264_ihadamard_scaling.c +* +* @brief +* Contains definition of functions for h264 inverse hadamard 4x4 transform and +* scaling +* +* @author +* ittiam +* +* @par List of Functions: +* - ih264_ihadamard_scaling_4x4 +* - ih264_ihadamard_scaling_2x2_uv +* +* @remarks +* none +* +******************************************************************************* +*/ /*****************************************************************************/ /* File Includes */ /*****************************************************************************/ -/* User include files */ +/* User Include Files */ #include "ih264_typedefs.h" +#include "ih264_macros.h" #include "ih264_defs.h" #include "ih264_trans_macros.h" -#include "ih264_macros.h" #include "ih264_trans_data.h" #include "ih264_size_defs.h" #include "ih264_structs.h" #include "ih264_trans_quant_itrans_iquant.h" -/* - ******************************************************************************** - * - * @brief This function performs a 4x4 inverse hadamard transform on the 4x4 DC coefficients - * of a 16x16 intra prediction macroblock, and then performs scaling. - * prediction buffer - * - * @par Description: - * The DC coefficients pass through a 2-stage inverse hadamard transform. - * This inverse transformed content is scaled to based on Qp value. - * - * @param[in] pi2_src - * input 4x4 block of DC coefficients - * - * @param[out] pi2_out - * output 4x4 block - * - * @param[in] pu2_iscal_mat - * pointer to scaling list - * - * @param[in] pu2_weigh_mat - * pointer to weight matrix - * - * @param[in] u4_qp_div_6 - * Floor (qp/6) - * - * @param[in] pi4_tmp - * temporary buffer of size 1*16 - * - * @returns none - * - * @remarks none - * - ******************************************************************************* - */ + +/*****************************************************************************/ +/* Function Definitions */ +/*****************************************************************************/ + +/** +******************************************************************************** +* +* @brief This function performs a 4x4 inverse hadamard transform on the luma +* DC coefficients and then performs scaling. +* +* @par Description: +* The DC coefficients pass through a 2-stage inverse hadamard transform. +* This inverse transformed content is scaled to based on Qp value. +* +* @param[in] pi2_src +* input 4x4 block of DC coefficients +* +* @param[out] pi2_out +* output 4x4 block +* +* @param[in] pu2_iscal_mat +* pointer to scaling list +* +* @param[in] pu2_weigh_mat +* pointer to weight matrix +* +* @param[in] u4_qp_div_6 +* Floor (qp/6) +* +* @param[in] pi4_tmp +* temporary buffer of size 1*16 +* +* @returns none +* +* @remarks none +* +******************************************************************************* +*/ void ih264_ihadamard_scaling_4x4(WORD16* pi2_src, WORD16* pi2_out, const UWORD16 *pu2_iscal_mat, @@ -94,13 +102,15 @@ void ih264_ihadamard_scaling_4x4(WORD16* pi2_src, { WORD32 i; WORD32 x0, x1, x2, x3, x4, x5, x6, x7; - WORD16* pi2_src_ptr, *pi2_out_ptr; - WORD32* pi4_tmp_ptr; + WORD16 *pi2_src_ptr, *pi2_out_ptr; + WORD32 *pi4_tmp_ptr; WORD32 rnd_fact = (u4_qp_div_6 < 6) ? (1 << (5 - u4_qp_div_6)) : 0; + pi4_tmp_ptr = pi4_tmp; pi2_src_ptr = pi2_src; pi2_out_ptr = pi2_out; - // Horizontal transform + + /* horizontal transform */ for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) { x4 = pi2_src_ptr[0]; @@ -121,8 +131,9 @@ void ih264_ihadamard_scaling_4x4(WORD16* pi2_src, pi4_tmp_ptr += SUB_BLK_WIDTH_4x4; pi2_src_ptr += SUB_BLK_WIDTH_4x4; } + + /* vertical transform */ pi4_tmp_ptr = pi4_tmp; - // Vertical Transform for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) { x4 = pi4_tmp_ptr[0]; @@ -143,15 +154,50 @@ void ih264_ihadamard_scaling_4x4(WORD16* pi2_src, pi4_tmp_ptr++; } pi4_tmp_ptr = pi4_tmp; - //Scaling + + /* scaling */ for(i = 0; i < (SUB_BLK_WIDTH_4x4 * SUB_BLK_WIDTH_4x4); i++) { - INV_QUANT(pi4_tmp_ptr[i], pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, - rnd_fact, 6); - pi2_out_ptr[i] = pi4_tmp_ptr[i]; + INV_QUANT(pi4_tmp_ptr[i], pu2_iscal_mat[0], pu2_weigh_mat[0], + u4_qp_div_6, rnd_fact, 6); + pi2_out_ptr[i] = pi4_tmp_ptr[i]; } } +/** +******************************************************************************** +* +* @brief This function performs a 2x2 inverse hadamard transform on the chroma +* DC coefficients and then performs scaling. +* +* @par Description: +* The DC coefficients pass through a 2-stage inverse hadamard transform. +* This inverse transformed content is scaled to based on Qp value. +* +* @param[in] pi2_src +* input 2x2 block of DC coefficients +* +* @param[out] pi2_out +* output 2x2 block +* +* @param[in] pu2_iscal_mat +* pointer to scaling list +* +* @param[in] pu2_weigh_mat +* pointer to weight matrix +* +* @param[in] u4_qp_div_6 +* Floor (qp/6) +* +* @param[in] pi4_tmp +* temporary buffer of size 1*16 +* +* @returns none +* +* @remarks none +* +******************************************************************************* +*/ void ih264_ihadamard_scaling_2x2_uv(WORD16* pi2_src, WORD16* pi2_out, const UWORD16 *pu2_iscal_mat, @@ -159,58 +205,60 @@ void ih264_ihadamard_scaling_2x2_uv(WORD16* pi2_src, UWORD32 u4_qp_div_6, WORD32* pi4_tmp) { - WORD32 i4_x0,i4_x1,i4_x2,i4_x3,i4_x4,i4_x5,i4_x6,i4_x7; - WORD32 i4_y0,i4_y1,i4_y2,i4_y3,i4_y4,i4_y5,i4_y6,i4_y7; - - UNUSED(pi4_tmp); - - i4_x4 = pi2_src[0]; - i4_x5 = pi2_src[1]; - i4_x6 = pi2_src[2]; - i4_x7 = pi2_src[3]; - - i4_x0 = i4_x4 + i4_x5; - i4_x1 = i4_x4 - i4_x5; - i4_x2 = i4_x6 + i4_x7; - i4_x3 = i4_x6 - i4_x7; - - i4_x4 = i4_x0+i4_x2; - i4_x5 = i4_x1+i4_x3; - i4_x6 = i4_x0-i4_x2; - i4_x7 = i4_x1-i4_x3; - - INV_QUANT(i4_x4,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - INV_QUANT(i4_x5,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - INV_QUANT(i4_x6,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - INV_QUANT(i4_x7,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - - pi2_out[0] = i4_x4; - pi2_out[1] = i4_x5; - pi2_out[2] = i4_x6; - pi2_out[3] = i4_x7; - - i4_y4 = pi2_src[4]; - i4_y5 = pi2_src[5]; - i4_y6 = pi2_src[6]; - i4_y7 = pi2_src[7]; - - i4_y0 = i4_y4 + i4_y5; - i4_y1 = i4_y4 - i4_y5; - i4_y2 = i4_y6 + i4_y7; - i4_y3 = i4_y6 - i4_y7; - - i4_y4 = i4_y0+i4_y2; - i4_y5 = i4_y1+i4_y3; - i4_y6 = i4_y0-i4_y2; - i4_y7 = i4_y1-i4_y3; - - INV_QUANT(i4_y4,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - INV_QUANT(i4_y5,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - INV_QUANT(i4_y6,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - INV_QUANT(i4_y7,pu2_iscal_mat[0],pu2_weigh_mat[0],u4_qp_div_6,0,5); - - pi2_out[4] = i4_y4; - pi2_out[5] = i4_y5; - pi2_out[6] = i4_y6; - pi2_out[7] = i4_y7; + WORD32 i4_x0, i4_x1, i4_x2, i4_x3, i4_x4, i4_x5, i4_x6, i4_x7; + WORD32 i4_y0, i4_y1, i4_y2, i4_y3, i4_y4, i4_y5, i4_y6, i4_y7; + + UNUSED(pi4_tmp); + + /* U Plane */ + i4_x4 = pi2_src[0]; + i4_x5 = pi2_src[1]; + i4_x6 = pi2_src[2]; + i4_x7 = pi2_src[3]; + + i4_x0 = i4_x4 + i4_x5; + i4_x1 = i4_x4 - i4_x5; + i4_x2 = i4_x6 + i4_x7; + i4_x3 = i4_x6 - i4_x7; + + i4_x4 = i4_x0 + i4_x2; + i4_x5 = i4_x1 + i4_x3; + i4_x6 = i4_x0 - i4_x2; + i4_x7 = i4_x1 - i4_x3; + + INV_QUANT(i4_x4, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + INV_QUANT(i4_x5, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + INV_QUANT(i4_x6, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + INV_QUANT(i4_x7, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + + pi2_out[0] = i4_x4; + pi2_out[1] = i4_x5; + pi2_out[2] = i4_x6; + pi2_out[3] = i4_x7; + + /* V Plane */ + i4_y4 = pi2_src[4]; + i4_y5 = pi2_src[5]; + i4_y6 = pi2_src[6]; + i4_y7 = pi2_src[7]; + + i4_y0 = i4_y4 + i4_y5; + i4_y1 = i4_y4 - i4_y5; + i4_y2 = i4_y6 + i4_y7; + i4_y3 = i4_y6 - i4_y7; + + i4_y4 = i4_y0 + i4_y2; + i4_y5 = i4_y1 + i4_y3; + i4_y6 = i4_y0 - i4_y2; + i4_y7 = i4_y1 - i4_y3; + + INV_QUANT(i4_y4, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + INV_QUANT(i4_y5, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + INV_QUANT(i4_y6, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + INV_QUANT(i4_y7, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, 0, 5); + + pi2_out[4] = i4_y4; + pi2_out[5] = i4_y5; + pi2_out[6] = i4_y6; + pi2_out[7] = i4_y7; } |