LCOV - code coverage report
Current view: top level - lib_isar - isar_splitRendererPost.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ a21f94bc6bac334fe001a5bad2f7b32b79038097 Lines: 516 543 95.0 %
Date: 2025-11-01 05:07:43 Functions: 18 18 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             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
      37             : #include <string.h>
      38             : #endif
      39             : #include "ivas_prot.h"
      40             : #include "prot.h"
      41             : #include "isar_rom_post_rend.h"
      42             : #include "isar_prot.h"
      43             : #ifdef DEBUGGING
      44             : #include "debug.h"
      45             : #endif
      46             : #include "wmc_auto.h"
      47             : 
      48             : 
      49             : /*---------------------------------------------------------------------*
      50             :  * Local function declarations
      51             :  *---------------------------------------------------------------------*/
      52             : 
      53             : static void isar_SplitRenderer_PostRenderer( ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const IVAS_QUATERNION Quaternion_act );
      54             : 
      55             : 
      56             : /*-------------------------------------------------------------------------
      57             :  * isar_splitBinPostRendOpen()
      58             :  *
      59             :  *
      60             :  *------------------------------------------------------------------------*/
      61             : 
      62        1032 : ivas_error isar_splitBinPostRendOpen(
      63             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle  */
      64             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,             /* i/o: pose correction data handle    */
      65             :     const int32_t output_Fs                                  /* i  : output sampling rate           */
      66             : )
      67             : {
      68             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinRend;
      69             :     ivas_error error;
      70             :     int16_t ch;
      71             : 
      72        1032 :     if ( ( hBinRend = (ISAR_BIN_HR_SPLIT_POST_REND_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_POST_REND ) ) ) == NULL )
      73             :     {
      74           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split post renderer Module \n" ) );
      75             :     }
      76             : 
      77        3096 :     for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
      78             :     {
      79        2064 :         hBinRend->cldfbSyn[ch] = NULL;
      80        2064 :         hBinRend->cldfbAna[ch] = NULL;
      81             :     }
      82             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
      83             :     for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ )
      84             :     {
      85             :         for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
      86             :         {
      87             :             hBinRend->cldfbSynReconsBinDec[i][ch] = NULL;
      88             :         }
      89             :     }
      90             : #endif
      91             : 
      92        3096 :     for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
      93             :     {
      94        2064 :         if ( ( error = openCldfb( &( hBinRend->cldfbSyn[ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
      95             :         {
      96           0 :             return error;
      97             :         }
      98        2064 :         if ( ( error = openCldfb( &( hBinRend->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
      99             :         {
     100           0 :             return error;
     101             :         }
     102             :     }
     103             : 
     104             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     105             :     for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ )
     106             :     {
     107             :         for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
     108             :         {
     109             :             if ( ( error = openCldfb( &( hBinRend->cldfbSynReconsBinDec[i][ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
     110             :             {
     111             :                 return error;
     112             :             }
     113             :         }
     114             :     }
     115             : #endif
     116        1032 :     hBinRend->cf_flag = 0;
     117        1032 :     set_fix_rotation_mat( hBinRend->fix_pos_rot_mat, pMultiBinPoseData );
     118        1032 :     set_pose_types( hBinRend->pose_type, pMultiBinPoseData );
     119        1032 :     isar_split_rend_init_huff_cfg( &hBinRend->huff_cfg );
     120        1032 :     *hBinHrSplitPostRend = hBinRend;
     121             : 
     122        1032 :     return IVAS_ERR_OK;
     123             : }
     124             : 
     125             : 
     126             : /*-------------------------------------------------------------------------
     127             :  * isar_splitBinPostRendClose()
     128             :  *
     129             :  *
     130             :  *------------------------------------------------------------------------*/
     131             : 
     132        1032 : void isar_splitBinPostRendClose(
     133             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle    */
     134             : )
     135             : {
     136             :     int16_t ch;
     137             : 
     138        1032 :     if ( ( *hBinHrSplitPostRend ) != NULL )
     139             :     {
     140        3096 :         for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
     141             :         {
     142        2064 :             if ( ( *hBinHrSplitPostRend )->cldfbSyn[ch] != NULL )
     143             :             {
     144        2064 :                 deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) );
     145        2064 :                 ( *hBinHrSplitPostRend )->cldfbSyn[ch] = NULL;
     146             :             }
     147        2064 :             if ( ( *hBinHrSplitPostRend )->cldfbAna[ch] != NULL )
     148             :             {
     149        2064 :                 deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) );
     150        2064 :                 ( *hBinHrSplitPostRend )->cldfbAna[ch] = NULL;
     151             :             }
     152             :         }
     153             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     154             :         for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ )
     155             :         {
     156             :             for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
     157             :             {
     158             :                 if ( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] != NULL )
     159             :                 {
     160             :                     deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] ) );
     161             :                     ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] = NULL;
     162             :                 }
     163             :             }
     164             :         }
     165             : #endif
     166             : 
     167        1032 :         free( ( *hBinHrSplitPostRend ) );
     168        1032 :         ( *hBinHrSplitPostRend ) = NULL;
     169             :     }
     170             : 
     171        1032 :     return;
     172             : }
     173             : 
     174             : 
     175             : /*-----------------------------------------------------------------------------------------*
     176             :  * Function isar_split_rend_huffman_decode_opt()
     177             :  *
     178             :  *
     179             :  *-----------------------------------------------------------------------------------------*/
     180             : 
     181    48759600 : static int16_t isar_split_rend_huffman_decode_opt(
     182             :     isar_split_rend_huffman_cfg_t *huff_cfg,
     183             :     ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle                */
     184             :     const int16_t *idx_trav_list )
     185             : {
     186             :     int32_t i, ind, code, num_bits, code_b, num_bits_read;
     187             :     const int32_t *codebook;
     188             : 
     189    48759600 :     codebook = huff_cfg->codebook;
     190    48759600 :     num_bits_read = 0;
     191    48759600 :     ind = huff_cfg->codebook[0] - 1;
     192    48759600 :     code = 0;
     193   216547200 :     for ( i = 0; i < huff_cfg->sym_len; i++ )
     194             :     {
     195   216547200 :         codebook = codebook + idx_trav_list[i] * 3;
     196   216547200 :         num_bits = codebook[1];
     197   216547200 :         code_b = codebook[2];
     198   216547200 :         num_bits_read = num_bits - num_bits_read;
     199   216547200 :         code = code << num_bits_read;
     200   216547200 :         if ( num_bits_read > 0 )
     201             :         {
     202    91690309 :             code |= ISAR_SPLIT_REND_BITStream_read_int32( pBits, num_bits_read );
     203             :         }
     204             : 
     205   216547200 :         if ( code == code_b )
     206             :         {
     207    48759600 :             ind = codebook[0];
     208    48759600 :             break;
     209             :         }
     210             : 
     211   167787600 :         num_bits_read = num_bits;
     212   167787600 :         codebook = huff_cfg->codebook;
     213             :     }
     214             : 
     215             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     216             :     assert( ind >= huff_cfg->codebook[0] );
     217             : #endif
     218    48759600 :     return (int16_t) ind;
     219             : }
     220             : 
     221             : 
     222             : /*-----------------------------------------------------------------------------------------*
     223             :  * Function isar_split_rend_unquant_md()
     224             :  *
     225             :  *
     226             :  *-----------------------------------------------------------------------------------------*/
     227             : 
     228    11994480 : static void isar_split_rend_unquant_md(
     229             :     ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd,
     230             :     ISAR_SPLIT_REND_POSE_TYPE pose_type,
     231             :     const int16_t real_only,
     232             :     float fix_pos_rot_mat[][BINAURAL_CHANNELS],
     233             :     const float pred_quant_step )
     234             : {
     235             :     int16_t ch1, ch2;
     236             :     int16_t gd_idx_min;
     237             : 
     238    11994480 :     if ( pose_type == PRED_ONLY || pose_type == PRED_ROLL_ONLY )
     239     8564200 :     {
     240             :         float quantstep;
     241             : 
     242     8564200 :         quantstep = pred_quant_step;
     243     8564200 :         if ( real_only )
     244             :         {
     245    13276248 :             for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     246             :             {
     247    26552496 :                 for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     248             :                 {
     249    17701664 :                     hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * quantstep;
     250    17701664 :                     hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re[ch1][ch2] + ( ( ch1 == ch2 ) ? 1.0f : 0.0f );
     251             :                 }
     252             :             }
     253             : 
     254    13276248 :             for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     255             :             {
     256    26552496 :                 for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     257             :                 {
     258    17701664 :                     hMd->pred_mat_im[ch1][ch2] = 0.0f;
     259             :                 }
     260             :             }
     261             :         }
     262             :         else
     263             :         {
     264    12416352 :             for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     265             :             {
     266    24832704 :                 for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     267             :                 {
     268    16555136 :                     hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * quantstep;
     269    16555136 :                     hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re[ch1][ch2] + fix_pos_rot_mat[ch1][ch2];
     270             :                 }
     271             :             }
     272             : 
     273    12416352 :             for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     274             :             {
     275    24832704 :                 for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     276             :                 {
     277    16555136 :                     hMd->pred_mat_im[ch1][ch2] = hMd->pred_mat_im_idx[ch1][ch2] * quantstep;
     278             :                 }
     279             :             }
     280             :         }
     281             :     }
     282     3430280 :     else if ( pose_type == COM_GAIN_ONLY )
     283             :     {
     284           0 :         gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_D_1BYQ_STEP * ISAR_SPLIT_REND_D_MIN_VAL );
     285           0 :         hMd->gd_idx += gd_idx_min;
     286           0 :         hMd->gd = hMd->gd_idx * ISAR_SPLIT_REND_D_Q_STEP;
     287             :     }
     288     3430280 :     else if ( pose_type == LR_GAIN_ONLY )
     289             :     {
     290     3430280 :         gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * ISAR_SPLIT_REND_PITCH_G_MIN_VAL );
     291     3430280 :         hMd->gd_idx += gd_idx_min;
     292     3430280 :         hMd->gd = hMd->gd_idx * ISAR_SPLIT_REND_PITCH_G_Q_STEP;
     293             : 
     294     3430280 :         hMd->gd2_idx += gd_idx_min;
     295     3430280 :         hMd->gd2 = hMd->gd2_idx * ISAR_SPLIT_REND_PITCH_G_Q_STEP;
     296             :     }
     297             :     else
     298             :     {
     299           0 :         hMd->gd = 0.0f;
     300             :     }
     301             : 
     302    11994480 :     return;
     303             : }
     304             : 
     305             : 
     306             : /*-----------------------------------------------------------------------------------------*
     307             :  * Function isar_splitBinPostRendMdBase2Dec()
     308             :  *
     309             :  *
     310             :  *-----------------------------------------------------------------------------------------*/
     311             : 
     312         242 : static void isar_splitBinPostRendMdBase2Dec(
     313             :     ISAR_SPLIT_REND_BITS_HANDLE pBits,                      /* i/o: ISAR bits handle                */
     314             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle    */
     315             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,            /* i/o: pose correction data handle     */
     316             :     const int16_t num_subframes,
     317             :     const int16_t pred_real_bands_yaw,
     318             :     const int16_t pred_imag_bands_yaw,
     319             :     const int16_t pred_quant_pnts_yaw,
     320             :     const int16_t d_bands_yaw,
     321             :     const int16_t bands_pitch,
     322             :     const int16_t pred_real_bands_roll,
     323             :     const int16_t pred_imag_bands_roll )
     324             : {
     325             :     int16_t sf_idx, pos_idx, b, ch1, ch2;
     326             :     int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len;
     327             :     int16_t min_pred_roll_idx, pred_roll_code_len;
     328             :     int16_t pred_cb_idx;
     329             :     int16_t code;
     330             :     ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd;
     331             :     ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg;
     332             : 
     333         242 :     pHuff_cfg = &hBinHrSplitPostRend->huff_cfg;
     334             : 
     335         242 :     if ( pred_quant_pnts_yaw == ISAR_SPLIT_REND_PRED_63QUANT_PNTS )
     336             :     {
     337         240 :         pred_cb_idx = 1;
     338             :     }
     339             :     else
     340             :     {
     341           2 :         pred_cb_idx = 0;
     342             :     }
     343         242 :     min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0];
     344         242 :     min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0];
     345         242 :     min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0];
     346         242 :     min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0];
     347         242 :     pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx];
     348         242 :     pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len;
     349         242 :     gd_code_len = pHuff_cfg->gd_base2_code_len;
     350         242 :     p_gd_code_len = pHuff_cfg->p_gd_base2_code_len;
     351             : 
     352         484 :     for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
     353             :     {
     354        1310 :         for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     355             :         {
     356        1068 :             if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW )
     357             :             {
     358        2764 :                 for ( b = 0; b < pred_imag_bands_yaw; b++ )
     359             :                 {
     360        2280 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     361        6840 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     362             :                     {
     363       13680 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     364             :                         {
     365        9120 :                             code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len );
     366        9120 :                             hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_idx;
     367             :                         }
     368             :                     }
     369        6840 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     370             :                     {
     371       13680 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     372             :                         {
     373        9120 :                             code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len );
     374        9120 :                             hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_idx;
     375             :                         }
     376             :                     }
     377             :                 }
     378             : 
     379        7884 :                 for ( ; b < pred_real_bands_yaw; b++ )
     380             :                 {
     381        7400 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     382       22200 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     383             :                     {
     384       14800 :                         code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len );
     385       14800 :                         hMd->pred_mat_re_idx[ch1][ch1] = code + min_pred_idx;
     386             :                     }
     387        7400 :                     hMd->pred_mat_re_idx[0][1] = 0;
     388        7400 :                     hMd->pred_mat_re_idx[1][0] = 0;
     389             :                 }
     390         484 :                 for ( b = 0; b < d_bands_yaw; b++ )
     391             :                 {
     392           0 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     393           0 :                     code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, gd_code_len );
     394           0 :                     hMd->gd_idx = code + min_gd_idx;
     395             :                 }
     396             :             }
     397         584 :             else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY )
     398             :             {
     399        7308 :                 for ( b = 0; b < bands_pitch; b++ )
     400             :                 {
     401        6960 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     402        6960 :                     code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, p_gd_code_len );
     403        6960 :                     hMd->gd_idx = code + min_p_gd_idx;
     404        6960 :                     code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, p_gd_code_len );
     405        6960 :                     hMd->gd2_idx = code + min_p_gd_idx;
     406             :                 }
     407             :             }
     408             :             else
     409             :             {
     410        1180 :                 for ( b = 0; b < pred_imag_bands_roll; b++ )
     411             :                 {
     412         944 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     413        2832 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     414             :                     {
     415        5664 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     416             :                         {
     417        3776 :                             code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len );
     418        3776 :                             hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_roll_idx;
     419             :                         }
     420             :                     }
     421        2832 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     422             :                     {
     423        5664 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     424             :                         {
     425        3776 :                             code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len );
     426        3776 :                             hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_roll_idx;
     427             :                         }
     428             :                     }
     429             :                 }
     430             : 
     431        4012 :                 for ( ; b < pred_real_bands_roll; b++ )
     432             :                 {
     433        3776 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     434       11328 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     435             :                     {
     436        7552 :                         code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len );
     437        7552 :                         hMd->pred_mat_re_idx[ch1][ch1] = code + min_pred_roll_idx;
     438             :                     }
     439        3776 :                     hMd->pred_mat_re_idx[0][1] = 0;
     440        3776 :                     hMd->pred_mat_re_idx[1][0] = 0;
     441             :                 }
     442             :             }
     443             :         }
     444             :     }
     445             : 
     446         242 :     return;
     447             : }
     448             : 
     449             : 
     450             : /*-----------------------------------------------------------------------------------------*
     451             :  * Function isar_splitBinPostRendMdHuffDec()
     452             :  *
     453             :  *
     454             :  *-----------------------------------------------------------------------------------------*/
     455             : 
     456      149771 : static void isar_splitBinPostRendMdHuffDec(
     457             :     ISAR_SPLIT_REND_BITS_HANDLE pBits,                      /* i/o: ISAR bits handle                */
     458             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle   */
     459             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,            /* i/o: pose correction data handle     */
     460             :     const int16_t num_subframes,
     461             :     const int16_t pred_real_bands_yaw,
     462             :     const int16_t pred_imag_bands_yaw,
     463             :     const int16_t pred_quant_pnts_yaw,
     464             :     const int16_t d_bands_yaw,
     465             :     const int16_t bands_pitch,
     466             :     const int16_t pred_real_bands_roll,
     467             :     const int16_t pred_imag_bands_roll )
     468             : {
     469             :     int16_t pos_idx, b, sf_idx;
     470             :     int16_t ch1, ch2;
     471             :     int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
     472             :     int16_t min_pred_idx, max_pred_idx;
     473             :     int16_t min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx;
     474             :     ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd;
     475             :     ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg;
     476             : 
     477      149771 :     pHuff_cfg = &hBinHrSplitPostRend->huff_cfg;
     478             : 
     479      149771 :     if ( pred_quant_pnts_yaw == ISAR_SPLIT_REND_PRED_63QUANT_PNTS )
     480             :     {
     481      149748 :         pred_cb_idx = 1;
     482             :     }
     483             :     else
     484             :     {
     485          23 :         pred_cb_idx = 0;
     486             :     }
     487      149771 :     min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0];
     488      149771 :     max_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[( pred_quant_pnts_yaw - 1 ) * 3];
     489             : 
     490      149771 :     min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0];
     491      149771 :     max_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3];
     492             : 
     493      299542 :     for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
     494             :     {
     495      748427 :         for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     496             :         {
     497      598656 :             if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW )
     498             :             {
     499     3923310 :                 for ( b = 0; b < pred_imag_bands_yaw; b++ )
     500             :                 {
     501     3623768 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     502    10871304 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     503             :                     {
     504    21742608 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     505             :                         {
     506    14495072 :                             sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] );
     507             :                         }
     508             :                     }
     509     3623768 :                     isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_idx, max_pred_idx );
     510    10871304 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     511             :                     {
     512    21742608 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     513             :                         {
     514    14495072 :                             sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] );
     515             :                         }
     516             :                     }
     517     3623768 :                     isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx );
     518             :                 }
     519     2666614 :                 for ( ; b < pred_real_bands_yaw; b++ )
     520             :                 {
     521     2367072 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     522     7101216 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     523             :                     {
     524     4734144 :                         sym_adj_idx[ch1][ch1] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] );
     525             :                     }
     526     2367072 :                     sym_adj_idx[1][0] = 0;
     527     2367072 :                     sym_adj_idx[0][1] = 0;
     528     2367072 :                     isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_idx, max_pred_idx );
     529             :                 }
     530      299542 :                 for ( b = 0; b < d_bands_yaw; b++ )
     531             :                 {
     532           0 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     533           0 :                     hMd->gd_idx = isar_split_rend_huffman_decode_opt( &pHuff_cfg->gd, pBits, pHuff_cfg->gd_idx_trav );
     534             :                 }
     535             :             }
     536      299114 :             else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY )
     537             :             {
     538     3594486 :                 for ( b = 0; b < bands_pitch; b++ )
     539             :                 {
     540     3423320 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     541     3423320 :                     hMd->gd_idx = isar_split_rend_huffman_decode_opt( &pHuff_cfg->p_gd, pBits, pHuff_cfg->p_gd_idx_trav );
     542             : 
     543     3423320 :                     hMd->gd2_idx = isar_split_rend_huffman_decode_opt( &pHuff_cfg->p_gd, pBits, pHuff_cfg->p_gd_idx_trav );
     544             :                 }
     545             :             }
     546             :             else
     547             :             {
     548      639740 :                 for ( b = 0; b < pred_imag_bands_roll; b++ )
     549             :                 {
     550      511792 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     551             : 
     552     1535376 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     553             :                     {
     554     3070752 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     555             :                         {
     556     2047168 :                             sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav );
     557             :                         }
     558             :                     }
     559      511792 :                     isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx );
     560     1535376 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     561             :                     {
     562     3070752 :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     563             :                         {
     564     2047168 :                             sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav );
     565             :                         }
     566             :                     }
     567      511792 :                     isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx );
     568             :                 }
     569             : 
     570     2175116 :                 for ( ; b < pred_real_bands_roll; b++ )
     571             :                 {
     572     2047168 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     573             : 
     574     6141504 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     575             :                     {
     576     4094336 :                         sym_adj_idx[ch1][ch1] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav );
     577             :                     }
     578     2047168 :                     sym_adj_idx[1][0] = 0;
     579     2047168 :                     sym_adj_idx[0][1] = 0;
     580     2047168 :                     isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_roll_idx, max_pred_roll_idx );
     581             :                 }
     582             :             }
     583             :         }
     584             :     }
     585             : 
     586      149771 :     return;
     587             : }
     588             : 
     589             : 
     590             : /*-----------------------------------------------------------------------------------------*
     591             :  * Function isar_splitBinPostRendMdDec()
     592             :  *
     593             :  *
     594             :  *-----------------------------------------------------------------------------------------*/
     595             : 
     596      150013 : void isar_splitBinPostRendMdDec(
     597             :     ISAR_SPLIT_REND_BITS_HANDLE pBits,                      /* i/o: ISAR bits handle                */
     598             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle   */
     599             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData             /* i/o: pose correction data handle     */
     600             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     601             :     ,
     602             :     BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend
     603             : #endif
     604             : )
     605             : {
     606             :     int16_t pos_idx, b, sf_idx, num_subframes, ch1;
     607             :     int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS];
     608             :     int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS];
     609             :     int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS];
     610             :     int16_t num_quant_strats;
     611             :     int32_t quant_strat_bits, is_huff_coding, quant_strat;
     612             :     int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS];
     613             :     float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS];
     614             :     float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS];
     615             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     616             :     int16_t ch1, ch2;
     617             : #endif
     618             :     ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd;
     619             :     ISAR_SPLIT_REND_CONFIG_DATA split_rend_config;
     620             :     ISAR_SPLIT_REND_ROT_AXIS rot_axis;
     621             :     int16_t ro_md_flag, num_bits, axis_code;
     622             : 
     623      150013 :     hBinHrSplitPostRend->low_Res = 1;
     624             : 
     625      150013 :     split_rend_config.dof = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_DOF_BITS );
     626      150013 :     split_rend_config.hq_mode = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HQ_MODE_BITS );
     627             : 
     628      150013 :     num_bits = isar_renderSplitGetRot_axisNumBits( split_rend_config.dof );
     629      150013 :     if ( num_bits > 0 )
     630             :     {
     631       64456 :         axis_code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, (int32_t) num_bits );
     632             :     }
     633             :     else
     634             :     {
     635       85557 :         axis_code = 0;
     636             :     }
     637      150013 :     rot_axis = isar_renderSplitGetRot_axisFromCode( split_rend_config.dof, axis_code );
     638      150013 :     ro_md_flag = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_RO_FLAG_BITS );
     639             : 
     640      150013 :     isar_renderSplitGetMultiBinPoseData( &split_rend_config, pMultiBinPoseData, rot_axis );
     641             : 
     642      150013 :     set_fix_rotation_mat( hBinHrSplitPostRend->fix_pos_rot_mat, pMultiBinPoseData );
     643      150013 :     set_pose_types( hBinHrSplitPostRend->pose_type, pMultiBinPoseData );
     644             : 
     645      150013 :     num_subframes = ( hBinHrSplitPostRend->low_Res == 0 ) ? MAX_PARAM_SPATIAL_SUBFRAMES : 1;
     646      300026 :     for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
     647             :     {
     648             :         int16_t angle;
     649             : 
     650      150013 :         hBinHrSplitPostRend->QuaternionsPre[sf_idx].w = -3.0f;
     651             : 
     652      150013 :         angle = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS );
     653      150013 :         angle -= 180;
     654      150013 :         hBinHrSplitPostRend->QuaternionsPre[sf_idx].x = (float) angle;
     655             : 
     656      150013 :         angle = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS );
     657      150013 :         angle -= 180;
     658      150013 :         hBinHrSplitPostRend->QuaternionsPre[sf_idx].y = (float) angle;
     659             : 
     660      150013 :         angle = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS );
     661      150013 :         angle -= 180;
     662      150013 :         hBinHrSplitPostRend->QuaternionsPre[sf_idx].z = (float) angle;
     663             :     }
     664             : 
     665      150013 :     isar_split_rend_get_quant_params(
     666             :         MAX_SPLIT_REND_MD_BANDS,
     667             :         pred_real_bands_yaw,
     668             :         pred_imag_bands_yaw,
     669             :         pred_quant_pnts_yaw,
     670             :         pred_quantstep_yaw,
     671             :         pred_1byquantstep_yaw,
     672             :         d_bands_yaw,
     673             :         bands_pitch,
     674             :         pred_real_bands_roll,
     675             :         pred_imag_bands_roll,
     676             :         ro_md_flag,
     677             :         &num_quant_strats );
     678             : 
     679      150013 :     quant_strat_bits = (int32_t) ceilf( log2f( num_quant_strats ) );
     680      150013 :     is_huff_coding = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 );
     681      150013 :     quant_strat = ISAR_SPLIT_REND_BITStream_read_int32( pBits, quant_strat_bits );
     682             : 
     683      150013 :     if ( is_huff_coding == 0 )
     684             :     {
     685         242 :         isar_splitBinPostRendMdBase2Dec(
     686             :             pBits, hBinHrSplitPostRend,
     687             :             pMultiBinPoseData,
     688             :             num_subframes,
     689         242 :             pred_real_bands_yaw[quant_strat],
     690         242 :             pred_imag_bands_yaw[quant_strat],
     691         242 :             pred_quant_pnts_yaw[quant_strat],
     692         242 :             d_bands_yaw[quant_strat],
     693         242 :             bands_pitch[quant_strat],
     694         242 :             pred_real_bands_roll[quant_strat],
     695         242 :             pred_imag_bands_roll[quant_strat] );
     696             :     }
     697             :     else
     698             :     {
     699      149771 :         isar_splitBinPostRendMdHuffDec(
     700             :             pBits, hBinHrSplitPostRend,
     701             :             pMultiBinPoseData,
     702             :             num_subframes,
     703      149771 :             pred_real_bands_yaw[quant_strat],
     704      149771 :             pred_imag_bands_yaw[quant_strat],
     705      149771 :             pred_quant_pnts_yaw[quant_strat],
     706      149771 :             d_bands_yaw[quant_strat],
     707      149771 :             bands_pitch[quant_strat],
     708      149771 :             pred_real_bands_roll[quant_strat],
     709      149771 :             pred_imag_bands_roll[quant_strat] );
     710             :     }
     711             : #ifdef SPLIT_MD_CODING_DEBUG
     712             :     for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
     713             :     {
     714             :         int16_t val, ch2, val_ref;
     715             :         char filename[200] = "split_md_debug_indices.bin";
     716             :         for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     717             :         {
     718             :             if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW )
     719             :             {
     720             :                 for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ )
     721             :                 {
     722             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     723             :                     {
     724             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     725             :                         {
     726             :                             val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2];
     727             :                             dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     728             :                             if ( abs( val_ref - val ) > 0 )
     729             :                             {
     730             :                                 assert( 0 );
     731             :                             }
     732             :                         }
     733             :                     }
     734             :                 }
     735             :                 for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ )
     736             :                 {
     737             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     738             :                     {
     739             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     740             :                         {
     741             :                             val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2];
     742             :                             dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     743             :                             if ( abs( val_ref - val ) > 0 )
     744             :                             {
     745             :                                 assert( 0 );
     746             :                             }
     747             :                         }
     748             :                     }
     749             :                 }
     750             :                 for ( b = 0; b < d_bands_yaw[quant_strat]; b++ )
     751             :                 {
     752             :                     val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd_idx;
     753             :                     dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     754             :                     if ( abs( val_ref - val ) > 0 )
     755             :                     {
     756             :                         assert( 0 );
     757             :                     }
     758             :                 }
     759             :             }
     760             :             else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY )
     761             :             {
     762             :                 for ( b = 0; b < bands_pitch[quant_strat]; b++ )
     763             :                 {
     764             :                     val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd_idx;
     765             :                     dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     766             :                     if ( abs( val_ref - val ) > 0 )
     767             :                     {
     768             :                         assert( 0 );
     769             :                     }
     770             :                     val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd2_idx;
     771             :                     dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     772             :                     if ( abs( val_ref - val ) > 0 )
     773             :                     {
     774             :                         assert( 0 );
     775             :                     }
     776             :                 }
     777             :             }
     778             :             else
     779             :             {
     780             :                 for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ )
     781             :                 {
     782             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     783             :                     {
     784             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     785             :                         {
     786             :                             val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2];
     787             :                             dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     788             :                             if ( abs( val_ref - val ) > 0 )
     789             :                             {
     790             :                                 assert( 0 );
     791             :                             }
     792             :                         }
     793             :                     }
     794             :                 }
     795             :                 for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ )
     796             :                 {
     797             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     798             :                     {
     799             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     800             :                         {
     801             :                             val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2];
     802             :                             dbgread( &val_ref, sizeof( int16_t ), 1, filename );
     803             :                             if ( abs( val_ref - val ) > 0 )
     804             :                             {
     805             :                                 assert( 0 );
     806             :                             }
     807             :                         }
     808             :                     }
     809             :                 }
     810             :             }
     811             :         }
     812             :     }
     813             : #endif
     814             : 
     815      300026 :     for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
     816             :     {
     817      749737 :         for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     818             :         {
     819      599724 :             if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW )
     820             :             {
     821     3926074 :                 for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ )
     822             :                 {
     823     3626048 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     824     3626048 :                     isar_split_rend_unquant_md( hMd, PRED_ONLY, 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], pred_quantstep_yaw[quant_strat] );
     825             :                 }
     826     2674498 :                 for ( ; b < pred_real_bands_yaw[quant_strat]; b++ )
     827             :                 {
     828     2374472 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     829     2374472 :                     isar_split_rend_unquant_md( hMd, PRED_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], pred_quantstep_yaw[quant_strat] );
     830             :                 }
     831      300026 :                 for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ )
     832             :                 {
     833           0 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     834           0 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     835             :                     {
     836           0 :                         set_zero( hMd->pred_mat_re[ch1], BINAURAL_CHANNELS );
     837           0 :                         set_zero( hMd->pred_mat_im[ch1], BINAURAL_CHANNELS );
     838           0 :                         hMd->pred_mat_re[ch1][ch1] = 1.0f;
     839             :                     }
     840             :                 }
     841      300026 :                 for ( b = 0; b < d_bands_yaw[quant_strat]; b++ )
     842             :                 {
     843           0 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     844           0 :                     isar_split_rend_unquant_md( hMd, COM_GAIN_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], 0 );
     845             :                 }
     846     6300546 :                 for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ )
     847             :                 {
     848     6000520 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     849     6000520 :                     hMd->gd = 0.0f;
     850             :                 }
     851             :             }
     852      299698 :             else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY )
     853             :             {
     854     3601794 :                 for ( b = 0; b < bands_pitch[quant_strat]; b++ )
     855             :                 {
     856     3430280 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     857     3430280 :                     isar_split_rend_unquant_md( hMd, LR_GAIN_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], 0 );
     858             :                 }
     859      171514 :                 for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ )
     860             :                 {
     861           0 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     862           0 :                     hMd->gd = 1.0f;
     863           0 :                     hMd->gd2 = 1.0f;
     864             :                 }
     865             :             }
     866             :             else
     867             :             {
     868      640920 :                 for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ )
     869             :                 {
     870      512736 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     871      512736 :                     isar_split_rend_unquant_md( hMd, PRED_ROLL_ONLY, 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_Q_STEP );
     872             :                 }
     873     2179128 :                 for ( ; b < pred_real_bands_roll[quant_strat]; b++ )
     874             :                 {
     875     2050944 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     876     2050944 :                     isar_split_rend_unquant_md( hMd, PRED_ROLL_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_Q_STEP );
     877             :                 }
     878      128184 :                 for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ )
     879             :                 {
     880           0 :                     hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b];
     881           0 :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     882             :                     {
     883           0 :                         set_zero( hMd->pred_mat_re[ch1], BINAURAL_CHANNELS );
     884           0 :                         set_zero( hMd->pred_mat_im[ch1], BINAURAL_CHANNELS );
     885           0 :                         hMd->pred_mat_re[ch1][ch1] = 1.0f;
     886             :                     }
     887             :                 }
     888             :             }
     889             :         }
     890             :     }
     891             : 
     892             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
     893             :     for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
     894             :     {
     895             :         float val;
     896             :         for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ )
     897             :         {
     898             :             if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW )
     899             :             {
     900             :                 for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ )
     901             :                 {
     902             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     903             :                     {
     904             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     905             :                         {
     906             :                             val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2];
     907             :                             if ( fabsf( hMd->pred_mat_re_idx[ch1][ch2] - val ) > 1e-20 )
     908             :                             {
     909             :                                 assert( 0 );
     910             :                             }
     911             :                         }
     912             :                     }
     913             :                 }
     914             :                 for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ )
     915             :                 {
     916             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     917             :                     {
     918             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     919             :                         {
     920             :                             val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2];
     921             :                             if ( fabsf( hMd->pred_mat_im_idx[ch1][ch2] - val ) > 1e-20 )
     922             :                             {
     923             :                                 assert( 0 );
     924             :                             }
     925             :                         }
     926             :                     }
     927             :                 }
     928             :                 for ( b = 0; b < d_bands_yaw[quant_strat]; b++ )
     929             :                 {
     930             :                     val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx;
     931             :                     if ( fabsf( hMd->gd_idx - val ) > 1e-20 )
     932             :                     {
     933             :                         assert( 0 );
     934             :                     }
     935             :                 }
     936             :             }
     937             :             else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY )
     938             :             {
     939             :                 for ( b = 0; b < bands_pitch[quant_strat]; b++ )
     940             :                 {
     941             :                     val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx;
     942             :                     if ( fabsf( hMd->gd_idx - val ) > 1e-20 )
     943             :                     {
     944             :                         assert( 0 );
     945             :                     }
     946             :                     val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_idx;
     947             :                     if ( fabsf( hMd->gd2_idx - val ) > 1e-20 )
     948             :                     {
     949             :                         assert( 0 );
     950             :                     }
     951             :                 }
     952             :             }
     953             :             else
     954             :             {
     955             :                 for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ )
     956             :                 {
     957             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     958             :                     {
     959             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     960             :                         {
     961             :                             val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2];
     962             :                             if ( fabsf( hMd->pred_mat_re_idx[ch1][ch2] - val ) > 1e-20 )
     963             :                             {
     964             :                                 assert( 0 );
     965             :                             }
     966             :                         }
     967             :                     }
     968             :                 }
     969             :                 for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ )
     970             :                 {
     971             :                     for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ )
     972             :                     {
     973             :                         for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ )
     974             :                         {
     975             :                             val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2];
     976             :                             if ( fabsf( hMd->pred_mat_im_idx[ch1][ch2] - val ) > 1e-20 )
     977             :                             {
     978             :                                 assert( 0 );
     979             :                             }
     980             :                         }
     981             :                     }
     982             :                 }
     983             :             }
     984             :         }
     985             :     }
     986             : #endif
     987             : 
     988      150013 :     return;
     989             : }
     990             : 
     991             : 
     992             : /*-----------------------------------------------------------------------------------------*
     993             :  * Function wrap_around_angle()
     994             :  *
     995             :  *
     996             :  *-----------------------------------------------------------------------------------------*/
     997             : 
     998     1655328 : static void wrap_around_angle(
     999             :     float *a )
    1000             : {
    1001     1655328 :     if ( ( *a ) > 180.0f )
    1002             :     {
    1003       13186 :         ( *a ) = ( *a ) - 360;
    1004             :     }
    1005     1642142 :     else if ( ( *a ) < -180.0f )
    1006             :     {
    1007        6560 :         ( *a ) = ( *a ) + 360;
    1008             :     }
    1009             : 
    1010     1655328 :     return;
    1011             : }
    1012             : 
    1013             : 
    1014             : /*-----------------------------------------------------------------------------------------*
    1015             :  * Function wrap_around_angle()
    1016             :  *
    1017             :  *
    1018             :  *-----------------------------------------------------------------------------------------*/
    1019             : 
    1020      551776 : static void wrap_around_ypr(
    1021             :     IVAS_QUATERNION *Quaternions )
    1022             : {
    1023             :     /*only if quat is actually yaw, pitch , roll angles*/
    1024      551776 :     if ( Quaternions->w == -3.0f )
    1025             :     {
    1026      551776 :         wrap_around_angle( &Quaternions->x );
    1027      551776 :         wrap_around_angle( &Quaternions->y );
    1028      551776 :         wrap_around_angle( &Quaternions->z );
    1029             :     }
    1030             : 
    1031      551776 :     return;
    1032             : }
    1033             : 
    1034             : 
    1035             : /*-----------------------------------------------------------------------------------------*
    1036             :  * Function wrap_around_angle()
    1037             :  *
    1038             :  *
    1039             :  *-----------------------------------------------------------------------------------------*/
    1040             : 
    1041     1655328 : static float get_interp_fact(
    1042             :     float p[MAX_HEAD_ROT_POSES],
    1043             :     const float p_t,
    1044             :     const int16_t ind[2] )
    1045             : {
    1046             :     float n, d, interp_fact;
    1047             : 
    1048     1655328 :     if ( ind[0] != ind[1] )
    1049             :     {
    1050      838491 :         n = p[ind[0]] - p[ind[1]];
    1051      838491 :         d = p[ind[0]] - p_t;
    1052      838491 :         interp_fact = d / n;
    1053      838491 :         if ( interp_fact < 0.0f )
    1054             :         {
    1055      655946 :             d = max( -1.0f * MAX_EXTRAPOLATION_ANGLE, ( min( MAX_EXTRAPOLATION_ANGLE, d ) ) );
    1056      655946 :             n = sinf( n * ( EVS_PI / 180.0f ) );
    1057      655946 :             d = sinf( d * ( EVS_PI / 180.0f ) );
    1058      655946 :             interp_fact = d / n;
    1059             :         }
    1060             :     }
    1061             :     else
    1062             :     {
    1063      816837 :         interp_fact = 0.0f;
    1064             :     }
    1065             : 
    1066     1655328 :     return interp_fact;
    1067             : }
    1068             : 
    1069             : 
    1070             : /*-----------------------------------------------------------------------------------------*
    1071             :  * Function get_nearest_pose_ind()
    1072             :  *
    1073             :  *
    1074             :  *-----------------------------------------------------------------------------------------*/
    1075             : 
    1076      956091 : static void get_nearest_pose_ind(
    1077             :     float p[MAX_HEAD_ROT_POSES],
    1078             :     const float p_t,
    1079             :     int16_t ind[2],
    1080             :     const int16_t num_poses )
    1081             : {
    1082             :     float min_diff, diff;
    1083             :     int16_t pos_idx;
    1084             : 
    1085      956091 :     ind[0] = 0;
    1086      956091 :     ind[1] = 0;
    1087      956091 :     min_diff = 360.0f;
    1088             : 
    1089             :     /*find the closest pose from assumed poses*/
    1090     5900026 :     for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    1091             :     {
    1092     4943935 :         diff = fabsf( p_t - p[pos_idx] );
    1093     4943935 :         if ( diff < min_diff )
    1094             :         {
    1095     1691276 :             ind[0] = pos_idx;
    1096     1691276 :             min_diff = (float) diff;
    1097             :         }
    1098             :     }
    1099             : 
    1100      956091 :     min_diff = 360.0;
    1101     5900026 :     for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    1102             :     {
    1103     4943935 :         diff = fabsf( p_t - p[pos_idx] );
    1104     4943935 :         if ( ( diff < min_diff ) &&
    1105     2418364 :              ( fabs( p[pos_idx] - p[ind[0]] ) > EPSILON ) )
    1106             :         {
    1107      856135 :             ind[1] = pos_idx;
    1108      856135 :             min_diff = (float) diff;
    1109             :         }
    1110             :     }
    1111             : 
    1112      956091 :     return;
    1113             : }
    1114             : 
    1115             : 
    1116             : /*-----------------------------------------------------------------------------------------*
    1117             :  * Function get_interpolation_vars()
    1118             :  *
    1119             :  *
    1120             :  *-----------------------------------------------------------------------------------------*/
    1121             : 
    1122      551776 : static void get_interpolation_vars(
    1123             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle     */
    1124             :     const IVAS_QUATERNION *Quaternions_ref,
    1125             :     const IVAS_QUATERNION *Quaternions_act,
    1126             :     int16_t interp_yaw_pose_idx[2],
    1127             :     int16_t interp_pitch_pose_idx[2],
    1128             :     int16_t interp_roll_pose_idx[2],
    1129             :     float *interp_yaw_fact,
    1130             :     float *interp_pitch_fact,
    1131             :     float *interp_roll_fact )
    1132             : {
    1133             :     IVAS_QUATERNION quaternions_diff, quaternions_ref_euler, quaternions_act_euler;
    1134             :     float y[MAX_HEAD_ROT_POSES], p[MAX_HEAD_ROT_POSES], r[MAX_HEAD_ROT_POSES];
    1135             :     int16_t pos_idx, num_poses;
    1136             : 
    1137      551776 :     quaternions_diff.x = 0.0f;
    1138      551776 :     quaternions_diff.y = 0.0f;
    1139      551776 :     quaternions_diff.z = 0.0f;
    1140             : 
    1141      551776 :     num_poses = pMultiBinPoseData->num_poses;
    1142     3405912 :     for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    1143             :     {
    1144     2854136 :         quaternions_diff.x = pMultiBinPoseData->relative_head_poses[pos_idx][0];
    1145     2854136 :         quaternions_diff.y = pMultiBinPoseData->relative_head_poses[pos_idx][1];
    1146     2854136 :         quaternions_diff.z = pMultiBinPoseData->relative_head_poses[pos_idx][2];
    1147     2854136 :         y[pos_idx] = quaternions_diff.x;
    1148     2854136 :         p[pos_idx] = quaternions_diff.y;
    1149     2854136 :         r[pos_idx] = quaternions_diff.z;
    1150             :     }
    1151             : 
    1152             :     /*interpolation if actual pose is not same as one of assumed poses*/
    1153             :     /*get the deviation*/
    1154      551776 :     Quat2EulerDegree( *Quaternions_ref, &quaternions_ref_euler.z, &quaternions_ref_euler.y, &quaternions_ref_euler.x ); /*order in Quat2Euler seems to be reversed ?*/
    1155      551776 :     Quat2EulerDegree( *Quaternions_act, &quaternions_act_euler.z, &quaternions_act_euler.y, &quaternions_act_euler.x ); /*order in Quat2Euler seems to be reversed ?*/
    1156      551776 :     quaternions_diff.w = -3.0f;                                                                                         /*euler*/
    1157      551776 :     quaternions_diff.x = quaternions_act_euler.x - quaternions_ref_euler.x;
    1158      551776 :     quaternions_diff.y = quaternions_act_euler.y - quaternions_ref_euler.y;
    1159      551776 :     quaternions_diff.z = quaternions_act_euler.z - quaternions_ref_euler.z;
    1160      551776 :     wrap_around_ypr( &quaternions_diff );
    1161             : 
    1162      551776 :     interp_yaw_pose_idx[0] = 0;
    1163      551776 :     interp_yaw_pose_idx[1] = 0;
    1164      551776 :     if ( fabs( quaternions_diff.x ) > EPSILON )
    1165             :     {
    1166      551429 :         get_nearest_pose_ind( y, quaternions_diff.x, interp_yaw_pose_idx, num_poses );
    1167             :     }
    1168      551776 :     *interp_yaw_fact = get_interp_fact( y, quaternions_diff.x, interp_yaw_pose_idx );
    1169             : 
    1170      551776 :     interp_pitch_pose_idx[0] = 0;
    1171      551776 :     interp_pitch_pose_idx[1] = 0;
    1172      551776 :     if ( fabs( quaternions_diff.y ) > EPSILON )
    1173             :     {
    1174      233117 :         get_nearest_pose_ind( p, quaternions_diff.y, interp_pitch_pose_idx, num_poses );
    1175             :     }
    1176      551776 :     *interp_pitch_fact = get_interp_fact( p, quaternions_diff.y, interp_pitch_pose_idx );
    1177             : 
    1178      551776 :     interp_roll_pose_idx[0] = 0;
    1179      551776 :     interp_roll_pose_idx[1] = 0;
    1180      551776 :     if ( fabs( quaternions_diff.z ) > EPSILON )
    1181             :     {
    1182      171545 :         get_nearest_pose_ind( r, quaternions_diff.z, interp_roll_pose_idx, num_poses );
    1183             :     }
    1184      551776 :     *interp_roll_fact = get_interp_fact( r, quaternions_diff.z, interp_roll_pose_idx );
    1185             : 
    1186      551776 :     return;
    1187             : }
    1188             : 
    1189             : 
    1190             : /*-----------------------------------------------------------------------------------------*
    1191             :  * Function interpolate_pred_matrix()
    1192             :  *
    1193             :  *
    1194             :  *-----------------------------------------------------------------------------------------*/
    1195             : 
    1196    13154760 : static void interpolate_pred_matrix(
    1197             :     ISAR_BIN_HR_SPLIT_REND_MD rot_md[][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS],
    1198             :     const int16_t sf_idx,
    1199             :     const int16_t band_idx,
    1200             :     const int16_t ind[2],
    1201             :     const float interp_fact,
    1202             :     float mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS],
    1203             :     float mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS] )
    1204             : {
    1205             :     int16_t ch_idx1, ch_idx2;
    1206             :     float diff;
    1207             :     ISAR_BIN_HR_SPLIT_REND_MD *pRot_md;
    1208             :     float mix_mat_re1[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1209             :     float mix_mat_im1[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1210             :     float mix_mat_re2[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1211             :     float mix_mat_im2[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1212             : 
    1213    39464280 :     for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1214             :     {
    1215    26309520 :         set_zero( mix_mat_re1[ch_idx1], BINAURAL_CHANNELS );
    1216    26309520 :         set_zero( mix_mat_im1[ch_idx1], BINAURAL_CHANNELS );
    1217    26309520 :         mix_mat_re1[ch_idx1][ch_idx1] = 1.0f;
    1218             : 
    1219    26309520 :         set_zero( mix_mat_re2[ch_idx1], BINAURAL_CHANNELS );
    1220    26309520 :         set_zero( mix_mat_im2[ch_idx1], BINAURAL_CHANNELS );
    1221    26309520 :         mix_mat_re2[ch_idx1][ch_idx1] = 1.0f;
    1222             :     }
    1223             : 
    1224    13154760 :     if ( ind[0] != 0 )
    1225             :     {
    1226    11850680 :         pRot_md = &rot_md[ind[0] - 1][sf_idx][band_idx];
    1227             : 
    1228    35552040 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1229             :         {
    1230    71104080 :             for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ )
    1231             :             {
    1232    47402720 :                 mix_mat_re1[ch_idx1][ch_idx2] = pRot_md->pred_mat_re[ch_idx1][ch_idx2];
    1233    47402720 :                 mix_mat_im1[ch_idx1][ch_idx2] = pRot_md->pred_mat_im[ch_idx1][ch_idx2];
    1234             :             }
    1235             :         }
    1236             :     }
    1237             : 
    1238    13154760 :     if ( ind[1] != 0 )
    1239             :     {
    1240     1304080 :         pRot_md = &rot_md[ind[1] - 1][sf_idx][band_idx];
    1241             : 
    1242     3912240 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1243             :         {
    1244     7824480 :             for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ )
    1245             :             {
    1246     5216320 :                 mix_mat_re2[ch_idx1][ch_idx2] = pRot_md->pred_mat_re[ch_idx1][ch_idx2];
    1247     5216320 :                 mix_mat_im2[ch_idx1][ch_idx2] = pRot_md->pred_mat_im[ch_idx1][ch_idx2];
    1248             :             }
    1249             :         }
    1250             :     }
    1251             : 
    1252    39464280 :     for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1253             :     {
    1254    78928560 :         for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ )
    1255             :         {
    1256    52619040 :             diff = mix_mat_re1[ch_idx1][ch_idx2] - mix_mat_re2[ch_idx1][ch_idx2];
    1257    52619040 :             mat_re[ch_idx1][ch_idx2] = mix_mat_re1[ch_idx1][ch_idx2] - ( diff * interp_fact );
    1258             : 
    1259    52619040 :             diff = mix_mat_im1[ch_idx1][ch_idx2] - mix_mat_im2[ch_idx1][ch_idx2];
    1260    52619040 :             mat_im[ch_idx1][ch_idx2] = mix_mat_im1[ch_idx1][ch_idx2] - ( diff * interp_fact );
    1261             :         }
    1262             :     }
    1263             : 
    1264    13154760 :     return;
    1265             : }
    1266             : 
    1267             : 
    1268             : /*-----------------------------------------------------------------------------------------*
    1269             :  * Function interpolate_rend_md()
    1270             :  *
    1271             :  *
    1272             :  *-----------------------------------------------------------------------------------------*/
    1273             : 
    1274    11035520 : static void interpolate_rend_md(
    1275             :     ISAR_BIN_HR_SPLIT_REND_MD rot_md[][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS],
    1276             :     float mix_mat_re[][BINAURAL_CHANNELS],
    1277             :     float mix_mat_im[][BINAURAL_CHANNELS],
    1278             :     float *gd_int,
    1279             :     const int16_t sf_idx,
    1280             :     const int16_t band_idx,
    1281             :     const int16_t interp_yaw_pose_idx[2],
    1282             :     const int16_t interp_pitch_pose_idx[2],
    1283             :     const int16_t interp_roll_pose_idx[2],
    1284             :     const float interp_yaw_fact,
    1285             :     const float interp_pitch_fact,
    1286             :     const float interp_roll_fact )
    1287             : {
    1288             :     int16_t ch_idx1, idx1, idx2;
    1289             :     float mix_mat_re1[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1290             :     float mix_mat_im1[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1291             :     float mix_mat_re3[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1292             :     float mix_mat_im3[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1293             :     int16_t ch_idx2;
    1294             :     float gd1, gd2, gd3, gd4, diff, pitch_gain_r, pitch_gain_l;
    1295             : 
    1296    11035520 :     gd1 = 0.0f;
    1297    11035520 :     gd2 = 0.0f;
    1298             : 
    1299    11035520 :     idx1 = interp_yaw_pose_idx[0];
    1300    11035520 :     idx2 = interp_yaw_pose_idx[1];
    1301    11035520 :     if ( ( idx1 != 0 ) || ( idx2 != 0 ) )
    1302             :     {
    1303    11028580 :         interpolate_pred_matrix( rot_md, sf_idx, band_idx, interp_yaw_pose_idx, interp_yaw_fact, mix_mat_re, mix_mat_im );
    1304             : 
    1305    11028580 :         if ( idx1 != 0 )
    1306             :         {
    1307    10781020 :             gd1 = rot_md[idx1 - 1][sf_idx][band_idx].gd;
    1308             :         }
    1309             : 
    1310    11028580 :         if ( idx2 != 0 )
    1311             :         {
    1312      247560 :             gd2 = rot_md[idx2 - 1][sf_idx][band_idx].gd;
    1313             :         }
    1314             : 
    1315    11028580 :         diff = gd1 - gd2;
    1316    11028580 :         *gd_int = gd1 - ( diff * interp_yaw_fact );
    1317             :     }
    1318             :     else
    1319             :     {
    1320             :         /*P = P'*/
    1321       20820 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1322             :         {
    1323       13880 :             set_zero( mix_mat_re[ch_idx1], BINAURAL_CHANNELS );
    1324       13880 :             set_zero( mix_mat_im[ch_idx1], BINAURAL_CHANNELS );
    1325       13880 :             mix_mat_re[ch_idx1][ch_idx1] = 1.0f;
    1326             :         }
    1327        6940 :         *gd_int = 0.0f;
    1328             :     }
    1329             : 
    1330    11035520 :     idx1 = interp_pitch_pose_idx[0];
    1331    11035520 :     idx2 = interp_pitch_pose_idx[1];
    1332    11035520 :     if ( ( idx1 != 0 ) || ( idx2 != 0 ) )
    1333             :     {
    1334     3615060 :         gd1 = 1.0f;
    1335     3615060 :         gd2 = 1.0f;
    1336             : 
    1337     3615060 :         gd3 = 1.0f;
    1338     3615060 :         gd4 = 1.0f;
    1339             : 
    1340     3615060 :         if ( idx1 != 0 )
    1341             :         {
    1342     2853020 :             gd1 = rot_md[idx1 - 1][sf_idx][band_idx].gd;
    1343     2853020 :             gd3 = rot_md[idx1 - 1][sf_idx][band_idx].gd2;
    1344             :         }
    1345     3615060 :         if ( idx2 != 0 )
    1346             :         {
    1347      762040 :             gd2 = rot_md[idx2 - 1][sf_idx][band_idx].gd;
    1348      762040 :             gd4 = rot_md[idx2 - 1][sf_idx][band_idx].gd2;
    1349             :         }
    1350     3615060 :         diff = gd1 - gd2;
    1351     3615060 :         pitch_gain_l = gd1 - ( diff * interp_pitch_fact );
    1352     3615060 :         pitch_gain_l = max( 0.0f, pitch_gain_l );
    1353             : 
    1354     3615060 :         diff = gd3 - gd4;
    1355     3615060 :         pitch_gain_r = gd3 - ( diff * interp_pitch_fact );
    1356     3615060 :         pitch_gain_r = max( 0.0f, pitch_gain_r );
    1357             : 
    1358    10845180 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1359             :         {
    1360     7230120 :             mix_mat_re[ch_idx1][0] *= pitch_gain_l;
    1361     7230120 :             mix_mat_re[ch_idx1][1] *= pitch_gain_r;
    1362     7230120 :             mix_mat_im[ch_idx1][0] *= pitch_gain_l;
    1363     7230120 :             mix_mat_im[ch_idx1][1] *= pitch_gain_r;
    1364             :         }
    1365             :     }
    1366             :     else
    1367             :     {
    1368     7420460 :         pitch_gain_l = 1.0f;
    1369     7420460 :         pitch_gain_r = 1.0f;
    1370             :     }
    1371             : 
    1372    11035520 :     idx1 = interp_roll_pose_idx[0];
    1373    11035520 :     idx2 = interp_roll_pose_idx[1];
    1374    11035520 :     if ( ( idx1 != 0 ) || ( idx2 != 0 ) )
    1375             :     {
    1376     2126180 :         interpolate_pred_matrix( rot_md, sf_idx, band_idx, interp_roll_pose_idx, interp_roll_fact, mix_mat_re3, mix_mat_im3 );
    1377             : 
    1378     2126180 :         isar_mat_mult_2by2_complex( mix_mat_re, mix_mat_im, mix_mat_re3, mix_mat_im3, mix_mat_re1, mix_mat_im1 );
    1379             : 
    1380     6378540 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1381             :         {
    1382    12757080 :             for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ )
    1383             :             {
    1384     8504720 :                 mix_mat_re[ch_idx1][ch_idx2] = mix_mat_re1[ch_idx1][ch_idx2];
    1385     8504720 :                 mix_mat_im[ch_idx1][ch_idx2] = mix_mat_im1[ch_idx1][ch_idx2];
    1386             :             }
    1387             :         }
    1388             :     }
    1389             : 
    1390    11035520 :     return;
    1391             : }
    1392             : 
    1393             : 
    1394             : /*-----------------------------------------------------------------------------------------*
    1395             :  * Function isar_SplitRenderer_PostRenderer()
    1396             :  *
    1397             :  *
    1398             :  *-----------------------------------------------------------------------------------------*/
    1399             : 
    1400      551776 : static void isar_SplitRenderer_PostRenderer(
    1401             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer,                                                          /* i/o: binaural renderer handle         */
    1402             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,                                                                  /* i/o: pose correction data handle      */
    1403             :     float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o  : Reference/out Binaural signals */
    1404             :     float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o  : Reference/out Binaural signals */
    1405             :     const IVAS_QUATERNION Quaternion_act )
    1406             : {
    1407             :     int16_t pos_idx, b, brange[2], ch_idx1;
    1408             :     int16_t num_md_bands, slot_idx, b2, num_slots, sf_idx_md;
    1409             :     float pred_out_re[BINAURAL_CHANNELS], pred_out_im[BINAURAL_CHANNELS], tmp_re, tmp_im, gd_int;
    1410             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1411             :     ISAR_BIN_HR_SPLIT_REND_MD rot_md_act[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS];
    1412             : #else
    1413             :     ISAR_BIN_HR_SPLIT_REND_MD rot_md_act[1][MAX_SPLIT_REND_MD_BANDS];
    1414             : #endif
    1415             :     int16_t interp_yaw_pose_idx[2], interp_pitch_pose_idx[2], interp_roll_pose_idx[2];
    1416             :     float interp_yaw_fact, interp_pitch_fact, interp_roll_fact;
    1417             :     float mix_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1418             :     float mix_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    1419             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1420             :     float Cldfb_RealBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    1421             :     float Cldfb_ImagBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    1422             : #endif
    1423             :     float fade;
    1424             :     float *pMix_mat_re_prev[BINAURAL_CHANNELS];
    1425             :     float *pMix_mat_im_prev[BINAURAL_CHANNELS];
    1426      551776 :     const int16_t *pBand_grouping = isar_split_rend_band_grouping;
    1427             : 
    1428      551776 :     num_md_bands = MAX_SPLIT_REND_MD_BANDS;
    1429             : 
    1430      551776 :     push_wmops( "isar_SplitRenderer_PostRenderer" );
    1431             : 
    1432      551776 :     num_slots = MAX_PARAM_SPATIAL_SUBFRAMES;
    1433             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1434             :     pos_idx = MAX_HEAD_ROT_POSES - 1;
    1435             : #else
    1436      551776 :     pos_idx = 0;
    1437             : #endif
    1438             : 
    1439      551776 :     sf_idx_md = 0;
    1440      551776 :     get_interpolation_vars( pMultiBinPoseData, &hBinPostRenderer->QuaternionsPre[sf_idx_md], &Quaternion_act, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, &interp_yaw_fact, &interp_pitch_fact, &interp_roll_fact );
    1441             : 
    1442    11587296 :     for ( b = 0; b < num_md_bands; b++ )
    1443             :     {
    1444    33106560 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1445             :         {
    1446    22071040 :             set_zero( mix_mat_re[ch_idx1], BINAURAL_CHANNELS );
    1447    22071040 :             set_zero( mix_mat_im[ch_idx1], BINAURAL_CHANNELS );
    1448    22071040 :             mix_mat_re[ch_idx1][ch_idx1] = 1.0f;
    1449             :         }
    1450    11035520 :         gd_int = 0.0f;
    1451    11035520 :         interpolate_rend_md( hBinPostRenderer->rot_md, mix_mat_re, mix_mat_im, &gd_int, sf_idx_md, b, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, interp_yaw_fact, interp_pitch_fact, interp_roll_fact );
    1452             : 
    1453    33106560 :         for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1454             :         {
    1455             :             /*update the prediction matrix with interpolated matrix*/
    1456    22071040 :             rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] = mix_mat_re[ch_idx1][0];
    1457    22071040 :             rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] = mix_mat_re[ch_idx1][1];
    1458    22071040 :             rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] = mix_mat_im[ch_idx1][0];
    1459    22071040 :             rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] = mix_mat_im[ch_idx1][1];
    1460    22071040 :             rot_md_act[pos_idx][b].gd = gd_int;
    1461             :         }
    1462             :     }
    1463             : 
    1464             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1465             :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES - 1; pos_idx++ )
    1466             :     {
    1467             :         for ( b = 0; b < num_md_bands; b++ )
    1468             :         {
    1469             :             if ( hBinPostRenderer->pose_type[pos_idx] == PITCH_ONLY )
    1470             :             {
    1471             : 
    1472             :                 for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1473             :                 {
    1474             :                     set_zero( hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1], BINAURAL_CHANNELS );
    1475             :                     set_zero( hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1], BINAURAL_CHANNELS );
    1476             :                     hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][ch_idx1] = 1.0f;
    1477             :                 }
    1478             :                 hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[0][0] *= hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd;
    1479             :                 hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[1][1] *= hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd2;
    1480             :                 hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd = 0.0f;
    1481             :             }
    1482             :             else if ( hBinPostRenderer->pose_type[pos_idx] == ANY_ROLL )
    1483             :             {
    1484             :                 hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd = 0.0f;
    1485             :             }
    1486             : 
    1487             :             for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1488             :             {
    1489             : 
    1490             :                 /*update the prediction matrix with interpolated matrix*/
    1491             :                 rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][0];
    1492             :                 rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][1];
    1493             :                 rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1][0];
    1494             :                 rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1][1];
    1495             :                 rot_md_act[pos_idx][b].gd = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd;
    1496             :             }
    1497             :         }
    1498             :     }
    1499             : 
    1500             :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1501             : #else
    1502      551776 :     pos_idx = 0;
    1503             : #endif
    1504             :     {
    1505     2758880 :         for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ )
    1506             :         {
    1507     2207104 :             fade = ( (float) slot_idx + 1.0f ) / MAX_PARAM_SPATIAL_SUBFRAMES;
    1508     2207104 :             fade = min( fade, 1.0f );
    1509    46349184 :             for ( b = 0; b < num_md_bands; b++ )
    1510             :             {
    1511   132426240 :                 for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1512             :                 {
    1513    88284160 :                     if ( hBinPostRenderer->cf_flag )
    1514             :                     {
    1515    88173120 :                         pMix_mat_re_prev[ch_idx1] = hBinPostRenderer->mixer_mat_re[pos_idx][b][ch_idx1];
    1516    88173120 :                         pMix_mat_im_prev[ch_idx1] = hBinPostRenderer->mixer_mat_im[pos_idx][b][ch_idx1];
    1517    88173120 :                         mix_mat_re[ch_idx1][0] = fade * ( rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] ) +
    1518    88173120 :                                                  ( 1.0f - fade ) * pMix_mat_re_prev[ch_idx1][0];
    1519    88173120 :                         mix_mat_re[ch_idx1][1] = fade * ( rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] ) +
    1520    88173120 :                                                  ( 1.0f - fade ) * pMix_mat_re_prev[ch_idx1][1];
    1521             : 
    1522    88173120 :                         mix_mat_im[ch_idx1][0] = fade * ( rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] ) +
    1523    88173120 :                                                  ( 1.0f - fade ) * pMix_mat_im_prev[ch_idx1][0];
    1524    88173120 :                         mix_mat_im[ch_idx1][1] = fade * ( rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] ) +
    1525    88173120 :                                                  ( 1.0f - fade ) * pMix_mat_im_prev[ch_idx1][1];
    1526             :                     }
    1527             :                     else
    1528             :                     {
    1529      111040 :                         mix_mat_re[ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0];
    1530      111040 :                         mix_mat_re[ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1];
    1531      111040 :                         mix_mat_im[ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0];
    1532      111040 :                         mix_mat_im[ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1];
    1533             :                     }
    1534             :                 }
    1535             : 
    1536    44142080 :                 brange[0] = pBand_grouping[b];
    1537    44142080 :                 brange[1] = pBand_grouping[b + 1];
    1538   176568320 :                 for ( b2 = brange[0]; b2 < brange[1]; b2++ )
    1539             :                 {
    1540   397278720 :                     for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1541             :                     {
    1542             :                         /* Apply prediction matrix */
    1543   264852480 :                         IVAS_CMULT_FLOAT( Cldfb_RealBuffer_Ref_Binaural[0][slot_idx][b2],
    1544             :                                           Cldfb_ImagBuffer_Ref_Binaural[0][slot_idx][b2],
    1545             :                                           mix_mat_re[0][ch_idx1],
    1546             :                                           mix_mat_im[0][ch_idx1],
    1547             :                                           tmp_re,
    1548             :                                           tmp_im );
    1549   264852480 :                         pred_out_re[ch_idx1] = tmp_re;
    1550   264852480 :                         pred_out_im[ch_idx1] = tmp_im;
    1551             : 
    1552   264852480 :                         IVAS_CMULT_FLOAT( Cldfb_RealBuffer_Ref_Binaural[1][slot_idx][b2],
    1553             :                                           Cldfb_ImagBuffer_Ref_Binaural[1][slot_idx][b2],
    1554             :                                           mix_mat_re[1][ch_idx1],
    1555             :                                           mix_mat_im[1][ch_idx1],
    1556             :                                           tmp_re,
    1557             :                                           tmp_im );
    1558   264852480 :                         pred_out_re[ch_idx1] += tmp_re;
    1559   264852480 :                         pred_out_im[ch_idx1] += tmp_im;
    1560             :                     }
    1561             : 
    1562             : 
    1563   397278720 :                     for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1564             :                     {
    1565             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1566             :                         Cldfb_RealBuffer_Recons_Binaural[pos_idx][ch_idx1][slot_idx][b2] = pred_out_re[ch_idx1];
    1567             :                         Cldfb_ImagBuffer_Recons_Binaural[pos_idx][ch_idx1][slot_idx][b2] = pred_out_im[ch_idx1];
    1568             : #else
    1569   264852480 :                         Cldfb_RealBuffer_Ref_Binaural[ch_idx1][slot_idx][b2] = pred_out_re[ch_idx1];
    1570   264852480 :                         Cldfb_ImagBuffer_Ref_Binaural[ch_idx1][slot_idx][b2] = pred_out_im[ch_idx1];
    1571             : #endif
    1572             :                     }
    1573             :                 }
    1574             :             }
    1575             :         }
    1576             :     }
    1577             : 
    1578             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1579             :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1580             : #else
    1581      551776 :     pos_idx = 0;
    1582             : #endif
    1583             :     {
    1584    11587296 :         for ( b = 0; b < num_md_bands; b++ )
    1585             :         {
    1586    33106560 :             for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1587             :             {
    1588    22071040 :                 hBinPostRenderer->mixer_mat_re[pos_idx][b][ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0];
    1589    22071040 :                 hBinPostRenderer->mixer_mat_re[pos_idx][b][ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1];
    1590    22071040 :                 hBinPostRenderer->mixer_mat_im[pos_idx][b][ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0];
    1591    22071040 :                 hBinPostRenderer->mixer_mat_im[pos_idx][b][ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1];
    1592             :             }
    1593    11035520 :             hBinPostRenderer->gd_mem[pos_idx][b] = rot_md_act[pos_idx][b].gd;
    1594             :         }
    1595             :     }
    1596      551776 :     hBinPostRenderer->cf_flag = 1;
    1597             : 
    1598             : #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    1599             :     {
    1600             :         int16_t num_cldfb_bands;
    1601             :         num_cldfb_bands = CLDFB_NO_CHANNELS_MAX;
    1602             :         for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ )
    1603             :         {
    1604             :             index_slot = sf_idx * num_slots + slot_idx;
    1605             :             for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
    1606             :             {
    1607             :                 mvr2r( Cldfb_RealBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES - 1][ch_idx1][index_slot], Cldfb_RealBuffer_Ref_Binaural[ch_idx1][index_slot], num_cldfb_bands );
    1608             :                 mvr2r( Cldfb_ImagBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES - 1][ch_idx1][index_slot], Cldfb_ImagBuffer_Ref_Binaural[ch_idx1][index_slot], num_cldfb_bands );
    1609             :             }
    1610             :         }
    1611             : 
    1612             :         for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1613             :         {
    1614             :             char fname[200] = "recons_out_pos";
    1615             :             char tag[2];
    1616             :             tag[0] = (char) ( '0' + pos_idx );
    1617             :             tag[1] = '\0';
    1618             :             strcat( fname, tag );
    1619             :             strcat( fname, ".wav" );
    1620             :             isar_log_cldfb2wav_data(
    1621             :                 Cldfb_RealBuffer_Recons_Binaural[pos_idx],
    1622             :                 Cldfb_ImagBuffer_Recons_Binaural[pos_idx],
    1623             :                 hBinPostRenderer->cldfbSynReconsBinDec[pos_idx],
    1624             :                 BINAURAL_CHANNELS,
    1625             :                 num_cldfb_bands,
    1626             :                 48000,
    1627             :                 num_slots,
    1628             :                 sf_idx * num_slots,
    1629             :                 fname );
    1630             :         }
    1631             :     }
    1632             : 
    1633             : #endif
    1634      551776 :     pop_wmops();
    1635      551776 :     return;
    1636             : }
    1637             : 
    1638             : 
    1639             : /*-----------------------------------------------------------------------------------------*
    1640             :  * Function isar_rend_CldfbSplitPostRendProcessTdIn()
    1641             :  *
    1642             :  *
    1643             :  *-----------------------------------------------------------------------------------------*/
    1644             : 
    1645      228456 : static void isar_rend_CldfbSplitPostRendProcessTdIn(
    1646             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle    */
    1647             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,            /* i/o: pose correction data handle     */
    1648             :     const IVAS_QUATERNION QuaternionPost,
    1649             :     float output[][L_FRAME48k] )
    1650             : {
    1651             :     int16_t ch_idx, slot_idx, num_cldfb_bands;
    1652             :     float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    1653             :     float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    1654      228456 :     num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels;
    1655             : 
    1656             :     /* Implement CLDFB analysis */
    1657      685368 :     for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ )
    1658             :     {
    1659     2284560 :         for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ )
    1660             :         {
    1661     1827648 :             cldfbAnalysis_ts( &( output[ch_idx][num_cldfb_bands * slot_idx] ),
    1662     1827648 :                               Cldfb_RealBuffer_Binaural[ch_idx][slot_idx],
    1663     1827648 :                               Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx],
    1664             :                               num_cldfb_bands,
    1665             :                               hBinHrSplitPostRend->cldfbAna[ch_idx] );
    1666             :         }
    1667             :     }
    1668             : 
    1669      228456 :     isar_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost );
    1670             : 
    1671             :     /* Implement CLDFB synthesis */
    1672      685368 :     for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ )
    1673             :     {
    1674             :         float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES];
    1675             :         float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES];
    1676             : 
    1677     2284560 :         for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ )
    1678             :         {
    1679     1827648 :             RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx];
    1680     1827648 :             ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx];
    1681             :         }
    1682             : 
    1683      456912 :         cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] );
    1684             :     }
    1685             : 
    1686      228456 :     return;
    1687             : }
    1688             : 
    1689             : 
    1690             : /*-----------------------------------------------------------------------------------------*
    1691             :  * Function isar_rend_CldfbSplitPostRendProcess()
    1692             :  *
    1693             :  *
    1694             :  *-----------------------------------------------------------------------------------------*/
    1695             : 
    1696      551776 : void isar_rend_CldfbSplitPostRendProcess(
    1697             :     ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle   */
    1698             :     MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,            /* i/o: pose correction data handle     */
    1699             :     const IVAS_QUATERNION QuaternionPost,
    1700             :     float Cldfb_RealBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],
    1701             :     float Cldfb_ImagBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],
    1702             :     float output[][L_FRAME48k],
    1703             :     const int16_t cldfb_in_flag )
    1704             : {
    1705             :     int16_t ch_idx, slot_idx, num_cldfb_bands;
    1706             : 
    1707      551776 :     push_wmops( "isar_rend_CldfbSplitPostRendProcess" );
    1708             : 
    1709      551776 :     num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels;
    1710             : 
    1711      551776 :     if ( cldfb_in_flag == 0 )
    1712             :     {
    1713      228456 :         isar_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, QuaternionPost, output );
    1714      228456 :         pop_wmops();
    1715      228456 :         return;
    1716             :     }
    1717             : 
    1718      323320 :     isar_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost );
    1719             : 
    1720             :     /* Implement CLDFB synthesis */
    1721      969960 :     for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ )
    1722             :     {
    1723             :         float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES];
    1724             :         float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES];
    1725             : 
    1726     3233200 :         for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ )
    1727             :         {
    1728     2586560 :             RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx];
    1729     2586560 :             ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx];
    1730             :         }
    1731             : 
    1732      646640 :         cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] );
    1733             :     }
    1734             : 
    1735      323320 :     pop_wmops();
    1736      323320 :     return;
    1737             : }
    1738             : 
    1739             : 
    1740             : /*-----------------------------------------------------------------------------------------*
    1741             :  * Function isar_init_split_post_rend_handles()
    1742             :  *
    1743             :  *
    1744             :  *-----------------------------------------------------------------------------------------*/
    1745             : 
    1746        1032 : void isar_init_split_post_rend_handles(
    1747             :     ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle     */
    1748             : )
    1749             : {
    1750        1032 :     hSplitRendWrapper->hBinHrSplitPostRend = NULL;
    1751        1032 :     hSplitRendWrapper->hSplitBinLCLDDec = NULL;
    1752        1032 :     hSplitRendWrapper->hLc3plusDec = NULL;
    1753        1032 :     isar_init_multi_bin_pose_data( &hSplitRendWrapper->multiBinPoseData );
    1754        1032 :     hSplitRendWrapper->first_good_frame_received = 0;
    1755             : 
    1756        1032 :     return;
    1757             : }

Generated by: LCOV version 1.14