libhevcdec: Unify itrans_res family and remove redundant HBD implementation

Currently, libhevc maintains two separate implementations for inverse
transform residual functions: ihevc_itrans_res_* and ihevc_hbd_itrans_res_*.

Since both 8-bit and HBD inverse transform residual routines output signed
16-bit residuals (WORD16 *pi2_dst), the only algorithmic difference between
8-bit and HBD variants is the 2nd stage shift:

    Stage 1 shift: IT_SHIFT_STAGE_1 = 7 (fixed across all bit depths)
    Stage 2 shift: shift = 20 - bit_depth
        - 8-bit:  20 - 8  = 12 (IT_SHIFT_STAGE_2)
        - 10-bit: 20 - 10 = 10

This commit cleans up the entire itrans_res family (4x4_ttype1, 4x4, dc, 8x8,
16x16, 32x32) as follows:

1. common/ihevc_itrans_res.h & common/ihevc_itrans_res.c:
   - Add 'UWORD8 bit_depth' parameter to ihevc_itrans_res_* function
     signatures and typedefs.
   - Replace hardcoded 'shift = IT_SHIFT_STAGE_2;' with 'shift = 20 - bit_depth;'.
   - Remove obsolete ihevc_hbd_itrans_res_* prototypes and typedefs.

2. common/ihevc_hbd_itrans_res.c:
   - Delete file (~2,335 redundant lines removed).

3. Update tests/common/ihevc_itrans_res_test.cc to test bit depths 8 and 10
This commit is contained in:
Narayan Kalaburgi 2026-09-07 17:42:50 +05:30 • committed by Harish Mahendrakar
parent 96c76d073c
commit 9886db71d3
12 changed files with 62 additions and 2498 deletions

View file

@ -1060,14 +1060,6 @@ void ihevcd_update_function_ptr(codec_t *ps_codec)
ps_codec->apf_hbd_intra_pred_chroma[9] = (pf_hbd_intra_pred_chroma)ps_codec->s_func_selector.ihevc_hbd_intra_pred_chroma_ver_fptr;
ps_codec->apf_hbd_intra_pred_chroma[10] = (pf_hbd_intra_pred_chroma)ps_codec->s_func_selector.ihevc_hbd_intra_pred_chroma_mode_27_to_33_fptr;
ps_codec->apf_hbd_itrans_res[0] = (pf_hbd_itrans_res)ps_codec->s_func_selector.ihevc_hbd_itrans_res_4x4_ttype1_fptr;
ps_codec->apf_hbd_itrans_res[1] = (pf_hbd_itrans_res)ps_codec->s_func_selector.ihevc_hbd_itrans_res_4x4_fptr;
ps_codec->apf_hbd_itrans_res[2] = (pf_hbd_itrans_res)ps_codec->s_func_selector.ihevc_hbd_itrans_res_8x8_fptr;
ps_codec->apf_hbd_itrans_res[3] = (pf_hbd_itrans_res)ps_codec->s_func_selector.ihevc_hbd_itrans_res_16x16_fptr;
ps_codec->apf_hbd_itrans_res[4] = (pf_hbd_itrans_res)ps_codec->s_func_selector.ihevc_hbd_itrans_res_32x32_fptr;
ps_codec->apf_hbd_itrans_res_dc = (pf_hbd_itrans_res_dc)ps_codec->s_func_selector.ihevc_hbd_itrans_res_dc_fptr;
ps_codec->apf_hbd_itrans_recon[0] = (pf_hbd_itrans_recon)ps_codec->s_func_selector.ihevc_hbd_itrans_recon_4x4_ttype1_fptr;
ps_codec->apf_hbd_itrans_recon[1] = (pf_hbd_itrans_recon)ps_codec->s_func_selector.ihevc_hbd_itrans_recon_4x4_fptr;
ps_codec->apf_hbd_itrans_recon[2] = (pf_hbd_itrans_recon)ps_codec->s_func_selector.ihevc_hbd_itrans_recon_8x8_fptr;

