From 813a903c7fe066e57712e6093529cc7528956065 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 4 Sep 2023 20:21:26 +0200 Subject: [PATCH 1/6] - issue 764: output buffers harmonization - introduce new function for the same code block at four different places; under FIX_764_HARM_CODE --- lib_com/ivas_prot.h | 8 + lib_com/options.h | 2 + lib_dec/ivas_dec.c | 249 +++++++++++++-------------- lib_dec/ivas_jbm_dec.c | 279 ++++++++++++++++--------------- lib_dec/ivas_mono_dmx_renderer.c | 25 +++ 5 files changed, 298 insertions(+), 265 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6893be758d..e4ca1bb93a 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 d945683e41..c75dcb0287 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,8 @@ #define OSBA_SPLIT_RENDERING #endif +#define FIX_764_HARM_CODE /* A: issue 764: introduce new function for the same code block at four different places */ + /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 8d41109c07..777c3e86dc 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -62,15 +62,16 @@ 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 @@ -95,11 +96,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 +109,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 +132,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 +152,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 +160,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 +180,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 +189,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 +207,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 +223,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 +260,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 ) { @@ -306,9 +312,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 +362,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 +405,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 +426,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 +522,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 +550,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 +578,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 +617,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 +625,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 +633,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 +641,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 +677,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 +766,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 ); } } } @@ -789,12 +783,12 @@ ivas_error ivas_dec( /* 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] ); + 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 +798,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 +823,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 @@ -880,16 +873,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 +891,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 ); } } } @@ -912,7 +905,7 @@ ivas_error ivas_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { #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 { ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); @@ -920,7 +913,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 ); } @@ -964,14 +957,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; } @@ -980,7 +973,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 */ @@ -1009,7 +1002,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; } @@ -1018,7 +1011,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; } @@ -1028,26 +1021,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; } @@ -1056,25 +1049,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 ) { @@ -1084,13 +1075,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 ); } } } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1fe58874a0..bd21d2edd5 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,16 +150,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; } @@ -169,22 +165,22 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - 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 ); } 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 ) @@ -201,7 +197,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 ); } @@ -222,21 +218,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; } @@ -254,19 +250,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 ) ) ) { @@ -277,32 +271,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 ) @@ -346,34 +341,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 ) @@ -381,16 +376,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 ); } @@ -407,12 +393,12 @@ ivas_error ivas_jbm_dec_tc( 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] ); + 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; } @@ -422,14 +408,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 ) ) { ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); } @@ -449,11 +434,11 @@ 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] ); + 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; } @@ -468,7 +453,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 ); @@ -482,14 +467,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; } @@ -498,7 +483,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 */ @@ -523,7 +508,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; } @@ -532,7 +517,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; } @@ -542,26 +527,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; } @@ -570,39 +555,39 @@ 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 ); + ivas_mono_stereo_downmix_mcmasa( st_ivas, p_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_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; } } } - /*----------------------------------------------------------------* * 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 ); @@ -645,7 +630,7 @@ ivas_error ivas_jbm_dec_tc( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -662,21 +647,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 ); @@ -690,6 +672,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 ); @@ -707,6 +690,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 ) @@ -721,7 +705,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 ) { @@ -729,7 +716,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 ) { @@ -752,13 +743,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; } @@ -783,19 +777,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" ); /*----------------------------------------------------------------* @@ -809,7 +803,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]; @@ -828,8 +821,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; } @@ -867,14 +859,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 */ @@ -885,6 +882,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 ) { @@ -893,10 +891,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 ) { @@ -914,8 +916,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; } @@ -949,9 +950,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; } @@ -1007,21 +1006,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 ) @@ -1039,6 +1029,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); } } @@ -1071,7 +1062,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 ); @@ -1091,6 +1082,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); } } @@ -1110,6 +1102,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 */ @@ -1203,8 +1196,9 @@ ivas_error ivas_jbm_dec_render( } #endif *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; + pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -1239,8 +1233,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; @@ -1288,7 +1280,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; } @@ -1299,6 +1291,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 ) { @@ -1329,7 +1322,7 @@ 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; } @@ -1357,7 +1350,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; } @@ -1417,7 +1410,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } #endif - return error; + return IVAS_ERR_OK; } @@ -1432,9 +1425,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; @@ -1446,7 +1436,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; } @@ -1510,7 +1500,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 ) @@ -1570,7 +1560,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 ); @@ -1596,6 +1586,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 */ @@ -1648,6 +1639,8 @@ void ivas_jbm_dec_get_md_map_even_spacing( ++sf_idx; } } + + return; } @@ -1748,8 +1741,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; } @@ -1851,11 +1843,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 */ ) { @@ -1880,6 +1873,7 @@ int16_t ivas_jbm_dec_get_render_granularity( return render_granularity; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() * @@ -1897,13 +1891,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 *-----------------------------------------------------------------*/ @@ -1996,7 +1987,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( st_ivas->hTcBuffer = hTcBuffer; - return error; + return IVAS_ERR_OK; } @@ -2015,13 +2006,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 */ @@ -2105,7 +2093,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->tc[ch_idx] = NULL; } - return error; + return IVAS_ERR_OK; } @@ -2121,7 +2109,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; @@ -2321,6 +2308,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[], @@ -2387,6 +2381,8 @@ void ivas_jbm_dec_copy_tc_no_tsm( } hTcBuffer->n_samples_rendered = 0; hTcBuffer->subframes_rendered = 0; + + return; } @@ -2395,6 +2391,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 ) { @@ -2421,6 +2418,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 ) { @@ -2454,6 +2452,8 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections; } + + return; } @@ -2462,6 +2462,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 */ @@ -2490,6 +2491,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; } @@ -2498,6 +2501,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 */ ) @@ -2556,5 +2560,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 56c13adf37..7ee5382408 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 -- GitLab From 85ca6af84406b10f4c6526c8c1d4e3c9656fb4ad Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 4 Sep 2023 20:36:20 +0200 Subject: [PATCH 2/6] fix SR build --- lib_dec/ivas_dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 777c3e86dc..9cf5a4c0f3 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -294,7 +294,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; } @@ -852,7 +852,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; } @@ -931,7 +931,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; } -- GitLab From d13327e9d9f4da88d3adcd1b0a16d389a2bc42ee Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Sep 2023 16:31:43 +0200 Subject: [PATCH 3/6] remove unnecessary condition --- lib_dec/ivas_dec.c | 5 +---- lib_dec/ivas_jbm_dec.c | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 1425ceb670..f1429f9c94 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -777,14 +777,11 @@ 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 ) { + /* 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, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ecc137b78d..2ee638b42e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -406,7 +406,6 @@ 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 ) // ToDo: this is missing in ivas_dec() -> TBV @@ -414,11 +413,9 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg; } + /* 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, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; @@ -455,6 +452,7 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { + /* 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] ); -- GitLab From b36f5f6e92020f807183fa4ed10c45ce66333c2b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Sep 2023 16:34:16 +0200 Subject: [PATCH 4/6] remove dead code for MC_MODE_PARAMUPMIX branch --- lib_dec/ivas_jbm_dec.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2ee638b42e..5cb8912bec 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -588,19 +588,6 @@ ivas_error ivas_jbm_dec_tc( ivas_mono_stereo_downmix_mcmasa( st_ivas, p_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, 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, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } } /*----------------------------------------------------------------* -- GitLab From 0fff3dd3b572a2cf1eabcc8b35bcd9a0cd0bf417 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Sep 2023 16:36:02 +0200 Subject: [PATCH 5/6] correct check against NULL --- lib_dec/ivas_jbm_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5cb8912bec..764392921e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -331,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 ) -- GitLab From 99f4eeb842e5cca6861012bfb2303738fc4c54e5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Sep 2023 16:51:20 +0200 Subject: [PATCH 6/6] remove comment --- lib_dec/ivas_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index f1429f9c94..5605cb09fd 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -917,7 +917,7 @@ ivas_error ivas_dec( } else { - ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, output_frame, p_output, p_output ); // ToDo: this is missing in ivas_jbm_dec() + ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, output_frame, p_output, p_output ); } } else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) -- GitLab