Commit d0d54aa7 authored by bayers's avatar bayers
Browse files

keep the 20ms JBM householding inside the API, change ISM TD renderer to...

keep the 20ms JBM householding inside the API, change ISM TD renderer to really render subframes and in case of combined orientation use the same MD logic as the TD binaural renderer
parent 8c97318a
Loading
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -3277,13 +3277,6 @@ static ivas_error decodeVoIP(
        }
#endif

#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
        if ( vec_pos_update == 0 )
        {
            IVAS_DEC_VoIP_Set20msStart( hIvasDec );
        }
#endif

        /* read all packets with a receive time smaller than the system time */
        while ( nextPacketRcvTime_ms <= systemTime_ms )
        {
+109 −35
Original line number Diff line number Diff line
@@ -254,31 +254,71 @@ void ivas_ism_render_sf(
    int16_t tc_offset;
    int16_t interp_offset;
    float gain, prev_gain;
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
    int16_t ism_md_subframe_update_jbm, slots_to_render, first_sf, last_sf, subframe_idx;
    int16_t n_samples_rendered_loop;
#endif

    num_objects = st_ivas->nchan_transport;
    if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
    {
        num_objects = st_ivas->nchan_ism;
    }
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
    /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
    slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / st_ivas->hTcBuffer->n_samples_granularity );
    first_sf = st_ivas->hTcBuffer->subframes_rendered;
    last_sf = first_sf;
    n_samples_rendered_loop = 0;

    while ( slots_to_render > 0 )
    {
        slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf];
        last_sf++;
    }

#endif
    nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;

    tc_offset = st_ivas->hTcBuffer->n_samples_rendered;
    interp_offset = st_ivas->hTcBuffer->n_samples_rendered;

#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
    /* Number of subframes to delay metadata to sync with audio */
    if ( st_ivas->hDecoderConfig->Opt_delay_comp )
    {
        ism_md_subframe_update_jbm = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 );
    }
    else
    {
        ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2;
    }

#endif
    for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ )
    {
        set_f( output_f[i], 0.0f, n_samples_to_render );
    }

#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
    for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    {
        int16_t n_samples_in_subframe;

        n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
#endif

#ifdef NONBE_UNIFIED_DECODING_PATHS
        if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
#else
    if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] )
#endif
        {
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
            ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator );
#else
        ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator );
#endif
            interp_offset = 0;
        }

@@ -291,7 +331,18 @@ void ivas_ism_render_sf(
        if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 )
#endif
            {
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
                if ( subframe_idx >= ism_md_subframe_update_jbm )
                {
                    rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
                }
                else
                {
                    rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
                }
#else
            rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup );
#endif

                if ( st_ivas->hEFAPdata != NULL )
                {
@@ -313,10 +364,18 @@ void ivas_ism_render_sf(
                {
                    g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset];
                    tc = &st_ivas->hTcBuffer->tc[i][tc_offset];
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
                    for ( k = 0; k < n_samples_in_subframe; k++ )
#else
                for ( k = 0; k < n_samples_to_render; k++ )
#endif
                    {
                        g2 = 1.0f - *g1;
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
                        output_f[j2][k + n_samples_rendered_loop] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ );
#else
                    output_f[j2][k] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ );
#endif
                    }
                }

@@ -334,8 +393,23 @@ void ivas_ism_render_sf(

#ifdef NONBE_UNIFIED_DECODING_PATHS
        /* update combined orientation access index */
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
        ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_in_subframe );
#else
        ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_to_render );
#endif
#endif
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
        n_samples_rendered_loop += n_samples_in_subframe;
        if ( st_ivas->renderer_type == RENDERER_TD_PANNING )
        {
            st_ivas->hTcBuffer->subframes_rendered += 1;
            st_ivas->hTcBuffer->slots_rendered += st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
        }
        tc_offset += n_samples_in_subframe;
        interp_offset += n_samples_in_subframe;
    }
#endif

    return;
}
+19 −23
Original line number Diff line number Diff line
@@ -134,7 +134,9 @@ static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE
#ifdef NONBE_UNIFIED_DECODING_PATHS
static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize );
#endif

#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesRendered );
#endif

/*---------------------------------------------------------------------*
 * IVAS_DEC_Open()
@@ -787,6 +789,9 @@ ivas_error IVAS_DEC_EnableVoIP(
    hIvasDec->hVoIP->lastDecodedWasActive = 0;
    hIvasDec->hVoIP->hCurrentDataUnit = NULL;
    hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC );
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
    hIvasDec->hVoIP->nSamplesRendered20ms = 0;
#endif

#define WMC_TOOL_SKIP
    /* Bitstream conversion is not counted towards complexity and memory usage */
@@ -1583,6 +1588,9 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples(
    if ( hIvasDec->st_ivas->hTcBuffer != NULL )
    {
        *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered;
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
        *nSamplesBuffered += hIvasDec->hVoIP->nSamplesRendered20ms;
#endif
    }

    return IVAS_ERR_OK;
@@ -2658,7 +2666,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
            }

#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
            extBufferedSamples = hVoIP->nSamplesRendered20ms + nSamplesBuffered;
            extBufferedSamples = nSamplesBuffered;
#else
            extBufferedSamples = nSamplesRendered + nSamplesBuffered;
#endif
@@ -2773,7 +2781,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
            hIvasDec->nSamplesRendered += nSamplesToZero;
            hIvasDec->nSamplesAvailableNext -= nSamplesToZero;
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
            hVoIP->nSamplesRendered20ms += nSamplesToZero;
            update_voip_rendered20ms( hIvasDec, nSamplesToZero );
#endif
        }
        else
@@ -2794,7 +2802,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(

            nSamplesRendered += nSamplesRendered_loop;
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
            hVoIP->nSamplesRendered20ms += nSamplesRendered_loop;
            update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop );
#endif
        }
    }
@@ -2802,31 +2810,19 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
    return IVAS_ERR_OK;
}


#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
/*---------------------------------------------------------------------*
 * IVAS_DEC_VoIP_Set20msStart( )
 * update_voip_rendered20ms( )
 *
 * Function to tell the API that a new 20ms rendered samples border has been reached
 * needed for correct JBM packet buffer operations
 * Function to flush remaining audio in VoIP
 *---------------------------------------------------------------------*/
ivas_error IVAS_DEC_VoIP_Set20msStart(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */
)
{
    ivas_error error;

    error = IVAS_ERR_OK;

    if ( hIvasDec->hVoIP == NULL )
static void update_voip_rendered20ms(
    IVAS_DEC_HANDLE hIvasDec,
    const int16_t nSamplesRendered )
{
        return IVAS_ERR_UNKNOWN;
    }

    hIvasDec->hVoIP->nSamplesRendered20ms = 0;


    return error;
    hIvasDec->hVoIP->nSamplesRendered20ms = ( hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered ) % hIvasDec->hVoIP->nSamplesFrame;
}

#endif
+0 −6
Original line number Diff line number Diff line
@@ -290,12 +290,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
#endif
);

#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
ivas_error IVAS_DEC_VoIP_Set20msStart( 
	IVAS_DEC_HANDLE hIvasDec  /* i/o: IVAS decoder handle */
);
#endif

ivas_error IVAS_DEC_Flush(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    const int16_t nSamplesPerChannel,           /* i  : number of samples per channel requested to be written to output buffer  */