View file

@ -194,13 +194,6 @@ typedef struct
ihevc_hbd_chroma_itrans_recon_16x16_ft *ihevc_hbd_chroma_itrans_recon_16x16_fptr;
ihevc_hbd_chroma_itrans_recon_32x32_ft *ihevc_hbd_chroma_itrans_recon_32x32_fptr;
ihevc_hbd_itrans_res_4x4_ttype1_ft *ihevc_hbd_itrans_res_4x4_ttype1_fptr;
ihevc_hbd_itrans_res_4x4_ft *ihevc_hbd_itrans_res_4x4_fptr;
ihevc_hbd_itrans_res_8x8_ft *ihevc_hbd_itrans_res_8x8_fptr;
ihevc_hbd_itrans_res_16x16_ft *ihevc_hbd_itrans_res_16x16_fptr;
ihevc_hbd_itrans_res_32x32_ft *ihevc_hbd_itrans_res_32x32_fptr;
ihevc_hbd_itrans_res_dc_ft *ihevc_hbd_itrans_res_dc_fptr;
ihevc_hbd_recon_4x4_ttype1_ft *ihevc_hbd_recon_4x4_ttype1_fptr;
ihevc_hbd_recon_4x4_ft *ihevc_hbd_recon_4x4_fptr;
ihevc_hbd_recon_8x8_ft *ihevc_hbd_recon_8x8_fptr;

View file

@ -212,13 +212,6 @@ void ihevcd_init_function_ptr_generic(func_selector_t *ps_func_selector)
ps_func_selector->ihevcd_hbd_itrans_recon_dc_luma_fptr = &ihevcd_hbd_itrans_recon_dc_luma;
ps_func_selector->ihevcd_hbd_itrans_recon_dc_chroma_fptr = &ihevcd_hbd_itrans_recon_dc_chroma;
ps_func_selector->ihevc_hbd_itrans_res_4x4_ttype1_fptr = &ihevc_hbd_itrans_res_4x4_ttype1;
ps_func_selector->ihevc_hbd_itrans_res_4x4_fptr = &ihevc_hbd_itrans_res_4x4;
ps_func_selector->ihevc_hbd_itrans_res_8x8_fptr = &ihevc_hbd_itrans_res_8x8;
ps_func_selector->ihevc_hbd_itrans_res_16x16_fptr = &ihevc_hbd_itrans_res_16x16;
ps_func_selector->ihevc_hbd_itrans_res_32x32_fptr = &ihevc_hbd_itrans_res_32x32;
ps_func_selector->ihevc_hbd_itrans_res_dc_fptr = &ihevc_hbd_itrans_res_dc;
ps_func_selector->ihevc_hbd_deblk_luma_vert_fptr = &ihevc_hbd_deblk_luma_vert;
ps_func_selector->ihevc_hbd_deblk_luma_horz_fptr = &ihevc_hbd_deblk_luma_horz;
ps_func_selector->ihevc_hbd_deblk_chroma_vert_fptr = &ihevc_hbd_deblk_chroma_vert;

View file

