Loading lib_com/ivas_cnst.h +9 −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 Loading @@ -1338,8 +1341,13 @@ typedef enum #define MCMASA_SEPARATE_BRATE IVAS_64k /* minimum bitrate from which separated channel coding is supported */ #define MCMASA_MAX_ANA_CHANS 11 /* Maximum number of channels currently used in analysis of multichannel formats */ #ifdef IVAS_FLOAT_FIXED #define MCMASA_MONOBITRATIO_64k_Q31 ( 536870912 ) #define MCMASA_MONOBITRATIO_Q31 ( 644245095 ) #else #define MCMASA_MONOBITRATIO 0.3f #define MCMASA_MONOBITRATIO_64k 0.25f #endif #define MC_MASA_THR_ELEVATION 40 #define MCMASA_LFE_QLOW -6.5f 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 lib_com/ivas_mc_com.c +167 −21 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ #include "prot.h" #include "ivas_prot.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif /*--------------------------------------------------------------- Loading @@ -46,13 +49,84 @@ * ---------------------------------------------------------------*/ /*! r : MC format mode */ #ifndef IVAS_FLOAT_FIXED MC_MODE ivas_mc_mode_select( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ const int32_t total_brate /* i : IVAS total bitrate */ ) { MC_MODE mc_mode = MC_MODE_MCT; switch ( mc_ls_setup ) { case MC_LS_SETUP_5_1: if ( total_brate < IVAS_48k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_96k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_7_1: if ( total_brate < IVAS_48k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_128k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_5_1_2: if ( total_brate < IVAS_48k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_128k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_5_1_4: if ( total_brate < IVAS_96k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_160k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_7_1_4: if ( total_brate < IVAS_128k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_160k ) { mc_mode = MC_MODE_PARAMMC; } else if ( total_brate < IVAS_192k ) { mc_mode = MC_MODE_PARAMUPMIX; } break; default: assert( 0 && "LS Setup not supported or defined for MC mode!\n" ); } return mc_mode; } #else MC_MODE ivas_mc_mode_select_fx( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ const Word32 total_brate /* i : IVAS total bitrate */ ) { MC_MODE mc_mode = MC_MODE_MCT; move16(); move32(); SWITCH( mc_ls_setup ) { Loading @@ -60,65 +134,65 @@ MC_MODE ivas_mc_mode_select( IF( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_96k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_7_1: IF( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_5_1_2: IF( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_5_1_4: IF( LT_32( total_brate, IVAS_96k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_160k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_7_1_4: IF( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_160k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_192k ) ) { mc_mode = MC_MODE_PARAMUPMIX; move16(); move32(); } BREAK; default: Loading @@ -127,6 +201,7 @@ MC_MODE ivas_mc_mode_select( return mc_mode; } #endif /*--------------------------------------------------------------- Loading @@ -137,7 +212,7 @@ MC_MODE ivas_mc_mode_select( /*! r : number of loudspeaker channels */ #ifdef IVAS_FLOAT_FIXED Word16 ivas_mc_ls_setup_get_num_channels( Word16 ivas_mc_ls_setup_get_num_channels_fx( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ ) { Loading Loading @@ -216,6 +291,7 @@ int16_t ivas_mc_ls_setup_get_num_channels( * ---------------------------------------------------------------*/ /*! r : multi channel loudspeaker setup */ #ifndef IVAS_FLOAT_FIXED MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( const AUDIO_CONFIG output_config /* i : output audio configuration */ ) Loading @@ -223,29 +299,61 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( MC_LS_SETUP mc_ls_setup; mc_ls_setup = MC_LS_SETUP_INVALID; move16(); switch ( output_config ) { case IVAS_AUDIO_CONFIG_5_1: mc_ls_setup = MC_LS_SETUP_5_1; break; case IVAS_AUDIO_CONFIG_7_1: mc_ls_setup = MC_LS_SETUP_7_1; break; case IVAS_AUDIO_CONFIG_5_1_2: mc_ls_setup = MC_LS_SETUP_5_1_2; break; case IVAS_AUDIO_CONFIG_5_1_4: mc_ls_setup = MC_LS_SETUP_5_1_4; break; case IVAS_AUDIO_CONFIG_7_1_4: mc_ls_setup = MC_LS_SETUP_7_1_4; break; default: assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" ); } return mc_ls_setup; } #else MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup_fx( const AUDIO_CONFIG output_config /* i : output audio configuration */ ) { MC_LS_SETUP mc_ls_setup; mc_ls_setup = MC_LS_SETUP_INVALID; move32(); SWITCH( output_config ) { case IVAS_AUDIO_CONFIG_5_1: mc_ls_setup = MC_LS_SETUP_5_1; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_7_1: mc_ls_setup = MC_LS_SETUP_7_1; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_5_1_2: mc_ls_setup = MC_LS_SETUP_5_1_2; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_5_1_4: mc_ls_setup = MC_LS_SETUP_5_1_4; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_7_1_4: mc_ls_setup = MC_LS_SETUP_7_1_4; move16(); move32(); BREAK; default: assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" ); Loading @@ -253,6 +361,7 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( return mc_ls_setup; } #endif /*--------------------------------------------------------------- Loading @@ -262,35 +371,72 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( * ---------------------------------------------------------------*/ /*! r: audio configuration*/ #ifndef IVAS_FLOAT_FIXED AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup*/ ) { AUDIO_CONFIG audio_config; audio_config = IVAS_AUDIO_CONFIG_INVALID; move16(); switch ( mc_ls_setup ) { case MC_LS_SETUP_5_1: audio_config = IVAS_AUDIO_CONFIG_5_1; break; case MC_LS_SETUP_7_1: audio_config = IVAS_AUDIO_CONFIG_7_1; break; case MC_LS_SETUP_5_1_2: audio_config = IVAS_AUDIO_CONFIG_5_1_2; break; case MC_LS_SETUP_5_1_4: audio_config = IVAS_AUDIO_CONFIG_5_1_4; break; case MC_LS_SETUP_7_1_4: audio_config = IVAS_AUDIO_CONFIG_7_1_4; break; default: assert( 0 && "MC loudspeaker setup is not valid!\n" ); } return audio_config; } #else AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config_fx( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup*/ ) { AUDIO_CONFIG audio_config; audio_config = IVAS_AUDIO_CONFIG_INVALID; move32(); SWITCH( mc_ls_setup ) { case MC_LS_SETUP_5_1: audio_config = IVAS_AUDIO_CONFIG_5_1; move32(); BREAK; case MC_LS_SETUP_7_1: audio_config = IVAS_AUDIO_CONFIG_7_1; move32(); BREAK; case MC_LS_SETUP_5_1_2: audio_config = IVAS_AUDIO_CONFIG_5_1_2; move32(); BREAK; case MC_LS_SETUP_5_1_4: audio_config = IVAS_AUDIO_CONFIG_5_1_4; move32(); BREAK; case MC_LS_SETUP_7_1_4: audio_config = IVAS_AUDIO_CONFIG_7_1_4; move32(); BREAK; default: assert( 0 && "MC loudspeaker setup is not valid!\n" ); } move16(); return audio_config; } #endif lib_com/ivas_mc_param_com.c +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ void ivas_param_mc_metadata_open( #ifndef FIX_901_PARAMMC_DEAD_CODE Word16 nchan_setup; nchan_setup = ivas_mc_ls_setup_get_num_channels( mc_ls_setup ); nchan_setup = ivas_mc_ls_setup_get_num_channels_fx( mc_ls_setup ); #endif /* get coding band mappings */ Loading lib_com/ivas_mcmasa_com.c +50 −66 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib_com/ivas_cnst.h +9 −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 Loading @@ -1338,8 +1341,13 @@ typedef enum #define MCMASA_SEPARATE_BRATE IVAS_64k /* minimum bitrate from which separated channel coding is supported */ #define MCMASA_MAX_ANA_CHANS 11 /* Maximum number of channels currently used in analysis of multichannel formats */ #ifdef IVAS_FLOAT_FIXED #define MCMASA_MONOBITRATIO_64k_Q31 ( 536870912 ) #define MCMASA_MONOBITRATIO_Q31 ( 644245095 ) #else #define MCMASA_MONOBITRATIO 0.3f #define MCMASA_MONOBITRATIO_64k 0.25f #endif #define MC_MASA_THR_ELEVATION 40 #define MCMASA_LFE_QLOW -6.5f 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
lib_com/ivas_mc_com.c +167 −21 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ #include "prot.h" #include "ivas_prot.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif /*--------------------------------------------------------------- Loading @@ -46,13 +49,84 @@ * ---------------------------------------------------------------*/ /*! r : MC format mode */ #ifndef IVAS_FLOAT_FIXED MC_MODE ivas_mc_mode_select( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ const int32_t total_brate /* i : IVAS total bitrate */ ) { MC_MODE mc_mode = MC_MODE_MCT; switch ( mc_ls_setup ) { case MC_LS_SETUP_5_1: if ( total_brate < IVAS_48k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_96k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_7_1: if ( total_brate < IVAS_48k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_128k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_5_1_2: if ( total_brate < IVAS_48k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_128k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_5_1_4: if ( total_brate < IVAS_96k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_160k ) { mc_mode = MC_MODE_PARAMMC; } break; case MC_LS_SETUP_7_1_4: if ( total_brate < IVAS_128k ) { mc_mode = MC_MODE_MCMASA; } else if ( total_brate < IVAS_160k ) { mc_mode = MC_MODE_PARAMMC; } else if ( total_brate < IVAS_192k ) { mc_mode = MC_MODE_PARAMUPMIX; } break; default: assert( 0 && "LS Setup not supported or defined for MC mode!\n" ); } return mc_mode; } #else MC_MODE ivas_mc_mode_select_fx( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ const Word32 total_brate /* i : IVAS total bitrate */ ) { MC_MODE mc_mode = MC_MODE_MCT; move16(); move32(); SWITCH( mc_ls_setup ) { Loading @@ -60,65 +134,65 @@ MC_MODE ivas_mc_mode_select( IF( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_96k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_7_1: IF( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_5_1_2: IF( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_5_1_4: IF( LT_32( total_brate, IVAS_96k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_160k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } BREAK; case MC_LS_SETUP_7_1_4: IF( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_MCMASA; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_160k ) ) { mc_mode = MC_MODE_PARAMMC; move16(); move32(); } ELSE IF( LT_32( total_brate, IVAS_192k ) ) { mc_mode = MC_MODE_PARAMUPMIX; move16(); move32(); } BREAK; default: Loading @@ -127,6 +201,7 @@ MC_MODE ivas_mc_mode_select( return mc_mode; } #endif /*--------------------------------------------------------------- Loading @@ -137,7 +212,7 @@ MC_MODE ivas_mc_mode_select( /*! r : number of loudspeaker channels */ #ifdef IVAS_FLOAT_FIXED Word16 ivas_mc_ls_setup_get_num_channels( Word16 ivas_mc_ls_setup_get_num_channels_fx( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ ) { Loading Loading @@ -216,6 +291,7 @@ int16_t ivas_mc_ls_setup_get_num_channels( * ---------------------------------------------------------------*/ /*! r : multi channel loudspeaker setup */ #ifndef IVAS_FLOAT_FIXED MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( const AUDIO_CONFIG output_config /* i : output audio configuration */ ) Loading @@ -223,29 +299,61 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( MC_LS_SETUP mc_ls_setup; mc_ls_setup = MC_LS_SETUP_INVALID; move16(); switch ( output_config ) { case IVAS_AUDIO_CONFIG_5_1: mc_ls_setup = MC_LS_SETUP_5_1; break; case IVAS_AUDIO_CONFIG_7_1: mc_ls_setup = MC_LS_SETUP_7_1; break; case IVAS_AUDIO_CONFIG_5_1_2: mc_ls_setup = MC_LS_SETUP_5_1_2; break; case IVAS_AUDIO_CONFIG_5_1_4: mc_ls_setup = MC_LS_SETUP_5_1_4; break; case IVAS_AUDIO_CONFIG_7_1_4: mc_ls_setup = MC_LS_SETUP_7_1_4; break; default: assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" ); } return mc_ls_setup; } #else MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup_fx( const AUDIO_CONFIG output_config /* i : output audio configuration */ ) { MC_LS_SETUP mc_ls_setup; mc_ls_setup = MC_LS_SETUP_INVALID; move32(); SWITCH( output_config ) { case IVAS_AUDIO_CONFIG_5_1: mc_ls_setup = MC_LS_SETUP_5_1; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_7_1: mc_ls_setup = MC_LS_SETUP_7_1; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_5_1_2: mc_ls_setup = MC_LS_SETUP_5_1_2; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_5_1_4: mc_ls_setup = MC_LS_SETUP_5_1_4; move16(); move32(); BREAK; case IVAS_AUDIO_CONFIG_7_1_4: mc_ls_setup = MC_LS_SETUP_7_1_4; move16(); move32(); BREAK; default: assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" ); Loading @@ -253,6 +361,7 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( return mc_ls_setup; } #endif /*--------------------------------------------------------------- Loading @@ -262,35 +371,72 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( * ---------------------------------------------------------------*/ /*! r: audio configuration*/ #ifndef IVAS_FLOAT_FIXED AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup*/ ) { AUDIO_CONFIG audio_config; audio_config = IVAS_AUDIO_CONFIG_INVALID; move16(); switch ( mc_ls_setup ) { case MC_LS_SETUP_5_1: audio_config = IVAS_AUDIO_CONFIG_5_1; break; case MC_LS_SETUP_7_1: audio_config = IVAS_AUDIO_CONFIG_7_1; break; case MC_LS_SETUP_5_1_2: audio_config = IVAS_AUDIO_CONFIG_5_1_2; break; case MC_LS_SETUP_5_1_4: audio_config = IVAS_AUDIO_CONFIG_5_1_4; break; case MC_LS_SETUP_7_1_4: audio_config = IVAS_AUDIO_CONFIG_7_1_4; break; default: assert( 0 && "MC loudspeaker setup is not valid!\n" ); } return audio_config; } #else AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config_fx( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup*/ ) { AUDIO_CONFIG audio_config; audio_config = IVAS_AUDIO_CONFIG_INVALID; move32(); SWITCH( mc_ls_setup ) { case MC_LS_SETUP_5_1: audio_config = IVAS_AUDIO_CONFIG_5_1; move32(); BREAK; case MC_LS_SETUP_7_1: audio_config = IVAS_AUDIO_CONFIG_7_1; move32(); BREAK; case MC_LS_SETUP_5_1_2: audio_config = IVAS_AUDIO_CONFIG_5_1_2; move32(); BREAK; case MC_LS_SETUP_5_1_4: audio_config = IVAS_AUDIO_CONFIG_5_1_4; move32(); BREAK; case MC_LS_SETUP_7_1_4: audio_config = IVAS_AUDIO_CONFIG_7_1_4; move32(); BREAK; default: assert( 0 && "MC loudspeaker setup is not valid!\n" ); } move16(); return audio_config; } #endif
lib_com/ivas_mc_param_com.c +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ void ivas_param_mc_metadata_open( #ifndef FIX_901_PARAMMC_DEAD_CODE Word16 nchan_setup; nchan_setup = ivas_mc_ls_setup_get_num_channels( mc_ls_setup ); nchan_setup = ivas_mc_ls_setup_get_num_channels_fx( mc_ls_setup ); #endif /* get coding band mappings */ Loading
lib_com/ivas_mcmasa_com.c +50 −66 File changed.Preview size limit exceeded, changes collapsed. Show changes