Commit 3812c580 authored by sagnowski's avatar sagnowski
Browse files

Fixed scaling issues when outputting to SPLIT_BINAURAL_PCM from CLDFB split rendering

parent 9f8fb15f
Loading
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -1388,7 +1388,8 @@ static ivas_error isar_generate_metadata_and_bitstream(
    Decoder_Struct *st_ivas,                 /* i/o: IVAS decoder handle                */
    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        */
    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 */
)
{
    // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream,
@@ -1473,7 +1474,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
    }
    // NOTE(sgi): BASOP special - not in float version
    Word16 q1 = 31, q2 = 31, Q_buff = 31;
    Word16 Q_out[CLDFB_NO_COL_MAX]; // NOTE(sgi): Seems unnecessarily large. Only indices 0 and 1 are used, value at index 1 is writen but never read.
    Word16 Q_out[CLDFB_NO_COL_MAX];
    Q_out[0] = 31;

    IF( EQ_16( cldfb_in_flag, 1 ) )
@@ -1530,6 +1531,7 @@ static ivas_error isar_generate_metadata_and_bitstream(
    {
        return error;
    }
    *td_q = Q_out[0];

    return IVAS_ERR_OK;
}
@@ -1751,6 +1753,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    Word16 i;
    Word16 pcm_out_flag;
    Word16 numSamplesPerChannelToOutput;
    Word16 td_q;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
@@ -1782,7 +1785,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 ) ) != IVAS_ERR_OK )
    if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, &td_q ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -1804,7 +1807,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
#ifdef DEBUGGING
        st_ivas->noClipping +=
#endif
            ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out );
            ivas_syn_output_fx( p_head_pose_buf, td_q, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out );
    }
#else
    Decoder_Struct *st_ivas;
@@ -5433,8 +5436,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL )
    {
        Word16 td_q;

        /* 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 ) ) != IVAS_ERR_OK )
        IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -5456,7 +5461,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples
#ifdef DEBUGGING
            st_ivas->noClipping +=
#endif
                ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf );
                ivas_syn_output_fx( p_head_pose_buf, td_q, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf );
        }
    }
#endif