Commit 67a435e5 authored by emerit's avatar emerit
Browse files

typo and bug fix

parent 633890a5
Loading
Loading
Loading
Loading
+10 −297
Original line number Diff line number Diff line
@@ -880,7 +880,7 @@ static ivas_error ivas_binaural_hrtf_open_fx(
#endif
            move32();
        }
        if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) )
        IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) )
        {
#ifdef FIX_CREND_SIMPLIFY_CODE
            HrtfFastConv->FASTCONV_latency_s_fx = FASTCONV_HOA2_latency_s_fx;
@@ -891,7 +891,7 @@ static ivas_error ivas_binaural_hrtf_open_fx(
            move32();
#endif
        }
        if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) )
        IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) )
        {
#ifdef FIX_CREND_SIMPLIFY_CODE
            HrtfFastConv->FASTCONV_latency_s_fx = FASTCONV_HOA3_latency_s_fx;
@@ -902,7 +902,7 @@ static ivas_error ivas_binaural_hrtf_open_fx(
            move32();
#endif
        }
        if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) )
        IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) )
        {
#ifdef FIX_CREND_SIMPLIFY_CODE
            HrtfFastConv->FASTCONV_latency_s_fx = FASTCONV_FOA_latency_s_fx;
@@ -1891,294 +1891,6 @@ void ivas_binaural_add_LFE_fx(
    return;
}

#ifdef FIX_CREND_SIMPLIFY_CODE
#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];
    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];
    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++;
                }
            }
            /*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;
                }
            }
        }

        /* Implement binaural rendering */
        ivas_binRenderer(
            st_ivas->hBinRenderer,
            &st_ivas->hSplitBinRend->splitrend.multiBinPoseData,
            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 );

        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 );
                    }
                }
            }
        }

        /* 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++ )
            {
                RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx];
                ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx];
            }

            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];
    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];
    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++;
                }
            }

            /*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][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;
                }
            }
        }

        /* Implement binaural rendering */
        ivas_binRenderer(
            st_ivas->hBinRenderer,
            &st_ivas->hSplitBinRend->splitrend.multiBinPoseData,
            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 );

        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 );
                    }
                }
            }
        }

        /* 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++ )
            {
                RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx];
                ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx];
            }

            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
#endif

/*-------------------------------------------------------------------------
 * ivas_binRenderer_fx()
 *
@@ -2223,13 +1935,7 @@ void ivas_binRenderer_fx(
    /* Head rotation in HOA3 or CICPx */
    test();
    test();
#ifdef FIX_CREND_SIMPLIFY_CODE
    test();
    IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 &&
        ( NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) && NE_16( hBinRenderer->nInChannels, HOA2_CHANNELS ) && NE_16( hBinRenderer->nInChannels, FOA_CHANNELS ) ) )
#else
    IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb )
#endif
    {
        IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 )
        {
@@ -2257,7 +1963,14 @@ void ivas_binRenderer_fx(

    /* HOA decoding to CICP19 if needed*/
    test();
#ifdef FIX_CREND_SIMPLIFY_CODE
    test();
    test();
    IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 &&
        ( NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) && NE_16( hBinRenderer->nInChannels, HOA2_CHANNELS ) && NE_16( hBinRenderer->nInChannels, FOA_CHANNELS ) ) )
#else
    IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) )
#endif
    {
        ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx,
                                 hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx );
+6 −6
Original line number Diff line number Diff line
@@ -1111,12 +1111,8 @@ typedef struct
typedef struct
{
#ifdef FIX_989_TD_REND_ROM
    int16_t elevDim3;
    const Word32 *elevKSeq_fx; /* Array, length elevDim3-2       */
    int16_t azimDim3;
    const Word32 *azimKSeq_fx; /* Array, length azimDim3-2            */
    const Word32 *W_fx;        /* Array, size (elevDim3*azimDim3) x K */
    Word16 W_e;
    Word16 elevDim3;
    Word16 azimDim3;
#else
    Word16 N; /* Polynomial degree */

@@ -1144,6 +1140,10 @@ typedef struct
#endif
    Word16 elevSegSamples;
    Word16 resamp_factor_fx; /*Q14*/
    const Word32 *elevKSeq_fx; /* Array, length elevDim3-2       */
    const Word32 *azimKSeq_fx; /* Array, length azimDim3-2            */
    const Word32 *W_fx;        /* Array, size (elevDim3*azimDim3) x K */
    Word16 W_e;
    const Word32 *azimBsShape_fx;
    const Word32 *elevBsShape_fx;