LCOV - code coverage report
Current view: top level - lib_rend - ivas_crend.c (source / functions) Hit Total Coverage
Test: Coverage on main -- merged total coverage @ efe53129c9ed87a5067dd0a8fb9dca41db9c4add Lines: 743 849 87.5 %
Date: 2026-02-12 08:06:51 Functions: 17 17 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2026 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 "prot.h"
      36             : #include "ivas_prot.h"
      37             : #include "ivas_prot_rend.h"
      38             : #include "ivas_cnst.h"
      39             : #include "ivas_rom_rend.h"
      40             : #include <math.h>
      41             : #include "ivas_rom_binaural_crend_head.h"
      42             : #include "ivas_stat_rend.h"
      43             : #include "lib_rend.h"
      44             : #ifdef DEBUGGING
      45             : #include "debug.h"
      46             : #endif
      47             : #include "wmc_auto.h"
      48             : 
      49             : 
      50             : /*-------------------------------------------------------------------------
      51             :  * ivas_Crend_hrtf_init()
      52             :  *
      53             :  * Initialize hHrtf handle
      54             :  *------------------------------------------------------------------------*/
      55             : 
      56       19343 : ivas_error ivas_Crend_hrtf_init(
      57             :     HRTFS_CREND_DATA *hHrtf /* i/o: HRTF handle     */
      58             : )
      59             : {
      60             :     int16_t i, j;
      61             : 
      62       19343 :     if ( hHrtf == NULL )
      63             :     {
      64           0 :         return IVAS_ERR_WRONG_PARAMS;
      65             :     }
      66             : 
      67       19343 :     hHrtf->latency_s = 0;
      68       19343 :     hHrtf->gain_lfe = 0;
      69       19343 :     hHrtf->max_num_ir = 0;
      70       19343 :     hHrtf->max_num_iterations = 0;
      71       19343 :     hHrtf->index_frequency_max_diffuse = 0;
      72       19343 :     hHrtf->same_inv_diffuse_weight = 1;
      73             : 
      74      328831 :     for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
      75             :     {
      76      928464 :         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
      77             :         {
      78      618976 :             hHrtf->inv_diffuse_weight[j][i] = 0;
      79      618976 :             hHrtf->num_iterations[i][j] = 0;
      80      618976 :             hHrtf->pIndex_frequency_max[i][j] = NULL;
      81      618976 :             hHrtf->pOut_to_bin_re[i][j] = NULL;
      82      618976 :             hHrtf->pOut_to_bin_im[i][j] = NULL;
      83      618976 :             hHrtf->pOut_to_bin_re_dyn[i][j] = NULL;
      84      618976 :             hHrtf->pOut_to_bin_im_dyn[i][j] = NULL;
      85      618976 :             hHrtf->pIndex_frequency_max_dyn[i][j] = NULL;
      86             :         }
      87             :     }
      88             : 
      89       58029 :     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
      90             :     {
      91       38686 :         hHrtf->num_iterations_diffuse[j] = 0;
      92       38686 :         hHrtf->pIndex_frequency_max_diffuse[j] = NULL;
      93       38686 :         hHrtf->pOut_to_bin_diffuse_re[j] = NULL;
      94       38686 :         hHrtf->pOut_to_bin_diffuse_im[j] = NULL;
      95       38686 :         hHrtf->pIndex_frequency_max_diffuse_dyn[j] = NULL;
      96       38686 :         hHrtf->pOut_to_bin_diffuse_re_dyn[j] = NULL;
      97       38686 :         hHrtf->pOut_to_bin_diffuse_im_dyn[j] = NULL;
      98             :     }
      99             : 
     100       19343 :     hHrtf->init_from_rom = 1;
     101             : 
     102       19343 :     return IVAS_ERR_OK;
     103             : }
     104             : 
     105             : 
     106             : /*-------------------------------------------------------------------------
     107             :  * ivas_hrtf_open()
     108             :  *
     109             :  * Open hHrtf handle for Crend renderer
     110             :  *------------------------------------------------------------------------*/
     111             : 
     112       17055 : static ivas_error ivas_hrtf_open(
     113             :     HRTFS_CREND_HANDLE *hHrtf_out /* o  : HRTF handle     */
     114             : )
     115             : {
     116             :     HRTFS_CREND_HANDLE hHrtf;
     117             :     ivas_error error;
     118             : 
     119       17055 :     if ( *hHrtf_out == NULL )
     120             :     {
     121       17055 :         if ( ( hHrtf = (HRTFS_CREND_HANDLE) malloc( sizeof( HRTFS_CREND_DATA ) ) ) == NULL )
     122             :         {
     123           0 :             return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend HRTFS Handle\n" );
     124             :         }
     125             : 
     126       17055 :         if ( ( error = ivas_Crend_hrtf_init( hHrtf ) ) != IVAS_ERR_OK )
     127             :         {
     128           0 :             return error;
     129             :         }
     130             : 
     131       17055 :         *hHrtf_out = hHrtf;
     132             :     }
     133             :     else
     134             :     {
     135           0 :         return IVAS_ERR_INTERNAL;
     136             :     }
     137             : 
     138       17055 :     return IVAS_ERR_OK;
     139             : }
     140             : 
     141             : /*-------------------------------------------------------------------------
     142             :  * ivas_hrtf_close()
     143             :  *
     144             :  * Close hHrtf handle
     145             :  *------------------------------------------------------------------------*/
     146             : 
     147       17055 : static void ivas_hrtf_close(
     148             :     HRTFS_CREND_HANDLE *hHrtf /* i/o: Crend HRTF handle         */
     149             : )
     150             : {
     151       17055 :     if ( hHrtf == NULL || *hHrtf == NULL )
     152             :     {
     153           0 :         return;
     154             :     }
     155             : 
     156       17055 :     free( *hHrtf );
     157       17055 :     *hHrtf = NULL;
     158             : 
     159       17055 :     return;
     160             : }
     161             : 
     162             : 
     163             : /*-------------------------------------------------------------------------
     164             :  * ivas_rend_initCrend()
     165             :  *
     166             :  * Allocate and initialize crend renderer handle
     167             :  *------------------------------------------------------------------------*/
     168             : 
     169       19343 : static ivas_error ivas_rend_initCrend(
     170             :     CREND_WRAPPER *pCrend,
     171             :     const AUDIO_CONFIG inConfig,
     172             :     const AUDIO_CONFIG outConfig,
     173             :     HRTFS_CREND_HANDLE hHrtfCrend,
     174             :     const int16_t ext_rend_flag,
     175             :     const int32_t output_Fs )
     176             : {
     177             :     int16_t i, j, tmp, tmp2;
     178             :     int16_t nchan_in;
     179             :     IVAS_REND_AudioConfigType inConfigType;
     180             :     HRTFS_CREND_HANDLE hHrtf;
     181             :     ivas_error error;
     182             : 
     183       19343 :     inConfigType = getAudioConfigType( inConfig );
     184       19343 :     hHrtf = pCrend->hHrtfCrend;
     185             : 
     186             :     /* Do all error checks up front so that the nested if later is easier */
     187       19343 :     if ( inConfigType != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED && inConfigType != IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS )
     188             :     {
     189           0 :         return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Encountered unsupported input config in Crend" );
     190             :     }
     191             : 
     192       19343 :     if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
     193             :     {
     194           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" );
     195             :     }
     196             : 
     197       19343 :     if ( hHrtf == NULL )
     198             :     {
     199       19343 :         if ( hHrtfCrend != NULL && ext_rend_flag == 0 )
     200             :         {
     201             :             /* HRTF set loaded from binary file */
     202        2288 :             hHrtf = hHrtfCrend;
     203        2288 :             hHrtf->init_from_rom = 0;
     204             :         }
     205             :         else
     206             :         {
     207             :             /* create new handle when HRTF is loaded from ROM, or external renderer is used */
     208       17055 :             if ( ( error = ivas_hrtf_open( &hHrtf ) ) != IVAS_ERR_OK )
     209             :             {
     210           0 :                 return error;
     211             :             }
     212             : 
     213       17055 :             hHrtf->init_from_rom = 1;
     214       17055 :             if ( hHrtfCrend != NULL )
     215             :             {
     216           0 :                 hHrtf->init_from_rom = 0;
     217             :             }
     218             :         }
     219             :     }
     220             : 
     221       19343 :     if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK )
     222             :     {
     223           0 :         return error;
     224             :     }
     225       19343 :     hHrtf->max_num_ir = nchan_in;
     226             : 
     227       19343 :     if ( hHrtf->max_num_ir <= 0 )
     228             :     {
     229           0 :         return IVAS_ERR_INTERNAL_FATAL;
     230             :     }
     231             : 
     232       19343 :     if ( hHrtf->init_from_rom )
     233             :     {
     234       17055 :         if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
     235             :         {
     236       14075 :             hHrtf->max_num_ir -= 1; /* subtract LFE */
     237       14075 :             hHrtf->gain_lfe = GAIN_LFE;
     238             : 
     239       14075 :             if ( output_Fs == 48000 )
     240             :             {
     241        6501 :                 if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     242             :                 {
     243        5010 :                     hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s;
     244        5010 :                     hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_48kHz;
     245        5010 :                     hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz;
     246             :                 }
     247             :                 else
     248             :                 {
     249        1491 :                     hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s;
     250        1491 :                     hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_48kHz;
     251        1491 :                     hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz;
     252             :                 }
     253             : 
     254       19503 :                 for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     255             :                 {
     256       13002 :                     if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     257             :                     {
     258       10020 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[j];
     259       10020 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[j];
     260       10020 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz[j];
     261       10020 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[j];
     262             :                     }
     263             :                     else
     264             :                     {
     265        2982 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[j];
     266        2982 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[j];
     267        2982 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[j];
     268        2982 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[j];
     269             :                     }
     270             :                 }
     271             :             }
     272        7574 :             else if ( output_Fs == 32000 )
     273             :             {
     274        3407 :                 if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     275             :                 {
     276        3044 :                     hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s;
     277        3044 :                     hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_32kHz;
     278        3044 :                     hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz;
     279             :                 }
     280             :                 else
     281             :                 {
     282         363 :                     hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s;
     283         363 :                     hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_32kHz;
     284         363 :                     hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz;
     285             :                 }
     286             : 
     287       10221 :                 for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     288             :                 {
     289        6814 :                     if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     290             :                     {
     291        6088 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[j];
     292        6088 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[j];
     293        6088 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz[j];
     294        6088 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[j];
     295             :                     }
     296             :                     else
     297             :                     {
     298         726 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[j];
     299         726 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[j];
     300         726 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[j];
     301         726 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[j];
     302             :                     }
     303             :                 }
     304             :             }
     305        4167 :             else if ( output_Fs == 16000 )
     306             :             {
     307        4167 :                 if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     308             :                 {
     309        2094 :                     hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s;
     310             : 
     311        2094 :                     hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_16kHz;
     312        2094 :                     hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz;
     313             :                 }
     314             :                 else
     315             :                 {
     316        2073 :                     hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s;
     317        2073 :                     hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_16kHz;
     318        2073 :                     hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz;
     319             :                 }
     320             : 
     321       12501 :                 for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     322             :                 {
     323        8334 :                     if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     324             :                     {
     325        4188 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[j];
     326        4188 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[j];
     327        4188 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz[j];
     328        4188 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[j];
     329             :                     }
     330             :                     else
     331             :                     {
     332        4146 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[j];
     333        4146 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[j];
     334        4146 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[j];
     335        4146 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[j];
     336             :                     }
     337             :                 }
     338             :             }
     339             :             else
     340             :             {
     341           0 :                 return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" );
     342             :             }
     343             : 
     344      135008 :             for ( i = 0; i < hHrtf->max_num_ir; i++ )
     345             :             {
     346      120933 :                 if ( inConfig == IVAS_AUDIO_CONFIG_5_1 )
     347             :                 {
     348       23680 :                     tmp = channelIndex_CICP6[i];
     349             :                 }
     350       97253 :                 else if ( inConfig == IVAS_AUDIO_CONFIG_7_1 )
     351             :                 {
     352        1848 :                     tmp = channelIndex_CICP12[i];
     353             :                 }
     354       95405 :                 else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_2 )
     355             :                 {
     356        6636 :                     tmp = channelIndex_CICP14[i];
     357             :                 }
     358       88769 :                 else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_4 )
     359             :                 {
     360        2826 :                     tmp = channelIndex_CICP16[i];
     361             :                 }
     362       85943 :                 else if ( inConfig == IVAS_AUDIO_CONFIG_7_1_4 )
     363             :                 {
     364       85943 :                     tmp = channelIndex_CICP19[i];
     365             :                 }
     366             :                 else
     367             :                 {
     368           0 :                     return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" );
     369             :                 }
     370             : 
     371      120933 :                 if ( output_Fs == 48000 )
     372             :                 {
     373      160173 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     374             :                     {
     375      106782 :                         if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     376             :                         {
     377       88328 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[j][tmp];
     378       88328 :                             hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_48kHz[tmp][j];
     379       88328 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[tmp][j];
     380       88328 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_48kHz[tmp][j];
     381       88328 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_48kHz[tmp][j];
     382             :                         }
     383             :                         else
     384             :                         {
     385       18454 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[j][tmp];
     386       18454 :                             hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_48kHz[tmp][j];
     387       18454 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[tmp][j];
     388       18454 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_48kHz[tmp][j];
     389       18454 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_48kHz[tmp][j];
     390             :                         }
     391             :                     }
     392             :                 }
     393       67542 :                 else if ( output_Fs == 32000 )
     394             :                 {
     395      108021 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     396             :                     {
     397       72014 :                         if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     398             :                         {
     399       66112 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[j][tmp];
     400       66112 :                             hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_32kHz[tmp][j];
     401       66112 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[tmp][j];
     402       66112 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_32kHz[tmp][j];
     403       66112 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_32kHz[tmp][j];
     404             :                         }
     405             :                         else
     406             :                         {
     407        5902 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[j][tmp];
     408        5902 :                             hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_32kHz[tmp][j];
     409        5902 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[tmp][j];
     410        5902 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_32kHz[tmp][j];
     411        5902 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_32kHz[tmp][j];
     412             :                         }
     413             :                     }
     414             :                 }
     415       31535 :                 else if ( output_Fs == 16000 )
     416             :                 {
     417       94605 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     418             :                     {
     419       63070 :                         if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     420             :                         {
     421       40068 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[j][tmp];
     422       40068 :                             hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_16kHz[tmp][j];
     423       40068 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[tmp][j];
     424       40068 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_16kHz[tmp][j];
     425       40068 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_16kHz[tmp][j];
     426             :                         }
     427             :                         else
     428             :                         {
     429       23002 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[j][tmp];
     430       23002 :                             hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_16kHz[tmp][j];
     431       23002 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[tmp][j];
     432       23002 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_16kHz[tmp][j];
     433       23002 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_16kHz[tmp][j];
     434             :                         }
     435             :                     }
     436             :                 }
     437             :                 else
     438             :                 {
     439           0 :                     return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" );
     440             :                 }
     441             :             }
     442             :         }
     443        2980 :         else if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS )
     444             :         {
     445        2980 :             if ( inConfig == IVAS_AUDIO_CONFIG_HOA3 )
     446             :             {
     447        1484 :                 if ( output_Fs == 48000 )
     448             :                 {
     449        1044 :                     hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s;
     450        1044 :                     hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_48kHz;
     451        1044 :                     hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz;
     452             : 
     453       17748 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     454             :                     {
     455       50112 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     456             :                         {
     457       33408 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[j][i];
     458       33408 :                             hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j];
     459       33408 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j];
     460       33408 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j];
     461       33408 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz[i][j];
     462             :                         }
     463             :                     }
     464        3132 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     465             :                     {
     466        2088 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[j];
     467        2088 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[j];
     468        2088 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[j];
     469        2088 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[j];
     470             :                     }
     471             :                 }
     472         440 :                 else if ( output_Fs == 32000 )
     473             :                 {
     474         219 :                     hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s;
     475         219 :                     hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_32kHz;
     476         219 :                     hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz;
     477             : 
     478        3723 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     479             :                     {
     480       10512 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     481             :                         {
     482        7008 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[j][i];
     483        7008 :                             hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j];
     484        7008 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j];
     485        7008 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j];
     486        7008 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz[i][j];
     487             :                         }
     488             :                     }
     489             : 
     490         657 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     491             :                     {
     492         438 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[j];
     493         438 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[j];
     494         438 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[j];
     495         438 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[j];
     496             :                     }
     497             :                 }
     498         221 :                 else if ( output_Fs == 16000 )
     499             :                 {
     500         221 :                     hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s;
     501         221 :                     hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_16kHz;
     502         221 :                     hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz;
     503             : 
     504        3757 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     505             :                     {
     506       10608 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     507             :                         {
     508        7072 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[j][i];
     509        7072 :                             hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j];
     510        7072 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j];
     511        7072 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j];
     512        7072 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz[i][j];
     513             :                         }
     514             :                     }
     515             : 
     516         663 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     517             :                     {
     518         442 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[j];
     519         442 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[j];
     520         442 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[j];
     521         442 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[j];
     522             :                     }
     523             :                 }
     524             :                 else
     525             :                 {
     526           0 :                     return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" );
     527             :                 }
     528             :             }
     529        1496 :             else if ( inConfig == IVAS_AUDIO_CONFIG_HOA2 )
     530             :             {
     531         706 :                 if ( output_Fs == 48000 )
     532             :                 {
     533         278 :                     hHrtf->latency_s = CRendBin_HOA2_HRIR_latency_s;
     534         278 :                     hHrtf->max_num_iterations = CRendBin_HOA2_HRIR_max_num_iterations_48kHz;
     535         278 :                     hHrtf->index_frequency_max_diffuse = CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz;
     536             : 
     537        2780 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     538             :                     {
     539        7506 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     540             :                         {
     541        5004 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[j][i];
     542        5004 :                             hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_48kHz[i][j];
     543        5004 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[i][j];
     544        5004 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_48kHz[i][j];
     545        5004 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_48kHz[i][j];
     546             :                         }
     547             :                     }
     548         834 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     549             :                     {
     550         556 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[j];
     551         556 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[j];
     552         556 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz[j];
     553         556 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz[j];
     554             :                     }
     555             :                 }
     556         428 :                 else if ( output_Fs == 32000 )
     557             :                 {
     558         214 :                     hHrtf->latency_s = CRendBin_HOA2_HRIR_latency_s;
     559         214 :                     hHrtf->max_num_iterations = CRendBin_HOA2_HRIR_max_num_iterations_32kHz;
     560         214 :                     hHrtf->index_frequency_max_diffuse = CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz;
     561             : 
     562        2140 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     563             :                     {
     564        5778 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     565             :                         {
     566        3852 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[j][i];
     567        3852 :                             hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_32kHz[i][j];
     568        3852 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[i][j];
     569        3852 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_32kHz[i][j];
     570        3852 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_32kHz[i][j];
     571             :                         }
     572             :                     }
     573             : 
     574         642 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     575             :                     {
     576         428 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[j];
     577         428 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[j];
     578         428 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz[j];
     579         428 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz[j];
     580             :                     }
     581             :                 }
     582         214 :                 else if ( output_Fs == 16000 )
     583             :                 {
     584         214 :                     hHrtf->latency_s = CRendBin_HOA2_HRIR_latency_s;
     585         214 :                     hHrtf->max_num_iterations = CRendBin_HOA2_HRIR_max_num_iterations_16kHz;
     586         214 :                     hHrtf->index_frequency_max_diffuse = CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz;
     587             : 
     588        2140 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     589             :                     {
     590        5778 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     591             :                         {
     592        3852 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[j][i];
     593        3852 :                             hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_16kHz[i][j];
     594        3852 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[i][j];
     595        3852 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_16kHz[i][j];
     596        3852 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_16kHz[i][j];
     597             :                         }
     598             :                     }
     599             : 
     600         642 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     601             :                     {
     602         428 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[j];
     603         428 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[j];
     604         428 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz[j];
     605         428 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz[j];
     606             :                     }
     607             :                 }
     608             :                 else
     609             :                 {
     610           0 :                     return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" );
     611             :                 }
     612             :             }
     613         790 :             else if ( inConfig == IVAS_AUDIO_CONFIG_FOA )
     614             :             {
     615         790 :                 if ( output_Fs == 48000 )
     616             :                 {
     617         353 :                     hHrtf->latency_s = CRendBin_FOA_HRIR_latency_s;
     618         353 :                     hHrtf->max_num_iterations = CRendBin_FOA_HRIR_max_num_iterations_48kHz;
     619         353 :                     hHrtf->index_frequency_max_diffuse = CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz;
     620             : 
     621        1765 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     622             :                     {
     623        4236 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     624             :                         {
     625        2824 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[j][i];
     626        2824 :                             hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_48kHz[i][j];
     627        2824 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[i][j];
     628        2824 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_48kHz[i][j];
     629        2824 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_FOA_HRIR_coeff_im_48kHz[i][j];
     630             :                         }
     631             :                     }
     632        1059 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     633             :                     {
     634         706 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[j];
     635         706 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[j];
     636         706 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz[j];
     637         706 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz[j];
     638             :                     }
     639             :                 }
     640         437 :                 else if ( output_Fs == 32000 )
     641             :                 {
     642         219 :                     hHrtf->latency_s = CRendBin_FOA_HRIR_latency_s;
     643         219 :                     hHrtf->max_num_iterations = CRendBin_FOA_HRIR_max_num_iterations_32kHz;
     644         219 :                     hHrtf->index_frequency_max_diffuse = CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz;
     645             : 
     646        1095 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     647             :                     {
     648        2628 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     649             :                         {
     650        1752 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[j][i];
     651        1752 :                             hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_32kHz[i][j];
     652        1752 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[i][j];
     653        1752 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_32kHz[i][j];
     654        1752 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_FOA_HRIR_coeff_im_32kHz[i][j];
     655             :                         }
     656             :                     }
     657             : 
     658         657 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     659             :                     {
     660         438 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[j];
     661         438 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[j];
     662         438 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz[j];
     663         438 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz[j];
     664             :                     }
     665             :                 }
     666         218 :                 else if ( output_Fs == 16000 )
     667             :                 {
     668         218 :                     hHrtf->latency_s = CRendBin_FOA_HRIR_latency_s;
     669         218 :                     hHrtf->max_num_iterations = CRendBin_FOA_HRIR_max_num_iterations_16kHz;
     670         218 :                     hHrtf->index_frequency_max_diffuse = CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz;
     671             : 
     672        1090 :                     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     673             :                     {
     674        2616 :                         for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     675             :                         {
     676        1744 :                             hHrtf->inv_diffuse_weight[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[j][i];
     677        1744 :                             hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_16kHz[i][j];
     678        1744 :                             hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[i][j];
     679        1744 :                             hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_16kHz[i][j];
     680        1744 :                             hHrtf->pOut_to_bin_im[i][j] = CRendBin_FOA_HRIR_coeff_im_16kHz[i][j];
     681             :                         }
     682             :                     }
     683             : 
     684         654 :                     for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     685             :                     {
     686         436 :                         hHrtf->num_iterations_diffuse[j] = CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[j];
     687         436 :                         hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[j];
     688         436 :                         hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz[j];
     689         436 :                         hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz[j];
     690             :                     }
     691             :                 }
     692             :                 else
     693             :                 {
     694           0 :                     return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" );
     695             :                 }
     696             :             }
     697             :             else
     698             :             {
     699           0 :                 return IVAS_ERROR( IVAS_ERR_INVALID_INPUT_FORMAT, "Encountered unsupported input config in Crend" );
     700             :             }
     701             :         }
     702             :         else
     703             :         {
     704           0 :             return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported renderer type in Crend" );
     705             :         }
     706             :     }
     707             :     else
     708             :     {
     709        2288 :         if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
     710             :         {
     711        2288 :             hHrtf->max_num_ir -= 1; /* subtract LFE */
     712        2288 :             hHrtf->gain_lfe = GAIN_LFE;
     713             :         }
     714             : 
     715        2288 :         if ( ext_rend_flag == 1 )
     716             :         {
     717           0 :             if ( hHrtfCrend == NULL )
     718             :             {
     719           0 :                 return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " );
     720             :             }
     721           0 :             hHrtf->latency_s = hHrtfCrend->latency_s;
     722           0 :             hHrtf->max_num_iterations = hHrtfCrend->max_num_iterations;
     723           0 :             hHrtf->index_frequency_max_diffuse = hHrtfCrend->index_frequency_max_diffuse;
     724             : 
     725           0 :             for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     726             :             {
     727           0 :                 hHrtf->num_iterations_diffuse[j] = hHrtfCrend->num_iterations_diffuse[j];
     728           0 :                 hHrtf->pIndex_frequency_max_diffuse[j] = hHrtfCrend->pIndex_frequency_max_diffuse[j];
     729           0 :                 hHrtf->pOut_to_bin_diffuse_re[j] = hHrtfCrend->pOut_to_bin_diffuse_re[j];
     730           0 :                 hHrtf->pOut_to_bin_diffuse_im[j] = hHrtfCrend->pOut_to_bin_diffuse_im[j];
     731             :             }
     732             :         }
     733             : 
     734        2288 :         if ( inConfig == IVAS_AUDIO_CONFIG_7_1 && ext_rend_flag == 0 )
     735             :         {
     736             :             /* hack to enable pointers swapping - needed when indexes of 'channelIndex_CICPx[]' are not in increasing order */
     737         189 :             for ( i = 5; i < hHrtf->max_num_ir; i++ )
     738             :             {
     739         126 :                 tmp = channelIndex_CICP12[i];
     740         126 :                 tmp2 = channelIndex_CICP14[i];
     741             : 
     742         378 :                 for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     743             :                 {
     744         252 :                     hHrtf->inv_diffuse_weight[j][tmp2] = hHrtfCrend->inv_diffuse_weight[j][tmp];
     745         252 :                     hHrtf->num_iterations[tmp2][j] = hHrtfCrend->num_iterations[tmp][j];
     746         252 :                     hHrtf->pIndex_frequency_max[tmp2][j] = hHrtfCrend->pIndex_frequency_max[tmp][j];
     747         252 :                     hHrtf->pOut_to_bin_re[tmp2][j] = hHrtfCrend->pOut_to_bin_re[tmp][j];
     748         252 :                     hHrtf->pOut_to_bin_im[tmp2][j] = hHrtfCrend->pOut_to_bin_im[tmp][j];
     749             :                 }
     750             :             }
     751             :         }
     752             : 
     753       26384 :         for ( i = 0; i < hHrtf->max_num_ir; i++ )
     754             :         {
     755       24096 :             if ( inConfig == IVAS_AUDIO_CONFIG_5_1 )
     756             :             {
     757         360 :                 tmp = channelIndex_CICP6[i];
     758             :             }
     759       23736 :             else if ( inConfig == IVAS_AUDIO_CONFIG_7_1 )
     760             :             {
     761         441 :                 if ( ext_rend_flag == 0 )
     762             :                 {
     763         441 :                     tmp = channelIndex_CICP14[i];
     764             :                 }
     765             :                 else
     766             :                 {
     767           0 :                     tmp = channelIndex_CICP12[i];
     768             :                 }
     769             :             }
     770       23295 :             else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_2 )
     771             :             {
     772         441 :                 tmp = channelIndex_CICP14[i];
     773             :             }
     774       22854 :             else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_4 )
     775             :             {
     776         612 :                 tmp = channelIndex_CICP16[i];
     777             :             }
     778       22242 :             else if ( inConfig == IVAS_AUDIO_CONFIG_7_1_4 )
     779             :             {
     780       22242 :                 tmp = channelIndex_CICP19[i];
     781             :             }
     782           0 :             else if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS )
     783             :             {
     784           0 :                 tmp = i;
     785             :             }
     786             :             else
     787             :             {
     788           0 :                 return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" );
     789             :             }
     790             : 
     791       72288 :             for ( j = 0; j < BINAURAL_CHANNELS; j++ )
     792             :             {
     793       48192 :                 hHrtf->inv_diffuse_weight[j][i] = hHrtfCrend->inv_diffuse_weight[j][tmp];
     794       48192 :                 hHrtf->num_iterations[i][j] = hHrtfCrend->num_iterations[tmp][j];
     795             : 
     796       48192 :                 if ( ext_rend_flag == 0 )
     797             :                 {
     798             :                     /* in case of HRTF handle reuse, swap the pointers for correct deallocation at the exit */
     799             : #define WMC_TOOL_SKIP
     800       48192 :                     swap( hHrtf->pIndex_frequency_max[i][j], hHrtf->pIndex_frequency_max[tmp][j], const uint16_t * );
     801             :                     MOVE( 3 );
     802       48192 :                     swap( hHrtf->pOut_to_bin_re[i][j], hHrtf->pOut_to_bin_re[tmp][j], const float * );
     803             :                     MOVE( 3 );
     804       48192 :                     swap( hHrtf->pOut_to_bin_im[i][j], hHrtf->pOut_to_bin_im[tmp][j], const float * );
     805             :                     MOVE( 3 );
     806             : #undef WMC_TOOL_SKIP
     807             :                 }
     808             :                 else
     809             :                 {
     810           0 :                     hHrtf->pIndex_frequency_max[i][j] = hHrtfCrend->pIndex_frequency_max[tmp][j];
     811           0 :                     hHrtf->pOut_to_bin_re[i][j] = hHrtfCrend->pOut_to_bin_re[tmp][j];
     812           0 :                     hHrtf->pOut_to_bin_im[i][j] = hHrtfCrend->pOut_to_bin_im[tmp][j];
     813             :                 }
     814             :             }
     815             :         }
     816             :     }
     817             : 
     818       19343 :     hHrtf->same_inv_diffuse_weight = 1;
     819      197630 :     for ( i = 0; i < hHrtf->max_num_ir; i++ )
     820             :     {
     821      178287 :         if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
     822             :         {
     823      108706 :             if ( hHrtf->inv_diffuse_weight[0][i] != hHrtf->inv_diffuse_weight[1][i] )
     824             :             {
     825           0 :                 hHrtf->same_inv_diffuse_weight = 0;
     826           0 :                 break;
     827             :             }
     828             :         }
     829             :     }
     830             : 
     831       19343 :     pCrend->hHrtfCrend = hHrtf;
     832             : 
     833       19343 :     return IVAS_ERR_OK;
     834             : }
     835             : 
     836             : 
     837             : /*-------------------------------------------------------------------------
     838             :  * ivas_shoebox_data_init()
     839             :  *
     840             :  * Initialize shoebox_data_t handle
     841             :  *------------------------------------------------------------------------*/
     842             : 
     843        1304 : static ivas_error ivas_shoebox_data_init(
     844             :     shoebox_data_t *hShoeboxData /* i/o: shoebox_data_t handle     */
     845             : )
     846             : {
     847             :     int16_t i;
     848             : 
     849        1304 :     if ( hShoeboxData == NULL )
     850             :     {
     851           0 :         return IVAS_ERR_WRONG_PARAMS;
     852             :     }
     853             : 
     854      196904 :     for ( i = 0; i < 150; i++ )
     855             :     {
     856      195600 :         hShoeboxData->data[i] = 0.0f;
     857             :     }
     858        2608 :     for ( i = 0; i < 1; i++ )
     859             :     {
     860        1304 :         hShoeboxData->size[i] = 0;
     861             :     }
     862             : 
     863        1304 :     return IVAS_ERR_OK;
     864             : }
     865             : 
     866             : 
     867             : /*-------------------------------------------------------------------------
     868             :  * ivas_shoebox_output_init()
     869             :  *
     870             :  * Initialize shoebox_output_t handle
     871             :  *------------------------------------------------------------------------*/
     872             : 
     873         326 : static ivas_error ivas_shoebox_output_init(
     874             :     shoebox_output_t *hShoeboxOutput /* i/o: shoebox_output_t handle     */
     875             : )
     876             : {
     877             :     ivas_error error;
     878             : 
     879         326 :     if ( hShoeboxOutput == NULL )
     880             :     {
     881           0 :         return IVAS_ERR_WRONG_PARAMS;
     882             :     }
     883             : 
     884         326 :     hShoeboxOutput->n_sources = 0;
     885         326 :     hShoeboxOutput->n_ref = 0;
     886             : 
     887         326 :     if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->times ) ) != IVAS_ERR_OK )
     888             :     {
     889           0 :         return error;
     890             :     }
     891             : 
     892         326 :     if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->gains ) ) != IVAS_ERR_OK )
     893             :     {
     894           0 :         return error;
     895             :     }
     896             : 
     897         326 :     if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->az_angle ) ) != IVAS_ERR_OK )
     898             :     {
     899           0 :         return error;
     900             :     }
     901             : 
     902         326 :     if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->el_angle ) ) != IVAS_ERR_OK )
     903             :     {
     904           0 :         return error;
     905             :     }
     906             : 
     907         326 :     return IVAS_ERR_OK;
     908             : }
     909             : 
     910             : 
     911             : /*-------------------------------------------------------------------------
     912             :  * ivas_shoebox_config_init()
     913             :  *
     914             :  * Initialize shoebox_config_t handle
     915             :  *------------------------------------------------------------------------*/
     916             : 
     917         326 : static ivas_error ivas_shoebox_config_init_params(
     918             :     shoebox_config_t *hShoeboxConfig /* i/o: shoebox_config_t handle     */
     919             : )
     920             : {
     921             :     int16_t i;
     922             : 
     923         326 :     if ( hShoeboxConfig == NULL )
     924             :     {
     925           0 :         return IVAS_ERR_WRONG_PARAMS;
     926             :     }
     927             : 
     928         326 :     hShoeboxConfig->room_L = 0.0f;
     929         326 :     hShoeboxConfig->room_W = 0.0f;
     930         326 :     hShoeboxConfig->room_H = 0.0f;
     931             : 
     932        2282 :     for ( i = 0; i < IVAS_ROOM_ABS_COEFF; i++ )
     933             :     {
     934        1956 :         hShoeboxConfig->abs_coeff[i] = 0.0f;
     935             :     }
     936        1304 :     for ( i = 0; i < 3; i++ )
     937             :     {
     938         978 :         hShoeboxConfig->list_orig[i] = 0.0f;
     939             :     }
     940             : 
     941         326 :     return IVAS_ERR_OK;
     942             : }
     943             : 
     944             : 
     945             : /*-------------------------------------------------------------------------
     946             :  * ivas_shoebox_obj_init()
     947             :  *
     948             :  * Initialize shoebox_obj_t handle
     949             :  *------------------------------------------------------------------------*/
     950             : 
     951         326 : static ivas_error ivas_shoebox_obj_init(
     952             :     shoebox_obj_t *hShoeboxObj /* i/o: shoebox_obj_t handle     */
     953             : )
     954             : {
     955             :     int16_t i;
     956             :     ivas_error error;
     957             : 
     958         326 :     if ( hShoeboxObj == NULL )
     959             :     {
     960           0 :         return IVAS_ERR_WRONG_PARAMS;
     961             :     }
     962             : 
     963         326 :     hShoeboxObj->isCartesian = 0;
     964         326 :     hShoeboxObj->isRelative = 0;
     965         326 :     hShoeboxObj->isZHeight = 0;
     966         326 :     hShoeboxObj->isRadians = 0;
     967         326 :     hShoeboxObj->MAX_SOURCES = 0;
     968         326 :     hShoeboxObj->max_bands = 0;
     969         326 :     hShoeboxObj->REF_ORDER = 0;
     970             : 
     971       24776 :     for ( i = 0; i < 75; i++ )
     972             :     {
     973       24450 :         hShoeboxObj->src_pos[i] = 0.0f;
     974             :     }
     975        8476 :     for ( i = 0; i < 25; i++ )
     976             :     {
     977        8150 :         hShoeboxObj->src_dist[i] = 0.0f;
     978             :     }
     979        1304 :     for ( i = 0; i < 3; i++ )
     980             :     {
     981         978 :         hShoeboxObj->list_pos[i] = 0.0f;
     982             :     }
     983             : 
     984         326 :     hShoeboxObj->nSrc = 0;
     985         326 :     hShoeboxObj->radius = 0.0f;
     986         326 :     hShoeboxObj->min_wall_dist = 0.0f;
     987         326 :     hShoeboxObj->soundspeed = 0.0f;
     988         326 :     hShoeboxObj->air_coeff = 0.0f;
     989             : 
     990         326 :     if ( ( error = ivas_shoebox_config_init_params( &hShoeboxObj->cal ) ) != IVAS_ERR_OK )
     991             :     {
     992           0 :         return error;
     993             :     }
     994             : 
     995         326 :     return IVAS_ERR_OK;
     996             : }
     997             : 
     998             : 
     999             : /*-------------------------------------------------------------------------
    1000             :  * ivas_er_init_handle()
    1001             :  *
    1002             :  * Initialize early reflections handle
    1003             :  *------------------------------------------------------------------------*/
    1004             : 
    1005         326 : static ivas_error ivas_er_init_handle(
    1006             :     er_struct_t *reflections /* i/o: early reflections handle     */
    1007             : )
    1008             : {
    1009             :     int16_t i;
    1010             :     ivas_error error;
    1011             : 
    1012         326 :     if ( reflections == NULL )
    1013             :     {
    1014           0 :         return IVAS_ERR_WRONG_PARAMS;
    1015             :     }
    1016             : 
    1017         326 :     reflections->audio_config = IVAS_AUDIO_CONFIG_INVALID;
    1018         326 :     reflections->use_er = 0;
    1019         326 :     reflections->is_ready = 0;
    1020         326 :     reflections->circ_len = 0;
    1021         326 :     reflections->circ_insert = 0;
    1022         326 :     reflections->n_total_reflections = 0;
    1023         326 :     reflections->is_cartesian = 0;
    1024         326 :     reflections->is_relative = 0;
    1025         326 :     reflections->max_frame_size = 0;
    1026         326 :     reflections->output_Fs = 0.0f;
    1027             : 
    1028       24776 :     for ( i = 0; i < 75; i++ )
    1029             :     {
    1030       24450 :         reflections->source_positions[i] = 0.0f;
    1031             :     }
    1032        1304 :     for ( i = 0; i < 3; i++ )
    1033             :     {
    1034         978 :         reflections->user_origin[i] = 0.0f;
    1035         978 :         if ( i == 2 )
    1036             :         {
    1037         326 :             reflections->user_origin[i] = ER_LIST_HEIGHT;
    1038             :         }
    1039             :     }
    1040             : 
    1041         326 :     reflections->circ_buffers = NULL;
    1042         326 :     reflections->closest_ch_idx = NULL;
    1043             : 
    1044         326 :     if ( ( error = ivas_shoebox_output_init( &reflections->shoebox_data ) ) != IVAS_ERR_OK )
    1045             :     {
    1046           0 :         return error;
    1047             :     }
    1048             : 
    1049         326 :     if ( ( error = ivas_shoebox_obj_init( &reflections->shoebox_lib ) ) != IVAS_ERR_OK )
    1050             :     {
    1051           0 :         return error;
    1052             :     }
    1053             : 
    1054         326 :     return IVAS_ERR_OK;
    1055             : }
    1056             : 
    1057             : 
    1058             : /*-------------------------------------------------------------------------
    1059             :  * ivas_rend_initCrendWrapper()
    1060             :  *
    1061             :  * Allocate and initialize crend renderer handle
    1062             :  *------------------------------------------------------------------------*/
    1063             : 
    1064       19343 : ivas_error ivas_rend_initCrendWrapper(
    1065             :     CREND_WRAPPER_HANDLE *pCrend,
    1066             :     const int16_t num_poses )
    1067             : {
    1068             :     int16_t i;
    1069             :     CREND_HANDLE hCrend;
    1070             :     int16_t pos_idx;
    1071             : 
    1072       19343 :     if ( pCrend == NULL )
    1073             :     {
    1074           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" );
    1075             :     }
    1076             : 
    1077       19343 :     if ( ( *pCrend = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL )
    1078             :     {
    1079           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" );
    1080             :     }
    1081             : 
    1082       19343 :     ( *pCrend )->binaural_latency_ns = 0;
    1083       19343 :     ( *pCrend )->hHrtfCrend = NULL;
    1084             : 
    1085      174087 :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1086             :     {
    1087      154744 :         ( *pCrend )->hCrend[pos_idx] = NULL;
    1088             :     }
    1089             : 
    1090       39726 :     for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    1091             :     {
    1092       20383 :         hCrend = NULL;
    1093       20383 :         if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL )
    1094             :         {
    1095           0 :             return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" );
    1096             :         }
    1097             : 
    1098       20383 :         hCrend->lfe_delay_line = NULL;
    1099             : 
    1100      346511 :         for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
    1101             :         {
    1102      326128 :             hCrend->freq_buffer_re[i] = NULL;
    1103      326128 :             hCrend->freq_buffer_im[i] = NULL;
    1104             :         }
    1105             : 
    1106       61149 :         for ( i = 0; i < BINAURAL_CHANNELS; i++ )
    1107             :         {
    1108       40766 :             hCrend->prev_out_buffer[i] = NULL;
    1109             :         }
    1110             : 
    1111       20383 :         hCrend->freq_buffer_re_diffuse[0] = NULL;
    1112       20383 :         hCrend->freq_buffer_re_diffuse[1] = NULL;
    1113       20383 :         hCrend->freq_buffer_im_diffuse[0] = NULL;
    1114       20383 :         hCrend->freq_buffer_im_diffuse[1] = NULL;
    1115       20383 :         hCrend->hReverb = NULL;
    1116       20383 :         hCrend->reflections = NULL;
    1117       20383 :         hCrend->delay_line_rw_index = 0;
    1118       20383 :         hCrend->diffuse_delay_line_rw_index = 0;
    1119       20383 :         hCrend->hTrack = NULL;
    1120       20383 :         hCrend->m_fYaw = 0;
    1121       20383 :         hCrend->m_fPitch = 0;
    1122       20383 :         hCrend->m_fRoll = 0;
    1123             : 
    1124       20383 :         ( *pCrend )->hCrend[pos_idx] = hCrend;
    1125             :     }
    1126             : 
    1127       19343 :     return IVAS_ERR_OK;
    1128             : }
    1129             : 
    1130             : 
    1131             : /*-------------------------------------------------------------------------
    1132             :  * ivas_rend_openMultiBinCrend()
    1133             :  *
    1134             :  * Allocate and initialize crend renderer handle
    1135             :  *------------------------------------------------------------------------*/
    1136             : 
    1137         170 : ivas_error ivas_rend_openMultiBinCrend(
    1138             :     CREND_WRAPPER_HANDLE *pCrend,
    1139             :     const AUDIO_CONFIG inConfig,
    1140             :     const AUDIO_CONFIG outConfig,
    1141             :     const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
    1142             :     const int32_t output_Fs )
    1143             : {
    1144         170 :     return ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, 0, pMultiBinPoseData->num_poses );
    1145             : }
    1146             : 
    1147             : 
    1148             : /*-------------------------------------------------------------------------
    1149             :  * ivas_rend_openCrend()
    1150             :  *
    1151             :  * Allocate and initialize crend renderer handle
    1152             :  *------------------------------------------------------------------------*/
    1153             : 
    1154       19343 : ivas_error ivas_rend_openCrend(
    1155             :     CREND_WRAPPER_HANDLE *pCrend,
    1156             :     const AUDIO_CONFIG inConfig,
    1157             :     const AUDIO_CONFIG outConfig,
    1158             :     RENDER_CONFIG_DATA *hRendCfg,
    1159             :     HRTFS_CREND_HANDLE hHrtfCrend,
    1160             :     HRTFS_STATISTICS_HANDLE hHrtfStatistics,
    1161             :     const int32_t output_Fs,
    1162             :     const int16_t ext_rend_flag,
    1163             :     const int16_t num_poses )
    1164             : {
    1165             :     int16_t i, subframe_length;
    1166             :     int32_t max_total_ir_len;
    1167             :     HRTFS_CREND_HANDLE hHrtf;
    1168             :     CREND_HANDLE hCrend;
    1169             :     ivas_error error;
    1170             :     int16_t pos_idx;
    1171             : 
    1172       19343 :     if ( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK )
    1173             :     {
    1174           0 :         return error;
    1175             :     }
    1176             : 
    1177       19343 :     subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES;
    1178             : 
    1179       19343 :     if ( ( *pCrend )->hHrtfCrend == NULL )
    1180             :     {
    1181       19343 :         if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hHrtfCrend, ext_rend_flag, output_Fs ) ) != IVAS_ERR_OK )
    1182             :         {
    1183           0 :             return error;
    1184             :         }
    1185             :     }
    1186             : 
    1187       39726 :     for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    1188             :     {
    1189       20383 :         hCrend = ( *pCrend )->hCrend[pos_idx];
    1190       20383 :         hHrtf = ( *pCrend )->hHrtfCrend;
    1191             : 
    1192       20383 :         if ( hHrtf != NULL )
    1193             :         {
    1194       20383 :             max_total_ir_len = hHrtf->max_num_iterations * subframe_length;
    1195             : 
    1196      212150 :             for ( i = 0; i < hHrtf->max_num_ir; i++ )
    1197             :             {
    1198      191767 :                 if ( ( hCrend->freq_buffer_re[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1199             :                 {
    1200           0 :                     return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1201             :                 }
    1202      191767 :                 set_zero_l( hCrend->freq_buffer_re[i], max_total_ir_len );
    1203             : 
    1204      191767 :                 if ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1205             :                 {
    1206           0 :                     return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1207             :                 }
    1208      191767 :                 set_zero_l( hCrend->freq_buffer_im[i], max_total_ir_len );
    1209             :             }
    1210             : 
    1211       61149 :             for ( i = 0; i < BINAURAL_CHANNELS; i++ )
    1212             :             {
    1213       40766 :                 if ( ( hCrend->prev_out_buffer[i] = (float *) malloc( sizeof( float ) * subframe_length ) ) == NULL )
    1214             :                 {
    1215           0 :                     return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1216             :                 }
    1217       40766 :                 set_zero_l( hCrend->prev_out_buffer[i], subframe_length );
    1218             :             }
    1219             : 
    1220       20383 :             max_total_ir_len = hHrtf->num_iterations_diffuse[0] * subframe_length;
    1221             : 
    1222       20383 :             if ( max_total_ir_len > 0 )
    1223             :             {
    1224       11222 :                 if ( ( hCrend->freq_buffer_re_diffuse[0] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1225             :                 {
    1226           0 :                     return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1227             :                 }
    1228       11222 :                 if ( hHrtf->same_inv_diffuse_weight == 0 )
    1229             :                 {
    1230           0 :                     if ( ( hCrend->freq_buffer_re_diffuse[1] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1231             :                     {
    1232           0 :                         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1233             :                     }
    1234             :                 }
    1235             :                 else
    1236             :                 {
    1237       11222 :                     hCrend->freq_buffer_re_diffuse[1] = NULL;
    1238             :                 }
    1239       11222 :                 set_zero_l( hCrend->freq_buffer_re_diffuse[0], max_total_ir_len );
    1240       11222 :                 if ( hCrend->freq_buffer_re_diffuse[1] != NULL )
    1241             :                 {
    1242           0 :                     set_zero_l( hCrend->freq_buffer_re_diffuse[1], max_total_ir_len );
    1243             :                 }
    1244             : 
    1245       11222 :                 if ( ( hCrend->freq_buffer_im_diffuse[0] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1246             :                 {
    1247           0 :                     return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1248             :                 }
    1249       11222 :                 if ( hHrtf->same_inv_diffuse_weight == 0 )
    1250             :                 {
    1251           0 :                     if ( ( hCrend->freq_buffer_im_diffuse[1] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1252             :                     {
    1253           0 :                         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1254             :                     }
    1255             :                 }
    1256             :                 else
    1257             :                 {
    1258       11222 :                     hCrend->freq_buffer_im_diffuse[1] = NULL;
    1259             :                 }
    1260       11222 :                 set_zero_l( hCrend->freq_buffer_im_diffuse[0], max_total_ir_len );
    1261       11222 :                 if ( hCrend->freq_buffer_im_diffuse[1] != NULL )
    1262             :                 {
    1263           0 :                     set_zero_l( hCrend->freq_buffer_im_diffuse[1], max_total_ir_len );
    1264             :                 }
    1265             :             }
    1266             :             else
    1267             :             {
    1268        9161 :                 hCrend->freq_buffer_re_diffuse[0] = NULL;
    1269        9161 :                 hCrend->freq_buffer_im_diffuse[0] = NULL;
    1270        9161 :                 hCrend->freq_buffer_re_diffuse[1] = NULL;
    1271        9161 :                 hCrend->freq_buffer_im_diffuse[1] = NULL;
    1272             :             }
    1273       20383 :             max_total_ir_len = (int32_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;
    1274       20383 :             if ( max_total_ir_len > 0 )
    1275             :             {
    1276       20383 :                 if ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL )
    1277             :                 {
    1278           0 :                     return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
    1279             :                 }
    1280       20383 :                 set_zero_l( hCrend->lfe_delay_line, max_total_ir_len );
    1281             :             }
    1282             :             else
    1283             :             {
    1284           0 :                 hCrend->lfe_delay_line = NULL;
    1285             :             }
    1286             : 
    1287       20383 :             if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
    1288             :             {
    1289        4130 :                 if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK )
    1290             :                 {
    1291           0 :                     return error;
    1292             :                 }
    1293             : 
    1294        4130 :                 if ( hRendCfg->roomAcoustics.use_er == 1 )
    1295             :                 {
    1296             : 
    1297             :                     /* Allocate memory for reflections */
    1298         326 :                     hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) );
    1299         326 :                     if ( !hCrend->reflections )
    1300             :                     {
    1301           0 :                         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" );
    1302             :                     }
    1303         326 :                     if ( ( error = ivas_er_init_handle( hCrend->reflections ) ) != IVAS_ERR_OK )
    1304             :                     {
    1305           0 :                         return error;
    1306             :                     }
    1307             : 
    1308         326 :                     hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er;
    1309         326 :                     hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity;
    1310             : 
    1311             :                     /* Set sample rate and frame size */
    1312         326 :                     hCrend->reflections->output_Fs = (float) output_Fs;
    1313         326 :                     hCrend->reflections->max_frame_size = (int16_t) ( output_Fs / FRAMES_PER_SEC );
    1314             : 
    1315             :                     /* Init Shoebox */
    1316         326 :                     ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg );
    1317             : 
    1318             :                     /* Init and compute Reflections */
    1319         326 :                     if ( ( error = ivas_er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK )
    1320             :                     {
    1321           0 :                         return error;
    1322             :                     }
    1323             :                 }
    1324             :                 else
    1325             :                 {
    1326        3804 :                     hCrend->reflections = NULL;
    1327             :                 }
    1328             :             }
    1329             :             else
    1330             :             {
    1331       16253 :                 hCrend->hReverb = NULL;
    1332             :             }
    1333             : 
    1334       20383 :             ( *pCrend )->binaural_latency_ns = (int32_t) ( ( *pCrend )->hHrtfCrend->latency_s * 1000000000.f );
    1335             :         }
    1336             : 
    1337       20383 :         ( *pCrend )->hCrend[pos_idx] = hCrend;
    1338             :     }
    1339             : 
    1340       19343 :     return IVAS_ERR_OK;
    1341             : }
    1342             : 
    1343             : 
    1344             : /*-------------------------------------------------------------------------
    1345             :  * ivas_rend_closeCrend()
    1346             :  *
    1347             :  * Deallocate Crend renderer handle
    1348             :  *------------------------------------------------------------------------*/
    1349             : 
    1350     2394680 : void ivas_rend_closeCrend(
    1351             :     CREND_WRAPPER_HANDLE *pCrend )
    1352             : {
    1353             :     int16_t i;
    1354             :     int16_t pos_idx;
    1355             :     CREND_HANDLE hCrend;
    1356             : 
    1357     2394680 :     if ( pCrend == NULL || *pCrend == NULL )
    1358             :     {
    1359     2375337 :         return;
    1360             :     }
    1361             : 
    1362       19343 :     if ( ( *pCrend )->hHrtfCrend != NULL && ( *pCrend )->hHrtfCrend->init_from_rom )
    1363             :     {
    1364       17055 :         ivas_hrtf_close( &( *pCrend )->hHrtfCrend );
    1365             :     }
    1366             : 
    1367      174087 :     for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ )
    1368             :     {
    1369      154744 :         hCrend = ( *pCrend )->hCrend[pos_idx];
    1370      154744 :         if ( hCrend != NULL )
    1371             :         {
    1372      346511 :             for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
    1373             :             {
    1374      326128 :                 if ( hCrend->freq_buffer_re[i] != NULL )
    1375             :                 {
    1376      191767 :                     free( hCrend->freq_buffer_re[i] );
    1377      191767 :                     hCrend->freq_buffer_re[i] = NULL;
    1378             :                 }
    1379      326128 :                 if ( hCrend->freq_buffer_im[i] != NULL )
    1380             :                 {
    1381      191767 :                     free( hCrend->freq_buffer_im[i] );
    1382      191767 :                     hCrend->freq_buffer_im[i] = NULL;
    1383             :                 }
    1384             :             }
    1385             : 
    1386       61149 :             for ( i = 0; i < BINAURAL_CHANNELS; i++ )
    1387             :             {
    1388       40766 :                 if ( hCrend->prev_out_buffer[i] != NULL )
    1389             :                 {
    1390       40766 :                     free( hCrend->prev_out_buffer[i] );
    1391       40766 :                     hCrend->prev_out_buffer[i] = NULL;
    1392             :                 }
    1393             :             }
    1394             : 
    1395       20383 :             if ( hCrend->lfe_delay_line != NULL )
    1396             :             {
    1397       20383 :                 free( hCrend->lfe_delay_line );
    1398       20383 :                 hCrend->lfe_delay_line = NULL;
    1399             :             }
    1400       20383 :             if ( hCrend->freq_buffer_re_diffuse[0] != NULL )
    1401             :             {
    1402       11222 :                 free( hCrend->freq_buffer_re_diffuse[0] );
    1403       11222 :                 hCrend->freq_buffer_re_diffuse[0] = NULL;
    1404             :             }
    1405             : 
    1406       20383 :             if ( hCrend->freq_buffer_im_diffuse[0] != NULL )
    1407             :             {
    1408       11222 :                 free( hCrend->freq_buffer_im_diffuse[0] );
    1409       11222 :                 hCrend->freq_buffer_im_diffuse[0] = NULL;
    1410             :             }
    1411             : 
    1412       20383 :             if ( hCrend->freq_buffer_re_diffuse[1] != NULL )
    1413             :             {
    1414           0 :                 free( hCrend->freq_buffer_re_diffuse[1] );
    1415           0 :                 hCrend->freq_buffer_re_diffuse[1] = NULL;
    1416             :             }
    1417             : 
    1418       20383 :             if ( hCrend->freq_buffer_im_diffuse[1] != NULL )
    1419             :             {
    1420           0 :                 free( hCrend->freq_buffer_im_diffuse[1] );
    1421           0 :                 hCrend->freq_buffer_im_diffuse[1] = NULL;
    1422             :             }
    1423             : 
    1424       20383 :             if ( hCrend->hTrack != NULL )
    1425             :             {
    1426           0 :                 free( hCrend->hTrack );
    1427           0 :                 hCrend->hTrack = NULL;
    1428             :             }
    1429             : 
    1430       20383 :             ivas_reverb_close( &hCrend->hReverb );
    1431             : 
    1432       20383 :             if ( hCrend->reflections != NULL )
    1433             :             {
    1434         326 :                 if ( hCrend->reflections->closest_ch_idx != NULL )
    1435             :                 {
    1436         326 :                     free( hCrend->reflections->closest_ch_idx );
    1437         326 :                     hCrend->reflections->closest_ch_idx = NULL;
    1438             :                 }
    1439             : 
    1440         326 :                 if ( hCrend->reflections->circ_buffers != NULL )
    1441             :                 {
    1442         326 :                     free( hCrend->reflections->circ_buffers );
    1443         326 :                     hCrend->reflections->circ_buffers = NULL;
    1444             :                 }
    1445             : 
    1446         326 :                 free( hCrend->reflections );
    1447         326 :                 hCrend->reflections = NULL;
    1448             :             }
    1449             : 
    1450       20383 :             free( hCrend );
    1451       20383 :             hCrend = NULL;
    1452       20383 :             ( *pCrend )->hCrend[pos_idx] = hCrend;
    1453             :         }
    1454             :     }
    1455             : 
    1456       19343 :     free( *pCrend );
    1457       19343 :     *pCrend = NULL;
    1458             : 
    1459       19343 :     return;
    1460             : }
    1461             : 
    1462             : 
    1463             : /*-------------------------------------------------------------------------
    1464             :  * ivas_rend_closeCldfbRend()
    1465             :  *
    1466             :  * Close CLDFB based fastconv binaural renderer memories
    1467             :  *------------------------------------------------------------------------*/
    1468             : 
    1469           8 : void ivas_rend_closeCldfbRend(
    1470             :     CLDFB_REND_WRAPPER *pCldfbRend )
    1471             : {
    1472           8 :     if ( pCldfbRend->hCldfbRend->hInputSetup != NULL )
    1473             :     {
    1474           8 :         free( pCldfbRend->hCldfbRend->hInputSetup );
    1475           8 :         pCldfbRend->hCldfbRend->hInputSetup = NULL;
    1476             :     }
    1477             : 
    1478           8 :     ivas_binRenderer_close( &pCldfbRend->hCldfbRend );
    1479             : 
    1480           8 :     ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv );
    1481             : 
    1482           8 :     return;
    1483             : }
    1484             : 
    1485             : 
    1486             : /*-----------------------------------------------------------------------------------------*
    1487             :  * Function ivas_rend_crendConvolver()
    1488             :  *
    1489             :  * Convolver block
    1490             :  *-----------------------------------------------------------------------------------------*/
    1491             : 
    1492    75219445 : static ivas_error ivas_rend_crendConvolver(
    1493             :     const CREND_WRAPPER *pCrend,
    1494             :     AUDIO_CONFIG inConfig,
    1495             :     AUDIO_CONFIG outConfig,
    1496             :     float *pcm_in[],
    1497             :     float *pcm_out[],
    1498             :     const int32_t output_Fs,
    1499             :     const int16_t i_ts,
    1500             :     const int16_t pos_idx )
    1501             : {
    1502             :     int16_t i, j, k, m;
    1503             :     int16_t subframe_length, idx_in;
    1504             :     int16_t lfe_idx_in;
    1505             :     int32_t offset, offset_in, offset_diffuse;
    1506             :     int16_t nchan_in, nchan_out;
    1507             :     const float *pIn;
    1508             :     const float *pFreq_filt_re, *pFreq_filt_im;
    1509    75219445 :     float *pFreq_buf_re = NULL, *pFreq_buf_im = NULL;
    1510    75219445 :     float *pFreq_buf2_re = NULL, *pFreq_buf2_im = NULL;
    1511             :     float pOut[2 /*Re,Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
    1512             :     float tmp_out_re[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp_out_im[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
    1513             :     CREND_HANDLE hCrend;
    1514             :     ivas_error error;
    1515             : 
    1516    75219445 :     hCrend = pCrend->hCrend[pos_idx];
    1517             : 
    1518    75219445 :     if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK )
    1519             :     {
    1520           0 :         return error;
    1521             :     }
    1522             : 
    1523    75219445 :     if ( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ) != IVAS_ERR_OK )
    1524             :     {
    1525           0 :         return error;
    1526             :     }
    1527             : 
    1528    75219445 :     subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES;
    1529             : 
    1530    75219445 :     lfe_idx_in = -1;
    1531    75219445 :     if ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
    1532             :     {
    1533    48695725 :         if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM )
    1534             :         {
    1535    48695725 :             lfe_idx_in = LFE_CHANNEL;
    1536             :         }
    1537             :         else
    1538             :         {
    1539           0 :             assert( 0 && "Custom LS not supported in CRend" );
    1540             :         }
    1541             :     }
    1542             : 
    1543    75219445 :     offset = hCrend->delay_line_rw_index * subframe_length;                 /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */
    1544    75219445 :     offset_diffuse = hCrend->diffuse_delay_line_rw_index * subframe_length; /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */
    1545             : 
    1546    75219445 :     if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    1547             :     {
    1548    38822868 :         set_zero( &hCrend->freq_buffer_re_diffuse[0][offset_diffuse], subframe_length );
    1549    38822868 :         set_zero( &hCrend->freq_buffer_im_diffuse[0][offset_diffuse], subframe_length );
    1550    38822868 :         if ( pCrend->hHrtfCrend->same_inv_diffuse_weight == 0 )
    1551             :         {
    1552           0 :             set_zero( &hCrend->freq_buffer_re_diffuse[1][offset_diffuse], subframe_length );
    1553           0 :             set_zero( &hCrend->freq_buffer_im_diffuse[1][offset_diffuse], subframe_length );
    1554             :         }
    1555             :     }
    1556             : 
    1557    75219445 :     if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    1558             :     {
    1559    38822868 :         if ( pCrend->hHrtfCrend->same_inv_diffuse_weight )
    1560             :         {
    1561    38822868 :             pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse];
    1562    38822868 :             pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse];
    1563             :         }
    1564             :         else
    1565             :         {
    1566           0 :             pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse];
    1567           0 :             pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse];
    1568           0 :             pFreq_buf2_re = &hCrend->freq_buffer_re_diffuse[1][offset_diffuse];
    1569           0 :             pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse[1][offset_diffuse];
    1570             :         }
    1571             :     }
    1572             : 
    1573    75219445 :     i = 0;
    1574   880917157 :     for ( idx_in = 0; idx_in < nchan_in; idx_in++ )
    1575             :     {
    1576   805697712 :         pIn = &pcm_in[idx_in][i_ts * subframe_length];
    1577   805697712 :         if ( idx_in != lfe_idx_in )
    1578             :         {
    1579   757001987 :             if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    1580             :             {
    1581   415026528 :                 if ( pCrend->hHrtfCrend->same_inv_diffuse_weight )
    1582             :                 {
    1583   415026528 :                     pFreq_filt_re = &hCrend->freq_buffer_re[i][offset];
    1584   415026528 :                     pFreq_filt_im = &hCrend->freq_buffer_im[i][offset];
    1585             : 
    1586 38337807809 :                     for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
    1587             :                     {
    1588 37922781281 :                         pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i];
    1589 37922781281 :                         pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i];
    1590             :                     }
    1591             :                 }
    1592             :                 else
    1593             :                 {
    1594           0 :                     pFreq_filt_re = &hCrend->freq_buffer_re[i][offset];
    1595           0 :                     pFreq_filt_im = &hCrend->freq_buffer_im[i][offset];
    1596             : 
    1597           0 :                     for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
    1598             :                     {
    1599           0 :                         pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i];
    1600           0 :                         pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i];
    1601           0 :                         pFreq_buf2_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[1][i];
    1602           0 :                         pFreq_buf2_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[1][i];
    1603             :                     }
    1604             :                 }
    1605             :             }
    1606             : 
    1607   757001987 :             ivas_mdft( pIn, &hCrend->freq_buffer_re[i][offset], &hCrend->freq_buffer_im[i][offset], subframe_length, subframe_length );
    1608   757001987 :             i++;
    1609             :         }
    1610             :     }
    1611             : 
    1612   225658335 :     for ( j = 0; j < nchan_out; j++ )
    1613             :     {
    1614   150438890 :         set_zero( tmp_out_re, subframe_length );
    1615   150438890 :         set_zero( tmp_out_im, subframe_length );
    1616             : 
    1617   150438890 :         i = 0;
    1618  1761834314 :         for ( idx_in = 0; idx_in < nchan_in; idx_in++ )
    1619             :         {
    1620  1611395424 :             if ( idx_in != lfe_idx_in )
    1621             :             {
    1622  1514003974 :                 offset = 0;
    1623 20709115074 :                 for ( m = 0; m < pCrend->hHrtfCrend->num_iterations[i][j]; m++ )
    1624             :                 {
    1625 19195111100 :                     offset_in = ( hCrend->delay_line_rw_index + pCrend->hHrtfCrend->max_num_iterations - pCrend->hHrtfCrend->num_iterations[i][j] + m + 1 );
    1626 19195111100 :                     offset_in = offset_in % ( pCrend->hHrtfCrend->max_num_iterations );
    1627 19195111100 :                     offset_in = offset_in * subframe_length;
    1628 19195111100 :                     pFreq_buf_re = &hCrend->freq_buffer_re[i][offset_in];
    1629 19195111100 :                     pFreq_buf_im = &hCrend->freq_buffer_im[i][offset_in];
    1630 19195111100 :                     pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_re[i][j][offset];
    1631 19195111100 :                     pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_im[i][j][offset];
    1632             : 
    1633 >22258*10^8 :                     for ( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max[i][j][m]; k++ )
    1634             :                     {
    1635 >22066*10^8 :                         tmp_out_re[k] += pFreq_buf_re[k] * pFreq_filt_re[k] - pFreq_buf_im[k] * pFreq_filt_im[k];
    1636 >22066*10^8 :                         tmp_out_im[k] += pFreq_buf_re[k] * pFreq_filt_im[k] + pFreq_buf_im[k] * pFreq_filt_re[k];
    1637             :                     }
    1638 19195111100 :                     offset = offset + k;
    1639             :                 }
    1640  1514003974 :                 i++;
    1641             :             }
    1642             :         }
    1643             : 
    1644   150438890 :         offset = 0;
    1645  3256268330 :         for ( m = 0; m < pCrend->hHrtfCrend->num_iterations_diffuse[j]; m++ )
    1646             :         {
    1647  3105829440 :             offset_diffuse = ( hCrend->diffuse_delay_line_rw_index + m + 1 );
    1648  3105829440 :             offset_diffuse = offset_diffuse % pCrend->hHrtfCrend->num_iterations_diffuse[0];
    1649  3105829440 :             offset_diffuse = offset_diffuse * subframe_length;
    1650  3105829440 :             if ( pCrend->hHrtfCrend->same_inv_diffuse_weight )
    1651             :             {
    1652  3105829440 :                 pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse];
    1653  3105829440 :                 pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse];
    1654             :             }
    1655             :             else
    1656             :             {
    1657           0 :                 pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[j][offset_diffuse];
    1658           0 :                 pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[j][offset_diffuse];
    1659             :             }
    1660  3105829440 :             pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re[j][offset];
    1661  3105829440 :             pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im[j][offset];
    1662             : 
    1663 >21718*10^7 :             for ( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max_diffuse[j][m]; k++ )
    1664             :             {
    1665 >21407*10^7 :                 tmp_out_re[k] += pFreq_buf_re[k] * pFreq_filt_re[k] - pFreq_buf_im[k] * pFreq_filt_im[k];
    1666 >21407*10^7 :                 tmp_out_im[k] += pFreq_buf_re[k] * pFreq_filt_im[k] + pFreq_buf_im[k] * pFreq_filt_re[k];
    1667             :             }
    1668  3105829440 :             offset = offset + k;
    1669             :         }
    1670             : 
    1671   150438890 :         ivas_imdft( tmp_out_re, tmp_out_im, pOut, subframe_length );
    1672             : 
    1673   150438890 :         pFreq_buf_re = &pcm_out[j][i_ts * subframe_length];
    1674 25733646250 :         for ( k = 0; k < subframe_length; k++ )
    1675             :         {
    1676 25583207360 :             pFreq_buf_re[k] = pOut[k] + hCrend->prev_out_buffer[j][k];
    1677 25583207360 :             hCrend->prev_out_buffer[j][k] = pOut[k + subframe_length];
    1678             :         }
    1679             :     }
    1680             : 
    1681    75219445 :     hCrend->delay_line_rw_index++;
    1682    75219445 :     hCrend->delay_line_rw_index = hCrend->delay_line_rw_index % ( pCrend->hHrtfCrend->max_num_iterations );
    1683    75219445 :     if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    1684             :     {
    1685    38822868 :         hCrend->diffuse_delay_line_rw_index++;
    1686    38822868 :         hCrend->diffuse_delay_line_rw_index = hCrend->diffuse_delay_line_rw_index % ( pCrend->hHrtfCrend->num_iterations_diffuse[0] );
    1687             :     }
    1688             : 
    1689    75219445 :     return IVAS_ERR_OK;
    1690             : }
    1691             : 
    1692             : 
    1693             : /*-----------------------------------------------------------------------------------------*
    1694             :  * Function ivas_rend_crendProcessSubframe()
    1695             :  *
    1696             :  *
    1697             :  *-----------------------------------------------------------------------------------------*/
    1698             : 
    1699    48286546 : ivas_error ivas_rend_crendProcessSubframe(
    1700             :     const CREND_WRAPPER *pCrend,                                /* i/o: Crend wrapper handle                    */
    1701             :     const AUDIO_CONFIG inConfig,                                /* i  : input audio configuration               */
    1702             :     const AUDIO_CONFIG outConfig,                               /* i  : output audio configuration              */
    1703             :     const DECODER_CONFIG_HANDLE hDecoderConfig,                 /* i  : decoder config. structure               */
    1704             :     const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i  : combined orientation handle             */
    1705             :     const IVAS_OUTPUT_SETUP_HANDLE hIntSetup,                   /* i  : internal setup handle                   */
    1706             :     const EFAP_HANDLE hEFAPdata,                                /* i  : EFAP handle                             */
    1707             :     DECODER_TC_BUFFER_HANDLE hTcBuffer,                         /* i/o: TC handle                               */
    1708             :     float *input_f[],                                           /* i  : transport channels                      */
    1709             :     float *output[],                                            /* i/o: input/output audio channels             */
    1710             :     const int16_t n_samples_to_render,                          /* i  : output frame length per channel         */
    1711             :     const int32_t output_Fs,                                    /* i  : output sampling rate                    */
    1712             :     const int16_t pos_idx                                       /* i  : pose index                              */
    1713             : )
    1714             : {
    1715             :     int16_t subframe_idx, subframe_len;
    1716             :     int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render;
    1717             :     float *tc_local[MAX_OUTPUT_CHANNELS];
    1718             :     float *p_output[BINAURAL_CHANNELS];
    1719             :     float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
    1720             :     float *p_pcm_tmp[BINAURAL_CHANNELS];
    1721             :     IVAS_REND_AudioConfigType inConfigType;
    1722             :     ivas_error error;
    1723             :     int8_t combinedOrientationEnabled;
    1724             :     CREND_HANDLE hCrend;
    1725             : 
    1726    48286546 :     hCrend = pCrend->hCrend[pos_idx];
    1727             : 
    1728    48286546 :     combinedOrientationEnabled = 0;
    1729    48286546 :     if ( hCombinedOrientationData != NULL )
    1730             :     {
    1731      393724 :         if ( hCombinedOrientationData->enableCombinedOrientation[0] != 0 )
    1732             :         {
    1733      393724 :             combinedOrientationEnabled = 1;
    1734             :         }
    1735             :     }
    1736             : 
    1737    48286546 :     push_wmops( "ivas_rend_crendProcessSubframe" );
    1738    48286546 :     inConfigType = getAudioConfigType( inConfig );
    1739             : 
    1740    48286546 :     if ( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ) != IVAS_ERR_OK )
    1741             :     {
    1742           0 :         return error;
    1743             :     }
    1744             : 
    1745    48286546 :     if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK )
    1746             :     {
    1747           0 :         return error;
    1748             :     }
    1749             : 
    1750   564744333 :     for ( ch = 0; ch < nchan_in; ch++ )
    1751             :     {
    1752   516457787 :         tc_local[ch] = input_f[ch];
    1753             :     }
    1754             : 
    1755   144859638 :     for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
    1756             :     {
    1757    96573092 :         p_pcm_tmp[ch] = pcm_tmp[ch];
    1758    96573092 :         p_output[ch] = output[ch];
    1759             :     }
    1760             : 
    1761    48286546 :     if ( hTcBuffer != NULL )
    1762             :     {
    1763     2266507 :         slot_size = hTcBuffer->n_samples_granularity;
    1764             : 
    1765             :         /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
    1766     2266507 :         slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size );
    1767     2266507 :         first_sf = hTcBuffer->subframes_rendered;
    1768     2266507 :         last_sf = first_sf;
    1769             : 
    1770     6579983 :         while ( slots_to_render > 0 )
    1771             :         {
    1772     4313476 :             slots_to_render -= hTcBuffer->subframe_nbslots[last_sf];
    1773     4313476 :             last_sf++;
    1774             :         }
    1775     2266507 :         subframe_len = -1; /* will be set later */
    1776             :     }
    1777             :     else
    1778             :     {
    1779    46020039 :         subframe_len = (int16_t) ( output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) );
    1780    46020039 :         first_sf = 0;
    1781    46020039 :         last_sf = n_samples_to_render / subframe_len;
    1782             :     }
    1783             : 
    1784   123505991 :     for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    1785             :     {
    1786    75219445 :         if ( hTcBuffer != NULL )
    1787             :         {
    1788     4313476 :             subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity;
    1789             :         }
    1790             : 
    1791             :         /* Early Reflections */
    1792    75219445 :         if ( hCrend->reflections != NULL )
    1793             :         {
    1794     3804290 :             if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 )
    1795             :             {
    1796     2472374 :                 if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, 0, tc_local, inConfig ) ) != IVAS_ERR_OK )
    1797             :                 {
    1798           0 :                     return error;
    1799             :                 }
    1800             :             }
    1801             :         }
    1802             : 
    1803    75219445 :         if ( hDecoderConfig && combinedOrientationEnabled )
    1804             :         {
    1805             :             /* Rotation in SHD for:
    1806             :                 MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL
    1807             :                 SBA SPAR -> BINAURAL or BINAURAL_ROOM
    1808             :             */
    1809      806152 :             if ( inConfig == IVAS_AUDIO_CONFIG_FOA || inConfig == IVAS_AUDIO_CONFIG_HOA2 || inConfig == IVAS_AUDIO_CONFIG_HOA3 )
    1810             :             {
    1811      351720 :                 rotateFrame_shd( hCombinedOrientationData, tc_local, subframe_len, *hIntSetup, 0 );
    1812             :             }
    1813             :             /* Rotation in SD for MC -> BINAURAL_ROOM */
    1814      454432 :             else if ( ( hIntSetup != NULL ) && hIntSetup->is_loudspeaker_setup )
    1815             :             {
    1816      454432 :                 rotateFrame_sd( hCombinedOrientationData, tc_local, subframe_len, *hIntSetup, hEFAPdata, 0 );
    1817             :             }
    1818             :         }
    1819             : 
    1820    75219445 :         if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) )
    1821             :         {
    1822    75219445 :             if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK )
    1823             :             {
    1824           0 :                 return error;
    1825             :             }
    1826             : 
    1827    75219445 :             if ( pCrend->hCrend[0]->hReverb != NULL )
    1828             :             {
    1829    25144598 :                 if ( ( error = ivas_reverb_process( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK )
    1830             :                 {
    1831           0 :                     return error;
    1832             :                 }
    1833             :             }
    1834             : 
    1835   880917157 :             for ( ch = 0; ch < nchan_in; ch++ )
    1836             :             {
    1837   805697712 :                 tc_local[ch] += subframe_len;
    1838             :             }
    1839             : 
    1840    75219445 :             if ( hTcBuffer != NULL )
    1841             :             {
    1842     4313476 :                 hTcBuffer->slots_rendered += hTcBuffer->subframe_nbslots[subframe_idx];
    1843             :             }
    1844             :         }
    1845             :         else
    1846             :         {
    1847           0 :             return IVAS_ERR_INVALID_INPUT_FORMAT;
    1848             :         }
    1849             : 
    1850   225658335 :         for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
    1851             :         {
    1852             :             /* move to output */
    1853   150438890 :             mvr2r( pcm_tmp[ch], p_output[ch], subframe_len );
    1854             : 
    1855   150438890 :             p_output[ch] += subframe_len;
    1856             :         }
    1857             : 
    1858             :         /* update combined orientation access index */
    1859    75219445 :         ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len );
    1860             :     }
    1861             : 
    1862    48286546 :     if ( hTcBuffer != NULL )
    1863             :     {
    1864     2266507 :         hTcBuffer->subframes_rendered = last_sf;
    1865             :     }
    1866             : 
    1867    48286546 :     pop_wmops();
    1868             : 
    1869    48286546 :     return IVAS_ERR_OK;
    1870             : }
    1871             : 
    1872             : 
    1873             : /*-----------------------------------------------------------------------------------------*
    1874             :  * Function ivas_rend_crend_ProcessSubframesSplitBin()
    1875             :  *
    1876             :  * Process call for IVAS Crend renderer
    1877             :  *-----------------------------------------------------------------------------------------*/
    1878             : 
    1879       13535 : ivas_error ivas_rend_crendProcessSubframesSplitBin(
    1880             :     const CREND_WRAPPER *pCrend,                                /* i/o: Crend wrapper handle                    */
    1881             :     const AUDIO_CONFIG inConfig,                                /* i  : input audio configuration               */
    1882             :     const AUDIO_CONFIG outConfig,                               /* i  : output audio configuration              */
    1883             :     const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,          /* i/o: pose correction data handle             */
    1884             :     const DECODER_CONFIG_HANDLE hDecoderConfig,                 /* i  : decoder config. structure               */
    1885             :     const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i  : combined orientation handle             */
    1886             :     const IVAS_OUTPUT_SETUP_HANDLE hIntSetup,                   /* i  : internal setup handle                   */
    1887             :     const EFAP_HANDLE hEFAPdata,                                /* i  : EFAP handle                             */
    1888             :     DECODER_TC_BUFFER_HANDLE hTcBuffer,                         /* i/o: TC handle                               */
    1889             :     float *input_f[],                                           /* i  : transport channels                      */
    1890             :     float *output[],                                            /* i/o: input/output audio channels             */
    1891             :     const int16_t n_samples_to_render,                          /* i  : output frame length per channel         */
    1892             :     const int32_t output_Fs                                     /* i  : output sampling rate                    */
    1893             : )
    1894             : {
    1895             :     int16_t i, j;
    1896             :     int16_t sf;
    1897             :     int16_t pos_idx;
    1898             :     ivas_error error;
    1899             :     float gain_lfe;
    1900             :     float tmpLfeBuffer[L_FRAME48k];
    1901             :     int16_t original_subframes_rendered, original_slots_rendered;
    1902             :     float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    1903             :     float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS];
    1904             :     float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    1905             :     COMBINED_ORIENTATION_DATA combinedOrientationDataLocal;
    1906             :     COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal;
    1907             : 
    1908             :     /* save current head positions */
    1909       13535 :     pCombinedOrientationDataLocal = hCombinedOrientationData;
    1910       13535 :     combinedOrientationDataLocal = *pCombinedOrientationDataLocal;
    1911       13535 :     original_subframes_rendered = hTcBuffer->subframes_rendered;
    1912       13535 :     original_slots_rendered = hTcBuffer->slots_rendered;
    1913             : 
    1914             :     /* copy input */
    1915      230095 :     for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i )
    1916             :     {
    1917      216560 :         mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render );
    1918             :     }
    1919             : 
    1920      230095 :     for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
    1921             :     {
    1922      216560 :         p_tmpInputBuffer[i] = tmpInputBuffer[i];
    1923             :     }
    1924             : 
    1925             :     /* save current head positions */
    1926       13535 :     pCombinedOrientationDataLocal = hCombinedOrientationData;
    1927       13535 :     combinedOrientationDataLocal = *pCombinedOrientationDataLocal;
    1928       13535 :     if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
    1929             :     {
    1930       39100 :         for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf )
    1931             :         {
    1932       29325 :             combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0];
    1933      117300 :             for ( i = 0; i < 3; i++ )
    1934             :             {
    1935      351900 :                 for ( j = 0; j < 3; j++ )
    1936             :                 {
    1937      263925 :                     combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j];
    1938             :                 }
    1939             :             }
    1940             :         }
    1941             :     }
    1942             : 
    1943             :     /* copy LFE to tmpLfeBuffer and apply gain only once */
    1944       13535 :     if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 )
    1945             :     {
    1946           0 :         mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, n_samples_to_render );
    1947           0 :         gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE;
    1948           0 :         v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, n_samples_to_render );
    1949             :     }
    1950             :     else
    1951             :     {
    1952       13535 :         set_zero( tmpLfeBuffer, n_samples_to_render );
    1953             :     }
    1954             : 
    1955       70680 :     for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx )
    1956             :     {
    1957             :         /* Update head positions */
    1958             :         IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs;
    1959      285725 :         for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ )
    1960             :         {
    1961      228580 :             Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i];
    1962      228580 :             Quaternions_abs.w = -3.0f;
    1963      228580 :             Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/
    1964             : 
    1965      228580 :             Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0];
    1966      228580 :             Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1];
    1967      228580 :             Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2];
    1968      228580 :             combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs;
    1969      228580 :             QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] );
    1970             :         }
    1971             : 
    1972       57145 :         pCombinedOrientationDataLocal = &combinedOrientationDataLocal;
    1973             : 
    1974       57145 :         hTcBuffer->subframes_rendered = original_subframes_rendered;
    1975       57145 :         hTcBuffer->slots_rendered = original_slots_rendered;
    1976             : 
    1977             :         /* update combined orientation access index */
    1978       57145 :         ivas_combined_orientation_set_to_start_index( pCombinedOrientationDataLocal );
    1979             : 
    1980      228580 :         for ( i = 0; i < 3; i++ )
    1981             :         {
    1982      171435 :             mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 );
    1983             :         }
    1984             : 
    1985       57145 :         if ( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal,
    1986             :                                                        hIntSetup, hEFAPdata, hTcBuffer, p_tmpInputBuffer, p_tmpInputBuffer, n_samples_to_render, output_Fs, pos_idx ) ) != IVAS_ERR_OK )
    1987             :         {
    1988           0 :             return error;
    1989             :         }
    1990             : 
    1991      228580 :         for ( i = 0; i < 3; i++ )
    1992             :         {
    1993      171435 :             mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 );
    1994             :         }
    1995             : 
    1996      171435 :         for ( i = 0; i < BINAURAL_CHANNELS; ++i )
    1997             :         {
    1998             :             /* accumulate LFE to output */
    1999      114290 :             v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], n_samples_to_render );
    2000             : 
    2001             :             /* move to split bin output buffer */
    2002      114290 :             mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], n_samples_to_render );
    2003             :         }
    2004             : 
    2005             :         /* overwrite rendered channels with input again for next iteration */
    2006      971465 :         for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i )
    2007             :         {
    2008      914320 :             mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render );
    2009             :         }
    2010             : 
    2011             :         /* restore original headrotation data */
    2012      285725 :         for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ )
    2013             :         {
    2014      228580 :             combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i];
    2015             :         }
    2016             :     }
    2017             : 
    2018             :     /* copy split binaural rendered signals to final output */
    2019      127825 :     for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i )
    2020             :     {
    2021      114290 :         mvr2r( tmpSplitBinBuffer[i], output[i], n_samples_to_render );
    2022             :     }
    2023             : 
    2024             :     /* update main combined orientation access index */
    2025       13535 :     ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_to_render );
    2026             : 
    2027       13535 :     return IVAS_ERR_OK;
    2028             : }

Generated by: LCOV version 1.14