Loading lib_dec/ivas_jbm_dec.c +252 −191 Original line number Diff line number Diff line Loading @@ -69,12 +69,13 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t #endif #ifdef IVAS_FLOAT_FIXED static Word16 ceil_fx16( Word16 inp, Word16 Q ); static Word16 ceil_fx16( Word16 inp, Word16 Q ) { static Word16 ceil_fx16( Word16 inp, Word16 Q ) { Word16 ret = shr( inp, Q ); IF( inp & ( ( 1 << Q ) - 1) > 0) { IF( inp & ( ( 1 << Q ) - 1 ) > 0 ) { ret = ret + 1; } return ret; Loading Loading @@ -3406,7 +3407,37 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER #ifdef IVAS_FLOAT_FIXED Word16 ch_idx; exp = 16; for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = tmp_buffer_fx[ch_idx]; } for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) { exp = s_min( exp , Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); } exp -= 2; for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] * ( 1 << exp ) ); } } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); } } #else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); #endif #endif } } Loading Loading @@ -3804,7 +3835,39 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER #ifdef IVAS_FLOAT_FIXED Word16 ch_idx; exp = 16; for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { exp = s_min( exp, Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); } exp -= 1; for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] *(1<< exp) ) ; } } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); } } #else ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); #endif #endif } } Loading Loading @@ -5825,7 +5888,6 @@ ivas_error ivas_jbm_dec_metadata_open( #endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_masa_meta_to_buffer() * Loading Loading @@ -5908,7 +5970,6 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( #endif /*--------------------------------------------------------------------------* * ivas_jbm_masa_sf_to_slot_map() * Loading lib_rend/ivas_limiter.c +48 −7 Original line number Diff line number Diff line Loading @@ -160,21 +160,21 @@ static Word16 detect_strong_saturations_fx( ) { Word16 apply_strong_limiting; Word32 compare_max_value_Mul_3, compare_max_value_Mul_10; Word64 compare_max_value_Mul_3, compare_max_value_Mul_10; apply_strong_limiting = 0; compare_max_value_Mul_3 = L_lshl(98187,q_factor); // 3 * IVAS_LIMITER_THRESHOLD compare_max_value_Mul_10 = L_lshl( 327290, q_factor );//10 * IVAS_LIMITER_THRESHOLD compare_max_value_Mul_3 = W_shl(98187,q_factor); // 3 * IVAS_LIMITER_THRESHOLD compare_max_value_Mul_10 = W_shl( 327290, q_factor );//10 * IVAS_LIMITER_THRESHOLD IF ( BER_detect ) { *strong_saturation_cnt = 50; apply_strong_limiting = 1; } ELSE IF( GT_32( max_val , compare_max_value_Mul_3) && GT_16(*strong_saturation_cnt , 0 )) ELSE IF( GT_64( max_val, compare_max_value_Mul_3 ) && GT_16( *strong_saturation_cnt, 0 ) ) { apply_strong_limiting = 1; } ELSE IF( GT_32 (max_val , compare_max_value_Mul_10) ) ELSE IF( GT_64( max_val, compare_max_value_Mul_10 ) ) { *strong_saturation_cnt += 20; *strong_saturation_cnt = min( *strong_saturation_cnt, 50 ); Loading Loading @@ -371,6 +371,47 @@ void ivas_limiter_close( return; } #endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ivas_limiter_dec() * * In-place saturation control for multichannel buffers with adaptive * release time and special handling of bit errors *-------------------------------------------------------------------*/ void ivas_limiter_dec_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const Word16 num_channels, /* i : number of channels to be processed */ const Word16 output_frame, /* i : number of samples per channel in the buffer */ const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor ) { Word16 c; Word32 **channels; /* return early if given bad parameters */ IF ( hLimiter == NULL || output == NULL || output_frame <= 0 ) { return; } /* Update number of channels and prepare pointers to the beginning of each of them */ assert( num_channels <= hLimiter->max_num_channels && "Number of channels must be lower than the maximum set during limiter initialization!" ); hLimiter->num_channels = min( num_channels, hLimiter->max_num_channels ); channels = hLimiter->channel_ptrs_fx; FOR ( c = 0; c < num_channels; ++c ) { channels[c] = output[c]; } Word32 limiter_thresold = L_shl( IVAS_LIMITER_THRESHOLD, q_factor ); limiter_process_fx( hLimiter, output_frame, limiter_thresold, BER_detect, &hLimiter->strong_saturation_count, q_factor ); return; } #endif /*-------------------------------------------------------------------* * ivas_limiter_dec() Loading Loading @@ -410,7 +451,6 @@ void ivas_limiter_dec( return; } #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * limiter_process() Loading Loading @@ -500,6 +540,7 @@ void limiter_process_fx( } releaseHeuristic = hLimiter->release_heuristic_fx; q_fact_gain = Q30; IF (GT_32( max_val , threshold) ) { frame_gain = L_shl(divide3232( threshold, max_val ),15);//to q30 Loading lib_rend/ivas_prot_rend.h +11 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,17 @@ void ivas_limiter_dec const int16_t output_frame, /* i : number of samples per channel in the buffer */ const int16_t BER_detect /* i : BER detect flag */ ); #ifdef IVAS_FLOAT_FIXED void ivas_limiter_dec_fx ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const Word16 num_channels, /* i : number of channels to be processed */ const Word16 output_frame, /* i : number of samples per channel in the buffer */ const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor ); #endif void limiter_process( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ Loading Loading
lib_dec/ivas_jbm_dec.c +252 −191 Original line number Diff line number Diff line Loading @@ -69,12 +69,13 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t #endif #ifdef IVAS_FLOAT_FIXED static Word16 ceil_fx16( Word16 inp, Word16 Q ); static Word16 ceil_fx16( Word16 inp, Word16 Q ) { static Word16 ceil_fx16( Word16 inp, Word16 Q ) { Word16 ret = shr( inp, Q ); IF( inp & ( ( 1 << Q ) - 1) > 0) { IF( inp & ( ( 1 << Q ) - 1 ) > 0 ) { ret = ret + 1; } return ret; Loading Loading @@ -3406,7 +3407,37 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER #ifdef IVAS_FLOAT_FIXED Word16 ch_idx; exp = 16; for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = tmp_buffer_fx[ch_idx]; } for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) { exp = s_min( exp , Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); } exp -= 2; for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] * ( 1 << exp ) ); } } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); } } #else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); #endif #endif } } Loading Loading @@ -3804,7 +3835,39 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER #ifdef IVAS_FLOAT_FIXED Word16 ch_idx; exp = 16; for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { exp = s_min( exp, Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); } exp -= 1; for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] *(1<< exp) ) ; } } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { for ( j = 0; j < *nSamplesRendered; j++ ) { p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); } } #else ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); #endif #endif } } Loading Loading @@ -5825,7 +5888,6 @@ ivas_error ivas_jbm_dec_metadata_open( #endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_masa_meta_to_buffer() * Loading Loading @@ -5908,7 +5970,6 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( #endif /*--------------------------------------------------------------------------* * ivas_jbm_masa_sf_to_slot_map() * Loading
lib_rend/ivas_limiter.c +48 −7 Original line number Diff line number Diff line Loading @@ -160,21 +160,21 @@ static Word16 detect_strong_saturations_fx( ) { Word16 apply_strong_limiting; Word32 compare_max_value_Mul_3, compare_max_value_Mul_10; Word64 compare_max_value_Mul_3, compare_max_value_Mul_10; apply_strong_limiting = 0; compare_max_value_Mul_3 = L_lshl(98187,q_factor); // 3 * IVAS_LIMITER_THRESHOLD compare_max_value_Mul_10 = L_lshl( 327290, q_factor );//10 * IVAS_LIMITER_THRESHOLD compare_max_value_Mul_3 = W_shl(98187,q_factor); // 3 * IVAS_LIMITER_THRESHOLD compare_max_value_Mul_10 = W_shl( 327290, q_factor );//10 * IVAS_LIMITER_THRESHOLD IF ( BER_detect ) { *strong_saturation_cnt = 50; apply_strong_limiting = 1; } ELSE IF( GT_32( max_val , compare_max_value_Mul_3) && GT_16(*strong_saturation_cnt , 0 )) ELSE IF( GT_64( max_val, compare_max_value_Mul_3 ) && GT_16( *strong_saturation_cnt, 0 ) ) { apply_strong_limiting = 1; } ELSE IF( GT_32 (max_val , compare_max_value_Mul_10) ) ELSE IF( GT_64( max_val, compare_max_value_Mul_10 ) ) { *strong_saturation_cnt += 20; *strong_saturation_cnt = min( *strong_saturation_cnt, 50 ); Loading Loading @@ -371,6 +371,47 @@ void ivas_limiter_close( return; } #endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ivas_limiter_dec() * * In-place saturation control for multichannel buffers with adaptive * release time and special handling of bit errors *-------------------------------------------------------------------*/ void ivas_limiter_dec_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const Word16 num_channels, /* i : number of channels to be processed */ const Word16 output_frame, /* i : number of samples per channel in the buffer */ const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor ) { Word16 c; Word32 **channels; /* return early if given bad parameters */ IF ( hLimiter == NULL || output == NULL || output_frame <= 0 ) { return; } /* Update number of channels and prepare pointers to the beginning of each of them */ assert( num_channels <= hLimiter->max_num_channels && "Number of channels must be lower than the maximum set during limiter initialization!" ); hLimiter->num_channels = min( num_channels, hLimiter->max_num_channels ); channels = hLimiter->channel_ptrs_fx; FOR ( c = 0; c < num_channels; ++c ) { channels[c] = output[c]; } Word32 limiter_thresold = L_shl( IVAS_LIMITER_THRESHOLD, q_factor ); limiter_process_fx( hLimiter, output_frame, limiter_thresold, BER_detect, &hLimiter->strong_saturation_count, q_factor ); return; } #endif /*-------------------------------------------------------------------* * ivas_limiter_dec() Loading Loading @@ -410,7 +451,6 @@ void ivas_limiter_dec( return; } #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * limiter_process() Loading Loading @@ -500,6 +540,7 @@ void limiter_process_fx( } releaseHeuristic = hLimiter->release_heuristic_fx; q_fact_gain = Q30; IF (GT_32( max_val , threshold) ) { frame_gain = L_shl(divide3232( threshold, max_val ),15);//to q30 Loading
lib_rend/ivas_prot_rend.h +11 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,17 @@ void ivas_limiter_dec const int16_t output_frame, /* i : number of samples per channel in the buffer */ const int16_t BER_detect /* i : BER detect flag */ ); #ifdef IVAS_FLOAT_FIXED void ivas_limiter_dec_fx ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const Word16 num_channels, /* i : number of channels to be processed */ const Word16 output_frame, /* i : number of samples per channel in the buffer */ const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor ); #endif void limiter_process( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ Loading