Commit c20a7e41 authored by vaclav's avatar vaclav
Browse files

address comments

parent 1adf8e1a
Loading
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -259,11 +259,7 @@ int main(
     * Open decoder handle
     *------------------------------------------------------------------------------------------*/

#ifdef LIB_DEC_REVISION
    if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.output_Fs, arg.decMode ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.decMode ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
@@ -450,7 +446,7 @@ int main(
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535;

#ifdef LIB_DEC_REVISION
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.voipMode, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled,
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled,
                                       arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled,
                                       arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
#else
@@ -1242,7 +1238,7 @@ static bool parseCmdlIVAS_dec(
                if ( !is_digits_only( argv[i] ) )
                {
#ifdef LIB_DEC_REVISION
                    fprintf( stderr, "Error: Render frame size not specified!\n\n" );
                    fprintf( stderr, "Error: Render frame size is invalid or not specified!\n\n" );
                    usage_dec();
#endif
                    return false;
@@ -2122,6 +2118,19 @@ static ivas_error decodeG192(
    SplitFileReadWrite *splitRendWriter = NULL;
    int16_t isSplitRend, isSplitCoded;

#ifdef VARIABLE_SPEED_DECODING
#ifdef LIB_DEC_REVISION
    if ( arg.tsmEnabled )
    {
        if ( ( error = IVAS_DEC_EnableTsm( hIvasDec ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_DEC_EnableTsm, code: %d\n", error );
            return error;
        }
    }

#endif
#endif
    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error );
+95 −24
Original line number Diff line number Diff line
@@ -81,7 +81,9 @@ struct IVAS_DEC
    bool isInitialized;

    int16_t bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */
#ifdef DEBUGGING
    bool Opt_VOIP; /* flag indicating VOIP mode with JBM */
#endif
    int16_t tsm_scale; /* scale for TSM operation */
    int16_t tsm_max_scaling;
    int16_t timeScalingDone; /* have we done already one TSM in a 20ms frame? */
@@ -159,9 +161,6 @@ static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nS
/* may return an error but may still have allocated memory - thus run Close also in case of error to release memory */
ivas_error IVAS_DEC_Open(
    IVAS_DEC_HANDLE *phIvasDec, /* i/o: pointer to an IVAS decoder handle to be opened  */
#ifdef LIB_DEC_REVISION
    const int32_t output_Fs, /* i  : output sampling frequency                       */
#endif
    const IVAS_DEC_MODE mode    /* i  : compatibility mode (EVS or IVAS)                */
)
{
@@ -192,12 +191,10 @@ ivas_error IVAS_DEC_Open(
    hIvasDec->needNewFrame = false;
    hIvasDec->nTransportChannelsOld = 0;
    hIvasDec->nSamplesAvailableNext = 0;
#ifdef LIB_DEC_REVISION
    hIvasDec->nSamplesFrame = (uint16_t) ( output_Fs / FRAMES_PER_SEC );
#else
#ifndef LIB_DEC_REVISION
    hIvasDec->nSamplesRendered = 0;
    hIvasDec->nSamplesFrame = 0;
#endif
    hIvasDec->nSamplesFrame = 0;
    hIvasDec->hasBeenFedFrame = false;
    hIvasDec->hasBeenFedFirstGoodFrame = false;
    hIvasDec->hasDecodedFirstGoodFrame = false;
@@ -211,7 +208,9 @@ ivas_error IVAS_DEC_Open(
    hIvasDec->mode = mode;

    hIvasDec->bitstreamformat = G192;
#ifdef DEBUGGING
    hIvasDec->Opt_VOIP = 0;
#endif
    hIvasDec->amrwb_rfc4867_flag = -1;
    hIvasDec->prev_ft_speech = 1; /* RXDTX handler previous frametype flag for G.192 format AMRWB SID_FIRST detection */
    hIvasDec->CNG = 0;            /* RXDTX handler CNG = 1, no CNG = 0*/
@@ -433,6 +432,32 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat(
    return IVAS_DEC_BS_UNKOWN;
}

#ifdef LIB_DEC_REVISION

/*---------------------------------------------------------------------*
 * create_flush_buffer()
 *
 * Create flush buffer - needed for binaural outputs with TSM or in VoIP mode
 *---------------------------------------------------------------------*/

static ivas_error create_flush_buffer(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle            */
)
{
    hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) );
    if ( hIvasDec->flushbuffer == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate JBM flush buffer" );
    }

    hIvasDec->pcmType = IVAS_DEC_PCM_INT16;
    set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES );

    return IVAS_ERR_OK;
}

#endif


/*---------------------------------------------------------------------*
 * IVAS_DEC_Configure( )
@@ -445,10 +470,9 @@ ivas_error IVAS_DEC_Configure(
    IVAS_DEC_HANDLE hIvasDec,        /* i/o: IVAS decoder handle                        */
    const uint32_t sampleRate,       /* i  : output sampling frequency                  */
    const AUDIO_CONFIG outputConfig, /* i  : output configuration                       */
#ifdef LIB_DEC_REVISION
    const bool voipMode, /* i  : enable VoIP mode with JBM                  */
#endif
#ifndef LIB_DEC_REVISION
    const bool tsmEnabled, /* i  : enable TSM                                 */
#endif
    const IVAS_RENDER_FRAMESIZE renderFramesize,       /* i  : rendering frame size                       */
    const bool customLsOutputEnabled,                  /* i  : enable custom loudspeaker setup handle     */
    const bool hrtfReaderEnabled,                      /* i  : enable HRTF binary file input              */
@@ -507,7 +531,9 @@ ivas_error IVAS_DEC_Configure(
        hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config );
    }

#ifndef LIB_DEC_REVISION
    hDecoderConfig->Opt_tsm = (int16_t) tsmEnabled;
#endif
    hDecoderConfig->Opt_LsCustom = (int16_t) customLsOutputEnabled;
    hDecoderConfig->Opt_Headrotation = (int16_t) enableHeadRotation;
    hDecoderConfig->orientation_tracking = orientation_tracking;
@@ -554,21 +580,16 @@ ivas_error IVAS_DEC_Configure(
        hIvasDec->st_ivas->ivas_format = MONO_FORMAT;
    }

#ifndef LIB_DEC_REVISION
    hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC );
#ifndef LIB_DEC_REVISION
    hIvasDec->nSamplesAvailableNext = 0;
    hIvasDec->nSamplesRendered = 0;
    hIvasDec->tsm_scale = 100;
    hIvasDec->tsm_max_scaling = 0;
    hIvasDec->tsm_quality = 1.0f;
#endif
#ifdef LIB_DEC_REVISION
    /* Create flush buffer - needed for binaural outputs with TSM or in VoIP mode */
    if ( ( tsmEnabled || voipMode ) && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
#else

    /* Init flush buffer if necessary (only needed for binaural)*/
    if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
#endif
    {
        hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) );
        if ( hIvasDec->flushbuffer == NULL )
@@ -578,6 +599,7 @@ ivas_error IVAS_DEC_Configure(
        hIvasDec->pcmType = IVAS_DEC_PCM_INT16;
        set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES );
    }
#endif

    return IVAS_ERR_OK;
}
@@ -785,8 +807,11 @@ ivas_error IVAS_DEC_EnableVoIP(

    hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig;

#ifdef DEBUGGING
    hIvasDec->Opt_VOIP = 1;
#endif
    hDecoderConfig->Opt_tsm = 1;

    if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
    {
        hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config );
@@ -835,6 +860,7 @@ ivas_error IVAS_DEC_EnableVoIP(
    {
        return IVAS_ERR_FAILED_ALLOC;
    }

#ifdef NONBE_1122_KEEP_EVS_MODE_UNCHANGED
    if ( hIvasDec->mode == IVAS_DEC_MODE_EVS )
    {
@@ -842,8 +868,14 @@ ivas_error IVAS_DEC_EnableVoIP(
    }
#endif

#ifndef LIB_DEC_REVISION
    /* init flush buffer if necessary (only needed for binaural)*/
#ifdef LIB_DEC_REVISION
    /* init flush buffer (needed for binaural outputs) */
    if ( ( error = create_flush_buffer( hIvasDec ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in create_flush_buffer , code: %d\n", error );
        return error;
    }
#else
    if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
    {
        hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) );
@@ -851,6 +883,7 @@ ivas_error IVAS_DEC_EnableVoIP(
        set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES );
    }
#endif

    return IVAS_ERR_OK;
}

@@ -3759,6 +3792,43 @@ ivas_error IVAS_DEC_VoIP_SetScale(
    return IVAS_ERR_OK;
}

#ifdef VARIABLE_SPEED_DECODING
#ifdef LIB_DEC_REVISION

/*---------------------------------------------------------------------*
 * IVAS_DEC_EnableTsm( )
 *
 * Enable Time-Scale Modification (TSM)
 *---------------------------------------------------------------------*/

ivas_error IVAS_DEC_EnableTsm(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle   */
)
{
    AUDIO_CONFIG output_config;
    ivas_error error;

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

    hIvasDec->st_ivas->hDecoderConfig->Opt_tsm = 1;

    /* init flush buffer if necessary (only needed for binaural) */
    output_config = hIvasDec->st_ivas->hDecoderConfig->output_config;
    if ( hIvasDec->flushbuffer == NULL && ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        if ( ( error = create_flush_buffer( hIvasDec ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    return IVAS_ERR_OK;
}

#endif

/*---------------------------------------------------------------------*
 * IVAS_DEC_TSM_SetQuality( )
@@ -3797,6 +3867,7 @@ ivas_error IVAS_DEC_TSM_SetQuality(
    return IVAS_ERR_OK;
}

#endif

/*---------------------------------------------------------------------*
 * IVAS_DEC_VoIP_GetSamples( )
@@ -4057,7 +4128,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
/*---------------------------------------------------------------------*
 * update_voip_rendered20ms( )
 *
 * Return number of samples that have been rendered since the last 20ms render border
 * Update the number of samples that have been rendered since the last 20ms render border
 *---------------------------------------------------------------------*/

static void update_voip_rendered20ms(
@@ -4955,7 +5026,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure(

    l_ts = (uint16_t) hIvasDec->st_ivas->hTcBuffer->n_samples_granularity;

    if ( isInitialized_voip == false )
    if ( !isInitialized_voip )
#else
    apa_buffer_size = hIvasDec->nSamplesFrame;

+11 −8
Original line number Diff line number Diff line
@@ -114,9 +114,6 @@ typedef ivas_error ( *JbmTraceFileWriterFn )( const void *data, void *writer );
/*! r: error code */
ivas_error IVAS_DEC_Open(
    IVAS_DEC_HANDLE *phIvasDec,                 /* i/o: pointer to an IVAS decoder handle to be opened                          */
#ifdef LIB_DEC_REVISION
    const int32_t output_Fs,                    /* i  : output sampling frequency                                               */
#endif
    IVAS_DEC_MODE mode                          /* i  : compatibility mode (EVS or IVAS)                                        */
);

@@ -125,10 +122,9 @@ ivas_error IVAS_DEC_Configure(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    const uint32_t sampleRate,                  /* i  : output sampling frequency                                               */
    const IVAS_AUDIO_CONFIG outputConfig,       /* i  : audio configuration                                                     */
#ifdef LIB_DEC_REVISION
    const bool voipMode,                        /* i  : enable VoIP mode with JBM                                               */
#endif 
#ifndef LIB_DEC_REVISION
    const bool tsmEnabled,                      /* i  : enable TSM                                                              */
    #endif
    const IVAS_RENDER_FRAMESIZE renderFramesize,/* i  : rendering frame size                                                    */
    const bool customLsOutputEnabled,           /* i  : enable custom loudspeaker setup handle                                  */
    const bool hrtfReaderEnabled,               /* i  : enable HRTF binary file input                                           */
@@ -301,12 +297,19 @@ ivas_error IVAS_DEC_VoIP_SetScale(
    const int16_t scale                         /* i  : TSM scale to set                                                        */
);

#ifdef VARIABLE_SPEED_DECODING
#ifdef LIB_DEC_REVISION
ivas_error IVAS_DEC_EnableTsm(
    IVAS_DEC_HANDLE hIvasDec                    /* i/o: IVAS decoder handle                                                     */
);
#endif

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

#endif
/*! r: error code */
ivas_error IVAS_DEC_VoIP_GetSamples(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */