Commit e49b861c authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'main' into 763-add-new-scheduled-sanitizer-tests-for-foa-hoa2-and-combined-formats

parents bb0f4269 f17ca1f1
Loading
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#endif
#ifdef VARIABLE_SPEED_DECODING
#include "tsm_scale_file_reader.h"
#include <math.h>
#endif
#include "vector3_pair_file_reader.h"
#ifdef DEBUGGING
@@ -1224,7 +1225,9 @@ static bool parseCmdlIVAS_dec(
            i++;
            int32_t tmp = 100;
            arg->tsmEnabled = true;
#ifndef NONBE_UNIFIED_DECODING_PATHS
            arg->enable5ms = true;
#endif
            if ( i < argc - 3 )
            {
                if ( !is_digits_only( argv[i] ) )
@@ -2120,6 +2123,7 @@ static ivas_error decodeG192(
    /* we always start with needing a new frame */
    needNewFrame = true;

#ifndef FIX_899_VARIABLE_SPEED_DECODING
#ifdef DEBUGGING
#ifdef VARIABLE_SPEED_DECODING
    /*------------------------------------------------------------------------------------------*
@@ -2146,6 +2150,7 @@ static ivas_error decodeG192(
        }
    }
#endif
#endif
#endif

    if ( !arg.quietModeEnabled )
@@ -2191,6 +2196,45 @@ static ivas_error decodeG192(
    }
#endif

#ifdef FIX_899_VARIABLE_SPEED_DECODING
#ifdef DEBUGGING
#ifdef VARIABLE_SPEED_DECODING
    /*------------------------------------------------------------------------------------------*
     * Open TSM scale file or set global TSM scale
     *------------------------------------------------------------------------------------------*/

    if ( arg.tsmEnabled )
    {
        if ( arg.tsmScaleFileEnabled )
        {
            if ( ( tsmScaleFileReader = TsmScaleFileReader_open( arg.tsmScaleFileName ) ) == NULL )
            {
                fprintf( stderr, "\nError: Can't open TSM scale file %s \n\n", arg.tsmScaleFileName );
                goto cleanup;
            }
        }
        else
        {
            int16_t maxScaling;
            /* max scaling as abs diff to the normal frame size in samples */
            maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) );
            if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, arg.tsmScale ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }
        /* set lowest possbile TSM quality to make sure it is applied as much as possible */
        if ( ( error = IVAS_DEC_TSM_SetQuality( hIvasDec, -2.0f ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_TSM_SetQuality failed: %s \n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
    }
#endif
#endif
#endif

    /*------------------------------------------------------------------------------------------*
     * Loop for every packet (frame) of bitstream data
     * - Read the bitstream packet
@@ -2343,7 +2387,14 @@ static ivas_error decodeG192(
                        fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename );
                        goto cleanup;
                    }
#ifdef FIX_899_VARIABLE_SPEED_DECODING
                    int16_t maxScaling;
                    /* max scaling as abs diff to the normal frame size in samples */
                    maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) );
                    if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, arg.tsmScale ) ) != IVAS_ERR_OK )
#else
                    if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, scale, scale ) ) != IVAS_ERR_OK )
#endif
                    {
                        fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
@@ -2415,6 +2466,22 @@ static ivas_error decodeG192(
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif
#ifdef FIX_899_VARIABLE_SPEED_DECODING
            if ( needNewFrame )
            {
                frame++;
                if ( !arg.quietModeEnabled )
                {
                    fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame );
#ifdef DEBUGGING
                    if ( IVAS_DEC_GetBerDetectFlag( hIvasDec ) )
                    {
                        fprintf( stdout, "\n   Decoding error: BER detected in frame %d !!!!!\n", frame - 1 );
                    }
#endif
                }
            }
#endif

        } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK );

@@ -2538,6 +2605,7 @@ static ivas_error decodeG192(
            }
        }
        vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len;
#ifndef FIX_899_VARIABLE_SPEED_DECODING
        if ( needNewFrame )
        {
            frame++;
@@ -2552,6 +2620,7 @@ static ivas_error decodeG192(
#endif
            }
        }
#endif
#ifdef WMOPS
        if ( vec_pos_update == 0 )
        {

lib_com/options.h

100644 → 100755
+3 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@
#define FIX_643_PCA_OPTION                              /* VA: issue 643: rename PCA bypass command-line option */

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

#define FIX_899_VARIABLE_SPEED_DECODING                       /* FhG: Fix variable speed decoding                                    */

/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt selection floating point code */
@@ -165,6 +165,8 @@
#define NONBE_FIX_871_ACELP_CRASH_IN_OSBA                     /* FhG: isse 871: crash in ACELP core encoder with OSBA */
#define NONBE_FIX_225_MASA_EXT_REND                           /* Nokia: Resolve #225: Complete MASA external renderer implementation */
#define NONBE_FIX_897_USAN_WITH_MASA_RENDERING                /* Nokia: issue #897: USAN null pointer in MASA external renderer to Ambisonics */
#define NONBE_FIX_903_OSBA_TO_STEREO                          /* VA: issue 903: fix OSBA to stereo rendering issue */
#define NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT                     /* FhG: issue 811: change double precision functions to float in DFT Stereo */

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

+14 −0
Original line number Diff line number Diff line
@@ -1186,13 +1186,27 @@ ivas_error ivas_jbm_dec_render(
            {
                *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );

#ifdef NONBE_FIX_903_OSBA_TO_STEREO
                /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case */
                if ( st_ivas->nchan_ism == 1 )
                {
                    mvr2r( p_output[2], p_output[3], *nSamplesRendered );
                    mvr2r( p_output[1], p_output[2], *nSamplesRendered );
                    p_tc[3] = p_output[3];
                }
#endif

                /* render objects */
                ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered );

                /* add already rendererd SBA part */
                for ( n = 0; n < nchan_out; n++ )
                {
#ifdef NONBE_FIX_903_OSBA_TO_STEREO
                    v_add( p_output[n], p_tc[n + max( nchan_out, st_ivas->nchan_ism )], p_output[n], *nSamplesRendered );
#else
                    v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered );
#endif
                }
            }
            else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )

