Commit aa97c903 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

Merge branch 'split_rend_debug_cleanup' into 'float-pc'

[skip-name-check] Split rend clean up of stale debug functions in ivas_binRenderer_internal.c

See merge request !1745
parents d5f7a0ca 34936644
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -5207,20 +5207,6 @@ ivas_error ivas_allocate_binaural_hrtf(
    const int16_t allocate_init_flag                            /* i  : Memory allocation flag                          */
);

#ifdef DEBUGGING
void ivas_binaural_cldfb(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                  */
    float *output_f[]                                           /* i/o: synthesized core-coder transport channels/DirAC output  */
);

void ivas_binaural_cldfb_sf(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                  */
    const int16_t n_samples_to_render,                          /* i  : output frame length per channel                         */
    const int16_t slot_size,                                    /* i  : JBM slot size                                           */
    float *output_f[]                                           /* i/o: synthesized core-coder transport channels/DirAC output  */
);
#endif

void ivas_binRenderer(
    BINAURAL_RENDERER_HANDLE hBinRenderer,                      /* i/o: binaural renderer handle                                */
#ifdef SPLIT_REND_WITH_HEAD_ROT
+0 −323
Original line number Diff line number Diff line
@@ -1583,329 +1583,6 @@ void ivas_binaural_add_LFE(
}


#ifdef DEBUGGING
/*-------------------------------------------------------------------------*
 * ivas_binaural_cldfb()
 *
 * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis
 *-------------------------------------------------------------------------*/

void ivas_binaural_cldfb(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                                  */
    float *output_f[]        /* i/o: synthesized core-coder transport channels/DirAC output  */
)
{
    float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#else
    float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#endif
    int16_t slot_idx, subframeIdx, index_slot, idx_in, idx_lfe, maxBand, ch;

    /* Implement a 5 msec loops */
    maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 );

    for ( subframeIdx = 0; subframeIdx < ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ); subframeIdx++ )
    {
        for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ )
        {
            index_slot = subframeIdx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx;

            /* Implement CLDFB analysis */
            idx_in = 0;
            idx_lfe = 0;

            for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ )
            {
                if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[idx_lfe] == ch ) )
                {
                    if ( idx_lfe < ( st_ivas->hIntSetup.num_lfe - 1 ) )
                    {
                        idx_lfe++;
                    }
                }
                else
                {
                    cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }
            }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            /*LFE handling for split rendering cases*/
            if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
            {
                for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ )
                {
                    ch = st_ivas->hIntSetup.index_lfe[idx_lfe];
                    cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }

                if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL )
                {
                    for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ )
                    {
                        mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand );
                        mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand );
                    }
                    st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config;
                }
            }
#endif
        }

        /* Implement binaural rendering */
        ivas_binRenderer(
            st_ivas->hBinRenderer,
#ifdef SPLIT_REND_WITH_HEAD_ROT
            &st_ivas->hSplitBinRend.splitrend.multiBinPoseData,
#endif
            st_ivas->hCombinedOrientationData,
            JBM_CLDFB_SLOTS_IN_SUBFRAME,
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
            NULL,
#endif
            Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural,
            Cldfb_RealBuffer, Cldfb_ImagBuffer );

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            int16_t pos_idx;
            for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ )
            {
                if ( st_ivas->hIntSetup.num_lfe > 0 )
                {
                    v_multc( Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand );
                    v_multc( Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand );
                }
            }

            for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
            {
                for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ )
                {
                    for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
                    {
                        if ( st_ivas->hIntSetup.num_lfe > 0 )
                        {
                            v_add( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx],
                                   Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx],
                                   Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx],
                                   maxBand );

                            v_add( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx],
                                   Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx],
                                   Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx],
                                   maxBand );
                        }

                        mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand );
                        mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand );
                    }
                }
            }
        }
#endif
        /* update combined orientation access index */
        ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES );

        /* Implement CLDFB synthesis */
        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
            float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];

            index_slot = subframeIdx * MAX_PARAM_SPATIAL_SUBFRAMES;

            for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx];
                ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx];
#else
                RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch][slot_idx];
                ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch][slot_idx];
#endif
            }

            cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * maxBand] ), maxBand * MAX_PARAM_SPATIAL_SUBFRAMES, st_ivas->cldfbSynDec[ch] );
        }
    }

    return;
}


