Commit 8721de1f authored by vaclav's avatar vaclav
Browse files

Merge branch '1930-ref-PortFlpMr1775' into 'ivas-float-update'

Port MR1775 from float to FLP-ref

See merge request !2126
parents 764ffb9b 5712c437
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -594,8 +594,16 @@ int main(
            fprintf( stdout, "FEC:                    %.2f %%\n", arg.FER );
        }
    }
#else
#ifdef FIX_VOIP_FUNCTIONS
    if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
    }
#else
    IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode );
#endif
#endif

    /*-------------------------------------------------------------------*
+1 −0
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@
#define FIX_1101_CLEANING_JBM_CALL                      /* VA: issue 1101: remove obsolete call of ivas_jbm_dec_tc_buffer_open() */
#define NONBE_FIX_1337_MISSING_DIRECTIVITY_DISTATT_EXTREND /* Eri: issue 1337: Missing directivity setting and distance attenuation in external renderer IVAS_rend */
#define FIX_1348_OVERFLOW                               /* FhG: fix BASOP overflow in hq_lr_dec(), brings floating-point code inline with FX */
#define FIX_VOIP_FUNCTIONS                              /* VA: fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to API functions */
#define FIX_587_DEFAULT_REVERB                          /* Philips: issue 587: inconsistent default reverb parameters across renderers */
#define NONBE_1214_PLC_LSF_MEMORY                       /* VA: issue 1224: reset ACELP PLC FEC memory in case of switching from MDCT stereo to TD/DFT stereo */

