Commit 06583ecb authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into 749-harmonize-ism-metadata-structures

parents 9d939bf7 0ff43050
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -282,6 +282,17 @@ void ivas_destroy_enc(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);

#ifdef FIX_803_SCE_MD_HANDLE
ivas_error ivas_initialize_MD_bstr_enc(
    BSTR_ENC_HANDLE *hBstr,                                     /* o  : encoder MD bitstream handle             */
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);

void ivas_destroy_MD_bstr_enc(
    BSTR_ENC_HANDLE *hMetaData                                  /* i/o: encoder MD bitstream handle             */
);
#endif

ivas_error ivas_init_decoder_front(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);
+2 −1
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@
#define FIX_676_JBM_USAN                                /* FhG: Issue 676: USAN in JBM */
#define FIX_796_MCT_MODE_DIFF_JBM                       /* FhG: Issue 796: fix differences between JBM and non-JBM fOR MC */
#define LIB_REND_FIX_HRTFPARAMBIN_MEMLEAK               /* fix 755 */
#define FIX_803_SCE_MD_HANDLE                           /* VA: issue 803: Resolve "MD handle needed only for one SCE" */


/* #################### End BE switches ################################## */
@@ -208,9 +209,9 @@
#define NONBE_FIX_588_UPDATE_FASTCONV_SD                      /* FhG: issue 588: update FastConv SD HRTFs in CLDFB domain with new conversion method */
#define NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN                  /* FhG: Issue 778: MSAN error due to uninitialized TNS configuration */
#define NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ                 /* VA: issue 797:  fix of crash when the separated object is inactive and the MASA metadata is using very few bits */

#define NONBE_FIX_798_OSBA_MC_DEC_CRASH


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

/* ################## End DEVELOPMENT switches ######################### */
+26 −0
Original line number Diff line number Diff line
@@ -280,6 +280,10 @@ ivas_error ivas_corecoder_enc_reconfig(
                copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
                st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
                st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */

#ifdef FIX_803_SCE_MD_HANDLE
                ivas_destroy_MD_bstr_enc( &( st_ivas->hSCE[sce_id]->hMetaData ) );
#endif
            }

            for ( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ )
@@ -301,6 +305,16 @@ ivas_error ivas_corecoder_enc_reconfig(
                    reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot );
                }
            }

#ifdef FIX_803_SCE_MD_HANDLE
            if ( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData == NULL )
            {
                if ( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#endif
        }

        if ( st_ivas->nCPE > 0 )
@@ -413,6 +427,7 @@ ivas_error ivas_corecoder_enc_reconfig(
            {
                mvr2r( input_buff[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, len_inp_memory );
            }

            if ( st_ivas->nCPE )
            {
                for ( n = 0; n < CPE_CHANNELS; n++ )
@@ -472,6 +487,12 @@ ivas_error ivas_corecoder_enc_reconfig(
        {
            if ( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData == NULL )
            {
#ifdef FIX_803_SCE_MD_HANDLE
                if ( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#else
                if ( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MetaData structure\n" ) );
@@ -484,17 +505,22 @@ ivas_error ivas_corecoder_enc_reconfig(
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot = 0;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_bits_tot = 0;
                st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->st_ivas = st_ivas;
#endif
            }

            reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot );

            for ( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ )
            {
#ifdef FIX_803_SCE_MD_HANDLE
                ivas_destroy_MD_bstr_enc( &( st_ivas->hCPE[cpe_id]->hMetaData ) );
#else
                if ( st_ivas->hCPE[cpe_id]->hMetaData != NULL )
                {
                    free( st_ivas->hCPE[cpe_id]->hMetaData );
                    st_ivas->hCPE[cpe_id]->hMetaData = NULL;
                }
#endif
            }
        }

+13 −0
Original line number Diff line number Diff line
@@ -877,11 +877,19 @@ ivas_error create_cpe_enc(
     * Metadata: allocate and initialize
     *-----------------------------------------------------------------*/

#ifndef FIX_803_SCE_MD_HANDLE
    /* we need the meta data handle also if we init as MC_FORMAT/MCT since it might be needed
       at a bit rate switch to ParamMC or McMASA and the metadata index list is only really reachable
       in the ivas_init_encoder() function and has to be connected to the MD handle there */
#endif
    if ( cpe_id == ( st_ivas->nCPE - 1 ) )
    {
#ifdef FIX_803_SCE_MD_HANDLE
        if ( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        if ( ( hCPE->hMetaData = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MetaData structure\n" ) );
@@ -893,6 +901,7 @@ ivas_error create_cpe_enc(
        hCPE->hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
        hCPE->hMetaData->st_ivas = st_ivas;
        reset_indices_enc( hCPE->hMetaData, st_ivas->ivas_max_num_indices_metadata );
#endif
    }

    /*-----------------------------------------------------------------*
@@ -1085,11 +1094,15 @@ void destroy_cpe_enc(
        }
    }

#ifdef FIX_803_SCE_MD_HANDLE
    ivas_destroy_MD_bstr_enc( &( hCPE->hMetaData ) );
#else
    if ( hCPE->hMetaData != NULL )
    {
        free( hCPE->hMetaData );
        hCPE->hMetaData = NULL;
    }
#endif

    for ( n = 0; n < CPE_CHANNELS; n++ )
    {
+55 −0
Original line number Diff line number Diff line
@@ -1229,3 +1229,58 @@ void ivas_destroy_enc(

    return;
}

#ifdef FIX_803_SCE_MD_HANDLE
/*-------------------------------------------------------------------------
 * ivas_initialize_MD_bstr_enc()
 *
 * Allocate and initialize SCE/CPE MD bitstream handle
 *-------------------------------------------------------------------------*/

ivas_error ivas_initialize_MD_bstr_enc(
    BSTR_ENC_HANDLE *hMetaData_out, /* o  : encoder MD bitstream handle */
    Encoder_Struct *st_ivas         /* i/o: IVAS encoder structure      */
)
{
    BSTR_ENC_HANDLE hMetaData;

    if ( ( hMetaData = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MetaData structure\n" ) );
    }

    /* set pointer to the buffer of metadata indices */
    hMetaData->ind_list = st_ivas->ind_list_metadata;
    hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata;
    hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata;
    hMetaData->st_ivas = st_ivas;

    reset_indices_enc( hMetaData, st_ivas->ivas_max_num_indices_metadata );

    *hMetaData_out = hMetaData;

    return IVAS_ERR_OK;
}


/*-------------------------------------------------------------------------
 * ivas_destroy_MD_bstr_enc()
 *
 * Destroy SCE/CPE MD bistream handle
 *-------------------------------------------------------------------------*/

void ivas_destroy_MD_bstr_enc(
    BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle  */
)
{
    if ( hMetaData == NULL || *hMetaData == NULL )
    {
        return;
    }

    free( *hMetaData );
    *hMetaData = NULL;

    return;
}
#endif
Loading