Commit 566780d2 authored by thomas dettbarn's avatar thomas dettbarn
Browse files

Merge branch '2102_basop_split-rendering-in-voip-mode' of...

Merge branch '2102_basop_split-rendering-in-voip-mode' of https://forge.3gpp.org/rep/sa4/audio/ivas-basop into 2102_basop_split-rendering-in-voip-mode
parents 1d9b752a 9f39d1a8
Loading
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2581,7 +2581,20 @@ ivas_error ivas_jbm_dec_render_fx(
    IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */
        const Word32* p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];

        nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses;

        /* Save TD signals for pose correction if they are to be used */
        if ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL )
        {
            FOR( i = 0; i < nchan_out_syn_output; i++ )
            {
                p_output_fx_const[i] = p_output_fx[i];
            }
            ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); // TODO(sgi): change num_samples_per_channel to unsigned
        }

#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR  // TODO(sgi): verify if this is needed in BASOP
        if ( st_ivas->flushing )
        {
+29 −18
Original line number Diff line number Diff line
@@ -1357,6 +1357,7 @@ static ivas_error isar_render_poses(
    }
#endif


    IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) )
    {
#if 1 /* NOTE(sgi): Workaround for bit width mismatch */
@@ -1375,6 +1376,8 @@ static ivas_error isar_render_poses(
        // NOTE(det2sgi): Was the requirement for the TD_Ringbuf a 32 Bit Datatype? A 16 Bit would make more sense.
        ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples );
    }
// NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here.
// To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer.

    return error;
}
@@ -1391,7 +1394,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
    Word32 **p_head_pose_buf,                               /* i/o: PCM buffer with head-pose data     */
    Word16 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        */
    Word16* td_q                             /* o  : Q-format of the TD output if rendering from CLDFB */
    Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]    /* o  : Q-format of each channel of p_head_pose_buf */
)
{
    // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream,
@@ -1457,10 +1460,12 @@ static ivas_error isar_generate_metadata_and_bitstream(
    IF ( st_ivas->hBinRendererTd != NULL )
    {
        ro_md_flag = 1;
        move16();
    }
    ELSE
    {
        ro_md_flag = 0;
        move16();
    }

    IF( st_ivas->hHeadTrackData != NULL )
@@ -1475,8 +1480,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
        Quaternion.z_fx = 0;
    }
    // NOTE(sgi): BASOP special - not in float version
    Word16 q1 = 31, q2 = 31, Q_buff = 31;
    Word16 Q_out[CLDFB_NO_COL_MAX];
    Word16 q1 = 31, q2 = 31, Q_buff;
    Q_out[0] = 31;

    IF( EQ_16( cldfb_in_flag, 1 ) )
@@ -1518,6 +1522,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
        }
        Q_out[0] = add( Q_out[0], Q11 );
        Q_out[1] = Q_out[0];
        Q_buff = Q31 + Q6; // TODO(sgi): likely unneeded
    }

    IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend,
@@ -1534,11 +1539,6 @@ static ivas_error isar_generate_metadata_and_bitstream(
        return error;
    }

    IF( EQ_16( cldfb_in_flag, 1 ) )
    {
        *td_q = Q_out[0];
    }

    return IVAS_ERR_OK;
}
#endif /* FIX_1119_SPLIT_RENDERING_VOIP */
@@ -1759,8 +1759,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    Word16 i;
    Word16 pcm_out_flag;
    Word16 numSamplesPerChannelToOutput;
    Word16 td_q = 11;
    Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS];

    test();
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
@@ -1791,7 +1792,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        p_head_pose_buf[i] = head_pose_buf[i];
    }

    if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, &td_q ) ) != IVAS_ERR_OK )
    if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -1799,6 +1800,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */
    if ( pcm_out_flag )
    {
        FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
        {
            scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11
        }
        if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS )
        {
#ifndef DISABLE_LIMITER
@@ -1813,7 +1818,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
#ifdef DEBUGGING
        st_ivas->noClipping +=
#endif
            ivas_syn_output_fx( p_head_pose_buf, td_q, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out );
            ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out );
    }
#else
    Decoder_Struct *st_ivas;
@@ -5442,10 +5447,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL )
    {
        Word16 td_q = 11;;
        Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS];
        Word16 i;

        /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */
        IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK )
        IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -5453,6 +5459,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples
        /* Synthesise PCM output if split PCM */
        IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
            {
                scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11
            }

            IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS )
            {
#ifndef DISABLE_LIMITER
@@ -5467,7 +5478,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples
#ifdef DEBUGGING
            st_ivas->noClipping +=
#endif
                ivas_syn_output_fx( p_head_pose_buf, td_q, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf );
                ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf );
        }
    }
#endif