Commit a076319b authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Port the missing part of RenderConfigReader_checkValues() from float; fix RefDist_fx calculation.

parent 7a7b3a68
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -351,7 +351,11 @@ typedef struct _IVAS_RENDER_CONFIG
    float directivity[IVAS_MAX_NUM_OBJECTS * 3];
    Word16 directivity_fx[IVAS_MAX_NUM_OBJECTS * 3]; // has the following q-factor pattern: {6, 6, 15, 6, 6, 15, 6, 6, 15, 6, 6, 15}
    float distAtt[3];
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    Word32 distAtt_fx[3]; /* {Q27, Q27, Q30} */
#else
    Word32 distAtt_fx[3]; /* {Q27, Q30, Q30} */
#endif

} IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE;

+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@
#define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX        /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */
#define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN      /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */
#define FIX_2495_Q_ALIGN_OSBA_RENDERER                  /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */
#define FIX_2500_ISM4_BIN_REVERB_DISTORTION             /* FhG: Basop issue #2500: Port the missing part of RenderConfigReader_checkValues() from float; fix RefDist_fx calculation. */

/* ##################### End NON-BE switches ########################### */

+8 −0
Original line number Diff line number Diff line
@@ -204,7 +204,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx(
            move16();
            DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/
            move32();
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            DistAtten.RefDist_fx = ONE_IN_Q27; // Q27
#else
            DistAtten.RefDist_fx = ONE_IN_Q30; // Q30
#endif
            move32();
            DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30
            move32();
@@ -264,7 +268,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx(
                move16();
                DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/
                move32();
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
                DistAtten.RefDist_fx = ONE_IN_Q27; // Q27
#else
                DistAtten.RefDist_fx = ONE_IN_Q30; // Q30
#endif
                move32();
                DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30
                move32();
+29 −0
Original line number Diff line number Diff line
@@ -653,7 +653,11 @@ static void TDREND_SRC_SPATIAL_Init_fx(
    move16();
    SrcSpatial_p->DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0
    move16();
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q27; // Q27
#else
    SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q30; // Q30
#endif
    move32();
    SrcSpatial_p->DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/
    move32();
@@ -859,13 +863,30 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx(
    {
        case TDREND_DIST_ATTEN_MODEL_INV_DIST:
            /* DistGain = powf( DistAtten_p->RefDist / Dist2, DistAtten_p->RollOffFactor ); */
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 4) */
            tmp32 = L_deposit_h( tmp16 );                                                      /* tmp32 is Q(31 - Dist_s + Dist2_e - 4) */
            /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 4) = Dist_s - Dist2_e + 4, RollOffFactor_fx exponent: 31 - 30 = 1 */
            tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 4 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */
#else
            tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 1) */
            tmp32 = L_deposit_h( tmp16 );                                                      /* tmp32 is Q(31 - Dist_s + Dist2_e - 1) */
            /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 1) = Dist_s - Dist2_e + 1, RollOffFactor_fx exponent: 31 - 30 = 1 */
            tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 1 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */
#endif
            BREAK;

        case TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED:
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->RefDist_fx, 4 );
            IF( flag < 0 )
            {
                Dist2_fx = DistAtten_p->RefDist_fx; // Q27
                move32();
                Dist2_e = 4;
                move16();
            }
#else
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->RefDist_fx, 1 );
            IF( flag < 0 )
            {
@@ -874,6 +895,7 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx(
                Dist2_e = 1;
                move16();
            }
#endif
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->MaxDist_fx, 4 );
            IF( flag > 0 )
            {
@@ -883,10 +905,17 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx(
                move16();
            }
            /* DistGain = powf( DistAtten_p->RefDist / Dist2, DistAtten_p->RollOffFactor ); */
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 4) */
            tmp32 = L_deposit_h( tmp16 );                                                      /* tmp32 is Q(31 - Dist_s + Dist2_e - 4) */
            /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 4) = Dist_s - Dist2_e + 4, RollOffFactor_fx exponent: 31 - 30 = 1 */
            tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 4 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */
#else
            tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 1) */
            tmp32 = L_deposit_h( tmp16 );                                                      /* tmp32 is Q(31 - Dist_s + Dist2_e - 1) */
            /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 1) = Dist_s - Dist2_e + 1, RollOffFactor_fx exponent: 31 - 30 = 1 */
            tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 1 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */
#endif

            BREAK;
    }
+4 −0
Original line number Diff line number Diff line
@@ -142,7 +142,11 @@ ivas_error ivas_render_config_init_from_rom_fx(
    }
    ( *hRenderConfig )->distAtt_fx[0] = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ /* Default max dist */
    move32();
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    ( *hRenderConfig )->distAtt_fx[1] = ONE_IN_Q27; // Q27   /* Default ref dist */
#else
    ( *hRenderConfig )->distAtt_fx[1] = ONE_IN_Q30; // Q30   /* Default ref dist */
#endif
    move32();
    ( *hRenderConfig )->distAtt_fx[2] = ONE_IN_Q30; // Q30   /* Default rolloff factor */
    move32();
Loading