/*-------------------------------------------------------------------------*
 * ivas_binaural_cldfb_sf()
 *
 * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis
 *-------------------------------------------------------------------------*/

void ivas_binaural_cldfb_sf(
    Decoder_Struct *st_ivas,           /* i/o: IVAS decoder structure                                  */
    const int16_t n_samples_to_render, /* i  : output frame length per channel                         */
    const int16_t slot_size,           /* i  : JBM slot size                                           */
    float *output_f[]                  /* i/o: synthesized core-coder transport channels/DirAC output  */
)
{
    float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#else
    float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#endif
    int16_t slot_idx, subframeIdx, index_slot, idx_in, idx_lfe, maxBand, ch;
    int16_t slots_to_render, first_sf, last_sf;
    int16_t slot_index_start, slot_index_start_cldfb;

    /* Implement a 5 msec loops */
    maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 );

    /* 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 / slot_size );
    first_sf = st_ivas->hTcBuffer->subframes_rendered;
    last_sf = first_sf;
    slot_index_start = st_ivas->hTcBuffer->slots_rendered;
    slot_index_start_cldfb = 0;
    st_ivas->hTcBuffer->slots_rendered += slots_to_render;

    while ( slots_to_render > 0 )
    {
        slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf];
        last_sf++;
    }
    for ( subframeIdx = first_sf; subframeIdx < last_sf; subframeIdx++ )
    {
        for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ )
        {
            index_slot = slot_index_start + slot_idx;

            /* Implement CLDFB analysis */
            idx_in = 0;
            idx_lfe = 0;

            for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ )
            {
                if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[idx_lfe] == ch ) )
                {
                    if ( idx_lfe < ( st_ivas->hIntSetup.num_lfe - 1 ) )
                    {
                        idx_lfe++;
                    }
                }
                else
                {
                    cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }
            }
<<<<<<< HEAD

#ifdef SPLIT_REND_WITH_HEAD_ROT
                /*LFE handling for split rendering cases*/
                if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
                     ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
            {
                for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ )
                {
                    ch = st_ivas->hIntSetup.index_lfe[idx_lfe];
                    cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }

#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL )
                {
                    for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ )
                    {
                        mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][slot_index_start + slot_idx], maxBand );
                        mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_index_start + slot_idx], maxBand );
                    }
                    st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config;
                }
#endif
            }
#endif
            == == == =
>>>>>>> float-pc
        }

        /* Implement binaural rendering */
        ivas_binRenderer(
            st_ivas->hBinRenderer,
#ifdef SPLIT_REND_WITH_HEAD_ROT
            &st_ivas->hSplitBinRend.splitrend.multiBinPoseData,
#endif
            st_ivas->hCombinedOrientationData,
            st_ivas->hTcBuffer->subframe_nbslots[subframeIdx],
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
            NULL,
#endif
            Cldfb_RealBuffer_Binaural,
            Cldfb_ImagBuffer_Binaural,
            Cldfb_RealBuffer,
            Cldfb_ImagBuffer );

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            int16_t pos_idx;
            for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
            {
                for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ )
                {
                    for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
                    {
                        mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand );
                        mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand );
                    }
                }
            }
        }
#endif

        /* update combined orientation access index */
        ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] );

        /* Implement CLDFB synthesis */
        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];
            float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES];

            for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx];
                ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx];
#else
        RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch][slot_idx];
        ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch][slot_idx];
#endif
            }

            cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_index_start_cldfb * maxBand] ), maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], st_ivas->cldfbSynDec[ch] );
        }
        slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx];
        slot_index_start_cldfb += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx];
    }

    st_ivas->hTcBuffer->subframes_rendered = last_sf;

    return;
}
#endif


/*-------------------------------------------------------------------------
 * ivas_binRenderer()
 *
+0 −6
Original line number Diff line number Diff line
@@ -1127,12 +1127,6 @@ ivas_error ivas_jbm_dec_render(
                    return error;
                }
            }
#ifdef DEBUGGING
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
            {
                ivas_binaural_cldfb_sf( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->nb_subframes, p_output );
            }
#endif
        }
    }
    else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT )