Loading lib_com/cnst.h +5 −0 Original line number Diff line number Diff line Loading @@ -119,10 +119,15 @@ #define ONE_IN_Q30 1073741824 #define ONE_IN_Q31 0x7fffffff #define MAX_WORD16 32767 #define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants *----------------------------------------------------------------------------------*/ #define DEGREE_180_Q_22 754974720 #define DEGREE_360_Q_22 1509949440 #define MODE1 1 #define MODE2 2 Loading lib_com/ivas_cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -903,6 +903,7 @@ typedef enum { #define DIRAC_LOW_BANDRES_STEP 2 /* always combine two bands for low band resolution in the DirAC parameter coding */ #define DIRAC_NO_COL_AVG_DIFF 32 /* Number of slots for averaging intensity vector for diffuseness computation */ #define DIRAC_DIFFUSE_LEVELS 8 /* Size of the diffuseness alphabet (constant value) */ #define INV_DIRAC_DIFFUSE_LEVELS_Q13 1170 /* 1/(DIRAC_DIFFUSE_LEVELS - 1) in Q13 */ #define DIRAC_DITH_SEED 29680 #define DIRAC_MAX_BITS 512 /* Maximum number of bits for DirAC side information per frame */ #define MAX_NUM_ENC_CLDFB_INSTANCES 8 /* Maximum Cldfb instances in DirAC encoder */ Loading lib_com/ivas_dirac_com.c +1 −3 Original line number Diff line number Diff line Loading @@ -883,9 +883,7 @@ void deindex_spherical_component_fx( BREAK; case 1: *az_idx = sph_idx; q_az_idx = norm_l( *az_idx ); az_idx_fx = L_shl( *az_idx, q_az_idx ); *az_fx = L_shl( Mpy_32_32( az_idx_fx, L_shl( -180, 22 ) ), 31 - q_az_idx ); *az_fx = L_shl((*az_idx) * (-180), 22); *el_fx = 0; *el_idx = 0; BREAK; Loading lib_com/ivas_masa_com.c +168 −147 Original line number Diff line number Diff line Loading @@ -389,9 +389,17 @@ void masa_sample_rate_band_correction( for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { hQMetaData->q_direction[0].band_data[band].azimuth[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf] = 0; #endif hQMetaData->q_direction[0].band_data[band].elevation[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = 0; #endif hQMetaData->q_direction[0].band_data[band].energy_ratio[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = 0; #endif if ( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = 0u; Loading @@ -400,8 +408,17 @@ void masa_sample_rate_band_correction( if ( hQMetaData->no_directions == 2 ) { hQMetaData->q_direction[1].band_data[band].azimuth[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[1].band_data[band].azimuth_fx[sf] = 0; #endif hQMetaData->q_direction[1].band_data[band].elevation[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[1].band_data[band].elevation_fx[sf] = 0; #endif hQMetaData->q_direction[1].band_data[band].energy_ratio[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[sf] = 0; #endif if ( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL ) { Loading Loading @@ -791,152 +808,156 @@ void deindex_sph_idx( return; } #ifdef IVAS_FLOAT_FIXED // void deindex_sph_idx( // const UWord16 sphIndex, /* i : Spherical index */ // const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ // Word32 *theta_fx, /* o : Elevation */ // Word32 *phi_fx /* o : Azimuth */ //) //{ // Word32 ba_crt_fx, del_crt_fx, div_crt_fx, a4_crt_fx; // Word32 estim; // Word32 base_low, base_up; // Word16 n_crt; // Word16 id_th; // Word16 sign_theta; // Word16 id_phi; // Word16 no_th = gridData->no_theta; // const Word16 *n = gridData->no_phi; // const Word32 ba_fx[3] = { 109465, 63736, 62894 }; // q = 9 // const Word32 del_fx[3] = { 409511008, 666052608, 729124992 }; // q = 9 // const Word32 div_fx[3] = { -121, -51, -47 }; // q = 9 // const Word32 a4_fx[3] = { -4308, -10144, -11124 }; // q = 9 // const UWord16 limit_index1 = 64964, limit_index2 = 47870; // // if ( sphIndex >= limit_index1 ) // { // ba_crt_fx = ba_fx[2]; // div_crt_fx = div_fx[2]; // a4_crt_fx = a4_fx[2]; // del_crt_fx = del_fx[2]; // } // else if ( sphIndex >= limit_index2 ) // { // ba_crt_fx = ba_fx[1]; // div_crt_fx = div_fx[1]; // a4_crt_fx = a4_fx[1]; // del_crt_fx = del_fx[1]; // } // else // { // ba_crt_fx = ba_fx[0]; // div_crt_fx = div_fx[0]; // a4_crt_fx = a4_fx[0]; // del_crt_fx = del_fx[0]; // } // estim = ba_crt_fx + div_crt_fx * sqrtf( del_crt + a4_crt * sphIndex ); // // if ( estim > MASA_NO_CIRCLES ) // { // estim = MASA_NO_CIRCLES; // } // // assert( estim > 0 ); // id_th = (int16_t) roundf( estim ) - 1; // if ( id_th < 0 ) // { // id_th = 0; // } // // if ( id_th == 0 ) // { // base_low = 0; // base_up = n[0]; // } // else // { // estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f ); // base_low = n[0]; // if ( id_th >= 2 ) // { // if ( id_th == 2 ) // { // base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); // } // else // { // base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); // } // } // base_up = base_low + 2 * n[id_th]; // } // // sign_theta = 1; // // n_crt = n[id_th]; // if ( sphIndex < base_low ) // { // id_th--; // n_crt = n[id_th]; // if ( id_th == 0 ) // { // base_low = 0; // base_up = n_crt; // } // else // { // base_up = base_low; // base_low -= 2 * n[id_th]; // } // assert( sphIndex >= base_low ); // } // else if ( sphIndex >= base_up ) // { // id_th++; // n_crt = n[id_th]; // base_low = base_up; // base_up += 2 * n_crt; // assert( sphIndex < base_up ); // } // // id_phi = (int16_t) ( sphIndex - base_low ); // if ( sphIndex - base_low >= n_crt ) // { // id_phi -= n_crt; // sign_theta = -1; // } // // if ( id_th == 0 ) // { // *theta = 0.f; // *phi = (float) sphIndex * 360 / (float) n_crt - 180; // } // else // { // if ( id_th == no_th - 1 ) // { // id_phi = 0; // *phi = -180; // *theta = 90 * (float) sign_theta; // } // else // { // *theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta; // if ( id_th % 2 == 0 ) // { // *phi = (float) id_phi * 360 / (float) n_crt - 180; // } // else // { // *phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180; // } // } // } // // return; // } #endif void deindex_sph_idx_fx( const uint16_t sphIndex, /* i : Spherical index */ const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ Word32 *theta_fx, /* o : Elevation */ Word32 *phi_fx /* o : Azimuth */ ) { // temp conversion as function using sin and cos float theta = (float) *theta_fx / ( 1 << 22 ); float phi = (float) *phi_fx / ( 1 << 22 ); float ba_crt, del_crt, div_crt, a4_crt; float estim; int32_t base_low, base_up; int16_t n_crt; int16_t id_th; int16_t sign_theta; int16_t id_phi; int16_t no_th = gridData->no_theta; const int16_t *n = gridData->no_phi; const float ba[3] = { 2.137991118026424e+02f, 1.244854404591542e+02f, 1.228408647140870e+02f }; const float del[3] = { 7.998262115303199e+05f, 1.300883976959332e+06f, 1.424072242426373e+06f }; const float div[3] = { -0.237662341081474f, -0.100938185496887f, -0.092050209205032f }; const float a4[3] = { -8.415300425381099f, -19.814106922515204f, -21.727272727270197f }; const uint16_t limit_index1 = 64964, limit_index2 = 47870; if ( sphIndex >= limit_index1 ) { ba_crt = ba[2]; div_crt = div[2]; a4_crt = a4[2]; del_crt = del[2]; } else if ( sphIndex >= limit_index2 ) { ba_crt = ba[1]; div_crt = div[1]; a4_crt = a4[1]; del_crt = del[1]; } else { ba_crt = ba[0]; div_crt = div[0]; a4_crt = a4[0]; del_crt = del[0]; } estim = ba_crt + div_crt * sqrtf( del_crt + a4_crt * sphIndex ); if ( estim > MASA_NO_CIRCLES ) { estim = MASA_NO_CIRCLES; } assert( estim > 0 ); id_th = (int16_t) roundf( estim ) - 1; if ( id_th < 0 ) { id_th = 0; } if ( id_th == 0 ) { base_low = 0; base_up = n[0]; } else { estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f ); base_low = n[0]; if ( id_th >= 2 ) { if ( id_th == 2 ) { base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); } else { base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); } } base_up = base_low + 2 * n[id_th]; } sign_theta = 1; n_crt = n[id_th]; if ( sphIndex < base_low ) { id_th--; n_crt = n[id_th]; if ( id_th == 0 ) { base_low = 0; base_up = n_crt; } else { base_up = base_low; base_low -= 2 * n[id_th]; } assert( sphIndex >= base_low ); } else if ( sphIndex >= base_up ) { id_th++; n_crt = n[id_th]; base_low = base_up; base_up += 2 * n_crt; assert( sphIndex < base_up ); } id_phi = (int16_t) ( sphIndex - base_low ); if ( sphIndex - base_low >= n_crt ) { id_phi -= n_crt; sign_theta = -1; } if ( id_th == 0 ) { theta = 0.f; phi = (float) sphIndex * 360 / (float) n_crt - 180; } else { if ( id_th == no_th - 1 ) { id_phi = 0; phi = -180; theta = 90 * (float) sign_theta; } else { theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta; if ( id_th % 2 == 0 ) { phi = (float) id_phi * 360 / (float) n_crt - 180; } else { phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180; } } } *theta_fx = theta * ( 1 << 22 ); *phi_fx = phi * ( 1 << 22 ); return; } /*--------------------------------------------------------------- * valid_ratio_index() Loading lib_com/ivas_prot.h +23 −1 Original line number Diff line number Diff line Loading @@ -3225,6 +3225,12 @@ void deindex_sph_idx( float *theta, /* o : Elevation */ float *phi /* o : Azimuth */ ); void deindex_sph_idx_fx( const uint16_t sphIndex, /* i : Spherical index */ const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ Word32 *theta_fx, /* o : Elevation */ Word32 *phi_fx /* o : Azimuth */ ); /*! r: output index for direction */ uint16_t index_theta_phi_16( Loading Loading @@ -3335,6 +3341,11 @@ void ivas_qmetadata_azimuth_elevation_to_direction_vector( const float el, /* i : elevation */ float *dv /* o : direction vector */ ); void ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( const Word32 az, /* i : azimuth */ const Word32 el, /* i : elevation */ Word32 *dv /* o : direction vector */ ); void ivas_qmetadata_direction_vector_to_azimuth_elevation( const float *dv, /* i : direction vector */ Loading @@ -3342,6 +3353,12 @@ void ivas_qmetadata_direction_vector_to_azimuth_elevation( float *el /* o : elevation */ ); void ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( const Word32 *dv, /* i : direction vector */ const Word32 div_q, Word32 *az, /* o : azimuth */ Word32 *el /* o : elevation */ ); ivas_error only_reduce_bits_direction( int16_t *reduce_bits_out, IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ Loading Loading @@ -3433,7 +3450,12 @@ int16_t quantize_phi( float *phi_hat, /* o : quantized azimuth */ const int16_t n /* i : azimuth codebook size */ ); int16_t quantize_phi_fx( Word32 phi, /* i : azimuth value */ const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ Word32 *phi_hat, /* o : quantized azimuth */ const int16_t n /* i : azimuth codebook size */ ); /*! r: decoded elevation value */ float deindex_elevation( uint16_t *id_th, /* i : input index */ Loading Loading
lib_com/cnst.h +5 −0 Original line number Diff line number Diff line Loading @@ -119,10 +119,15 @@ #define ONE_IN_Q30 1073741824 #define ONE_IN_Q31 0x7fffffff #define MAX_WORD16 32767 #define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants *----------------------------------------------------------------------------------*/ #define DEGREE_180_Q_22 754974720 #define DEGREE_360_Q_22 1509949440 #define MODE1 1 #define MODE2 2 Loading
lib_com/ivas_cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -903,6 +903,7 @@ typedef enum { #define DIRAC_LOW_BANDRES_STEP 2 /* always combine two bands for low band resolution in the DirAC parameter coding */ #define DIRAC_NO_COL_AVG_DIFF 32 /* Number of slots for averaging intensity vector for diffuseness computation */ #define DIRAC_DIFFUSE_LEVELS 8 /* Size of the diffuseness alphabet (constant value) */ #define INV_DIRAC_DIFFUSE_LEVELS_Q13 1170 /* 1/(DIRAC_DIFFUSE_LEVELS - 1) in Q13 */ #define DIRAC_DITH_SEED 29680 #define DIRAC_MAX_BITS 512 /* Maximum number of bits for DirAC side information per frame */ #define MAX_NUM_ENC_CLDFB_INSTANCES 8 /* Maximum Cldfb instances in DirAC encoder */ Loading
lib_com/ivas_dirac_com.c +1 −3 Original line number Diff line number Diff line Loading @@ -883,9 +883,7 @@ void deindex_spherical_component_fx( BREAK; case 1: *az_idx = sph_idx; q_az_idx = norm_l( *az_idx ); az_idx_fx = L_shl( *az_idx, q_az_idx ); *az_fx = L_shl( Mpy_32_32( az_idx_fx, L_shl( -180, 22 ) ), 31 - q_az_idx ); *az_fx = L_shl((*az_idx) * (-180), 22); *el_fx = 0; *el_idx = 0; BREAK; Loading
lib_com/ivas_masa_com.c +168 −147 Original line number Diff line number Diff line Loading @@ -389,9 +389,17 @@ void masa_sample_rate_band_correction( for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { hQMetaData->q_direction[0].band_data[band].azimuth[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf] = 0; #endif hQMetaData->q_direction[0].band_data[band].elevation[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = 0; #endif hQMetaData->q_direction[0].band_data[band].energy_ratio[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = 0; #endif if ( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = 0u; Loading @@ -400,8 +408,17 @@ void masa_sample_rate_band_correction( if ( hQMetaData->no_directions == 2 ) { hQMetaData->q_direction[1].band_data[band].azimuth[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[1].band_data[band].azimuth_fx[sf] = 0; #endif hQMetaData->q_direction[1].band_data[band].elevation[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[1].band_data[band].elevation_fx[sf] = 0; #endif hQMetaData->q_direction[1].band_data[band].energy_ratio[sf] = 0.0f; #ifdef IVAS_FLOAT_FIXED hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[sf] = 0; #endif if ( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL ) { Loading Loading @@ -791,152 +808,156 @@ void deindex_sph_idx( return; } #ifdef IVAS_FLOAT_FIXED // void deindex_sph_idx( // const UWord16 sphIndex, /* i : Spherical index */ // const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ // Word32 *theta_fx, /* o : Elevation */ // Word32 *phi_fx /* o : Azimuth */ //) //{ // Word32 ba_crt_fx, del_crt_fx, div_crt_fx, a4_crt_fx; // Word32 estim; // Word32 base_low, base_up; // Word16 n_crt; // Word16 id_th; // Word16 sign_theta; // Word16 id_phi; // Word16 no_th = gridData->no_theta; // const Word16 *n = gridData->no_phi; // const Word32 ba_fx[3] = { 109465, 63736, 62894 }; // q = 9 // const Word32 del_fx[3] = { 409511008, 666052608, 729124992 }; // q = 9 // const Word32 div_fx[3] = { -121, -51, -47 }; // q = 9 // const Word32 a4_fx[3] = { -4308, -10144, -11124 }; // q = 9 // const UWord16 limit_index1 = 64964, limit_index2 = 47870; // // if ( sphIndex >= limit_index1 ) // { // ba_crt_fx = ba_fx[2]; // div_crt_fx = div_fx[2]; // a4_crt_fx = a4_fx[2]; // del_crt_fx = del_fx[2]; // } // else if ( sphIndex >= limit_index2 ) // { // ba_crt_fx = ba_fx[1]; // div_crt_fx = div_fx[1]; // a4_crt_fx = a4_fx[1]; // del_crt_fx = del_fx[1]; // } // else // { // ba_crt_fx = ba_fx[0]; // div_crt_fx = div_fx[0]; // a4_crt_fx = a4_fx[0]; // del_crt_fx = del_fx[0]; // } // estim = ba_crt_fx + div_crt_fx * sqrtf( del_crt + a4_crt * sphIndex ); // // if ( estim > MASA_NO_CIRCLES ) // { // estim = MASA_NO_CIRCLES; // } // // assert( estim > 0 ); // id_th = (int16_t) roundf( estim ) - 1; // if ( id_th < 0 ) // { // id_th = 0; // } // // if ( id_th == 0 ) // { // base_low = 0; // base_up = n[0]; // } // else // { // estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f ); // base_low = n[0]; // if ( id_th >= 2 ) // { // if ( id_th == 2 ) // { // base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); // } // else // { // base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); // } // } // base_up = base_low + 2 * n[id_th]; // } // // sign_theta = 1; // // n_crt = n[id_th]; // if ( sphIndex < base_low ) // { // id_th--; // n_crt = n[id_th]; // if ( id_th == 0 ) // { // base_low = 0; // base_up = n_crt; // } // else // { // base_up = base_low; // base_low -= 2 * n[id_th]; // } // assert( sphIndex >= base_low ); // } // else if ( sphIndex >= base_up ) // { // id_th++; // n_crt = n[id_th]; // base_low = base_up; // base_up += 2 * n_crt; // assert( sphIndex < base_up ); // } // // id_phi = (int16_t) ( sphIndex - base_low ); // if ( sphIndex - base_low >= n_crt ) // { // id_phi -= n_crt; // sign_theta = -1; // } // // if ( id_th == 0 ) // { // *theta = 0.f; // *phi = (float) sphIndex * 360 / (float) n_crt - 180; // } // else // { // if ( id_th == no_th - 1 ) // { // id_phi = 0; // *phi = -180; // *theta = 90 * (float) sign_theta; // } // else // { // *theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta; // if ( id_th % 2 == 0 ) // { // *phi = (float) id_phi * 360 / (float) n_crt - 180; // } // else // { // *phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180; // } // } // } // // return; // } #endif void deindex_sph_idx_fx( const uint16_t sphIndex, /* i : Spherical index */ const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ Word32 *theta_fx, /* o : Elevation */ Word32 *phi_fx /* o : Azimuth */ ) { // temp conversion as function using sin and cos float theta = (float) *theta_fx / ( 1 << 22 ); float phi = (float) *phi_fx / ( 1 << 22 ); float ba_crt, del_crt, div_crt, a4_crt; float estim; int32_t base_low, base_up; int16_t n_crt; int16_t id_th; int16_t sign_theta; int16_t id_phi; int16_t no_th = gridData->no_theta; const int16_t *n = gridData->no_phi; const float ba[3] = { 2.137991118026424e+02f, 1.244854404591542e+02f, 1.228408647140870e+02f }; const float del[3] = { 7.998262115303199e+05f, 1.300883976959332e+06f, 1.424072242426373e+06f }; const float div[3] = { -0.237662341081474f, -0.100938185496887f, -0.092050209205032f }; const float a4[3] = { -8.415300425381099f, -19.814106922515204f, -21.727272727270197f }; const uint16_t limit_index1 = 64964, limit_index2 = 47870; if ( sphIndex >= limit_index1 ) { ba_crt = ba[2]; div_crt = div[2]; a4_crt = a4[2]; del_crt = del[2]; } else if ( sphIndex >= limit_index2 ) { ba_crt = ba[1]; div_crt = div[1]; a4_crt = a4[1]; del_crt = del[1]; } else { ba_crt = ba[0]; div_crt = div[0]; a4_crt = a4[0]; del_crt = del[0]; } estim = ba_crt + div_crt * sqrtf( del_crt + a4_crt * sphIndex ); if ( estim > MASA_NO_CIRCLES ) { estim = MASA_NO_CIRCLES; } assert( estim > 0 ); id_th = (int16_t) roundf( estim ) - 1; if ( id_th < 0 ) { id_th = 0; } if ( id_th == 0 ) { base_low = 0; base_up = n[0]; } else { estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f ); base_low = n[0]; if ( id_th >= 2 ) { if ( id_th == 2 ) { base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); } else { base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); } } base_up = base_low + 2 * n[id_th]; } sign_theta = 1; n_crt = n[id_th]; if ( sphIndex < base_low ) { id_th--; n_crt = n[id_th]; if ( id_th == 0 ) { base_low = 0; base_up = n_crt; } else { base_up = base_low; base_low -= 2 * n[id_th]; } assert( sphIndex >= base_low ); } else if ( sphIndex >= base_up ) { id_th++; n_crt = n[id_th]; base_low = base_up; base_up += 2 * n_crt; assert( sphIndex < base_up ); } id_phi = (int16_t) ( sphIndex - base_low ); if ( sphIndex - base_low >= n_crt ) { id_phi -= n_crt; sign_theta = -1; } if ( id_th == 0 ) { theta = 0.f; phi = (float) sphIndex * 360 / (float) n_crt - 180; } else { if ( id_th == no_th - 1 ) { id_phi = 0; phi = -180; theta = 90 * (float) sign_theta; } else { theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta; if ( id_th % 2 == 0 ) { phi = (float) id_phi * 360 / (float) n_crt - 180; } else { phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180; } } } *theta_fx = theta * ( 1 << 22 ); *phi_fx = phi * ( 1 << 22 ); return; } /*--------------------------------------------------------------- * valid_ratio_index() Loading
lib_com/ivas_prot.h +23 −1 Original line number Diff line number Diff line Loading @@ -3225,6 +3225,12 @@ void deindex_sph_idx( float *theta, /* o : Elevation */ float *phi /* o : Azimuth */ ); void deindex_sph_idx_fx( const uint16_t sphIndex, /* i : Spherical index */ const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ Word32 *theta_fx, /* o : Elevation */ Word32 *phi_fx /* o : Azimuth */ ); /*! r: output index for direction */ uint16_t index_theta_phi_16( Loading Loading @@ -3335,6 +3341,11 @@ void ivas_qmetadata_azimuth_elevation_to_direction_vector( const float el, /* i : elevation */ float *dv /* o : direction vector */ ); void ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( const Word32 az, /* i : azimuth */ const Word32 el, /* i : elevation */ Word32 *dv /* o : direction vector */ ); void ivas_qmetadata_direction_vector_to_azimuth_elevation( const float *dv, /* i : direction vector */ Loading @@ -3342,6 +3353,12 @@ void ivas_qmetadata_direction_vector_to_azimuth_elevation( float *el /* o : elevation */ ); void ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( const Word32 *dv, /* i : direction vector */ const Word32 div_q, Word32 *az, /* o : azimuth */ Word32 *el /* o : elevation */ ); ivas_error only_reduce_bits_direction( int16_t *reduce_bits_out, IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ Loading Loading @@ -3433,7 +3450,12 @@ int16_t quantize_phi( float *phi_hat, /* o : quantized azimuth */ const int16_t n /* i : azimuth codebook size */ ); int16_t quantize_phi_fx( Word32 phi, /* i : azimuth value */ const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ Word32 *phi_hat, /* o : quantized azimuth */ const int16_t n /* i : azimuth codebook size */ ); /*! r: decoded elevation value */ float deindex_elevation( uint16_t *id_th, /* i : input index */ Loading