Loading lib_com/ivas_cnst.h +11 −6 Original line number Diff line number Diff line Loading @@ -1170,8 +1170,9 @@ typedef enum #define MP_MAX_AVERG_DIRS 10 #define MP_MAX_GROUP_TRANSPORT_CFG 3 #define MP_MAX_GROUP_TRANSPORT 2 #define MP_MAX_CHANNEL_BITS 3840 #define MP_MIN_DIRECTIONS 2 #define MP_MIN_DIRECTIONS 1 #define MP_MAX_DIRECTIONS 4 #define MP_NB_HIS_DIRECTIONS 10 Loading @@ -1181,7 +1182,11 @@ typedef enum #define MP_SVD_TD_CLOS 8 #define MP_COLS_R1 70 #ifdef IVAS_SBA_MP_768KBPS_ROOM_TABLE #define MP_COLS_R2 64 #else #define MP_COLS_R2 32 #endif #define MP_FIXED_DIR_ROWS 1024 #define MP_MIN_ANGLE_RAD ( 4.f * EVS_PI / MP_FIXED_DIR_ROWS ) #define MP_MIN_ANGLE_INDEX 548 Loading @@ -1204,13 +1209,13 @@ typedef enum #define MP_HUFFMAN_CODEBOOK_OFFSET 2 #define MP_MAX_CHANNELS_DECORR 4 #define MP_MAX_DECORR_CONFIG ( 3 * 4 ) #ifdef FIX_IVAS_SBA_MP_768KBPS #define MP_MIN_POST_DIFFUSENESS 0.125f #define MP_MAX_DECORR_CONFIG 2 #define MP_MIN_POST_DIFFUSENESS 0.25f #define MP_GAIN_POST_FACTOR 0.125f #define MP_GAIN_POST_BIN 45 #define MP_MIN_GAIN_DB 1.258925f #define MP_SMOOTH_SFB_INDEX 8 #endif #endif /*----------------------------------------------------------------------------------* * MASA constants Loading lib_com/ivas_mct_com.c +114 −117 Original line number Diff line number Diff line Loading @@ -62,81 +62,108 @@ void splitAvailableBitsMP( int16_t core[MCT_MAX_CHANNELS]; MCT_CHAN_MODE mct_chan_mode[MCT_MAX_CHANNELS]; MP_TCS_DMX_CONFIG tcs_cfg; int16_t nchan_active; int16_t nchan_overflow_mask[MCT_MAX_CHANNELS]; int16_t group_bits_frame_channel[MP_MAX_GROUP_TRANSPORT]; int16_t nchan_overflow, all_overflow_flag; int16_t target_max_bits_frame, max_bits_frame; float tmp_ratio, adjust_ratio; float channel_ratio; float group_split_ratio[MP_MAX_GROUP_TRANSPORT]; int16_t group_nchan_active[MP_MAX_GROUP_TRANSPORT]; int16_t total_nchan_active, group_bits_frame, average_bits_frame, min_bits_frame, max_bits_frame, total_split_ratio; max_chn = 0; min_bits_tot = 0; nchan_active = 0; set_s( nchan_overflow_mask, 0, MCT_MAX_CHANNELS ); target_max_bits_frame = 0; nchan_overflow = 0; all_overflow_flag = 0; total_nchan_active = 0; average_bits_frame = 0; total_split_ratio = 0; channel_ratio = 1.f / nchan; tcs_cfg = ivas_mp_get_transport_group_config( sba_order, total_bitrate, nchan ); max_bits_frame = ( int16_t )( tcs_cfg.max_bitrate / FRAMES_PER_SEC ); for ( ch = 0; ch < nchan; ch++ ) min_bits_frame = (int16_t) ( tcs_cfg.min_bitrate / FRAMES_PER_SEC ); max_bits_frame = MP_MAX_CHANNEL_BITS; mvr2r( tcs_cfg.group_split_ratio, group_split_ratio, MP_MAX_GROUP_TRANSPORT ); for ( ch_idx = 0, group_idx = 0; group_idx < tcs_cfg.nb_group; group_idx++ ) { group_nchan_active[group_idx] = 0; for ( ch = 0; ch < tcs_cfg.nb_chan_group[group_idx]; ch++ ) { if ( enc_dec == ENC ) { mct_chan_mode[ch] = ( (Encoder_State *) sts[ch] )->mct_chan_mode; core[ch] = ( (Encoder_State *) sts[ch] )->core; mct_chan_mode[ch_idx] = ( (Encoder_State *) sts[ch_idx] )->mct_chan_mode; core[ch_idx] = ( (Encoder_State *) sts[ch_idx] )->core; } else { mct_chan_mode[ch] = ( (Decoder_State *) sts[ch] )->mct_chan_mode; core[ch] = ( (Decoder_State *) sts[ch] )->core; mct_chan_mode[ch_idx] = ( (Decoder_State *) sts[ch_idx] )->mct_chan_mode; core[ch_idx] = ( (Decoder_State *) sts[ch_idx] )->core; } if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) { nchan_active++; } assert( mct_chan_mode[ch] != MCT_CHAN_MODE_LFE ); } assert( nchan_active <= nchan ); for ( ch = 0; ch < nchan; ch++ ) { if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) if ( mct_chan_mode[ch_idx] != MCT_CHAN_MODE_IGNORE ) { min_chan_bits[ch] = 0; min_chan_bits[ch_idx] = 0; nSubframes = ( core[ch] == TCX_20_CORE ) ? 1 : NB_DIV; nSubframes = ( core[ch_idx] == TCX_20_CORE ) ? 1 : NB_DIV; for ( k = 0; k < nSubframes; k++ ) { min_chan_bits[ch] += SMDCT_MINIMUM_ARITH_BITS + MIN_SAFETY_BITS_MC; min_chan_bits[ch_idx] += SMDCT_MINIMUM_ARITH_BITS + MIN_SAFETY_BITS_MC; } min_bits_tot += min_chan_bits[ch]; min_bits_tot += min_chan_bits[ch_idx]; group_nchan_active[group_idx]++; total_nchan_active++; total_split_ratio += split_ratio[ch_idx]; } assert( mct_chan_mode[ch_idx] != MCT_CHAN_MODE_LFE ); ch_idx++; } } /* tuning for group split ratio */ remaining_bits = total_bits - min_bits_tot; bits_split = 0; diff = 0; tmp = 0; max_chn = 0; if ( ( total_nchan_active > 1 && total_nchan_active < nchan ) && ( tcs_cfg.nb_group > 1 ) ) { average_bits_frame = (int16_t) ( remaining_bits / total_nchan_active ); tmp = (int16_t) ( ( (float) ( nchan - total_nchan_active ) / nchan ) * min_bits_frame ); if ( nchan_active > 1 && nchan_active < nchan ) tmp_ratio = 1.f / total_nchan_active; group_split_ratio[0] = (float) ( group_nchan_active[0] ) * tmp_ratio + channel_ratio; group_split_ratio[0] = min( 0.75f, group_split_ratio[0] ); group_split_ratio[1] = 1.f - group_split_ratio[0]; tmp_ratio = ( (float) ( average_bits_frame ) ) / remaining_bits; if ( group_nchan_active[1] <= group_nchan_active[0] ) { all_overflow_flag = 0; target_max_bits_frame = ( int16_t )( remaining_bits / nchan_active ); if ( max_bits_frame < target_max_bits_frame ) adjust_ratio = ( ( (float) ( group_nchan_active[0] - group_nchan_active[1] ) ) / total_nchan_active ) * tmp_ratio; group_split_ratio[0] = group_split_ratio[0] + adjust_ratio; group_split_ratio[0] = max( 0.275f, min( 0.725f, group_split_ratio[0] ) ); group_split_ratio[1] = 1.f - group_split_ratio[0]; } else if ( group_nchan_active[0] < group_nchan_active[1] ) { max_bits_frame = target_max_bits_frame; all_overflow_flag = 1; adjust_ratio = ( ( (float) ( group_nchan_active[1] - group_nchan_active[0] ) ) / total_nchan_active ) * tmp_ratio; group_split_ratio[0] = group_split_ratio[0] - adjust_ratio; group_split_ratio[0] = min( 0.65f, max( 0.35f, group_split_ratio[0] ) ); group_split_ratio[1] = 1.f - group_split_ratio[0]; } tmp = min( tmp, min_bits_frame / 3 ); min_bits_frame += tmp; assert( min_bits_frame <= 1280 ); } else { min_bits_frame -= ( min_bits_frame >> 2 ); max_bits_frame -= ( min_bits_frame >> 2 ); } /* split bits by group ratio */ tmp = 0; bits_split = 0; for ( ch_idx = 0, group_idx = 0; group_idx < tcs_cfg.nb_group; group_idx++ ) { group_bits_frame_channel[group_idx] = ( int16_t )( remaining_bits * tcs_cfg.group_split_ratio[group_idx] ); group_bits_frame = (int16_t) ( remaining_bits * group_split_ratio[group_idx] ); for ( ch = 0; ch < tcs_cfg.nb_chan_group[group_idx]; ch++ ) { Loading @@ -153,21 +180,22 @@ void splitAvailableBitsMP( { assert( split_ratio[ch_idx] >= 1 && split_ratio[ch_idx] < BITRATE_MCT_RATIO_RANGE ); *bits_frame_channel = split_ratio[ch_idx] * group_bits_frame_channel[group_idx] / BITRATE_MCT_RATIO_RANGE + min_chan_bits[ch_idx]; bits_split += *bits_frame_channel; *bits_frame_channel = split_ratio[ch_idx] * group_bits_frame / BITRATE_MCT_RATIO_RANGE + min_chan_bits[ch_idx]; /*determine channel with most bits (energy)*/ if ( *bits_frame_channel > tmp ) if ( ( *bits_frame_channel > tmp ) ) { tmp = *bits_frame_channel; max_chn = ch_idx; } } *bits_frame_channel = min( max( *bits_frame_channel, min_bits_frame ), max_bits_frame ); bits_split += *bits_frame_channel; } ch_idx++; } } diff = 0; if ( bits_split != total_bits ) { diff = bits_split - total_bits; Loading @@ -188,71 +216,12 @@ void splitAvailableBitsMP( if ( mct_chan_mode[ch_idx] != MCT_CHAN_MODE_IGNORE ) { *bits_frame_channel -= diff * split_ratio[ch_idx] / ( BITRATE_MCT_RATIO_RANGE * tcs_cfg.nb_group ); *bits_frame_channel -= diff * split_ratio[ch_idx] / /*( BITRATE_MCT_RATIO_RANGE * tcs_cfg.nb_group )*/ total_split_ratio; *bits_frame_channel = max( min_chan_bits[ch_idx], *bits_frame_channel ); bits_split += *bits_frame_channel; if ( *bits_frame_channel > max_bits_frame && all_overflow_flag ) { nchan_overflow_mask[ch_idx] = 1; nchan_overflow++; } } ch_idx++; } } } if ( all_overflow_flag ) { bits_split = 0; for ( ch = 0; ch < nchan; ch++ ) { if ( enc_dec == ENC ) { bits_frame_channel = &( (Encoder_State *) sts[ch] )->bits_frame_channel; } else /* DEC */ { bits_frame_channel = &( (Decoder_State *) sts[ch] )->bits_frame_channel; } if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) { if ( nchan_overflow_mask[ch] ) { *bits_frame_channel = max_bits_frame; *bits_frame_channel = max( min_chan_bits[ch], *bits_frame_channel ); } bits_split += *bits_frame_channel; } } diff = total_bits - bits_split; assert( diff >= 0 ); assert( nchan_active >= 1 ); diff = ( int16_t )( diff / max( 1, nchan_active ) ); bits_split = 0; for ( ch = 0; ch < nchan; ch++ ) { if ( enc_dec == ENC ) { bits_frame_channel = &( (Encoder_State *) sts[ch] )->bits_frame_channel; } else /* DEC */ { bits_frame_channel = &( (Decoder_State *) sts[ch] )->bits_frame_channel; } if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) { *bits_frame_channel += diff; *bits_frame_channel = max( min_chan_bits[ch], *bits_frame_channel ); bits_split += *bits_frame_channel; ch_idx++; } } } Loading Loading @@ -440,5 +409,33 @@ void splitAvailableBitsMCT( } } #ifdef DEBUG_IVAS_SBA_MP_768KBPS { if ( enc_dec == ENC ) { FILE *f_chan_bits = fopen( "..\\res\\channels_bits.txt", "a+" ); float bits_frame_channel_kbps = 0.f; fprintf( f_chan_bits, "%f: ", ( total_bits * FRAMES_PER_SEC ) / 1000.f ); for ( int16_t ch = 0; ch < nchan; ch++ ) { bits_frame_channel = &( (Encoder_State *) sts[ch] )->bits_frame_channel; bits_frame_channel_kbps = (float) ( *bits_frame_channel * FRAMES_PER_SEC ) / 1000.f; fprintf( f_chan_bits, "%f, ", bits_frame_channel_kbps ); } fprintf( f_chan_bits, "\n" ); if ( f_chan_bits != NULL ) { fclose( f_chan_bits ); } } } #endif return; } lib_com/ivas_mp_com.c +11 −2 Original line number Diff line number Diff line Loading @@ -119,7 +119,11 @@ int16_t ivas_mp_get_transport_channels( nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ); break; case SBA_HOA3_ORDER: nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ) - 1; /* HOA2 -> 2H1V */ #ifdef IVAS_SBA_MP_TCS9 nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ); #else nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ) - 1; #endif break; default: break; Loading Loading @@ -222,6 +226,7 @@ void ivas_mp_config_open( hConfig->mp_dirac_band_factor = ( NS2SA( sr, MP_OVERLAP_5MS_NS ) / NS2SA( sr, DIRAC_SLOT_NS ) ); hConfig->nb_subbands = MP_MAX_NBANDS; if ( sr == 48000 ) { mvs2s( ivas_mp_dirac_band_group_48kHz, hConfig->band_grouping, hConfig->nb_subbands + 1 ); Loading Loading @@ -257,7 +262,11 @@ void ivas_mp_config_open( } else if ( sba_order_input == SBA_HOA3_ORDER ) { mvs2s( ivas_mp_transport_channels_2H1V_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT ); #ifdef IVAS_SBA_MP_TCS9 mvs2s( ivas_mp_transport_channels_HOA2_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT ); #else mvs2s( ivas_mp_transport_channels_3H1V_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT ); #endif } } Loading lib_com/ivas_mp_rom.c +127 −7 Original line number Diff line number Diff line Loading @@ -76,24 +76,139 @@ const int16_t ivas_mp_transport_channels_HOA2_table[MP_MAX_CHANNELS_TRANSPORT] = 0, 1, 2, 3, 4, 5, 6, 7, 8 }; const int16_t ivas_mp_transport_channels_2H1V_table[MP_MAX_CHANNELS_TRANSPORT] = { 0, 1, 2, 3, 4, 5, 7, 8 const int16_t ivas_mp_transport_channels_3H1V_table[MP_MAX_CHANNELS_TRANSPORT] = { 0, 1, 2, 3, 4, 8, 9, 15 }; const MP_DECORR_CONFIG ivas_mp_decorrelation_cfg_table[MP_MAX_DECORR_CONFIG] = { { SBA_HOA3_ORDER, IVAS_768k, 2, { 9, 15 }, 8 }, { SBA_HOA3_ORDER, IVAS_768k, 2, { 5, 7 }, 8 }, }; const MP_TCS_DMX_CONFIG ivas_mp_TCs_dmx_cfg_table[MP_MAX_GROUP_TRANSPORT_CFG] = { { SBA_FOA_ORDER, IVAS_768k, 4, 1, { 4, 0 }, 208000, { 1.f, 0.f } }, { SBA_HOA2_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 116000, { 0.55f, 0.45f } }, { SBA_HOA3_ORDER, IVAS_768k, 8, 2, { 4, 4 }, 112000, { 0.625f, 0.375f } }, { SBA_FOA_ORDER, IVAS_768k, 4, 1, { 4, 0 }, 64000, 208000, { 1.f, 0.f } }, { SBA_HOA2_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 48000, 116000, { 0.55f, 0.45f } }, #ifdef IVAS_SBA_MP_TCS9 { SBA_HOA3_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 32000, 116000, { 0.55f, 0.45f } }, #else { SBA_HOA3_ORDER, IVAS_768k, 8, 2, { 4, 4 }, 48000, 128000, { 0.625f, 0.375f } }, #endif }; const int16_t ivas_mp_q_gain_table[MP_Q_GAIN_TABLE_SIZE] = { ( (int16_t) ( MP_MIN_Q_GAIN ) ), -55, -50, -45, -40, -38, -36, -34, -32, -30, -28, -26, -24, -22, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, ( (int16_t) ( MP_MAX_Q_GAIN ) ) }; #if 1 const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP] = { /* 1 bits x 1 */ { { { 0, 1, 1 } , }, 1 }, /* 3 bits x2 : index = 1, offset = MP_HUFFMAN_CODEBOOK_OFFSET */ { { { -1, 1, 3 }, { 1, 0, 3 }, }, 2 }, /* 4 bits x2 */ { { { -2, 4, 4 }, { 2, 5, 4 }, }, 2 }, /* 5 bits x2 */ { { { -3, 12, 5 }, { 3, 13, 5 }, }, 2 }, /* 6 bits x2 */ { { { -4, 28, 6 }, { 4, 29, 6 }, }, 2 }, /* 7 bits x2 */ { { { -5, 60, 7 }, { 5, 61, 7 }, }, 2 }, /* 8 bits x2 */ { { { -6, 125, 8 }, { 6, 124, 8 }, }, 2 }, /* 9 bits x2 */ { { { -7, 253, 9 }, { 7, 252, 9 }, }, 2 }, /* 10 bits x2 */ { { { -8, 510, 10 }, { 8, 509, 10 }, }, 2 }, /* 11 bits x1 */ { { { 9, 1023, 11 } }, 1 }, /* 12 bits x1 */ { { { -9, 2033, 12 }, }, 1 }, /* 13 bits x4 */ { { { -24, 4089, 13 }, { -10, 4071, 13 }, { 10, 4065, 13 }, { 24, 4069, 13 }, }, 4 }, /* 14 bits x3 */ { { { -11, 8176, 14 }, { 11, 8128, 14 }, { 12, 8177, 14 }, }, 3 }, /* 15 bits x10 */ { { { -13, 16361, 15 }, { -12, 16274, 15 }, { 13, 16258, 15 }, { 14, 16280, 15 }, { 15, 16360, 15 }, { 16, 16365, 15 }, { 17, 16363, 15 }, { 20, 16364, 15 }, { 22, 16367, 15 }, { 23, 16275, 15 }, }, 10 }, /* 16 bits x11 */ { { { -19, 32732, 16 }, { -18, 32724, 16 }, { -17, 32567, 16 }, { -16, 32564, 16 }, { -15, 32563, 16 }, { -14, 32544, 16 }, { 18, 32519, 16 }, { 19, 32545, 16 }, { 21, 32547, 16 }, { 25, 32565, 16 }, { 31, 32518, 16 } }, 11 }, /* 17 bits x8 */ { { { -31, 65132, 17 }, { -25, 65451, 17 }, { -20, 65092, 17 }, { -22, 65450, 17 }, { -21, 65124, 17 }, { 26, 65125, 17 }, { 27, 65133, 17 }, { 28, 65467, 17 }, }, 8 }, /* 18 bits x1 */ { { { -23, 130187, 18 }, }, 1 }, /* 19 bits x5 */ { { { -30, 261866, 19 }, { -29, 261865, 19 }, { -26, 260372, 19 }, { 29, 261864, 19 }, { 30, 260373, 19 }, }, 5 }, /* 20 bits x2 */ { { { -28, 523735, 20 }, { -27, 523734, 20 }, }, 2 }, }; #else const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP] = { /* 1 bits x 1 */ { Loading Loading @@ -230,6 +345,11 @@ const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP { -27, 523734, 20 } }, 2 } }; #endif const int16_t ivas_mp_proj_band_group_48kHz[MP_MAX_NBANDS + 2] = { 0, 1, 2, 3, 4, 5, 6, 8, 12, 18, 26, 36, 48, 60 }; const Huffman_codebook ivas_mp_huffman_codebook_table[MP_Q_GAIN_TABLE_SIZE * 2 - 1] = { { 3, 13, 5 }, /* 10010 -> 01101 */ Loading lib_com/ivas_rom_com.h +2 −1 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ extern const int16_t ivas_mp_direction_component_mask_table[MP_CHANNELS_HOA3]; /* Transport channels configuration */ extern const int16_t ivas_mp_transport_channels_FOA_table[MP_MAX_CHANNELS_TRANSPORT]; extern const int16_t ivas_mp_transport_channels_HOA2_table[MP_MAX_CHANNELS_TRANSPORT]; extern const int16_t ivas_mp_transport_channels_2H1V_table[MP_MAX_CHANNELS_TRANSPORT]; extern const int16_t ivas_mp_transport_channels_3H1V_table[MP_MAX_CHANNELS_TRANSPORT]; extern const MP_DECORR_CONFIG ivas_mp_decorrelation_cfg_table[MP_MAX_DECORR_CONFIG]; extern const MP_TCS_DMX_CONFIG ivas_mp_TCs_dmx_cfg_table[MP_MAX_GROUP_TRANSPORT_CFG]; Loading @@ -220,6 +220,7 @@ extern const Huffman_codebook ivas_mp_huffman_codebook_table[MP_Q_GAIN_TABLE_SIZ extern const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP]; /* MP table */ extern const int16_t ivas_mp_proj_band_group_48kHz[MP_MAX_NBANDS + 2]; extern const float ivas_mp_basis_matrix_R1[MP_MAX_NB_COEFFS][MP_COLS_R1]; extern const int16_t ivas_mp_basis_matrix_R2[MP_COLS_R1][MP_COLS_R2]; extern const float ivas_mp_direction_angle_matrix[MP_FIXED_DIR_ROWS][2]; Loading Loading
lib_com/ivas_cnst.h +11 −6 Original line number Diff line number Diff line Loading @@ -1170,8 +1170,9 @@ typedef enum #define MP_MAX_AVERG_DIRS 10 #define MP_MAX_GROUP_TRANSPORT_CFG 3 #define MP_MAX_GROUP_TRANSPORT 2 #define MP_MAX_CHANNEL_BITS 3840 #define MP_MIN_DIRECTIONS 2 #define MP_MIN_DIRECTIONS 1 #define MP_MAX_DIRECTIONS 4 #define MP_NB_HIS_DIRECTIONS 10 Loading @@ -1181,7 +1182,11 @@ typedef enum #define MP_SVD_TD_CLOS 8 #define MP_COLS_R1 70 #ifdef IVAS_SBA_MP_768KBPS_ROOM_TABLE #define MP_COLS_R2 64 #else #define MP_COLS_R2 32 #endif #define MP_FIXED_DIR_ROWS 1024 #define MP_MIN_ANGLE_RAD ( 4.f * EVS_PI / MP_FIXED_DIR_ROWS ) #define MP_MIN_ANGLE_INDEX 548 Loading @@ -1204,13 +1209,13 @@ typedef enum #define MP_HUFFMAN_CODEBOOK_OFFSET 2 #define MP_MAX_CHANNELS_DECORR 4 #define MP_MAX_DECORR_CONFIG ( 3 * 4 ) #ifdef FIX_IVAS_SBA_MP_768KBPS #define MP_MIN_POST_DIFFUSENESS 0.125f #define MP_MAX_DECORR_CONFIG 2 #define MP_MIN_POST_DIFFUSENESS 0.25f #define MP_GAIN_POST_FACTOR 0.125f #define MP_GAIN_POST_BIN 45 #define MP_MIN_GAIN_DB 1.258925f #define MP_SMOOTH_SFB_INDEX 8 #endif #endif /*----------------------------------------------------------------------------------* * MASA constants Loading
lib_com/ivas_mct_com.c +114 −117 Original line number Diff line number Diff line Loading @@ -62,81 +62,108 @@ void splitAvailableBitsMP( int16_t core[MCT_MAX_CHANNELS]; MCT_CHAN_MODE mct_chan_mode[MCT_MAX_CHANNELS]; MP_TCS_DMX_CONFIG tcs_cfg; int16_t nchan_active; int16_t nchan_overflow_mask[MCT_MAX_CHANNELS]; int16_t group_bits_frame_channel[MP_MAX_GROUP_TRANSPORT]; int16_t nchan_overflow, all_overflow_flag; int16_t target_max_bits_frame, max_bits_frame; float tmp_ratio, adjust_ratio; float channel_ratio; float group_split_ratio[MP_MAX_GROUP_TRANSPORT]; int16_t group_nchan_active[MP_MAX_GROUP_TRANSPORT]; int16_t total_nchan_active, group_bits_frame, average_bits_frame, min_bits_frame, max_bits_frame, total_split_ratio; max_chn = 0; min_bits_tot = 0; nchan_active = 0; set_s( nchan_overflow_mask, 0, MCT_MAX_CHANNELS ); target_max_bits_frame = 0; nchan_overflow = 0; all_overflow_flag = 0; total_nchan_active = 0; average_bits_frame = 0; total_split_ratio = 0; channel_ratio = 1.f / nchan; tcs_cfg = ivas_mp_get_transport_group_config( sba_order, total_bitrate, nchan ); max_bits_frame = ( int16_t )( tcs_cfg.max_bitrate / FRAMES_PER_SEC ); for ( ch = 0; ch < nchan; ch++ ) min_bits_frame = (int16_t) ( tcs_cfg.min_bitrate / FRAMES_PER_SEC ); max_bits_frame = MP_MAX_CHANNEL_BITS; mvr2r( tcs_cfg.group_split_ratio, group_split_ratio, MP_MAX_GROUP_TRANSPORT ); for ( ch_idx = 0, group_idx = 0; group_idx < tcs_cfg.nb_group; group_idx++ ) { group_nchan_active[group_idx] = 0; for ( ch = 0; ch < tcs_cfg.nb_chan_group[group_idx]; ch++ ) { if ( enc_dec == ENC ) { mct_chan_mode[ch] = ( (Encoder_State *) sts[ch] )->mct_chan_mode; core[ch] = ( (Encoder_State *) sts[ch] )->core; mct_chan_mode[ch_idx] = ( (Encoder_State *) sts[ch_idx] )->mct_chan_mode; core[ch_idx] = ( (Encoder_State *) sts[ch_idx] )->core; } else { mct_chan_mode[ch] = ( (Decoder_State *) sts[ch] )->mct_chan_mode; core[ch] = ( (Decoder_State *) sts[ch] )->core; mct_chan_mode[ch_idx] = ( (Decoder_State *) sts[ch_idx] )->mct_chan_mode; core[ch_idx] = ( (Decoder_State *) sts[ch_idx] )->core; } if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) { nchan_active++; } assert( mct_chan_mode[ch] != MCT_CHAN_MODE_LFE ); } assert( nchan_active <= nchan ); for ( ch = 0; ch < nchan; ch++ ) { if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) if ( mct_chan_mode[ch_idx] != MCT_CHAN_MODE_IGNORE ) { min_chan_bits[ch] = 0; min_chan_bits[ch_idx] = 0; nSubframes = ( core[ch] == TCX_20_CORE ) ? 1 : NB_DIV; nSubframes = ( core[ch_idx] == TCX_20_CORE ) ? 1 : NB_DIV; for ( k = 0; k < nSubframes; k++ ) { min_chan_bits[ch] += SMDCT_MINIMUM_ARITH_BITS + MIN_SAFETY_BITS_MC; min_chan_bits[ch_idx] += SMDCT_MINIMUM_ARITH_BITS + MIN_SAFETY_BITS_MC; } min_bits_tot += min_chan_bits[ch]; min_bits_tot += min_chan_bits[ch_idx]; group_nchan_active[group_idx]++; total_nchan_active++; total_split_ratio += split_ratio[ch_idx]; } assert( mct_chan_mode[ch_idx] != MCT_CHAN_MODE_LFE ); ch_idx++; } } /* tuning for group split ratio */ remaining_bits = total_bits - min_bits_tot; bits_split = 0; diff = 0; tmp = 0; max_chn = 0; if ( ( total_nchan_active > 1 && total_nchan_active < nchan ) && ( tcs_cfg.nb_group > 1 ) ) { average_bits_frame = (int16_t) ( remaining_bits / total_nchan_active ); tmp = (int16_t) ( ( (float) ( nchan - total_nchan_active ) / nchan ) * min_bits_frame ); if ( nchan_active > 1 && nchan_active < nchan ) tmp_ratio = 1.f / total_nchan_active; group_split_ratio[0] = (float) ( group_nchan_active[0] ) * tmp_ratio + channel_ratio; group_split_ratio[0] = min( 0.75f, group_split_ratio[0] ); group_split_ratio[1] = 1.f - group_split_ratio[0]; tmp_ratio = ( (float) ( average_bits_frame ) ) / remaining_bits; if ( group_nchan_active[1] <= group_nchan_active[0] ) { all_overflow_flag = 0; target_max_bits_frame = ( int16_t )( remaining_bits / nchan_active ); if ( max_bits_frame < target_max_bits_frame ) adjust_ratio = ( ( (float) ( group_nchan_active[0] - group_nchan_active[1] ) ) / total_nchan_active ) * tmp_ratio; group_split_ratio[0] = group_split_ratio[0] + adjust_ratio; group_split_ratio[0] = max( 0.275f, min( 0.725f, group_split_ratio[0] ) ); group_split_ratio[1] = 1.f - group_split_ratio[0]; } else if ( group_nchan_active[0] < group_nchan_active[1] ) { max_bits_frame = target_max_bits_frame; all_overflow_flag = 1; adjust_ratio = ( ( (float) ( group_nchan_active[1] - group_nchan_active[0] ) ) / total_nchan_active ) * tmp_ratio; group_split_ratio[0] = group_split_ratio[0] - adjust_ratio; group_split_ratio[0] = min( 0.65f, max( 0.35f, group_split_ratio[0] ) ); group_split_ratio[1] = 1.f - group_split_ratio[0]; } tmp = min( tmp, min_bits_frame / 3 ); min_bits_frame += tmp; assert( min_bits_frame <= 1280 ); } else { min_bits_frame -= ( min_bits_frame >> 2 ); max_bits_frame -= ( min_bits_frame >> 2 ); } /* split bits by group ratio */ tmp = 0; bits_split = 0; for ( ch_idx = 0, group_idx = 0; group_idx < tcs_cfg.nb_group; group_idx++ ) { group_bits_frame_channel[group_idx] = ( int16_t )( remaining_bits * tcs_cfg.group_split_ratio[group_idx] ); group_bits_frame = (int16_t) ( remaining_bits * group_split_ratio[group_idx] ); for ( ch = 0; ch < tcs_cfg.nb_chan_group[group_idx]; ch++ ) { Loading @@ -153,21 +180,22 @@ void splitAvailableBitsMP( { assert( split_ratio[ch_idx] >= 1 && split_ratio[ch_idx] < BITRATE_MCT_RATIO_RANGE ); *bits_frame_channel = split_ratio[ch_idx] * group_bits_frame_channel[group_idx] / BITRATE_MCT_RATIO_RANGE + min_chan_bits[ch_idx]; bits_split += *bits_frame_channel; *bits_frame_channel = split_ratio[ch_idx] * group_bits_frame / BITRATE_MCT_RATIO_RANGE + min_chan_bits[ch_idx]; /*determine channel with most bits (energy)*/ if ( *bits_frame_channel > tmp ) if ( ( *bits_frame_channel > tmp ) ) { tmp = *bits_frame_channel; max_chn = ch_idx; } } *bits_frame_channel = min( max( *bits_frame_channel, min_bits_frame ), max_bits_frame ); bits_split += *bits_frame_channel; } ch_idx++; } } diff = 0; if ( bits_split != total_bits ) { diff = bits_split - total_bits; Loading @@ -188,71 +216,12 @@ void splitAvailableBitsMP( if ( mct_chan_mode[ch_idx] != MCT_CHAN_MODE_IGNORE ) { *bits_frame_channel -= diff * split_ratio[ch_idx] / ( BITRATE_MCT_RATIO_RANGE * tcs_cfg.nb_group ); *bits_frame_channel -= diff * split_ratio[ch_idx] / /*( BITRATE_MCT_RATIO_RANGE * tcs_cfg.nb_group )*/ total_split_ratio; *bits_frame_channel = max( min_chan_bits[ch_idx], *bits_frame_channel ); bits_split += *bits_frame_channel; if ( *bits_frame_channel > max_bits_frame && all_overflow_flag ) { nchan_overflow_mask[ch_idx] = 1; nchan_overflow++; } } ch_idx++; } } } if ( all_overflow_flag ) { bits_split = 0; for ( ch = 0; ch < nchan; ch++ ) { if ( enc_dec == ENC ) { bits_frame_channel = &( (Encoder_State *) sts[ch] )->bits_frame_channel; } else /* DEC */ { bits_frame_channel = &( (Decoder_State *) sts[ch] )->bits_frame_channel; } if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) { if ( nchan_overflow_mask[ch] ) { *bits_frame_channel = max_bits_frame; *bits_frame_channel = max( min_chan_bits[ch], *bits_frame_channel ); } bits_split += *bits_frame_channel; } } diff = total_bits - bits_split; assert( diff >= 0 ); assert( nchan_active >= 1 ); diff = ( int16_t )( diff / max( 1, nchan_active ) ); bits_split = 0; for ( ch = 0; ch < nchan; ch++ ) { if ( enc_dec == ENC ) { bits_frame_channel = &( (Encoder_State *) sts[ch] )->bits_frame_channel; } else /* DEC */ { bits_frame_channel = &( (Decoder_State *) sts[ch] )->bits_frame_channel; } if ( mct_chan_mode[ch] != MCT_CHAN_MODE_IGNORE ) { *bits_frame_channel += diff; *bits_frame_channel = max( min_chan_bits[ch], *bits_frame_channel ); bits_split += *bits_frame_channel; ch_idx++; } } } Loading Loading @@ -440,5 +409,33 @@ void splitAvailableBitsMCT( } } #ifdef DEBUG_IVAS_SBA_MP_768KBPS { if ( enc_dec == ENC ) { FILE *f_chan_bits = fopen( "..\\res\\channels_bits.txt", "a+" ); float bits_frame_channel_kbps = 0.f; fprintf( f_chan_bits, "%f: ", ( total_bits * FRAMES_PER_SEC ) / 1000.f ); for ( int16_t ch = 0; ch < nchan; ch++ ) { bits_frame_channel = &( (Encoder_State *) sts[ch] )->bits_frame_channel; bits_frame_channel_kbps = (float) ( *bits_frame_channel * FRAMES_PER_SEC ) / 1000.f; fprintf( f_chan_bits, "%f, ", bits_frame_channel_kbps ); } fprintf( f_chan_bits, "\n" ); if ( f_chan_bits != NULL ) { fclose( f_chan_bits ); } } } #endif return; }
lib_com/ivas_mp_com.c +11 −2 Original line number Diff line number Diff line Loading @@ -119,7 +119,11 @@ int16_t ivas_mp_get_transport_channels( nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ); break; case SBA_HOA3_ORDER: nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ) - 1; /* HOA2 -> 2H1V */ #ifdef IVAS_SBA_MP_TCS9 nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ); #else nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ) - 1; #endif break; default: break; Loading Loading @@ -222,6 +226,7 @@ void ivas_mp_config_open( hConfig->mp_dirac_band_factor = ( NS2SA( sr, MP_OVERLAP_5MS_NS ) / NS2SA( sr, DIRAC_SLOT_NS ) ); hConfig->nb_subbands = MP_MAX_NBANDS; if ( sr == 48000 ) { mvs2s( ivas_mp_dirac_band_group_48kHz, hConfig->band_grouping, hConfig->nb_subbands + 1 ); Loading Loading @@ -257,7 +262,11 @@ void ivas_mp_config_open( } else if ( sba_order_input == SBA_HOA3_ORDER ) { mvs2s( ivas_mp_transport_channels_2H1V_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT ); #ifdef IVAS_SBA_MP_TCS9 mvs2s( ivas_mp_transport_channels_HOA2_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT ); #else mvs2s( ivas_mp_transport_channels_3H1V_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT ); #endif } } Loading
lib_com/ivas_mp_rom.c +127 −7 Original line number Diff line number Diff line Loading @@ -76,24 +76,139 @@ const int16_t ivas_mp_transport_channels_HOA2_table[MP_MAX_CHANNELS_TRANSPORT] = 0, 1, 2, 3, 4, 5, 6, 7, 8 }; const int16_t ivas_mp_transport_channels_2H1V_table[MP_MAX_CHANNELS_TRANSPORT] = { 0, 1, 2, 3, 4, 5, 7, 8 const int16_t ivas_mp_transport_channels_3H1V_table[MP_MAX_CHANNELS_TRANSPORT] = { 0, 1, 2, 3, 4, 8, 9, 15 }; const MP_DECORR_CONFIG ivas_mp_decorrelation_cfg_table[MP_MAX_DECORR_CONFIG] = { { SBA_HOA3_ORDER, IVAS_768k, 2, { 9, 15 }, 8 }, { SBA_HOA3_ORDER, IVAS_768k, 2, { 5, 7 }, 8 }, }; const MP_TCS_DMX_CONFIG ivas_mp_TCs_dmx_cfg_table[MP_MAX_GROUP_TRANSPORT_CFG] = { { SBA_FOA_ORDER, IVAS_768k, 4, 1, { 4, 0 }, 208000, { 1.f, 0.f } }, { SBA_HOA2_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 116000, { 0.55f, 0.45f } }, { SBA_HOA3_ORDER, IVAS_768k, 8, 2, { 4, 4 }, 112000, { 0.625f, 0.375f } }, { SBA_FOA_ORDER, IVAS_768k, 4, 1, { 4, 0 }, 64000, 208000, { 1.f, 0.f } }, { SBA_HOA2_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 48000, 116000, { 0.55f, 0.45f } }, #ifdef IVAS_SBA_MP_TCS9 { SBA_HOA3_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 32000, 116000, { 0.55f, 0.45f } }, #else { SBA_HOA3_ORDER, IVAS_768k, 8, 2, { 4, 4 }, 48000, 128000, { 0.625f, 0.375f } }, #endif }; const int16_t ivas_mp_q_gain_table[MP_Q_GAIN_TABLE_SIZE] = { ( (int16_t) ( MP_MIN_Q_GAIN ) ), -55, -50, -45, -40, -38, -36, -34, -32, -30, -28, -26, -24, -22, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, ( (int16_t) ( MP_MAX_Q_GAIN ) ) }; #if 1 const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP] = { /* 1 bits x 1 */ { { { 0, 1, 1 } , }, 1 }, /* 3 bits x2 : index = 1, offset = MP_HUFFMAN_CODEBOOK_OFFSET */ { { { -1, 1, 3 }, { 1, 0, 3 }, }, 2 }, /* 4 bits x2 */ { { { -2, 4, 4 }, { 2, 5, 4 }, }, 2 }, /* 5 bits x2 */ { { { -3, 12, 5 }, { 3, 13, 5 }, }, 2 }, /* 6 bits x2 */ { { { -4, 28, 6 }, { 4, 29, 6 }, }, 2 }, /* 7 bits x2 */ { { { -5, 60, 7 }, { 5, 61, 7 }, }, 2 }, /* 8 bits x2 */ { { { -6, 125, 8 }, { 6, 124, 8 }, }, 2 }, /* 9 bits x2 */ { { { -7, 253, 9 }, { 7, 252, 9 }, }, 2 }, /* 10 bits x2 */ { { { -8, 510, 10 }, { 8, 509, 10 }, }, 2 }, /* 11 bits x1 */ { { { 9, 1023, 11 } }, 1 }, /* 12 bits x1 */ { { { -9, 2033, 12 }, }, 1 }, /* 13 bits x4 */ { { { -24, 4089, 13 }, { -10, 4071, 13 }, { 10, 4065, 13 }, { 24, 4069, 13 }, }, 4 }, /* 14 bits x3 */ { { { -11, 8176, 14 }, { 11, 8128, 14 }, { 12, 8177, 14 }, }, 3 }, /* 15 bits x10 */ { { { -13, 16361, 15 }, { -12, 16274, 15 }, { 13, 16258, 15 }, { 14, 16280, 15 }, { 15, 16360, 15 }, { 16, 16365, 15 }, { 17, 16363, 15 }, { 20, 16364, 15 }, { 22, 16367, 15 }, { 23, 16275, 15 }, }, 10 }, /* 16 bits x11 */ { { { -19, 32732, 16 }, { -18, 32724, 16 }, { -17, 32567, 16 }, { -16, 32564, 16 }, { -15, 32563, 16 }, { -14, 32544, 16 }, { 18, 32519, 16 }, { 19, 32545, 16 }, { 21, 32547, 16 }, { 25, 32565, 16 }, { 31, 32518, 16 } }, 11 }, /* 17 bits x8 */ { { { -31, 65132, 17 }, { -25, 65451, 17 }, { -20, 65092, 17 }, { -22, 65450, 17 }, { -21, 65124, 17 }, { 26, 65125, 17 }, { 27, 65133, 17 }, { 28, 65467, 17 }, }, 8 }, /* 18 bits x1 */ { { { -23, 130187, 18 }, }, 1 }, /* 19 bits x5 */ { { { -30, 261866, 19 }, { -29, 261865, 19 }, { -26, 260372, 19 }, { 29, 261864, 19 }, { 30, 260373, 19 }, }, 5 }, /* 20 bits x2 */ { { { -28, 523735, 20 }, { -27, 523734, 20 }, }, 2 }, }; #else const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP] = { /* 1 bits x 1 */ { Loading Loading @@ -230,6 +345,11 @@ const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP { -27, 523734, 20 } }, 2 } }; #endif const int16_t ivas_mp_proj_band_group_48kHz[MP_MAX_NBANDS + 2] = { 0, 1, 2, 3, 4, 5, 6, 8, 12, 18, 26, 36, 48, 60 }; const Huffman_codebook ivas_mp_huffman_codebook_table[MP_Q_GAIN_TABLE_SIZE * 2 - 1] = { { 3, 13, 5 }, /* 10010 -> 01101 */ Loading
lib_com/ivas_rom_com.h +2 −1 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ extern const int16_t ivas_mp_direction_component_mask_table[MP_CHANNELS_HOA3]; /* Transport channels configuration */ extern const int16_t ivas_mp_transport_channels_FOA_table[MP_MAX_CHANNELS_TRANSPORT]; extern const int16_t ivas_mp_transport_channels_HOA2_table[MP_MAX_CHANNELS_TRANSPORT]; extern const int16_t ivas_mp_transport_channels_2H1V_table[MP_MAX_CHANNELS_TRANSPORT]; extern const int16_t ivas_mp_transport_channels_3H1V_table[MP_MAX_CHANNELS_TRANSPORT]; extern const MP_DECORR_CONFIG ivas_mp_decorrelation_cfg_table[MP_MAX_DECORR_CONFIG]; extern const MP_TCS_DMX_CONFIG ivas_mp_TCs_dmx_cfg_table[MP_MAX_GROUP_TRANSPORT_CFG]; Loading @@ -220,6 +220,7 @@ extern const Huffman_codebook ivas_mp_huffman_codebook_table[MP_Q_GAIN_TABLE_SIZ extern const Huffman_codebook_model ivas_mp_huffman_codebook_model[MP_MAX_HUFFMAN_GROUP]; /* MP table */ extern const int16_t ivas_mp_proj_band_group_48kHz[MP_MAX_NBANDS + 2]; extern const float ivas_mp_basis_matrix_R1[MP_MAX_NB_COEFFS][MP_COLS_R1]; extern const int16_t ivas_mp_basis_matrix_R2[MP_COLS_R1][MP_COLS_R2]; extern const float ivas_mp_direction_angle_matrix[MP_FIXED_DIR_ROWS][2]; Loading