Commit fd36eaba authored by vaclav's avatar vaclav
Browse files

issue 803: Resolve "MD handle needed only for one SCE"; under FIX_803_SCE_MD_HANDLE

parent 27b71568
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                  */
);
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@
#define FIX_764_HARM_CODE                               /* VA: issue 764: introduce new function for the same code block at four different places */
#define FIX_747_ISM_TODOS                               /* VA: issue 747 - address ISM ToDos */
#define FIX_ISMRENDERER_HANDLE_DEALLOC                  /* VA: issue 781: harmonize Deallocation of handle 'hIsmRendererData' */

#define FIX_803_SCE_MD_HANDLE                           /* VA: issue 803: Resolve "MD handle needed only for one SCE" */

/* #################### End BE switches ################################## */

+25 −0
Original line number Diff line number Diff line
@@ -279,6 +279,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++ )
@@ -305,6 +309,16 @@ ivas_error ivas_corecoder_enc_reconfig(
                {
                }
            }

#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 )
@@ -490,6 +504,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" ) );
@@ -502,17 +522,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
@@ -882,11 +882,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" ) );
@@ -898,6 +906,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
    }

    /*-----------------------------------------------------------------*
@@ -1091,11 +1100,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
@@ -1222,3 +1222,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