Commit 6a9ab0a3 authored by vaclav's avatar vaclav
Browse files

merge MEM_ALLOC_APP_DEC_JBM into MEM_ALLOC_APP_DEC

parent 1c1ff30b
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2474,7 +2474,7 @@ static ivas_error decodeG192(
            }
            else
            {
#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
                if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame, 1 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
@@ -3290,7 +3290,7 @@ static ivas_error decodeVoIP(

        /* decode and get samples */
#ifdef SUPPORT_JBM_TRACEFILE
#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
        int16_t nSamplesRendered_pre = 0;

        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered_pre, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
@@ -3298,7 +3298,7 @@ static ivas_error decodeVoIP(
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
        int16_t nSamplesRendered_pre = 0;

        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered_pre ) ) != IVAS_ERR_OK )
@@ -3311,7 +3311,7 @@ static ivas_error decodeVoIP(
            goto cleanup;
        }

#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
        /* Reconfigure IVAS decoder handles and reallocate the memory if IVAS total bitrate has changed */
        uint16_t nSamplesRendered2 = 0;
        if ( ( error = IVAS_DEC_Setup( hIvasDec, &nSamplesRendered2, IVAS_DEC_PCM_INT16, pcmBuf + nSamplesRendered_pre * nOutChannels ) ) != IVAS_ERR_OK )
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@

#define MEM_ALLOC_APP                                   /* VA: call memory allocate/reallocation from the application */ 
#define MEM_ALLOC_APP_DEC                               /* VA: call memory allocate/reallocation from the application, decoder part */ 
#define MEM_ALLOC_APP_DEC_JBM


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

+20 −31
Original line number Diff line number Diff line
@@ -891,17 +891,17 @@ ivas_error IVAS_DEC_FeedFrame_Serial(
 * Main function to decode to PCM data
 *---------------------------------------------------------------------*/


ivas_error IVAS_DEC_GetSamples(
    IVAS_DEC_HANDLE hIvasDec,        /* i/o: IVAS decoder handle                                                     */
    const int16_t nSamplesAsked,     /* i  : number of samples wanted by the caller                                  */
    const IVAS_DEC_PCM_TYPE pcmType, /* i  : type for the decoded PCM resolution                                     */
    void *pcmBuf,                    /* o  : output synthesis signal                                                 */
    int16_t *nOutSamples,            /* o  : number of samples per channel written to output buffer                  */
#ifdef MEM_ALLOC_APP_DEC
    bool *needNewFrame,       /* o  : indication that the decoder needs a new frame                           */
    const int16_t flag_decode /* i  : flag to indicate decoding                                               */
#else
    bool *needNewFrame /* o  : indication that the decoder needs a new frame                           */
#ifdef MEM_ALLOC_APP_DEC_JBM
    ,
    const int16_t flag_decode
#endif
)
{
@@ -979,25 +979,14 @@ ivas_error IVAS_DEC_GetSamples(
        /* check if we need to run the setup function */
        if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame )
        {
#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
            if ( flag_decode == 0 )
            {
                /* do not run decoder */
                *nOutSamples = -1;

                return IVAS_ERR_OK;
            }
#endif

#ifdef MEM_ALLOC_APP_DEC
#ifndef MEM_ALLOC_APP_DEC_JBM
            if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) // ToDo: TBD for JBM
            {
                if ( ( error = IVAS_DEC_Setup( hIvasDec, &nSamplesRendered, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#endif

            if ( hIvasDec->mode == IVAS_DEC_MODE_EVS )
            {
@@ -1232,7 +1221,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    }

    /* Decode and render */
#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
    if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame, 1 ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK )
@@ -1386,8 +1375,6 @@ static
        /* no frame was fed, do nothing */
        return IVAS_ERR_OK;
    }
#endif
#ifdef MEM_ALLOC_APP_DEC_JBM

    if ( !( hIvasDec->hasBeenFedFirstGoodFrame && ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) ) )
    {
@@ -2699,10 +2686,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
    uint16_t nSamplesPerChannel,     /* i  : number of samples per channel requested to be written to output buffer                  */
    const IVAS_DEC_PCM_TYPE pcmType, /* i  : type for the decoded PCM resolution          */
    void *pcmBuf,                    /* o  : output synthesis signal                      */
#ifdef MEM_ALLOC_APP_DEC
    const uint32_t systemTimestamp_ms, /* i  : current system timestamp                    */
    int16_t *nSamplesRendered_pre      /* o  : number of already rendered samples          */
#else
    const uint32_t systemTimestamp_ms /* i  : current system timestamp                    */
#ifdef MEM_ALLOC_APP_DEC_JBM
    ,
    int16_t *nSamplesRendered_pre
#endif
#ifdef SUPPORT_JBM_TRACEFILE
    ,
@@ -2868,7 +2856,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
            nSamplesToRender = nSamplesPerChannel - nSamplesRendered;

            /* render IVAS frames  directly to the output buffer */
#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
            if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp, 0 ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK )
@@ -2877,9 +2865,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
                return error;
            }

#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
            if ( nSamplesRendered_loop == -1 )
            {
                /* stop the rendering for now */
                *nSamplesRendered_pre = nSamplesRendered;

                break;
@@ -2894,7 +2883,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
    return IVAS_ERR_OK;
}

#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC

/*---------------------------------------------------------------------*
 * IVAS_DEC_GetSamples_wrapper( )
+9 −6
Original line number Diff line number Diff line
@@ -168,9 +168,11 @@ ivas_error IVAS_DEC_GetSamples(
    const IVAS_DEC_PCM_TYPE pcmType,            /* i  : type for the decoded PCM resolution                                     */
    void *pcmBuf,                               /* o  : output synthesis signal                                                 */
    int16_t *nOutSamples,                       /* o  : number of samples per channel written to output buffer                  */
#ifdef MEM_ALLOC_APP_DEC
    bool *needNewFrame,                         /* o  : indication that the decoder needs a new frame                           */
    const int16_t flag_decode                   /* i  : flag to indicate decoding                                               */
#else
    bool *needNewFrame                          /* o  : indication that the decoder needs a new frame                           */
#ifdef MEM_ALLOC_APP_DEC_JBM
    ,const int16_t flag_decode
#endif
);

@@ -296,10 +298,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
    uint16_t nSamplesPerChannel,                /* i  : number of samples per channel requested to be written to output buffer  */
    const IVAS_DEC_PCM_TYPE pcmType,            /* i  : type for the decoded PCM resolution                                     */
    void *pcmBuf,                               /* o  : output synthesis signal                                                 */
#ifdef MEM_ALLOC_APP_DEC
    const uint32_t systemTimestamp_ms,          /* i  : current system timestamp                                                */
    int16_t *nSamplesRendered_pre               /* o  : number of already rendered samples                                      */
#else
    const uint32_t systemTimestamp_ms           /* i  : current system timestamp                                                */
#ifdef MEM_ALLOC_APP_DEC_JBM
    ,
    int16_t *nSamplesRendered_pre
#endif
#ifdef SUPPORT_JBM_TRACEFILE
    , JbmTraceFileWriterFn jbmWriterFn,
@@ -307,7 +310,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
#endif
);

#ifdef MEM_ALLOC_APP_DEC_JBM
#ifdef MEM_ALLOC_APP_DEC
ivas_error IVAS_DEC_GetSamples_wrapper(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    const int16_t nSamplesAsked,                /* i  : number of samples wanted by the caller                                  */