Commit b88e49b3 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Merge branch 'main' to '196-refactor-renderer-output-configuration'

parents 40c37a8d f221482e
Loading
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -587,7 +587,11 @@ int main(

    if ( arg.hrtfReaderEnabled )
    {
#ifdef UPDATE_SBA_FILTER
        IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;
#else
        IVAS_DEC_HRTF_HANDLE hHrtfTD;
#endif

        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );

@@ -598,7 +602,11 @@ int main(
        }


#ifdef UPDATE_SBA_FILTER
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL;
#else
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF;
#endif
        IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF );

        if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
@@ -606,14 +614,22 @@ int main(
            fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfCRendFileName );
            goto cleanup;
        }
#ifdef UPDATE_SBA_FILTER
        IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv = NULL;
#else
        IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv;
#endif
        IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv );

        if ( ( error = load_fastconv_HRTF_from_binary( hHrtfFastConv, hrtfReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s for FastConv \n\n", arg.hrtfCRendFileName );
        }
#ifdef UPDATE_SBA_FILTER
        IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin = NULL;
#else
        IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin;
#endif
        IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin );

        if ( ( error = load_parambin_HRTF_from_binary( hHrtfParambin, hrtfReader ) ) != IVAS_ERR_OK )
@@ -702,10 +718,18 @@ cleanup:

    if ( arg.hrtfReaderEnabled )
    {
#ifdef UPDATE_SBA_FILTER
        IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;
#else
        IVAS_DEC_HRTF_HANDLE hHrtfTD;
#endif
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
        dealloc_HRTF_binary( hHrtfTD );
#ifdef UPDATE_SBA_FILTER
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL;
#else
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF;
#endif
        IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF );
        destroy_SetOfHRTF( hSetOfHRTF );
    }
@@ -1796,7 +1820,6 @@ static ivas_error decodeG192(
            }
        }


        /* Write current frame */
        if ( decodedGoodFrame )
        {
@@ -1882,6 +1905,7 @@ static ivas_error decodeG192(
     *------------------------------------------------------------------------------------------*/

    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );

    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
+14 −1
Original line number Diff line number Diff line
@@ -69,10 +69,17 @@ int32_t get_delay(
        {
            delay = IVAS_ENC_DELAY_NS;

#ifdef FIX_356_ISM_METADATA_SYNC
            if ( ivas_format == ISM_FORMAT || ivas_format == MASA_FORMAT )
            {
                delay = 0; /* All delay is compensated in the decoder with MASA/ISM */
            }
#else
            if ( ivas_format == MASA_FORMAT )
            {
                delay = 0; /* All delay is compensated in the decoder with MASA */
            }
#endif
        }

        if ( ivas_format == SBA_FORMAT )
@@ -104,11 +111,17 @@ int32_t get_delay(
                delay += IVAS_FB_DEC_DELAY_NS;
            }


#ifdef FIX_356_ISM_METADATA_SYNC
            if ( ivas_format == ISM_FORMAT || ivas_format == MASA_FORMAT )
            {
                delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with ISM/MASA */
            }
#else
            if ( ivas_format == MASA_FORMAT )
            {
                delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with MASA */
            }
#endif
        }
    }

+10 −0
Original line number Diff line number Diff line
@@ -1517,7 +1517,11 @@ typedef enum

#define BINAURAL_MAXBANDS                       60                          /* Max number of bands */
#define BINAURAL_CONVBANDS                      50                          /* Bands upto which convolution is performed */
#ifdef UPDATE_SBA_FILTER
#define BINAURAL_NTAPS                           5
#else
#define BINAURAL_NTAPS                           7
#endif
#define BINAURAL_NTAPS_MAX                      96

#define HRTF_SH_ORDER                           3
@@ -1535,7 +1539,13 @@ typedef enum
{
    BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,       /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
#ifdef UPDATE_SBA_FILTER    
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,            /*  HOA3 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA2,            /* HOA2 */
    BINAURAL_INPUT_AUDIO_CONFIG_FOA,            /* FOA */
#else    
    BINAURAL_INPUT_AUDIO_CONFIG_HOA,            /* FOA, HOA2, HOA3 */
#endif    
    BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED       /* Not used */

} BINAURAL_INPUT_AUDIO_CONFIG;
+26 −8
Original line number Diff line number Diff line
@@ -947,9 +947,11 @@ void deindex_spherical_component(
 *-----------------------------------------------------------------*/

void calculate_hodirac_sector_parameters(
#ifdef FIX_485_STATIC_BUFFERS
    DIRAC_ENC_HANDLE hDirAC, /* i  : DirAC handle                               */
#endif
    float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector (L+1)^2 x N_bins, real part  */
    float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector, imaginary part              */
    const int16_t N_bins,                                         /* i  : number of bins                             */
    const float beta,                                             /* i  : forgetting factor for average filtering    */
    const int16_t *band_grouping,                                 /* i  : indices of band groups                     */
    const int16_t N_bands,                                        /* i  : number of bands (groups)                   */
@@ -961,13 +963,12 @@ void calculate_hodirac_sector_parameters(
)
{
    int16_t i_sec, i_bin, i_band;

    float p_real, p_imag, normI, energy, tmp_diff;

    float sec_I_vec_x[NUM_ANA_SECTORS];
    float sec_I_vec_y[NUM_ANA_SECTORS];
    float sec_I_vec_z[NUM_ANA_SECTORS];

#ifndef FIX_485_STATIC_BUFFERS
    static int16_t firstrun_sector_params = 1;

    static float sec_I_vec_smth_x[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS];
@@ -977,9 +978,6 @@ void calculate_hodirac_sector_parameters(
    static float energy_smth[NUM_ANA_SECTORS][IVAS_MAX_NUM_BANDS];
    static float azi_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS];
    static float ele_prev[NUM_ANA_SECTORS * IVAS_MAX_NUM_BANDS];

#ifdef DEBUGGING
    assert( N_bins <= DIRAC_NO_FB_BANDS_MAX );
#endif

    for ( i_sec = 0; i_sec < NUM_ANA_SECTORS; i_sec++ )
@@ -1016,6 +1014,15 @@ void calculate_hodirac_sector_parameters(
            float *p_ene = &ene[i_sec * N_bands + i_band];

            float *p_diff = &diff[i_sec * N_bands + i_band];
#ifdef FIX_485_STATIC_BUFFERS
            float *p_azi_prev = &hDirAC->azi_prev[i_sec * N_bands + i_band];
            float *p_ele_prev = &hDirAC->ele_prev[i_sec * N_bands + i_band];

            float *p_energy_smth = &hDirAC->energy_smth[i_sec][i_band];
            float *p_sec_I_vec_smth_x = &hDirAC->sec_I_vec_smth_x[i_sec][i_band];
            float *p_sec_I_vec_smth_y = &hDirAC->sec_I_vec_smth_y[i_sec][i_band];
            float *p_sec_I_vec_smth_z = &hDirAC->sec_I_vec_smth_z[i_sec][i_band];
#else
            float *p_azi_prev = &azi_prev[i_sec * N_bands + i_band];
            float *p_ele_prev = &ele_prev[i_sec * N_bands + i_band];

@@ -1023,7 +1030,7 @@ void calculate_hodirac_sector_parameters(
            float *p_sec_I_vec_smth_x = &sec_I_vec_smth_x[i_sec][i_band];
            float *p_sec_I_vec_smth_y = &sec_I_vec_smth_y[i_sec][i_band];
            float *p_sec_I_vec_smth_z = &sec_I_vec_smth_z[i_sec][i_band];

#endif
            *p_sec_I_vec_x = 0.f;
            *p_sec_I_vec_y = 0.f;
            *p_sec_I_vec_z = 0.f;
@@ -1089,8 +1096,11 @@ void calculate_hodirac_sector_parameters(
                                       sec_z_real * sec_z_real + sec_z_imag * sec_z_imag );
                }
            }

#ifdef FIX_485_STATIC_BUFFERS
            if ( hDirAC->firstrun_sector_params )
#else
            if ( firstrun_sector_params )
#endif
            {
                *p_sec_I_vec_smth_x = *p_sec_I_vec_x;
                *p_sec_I_vec_smth_y = *p_sec_I_vec_y;
@@ -1132,7 +1142,11 @@ void calculate_hodirac_sector_parameters(
            }
            if ( tmp_diff > 0.5f )
            {
#ifdef FIX_485_STATIC_BUFFERS
                if ( hDirAC->firstrun_sector_params )
#else
                if ( firstrun_sector_params )
#endif
                {
                    *p_azi = 0.f;
                    *p_ele = 0.f;
@@ -1151,7 +1165,11 @@ void calculate_hodirac_sector_parameters(
        }
    }

#ifdef FIX_485_STATIC_BUFFERS
    hDirAC->firstrun_sector_params = 0;
#else
    firstrun_sector_params = 0;
#endif

    return;
}
+17 −4
Original line number Diff line number Diff line
@@ -49,9 +49,22 @@
 *---------------------------------------------------------------*/

#define MASA_EXTRA_BAND_META_BITS 40

#define MASA_SMALL_INC_META_BITS 10


#ifdef HR_METADATA
/*---------------------------------------------------------------
 * Local prototypes
 *---------------------------------------------------------------*/

static int16_t quantize_theta_masa( float x, const int16_t no_cb, float *xhat );

static int16_t quantize_phi_masa( float phi, const int16_t flag_delta, float *phi_hat, const int16_t n );

#endif


/*---------------------------------------------------------------
 * ivas_masa_setup()
 *
@@ -479,7 +492,7 @@ uint16_t index_theta_phi_16(
        sign_th = 1;
    }

    id_th = quantize_theta( abs_theta, gridData->no_theta, &theta_hat );
    id_th = quantize_theta_masa( abs_theta, gridData->no_theta, &theta_hat );
    if ( gridData->no_theta > 1 )
    {
        if ( gridData->no_phi[id_th] > 1 )
@@ -547,7 +560,7 @@ uint16_t index_theta_phi_16(
 *------------------------------------------------------------------------*/

/*! r: output index */
int16_t quantize_theta(
static int16_t quantize_theta_masa(
    float x,             /* i  : theta value to be quantized  */
    const int16_t no_cb, /* i  : number of codewords          */
    float *xhat          /* o  : quantized value              */
@@ -589,7 +602,7 @@ int16_t quantize_theta(
 *------------------------------------------------------------------------*/

/*! r: index azimuth */
int16_t quantize_phi_masa(
static int16_t quantize_phi_masa(
    float phi,                /* i  : azimuth value                                                   */
    const int16_t flag_delta, /* i  : flag indicating if the azimuth codebook is translated or not    */
    float *phi_hat,           /* o  : quantized azimuth                                               */
Loading