Commit 8d55d2b3 authored by vaclav's avatar vaclav
Browse files

Merge branch '1954-basop-PortFlpMr2069' into 'main'

Port MR2069 from float to BASOP - Simplification of lib_dec.c

Closes #1954

See merge request !2164
parents 806f8830 6514cf8d
Loading
Loading
Loading
Loading
+65 −1
Original line number Diff line number Diff line
@@ -405,12 +405,18 @@ int main(

    asked_frame_size = arg.renderFramesize;
    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.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain_fx, arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, 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_fx,
                                       arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
    }

    if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -896,18 +902,30 @@ static bool parseCmdlIVAS_dec(

        if ( strcmp( argv_to_upper, "-VOIP" ) == 0 )
        {
#ifdef LIB_DEC_REVISION
            arg->voipMode = true;
#else
            arg->voipMode = 1;
#endif
            i++;
        }
        else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=0" ) == 0 )
        {
#ifdef LIB_DEC_REVISION
            arg->voipMode = true;
#else
            arg->voipMode = 1;
#endif
            arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP;
            i++;
        }
        else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=1" ) == 0 )
        {
#ifdef LIB_DEC_REVISION
            arg->voipMode = true;
#else
            arg->voipMode = 1;
#endif
            arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF;
            i++;
        }
@@ -988,6 +1006,11 @@ static bool parseCmdlIVAS_dec(
            {
                if ( !is_digits_only( argv[i] ) )
                {
#ifdef LIB_DEC_REVISION
                    fprintf( stderr, "Error: Render frame size is invalid or not specified!\n\n" );
                    usage_dec();
#endif

                    return false;
                }

@@ -1588,6 +1611,7 @@ static ivas_error initOnFirstGoodFrame(
        return error;
    }

#ifndef LIB_DEC_REVISION
    int32_t pcmFrameSize;

    if ( ( error = IVAS_DEC_GetPcmFrameSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK )
@@ -1595,7 +1619,7 @@ static ivas_error initOnFirstGoodFrame(
        fprintf( stderr, "\nError in IVAS_DEC_GetPcmFrameSize, error code: %d\n", error );
        return error;
    }

#endif
    if ( isSplitRend )
    {
        /* Open split rendering metadata writer */
@@ -1653,7 +1677,23 @@ static ivas_error initOnFirstGoodFrame(
        }
    }

#ifdef LIB_DEC_REVISION
    int16_t pcmFrameSize;
    if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_GetOutputBufferSize, error code: %d\n", error );
        return error;
    }

#endif
    int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) );
#ifdef LIB_DEC_REVISION
    if ( zeroBuf == NULL )
    {
        fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" );
        return IVAS_ERR_FAILED_ALLOC;
    }
#endif
    memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) );

    for ( int16_t i = 0; i < numInitialBadFrames; ++i )
