LCOV - code coverage report
Current view: top level - lib_isar - isar_splitRenderer_utils.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ b5bd5e0684ad2d9250297e1e7a0ddc986cb7b37e Lines: 321 362 88.7 %
Date: 2025-10-27 07:01:45 Functions: 25 25 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 <math.h>
      36             : #include "ivas_prot.h"
      37             : #include "isar_rom_post_rend.h"
      38             : #include "lib_isar_post_rend.h"
      39             : #include "isar_prot.h"
      40             : #ifdef DEBUGGING
      41             : #include "debug.h"
      42             : #endif
      43             : #include "wmc_auto.h"
      44             : 
      45             : 
      46             : /*-------------------------------------------------------------------------
      47             :  * Function isar_mat_mult_2by2_complex()
      48             :  *
      49             :  *
      50             :  *------------------------------------------------------------------------*/
      51             : 
      52    23526640 : void isar_mat_mult_2by2_complex(
      53             :     float in_re1[2][2],
      54             :     float in_im1[2][2],
      55             :     float in_re2[2][2],
      56             :     float in_im2[2][2],
      57             :     float out_re2[2][2],
      58             :     float out_im2[2][2] )
      59             : {
      60             :     int16_t i, j;
      61             :     float tmp_re, tmp_im;
      62             : 
      63    70579920 :     for ( i = 0; i < 2; i++ )
      64             :     {
      65   141159840 :         for ( j = 0; j < 2; j++ )
      66             :         {
      67    94106560 :             IVAS_CMULT_FLOAT( in_re1[i][0], in_im1[i][0], in_re2[0][j], in_im2[0][j], tmp_re, tmp_im );
      68    94106560 :             out_re2[i][j] = tmp_re;
      69    94106560 :             out_im2[i][j] = tmp_im;
      70             : 
      71    94106560 :             IVAS_CMULT_FLOAT( in_re1[i][1], in_im1[i][1], in_re2[1][j], in_im2[1][j], tmp_re, tmp_im );
      72    94106560 :             out_re2[i][j] += tmp_re;
      73    94106560 :             out_im2[i][j] += tmp_im;
      74             :         }
      75             :     }
      76             : 
      77    23526640 :     return;
      78             : }
      79             : 
      80             : 
      81             : /*-------------------------------------------------------------------------
      82             :  * Function isar_split_rend_huffman_dec_init_min_max_len()
      83             :  *
      84             :  *
      85             :  *------------------------------------------------------------------------*/
      86             : 
      87       25752 : static void isar_split_rend_huffman_dec_init_min_max_len(
      88             :     isar_split_rend_huffman_cfg_t *p_huff_cfg )
      89             : {
      90             :     int16_t i, code_len;
      91             :     const int32_t *codebook;
      92             : 
      93       25752 :     codebook = p_huff_cfg->codebook;
      94             : 
      95       25752 :     p_huff_cfg->min_len = p_huff_cfg->sym_len;
      96       25752 :     p_huff_cfg->max_len = 0;
      97             : 
      98      755392 :     for ( i = 0; i < p_huff_cfg->sym_len; i++ )
      99             :     {
     100      729640 :         code_len = (int16_t) codebook[1];
     101      729640 :         if ( p_huff_cfg->min_len > code_len )
     102             :         {
     103      154512 :             p_huff_cfg->min_len = code_len;
     104             :         }
     105      729640 :         if ( p_huff_cfg->max_len < code_len )
     106             :         {
     107      137344 :             p_huff_cfg->max_len = code_len;
     108             :         }
     109      729640 :         codebook = codebook + 3;
     110             :     }
     111             : 
     112       25752 :     return;
     113             : }
     114             : 
     115             : 
     116             : /*-------------------------------------------------------------------------
     117             :  * Function is_idx_present()
     118             :  *
     119             :  *
     120             :  *------------------------------------------------------------------------*/
     121             : 
     122    21584468 : static int16_t is_idx_present(
     123             :     int16_t *idx_list,
     124             :     const int16_t idx,
     125             :     const int16_t len )
     126             : {
     127             :     int16_t i;
     128             : 
     129   381554508 :     for ( i = 0; i < len; i++ )
     130             :     {
     131   373695856 :         if ( idx_list[i] == idx )
     132             :         {
     133    13725816 :             return 1;
     134             :         }
     135             :     }
     136             : 
     137     7858652 :     return 0;
     138             : }
     139             : 
     140             : 
     141             : /*-------------------------------------------------------------------------
     142             :  * Function isar_split_huff_get_idx_trav_list()
     143             :  *
     144             :  *
     145             :  *------------------------------------------------------------------------*/
     146             : 
     147       25752 : static void isar_split_huff_get_idx_trav_list(
     148             :     int16_t *idx_list,
     149             :     isar_split_rend_huffman_cfg_t *p_huff_cfg )
     150             : {
     151             :     int16_t i, j, min_idx;
     152             :     int32_t min_bits;
     153             :     const int32_t *codebook;
     154             : 
     155      755392 :     for ( i = 0; i < p_huff_cfg->sym_len; i++ )
     156             :     {
     157      729640 :         idx_list[i] = -1;
     158             :     }
     159             : 
     160      755392 :     for ( i = 0; i < p_huff_cfg->sym_len; i++ )
     161             :     {
     162      729640 :         codebook = p_huff_cfg->codebook;
     163      729640 :         min_bits = p_huff_cfg->max_len;
     164      729640 :         min_idx = -1;
     165    28910912 :         for ( j = 0; j < p_huff_cfg->sym_len; j++ )
     166             :         {
     167    28181272 :             if ( ( min_bits >= codebook[1] ) && ( is_idx_present( idx_list, j, i + 1 ) == 0 ) )
     168             :             {
     169     7858652 :                 min_bits = codebook[1];
     170     7858652 :                 min_idx = j;
     171             :             }
     172    28181272 :             codebook += 3;
     173             :         }
     174      729640 :         idx_list[i] = min_idx;
     175             :     }
     176             : 
     177       25752 :     return;
     178             : }
     179             : 
     180             : 
     181             : /*-------------------------------------------------------------------------
     182             :  * Function isar_split_rend_init_huff_cfg()
     183             :  *
     184             :  *
     185             :  *------------------------------------------------------------------------*/
     186             : 
     187        4292 : void isar_split_rend_init_huff_cfg(
     188             :     ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg )
     189             : {
     190        4292 :     pHuff_cfg->pred[0].codebook = &isar_split_rend_huff_pred31_consts[0][0];
     191        4292 :     pHuff_cfg->pred[0].sym_len = ISAR_SPLIT_REND_PRED_31QUANT_PNTS;
     192        4292 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[0] );
     193        4292 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[0], &pHuff_cfg->pred[0] );
     194        4292 :     pHuff_cfg->pred_base2_code_len[0] = (int16_t) ceilf( log2f( pHuff_cfg->pred[0].sym_len ) );
     195             : 
     196        4292 :     pHuff_cfg->pred[1].codebook = &isar_split_rend_huff_pred63_consts[0][0];
     197        4292 :     pHuff_cfg->pred[1].sym_len = ISAR_SPLIT_REND_PRED_63QUANT_PNTS;
     198        4292 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[1] );
     199        4292 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[1], &pHuff_cfg->pred[1] );
     200        4292 :     pHuff_cfg->pred_base2_code_len[1] = (int16_t) ceilf( log2f( pHuff_cfg->pred[1].sym_len ) );
     201             : 
     202             : 
     203        4292 :     pHuff_cfg->pred_roll.codebook = &isar_split_rend_huff_roll_pred_consts[0][0];
     204        4292 :     pHuff_cfg->pred_roll.sym_len = ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS;
     205        4292 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred_roll );
     206        4292 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_roll_idx_trav, &pHuff_cfg->pred_roll );
     207        4292 :     pHuff_cfg->pred_roll_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->pred_roll.sym_len ) );
     208             : 
     209        4292 :     pHuff_cfg->gd.codebook = &isar_split_rend_huff_d_consts[0][0];
     210        4292 :     pHuff_cfg->gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS;
     211        4292 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->gd );
     212        4292 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->gd_idx_trav, &pHuff_cfg->gd );
     213        4292 :     pHuff_cfg->gd_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->gd.sym_len ) );
     214             : 
     215        4292 :     pHuff_cfg->p_gd.codebook = &isar_split_rend_huff_p_d_consts[0][0];
     216        4292 :     pHuff_cfg->p_gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS;
     217        4292 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd );
     218        4292 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_idx_trav, &pHuff_cfg->p_gd );
     219        4292 :     pHuff_cfg->p_gd_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->p_gd.sym_len ) );
     220             : 
     221        4292 :     pHuff_cfg->p_gd_diff.codebook = &isar_split_rend_huff_p_d_diff_consts[0][0];
     222        4292 :     pHuff_cfg->p_gd_diff.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS;
     223        4292 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd_diff );
     224        4292 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_diff_idx_trav, &pHuff_cfg->p_gd_diff );
     225        4292 :     pHuff_cfg->p_gd_diff_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->p_gd_diff.sym_len ) );
     226             : 
     227        4292 :     return;
     228             : }
     229             : 
     230             : 
     231             : /*-------------------------------------------------------------------------
     232             :  * Function set_fix_rotation_mat()
     233             :  *
     234             :  *
     235             :  *------------------------------------------------------------------------*/
     236             : 
     237      499445 : void set_fix_rotation_mat(
     238             :     float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS],
     239             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */
     240             : )
     241             : {
     242             :     float yaw_a, cos_yaw, sin_yaw;
     243             :     int16_t pos_idx;
     244      499445 :     yaw_a = 0.0f;
     245             : 
     246     2546437 :     for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     247             :     {
     248     2046992 :         yaw_a = pMultiBinPoseData->relative_head_poses[pos_idx + 1][0];
     249     2046992 :         cos_yaw = cosf( EVS_PI * yaw_a / 180.0f );
     250     2046992 :         sin_yaw = sinf( EVS_PI * yaw_a / 180.0f );
     251     2046992 :         sin_yaw = 0.0f;
     252     2046992 :         fix_pos_rot_mat[pos_idx][0][0] = cos_yaw;
     253     2046992 :         fix_pos_rot_mat[pos_idx][1][1] = cos_yaw;
     254     2046992 :         fix_pos_rot_mat[pos_idx][0][1] = sin_yaw;
     255     2046992 :         fix_pos_rot_mat[pos_idx][1][0] = -1.0f * sin_yaw;
     256             :     }
     257             : 
     258      499445 :     return;
     259             : }
     260             : 
     261             : 
     262             : /*-------------------------------------------------------------------------
     263             :  * Function set_pose_types()
     264             :  *
     265             :  *
     266             :  *------------------------------------------------------------------------*/
     267             : 
     268      499445 : void set_pose_types(
     269             :     ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], /* o  : ISAR pose type              */
     270             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData                  /* i  : pose correction data handle */
     271             : )
     272             : {
     273             :     int16_t pos_idx;
     274             : 
     275     2546437 :     for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     276             :     {
     277     2046992 :         if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] ) > EPSILON )
     278             :         {
     279      998890 :             pose_type[pos_idx] = ANY_YAW;
     280             :         }
     281     1048102 :         else if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][2] ) > EPSILON )
     282             :         {
     283      455391 :             pose_type[pos_idx] = ANY_ROLL;
     284             :         }
     285             :         else
     286             :         {
     287      592711 :             pose_type[pos_idx] = PITCH_ONLY;
     288             :         }
     289             :     }
     290             : 
     291      499445 :     return;
     292             : }
     293             : 
     294             : 
     295             : /*-------------------------------------------------------------------------
     296             :  * Function wrap_a()
     297             :  *
     298             :  *
     299             :  *------------------------------------------------------------------------*/
     300             : 
     301    85085480 : static int16_t wrap_a(
     302             :     int16_t val,
     303             :     const int16_t min_val,
     304             :     const int16_t max_val )
     305             : {
     306    85085480 :     if ( val < min_val )
     307             :     {
     308       95515 :         val = max_val - min_val + val + 1;
     309             :     }
     310             : 
     311    85085480 :     if ( val > max_val )
     312             :     {
     313      107038 :         val = min_val + val - max_val - 1;
     314             :     }
     315             : 
     316    85085480 :     return val;
     317             : }
     318             : 
     319             : 
     320             : /*-------------------------------------------------------------------------
     321             :  * Function isar_SplitRenderer_getdiagdiff()
     322             :  *
     323             :  *
     324             :  *------------------------------------------------------------------------*/
     325             : 
     326    42542740 : void isar_SplitRenderer_getdiagdiff(
     327             :     int16_t in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS],
     328             :     int16_t out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS],
     329             :     const int16_t sign,
     330             :     const int16_t min_val,
     331             :     const int16_t max_val )
     332             : {
     333    42542740 :     out_idx[0][0] = in_idx[0][0];
     334    42542740 :     out_idx[0][1] = in_idx[0][1];
     335    42542740 :     out_idx[1][1] = in_idx[1][1] + sign * out_idx[0][0];
     336    42542740 :     out_idx[1][1] = wrap_a( out_idx[1][1], min_val, max_val );
     337    42542740 :     out_idx[1][0] = in_idx[1][0] + sign * out_idx[0][1];
     338    42542740 :     out_idx[1][0] = wrap_a( out_idx[1][0], min_val, max_val );
     339             : 
     340    42542740 :     return;
     341             : }
     342             : 
     343             : 
     344             : /*-------------------------------------------------------------------------
     345             :  * Function ISAR_SPLIT_REND_BITStream_read_int32()
     346             :  *
     347             :  *
     348             :  *------------------------------------------------------------------------*/
     349             : 
     350             : /*! r: parameter value */
     351  1031770897 : int32_t ISAR_SPLIT_REND_BITStream_read_int32(
     352             :     ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle             */
     353             :     const int32_t bits                 /* i  : number of bits to be read    */
     354             : )
     355             : {
     356             :     int32_t val, k, bit_val;
     357             : 
     358             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     359             :     assert( ( pBits->bits_written - pBits->bits_read ) >= bits );
     360             :     assert( bits <= 32 );
     361             : 
     362             : #endif
     363             :     /* write bit by bit */
     364  1031770897 :     val = 0;
     365  3756512448 :     for ( k = bits - 1; k >= 0; k-- )
     366             :     {
     367  2724741551 :         bit_val = ( pBits->bits_buf[pBits->bits_read >> 3] & ( 1 << ( pBits->bits_read & 7 ) ) ) != 0;
     368  2724741551 :         val |= bit_val << k;
     369  2724741551 :         pBits->bits_read++;
     370             :     }
     371             : 
     372  1031770897 :     return val;
     373             : }
     374             : 
     375             : 
     376             : /*-------------------------------------------------------------------------
     377             :  * Function ISAR_SPLIT_REND_BITStream_write_int32()
     378             :  *
     379             :  *
     380             :  *------------------------------------------------------------------------*/
     381             : 
     382  1042183862 : void ISAR_SPLIT_REND_BITStream_write_int32(
     383             :     ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle                 */
     384             :     const int32_t val,                 /* i  : parameter value                  */
     385             :     const int32_t bits                 /* i  : number of bits to be written     */
     386             : )
     387             : {
     388             :     int32_t mask, k;
     389             : 
     390             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     391             :     /*protection check*/
     392             :     if ( ( pBits->buf_len << 3 ) < ( pBits->bits_written + bits ) )
     393             :     {
     394             :         assert( 0 );
     395             :     }
     396             : #endif
     397             : 
     398  1042183862 :     mask = 1 << ( bits - 1 );
     399             :     /* write bit by bit */
     400  3438701985 :     for ( k = 0; k < bits; k++ )
     401             :     {
     402  2396518123 :         if ( val & mask )
     403             :         {
     404   979189499 :             pBits->bits_buf[pBits->bits_written >> 3] |= ( 1 << ( pBits->bits_written & 7 ) );
     405             :         }
     406             :         else
     407             :         {
     408  1417328624 :             pBits->bits_buf[pBits->bits_written >> 3] &= ~( 1 << ( pBits->bits_written & 7 ) );
     409             :         }
     410  2396518123 :         pBits->bits_written++;
     411  2396518123 :         mask >>= 1;
     412             :     }
     413             : 
     414  1042183862 :     return;
     415             : }
     416             : 
     417             : 
     418             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     419             : /*-------------------------------------------------------------------------
     420             :  * isar_log_cldfb2wav_data()
     421             :  *
     422             :  *
     423             :  *------------------------------------------------------------------------*/
     424             : 
     425             : void isar_log_cldfb2wav_data(
     426             :     float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
     427             :     float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
     428             :     HANDLE_CLDFB_FILTER_BANK *cldfbSyn,
     429             :     const int16_t num_chs,
     430             :     const int16_t num_freq_bands,
     431             :     const int32_t output_Fs,
     432             :     const int16_t num_slots,
     433             :     const int16_t start_slot_idx,
     434             :     const char *filename )
     435             : {
     436             :     float *RealBuffer[CLDFB_NO_COL_MAX];
     437             :     float *ImagBuffer[CLDFB_NO_COL_MAX];
     438             :     float pcm_out[BINAURAL_CHANNELS][L_FRAME48k];
     439             :     float *pPcm[BINAURAL_CHANNELS];
     440             :     float Cldfb_local_Real[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
     441             :     float Cldfb_local_Imag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
     442             :     int16_t sf, ch;
     443             : 
     444             :     assert( num_chs <= BINAURAL_CHANNELS );
     445             :     for ( ch = 0; ch < num_chs; ch++ )
     446             :     {
     447             :         for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ )
     448             :         {
     449             :             mvr2r( Cldfb_In_Real[ch][sf], Cldfb_local_Real[ch][sf], num_freq_bands );
     450             :             mvr2r( Cldfb_In_Imag[ch][sf], Cldfb_local_Imag[ch][sf], num_freq_bands );
     451             :             RealBuffer[sf - start_slot_idx] = Cldfb_local_Real[ch][sf];
     452             :             ImagBuffer[sf - start_slot_idx] = Cldfb_local_Imag[ch][sf];
     453             :         }
     454             :         cldfbSynthesis( RealBuffer, ImagBuffer, &( pcm_out[ch][0] ), num_freq_bands * num_slots, cldfbSyn[ch] );
     455             :         pPcm[ch] = pcm_out[ch];
     456             :     }
     457             :     dbgwrite_wav( pPcm, num_freq_bands * num_slots, filename, output_Fs, num_chs );
     458             : 
     459             :     return;
     460             : }
     461             : #endif
     462             : 
     463             : 
     464             : /*-------------------------------------------------------------------------
     465             :  * Function isar_get_split_rend_md_target_brate()
     466             :  *
     467             :  *
     468             :  *------------------------------------------------------------------------*/
     469             : 
     470             : /*! r: ISAR MD bitrate */
     471      241438 : int32_t isar_get_split_rend_md_target_brate(
     472             :     const int32_t SplitRendBitRate, /* i  : ISAR bitrate                    */
     473             :     const int16_t pcm_out_flag      /* i  : flag to indicate PCM output     */
     474             : )
     475             : {
     476             :     int32_t md_bitrate;
     477             : 
     478      241438 :     if ( pcm_out_flag == 1 )
     479             :     {
     480       13073 :         md_bitrate = SplitRendBitRate;
     481             :     }
     482             :     else
     483             :     {
     484      228365 :         switch ( SplitRendBitRate )
     485             :         {
     486      103284 :             case SPLIT_REND_768k:
     487             :             {
     488      103284 :                 md_bitrate = 256000;
     489      103284 :                 break;
     490             :             }
     491       92986 :             case SPLIT_REND_512k:
     492             :             {
     493       92986 :                 md_bitrate = 128000;
     494       92986 :                 break;
     495             :             }
     496       32095 :             case SPLIT_REND_384k:
     497             :             {
     498       32095 :                 md_bitrate = 128000;
     499       32095 :                 break;
     500             :             }
     501           0 :             default:
     502             :             {
     503           0 :                 return -1;
     504             :             }
     505             :         }
     506             :     }
     507             : 
     508      241438 :     return md_bitrate;
     509             : }
     510             : 
     511             : 
     512             : /*-------------------------------------------------------------------------
     513             :  * Function isar_get_lcld_bitrate()
     514             :  *
     515             :  *
     516             :  *------------------------------------------------------------------------*/
     517             : 
     518             : /*! r: LCLD codec bitrate */
     519       57768 : int32_t isar_get_lcld_bitrate(
     520             :     const int32_t SplitRendBitRate,                               /* i  : ISAR bitrate              */
     521             :     const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i  : ISAR pose correction mode */
     522             : )
     523             : {
     524       57768 :     if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
     525             :     {
     526        1698 :         switch ( SplitRendBitRate )
     527             :         {
     528         796 :             case SPLIT_REND_768k:
     529             :             {
     530         796 :                 return IVAS_512k;
     531             :             }
     532         674 :             case SPLIT_REND_512k:
     533             :             {
     534         674 :                 return IVAS_384k;
     535             :             }
     536         228 :             case SPLIT_REND_384k:
     537             :             {
     538         228 :                 return IVAS_256k;
     539             :             }
     540           0 :             default:
     541             :             {
     542           0 :                 assert( 0 );
     543             :             }
     544             :         }
     545             :     }
     546             :     else
     547             :     {
     548       56070 :         return SplitRendBitRate;
     549             :     }
     550             : 
     551             :     return -1;
     552             : }
     553             : 
     554             : 
     555             : /*-------------------------------------------------------------------------
     556             :  * Function isar_get_lc3plus_bitrate()
     557             :  *
     558             :  *
     559             :  *------------------------------------------------------------------------*/
     560             : 
     561       56334 : int32_t isar_get_lc3plus_bitrate(
     562             :     const int32_t SplitRendBitRate,                                /* i  : ISAR bitrate                 */
     563             :     const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i  : ISAR pose correction mode    */
     564             :     const int32_t nChannels,                                       /* i  : number of channels           */
     565             :     const int32_t codecFrameDurationUs                             /* i  : ISAR frame length in us      */
     566             : )
     567             : {
     568             :     int32_t bitrate;
     569             : 
     570       56334 :     bitrate = isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode );
     571             : 
     572             :     /* Check for LC3plus LEA 48_6 LC3 compatibility mode signalling */
     573       56334 :     if ( ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE == poseCorrectionMode && bitrate == 256000 && nChannels == 2 && codecFrameDurationUs == 10000 )
     574             :     {
     575       10973 :         bitrate = 2 * 126000;
     576             :     }
     577             : 
     578       56334 :     return bitrate;
     579             : }
     580             : 
     581             : 
     582             : /*-------------------------------------------------------------------------
     583             :  * Function isar_split_rend_validate_config()
     584             :  *
     585             :  *
     586             :  *------------------------------------------------------------------------*/
     587             : 
     588        5112 : ivas_error isar_split_rend_validate_config(
     589             :     const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config     */
     590             :     const int16_t pcm_out_flag                           /* i  : flag to indicate PCM output            */
     591             : )
     592             : {
     593             :     /* Valid DOF range is 0-3 */
     594        5112 :     if ( pSplitRendConfig->dof < 0 || pSplitRendConfig->dof > 3 )
     595             :     {
     596           0 :         return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Valid DOF range is 0-3" );
     597             :     }
     598             : 
     599             :     /* Only CLDFB pose correction supports HQ mode  */
     600        5112 :     if ( pSplitRendConfig->poseCorrectionMode != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB && pSplitRendConfig->hq_mode != 0 )
     601             :     {
     602           0 :         return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Only CLDFB pose correction supports HQ mode" );
     603             :     }
     604             : 
     605             :     /* Split rendering with no pose correction - 0 DOF and pose correction NONE must only ever be set together */
     606        5112 :     if ( ( pSplitRendConfig->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof != 0 ) ||
     607        5112 :          ( pSplitRendConfig->poseCorrectionMode != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof == 0 ) )
     608             :     {
     609           0 :         return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "0 DOF and pose correction NONE must only ever be set together" );
     610             :     }
     611             : 
     612        5112 :     if ( pSplitRendConfig->codec_frame_size_ms != 0 ) /* 0 means "default for current codec", will be set to actual value at a later stage */
     613             :     {
     614        2820 :         if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LCLD && pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 && pSplitRendConfig->codec_frame_size_ms != 20 )
     615             :         {
     616           0 :             return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LCLD codec" );
     617             :         }
     618             : 
     619        2820 :         if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && ( pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 ) )
     620             :         {
     621           0 :             return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LC3plus codec" );
     622             :         }
     623             :     }
     624             : 
     625             :     /* Validate bitrate */
     626        5112 :     if ( pcm_out_flag == 0 )
     627             :     {
     628        5036 :         switch ( pSplitRendConfig->splitRendBitRate )
     629             :         {
     630         600 :             case SPLIT_REND_256k:
     631         600 :                 if ( pSplitRendConfig->dof != 0 )
     632             :                 {
     633           0 :                     return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" );
     634             :                 }
     635         600 :                 break;
     636         260 :             case SPLIT_REND_320k:
     637             :                 /* Only valid with 0 DOF */
     638         260 :                 if ( pSplitRendConfig->dof != 0 )
     639             :                 {
     640           0 :                     return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" );
     641             :                 }
     642         260 :                 break;
     643        4176 :             case SPLIT_REND_384k:
     644             :             case SPLIT_REND_512k:
     645             :             case SPLIT_REND_768k:
     646             :                 /* Always valid */
     647        4176 :                 break;
     648           0 :             default:
     649           0 :                 return IVAS_ERR_LC3PLUS_INVALID_BITRATE;
     650             :         }
     651             :     }
     652             :     else
     653             :     {
     654          76 :         if ( pSplitRendConfig->dof == 1 )
     655             :         {
     656          12 :             if ( pSplitRendConfig->splitRendBitRate < 34000 )
     657             :             {
     658           0 :                 return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 34 kbps" );
     659             :             }
     660             :         }
     661          64 :         else if ( pSplitRendConfig->dof == 2 )
     662             :         {
     663           8 :             if ( pSplitRendConfig->splitRendBitRate < 50000 )
     664             :             {
     665           0 :                 return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 50 kbps" );
     666             :             }
     667             :         }
     668          56 :         else if ( pSplitRendConfig->dof == 3 )
     669             :         {
     670          56 :             if ( pSplitRendConfig->splitRendBitRate < 82000 )
     671             :             {
     672           0 :                 return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 82 kbps" );
     673             :             }
     674             :         }
     675             :     }
     676             : 
     677        5112 :     return IVAS_ERR_OK;
     678             : }
     679             : 
     680             : 
     681             : /*-------------------------------------------------------------------------
     682             :  * Function isar_split_rend_get_quant_params()
     683             :  *
     684             :  *
     685             :  *------------------------------------------------------------------------*/
     686             : 
     687      495153 : void isar_split_rend_get_quant_params(
     688             :     const int16_t num_md_bands,
     689             :     int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     690             :     int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     691             :     int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     692             :     float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     693             :     float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     694             :     int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     695             :     int16_t bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     696             :     int16_t pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     697             :     int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS],
     698             :     const int16_t ro_flag,
     699             :     int16_t *num_quant_strats )
     700             : {
     701             :     int16_t q;
     702             : 
     703      495153 :     *num_quant_strats = ISAR_SPLIT_REND_NUM_QUANT_STRATS;
     704             : 
     705      495153 :     pred_quant_pnts_yaw[0] = ISAR_SPLIT_REND_PRED_63QUANT_PNTS;
     706      495153 :     pred_quantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_Q_STEP;
     707      495153 :     pred_1byquantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_1BYQ_STEP;
     708     1980612 :     for ( q = 1; q < *num_quant_strats; q++ )
     709             :     {
     710     1485459 :         pred_quant_pnts_yaw[q] = ISAR_SPLIT_REND_PRED_31QUANT_PNTS;
     711     1485459 :         pred_quantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_Q_STEP;
     712     1485459 :         pred_1byquantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_1BYQ_STEP;
     713             :     }
     714             : 
     715     2475765 :     for ( q = 0; q < *num_quant_strats; q++ )
     716             :     {
     717     1980612 :         pred_real_bands_yaw[q] = num_md_bands;
     718     1980612 :         pred_real_bands_roll[q] = num_md_bands;
     719             :     }
     720             : 
     721      495153 :     if ( ro_flag )
     722             :     {
     723     1196745 :         for ( q = 0; q < *num_quant_strats; q++ )
     724             :         {
     725      957396 :             pred_imag_bands_yaw[q] = SPLIT_REND_RO_MD_BAND_THRESH;
     726             :         }
     727             :     }
     728             :     else
     729             :     {
     730      767412 :         for ( q = 0; q < *num_quant_strats - 2; q++ )
     731             :         {
     732      511608 :             pred_imag_bands_yaw[q] = num_md_bands;
     733             :         }
     734      255804 :         pred_imag_bands_yaw[( *num_quant_strats - 2 )] = COMPLEX_MD_BAND_THRESH_HIGH;
     735      255804 :         pred_imag_bands_yaw[( *num_quant_strats - 1 )] = COMPLEX_MD_BAND_THRESH_LOW;
     736             :     }
     737             : 
     738     2475765 :     for ( q = 0; q < *num_quant_strats; q++ )
     739             :     {
     740     1980612 :         pred_imag_bands_roll[q] = SPLIT_REND_RO_MD_BAND_THRESH;
     741             :     }
     742             : 
     743     2475765 :     for ( q = 0; q < *num_quant_strats; q++ )
     744             :     {
     745     1980612 :         d_bands_yaw[q] = 0;
     746     1980612 :         bands_pitch[q] = num_md_bands;
     747             :     }
     748             : 
     749      495153 :     return;
     750             : }
     751             : 
     752             : 
     753             : /*-------------------------------------------------------------------------
     754             :  * Function isar_renderSplitGetRot_axisNumBits()
     755             :  *
     756             :  *
     757             :  *------------------------------------------------------------------------*/
     758             : 
     759      495153 : int16_t isar_renderSplitGetRot_axisNumBits(
     760             :     const int16_t dof )
     761             : {
     762             :     int16_t num_bits;
     763      495153 :     if ( dof < 3 )
     764             :     {
     765      184204 :         num_bits = 2;
     766             :     }
     767             :     else
     768             :     {
     769      310949 :         num_bits = 0;
     770             :     }
     771             : 
     772      495153 :     return num_bits;
     773             : }
     774             : 
     775             : 
     776             : /*-------------------------------------------------------------------------
     777             :  * Function isar_renderSplitGetRot_axisFromCode()
     778             :  *
     779             :  *
     780             :  *------------------------------------------------------------------------*/
     781             : 
     782      253715 : ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode(
     783             :     const int16_t dof,
     784             :     const int16_t code )
     785             : {
     786             :     ISAR_SPLIT_REND_ROT_AXIS rot_axis;
     787             : 
     788      253715 :     if ( dof == 1 )
     789             :     {
     790       67226 :         rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code;
     791             :     }
     792      186489 :     else if ( dof == 2 )
     793             :     {
     794       34176 :         if ( code == 0 )
     795             :         {
     796       34176 :             rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code;
     797             :         }
     798             :         else
     799             :         {
     800           0 :             rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) ( code - 1 ) + YAW_PITCH;
     801             :         }
     802             :     }
     803             :     else
     804             :     {
     805      152313 :         rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) DEFAULT_AXIS;
     806             :     }
     807             : 
     808      253715 :     return rot_axis;
     809             : }
     810             : 
     811             : 
     812             : /*-------------------------------------------------------------------------
     813             :  * Function isar_renderSplitGetCodeFromRot_axis()
     814             :  *
     815             :  *
     816             :  *------------------------------------------------------------------------*/
     817             : 
     818      241438 : int16_t isar_renderSplitGetCodeFromRot_axis(
     819             :     const int16_t dof,
     820             :     const ISAR_SPLIT_REND_ROT_AXIS rot_axis,
     821             :     int16_t *num_bits )
     822             : {
     823      241438 :     int16_t code = 0;
     824             : 
     825      241438 :     if ( dof == 1 )
     826             :     {
     827       48582 :         code = (int16_t) rot_axis;
     828             :     }
     829      192856 :     else if ( dof == 2 )
     830             :     {
     831       34220 :         if ( rot_axis == DEFAULT_AXIS )
     832             :         {
     833       34220 :             code = (int16_t) rot_axis;
     834             :         }
     835             :         else
     836             :         {
     837           0 :             code = (int16_t) ( rot_axis - YAW_PITCH ) + 1;
     838             :         }
     839             :     }
     840             :     else
     841             :     {
     842      158636 :         code = (int16_t) DEFAULT_AXIS;
     843             :     }
     844      241438 :     *num_bits = isar_renderSplitGetRot_axisNumBits( dof );
     845             : 
     846      241438 :     return code;
     847             : }
     848             : 
     849             : 
     850             : /*-------------------------------------------------------------------------
     851             :  * Function isar_renderSplitGetMultiBinPoseData()
     852             :  *
     853             :  *
     854             :  *------------------------------------------------------------------------*/
     855             : 
     856      899591 : void isar_renderSplitGetMultiBinPoseData(
     857             :     const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i  : Split renderer pre-renderer config                       */
     858             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,           /* i/o: pose correction data handle                              */
     859             :     const ISAR_SPLIT_REND_ROT_AXIS rot_axis                /* i  : external control for rotation axis for split rendering   */
     860             : )
     861             : {
     862             :     int16_t pos_idx, num_yaw_poses, num_pitch_poses, num_roll_poses;
     863             :     const float *relative_yaw_angles;
     864             :     const float *relative_pitch_angles;
     865             :     const float *relative_roll_angles;
     866             : 
     867     8096319 :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
     868             :     {
     869     7196728 :         pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f;
     870     7196728 :         pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f;
     871     7196728 :         pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f;
     872             :     }
     873             : 
     874             :     /* 0 DOF defaults */
     875      899591 :     num_yaw_poses = 0;
     876      899591 :     num_pitch_poses = 0;
     877      899591 :     num_roll_poses = 0;
     878             : 
     879             :     /* defaults for all DOF except 3DOF HQ */
     880      899591 :     relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles_hq;
     881      899591 :     relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles_hq;
     882      899591 :     relative_roll_angles = isar_split_rend_relative_roll_pos_angles_hq;
     883             : 
     884      899591 :     if ( pSplit_rend_config->dof == 1 )
     885             :     {
     886      155536 :         switch ( rot_axis )
     887             :         {
     888      155536 :             case DEFAULT_AXIS:
     889             :             case YAW:
     890             :             {
     891      155536 :                 num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     892      155536 :                 break;
     893             :             }
     894           0 :             case PITCH:
     895             :             {
     896           0 :                 num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES;
     897           0 :                 break;
     898             :             }
     899           0 :             case ROLL:
     900             :             {
     901           0 :                 num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES;
     902           0 :                 break;
     903             :             }
     904           0 :             default:
     905             :             {
     906           0 :                 assert( 0 && "unsupported rotation axis value" );
     907             :             }
     908             :         }
     909             :     }
     910      744055 :     else if ( pSplit_rend_config->dof == 2 )
     911             :     {
     912       96846 :         switch ( rot_axis )
     913             :         {
     914       96846 :             case DEFAULT_AXIS:
     915             :             case YAW_PITCH:
     916             :             {
     917       96846 :                 num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     918       96846 :                 num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES;
     919       96846 :                 break;
     920             :             }
     921           0 :             case YAW_ROLL:
     922             :             {
     923           0 :                 num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     924           0 :                 num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES;
     925           0 :                 break;
     926             :             }
     927           0 :             case PITCH_ROLL:
     928             :             {
     929           0 :                 num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES;
     930           0 :                 num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES;
     931           0 :                 break;
     932             :             }
     933           0 :             default:
     934             :             {
     935           0 :                 assert( 0 && "unsupported rotation axis value" );
     936             :             }
     937             :         }
     938             :     }
     939      647209 :     else if ( pSplit_rend_config->dof == 3 )
     940             :     {
     941      442245 :         if ( pSplit_rend_config->hq_mode == 1 )
     942             :         {
     943      196319 :             relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles_hq;
     944      196319 :             relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles_hq;
     945      196319 :             relative_roll_angles = isar_split_rend_relative_roll_pos_angles_hq;
     946      196319 :             num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     947      196319 :             num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES;
     948      196319 :             num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES;
     949             :         }
     950             :         else
     951             :         {
     952      245926 :             relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles;
     953      245926 :             relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles;
     954      245926 :             relative_roll_angles = isar_split_rend_relative_roll_pos_angles;
     955      245926 :             num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     956      245926 :             num_pitch_poses = 1;
     957      245926 :             num_roll_poses = 1;
     958             :         }
     959             :     }
     960             : 
     961      899591 :     pMultiBinPoseData->num_poses = num_yaw_poses + num_pitch_poses + num_roll_poses + 1;
     962      899591 :     assert( pMultiBinPoseData->num_poses <= MAX_HEAD_ROT_POSES );
     963             : 
     964     2288845 :     for ( pos_idx = 0; pos_idx < num_yaw_poses; pos_idx++ )
     965             :     {
     966     1389254 :         pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] = relative_yaw_angles[pos_idx];
     967             :     }
     968             : 
     969     1731847 :     for ( pos_idx = 0; pos_idx < num_pitch_poses; pos_idx++ )
     970             :     {
     971      832256 :         pMultiBinPoseData->relative_head_poses[pos_idx + num_yaw_poses + 1][1] = relative_pitch_angles[pos_idx];
     972             :     }
     973             : 
     974     1538155 :     for ( pos_idx = 0; pos_idx < num_roll_poses; pos_idx++ )
     975             :     {
     976      638564 :         pMultiBinPoseData->relative_head_poses[pos_idx + num_yaw_poses + num_pitch_poses + 1][2] = relative_roll_angles[pos_idx];
     977             :     }
     978      899591 :     pMultiBinPoseData->dof = pSplit_rend_config->dof;
     979      899591 :     pMultiBinPoseData->hq_mode = pSplit_rend_config->hq_mode;
     980      899591 :     pMultiBinPoseData->rot_axis = rot_axis;
     981      899591 :     pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode;
     982             : 
     983      899591 :     return;
     984             : }
     985             : 
     986             : 
     987             : /*-------------------------------------------------------------------------
     988             :  * Function isar_renderSplitUpdateNoCorrectionPoseData()
     989             :  *
     990             :  *
     991             :  *------------------------------------------------------------------------*/
     992             : 
     993         144 : void isar_renderSplitUpdateNoCorrectionPoseData(
     994             :     const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i  : Split renderer pre-renderer config   */
     995             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData            /* i/o: pose correction data handle          */
     996             : )
     997             : {
     998         144 :     pMultiBinPoseData->num_poses = 1;
     999         144 :     assert( pSplit_rend_config->dof == 0 );
    1000         144 :     pMultiBinPoseData->dof = pSplit_rend_config->dof;
    1001         144 :     assert( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE );
    1002         144 :     pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode;
    1003             : 
    1004         144 :     return;
    1005             : }
    1006             : 
    1007             : 
    1008             : /*-------------------------------------------------------------------------
    1009             :  * Function isar_init_multi_bin_pose_data()
    1010             :  *
    1011             :  *
    1012             :  *------------------------------------------------------------------------*/
    1013             : 
    1014        5112 : void isar_init_multi_bin_pose_data(
    1015             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle     */
    1016             : )
    1017             : {
    1018             :     int16_t pos_idx;
    1019             : 
    1020       46008 :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1021             :     {
    1022       40896 :         pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f;
    1023       40896 :         pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f;
    1024       40896 :         pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f;
    1025             :     }
    1026        5112 :     pMultiBinPoseData->num_poses = 1;
    1027        5112 :     pMultiBinPoseData->dof = 3;
    1028        5112 :     pMultiBinPoseData->hq_mode = 0;
    1029        5112 :     pMultiBinPoseData->rot_axis = DEFAULT_AXIS;
    1030             : 
    1031        5112 :     return;
    1032             : }
    1033             : 
    1034             : 
    1035             : /*-------------------------------------------------------------------------
    1036             :  * Function isar_framesize_to_ms()
    1037             :  *
    1038             :  *
    1039             :  *------------------------------------------------------------------------*/
    1040             : 
    1041        1084 : ivas_error isar_framesize_to_ms(
    1042             :     const IVAS_RENDER_FRAMESIZE frame_size, /* i  : frame size enum         */
    1043             :     int16_t *ms                             /* o  : frame size in ms        */
    1044             : )
    1045             : {
    1046        1084 :     switch ( frame_size )
    1047             :     {
    1048          10 :         case IVAS_RENDER_FRAMESIZE_5MS:
    1049          10 :             *ms = 5;
    1050          10 :             break;
    1051          40 :         case IVAS_RENDER_FRAMESIZE_10MS:
    1052          40 :             *ms = 10;
    1053          40 :             break;
    1054        1034 :         case IVAS_RENDER_FRAMESIZE_20MS:
    1055        1034 :             *ms = 20;
    1056        1034 :             break;
    1057           0 :         default:
    1058           0 :             return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported ISAR frame size" );
    1059             :     }
    1060             : 
    1061        1084 :     return IVAS_ERR_OK;
    1062             : }
    1063             : 
    1064             : 
    1065             : /*-------------------------------------------------------------------------
    1066             :  * Function isar_split_rend_choose_default_codec()
    1067             :  *
    1068             :  *
    1069             :  *------------------------------------------------------------------------*/
    1070             : 
    1071        2560 : ivas_error isar_split_rend_choose_default_codec(
    1072             :     ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting                */
    1073             :     int16_t *pIsar_frame_size_ms,  /* i/o: pointer to ISAR frame size setting      */
    1074             :     int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting     */
    1075             :     const int16_t cldfb_in_flag,   /* i  : flag indicating rendering in TD         */
    1076             :     const int16_t pcm_out_flag,    /* i  : flag to indicate PCM output             */
    1077             :     const int16_t num_subframes    /* i  : number of subframes                     */
    1078             : )
    1079             : {
    1080        2560 :     if ( pcm_out_flag == 0 )
    1081             :     {
    1082        2518 :         if ( *pCodec == ISAR_SPLIT_REND_CODEC_DEFAULT )
    1083             :         {
    1084        1706 :             *pCodec = cldfb_in_flag ? ISAR_SPLIT_REND_CODEC_LCLD : ISAR_SPLIT_REND_CODEC_LC3PLUS;
    1085             :         }
    1086             :     }
    1087             :     else
    1088             :     {
    1089          42 :         *pCodec = ISAR_SPLIT_REND_CODEC_NONE;
    1090             :     }
    1091             : 
    1092        2560 :     if ( *pCodec_frame_size_ms == 0 ) /* codec frame size hasn't been set yet - use default for current configuration */
    1093             :     {
    1094        2300 :         switch ( *pCodec )
    1095             :         {
    1096        1344 :             case ISAR_SPLIT_REND_CODEC_LCLD:
    1097        1344 :                 *pCodec_frame_size_ms = num_subframes * 5;
    1098        1344 :                 break;
    1099         956 :             case ISAR_SPLIT_REND_CODEC_LC3PLUS:
    1100             :             case ISAR_SPLIT_REND_CODEC_NONE:
    1101         956 :                 *pCodec_frame_size_ms = 5;
    1102         956 :                 break;
    1103           0 :             default:
    1104           0 :                 return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" );
    1105             :         }
    1106         260 :     }
    1107             : 
    1108        2560 :     if ( *pIsar_frame_size_ms == 0 ) /* ISAR frame size hasn't been set yet - use default for current configuration */
    1109             :     {
    1110           0 :         *pIsar_frame_size_ms = 20;
    1111             :     }
    1112             : 
    1113        2560 :     return IVAS_ERR_OK;
    1114             : }
    1115             : 
    1116             : 
    1117             : /*-------------------------------------------------------------------*
    1118             :  * Function get_bit()
    1119             :  *
    1120             :  *
    1121             :  *-------------------------------------------------------------------*/
    1122             : 
    1123     1631884 : int32_t get_bit(
    1124             :     const int32_t state,
    1125             :     const int32_t bit_id )
    1126             : {
    1127     1631884 :     return ( state & ( 1 << bit_id ) );
    1128             : }

Generated by: LCOV version 1.14