Commit cb041813 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

fix bugs in lib rend

parent aa36b6b4
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1411,7 +1411,7 @@ static void QuantizeSpectrumDPCM_Opt(
                    FOR( k = 0; k < piGroupLengths[n]; k++ )
                    {
                        /* prediction */
                        fReal_fx = L_sub_sat( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) );
                        fReal_fx = L_sub( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) );
                        fImag_fx = L_add( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevImag_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevReal_fx ) );
                        ppiQReal_fx = Quantize_fx( L_add_sat( L_shr_r_sat( ppfReal_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), fReal_fx ), /* quantize residual */
                                                   fSCFGain_fx,
@@ -1426,7 +1426,7 @@ static void QuantizeSpectrumDPCM_Opt(
                        ppiQImag[iBlockOffset][iFBOffset] = L_shr( ppiQImag_fx, 21 );

                        ppiQReal_fx = L_shl( ppiQReal[iBlockOffset][iFBOffset], 21 );
                        fPrevReal_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQReal_fx,
                        fPrevReal_fx = L_sub( L_shl( UnQuantize_fx( ppiQReal_fx,
                                                                        fInvSCFGain_fx,
                                                                        ppiSignReal[iBlockOffset][iFBOffset] ),
                                                         9 ),
@@ -1434,7 +1434,7 @@ static void QuantizeSpectrumDPCM_Opt(
                        /* add prediction to quantized residual = reconstructed sample */

                        ppiQImag_fx = L_shl( ppiQImag[iBlockOffset][iFBOffset], 21 );
                        fPrevImag_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQImag_fx,
                        fPrevImag_fx = L_sub( L_shl( UnQuantize_fx( ppiQImag_fx,
                                                                        fInvSCFGain_fx,
                                                                        ppiSignImag[iBlockOffset][iFBOffset] ),
                                                         9 ),
+43 −3
Original line number Diff line number Diff line
@@ -1641,7 +1641,7 @@ static ivas_error alignInputDelay(
    const IVAS_REND_ReadOnlyAudioBuffer inputAudio,
    const Word32 maxGlobalDelayNs,
    const Word32 sampleRateOut,
    const Word16 cldfb2tdSampleFact,
    const Word16 cldfb2tdSampleShift,
    const bool flushInputs )
{
    ivas_error error;
@@ -1650,7 +1650,7 @@ static ivas_error alignInputDelay(
    UWord16 ringBufferSize, preDelay;

    maxGlobalDelaySamples = latencyNsToSamples( sampleRateOut, maxGlobalDelayNs );
    maxGlobalDelaySamples = i_mult( maxGlobalDelaySamples, cldfb2tdSampleFact );
    maxGlobalDelaySamples = shl( maxGlobalDelaySamples, cldfb2tdSampleShift );

    /* check if we need to open the delay buffer */
    IF( inputBase->delayBuffer == NULL )
@@ -1661,7 +1661,7 @@ static ivas_error alignInputDelay(

        /* pre delay for this input is maximum delay - input delay */
        preDelay = sub( maxGlobalDelaySamples,
                        i_mult( inputBase->delayNumSamples, cldfb2tdSampleFact ) );
                        shl( inputBase->delayNumSamples, cldfb2tdSampleShift ) );

        IF( GT_32( preDelay, 0 ) )
        {
@@ -9422,6 +9422,46 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream(
        }
    }

    Word16 q1 = 31, q2 = 31, Q_buff, j;
    Word16 num_poses = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses;

    FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ )
    {
        FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ )
        {
            q1 = s_min( q1, L_norm_arr( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) );
            q2 = s_min( q2, L_norm_arr( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) );
        }
    }
    Q_buff = s_min( q1, q2 );
    FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ )
    {
        FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ )
        {
            scale_sig32( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff );
            scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff );
        }
    }
    Q_buff = Q_buff + *outAudio.pq_fact;

    IF( EQ_16( cldfb_in_flag, 0 ) )
    {
        /*TD input*/
        num_poses = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses;

        FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i )
        {
            Q_out[0] = s_min( Q_out[0], L_norm_arr( tmpBinaural_buff[i], L_FRAME48k ) );
        }

        FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i )
        {
            scale_sig32( tmpBinaural_buff[i], L_FRAME48k, Q_out[0] );
        }

        Q_out[0] = Q_out[0] + *outAudio.pq_fact;
    }

    max_bands = extract_l( Mpy_32_32( imult3216( hIvasRend->sampleRateOut, BINAURAL_MAXBANDS ), 44740 /* 1/48000 in Q31 */ ) );
    IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper,
                                                         hIvasRend->headRotData.headPositions[0],