LCOV - code coverage report
Current view: top level - lib_rend - ivas_output_init.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 265 275 96.4 %
Date: 2025-05-03 01:55:50 Functions: 4 4 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_fx.h"
      37             : #include "ivas_prot_rend_fx.h"
      38             : #include "ivas_rom_com.h"
      39             : #include "ivas_rom_com_fx.h"
      40             : #include "wmc_auto.h"
      41             : #include "ivas_prot_fx.h"
      42             : /*-------------------------------------------------------------------------*
      43             :  * audioCfg2channels()
      44             :  *
      45             :  * Map Audio configuration to number of channels
      46             :  *-------------------------------------------------------------------------*/
      47             : 
      48             : /*! r: number of audio channels */
      49    14542276 : Word16 audioCfg2channels(
      50             :     AUDIO_CONFIG output_config /* i  : output audio configuration  */
      51             : )
      52             : {
      53             :     Word16 nchan_out;
      54             : 
      55    14542276 :     SWITCH( output_config )
      56             :     {
      57      340495 :         case IVAS_AUDIO_CONFIG_MONO:
      58      340495 :             nchan_out = 1;
      59      340495 :             move16();
      60      340495 :             BREAK;
      61      593867 :         case IVAS_AUDIO_CONFIG_STEREO:
      62      593867 :             nchan_out = 2;
      63      593867 :             move16();
      64      593867 :             BREAK;
      65     1498419 :         case IVAS_AUDIO_CONFIG_5_1:
      66     1498419 :             nchan_out = 6;
      67     1498419 :             move16();
      68     1498419 :             BREAK;
      69      221554 :         case IVAS_AUDIO_CONFIG_7_1:
      70      221554 :             nchan_out = 8;
      71      221554 :             move16();
      72      221554 :             BREAK;
      73       70962 :         case IVAS_AUDIO_CONFIG_5_1_2:
      74       70962 :             nchan_out = 8;
      75       70962 :             move16();
      76       70962 :             BREAK;
      77      109083 :         case IVAS_AUDIO_CONFIG_5_1_4:
      78      109083 :             nchan_out = 10;
      79      109083 :             move16();
      80      109083 :             BREAK;
      81     1151745 :         case IVAS_AUDIO_CONFIG_7_1_4:
      82     1151745 :             nchan_out = 12;
      83     1151745 :             move16();
      84     1151745 :             BREAK;
      85     2767704 :         case IVAS_AUDIO_CONFIG_FOA:
      86     2767704 :             nchan_out = 4;
      87     2767704 :             move16();
      88     2767704 :             BREAK;
      89      378385 :         case IVAS_AUDIO_CONFIG_HOA2:
      90      378385 :             nchan_out = 9;
      91      378385 :             move16();
      92      378385 :             BREAK;
      93     2187511 :         case IVAS_AUDIO_CONFIG_HOA3:
      94     2187511 :             nchan_out = 16;
      95     2187511 :             move16();
      96     2187511 :             BREAK;
      97           0 :         case IVAS_AUDIO_CONFIG_OBA:
      98           0 :             nchan_out = 8;
      99           0 :             move16();
     100           0 :             BREAK;
     101     3875125 :         case IVAS_AUDIO_CONFIG_BINAURAL:
     102             :         case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
     103             :         case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
     104     3875125 :             nchan_out = 2;
     105     3875125 :             move16();
     106     3875125 :             BREAK;
     107      433250 :         case IVAS_AUDIO_CONFIG_ISM1:
     108      433250 :             nchan_out = 1;
     109      433250 :             move16();
     110      433250 :             BREAK;
     111      146395 :         case IVAS_AUDIO_CONFIG_ISM2:
     112      146395 :             nchan_out = 2;
     113      146395 :             move16();
     114      146395 :             BREAK;
     115      175976 :         case IVAS_AUDIO_CONFIG_ISM3:
     116      175976 :             nchan_out = 3;
     117      175976 :             move16();
     118      175976 :             BREAK;
     119      459805 :         case IVAS_AUDIO_CONFIG_ISM4:
     120      459805 :             nchan_out = 4;
     121      459805 :             move16();
     122      459805 :             BREAK;
     123      132000 :         default:
     124      132000 :             IVAS_ERROR( IVAS_ERR_INTERNAL, "Error: illegal output configuration\n" );
     125      132000 :             nchan_out = -1;
     126      132000 :             move16();
     127      132000 :             BREAK;
     128             :     }
     129             : 
     130    14542276 :     return ( nchan_out );
     131             : }
     132             : 
     133             : /*-------------------------------------------------------------------------*
     134             :  * ivas_output_init()
     135             :  *
     136             :  * Initialize and configure IVAS output parameters
     137             :  *-------------------------------------------------------------------------*/
     138        5347 : void ivas_output_init(
     139             :     IVAS_OUTPUT_SETUP *hOutSetup,    /* o  : IVAS output setup structure */
     140             :     const AUDIO_CONFIG output_config /* i  : output audio configuration  */
     141             : )
     142             : {
     143             :     Word16 nchan_out;
     144             : 
     145             :     /* set general default values */
     146        5347 :     hOutSetup->output_config = output_config;
     147        5347 :     move16();
     148        5347 :     hOutSetup->is_loudspeaker_setup = 0;
     149        5347 :     move16();
     150        5347 :     hOutSetup->is_binaural_setup = 0;
     151        5347 :     move16();
     152        5347 :     hOutSetup->ambisonics_order = -1;
     153        5347 :     move16();
     154        5347 :     hOutSetup->separateChannelEnabled = 0;
     155        5347 :     move16();
     156        5347 :     hOutSetup->separateChannelIndex = 0;
     157        5347 :     move16();
     158             : 
     159        5347 :     IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     160             :     {
     161           5 :         hOutSetup->is_loudspeaker_setup = 1;
     162           5 :         move16();
     163             :         /* set in ivas_init_decoder: */
     164             :         /* hOutSetup->ls_azimuth */
     165             :         /* hOutSetup->ls_elevation    */
     166             :         /* hOutSetup->num_lfe         */
     167             :         /* hOutSetup->index_lfe[0]    */
     168             :         /* hOutSetup->is_planar_setup */
     169             :     }
     170             :     ELSE
     171             :     {
     172             :         /* Set default values for all other than custom LS setup */
     173        5342 :         hOutSetup->ls_azimuth_fx = NULL;
     174        5342 :         hOutSetup->ls_elevation_fx = NULL;
     175        5342 :         hOutSetup->num_lfe = 0;
     176        5342 :         move16();
     177        5342 :         hOutSetup->index_lfe[0] = -1;
     178        5342 :         move16();
     179        5342 :         hOutSetup->is_planar_setup = 0;
     180        5342 :         move16();
     181             : 
     182             :         /* set output setup specific values */
     183        5342 :         SWITCH( output_config )
     184             :         {
     185         101 :             case IVAS_AUDIO_CONFIG_MONO:
     186         101 :                 hOutSetup->is_loudspeaker_setup = 1;
     187         101 :                 move16();
     188         101 :                 BREAK;
     189         178 :             case IVAS_AUDIO_CONFIG_STEREO:
     190         178 :                 hOutSetup->is_loudspeaker_setup = 1;
     191         178 :                 move16();
     192         178 :                 hOutSetup->ls_azimuth_fx = ls_azimuth_CICP2_fx;     // Q22
     193         178 :                 hOutSetup->ls_elevation_fx = ls_elevation_CICP2_fx; // Q22
     194         178 :                 BREAK;
     195        1564 :             case IVAS_AUDIO_CONFIG_FOA:
     196        1564 :                 hOutSetup->ambisonics_order = SBA_FOA_ORDER;
     197        1564 :                 move16();
     198        1564 :                 BREAK;
     199          95 :             case IVAS_AUDIO_CONFIG_HOA2:
     200          95 :                 hOutSetup->ambisonics_order = SBA_HOA2_ORDER;
     201          95 :                 move16();
     202          95 :                 BREAK;
     203         444 :             case IVAS_AUDIO_CONFIG_HOA3:
     204         444 :                 hOutSetup->ambisonics_order = SBA_HOA3_ORDER;
     205         444 :                 move16();
     206         444 :                 BREAK;
     207         831 :             case IVAS_AUDIO_CONFIG_5_1:
     208         831 :                 hOutSetup->num_lfe = 1;
     209         831 :                 move16();
     210         831 :                 hOutSetup->index_lfe[0] = 3;
     211         831 :                 move16();
     212         831 :                 hOutSetup->is_loudspeaker_setup = 1;
     213         831 :                 move16();
     214         831 :                 hOutSetup->ls_azimuth_fx = ls_azimuth_CICP6_fx;     // Q22
     215         831 :                 hOutSetup->ls_elevation_fx = ls_elevation_CICP6_fx; // Q22
     216         831 :                 hOutSetup->is_planar_setup = 1;
     217         831 :                 move16();
     218         831 :                 BREAK;
     219          32 :             case IVAS_AUDIO_CONFIG_7_1:
     220          32 :                 hOutSetup->num_lfe = 1;
     221          32 :                 move16();
     222          32 :                 hOutSetup->index_lfe[0] = 3;
     223          32 :                 move16();
     224          32 :                 hOutSetup->is_loudspeaker_setup = 1;
     225          32 :                 move16();
     226          32 :                 hOutSetup->ls_azimuth_fx = ls_azimuth_CICP12_fx;     // Q22
     227          32 :                 hOutSetup->ls_elevation_fx = ls_elevation_CICP12_fx; // Q22
     228          32 :                 hOutSetup->is_planar_setup = 1;
     229          32 :                 move16();
     230          32 :                 BREAK;
     231          34 :             case IVAS_AUDIO_CONFIG_5_1_2:
     232          34 :                 hOutSetup->num_lfe = 1;
     233          34 :                 move16();
     234          34 :                 hOutSetup->index_lfe[0] = 3;
     235          34 :                 move16();
     236          34 :                 hOutSetup->is_loudspeaker_setup = 1;
     237          34 :                 move16();
     238          34 :                 hOutSetup->ls_azimuth_fx = ls_azimuth_CICP14_fx;     // Q22
     239          34 :                 hOutSetup->ls_elevation_fx = ls_elevation_CICP14_fx; // Q22
     240          34 :                 hOutSetup->is_planar_setup = 0;
     241          34 :                 move16();
     242          34 :                 BREAK;
     243          29 :             case IVAS_AUDIO_CONFIG_5_1_4:
     244          29 :                 hOutSetup->num_lfe = 1;
     245          29 :                 move16();
     246          29 :                 hOutSetup->index_lfe[0] = 3;
     247          29 :                 move16();
     248          29 :                 hOutSetup->is_loudspeaker_setup = 1;
     249          29 :                 move16();
     250          29 :                 hOutSetup->ls_azimuth_fx = ls_azimuth_CICP16_fx;     // Q22
     251          29 :                 hOutSetup->ls_elevation_fx = ls_elevation_CICP16_fx; // Q22
     252          29 :                 hOutSetup->is_planar_setup = 0;
     253          29 :                 move16();
     254          29 :                 BREAK;
     255         688 :             case IVAS_AUDIO_CONFIG_7_1_4:
     256         688 :                 hOutSetup->num_lfe = 1;
     257         688 :                 move16();
     258         688 :                 hOutSetup->index_lfe[0] = 3;
     259         688 :                 move16();
     260         688 :                 hOutSetup->is_loudspeaker_setup = 1;
     261         688 :                 move16();
     262         688 :                 hOutSetup->ls_azimuth_fx = ls_azimuth_CICP19_fx;     // Q22
     263         688 :                 hOutSetup->ls_elevation_fx = ls_elevation_CICP19_fx; // Q22
     264         688 :                 hOutSetup->is_planar_setup = 0;
     265         688 :                 move16();
     266         688 :                 BREAK;
     267         801 :             case IVAS_AUDIO_CONFIG_BINAURAL:
     268             :             case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
     269             :             case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
     270             :             case IVAS_AUDIO_CONFIG_ISM1:
     271             :             case IVAS_AUDIO_CONFIG_ISM2:
     272             :             case IVAS_AUDIO_CONFIG_ISM3:
     273             :             case IVAS_AUDIO_CONFIG_ISM4:
     274         801 :                 hOutSetup->is_binaural_setup = 1;
     275         801 :                 move16();
     276        1346 :             case IVAS_AUDIO_CONFIG_EXTERNAL:
     277             :                 /* Default values are used */
     278        1346 :                 BREAK;
     279           0 :             default:
     280           0 :                 return;
     281             :         }
     282             :     }
     283             : 
     284        5347 :     test();
     285        5347 :     IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && NE_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     286             :     {
     287        4797 :         nchan_out = audioCfg2channels( output_config );
     288        4797 :         hOutSetup->nchan_out_woLFE = sub( nchan_out, hOutSetup->num_lfe );
     289        4797 :         move16();
     290             :     }
     291             : 
     292        5347 :     return;
     293             : }
     294             : 
     295             : 
     296             : /*-----------------------------------------------------------------*
     297             :  * ivas_get_nchan_buffers_dec()
     298             :  *
     299             :  * Return number of decoder audio buffers
     300             :  *-----------------------------------------------------------------*/
     301             : 
     302             : /*! r: number of decoder buffers */
     303     3127752 : Word16 ivas_get_nchan_buffers_dec(
     304             :     Decoder_Struct *st_ivas,         /* i/o: IVAS decoder structure                */
     305             :     const Word16 sba_analysis_order, /* i  : SBA order evaluated in SBA decoder    */
     306             :     const Word32 ivas_total_brate    /* i  : total IVAS bitrate                    */
     307             : )
     308             : {
     309             :     Word16 nchan_out_buff;
     310             :     AUDIO_CONFIG output_config;
     311             : 
     312     3127752 :     output_config = st_ivas->hDecoderConfig->output_config;
     313     3127752 :     move16();
     314             : 
     315     3127752 :     nchan_out_buff = MAX_OUTPUT_CHANNELS;
     316     3127752 :     move16();
     317             : 
     318     3127752 :     IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
     319             :     {
     320          10 :         nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
     321          10 :         move16();
     322             :     }
     323     3127742 :     ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
     324             :     {
     325      277212 :         nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS );
     326             :     }
     327     2850530 :     ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
     328             :     {
     329      640956 :         nchan_out_buff = st_ivas->nchan_ism;
     330      640956 :         move16();
     331             : 
     332      640956 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     333             :         {
     334       27018 :             nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
     335             :         }
     336      613938 :         ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     337             :         {
     338      520242 :             nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
     339      520242 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
     340             :         }
     341             :     }
     342     2209574 :     ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
     343             :     {
     344             :         Word16 nchan_internal;
     345     1106275 :         nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
     346     1106275 :         nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
     347     1106275 :         move16();
     348             : 
     349     1106275 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     350             :         {
     351       18018 :             nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
     352             :         }
     353             :         ELSE
     354             :         {
     355     1088257 :             nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
     356     1088257 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
     357             :         }
     358     1106275 :         nchan_out_buff = s_max( nchan_out_buff, nchan_internal );
     359             :     }
     360     1103299 :     ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
     361             :     {
     362      173416 :         nchan_out_buff = CPE_CHANNELS;
     363      173416 :         move16();
     364             : 
     365      173416 :         test();
     366      173416 :         test();
     367      173416 :         test();
     368      173416 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     369             :         {
     370           0 :             nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
     371             :         }
     372      173416 :         ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     373             :         {
     374       65850 :             nchan_out_buff = shl( CPE_CHANNELS, 1 );
     375             :         }
     376      107566 :         ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     377             :         {
     378       92682 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
     379       92682 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
     380             :         }
     381             :     }
     382      929883 :     ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
     383             :     {
     384       49028 :         nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS );
     385             : 
     386       49028 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     387             :         {
     388           0 :             nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
     389             :         }
     390       49028 :         ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     391             :         {
     392       46307 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
     393       46307 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
     394             :         }
     395             :     }
     396      880855 :     ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
     397             :     {
     398             :         Word16 nchan_internal;
     399      444109 :         nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
     400      444109 :         nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport );
     401             : 
     402      444109 :         IF( st_ivas->hMCT != NULL )
     403             :         {
     404      335727 :             nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */
     405             :         }
     406             : 
     407      444109 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     408             :         {
     409           0 :             nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
     410             :         }
     411      444109 :         ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     412             :         {
     413      379863 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
     414      379863 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
     415             : 
     416      379863 :             test();
     417      379863 :             IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) )
     418             :             {
     419       32032 :                 nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */
     420             :             }
     421             :             ELSE
     422             :             {
     423      347831 :                 nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */
     424             :             }
     425             :         }
     426       64246 :         ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     427             :         {
     428       64246 :             nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */
     429             :         }
     430             : 
     431      444109 :         test();
     432      444109 :         IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
     433             :         {
     434      387342 :             nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) );
     435             :         }
     436      444109 :         nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS );
     437             :     }
     438      436746 :     ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
     439             :     {
     440      436746 :         nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
     441             : 
     442      436746 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
     443             :         {
     444       18018 :             nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
     445             :         }
     446             :         ELSE
     447             :         {
     448      418728 :             nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
     449      418728 :             nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
     450             :         }
     451             :     }
     452             : 
     453             : 
     454     3127752 :     return nchan_out_buff;
     455             : }
     456             : 
     457             : /*-------------------------------------------------------------------*
     458             :  * ivas_output_buff_dec()
     459             :  *
     460             :  * Allocate/reallocate output audio buffers
     461             :  *-------------------------------------------------------------------*/
     462        4857 : ivas_error ivas_output_buff_dec_fx(
     463             :     Word32 *p_output_f[],            /* i/o: output audio buffers                       */
     464             :     const Word16 nchan_out_buff_old, /* i  : previous frame number of output channels   */
     465             :     const Word16 nchan_out_buff      /* i  : number of output channels                  */
     466             : )
     467             : {
     468             :     Word16 ch;
     469        4857 :     IF( GT_16( nchan_out_buff, nchan_out_buff_old ) )
     470             :     {
     471        3048 :         FOR( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
     472             :         {
     473             :             /* note: these are intra-frame heap memories */
     474        2554 :             IF( ( p_output_f[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */
     475             :             {
     476           0 :                 return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
     477             :             }
     478             :         }
     479             :     }
     480             :     ELSE
     481             :     {
     482        6834 :         FOR( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ )
     483             :         {
     484        2471 :             free( p_output_f[ch] );
     485        2471 :             p_output_f[ch] = NULL;
     486             :         }
     487             :     }
     488        4857 :     return IVAS_ERR_OK;
     489             : }

Generated by: LCOV version 1.14