Commit 2b59c6fc authored by vaclav's avatar vaclav
Browse files

reintroduce function restartDecoder()

parent a6eac327
Loading
Loading
Loading
Loading
Loading
+35 −9
Original line number Diff line number Diff line
@@ -191,7 +191,9 @@ static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBs
static int16_t app_own_random( int16_t *seed );
#endif
static void do_object_editing( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );
#ifndef FIX_FMSW_DEC
#ifdef FIX_FMSW_DEC
static ivas_error restartDecoder( IVAS_DEC_HANDLE hIvasDec, const IVAS_DEC_MODE decMode );
#else
static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData );
#endif

@@ -2638,9 +2640,9 @@ static ivas_error decodeG192(
                if ( restartNeeded )
                {
#ifdef FIX_FMSW_DEC
                    if ( ( error = IVAS_DEC_Restart( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in G.192 */
                    if ( ( error = restartDecoder( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in G.192 */
                    {
                        fprintf( stderr, "\nIVAS_DEC_Restart failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        fprintf( stderr, "\nDecoder restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
#else
@@ -3434,9 +3436,9 @@ static ivas_error decodeVoIP(
        {
#ifdef FIX_FMSW_DEC
            arg.decMode = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            if ( ( error = IVAS_DEC_Restart( hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) /* note: switching between EVS and IVAS is supported in RTP */
            if ( ( error = restartDecoder( hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) /* note: switching between EVS and IVAS is supported in RTP */
            {
                fprintf( stderr, "\nIVAS_DEC_Restart failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                fprintf( stderr, "\nDecoder restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
#else
@@ -3687,16 +3689,16 @@ static ivas_error decodeVoIP(
                if ( restartNeeded )
                {
#ifdef FIX_FMSW_DEC
                    if ( ( error = IVAS_DEC_Restart( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in non-RTP VoIP */
                    if ( ( error = restartDecoder( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in non-RTP VoIP */
                    {
                        fprintf( stderr, "\nIVAS_DEC_Restart failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        fprintf( stderr, "\nDecoder restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
#else
                    IVAS_DEC_BS_FORMAT tempBsFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempBsFormat ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error );
                        fprintf( stderr, "\nFailed to restart decoder\n" );
                        goto cleanup;
                    }

@@ -4401,13 +4403,37 @@ static ivas_error load_hrtf_from_file(
    return IVAS_ERR_OK;
}

#ifndef FIX_FMSW_DEC

/*---------------------------------------------------------------------*
 * restartDecoder()
 *
 * Restart decoder in case of IVAS format switching
 *---------------------------------------------------------------------*/

#ifdef FIX_FMSW_DEC
static ivas_error restartDecoder(
    IVAS_DEC_HANDLE hIvasDec,   /* i/o: IVAS decoder handle                             */
    const IVAS_DEC_MODE decMode /* i  : mode the decoder is operating in (EVS or IVAS)  */
)
{
    ivas_error error;

    if ( hIvasDec == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    if ( ( error = IVAS_DEC_Restart( hIvasDec, decMode ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nIVAS_DEC_Restart failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        return error;
    }

    // TODO: fix to EXT output will come here

    return IVAS_ERR_OK;
}
#else
static ivas_error restartDecoder(
    IVAS_DEC_HANDLE *phIvasDec,
    const IVAS_DEC_MODE decMode,