LCOV - code coverage report
Current view: top level - lib_dec - ivas_sce_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 198 207 95.7 %
Date: 2025-05-03 01:55:50 Functions: 3 3 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 "cnst.h"
      37             : #include "ivas_cnst.h"
      38             : #include "rom_com.h"
      39             : #include "prot_fx.h"
      40             : #include "ivas_prot_fx.h"
      41             : #include "ivas_rom_com.h"
      42             : #include "wmc_auto.h"
      43             : 
      44             : /*--------------------------------------------------------------------------*
      45             :  * ivas_sce_dec()
      46             :  *
      47             :  * Single Channel Element (SCE) decoding routine
      48             :  *--------------------------------------------------------------------------*/
      49             : 
      50      315557 : ivas_error ivas_sce_dec_fx(
      51             :     Decoder_Struct *st_ivas,      /* i/o: IVAS decoder structure              */
      52             :     const Word16 sce_id,          /* i  : SCE # identifier                    Q0*/
      53             :     Word32 *output[1],            /* o  : output synthesis signal             Q11*/
      54             :     const Word16 output_frame,    /* i  : output frame length per channel     Q0*/
      55             :     const Word16 nb_bits_metadata /* i  : number of metadata bits             Q0*/
      56             : )
      57             : {
      58             :     Word32 outputHB[1][L_FRAME48k]; /*Word32 buffer for output HB synthesis, one channel */
      59             :     SCE_DEC_HANDLE hSCE;
      60             :     Decoder_State *st;
      61             :     Word32 ivas_total_brate, last_ivas_total_brate;
      62             :     ivas_error error;
      63             : 
      64      315557 :     error = IVAS_ERR_OK;
      65      315557 :     move32();
      66             : 
      67      315557 :     push_wmops( "ivas_sce_dec" );
      68             : 
      69      315557 :     hSCE = st_ivas->hSCE[sce_id];
      70      315557 :     st = hSCE->hCoreCoder[0];
      71             : 
      72      315557 :     st->BER_detect = s_or( st->BER_detect, st_ivas->BER_detect );
      73      315557 :     move16();
      74             : 
      75      315557 :     ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /*Q0*/
      76      315557 :     move32();
      77      315557 :     last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; /*Q0*/
      78      315557 :     move32();
      79             : 
      80      315557 :     IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) )
      81             :     {
      82      239500 :         st->cng_type = FD_CNG;
      83      239500 :         move16();
      84             :     }
      85             : 
      86             :     /*------------------------------------------------------------------*
      87             :      * Read audio bandwidth info
      88             :      *-----------------------------------------------------------------*/
      89             : 
      90             :     /* set total_brate - needed in DTX */
      91      315557 :     test();
      92      315557 :     test();
      93      315557 :     test();
      94      315557 :     test();
      95      315557 :     IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
      96             :     {
      97        1890 :         st->total_brate = L_sub( ivas_total_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/
      98        1890 :         move16();
      99        1890 :         test();
     100        1890 :         assert( EQ_32( st->total_brate, SID_2k40 ) && "SCE SID must be 2.4kbps!" );
     101             : 
     102        1890 :         test();
     103        1890 :         IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->hISMDTX.sce_id_dtx, sce_id ) )
     104             :         {
     105        1052 :             st->total_brate = FRAME_NO_DATA;
     106        1052 :             move32();
     107             :         }
     108             :     }
     109      313667 :     ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, FRAME_NO_DATA ) )
     110             :     {
     111        5497 :         st->total_brate = FRAME_NO_DATA;
     112        5497 :         move32();
     113             :     }
     114      308170 :     ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && LE_32( last_ivas_total_brate, IVAS_SID_5k2 ) )
     115             :     {
     116          49 :         st->total_brate = L_sub( hSCE->element_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/
     117          49 :         move32();
     118             :     }
     119             : 
     120             :     /* read the bandwidth */
     121      315557 :     test();
     122      315557 :     IF( st_ivas->bfi || LE_32( st->total_brate, SID_2k40 ) )
     123             :     {
     124             :         /* BFI or SID/NO_DATA frame -> do nothing */
     125             :     }
     126             :     ELSE
     127             :     {
     128      303204 :         test();
     129      303204 :         test();
     130      303204 :         test();
     131      303204 :         IF( st->low_rate_mode )
     132             :         {
     133             :             /* ISM Low-rate mode -> always WB */
     134        6736 :             st->bwidth = WB;
     135        6736 :             move16();
     136             :         }
     137      296468 :         ELSE IF( LT_32( hSCE->element_brate, MIN_BRATE_SWB_SCE ) )
     138             :         {
     139             :             /* only WB is supported */
     140        5950 :             st->bwidth = WB;
     141        5950 :             move16();
     142             :         }
     143      290518 :         ELSE IF( ( LT_32( hSCE->element_brate, MIN_BRATE_FB_STEREO ) && !st->is_ism_format ) ||
     144             :                  ( LT_32( hSCE->element_brate, MIN_BRATE_FB_ISM ) && st->is_ism_format ) )
     145             :         {
     146             :             /* WB and SWB are supported */
     147       53786 :             st->bwidth = add( get_next_indice_fx( st, 1 ), WB ); /*Q0*/
     148       53786 :             move16();
     149             :         }
     150             :         ELSE
     151             :         {
     152             :             /* WB, SWB and FB are supported */
     153      236732 :             st->bwidth = get_next_indice_fx( st, NBITS_BWIDTH ); /*Q0*/
     154      236732 :             move16();
     155             :         }
     156             :     }
     157             : 
     158             :     /*------------------------------------------------------------------*
     159             :      * Initialization
     160             :      *-----------------------------------------------------------------*/
     161             : 
     162      315557 :     st->idchan = 0;
     163      315557 :     move16();
     164      315557 :     st->element_mode = IVAS_SCE;
     165      315557 :     move16();
     166             : 
     167             :     /* Force to MODE1 in IVAS */
     168      315557 :     st->codec_mode = MODE1;
     169      315557 :     move16();
     170             : 
     171             :     /* set "bits_frame_nominal" */
     172      315557 :     test();
     173      315557 :     IF( ( st_ivas->hQMetaData != NULL ) &&
     174             :         NE_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) )
     175             :     {
     176       40758 :         test();
     177       40758 :         test();
     178       40758 :         test();
     179       40758 :         test();
     180       40758 :         IF( EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
     181             :         {
     182        9360 :             st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); /*Q0*/
     183        9360 :             move16();
     184             :         }
     185       31398 :         ELSE IF( ( EQ_16( (Word16) st_ivas->mc_mode, MC_MODE_MCMASA ) && GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) ) || ( EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) )
     186             :         {
     187        2173 :             st->bits_frame_nominal = extract_l( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/
     188        2173 :             move16();
     189             :         }
     190       29225 :         ELSE IF( EQ_16( (Word16) st_ivas->ism_mode, ISM_MODE_NONE ) && EQ_16( (Word16) st_ivas->ivas_format, SBA_ISM_FORMAT ) )
     191             :         {
     192        6255 :             st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/
     193        6255 :             move16();
     194             :         }
     195             :         ELSE
     196             :         {
     197       22970 :             st->bits_frame_nominal = st_ivas->hQMetaData->bits_frame_nominal; /*Q0*/
     198       22970 :             move16();
     199             :         }
     200             :     }
     201      274799 :     ELSE IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) )
     202             :     {
     203       35299 :         st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/
     204       35299 :         move16();
     205             :     }
     206             :     ELSE
     207             :     {
     208      239500 :         st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); /*Q0*/
     209      239500 :         move16();
     210             :     }
     211             : 
     212             : 
     213             :     /* set "total_brate" */
     214      315557 :     test();
     215      315557 :     test();
     216      315557 :     test();
     217      315557 :     test();
     218      315557 :     IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
     219             :     {
     220        1890 :         st->total_brate = L_sub( ivas_total_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/
     221             : 
     222        1890 :         if ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->hISMDTX.sce_id_dtx, sce_id ) )
     223             :         {
     224        1052 :             st->total_brate = FRAME_NO_DATA;
     225        1052 :             move32();
     226             :         }
     227             :     }
     228      313667 :     ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, FRAME_NO_DATA ) )
     229             :     {
     230        5497 :         st->total_brate = ivas_total_brate; /*Q0*/
     231        5497 :         move32();
     232             :     }
     233      308170 :     ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) /* note: in ISMs, total_brate[] is set in ivas_ism_config() */
     234             :     {
     235       59776 :         st->total_brate = L_sub( hSCE->element_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/
     236       59776 :         move32();
     237             :     }
     238             : 
     239             :     /*----------------------------------------------------------------*
     240             :      * Core codec configuration
     241             :      *----------------------------------------------------------------*/
     242             : 
     243             :     /* set ACELP12k8 / ACELP16k flag for flexible ACELP core */
     244      315557 :     test();
     245      315557 :     test();
     246      315557 :     test();
     247      315557 :     test();
     248      315557 :     test();
     249      315557 :     IF( ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) &&
     250             :         st->low_rate_mode && !( EQ_32( st->total_brate, SID_2k40 ) || EQ_32( st->total_brate, FRAME_NO_DATA ) ) )
     251             :     {
     252        6758 :         st->flag_ACELP16k = 0;
     253        6758 :         move16();
     254             :     }
     255             :     ELSE
     256             :     {
     257      308799 :         st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); /*Q0*/
     258      308799 :         move16();
     259             :     }
     260             : 
     261      315557 :     IF( is_DTXrate( ivas_total_brate ) )
     262             :     {
     263        7387 :         st->VAD = 0;
     264        7387 :         move16();
     265             :     }
     266             :     ELSE
     267             :     {
     268      308170 :         st->VAD = 1;
     269      308170 :         move16();
     270             :     }
     271             : 
     272             : 
     273      315557 :     test();
     274      315557 :     test();
     275      315557 :     test();
     276      315557 :     IF( st->VAD && LE_32( hSCE->element_brate, CNA_MAX_BRATE ) )
     277             :     {
     278       34061 :         st->flag_cna = 1;
     279       34061 :         move16();
     280             :     }
     281      281496 :     ELSE IF( ( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( hSCE->element_brate, ACELP_32k ) )
     282             :     {
     283       35675 :         st->flag_cna = 1;
     284       35675 :         move16();
     285             :     }
     286             :     ELSE
     287             :     {
     288      245821 :         st->flag_cna = 0;
     289      245821 :         move16();
     290             :     }
     291             : 
     292             :     /*----------------------------------------------------------------*
     293             :      * Decoder
     294             :      *----------------------------------------------------------------*/
     295             : 
     296      315557 :     set32_fx( output[0], 0, L_FRAME48k );
     297             : 
     298      315557 :     IF( NE_32( ( error = ivas_core_dec_fx( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ), IVAS_ERR_OK ) )
     299             :     {
     300           0 :         return error;
     301             :     }
     302             : 
     303      315557 :     IF( st_ivas->sba_dirac_stereo_flag && ( GT_32( st->core_brate, SID_2k40 ) || EQ_16( st->cng_type, LP_CNG ) ) )
     304             :     {
     305             :         /* skip addition of ACELP BWE for now, will be done after upmix */
     306        4420 :         Copy32( outputHB[0], hSCE->save_hb_synth_fx, output_frame ); /*Q11*/
     307        4420 :         hSCE->q_save_hb_synth_fx = Q11;
     308        4420 :         move16();
     309             :     }
     310      311137 :     ELSE IF( !st_ivas->sba_dirac_stereo_flag )
     311             :     {
     312             :         Word32 output_Fs;
     313             : 
     314      311046 :         output_Fs = st_ivas->hDecoderConfig->output_Fs; /*Q0*/
     315      311046 :         move32();
     316             : 
     317             :         /*----------------------------------------------------------------*
     318             :          * LB synthesis synchronization between IVAS formats
     319             :          *----------------------------------------------------------------*/
     320             : 
     321      311046 :         delay_signal32_fx( output[0], output_frame, st->prev_synth_buffer32_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) );
     322             : 
     323             :         /*----------------------------------------------------------------*
     324             :          * HB synthesis synchronization between IVAS formats
     325             :          *----------------------------------------------------------------*/
     326             : 
     327      311046 :         delay_signal32_fx( outputHB[0], output_frame, hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) );
     328             : 
     329             :         /*----------------------------------------------------------------*
     330             :          * output LB and HB mix
     331             :          *----------------------------------------------------------------*/
     332             : 
     333      311046 :         v_add_fx( output[0], outputHB[0], output[0], output_frame ); /*Q11*/
     334             :     }
     335             : 
     336             :     /*----------------------------------------------------------------*
     337             :      * Common updates
     338             :      *----------------------------------------------------------------*/
     339             : 
     340      315557 :     hSCE->last_element_brate = hSCE->element_brate; /*Q0*/
     341      315557 :     move32();
     342             : 
     343      315557 :     st_ivas->BER_detect = s_or( st_ivas->BER_detect, st->BER_detect ); /*Q0*/
     344      315557 :     move16();
     345             : 
     346             : 
     347      315557 :     pop_wmops();
     348      315557 :     return error;
     349             : }
     350             : 
     351             : 
     352             : /*-------------------------------------------------------------------------
     353             :  * create_sce_dec()
     354             :  *
     355             :  * Create, allocate and initialize IVAS decoder SCE handle
     356             :  *-------------------------------------------------------------------------*/
     357             : 
     358        2434 : ivas_error create_sce_dec(
     359             :     Decoder_Struct *st_ivas,   /* i/o: IVAS decoder structure      */
     360             :     const Word16 sce_id,       /* i  : SCE # identifier            Q0*/
     361             :     const Word32 element_brate /* i  : element bitrate             Q0*/
     362             : )
     363             : {
     364             :     SCE_DEC_HANDLE hSCE;
     365             :     Decoder_State *st;
     366             :     ivas_error error;
     367             :     Word16 output_frame;
     368             : 
     369        2434 :     error = IVAS_ERR_OK;
     370        2434 :     move16();
     371        2434 :     output_frame = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/
     372             : 
     373             :     /*-----------------------------------------------------------------*
     374             :      * Allocate SCE handle
     375             :      *-----------------------------------------------------------------*/
     376             : 
     377        2434 :     IF( ( hSCE = (SCE_DEC_HANDLE) malloc( sizeof( SCE_DEC_DATA ) ) ) == NULL )
     378             :     {
     379           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SCE\n" ) );
     380             :     }
     381             : 
     382             :     /*-----------------------------------------------------------------*
     383             :      * Initialization - general parameters
     384             :      *-----------------------------------------------------------------*/
     385             : 
     386        2434 :     hSCE->sce_id = sce_id; /*Q0*/
     387        2434 :     move16();
     388        2434 :     hSCE->element_brate = element_brate; /*Q0*/
     389        2434 :     move32();
     390             : 
     391        2434 :     set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) );
     392             : 
     393             :     /*-----------------------------------------------------------------*
     394             :      * Core Coder, 1 instance: allocate and initialize
     395             :      *-----------------------------------------------------------------*/
     396             : 
     397             :     // IF ( ( st = (DEC_CORE_HANDLE) calloc( sizeof( Decoder_State ) ) ) == NULL )
     398        2434 :     IF( ( st = (Decoder_State *) calloc( 1, sizeof( Decoder_State ) ) ) == NULL )
     399             :     {
     400           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) );
     401             :     }
     402             : 
     403        2434 :     copy_decoder_config( st_ivas, st );
     404             : 
     405        2434 :     st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
     406        2434 :     move32();
     407        2434 :     st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
     408        2434 :     move16();
     409        2434 :     st->is_ism_format = 0;
     410        2434 :     move16();
     411             : 
     412        2434 :     test();
     413        2434 :     if ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) )
     414             :     {
     415        1688 :         st->is_ism_format = 1;
     416        1688 :         move16();
     417             :     }
     418             : 
     419             :     // if (st_ivas->mode == IVAS_DEC_MODE_EVS)
     420        2434 :     IF( EQ_16( st->element_mode, EVS_MONO ) )
     421             :     {
     422           3 :         error = init_decoder_fx( st, EVS_MONO );
     423           3 :         IF( error )
     424             :         {
     425           0 :             return error;
     426             :         }
     427             :     }
     428             :     ELSE
     429             :     {
     430        2431 :         error = init_decoder_ivas_fx( st, 0, st_ivas->mc_mode );
     431        2431 :         IF( error )
     432             :         {
     433           0 :             return error;
     434             :         }
     435             :     }
     436             : 
     437        2434 :     IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) )
     438             :     {
     439          57 :         IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) )
     440             :         {
     441           0 :             return error;
     442             :         }
     443             :     }
     444             :     ELSE
     445             :     {
     446        2377 :         st->cldfbSynHB = NULL;
     447             :     }
     448             : 
     449             :     /* allocate and initialize "hTdCngDec" - needed in DTX */
     450        2434 :     IF( ( sce_id == 0 ) && st->hTdCngDec == NULL )
     451             :     {
     452        1238 :         IF( ( st->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL )
     453             :         {
     454           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) );
     455             :         }
     456             : 
     457        1238 :         td_cng_dec_init_fx( st );
     458             :     }
     459             : 
     460             :     /*-----------------------------------------------------------------*
     461             :      * Synthesis buffers: allocate and initialize
     462             :      *-----------------------------------------------------------------*/
     463             : 
     464        2434 :     IF( st_ivas->sba_dirac_stereo_flag )
     465             :     {
     466          87 :         IF( ( hSCE->save_synth_fx = (Word32 *) malloc( sizeof( *( hSCE->save_synth_fx ) ) * output_frame ) ) == NULL )
     467             :         {
     468           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) );
     469             :         }
     470          87 :         set_zero_fx( hSCE->save_synth_fx, output_frame );
     471          87 :         hSCE->q_save_synth_fx = 0;
     472          87 :         move16();
     473             : 
     474          87 :         IF( ( hSCE->save_hb_synth_fx = (Word32 *) malloc( sizeof( *( hSCE->save_hb_synth_fx ) ) * output_frame ) ) == NULL )
     475             :         {
     476           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) );
     477             :         }
     478          87 :         set_zero_fx( hSCE->save_hb_synth_fx, output_frame );
     479          87 :         hSCE->q_save_hb_synth_fx = 0;
     480          87 :         move16();
     481             :     }
     482             :     ELSE
     483             :     {
     484        2347 :         hSCE->save_synth_fx = NULL;
     485        2347 :         hSCE->save_hb_synth_fx = NULL;
     486             :     }
     487             : 
     488        2434 :     hSCE->hCoreCoder[0] = st;
     489        2434 :     st_ivas->hSCE[sce_id] = hSCE;
     490             : 
     491        2434 :     return error;
     492             : }
     493             : 
     494             : 
     495             : /*-------------------------------------------------------------------------
     496             :  * destroy_sce_dec()
     497             :  *
     498             :  * Destroy and deallocate IVAS decoder SCE handle
     499             :  *-------------------------------------------------------------------------*/
     500             : 
     501        2434 : void destroy_sce_dec(
     502             :     SCE_DEC_HANDLE hSCE /* i/o: SCE decoder structure               */
     503             : )
     504             : {
     505             :     Decoder_State *st;
     506             : 
     507        2434 :     st = hSCE->hCoreCoder[0];
     508             : 
     509        2434 :     IF( st != NULL )
     510             :     {
     511        2434 :         destroy_core_dec_fx( st );
     512             : 
     513        2434 :         free( st );
     514        2434 :         st = NULL;
     515             :     }
     516             : 
     517        2434 :     IF( hSCE->save_synth_fx != NULL )
     518             :     {
     519          32 :         free( hSCE->save_synth_fx );
     520          32 :         hSCE->save_synth_fx = NULL;
     521             :     }
     522        2434 :     IF( hSCE->save_hb_synth_fx != NULL )
     523             :     {
     524          32 :         free( hSCE->save_hb_synth_fx );
     525          32 :         hSCE->save_hb_synth_fx = NULL;
     526             :     }
     527             : 
     528        2434 :     free( hSCE );
     529             : 
     530        2434 :     return;
     531             : }

Generated by: LCOV version 1.14