diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 072bc390c9ecfb30c8a6225f9f32664096054078..53111de7533b6aed005491ce3cf00594246209a9 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -762,6 +762,14 @@ void dtx_read_padding_bits( const int16_t num_bits ); +#ifdef FIX_764_HARM_CODE +void ivas_apply_non_diegetic_panning( + float *output_f[], /* i/o: core-coder transport mono channel/stereo output */ + const float non_diegetic_pan_gain, /* i : non-diegetic panning gain */ + const int16_t output_frame /* i : output frame length per channel */ +); +#endif + /*----------------------------------------------------------------------------------* * JBM prototypes diff --git a/lib_com/options.h b/lib_com/options.h index ae33ed115ba8581269bc29a9c84fd743cfeef3cd..876ca8adc254b123eef33da99b0a3364de56cfe2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,9 +173,9 @@ #define FIX_759_CODE_COVERAGE_OSBA /* VA: issue 759: remove obsolete code in the OSBA encoder */ #define FIX_708_AEID_COMMAND_LINE /* VA: issue 708: improve AEID command-line robustness */ #define FIX_518_ISM_BRIR_EXTREND /* FhG: fix issue #518, cleanup ISM to BINAURAL_ROOM_IR rendering in the external renderer */ +#define FIX_764_HARM_CODE /* VA: issue 764: introduce new function for the same code block at four different places */ -/* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt selection floating point code */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index a5fe7aa36c26e31967415d130137f3e80d2793ed..5605cb09fd99766a2ad074804842ab6b48d2d4fc 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -62,26 +62,24 @@ ivas_error ivas_dec( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* 'float' buffer for output synthesis */ + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* 'float' buffer for output synthesis */ int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; +#ifndef FIX_764_HARM_CODE float pan_left, pan_right; +#endif ivas_error error; - float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; int16_t num_md_sub_frames; int32_t ism_total_brate; #if defined SPLIT_REND_WITH_HEAD_ROT int16_t nchan_out_syn_output; #endif - error = IVAS_ERR_OK; - push_wmops( "ivas_dec" ); - /*----------------------------------------------------------------* * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ @@ -95,11 +93,9 @@ ivas_error ivas_dec( for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { - output[n] = st_ivas->p_output_f[n]; - p_output[n] = output[n]; + p_output[n] = st_ivas->p_output_f[n]; } - /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ @@ -110,8 +106,11 @@ ivas_error ivas_dec( } #if defined SPLIT_REND_WITH_HEAD_ROT - if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + /*----------------------------------------------------------------* + * Binaural split rendering setup + *----------------------------------------------------------------*/ + + if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { ivas_set_split_rend_ht_setup( &st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData ); } @@ -130,14 +129,13 @@ ivas_error ivas_dec( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } - output[n] = st_ivas->p_output_f[n]; - p_output[n] = output[n]; + p_output[n] = st_ivas->p_output_f[n]; } /* zero output when first frame(s) is lost */ for ( n = 0; n < nchan_out; n++ ) { - set_f( output[n], 0.0f, output_frame ); + set_f( p_output[n], 0.0f, output_frame ); } #ifdef DEBUG_MODE_INFO @@ -151,7 +149,7 @@ ivas_error ivas_dec( { st_ivas->hCPE[0]->element_brate = ivas_total_brate; - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -159,7 +157,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -179,7 +177,7 @@ ivas_error ivas_dec( } /* decode dominant object first so the noise energy of the other objects can be limited */ - if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } @@ -188,16 +186,14 @@ ivas_error ivas_dec( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, - st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, - st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -208,14 +204,14 @@ ivas_error ivas_dec( /* for DTX frames, dominant object has already been decoded before */ if ( !( ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) { - if ( ( error = ivas_sce_dec( st_ivas, n, &output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) { return error; } } /* HP filtering */ - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -224,27 +220,30 @@ ivas_error ivas_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( output, st_ivas->nchan_transport, output_frame ); + ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); ivas_param_ism_params_to_masa_param_mapping( st_ivas ); - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { +#ifdef FIX_764_HARM_CODE + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, output_frame ); +#else pan_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; pan_right = 1.f - pan_left; - v_multc( output[0], pan_right, output[1], output_frame ); - v_multc( output[0], pan_left, output[0], output_frame ); + v_multc( p_output[0], pan_right, p_output[1], output_frame ); + v_multc( p_output[0], pan_left, p_output[0], output_frame ); +#endif } else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { - ivas_param_ism_dec( st_ivas, output ); + ivas_param_ism_dec( st_ivas, p_output ); if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { @@ -258,14 +257,18 @@ ivas_error ivas_dec( /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { +#ifdef FIX_764_HARM_CODE + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, output_frame ); +#else pan_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; pan_right = 1.f - pan_left; - v_multc( output[0], pan_right, output[1], output_frame ); - v_multc( output[0], pan_left, output[0], output_frame ); + v_multc( p_output[0], pan_right, p_output[1], output_frame ); + v_multc( p_output[0], pan_left, p_output[0], output_frame ); +#endif } else if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -288,7 +291,7 @@ ivas_error ivas_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -306,9 +309,7 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, - NULL, NULL, NULL, p_output, output_Fs, - MAX_PARAM_SPATIAL_SUBFRAMES + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES #ifdef SPLIT_REND_WITH_HEAD_ROT , 0 @@ -358,21 +359,21 @@ ivas_error ivas_dec( /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE > 1 ) { - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -401,19 +402,17 @@ ivas_error ivas_dec( if ( st_ivas->ivas_format == SBA_FORMAT ) { - ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, output, output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, p_output, p_output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } - ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); + ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, st_ivas->ivas_format == MC_FORMAT ); } else if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) { @@ -424,61 +423,56 @@ ivas_error ivas_dec( #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC for ( n = 0; n < nchan_remapped; n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } #endif if ( st_ivas->ivas_format == SBA_FORMAT ) { - nchan_remapped = ivas_sba_remapTCs( output, st_ivas, output_frame ); + nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); - ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, p_output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } else if ( st_ivas->renderer_type != RENDERER_DISABLE ) { - ivas_spar_dec_agc_pca( st_ivas, output, output_frame ); + ivas_spar_dec_agc_pca( st_ivas, p_output, output_frame ); } } if ( st_ivas->ivas_format == MASA_FORMAT ) { - ivas_masa_prerender( st_ivas, output, output_frame, nchan_remapped ); + ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( output, nchan_remapped, output_frame ); + ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); } /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, nchan_remapped, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); } else if ( st_ivas->ivas_format == MASA_FORMAT ) { if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, - 0, - output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, 0, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { - ivas_dirac_dec( st_ivas, output, nchan_remapped, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec( st_ivas, p_output, nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); } } else if ( !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) { - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ { return error; } @@ -525,27 +519,27 @@ ivas_error ivas_dec( /* decode ISM channels */ for ( n = 0; n < nchan_transport_ism; n++ ) { - if ( ( error = ivas_sce_dec( st_ivas, n, &output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } } /* decode MASA channels */ - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } if ( st_ivas->hCPE[0]->nchan_out == 1 ) { - mvr2r( output[0], output[1], output_frame ); /* Copy mono signal to stereo output channels */ + mvr2r( p_output[0], p_output[1], output_frame ); /* Copy mono signal to stereo output channels */ } /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -553,28 +547,27 @@ ivas_error ivas_dec( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } } else { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); } } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { - ivas_omasa_dirac_rend( st_ivas, output, output_frame ); + ivas_omasa_dirac_rend( st_ivas, p_output, output_frame ); } /* external output */ - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + if ( output_config == AUDIO_CONFIG_EXTERNAL ) { /* sanity check in case of bitrate switching */ if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) @@ -582,7 +575,7 @@ ivas_error ivas_dec( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } - ivas_omasa_rearrange_channels( output, nchan_transport_ism, output_frame ); + ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -621,7 +614,7 @@ ivas_error ivas_dec( if ( st_ivas->nSCE == 1 ) { st = st_ivas->hSCE[0]->hCoreCoder[0]; - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -629,7 +622,7 @@ ivas_error ivas_dec( else if ( st_ivas->nCPE == 1 ) { st = st_ivas->hCPE[0]->hCoreCoder[0]; - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -637,7 +630,7 @@ ivas_error ivas_dec( else if ( st_ivas->nCPE > 1 ) { st = st_ivas->hCPE[0]->hCoreCoder[0]; - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -645,27 +638,25 @@ ivas_error ivas_dec( if ( st_ivas->sba_dirac_stereo_flag ) { - ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[sba_ch_idx], &output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &p_output[sba_ch_idx], &p_output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[sba_ch_idx] ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); - ivas_sba_dirac_stereo_dec( st_ivas, &output[sba_ch_idx], output_frame, 0 ); + ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); } /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - nchan_remapped = ivas_sba_remapTCs( &output[sba_ch_idx], st_ivas, output_frame ); + nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); #ifdef DEBUG_OSBA if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -683,88 +674,87 @@ ivas_error ivas_dec( #endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - - ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } else if ( st_ivas->renderer_type != RENDERER_DISABLE ) { - ivas_spar_dec_agc_pca( st_ivas, &output[sba_ch_idx], output_frame ); + ivas_spar_dec_agc_pca( st_ivas, &p_output[sba_ch_idx], output_frame ); } if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( &output[sba_ch_idx], nchan_remapped, output_frame ); + ivas_dirac_dec_binaural_sba_gain( &p_output[sba_ch_idx], nchan_remapped, output_frame ); } /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[sba_ch_idx], nchan_remapped, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &p_output[sba_ch_idx], nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } } else { - ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); + ivas_sba_upmixer_renderer( st_ivas, &p_output[sba_ch_idx], output_frame ); } } else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) { if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } else /* stereo output */ { /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case */ if ( nchan_ism == 1 ) { - mvr2r( output[2], output[3], output_frame ); - mvr2r( output[1], output[2], output_frame ); + mvr2r( p_output[2], p_output[3], output_frame ); + mvr2r( p_output[1], p_output[2], output_frame ); } + ivas_ism_render( st_ivas, p_output, output_frame ); } for ( n = 0; n < nchan_out; n++ ) { - v_add( output[n], output[n + max( nchan_out, nchan_ism )], output[n], output_frame ); + v_add( p_output[n], p_output[n + max( nchan_out, nchan_ism )], p_output[n], output_frame ); } } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) { - if ( ( error = ivas_osba_render( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_osba_render( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) + else if ( output_config != AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) { - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ + else if ( output_config == AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { for ( n = 0; n < nchan_ism; n++ ) { - delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + delay_signal( p_output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &p_output[sba_ch_idx], output_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -773,11 +763,12 @@ ivas_error ivas_dec( { for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) { - mvr2r( output[n], output[n + nchan_ism], output_frame ); + mvr2r( p_output[n], p_output[n + nchan_ism], output_frame ); } + for ( n = 0; n < nchan_ism; n++ ) { - set_zero( output[n], output_frame ); + set_zero( p_output[n], output_frame ); } } } @@ -786,15 +777,12 @@ ivas_error ivas_dec( { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - /* LFE channel decoder */ if ( st_ivas->mc_mode == MC_MODE_MCT ) { - ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); - } + /* LFE channel decoder */ + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -804,7 +792,7 @@ ivas_error ivas_dec( { if ( n != LFE_CHANNEL ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } @@ -829,8 +817,7 @@ ivas_error ivas_dec( { #endif if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, - MAX_PARAM_SPATIAL_SUBFRAMES + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES #ifdef SPLIT_REND_WITH_HEAD_ROT , 0 @@ -859,7 +846,7 @@ ivas_error ivas_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -880,16 +867,16 @@ ivas_error ivas_dec( } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { - ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } - ivas_mc_paramupmix_dec( st_ivas, output ); + ivas_mc_paramupmix_dec( st_ivas, p_output ); /* HP filtering */ if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -898,7 +885,7 @@ ivas_error ivas_dec( { if ( n != LFE_CHANNEL ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } } @@ -915,7 +902,7 @@ ivas_error ivas_dec( if ( !( st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) ) #else #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif #endif { @@ -924,7 +911,7 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_MC ) { - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) ) + if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) { ivas_ls_setup_conversion( st_ivas, audioCfg2channels( AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); } @@ -942,7 +929,7 @@ ivas_error ivas_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -968,14 +955,14 @@ ivas_error ivas_dec( if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE > 1 ) { - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -984,7 +971,7 @@ ivas_error ivas_dec( /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -1013,7 +1000,7 @@ ivas_error ivas_dec( if ( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -1022,7 +1009,7 @@ ivas_error ivas_dec( n = st_ivas->hOutSetup.separateChannelIndex; /* Decode the separated channel to output[n] to be combined with the synthesized channels */ - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -1032,26 +1019,26 @@ ivas_error ivas_dec( output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_5_1_2 || ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { - ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, output, output_frame, n, LFE_CHANNEL ); + ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, p_output, output_frame, n, LFE_CHANNEL ); } else if ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal( output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + delay_signal( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); } } else { if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -1060,25 +1047,23 @@ ivas_error ivas_dec( if ( st_ivas->sba_dirac_stereo_flag ) /* use the flag to trigger the DFT upmix */ { - ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, 1 ); + ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, 1 ); } /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); } else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ { - ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec( st_ivas, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { @@ -1088,13 +1073,13 @@ ivas_error ivas_dec( { for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ ) { - set_zero( output[n], output_frame ); + set_zero( p_output[n], output_frame ); } } } else if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { - ivas_mono_stereo_downmix_mcmasa( st_ivas, output, output_frame ); + ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); } } } @@ -1201,5 +1186,5 @@ ivas_error ivas_dec( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 15164e5a18a1199740570d6e8238a31fe57c052a..764392921e9e8e1e5fa06d075231f0c0f470440d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -58,31 +58,30 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() * * Principal IVAS JBM decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : transport channel signals */ ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *output[MAX_OUTPUT_CHANNELS]; /* 'float' buffer for output synthesis */ /* TODO: can be allocated dynamically using st_ivas->p_output_f */ - float p_output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + float output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* TODO: can be allocated dynamically using st_ivas->p_output_f */ int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; ivas_error error; - float *p_output[MAX_TRANSPORT_CHANNELS]; int16_t num_md_sub_frames; int32_t ism_total_brate; - error = IVAS_ERR_OK; - push_wmops( "ivas_jbm_dec_tc" ); /*----------------------------------------------------------------* @@ -98,12 +97,11 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { - output[n] = p_output_f[n]; - p_output[n] = &output[n][0]; + p_output[n] = output_f[n]; } /*----------------------------------------------------------------* - * Decoding + Rendering + * Decoding + pre-rendering *----------------------------------------------------------------*/ if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) @@ -124,7 +122,7 @@ ivas_error ivas_jbm_dec_tc( else if ( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -132,7 +130,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) @@ -152,7 +150,7 @@ ivas_error ivas_jbm_dec_tc( #ifdef NONBE_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* decode dominant object first so the noise energy of the other objects can be limited */ - if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } @@ -162,16 +160,14 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, - st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, - st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -183,7 +179,7 @@ ivas_error ivas_jbm_dec_tc( /* for DTX frames, dominant object has already been decoded before */ if ( !( ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) { - if ( ( error = ivas_sce_dec( st_ivas, n, &output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) { return error; } @@ -196,16 +192,16 @@ ivas_error ivas_jbm_dec_tc( #endif /* HP filtering */ - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( output, st_ivas->nchan_transport, output_frame ); + ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); } } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) @@ -222,7 +218,7 @@ ivas_error ivas_jbm_dec_tc( return error; } - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + if ( output_config == AUDIO_CONFIG_EXTERNAL ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } @@ -243,21 +239,21 @@ ivas_error ivas_jbm_dec_tc( /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE > 1 ) { - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -275,19 +271,17 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == SBA_FORMAT ) { - ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, output, output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, p_output, p_output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } - ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); + ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, st_ivas->ivas_format == MC_FORMAT ); } else if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) { @@ -298,32 +292,33 @@ ivas_error ivas_jbm_dec_tc( #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC for ( n = 0; n < nchan_remapped; n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } #endif + if ( st_ivas->ivas_format == SBA_FORMAT ) { - nchan_remapped = ivas_sba_remapTCs( output, st_ivas, output_frame ); + nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, p_output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } else { - ivas_spar_dec_agc_pca( st_ivas, output, output_frame ); + ivas_spar_dec_agc_pca( st_ivas, p_output, output_frame ); } } if ( st_ivas->ivas_format == MASA_FORMAT ) { - ivas_masa_prerender( st_ivas, output, output_frame, nchan_remapped ); + ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( output, nchan_remapped, output_frame ); + ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -336,7 +331,7 @@ ivas_error ivas_jbm_dec_tc( /* Set the number of objects for the parametric rendering */ dirac_bs_md_write_idx = 0; - if ( st_ivas->hDirAC != NULL ) + if ( st_ivas->hSpatParamRendCom != NULL ) { st_ivas->hSpatParamRendCom->numIsmDirections = 0; if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) @@ -367,34 +362,34 @@ ivas_error ivas_jbm_dec_tc( /* decode ISM channels */ for ( n = 0; n < nchan_transport_ism; n++ ) { - if ( ( error = ivas_sce_dec( st_ivas, n, &output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } } /* decode MASA channels */ - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } if ( st_ivas->hCPE[0]->nchan_out == 1 ) { - mvr2r( output[0], output[1], output_frame ); /* Copy mono signal to stereo output channels */ + mvr2r( p_output[0], p_output[1], output_frame ); /* Copy mono signal to stereo output channels */ } /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } - else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + else if ( output_config == AUDIO_CONFIG_EXTERNAL ) { /* sanity check in case of bitrate switching */ if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) @@ -402,16 +397,7 @@ ivas_error ivas_jbm_dec_tc( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } - /* in case of external rendering, rearrange the channels order */ - mvr2r( output[0], output[MAX_TRANSPORT_CHANNELS - 2], output_frame ); - mvr2r( output[1], output[MAX_TRANSPORT_CHANNELS - 1], output_frame ); - - for ( n = 0; n < nchan_transport_ism; n++ ) - { - mvr2r( output[st_ivas->nchan_transport + n], output[n], output_frame ); - } - mvr2r( output[MAX_TRANSPORT_CHANNELS - 2], output[n], output_frame ); - mvr2r( output[MAX_TRANSPORT_CHANNELS - 1], output[++n], output_frame ); + ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } @@ -420,20 +406,17 @@ ivas_error ivas_jbm_dec_tc( { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - /* LFE channel decoder */ if ( st_ivas->mc_mode == MC_MODE_MCT ) { - if ( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg == NULL ) + if ( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg == NULL ) // ToDo: this is missing in ivas_dec() -> TBV { st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg; } - ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); - } + /* LFE channel decoder */ + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -443,14 +426,13 @@ ivas_error ivas_jbm_dec_tc( { if ( n != LFE_CHANNEL ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == AUDIO_CONFIG_FOA || st_ivas->intern_config == AUDIO_CONFIG_HOA2 || st_ivas->intern_config == AUDIO_CONFIG_HOA3 ) ) { - if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= - ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) + if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) // ToDo: this is missing in ivas_dec() -> TBV { ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); } @@ -470,11 +452,12 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { - ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); + /* LFE channel decoder */ + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -489,7 +472,7 @@ ivas_error ivas_jbm_dec_tc( { if ( n != LFE_CHANNEL ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } ivas_ls_setup_conversion( st_ivas, audioCfg2channels( AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); @@ -503,14 +486,14 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE > 1 ) { - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -519,7 +502,7 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } /* Rendering */ @@ -544,7 +527,7 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -553,7 +536,7 @@ ivas_error ivas_jbm_dec_tc( n = LFE_CHANNEL - 1; /* Decode the separated channel to output[n] to be combined with the synthesized channels */ - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -563,26 +546,26 @@ ivas_error ivas_jbm_dec_tc( output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_5_1_2 || ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { - ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, output, output_frame, n, LFE_CHANNEL ); + ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, p_output, output_frame, n, LFE_CHANNEL ); } else if ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal( output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + delay_signal( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); } } else { if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } else if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -591,39 +574,26 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->sba_dirac_stereo_flag ) /* use the flag to trigger the DFT upmix */ { - ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, 1 ); + ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, 1 ); } /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { - ivas_mono_stereo_downmix_mcmasa( st_ivas, output, output_frame ); - } - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - - /* at least decode everything here, the rest is ToDo, for this we just output zeroes atm */ - ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); - - ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; + ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); } } } - /*----------------------------------------------------------------* * Write IVAS transport channels *----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) { ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); @@ -666,7 +636,7 @@ ivas_error ivas_jbm_dec_tc( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -683,21 +653,18 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( float *data /* i : transport channels */ ) { - float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; - int16_t n_render_timeslots; - int16_t n; + int16_t n, n_render_timeslots; ivas_error error; - error = IVAS_ERR_OK; - push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f[n] = &data_f[n][0]; } + if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) { ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); @@ -711,6 +678,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); @@ -728,6 +696,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); + ivas_param_ism_params_to_masa_param_mapping( st_ivas ); } else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) @@ -742,7 +711,10 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -750,7 +722,11 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( { n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + + if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK ) + { + return error; + } if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { @@ -773,13 +749,16 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + if ( ( error = ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ) ) != IVAS_ERR_OK ) + { + return error; + } } } pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -804,19 +783,19 @@ ivas_error ivas_jbm_dec_render( { int16_t n, nchan_out; int16_t nchan_transport; - float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ + float *p_output[MAX_OUTPUT_CHANNELS]; + float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis */ int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; +#ifndef FIX_764_HARM_CODE float pan_left, pan_right; +#endif int16_t nSamplesAskedLocal; ivas_error error; - float *p_output[MAX_OUTPUT_CHANNELS]; float *p_tc[MAX_TRANSPORT_CHANNELS]; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - error = IVAS_ERR_OK; - push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -830,7 +809,6 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; - for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { p_output[n] = &output[n][0]; @@ -849,8 +827,7 @@ ivas_error ivas_jbm_dec_render( * Combine orientations *----------------------------------------------------------------*/ - if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, - st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) { return error; } @@ -888,14 +865,19 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); +#ifdef FIX_764_HARM_CODE + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); +#else pan_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; pan_right = 1.f - pan_left; v_multc( p_tc[0], pan_right, output[1], *nSamplesRendered ); v_multc( p_tc[0], pan_left, output[0], *nSamplesRendered ); +#endif } else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* Convert CICP19 -> Ambisonics */ @@ -906,6 +888,7 @@ ivas_error ivas_jbm_dec_render( else /* ISM_MODE_DISC */ { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -914,10 +897,14 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { +#ifdef FIX_764_HARM_CODE + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); +#else pan_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; pan_right = 1.f - pan_left; v_multc( p_tc[0], pan_right, output[1], *nSamplesRendered ); v_multc( p_tc[0], pan_left, output[0], *nSamplesRendered ); +#endif } else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { @@ -935,8 +922,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, - NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -970,9 +956,7 @@ ivas_error ivas_jbm_dec_render( mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, - 0, - output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, 0, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } @@ -1028,21 +1012,12 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - crendInPlaceRotation ? p_output : p_tc, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -1060,6 +1035,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); } } @@ -1092,7 +1068,7 @@ ivas_error ivas_jbm_dec_render( { #ifdef SPLIT_REND_WITH_HEAD_ROT /*handled in CLDFB domain already*/ - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif { ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); @@ -1112,6 +1088,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); } } @@ -1131,6 +1108,7 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ { ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ @@ -1224,8 +1202,9 @@ ivas_error ivas_jbm_dec_render( } #endif *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; + pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -1260,8 +1239,6 @@ ivas_error ivas_jbm_dec_flush_renderer( float output[MAX_CICP_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; float *p_output[MAX_CICP_CHANNELS]; - error = IVAS_ERR_OK; - *nSamplesRendered = 0; hTcBuffer = st_ivas->hTcBuffer; @@ -1309,7 +1286,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Binaural rendering */ if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1320,6 +1297,7 @@ ivas_error ivas_jbm_dec_flush_renderer( set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, hTcBuffer->n_samples_granularity ); ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { @@ -1350,12 +1328,11 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } - ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } @@ -1378,7 +1355,7 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( st_ivas->nchan_ism > 0 ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1438,7 +1415,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } #endif - return error; + return IVAS_ERR_OK; } @@ -1453,9 +1430,6 @@ ivas_error ivas_jbm_dec_set_discard_samples( ) { int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; - ivas_error error; - - error = IVAS_ERR_OK; /* render first frame with front zero padding and discarding those samples */ nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; @@ -1467,7 +1441,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; } - return error; + return IVAS_ERR_OK; } @@ -1531,7 +1505,7 @@ void ivas_jbm_dec_get_adapted_subframes( uint16_t nCldfbSlotsLocal = nCldfbTs; /* 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) */ + in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); *nb_subframes = 0; if ( nSlotsInFirstSubframe > 0 ) @@ -1591,7 +1565,7 @@ void ivas_jbm_dec_get_md_map( } /* changed part (first segment), interpolate index to parameters - (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ + (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) { dec = ( (float) ( src_idx + 1 ) ) / ( (float) jbm_segment_len ); @@ -1617,6 +1591,7 @@ void ivas_jbm_dec_get_md_map( * * Get an meta data map adapted to a time scale modified IVAS frame. Distribute slots evenly across the modified frame. *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_md_map_even_spacing( const int16_t len, /* i : length of the modfied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ @@ -1669,6 +1644,8 @@ void ivas_jbm_dec_get_md_map_even_spacing( ++sf_idx; } } + + return; } @@ -1769,8 +1746,7 @@ int16_t ivas_jbm_dec_get_num_tc_channels( /* do all static dmx already in the TC decoder if less channels than transported... */ if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == AUDIO_CONFIG_FOA || st_ivas->intern_config == AUDIO_CONFIG_HOA2 || st_ivas->intern_config == AUDIO_CONFIG_HOA3 ) ) { - if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= - ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) + if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) { num_tc = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; } @@ -1872,11 +1848,12 @@ static void ivas_jbm_dec_copy_tc( * * *--------------------------------------------------------------------------*/ + /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ ) { @@ -1901,6 +1878,7 @@ int16_t ivas_jbm_dec_get_render_granularity( return render_granularity; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() * @@ -1918,13 +1896,10 @@ ivas_error ivas_jbm_dec_tc_buffer_open( { int16_t nsamp_to_allocate; DECODER_TC_BUFFER_HANDLE hTcBuffer; - ivas_error error; int16_t nMaxSlotsPerSubframe; int16_t nchan_residual; int16_t ch_idx; - error = IVAS_ERR_OK; - /*-----------------------------------------------------------------* * prepare library opening *-----------------------------------------------------------------*/ @@ -2017,7 +1992,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( st_ivas->hTcBuffer = hTcBuffer; - return error; + return IVAS_ERR_OK; } @@ -2036,13 +2011,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ) { - ivas_error error; int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; int16_t ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; - error = IVAS_ERR_OK; - hTcBuffer = st_ivas->hTcBuffer; /* if granularity changes, adapt subframe_nb_slots */ @@ -2126,7 +2098,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->tc[ch_idx] = NULL; } - return error; + return IVAS_ERR_OK; } @@ -2142,7 +2114,6 @@ static void ivas_jbm_dec_tc_buffer_playout( uint16_t *nSamplesRendered, float *output[] ) { - int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; slot_size = st_ivas->hTcBuffer->n_samples_granularity; @@ -2342,6 +2313,13 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( return buffer_mode; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_copy_tc_no_tsm() + * + * + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_copy_tc_no_tsm( Decoder_Struct *st_ivas, float *tc[], @@ -2408,6 +2386,8 @@ void ivas_jbm_dec_copy_tc_no_tsm( } hTcBuffer->n_samples_rendered = 0; hTcBuffer->subframes_rendered = 0; + + return; } @@ -2416,6 +2396,7 @@ void ivas_jbm_dec_copy_tc_no_tsm( * * Open structure for metadata buffering in JBM *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_metadata_open( Decoder_Struct *st_ivas ) { @@ -2442,6 +2423,7 @@ ivas_error ivas_jbm_dec_metadata_open( * * Copy decoded MASA metadata to a ring buffer *--------------------------------------------------------------------------*/ + static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ) { @@ -2475,6 +2457,8 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections; } + + return; } @@ -2483,6 +2467,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( * * Map input MASA metadata subframes to slots in JBM processing *--------------------------------------------------------------------------*/ + static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nCldfbTs /* i : number of CLDFB time slots */ @@ -2511,6 +2496,8 @@ static void ivas_jbm_masa_sf_to_slot_map( hJbmMetadata->sf_write_idx = ( hJbmMetadata->sf_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hJbmMetadata->sf_md_buffer_length; hJbmMetadata->slot_write_idx = ( hJbmMetadata->slot_write_idx + nCldfbTs ) % hJbmMetadata->slot_md_buffer_length; + + return; } @@ -2519,6 +2506,7 @@ static void ivas_jbm_masa_sf_to_slot_map( * * Map input MASA metadata subframes to output subframes in JBM processing *--------------------------------------------------------------------------*/ + void ivas_jbm_masa_sf_to_sf_map( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -2577,5 +2565,8 @@ void ivas_jbm_masa_sf_to_sf_map( break; } } + extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections; + + return; } diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 56c13adf3703a1de2de7688b9ee5388ecb73c50a..7ee5382408b715496c8102b70ccd5ca7e6fffd11 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -186,3 +186,28 @@ void ivas_mono_stereo_downmix_mcmasa( return; } + +#ifdef FIX_764_HARM_CODE +/*------------------------------------------------------------------------- + * ivas_apply_non_diegetic_panning() + * + * Apply non-diegetic panning + *------------------------------------------------------------------------*/ + +void ivas_apply_non_diegetic_panning( + float *output_f[], /* i/o: core-coder transport mono channel/stereo output */ + const float non_diegetic_pan_gain, /* i : non-diegetic panning gain */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + float pan_left, pan_right; + + pan_left = ( non_diegetic_pan_gain + 1.f ) * 0.5f; + pan_right = 1.f - pan_left; + + v_multc( output_f[0], pan_right, output_f[1], output_frame ); + v_multc( output_f[0], pan_left, output_f[0], output_frame ); + + return; +} +#endif