+111 −22
Original line number Diff line number Diff line
@@ -422,7 +422,6 @@ ivas_error IVAS_DEC_Configure(
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;

    error = IVAS_ERR_OK;
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
@@ -521,7 +520,7 @@ ivas_error IVAS_DEC_Configure(
    hIvasDec->tsm_max_scaling = 0;
    hIvasDec->tsm_quality = 1.0f;

    return error;
    return IVAS_ERR_OK;
}


@@ -557,7 +556,7 @@ ivas_error IVAS_DEC_EnableSplitRendering(
 * Get the 5ms flag
 *---------------------------------------------------------------------*/

int16_t get_render_frame_size_ms(
static int16_t get_render_frame_size_ms(
    const IVAS_RENDER_FRAMESIZE render_framesize )
{
    return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) );
@@ -717,9 +716,6 @@ ivas_error IVAS_DEC_EnableVoIP(
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;

    error = IVAS_ERR_OK;


    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
@@ -776,7 +772,7 @@ ivas_error IVAS_DEC_EnableVoIP(
        return IVAS_ERR_FAILED_ALLOC;
    }

    return error;
    return IVAS_ERR_OK;
}


@@ -1090,6 +1086,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    int16_t ro_md_flag;
    IVAS_QUATERNION Quaternion;

#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
#endif

    error = IVAS_ERR_OK;
    st_ivas = hIvasDec->st_ivas;
    output_config = st_ivas->hDecoderConfig->output_config;
@@ -1526,6 +1529,13 @@ ivas_error IVAS_DEC_GetFormat(
    IVAS_DEC_BS_FORMAT *format /* o  : format detected from bitstream fed to the decoder */
)
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    if ( hIvasDec->hasDecodedFirstGoodFrame )
    {
        *format = mapIvasFormat( hIvasDec->st_ivas->ivas_format );
@@ -1534,12 +1544,14 @@ ivas_error IVAS_DEC_GetFormat(
    {
        *format = IVAS_DEC_BS_UNKOWN;
    }

#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
    if ( *format == IVAS_DEC_BS_MASA && hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT )
    {
        *format = IVAS_DEC_BS_MASA_ISM;
    }
#endif

    return IVAS_ERR_OK;
}

@@ -1619,6 +1631,13 @@ ivas_error IVAS_DEC_GetNumOutputChannels(
    int16_t *numOutputChannels /* o  : number of PCM output channels   */
)
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    if ( hIvasDec->hasDecodedFirstGoodFrame )
    {
        *numOutputChannels = hIvasDec->st_ivas->hDecoderConfig->nchan_out;
@@ -2392,7 +2411,11 @@ static bool isSidFrame(
    return false;
}

static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits )

static void bsCompactToSerial(
    const uint8_t *compact,
    uint16_t *serial,
    const uint16_t num_bits )
{
/* Bitstream conversion is not counted towards complexity and memory usage */
#define WMC_TOOL_SKIP
@@ -2441,6 +2464,13 @@ ivas_error IVAS_DEC_VoIP_FeedFrame(
    int16_t partialCopyFrameType, partialCopyOffset;
    int16_t result;

#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || au == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    if ( auSize == 0 )
    {
        return IVAS_ERR_OK; /* ignore empty/NO_DATA frame - shouldn't be transmitted in RTP */
@@ -2519,9 +2549,12 @@ ivas_error IVAS_DEC_VoIP_SetScale(
    const int16_t scale       /* i  : TSM scale to set in percent of the default frame size                       */
)
{
    ivas_error error;

    error = IVAS_ERR_OK;
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
#endif

    if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false )
    {
@@ -2533,13 +2566,21 @@ ivas_error IVAS_DEC_VoIP_SetScale(
        hIvasDec->tsm_max_scaling = maxScaling;
    }

    return error;
    return IVAS_ERR_OK;
}

/*---------------------------------------------------------------------*
 * IVAS_DEC_VoIP_SetScale( )
 * IVAS_DEC_TSM_SetQuality( )
 *
 * Set the TSM scale
 * set the quality theshold for the time scale modiciation that is used
 * to determine if the TSM yielded a signal that satisfies the minimum
 * quality requirements.
 * quality is lower limit for minimum quality
 * Range is [-2;2] - where positive values allow
 * only pasting with same phase information
 * Negative values would yield cross phased pasting
 * When not setting the minimum quality with this function the default
 * value used is 1.0f
 *---------------------------------------------------------------------*/

ivas_error IVAS_DEC_TSM_SetQuality(
@@ -2547,11 +2588,14 @@ ivas_error IVAS_DEC_TSM_SetQuality(
    const float quality       /* i  : target TSM quality    */
)
{
    ivas_error error;

    error = IVAS_ERR_OK;
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false )
#endif
    if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm )
    {
        return IVAS_ERR_TSM_NOT_ENABLED;
    }
@@ -2560,7 +2604,7 @@ ivas_error IVAS_DEC_TSM_SetQuality(
        hIvasDec->tsm_quality = quality;
    }

    return error;
    return IVAS_ERR_OK;
}


@@ -2594,6 +2638,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
    int16_t nSamplesRendered;
    uint8_t nOutChannels;

#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->hVoIP == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    st_ivas = hIvasDec->st_ivas;
    hDecoderConfig = st_ivas->hDecoderConfig;
    hVoIP = hIvasDec->hVoIP;
@@ -2764,13 +2815,18 @@ static void update_voip_rendered20ms(
    const int16_t nSamplesRendered )
{
    int16_t nSamplesRenderedTotal;

    nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered;

    /* we have crossed a 20ms border, reset the time scaling done flag */
    if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame )
    {
        hIvasDec->timeScalingDone = 0;
    }

    hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame;

    return;
}


@@ -2792,6 +2848,13 @@ ivas_error IVAS_DEC_Flush(
    uint16_t nSamplesToRender;
    uint16_t nSamplesFlushedLocal;

#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext );

    nSamplesToRender = (uint16_t) *nSamplesFlushed;
@@ -2806,6 +2869,7 @@ ivas_error IVAS_DEC_Flush(
    {
        *nSamplesFlushed = 0;
    }

    return error;
}

@@ -2820,6 +2884,13 @@ bool IVAS_DEC_VoIP_IsEmpty(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
    const int16_t nSamplesAsked )
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) );
}

@@ -2923,10 +2994,13 @@ static void store_JbmData(
ivas_error IVAS_DEC_GetJbmData(
    IVAS_DEC_HANDLE hIvasDec,         /* i/o: IVAS decoder handle */
    IVAS_JBM_TRACE_DATA *JbmTraceData /* o  : JBM Trace data      */

)
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || JbmTraceData == NULL )
#else
    if ( hIvasDec->hVoIP == NULL )
#endif
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
@@ -3151,14 +3225,29 @@ static ivas_error printConfigInfo_dec(
 * Print decoder set-up info
 *---------------------------------------------------------------------*/

#ifdef FIX_VOIP_FUNCTIONS
ivas_error IVAS_DEC_PrintConfig(
#else
void IVAS_DEC_PrintConfig(
#endif
    const IVAS_DEC_HANDLE hIvasDec,
    const bool quietModeEnabled,
    const bool voipMode )
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#endif
    printConfigInfo_dec( hIvasDec->st_ivas, hIvasDec->bitstreamformat, voipMode, quietModeEnabled );

#ifdef FIX_VOIP_FUNCTIONS
    return IVAS_ERR_OK;
#else
    return;
#endif
}


+16 −12
Original line number Diff line number Diff line
@@ -483,7 +483,11 @@ const char *IVAS_DEC_GetErrorMessage(
    ivas_error error                            /* i  : decoder error code enum                                                 */
);

#ifdef FIX_VOIP_FUNCTIONS
ivas_error IVAS_DEC_PrintConfig(
#else
void IVAS_DEC_PrintConfig(
#endif
    const IVAS_DEC_HANDLE hIvasDec,             /* i  : IVAS decoder handle                                                     */
    const bool quietModeEnabled,                /* i  : quiet mode flag: if true, reduces the amount of config info printed      */
    const bool voipMode