Commit 204bcb4c authored by vaclav's avatar vaclav
Browse files

port NONBE_FIX_1065_ISM_MD_HANDLE

parent 6c110134
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1001,10 +1001,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]            */
+1 −0
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@
#define FIX_998_UNUSED_FUNCTION                         /* FhG: issue 998: delete unused funtion ivas_dirac_dec_get_response_split_order */ 
#define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO             /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */
#define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING       /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */
#define NONBE_FIX_1065_ISM_MD_HANDLE                    /* VA: issue 1065: Allocate only the necessary number of ISM MD decoder handles. */

/* #################### End BASOP porting switches ############################ */

+20 −3
Original line number Diff line number Diff line
@@ -1243,7 +1243,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;
        }
@@ -1574,11 +1578,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 )
        {
+69 −4
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,8 +735,21 @@ 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
    /* sanity freeing - it can happen only in reconfiguration when a smaller number of handles than before is requested */
    for ( ; ch < MAX_NUM_OBJECTS; ch++ )
    {
        if ( st_ivas->hIsmMetaData[ch] != NULL )
        {
            free( st_ivas->hIsmMetaData[ch] );
            st_ivas->hIsmMetaData[ch] = NULL;
        }
    }

#endif
    if ( element_brate_tmp != NULL )
    {
        if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
+21 −0
Original line number Diff line number Diff line
@@ -155,7 +155,11 @@ ivas_error ivas_omasa_dec_config(
    void *data                           /* o  : output synthesis signal     */
)
{
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
    int16_t k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old;
#else
    int16_t k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old, n_MD;
#endif
    int32_t ivas_total_brate, ism_total_brate, cpe_brate;
    ISM_MODE ism_mode_old;
    IVAS_FORMAT ivas_format_orig;
@@ -247,6 +251,22 @@ ivas_error ivas_omasa_dec_config(
    if ( ism_mode_old != st_ivas->ism_mode )
    {
        /* ISM MD reconfig. */
#ifdef NONBE_FIX_1065_ISM_MD_HANDLE
        if ( st_ivas->hIsmMetaData[0] == NULL )
        {
            if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else
        {
            for ( k = 0; k < st_ivas->nchan_ism; k++ )
            {
                ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[k] );
            }
        }
#else
        n_MD = 0;

        if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
@@ -274,6 +294,7 @@ ivas_error ivas_omasa_dec_config(
        }

        ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD );
#endif

        st_ivas->hCPE[0]->element_brate = ivas_total_brate - ism_total_brate;