diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9eb1af512e5af4a474e88a0acc1b45ceaa8cf22f..80985de5ba8d506da82f5e9e2f8e0e5a1b4ff6d8 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -203,6 +203,7 @@ + @@ -220,7 +221,7 @@ - + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 85fd7e8d69d9525cb57f85116ec907fd107821c2..1f950d7318ef8d5571306b550060041a6d62ac68 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -469,6 +469,11 @@ common_ivas_c + + + + common_ivas_c + diff --git a/lib_com/ivas_osba_com.c b/lib_com/ivas_osba_com.c new file mode 100644 index 0000000000000000000000000000000000000000..ae89edcfc58213869f6b6dd8aaab0a684748a942 --- /dev/null +++ b/lib_com/ivas_osba_com.c @@ -0,0 +1,71 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include "ivas_cnst.h" +#include "ivas_prot.h" +#include "prot.h" +#include "ivas_rom_com.h" +#ifdef DEBUGGING +#include "debug.h" +#endif + +/*! r : ISM format mode */ +ISM_MODE ivas_osba_ism_mode_select( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t nchan_ism /* i : number of input ISM's */ +) +{ + ISM_MODE ism_mode = ISM_MODE_NONE; + + switch ( nchan_ism ) + { + case 1: + if ( ivas_total_brate >= IVAS_96k ) + { + ism_mode = ISM_SBA_MODE_DISC; + } + break; + + + case 2: + case 3: + case 4: + if ( ivas_total_brate >= IVAS_128k ) + { + ism_mode = ISM_SBA_MODE_DISC; + } + break; + } + + return ism_mode; +} diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2886480fffc0afa48bb1be1f2069e58061a75d85..470115c11e18154013b19a653f5b2599fb9fb61d 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5593,6 +5593,10 @@ void ivas_osba_data_close( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ ); +ISM_MODE ivas_osba_ism_mode_select( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t nchan_ism /* i : number of input ISM's */ +); /*----------------------------------------------------------------------------------* * OMASA prototypes diff --git a/lib_com/options.h b/lib_com/options.h index c71be15d676c5ac0e01b37da5efde6895540429a..d2c8114eb613c51a987df174a400fd759bb3cb55 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -182,6 +182,7 @@ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to actiate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on )*/ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ +#define NONBE_FIX_ISM_XOVER_BR /* FhG: issue 1072: select OSBA coding method depending on number of object and bitrate */ #define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nok: issue 1497 - porting OMASA EXT MR */ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index be20a65d1c1db18252cd29419320dc41ac431825..7a6db2376dfa5f1ff2c3ba329257724fd50ac2df 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -270,7 +270,11 @@ ivas_error ivas_corecoder_dec_reconfig( } else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) { +#ifdef NONBE_FIX_ISM_XOVER_BR + if ( ( error = mct_dec_reconfigure( st_ivas, nchan_transport_real != nchan_transport_old ) ) != IVAS_ERR_OK ) +#else if ( ( error = mct_dec_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -351,7 +355,11 @@ ivas_error ivas_corecoder_dec_reconfig( * Set CNA/CNG flags *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISM_XOVER_BR + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) +#endif { ivas_sba_set_cna_cng_flag( st_ivas ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c7df954dbc461bb37da1e889df151e97725e0761..81be8626f3ac3808b3d1866831f7c8931ee73be2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -462,12 +462,25 @@ ivas_error ivas_dec_setup( /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#ifdef NONBE_FIX_ISM_XOVER_BR + { + int16_t n; + + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( n + 1 ) >> 1; + } +#else { st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; } +#endif } +#ifdef NONBE_FIX_ISM_XOVER_BR + if ( ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ) == ISM_SBA_MODE_DISC ) +#else if ( ivas_total_brate >= IVAS_256k ) +#endif { st_ivas->ism_mode = ISM_SBA_MODE_DISC; } @@ -1545,7 +1558,16 @@ ivas_error ivas_init_decoder( if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef NONBE_FIX_ISM_XOVER_BR + { + int16_t n_all; + + n_all = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( n_all + 1 ) >> 1; + } +#else st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; +#endif st_ivas->element_mode_init = IVAS_CPE_MDCT; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index e3d4919ba14236b44d6f60b03a396cb1c9b3195d..535f1edb211d9e8ee2f194acfed001bbd8466f7a 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -153,6 +153,10 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( return error; } +#ifdef NONBE_FIX_ISM_XOVER_BR + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 75c97527b6345358da13822949d1c73f73dbc09c..7d01fabe9fdc885c69762d4cf2719054276b26e1 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -70,7 +70,11 @@ void ivas_sba_set_cna_cng_flag( st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1; st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1; } +#ifdef NONBE_FIX_ISM_XOVER_BR + else if ( st_ivas->nchan_transport == 2 && st_ivas->ivas_format != SBA_ISM_FORMAT ) +#else else if ( st_ivas->nchan_transport == 2 ) +#endif { for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -120,6 +124,9 @@ ivas_error ivas_sba_dec_reconfigure( ivas_error error; ISM_MODE ism_mode_old; int16_t granularity_new; +#ifdef NONBE_FIX_ISM_XOVER_BR + int16_t nchan_transport; +#endif ism_mode_old = st_ivas->ism_mode; hDecoderConfig = st_ivas->hDecoderConfig; @@ -139,7 +146,11 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifdef NONBE_FIX_ISM_XOVER_BR + if ( ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ) == ISM_SBA_MODE_DISC ) +#else if ( ivas_total_brate >= IVAS_256k ) +#endif { st_ivas->ism_mode = ISM_SBA_MODE_DISC; } @@ -433,6 +444,9 @@ ivas_error ivas_sba_dec_reconfigure( * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport = st_ivas->nchan_transport; +#endif if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -501,7 +515,12 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport += st_ivas->nchan_ism; + st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; +#else st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; +#endif } else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) { @@ -515,15 +534,24 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); } +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport = st_ivas->nchan_transport; +#endif nchan_transport_old += st_ivas->nchan_ism; st_ivas->ism_mode = ISM_MODE_NONE; } else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; + nchan_transport_old += st_ivas->nchan_ism; +#else st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; nchan_transport_old += st_ivas->nchan_ism; +#endif } } diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index b5339333d3156033315946605994d27c7b5d611a..48c37b0d6ed0454b0a397a49daf9116398a28e92 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -458,7 +458,12 @@ ivas_error ivas_corecoder_enc_reconfig( } else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) { + +#ifdef NONBE_FIX_ISM_XOVER_BR + if ( ( error = mct_enc_reconfigure( st_ivas, nchan_transport_old_real != nchan_transport_real ) ) != IVAS_ERR_OK ) +#else if ( ( error = mct_enc_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 6f2672cfc8ef9fcb6e7a821ec00342b0986742f6..8dede71f3f6618a3e80c6f655b2e383c00689f1f 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -686,10 +686,14 @@ ivas_error ivas_init_encoder( { st_ivas->ism_mode = ISM_MODE_NONE; +#ifdef NONBE_FIX_ISM_XOVER_BR + st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism ); +#else if ( ivas_total_brate >= IVAS_256k ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; } +#endif if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) { @@ -744,7 +748,16 @@ ivas_error ivas_init_encoder( else { /* allocate and initialize MCT core coder */ +#ifdef NONBE_FIX_ISM_XOVER_BR + { + int16_t n_all; + + n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( n_all + 1 ) >> 1; + } +#else st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; +#endif for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 5def5e5a4bccd30ee0a2277b61a84aab24c08a85..4e6b4dde6eb7f0c24d8adfd6d7cf7da76b2a259b 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -185,6 +185,10 @@ ivas_error ivas_osba_enc_reconfig( error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; +#ifdef NONBE_FIX_ISM_XOVER_BR + int16_t nchan_transport; +#endif + if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) { @@ -197,6 +201,9 @@ ivas_error ivas_osba_enc_reconfig( spar_reconfig_flag = 0; old_ism_mode = st_ivas->ism_mode; +#ifdef NONBE_FIX_ISM_XOVER_BR + st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism ); +#else if ( ivas_total_brate >= IVAS_256k ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; @@ -205,9 +212,11 @@ ivas_error ivas_osba_enc_reconfig( { st_ivas->ism_mode = ISM_MODE_NONE; } +#endif nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands; @@ -333,21 +342,42 @@ ivas_error ivas_osba_enc_reconfig( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport = st_ivas->nchan_transport; +#endif if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef NONBE_FIX_ISM_XOVER_BR + { + nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; + } +#else st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; +#endif } else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) { + nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; + +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport = st_ivas->nchan_transport; +#endif } else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef NONBE_FIX_ISM_XOVER_BR + nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; + nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; +#else st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; +#endif } if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ) ) != IVAS_ERR_OK )