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

Generated by: LCOV version 1.14