Commit e4195c38 authored by sbsarac's avatar sbsarac
Browse files

Merge branch 'main' into 1129-external-renderer-binaural-room-reverb-output-level-high

parents 2cfaa9c1 23bfe4db
Loading
Loading
Loading
Loading
Loading
+0 −47
Original line number Diff line number Diff line
@@ -128,11 +128,7 @@ typedef struct
    bool customLsOutputEnabled;
    char *customLsSetupFilename;
    int16_t orientation_tracking;
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
    bool non_diegetic_pan_enabled;
#else
    int16_t Opt_non_diegetic_pan;
#endif
    float non_diegetic_pan_gain;
    bool renderConfigEnabled;
    char *renderConfigFilename;
@@ -152,11 +148,7 @@ typedef struct
#endif
#endif
    AcousticEnvironmentSequence aeSequence;
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
    bool dpidEnabled;
#else
    int16_t Opt_dpid_on;
#endif
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];

} DecArguments;
@@ -415,12 +407,7 @@ int main(
    if ( arg.renderConfigEnabled )
    {
        /* sanity check */
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.non_diegetic_pan_enabled == false )
#else
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
             arg.Opt_non_diegetic_pan == 0 )
#endif
        {
            fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -440,13 +427,8 @@ int main(
    asked_frame_size = arg.renderFramesize;
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535;

#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain,
                                       arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain,
                                       arg.Opt_dpid_on, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
@@ -612,12 +594,7 @@ int main(

        /* sanity check */
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB &&
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
             arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.non_diegetic_pan_enabled == false )
#else
             arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
             arg.Opt_non_diegetic_pan == 0 )
#endif
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" );
            goto cleanup;
@@ -1088,20 +1065,12 @@ static bool parseCmdlIVAS_dec(

    arg->renderConfigEnabled = false;
    arg->renderConfigFilename = NULL;
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
    arg->dpidEnabled = false;
#else
    arg->Opt_dpid_on = 0;
#endif

    arg->outputMdFilename = NULL;

    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
    arg->non_diegetic_pan_enabled = false;
#else
    arg->Opt_non_diegetic_pan = 0;
#endif
    arg->non_diegetic_pan_gain = 0.f;
    arg->tsmEnabled = false;
    arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS;
@@ -1440,11 +1409,7 @@ static bool parseCmdlIVAS_dec(
        else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 )
        {
            i++;
#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
            arg->non_diegetic_pan_enabled = true;
#else
            arg->Opt_non_diegetic_pan = 1;
#endif
            strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 );
            argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0';
            to_upper( argv_to_upper );
@@ -1541,11 +1506,7 @@ static bool parseCmdlIVAS_dec(
        {
            int16_t id, tmp;

#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
            arg->dpidEnabled = true;
#else
            arg->Opt_dpid_on = 1;
#endif
            ++i;
            tmp = 0;
            while ( is_number( argv[i + tmp] ) && tmp < IVAS_MAX_NUM_OBJECTS )
@@ -1626,11 +1587,7 @@ static bool parseCmdlIVAS_dec(
        }
        i++;

#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
        if ( arg->non_diegetic_pan_enabled && arg->outputConfig != IVAS_AUDIO_CONFIG_STEREO )
#else
        if ( ( arg->Opt_non_diegetic_pan ) && ( arg->outputConfig != IVAS_AUDIO_CONFIG_STEREO ) )
#endif
        {
            fprintf( stderr, "Error: non-diegetic panning is supported in stereo only\n\n" );
            usage_dec();
@@ -1649,11 +1606,7 @@ static bool parseCmdlIVAS_dec(
        arg->outputConfig = IVAS_AUDIO_CONFIG_MONO;
        arg->decMode = IVAS_DEC_MODE_EVS;

#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION
        if ( arg->non_diegetic_pan_enabled )
#else
        if ( ( arg->Opt_non_diegetic_pan ) )
#endif
        {
            arg->outputConfig = IVAS_AUDIO_CONFIG_STEREO;
        }
+10 −1
Original line number Diff line number Diff line
@@ -1519,6 +1519,7 @@ static bool parseCmdlIVAS_enc(
                {
                    fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" );
                    usage_enc();
                    return false;
                }
                else
                {
@@ -1530,6 +1531,7 @@ static bool parseCmdlIVAS_enc(
                    {
                        fprintf( stderr, "Error: Too high number of ISM channels!\n\n" );
                        usage_enc();
                        return false;
                    }
                }
            }
@@ -1537,6 +1539,7 @@ static bool parseCmdlIVAS_enc(
            {
                fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" );
                usage_enc();
                return false;
            }
            if ( i < argc - 4 )
            {
@@ -1556,7 +1559,7 @@ static bool parseCmdlIVAS_enc(
                    default:
                        fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" );
                        usage_enc();
                        break;
                        return false;
                }
            }

@@ -1581,6 +1584,7 @@ static bool parseCmdlIVAS_enc(
                {
                    fprintf( stderr, "Error: not enough arguments\n\n" );
                    usage_enc();
                    return false;
                }
            }

@@ -1593,6 +1597,7 @@ static bool parseCmdlIVAS_enc(
            {
                fprintf( stderr, "Error: not enough MASA arguments\n\n" );
                usage_enc();
                return false;
            }
        }
        else if ( strcmp( to_upper( argv[i] ), "-ISM_SBA" ) == 0 )
@@ -1611,6 +1616,7 @@ static bool parseCmdlIVAS_enc(
                {
                    fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" );
                    usage_enc();
                    return false;
                }
                else
                {
@@ -1622,6 +1628,7 @@ static bool parseCmdlIVAS_enc(
                    {
                        fprintf( stderr, "Error: Too high number of ISM channels!\n\n" );
                        usage_enc();
                        return false;
                    }
                }
            }
@@ -1629,6 +1636,7 @@ static bool parseCmdlIVAS_enc(
            {
                fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" );
                usage_enc();
                return false;
            }

            if ( i < argc - 4 )
@@ -1680,6 +1688,7 @@ static bool parseCmdlIVAS_enc(
                {
                    fprintf( stderr, "Error: not enough arguments\n\n" );
                    usage_enc();
                    return false;
                }
            }
        }
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ COLUMNS = [
    "MLD",
    "MAXIMUM ABS DIFF",
    "MIN_SSNR",
    "MIN_ODG",
]
COLUMNS_GLOBAL = COLUMNS[:1]
COLUMNS_DIFFERENTIAL = COLUMNS[3:]
+77 −33
Original line number Diff line number Diff line
@@ -46,14 +46,12 @@
#include "ivas_prot.h"
#include "wmc_auto.h"


#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
/*-------------------------------------------------------------------*
 * Local function prototypes
 * Local constants
 *-------------------------------------------------------------------*/

static float Find_bit_frac( const int16_t nb_band, const int16_t remaining_bits );

static void reajust_bits( float *bits_per_bands, const int16_t st_band, const int16_t end_band, const int16_t sum_bit_in, const int16_t bit_bdgt_in );
#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
#define Q15_0_33             10922                     /* 0.33 */
#define Q18_0_1              26214                     /* 0.1  */
#define Q18_0_50             131072                    /* 0.50 */
@@ -72,9 +70,24 @@ static void reajust_bits( float *bits_per_bands, const int16_t st_band, const in
#define Q31_0_02    42949673  /* 0.02  */
#define Q31_0_17    365072220 /* 0.17  */
#define Q31_0_23    493921239 /* 0.23  */

#endif

/*-------------------------------------------------------------------*
 * Local function prototypes
 *-------------------------------------------------------------------*/

static float Find_bit_frac( const int16_t nb_band, const int16_t remaining_bits );

static void reajust_bits( float *bits_per_bands, const int16_t st_band, const int16_t end_band, const int16_t sum_bit_in, const int16_t bit_bdgt_in );

#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div );

static Word16 Find_bit_alloc_IVAS_int( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, const Word16 L_frame, Word16 *bit, Word16 *max_ener_band, float *ener_vec, float *bits_per_bands );

static Word16 maximum_fx( const Word16 *vec_fx, const Word16 lvec_fx, Word16 *max_fx );

#endif

/*-------------------------------------------------------------------*
@@ -398,7 +411,7 @@ void bands_and_bit_alloc(
                }
            }
#else
            nb_tot_bands = Find_bit_alloc_IVAS_int( core_brate, GSC_IVAS_mode, Diff_len, nb_tot_bands, L_frame, bit, max_ener_band, ener_vec, bits_per_bands );
            nb_tot_bands = (int16_t) Find_bit_alloc_IVAS_int( (Word32) core_brate, (Word16) GSC_IVAS_mode, (Word16) Diff_len, (Word16) nb_tot_bands, (Word16) L_frame, (Word16 *) bit, (Word16 *) max_ener_band, ener_vec, bits_per_bands );
            nb_bands = nb_tot_bands;
#endif
        }
@@ -962,9 +975,17 @@ static float Find_bit_frac(

    return ( var_out );
}

#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING

static Word16 Find_bit_alloc_IVAS_int(                               /*o: Number of band to encode */
/*-------------------------------------------------------------------*
 * Find_bit_alloc_IVAS_int()
 *
 *
 *-------------------------------------------------------------------*/

/*! r: Number of bands to encode */
static Word16 Find_bit_alloc_IVAS_int(
    const Word32 core_brate,      /* i  : core bit rate                                         */
    const Word16 GSC_IVAS_mode,   /* i  : GSC IVAS mode                                         */
    const Word16 Diff_len,        /* i  : Length of the difference signal (before pure spectral)*/
@@ -978,27 +999,26 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
{
    Word32 mp, mb, nb_bands_adj, bit_adj;
    Word16 nb_pulse_per_band[MBANDS_GN_BITALLOC16k];
    Word32 SWB_bit_budget; // Q0 -> Q18
    Word32 SWB_bit_budget; /* Q0 -> Q18 */
    Word16 i, j, nb_bands_max, st_band, nb_tot_bands_loc, etmp;
    Word32 sum_bit /*Q18*/, bit_fracf /*Q18*/;
    Word16 d_tmp, e_div, tmp16, ener_vec[MBANDS_GN_BITALLOC16k];
    Word32 Ltmp, etmp_32fx, bits_per_bands[MBANDS_GN_BITALLOC16k];


    SWB_bit_budget = *bit; // Q0
    SWB_bit_budget = *bit; /* Q0 */
    st_band = 5;
    nb_bands_max = nb_tot_bands_in;


    for ( i = 0; i < MBANDS_GN; i++ )
    {
        ener_vec[i] = (short) ( ener_vec_io[i] ); /* Q12 -> Q12 */
        ener_vec[i] = (Word16) ( ener_vec_io[i] ); /* Q12 -> Q12 */
    }

    if ( L_frame == L_FRAME16k )
    {
        for ( i = MBANDS_GN; i < MBANDS_GN_BITALLOC16k; i++ )
        {
            ener_vec[i] = (short) ( ener_vec_io[i] * 4096.0 + 0.5f ); /* Q0 -> Q12 */
            ener_vec[i] = (Word16) ( ener_vec_io[i] * 4096.0 + 0.5f ); /* Q0 -> Q12 */
        }
    }

@@ -1020,12 +1040,14 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
    {
        nb_bands_max -= 6;
    }

    if ( GSC_IVAS_mode == 2 )
    {
        /* bit_fracf += 0.1f; */
        bit_fracf += Q18_0_1; /* Q18*/
        nb_bands_max -= 1;
    }

    if ( GSC_IVAS_mode == 3 )
    {
        /* bit_fracf -= 0.1f; */
@@ -1041,12 +1063,12 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
    if ( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG )
    {
        /* nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;*/
        nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, 18 ) ), Q18_0_75 ); // Q18
        nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, 18 ) ), Q18_0_75 ); /* Q18 */
    }
    else if ( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG )
    {
        /*nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;*/
        nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, 18 ) ), Q18_1_2 ); // Q18
        nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, 18 ) ), Q18_1_2 ); /* Q18 */
    }
    /*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/

@@ -1135,10 +1157,10 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
        max_ener_band[j] = i;
        ener_vec[i] = MIN16B;
    }

    /* Recompute the final bit distribution for HF */
    IF( nb_tot_bands_loc > st_band )
    {
        /* This is not bit exact because of the precision lost */
        /* mb = ( SWB_bit_budget * 2 / ( nb_tot_bands_loc - st_band ) ) - mp; */
        d_tmp = Find_norm_inv( L_deposit_h( sub( nb_tot_bands_loc, st_band ) ), &e_div );
        mb = L_sub( L_shr( Mpy_32_16_1( L_shl( SWB_bit_budget, 1 ), d_tmp ), e_div ), mp ); /* Q18 */
@@ -1155,9 +1177,10 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
                bits_per_bands[max_ener_band[j]] = mb;
            }
            mb -= bit_fracf;
            SWB_bit_budget -= bits_per_bands[max_ener_band[j]]; // Q18
            SWB_bit_budget -= bits_per_bands[max_ener_band[j]]; /* Q18 */
        }
    }

    /* Series of verification in case bit allocated != the budget */
    if ( SWB_bit_budget > 0 )
    {
@@ -1191,7 +1214,6 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
            bits_per_bands[i] = Q18_112;
            j = add( j, add( i, 1 ) );
        }

        /* safety check for overage bit reallocation */
        /* else if (bits_per_bands[i] + sum_bit / 3 > 112) */
        else if ( L_add( bits_per_bands[i], Mpy_32_16_1( sum_bit, Q15_0_33 ) ) > Q18_112 )