lib_dec/ivas_stereo_dft_dec.c

100644 → 100755
+8 −0
Original line number Diff line number Diff line
@@ -135,10 +135,18 @@ static void stereo_dft_dequantize_res_gains_f(

        /* compensate for the offset and extract/remove sign of first index */
        sign = ind1[i] < 15 ? -1 : 1;
#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT
        i1 = (int16_t) floorf( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 );
#else
        i1 = (int16_t) floor( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 );
#endif
        fi = ( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ) - i1;

#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT
        j1 = (int16_t) floorf( ind2[i] );
#else
        j1 = (int16_t) floor( ind2[i] );
#endif
        fj = ind2[i] - j1;

        /* choose base indices for interpolation */
+49 −3
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ struct IVAS_DEC
    bool Opt_VOIP;           /* flag indicating VOIP mode with JBM */
    int16_t tsm_scale;       /* scale for TSM operation */
    int16_t tsm_max_scaling;
#ifdef FIX_899_VARIABLE_SPEED_DECODING
    float tsm_quality;
#endif
    float *apaExecBuffer; /* Buffer for APA scaling */
    PCMDSP_APA_HANDLE hTimeScaler;
    bool needNewFrame;
@@ -163,6 +166,10 @@ ivas_error IVAS_DEC_Open(
    hIvasDec->apaExecBuffer = NULL;
    hIvasDec->hTimeScaler = NULL;
    hIvasDec->tsm_scale = 100;
#ifdef FIX_899_VARIABLE_SPEED_DECODING
    hIvasDec->tsm_max_scaling = 0;
    hIvasDec->tsm_quality = 1.0f;
#endif
    hIvasDec->needNewFrame = false;
    hIvasDec->nTransportChannelsOld = 0;
    hIvasDec->nSamplesAvailableNext = 0;
@@ -488,7 +495,12 @@ ivas_error IVAS_DEC_Configure(
    hIvasDec->nSamplesAvailableNext = 0;
    hIvasDec->nSamplesRendered = 0;
    hIvasDec->tsm_scale = 100;
#ifdef FIX_899_VARIABLE_SPEED_DECODING
    hIvasDec->tsm_max_scaling = 0;
    hIvasDec->tsm_quality = 1.0f;
#else
    hIvasDec->tsm_max_scaling = 100;
#endif

    return error;
}
@@ -2528,8 +2540,8 @@ ivas_error IVAS_DEC_VoIP_FeedFrame(

ivas_error IVAS_DEC_VoIP_SetScale(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle                                                         */
    const int16_t maxScaling,
    const int16_t scale /* i  : TSM scale to set                            */
    const int16_t maxScaling, /* i  : max allowed absolute difference in samples from the default 20ms frame size */
    const int16_t scale       /* i  : TSM scale to set in percent of the default frame size                       */
)
{
    ivas_error error;
@@ -2549,6 +2561,36 @@ ivas_error IVAS_DEC_VoIP_SetScale(
    return error;
}

#ifdef FIX_899_VARIABLE_SPEED_DECODING
/*---------------------------------------------------------------------*
 * IVAS_DEC_VoIP_SetScale( )
 *
 * Set the TSM scale
 *---------------------------------------------------------------------*/

ivas_error IVAS_DEC_TSM_SetQuality(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle                                                         */
    const float quality       /* i  : target TSM quality                                                          */
)
{
    ivas_error error;

    error = IVAS_ERR_OK;

    if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false )
    {
        return IVAS_ERR_TSM_NOT_ENABLED;
    }
    else
    {
        hIvasDec->tsm_quality = quality;
    }

    return error;
}

#endif


/*---------------------------------------------------------------------*
 * IVAS_DEC_VoIP_GetSamples( )
@@ -3634,7 +3676,11 @@ static ivas_error IVAS_DEC_VoIP_reconfigure(
            uint16_t wss, css;
            float startQuality;

#ifdef FIX_899_VARIABLE_SPEED_DECODING
            startQuality = hIvasDec->tsm_quality;
#else
            startQuality = 1.0f;
#endif
            apa_buffer_size = APA_BUF_PER_CHANNEL;

            /* get current renderer type*/
Loading