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 enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 268 276 97.1 %
Date: 2025-05-03 01:55:50 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      450517 : 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     6582979 :     FOR( i = 0; i < length; i++ )
      57             :     {
      58     6132462 :         IF( LT_16( pArr[i], min_val ) )
      59             :         {
      60        3091 :             pArr[i] = add( sub( max_val, min_val ), add( pArr[i], 1 ) );
      61        3091 :             move16();
      62             :         }
      63     6132462 :         IF( GT_16( pArr[i], max_val ) )
      64             :         {
      65        1460 :             pArr[i] = sub( add( min_val, pArr[i] ), add( max_val, 1 ) );
      66        1460 :             move16();
      67             :         }
      68             :     }
      69             : 
      70      450517 :     return;
      71             : }
      72             : 
      73             : 
      74             : /*-----------------------------------------------------------------------------------------*
      75             :  * Function ivas_get_cum_freq_model()
      76             :  *
      77             :  * get cumulative frequency model
      78             :  *-----------------------------------------------------------------------------------------*/
      79             : 
      80      261000 : 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      261000 :     pCum_freq_model[length] = 0;
      88      261000 :     move16();
      89             : 
      90     2434080 :     FOR( i = length; i > 0; i-- )
      91             :     {
      92     2173080 :         pCum_freq_model[i - 1] = add( pCum_freq_model[i], pFreq_model[i] );
      93     2173080 :         move16();
      94             :     }
      95             : 
      96      261000 :     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       21750 : 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       21750 :     Word16 pred_r_to_idx = -1;
     111       21750 :     move16();
     112       21750 :     IF( active_w_flag == 0 )
     113             :     {
     114       17790 :         SWITCH( num_quant_points_pred_r )
     115             :         {
     116        2604 :             case 1:
     117        2604 :                 pred_r_to_idx = PRED_Q_1;
     118        2604 :                 move16();
     119        2604 :                 BREAK;
     120        1319 :             case 7:
     121        1319 :                 pred_r_to_idx = PRED_Q_7;
     122        1319 :                 move16();
     123        1319 :                 BREAK;
     124        5520 :             case 15:
     125        5520 :                 pred_r_to_idx = PRED_Q_15;
     126        5520 :                 move16();
     127        5520 :                 BREAK;
     128        7045 :             case 21:
     129        7045 :                 pred_r_to_idx = PRED_Q_21;
     130        7045 :                 move16();
     131        7045 :                 BREAK;
     132        1302 :             case 31:
     133        1302 :                 pred_r_to_idx = PRED_Q_31;
     134        1302 :                 move16();
     135        1302 :                 BREAK;
     136           0 :             default:
     137           0 :                 assert( !"Forbidden value for prediction quantization strategy index" );
     138             :                 BREAK;
     139             :         }
     140             :     }
     141             :     ELSE
     142             :     {
     143        3960 :         SWITCH( num_quant_points_pred_r )
     144             :         {
     145        1001 :             case 7:
     146        1001 :                 pred_r_to_idx = PRED_Q_7_ACTIVE_W;
     147        1001 :                 move16();
     148        1001 :                 BREAK;
     149        2640 :             case 15:
     150        2640 :                 pred_r_to_idx = PRED_Q_15_ACTIVE_W;
     151        2640 :                 move16();
     152        2640 :                 BREAK;
     153         319 :             case 21:
     154         319 :                 pred_r_to_idx = PRED_Q_21_ACTIVE_W;
     155         319 :                 move16();
     156         319 :                 BREAK;
     157           0 :             default:
     158           0 :                 assert( !"Forbidden value for prediction quantization strategy index" );
     159             :                 BREAK;
     160             :         }
     161             :     }
     162             : 
     163       21750 :     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       21750 : Word16 ivas_map_num_drct_r_to_idx_fx(
     174             :     const Word16 num_quant_points_drct_r )
     175             : {
     176       21750 :     Word16 drct_r_to_idx = -1;
     177       21750 :     move16();
     178       21750 :     SWITCH( num_quant_points_drct_r )
     179             :     {
     180       10828 :         case 1:
     181       10828 :             drct_r_to_idx = DRCT_Q_1;
     182       10828 :             move16();
     183       10828 :             BREAK;
     184        6728 :         case 7:
     185        6728 :             drct_r_to_idx = DRCT_Q_7;
     186        6728 :             move16();
     187        6728 :             BREAK;
     188        1868 :         case 9:
     189        1868 :             drct_r_to_idx = DRCT_Q_9;
     190        1868 :             move16();
     191        1868 :             BREAK;
     192        2326 :         case 11:
     193        2326 :             drct_r_to_idx = DRCT_Q_11;
     194        2326 :             move16();
     195        2326 :             BREAK;
     196           0 :         default:
     197           0 :             assert( !"Forbidden value for DRCT quantization strategy index" );
     198             :             BREAK;
     199             :     }
     200       21750 :     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       21750 : Word16 ivas_map_num_decd_r_to_idx_fx(
     211             :     const Word16 num_quant_points_decd_r )
     212             : {
     213       21750 :     Word16 decd_r_to_idx = -1;
     214       21750 :     move16();
     215       21750 :     SWITCH( num_quant_points_decd_r )
     216             :     {
     217        2908 :         case 1:
     218        2908 :             decd_r_to_idx = DECD_Q_1;
     219        2908 :             move16();
     220        2908 :             BREAK;
     221        6400 :         case 3:
     222        6400 :             decd_r_to_idx = DECD_Q_3;
     223        6400 :             move16();
     224        6400 :             BREAK;
     225        6920 :         case 5:
     226        6920 :             decd_r_to_idx = DECD_Q_5;
     227        6920 :             move16();
     228        6920 :             BREAK;
     229        1754 :         case 7:
     230        1754 :             decd_r_to_idx = DECD_Q_7;
     231        1754 :             move16();
     232        1754 :             BREAK;
     233        1868 :         case 9:
     234        1868 :             decd_r_to_idx = DECD_Q_9;
     235        1868 :             move16();
     236        1868 :             BREAK;
     237        1900 :         case 11:
     238        1900 :             decd_r_to_idx = DECD_Q_11;
     239        1900 :             move16();
     240        1900 :             BREAK;
     241           0 :         default:
     242           0 :             assert( !"Forbidden value for DECD quantization strategy index" );
     243             :             BREAK;
     244             :     }
     245             : 
     246       21750 :     return decd_r_to_idx;
     247             : }
     248             : 
     249             : 
     250             : /*---------------------------------------------------------------------------------------- - *
     251             :  * Function ivas_spar_arith_com_init()
     252             :  *
     253             :  * arith coder init
     254             :  *---------------------------------------------------------------------------------------- - */
     255             : 
     256       32625 : 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       32625 :     pArith->vals = pFreq_models->vals;
     268       32625 :     pArith->range = q_levels;
     269       32625 :     move16();
     270       32625 :     pArith->num_models = pFreq_models->num_models;
     271       32625 :     move16();
     272       32625 :     pArith->dyn_model_bits = ivas_get_bits_to_encode( pArith->num_models - 1 );
     273       32625 :     move16();
     274       32625 :     pArith->pFreq_model = pFreq_models->freq_model[0];
     275             : 
     276       32625 :     ivas_get_cum_freq_model_fx( pArith->pFreq_model, pArith->range, pArith->cum_freq[0] );
     277             : 
     278      130500 :     FOR( i = 0; i < pArith->num_models - 1; i++ )
     279             :     {
     280       97875 :         pArith->pAlt_freq_models[i] = pFreq_models->freq_model[i + 1];
     281       97875 :         ivas_get_cum_freq_model_fx( pArith->pAlt_freq_models[i], pArith->range, pArith->cum_freq[i + 1] );
     282             :     }
     283             : 
     284       32625 :     IF( enc_dec == ENC )
     285             :     {
     286       16749 :         sum = 0;
     287       16749 :         move16();
     288      156200 :         FOR( i = 1; i < pArith->range + 1; i++ )
     289             :         {
     290      139451 :             sum = add( sum, pArith->pFreq_model[i] );
     291             :         }
     292       16749 :         log2_int = norm_s( sum );
     293       16749 :         tmp32 = L_deposit_h( shl( sum, log2_int ) );
     294       16749 :         log2_frac = Log2_norm_lc( tmp32 );
     295       16749 :         log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     296       16749 :         L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     297      156200 :         FOR( i = 1; i < pArith->range + 1; i++ )
     298             :         {
     299      139451 :             log2_int = norm_s( pArith->pFreq_model[i] );
     300      139451 :             tmp32 = L_deposit_h( shl( pArith->pFreq_model[i], log2_int ) );
     301      139451 :             log2_frac = Log2_norm_lc( tmp32 );
     302      139451 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     303      139451 :             L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     304      139451 :             pArith->saved_dist_arr[0][i - 1] = L_sub( L_tmp1, L_tmp2 );
     305      139451 :             move32();
     306             :         }
     307             : 
     308       66996 :         FOR( j = 0; j < pArith->num_models - 1; j++ )
     309             :         {
     310       50247 :             sum = 0;
     311       50247 :             move16();
     312      468600 :             FOR( i = 1; i < pArith->range + 1; i++ )
     313             :             {
     314      418353 :                 sum = add( sum, pArith->pAlt_freq_models[j][i] );
     315             :             }
     316       50247 :             log2_int = norm_s( sum );
     317       50247 :             tmp32 = L_deposit_h( shl( sum, log2_int ) );
     318       50247 :             log2_frac = Log2_norm_lc( tmp32 );
     319       50247 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     320       50247 :             L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     321      468600 :             FOR( i = 1; i < pArith->range + 1; i++ )
     322             :             {
     323      418353 :                 log2_int = norm_s( pArith->pAlt_freq_models[j][i] );
     324      418353 :                 tmp32 = L_deposit_h( shl( pArith->pAlt_freq_models[j][i], log2_int ) );
     325      418353 :                 log2_frac = Log2_norm_lc( tmp32 );
     326      418353 :                 log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     327      418353 :                 L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     328      418353 :                 pArith->saved_dist_arr[j + 1][i - 1] = L_sub( L_tmp1, L_tmp2 );
     329      418353 :                 move32();
     330             :             }
     331             :         }
     332             :     }
     333             : 
     334       32625 :     pArith_diff->vals = pFreq_models->diff_vals;
     335       32625 :     pArith_diff->range = q_levels;
     336       32625 :     move16();
     337       32625 :     pArith_diff->num_models = pFreq_models->diff_num_models;
     338       32625 :     move16();
     339       32625 :     pArith_diff->dyn_model_bits = ivas_get_bits_to_encode( pArith_diff->num_models - 1 );
     340       32625 :     move16();
     341       32625 :     pArith_diff->pFreq_model = pFreq_models->diff_freq_model[0];
     342             : 
     343       32625 :     ivas_get_cum_freq_model_fx( pArith_diff->pFreq_model, pArith_diff->range, pArith_diff->cum_freq[0] );
     344             : 
     345      130500 :     FOR( i = 0; i < pArith_diff->num_models - 1; i++ )
     346             :     {
     347       97875 :         pArith_diff->pAlt_freq_models[i] = pFreq_models->diff_freq_model[i + 1];
     348       97875 :         ivas_get_cum_freq_model_fx( pArith_diff->pAlt_freq_models[i], pArith_diff->range, pArith_diff->cum_freq[i + 1] );
     349             :     }
     350             : 
     351       32625 :     IF( enc_dec == ENC )
     352             :     {
     353       16749 :         sum = 0;
     354       16749 :         move16();
     355      156200 :         FOR( i = 1; i < pArith_diff->range + 1; i++ )
     356             :         {
     357      139451 :             sum = add( sum, pArith_diff->pFreq_model[i] );
     358             :         }
     359       16749 :         log2_int = norm_s( sum );
     360       16749 :         tmp32 = L_deposit_h( shl( sum, log2_int ) );
     361       16749 :         log2_frac = Log2_norm_lc( tmp32 );
     362       16749 :         log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     363       16749 :         L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     364      156200 :         FOR( i = 1; i < pArith_diff->range + 1; i++ )
     365             :         {
     366      139451 :             log2_int = norm_s( pArith_diff->pFreq_model[i] );
     367      139451 :             tmp32 = L_deposit_h( shl( pArith_diff->pFreq_model[i], log2_int ) );
     368      139451 :             log2_frac = Log2_norm_lc( tmp32 );
     369      139451 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     370      139451 :             L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     371      139451 :             pArith_diff->saved_dist_arr[0][i - 1] = L_sub( L_tmp1, L_tmp2 );
     372      139451 :             move32();
     373             :         }
     374             : 
     375       66996 :         FOR( j = 0; j < pArith_diff->num_models - 1; j++ )
     376             :         {
     377       50247 :             sum = 0;
     378       50247 :             move16();
     379      468600 :             FOR( i = 1; i < pArith_diff->range + 1; i++ )
     380             :             {
     381      418353 :                 sum = add( sum, pArith_diff->pAlt_freq_models[j][i] );
     382             :             }
     383       50247 :             log2_int = norm_s( sum );
     384       50247 :             tmp32 = L_deposit_h( shl( sum, log2_int ) );
     385       50247 :             log2_frac = Log2_norm_lc( tmp32 );
     386       50247 :             log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     387       50247 :             L_tmp2 = L_add( log2_int32, log2_frac ); /* Q15 */
     388      468600 :             FOR( i = 1; i < pArith_diff->range + 1; i++ )
     389             :             {
     390      418353 :                 log2_int = norm_s( pArith_diff->pAlt_freq_models[j][i] );
     391      418353 :                 tmp32 = L_deposit_h( shl( pArith_diff->pAlt_freq_models[j][i], log2_int ) );
     392      418353 :                 log2_frac = Log2_norm_lc( tmp32 );
     393      418353 :                 log2_int32 = L_shl( sub( sub( 30, log2_int ), 16 ), 15 );
     394      418353 :                 L_tmp1 = L_add( log2_int32, log2_frac ); /* Q15 */
     395      418353 :                 pArith_diff->saved_dist_arr[j + 1][i - 1] = L_sub( L_tmp1, L_tmp2 );
     396      418353 :                 move32();
     397             :             }
     398             :         }
     399             :     }
     400             : 
     401       32625 :     return;
     402             : }
     403             : 
     404             : 
     405             : /*-----------------------------------------------------------------------------------------*
     406             :  * Function ivas_spar_arith_coeffs_com_init()
     407             :  *
     408             :  * Init for Arithm. coding
     409             :  *-----------------------------------------------------------------------------------------*/
     410             : 
     411        3625 : 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       14500 :     FOR( i = 0; i < MAX_QUANT_STRATS; i++ )
     421             :     {
     422       10875 :         num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */
     423       10875 :         move16();
     424       10875 :         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       10875 :         ivas_spar_arith_com_init_fx( &pArith_coeffs->pred_arith_re[i], &ivas_arith_pred_r_consts[pred_r_index],
     426       10875 :                                      &pArith_coeffs->pred_arith_re_diff[i], pSpar_cfg->quant_strat[i].PR.q_levels[0], enc_dec );
     427             : 
     428       10875 :         num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */
     429       10875 :         move16();
     430       10875 :         drct_r_index = ivas_map_num_drct_r_to_idx_fx( num_quant_points_drct_r );
     431       10875 :         ivas_spar_arith_com_init_fx( &pArith_coeffs->drct_arith_re[i], &ivas_arith_drct_r_consts[drct_r_index],
     432       10875 :                                      &pArith_coeffs->drct_arith_re_diff[i], pSpar_cfg->quant_strat[i].C.q_levels[0], enc_dec );
     433             : 
     434       10875 :         num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */
     435       10875 :         move16();
     436       10875 :         decd_r_index = ivas_map_num_decd_r_to_idx_fx( num_quant_points_decd_r );
     437       10875 :         ivas_spar_arith_com_init_fx( &pArith_coeffs->decd_arith_re[i], &ivas_arith_decd_r_consts[decd_r_index],
     438       10875 :                                      &pArith_coeffs->decd_arith_re_diff[i], pSpar_cfg->quant_strat[i].P_r.q_levels[0], enc_dec );
     439             :     }
     440             : 
     441        3625 :     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       15876 : 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       15876 :     codebook = p_huff_cfg->codebook;
     458             : 
     459       15876 :     p_huff_cfg->min_len = p_huff_cfg->sym_len;
     460       15876 :     move16();
     461       15876 :     p_huff_cfg->max_len = 0;
     462       15876 :     move16();
     463             : 
     464      148060 :     FOR( i = 0; i < p_huff_cfg->sym_len; i++ )
     465             :     {
     466      132184 :         code_len = codebook[1];
     467      132184 :         move16();
     468      132184 :         if ( GT_16( p_huff_cfg->min_len, code_len ) )
     469             :         {
     470       27358 :             p_huff_cfg->min_len = code_len;
     471       27358 :             move16();
     472             :         }
     473      132184 :         if ( LT_16( p_huff_cfg->max_len, code_len ) )
     474             :         {
     475       11907 :             p_huff_cfg->max_len = code_len;
     476       11907 :             move16();
     477             :         }
     478      132184 :         codebook = codebook + 3;
     479             :     }
     480             : 
     481       15876 :     return;
     482             : }
     483             : 
     484             : 
     485             : /*-----------------------------------------------------------------------------------------*
     486             :  * Function ivas_spar_huff_coeffs_com_init()
     487             :  *
     488             :  * Init for Huffman decoding
     489             :  *-----------------------------------------------------------------------------------------*/
     490             : 
     491        3625 : 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       14500 :     FOR( i = 0; i < MAX_QUANT_STRATS; i++ )
     502             :     {
     503       10875 :         p_huff_cfg = &pHuff_coeffs->pred_huff_re[i];
     504       10875 :         num_quant_points_pred_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][0]; /* 0: pred_r */
     505       10875 :         move16();
     506       10875 :         pred_r_index = ivas_map_num_pred_r_to_idx_fx( num_quant_points_pred_r, 0 );
     507       10875 :         p_huff_cfg->codebook = &ivas_huff_pred_r_consts[pred_r_index].code_book[0][0];
     508       10875 :         IF( EQ_16( enc_dec, DEC ) )
     509             :         {
     510        5292 :             p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].PR.q_levels[0];
     511        5292 :             move16();
     512        5292 :             ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg );
     513             :         }
     514             : 
     515       10875 :         p_huff_cfg = &pHuff_coeffs->drct_huff_re[i];
     516       10875 :         num_quant_points_drct_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][1]; /* 1: drct_r */
     517       10875 :         move16();
     518       10875 :         drct_r_index = ivas_map_num_drct_r_to_idx_fx( num_quant_points_drct_r );
     519       10875 :         p_huff_cfg->codebook = &ivas_huff_drct_r_consts[drct_r_index].code_book[0][0];
     520       10875 :         IF( EQ_16( enc_dec, DEC ) )
     521             :         {
     522        5292 :             p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].C.q_levels[0];
     523        5292 :             move16();
     524        5292 :             ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg );
     525             :         }
     526             : 
     527       10875 :         p_huff_cfg = &pHuff_coeffs->decd_huff_re[i];
     528       10875 :         num_quant_points_decd_r = ivas_spar_br_table_consts[table_idx].q_lvls[i][2]; /* 2: decd_r */
     529       10875 :         move16();
     530       10875 :         decd_r_index = ivas_map_num_decd_r_to_idx_fx( num_quant_points_decd_r );
     531       10875 :         p_huff_cfg->codebook = &ivas_huff_decd_r_consts[decd_r_index].code_book[0][0];
     532       10875 :         IF( EQ_16( enc_dec, DEC ) )
     533             :         {
     534        5292 :             p_huff_cfg->sym_len = pSpar_cfg->quant_strat[i].P_r.q_levels[0];
     535        5292 :             move16();
     536        5292 :             ivas_huffman_dec_init_min_max_len_fx( p_huff_cfg );
     537             :         }
     538             :     }
     539             : 
     540        3625 :     return;
     541             : }

Generated by: LCOV version 1.14