@@ -1870,6 +1910,19 @@ static ivas_error decodeG192(
#endif
#endif

#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 );
@@ -2224,7 +2277,11 @@ static ivas_error decodeG192(
            }
            else
            {
#ifdef LIB_DEC_REVISION
                if ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
@@ -2264,6 +2321,9 @@ static ivas_error decodeG192(
            {
                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK )
                {
#ifdef LIB_DEC_REVISION
                    fprintf( stderr, "Error in initOnFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) );
#endif
                    goto cleanup;
                }
            }
@@ -3014,7 +3074,11 @@ static ivas_error decodeVoIP(
        {
            if ( ( error = IVAS_DEC_HasDecodedFirstGoodFrame( hIvasDec, &decodedGoodFrame ) ) != IVAS_ERR_OK )
            {
#ifdef LIB_DEC_REVISION
                fprintf( stderr, "Error in IVAS_DEC_HasDecodedFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) );
#else
                fprintf( stderr, "Error in IVAS_DEC_HasDecodedFirstGoodFrame, code: %d\n", error );
#endif
                goto cleanup;
            }

+5 −2
Original line number Diff line number Diff line
@@ -4220,8 +4220,11 @@ Word64 var_32_fx(
);

ivas_error ivas_jbm_dec_tc_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                      */
#ifndef LIB_DEC_REVISION
    ,
    Word32 *data_fx 
#endif
);

ivas_error ivas_jbm_dec_flush_renderer_fx(
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@
#define FIX_1384_MSAN_ivas_spar_dec_open                /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */
#define FIX_1388_MSAN_ivas_init_decoder                 /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */
#define FIX_1288_SPLIT_REND_XSAN                        /* Dlb: Fix asan, msan and usan issues in split rendering mode*/
#define LIB_DEC_REVISION                                /* VA: cleaning and simplification of lib_dec.c */

// object-editing feature porting
#define OBJ_EDITING_INTERFACE                           /* Interface for object editing */
+9 −2
Original line number Diff line number Diff line
@@ -80,8 +80,11 @@ static Word16 ceil_fx16(
 *--------------------------------------------------------------------------*/

ivas_error ivas_jbm_dec_tc_fx(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure         */
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure         */
#ifndef LIB_DEC_REVISION
    ,
    Word32 *data_fx /*Q11*/
#endif
)
{
    Word16 ch, n, output_frame, nchan_out, i, ii;
@@ -1482,11 +1485,15 @@ ivas_error ivas_jbm_dec_tc_fx(
     * Write IVAS transport channels
     *----------------------------------------------------------------*/

#ifdef LIB_DEC_REVISION
    IF( st_ivas->hDecoderConfig->Opt_tsm == 0 )
#else
    IF( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) )
    {
        ivas_syn_output_f_fx( p_output_fx, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data_fx );
    }
    ELSE
#endif
    {
        /* directly copy to tc buffers */
        /*note : the q of cldfb buffers (imag/real) are needed to be Q_p_output - 5 here 6 is taken for that*/
+16 −1
Original line number Diff line number Diff line
@@ -111,7 +111,9 @@ ivas_error IVAS_DEC_Configure(
    IVAS_DEC_HANDLE hIvasDec,                               /* i/o: IVAS decoder handle                                                     */
    const UWord32 sampleRate,                               /* i  : output sampling frequency                                               */
    const IVAS_AUDIO_CONFIG outputConfig,                   /* i  : output configuration                                                    */
#ifndef LIB_DEC_REVISION
    const bool tsmEnabled,                                  /* i  : enable time scale modification                                          */
    #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                                           */
@@ -155,7 +157,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
);

/*! r: decoder error code */
#ifdef LIB_DEC_REVISION
ivas_error IVAS_DEC_GetSamplesRenderer(
#else
ivas_error IVAS_DEC_GetSamples(
#endif
    IVAS_DEC_HANDLE hIvasDec,                               /* i/o: IVAS decoder handle                                                     */
    const Word16 nSamplesAsked,                             /* i  : number of samples wanted by the caller                                  */
    Word16 *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 Q0 */
@@ -281,11 +287,19 @@ ivas_error IVAS_DEC_VoIP_SetScale(
    const Word16 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

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

#endif
/*! r: error code */
ivas_error IVAS_DEC_VoIP_GetSamples(
    IVAS_DEC_HANDLE hIvasDec,                               /* i/o: IVAS decoder handle                                                     */
@@ -454,12 +468,13 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame(
    bool *hasDecodedFirstGoodFrame                          /* o  : flag indicating if the decoder has decoded a good frame since it was configured */
);

#ifndef LIB_DEC_REVISION
/*! r: error code */
ivas_error IVAS_DEC_GetPcmFrameSize(
    IVAS_DEC_HANDLE hIvasDec,                               /* i/o: IVAS decoder handle                                                     */
    Word32 *pcmFrameSize                                    /* o  : total size of the PCM output frame. This takes into account the number of output channels Q0 */
);

#endif
/*! r: true if decoder has no data in VoIP jitter buffer */
bool IVAS_DEC_VoIP_IsEmpty(
    IVAS_DEC_HANDLE hIvasDec,                               /* i/o: IVAS decoder handle                                                     */
Loading