LCOV - code coverage report
Current view: top level - lib_dec - ivas_ism_renderer.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ 0c5691e6405a865cd50088c4936e8acb16f658a1 Lines: 182 189 96.3 %
Date: 2025-12-18 05:24:35 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "ivas_cnst.h"
      36             : #include "prot.h"
      37             : #include "ivas_prot.h"
      38             : #include "ivas_prot_rend.h"
      39             : #include "ivas_stat_com.h"
      40             : #include "ivas_rom_com.h"
      41             : #include "ivas_rom_dec.h"
      42             : #include <math.h>
      43             : #ifdef DEBUGGING
      44             : #include "debug.h"
      45             : #endif
      46             : #include "wmc_auto.h"
      47             : 
      48             : 
      49             : /*-------------------------------------------------------------------------*
      50             :  * ivas_ism_renderer_open()
      51             :  *
      52             :  * Open struct for object rendering, reserve memory, and init values.
      53             :  *-------------------------------------------------------------------------*/
      54             : 
      55         589 : ivas_error ivas_ism_renderer_open(
      56             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
      57             : )
      58             : {
      59             :     int16_t i;
      60             :     uint16_t interpolator_length;
      61             :     uint16_t init_interpolator_length;
      62             :     ivas_error error;
      63             : 
      64         589 :     if ( ( st_ivas->hIsmRendererData = (ISM_RENDERER_HANDLE) malloc( sizeof( ISM_RENDERER_DATA ) ) ) == NULL )
      65             :     {
      66           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer\n" ) );
      67             :     }
      68             : 
      69         589 :     if ( st_ivas->hIntSetup.is_loudspeaker_setup &&
      70         215 :          st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO &&
      71         184 :          st_ivas->hIntSetup.ls_azimuth != NULL && st_ivas->hIntSetup.ls_elevation != NULL &&
      72         184 :          st_ivas->hEFAPdata == NULL )
      73             :     {
      74         184 :         if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
      75             :         {
      76           0 :             return error;
      77             :         }
      78             :     }
      79             : 
      80        2945 :     for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
      81             :     {
      82        2356 :         set_f( st_ivas->hIsmRendererData->prev_gains[i], 0.0f, MAX_OUTPUT_CHANNELS );
      83        2356 :         set_f( st_ivas->hIsmRendererData->gains[i], 0.0f, MAX_OUTPUT_CHANNELS );
      84             :     }
      85             : 
      86         589 :     if ( st_ivas->hDecoderConfig->Opt_tsm )
      87             :     {
      88         195 :         init_interpolator_length = NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_CLDFB_TIMESLOTS * CLDFB_SLOT_NS );
      89         195 :         interpolator_length = (uint16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
      90             :     }
      91             :     else
      92             :     {
      93         394 :         init_interpolator_length = (uint16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
      94         394 :         interpolator_length = init_interpolator_length;
      95             :     }
      96             : 
      97         589 :     if ( ( st_ivas->hIsmRendererData->interpolator = (float *) malloc( sizeof( float ) * init_interpolator_length ) ) == NULL )
      98             :     {
      99           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer interpolator\n" ) );
     100             :     }
     101             : 
     102      507149 :     for ( i = 0; i < interpolator_length; i++ )
     103             :     {
     104      506560 :         st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 );
     105             :     }
     106             : 
     107         589 :     return IVAS_ERR_OK;
     108             : }
     109             : 
     110             : 
     111             : /*-------------------------------------------------------------------------*
     112             :  * ivas_ism_renderer_close()
     113             :  *
     114             :  * Close struct for object rendering.
     115             :  *-------------------------------------------------------------------------*/
     116             : 
     117       12235 : void ivas_ism_renderer_close(
     118             :     ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */
     119             : )
     120             : {
     121       12235 :     if ( hIsmRendererData == NULL || *hIsmRendererData == NULL )
     122             :     {
     123       10252 :         return;
     124             :     }
     125             : 
     126        1983 :     if ( ( *hIsmRendererData )->interpolator != NULL )
     127             :     {
     128        1983 :         free( ( *hIsmRendererData )->interpolator );
     129        1983 :         ( *hIsmRendererData )->interpolator = NULL;
     130             :     }
     131             : 
     132        1983 :     free( *hIsmRendererData );
     133        1983 :     *hIsmRendererData = NULL;
     134             : 
     135        1983 :     return;
     136             : }
     137             : 
     138             : 
     139             : /*-------------------------------------------------------------------------*
     140             :  * ivas_ism_render_sf()
     141             :  *
     142             :  * Object rendering process
     143             :  *-------------------------------------------------------------------------*/
     144             : 
     145       27911 : void ivas_ism_render_sf(
     146             :     Decoder_Struct *st_ivas,           /* i/o: IVAS decoder structure                      */
     147             :     const RENDERER_TYPE renderer_type, /* i  : active renderer type                        */
     148             :     float *output_f[],                 /* i/o: core-coder transport channels/object output */
     149             :     const int16_t n_samples_to_render  /* i  : output frame length per channel             */
     150             : )
     151             : {
     152             :     int16_t i, j, k, j2;
     153             :     float *g1, g2, *tc;
     154             :     int16_t num_objects, nchan_out_woLFE, lfe_index;
     155             :     int16_t azimuth, elevation;
     156             :     int16_t tc_offset;
     157             :     int16_t interp_offset;
     158             :     float gain, prev_gain;
     159             :     float tc_local[MAX_NUM_OBJECTS][L_FRAME48k];
     160             :     float *p_tc[MAX_NUM_OBJECTS];
     161             :     int16_t ism_md_subframe_update_jbm, slots_to_render, first_sf, last_sf, subframe_idx;
     162             :     int16_t n_samples_rendered_loop;
     163             : 
     164             :     /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
     165       27911 :     slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / st_ivas->hTcBuffer->n_samples_granularity );
     166       27911 :     first_sf = st_ivas->hTcBuffer->subframes_rendered;
     167       27911 :     last_sf = first_sf;
     168       27911 :     n_samples_rendered_loop = 0;
     169             : 
     170      134069 :     while ( slots_to_render > 0 )
     171             :     {
     172      106158 :         slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf];
     173      106158 :         last_sf++;
     174             :     }
     175             : #ifdef DEBUGGING
     176             :     assert( slots_to_render == 0 );
     177             :     assert( last_sf <= st_ivas->hTcBuffer->nb_subframes );
     178             : #endif
     179       27911 :     num_objects = st_ivas->nchan_ism;
     180             : 
     181       27911 :     nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
     182             : 
     183       27911 :     tc_offset = st_ivas->hTcBuffer->n_samples_rendered;
     184       27911 :     interp_offset = st_ivas->hTcBuffer->n_samples_rendered;
     185             : 
     186             :     /* Number of subframes to delay metadata to sync with audio */
     187       27911 :     if ( st_ivas->hDecoderConfig->Opt_delay_comp )
     188             :     {
     189       24543 :         ism_md_subframe_update_jbm = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 );
     190             :     }
     191             :     else
     192             :     {
     193        3368 :         ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2;
     194             :     }
     195             : 
     196      104593 :     for ( i = 0; i < num_objects; i++ )
     197             :     {
     198       76682 :         mvr2r( &output_f[i][tc_offset], tc_local[i], n_samples_to_render );
     199       76682 :         p_tc[i] = tc_local[i];
     200             :     }
     201             : 
     202      280275 :     for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ )
     203             :     {
     204      252364 :         set_f( output_f[i], 0.0f, n_samples_to_render );
     205             :     }
     206             : 
     207      134069 :     for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
     208             :     {
     209             :         int16_t n_samples_in_subframe;
     210             : 
     211      106158 :         n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
     212             : 
     213      106158 :         if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
     214             :         {
     215       11992 :             ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator );
     216       11992 :             interp_offset = 0;
     217             :         }
     218             : 
     219      396428 :         for ( i = 0; i < num_objects; i++ )
     220             :         {
     221             :             /* Combined rotation: rotate the object positions depending the head and external orientations */
     222      290270 :             if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
     223             :             {
     224       11992 :                 if ( subframe_idx >= ism_md_subframe_update_jbm )
     225             :                 {
     226        8994 :                     rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
     227             :                 }
     228             :                 else
     229             :                 {
     230        2998 :                     rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
     231             :                 }
     232             : 
     233       11992 :                 if ( st_ivas->hEFAPdata != NULL )
     234             :                 {
     235       11992 :                     efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP );
     236       11992 :                     v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE );
     237             :                 }
     238             :             }
     239             : 
     240      290270 :             lfe_index = 0;
     241     2700659 :             for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ )
     242             :             {
     243     2410389 :                 if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) )
     244             :                 {
     245      177787 :                     ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++;
     246             :                 }
     247             : 
     248     2410389 :                 gain = st_ivas->hIsmRendererData->gains[i][j];
     249     2410389 :                 prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j];
     250     2410389 :                 if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f )
     251             :                 {
     252     1217721 :                     g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset];
     253     1217721 :                     tc = p_tc[i];
     254   265609801 :                     for ( k = 0; k < n_samples_in_subframe; k++ )
     255             :                     {
     256   264392080 :                         g2 = 1.0f - *g1;
     257   264392080 :                         output_f[j2][k + n_samples_rendered_loop] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ );
     258             :                     }
     259             :                 }
     260             : 
     261             :                 /* update here only in case of head rotation */
     262     2410389 :                 if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
     263             :                 {
     264      131912 :                     st_ivas->hIsmRendererData->prev_gains[i][j] = gain;
     265             :                 }
     266             :             }
     267      290270 :             p_tc[i] += n_samples_in_subframe;
     268             :         }
     269             : 
     270             :         /* update combined orientation access index */
     271      106158 :         ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_in_subframe );
     272             : 
     273      106158 :         n_samples_rendered_loop += n_samples_in_subframe;
     274             :         /* update rendered subframe and slots info for all cases apart from a following crend call, the update will
     275             :            then happen in the crend call*/
     276      106158 :         if ( renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM )
     277             :         {
     278       62961 :             st_ivas->hTcBuffer->subframes_rendered += 1;
     279       62961 :             st_ivas->hTcBuffer->slots_rendered += st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
     280             :         }
     281      106158 :         tc_offset += n_samples_in_subframe;
     282      106158 :         interp_offset += n_samples_in_subframe;
     283             :     }
     284             : 
     285       27911 :     return;
     286             : }
     287             : 
     288             : 
     289             : /*-------------------------------------------------------------------------*
     290             :  * ivas_ism_get_stereo_gains()
     291             :  *
     292             :  *
     293             :  *-------------------------------------------------------------------------*/
     294             : 
     295      231458 : void ivas_ism_get_stereo_gains(
     296             :     const float azimuth,   /* i  : object azimuth       */
     297             :     const float elevation, /* i  : object elevation     */
     298             :     float *left_gain,      /* o  : left channel gain    */
     299             :     float *right_gain      /* o  : right channel gain   */
     300             : )
     301             : {
     302             :     float aziRad, eleRad;
     303             :     float y, mappedX, aziRadMapped, A, A2, A3;
     304             : 
     305             :     /* Convert azi and ele to an azi value of the cone of confusion */
     306      231458 :     aziRad = azimuth * PI_OVER_180;
     307      231458 :     eleRad = elevation * PI_OVER_180;
     308      231458 :     y = ( sinf( aziRad ) * cosf( eleRad ) );
     309      231458 :     mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) );
     310      231458 :     aziRadMapped = atan2f( y, mappedX );
     311             : 
     312             :     /* Determine the amplitude panning gains */
     313      231458 :     if ( aziRadMapped >= LS_ANGLE_RAD_30_DEG )
     314             :     { /* Left side */
     315       22088 :         *left_gain = 1.0f;
     316       22088 :         *right_gain = 0.0f;
     317             :     }
     318      209370 :     else if ( aziRadMapped <= -LS_ANGLE_RAD_30_DEG )
     319             :     { /* Right side */
     320       23846 :         *left_gain = 0.0f;
     321       23846 :         *right_gain = 1.0f;
     322             :     }
     323             :     else /* Tangent panning law */
     324             :     {
     325      185524 :         A = tanf( aziRadMapped ) * INV_TAN_LS_ANGLE_RAD_30_DEG;
     326      185524 :         A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f );
     327      185524 :         A3 = 1.0f / ( A2 * A2 + 1.0f );
     328      185524 :         *left_gain = sqrtf( A3 );
     329      185524 :         *right_gain = sqrtf( 1.0f - A3 );
     330             :     }
     331             : 
     332      231458 :     return;
     333             : }
     334             : 
     335             : 
     336             : /*-------------------------------------------------------------------------*
     337             :  * ivas_omasa_separate_object_renderer_open()
     338             :  *
     339             :  * Open structures, reserve memory, and init values.
     340             :  *-------------------------------------------------------------------------*/
     341             : 
     342        1269 : ivas_error ivas_omasa_separate_object_renderer_open(
     343             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
     344             : )
     345             : {
     346             :     int16_t interpolator_length;
     347             :     int16_t i;
     348             :     int16_t init_interpolator_length;
     349             : 
     350        1269 :     if ( ( st_ivas->hIsmRendererData = (ISM_RENDERER_HANDLE) malloc( sizeof( ISM_RENDERER_DATA ) ) ) == NULL )
     351             :     {
     352           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM renderer \n" ) );
     353             :     }
     354             : 
     355        6345 :     for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
     356             :     {
     357        5076 :         set_f( st_ivas->hIsmRendererData->prev_gains[i], 0.0f, MAX_OUTPUT_CHANNELS );
     358             :     }
     359             : 
     360        1269 :     init_interpolator_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES );
     361        1269 :     interpolator_length = init_interpolator_length;
     362        1269 :     if ( ( st_ivas->hIsmRendererData->interpolator = (float *) malloc( sizeof( float ) * init_interpolator_length ) ) == NULL )
     363             :     {
     364           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM renderer interpolator \n" ) );
     365             :     }
     366             : 
     367      305589 :     for ( i = 0; i < interpolator_length; i++ )
     368             :     {
     369      304320 :         st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length );
     370             :     }
     371        1269 :     st_ivas->hIsmRendererData->interpolator_length = interpolator_length;
     372             : 
     373        1269 :     return IVAS_ERR_OK;
     374             : }
     375             : 
     376             : 
     377             : /*-------------------------------------------------------------------------*
     378             :  * ivas_omasa_separate_object_renderer_close()
     379             :  *
     380             :  * Close structures, free memory.
     381             :  *-------------------------------------------------------------------------*/
     382             : 
     383        9892 : void ivas_omasa_separate_object_renderer_close(
     384             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
     385             : )
     386             : {
     387             :     int16_t i;
     388             : 
     389        9892 :     if ( st_ivas->hMasaIsmData != NULL )
     390             :     {
     391        9892 :         if ( st_ivas->hMasaIsmData->delayBuffer != NULL )
     392             :         {
     393        6603 :             for ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ )
     394             :             {
     395        4563 :                 if ( st_ivas->hMasaIsmData->delayBuffer[i] != NULL )
     396             :                 {
     397        4563 :                     free( st_ivas->hMasaIsmData->delayBuffer[i] );
     398        4563 :                     st_ivas->hMasaIsmData->delayBuffer[i] = NULL;
     399             :                 }
     400             :             }
     401             : 
     402        2040 :             free( st_ivas->hMasaIsmData->delayBuffer );
     403        2040 :             st_ivas->hMasaIsmData->delayBuffer = NULL;
     404             :         }
     405             :     }
     406             : 
     407        9892 :     ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
     408             : 
     409        9892 :     return;
     410             : }
     411             : 
     412             : 
     413             : /*-------------------------------------------------------------------------*
     414             :  * ivas_omasa_separate_object_render_jbm()
     415             :  *
     416             :  * Rendering separated objects and mixing them to the parametrically rendered signals for JBM
     417             :  *-------------------------------------------------------------------------*/
     418             : 
     419        9818 : void ivas_omasa_separate_object_render_jbm(
     420             :     Decoder_Struct *st_ivas,         /* i/o: IVAS decoder structure                      */
     421             :     const uint16_t nSamplesRendered, /* i  : number of samples rendered                  */
     422             :     float input_f_in[][L_FRAME48k],  /* i  : separated object signal                     */
     423             :     float *output_f[],               /* o  : rendered time signal                        */
     424             :     const int16_t subframes_rendered /* i  : number of subframes rendered                */
     425             : )
     426             : {
     427             :     VBAP_HANDLE hVBAPdata;
     428             :     DIRAC_REND_HANDLE hDirACRend;
     429             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
     430             :     int16_t nchan_out_woLFE, num_lfe;
     431             :     ISM_RENDERER_HANDLE hRendererData;
     432             :     int16_t j, k, j2;
     433             :     int16_t obj;
     434             :     float gains[MAX_OUTPUT_CHANNELS];
     435             :     float g1, g2;
     436             :     int16_t lfe_index;
     437             :     int16_t azimuth, elevation;
     438             :     int16_t num_objects;
     439             :     uint8_t single_separated;
     440             :     float *input_f[MAX_TRANSPORT_CHANNELS];
     441             :     float *output_f_local[MAX_OUTPUT_CHANNELS];
     442             :     int16_t offsetSamples;
     443             :     int16_t n_samples_sf, md_idx;
     444             :     int16_t slots_to_render, first_sf, last_sf, subframe_idx;
     445             : 
     446        9818 :     hVBAPdata = st_ivas->hVBAPdata;
     447        9818 :     hDirACRend = st_ivas->hDirACRend;
     448        9818 :     hSpatParamRendCom = st_ivas->hSpatParamRendCom;
     449        9818 :     nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
     450        9818 :     num_lfe = st_ivas->hIntSetup.num_lfe;
     451        9818 :     hRendererData = st_ivas->hIsmRendererData;
     452        9818 :     lfe_index = hDirACRend->hOutSetup.index_lfe[0];
     453             : 
     454        9818 :     if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
     455             :     {
     456        5699 :         single_separated = 1;
     457        5699 :         num_objects = 1;
     458             :     }
     459             :     else
     460             :     {
     461        4119 :         single_separated = 0;
     462        4119 :         num_objects = st_ivas->nchan_ism;
     463             :     }
     464             : 
     465       82170 :     for ( j = 0; j < nchan_out_woLFE + num_lfe; j++ )
     466             :     {
     467       72352 :         output_f_local[j] = output_f[j];
     468             :     }
     469             : 
     470       25386 :     for ( obj = 0; obj < num_objects; obj++ )
     471             :     {
     472       15568 :         input_f[obj] = input_f_in[obj];
     473             :     }
     474             : 
     475        9818 :     slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size;
     476        9818 :     first_sf = subframes_rendered;
     477        9818 :     last_sf = first_sf;
     478             : 
     479       41156 :     while ( slots_to_render > 0 )
     480             :     {
     481       31338 :         slots_to_render -= hSpatParamRendCom->subframe_nbslots[last_sf];
     482       31338 :         last_sf++;
     483             :     }
     484             : 
     485       25386 :     for ( obj = 0; obj < num_objects; obj++ )
     486             :     {
     487       15568 :         offsetSamples = 0;
     488             : 
     489       63170 :         for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
     490             :         {
     491       47602 :             n_samples_sf = hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->slot_size;
     492       47602 :             if ( n_samples_sf != hRendererData->interpolator_length )
     493             :             {
     494     1443538 :                 for ( k = 0; k < n_samples_sf; k++ )
     495             :                 {
     496     1435440 :                     hRendererData->interpolator[k] = (float) k / ( (float) n_samples_sf );
     497             :                 }
     498        8098 :                 hRendererData->interpolator_length = n_samples_sf;
     499             :             }
     500             : 
     501       47602 :             md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx];
     502             : 
     503       47602 :             if ( single_separated )
     504             :             {
     505       19660 :                 if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->ism_dir_is_edited[st_ivas->hMasaIsmData->idx_separated_ism] )
     506             :                 {
     507           0 :                     azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism];
     508           0 :                     elevation = st_ivas->hMasaIsmData->elevation_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism];
     509             :                 }
     510             :                 else
     511             :                 {
     512       19660 :                     azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx];
     513       19660 :                     elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx];
     514             :                 }
     515             :             }
     516             :             else
     517             :             {
     518       27942 :                 if ( st_ivas->hMasaIsmData->ism_dir_is_edited[obj] )
     519             :                 {
     520        9898 :                     azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[obj];
     521        9898 :                     elevation = st_ivas->hMasaIsmData->elevation_ism_edited[obj];
     522             :                 }
     523             :                 else
     524             :                 {
     525       18044 :                     azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx];
     526       18044 :                     elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx];
     527             :                 }
     528             :             }
     529             : 
     530       47602 :             if ( st_ivas->hOutSetup.is_planar_setup )
     531             :             {
     532             :                 /* If no elevation support in output format, then rendering should be done with zero elevation */
     533        5084 :                 elevation = 0;
     534             :             }
     535             : 
     536       47602 :             if ( hVBAPdata != NULL )
     537             :             {
     538       14190 :                 vbap_determine_gains( hVBAPdata, gains, azimuth, elevation, 1 );
     539             :             }
     540             :             else
     541             :             {
     542       33412 :                 ivas_dirac_dec_get_response( azimuth, elevation, gains, hDirACRend->hOutSetup.ambisonics_order );
     543             :             }
     544             : 
     545      424484 :             for ( j = 0; j < nchan_out_woLFE; j++ )
     546             :             {
     547      376882 :                 if ( hDirACRend->hOutSetup.num_lfe > 0 )
     548             :                 {
     549      108322 :                     j2 = j + ( j >= lfe_index );
     550             :                 }
     551             :                 else
     552             :                 {
     553      268560 :                     j2 = j;
     554             :                 }
     555             : 
     556      376882 :                 if ( fabsf( gains[j] ) > 0.0f || fabsf( hRendererData->prev_gains[obj][j] ) > 0.0f )
     557             :                 {
     558    62100879 :                     for ( k = 0; k < n_samples_sf; k++ )
     559             :                     {
     560    61813240 :                         g1 = hRendererData->interpolator[k];
     561    61813240 :                         g2 = 1.0f - g1;
     562    61813240 :                         output_f_local[j2][k + offsetSamples] += ( g1 * gains[j] + g2 * hRendererData->prev_gains[obj][j] ) * input_f[obj][k + offsetSamples];
     563             :                     }
     564             :                 }
     565      376882 :                 hRendererData->prev_gains[obj][j] = gains[j];
     566             :             }
     567             : 
     568       47602 :             offsetSamples += n_samples_sf;
     569             :         }
     570             :     }
     571             : 
     572        9818 :     return;
     573             : }

Generated by: LCOV version 1.14