@ -809,33 +809,16 @@ static void ihevcd_iquant_itrans_resi_recon_tu_plane(process_ctxt_t *ps_proc,
if(0 == ps_pl_tu_ctxt->coeff_type)
{
WORD32 func_tmp_idx = chroma_plane != NULL_PLANE ? func_idx - 4 : func_idx;
if(ps_codec->i4_pixel_size_y > 1) {
ps_codec->apf_hbd_itrans_res[func_tmp_idx](ps_pl_tu_ctxt->pi2_tu_coeff,
ps_proc->pi2_itrans_intrmd_buf, residue_out,
ps_pl_tu_ctxt->tu_coeff_stride, trans_size,
ps_pl_tu_ctxt->zero_cols,
ps_pl_tu_ctxt->zero_rows, (UWORD8)bit_depth);
}
else
{
ps_codec->apf_itrans_res[func_tmp_idx](ps_pl_tu_ctxt->pi2_tu_coeff,
ps_proc->pi2_itrans_intrmd_buf, residue_out,
ps_pl_tu_ctxt->tu_coeff_stride, trans_size,
ps_pl_tu_ctxt->zero_cols,
ps_pl_tu_ctxt->zero_rows);
}
ps_codec->apf_itrans_res[func_tmp_idx](ps_pl_tu_ctxt->pi2_tu_coeff,
ps_proc->pi2_itrans_intrmd_buf, residue_out,
ps_pl_tu_ctxt->tu_coeff_stride, trans_size,
ps_pl_tu_ctxt->zero_cols,
ps_pl_tu_ctxt->zero_rows, (UWORD8)bit_depth);
}
else /* DC only */
{
if(ps_codec->i4_pixel_size_y > 1) {
ps_codec->apf_hbd_itrans_res_dc(residue_out, trans_size, log2_trans_size,
ps_pl_tu_ctxt->coeff_value, (UWORD8)bit_depth);
}
else
{
ps_codec->apf_itrans_res_dc(residue_out, trans_size, log2_trans_size,
ps_pl_tu_ctxt->coeff_value);
}
ps_codec->apf_itrans_res_dc(residue_out, trans_size, log2_trans_size,
ps_pl_tu_ctxt->coeff_value, (UWORD8)bit_depth);
}
ps_pl_tu_ctxt->zero_cols = 0;
}

View file

@ -1639,7 +1639,8 @@ typedef void (*pf_itrans_res)(WORD16 *pi2_src,
WORD32 i4_src_strd,
WORD32 i4_dst_strd,
WORD32 zero_cols,
WORD32 zero_rows);
WORD32 zero_rows,
UWORD8 bit_depth);
typedef void (*pf_itrans_recon)(WORD16 *pi2_src,
WORD16 *pi2_tmp,
@ -1669,7 +1670,8 @@ typedef void (*pf_itrans_recon_dc)(UWORD8 *pu1_pred,
typedef void (*pf_itrans_res_dc)(WORD16 *pi2_dst,
WORD32 dst_strd,
WORD32 log2_trans_size,
WORD16 i2_coeff_value);
WORD16 i2_coeff_value,
UWORD8 bit_depth);
typedef void (*pf_sao_luma)(UWORD8 *,
@ -1716,21 +1718,6 @@ typedef void (*pf_hbd_itrans_recon)(WORD16 *pi2_src,
WORD32 i4_zero_rows,
UWORD8 u1_bit_depth);
typedef void (*pf_hbd_itrans_res)(WORD16 *pi2_src,
WORD16 *pi2_tmp,
WORD16 *pi2_dst,
WORD32 src_strd,
WORD32 dst_strd,
WORD32 zero_cols,
WORD32 zero_rows,
UWORD8 bit_depth);
typedef void (*pf_hbd_itrans_res_dc)(WORD16 *pi2_dst,
WORD32 dst_strd,
WORD32 log2_trans_size,
WORD16 i2_coeff_value,
UWORD8 bit_depth);
typedef void (*pf_hbd_recon)(WORD16 *pi2_src,
UWORD16 *pu2_pred,
UWORD16 *pu2_dst,
@ -2442,8 +2429,6 @@ struct _codec_t
pf_hbd_sao_luma apf_hbd_sao_luma[4];
pf_hbd_sao_chroma apf_hbd_sao_chroma[4];
pf_hbd_inter_pred apf_hbd_inter_pred[22];
pf_hbd_itrans_res apf_hbd_itrans_res[5];
pf_hbd_itrans_res_dc apf_hbd_itrans_res_dc;
/** Funtion pointers for all the leaf level functions */
func_selector_t s_func_selector;