Commit 3968695c authored by vaclav's avatar vaclav Committed by emerit
Browse files

issue 1065: Allocate only the necessary number of ISM MD decoder handles;...

issue 1065: Allocate only the necessary number of ISM MD decoder handles; under NONBE_FIX_1065_ISM_MD_HANDLE
parent 387334ce
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -981,10 +981,20 @@ ivas_error ivas_ism_metadata_enc_create(

ivas_error ivas_ism_metadata_dec_create(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
    const int16_t n_ISms,                                       /* i  : number of separately coded objects          */
#else
    const int16_t n_ISms,                                       /* i  : number of objects                           */
#endif
    int32_t element_brate_tmp[]                                 /* o  : element bitrate per object                  */
);

#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
void ivas_ism_reset_metadata_handle_dec(
    ISM_METADATA_HANDLE hIsmMeta                                /* i/o: ISM metadata handle                         */
);

#endif
ivas_error ivas_ism_enc(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                      */
    float *data[],                                             /* i  : input signal [channels][samples]            */
+3 −1
Original line number Diff line number Diff line
@@ -177,6 +177,8 @@

#define NON_BE_FIX_1048_THRESHOLD_COH_BASOP             /* Nokia: Fix 1048 replace comparison with 0 with comparison to threshold, to align with BASOP*/
#define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX               /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */
#define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG               /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */
#define NONBE_FIX_1065_ISM_MD_HANDLE                    /* VA: issue 1065: Allocate only the necessary number of ISM MD decoder handles. */

/* ##################### End NON-BE switches ########################### */

+20 −2
Original line number Diff line number Diff line
@@ -1336,7 +1336,11 @@ ivas_error ivas_init_decoder(
            }
        }

#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
        if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -1670,10 +1674,24 @@ ivas_error ivas_init_decoder(

            reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] );

#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
            if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
            {
                if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
            else
            {
#endif
                if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
            }
#endif
        }
        else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
        {
+66 −6
Original line number Diff line number Diff line
@@ -642,6 +642,40 @@ ivas_error ivas_ism_metadata_dec(
    return IVAS_ERR_OK;
}

#ifdef NONBE_FIX_1065_ISM_MD_HANDLE

/*-------------------------------------------------------------------*
 * ivas_ism_reset_metadata_handle_dec()
 *
 * Reset ISM decoder metadata handle
 *-------------------------------------------------------------------*/

void ivas_ism_reset_metadata_handle_dec(
    ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle     */
)
{
    hIsmMeta->last_ism_metadata_flag = 0;
    hIsmMeta->position_angle.last_angle1_idx = 0;
    hIsmMeta->position_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
    hIsmMeta->orientation_angle.last_angle1_idx = 0;
    hIsmMeta->orientation_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
    hIsmMeta->last_radius_idx = 8; /* Init to radius 1.0 */

    hIsmMeta->last_true_azimuth = 0;
    hIsmMeta->last_true_elevation = 0;
    hIsmMeta->last_azimuth = 0;
    hIsmMeta->last_elevation = 0;

    hIsmMeta->ism_imp = -1;
    hIsmMeta->ism_md_null_flag = 0;
    hIsmMeta->ism_md_lowrate_flag = 0;

    ivas_ism_reset_metadata( hIsmMeta );

    return;
}

#endif

/*-------------------------------------------------------------------------
 * ivas_ism_metadata_dec_create()
@@ -651,7 +685,11 @@ ivas_error ivas_ism_metadata_dec(

ivas_error ivas_ism_metadata_dec_create(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure              */
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
    const int16_t n_ISms, /* i  : number of separately coded objects  */
#else
    const int16_t n_ISms, /* i  : number of objects                   */
#endif
    int32_t element_brate_tmp[] /* o  : element bitrate per object          */
)
{
@@ -659,13 +697,27 @@ ivas_error ivas_ism_metadata_dec_create(
    ivas_error error;

/* allocate ISM metadata handles */
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
    for ( ch = 0; ch < n_ISms; ch++ )
#else
    for ( ch = 0; ch < MAX_NUM_OBJECTS; ch++ )
#endif
    {
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
        if ( st_ivas->hIsmMetaData[ch] == NULL ) /* note: the handle can be allocated in OMASA bitrate switching from ISM_MASA_MODE_xxx_ONE_OBJ to ISM_MASA_MODE_DISC mode for 'ch==0' */
        {
#endif
            if ( ( st_ivas->hIsmMetaData[ch] = (ISM_METADATA_HANDLE) malloc( sizeof( ISM_METADATA_FRAME ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM MetaData\n" ) );
            }
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
        }
#endif

#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
        ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[ch] );
#else
        st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0;
        st_ivas->hIsmMetaData[ch]->position_angle.last_angle1_idx = 0;
        st_ivas->hIsmMetaData[ch]->position_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
@@ -683,7 +735,15 @@ ivas_error ivas_ism_metadata_dec_create(
        st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = 0;

        ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] );
#endif
    }

#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
    for ( ; ch < MAX_NUM_OBJECTS; ch++ )
    {
        st_ivas->hIsmMetaData[ch] = NULL;
    }
#endif

    if ( element_brate_tmp != NULL )
    {
+13 −0
Original line number Diff line number Diff line
@@ -300,6 +300,12 @@ ivas_error ivas_omasa_dec_config(
        if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
        {
            /* the full number of hIsmMetaData are needed for EXT output */
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
            for ( k = 0; k < st_ivas->nchan_ism; k++ )
            {
                ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[k] );
            }
#else
            n_MD = st_ivas->nchan_ism;
            ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );

@@ -309,6 +315,7 @@ ivas_error ivas_omasa_dec_config(
            }

            ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD );
#endif
        }
        else
        {
@@ -323,6 +330,12 @@ ivas_error ivas_omasa_dec_config(
                        return error;
                    }
                }
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
                else
                {
                    ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[0] );
                }
#endif
            }
            else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
            {