LCOV - code coverage report
Current view: top level - lib_com - ivas_entropy_coder_common_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main @ b9bfbe380d1c207f5198ba67a82398b3d313550e Lines: 268 276 97.1 %
Date: 2025-11-16 02:22:47 Functions: 9 9 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "ivas_rom_com.h"
      36             : #include "math.h"
      37             : #include "prot_fx.h"
      38             : #include "wmc_auto.h"
      39             : #include "ivas_prot_fx.h"
      40             : 
      41             : 
      42             : /*-----------------------------------------------------------------------------------------*
      43             :  * Function ivas_wrap_arround)
      44             :  *
      45             :  * wrap around
      46             :  *-----------------------------------------------------------------------------------------*/
      47             : 
      48      471731 : void ivas_wrap_arround_fx(
      49             :     Word16 *pArr,
      50             :     const Word16 min_val,
      51             :     const Word16 max_val,
      52             :     const Word16 length )
      53             : {
      54             :     Word16 i;
      55             : 
      56     6893057 :     FOR( i = 0; i < length; i++ )
      57             :     {
      58     6421326 :         IF( LT_16( pArr[i], min_val ) )
      59             :         {
      60        3210 :             pArr[i] = add( sub( max_val, min_val ), add( pArr[i], 1 ) );
      61        3210 :             move16();
      62             :         }
      63     6421326 :         IF( GT_16( pArr[i], max_val ) )
      64             :         {
      65        1600 :             pArr[i] = sub( add( min_val, pArr[i] ), add( max_val, 1 ) );
      66        1600 :             move16();
      67             :         }
      68             :     }
      69             : 
      70      471731 :     return;
      71             : }
      72             : 
      73             : 
      74             : /*-----------------------------------------------------------------------------------------*
      75             :  * Function ivas_get_cum_freq_model()
      76             :  *
      77             :  * get cumulative frequency model
      78             :  *-----------------------------------------------------------------------------------------*/
      79             : 
      80      310608 : void ivas_get_cum_freq_model_fx(
      81             :     const Word16 *pFreq_model,
      82             :     const Word16 length,
      83             :     Word16 *pCum_freq_model )
      84             : {
      85             :     Word16 i;
      86             : 
      87      310608 :     pCum_freq_model[length] = 0;
      88      310608 :     move16();
      89             : 
      90     2886080 :     FOR( i = length; i > 0; i-- )
      91             :     {
      92     2575472 :         pCum_freq_model[i - 1] = add( pCum_freq_model[i], pFreq_model[i] );
      93     2575472 :         move16();
      94             :     }
      95             : 
      96      310608 :     return;
      97             : }
      98             : 
      99             : 
     100             : /*-----------------------------------------------------------------------------------------*
     101             :  * Function ivas_map_num_pred_r_to_idx()
     102             :  *
     103             :  * Map the ivas_arith_pred_r_consts and ivas_huff_pred_r_consts tables
     104             :  *-----------------------------------------------------------------------------------------*/
     105             : 
     106       25884 : Word16 ivas_map_num_pred_r_to_idx_fx(
     107             :     const Word16 num_quant_points_pred_r,
     108             :     const Word16 active_w_flag )
     109             : {
     110       25884 :     Word16 pred_r_to_idx = -1;
     111       25884 :     move16();
     112       25884 :     IF( active_w_flag == 0 )
     113             :     {
     114       21162 :         SWITCH( num_quant_points_pred_r )
     115             :         {
     116        3120 :             case 1:
     117        3120 :                 pred_r_to_idx = PRED_Q_1;
     118        3120 :                 move16();
     119        3120 :                 BREAK;
     120        1588 :             case 7:
     121        1588 :                 pred_r_to_idx = PRED_Q_7;
     122        1588 :                 move16();
     123        1588 :                 BREAK;
     124        6540 :             case 15:
     125        6540 :                 pred_r_to_idx = PRED_Q_15;
     126        6540 :                 move16();
     127        6540 :                 BREAK;
     128        8354 :             case 21:
     129        8354 :                 pred_r_to_idx = PRED_Q_21;
     130        8354 :                 move16();
     131        8354 :                 BREAK;
     132        1560 :             case 31:
     133        1560 :                 pred_r_to_idx = PRED_Q_31;
     134        1560 :                 move16();
     135        1560 :                 BREAK;
     136           0 :             default:
     137           0 :                 assert( !"Forbidden value for prediction quantization strategy index" );
     138             :                 BREAK;
     139             :         }
     140             :     }
     141             :     ELSE
     142             :     {
     143        4722 :         SWITCH( num_quant_points_pred_r )
     144             :         {
     145        1216 :             case 7:
     146        1216 :                 pred_r_to_idx = PRED_Q_7_ACTIVE_W;
     147        1216 :                 move16();
     148        1216 :                 BREAK;
     149        3148 :             case 15:
     150        3148 :                 pred_r_to_idx = PRED_Q_15_ACTIVE_W;
     151        3148 :                 move16();
     152        3148 :                 BREAK;
     153         358 :             case 21:
     154         358 :                 pred_r_to_idx = PRED_Q_21_ACTIVE_W;
     155         358 :                 move16();
     156         358 :                 BREAK;
     157           0 :             default:
     158           0 :                 assert( !"Forbidden value for prediction quantization strategy index" );
     159             :                 BREAK;
     160             :         }
     161             :     }
     162             : 
     163       25884 :     return pred_r_to_idx;
     164             : }
     165             : 
     166             : 
     167             : /*-----------------------------------------------------------------------------------------*
     168             :  * Function ivas_map_num_drct_r_to_idx()
     169             :  *
     170             :  * Map the ivas_arith_drct_r_consts and ivas_huff_drct_r_consts tables
     171             :  *-----------------------------------------------------------------------------------------*/
     172             : 
     173       25884 : Word16 ivas_map_num_drct_r_to_idx_fx(
     174             :     const Word16 num_quant_points_drct_r )
     175             : {
     176       25884 :     Word16 drct_r_to_idx = -1;
     177       25884 :     move16();
     178       25884 :     SWITCH( num_quant_points_drct_r )
     179             :     {
     180       13016 :         case 1:
     181       13016 :             drct_r_to_idx = DRCT_Q_1;
     182       13016 :             move16();
     183       13016 :             BREAK;
     184        7936 :         case 7:
     185        7936 :             drct_r_to_idx = DRCT_Q_7;
     186        7936 :             move16();
     187        7936 :             BREAK;
     188        2224 :         case 9:
     189        2224 :             drct_r_to_idx = DRCT_Q_9;
     190        2224 :             move16();
     191        2224 :             BREAK;
     192        2708 :         case 11:
     193        2708 :             drct_r_to_idx = DRCT_Q_11;
     194        2708 :             move16();
     195        2708 :             BREAK;
     196           0 :         default:
     197           0 :             assert( !"Forbidden value for DRCT quantization strategy index" );
     198             :             BREAK;
     199             :     }
     200       25884 :     return drct_r_to_idx;
     201             : }
     202             : 
     203             : 
     204             : /*-----------------------------------------------------------------------------------------*
     205             :  * Function ivas_map_num_decd_r_to_idx()
     206             :  *
     207             :  * Map the ivas_arith_decd_r_consts and ivas_huff_decd_r_consts tables
     208             :  *-----------------------------------------------------------------------------------------*/
     209             : 
     210       25884 : Word16 ivas_map_num_decd_r_to_idx_fx(
     211             :     const Word16 num_quant_points_decd_r )
     212             : {
     213       25884 :     Word16 decd_r_to_idx = -1;
     214       25884 :     move16();
     215       25884 :     SWITCH( num_quant_points_decd_r )
     216             :     {
     217        3572 :         case 1:
     218        3572 :             decd_r_to_idx = DECD_Q_1;
     219        3572 :             move16();
     220        3572 :             BREAK;
     221        7648 :         case 3:
     222        7648 :             decd_r_to_idx = DECD_Q_3;
     223        7648 :             move16();
     224        7648 :             BREAK;
     225        8132 :         case 5:
     226        8132 :             decd_r_to_idx = DECD_Q_5;
     227        8132 :             move16();
     228        8132 :             BREAK;
     229        2116 :         case 7:
     230        2116 :             decd_r_to_idx = DECD_Q_7;
     231        2116 :             move16();
     232        2116 :             BREAK;
     233        2224 :         case 9:
     234        2224 :             decd_r_to_idx = DECD_Q_9;
     235        2224 :             move16();
     236        2224 :             BREAK;
     237        2192 :         case 11:
     238        2192 :             decd_r_to_idx = DECD_Q_11;
     239        2192 :             move16();
     240        2192 :             BREAK;
     241           0 :         default:
     242           0 :             assert( !"Forbidden value for DECD quantization strategy index" );
     243             :             BREAK;
     244             :     }
     245             : 
     246       25884 :     return decd_r_to_idx;
     247             : }
     248             : 
     249             : 
     250             : /*---------------------------------------------------------------------------------------- - *
     251             :  * Function ivas_spar_arith_com_init()
     252             :  *
     253             :  * arith coder init
     254             :  *---------------------------------------------------------------------------------------- - */
     255             : 
     256       38826 : static void ivas_spar_arith_com_init_fx(
     257             :     ivas_arith_t *pArith,
     258             :     const ivas_freq_models_t *pFreq_models,
     259             :     ivas_arith_t *pArith_diff,
     260             :     const Word16 q_levels,
     261             :     const Word16 enc_dec )
     262             : {
     263             :     Word16 i, j;
     264             :     Word16 sum, log2_int, log2_frac;
     265             :     Word32 tmp32, log2_int32, L_tmp1, L_tmp2;
     266             : 
     267       38826 :     pArith->vals = pFreq_models->vals;
     268       38826 :     pArith->range = q_levels;
     269       38826 :     move16();
     270       38826 :     pArith->num_models = pFreq_models->num_models;
     271       38826 :     move16();
     272       38826 :     pArith->dyn_model_bits = ivas_get_bits_to_encode( pArith->num_models - 1 );
     273       38826 :     move16();
     274       38826 :     pArith->pFreq_model = pFreq_models->freq_model[0];
     275             : 
     276       38826 :     ivas_get_cum_freq_model_fx( pArith->pFreq_model, pArith->range, pArith->cum_freq[0] );
     277             : 
     278      155304 :     FOR( i = 0; i < pArith->num_models - 1; i++ )
     279             :     {
     280      116478 :         pArith->pAlt_freq_models[i] = pFreq_models->freq_model[i + 1];
     281      116478 :         ivas_get_cum_freq_model_fx( pArith->pAlt_freq_models[i], pArith->range, pArith->cum_freq[i + 1] );
     282             :     }
     283             : 
     284       38826 :     IF( enc_dec == ENC )
     285             :     {
     286       19413 :         sum = 0;
     287       19413 :         move16();
     288      180380 :         FOR( i = 1; i < pArith->range + 1; i++ )
     289             :         {
     290      160967 :             sum = add( sum, pArith->pFreq_model[i] );
     291             :         }
     292       19413 :         log2_int = norm_s( sum );
     293       19413 :         tmp32 = L_deposit_h( shl( sum, log2_int ) );
     294       19413 :         log2_frac = Log2_norm_lc( tmp32 );
     295       19413 :         log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     296       19413 :         L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     297      180380 :         FOR( i = 1; i < pArith->range + 1; i++ )
     298             :         {
     299      160967 :             log2_int = norm_s( pArith->pFreq_model[i] );
     300      160967 :             tmp32 = L_deposit_h( shl( pArith->pFreq_model[i], log2_int ) );
     301      160967 :             log2_frac = Log2_norm_lc( tmp32 );
     302      160967 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     303      160967 :             L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     304      160967 :             pArith->saved_dist_arr[0][i - 1] = L_sub( L_tmp1, L_tmp2 );
     305      160967 :             move32();
     306             :         }
     307             : 
     308       77652 :         FOR( j = 0; j < pArith->num_models - 1; j++ )
     309             :         {
     310       58239 :             sum = 0;
     311       58239 :             move16();
     312      541140 :             FOR( i = 1; i < pArith->range + 1; i++ )
     313             :             {
     314      482901 :                 sum = add( sum, pArith->pAlt_freq_models[j][i] );
     315             :             }
     316       58239 :             log2_int = norm_s( sum );
     317       58239 :             tmp32 = L_deposit_h( shl( sum, log2_int ) );
     318       58239 :             log2_frac = Log2_norm_lc( tmp32 );
     319       58239 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     320       58239 :             L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     321      541140 :             FOR( i = 1; i < pArith->range + 1; i++ )
     322             :             {
     323      482901 :                 log2_int = norm_s( pArith->pAlt_freq_models[j][i] );
     324      482901 :                 tmp32 = L_deposit_h( shl( pArith->pAlt_freq_models[j][i], log2_int ) );
     325      482901 :                 log2_frac = Log2_norm_lc( tmp32 );
     326      482901 :                 log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     327      482901 :                 L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     328      482901 :                 pArith->saved_dist_arr[j + 1][i - 1] = L_sub( L_tmp1, L_tmp2 );
     329      482901 :                 move32();
     330             :             }
     331             :         }
     332             :     }
     333             : 
     334       38826 :     pArith_diff->vals = pFreq_models->diff_vals;
     335       38826 :     pArith_diff->range = q_levels;
     336       38826 :     move16();
     337       38826 :     pArith_diff->num_models = pFreq_models->diff_num_models;
     338       38826 :     move16();
     339       38826 :     pArith_diff->dyn_model_bits = ivas_get_bits_to_encode( pArith_diff->num_models - 1 );
     340       38826 :     move16();
     341       38826 :     pArith_diff->pFreq_model = pFreq_models->diff_freq_model[0];
     342             : 
     343       38826 :     ivas_get_cum_freq_model_fx( pArith_diff->pFreq_model, pArith_diff->range, pArith_diff->cum_freq[0] );
     344             : 
     345      155304 :     FOR( i = 0; i < pArith_diff->num_models - 1; i++ )
     346             :     {
     347      116478 :         pArith_diff->pAlt_freq_models[i] = pFreq_models->diff_freq_model[i + 1];
     348      116478 :         ivas_get_cum_freq_model_fx( pArith_diff->pAlt_freq_models[i], pArith_diff->range, pArith_diff->cum_freq[i + 1] );
     349             :     }
     350             : 
     351       38826 :     IF( enc_dec == ENC )
     352             :     {
     353       19413 :         sum = 0;
     354       19413 :         move16();
     355      180380 :         FOR( i = 1; i < pArith_diff->range + 1; i++ )
     356             :         {
     357      160967 :             sum = add( sum, pArith_diff->pFreq_model[i] );
     358             :         }
     359       19413 :         log2_int = norm_s( sum );
     360       19413 :         tmp32 = L_deposit_h( shl( sum, log2_int ) );
     361       19413 :         log2_frac = Log2_norm_lc( tmp32 );
     362       19413 :         log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     363       19413 :         L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     364      180380 :         FOR( i = 1; i < pArith_diff->range + 1; i++ )
     365             :         {
     366      160967 :             log2_int = norm_s( pArith_diff->pFreq_model[i] );
     367      160967 :             tmp32 = L_deposit_h( shl( pArith_diff->pFreq_model[i], log2_int ) );
     368      160967 :             log2_frac = Log2_norm_lc( tmp32 );
     369      160967 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     370      160967 :             L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     371      160967 :             pArith_diff->saved_dist_arr[0][i - 1] = L_sub( L_tmp1, L_tmp2 );
     372      160967 :             move32();
     373             :         }
     374             : 
     375       77652 :         FOR( j = 0; j < pArith_diff->num_models - 1; j++ )
     376             :         {
     377       58239 :             sum = 0;
     378       58239 :             move16();
     379      541140 :             FOR( i = 1; i < pArith_diff->range + 1; i++ )
     380             :             {
     381      482901 :                 sum = add( sum, pArith_diff->pAlt_freq_models[j][i] );
     382             :             }
     383       58239 :             log2_int = norm_s( sum );
     384       58239 :             tmp32 = L_deposit_h( shl( sum, log2_int ) );
     385       58239 :             log2_frac = Log2_norm_lc( tmp32 );
     386       58239 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     387       58239 :             L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     388      541140 :             FOR( i = 1; i < pArith_diff->range + 1; i++ )
     389             :             {
     390      482901 :                 log2_int = norm_s( pArith_diff->pAlt_freq_models[j][i] );
     391      482901 :                 tmp32 = L_deposit_h( shl( pArith_diff->pAlt_freq_models[j][i], log2_int ) );
     392      482901 :                 log2_frac = Log2_norm_lc( tmp32 );
     393      482901 :                 log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     394      482901 :                 L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     395      482901 :                 pArith_diff->saved_dist_arr[j + 1][i - 1] = L_sub( L_tmp1, L_tmp2 );
     396      482901 :                 move32();
     397             :             }
     398             :         }
     399             :     }
     400             : 
     401       38826 :     return;
     402             : }
     403             : 
     404             : 
     405             : /*-----------------------------------------------------------------------------------------*
     406             :  * Function ivas_spar_arith_coeffs_com_init()
     407             :  *
     408             :  * Init for Arithm. coding
     409             :  *-----------------------------------------------------------------------------------------*/
     410             : 
     411        4314 : void ivas_spar_arith_coeffs_com_init_fx(
     412             :     ivas_arith_coeffs_t *pArith_coeffs,
     413             :     ivas_spar_md_com_cfg *pSpar_cfg,
     414             :     const Word16 table_idx,
     415             :     const Word16 enc_dec )
     416             : {
     417             :     Word16 i, pred_r_index, drct_r_index, decd_r_index;
     418             :     Word16 num_quant_points_pred_r, num_quant_points_drct_r, num_quant_points_decd_r;
     419             : 
     420       17256 :     FOR( i = 0; i < MAX_QUANT_STRATS; i++ )
     421             :     {
     422       12942 :         num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */
     423       12942 :         move16();
     424       12942 :         pred_r_index = ivas_map_num_pred_r_to_idx_fx( num_quant_points_pred_r, ivas_spar_br_table_consts[table_idx].active_w );
     425       12942 :         ivas_spar_arith_com_init_fx( &pArith_coeffs->pred_arith_re[i], &ivas_arith_pred_r_consts[pred_r_index],
     426       12942 :                                      &pArith_coeffs->pred_arith_re_diff[i], pSpar_cfg->quant_strat[i].PR.q_levels[0], enc_dec );
     427             : 
     428       12942 :         num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */
     429       12942 :         move16();
     430       12942 :         drct_r_index = ivas_map_num_drct_r_to_idx_fx( num_quant_points_drct_r );
     431       12942 :         ivas_spar_arith_com_init_fx( &pArith_coeffs->drct_arith_re[i], &ivas_arith_drct_r_consts[drct_r_index],
     432       12942 :                                      &pArith_coeffs->drct_arith_re_diff[i], pSpar_cfg->quant_strat[i].C.q_levels[0], enc_dec );
     433             : 
     434       12942 :         num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */
     435       12942 :         move16();
     436       12942 :         decd_r_index = ivas_map_num_decd_r_to_idx_fx( num_quant_points_decd_r );
     437       12942 :         ivas_spar_arith_com_init_fx( &pArith_coeffs->decd_arith_re[i], &ivas_arith_decd_r_consts[decd_r_index],
     438       12942 :                                      &pArith_coeffs->decd_arith_re_diff[i], pSpar_cfg->quant_strat[i].P_r.q_levels[0], enc_dec );
     439             :     }
     440             : 
     441        4314 :     return;
     442             : }
     443             : 
     444             : 
     445             : /*-----------------------------------------------------------------------------------------*
     446             :  * Function ivas_huffman_dec_init_min_max_len()
     447             :  *
     448             :  * Find min and max length in codebook and finalize initialization of ivas_huffman_cfg_t.
     449             :  *-----------------------------------------------------------------------------------------*/
     450             : 
     451       19413 : static void ivas_huffman_dec_init_min_max_len_fx(
     452             :     ivas_huffman_cfg_t *p_huff_cfg )
     453             : {
     454             :     Word16 i, code_len;
     455             :     const Word16 *codebook;
     456             : 
     457       19413 :     codebook = p_huff_cfg->codebook;
     458             : 
     459       19413 :     p_huff_cfg->min_len = p_huff_cfg->sym_len;
     460       19413 :     move16();
     461       19413 :     p_huff_cfg->max_len = 0;
     462       19413 :     move16();
     463             : 
     464      180380 :     FOR( i = 0; i < p_huff_cfg->sym_len; i++ )
     465             :     {
     466      160967 :         code_len = codebook[1];
     467      160967 :         move16();
     468      160967 :         if ( GT_16( p_huff_cfg->min_len, code_len ) )
     469             :         {
     470       33370 :             p_huff_cfg->min_len = code_len;
     471       33370 :             move16();
     472             :         }
     473      160967 :         if ( LT_16( p_huff_cfg->max_len, code_len ) )
     474             :         {
     475       14486 :             p_huff_cfg->max_len = code_len;
     476       14486 :             move16();
     477             :         }
     478      160967 :         codebook = codebook + 3;
     479             :     }
     480             : 
     481       19413 :     return;
     482             : }
     483             : 
     484             : 
     485             : /*-----------------------------------------------------------------------------------------*
     486             :  * Function ivas_spar_huff_coeffs_com_init()
     487             :  *
     488             :  * Init for Huffman decoding
     489             :  *-----------------------------------------------------------------------------------------*/
     490             : 
     491        4314 : void ivas_spar_huff_coeffs_com_init_fx(
     492             :     ivas_huff_coeffs_t *pHuff_coeffs,
     493             :     ivas_spar_md_com_cfg *pSpar_cfg,
     494             :     const Word16 table_idx,
     495             :     const Word16 enc_dec )
     496             : {
     497             :     Word16 i, pred_r_index, drct_r_index, decd_r_index;
     498             :     Word16 num_quant_points_pred_r, num_quant_points_drct_r, num_quant_points_decd_r;
     499             :     ivas_huffman_cfg_t *p_huff_cfg;
     500             : 
     501       17256 :     FOR( i = 0; i < MAX_QUANT_STRATS; i++ )
     502             :     {
     503       12942 :         p_huff_cfg = &pHuff_coeffs->pred_huff_re[i];
     504       12942 :         num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */
     505       12942 :         move16();
     506       12942 :         pred_r_index = ivas_map_num_pred_r_to_idx_fx( num_quant_points_pred_r, 0 );
     507       12942 :         p_huff_cfg->codebook = &ivas_huff_pred_r_consts[pred_r_index].code_book[0][0];
     508       12942 :         IF( EQ_16( enc_dec, DEC ) )
     509             :         {
     510        6471 :             p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].PR.q_levels[0];
     511        6471 :             move16();
     512        6471 :             ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg );
     513             :         }
     514             : 
     515       12942 :         p_huff_cfg = &pHuff_coeffs->drct_huff_re[i];
     516       12942 :         num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */
     517       12942 :         move16();
     518       12942 :         drct_r_index = ivas_map_num_drct_r_to_idx_fx( num_quant_points_drct_r );
     519       12942 :         p_huff_cfg->codebook = &ivas_huff_drct_r_consts[drct_r_index].code_book[0][0];
     520       12942 :         IF( EQ_16( enc_dec, DEC ) )
     521             :         {
     522        6471 :             p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].C.q_levels[0];
     523        6471 :             move16();
     524        6471 :             ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg );
     525             :         }
     526             : 
     527       12942 :         p_huff_cfg = &pHuff_coeffs->decd_huff_re[i];
     528       12942 :         num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */
     529       12942 :         move16();
     530       12942 :         decd_r_index = ivas_map_num_decd_r_to_idx_fx( num_quant_points_decd_r );
     531       12942 :         p_huff_cfg->codebook = &ivas_huff_decd_r_consts[decd_r_index].code_book[0][0];
     532       12942 :         IF( EQ_16( enc_dec, DEC ) )
     533             :         {
     534        6471 :             p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].P_r.q_levels[0];
     535        6471 :             move16();
     536        6471 :             ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg );
     537             :         }
     538             :     }
     539             : 
     540        4314 :     return;
     541             : }

Generated by: LCOV version 1.14