LCOV - code coverage report
Current view: top level - lib_enc - ivas_init_enc_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 433b9a9151a9a2d8368e99195fb62f91feaa9e26 Lines: 575 658 87.4 %
Date: 2025-06-29 23:58:00 Functions: 11 11 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 <assert.h>
      34             : #include <stdint.h>
      35             : #include "options.h"
      36             : #include "ivas_cnst.h"
      37             : #include "prot_fx.h"
      38             : #include "ivas_prot_fx.h"
      39             : #include "ivas_stat_enc.h"
      40             : #include "ivas_rom_com.h"
      41             : #include "wmc_auto.h"
      42             : #include "ivas_prot_fx.h"
      43             : #include "prot_fx_enc.h"
      44             : #ifdef DBG_BITSTREAM_ANALYSIS
      45             : #include <string.h>
      46             : #endif
      47             : 
      48             : 
      49             : /*-------------------------------------------------------------------*
      50             :  * ivas_write_format()
      51             :  *
      52             :  * Write IVAS format signaling
      53             :  *-------------------------------------------------------------------*/
      54             : 
      55      422922 : void ivas_write_format_fx(
      56             :     Encoder_Struct *st_ivas /* i/o: IVAS encoder structure   */
      57             : )
      58             : {
      59             :     Word16 ind, nBits, extra_bits;
      60             : 
      61      422922 :     ind = 0;
      62      422922 :     move16();
      63             : 
      64      422922 :     nBits = IVAS_FORMAT_SIGNALING_NBITS;
      65      422922 :     move16();
      66             : 
      67      422922 :     extra_bits = sub( IVAS_FORMAT_SIGNALING_NBITS_EXTENDED, IVAS_FORMAT_SIGNALING_NBITS );
      68             : 
      69      422922 :     switch ( st_ivas->hEncoderConfig->ivas_format )
      70             :     {
      71       72486 :         case STEREO_FORMAT:
      72       72486 :             ind = 0;
      73       72486 :             move16();
      74       72486 :             BREAK;
      75      103826 :         case ISM_FORMAT:
      76      103826 :             ind = 2;
      77      103826 :             move16();
      78      103826 :             IF( GE_32( st_ivas->hEncoderConfig->ivas_total_brate, IVAS_24k4 ) )
      79             :             {
      80       95106 :                 ind = 4;
      81       95106 :                 move16();
      82             : 
      83       95106 :                 nBits = add( nBits, extra_bits ); /* Q0 */
      84             :             }
      85      103826 :             BREAK;
      86       47850 :         case MC_FORMAT:
      87       47850 :             ind = 1;
      88       47850 :             move16();
      89       47850 :             BREAK;
      90      122500 :         case SBA_FORMAT:
      91      122500 :             ind = 6;
      92      122500 :             move16();
      93             : 
      94      122500 :             nBits = add( nBits, extra_bits ); /* Q0 */
      95      122500 :             BREAK;
      96       30626 :         case MASA_FORMAT:
      97       30626 :             ind = 7;
      98       30626 :             move16();
      99             : 
     100       30626 :             nBits = add( nBits, extra_bits ); /* Q0 */
     101       30626 :             BREAK;
     102       10634 :         case MASA_ISM_FORMAT:
     103       10634 :             IF( st_ivas->ism_mode == ISM_MODE_NONE )
     104             :             {
     105        2388 :                 ind = 7; /* send MASA format */
     106        2388 :                 move16();
     107        2388 :                 nBits = add( nBits, extra_bits ); /* Q0 */
     108             :             }
     109             :             ELSE
     110             :             {
     111        8246 :                 ind = 10;
     112        8246 :                 move16();
     113        8246 :                 nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) ); /* Q0 */
     114             :             }
     115       10634 :             BREAK;
     116       35000 :         case SBA_ISM_FORMAT:
     117       35000 :             IF( LT_32( st_ivas->hEncoderConfig->ivas_total_brate, IVAS_24k4 ) )
     118             :             {
     119        2651 :                 ind = 6; /* send SBA format */
     120        2651 :                 move16();
     121        2651 :                 nBits = add( nBits, extra_bits ); /* Q0 */
     122             :             }
     123             :             ELSE
     124             :             {
     125       32349 :                 ind = 11; /* 1011 */
     126       32349 :                 move16();
     127       32349 :                 nBits = add( nBits, add( extra_bits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ) ); /* Q0 */
     128             :             }
     129       35000 :             BREAK;
     130           0 :         default:
     131           0 :             assert( !"Invalid format. Aborting." );
     132             :             BREAK;
     133             :     }
     134             : 
     135      422922 :     IF( st_ivas->hSCE[0] != NULL )
     136             :     {
     137      181118 :         push_indice( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr, IND_IVAS_FORMAT, ind, nBits );
     138             :     }
     139      241804 :     ELSE IF( st_ivas->hCPE[0] != NULL )
     140             :     {
     141      241804 :         push_indice( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr, IND_IVAS_FORMAT, ind, nBits );
     142             :     }
     143             : 
     144      422922 :     return;
     145             : }
     146             : 
     147             : /*-------------------------------------------------------------------*
     148             :  * ivas_write_format_sid()
     149             :  *
     150             :  * Write IVAS format signaling in SID frames
     151             :  *-------------------------------------------------------------------*/
     152             : 
     153        2773 : void ivas_write_format_sid_fx(
     154             :     const IVAS_FORMAT ivas_format, /* i  : IVAS format               */
     155             :     const Word16 element_mode,     /* i  : element bitrate           Q0*/
     156             :     BSTR_ENC_HANDLE hBstr          /* i/o: encoder bitstream handle  */
     157             : )
     158             : {
     159        2773 :     Word16 ind = 0; /* to avoid compilation warning */
     160        2773 :     move16();
     161             : 
     162        2773 :     SWITCH( ivas_format )
     163             :     {
     164        1875 :         case STEREO_FORMAT:
     165        1875 :             IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
     166             :             {
     167         416 :                 ind = SID_MDCT_STEREO;
     168         416 :                 move16();
     169             :             }
     170        1459 :             ELSE IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
     171             :             {
     172        1459 :                 ind = SID_DFT_STEREO;
     173        1459 :                 move16();
     174             :             }
     175             :             ELSE
     176             :             {
     177           0 :                 assert( !"Wrong stereo mode for SID format signaling" );
     178             :             }
     179        1875 :             BREAK;
     180         536 :         case ISM_FORMAT:
     181         536 :             ind = SID_ISM;
     182         536 :             move16();
     183         536 :             BREAK;
     184           0 :         case MC_FORMAT:
     185           0 :             ind = SID_MULTICHANNEL;
     186           0 :             move16();
     187           0 :             BREAK;
     188         171 :         case SBA_FORMAT:
     189         171 :             SWITCH( element_mode )
     190             :             {
     191         110 :                 case IVAS_SCE:
     192         110 :                     ind = SID_SBA_1TC;
     193         110 :                     move16();
     194         110 :                     BREAK;
     195          61 :                 case IVAS_CPE_MDCT:
     196          61 :                     ind = SID_SBA_2TC;
     197          61 :                     move16();
     198          61 :                     BREAK;
     199           0 :                 default:
     200           0 :                     assert( !"Wrong element mode for SBA DTX!" );
     201             :                     BREAK;
     202             :             }
     203         171 :             BREAK;
     204         191 :         case MASA_FORMAT:
     205         191 :             IF( EQ_16( element_mode, IVAS_SCE ) )
     206             :             {
     207         117 :                 ind = SID_MASA_1TC;
     208         117 :                 move16();
     209             :             }
     210             :             ELSE
     211             :             {
     212          74 :                 ind = SID_MASA_2TC;
     213          74 :                 move16();
     214             :             }
     215         191 :             BREAK;
     216           0 :         default:
     217           0 :             assert( !"Reserved SID format symbol written." );
     218             :             BREAK;
     219             :     }
     220             : 
     221        2773 :     push_indice( hBstr, IND_IVAS_FORMAT, ind, SID_FORMAT_NBITS );
     222             : 
     223        2773 :     return;
     224             : }
     225             : 
     226             : /*-------------------------------------------------------------------*
     227             :  * getNumChanAnalysis()
     228             :  *
     229             :  * get number of input channels used for analysis/coding
     230             :  *-------------------------------------------------------------------*/
     231             : 
     232             : /*! r: number of channels to be analysed */
     233      422536 : Word16 getNumChanAnalysis_fx(
     234             :     Encoder_Struct *st_ivas /* i  : IVAS encoder structure              */
     235             : )
     236             : {
     237             :     Word16 n;
     238             : 
     239      422536 :     n = add( st_ivas->nSCE, CPE_CHANNELS * st_ivas->nCPE ); /* Q0 */
     240      422536 :     test();
     241      422536 :     test();
     242      422536 :     test();
     243      422536 :     test();
     244      422536 :     IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) )
     245             :     {
     246      122988 :         n = imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ); /* Q0 */
     247             :     }
     248      299548 :     ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) || EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) )
     249             :     {
     250       21510 :         n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
     251       21510 :         move16();
     252             :     }
     253      278038 :     ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
     254             :     {
     255         800 :         n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
     256         800 :         move16();
     257             :     }
     258      277238 :     ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
     259             :     {
     260       20754 :         n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
     261       20754 :         move16();
     262             :     }
     263      256484 :     ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) )
     264             :     {
     265        9088 :         n = st_ivas->hEncoderConfig->nchan_inp; /* Q0 */
     266        9088 :         move16();
     267             :     }
     268      247396 :     ELSE IF( EQ_32( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) )
     269             :     {
     270       35070 :         n = add( st_ivas->hEncoderConfig->nchan_ism, imult1616( add( st_ivas->sba_analysis_order, 1 ), add( st_ivas->sba_analysis_order, 1 ) ) ); /* Q0 */
     271             :     }
     272             : 
     273      422536 :     return n;
     274             : }
     275             : /*-------------------------------------------------------------------*
     276             :  * copy_encoder_config_fx()
     277             :  *
     278             :  * Copy configuration structrue to the state structrure
     279             :  *-------------------------------------------------------------------*/
     280             : 
     281       23135 : void copy_encoder_config_fx(
     282             :     Encoder_Struct *st_ivas, /* i  : IVAS encoder structure                                     */
     283             :     Encoder_State *st_fx,    /* o  : encoder state structure                            */
     284             :     const Word16 flag_all    /* i  : flag 1==update all, 0=partial update       Q0*/
     285             : )
     286             : {
     287       23135 :     IF( flag_all )
     288             :     {
     289        8252 :         st_fx->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */
     290        8252 :         move32();
     291             : 
     292        8252 :         st_fx->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */
     293        8252 :         move16();
     294        8252 :         st_fx->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */
     295        8252 :         move32();
     296             : 
     297        8252 :         st_fx->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */
     298        8252 :         move16();
     299             : 
     300        8252 :         st_fx->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */
     301        8252 :         move16();
     302             :     }
     303             : 
     304       23135 :     st_fx->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */
     305       23135 :     move16();
     306       23135 :     st_fx->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */
     307       23135 :     move16();
     308             : 
     309       23135 :     st_fx->codec_mode = st_ivas->codec_mode; /* Q0 */
     310       23135 :     move16();
     311       23135 :     st_fx->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */
     312       23135 :     move16();
     313             : 
     314       23135 :     st_fx->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */
     315       23135 :     move16();
     316       23135 :     st_fx->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */
     317       23135 :     move16();
     318       23135 :     st_fx->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */
     319       23135 :     move16();
     320             : 
     321             : #ifdef DEBUGGING
     322             :     st_fx->force = st_ivas->hEncoderConfig->force;
     323             : #ifdef DEBUG_FORCE_DIR
     324             :     st_fx->force_dir = st_ivas->hEncoderConfig->force_dir;
     325             : #endif
     326             : #endif
     327             : 
     328       23135 :     st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */
     329       23135 :     move16();
     330             : 
     331       23135 :     return;
     332             : }
     333             : 
     334             : /*-------------------------------------------------------------------------
     335             :  * ivas_initialize_handles_enc_fx()
     336             :  *
     337             :  * NULL initialization of handles
     338             :  *-------------------------------------------------------------------------*/
     339             : 
     340         624 : void ivas_initialize_handles_enc_fx(
     341             :     Encoder_Struct *st_ivas /* i/o: IVAS encoder structure                  */
     342             : )
     343             : {
     344             :     Word16 i;
     345             : 
     346        3120 :     FOR( i = 0; i < MAX_SCE; i++ )
     347             :     {
     348        2496 :         st_ivas->hSCE[i] = NULL;
     349             :     }
     350             : 
     351        4368 :     FOR( i = 0; i < MAX_CPE; i++ )
     352             :     {
     353        3744 :         st_ivas->hCPE[i] = NULL;
     354             :     }
     355             : 
     356         624 :     st_ivas->mem_hp20_in_fx = NULL;
     357             : 
     358             :     /* ISM metadata handles */
     359        3120 :     FOR( i = 0; i < MAX_NUM_OBJECTS; i++ )
     360             :     {
     361        2496 :         st_ivas->hIsmMetaData[i] = NULL;
     362             :     }
     363             : 
     364             :     /* ISM DTX handle */
     365         624 :     st_ivas->hISMDTX = NULL;
     366             : 
     367             :     /* Q Metadata handle */
     368         624 :     st_ivas->hQMetaData = NULL;
     369             : 
     370             :     /* DirAC handle */
     371         624 :     st_ivas->hDirAC = NULL;
     372             : 
     373             :     /* ParamISM handle */
     374         624 :     st_ivas->hParamIsm = NULL;
     375             :     /* SPAR handle */
     376         624 :     st_ivas->hSpar = NULL;
     377             : 
     378             :     /* MASA encoder handle */
     379         624 :     st_ivas->hMasa = NULL;
     380             : 
     381             :     /* MCT handle */
     382         624 :     st_ivas->hMCT = NULL;
     383             : 
     384             :     /* MC Param-Upmix handle */
     385         624 :     st_ivas->hMCParamUpmix = NULL;
     386             : 
     387             :     /* Parametric MC handle */
     388         624 :     st_ivas->hParamMC = NULL;
     389             : 
     390             :     /* Multi-channel MASA handle */
     391         624 :     st_ivas->hMcMasa = NULL;
     392             : 
     393             :     /* Stereo downmix for EVS encoder handle */
     394         624 :     st_ivas->hStereoDmxEVS = NULL;
     395             : 
     396             :     /* LFE  handle */
     397         624 :     st_ivas->hLFE = NULL;
     398             : 
     399             :     /* LFE low pass filter handle */
     400         624 :     st_ivas->hLfeLpf = NULL;
     401             : 
     402             :     /* Object MASA handle */
     403         624 :     st_ivas->hOMasa = NULL;
     404             : 
     405             :     /* OSBA handle */
     406         624 :     st_ivas->hOSba = NULL;
     407             : 
     408         624 :     return;
     409             : }
     410             : 
     411             : 
     412             : /*-------------------------------------------------------------------*
     413             :  * ivas_init_encoder()
     414             :  *
     415             :  * Initialize IVAS encoder state structure
     416             :  *-------------------------------------------------------------------*/
     417         624 : ivas_error ivas_init_encoder_fx(
     418             :     Encoder_Struct *st_ivas /* i/o: IVAS encoder structure      */
     419             : )
     420             : {
     421             :     Word16 i, n;
     422             :     Word16 nchan_inp_buff;
     423             :     Word16 sce_id, cpe_id;
     424             :     IVAS_FORMAT ivas_format;
     425             :     Word32 input_Fs, ivas_total_brate;
     426             :     Word32 element_brate_tmp[MAX_NUM_OBJECTS];
     427             :     ENCODER_CONFIG_HANDLE hEncoderConfig;
     428             :     ivas_error error;
     429             : 
     430         624 :     error = IVAS_ERR_OK;
     431         624 :     move32();
     432             : 
     433         624 :     hEncoderConfig = st_ivas->hEncoderConfig;
     434         624 :     ivas_format = hEncoderConfig->ivas_format;
     435         624 :     move32();
     436         624 :     input_Fs = hEncoderConfig->input_Fs; /* Q0 */
     437         624 :     move32();
     438         624 :     ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */
     439         624 :     move32();
     440             : 
     441         624 :     hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */
     442         624 :     move32();
     443             : 
     444         624 :     if ( NE_16( ivas_format, MONO_FORMAT ) )
     445             :     {
     446             :         /* In IVAS, ensure that minimum coded bandwidth is WB */
     447         621 :         hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */
     448         621 :         move16();
     449             :     }
     450         624 :     st_ivas->ism_mode = ISM_MODE_NONE;
     451         624 :     move32();
     452         624 :     st_ivas->mc_mode = MC_MODE_NONE;
     453         624 :     move32();
     454             : 
     455         624 :     st_ivas->nchan_transport = -1;
     456         624 :     move16();
     457             : 
     458             :     /*-----------------------------------------------------------------*
     459             :      * Allocate floating-point input audio buffers
     460             :      *-----------------------------------------------------------------*/
     461             : 
     462         624 :     nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */
     463         624 :     move16();
     464         624 :     IF( EQ_16( ivas_format, MONO_FORMAT ) )
     465             :     {
     466           3 :         nchan_inp_buff = 0;
     467           3 :         move16();
     468             :     }
     469         621 :     ELSE IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) )
     470             :     {
     471          44 :         IF( EQ_16( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */
     472             :         {
     473          12 :             nchan_inp_buff = add( nchan_inp_buff, 1 ); /* Q0 */
     474             :         }
     475             : 
     476          44 :         nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object        Q0*/
     477             :     }
     478             : 
     479        4278 :     FOR( n = 0; n < nchan_inp_buff; n++ )
     480             :     {
     481             :         /* note: these are intra-frame heap memories */
     482        3654 :         IF( ( st_ivas->p_data_fx[n] = (Word32 *) malloc( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) * sizeof( Word32 ) ) ) == NULL )
     483             :         {
     484           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) );
     485             :         }
     486        3654 :         set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) );
     487             :     }
     488         624 :     st_ivas->q_data_fx = Q11;
     489         624 :     move16();
     490        9450 :     FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
     491             :     {
     492        8826 :         st_ivas->p_data_fx[n] = NULL;
     493             :     }
     494             : 
     495             : 
     496             :     /*-----------------------------------------------------------------*
     497             :      * Allocate and initialize buffer of indices
     498             :      *-----------------------------------------------------------------*/
     499             : 
     500             :     /* set the maximum allowed number of indices in the list */
     501         624 :     st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */
     502         624 :     move16();
     503             : 
     504             :     /* allocate buffer of indices */
     505         624 :     IF( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL )
     506             :     {
     507           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) );
     508             :     }
     509             : 
     510             :     /* reset the list of indices */
     511      495014 :     FOR( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
     512             :     {
     513      494390 :         st_ivas->ind_list[i].nb_bits = -1;
     514      494390 :         move16();
     515             :     }
     516             : 
     517             : #ifdef BITSTERAM_ANALYSIS
     518             :     for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ )
     519             :     {
     520             :         memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) );
     521             :     }
     522             : #endif
     523             : 
     524             :     /* set the maximum allowed number of metadata indices in the list */
     525         624 :     st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */
     526         624 :     move16();
     527             :     /* allocate buffer of metadata indices */
     528         624 :     IF( st_ivas->ivas_max_num_indices_metadata > 0 )
     529             :     {
     530         621 :         IF( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL )
     531             :         {
     532           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of metadata indices!\n" ) );
     533             :         }
     534             : 
     535             :         /* reset the list of metadata indices */
     536      248661 :         FOR( i = 0; i < st_ivas->ivas_max_num_indices_metadata; i++ )
     537             :         {
     538      248040 :             st_ivas->ind_list_metadata[i].nb_bits = -1;
     539      248040 :             move16();
     540             :         }
     541             :     }
     542             :     ELSE
     543             :     {
     544           3 :         st_ivas->ind_list_metadata = NULL;
     545             :     }
     546             : 
     547             :     /*-----------------------------------------------------------------*
     548             :      * Allocate and initialize SCE/CPE and other handles
     549             :      *-----------------------------------------------------------------*/
     550             : 
     551         624 :     IF( EQ_32( ivas_format, MONO_FORMAT ) )
     552             :     {
     553           3 :         st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
     554           3 :         move16();
     555           3 :         st_ivas->nCPE = 0;
     556           3 :         move16();
     557           3 :         st_ivas->nchan_transport = 1;
     558           3 :         move16();
     559           3 :         sce_id = 0;
     560           3 :         move16();
     561             : #ifndef HARM_SCE_INIT
     562           3 :         test();
     563           3 :         IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
     564             :         {
     565           0 :             return error;
     566             :         }
     567             : #else
     568             :         test();
     569             :         IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
     570             :         {
     571             :             return error;
     572             :         }
     573             : #endif
     574             :         /* prepare stereo downmix for EVS */
     575           3 :         IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) )
     576             :         {
     577           2 :             IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK )
     578             :             {
     579           0 :                 return error;
     580             :             }
     581             :         }
     582             :     }
     583         621 :     ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) )
     584             :     {
     585          68 :         st_ivas->nSCE = 0;
     586          68 :         move16();
     587          68 :         st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
     588          68 :         move16();
     589          68 :         st_ivas->nchan_transport = CPE_CHANNELS;
     590          68 :         move16();
     591          68 :         cpe_id = 0;
     592          68 :         move16();
     593             : 
     594          68 :         IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
     595             :         {
     596           0 :             return error;
     597             :         }
     598             :     }
     599         553 :     ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) )
     600             :     {
     601          74 :         st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); /* Q0 */
     602          74 :         move32();
     603             : 
     604          74 :         IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK )
     605             :         {
     606           0 :             return error;
     607             :         }
     608             : 
     609         261 :         FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
     610             :         {
     611         187 :             IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
     612             :             {
     613           0 :                 return error;
     614             :             }
     615             :         }
     616             : 
     617          74 :         IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
     618             :         {
     619          17 :             IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     620             :             {
     621           0 :                 return error;
     622             :             }
     623             :         }
     624             : 
     625          74 :         IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
     626             :         {
     627          14 :             IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK )
     628             :             {
     629           0 :                 return error;
     630             :             }
     631             :         }
     632             :     }
     633         479 :     ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) )
     634             :     {
     635         319 :         IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
     636             :         {
     637           0 :             return error;
     638             :         }
     639             : 
     640         319 :         IF( EQ_32( ivas_format, SBA_FORMAT ) )
     641             :         {
     642         244 :             st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
     643         244 :             move16();
     644             : 
     645         244 :             IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
     646             :             {
     647           0 :                 return error;
     648             :             }
     649         244 :             IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     650             :             {
     651           0 :                 return error;
     652             :             }
     653             :         }
     654             :         ELSE
     655             :         {
     656          75 :             st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */
     657          75 :             move16();
     658             : 
     659          75 :             IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     660             :             {
     661           0 :                 return error;
     662             :             }
     663             :         }
     664             : 
     665         449 :         FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
     666             :         {
     667             :             Word32 res_dec, res_frac;
     668         130 :             iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
     669         130 :             IF( ( error = create_sce_enc_fx( st_ivas, sce_id, res_dec ) ) != IVAS_ERR_OK )
     670             :             {
     671           0 :                 return error;
     672             :             }
     673         130 :             test();
     674         130 :             IF( EQ_16( ivas_format, SBA_FORMAT ) && st_ivas->hEncoderConfig->Opt_DTX_ON )
     675             :             {
     676          45 :                 st_ivas->hSCE[sce_id]->hCoreCoder[0]->dtx_sce_sba = 1;
     677          45 :                 move16();
     678             :             }
     679             :         }
     680             : 
     681         591 :         FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     682             :         {
     683             :             Word32 res_dec, res_frac;
     684         272 :             iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
     685         272 :             IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
     686             :             {
     687           0 :                 return error;
     688             :             }
     689             : 
     690         816 :             FOR( n = 0; n < CPE_CHANNELS; n++ )
     691             :             {
     692         544 :                 if ( hEncoderConfig->Opt_DTX_ON )
     693             :                 {
     694          56 :                     st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1;
     695          56 :                     move16();
     696             :                 }
     697             :             }
     698             :         }
     699             : 
     700         319 :         IF( GT_16( st_ivas->nCPE, 1 ) )
     701             :         {
     702          83 :             IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
     703             :             {
     704           0 :                 return error;
     705             :             }
     706             :         }
     707             :     }
     708         160 :     ELSE IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) )
     709             :     {
     710             :         Word32 ism_total_brate;
     711             :         Word16 k;
     712             : 
     713          44 :         st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */
     714          44 :         move32();
     715          44 :         st_ivas->nchan_transport = 2;
     716          44 :         move16();
     717             : 
     718          44 :         IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
     719             :         {
     720           0 :             return error;
     721             :         }
     722             : 
     723          44 :         k = 0;
     724          44 :         move16();
     725          44 :         test();
     726         359 :         WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
     727             :         {
     728         315 :             k++;
     729             :         }
     730             : 
     731          44 :         ism_total_brate = 0;
     732          44 :         move32();
     733         111 :         FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
     734             :         {
     735          67 :             ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] ); /* Q0 */
     736          67 :             IF( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK )
     737             :             {
     738           0 :                 return error;
     739             :             }
     740             :         }
     741             : 
     742          44 :         IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
     743             :         {
     744           0 :             return error;
     745             :         }
     746          44 :         IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     747             :         {
     748           0 :             return error;
     749             :         }
     750             : 
     751          44 :         IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
     752             :         {
     753          27 :             IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     754             :             {
     755           0 :                 return error;
     756             :             }
     757             :         }
     758             : 
     759          44 :         IF( GE_32( L_sub( ivas_total_brate, ism_total_brate ), MIN_BRATE_MDCT_STEREO ) )
     760             :         {
     761          17 :             st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
     762          17 :             move16();
     763             :         }
     764             :         ELSE
     765             :         {
     766          27 :             st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_DFT;
     767          27 :             move16();
     768             :         }
     769             : 
     770          44 :         IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK )
     771             :         {
     772           0 :             return error;
     773             :         }
     774             :     }
     775         116 :     ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
     776             :     {
     777          35 :         st_ivas->ism_mode = ISM_MODE_NONE;
     778          35 :         move16();
     779             : 
     780          35 :         IF( GE_32( ivas_total_brate, IVAS_256k ) )
     781             :         {
     782          15 :             st_ivas->ism_mode = ISM_SBA_MODE_DISC;
     783          15 :             move16();
     784             :         }
     785             : 
     786          35 :         IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
     787             :         {
     788           0 :             return error;
     789             :         }
     790             : 
     791             :         /* allocate and initialize SBA handles */
     792          35 :         IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
     793             :         {
     794           0 :             return error;
     795             :         }
     796             : 
     797          35 :         st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */
     798             : 
     799          35 :         IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
     800             :         {
     801           0 :             return error;
     802             :         }
     803             : 
     804          35 :         IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     805             :         {
     806           0 :             return error;
     807             :         }
     808             : 
     809          35 :         IF( EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) )
     810             :         {
     811             :             /* allocate and initialize SBA core-coders */
     812          20 :             IF( EQ_16( st_ivas->nchan_transport, 1 ) )
     813             :             {
     814          11 :                 IF( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK )
     815             :                 {
     816           0 :                     return error;
     817             :                 }
     818             :             }
     819             : 
     820          34 :             FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     821             :             {
     822             :                 Word32 res_dec, res_frac;
     823          14 :                 iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
     824          14 :                 IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
     825             :                 {
     826           0 :                     return error;
     827             :                 }
     828             :             }
     829             : 
     830          20 :             IF( GT_16( st_ivas->nCPE, 1 ) )
     831             :             {
     832           5 :                 IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
     833             :                 {
     834           0 :                     return error;
     835             :                 }
     836             :             }
     837             :         }
     838             :         ELSE
     839             :         {
     840             :             /* allocate and initialize MCT core coder */
     841          15 :             st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); /* Q0 */
     842             : 
     843          70 :             FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     844             :             {
     845             :                 Word32 res_dec, res_frac;
     846          55 :                 iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 );
     847          55 :                 IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
     848             :                 {
     849           0 :                     return error;
     850             :                 }
     851             :             }
     852             : 
     853          15 :             IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
     854             :             {
     855           0 :                 return error;
     856             :             }
     857             :         }
     858          35 :         IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     859             :         {
     860           0 :             return error;
     861             :         }
     862             :     }
     863          81 :     ELSE IF( EQ_32( ivas_format, MC_FORMAT ) )
     864             :     {
     865          81 :         st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */
     866          81 :         move32();
     867             : 
     868          81 :         IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
     869             :         {
     870           0 :             return error;
     871             :         }
     872             : 
     873          81 :         IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
     874             :         {
     875          36 :             st_ivas->nSCE = 0;
     876          36 :             move16();
     877          36 :             st_ivas->nCPE = shr( hEncoderConfig->nchan_inp, CPE_CHANNELS_LOG2 ); /* Q0 */
     878          36 :             move16();
     879             : 
     880         181 :             FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     881             :             {
     882             :                 Word32 res_dec, res_frac;
     883         145 :                 iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 );
     884         145 :                 IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
     885             :                 {
     886           0 :                     return error;
     887             :                 }
     888             :             }
     889             : 
     890          36 :             IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
     891             :             {
     892           0 :                 return error;
     893             :             }
     894             : 
     895          36 :             IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
     896             :             {
     897           0 :                 return error;
     898             :             }
     899             : 
     900          36 :             st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */
     901          36 :             move16();
     902             :         }
     903          45 :         ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
     904             :         {
     905           5 :             st_ivas->nSCE = 0;
     906           5 :             move16();
     907           5 :             st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS >> 1;
     908           5 :             move16();
     909           5 :             st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
     910           5 :             move16();
     911             : 
     912           5 :             IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     913             :             {
     914           0 :                 return error;
     915             :             }
     916             : 
     917          25 :             FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     918             :             {
     919             :                 Word32 res_dec, res_frac;
     920          20 :                 iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 );
     921          20 :                 IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
     922             :                 {
     923           0 :                     return error;
     924             :                 }
     925             :             }
     926             : 
     927           5 :             IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
     928             :             {
     929           0 :                 return error;
     930             :             }
     931             : 
     932           5 :             IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
     933             :             {
     934           0 :                 return error;
     935             :             }
     936             :         }
     937          40 :         ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
     938             :         {
     939          10 :             IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     940             :             {
     941           0 :                 return error;
     942             :             }
     943             : 
     944          20 :             FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     945             :             {
     946             :                 Word32 res_dec, res_frac;
     947          10 :                 iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 );
     948          10 :                 IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK )
     949             :                 {
     950           0 :                     return error;
     951             :                 }
     952             :             }
     953             : 
     954          10 :             IF( GT_16( st_ivas->nCPE, 1 ) )
     955             :             {
     956           0 :                 IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK )
     957             :                 {
     958           0 :                     return error;
     959             :                 }
     960             :             }
     961             :         }
     962          30 :         ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
     963             :         {
     964             :             Word32 brate_sce, brate_cpe;
     965             : 
     966          30 :             ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate );
     967             : 
     968          30 :             IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
     969             :             {
     970           0 :                 return error;
     971             :             }
     972             : 
     973          30 :             IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     974             :             {
     975           0 :                 return error;
     976             :             }
     977             : 
     978          30 :             IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK )
     979             :             {
     980           0 :                 return error;
     981             :             }
     982          30 :             ivas_mcmasa_split_brate_fx( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe );
     983             : 
     984          58 :             FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
     985             :             {
     986          28 :                 IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK )
     987             :                 {
     988           0 :                     return error;
     989             :                 }
     990             :             }
     991             : 
     992          35 :             FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
     993             :             {
     994           5 :                 hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; /* Q0 */
     995           5 :                 move16();
     996             : 
     997           5 :                 IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
     998             :                 {
     999           0 :                     return error;
    1000             :                 }
    1001             :             }
    1002             :         }
    1003             :     }
    1004             : 
    1005             :     /*-----------------------------------------------------------------*
    1006             :      * Allocate and initialize HP20 filter memories
    1007             :      *-----------------------------------------------------------------*/
    1008             : 
    1009             :     /* set number of input channels used for analysis/coding */
    1010         624 :     n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
    1011         624 :     move16();
    1012             : 
    1013         624 :     IF( n > 0 )
    1014             :     {
    1015         624 :         IF( ( st_ivas->mem_hp20_in_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
    1016             :         {
    1017           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
    1018             :         }
    1019             :     }
    1020             :     ELSE
    1021             :     {
    1022           0 :         st_ivas->mem_hp20_in_fx = NULL;
    1023             :     }
    1024             : 
    1025        3380 :     FOR( i = 0; i < n; i++ )
    1026             :     {
    1027        2756 :         IF( ( st_ivas->mem_hp20_in_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
    1028             :         {
    1029           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
    1030             :         }
    1031             : 
    1032        2756 :         set32_fx( st_ivas->mem_hp20_in_fx[i], 0, L_HP20_MEM + 2 );
    1033             :     }
    1034             : 
    1035         624 :     return error;
    1036             : }
    1037             : /*-------------------------------------------------------------------------
    1038             :  * destroy_core_enc()
    1039             :  *
    1040             :  * Close core encoder handles
    1041             :  *-------------------------------------------------------------------------*/
    1042             : 
    1043        8252 : void destroy_core_enc_fx(
    1044             :     ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure      */
    1045             : )
    1046             : {
    1047             :     Word16 i;
    1048             : 
    1049        8252 :     destroy_cldfb_encoder_fx( hCoreCoder );
    1050             : 
    1051        8252 :     IF( hCoreCoder->hSignalBuf != NULL )
    1052             :     {
    1053        8183 :         free( hCoreCoder->hSignalBuf );
    1054        8183 :         hCoreCoder->hSignalBuf = NULL;
    1055             :     }
    1056             : 
    1057        8252 :     IF( hCoreCoder->hBstr != NULL )
    1058             :     {
    1059             :         /* reset buffer of indices */
    1060        8183 :         FOR( i = 0; i < hCoreCoder->hBstr->nb_ind_tot; i++ )
    1061             :         {
    1062           0 :             hCoreCoder->hBstr->ind_list[i].nb_bits = -1;
    1063           0 :             move16();
    1064             :         }
    1065        8183 :         free( hCoreCoder->hBstr );
    1066        8183 :         hCoreCoder->hBstr = NULL;
    1067             :     }
    1068             : 
    1069        8252 :     IF( hCoreCoder->hLPDmem != NULL )
    1070             :     {
    1071        3042 :         free( hCoreCoder->hLPDmem );
    1072        3042 :         hCoreCoder->hLPDmem = NULL;
    1073             :     }
    1074             : 
    1075        8252 :     IF( hCoreCoder->hTranDet != NULL )
    1076             :     {
    1077        8183 :         free( hCoreCoder->hTranDet );
    1078        8183 :         hCoreCoder->hTranDet = NULL;
    1079             :     }
    1080             : 
    1081        8252 :     IF( hCoreCoder->hNoiseEst != NULL )
    1082             :     {
    1083        8171 :         free( hCoreCoder->hNoiseEst );
    1084        8171 :         hCoreCoder->hNoiseEst = NULL;
    1085             :     }
    1086             : 
    1087        8252 :     IF( hCoreCoder->hVAD != NULL )
    1088             :     {
    1089        8102 :         free( hCoreCoder->hVAD );
    1090        8102 :         hCoreCoder->hVAD = NULL;
    1091             :     }
    1092             : 
    1093        8252 :     IF( hCoreCoder->hVAD_CLDFB != NULL )
    1094             :     {
    1095             :         /* This is not required as we are not allocating memory dynamically */
    1096             :         // free( hCoreCoder->hVAD_CLDFB );
    1097           0 :         hCoreCoder->hVAD_CLDFB = NULL;
    1098             :     }
    1099             : 
    1100        8252 :     IF( hCoreCoder->hTdCngEnc != NULL )
    1101             :     {
    1102          85 :         free( hCoreCoder->hTdCngEnc );
    1103          85 :         hCoreCoder->hTdCngEnc = NULL;
    1104             :     }
    1105             : 
    1106        8252 :     IF( hCoreCoder->hDtxEnc != NULL )
    1107             :     {
    1108         488 :         free( hCoreCoder->hDtxEnc );
    1109         488 :         hCoreCoder->hDtxEnc = NULL;
    1110             :     }
    1111             : 
    1112        8252 :     IF( hCoreCoder->hSpMusClas != NULL )
    1113             :     {
    1114        8171 :         free( hCoreCoder->hSpMusClas );
    1115        8171 :         hCoreCoder->hSpMusClas = NULL;
    1116             :     }
    1117             : 
    1118        8252 :     IF( hCoreCoder->hGSCEnc != NULL )
    1119             :     {
    1120        3042 :         free( hCoreCoder->hGSCEnc );
    1121        3042 :         hCoreCoder->hGSCEnc = NULL;
    1122             :     }
    1123             : 
    1124        8252 :     IF( hCoreCoder->hSC_VBR != NULL )
    1125             :     {
    1126           0 :         free( hCoreCoder->hSC_VBR );
    1127           0 :         hCoreCoder->hSC_VBR = NULL;
    1128             :     }
    1129             : 
    1130        8252 :     IF( hCoreCoder->hAmrwb_IO != NULL )
    1131             :     {
    1132           0 :         free( hCoreCoder->hAmrwb_IO );
    1133           0 :         hCoreCoder->hAmrwb_IO = NULL;
    1134             :     }
    1135             : 
    1136        8252 :     IF( hCoreCoder->hBWE_TD != NULL )
    1137             :     {
    1138        3041 :         free( hCoreCoder->hBWE_TD );
    1139        3041 :         hCoreCoder->hBWE_TD = NULL;
    1140             :     }
    1141             : 
    1142        8252 :     IF( hCoreCoder->hBWE_FD != NULL )
    1143             :     {
    1144        3041 :         free( hCoreCoder->hBWE_FD );
    1145        3041 :         hCoreCoder->hBWE_FD = NULL;
    1146             :     }
    1147             : 
    1148        8252 :     IF( hCoreCoder->hRF != NULL )
    1149             :     {
    1150           0 :         free( hCoreCoder->hRF );
    1151           0 :         hCoreCoder->hRF = NULL;
    1152             :     }
    1153             : 
    1154        8252 :     IF( hCoreCoder->hTECEnc != NULL )
    1155             :     {
    1156           0 :         free( hCoreCoder->hTECEnc );
    1157           0 :         hCoreCoder->hTECEnc = NULL;
    1158             :     }
    1159             : 
    1160        8252 :     IF( hCoreCoder->hTcxEnc != NULL )
    1161             :     {
    1162        8101 :         free( hCoreCoder->hTcxEnc );
    1163        8101 :         hCoreCoder->hTcxEnc = NULL;
    1164             :     }
    1165             : 
    1166        8252 :     IF( hCoreCoder->hTcxCfg != NULL )
    1167             :     {
    1168        8101 :         free( hCoreCoder->hTcxCfg );
    1169        8101 :         hCoreCoder->hTcxCfg = NULL;
    1170             :     }
    1171             : 
    1172        8252 :     IF( hCoreCoder->hIGFEnc != NULL )
    1173             :     {
    1174        6382 :         free( hCoreCoder->hIGFEnc );
    1175        6382 :         hCoreCoder->hIGFEnc = NULL;
    1176             :     }
    1177             : 
    1178        8252 :     IF( hCoreCoder->hPlcExt != NULL )
    1179             :     {
    1180           0 :         free( hCoreCoder->hPlcExt );
    1181           0 :         hCoreCoder->hPlcExt = NULL;
    1182             :     }
    1183             : 
    1184        8252 :     IF( hCoreCoder->hHQ_core != NULL )
    1185             :     {
    1186        3061 :         free( hCoreCoder->hHQ_core );
    1187        3061 :         hCoreCoder->hHQ_core = NULL;
    1188             :     }
    1189             : 
    1190        8252 :     free( hCoreCoder );
    1191             : 
    1192        8252 :     return;
    1193             : }
    1194             : 
    1195           3 : void destroy_evs_core_enc_fx(
    1196             :     ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure      */
    1197             : )
    1198             : {
    1199             :     Word16 i;
    1200             : 
    1201           3 :     destroy_encoder_fx( hCoreCoder );
    1202             : 
    1203           3 :     IF( hCoreCoder->hSignalBuf != NULL )
    1204             :     {
    1205           3 :         free( hCoreCoder->hSignalBuf );
    1206           3 :         hCoreCoder->hSignalBuf = NULL;
    1207             :     }
    1208             : 
    1209           3 :     IF( hCoreCoder->hBstr != NULL )
    1210             :     {
    1211             :         /* reset buffer of indices */
    1212           3 :         FOR( i = 0; i < hCoreCoder->hBstr->nb_ind_tot; i++ )
    1213             :         {
    1214           0 :             hCoreCoder->hBstr->ind_list[i].nb_bits = -1;
    1215           0 :             move16();
    1216             :         }
    1217           3 :         free( hCoreCoder->hBstr );
    1218           3 :         hCoreCoder->hBstr = NULL;
    1219             :     }
    1220             : 
    1221           3 :     IF( hCoreCoder->hLPDmem != NULL )
    1222             :     {
    1223           3 :         free( hCoreCoder->hLPDmem );
    1224           3 :         hCoreCoder->hLPDmem = NULL;
    1225             :     }
    1226             : 
    1227           3 :     IF( hCoreCoder->hTranDet != NULL )
    1228             :     {
    1229           0 :         free( hCoreCoder->hTranDet );
    1230           0 :         hCoreCoder->hTranDet = NULL;
    1231             :     }
    1232             : 
    1233           3 :     IF( hCoreCoder->hNoiseEst != NULL )
    1234             :     {
    1235           3 :         free( hCoreCoder->hNoiseEst );
    1236           3 :         hCoreCoder->hNoiseEst = NULL;
    1237             :     }
    1238             : 
    1239           3 :     IF( hCoreCoder->hVAD != NULL )
    1240             :     {
    1241           3 :         free( hCoreCoder->hVAD );
    1242           3 :         hCoreCoder->hVAD = NULL;
    1243             :     }
    1244             : 
    1245           3 :     IF( hCoreCoder->hVAD_CLDFB != NULL )
    1246             :     {
    1247             :         /* This is not required as we are not allocating memory dynamically */
    1248             :         // free( hCoreCoder->hVAD_CLDFB );
    1249           0 :         hCoreCoder->hVAD_CLDFB = NULL;
    1250             :     }
    1251             : 
    1252           3 :     IF( hCoreCoder->hTdCngEnc != NULL )
    1253             :     {
    1254           3 :         free( hCoreCoder->hTdCngEnc );
    1255           3 :         hCoreCoder->hTdCngEnc = NULL;
    1256             :     }
    1257             : 
    1258           3 :     IF( hCoreCoder->hDtxEnc != NULL )
    1259             :     {
    1260           3 :         free( hCoreCoder->hDtxEnc );
    1261           3 :         hCoreCoder->hDtxEnc = NULL;
    1262             :     }
    1263             : 
    1264           3 :     IF( hCoreCoder->hSpMusClas != NULL )
    1265             :     {
    1266           3 :         free( hCoreCoder->hSpMusClas );
    1267           3 :         hCoreCoder->hSpMusClas = NULL;
    1268             :     }
    1269             : 
    1270           3 :     IF( hCoreCoder->hGSCEnc != NULL )
    1271             :     {
    1272           3 :         free( hCoreCoder->hGSCEnc );
    1273           3 :         hCoreCoder->hGSCEnc = NULL;
    1274             :     }
    1275             : 
    1276           3 :     IF( hCoreCoder->hSC_VBR != NULL )
    1277             :     {
    1278           3 :         free( hCoreCoder->hSC_VBR );
    1279           3 :         hCoreCoder->hSC_VBR = NULL;
    1280             :     }
    1281             : 
    1282           3 :     IF( hCoreCoder->hAmrwb_IO != NULL )
    1283             :     {
    1284           3 :         free( hCoreCoder->hAmrwb_IO );
    1285           3 :         hCoreCoder->hAmrwb_IO = NULL;
    1286             :     }
    1287             : 
    1288           3 :     IF( hCoreCoder->hBWE_TD != NULL )
    1289             :     {
    1290           3 :         free( hCoreCoder->hBWE_TD );
    1291           3 :         hCoreCoder->hBWE_TD = NULL;
    1292             :     }
    1293             : 
    1294           3 :     IF( hCoreCoder->hBWE_FD != NULL )
    1295             :     {
    1296           3 :         free( hCoreCoder->hBWE_FD );
    1297           3 :         hCoreCoder->hBWE_FD = NULL;
    1298             :     }
    1299             : 
    1300           3 :     IF( hCoreCoder->hRF != NULL )
    1301             :     {
    1302           3 :         free( hCoreCoder->hRF );
    1303           3 :         hCoreCoder->hRF = NULL;
    1304             :     }
    1305             : 
    1306           3 :     IF( hCoreCoder->hTECEnc != NULL )
    1307             :     {
    1308           3 :         free( hCoreCoder->hTECEnc );
    1309           3 :         hCoreCoder->hTECEnc = NULL;
    1310             :     }
    1311             : 
    1312           3 :     IF( hCoreCoder->hTcxEnc != NULL )
    1313             :     {
    1314           3 :         free( hCoreCoder->hTcxEnc );
    1315           3 :         hCoreCoder->hTcxEnc = NULL;
    1316             :     }
    1317             : 
    1318           3 :     IF( hCoreCoder->hTcxCfg != NULL )
    1319             :     {
    1320           3 :         free( hCoreCoder->hTcxCfg );
    1321           3 :         hCoreCoder->hTcxCfg = NULL;
    1322             :     }
    1323             : 
    1324           3 :     IF( hCoreCoder->hIGFEnc != NULL )
    1325             :     {
    1326           3 :         free( hCoreCoder->hIGFEnc );
    1327           3 :         hCoreCoder->hIGFEnc = NULL;
    1328             :     }
    1329             : 
    1330           3 :     IF( hCoreCoder->hPlcExt != NULL )
    1331             :     {
    1332           3 :         free( hCoreCoder->hPlcExt );
    1333           3 :         hCoreCoder->hPlcExt = NULL;
    1334             :     }
    1335             : 
    1336           3 :     IF( hCoreCoder->hHQ_core != NULL )
    1337             :     {
    1338           3 :         free( hCoreCoder->hHQ_core );
    1339           3 :         hCoreCoder->hHQ_core = NULL;
    1340             :     }
    1341             : 
    1342           3 :     free( hCoreCoder );
    1343             : 
    1344           3 :     return;
    1345             : }
    1346             : 
    1347             : 
    1348             : /*-------------------------------------------------------------------------
    1349             :  * ivas_destroy_enc_fx()
    1350             :  *
    1351             :  * Close IVAS encoder handles
    1352             :  *-------------------------------------------------------------------------*/
    1353         624 : void ivas_destroy_enc_fx(
    1354             :     Encoder_Struct *st_ivas /* i/o: IVAS encoder structure      */
    1355             : )
    1356             : {
    1357             :     Word16 i, n, nchan_inp;
    1358         624 :     nchan_inp = st_ivas->hEncoderConfig->nchan_inp;
    1359         624 :     move16();
    1360             : 
    1361             :     /* SCE handles */
    1362        3120 :     for ( i = 0; i < MAX_SCE; i++ )
    1363             :     {
    1364        2496 :         if ( st_ivas->hSCE[i] != NULL )
    1365             :         {
    1366         409 :             destroy_sce_enc_fx( st_ivas->hSCE[i], EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) );
    1367         409 :             st_ivas->hSCE[i] = NULL;
    1368             :         }
    1369             :     }
    1370             : 
    1371             :     /* CPE handles */
    1372        4368 :     for ( i = 0; i < MAX_CPE; i++ )
    1373             :     {
    1374        3744 :         if ( st_ivas->hCPE[i] != NULL )
    1375             :         {
    1376         738 :             destroy_cpe_enc( st_ivas->hCPE[i] );
    1377         738 :             st_ivas->hCPE[i] = NULL;
    1378             :         }
    1379             :     }
    1380             : 
    1381             :     /* HP20 filter handles */
    1382         624 :     if ( st_ivas->mem_hp20_in_fx != NULL )
    1383             :     {
    1384         624 :         n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */
    1385             : 
    1386        3503 :         for ( i = 0; i < n; i++ )
    1387             :         {
    1388        2879 :             free( st_ivas->mem_hp20_in_fx[i] );
    1389        2879 :             st_ivas->mem_hp20_in_fx[i] = NULL;
    1390             :         }
    1391         624 :         free( st_ivas->mem_hp20_in_fx );
    1392         624 :         st_ivas->mem_hp20_in_fx = NULL;
    1393             :     }
    1394             : 
    1395             :     /* ISM metadata handles */
    1396         624 :     ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
    1397             : 
    1398             :     /* ISM DTX Handle */
    1399         624 :     if ( st_ivas->hISMDTX != NULL )
    1400             :     {
    1401          14 :         free( st_ivas->hISMDTX );
    1402          14 :         st_ivas->hISMDTX = NULL;
    1403             :     }
    1404             : 
    1405             :     /* Q Metadata handle */
    1406         624 :     ivas_qmetadata_close_fx( &( st_ivas->hQMetaData ) );
    1407             : 
    1408             :     /* DirAC handle */
    1409         624 :     ivas_dirac_enc_close_fx( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs );
    1410             : 
    1411             :     /* ParamISM handle */
    1412         624 :     ivas_param_ism_enc_close_fx( &( st_ivas->hParamIsm ), st_ivas->hEncoderConfig->input_Fs );
    1413             : 
    1414             :     /* SPAR handle */
    1415         624 :     ivas_spar_enc_close_fx( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 );
    1416             : 
    1417             :     /* MASA handle */
    1418         624 :     ivas_masa_enc_close_fx( &( st_ivas->hMasa ) );
    1419             : 
    1420             :     /* MCT handle */
    1421         624 :     ivas_mct_enc_close_fx( &( st_ivas->hMCT ) );
    1422             : 
    1423             :     /* LFE handle */
    1424         624 :     ivas_lfe_enc_close_fx( &( st_ivas->hLFE ) );
    1425             : 
    1426             :     /* LFE low pass filter state */
    1427         624 :     ivas_lfe_lpf_enc_close_fx( &( st_ivas->hLfeLpf ) );
    1428             : 
    1429             :     /* Param-Upmix MC handle */
    1430         624 :     ivas_mc_paramupmix_enc_close_fx( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs );
    1431             : 
    1432             :     /* Parametric MC handle */
    1433         624 :     ivas_param_mc_enc_close_fx( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs );
    1434             : 
    1435             :     /* Multi-channel MASA handle */
    1436         624 :     ivas_mcmasa_enc_close_fx( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs );
    1437             : 
    1438             :     /* OMASA handle */
    1439         624 :     ivas_omasa_enc_close_fx( &( st_ivas->hOMasa ) );
    1440             : 
    1441             :     /* OSBA handle */
    1442         624 :     ivas_osba_enc_close_fx( &( st_ivas->hOSba ) );
    1443             : 
    1444             :     /* Stereo downmix for EVS encoder handle */
    1445         624 :     stereo_dmx_evs_close_encoder_fx( &( st_ivas->hStereoDmxEVS ) );
    1446             : 
    1447             :     /* Encoder configuration handle */
    1448         624 :     IF( st_ivas->hEncoderConfig != NULL )
    1449             :     {
    1450         624 :         free( st_ivas->hEncoderConfig );
    1451         624 :         st_ivas->hEncoderConfig = NULL;
    1452             :     }
    1453             : 
    1454             :     /* Buffer of indices */
    1455         624 :     IF( st_ivas->ind_list != NULL )
    1456             :     {
    1457         624 :         free( st_ivas->ind_list );
    1458             :     }
    1459             : 
    1460         624 :     IF( st_ivas->ind_list_metadata != NULL )
    1461             :     {
    1462         621 :         free( st_ivas->ind_list_metadata );
    1463             :     }
    1464             : 
    1465             :     /* floating-point input audio buffers */
    1466       13104 :     FOR( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
    1467             :     {
    1468       12480 :         IF( st_ivas->p_data_fx[n] != NULL )
    1469             :         {
    1470        3654 :             free( st_ivas->p_data_fx[n] );
    1471        3654 :             st_ivas->p_data_fx[n] = NULL;
    1472             :         }
    1473             :     }
    1474             : 
    1475             :     /* main IVAS handle */
    1476         624 :     free( st_ivas );
    1477             : 
    1478         624 :     return;
    1479             : }
    1480             : 
    1481             : /*-------------------------------------------------------------------------
    1482             :  * ivas_initialize_MD_bstr_enc_fx()
    1483             :  *
    1484             :  * Allocate and initialize SCE/CPE MD bitstream handle
    1485             :  *-------------------------------------------------------------------------*/
    1486             : 
    1487        4208 : ivas_error ivas_initialize_MD_bstr_enc_fx(
    1488             :     BSTR_ENC_HANDLE *hMetaData_out, /* o  : encoder MD bitstream handle */
    1489             :     Encoder_Struct *st_ivas         /* i/o: IVAS encoder structure      */
    1490             : )
    1491             : {
    1492             :     BSTR_ENC_HANDLE hMetaData;
    1493             : 
    1494        4208 :     IF( ( hMetaData = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL )
    1495             :     {
    1496           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MetaData structure\n" ) );
    1497             :     }
    1498             : 
    1499             :     /* set pointer to the buffer of metadata indices */
    1500        4208 :     hMetaData->ind_list = st_ivas->ind_list_metadata;
    1501        4208 :     hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
    1502        4208 :     hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata; /* Q0 */
    1503        4208 :     hMetaData->st_ivas = st_ivas;
    1504             : 
    1505        4208 :     reset_indices_enc_fx( hMetaData, st_ivas->ivas_max_num_indices_metadata );
    1506             : 
    1507        4208 :     *hMetaData_out = hMetaData;
    1508             : 
    1509        4208 :     return IVAS_ERR_OK;
    1510             : }
    1511             : 
    1512             : 
    1513             : /*-------------------------------------------------------------------------
    1514             :  * ivas_destroy_MD_bstr_enc_fx()
    1515             :  *
    1516             :  * Destroy SCE/CPE MD bitstream handle
    1517             :  *-------------------------------------------------------------------------*/
    1518             : 
    1519        8770 : void ivas_destroy_MD_bstr_enc_fx(
    1520             :     BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle  */
    1521             : )
    1522             : {
    1523        8770 :     test();
    1524        8770 :     IF( hMetaData == NULL || *hMetaData == NULL )
    1525             :     {
    1526        4562 :         return;
    1527             :     }
    1528             : 
    1529        4208 :     free( *hMetaData );
    1530        4208 :     *hMetaData = NULL;
    1531             : 
    1532        4208 :     return;
    1533             : }

Generated by: LCOV version 1.14