LCOV - code coverage report
Current view: top level - lib_isar - isar_splitRenderer_utils.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ a21f94bc6bac334fe001a5bad2f7b32b79038097 Lines: 314 362 86.7 %
Date: 2025-11-01 05:07:43 Functions: 24 25 96.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    13624720 : 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    40874160 :     for ( i = 0; i < 2; i++ )
      64             :     {
      65    81748320 :         for ( j = 0; j < 2; j++ )
      66             :         {
      67    54498880 :             IVAS_CMULT_FLOAT( in_re1[i][0], in_im1[i][0], in_re2[0][j], in_im2[0][j], tmp_re, tmp_im );
      68    54498880 :             out_re2[i][j] = tmp_re;
      69    54498880 :             out_im2[i][j] = tmp_im;
      70             : 
      71    54498880 :             IVAS_CMULT_FLOAT( in_re1[i][1], in_im1[i][1], in_re2[1][j], in_im2[1][j], tmp_re, tmp_im );
      72    54498880 :             out_re2[i][j] += tmp_re;
      73    54498880 :             out_im2[i][j] += tmp_im;
      74             :         }
      75             :     }
      76             : 
      77    13624720 :     return;
      78             : }
      79             : 
      80             : 
      81             : /*-------------------------------------------------------------------------
      82             :  * Function isar_split_rend_huffman_dec_init_min_max_len()
      83             :  *
      84             :  *
      85             :  *------------------------------------------------------------------------*/
      86             : 
      87       10356 : 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       10356 :     codebook = p_huff_cfg->codebook;
      94             : 
      95       10356 :     p_huff_cfg->min_len = p_huff_cfg->sym_len;
      96       10356 :     p_huff_cfg->max_len = 0;
      97             : 
      98      303776 :     for ( i = 0; i < p_huff_cfg->sym_len; i++ )
      99             :     {
     100      293420 :         code_len = (int16_t) codebook[1];
     101      293420 :         if ( p_huff_cfg->min_len > code_len )
     102             :         {
     103       62136 :             p_huff_cfg->min_len = code_len;
     104             :         }
     105      293420 :         if ( p_huff_cfg->max_len < code_len )
     106             :         {
     107       55232 :             p_huff_cfg->max_len = code_len;
     108             :         }
     109      293420 :         codebook = codebook + 3;
     110             :     }
     111             : 
     112       10356 :     return;
     113             : }
     114             : 
     115             : 
     116             : /*-------------------------------------------------------------------------
     117             :  * Function is_idx_present()
     118             :  *
     119             :  *
     120             :  *------------------------------------------------------------------------*/
     121             : 
     122     8680054 : 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   153439674 :     for ( i = 0; i < len; i++ )
     130             :     {
     131   150279368 :         if ( idx_list[i] == idx )
     132             :         {
     133     5519748 :             return 1;
     134             :         }
     135             :     }
     136             : 
     137     3160306 :     return 0;
     138             : }
     139             : 
     140             : 
     141             : /*-------------------------------------------------------------------------
     142             :  * Function isar_split_huff_get_idx_trav_list()
     143             :  *
     144             :  *
     145             :  *------------------------------------------------------------------------*/
     146             : 
     147       10356 : 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      303776 :     for ( i = 0; i < p_huff_cfg->sym_len; i++ )
     156             :     {
     157      293420 :         idx_list[i] = -1;
     158             :     }
     159             : 
     160      303776 :     for ( i = 0; i < p_huff_cfg->sym_len; i++ )
     161             :     {
     162      293420 :         codebook = p_huff_cfg->codebook;
     163      293420 :         min_bits = p_huff_cfg->max_len;
     164      293420 :         min_idx = -1;
     165    11626336 :         for ( j = 0; j < p_huff_cfg->sym_len; j++ )
     166             :         {
     167    11332916 :             if ( ( min_bits >= codebook[1] ) && ( is_idx_present( idx_list, j, i + 1 ) == 0 ) )
     168             :             {
     169     3160306 :                 min_bits = codebook[1];
     170     3160306 :                 min_idx = j;
     171             :             }
     172    11332916 :             codebook += 3;
     173             :         }
     174      293420 :         idx_list[i] = min_idx;
     175             :     }
     176             : 
     177       10356 :     return;
     178             : }
     179             : 
     180             : 
     181             : /*-------------------------------------------------------------------------
     182             :  * Function isar_split_rend_init_huff_cfg()
     183             :  *
     184             :  *
     185             :  *------------------------------------------------------------------------*/
     186             : 
     187        1726 : void isar_split_rend_init_huff_cfg(
     188             :     ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg )
     189             : {
     190        1726 :     pHuff_cfg->pred[0].codebook = &isar_split_rend_huff_pred31_consts[0][0];
     191        1726 :     pHuff_cfg->pred[0].sym_len = ISAR_SPLIT_REND_PRED_31QUANT_PNTS;
     192        1726 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[0] );
     193        1726 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[0], &pHuff_cfg->pred[0] );
     194        1726 :     pHuff_cfg->pred_base2_code_len[0] = (int16_t) ceilf( log2f( pHuff_cfg->pred[0].sym_len ) );
     195             : 
     196        1726 :     pHuff_cfg->pred[1].codebook = &isar_split_rend_huff_pred63_consts[0][0];
     197        1726 :     pHuff_cfg->pred[1].sym_len = ISAR_SPLIT_REND_PRED_63QUANT_PNTS;
     198        1726 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[1] );
     199        1726 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[1], &pHuff_cfg->pred[1] );
     200        1726 :     pHuff_cfg->pred_base2_code_len[1] = (int16_t) ceilf( log2f( pHuff_cfg->pred[1].sym_len ) );
     201             : 
     202             : 
     203        1726 :     pHuff_cfg->pred_roll.codebook = &isar_split_rend_huff_roll_pred_consts[0][0];
     204        1726 :     pHuff_cfg->pred_roll.sym_len = ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS;
     205        1726 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred_roll );
     206        1726 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_roll_idx_trav, &pHuff_cfg->pred_roll );
     207        1726 :     pHuff_cfg->pred_roll_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->pred_roll.sym_len ) );
     208             : 
     209        1726 :     pHuff_cfg->gd.codebook = &isar_split_rend_huff_d_consts[0][0];
     210        1726 :     pHuff_cfg->gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS;
     211        1726 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->gd );
     212        1726 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->gd_idx_trav, &pHuff_cfg->gd );
     213        1726 :     pHuff_cfg->gd_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->gd.sym_len ) );
     214             : 
     215        1726 :     pHuff_cfg->p_gd.codebook = &isar_split_rend_huff_p_d_consts[0][0];
     216        1726 :     pHuff_cfg->p_gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS;
     217        1726 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd );
     218        1726 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_idx_trav, &pHuff_cfg->p_gd );
     219        1726 :     pHuff_cfg->p_gd_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->p_gd.sym_len ) );
     220             : 
     221        1726 :     pHuff_cfg->p_gd_diff.codebook = &isar_split_rend_huff_p_d_diff_consts[0][0];
     222        1726 :     pHuff_cfg->p_gd_diff.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS;
     223        1726 :     isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd_diff );
     224        1726 :     isar_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_diff_idx_trav, &pHuff_cfg->p_gd_diff );
     225        1726 :     pHuff_cfg->p_gd_diff_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->p_gd_diff.sym_len ) );
     226             : 
     227        1726 :     return;
     228             : }
     229             : 
     230             : 
     231             : /*-------------------------------------------------------------------------
     232             :  * Function set_fix_rotation_mat()
     233             :  *
     234             :  *
     235             :  *------------------------------------------------------------------------*/
     236             : 
     237      289680 : 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      289680 :     yaw_a = 0.0f;
     245             : 
     246     1472032 :     for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     247             :     {
     248     1182352 :         yaw_a = pMultiBinPoseData->relative_head_poses[pos_idx + 1][0];
     249     1182352 :         cos_yaw = cosf( EVS_PI * yaw_a / 180.0f );
     250     1182352 :         sin_yaw = sinf( EVS_PI * yaw_a / 180.0f );
     251     1182352 :         sin_yaw = 0.0f;
     252     1182352 :         fix_pos_rot_mat[pos_idx][0][0] = cos_yaw;
     253     1182352 :         fix_pos_rot_mat[pos_idx][1][1] = cos_yaw;
     254     1182352 :         fix_pos_rot_mat[pos_idx][0][1] = sin_yaw;
     255     1182352 :         fix_pos_rot_mat[pos_idx][1][0] = -1.0f * sin_yaw;
     256             :     }
     257             : 
     258      289680 :     return;
     259             : }
     260             : 
     261             : 
     262             : /*-------------------------------------------------------------------------
     263             :  * Function set_pose_types()
     264             :  *
     265             :  *
     266             :  *------------------------------------------------------------------------*/
     267             : 
     268      289680 : 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     1472032 :     for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     276             :     {
     277     1182352 :         if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] ) > EPSILON )
     278             :         {
     279      579360 :             pose_type[pos_idx] = ANY_YAW;
     280             :         }
     281      602992 :         else if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][2] ) > EPSILON )
     282             :         {
     283      258056 :             pose_type[pos_idx] = ANY_ROLL;
     284             :         }
     285             :         else
     286             :         {
     287      344936 :             pose_type[pos_idx] = PITCH_ONLY;
     288             :         }
     289             :     }
     290             : 
     291      289680 :     return;
     292             : }
     293             : 
     294             : 
     295             : /*-------------------------------------------------------------------------
     296             :  * Function wrap_a()
     297             :  *
     298             :  *
     299             :  *------------------------------------------------------------------------*/
     300             : 
     301    49238384 : static int16_t wrap_a(
     302             :     int16_t val,
     303             :     const int16_t min_val,
     304             :     const int16_t max_val )
     305             : {
     306    49238384 :     if ( val < min_val )
     307             :     {
     308       18583 :         val = max_val - min_val + val + 1;
     309             :     }
     310             : 
     311    49238384 :     if ( val > max_val )
     312             :     {
     313       17302 :         val = min_val + val - max_val - 1;
     314             :     }
     315             : 
     316    49238384 :     return val;
     317             : }
     318             : 
     319             : 
     320             : /*-------------------------------------------------------------------------
     321             :  * Function isar_SplitRenderer_getdiagdiff()
     322             :  *
     323             :  *
     324             :  *------------------------------------------------------------------------*/
     325             : 
     326    24619192 : 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    24619192 :     out_idx[0][0] = in_idx[0][0];
     334    24619192 :     out_idx[0][1] = in_idx[0][1];
     335    24619192 :     out_idx[1][1] = in_idx[1][1] + sign * out_idx[0][0];
     336    24619192 :     out_idx[1][1] = wrap_a( out_idx[1][1], min_val, max_val );
     337    24619192 :     out_idx[1][0] = in_idx[1][0] + sign * out_idx[0][1];
     338    24619192 :     out_idx[1][0] = wrap_a( out_idx[1][0], min_val, max_val );
     339             : 
     340    24619192 :     return;
     341             : }
     342             : 
     343             : 
     344             : /*-------------------------------------------------------------------------
     345             :  * Function ISAR_SPLIT_REND_BITStream_read_int32()
     346             :  *
     347             :  *
     348             :  *------------------------------------------------------------------------*/
     349             : 
     350             : /*! r: parameter value */
     351   712284780 : 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   712284780 :     val = 0;
     365  2581495579 :     for ( k = bits - 1; k >= 0; k-- )
     366             :     {
     367  1869210799 :         bit_val = ( pBits->bits_buf[pBits->bits_read >> 3] & ( 1 << ( pBits->bits_read & 7 ) ) ) != 0;
     368  1869210799 :         val |= bit_val << k;
     369  1869210799 :         pBits->bits_read++;
     370             :     }
     371             : 
     372   712284780 :     return val;
     373             : }
     374             : 
     375             : 
     376             : /*-------------------------------------------------------------------------
     377             :  * Function ISAR_SPLIT_REND_BITStream_write_int32()
     378             :  *
     379             :  *
     380             :  *------------------------------------------------------------------------*/
     381             : 
     382   632105657 : 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   632105657 :     mask = 1 << ( bits - 1 );
     399             :     /* write bit by bit */
     400  2168642055 :     for ( k = 0; k < bits; k++ )
     401             :     {
     402  1536536398 :         if ( val & mask )
     403             :         {
     404   673293386 :             pBits->bits_buf[pBits->bits_written >> 3] |= ( 1 << ( pBits->bits_written & 7 ) );
     405             :         }
     406             :         else
     407             :         {
     408   863243012 :             pBits->bits_buf[pBits->bits_written >> 3] &= ~( 1 << ( pBits->bits_written & 7 ) );
     409             :         }
     410  1536536398 :         pBits->bits_written++;
     411  1536536398 :         mask >>= 1;
     412             :     }
     413             : 
     414   632105657 :     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      137941 : 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      137941 :     if ( pcm_out_flag == 1 )
     479             :     {
     480        1915 :         md_bitrate = SplitRendBitRate;
     481             :     }
     482             :     else
     483             :     {
     484      136026 :         switch ( SplitRendBitRate )
     485             :         {
     486       63486 :             case SPLIT_REND_768k:
     487             :             {
     488       63486 :                 md_bitrate = 256000;
     489       63486 :                 break;
     490             :             }
     491       52905 :             case SPLIT_REND_512k:
     492             :             {
     493       52905 :                 md_bitrate = 128000;
     494       52905 :                 break;
     495             :             }
     496       19635 :             case SPLIT_REND_384k:
     497             :             {
     498       19635 :                 md_bitrate = 128000;
     499       19635 :                 break;
     500             :             }
     501           0 :             default:
     502             :             {
     503           0 :                 return -1;
     504             :             }
     505             :         }
     506             :     }
     507             : 
     508      137941 :     return md_bitrate;
     509             : }
     510             : 
     511             : 
     512             : /*-------------------------------------------------------------------------
     513             :  * Function isar_get_lcld_bitrate()
     514             :  *
     515             :  *
     516             :  *------------------------------------------------------------------------*/
     517             : 
     518             : /*! r: LCLD codec bitrate */
     519       30706 : 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       30706 :     if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
     525             :     {
     526         684 :         switch ( SplitRendBitRate )
     527             :         {
     528         324 :             case SPLIT_REND_768k:
     529             :             {
     530         324 :                 return IVAS_512k;
     531             :             }
     532         270 :             case SPLIT_REND_512k:
     533             :             {
     534         270 :                 return IVAS_384k;
     535             :             }
     536          90 :             case SPLIT_REND_384k:
     537             :             {
     538          90 :                 return IVAS_256k;
     539             :             }
     540           0 :             default:
     541             :             {
     542           0 :                 assert( 0 );
     543             :             }
     544             :         }
     545             :     }
     546             :     else
     547             :     {
     548       30022 :         return SplitRendBitRate;
     549             :     }
     550             : 
     551             :     return -1;
     552             : }
     553             : 
     554             : 
     555             : /*-------------------------------------------------------------------------
     556             :  * Function isar_get_lc3plus_bitrate()
     557             :  *
     558             :  *
     559             :  *------------------------------------------------------------------------*/
     560             : 
     561       30042 : 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       30042 :     bitrate = isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode );
     571             : 
     572             :     /* Check for LC3plus LEA 48_6 LC3 compatibility mode signalling */
     573       30042 :     if ( ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE == poseCorrectionMode && bitrate == 256000 && nChannels == 2 && codecFrameDurationUs == 10000 )
     574             :     {
     575        7062 :         bitrate = 2 * 126000;
     576             :     }
     577             : 
     578       30042 :     return bitrate;
     579             : }
     580             : 
     581             : 
     582             : /*-------------------------------------------------------------------------
     583             :  * Function isar_split_rend_validate_config()
     584             :  *
     585             :  *
     586             :  *------------------------------------------------------------------------*/
     587             : 
     588        2064 : 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        2064 :     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        2064 :     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        2064 :     if ( ( pSplitRendConfig->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof != 0 ) ||
     607        2064 :          ( 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        2064 :     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        1136 :         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        1136 :         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        2064 :     if ( pcm_out_flag == 0 )
     627             :     {
     628        2044 :         switch ( pSplitRendConfig->splitRendBitRate )
     629             :         {
     630         244 :             case SPLIT_REND_256k:
     631         244 :                 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         244 :                 break;
     636         108 :             case SPLIT_REND_320k:
     637             :                 /* Only valid with 0 DOF */
     638         108 :                 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         108 :                 break;
     643        1692 :             case SPLIT_REND_384k:
     644             :             case SPLIT_REND_512k:
     645             :             case SPLIT_REND_768k:
     646             :                 /* Always valid */
     647        1692 :                 break;
     648           0 :             default:
     649           0 :                 return IVAS_ERR_LC3PLUS_INVALID_BITRATE;
     650             :         }
     651             :     }
     652             :     else
     653             :     {
     654          20 :         if ( pSplitRendConfig->dof == 1 )
     655             :         {
     656           4 :             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          16 :         else if ( pSplitRendConfig->dof == 2 )
     662             :         {
     663           4 :             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          12 :         else if ( pSplitRendConfig->dof == 3 )
     669             :         {
     670          12 :             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        2064 :     return IVAS_ERR_OK;
     678             : }
     679             : 
     680             : 
     681             : /*-------------------------------------------------------------------------
     682             :  * Function isar_split_rend_get_quant_params()
     683             :  *
     684             :  *
     685             :  *------------------------------------------------------------------------*/
     686             : 
     687      287954 : 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      287954 :     *num_quant_strats = ISAR_SPLIT_REND_NUM_QUANT_STRATS;
     704             : 
     705      287954 :     pred_quant_pnts_yaw[0] = ISAR_SPLIT_REND_PRED_63QUANT_PNTS;
     706      287954 :     pred_quantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_Q_STEP;
     707      287954 :     pred_1byquantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_1BYQ_STEP;
     708     1151816 :     for ( q = 1; q < *num_quant_strats; q++ )
     709             :     {
     710      863862 :         pred_quant_pnts_yaw[q] = ISAR_SPLIT_REND_PRED_31QUANT_PNTS;
     711      863862 :         pred_quantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_Q_STEP;
     712      863862 :         pred_1byquantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_1BYQ_STEP;
     713             :     }
     714             : 
     715     1439770 :     for ( q = 0; q < *num_quant_strats; q++ )
     716             :     {
     717     1151816 :         pred_real_bands_yaw[q] = num_md_bands;
     718     1151816 :         pred_real_bands_roll[q] = num_md_bands;
     719             :     }
     720             : 
     721      287954 :     if ( ro_flag )
     722             :     {
     723      711830 :         for ( q = 0; q < *num_quant_strats; q++ )
     724             :         {
     725      569464 :             pred_imag_bands_yaw[q] = SPLIT_REND_RO_MD_BAND_THRESH;
     726             :         }
     727             :     }
     728             :     else
     729             :     {
     730      436764 :         for ( q = 0; q < *num_quant_strats - 2; q++ )
     731             :         {
     732      291176 :             pred_imag_bands_yaw[q] = num_md_bands;
     733             :         }
     734      145588 :         pred_imag_bands_yaw[( *num_quant_strats - 2 )] = COMPLEX_MD_BAND_THRESH_HIGH;
     735      145588 :         pred_imag_bands_yaw[( *num_quant_strats - 1 )] = COMPLEX_MD_BAND_THRESH_LOW;
     736             :     }
     737             : 
     738     1439770 :     for ( q = 0; q < *num_quant_strats; q++ )
     739             :     {
     740     1151816 :         pred_imag_bands_roll[q] = SPLIT_REND_RO_MD_BAND_THRESH;
     741             :     }
     742             : 
     743     1439770 :     for ( q = 0; q < *num_quant_strats; q++ )
     744             :     {
     745     1151816 :         d_bands_yaw[q] = 0;
     746     1151816 :         bands_pitch[q] = num_md_bands;
     747             :     }
     748             : 
     749      287954 :     return;
     750             : }
     751             : 
     752             : 
     753             : /*-------------------------------------------------------------------------
     754             :  * Function isar_renderSplitGetRot_axisNumBits()
     755             :  *
     756             :  *
     757             :  *------------------------------------------------------------------------*/
     758             : 
     759      287954 : int16_t isar_renderSplitGetRot_axisNumBits(
     760             :     const int16_t dof )
     761             : {
     762             :     int16_t num_bits;
     763      287954 :     if ( dof < 3 )
     764             :     {
     765      116840 :         num_bits = 2;
     766             :     }
     767             :     else
     768             :     {
     769      171114 :         num_bits = 0;
     770             :     }
     771             : 
     772      287954 :     return num_bits;
     773             : }
     774             : 
     775             : 
     776             : /*-------------------------------------------------------------------------
     777             :  * Function isar_renderSplitGetRot_axisFromCode()
     778             :  *
     779             :  *
     780             :  *------------------------------------------------------------------------*/
     781             : 
     782      150013 : 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      150013 :     if ( dof == 1 )
     789             :     {
     790       42791 :         rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code;
     791             :     }
     792      107222 :     else if ( dof == 2 )
     793             :     {
     794       21665 :         if ( code == 0 )
     795             :         {
     796       21665 :             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       85557 :         rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) DEFAULT_AXIS;
     806             :     }
     807             : 
     808      150013 :     return rot_axis;
     809             : }
     810             : 
     811             : 
     812             : /*-------------------------------------------------------------------------
     813             :  * Function isar_renderSplitGetCodeFromRot_axis()
     814             :  *
     815             :  *
     816             :  *------------------------------------------------------------------------*/
     817             : 
     818      137941 : 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      137941 :     int16_t code = 0;
     824             : 
     825      137941 :     if ( dof == 1 )
     826             :     {
     827       30719 :         code = (int16_t) rot_axis;
     828             :     }
     829      107222 :     else if ( dof == 2 )
     830             :     {
     831       21665 :         if ( rot_axis == DEFAULT_AXIS )
     832             :         {
     833       21665 :             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       85557 :         code = (int16_t) DEFAULT_AXIS;
     843             :     }
     844      137941 :     *num_bits = isar_renderSplitGetRot_axisNumBits( dof );
     845             : 
     846      137941 :     return code;
     847             : }
     848             : 
     849             : 
     850             : /*-------------------------------------------------------------------------
     851             :  * Function isar_renderSplitGetMultiBinPoseData()
     852             :  *
     853             :  *
     854             :  *------------------------------------------------------------------------*/
     855             : 
     856      567043 : 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     5103387 :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
     868             :     {
     869     4536344 :         pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f;
     870     4536344 :         pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f;
     871     4536344 :         pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f;
     872             :     }
     873             : 
     874             :     /* 0 DOF defaults */
     875      567043 :     num_yaw_poses = 0;
     876      567043 :     num_pitch_poses = 0;
     877      567043 :     num_roll_poses = 0;
     878             : 
     879             :     /* defaults for all DOF except 3DOF HQ */
     880      567043 :     relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles_hq;
     881      567043 :     relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles_hq;
     882      567043 :     relative_roll_angles = isar_split_rend_relative_roll_pos_angles_hq;
     883             : 
     884      567043 :     if ( pSplit_rend_config->dof == 1 )
     885             :     {
     886      104241 :         switch ( rot_axis )
     887             :         {
     888      104241 :             case DEFAULT_AXIS:
     889             :             case YAW:
     890             :             {
     891      104241 :                 num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     892      104241 :                 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      462802 :     else if ( pSplit_rend_config->dof == 2 )
     911             :     {
     912       65007 :         switch ( rot_axis )
     913             :         {
     914       65007 :             case DEFAULT_AXIS:
     915             :             case YAW_PITCH:
     916             :             {
     917       65007 :                 num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     918       65007 :                 num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES;
     919       65007 :                 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      397795 :     else if ( pSplit_rend_config->dof == 3 )
     940             :     {
     941      257751 :         if ( pSplit_rend_config->hq_mode == 1 )
     942             :         {
     943      127905 :             relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles_hq;
     944      127905 :             relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles_hq;
     945      127905 :             relative_roll_angles = isar_split_rend_relative_roll_pos_angles_hq;
     946      127905 :             num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     947      127905 :             num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES;
     948      127905 :             num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES;
     949             :         }
     950             :         else
     951             :         {
     952      129846 :             relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles;
     953      129846 :             relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles;
     954      129846 :             relative_roll_angles = isar_split_rend_relative_roll_pos_angles;
     955      129846 :             num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES;
     956      129846 :             num_pitch_poses = 1;
     957      129846 :             num_roll_poses = 1;
     958             :         }
     959             :     }
     960             : 
     961      567043 :     pMultiBinPoseData->num_poses = num_yaw_poses + num_pitch_poses + num_roll_poses + 1;
     962      567043 :     assert( pMultiBinPoseData->num_poses <= MAX_HEAD_ROT_POSES );
     963             : 
     964     1421041 :     for ( pos_idx = 0; pos_idx < num_yaw_poses; pos_idx++ )
     965             :     {
     966      853998 :         pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] = relative_yaw_angles[pos_idx];
     967             :     }
     968             : 
     969     1082713 :     for ( pos_idx = 0; pos_idx < num_pitch_poses; pos_idx++ )
     970             :     {
     971      515670 :         pMultiBinPoseData->relative_head_poses[pos_idx + num_yaw_poses + 1][1] = relative_pitch_angles[pos_idx];
     972             :     }
     973             : 
     974      952699 :     for ( pos_idx = 0; pos_idx < num_roll_poses; pos_idx++ )
     975             :     {
     976      385656 :         pMultiBinPoseData->relative_head_poses[pos_idx + num_yaw_poses + num_pitch_poses + 1][2] = relative_roll_angles[pos_idx];
     977             :     }
     978      567043 :     pMultiBinPoseData->dof = pSplit_rend_config->dof;
     979      567043 :     pMultiBinPoseData->hq_mode = pSplit_rend_config->hq_mode;
     980      567043 :     pMultiBinPoseData->rot_axis = rot_axis;
     981      567043 :     pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode;
     982             : 
     983      567043 :     return;
     984             : }
     985             : 
     986             : 
     987             : /*-------------------------------------------------------------------------
     988             :  * Function isar_renderSplitUpdateNoCorrectionPoseData()
     989             :  *
     990             :  *
     991             :  *------------------------------------------------------------------------*/
     992             : 
     993           0 : 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           0 :     pMultiBinPoseData->num_poses = 1;
     999           0 :     assert( pSplit_rend_config->dof == 0 );
    1000           0 :     pMultiBinPoseData->dof = pSplit_rend_config->dof;
    1001           0 :     assert( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE );
    1002           0 :     pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode;
    1003             : 
    1004           0 :     return;
    1005             : }
    1006             : 
    1007             : 
    1008             : /*-------------------------------------------------------------------------
    1009             :  * Function isar_init_multi_bin_pose_data()
    1010             :  *
    1011             :  *
    1012             :  *------------------------------------------------------------------------*/
    1013             : 
    1014        2064 : 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       18576 :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1021             :     {
    1022       16512 :         pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f;
    1023       16512 :         pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f;
    1024       16512 :         pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f;
    1025             :     }
    1026        2064 :     pMultiBinPoseData->num_poses = 1;
    1027        2064 :     pMultiBinPoseData->dof = 3;
    1028        2064 :     pMultiBinPoseData->hq_mode = 0;
    1029        2064 :     pMultiBinPoseData->rot_axis = DEFAULT_AXIS;
    1030             : 
    1031        2064 :     return;
    1032             : }
    1033             : 
    1034             : 
    1035             : /*-------------------------------------------------------------------------
    1036             :  * Function isar_framesize_to_ms()
    1037             :  *
    1038             :  *
    1039             :  *------------------------------------------------------------------------*/
    1040             : 
    1041         358 : 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         358 :     switch ( frame_size )
    1047             :     {
    1048           4 :         case IVAS_RENDER_FRAMESIZE_5MS:
    1049           4 :             *ms = 5;
    1050           4 :             break;
    1051          16 :         case IVAS_RENDER_FRAMESIZE_10MS:
    1052          16 :             *ms = 10;
    1053          16 :             break;
    1054         338 :         case IVAS_RENDER_FRAMESIZE_20MS:
    1055         338 :             *ms = 20;
    1056         338 :             break;
    1057           0 :         default:
    1058           0 :             return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported ISAR frame size" );
    1059             :     }
    1060             : 
    1061         358 :     return IVAS_ERR_OK;
    1062             : }
    1063             : 
    1064             : 
    1065             : /*-------------------------------------------------------------------------
    1066             :  * Function isar_split_rend_choose_default_codec()
    1067             :  *
    1068             :  *
    1069             :  *------------------------------------------------------------------------*/
    1070             : 
    1071        1032 : 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        1032 :     if ( pcm_out_flag == 0 )
    1081             :     {
    1082        1022 :         if ( *pCodec == ISAR_SPLIT_REND_CODEC_DEFAULT )
    1083             :         {
    1084         702 :             *pCodec = cldfb_in_flag ? ISAR_SPLIT_REND_CODEC_LCLD : ISAR_SPLIT_REND_CODEC_LC3PLUS;
    1085             :         }
    1086             :     }
    1087             :     else
    1088             :     {
    1089          10 :         *pCodec = ISAR_SPLIT_REND_CODEC_NONE;
    1090             :     }
    1091             : 
    1092        1032 :     if ( *pCodec_frame_size_ms == 0 ) /* codec frame size hasn't been set yet - use default for current configuration */
    1093             :     {
    1094         928 :         switch ( *pCodec )
    1095             :         {
    1096         628 :             case ISAR_SPLIT_REND_CODEC_LCLD:
    1097         628 :                 *pCodec_frame_size_ms = num_subframes * 5;
    1098         628 :                 break;
    1099         300 :             case ISAR_SPLIT_REND_CODEC_LC3PLUS:
    1100             :             case ISAR_SPLIT_REND_CODEC_NONE:
    1101         300 :                 *pCodec_frame_size_ms = 5;
    1102         300 :                 break;
    1103           0 :             default:
    1104           0 :                 return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" );
    1105             :         }
    1106         104 :     }
    1107             : 
    1108        1032 :     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        1032 :     return IVAS_ERR_OK;
    1114             : }
    1115             : 
    1116             : 
    1117             : /*-------------------------------------------------------------------*
    1118             :  * Function get_bit()
    1119             :  *
    1120             :  *
    1121             :  *-------------------------------------------------------------------*/
    1122             : 
    1123     1130212 : int32_t get_bit(
    1124             :     const int32_t state,
    1125             :     const int32_t bit_id )
    1126             : {
    1127     1130212 :     return ( state & ( 1 << bit_id ) );
    1128             : }

Generated by: LCOV version 1.14