Loading lib_com/ivas_cnst.h +4 −1 Original line number Diff line number Diff line Loading @@ -1273,9 +1273,13 @@ enum #define MASA_NO_POINTS_EQUATOR 430 #define MASA_NO_CIRCLES 121 #define MASA_ASIN_OFFSET 0.0064471690266724975f #define MASA_ASIN_OFFSET_Q15 ( 211 ) #define MASA_NTOT2_FAC 32768.00566947353f #define MASA_NTOT2_FAC_Q15 ( 1073741952 ) #define MASA_ANGLE_AT_EQUATOR 0.012894427382667f #define MASA_ANGLE_AT_EQUATOR_Q31 ( 27690572 ) #define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f #define MASA_ANGLE_AT_EQUATOR_DEG_Q31 ( 1586552905l ) #define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ Loading @@ -1285,7 +1289,6 @@ enum #define NBITS_HR_COH 4 #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 (1453366656l) #define MASA_ANGLE_AT_EQUATOR_DEG_Q31 (1586552905l) #define MASA_JBM_RINGBUFFER_FRAMES 3 Loading lib_com/ivas_masa_com.c +132 −73 Original line number Diff line number Diff line Loading @@ -1416,153 +1416,212 @@ void deindex_sph_idx( } void deindex_sph_idx_fx( const uint16_t sphIndex, /* i : Spherical index */ 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 */ ) { // 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; Word32 ba_crt_fx, del_crt_fx, div_crt_fx, a4_crt_fx; Word32 estim_fx; 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] = { 1793476992, 1044259584, 1030463872 }; /* Q23 */ const Word32 del_fx[3] = { 819022016, 1332105216, 1458249984 }; /* Q10 */ const Word32 div_fx[3] = { -510376000, -216763104, -197676320 }; /* Q31 */ const Word32 a4_fx[3] = { -564741248, -1329702144, -1458092544 }; /* Q26 */ const UWord16 limit_index1 = 64964, limit_index2 = 47870; Word32 tmp32; Word16 tmp16, tmp_e; move16(); move16(); if ( sphIndex >= limit_index1 ) IF( GE_32( sphIndex, limit_index1 ) ) { ba_crt = ba[2]; div_crt = div[2]; a4_crt = a4[2]; del_crt = del[2]; ba_crt_fx = ba_fx[2]; move32(); div_crt_fx = div_fx[2]; move32(); a4_crt_fx = a4_fx[2]; move32(); del_crt_fx = del_fx[2]; move32(); } else if ( sphIndex >= limit_index2 ) ELSE IF( GE_32( sphIndex, limit_index2 ) ) { ba_crt = ba[1]; div_crt = div[1]; a4_crt = a4[1]; del_crt = del[1]; ba_crt_fx = ba_fx[1]; move32(); div_crt_fx = div_fx[1]; move32(); a4_crt_fx = a4_fx[1]; move32(); del_crt_fx = del_fx[1]; move32(); } else ELSE { ba_crt = ba[0]; div_crt = div[0]; a4_crt = a4[0]; del_crt = del[0]; ba_crt_fx = ba_fx[0]; move32(); div_crt_fx = div_fx[0]; move32(); a4_crt_fx = a4_fx[0]; move32(); del_crt_fx = del_fx[0]; move32(); } estim = ba_crt + div_crt * sqrtf( del_crt + a4_crt * sphIndex ); tmp32 = Mpy_32_32( a4_crt_fx, L_shl_sat( sphIndex, Q15 ) ); /* Q10 */ tmp32 = L_add( del_crt_fx, tmp32 ); /* Q10 */ tmp16 = Q31 - Q10; tmp32 = Sqrt32( tmp32, &tmp16 ); tmp32 = Mpy_32_32( div_crt_fx, tmp32 ); tmp32 = L_shr( tmp32, sub( Q8, tmp16 ) ); /* Q23 */ estim_fx = L_add( ba_crt_fx, tmp32 ); /* Q23 */ if ( estim > MASA_NO_CIRCLES ) if ( GT_32( estim_fx, MASA_NO_CIRCLES << Q23 ) ) { estim = MASA_NO_CIRCLES; estim_fx = MASA_NO_CIRCLES << Q23; move32(); } assert( estim > 0 ); id_th = (int16_t) roundf( estim ) - 1; assert( estim_fx > 0 ); id_th = sub( extract_l( L_shr_r( estim_fx, Q23 ) ), 1 ); /* Q0 */ if ( id_th < 0 ) { id_th = 0; move16(); } if ( id_th == 0 ) IF( id_th == 0 ) { base_low = 0; move32(); base_up = n[0]; move32(); } else ELSE { estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f ); estim_fx = Mpy_32_32( MASA_ANGLE_AT_EQUATOR_Q31, L_sub( L_shl( id_th, Q22 ), 2097152 ) /* 0.5f in Q22 */ ); /* Q22 */ base_low = n[0]; if ( id_th >= 2 ) move32(); IF( GE_16( id_th, 2 ) ) { if ( id_th == 2 ) tmp32 = estim_fx % 26353590; /* 2 * PI in Q22 */ tmp32 = Mpy_32_32( tmp32, 341782638 /* 2147483647 / 2 * PI */ ); /* Q7 */ tmp16 = extract_l( L_shr( tmp32, Q7 ) ); tmp16 = getSineWord16R2( tmp16 ); tmp16 = sub( tmp16, MASA_ASIN_OFFSET_Q15 ); tmp32 = Mpy_32_16_1( MASA_NTOT2_FAC_Q15, tmp16 ); /* Q15 */ IF( EQ_16( id_th, 2 ) ) { base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); base_low = L_add( base_low, L_shl( extract_l( L_shr( ceil_fixed( tmp32, Q15 ), Q15 ) ), 1 ) ); /* Q0 */ } else ELSE { base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); base_low = L_add( base_low, L_shl( extract_l( L_shr_r( tmp32, Q15 ) ), 1 ) ); /* Q0 */ } } base_up = base_low + 2 * n[id_th]; base_up = L_add( base_low, L_shl( n[id_th], 1 ) ); } sign_theta = 1; move16(); n_crt = n[id_th]; if ( sphIndex < base_low ) move16(); IF( LT_32( sphIndex, base_low ) ) { id_th--; n_crt = n[id_th]; if ( id_th == 0 ) move16(); IF( id_th == 0 ) { base_low = 0; move32(); base_up = n_crt; move32(); } else ELSE { base_up = base_low; base_low -= 2 * n[id_th]; move32(); base_low = L_sub( base_low, shl( n[id_th], 1 ) ); } assert( sphIndex >= base_low ); } else if ( sphIndex >= base_up ) ELSE IF( GE_32( sphIndex, base_up ) ) { id_th++; n_crt = n[id_th]; move16(); base_low = base_up; base_up += 2 * n_crt; move32(); base_up = L_add( base_up, shl( n_crt, 1 ) ); assert( sphIndex < base_up ); } id_phi = (int16_t) ( sphIndex - base_low ); if ( sphIndex - base_low >= n_crt ) id_phi = extract_l( L_sub( sphIndex, base_low ) ); IF( GE_32( L_sub( sphIndex, base_low ), n_crt ) ) { id_phi -= n_crt; id_phi = sub( id_phi, n_crt ); sign_theta = -1; move16(); } if ( id_th == 0 ) IF( id_th == 0 ) { theta = 0.f; phi = (float) sphIndex * 360 / (float) n_crt - 180; *theta_fx = 0; move32(); tmp32 = imult3216( sphIndex, 360 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp32, n_crt, &tmp_e ); tmp32 = L_shl( tmp16, add( Q7, tmp_e ) ); /* Q22 */ *phi_fx = L_sub( tmp32, 180 << Q22 ); /* Q22 */ move32(); } else ELSE { if ( id_th == no_th - 1 ) IF( EQ_16( id_th, sub( no_th, 1 ) ) ) { id_phi = 0; phi = -180; theta = 90 * (float) sign_theta; move16(); *phi_fx = -754974720; /* -180 in Q22 */ move32(); *theta_fx = L_shl( L_mult0( 90, sign_theta ), Q22 ); /* Q22 */ move32(); } else ELSE { theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta; if ( id_th % 2 == 0 ) *theta_fx = Mpy_32_32( L_shl( id_th, Q22 ), MASA_ANGLE_AT_EQUATOR_DEG_Q31 ); /* Q22 */ move32(); if ( EQ_16( sign_theta, -1 ) ) { phi = (float) id_phi * 360 / (float) n_crt - 180; *theta_fx = L_negate( *theta_fx ); /* Q22 */ move32(); } else IF( id_th % 2 == 0 ) { tmp32 = L_mult0( id_phi, 360 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp32, n_crt, &tmp_e ); tmp32 = L_shl( tmp16, add( Q7, tmp_e ) ); /* Q22 */ *phi_fx = L_sub( tmp32, 180 << Q22 ); /* Q22 */ move32(); } ELSE { phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180; tmp32 = L_add( L_mult0( id_phi, 360 ), 180 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp32, n_crt, &tmp_e ); tmp32 = L_shl( tmp16, add( Q7, tmp_e ) ); /* Q22 */ *phi_fx = L_sub( tmp32, 180 << Q22 ); /* Q22 */ move32(); } } } *theta_fx = (Word32) ( theta * ( 1 << 22 ) ); *phi_fx = (Word32) ( phi * ( 1 << 22 ) ); return; } Loading Loading
lib_com/ivas_cnst.h +4 −1 Original line number Diff line number Diff line Loading @@ -1273,9 +1273,13 @@ enum #define MASA_NO_POINTS_EQUATOR 430 #define MASA_NO_CIRCLES 121 #define MASA_ASIN_OFFSET 0.0064471690266724975f #define MASA_ASIN_OFFSET_Q15 ( 211 ) #define MASA_NTOT2_FAC 32768.00566947353f #define MASA_NTOT2_FAC_Q15 ( 1073741952 ) #define MASA_ANGLE_AT_EQUATOR 0.012894427382667f #define MASA_ANGLE_AT_EQUATOR_Q31 ( 27690572 ) #define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f #define MASA_ANGLE_AT_EQUATOR_DEG_Q31 ( 1586552905l ) #define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ Loading @@ -1285,7 +1289,6 @@ enum #define NBITS_HR_COH 4 #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 (1453366656l) #define MASA_ANGLE_AT_EQUATOR_DEG_Q31 (1586552905l) #define MASA_JBM_RINGBUFFER_FRAMES 3 Loading
lib_com/ivas_masa_com.c +132 −73 Original line number Diff line number Diff line Loading @@ -1416,153 +1416,212 @@ void deindex_sph_idx( } void deindex_sph_idx_fx( const uint16_t sphIndex, /* i : Spherical index */ 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 */ ) { // 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; Word32 ba_crt_fx, del_crt_fx, div_crt_fx, a4_crt_fx; Word32 estim_fx; 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] = { 1793476992, 1044259584, 1030463872 }; /* Q23 */ const Word32 del_fx[3] = { 819022016, 1332105216, 1458249984 }; /* Q10 */ const Word32 div_fx[3] = { -510376000, -216763104, -197676320 }; /* Q31 */ const Word32 a4_fx[3] = { -564741248, -1329702144, -1458092544 }; /* Q26 */ const UWord16 limit_index1 = 64964, limit_index2 = 47870; Word32 tmp32; Word16 tmp16, tmp_e; move16(); move16(); if ( sphIndex >= limit_index1 ) IF( GE_32( sphIndex, limit_index1 ) ) { ba_crt = ba[2]; div_crt = div[2]; a4_crt = a4[2]; del_crt = del[2]; ba_crt_fx = ba_fx[2]; move32(); div_crt_fx = div_fx[2]; move32(); a4_crt_fx = a4_fx[2]; move32(); del_crt_fx = del_fx[2]; move32(); } else if ( sphIndex >= limit_index2 ) ELSE IF( GE_32( sphIndex, limit_index2 ) ) { ba_crt = ba[1]; div_crt = div[1]; a4_crt = a4[1]; del_crt = del[1]; ba_crt_fx = ba_fx[1]; move32(); div_crt_fx = div_fx[1]; move32(); a4_crt_fx = a4_fx[1]; move32(); del_crt_fx = del_fx[1]; move32(); } else ELSE { ba_crt = ba[0]; div_crt = div[0]; a4_crt = a4[0]; del_crt = del[0]; ba_crt_fx = ba_fx[0]; move32(); div_crt_fx = div_fx[0]; move32(); a4_crt_fx = a4_fx[0]; move32(); del_crt_fx = del_fx[0]; move32(); } estim = ba_crt + div_crt * sqrtf( del_crt + a4_crt * sphIndex ); tmp32 = Mpy_32_32( a4_crt_fx, L_shl_sat( sphIndex, Q15 ) ); /* Q10 */ tmp32 = L_add( del_crt_fx, tmp32 ); /* Q10 */ tmp16 = Q31 - Q10; tmp32 = Sqrt32( tmp32, &tmp16 ); tmp32 = Mpy_32_32( div_crt_fx, tmp32 ); tmp32 = L_shr( tmp32, sub( Q8, tmp16 ) ); /* Q23 */ estim_fx = L_add( ba_crt_fx, tmp32 ); /* Q23 */ if ( estim > MASA_NO_CIRCLES ) if ( GT_32( estim_fx, MASA_NO_CIRCLES << Q23 ) ) { estim = MASA_NO_CIRCLES; estim_fx = MASA_NO_CIRCLES << Q23; move32(); } assert( estim > 0 ); id_th = (int16_t) roundf( estim ) - 1; assert( estim_fx > 0 ); id_th = sub( extract_l( L_shr_r( estim_fx, Q23 ) ), 1 ); /* Q0 */ if ( id_th < 0 ) { id_th = 0; move16(); } if ( id_th == 0 ) IF( id_th == 0 ) { base_low = 0; move32(); base_up = n[0]; move32(); } else ELSE { estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f ); estim_fx = Mpy_32_32( MASA_ANGLE_AT_EQUATOR_Q31, L_sub( L_shl( id_th, Q22 ), 2097152 ) /* 0.5f in Q22 */ ); /* Q22 */ base_low = n[0]; if ( id_th >= 2 ) move32(); IF( GE_16( id_th, 2 ) ) { if ( id_th == 2 ) tmp32 = estim_fx % 26353590; /* 2 * PI in Q22 */ tmp32 = Mpy_32_32( tmp32, 341782638 /* 2147483647 / 2 * PI */ ); /* Q7 */ tmp16 = extract_l( L_shr( tmp32, Q7 ) ); tmp16 = getSineWord16R2( tmp16 ); tmp16 = sub( tmp16, MASA_ASIN_OFFSET_Q15 ); tmp32 = Mpy_32_16_1( MASA_NTOT2_FAC_Q15, tmp16 ); /* Q15 */ IF( EQ_16( id_th, 2 ) ) { base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); base_low = L_add( base_low, L_shl( extract_l( L_shr( ceil_fixed( tmp32, Q15 ), Q15 ) ), 1 ) ); /* Q0 */ } else ELSE { base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) ); base_low = L_add( base_low, L_shl( extract_l( L_shr_r( tmp32, Q15 ) ), 1 ) ); /* Q0 */ } } base_up = base_low + 2 * n[id_th]; base_up = L_add( base_low, L_shl( n[id_th], 1 ) ); } sign_theta = 1; move16(); n_crt = n[id_th]; if ( sphIndex < base_low ) move16(); IF( LT_32( sphIndex, base_low ) ) { id_th--; n_crt = n[id_th]; if ( id_th == 0 ) move16(); IF( id_th == 0 ) { base_low = 0; move32(); base_up = n_crt; move32(); } else ELSE { base_up = base_low; base_low -= 2 * n[id_th]; move32(); base_low = L_sub( base_low, shl( n[id_th], 1 ) ); } assert( sphIndex >= base_low ); } else if ( sphIndex >= base_up ) ELSE IF( GE_32( sphIndex, base_up ) ) { id_th++; n_crt = n[id_th]; move16(); base_low = base_up; base_up += 2 * n_crt; move32(); base_up = L_add( base_up, shl( n_crt, 1 ) ); assert( sphIndex < base_up ); } id_phi = (int16_t) ( sphIndex - base_low ); if ( sphIndex - base_low >= n_crt ) id_phi = extract_l( L_sub( sphIndex, base_low ) ); IF( GE_32( L_sub( sphIndex, base_low ), n_crt ) ) { id_phi -= n_crt; id_phi = sub( id_phi, n_crt ); sign_theta = -1; move16(); } if ( id_th == 0 ) IF( id_th == 0 ) { theta = 0.f; phi = (float) sphIndex * 360 / (float) n_crt - 180; *theta_fx = 0; move32(); tmp32 = imult3216( sphIndex, 360 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp32, n_crt, &tmp_e ); tmp32 = L_shl( tmp16, add( Q7, tmp_e ) ); /* Q22 */ *phi_fx = L_sub( tmp32, 180 << Q22 ); /* Q22 */ move32(); } else ELSE { if ( id_th == no_th - 1 ) IF( EQ_16( id_th, sub( no_th, 1 ) ) ) { id_phi = 0; phi = -180; theta = 90 * (float) sign_theta; move16(); *phi_fx = -754974720; /* -180 in Q22 */ move32(); *theta_fx = L_shl( L_mult0( 90, sign_theta ), Q22 ); /* Q22 */ move32(); } else ELSE { theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta; if ( id_th % 2 == 0 ) *theta_fx = Mpy_32_32( L_shl( id_th, Q22 ), MASA_ANGLE_AT_EQUATOR_DEG_Q31 ); /* Q22 */ move32(); if ( EQ_16( sign_theta, -1 ) ) { phi = (float) id_phi * 360 / (float) n_crt - 180; *theta_fx = L_negate( *theta_fx ); /* Q22 */ move32(); } else IF( id_th % 2 == 0 ) { tmp32 = L_mult0( id_phi, 360 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp32, n_crt, &tmp_e ); tmp32 = L_shl( tmp16, add( Q7, tmp_e ) ); /* Q22 */ *phi_fx = L_sub( tmp32, 180 << Q22 ); /* Q22 */ move32(); } ELSE { phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180; tmp32 = L_add( L_mult0( id_phi, 360 ), 180 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp32, n_crt, &tmp_e ); tmp32 = L_shl( tmp16, add( Q7, tmp_e ) ); /* Q22 */ *phi_fx = L_sub( tmp32, 180 << Q22 ); /* Q22 */ move32(); } } } *theta_fx = (Word32) ( theta * ( 1 << 22 ) ); *phi_fx = (Word32) ( phi * ( 1 << 22 ) ); return; } Loading