LCOV - code coverage report
Current view: top level - lib_dec - ivas_sba_rendering_internal.c (source / functions) Hit Total Coverage
Test: Coverage on main -- conformance test test_26252.py @ 0c5691e6405a865cd50088c4936e8acb16f658a1 Lines: 146 160 91.2 %
Date: 2025-12-18 05:24:35 Functions: 7 8 87.5 %

          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 "prot.h"
      36             : #include "ivas_prot.h"
      37             : #include "ivas_prot_rend.h"
      38             : #include "ivas_stat_dec.h"
      39             : #include "ivas_cnst.h"
      40             : #include <math.h>
      41             : #ifdef DEBUGGING
      42             : #include "debug.h"
      43             : #endif
      44             : #include "wmc_auto.h"
      45             : 
      46             : 
      47             : #ifdef DEBUG_MODE_DIRAC
      48             : /*-----------------------------------------------------------------------*
      49             :  * Local function prototypes
      50             :  *-----------------------------------------------------------------------*/
      51             : 
      52             : static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame );
      53             : #endif
      54             : 
      55             : 
      56             : /*-------------------------------------------------------------------------*
      57             :  * ivas_sba2MC_cldfb()
      58             :  *
      59             :  * SBA signals transformed into MC in CLDFB domain
      60             :  *-------------------------------------------------------------------------*/
      61             : 
      62       27996 : void ivas_sba2mc_cldfb(
      63             :     IVAS_OUTPUT_SETUP hInSetup,                                             /* i  : Format of input layout        */
      64             :     float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part               */
      65             :     float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part               */
      66             :     const int16_t nb_channels_out,                                          /* i  : nb of output channels         */
      67             :     const int16_t nb_bands,                                                 /* i  : nb of CLDFB bands to process  */
      68             :     const int16_t nb_timeslots,                                             /* i  : number of time slots to process */
      69             :     const float *hoa_dec_mtx                                                /* i  : HOA decoding mtx              */
      70             : )
      71             : {
      72             :     int16_t iBlock, iBand, n, m;
      73             :     float realOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX];
      74             :     float g;
      75             :     float *p_real, *p_imag, *p_realOut, *p_imagOut;
      76             :     int16_t nb_channels_in;
      77             : 
      78       27996 :     push_wmops( "ivas_sba2mc_cldfb" );
      79       27996 :     nb_channels_in = hInSetup.nchan_out_woLFE;
      80       27996 :     assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" );
      81             : 
      82      335952 :     for ( n = 0; n < nb_channels_out; n++ )
      83             :     {
      84      307956 :         set_zero( realOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
      85      307956 :         set_zero( imagOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
      86             : 
      87     5235252 :         for ( m = 0; m < nb_channels_in; m++ )
      88             :         {
      89     4927296 :             g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m];
      90     4927296 :             p_realOut = realOut[n];
      91     4927296 :             p_imagOut = imagOut[n];
      92             : 
      93    24636480 :             for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ )
      94             :             {
      95    19709184 :                 p_real = RealBuffer[m][iBlock];
      96    19709184 :                 p_imag = ImagBuffer[m][iBlock];
      97   836208384 :                 for ( iBand = 0; iBand < nb_bands; iBand++ )
      98             :                 {
      99   816499200 :                     *p_realOut = *p_realOut + g * *( p_real++ );
     100   816499200 :                     *p_imagOut = *p_imagOut + g * *( p_imag++ );
     101   816499200 :                     p_realOut++;
     102   816499200 :                     p_imagOut++;
     103             :                 }
     104             :             }
     105             :         }
     106             :     }
     107             : 
     108      335952 :     for ( n = 0; n < nb_channels_out; n++ )
     109             :     {
     110      307956 :         p_realOut = realOut[n];
     111      307956 :         p_imagOut = imagOut[n];
     112             : 
     113     1539780 :         for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ )
     114             :         {
     115     1231824 :             p_real = RealBuffer[n][iBlock];
     116     1231824 :             p_imag = ImagBuffer[n][iBlock];
     117    52263024 :             for ( iBand = 0; iBand < nb_bands; iBand++ )
     118             :             {
     119    51031200 :                 *( p_real++ ) = *p_realOut++;
     120    51031200 :                 *( p_imag++ ) = *p_imagOut++;
     121             :             }
     122             :         }
     123             :     }
     124             : 
     125       27996 :     pop_wmops();
     126       27996 :     return;
     127             : }
     128             : 
     129             : 
     130             : /*-------------------------------------------------------------------------*
     131             :  * ivas_mc2sba()
     132             :  *
     133             :  * MC signals transformed into SBA in TD domain
     134             :  *-------------------------------------------------------------------------*/
     135             : 
     136       14383 : void ivas_mc2sba(
     137             :     IVAS_OUTPUT_SETUP hIntSetup, /* i  : Format of decoder output                         */
     138             :     float *in_buffer_td[],       /* i  : MC signals (on input) and the HOA3 (on output)   */
     139             :     float *buffer_td[],          /* i/o: MC signals (on input) and the HOA3 (on output)   */
     140             :     const int16_t output_frame,  /* i  : output frame length per channel                  */
     141             :     const int16_t sba_order,     /* i  : Ambisonic (SBA) order                            */
     142             :     const float gain_lfe         /* i  : gain for LFE, 0 = ignore LFE                     */
     143             : )
     144             : {
     145             :     int16_t i, j, k;
     146             :     int16_t idx_lfe, idx_in;
     147             :     float buffer_tmp[16][L_FRAME48k];
     148             :     float gains[16];
     149             :     int16_t azimuth, elevation;
     150             :     int16_t sba_num_chans;
     151             : 
     152       14383 :     assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
     153             :     /* Init*/
     154       14383 :     sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
     155      157463 :     for ( j = 0; j < sba_num_chans; j++ )
     156             :     {
     157      143080 :         set_zero( buffer_tmp[j], output_frame );
     158             :     }
     159             : 
     160             :     /* HOA encoding*/
     161       14383 :     idx_lfe = 0;
     162       14383 :     idx_in = 0;
     163      180979 :     for ( i = 0; i < hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe; i++ )
     164             :     {
     165      166596 :         if ( ( hIntSetup.num_lfe > 0 ) && ( i == hIntSetup.index_lfe[idx_lfe] ) )
     166             :         {
     167       14383 :             if ( gain_lfe > 0.f )
     168             :             {
     169             :                 /* Add LFE to omni W with gain*/
     170     5445375 :                 for ( k = 0; k < output_frame; k++ )
     171             :                 {
     172     5439600 :                     buffer_tmp[0][k] += gain_lfe * in_buffer_td[i][k];
     173             :                 }
     174             :             }
     175             : 
     176       14383 :             if ( idx_lfe < ( hIntSetup.num_lfe - 1 ) )
     177             :             {
     178           0 :                 idx_lfe++;
     179             :             }
     180             :         }
     181             :         else
     182             :         {
     183      152213 :             azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] );
     184      152213 :             elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] );
     185      152213 :             idx_in++;
     186             : 
     187             :             /* get HOA response for direction (ACN/SN3D)*/
     188      152213 :             ivas_dirac_dec_get_response(
     189             :                 azimuth,
     190             :                 elevation,
     191             :                 gains,
     192             :                 sba_order );
     193             : 
     194     1630093 :             for ( j = 0; j < sba_num_chans; j++ )
     195             :             {
     196  1286009240 :                 for ( k = 0; k < output_frame; k++ )
     197             :                 {
     198  1284531360 :                     buffer_tmp[j][k] += gains[j] * in_buffer_td[i][k];
     199             :                 }
     200             :             }
     201             :         }
     202             :     }
     203             : 
     204      157463 :     for ( j = 0; j < sba_num_chans; j++ )
     205             :     {
     206      143080 :         mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
     207             :     }
     208             : 
     209       14383 :     return;
     210             : }
     211             : 
     212             : 
     213             : /*-------------------------------------------------------------------------*
     214             :  * ivas_stereo2sba()
     215             :  *
     216             :  * stereo signal is transformed into SBA in TD domain
     217             :  *-------------------------------------------------------------------------*/
     218             : 
     219           0 : void ivas_stereo2sba(
     220             :     float *input_f[],          /* i  : core-coder transport stereo channels */
     221             :     float *output_f[],         /* o  : SBA output channels                  */
     222             :     const int16_t output_frame /* i  : output frame length per channel      */
     223             : )
     224             : {
     225             :     int16_t n;
     226             :     float tmp;
     227             : 
     228           0 :     for ( n = 0; n < output_frame; n++ )
     229             :     {
     230           0 :         tmp = input_f[0][n];
     231           0 :         output_f[0][n] = 0.5f * ( tmp + input_f[1][n] ); /* W = 0.5 * ( L + R ) */
     232           0 :         output_f[1][n] = 0.5f * ( tmp - input_f[1][n] ); /* Y = 0.5 * ( L - R ) */
     233             :     }
     234             : 
     235           0 :     return;
     236             : }
     237             : 
     238             : 
     239             : /*-------------------------------------------------------------------------*
     240             :  * ivas_param_mc_mc2sba_cldfb()
     241             :  *
     242             :  * MC signals transformed into SBA in CLDFB domain
     243             :  * used for binaural rendering with head rotation
     244             :  *-------------------------------------------------------------------------*/
     245             : 
     246      223572 : void ivas_param_mc_mc2sba_cldfb(
     247             :     IVAS_OUTPUT_SETUP hTransSetup,                                                /* i  : transported MC Format                                       */
     248             :     float *hoa_encoder,                                                           /* i  : HOA3 encoder for the transported MC format                  */
     249             :     const int16_t slot_idx,                                                       /* i  : current slot in the subframe                                */
     250             :     float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */
     251             :     float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */
     252             :     const int16_t nBands,                                                         /* i  : number of synth CLDFB bands                                 */
     253             :     const float gain_lfe                                                          /* i  : gain applied to LFE                                        */
     254             : )
     255             : {
     256             :     int16_t idx_ch, idx_band;
     257             :     int16_t idx_lfe, idx_in, idx_out;
     258             :     float Cldfb_RealBuffer_tmp[MAX_INTERN_CHANNELS][CLDFB_NO_CHANNELS_MAX];
     259             :     float Cldfb_ImagBuffer_tmp[MAX_INTERN_CHANNELS][CLDFB_NO_CHANNELS_MAX];
     260             :     float *gains;
     261             :     int16_t sba_num_chans;
     262             : 
     263             :     /* Init*/
     264      223572 :     sba_num_chans = MAX_INTERN_CHANNELS;
     265             : 
     266     3800724 :     for ( idx_ch = 0; idx_ch < sba_num_chans; idx_ch++ )
     267             :     {
     268     3577152 :         set_zero( Cldfb_RealBuffer_tmp[idx_ch], CLDFB_NO_CHANNELS_MAX );
     269     3577152 :         set_zero( Cldfb_ImagBuffer_tmp[idx_ch], CLDFB_NO_CHANNELS_MAX );
     270             :     }
     271             : 
     272      223572 :     idx_lfe = 0;
     273      223572 :     idx_in = 0;
     274     2604344 :     for ( idx_ch = 0; idx_ch < hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe; idx_ch++ )
     275             :     {
     276     2380772 :         if ( ( hTransSetup.num_lfe > 0 ) && ( idx_ch == hTransSetup.index_lfe[idx_lfe] ) )
     277             :         {
     278      223572 :             if ( gain_lfe > 0.f )
     279             :             {
     280             :                 /* Add LFE to Omni Channel i.e. W (Just first Band) */
     281      223572 :                 Cldfb_RealBuffer_tmp[0][0] += gain_lfe * Cldfb_RealBuffer[idx_ch][slot_idx][0];
     282      223572 :                 Cldfb_ImagBuffer_tmp[0][0] += gain_lfe * Cldfb_ImagBuffer[idx_ch][slot_idx][0];
     283             :             }
     284      223572 :             if ( idx_lfe < ( hTransSetup.num_lfe - 1 ) )
     285             :             {
     286           0 :                 idx_lfe++;
     287             :             }
     288             :         }
     289             :         else
     290             :         {
     291     2157200 :             gains = hoa_encoder + idx_in * sba_num_chans;
     292    36672400 :             for ( idx_out = 0; idx_out < sba_num_chans; idx_out++ )
     293             :             {
     294  2061490880 :                 for ( idx_band = 0; idx_band < nBands; idx_band++ )
     295             :                 {
     296  2026975680 :                     Cldfb_RealBuffer_tmp[idx_out][idx_band] += ( *gains ) * Cldfb_RealBuffer[idx_ch][slot_idx][idx_band];
     297  2026975680 :                     Cldfb_ImagBuffer_tmp[idx_out][idx_band] += ( *gains ) * Cldfb_ImagBuffer[idx_ch][slot_idx][idx_band];
     298             :                 }
     299    34515200 :                 gains++;
     300             :             }
     301     2157200 :             idx_in++;
     302             :         }
     303             :     }
     304             : 
     305     3800724 :     for ( idx_ch = 0; idx_ch < sba_num_chans; idx_ch++ )
     306             :     {
     307     3577152 :         mvr2r( Cldfb_RealBuffer_tmp[idx_ch], Cldfb_RealBuffer[idx_ch][slot_idx], nBands );
     308     3577152 :         mvr2r( Cldfb_ImagBuffer_tmp[idx_ch], Cldfb_ImagBuffer[idx_ch][slot_idx], nBands );
     309             :     }
     310             : 
     311      223572 :     return;
     312             : }
     313             : 
     314             : 
     315             : /*-------------------------------------------------------------------*
     316             :  * ivas_sba_remapTCs()
     317             :  *
     318             :  * Get TCs from Ambisonics signal in ACN
     319             :  *-------------------------------------------------------------------*/
     320             : 
     321             : /*! r: SBA DirAC stereo flag */
     322      242889 : int16_t ivas_sba_remapTCs(
     323             :     float *sba_data[],         /* i/o: SBA signals                  */
     324             :     Decoder_Struct *st_ivas,   /* i/o: decoder struct               */
     325             :     const int16_t output_frame /* i  : frame length                 */
     326             : )
     327             : {
     328             :     int16_t nchan_remapped;
     329             : 
     330             : #ifdef DEBUG_MODE_DIRAC
     331             :     debug_mode_dirac( sba_data, st_ivas->nchan_transport, output_frame );
     332             : #endif
     333             : 
     334      242889 :     nchan_remapped = st_ivas->nchan_transport;
     335      242889 :     if ( nchan_remapped == 3 )
     336             :     {
     337             : 
     338       34788 :         nchan_remapped++;
     339             : 
     340       34788 :         if ( nchan_remapped == 4 )
     341             :         {
     342             :             /*For planar A-format channel 2 and 3 are identical -> Z=0*/
     343       34788 :             mvr2r( sba_data[2], sba_data[3], output_frame );
     344             :         }
     345             :     }
     346             : 
     347      242889 :     if ( st_ivas->nchan_transport >= 3 )
     348             :     {
     349      140633 :         int16_t i = 0;
     350             :         float temp;
     351             : 
     352             :         /*convert WYXZ downmix to WYZX*/
     353   124836313 :         for ( i = 0; i < output_frame; i++ )
     354             :         {
     355   124695680 :             temp = sba_data[2][i];
     356   124695680 :             sba_data[2][i] = sba_data[3][i];
     357   124695680 :             sba_data[3][i] = temp;
     358   124695680 :             if ( st_ivas->nchan_transport == 3 )
     359             :             {
     360    27967680 :                 sba_data[2][i] = 0;
     361             :             }
     362             :         }
     363             :     }
     364             : 
     365      242889 :     return ( nchan_remapped );
     366             : }
     367             : 
     368             : 
     369             : /*-------------------------------------------------------------------------*
     370             :  * ivas_ism2sba_sf()
     371             :  *
     372             :  * ISM transformed into SBA in TD domain.
     373             :  *-------------------------------------------------------------------------*/
     374             : 
     375        7843 : void ivas_ism2sba_sf(
     376             :     float *buffer_in[],                   /* i  : TC buffer                       */
     377             :     float *buffer_out[],                  /* o  : TD signal buffers               */
     378             :     ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data                   */
     379             :     const int16_t num_objects,            /* i  : number of objects               */
     380             :     const int16_t n_samples_to_render,    /* i  : output frame length per channel */
     381             :     const int16_t offset,                 /* i  : offset for the interpolatr      */
     382             :     const int16_t sba_order               /* i  : Ambisonic (SBA) order           */
     383             : )
     384             : {
     385             :     int16_t i, j, k;
     386             :     float g1, *g2, *tc, *out, gain, prev_gain;
     387             :     float buffer_tmp[HOA3_CHANNELS][L_FRAME48k];
     388             :     int16_t sba_num_chans;
     389             : 
     390        7843 :     assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
     391        7843 :     assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" );
     392             : 
     393             :     /* Init*/
     394        7843 :     sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
     395       79755 :     for ( j = 0; j < sba_num_chans; j++ )
     396             :     {
     397       71912 :         set_zero( buffer_tmp[j], n_samples_to_render );
     398             :     }
     399             : 
     400       32568 :     for ( i = 0; i < num_objects; i++ )
     401             :     {
     402      256797 :         for ( j = 0; j < sba_num_chans; j++ )
     403             :         {
     404      232072 :             g2 = hIsmRendererData->interpolator + offset;
     405      232072 :             tc = buffer_in[i];
     406      232072 :             out = buffer_tmp[j];
     407      232072 :             gain = hIsmRendererData->gains[i][j];
     408      232072 :             prev_gain = hIsmRendererData->prev_gains[i][j];
     409   183374632 :             for ( k = 0; k < n_samples_to_render; k++ )
     410             :             {
     411   183142560 :                 g1 = 1.0f - *g2;
     412   183142560 :                 *( out++ ) += ( ( *( g2++ ) ) * gain + g1 * prev_gain ) * ( *( tc++ ) );
     413             :             }
     414             :         }
     415             :     }
     416             : 
     417       79755 :     for ( j = 0; j < sba_num_chans; j++ )
     418             :     {
     419       71912 :         mvr2r( buffer_tmp[j], buffer_out[j], n_samples_to_render );
     420             :     }
     421             : 
     422        7843 :     return;
     423             : }
     424             : 
     425             : 
     426             : /*-------------------------------------------------------------------*
     427             :  * ivas_sba_linear_renderer()
     428             :  *
     429             :  * Linear rendering for SBA format
     430             :  *-------------------------------------------------------------------*/
     431             : 
     432       64450 : ivas_error ivas_sba_linear_renderer(
     433             :     float *output_f[],                   /* i/o: synthesized core-coder transport channels/DirAC output  */
     434             :     const int16_t output_frame,          /* i  : output frame length per channel                         */
     435             :     const int16_t nchan_in,              /* i  : number of input ambisonics channels                     */
     436             :     const int16_t nchan_ism,             /* i  : number of objects                                      */
     437             :     const AUDIO_CONFIG output_config,    /* i  : output audio configuration                              */
     438             :     const IVAS_OUTPUT_SETUP output_setup /* i  : output format setup                                     */
     439             : )
     440             : {
     441             :     int16_t i;
     442             :     int16_t nchan_hoa;
     443             :     ivas_error error;
     444             : 
     445       64450 :     error = IVAS_ERR_OK;
     446             : 
     447             :     /* Number of channels of HOA depends of transport format which is mixed order xH1V*/
     448       64450 :     nchan_hoa = nchan_in;
     449             : 
     450       64450 :     if ( nchan_in == 6 ) /*2H1V*/
     451             :     {
     452           0 :         nchan_hoa = 9;
     453             :     }
     454       64450 :     else if ( nchan_in == 8 ) /*3H1V*/
     455             :     {
     456           0 :         nchan_hoa = 16;
     457             :     }
     458             : 
     459       64450 :     switch ( output_config )
     460             :     {
     461       57302 :         case IVAS_AUDIO_CONFIG_FOA:  /* Ambisonics output, order: 1 */
     462             :         case IVAS_AUDIO_CONFIG_HOA2: /* Ambisonics output, order: 2 */
     463             :         case IVAS_AUDIO_CONFIG_HOA3: /* Ambisonics output, order: 3 */
     464       57302 :             for ( i = nchan_hoa; i < output_setup.nchan_out_woLFE; i++ )
     465             :             {
     466           0 :                 set_zero( output_f[i], output_frame );
     467             :             }
     468       57302 :             break;
     469        7148 :         case IVAS_AUDIO_CONFIG_EXTERNAL:
     470       81816 :             for ( i = output_setup.nchan_out_woLFE - 1; i >= nchan_ism; i-- )
     471             :             {
     472       74668 :                 mvr2r( output_f[i - nchan_ism], output_f[i], output_frame );
     473             :             }
     474        7148 :             for ( ; i >= 0; i-- )
     475             :             {
     476           0 :                 set_zero( output_f[i], output_frame );
     477             :             }
     478        7148 :             break;
     479           0 :         default:
     480           0 :             return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: illegal output configuration, Exiting.\n" );
     481             :     }
     482             : 
     483       64450 :     return error;
     484             : }
     485             : 
     486             : 
     487             : /*-------------------------------------------------------------------*
     488             :  * ivas_sba_mix_matrix_determiner()
     489             :  *
     490             :  * Determine SBA mixing matrices
     491             :  *-------------------------------------------------------------------*/
     492             : 
     493       56153 : void ivas_sba_mix_matrix_determiner(
     494             :     SPAR_DEC_HANDLE hSpar,          /* i/o: SPAR decoder handle                 */
     495             :     float *output[],                /* i/o: transport/output audio channels     */
     496             :     const int16_t bfi,              /* i  : BFI flag                            */
     497             :     const int16_t nchan_remapped,   /* i  : num channels after remapping of TCs */
     498             :     const int16_t output_frame,     /* i  : output frame length                 */
     499             :     const int16_t num_md_sub_frames /* i  : number of subframes in mixing matrix*/
     500             : )
     501             : {
     502             :     int16_t i, ch;
     503             :     float temp;
     504             :     int16_t num_bands_out, nchan_transport, nchan_out;
     505             : 
     506             :     /* Convert numeric range */
     507      151382 :     for ( ch = 0; ch < nchan_remapped; ch++ )
     508             :     {
     509    75404669 :         for ( i = 0; i < output_frame; i++ )
     510             :         {
     511    75309440 :             temp = output[ch][i];
     512    75309440 :             temp = floorf( temp + 0.5f );
     513             : 
     514    75309440 :             if ( temp > MAX16B_FLT )
     515             :             {
     516           7 :                 temp = MAX16B_FLT;
     517             :             }
     518    75309433 :             else if ( temp < ( -1.0f * PCM16_TO_FLT_FAC ) )
     519             :             {
     520           1 :                 temp = ( -1.0f * PCM16_TO_FLT_FAC );
     521             :             }
     522    75309440 :             temp *= ( 1.0f / PCM16_TO_FLT_FAC );
     523    75309440 :             output[ch][i] = temp;
     524             :         }
     525             :     }
     526             : 
     527             :     /* AGC */
     528       56153 :     nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
     529       56153 :     nchan_out = nchan_transport;
     530       56153 :     ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame );
     531             : 
     532             :     /* Convert numeric range back */
     533      151382 :     for ( ch = 0; ch < nchan_out; ch++ )
     534             :     {
     535    75404669 :         for ( i = 0; i < output_frame; i++ )
     536             :         {
     537    75309440 :             output[ch][i] = output[ch][i] * PCM16_TO_FLT_FAC;
     538             :         }
     539             :     }
     540             : 
     541             :     /* Mixing matrix determiner */
     542       56153 :     num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
     543       56153 :     ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames );
     544             : 
     545       56153 :     return;
     546             : }
     547             : 
     548             : 
     549             : #ifdef DEBUG_MODE_DIRAC
     550             : /*-----------------------------------------------------------------------*
     551             :  * Debugging function
     552             :  *-----------------------------------------------------------------------*/
     553             : 
     554             : static void debug_mode_dirac(
     555             :     float output[MAX_OUTPUT_CHANNELS][L_FRAME48k],
     556             :     const int16_t nchan_transport,
     557             :     const int16_t output_frame )
     558             : {
     559             :     int16_t i, n;
     560             :     int16_t tmp[L_FRAME48k];
     561             :     char file_name[50] = { 0 };
     562             : 
     563             : #ifdef DEBUG_MODE_DIRAC_NOCORE
     564             :     for ( n = 0; n < nchan_transport; n++ )
     565             :     {
     566             :         sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) );
     567             :         dbgread( tmp, sizeof( int16_t ), output_frame, file_name );
     568             :         for ( i = 0; i < output_frame; i++ )
     569             :         {
     570             :             output[n][i] = (float) ( tmp[i] );
     571             :         }
     572             :     }
     573             : #else
     574             :     for ( n = 0; n < nchan_transport; n++ )
     575             :     {
     576             :         for ( i = 0; i < output_frame; i++ )
     577             :         {
     578             :             tmp[i] = (int16_t) ( output[n][i] + 0.5f );
     579             :         }
     580             : 
     581             :         sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) );
     582             :         dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name );
     583             :     }
     584             : #endif
     585             : 
     586             :     return;
     587             : }
     588             : #endif

Generated by: LCOV version 1.14