Commit c057b452 authored by emerit's avatar emerit
Browse files

Merge branch 'orange/fixpoint_crend_hrtf_file_format' of...

Merge branch 'orange/fixpoint_crend_hrtf_file_format' of https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec into orange/fixpoint_crend_hrtf_file_format
parents 13808b87 fd8894b6
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@
#define FIX_1123_FASTCONV_16BIT_ROM                     /* FhG: issue 1123: update FastConv ROM tables and scripts to generate 16 bit tables instead of float */
#define FIX_1123_PARAMBIN_16BIT_ROM                     /* FhG,Nok: issue 1123: update ParamBin ROM tables and scripts to generate 16 bit tables instead of float */
#define FIX_1123_TDREN_16BIT_ROM
#define FIX_1123_OPTIMIZE_BINARY_LOAD                   /* Nok: Optimize loading of binary files in fixed point format by precomputing scaling factors */
#define FIX_1053_AEID_FILE_TEST                         /* Philips: Tests for the -aeid file and fix for memory error */
#define FIX_1121_MASA_DESCRIPTOR                        /* VA: issue 1121: Define 'ivasmasaFormatDescriptor' at one common place */
#define FIX_1113_CLDFB_REND_IN_ISAR                     /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */
+12 −6
Original line number Diff line number Diff line
@@ -387,7 +387,13 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs(
    {
        /* Initialise tables from ROM */
        HRTFS_PARAMBIN *hrtfParambin;

#ifdef FIX_1123_PARAMBIN_16BIT_ROM
        float shCoef_scale, rt_scale, rene_scale, early_scale;
        shCoef_scale = powf( 2.f, -1.f * (float) hrtfShCoeffs_factorQ );
        rt_scale = powf( 2.f, -1.f * (float) parametricReverberationTimes_factorQ );
        rene_scale = powf( 2.f, -1.f * (float) parametricReverberationEneCorrections_factorQ );
        early_scale = powf( 2.f, -1.f * (float) parametricEarlyPartEneCorrection_factorQ );
#endif
        if ( ( hrtfParambin = (HRTFS_PARAMBIN *) malloc( sizeof( HRTFS_PARAMBIN ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for parametric binauralizer HRTF tables" );
@@ -400,8 +406,8 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs(
#ifdef FIX_1123_PARAMBIN_16BIT_ROM
                for ( k = 0; k < HRTF_NUM_BINS; k++ )
                {
                    hrtfParambin->hrtfShCoeffsRe[i][j][k] = (float) hrtfShCoeffsRe[i][j][k] * powf( 2.f, -1.f * (float) hrtfShCoeffs_factorQ );
                    hrtfParambin->hrtfShCoeffsIm[i][j][k] = (float) hrtfShCoeffsIm[i][j][k] * powf( 2.f, -1.f * (float) hrtfShCoeffs_factorQ );
                    hrtfParambin->hrtfShCoeffsRe[i][j][k] = (float) hrtfShCoeffsRe[i][j][k] * shCoef_scale;
                    hrtfParambin->hrtfShCoeffsIm[i][j][k] = (float) hrtfShCoeffsIm[i][j][k] * shCoef_scale;
                }
#else
                mvr2r( hrtfShCoeffsRe[i][j], hrtfParambin->hrtfShCoeffsRe[i][j], HRTF_NUM_BINS );
@@ -413,9 +419,9 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs(
#ifdef FIX_1123_PARAMBIN_16BIT_ROM
        for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
        {
            hrtfParambin->parametricReverberationTimes[i] = (float) parametricReverberationTimes[i] * powf( 2.f, -1.f * (float) parametricReverberationTimes_factorQ );
            hrtfParambin->parametricReverberationEneCorrections[i] = (float) parametricReverberationEneCorrections[i] * powf( 2.f, -1.f * (float) parametricReverberationEneCorrections_factorQ );
            hrtfParambin->parametricEarlyPartEneCorrection[i] = (float) parametricEarlyPartEneCorrection[i] * powf( 2.f, -1.f * (float) parametricEarlyPartEneCorrection_factorQ );
            hrtfParambin->parametricReverberationTimes[i] = (float) parametricReverberationTimes[i] * rt_scale;
            hrtfParambin->parametricReverberationEneCorrections[i] = (float) parametricReverberationEneCorrections[i] * rene_scale;
            hrtfParambin->parametricEarlyPartEneCorrection[i] = (float) parametricEarlyPartEneCorrection[i] * early_scale;
        }
#else
        mvr2r( parametricReverberationTimes, hrtfParambin->parametricReverberationTimes, CLDFB_NO_CHANNELS_MAX );
+38 −0
Original line number Diff line number Diff line
@@ -2616,6 +2616,9 @@ static ivas_error create_parambin_HRTF_from_rawdata_fx(
    uint32_t data_size_tmp;
    Word16 factorQ;
    int16_t *ptW16;
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
    float scaler;
#endif

    hrtf_data_rptr = hrtf_data;

@@ -2637,7 +2640,10 @@ static ivas_error create_parambin_HRTF_from_rawdata_fx(
    /* Q factor*/
    factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( Word16 );
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
    scaler = powf( 2.f, -1.f * (float) factorQ );

#endif
    data_size_tmp = HRTF_NUM_BINS * sizeof( int16_t );
    for ( i = 0; i < BINAURAL_CHANNELS; i++ )
    {
@@ -2646,7 +2652,11 @@ static ivas_error create_parambin_HRTF_from_rawdata_fx(
            ptW16 = (int16_t *) hrtf_data_rptr;
            for ( k = 0; k < HRTF_NUM_BINS; k++ )
            {
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
                ( *hHRTF )->hrtfShCoeffsRe[i][j][k] = (float) ptW16[k] * scaler;
#else
                ( *hHRTF )->hrtfShCoeffsRe[i][j][k] = (float) ptW16[k] * powf( 2.f, -1.f * (float) factorQ );
#endif
            }
            hrtf_data_rptr += data_size_tmp;
        }
@@ -2658,7 +2668,11 @@ static ivas_error create_parambin_HRTF_from_rawdata_fx(
            ptW16 = (int16_t *) hrtf_data_rptr;
            for ( k = 0; k < HRTF_NUM_BINS; k++ )
            {
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
                ( *hHRTF )->hrtfShCoeffsIm[i][j][k] = (float) ptW16[k] * scaler;
#else
                ( *hHRTF )->hrtfShCoeffsIm[i][j][k] = (float) ptW16[k] * powf( 2.f, -1.f * (float) factorQ );
#endif
            }
            hrtf_data_rptr += data_size_tmp;
        }
@@ -2674,33 +2688,57 @@ static ivas_error create_parambin_HRTF_from_rawdata_fx(
    /* Q factor*/
    factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( Word16 );
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
    scaler = powf( 2.f, -1.f * (float) factorQ );

#endif

    ptW16 = (int16_t *) hrtf_data_rptr;
    for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
    {
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
        ( *hHRTF )->parametricReverberationTimes[j] = (float) ptW16[j] * scaler;
#else
        ( *hHRTF )->parametricReverberationTimes[j] = (float) ptW16[j] * powf( 2.f, -1.f * factorQ );
#endif
    }
    hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t );

    /* Q factor*/
    factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( Word16 );
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
    scaler = powf( 2.f, -1.f * (float) factorQ );

#endif

    ptW16 = (int16_t *) hrtf_data_rptr;
    for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
    {
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
        ( *hHRTF )->parametricReverberationEneCorrections[j] = (float) ptW16[j] * scaler;
#else
        ( *hHRTF )->parametricReverberationEneCorrections[j] = (float) ptW16[j] * powf( 2.f, -1.f * factorQ );
#endif
    }
    hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t );

    /* Q factor*/
    factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( Word16 );
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
    scaler = powf( 2.f, -1.f * (float) factorQ );

#endif

    ptW16 = (int16_t *) hrtf_data_rptr;
    for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
    {
#ifdef FIX_1123_OPTIMIZE_BINARY_LOAD
        ( *hHRTF )->parametricEarlyPartEneCorrection[j] = (float) ptW16[j] * scaler;
#else
        ( *hHRTF )->parametricEarlyPartEneCorrection[j] = (float) ptW16[j] * powf( 2.f, -1.f * factorQ );
#endif
    }
    hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t );

+0 −6
Original line number Diff line number Diff line
@@ -178,9 +178,6 @@ def test_ism_binaural_headrotation_with_binary_hrir(
def test_masa_binaural_static_with_binary_hrir(
    test_info, in_fmt, out_fmt, frame_size, hrtf_tag
):
    if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]:
        pytest.skip("Skipping binaural room outputs for MASA as unimplemented.")

    compare_renderer_with_binary_fix_vs_with_binary_float(
        test_info,
        in_fmt,
@@ -198,9 +195,6 @@ def test_masa_binaural_static_with_binary_hrir(
def test_masa_binaural_headrotation_with_binary_hrir(
    test_info, in_fmt, out_fmt, trj_file, frame_size, hrtf_tag
):
    if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]:
        pytest.skip("Skipping binaural room outputs for MASA as unimplemented.")

    compare_renderer_with_binary_fix_vs_with_binary_float(
        test_info,
        in_fmt,