Commit 407b6c41 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Updated Q-format fixed-point representation for RT60 reverberation times (Q31 -> Q27)

parent b631ba1c
Loading
Loading
Loading
Loading
Loading
+904 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@
/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF   */           /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */

#define FIX_1024_REMOVE_PARAMMC_MIXING_MAT              /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */
#define FIX_1741_REVERB_TIMES_Q_FORMAT                  /* Philips: reverberation times in Q27 format instead of Q31 */

/* #################### End BASOP porting switches ############################ */

+4 −0
Original line number Diff line number Diff line
@@ -503,7 +503,11 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx(
                Copy( hrtfShCoeffsIm_fx[i][j], hrtfParambin->hrtfShCoeffsIm_fx[i][j], HRTF_NUM_BINS ); /*Q14*/
            }
        }
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX );                   /*Q27*/
#else
        Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX );                   /*Q31*/
#endif
        Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/
        Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX );           /*Q28*/
        *hHrtfParambin = hrtfParambin;
+30 −0
Original line number Diff line number Diff line
@@ -219,7 +219,11 @@ static void ivas_binaural_reverb_setPreDelay_fx(
static void ivas_binaural_reverb_setReverbTimes_fx(
    REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle                                  */
    const Word32 output_Fs,       /* i  : sampling_rate                                           */
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
    const Word32 *revTimes_fx,    /*Q27 i  : reverberation times T60 for each CLDFB bin in seconds   */
#else
    const Word32 *revTimes_fx,    /*Q31 i  : reverberation times T60 for each CLDFB bin in seconds   */
#endif
    const Word32 *revEnes_fx      /*Q31 i  : spectrum for reverberated sound at each CLDFB bin       */
)
{
@@ -324,7 +328,11 @@ static void ivas_binaural_reverb_setReverbTimes_fx(
        /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */
        L_tmp = Mpy_32_32( 1677721600, revTimes_fx[bin] ); // e10 --> 800 * 2^21, + e0
        tmp = BASOP_Util_Divide3232_Scale( 1073741824, L_tmp, &scale );
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        scale = add( scale, sub( 1, 14 ) ); // revTimes_fx in Q27
#else
        scale = add( scale, sub( 1, 10 ) );
#endif
        L_tmp = Mpy_32_16_1( -1610612736, tmp ); // * -3
        scale = add( 2, scale );
        L_tmp = Mpy_32_32( 1783446563, L_tmp ); // scale + 2
@@ -2386,7 +2394,11 @@ static ivas_error ivas_binaural_reverb_open_fx(
    const Word16 numBins,               /* i  : Q0 number of CLDFB bins                                    */
    const Word16 numCldfbSlotsPerFrame, /* i  : Q0 number of CLDFB slots per frame                         */
    const Word32 sampling_rate,         /* i  : Q0 sampling rate                                           */
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
    const Word32 *revTimes_fx,          /* i  : Q27 reverberation times T60 for each CLDFB bin in seconds   */
#else
    const Word32 *revTimes_fx,          /* i  : Q31 reverberation times T60 for each CLDFB bin in seconds   */
#endif
    const Word32 *revEnes_fx,           /* i  : Q31 spectrum for reverberated sound at each CLDFB bin       */
    const Word16 preDelay               /* i  : Q0 reverb pre-delay in CLDFB slots                         */
)
@@ -2446,9 +2458,15 @@ static ivas_error ivas_binaural_reverb_open_fx(
         * but not excessively long loops to generate reverberation. */
        /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */
        // hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 );
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 19 ), 19 );
        L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q18 );
        hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 18 ); /*Q0*/
#else
        Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 23 ), 23 );
        L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q22 );
        hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 22 ); /*Q0*/
#endif
        move16();
        hReverb->loopBufLength[bin] = s_min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] );

@@ -2541,7 +2559,11 @@ ivas_error ivas_binaural_reverb_init(
        }

        preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX );
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        floatToFixed_arrL( t60_temp, t60, Q27, CLDFB_NO_CHANNELS_MAX );
#else
        floatToFixed_arrL( t60_temp, t60, Q31, CLDFB_NO_CHANNELS_MAX );
#endif
        floatToFixed_arrL( ene_temp, ene, Q31, CLDFB_NO_CHANNELS_MAX );
    }
    else
@@ -2601,7 +2623,11 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx(
    }
    ELSE
    {
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        revTimes = hHrtfFastConv->fastconvReverberationTimes_fx;        /*Q27*/
#else
        revTimes = hHrtfFastConv->fastconvReverberationTimes_fx;        /*Q31*/
#endif
        revEne = hHrtfFastConv->fastconvReverberationEneCorrections_fx; /*Q31*/
        preDelay = 10;
        move16();
@@ -2646,7 +2672,11 @@ ivas_error ivas_binaural_reverb_open_parambin(
    }
    ELSE
    {
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        revTimes = hHrtfParambin->parametricReverberationTimes_fx;        /*Q27*/
#else
        revTimes = hHrtfParambin->parametricReverberationTimes_fx;        /*Q31*/
#endif
        revEne = hHrtfParambin->parametricReverberationEneCorrections_fx; /*Q31*/
        preDelay = 10;
        move16();
+8 −0
Original line number Diff line number Diff line
@@ -72,12 +72,20 @@ extern Word32 rightBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT
extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */

/* Reverberation parameters based on BRIRs for fastconv */
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];          /* Q27 */
#else
extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];          /* Q31 */
#endif
extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */

/* Binaural rendering data set based on BRIRs, to be used in a combined manner
 * with the above binaural rendering data set based on HRIRs for parametric
 * renderer */
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];          /* Q27 */
#else
extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];          /* Q31 */
#endif
extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */
extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];      /* Q28 */
Loading