Commit c60aa4e6 authored by vaclav's avatar vaclav
Browse files

port FIX_FLOAT_1539_G192_FORMAT_SWITCH

parent 7897b35e
Loading
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -159,7 +159,11 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs );
static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );
@@ -668,7 +672,11 @@ int main(
    }
    else
    {
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf );
#else
        error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf );
#endif
    }

    if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -2002,7 +2010,11 @@ static ivas_error decodeG192(
    Vector3PairFileReader *referenceVectorReader,
    ObjectEditFileReader *objectEditFileReader,
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    IVAS_DEC_HANDLE *phIvasDec,
#else
    IVAS_DEC_HANDLE hIvasDec,
#endif
    int16_t *pcmBuf )

{
@@ -2010,6 +2022,9 @@ static ivas_error decodeG192(
    uint16_t bit_stream[IVAS_MAX_BITS_PER_FRAME + 4 * 8];
    int16_t i, num_bits;
    int16_t bfi = 0;
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    IVAS_DEC_HANDLE hIvasDec = *phIvasDec;
#endif
    AudioFileWriter *afWriter = NULL;
    MasaFileWriter *masaWriter = NULL;
    bool decodedGoodFrame = false;
@@ -2033,6 +2048,9 @@ static ivas_error decodeG192(
    int16_t isSplitRend, isSplitCoded;
    IVAS_RENDER_CONFIG_DATA renderConfig;
    RenderConfigReader *renderConfigReader = NULL;
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    bool restartNeeded;
#endif

#ifdef VARIABLE_SPEED_DECODING
    if ( arg.tsmEnabled )
@@ -2289,6 +2307,37 @@ static ivas_error decodeG192(
                    return error;
                }

#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

                if ( restartNeeded )
                {
                    IVAS_DEC_BS_FORMAT tempFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error );
                        goto cleanup;
                    }
                    IVAS_DEC_MODE codecMode = ( tempFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
                    error = restartDecoder(
                        &hIvasDec,
                        codecMode,
                        &arg,
                        NULL, /* ToDo : Provide rendererConfig */
                        NULL  /* ToDo : Provide LS Custom Data */
                    );
                    if ( error != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nFailed to restart decoder\n" );
                        goto cleanup;
                    }
                    *phIvasDec = hIvasDec; /* Update for main()' s free */
                }
#endif

                /* Placeholder for memory reallocation */
                /* ... */

+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@
#define FIX_2479_HARM_PITCH_GAIN                        /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */
#define HARMONIZE_2481_EXTEND_SHRINK                    /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */
#define FIX_FLOAT_ISSUE_1546_DEAD_CODE                  /* FhG: remove dead code reported in the issue*/
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */

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

+448 −417
Original line number Diff line number Diff line
@@ -108,8 +108,9 @@ ivas_error ivas_dec_get_format_fx(
    Word16 nchan_ism, element_mode_flag;
    Word16 sba_order, sba_planar, sba_analysis_order;
    Word32 ivas_total_brate;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    Word16 Opt_tsm;

#endif
    UWord16 *bit_stream_orig;
    AUDIO_CONFIG signaled_config;
    ivas_error error;
@@ -121,8 +122,10 @@ ivas_error ivas_dec_get_format_fx(

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    move32();
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    Opt_tsm = st_ivas->hDecoderConfig->Opt_tsm;
    move16();
#endif
    bit_stream_orig = st_ivas->bit_stream;

    /*-------------------------------------------------------------------*
@@ -141,14 +144,15 @@ ivas_error ivas_dec_get_format_fx(
    test();
    IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) &&
        !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) &&
        !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) )
    {
        IF( Opt_tsm )
        {
        !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();

    return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -157,6 +161,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
}
#endif
}

/*-------------------------------------------------------------------*
@@ -192,14 +197,15 @@ ivas_error ivas_dec_get_format_fx(
        }

        test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
                IF( Opt_tsm )
                {
        IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
            IF( Opt_tsm ){
#endif
                st_ivas->restartNeeded = 1;
        move16();

        return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    }
    ELSE
    {
@@ -208,6 +214,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
    }
#endif
}

st_ivas->nchan_ism = nchan_ism;
@@ -229,14 +236,15 @@ ivas_error ivas_dec_get_format_fx(
    num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) )
            {
                IF( Opt_tsm )
                {
    IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();

    return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -245,6 +253,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" );
}
#endif
}

/* read Ambisonic (SBA) order */
@@ -253,14 +262,15 @@ ivas_error ivas_dec_get_format_fx(
sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );

test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) )
            {
                IF( Opt_tsm )
                {
IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    IF( Opt_tsm ){
#endif
        st_ivas->restartNeeded = 1;
move16();

return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -269,6 +279,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" );
}
#endif
}

sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order );
@@ -284,8 +295,12 @@ ivas_error ivas_dec_get_format_fx(
    k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
    IF( st_ivas->bit_stream[k - 1] )
    {
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        if ( st_ivas->nchan_transport == 1 )
#else
        test();
        if ( st_ivas->nchan_transport == 1 && Opt_tsm )
#endif
        {
            masaRestartCandidate = 1;
            move16();
@@ -298,8 +313,12 @@ ivas_error ivas_dec_get_format_fx(
    }
    ELSE
    {
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        if ( st_ivas->nchan_transport == 2 )
#else
        test();
        if ( st_ivas->nchan_transport == 2 && Opt_tsm )
#endif
        {
            masaRestartCandidate = 1;
            move16();
@@ -347,14 +366,15 @@ ivas_error ivas_dec_get_format_fx(
    }

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
                IF( Opt_tsm )
                {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();

    return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -363,6 +383,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
}
#endif
}

st_ivas->nchan_ism = nchan_ism;
@@ -379,14 +400,15 @@ ivas_error ivas_dec_get_format_fx(
    st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
                IF( Opt_tsm )
                {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();

    return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -395,6 +417,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
}
#endif
}

st_ivas->nchan_ism = nchan_ism;
@@ -407,14 +430,15 @@ ivas_error ivas_dec_get_format_fx(
    nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
                IF( Opt_tsm )
                {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();

    return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -423,6 +447,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
}
#endif
}

st_ivas->nchan_ism = nchan_ism;
@@ -448,14 +473,15 @@ ivas_error ivas_dec_get_format_fx(
}

test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) )
            {
                IF( Opt_tsm )
                {
IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    IF( Opt_tsm ){
#endif
        st_ivas->restartNeeded = 1;
move16();

return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -464,6 +490,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" );
}
#endif
}

st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism );
@@ -488,14 +515,15 @@ ivas_error ivas_dec_get_format_fx(
    signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx );

    test();
            IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) )
            {
                IF( Opt_tsm )
                {
    IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();

    return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
}
ELSE
{
@@ -504,6 +532,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" );
}
#endif
}

st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate );
@@ -600,14 +629,15 @@ ivas_error ivas_dec_get_format_fx(
        k = sub( k, 1 );

        test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
                IF( Opt_tsm )
                {
        IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
            IF( Opt_tsm ){
#endif
                st_ivas->restartNeeded = 1;
        move16();

        return IVAS_ERR_OK;
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    }
    ELSE
    {
@@ -616,6 +646,7 @@ ivas_error ivas_dec_get_format_fx(
#endif
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
    }
#endif
}

st_ivas->nchan_ism = nchan_ism;