Commit 63b2e559 authored by vaclav's avatar vaclav
Browse files

fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to VoIP...

fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to VoIP API functions; under FIX_VOIP_FUNCTIONS
parent 26e40740
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -590,8 +590,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
@@ -183,6 +183,7 @@
#define FIX_1166_TDREND_DIV0                            /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */
#define FIX_835_PARAMMC_BUFFER_VALUES                   /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */
#define FIX_1161_REDUCE_OMASA_HEAP                      /* VA: reduction of OMASA heap memory */
#define FIX_VOIP_FUNCTIONS                              /* VA: fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to API functions */

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

+111 −3
Original line number Diff line number Diff line
@@ -444,7 +444,9 @@ ivas_error IVAS_DEC_Configure(
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;

#ifndef FIX_VOIP_FUNCTIONS
    error = IVAS_ERR_OK;
#endif
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
@@ -554,7 +556,11 @@ ivas_error IVAS_DEC_Configure(
    }
#endif

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


@@ -750,9 +756,9 @@ ivas_error IVAS_DEC_EnableVoIP(
{
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;

#ifndef FIX_VOIP_FUNCTIONS
    error = IVAS_ERR_OK;

#endif

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
@@ -820,7 +826,11 @@ ivas_error IVAS_DEC_EnableVoIP(
    }
#endif

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


@@ -1674,6 +1684,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;
@@ -2117,6 +2134,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 );
@@ -2210,6 +2234,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;
@@ -3007,7 +3038,10 @@ 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
@@ -3056,6 +3090,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 */
@@ -3134,11 +3175,22 @@ ivas_error IVAS_DEC_VoIP_SetScale(
    const int16_t scale       /* i  : TSM scale to set in percent of the default frame size                       */
)
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
#else
    ivas_error error;

    error = IVAS_ERR_OK;
#endif

#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == 0 )
#else
    if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false )
#endif
    {
        return IVAS_ERR_TSM_NOT_ENABLED;
    }
@@ -3148,7 +3200,11 @@ ivas_error IVAS_DEC_VoIP_SetScale(
        hIvasDec->tsm_max_scaling = maxScaling;
    }

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


@@ -3172,6 +3228,13 @@ ivas_error IVAS_DEC_TSM_SetQuality(
    const float quality       /* i  : target TSM quality    */
)
{
#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 )
    {
        return IVAS_ERR_TSM_NOT_ENABLED;
@@ -3222,6 +3285,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
#endif
    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;
@@ -3459,13 +3529,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;
}


@@ -3487,6 +3562,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;
@@ -3515,6 +3597,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 ) );
}

@@ -3621,7 +3710,11 @@ ivas_error IVAS_DEC_GetJbmData(

)
{
#ifdef FIX_VOIP_FUNCTIONS
    if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || JbmTraceData == NULL )
#else
    if ( hIvasDec->hVoIP == NULL )
#endif
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
@@ -3933,14 +4026,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->hVoIP == 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
}


+4 −0
Original line number Diff line number Diff line
@@ -513,7 +513,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