@@ -1210,24 +1232,46 @@ static Word16 Find_bit_alloc_IVAS_int( /*o: Number
            bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit );
        }
    }

    for ( i = 0; i < MBANDS_GN_BITALLOC16k; i++ )
    {
        bits_per_bands_o[i] = (float) bits_per_bands[i] / 262144.0f; /* Q18 -> float */
    }

    return nb_tot_bands_loc;
}

static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div ) /* Find normalized 1 / ToDivide */

/*-------------------------------------------------------------------*
 * Find_norm_inv()
 *
 * Find normalized 1 / ToDivide
 *-------------------------------------------------------------------*/

static Word16 Find_norm_inv(
    const Word32 ToDivide,
    Word16 *e_div )
{
    Word16 d_tmp, e_tmp;

    e_tmp = norm_l( ToDivide );
    d_tmp = round_fx( L_shl( ToDivide, e_tmp ) );
    d_tmp = div_s( 16384, d_tmp ); /* 1.0 in Q14, dividend is normalize so >= 16384 as required for the division */
    *e_div = sub( 14, e_tmp );
    move16();

    return d_tmp;
}
static Word16 maximum_fx(                       /* o  : index of the maximum value in the input vector */


/*-------------------------------------------------------------------*
 * maximum_fx()
 *
 *
 *-------------------------------------------------------------------*/

/*! r: index of the maximum value in the input vector */
static Word16 maximum_fx(
    const Word16 *vec_fx, /* i  : input vector                      */
    const Word16 lvec_fx, /* i  : length of input vector            */
    Word16 *max_fx        /* o  : maximum value in the input vector */
@@ -1235,8 +1279,8 @@ static Word16 maximum_fx( /* o : index of the maximum val
{
    Word16 j, ind;
    Word16 tmp;
    ind = 0;

    ind = 0;
    tmp = vec_fx[0];

    for ( j = 1; j < lvec_fx; j++ )
+5 −6
Original line number Diff line number Diff line
@@ -160,10 +160,11 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */

//#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT          /* Orange issue 1031 : new fix point hrtf binary file format */
//#define FIX_CREND_SIMPLIFY_CODE                         /* Ora : simplify line code in crend */
//#define FIX_CREND_SIMPLIFY_CODE                       /* Orange: simplify line code in Crend */
#define FLOAT_FIX_POINT_HRTF_FILE_FORMAT                /* allows reading floation or fix point hrtf binary file format */
#define FIX_1138_SBA_EXT_ERROR_PRINTOUT                 /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */
#define FIX_1117_ISAR_MALLOC                            /* VA: issue 1117: call ISAR malloc() only at the initialization. */
#define FIX_1129_EXT_REND_OUTPUT_HIGH                   /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */
#define FIX_745_FIX_DATA_TYPE_CONVERSION                /* VA: issue 745: implicit data type conversion when calling IVAS_DEC_Configure() */

/* #################### End BE switches ################################## */

@@ -171,10 +172,8 @@
/* any switch which is non-be wrt selection floating point code */
/* all switches in this category should start with "NONBE_" */

#define NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* FhG: issue 1133: skip de-whitening of bg noise shape after frameloss period if the first good frame is an SID */
#define NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID /* FhG: issue 1133: in TCX PLC, don't scale hHQ_core->old_out after applying fade to noise in burst frame error */
#define NONBE_FIX_1130_DIV_ZERO_LEV_DUR                       /* VA: issue 1130: avoid div by zero in L-D by thresholding R[0] to a min value of 100.0 */
#define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING               /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */
#define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE               /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */

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

Loading