Unverified Commit 04625291 authored by norvell's avatar norvell
Browse files

Add FIX_BASOP_2023_TDREND_DISTATT_PRECISION to address distance attenuation precision issue

parent 07b86fd4
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_BASOP_2023_TDREND_DISTATT_PRECISION
    Word32 distAtt_fx[3]; /* {Q25, Q28, Q28} */
#else
    Word32 distAtt_fx[3]; /* {Q27, Q30, Q30} */
#endif

} IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE;

+3 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@
/* ################### Start DEBUGGING switches ######################## */

#ifndef RELEASE
/*#define DEBUGGING*/                           /* Activate debugging part of the code */
#define DEBUGGING                           /* Activate debugging part of the code */
#endif
/*#define WMOPS*/                               /* Activate complexity and memory counters */
/*#define WMOPS_PER_FRAME*/                     /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
@@ -58,7 +58,7 @@

#ifdef DEBUGGING
/*#define DBG_BITSTREAM_ANALYSIS*/              /* Write bitstream with annotations to a text file */
#define DEBUG_MODE_INFO                         /* Define to output most important parameters to the subdirectory "res/" */
/*#define DEBUG_MODE_INFO*/                         /* Define to output most important parameters to the subdirectory "res/" */
#define DEBUG_MODE_INFO_TWEAK                   /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */
#define DEBUG_FORCE_MDCT_STEREO_MODE            /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */
/*#define DEBUG_FORCE_DIR*/                     /* Force modes/parameters by reading from external binary files */
@@ -116,6 +116,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_BASOP_2023_TDREND_DISTATT_PRECISION         /* Eri: Distance attenuation scaling */

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

+9 −0
Original line number Diff line number Diff line
@@ -202,12 +202,21 @@ ivas_error ivas_td_binaural_open_unwrap_fx(

            DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0
            move16();
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
            DistAtten.MaxDist_fx = 528482304; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/
            move32();
            DistAtten.RefDist_fx = ONE_IN_Q28; // Q28
            move32();
            DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28
            move32();
#else
            DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/
            move32();
            DistAtten.RefDist_fx = ONE_IN_Q30; // Q30
            move32();
            DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30
            move32();
#endif

            // TDREND_SRC_SPATIAL_t *SrcSpatial_p = pBinRendTd->Sources[nS]->SrcSpatial_p;
            IF( NE_32( ( error = TDREND_MIX_SRC_SetPos_fx( pBinRendTd, nS, Pos_fx ) ), IVAS_ERR_OK ) )
+3 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
#include "ivas_rom_rend.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"

#include "debug.h"

/*---------------------------------------------------------------------*
 * Local function prototypes
@@ -74,6 +74,8 @@ ivas_error TDREND_REND_RenderSourceHRFilt_fx(
    Word16 left_filter_e;
    Word16 right_filter_e;

    dbgwrite( &Src_p->Gain_fx, sizeof( int ), 1, 1, "Gain_fx.int" );

    TDREND_Apply_ITD_fx( Src_p->InputFrame_p_fx, LeftOutputFrame_fx, RightOutputFrame_fx,
                         &Src_p->previtd, Src_p->itd, Src_p->mem_itd_fx, subframe_length );

+46 −9
Original line number Diff line number Diff line
@@ -653,12 +653,21 @@ static void TDREND_SRC_SPATIAL_Init_fx(
    move16();
    SrcSpatial_p->DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0
    move16();
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
    SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q28; // Q28
    move32();
    SrcSpatial_p->DistAtten.MaxDist_fx = 528482304; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/
    move32();
    SrcSpatial_p->DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28
    move32();
#else
    SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q30;                                                                                                                                         // Q30
    move32();
    SrcSpatial_p->DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/
    move32();
    SrcSpatial_p->DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30
    move16();
#endif

    return;
}
@@ -866,28 +875,56 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx(
            BREAK;

        case TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED:
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->RefDist_fx, 3 );
#else
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->RefDist_fx, 1 );
#endif
            IF( flag < 0 )
            {
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
                Dist2_fx = DistAtten_p->RefDist_fx; // Q28
                move32();
                Dist2_e = 3;
                move16();
#else
                Dist2_fx = DistAtten_p->RefDist_fx;                       // Q30
                move32();
                Dist2_e = 1;
                move16();
#endif
            }
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->MaxDist_fx, 6 );
#else
            flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->MaxDist_fx, 4 );
#endif
            IF( flag > 0 )
            {
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
                Dist2_fx = DistAtten_p->MaxDist_fx; // Q25
                move32();
                Dist2_e = 6;
                move16();
#else
                Dist2_fx = DistAtten_p->MaxDist_fx; // Q27
                move32();
                Dist2_e = 4;
                move16();
#endif
            }
            /* DistGain = powf( DistAtten_p->RefDist / Dist2, DistAtten_p->RollOffFactor ); */
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
            tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 3) */
            tmp32 = L_deposit_h( tmp16 );                                                      /* tmp32 is Q(31 - Dist_s + Dist2_e - 3) */
            /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 3) = Dist_s - Dist2_e + 3, RollOffFactor_fx exponent: 31 - 28 = 3 */
            tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 3 ), DistAtten_p->RollOffFactor_fx, 3, &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;
    }

Loading