diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 546f824a71120ec61bf4ced4c368de3e4f69dc5a..5df57bb51114b0ff78d7c55cdfeee069d0c43744 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6239,7 +6239,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( Word16 ivas_jbm_dec_get_render_granularity_fx( const RENDERER_TYPE renderer_type, /* i : renderer type */ const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ - const int32_t output_Fs /* i : sampling rate */ + const Word32 output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open_fx( diff --git a/lib_com/options.h b/lib_com/options.h index db344cb37062216bd8d3db0445ad7cd183b3d2f9..37fffd13ec20834422ff4e916401110da7d8c069 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,6 +87,8 @@ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ #define FIX_2082_FP_LEFTOVERS_OMASA_DEC /* Nokia: fix for issue 2082, cleaning remaining floating point code */ +#define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ + /* ################### End FIXES switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ff4374dddce06bb9bc85992aea770455d5536fd9..3d8fdda45734c500d71a4e5be581c0339bd4359f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1090,8 +1090,6 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - - // st = (st_ivas->nSCE > 0) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; IF( st_ivas->nSCE > 0 ) { st = st_ivas->hSCE[0]->hCoreCoder[0]; @@ -1111,6 +1109,7 @@ ivas_error ivas_jbm_dec_tc_fx( { return error; } + /* HP filtering */ FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -1169,6 +1168,7 @@ ivas_error ivas_jbm_dec_tc_fx( { return error; } + /* HP filtering */ FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -1258,7 +1258,6 @@ ivas_error ivas_jbm_dec_tc_fx( } /* read McMASA parameters from the bitstream */ - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -1285,13 +1284,12 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); /* Decode the separated channel to output[n] to be combined with the synthesized channels */ - set32_fx( p_output_fx[n], 0, L_FRAME48k ); - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; } + test(); test(); test(); @@ -1326,7 +1324,6 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -1675,7 +1672,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) { - ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, p_data_fx, Q11 ); + ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, p_data_fx, Q11 ); } hTcBuffer->n_samples_rendered = 0; @@ -2549,7 +2546,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); +#else set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); +#endif } #else /* render what is still there with zero padding */ @@ -2926,12 +2927,13 @@ void ivas_jbm_dec_get_adapted_linear_interpolator_fx( } ELSE { - set16_fx( interpolator_fx, 0, idx + 1 ); + set16_fx( interpolator_fx, 0, add( idx, 1 ) ); } return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_subframes() * @@ -2948,6 +2950,7 @@ void ivas_jbm_dec_get_adapted_subframes( UWord16 nCldfbSlotsLocal = nCldfbTs; move16(); Word16 temp, temp_e; + /* get last subframe size from previous frame, determine how many slots have to be processed in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) ); @@ -2983,6 +2986,8 @@ void ivas_jbm_dec_get_adapted_subframes( return; } + + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * @@ -3313,7 +3318,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( Word16 ivas_jbm_dec_get_render_granularity_fx( const RENDERER_TYPE renderer_type, /* i : renderer type */ const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ - const int32_t output_Fs /* i : sampling rate */ + const Word32 output_Fs /* i : sampling rate */ ) { Word16 render_granularity; @@ -3350,8 +3355,8 @@ Word16 ivas_jbm_dec_get_render_granularity_fx( static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t Opt_tsm /* i : TSM option flag */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 Opt_tsm /* i : TSM option flag */ ) { Word16 nsamp_to_allocate; @@ -3360,7 +3365,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( IF( Opt_tsm ) { n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); +#else n_samp_residual = add( hTcBuffer->n_samples_granularity, 1 ); +#endif } ELSE { @@ -3369,7 +3378,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( move16(); } +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full ); +#else nsamp_to_allocate = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; +#endif IF( Opt_tsm ) { @@ -3382,7 +3395,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( offset = 0; move16(); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) +#else FOR( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) +#endif { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; offset = add( offset, n_samp_full ); @@ -3470,7 +3487,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ - ivas_error ivas_jbm_dec_tc_buffer_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 248b8846b4c01d1030f45ac64fd5e445878ad9cf..73c8c9a405216f37d00e984a3a3189e341b5fa88 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1217,7 +1217,11 @@ ivas_error IVAS_DEC_GetSamplesRenderer( hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + IF( GT_16( hIvasDec->nSamplesFlushed, 0 ) ) +#else IF( GE_16( hIvasDec->nSamplesFlushed, 0 ) ) +#endif { /* note: offset (rendered samples) is always 0 */ Copy( hIvasDec->flushbuffer, pcmBuf, imult1616( hIvasDec->nSamplesFlushed, nOutChannels ) ); @@ -3570,7 +3574,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( IF( st_ivas->hDecoderConfig->Opt_tsm ) { /* feed residual samples to TSM for the next call */ +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) +#else IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) +#endif { return IVAS_ERR_UNKNOWN; } @@ -4261,7 +4269,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif - /* avoid time scaling multiple times in one sound card slot */ IF( NE_64( scale, 100U ) ) { @@ -4296,7 +4303,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) { return error;