Commit e1956b01 authored by vaclav's avatar vaclav
Browse files

Consolidate writing of TCs

parent bf499a5b
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -783,8 +783,12 @@ void ivas_apply_non_diegetic_panning(
 *----------------------------------------------------------------------------------*/

ivas_error ivas_dec_tc(
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                                      */
#else
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    float *data                                                 /* o  : output synthesis signals                                    */
#endif
);

ivas_error ivas_jbm_dec_flush_renderer(
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ uint32_t ivas_syn_output(
/*-------------------------------------------------------------------*
 * ivas_syn_output_f()
 *
 * Output IVAS synthesis signal into a linear buffer
 * Copy IVAS synthesis signals into a linear buffer
 *-------------------------------------------------------------------*/
#else
/*-------------------------------------------------------------------*
+6 −2
Original line number Diff line number Diff line
@@ -68,8 +68,12 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t
 *--------------------------------------------------------------------------*/

ivas_error ivas_dec_tc(
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure         */
#else
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure         */
    float *data              /* o  : transport channel signals      */
#endif
)
{
    int16_t n, output_frame, nchan_out;
@@ -724,6 +728,7 @@ ivas_error ivas_dec_tc(
        }
    }

#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS
    /*----------------------------------------------------------------*
     * Write IVAS transport channels
     *----------------------------------------------------------------*/
@@ -732,14 +737,13 @@ ivas_error ivas_dec_tc(
    {
        ivas_syn_output_f( p_output, output_frame, nchan_out, data );
    }
#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS
    else
    {
        /* directly copy to tc buffers */
        ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame );
    }
#endif

#endif
    /*----------------------------------------------------------------*
     * Common updates
     *----------------------------------------------------------------*/
+45 −16
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP );
static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs );
#endif
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf );
static ivas_error evs_dec_main( Decoder_Struct *st_ivas );
#else
static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf );
#endif
@@ -121,7 +121,11 @@ static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_form
static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig );
static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts );
static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels );
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec );
#else
static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples );
#endif
static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf );
static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf );
static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered );
@@ -1061,7 +1065,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
    {
        uint16_t l_ts, nTimeScalerOutSamples;
        uint8_t nTransportChannels;
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
        int16_t nResidualSamples, nSamplesTcsScaled;
#else
        int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse;
#endif

        if ( isSplitRend )
        {
@@ -1085,7 +1093,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
        }

        /* IVAS TC decoder */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
        if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec ) ) != IVAS_ERR_OK )
#else
        if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -1098,6 +1110,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
                return IVAS_ERR_UNKNOWN;
            }

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
            ivas_syn_output_f( hIvasDec->st_ivas->p_output_f, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer );

#endif
            if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 )
            {
                return IVAS_ERR_UNKNOWN;
@@ -1984,9 +2000,13 @@ static ivas_error IVAS_DEC_Setup(
 *---------------------------------------------------------------------*/

static ivas_error IVAS_DEC_GetTcSamples(
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle     */
#else
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle                                                     */
    float *pcmBuf,            /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels  */
    int16_t *nOutSamples      /* o  : number of samples per channel written to output buffer                  */
#endif
)
{
    Decoder_Struct *st_ivas;
@@ -1998,13 +2018,14 @@ static ivas_error IVAS_DEC_GetTcSamples(
    }

    st_ivas = hIvasDec->st_ivas;

#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS
    *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
#endif

    if ( hIvasDec->mode == IVAS_DEC_MODE_EVS )
    {
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
        if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf ) ) != IVAS_ERR_OK )
        if ( ( error = evs_dec_main( st_ivas ) ) != IVAS_ERR_OK )
#else
        if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK )
#endif
@@ -2015,7 +2036,11 @@ static ivas_error IVAS_DEC_GetTcSamples(
    else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS )
    {
        /* run the main IVAS decoding routine */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
        if ( ( error = ivas_dec_tc( st_ivas ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -4255,11 +4280,11 @@ void IVAS_DEC_PrintDisclaimer( void )
 *---------------------------------------------------------------------*/

static ivas_error evs_dec_main(
    Decoder_Struct *st_ivas,   /* i/o: IVAS decoder structure           */
    const int16_t nOutSamples, /* i  : number of samples per channel    */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    float *floatBuf /* o  : buffer for decoded PCM output    */
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure           */
#else
    Decoder_Struct *st_ivas,
    const int16_t nOutSamples,
    float *floatBuf,
    int16_t *pcmBuf
#endif
@@ -4268,11 +4293,18 @@ static ivas_error evs_dec_main(
    DEC_CORE_HANDLE *hCoreCoder;
    float mixer_left, mixer_rigth;
    float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN];
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    int16_t ch, nOutSamples;
#else
    int16_t ch;
#endif
    ivas_error error;

    hCoreCoder = st_ivas->hSCE[0]->hCoreCoder;
    hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
#endif

    mdct_switching_dec( hCoreCoder[0] );

@@ -4338,21 +4370,18 @@ static ivas_error evs_dec_main(
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    if ( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /* BE workaround */
        int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN];
        /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */
        int16_t pcm_buf_local[L_FRAME48k];

        if ( floatBuf == NULL )
        for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
        {
            return ( IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "APA buffer is missing in JBM processing\n" ) );
        }

        /* convert 'float' output data to 'short' */
#ifdef DEBUGGING
            st_ivas->noClipping +=
#endif
            ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local );
                ivas_syn_output( &p_output[ch], nOutSamples, 1, pcm_buf_local );

        mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out );
            mvs2r( pcm_buf_local, p_output[ch], nOutSamples );
        }
    }
#else
    if ( !st_ivas->hDecoderConfig->Opt_tsm )