Commit 9f446259 authored by sagnowski's avatar sagnowski
Browse files

Pop from ring buffers in one unified place

parent 1dd03e7c
Loading
Loading
Loading
Loading
+17 −18
Original line number Diff line number Diff line
@@ -1933,6 +1933,7 @@ static ivas_error isar_render_poses(
static ivas_error isar_generate_metadata_and_bitstream(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle                                       */
    float **p_head_pose_buf,
    int16_t nSamples,                        /* i  : duration of audio (in samples per channel) for which metadata should be generated */
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o  : output split rendering bits                               */
)
{
@@ -1943,10 +1944,10 @@ static ivas_error isar_generate_metadata_and_bitstream(
    ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend;
    int16_t max_band;
    int16_t pcm_out_flag;
    int16_t td_input;
    int16_t cldfb_in_flag;
    int16_t ro_md_flag;
    IVAS_QUATERNION Quaternion;
    int16_t i, j, num_poses, num_cldfb_slots;
    int16_t i, j, num_poses, num_cldfb_slots, n_samples_in_cldfb_slot;
    float *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX];
    float *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX];

@@ -1958,12 +1959,15 @@ static ivas_error isar_generate_metadata_and_bitstream(

    max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 );
    pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC;
    cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas );

    if ( !td_input )
    if ( cldfb_in_flag )
    {
        n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
        assert( nSamples % n_samples_in_cldfb_slot == 0 );
        num_cldfb_slots = nSamples / n_samples_in_cldfb_slot;

        num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses;
        num_cldfb_slots = (int16_t) hIvasDec->st_ivas->hDecoderConfig->render_framesize * JBM_CLDFB_SLOTS_IN_SUBFRAME;

        for ( i = 0; i < (int16_t) ( BINAURAL_CHANNELS * num_poses ); ++i )
        {
@@ -1988,6 +1992,11 @@ static ivas_error isar_generate_metadata_and_bitstream(
            }
        }
    }
    else
    {
        ivas_TD_RINGBUF_PopChannels( hIvasDec->st_ivas->hSplitBinRend->hMultiBinTdData, p_head_pose_buf, nSamples );
    }


    if ( st_ivas->hBinRendererTd != NULL )
    {
@@ -2019,7 +2028,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
                                                          splitRendBits,
                                                          p_Cldfb_RealBuffer_Binaural,
                                                          p_Cldfb_ImagBuffer_Binaural,
                                                          max_band, p_head_pose_buf, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK )
                                                          max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -2083,12 +2092,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        p_head_pose_buf[i] = head_pose_buf[i];
    }

    if ( !ivas_dec_split_rend_cldfb_in( st_ivas ) )
    {
        ivas_TD_RINGBUF_PopChannels( hIvasDec->st_ivas->hSplitBinRend->hMultiBinTdData, p_head_pose_buf, *nOutSamples );
    }

    error = isar_generate_metadata_and_bitstream( hIvasDec, p_head_pose_buf, splitRendBits );
    error = isar_generate_metadata_and_bitstream( hIvasDec, p_head_pose_buf, *nOutSamples, splitRendBits );
    if ( error != IVAS_ERR_OK )
    {
        return error;
@@ -3981,13 +3985,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples
            p_head_pose_buf[i] = head_pose_buf[i];
        }

        if ( !ivas_dec_split_rend_cldfb_in( st_ivas ) )
        {
            ivas_TD_RINGBUF_PopChannels( hIvasDec->st_ivas->hSplitBinRend->hMultiBinTdData, p_head_pose_buf, *nSamplesRendered );
        }

        /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */
        error = isar_generate_metadata_and_bitstream( hIvasDec, p_head_pose_buf, splitRendBits );
        error = isar_generate_metadata_and_bitstream( hIvasDec, p_head_pose_buf, *nSamplesRendered, splitRendBits );
        if ( error != IVAS_ERR_OK )
        {
            return error;