diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index d627c3e216ec435c48e177ec49b303e2bef9e09e..ff41d4f9c4589b68431da01ff0a2505cc5aa515e 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -293,6 +293,7 @@
+
@@ -407,4 +408,4 @@
-
\ No newline at end of file
+
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index d7893509f0d9dd035526a5802986820d691abefd..82f949db7889bd6c187294d75159e533348974b6 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -515,6 +515,7 @@
dec_ivas_c
+
dec_ivas_c
@@ -572,4 +573,4 @@
{e4a97be1-bcf8-43d3-b941-594f39f2d41b}
-
\ No newline at end of file
+
diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj
index e13746ea0e9953776662e1f337f5fb8c80e58a4c..c38a0e1e1a3bbbea206ef648e2c5682cc84f04fc 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -215,6 +215,7 @@
+
@@ -426,4 +427,4 @@
-
\ No newline at end of file
+
diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters
index c2b2c275b959eb14bb0e7239dd651ebeb5e2fe90..b15d61431f876896a9325af8c3b270dce4f76ea2 100644
--- a/Workspace_msvc/lib_enc.vcxproj.filters
+++ b/Workspace_msvc/lib_enc.vcxproj.filters
@@ -590,6 +590,7 @@
enc_ivas_c
+
enc_ivas_c
@@ -623,4 +624,4 @@
{6cccabbe-510f-43d3-90e1-8ed5ea3837d7}
-
\ No newline at end of file
+
diff --git a/apps/decoder.c b/apps/decoder.c
index 4e59e521cf00b3ea98fd26f01c665763c04bfd3b..c658acff9f72c57345da4aea9e579a5f2962e512 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -80,8 +80,12 @@ static
#else
#define MAX_FRAME_SIZE ( 48000 / 50 )
#endif
-#define MAX_NUM_OUTPUT_CHANNELS 16
+#define MAX_NUM_OUTPUT_CHANNELS 16
+#ifdef SBA_AND_OBJECTS
+#define MAX_OUTPUT_PCM_BUFFER_SIZE ( ( MAX_NUM_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) * MAX_FRAME_SIZE )
+#else
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE )
+#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
#define MAX_SPLIT_REND_BITRATE ( 768000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ? */
#define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / NUM_FRAMES_PER_SEC ) + 7 ) >> 3 )
@@ -1756,10 +1760,14 @@ static ivas_error initOnFirstGoodFrame(
fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error );
return error;
}
-
/* If outputting ISM, get number of objects, open output files and write zero metadata for initial bad frames */
#ifdef MASA_AND_OBJECTS
- if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM )
+ if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM
+#ifdef SBA_AND_OBJECTS
+
+ || *pBsFormat == IVAS_DEC_BS_SBA_ISM
+#endif
+ )
#else
if ( *pBsFormat == IVAS_DEC_BS_OBJ )
#endif
@@ -2014,6 +2022,9 @@ static ivas_error decodeG192(
Quaternions[i].x = 0.0f;
Quaternions[i].y = 0.0f;
Quaternions[i].z = 0.0f;
+ Pos[i].x = 0.0f;
+ Pos[i].y = 0.0f;
+ Pos[i].z = 0.0f;
}
}
else
@@ -2171,7 +2182,11 @@ static ivas_error decodeG192(
if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT )
{
#ifdef MASA_AND_OBJECTS
- if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM )
+ if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM
+#ifdef SBA_AND_OBJECTS
+ || bsFormat == IVAS_DEC_BS_SBA_ISM
+#endif
+ )
#else
if ( bsFormat == IVAS_DEC_BS_OBJ )
#endif
diff --git a/apps/encoder.c b/apps/encoder.c
index 672b3f55eddc5b16c7c7186aaf71015b0ce1e08f..4fa2b9a75020312e0d2b1daf227700560f67d3cc 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -98,6 +98,16 @@ typedef union _EncInputFormatConfig
} masa_ism;
#endif
+#ifdef SBA_AND_OBJECTS
+ struct EncSbaIsmConfig
+ {
+ int16_t numObjects;
+ const char *metadataFiles[IVAS_MAX_NUM_OBJECTS];
+ IVAS_ENC_SBA_ORDER order;
+ bool isPlanar;
+ } sba_ism;
+#endif
+
} EncInputFormatConfig;
/* Struct for storing cmdln arguments */
@@ -242,7 +252,11 @@ int main(
* Print out file names
*------------------------------------------------------------------------------------------*/
+#ifdef SBA_AND_OBJECTS
+ if ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM )
+#else
if ( arg.inputFormat == IVAS_ENC_INPUT_ISM )
+#endif
{
for ( i = 0; i < arg.inputFormatConfig.ism.numObjects; i++ )
{
@@ -436,6 +450,17 @@ int main(
goto cleanup;
}
break;
+
+#ifdef SBA_AND_OBJECTS
+ case IVAS_ENC_INPUT_SBA_ISM:
+ if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
+ exit( -1 );
+ }
+ break;
+#endif
+
#ifdef MASA_AND_OBJECTS
case IVAS_ENC_INPUT_MASA_ISM:
if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK )
@@ -445,6 +470,7 @@ int main(
}
break;
#endif
+
default:
fprintf( stderr, "\nInvalid input type\n\n" );
goto cleanup;
@@ -530,7 +556,13 @@ int main(
}
#ifdef MASA_AND_OBJECTS
- const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM ) ? arg.inputFormatConfig.ism.numObjects : 0;
+ const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM
+#ifdef SBA_AND_OBJECTS
+ || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM
+#endif
+ )
+ ? arg.inputFormatConfig.ism.numObjects
+ : 0;
#else
const int16_t numIsmInputs = arg.inputFormat == IVAS_ENC_INPUT_ISM ? arg.inputFormatConfig.ism.numObjects : 0;
#endif
@@ -1606,6 +1638,98 @@ static bool parseCmdlIVAS_enc(
}
}
#endif
+
+#ifdef SBA_AND_OBJECTS
+ else if ( strcmp( to_upper( argv[i] ), "-ISM_SBA" ) == 0 )
+ {
+ arg->inputFormat = IVAS_ENC_INPUT_SBA_ISM;
+ i++;
+
+ if ( i < argc - 5 )
+ {
+ if ( sscanf( argv[i], "%d", &tmp ) > 0 )
+ {
+ i++;
+ }
+
+ if ( tmp <= 0 )
+ {
+ fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" );
+ usage_enc();
+ }
+ else
+ {
+ if ( tmp <= IVAS_MAX_NUM_OBJECTS ) /* number of ISM channels */
+ {
+ arg->inputFormatConfig.sba_ism.numObjects = (int16_t) tmp;
+ }
+ else
+ {
+ fprintf( stderr, "Error: Too high number of ISM channels!\n\n" );
+ usage_enc();
+ }
+ }
+ }
+ else
+ {
+ fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" );
+ usage_enc();
+ }
+
+ if ( i < argc - 4 )
+ {
+ if ( sscanf( argv[i], "%d", &tmp ) > 0 )
+ {
+ i++;
+ }
+
+ arg->inputFormatConfig.sba_ism.isPlanar = ( tmp < 0 );
+
+ tmp = abs( tmp );
+ switch ( tmp )
+ {
+ case 1:
+ arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_FOA;
+ break;
+ case 2:
+ arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA2;
+ break;
+ case 3:
+ arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA3;
+ break;
+ default:
+ fprintf( stderr, "Error: Wrong SBA order specified!\n\n" );
+ usage_enc();
+ return false;
+ }
+ }
+
+ /* read input metadata files */
+ for ( j = 0; j < arg->inputFormatConfig.sba_ism.numObjects; j++ )
+ {
+ if ( i < argc - 4 )
+ {
+ if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 )
+ {
+ /* no metadata input file -> encode only audio streams */
+ arg->inputFormatConfig.sba_ism.metadataFiles[j] = NULL;
+ }
+ else
+ {
+ arg->inputFormatConfig.sba_ism.metadataFiles[j] = argv[i];
+ }
+
+ i++;
+ }
+ else
+ {
+ fprintf( stderr, "Error: not enough arguments\n\n" );
+ usage_enc();
+ }
+ }
+ }
+#endif
+
else if ( strcmp( argv_to_upper, "-STEREO_DMX_EVS" ) == 0 )
{
arg->inputFormat = IVAS_ENC_INPUT_MONO;
@@ -1787,6 +1911,10 @@ static void usage_enc( void )
fprintf( stdout, " for 4 ISM also 512000 \n" );
fprintf( stdout, " for IVAS SBA, MASA, MC R=(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" );
fprintf( stdout, " 96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" );
+#ifdef SBA_AND_OBJECTS
+ fprintf( stdout, " for IVAS objects-SBA R =(13200, 16400, 24400, 32000, 48000, 64000, 96000, 128000, \n" );
+ fprintf( stdout, " 160000, 192000, 256000, 384000, 512000)\n" );
+#endif
#ifdef MASA_AND_OBJECTS
fprintf( stdout, " for IVAS objects-MASA R =(13200, 16400, 24400, 32000, 48000, 64000, 96000, 128000, \n" );
fprintf( stdout, " 160000, 192000, 256000, 384000, 512000)\n" );
@@ -1814,6 +1942,12 @@ static void usage_enc( void )
fprintf( stdout, "-masa Ch File : MASA format \n" );
fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" );
fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" );
+#ifdef SBA_AND_OBJECTS
+ fprintf( stdout, "-ism_sba IsmChannels SBAorder IsmFiles : SBA and ISM format \n" );
+ fprintf( stdout, " where IsmChannels specifies the number of ISms (1-4)\n" );
+ fprintf( stdout, " and SBAorder specifies the SBA order (1 to 3) \n" );
+ fprintf( stdout, " and IsmFiles specify input files containing metadata, one file per object \n" );
+#endif
#ifdef MASA_AND_OBJECTS
fprintf( stdout, "-ism_masa IsmCh MasaCh IsmFiles MasaFile : MASA and ISM format \n" );
fprintf( stdout, " where IsmCh specifies the number of ISMs (1-4),\n" );
diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c
index ce0a9be3793c5127300c6401def440e407e27fe2..7bf6b844053b366e6d48a81e3e7aa1880a0cd504 100644
--- a/lib_com/bitstream.c
+++ b/lib_com/bitstream.c
@@ -446,7 +446,11 @@ int16_t get_ivas_max_num_indices(
return 1650;
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
else if ( ivas_format == SBA_FORMAT )
+#endif
{
if ( ivas_total_brate <= IVAS_16k4 )
{
@@ -867,7 +871,11 @@ int16_t get_ivas_max_num_indices_metadata(
return 80;
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
else if ( ivas_format == SBA_FORMAT )
+#endif
{
if ( ivas_total_brate <= IVAS_16k4 )
{
@@ -2806,14 +2814,18 @@ ivas_error preview_indices(
{
if ( bit_stream[2] )
{
-#ifdef MASA_AND_OBJECTS
+#if defined MASA_AND_OBJECTS || defined SBA_AND_OBJECTS
if ( bit_stream[3] )
{
- /* Placeholder for SBA + objects */
+#ifdef SBA_AND_OBJECTS
+ st_ivas->ivas_format = SBA_ISM_FORMAT;
+#endif
}
else
{
+#ifdef MASA_AND_OBJECTS
st_ivas->ivas_format = MASA_ISM_FORMAT;
+#endif
}
#else
/* placeholder for combined format signaling */
@@ -2982,6 +2994,34 @@ ivas_error preview_indices(
ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ /* read number of objects from the bitstream */
+ if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA )
+ {
+ st_ivas->nchan_ism = 2 * bit_stream[total_brate / FRAMES_PER_SEC - 1] + bit_stream[total_brate / FRAMES_PER_SEC - 2] + 1;
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ }
+
+ /* Read SBA planar flag and SBA order */
+ st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS] == 1 );
+
+ if ( total_brate > IVAS_256k )
+ {
+ st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 2] == 1 );
+ st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 1] == 1 );
+ }
+ else
+ {
+ st_ivas->sba_order = 3;
+ }
+
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order );
+
+ ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) );
+ }
+#endif
#ifdef MASA_AND_OBJECTS
else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
{
diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c
index 74ae97311e6aafde538db09657d4ce976870f4b5..0d08f64fd1296c562cc4a4bda6ca7c65a42ec9aa 100644
--- a/lib_com/delay_comp.c
+++ b/lib_com/delay_comp.c
@@ -82,8 +82,11 @@ int32_t get_delay(
delay = 0; /* All delay is compensated in the decoder with MASA */
}
}
-
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
if ( ivas_format == SBA_FORMAT )
+#endif
{
/* compensate for DirAC/SPAR filterbank delay */
delay += IVAS_FB_ENC_DELAY_NS;
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
old mode 100644
new mode 100755
index a6ad6440c93cd4af2a67e6f55affcccaf2d1cb9a..6d986b520bc56ff148dab958057e7edc678a5779
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -72,6 +72,9 @@ typedef enum
#ifdef MASA_AND_OBJECTS
MASA_ISM_FORMAT, /* IVAS combined MASA + objects format*/
#endif
+#ifdef SBA_AND_OBJECTS
+ SBA_ISM_FORMAT /* IVAS combined SBA + objects format */
+#endif
} IVAS_FORMAT;
@@ -81,7 +84,7 @@ typedef enum
#define IVAS_FORMAT_SIGNALING_NBITS 2 /* number of bits for signaling the IVAS format */
#define IVAS_FORMAT_SIGNALING_NBITS_EXTENDED ( IVAS_FORMAT_SIGNALING_NBITS + 1 )
-#ifdef MASA_AND_OBJECTS
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
#define IVAS_COMBINED_FORMAT_SIGNALLING_BITS 1
#endif
@@ -162,7 +165,15 @@ typedef enum
RENDERER_BINAURAL_MIXER_CONV,
RENDERER_BINAURAL_MIXER_CONV_ROOM,
RENDERER_NON_DIEGETIC_DOWNMIX
-
+#ifdef SBA_AND_OBJECTS
+ , RENDERER_OSBA_STEREO
+#endif
+#ifdef SBA_AND_OBJECTS
+ , RENDERER_OSBA_AMBI
+#endif
+#ifdef SBA_AND_OBJECTS
+ , RENDERER_OSBA_LS
+#endif
} RENDERER_TYPE;
/*----------------------------------------------------------------------------------*
@@ -418,7 +429,10 @@ typedef enum
ISM_MASA_MODE_PARAM_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using parametric object model */
ISM_MASA_MODE_DISC /* MASA ISM mode when all objects are encoded separarately */
#endif
-
+#ifdef SBA_AND_OBJECTS
+ ,
+ ISM_SBA_MODE_DISC /* MASA ISM mode when all objects are encoded separarately */
+#endif
} ISM_MODE;
@@ -1294,6 +1308,9 @@ typedef enum
MASA_FRAME_4SF
} MASA_FRAME_MODE;
+#ifdef SBA_AND_OBJECTS
+#define NO_BITS_MASA_ISM_NO_OBJ 2
+#endif
/*----------------------------------------------------------------------------------*
* Multichannel format
*----------------------------------------------------------------------------------*/
diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c
index 35fadda7092206763a0a4accff2038ad88d83764..05b2886231044c1c57e020f366c9d437eaa330dc 100644
--- a/lib_com/ivas_dirac_com.c
+++ b/lib_com/ivas_dirac_com.c
@@ -156,7 +156,11 @@ ivas_error ivas_dirac_config(
#endif
}
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
if ( ivas_format == SBA_FORMAT )
+#endif
{
hConfig->nbands = IVAS_MAX_NUM_BANDS;
@@ -174,7 +178,11 @@ ivas_error ivas_dirac_config(
}
hConfig->enc_param_start_band = 0;
hConfig->dec_param_estim = FALSE;
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) /* skip for MASA decoder */
+#else
if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */
+#endif
{
if ( ( error = ivas_dirac_sba_config( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
{
@@ -183,7 +191,11 @@ ivas_error ivas_dirac_config(
if ( hQMetaData != NULL )
{
+#ifdef SBA_AND_OBJECTS
+ if ( enc_dec == ENC || ( ivas_format != SBA_FORMAT && ivas_format != SBA_ISM_FORMAT ) ) /* Todo: This condition should probably be corrected in main */
+#else
if ( enc_dec == ENC || ivas_format != SBA_FORMAT )
+#endif
{
hConfig->nbands = hQMetaData->q_direction[0].cfg.nbands;
}
@@ -206,7 +218,11 @@ ivas_error ivas_dirac_config(
}
}
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
if ( ivas_format == SBA_FORMAT )
+#endif
{
ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft );
}
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
old mode 100644
new mode 100755
index 98229a668d8e11f1b576e22ad1a41182f48d932c..f029892be9154614c52b3be72a59d88221acd78f
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -1015,6 +1015,10 @@ ivas_error ivas_ism_metadata_enc(
const int16_t flag_omasa_ener_brate, /* i : less bitrate for objects in OMASA flag */
int16_t *omasa_stereo_sw_cnt
#endif
+#ifdef SBA_AND_OBJECTS
+ ,
+ const int16_t ini_frame
+#endif
);
ivas_error ivas_ism_metadata_dec(
@@ -1030,6 +1034,9 @@ ivas_error ivas_ism_metadata_dec(
const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */
int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */
int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */
+#ifdef SBA_AND_OBJECTS
+ , DEC_CORE_HANDLE st0
+#endif
);
@@ -3668,6 +3675,9 @@ void ivas_dirac_dec_read_BS(
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */
int16_t *nb_bits, /* o : number of bits read */
+#ifdef SBA_AND_OBJECTS
+ const int16_t last_bit_pos, /* i : last read bitstream position*/
+#endif
const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */
int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
);
@@ -4156,6 +4166,9 @@ ivas_error ivas_sba_linear_renderer(
float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
const int16_t output_frame, /* i : output frame length per channel */
const int16_t nchan_in, /* i : number of input ambisonics channels */
+#ifdef SBA_AND_OBJECTS
+ const int16_t nchan_ism,
+#endif
const AUDIO_CONFIG output_config, /* i : output audio configuration */
const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */
const float hoa_dec_mtx[] /* i : HOA decoding mtx */
@@ -5710,6 +5723,70 @@ void ivas_filter_process(
const int16_t length /* i : filter order */
);
+#ifdef SBA_AND_OBJECTS
+ivas_error ivas_osba_enc_open(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+);
+
+void ivas_osba_enc_close(
+ OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */
+);
+
+ivas_error ivas_osba_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+);
+
+void ivas_osba_enc(
+ OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */
+ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */
+ float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */
+ const int16_t input_frame, /* i : Input frame size */
+ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */
+ const ISM_MODE ism_mode, /* i : ISM mode */
+ const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */
+#ifdef SBA_AND_OBJECTS
+ , const int32_t input_Fs /* i : input sampling rate*/
+#endif
+);
+#ifdef SBA_AND_OBJECTS
+ivas_error ivas_masa_ism_data_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
+);
+ivas_error ivas_sba_ism_separate_object_renderer_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_osba_dirac_td_binaural(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output[][L_FRAME48k], /* o : output synthesis signal */
+ const int16_t output_frame /* i : output frame length per channel */
+);
+
+ivas_error ivas_osba_ism_metadata_dec(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const int32_t ism_total_brate, /* i : ISM total bitrate */
+ int16_t *nchan_ism, /* o : number of ISM separated channels */
+ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */
+);
+
+/*-------------------------------------------------------------------------*
+ * ivas_osba_render()
+ *
+ * Object + SBA rendering process.
+ *-------------------------------------------------------------------------*/
+
+void ivas_osba_render(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */
+ const int16_t output_frame /* i : output frame length per channel */
+);
+
+void ivas_masa_ism_data_close(
+ MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */
+);
+#endif
+#endif
+
#ifdef MASA_AND_OBJECTS
/*----------------------------------------------------------------------------------*
diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c
index a1af629f0c062190264ecd864254ae5fde057a97..e0dd9f5cff59a2169a5604a766262fdbcd78ee3b 100644
--- a/lib_com/ivas_td_decorr.c
+++ b/lib_com/ivas_td_decorr.c
@@ -118,7 +118,11 @@ ivas_error ivas_td_decorr_reconfig_dec(
ivas_error error;
useTdDecorr_new = 0;
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
if ( ivas_format == SBA_FORMAT )
+#endif
{
if ( nchan_transport == 1 )
{
@@ -146,7 +150,11 @@ ivas_error ivas_td_decorr_reconfig_dec(
if ( *useTdDecorr )
{
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_total_brate >= IVAS_13k2 && ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) )
+#else
if ( ivas_total_brate >= IVAS_13k2 && ivas_format == SBA_FORMAT )
+#endif
{
if ( *hTdDecorr == NULL )
{
diff --git a/lib_com/options.h b/lib_com/options.h
index 5774d4a8b2b4511b47b2e6db23ab28b7914e776a..cd53058025258d67a04c8d58e70bfed58332537e 100755
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -124,6 +124,7 @@
/*#define DEBUG_AGC*/ /* debug SPAR AGC in-out */
#endif
/*#define SPAR_HOA_DBG*/ /* SPAR HOA debug statements */
+/* #define DEBUG_OSBA */
/*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */
/*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */
#define DEBUG_JBM_CMD_OPTION /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */
@@ -204,7 +205,6 @@
#define FIX_619_ADD_UNDEF_VAL_FOR_CONCEALMENT_MODE /* FhG: fix usan error */
#define FIX_622_SILENCE_USAN_WARNING /* FhG: silenceusan warning in ifft code */
-
#define FIX_615_UBSAN_SPAR_TO_DIRAC /*Dlb : Fix for UBSAN issue 615*/
#define FIX_624_PLANAR_SBA_WB /*Dlb : Fix for unintialised value issue 624 */
@@ -222,10 +222,18 @@
#define FIX_647_SILENT_W_PARAMBIN /* Nokia: Issue #647: Fix silent W SH inputs in parametric binauralizer */
#define MASA_AND_OBJECTS /* Nokia: Combination of MASA and objects */
+
+#define SBA_AND_OBJECTS
+#ifdef SBA_AND_OBJECTS
+#define OSBA_BR_SWITCHING
+#define OSBA_SPLIT_RENDERING
+#endif
+
#define TD_REND_TUNING_RENAME /* Eri: Tuning of TD renderer model as part of contribution 25 and renaming for default HRIR set */
-#define FIX_SBA_VANISHING_RESIDUAL /*Dlb : Fix for vanishing residual cases when W channel is 0*/
+#define FIX_SBA_VANISHING_RESIDUAL /*Dlb : Fix for vanishing residual cases when W channel is 0*/
#define FIX_527_SBA_MONO_INPUT /* Dlb : Fix for mono content in a HOA input format */
+
#define FIX_653_BUG_IN_SKIP_MATRIX /* Dlb: fix for issue #653, bug in the ivas_spar_get_skip_mat function*/
#define FIX_663_PARAM_ISM_EXT /* FhG: Issue 663: ParamISM EXT output improvement */
#define FIX_673_OMASA_OBJ_MD_SYNC /* Nokia: Fix issue 673 by updating metadata in the third subframe to account for audio delay. */
diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c
old mode 100644
new mode 100755
index 95c7f19e60ca338f303cfbaa71c78f422aa10f57..dc2a4f9a0a7bab8c32b97a12ddd82ff138374cd6
--- a/lib_dec/ivas_dec.c
+++ b/lib_dec/ivas_dec.c
@@ -61,11 +61,15 @@ ivas_error ivas_dec(
)
{
int16_t n, output_frame, nchan_out;
- Decoder_State *st; /* used for bitstream handling */
+ Decoder_State *st; /* used for bitstream handling */
+#ifdef SBA_AND_OBJECTS
+ float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */
+#else
float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */
+#endif
int16_t nchan_remapped;
float output_lfe_ch[L_FRAME48k];
-#ifdef MASA_AND_OBJECTS
+#if defined MASA_AND_OBJECTS || defined SBA_AND_OBJECTS
int16_t nb_bits_metadata[MAX_SCE + 1];
#else
int16_t nb_bits_metadata[MAX_SCE];
@@ -74,7 +78,11 @@ ivas_error ivas_dec(
AUDIO_CONFIG output_config;
float pan_left, pan_right;
ivas_error error;
+#ifdef SBA_AND_OBJECTS
+ float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
+#else
float *p_output[MAX_OUTPUT_CHANNELS];
+#endif
#ifdef VLBR_20MS_MD
int16_t num_md_sub_frames;
#endif
@@ -113,11 +121,16 @@ ivas_error ivas_dec(
output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC );
+#ifdef SBA_AND_OBJECTS
+ for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
+#else
for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ )
+#endif
{
p_output[n] = &output[n][0];
}
+
/*----------------------------------------------------------------*
* Combine orientations
*----------------------------------------------------------------*/
@@ -209,14 +222,24 @@ 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 ) ) != 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
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]
+#endif
+ ) ) != 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 ) ) != 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
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]
+#endif
+ ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -516,7 +539,11 @@ ivas_error ivas_dec(
{
if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
{
- if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, 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,
+#ifdef SBA_AND_OBJECTS
+ 0,
+#endif
+ output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -646,6 +673,221 @@ ivas_error ivas_dec(
mvr2r( output[MAX_OUTPUT_CHANNELS - 1], output[++n], output_frame );
}
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ int16_t nchan_ism, sba_ch_idx;
+
+ set_s( nb_bits_metadata, 0, MAX_SCE + 1 );
+ nchan_ism = st_ivas->nchan_ism;
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ /* set ISM parameters and decode ISM metadata in OSBA format */
+ if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ sba_ch_idx = st_ivas->nchan_ism;
+ }
+ else
+ {
+ nb_bits_metadata[1] += NO_BITS_MASA_ISM_NO_OBJ;
+ sba_ch_idx = 0;
+ }
+
+ /* SBA metadata decoding */
+ if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 )
+ {
+ st_ivas->hCPE[0]->element_brate = ivas_total_brate;
+ }
+
+ /* core-decoding of transport channels */
+ 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 )
+ {
+ return error;
+ }
+ }
+ 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 )
+ {
+ return error;
+ }
+ }
+ 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 )
+ {
+ return error;
+ }
+ }
+
+ 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 );
+
+ 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_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
+#ifdef VLBR_20MS_MD
+ ,
+ st_ivas->last_active_ivas_total_brate
+#endif
+ ) );
+
+ ivas_sba_dirac_stereo_dec( st_ivas, &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 );
+ }
+
+ nchan_remapped = ivas_sba_remapTCs( &output[sba_ch_idx], st_ivas, output_frame );
+
+#ifdef DEBUG_OSBA
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism;
+ for ( int t = 0; t < output_frame; t++ )
+ {
+ for ( int c = 0; c < nchan; c++ )
+ {
+ int16_t val = (int16_t) ( output[c][t] + 0.5f );
+ dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" );
+ }
+ }
+ }
+#endif
+ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
+ {
+#ifdef VLBR_20MS_MD
+ 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 );
+#else
+ ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame );
+#endif
+ }
+ else if ( st_ivas->renderer_type != RENDERER_DISABLE )
+ {
+ ivas_spar_dec_agc_pca( st_ivas, &output[sba_ch_idx], output_frame );
+ }
+
+ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
+ {
+#ifdef FIX_564
+ /* loudness correction */
+ ivas_dirac_dec_binaural_sba_gain( &output[sba_ch_idx], nchan_remapped, output_frame );
+#else
+ float gain;
+
+ if ( nchan_remapped == 1 )
+ {
+ gain = 1.4454f;
+ }
+ else
+ {
+ gain = 1.3657f;
+ }
+
+ for ( n = 0; n < nchan_remapped; n++ )
+ {
+ v_multc( output[n], gain, output[n], output_frame );
+ }
+#endif
+ }
+
+ /* 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 );
+ }
+ 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 )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ ivas_sba_upmixer_renderer( st_ivas, &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 );
+ }
+ 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 );
+ }
+ 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 );
+ }
+ }
+ else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS )
+ {
+ ivas_osba_render( st_ivas, output, output_frame );
+ }
+ else if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 )
+ {
+ ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */
+ }
+ else if ( st_ivas->hDecoderConfig->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 );
+ }
+ }
+
+ ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame );
+
+ if ( st_ivas->ism_mode == ISM_MODE_NONE )
+ {
+ for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- )
+ {
+ mvr2r( output[n], output[n + nchan_ism], output_frame );
+ }
+ for ( n = 0; n < nchan_ism; n++ )
+ {
+ set_zero( output[n], output_frame );
+ }
+ }
+ }
+ }
#endif
else if ( st_ivas->ivas_format == MC_FORMAT )
{
diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c
index 04f7a72ce1dfbb069d7ff3d521492e6fd222e9d5..2a6ee7f1efa7c4a03fcb38dad0478c1b01c2946b 100644
--- a/lib_dec/ivas_dirac_dec.c
+++ b/lib_dec/ivas_dirac_dec.c
@@ -102,7 +102,11 @@ static ivas_error ivas_dirac_dec_config_internal(
if ( flag_config == DIRAC_OPEN )
{
+#ifdef SBA_AND_OBJECTS
+ hDirAC->spar_to_dirac_write_idx = ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ? DELAY_DIRAC_PARAM_DEC_SFR : 0;
+#else
hDirAC->spar_to_dirac_write_idx = st_ivas->ivas_format == SBA_FORMAT ? DELAY_DIRAC_PARAM_DEC_SFR : 0;
+#endif
hDirAC->dithering_seed = DIRAC_DITH_SEED;
st_ivas->hDirAC = hDirAC;
}
@@ -170,7 +174,11 @@ static ivas_error ivas_dirac_rend_config(
num_protos_diff_old = 0;
nchan_transport_orig = st_ivas->nchan_transport;
+#ifndef SBA_AND_OBJECTS
if ( st_ivas->ivas_format == SBA_FORMAT )
+#else
+ if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
+#endif
{
st_ivas->nchan_transport = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
}
@@ -180,8 +188,11 @@ static ivas_error ivas_dirac_rend_config(
{
nchan_transport = 1;
}
-
+#ifdef SBA_AND_OBJECTS
+ if ( flag_config == DIRAC_RECONFIGURE && ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) )
+#else
if ( flag_config == DIRAC_RECONFIGURE && st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
int16_t tmp1, tmp2, tmp3;
ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport_old, st_ivas->sba_planar, &tmp1, &tmp2, &tmp3 );
@@ -380,7 +391,12 @@ static ivas_error ivas_dirac_rend_config(
set_s( hDirACRend->proto_index_diff, 0, hDirACRend->num_outputs_diff );
hDirACRend->sba_map_tc = sba_map_tc;
+
+#ifdef SBA_AND_OBJECTS
+ if ( ( st_ivas->ivas_format == SBA_FORMAT ) || ( st_ivas->ivas_format == SBA_ISM_FORMAT ) )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
if ( st_ivas->sba_order > SBA_FOA_ORDER && ivas_total_brate >= IVAS_512k )
{
@@ -856,6 +872,10 @@ ivas_error ivas_dirac_dec_config(
case RENDERER_BINAURAL_FASTCONV_ROOM:
case RENDERER_SBA_LINEAR_ENC:
case RENDERER_SBA_LINEAR_DEC:
+#ifdef SBA_AND_OBJECTS
+ case RENDERER_OSBA_AMBI:
+ case RENDERER_OSBA_LS:
+#endif
need_dirac_rend = 1;
break;
default:
@@ -1063,18 +1083,28 @@ void ivas_dirac_dec_read_BS(
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */
int16_t *nb_bits, /* o : number of bits read */
- const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */
- int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
+#ifdef SBA_AND_OBJECTS
+ const int16_t last_bit_pos, /* i : last read bitstream position*/
+#endif
+ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */
+ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
)
{
int16_t i, j, b, dir, orig_dirac_bands;
int16_t next_bit_pos_orig;
+#ifndef SBA_AND_OBJECTS
*nb_bits = 0;
+#endif
if ( !st->bfi && ivas_total_brate > IVAS_SID_5k2 )
{
next_bit_pos_orig = st->next_bit_pos;
st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 );
-
+#ifdef SBA_AND_OBJECTS
+ if ( last_bit_pos > 0 )
+ {
+ st->next_bit_pos = last_bit_pos;
+ }
+#endif
/* 1 bit flag for signaling metadata to read */
b = st->bit_stream[( st->next_bit_pos )--];
( *nb_bits )++;
@@ -1837,8 +1867,11 @@ void ivas_dirac_dec_render_sf(
#endif
hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order );
-
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT )
+#else
if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT )
+#endif
{
coherence_flag = st_ivas->hQMetaData->coherence_flag;
}
@@ -2039,8 +2072,11 @@ void ivas_dirac_dec_render_sf(
{
md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx];
}
-
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
for ( ch = 0; ch < nchan_transport; ch++ )
{
@@ -2073,7 +2109,11 @@ void ivas_dirac_dec_render_sf(
}
/* CNG in DirAC, extra CLDFB ana for CNA*/
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) )
+#else
if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format != SBA_FORMAT )
+#endif
{
Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0];
@@ -2507,7 +2547,11 @@ void ivas_dirac_dec_render_sf(
st_ivas->cldfbSynDec[ch] );
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
+#else
else if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ )
{
diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c
index 353eaddc6009679793223144e767407eada76519..bee42c25c61edd6be34b451aee6b9c83fe85365f 100644
--- a/lib_dec/ivas_init_dec.c
+++ b/lib_dec/ivas_init_dec.c
@@ -70,7 +70,9 @@ static ivas_error ivas_dec_reconfig_split_rend(
ivas_error error;
int16_t cldfb_in, num_ch, ch, isCldfbNeeded, i, pcm_out;
SPLIT_REND_WRAPPER *hSplitRendWrapper;
+#ifndef OSBA_SPLIT_RENDERING
CLDFB_TYPE cldfbMode;
+#endif
hSplitRendWrapper = &st_ivas->splitBinRend.splitrend;
pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
@@ -88,23 +90,36 @@ static ivas_error ivas_dec_reconfig_split_rend(
st_ivas->hHeadTrackData->sr_pose_pred_axis );
isCldfbNeeded = 0;
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode = CLDFB_ANALYSIS;
+#else
+ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ cldfb_in = 0;
+ }
+#endif
if ( st_ivas->renderer_type != RENDERER_DISABLE )
{
if ( cldfb_in == 0 )
{
isCldfbNeeded = 1;
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode = CLDFB_ANALYSIS;
+#endif
}
else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in )
{
isCldfbNeeded = 1;
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode = CLDFB_SYNTHESIS;
+#endif
}
else if ( pcm_out && cldfb_in )
{
isCldfbNeeded = 1;
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode = CLDFB_SYNTHESIS;
+#endif
}
}
@@ -126,12 +141,28 @@ static ivas_error ivas_dec_reconfig_split_rend(
for ( ch = 0; ch < num_ch; ch++ )
{
if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ),
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode,
+#else
+ CLDFB_ANALYSIS,
+#endif
st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) );
}
}
+
+#ifdef OSBA_SPLIT_RENDERING
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ),
+ CLDFB_SYNTHESIS,
+ st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+#endif
}
else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL )
{
@@ -144,11 +175,26 @@ static ivas_error ivas_dec_reconfig_split_rend(
hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
}
}
+#ifdef OSBA_SPLIT_RENDERING
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL )
+ {
+ deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] );
+ hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL;
+ }
+ }
+#endif
free( hSplitRendWrapper->hCldfbHandles );
hSplitRendWrapper->hCldfbHandles = NULL;
}
+#ifdef OSBA_SPLIT_RENDERING
+ if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) &&
+ ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) )
+#else
if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD )
+#endif
{
for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
{
@@ -197,7 +243,12 @@ ivas_error ivas_dec_init_split_rend(
}
ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, ( cldfb_in == 0 ), pcm_out );
-
+#ifdef OSBA_SPLIT_RENDERING
+ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ cldfb_in = 0;
+ }
+#endif
error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend,
&st_ivas->hRenderConfig->split_rend_config,
st_ivas->hDecoderConfig->output_Fs,
@@ -369,6 +420,68 @@ ivas_error ivas_dec_setup(
}
}
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ /* the number of objects is written at the end of the bitstream, in the SBA metadata */
+ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1;
+
+ if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k )
+ {
+ /* read Ambisonic (SBA) planar flag */
+ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
+ num_bits_read += SBA_PLANAR_BITS;
+ }
+
+ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
+ st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read];
+ num_bits_read += SBA_ORDER_BITS;
+
+ /* read Ambisonic (SBA) order */
+ if ( ivas_total_brate < IVAS_256k )
+ {
+ st_ivas->sba_order = 3;
+ }
+
+
+ /* set Ambisonic (SBA) order used for analysis and coding */
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
+
+ if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate )
+ {
+ if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
+#ifdef OSBA_BR_SWITCHING
+ /*correct number of CPEs for discrete ISM coding*/
+ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1;
+ }
+#endif
+ }
+#ifndef OSBA_BR_SWITCHING
+ /*correct number of CPEs for discrete ISM coding*/
+ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1;
+ }
+#endif
+ if ( ivas_total_brate >= IVAS_256k )
+ {
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ }
+ else
+ {
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ }
+ }
#endif
else if ( st_ivas->ivas_format == MC_FORMAT )
{
@@ -608,15 +721,19 @@ static ivas_error ivas_read_format(
{
if ( st_ivas->bit_stream[*num_bits_read] )
{
-#ifdef MASA_AND_OBJECTS
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
( *num_bits_read )++;
+#ifdef SBA_AND_OBJECTS
if ( st_ivas->bit_stream[*num_bits_read] )
{
- /* Placeholder for SBA + objects */
+ st_ivas->ivas_format = SBA_ISM_FORMAT;
}
else
+#endif
{
+#ifdef MASA_AND_OBJECTS
st_ivas->ivas_format = MASA_ISM_FORMAT;
+#endif
}
#else
/* placeholder for combined format signaling */
@@ -627,7 +744,6 @@ static ivas_error ivas_read_format(
( *num_bits_read )++;
}
-
break;
case 3:
if ( st_ivas->bit_stream[*num_bits_read] )
@@ -637,6 +753,17 @@ static ivas_error ivas_read_format(
else
{
st_ivas->ivas_format = SBA_FORMAT;
+#ifdef SBA_AND_OBJECTS
+ /* read Ambisonic (SBA) planar flag */
+ st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1];
+ /* read Ambisonic (SBA) order */
+ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS];
+ st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS];
+ if ( st_ivas->sba_order == 0 )
+ {
+ st_ivas->ivas_format = SBA_ISM_FORMAT;
+ }
+#endif
}
( *num_bits_read )++;
@@ -742,11 +869,27 @@ int16_t getNumChanSynthesis(
{
n = CPE_CHANNELS;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->ivas_format != SBA_ISM_FORMAT )
+#else
else if ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
n = st_ivas->nchan_transport;
}
-
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ n = st_ivas->nchan_transport + st_ivas->nchan_ism;
+ }
+ else
+ {
+ n = st_ivas->nchan_transport;
+ }
+ }
+#endif
return n;
}
@@ -951,8 +1094,16 @@ ivas_error ivas_init_decoder(
if ( output_config == AUDIO_CONFIG_EXTERNAL )
{
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 );
+ hDecoderConfig->nchan_out += st_ivas->nchan_ism;
+ }
+ else
+#endif
#ifdef MASA_AND_OBJECTS
- if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
{
hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism;
}
@@ -974,6 +1125,16 @@ ivas_error ivas_init_decoder(
ivas_output_init( &( st_ivas->hOutSetup ), output_config );
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL )
+ {
+ st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
+ st_ivas->intern_config = AUDIO_CONFIG_HOA3;
+ st_ivas->hOutSetup.output_config = AUDIO_CONFIG_HOA3;
+ st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( AUDIO_CONFIG_HOA3 );
+ }
+#endif
+
/* Only initialize transport setup if it is used */
if ( st_ivas->transport_config != AUDIO_CONFIG_INVALID )
{
@@ -1290,6 +1451,131 @@ ivas_error ivas_init_decoder(
/* set CNA/CNG flags */
ivas_sba_set_cna_cng_flag( st_ivas );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ int32_t temp_brate[MAX_SCE];
+ st_ivas->ism_extmeta_active = -1;
+ st_ivas->ism_extmeta_cnt = 0;
+
+ if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup )
+ {
+ if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO )
+ {
+ if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ }
+ else
+ {
+ int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];
+
+ st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) )
+ {
+ st_ivas->hSpar->enc_param_start_band = 0;
+
+ set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
+ st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
+ }
+
+ ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
+ st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
+ }
+ st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
+
+ for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
+ {
+ if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
+ }
+
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1;
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ }
+
+ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ {
+ if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
+ }
+ }
+
+#ifdef OSBA_BR_SWITCHING
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nchan_transport += st_ivas->nchan_ism;
+ }
+#endif
+ if ( st_ivas->nCPE > 1 )
+ {
+ if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+#ifdef OSBA_BR_SWITCHING
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nchan_transport -= st_ivas->nchan_ism;
+ }
+#endif
+
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+
+ /* set CNA/CNG flags */
+ ivas_sba_set_cna_cng_flag( st_ivas );
+ }
+#endif
#ifdef MASA_AND_OBJECTS
else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
{
@@ -1779,11 +2065,21 @@ ivas_error ivas_init_decoder(
}
#endif
+#if defined SBA_AND_OBJECTS || defined SBA_AND_OBJECTS || defined SBA_AND_OBJECTS
+ if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) &&
+ ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) &&
+#else
if ( st_ivas->ivas_format == ISM_FORMAT &&
st_ivas->ism_mode == ISM_MODE_DISC &&
+#endif
( st_ivas->renderer_type == RENDERER_TD_PANNING ||
st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ||
st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ||
+#ifdef SBA_AND_OBJECTS
+ st_ivas->renderer_type == RENDERER_OSBA_STEREO ||
+ st_ivas->renderer_type == RENDERER_OSBA_AMBI ||
+ st_ivas->renderer_type == RENDERER_OSBA_LS ||
+#endif
st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
@@ -1793,6 +2089,27 @@ ivas_error ivas_init_decoder(
return error;
}
}
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ /* Allocate TD renderer for the objects in DISC mode */
+ if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
+ if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+#endif
/*-----------------------------------------------------------------*
* LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay
@@ -1860,7 +2177,11 @@ ivas_error ivas_init_decoder(
}
/* CLDFB Interpolation weights */
+#ifdef SBA_AND_OBJECTS
+ if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 )
+#endif
{
ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig );
}
@@ -2141,7 +2462,7 @@ void ivas_initialize_handles_dec(
st_ivas->hHrtfFastConv = NULL;
st_ivas->hHrtfParambin = NULL;
st_ivas->hoa_dec_mtx = NULL;
-#ifdef MASA_AND_OBJECTS
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
st_ivas->hMasaIsmData = NULL;
#endif
@@ -2334,6 +2655,10 @@ void ivas_destroy_dec(
free( st_ivas->hMonoDmxRenderer );
st_ivas->hMonoDmxRenderer = NULL;
}
+#ifdef SBA_AND_OBJECTS
+ /* MASA ISM structure */
+ ivas_masa_ism_data_close( &st_ivas->hMasaIsmData );
+#endif
#ifdef MASA_AND_OBJECTS
/* OMASA structure */
@@ -2415,9 +2740,16 @@ void ivas_init_dec_get_num_cldfb_instances(
int16_t *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */
)
{
+#ifdef SBA_AND_OBJECTS
+ IVAS_FORMAT ivas_format;
+#endif
*numCldfbAnalyses = st_ivas->nchan_transport;
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
+#ifdef SBA_AND_OBJECTS
+ ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
+#endif
+
switch ( st_ivas->renderer_type )
{
case RENDERER_BINAURAL_PARAMETRIC:
@@ -2433,8 +2765,21 @@ void ivas_init_dec_get_num_cldfb_instances(
{
*numCldfbAnalyses = st_ivas->nchan_transport + 1;
}
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ *numCldfbAnalyses += st_ivas->nchan_ism;
+ }
+ }
+#endif
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == MASA_ISM_FORMAT )
+#else
if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
+#endif
{
if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
{
@@ -2456,7 +2801,11 @@ void ivas_init_dec_get_num_cldfb_instances(
break;
case RENDERER_NON_DIEGETIC_DOWNMIX:
case RENDERER_MONO_DOWNMIX:
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT )
+#else
if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT )
+#endif
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
@@ -2484,7 +2833,11 @@ void ivas_init_dec_get_num_cldfb_instances(
break;
case RENDERER_NON_DIEGETIC_DOWNMIX:
case RENDERER_MONO_DOWNMIX:
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == ISM_FORMAT )
+#else
if ( st_ivas->ivas_format == ISM_FORMAT )
+#endif
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
@@ -2493,7 +2846,11 @@ void ivas_init_dec_get_num_cldfb_instances(
break;
#endif
case RENDERER_DIRAC:
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
@@ -2510,7 +2867,11 @@ void ivas_init_dec_get_num_cldfb_instances(
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
}
}
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format != SBA_FORMAT )
+#else
if ( st_ivas->ivas_format != SBA_FORMAT )
+#endif
{
if ( st_ivas->nchan_transport > 2 && st_ivas->sba_planar )
{
@@ -2551,7 +2912,14 @@ void ivas_init_dec_get_num_cldfb_instances(
case RENDERER_BINAURAL_MIXER_CONV_ROOM:
case RENDERER_BINAURAL_FASTCONV:
case RENDERER_BINAURAL_FASTCONV_ROOM:
+#ifdef SBA_AND_OBJECTS
+ case RENDERER_OSBA_STEREO:
+ case RENDERER_OSBA_AMBI:
+ case RENDERER_OSBA_LS:
+ if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
if ( st_ivas->sba_dirac_stereo_flag )
{
@@ -2687,7 +3055,7 @@ static ivas_error doSanityChecks_IVAS(
else if ( st_ivas->ivas_format == SBA_FORMAT )
{
/* Verify SBA output coniguration */
- if ( output_config == AUDIO_CONFIG_INVALID || output_config == AUDIO_CONFIG_EXTERNAL )
+ if ( output_config == AUDIO_CONFIG_INVALID )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" );
}
diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c
old mode 100644
new mode 100755
index 56a52f2be9944bc27587624bb71ad92cd52734d0..108a9428f14bd7c80c92e69889853ab7695d1170
--- a/lib_dec/ivas_ism_metadata_dec.c
+++ b/lib_dec/ivas_ism_metadata_dec.c
@@ -150,12 +150,18 @@ ivas_error ivas_ism_metadata_dec(
const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */
int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */
int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */
+#ifdef SBA_AND_OBJECTS
+ ,
+ DEC_CORE_HANDLE st0
+#endif
)
{
int16_t ch, nb_bits_start = 0, last_bit_pos;
int16_t idx_radius;
int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS];
+#ifndef SBA_AND_OBJECTS
DEC_CORE_HANDLE st0;
+#endif
int16_t ism_extmeta_bitstream;
int16_t non_diegetic_flag_global;
float yaw, pitch, radius;
@@ -178,7 +184,9 @@ ivas_error ivas_ism_metadata_dec(
push_wmops( "ism_meta_dec" );
/* initialization */
+#ifndef SBA_AND_OBJECTS
st0 = hSCE[0]->hCoreCoder[0];
+#endif
ism_metadata_flag_global = 0;
nchan_transport_prev = *nchan_transport;
@@ -204,10 +212,16 @@ ivas_error ivas_ism_metadata_dec(
/*----------------------------------------------------------------*
* Read ISM common signaling
*----------------------------------------------------------------*/
-
- /* number of objects was read in ivas_dec_setup() */
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode == ISM_SBA_MODE_DISC )
+ {
+ /* number of objects was read in ivas_dec_setup() */
+ st0->next_bit_pos += NO_BITS_MASA_ISM_NO_OBJ;
+ }
+ else
+#endif
#ifdef MASA_AND_OBJECTS
- if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ )
+ if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ )
#endif
{
/* number of objects was read in ivas_dec_setup() */
@@ -232,7 +246,11 @@ ivas_error ivas_ism_metadata_dec(
/* read extended metadata presence flag */
#ifdef MASA_AND_OBJECTS
+#ifdef SBA_AND_OBJECTS
+ if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE )
+#else
if ( ism_mode == ISM_MODE_DISC && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE )
+#endif
#else
if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE )
#endif
@@ -265,8 +283,15 @@ ivas_error ivas_ism_metadata_dec(
/* Read ISM metadata flags (one per object) */
for ( ch = 0; ch < *nchan_transport; ch++ )
{
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode == ISM_SBA_MODE_DISC )
+ {
+ ism_imp[ch] = get_next_indice( st0, 1 );
+ }
+ else
+#endif
#ifdef MASA_AND_OBJECTS
- if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
+ if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
{
/* ISM importance flag is already read in ivas_masa_decode() */
ism_imp[ch] = hIsmMeta[ch]->ism_imp;
@@ -367,11 +392,14 @@ ivas_error ivas_ism_metadata_dec(
for ( ch = 0; ch < nchan_ism; ch++ )
{
hIsmMetaData = hIsmMeta[ch];
+ if ( ism_mode == ISM_MODE_DISC
+#ifdef SBA_AND_OBJECTS
+ || ism_mode == ISM_SBA_MODE_DISC
+#endif
#ifdef MASA_AND_OBJECTS
- if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
-#else
- if ( ism_mode == ISM_MODE_DISC )
+ || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ
#endif
+ )
{
nb_bits_start = st0->next_bit_pos;
}
@@ -457,11 +485,14 @@ ivas_error ivas_ism_metadata_dec(
}
}
/* save number of metadata bits read */
+ if ( ism_mode == ISM_MODE_DISC
+#ifdef SBA_AND_OBJECTS
+ || ism_mode == ISM_SBA_MODE_DISC
+#endif
#ifdef MASA_AND_OBJECTS
- if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
-#else
- if ( ism_mode == ISM_MODE_DISC )
+ || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ
#endif
+ )
{
nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start;
}
@@ -545,6 +576,23 @@ ivas_error ivas_ism_metadata_dec(
hISMDTX.ism_dtx_hangover_cnt += 1;
}
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode == ISM_SBA_MODE_DISC )
+ {
+ /* set the bitstream pointer to its original position */
+ nb_bits_metadata[0] = st0->next_bit_pos;
+ st0->bit_stream = bstr_orig;
+ st0->next_bit_pos = next_bit_pos_orig;
+
+ /* updates*/
+ set_s( md_diff_flag, 1, nchan_ism );
+
+ update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag );
+ pop_wmops();
+ return IVAS_ERR_OK;
+ }
+#endif
+
#ifdef MASA_AND_OBJECTS
if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
{
diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c
index 55af4b59059225f8e53718761ce7d4315cc48bad..666488c436c20fb7ee900f8755632917666c907a 100644
--- a/lib_dec/ivas_jbm_dec.c
+++ b/lib_dec/ivas_jbm_dec.c
@@ -164,14 +164,24 @@ 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 ) ) != 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
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]
+#endif
+ ) ) != 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 ) ) != 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
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]
+#endif
+ ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -961,7 +971,11 @@ 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, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped,
+#ifdef SBA_AND_OBJECTS
+ 0,
+#endif
+ output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c
index ed5bd79d7a05db99a5a8189c8a1f574d3b920d84..31ae09fd3bbc15ee9f0437a148203164dc18e1e4 100755
--- a/lib_dec/ivas_mct_dec.c
+++ b/lib_dec/ivas_mct_dec.c
@@ -160,7 +160,11 @@ ivas_error ivas_mct_dec(
ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output );
/* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->sba_dirac_stereo_flag && st_ivas->ivas_format != SBA_ISM_FORMAT )
+#else
if ( st_ivas->sba_dirac_stereo_flag )
+#endif
{
for ( cpe_id = 1; cpe_id < nCPE; cpe_id++ )
{
@@ -226,14 +230,21 @@ ivas_error ivas_mct_dec(
for ( n = 0; n < CPE_CHANNELS; n++ )
{
-
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->sba_dirac_stereo_flag && ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) )
+#else
if ( st_ivas->sba_dirac_stereo_flag )
+#endif
{
ivas_post_proc( NULL, hCPE, n, synth[n], NULL, output_frame, 1 );
}
/* Postprocessing for ACELP/MDCT core switching and synchronization */
+#ifdef SBA_AND_OBJECTS
+ if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK )
+#else
if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, st_ivas->sba_dirac_stereo_flag, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -254,7 +265,11 @@ ivas_error ivas_mct_dec(
/* synthesis synchronization between stereo modes */
+#ifdef SBA_AND_OBJECTS
+ if ( !st_ivas->sba_dirac_stereo_flag || ( st_ivas->ivas_format == SBA_ISM_FORMAT && cpe_id < nCPE - 2 ) )
+#else
if ( !st_ivas->sba_dirac_stereo_flag )
+#endif
{
synchro_synthesis( ivas_total_brate, hCPE, output + cpe_id * CPE_CHANNELS, output_frame, 0 );
}
@@ -331,9 +346,22 @@ ivas_error create_mct_dec(
*-----------------------------------------------------------------*/
/* Determine active channels */
- if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT )
+ if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT
+#ifdef SBA_AND_OBJECTS
+ || st_ivas->ivas_format == SBA_ISM_FORMAT
+#endif
+ )
{
hMCT->nchan_out_woLFE = st_ivas->nchan_transport;
+
+#ifndef OSBA_BR_SWITCHING
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ hMCT->nchan_out_woLFE += st_ivas->nchan_ism;
+ }
+#endif
+#endif
}
else if ( st_ivas->mc_mode == MC_MODE_MCT )
{
@@ -441,7 +469,11 @@ ivas_error mct_dec_reconfigure(
if ( b_nchan_change )
{
/* Determine active channels */
- if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT )
+ if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT
+#ifdef OSBA_BR_SWITCHING
+ || st_ivas->ivas_format == SBA_ISM_FORMAT
+#endif
+ )
{
hMCT->nchan_out_woLFE = st_ivas->nchan_transport;
}
diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c
old mode 100644
new mode 100755
index 61d8c6809492ff8ed5ed8e662a3d7ed86838e46b..9937c9b8553d52bba2ca012cfeedfcdb5ef8e8fa
--- a/lib_dec/ivas_mono_dmx_renderer.c
+++ b/lib_dec/ivas_mono_dmx_renderer.c
@@ -94,7 +94,12 @@ void ivas_mono_downmix_render_passive(
MONO_DOWNMIX_RENDERER_HANDLE hDownmix;
numInputChannels = st_ivas->nSCE;
-
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ numInputChannels = st_ivas->nchan_ism;
+ }
+#endif
#ifdef MASA_AND_OBJECTS
if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
{
diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c
index e8a9c58efb3c423ef2ff4423e7ce2d653a382a11..faa4c3c38c9f6c70be80520fb626c90f5f083c99 100644
--- a/lib_dec/ivas_objectRenderer_internal.c
+++ b/lib_dec/ivas_objectRenderer_internal.c
@@ -57,7 +57,11 @@ ivas_error ivas_td_binaural_open(
int16_t num_src;
num_src = st_ivas->nchan_transport;
+#ifdef SBA_AND_OBJECTS
+ if ( ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) || ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) )
+#else
if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+#endif
{
num_src = st_ivas->nchan_ism;
}
@@ -86,16 +90,18 @@ ivas_error ivas_td_binaural_renderer(
)
{
int16_t ism_md_subframe_update;
-#ifdef MASA_AND_OBJECTS
- int16_t num_src;
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
+ int16_t nchan_transport;
#endif
-#ifdef MASA_AND_OBJECTS
- num_src = st_ivas->nchan_transport;
- if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
- {
- num_src = st_ivas->nchan_ism;
- }
+#if defined MASA_AND_OBJECTS
+ nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC
+#if defined SBA_AND_OBJECTS
+ || st_ivas->ism_mode == ISM_SBA_MODE_DISC
+#endif
+ )
+ ? st_ivas->nchan_ism
+ : st_ivas->nchan_transport;
#endif
if ( st_ivas->hDecoderConfig->Opt_delay_comp )
@@ -122,8 +128,8 @@ ivas_error ivas_td_binaural_renderer(
st_ivas->hReverb,
st_ivas->transport_config,
st_ivas->hBinRendererTd,
-#ifdef MASA_AND_OBJECTS
- num_src,
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
+ nchan_transport,
#else
st_ivas->nchan_transport,
#endif
diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c
index 356bdc3ff18525176516a59caaa41d891a81d4c0..acbde108f128a5b6359150742a4e4d28ef3c1424 100644
--- a/lib_dec/ivas_omasa_dec.c
+++ b/lib_dec/ivas_omasa_dec.c
@@ -531,7 +531,12 @@ ivas_error ivas_omasa_ism_metadata_dec(
{
/* decode ISM metadata */
if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, 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 ) ) != IVAS_ERR_OK )
+ nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]
+#endif
+ ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c
new file mode 100755
index 0000000000000000000000000000000000000000..09a6bd27c87116e16d1b417738d66ca0afc57132
--- /dev/null
+++ b/lib_dec/ivas_osba_dec.c
@@ -0,0 +1,356 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 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
+#include "ivas_cnst.h"
+#include "ivas_prot.h"
+#include "prot.h"
+#include "ivas_prot_rend.h"
+#include "ivas_rom_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+
+
+#ifdef SBA_AND_OBJECTS
+
+/*-------------------------------------------------------------------*
+ * ivas_masa_ism_data_open()
+ *
+ * Allocate and initialize MASA_ISM rendering handle
+ *-------------------------------------------------------------------*/
+
+ivas_error ivas_masa_ism_data_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
+)
+{
+ MASA_ISM_DATA_HANDLE hMasaIsmData;
+
+ if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) );
+ }
+ hMasaIsmData->delayBuffer = NULL;
+
+ st_ivas->hMasaIsmData = hMasaIsmData;
+
+ return IVAS_ERR_OK;
+}
+/*-------------------------------------------------------------------*
+ * ivas_masa_ism_data_close()
+ *
+ * Deallocate MASA_ISM rendering handle
+ *-------------------------------------------------------------------*/
+
+void ivas_masa_ism_data_close(
+ MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */
+)
+{
+ int16_t i;
+
+ if ( hMasaIsmData == NULL || *hMasaIsmData == NULL )
+ {
+ return;
+ }
+
+ if ( ( *hMasaIsmData )->delayBuffer != NULL )
+ {
+ for ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ )
+ {
+ free( ( *hMasaIsmData )->delayBuffer[i] );
+ }
+ free( ( *hMasaIsmData )->delayBuffer );
+ ( *hMasaIsmData )->delayBuffer = NULL;
+ }
+
+ free( *hMasaIsmData );
+ *hMasaIsmData = NULL;
+
+ return;
+}
+
+/*-------------------------------------------------------------------------*
+ * ivas_sba_ism_separate_object_renderer_open()
+ *
+ * Open structures, reserve memory, and init values.
+ *-------------------------------------------------------------------------*/
+
+ivas_error ivas_sba_ism_separate_object_renderer_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ int16_t i;
+
+ st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism;
+ st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );
+
+ if ( ( st_ivas->hMasaIsmData->delayBuffer = (float **) malloc( st_ivas->hMasaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) );
+ }
+
+ for ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ )
+ {
+ if ( ( st_ivas->hMasaIsmData->delayBuffer[i] = (float *) malloc( st_ivas->hMasaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) );
+ }
+ set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size );
+ }
+
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_osba_dirac_td_binaural()
+ *
+ * Binaural rendering in OMASA format
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_osba_dirac_td_binaural(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output[][L_FRAME48k], /* o : output synthesis signal */
+ const int16_t output_frame /* i : output frame length per channel */
+)
+{
+ int16_t n;
+ float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
+
+ ivas_error error;
+ float *p_sepobj[MAX_NUM_OBJECTS];
+ int16_t channel_offset;
+
+ for ( n = 0; n < MAX_NUM_OBJECTS; n++ )
+ {
+ p_sepobj[n] = &data_separated_objects[n][0];
+ }
+
+ channel_offset = st_ivas->nchan_ism;
+
+ for ( n = 0; n < st_ivas->nchan_ism; n++ )
+ {
+ mvr2r( output[n], data_separated_objects[n], output_frame );
+ }
+
+#ifdef OSBA_SPLIT_RENDERING
+ if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED &&
+ st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
+#endif
+ {
+ for ( n = 0; n < st_ivas->nchan_ism; n++ )
+ {
+ delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
+ }
+ }
+
+ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
+ {
+ ivas_sba_upmixer_renderer( st_ivas, &output[channel_offset], output_frame );
+ }
+ else
+ {
+ ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport );
+ }
+
+#ifdef DEBUG_OSBA
+ {
+ for ( int t = 0; t < output_frame; t++ )
+ {
+ for ( int c = 0; c < BINAURAL_CHANNELS; c++ )
+ {
+ int16_t val = (int16_t) ( output[channel_offset + c][t] + 0.5f );
+ dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/sba_fast_conv_out.raw" );
+ }
+ }
+ }
+#endif
+#ifdef OSBA_SPLIT_RENDERING
+ if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
+ ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig;
+ float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX];
+ float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX];
+ num_cldfb_bands = st_ivas->splitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels;
+ nchan_transport_orig = st_ivas->nchan_transport;
+ st_ivas->nchan_transport = st_ivas->nchan_ism;
+ ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame );
+ st_ivas->nchan_transport = nchan_transport_orig;
+ for ( n = 0; n < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n )
+ {
+ for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ )
+ {
+ cldfbAnalysis_ts( &( output[n][num_cldfb_bands * slot_idx] ),
+ Cldfb_RealBuffer,
+ Cldfb_ImagBuffer,
+ num_cldfb_bands,
+ st_ivas->splitBinRend.splitrend.hCldfbHandles->cldfbAna[n] );
+ for ( b = 0; b < num_cldfb_bands; b++ )
+ {
+ st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] =
+ ( 0.5f * st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] ) +
+ ( 0.5f * Cldfb_RealBuffer[b] );
+ st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] =
+ ( 0.5f * st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] ) +
+ ( 0.5f * Cldfb_ImagBuffer[b] );
+ }
+ }
+ }
+ }
+ else
+ {
+#endif
+ if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+#ifdef DEBUG_OSBA
+ {
+ for ( int t = 0; t < output_frame; t++ )
+ {
+ for ( int c = 0; c < BINAURAL_CHANNELS; c++ )
+ {
+ int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f );
+ dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/ism_td_bin_out.raw" );
+ }
+ }
+ }
+#endif
+ for ( n = 0; n < BINAURAL_CHANNELS; n++ )
+ {
+ int16_t i;
+ for ( i = 0; i < output_frame; i++ )
+ {
+ output[n][i] = 0.5f * output[channel_offset + n][i] + 0.5f * p_sepobj[n][i];
+ }
+ }
+#ifdef OSBA_SPLIT_RENDERING
+ }
+#endif
+
+ return IVAS_ERR_OK;
+}
+
+
+ivas_error ivas_osba_ism_metadata_dec(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const int32_t ism_total_brate, /* i : ISM total bitrate */
+ int16_t *nchan_ism, /* o : number of ISM separated channels */
+ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */
+)
+{
+ ivas_error error;
+ int16_t nchan_transport_ism;
+
+ /* set ISM parameters */
+ nchan_transport_ism = st_ivas->nchan_ism;
+ *nchan_ism = st_ivas->nchan_ism;
+
+
+ /* decode ISM metadata */
+ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, 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->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ return IVAS_ERR_OK;
+}
+
+/*-------------------------------------------------------------------------*
+ * ivas_osba_render()
+ *
+ * Object + SBA rendering process.
+ *-------------------------------------------------------------------------*/
+
+void ivas_osba_render(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */
+ const int16_t output_frame /* i : output frame length per channel */
+)
+{
+ float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k];
+ float *p_tmp_ism_out[MAX_OUTPUT_CHANNELS];
+ int16_t n, nchan_out, nchan_ism, sba_ch_idx;
+
+ nchan_out = st_ivas->hDecoderConfig->nchan_out;
+ nchan_ism = st_ivas->nchan_ism;
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ sba_ch_idx = st_ivas->nchan_ism;
+ }
+ else
+ {
+ sba_ch_idx = 0;
+ }
+
+ for ( n = 0; n < nchan_out; n++ )
+ {
+ p_tmp_ism_out[n] = &tmp_ism_out[n][0];
+ }
+
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ for ( n = 0; n < nchan_ism; n++ )
+ {
+ mvr2r( output_f[n], tmp_ism_out[n], output_frame );
+ delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
+ }
+
+ if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI )
+ {
+ ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order );
+ }
+ else
+ {
+ ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame );
+ }
+ }
+
+ ivas_sba_upmixer_renderer( st_ivas, &output_f[sba_ch_idx], output_frame );
+
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ for ( n = 0; n < nchan_out; n++ )
+ {
+ v_add( output_f[n + nchan_ism], tmp_ism_out[n], output_f[n], output_frame );
+ v_multc( output_f[n], 0.5f, output_f[n], output_frame );
+ }
+ }
+
+ return;
+}
+#endif
diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c
index 907f785c17f64fedf3f6527e928dc7f71fea9e09..8cf49138b2c8791d25713d18430b878619b8b436 100644
--- a/lib_dec/ivas_output_config.c
+++ b/lib_dec/ivas_output_config.c
@@ -151,11 +151,16 @@ void ivas_renderer_select(
}
}
}
+ else if ( st_ivas->ivas_format == MASA_FORMAT
#ifdef MASA_AND_OBJECTS
- else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) )
+ || st_ivas->ivas_format == MASA_ISM_FORMAT
+#endif
+#ifdef SBA_AND_OBJECTS
+ || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
#else
- else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) )
+ || ( st_ivas->ivas_format == SBA_FORMAT
#endif
+ && st_ivas->nchan_transport <= 2 ) )
{
*internal_config = output_config;
if ( output_config == AUDIO_CONFIG_BINAURAL
@@ -171,7 +176,11 @@ void ivas_renderer_select(
*renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
+#else
else if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
*internal_config = AUDIO_CONFIG_HOA3;
#ifdef FIX_571_REVERB_NOT_ACTIVATED_ISM
@@ -398,11 +407,27 @@ void ivas_renderer_select(
}
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
+#else
else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
+#ifdef SBA_AND_OBJECTS
+ IVAS_FORMAT ivas_format;
+#endif
*renderer_type = RENDERER_DIRAC;
+#ifdef SBA_AND_OBJECTS
+ ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
+#endif
+
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_FORMAT &&
+ ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT &&
( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) )
+#endif
{
if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA )
{
@@ -418,27 +443,76 @@ void ivas_renderer_select(
}
st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ||
+ ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) )
+#else
else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ||
( st_ivas->ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) )
+#endif
{
*renderer_type = RENDERER_DISABLE;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) )
+#else
else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) )
+#endif
{
*renderer_type = RENDERER_DISABLE;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO )
+#else
else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO )
+#endif
{
*renderer_type = RENDERER_STEREO_PARAMETRIC;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL )
+#else
else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL )
+#endif
{
*renderer_type = RENDERER_DISABLE;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO )
+#else
else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO )
+#endif
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_DEC;
+ }
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_STEREO )
+ {
+ *renderer_type = RENDERER_OSBA_STEREO;
+ }
+ else if ( ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_MONO )
+ {
+ *renderer_type = RENDERER_MONO_DOWNMIX;
+ }
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) )
+ {
+ *renderer_type = RENDERER_OSBA_AMBI;
+ }
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ *renderer_type = RENDERER_OSBA_LS;
+ }
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL )
{
*renderer_type = RENDERER_SBA_LINEAR_DEC;
}
+#endif
}
#ifdef MASA_AND_OBJECTS
else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c
index e1c95812ac916674eb430e1e236fd040f51483f0..7334ea49791768b027ecaaed5dd342190f128bf7 100755
--- a/lib_dec/ivas_sba_dec.c
+++ b/lib_dec/ivas_sba_dec.c
@@ -116,6 +116,11 @@ ivas_error ivas_sba_dec_reconfigure(
DECODER_CONFIG_HANDLE hDecoderConfig;
ivas_error error;
+#ifdef OSBA_BR_SWITCHING
+ ISM_MODE ism_mode_old;
+ ism_mode_old = st_ivas->ism_mode;
+#endif
+
error = IVAS_ERR_OK;
hDecoderConfig = st_ivas->hDecoderConfig;
@@ -129,6 +134,24 @@ ivas_error ivas_sba_dec_reconfigure(
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
nchan_hp20_old = getNumChanSynthesis( st_ivas );
+#ifdef OSBA_BR_SWITCHING
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( ivas_total_brate >= IVAS_256k )
+ {
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ }
+ else
+ {
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ }
+ }
+ else
+ {
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ }
+#endif
+
nSCE_old = st_ivas->nSCE;
nCPE_old = st_ivas->nCPE;
nchan_transport_old = st_ivas->nchan_transport;
@@ -311,12 +334,111 @@ ivas_error ivas_sba_dec_reconfigure(
/*-----------------------------------------------------------------*
* Allocate, initialize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/
+#ifdef OSBA_BR_SWITCHING
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ int32_t temp_brate[MAX_SCE];
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING ||
+ st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ||
+ st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ||
+ st_ivas->renderer_type == RENDERER_OSBA_STEREO ||
+ st_ivas->renderer_type == RENDERER_OSBA_AMBI ||
+ st_ivas->renderer_type == RENDERER_OSBA_LS ||
+ st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
+ st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
+ st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
+ {
+ /* Allocate TD renderer for the objects in DISC mode */
+ if ( st_ivas->hBinRendererTd == NULL )
+ {
+ if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
+ if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+
+ st_ivas->nchan_transport += st_ivas->nchan_ism;
+ st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1;
+ }
+ else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE )
+ {
+ /* ISM renderer handle */
+ if ( st_ivas->hIsmRendererData != NULL )
+ {
+ free( st_ivas->hIsmRendererData->interpolator );
+ free( st_ivas->hIsmRendererData );
+ st_ivas->hIsmRendererData = NULL;
+ }
+ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
+ ivas_masa_ism_data_close( &st_ivas->hMasaIsmData );
+
+ /* Time Domain binaural renderer handle */
+
+ if ( st_ivas->hBinRendererTd != NULL )
+ {
+ if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
+ {
+ ivas_td_binaural_close( &st_ivas->hBinRendererTd );
+ if ( st_ivas->hHrtfTD != NULL )
+ {
+ st_ivas->hHrtfTD = NULL;
+ }
+ }
+ }
+ nchan_transport_old += st_ivas->nchan_ism;
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ }
+ else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nchan_transport += st_ivas->nchan_ism;
+ st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1;
+ nCPE_old = st_ivas->nCPE;
+ nchan_transport_old = st_ivas->nchan_transport;
+ }
+ }
+#endif
if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
{
return error;
}
+#ifdef OSBA_BR_SWITCHING
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nchan_transport -= st_ivas->nchan_ism;
+ }
+ }
+#endif
+
/*-----------------------------------------------------------------*
* HP20 memories
*-----------------------------------------------------------------*/
@@ -550,7 +672,11 @@ void ivas_sba_dec_render(
if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
{
- ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
+ ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE,
+#ifdef SBA_AND_OBJECTS
+ 0,
+#endif
+ st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
}
if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots )
diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c
old mode 100644
new mode 100755
index f743f2072befbc2539301b578a20779115872521..1b12db0e6d2511b30709fa1cebc8df6ce84426ae
--- a/lib_dec/ivas_sba_dirac_stereo_dec.c
+++ b/lib_dec/ivas_sba_dirac_stereo_dec.c
@@ -78,6 +78,15 @@ int16_t ivas_get_sba_dirac_stereo_flag(
}
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ if ( output_config == AUDIO_CONFIG_STEREO )
+ {
+ sba_dirac_stereo_flag = 1;
+ }
+ }
+#endif
return sba_dirac_stereo_flag;
}
@@ -849,7 +858,11 @@ void ivas_sba_dirac_stereo_dec(
memOffset = NS2SA( output_frame * FRAMES_PER_SEC, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS );
ivas_sba_dirac_stereo_config( hStereoDft->hConfig );
+#ifdef SBA_AND_OBJECTS
+ hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) );
+#else
hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) );
+#endif
stereo_dft_dec_update( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ );
if ( st_ivas->nchan_transport > 1 )
{
@@ -873,9 +886,18 @@ void ivas_sba_dirac_stereo_dec(
/* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */
map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0],
st_ivas->ivas_format == MC_FORMAT,
+#ifdef SBA_AND_OBJECTS
+ ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame,
+ ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) );
+#else
( st_ivas->ivas_format != SBA_FORMAT || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame,
( st_ivas->ivas_format != SBA_FORMAT || mcmasa ) );
+#endif
+#ifdef SBA_AND_OBJECTS
+ if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa )
+#endif
{
set_f( hStereoDft->res_pred_gain, 1.f, 3 * STEREO_DFT_BAND_MAX );
}
@@ -923,7 +945,11 @@ void ivas_sba_dirac_stereo_dec(
ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain );
ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame,
+#ifdef SBA_AND_OBJECTS
+ ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft );
+#else
( st_ivas->ivas_format != SBA_FORMAT || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft );
+#endif
/* add HB to ACELP core */
v_add( output[0], hb_synth_stereo[0], output[0], output_frame );
@@ -932,7 +958,11 @@ void ivas_sba_dirac_stereo_dec(
v_add( output[1], hb_synth_stereo[1], output[1], output_frame );
/* apply TD Stereo Filling as is done in ICBWE */
+#ifdef SBA_AND_OBJECTS
+ ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) );
+#else
ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) );
+#endif
}
}
diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c
index 643c7b5a6c2146f49bcab96c21cf047bec9e4b1d..c0d40f88230c3f082001ca8b9ab45a7daf47b863 100644
--- a/lib_dec/ivas_sba_rendering_internal.c
+++ b/lib_dec/ivas_sba_rendering_internal.c
@@ -404,15 +404,34 @@ void ivas_sba_upmixer_renderer(
if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
{
+#ifdef SBA_AND_OBJECTS
+ float *output_f[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
+#else
float *output_f[MAX_OUTPUT_CHANNELS];
+#endif
int16_t ch;
+#ifdef SBA_AND_OBJECTS
+ AUDIO_CONFIG output_config;
+ output_config = ( st_ivas->ivas_format == SBA_ISM_FORMAT ? st_ivas->hOutSetup.output_config : st_ivas->hDecoderConfig->output_config );
+#endif
+#ifdef SBA_AND_OBJECTS
+ for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ )
+#else
for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
+#endif
{
output_f[ch] = output[ch];
}
-
+#ifdef SBA_AND_OBJECTS
+ ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE,
+#ifdef SBA_AND_OBJECTS
+ st_ivas->nchan_ism,
+#endif
+ output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
+#else
ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
+#endif
}
pop_wmops();
@@ -487,9 +506,12 @@ static void ivas_sba_mtx_mult(
*-------------------------------------------------------------------*/
ivas_error ivas_sba_linear_renderer(
- float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nchan_in, /* i : number of input ambisonics channels */
+ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */
+ const int16_t output_frame, /* i : output frame length per channel */
+ const int16_t nchan_in, /* i : number of input ambisonics channels */
+#ifdef SBA_AND_OBJECTS
+ const int16_t nchan_ism,
+#endif
const AUDIO_CONFIG output_config, /* i : output audio configuration */
const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */
const float hoa_dec_mtx[] /* i : HOA decoding mtx */
@@ -558,6 +580,18 @@ ivas_error ivas_sba_linear_renderer(
set_zero( output_f[i], output_frame );
}
break;
+#ifdef SBA_AND_OBJECTS
+ case AUDIO_CONFIG_EXTERNAL:
+ for ( i = output_setup.nchan_out_woLFE - 1; i >= nchan_ism; i-- )
+ {
+ mvr2r( output_f[i - nchan_ism], output_f[i], output_frame );
+ }
+ for ( ; i >= 0; i-- )
+ {
+ set_zero( output_f[i], output_frame );
+ }
+ break;
+#endif
default:
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: illegal output configuration, Exiting.\n" );
}
diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c
index 3f8d8052e45698e1507143d36861f32f4213f0f9..57b3c3c5afabc19e7a5c6e36b51a626e8d7c5816 100755
--- a/lib_dec/ivas_sce_dec.c
+++ b/lib_dec/ivas_sce_dec.c
@@ -165,6 +165,12 @@ ivas_error ivas_sce_dec(
{
st->bits_frame_nominal = (int16_t) ( hSCE->element_brate / FRAMES_PER_SEC );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ism_mode == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ st->bits_frame_nominal = (int16_t) ( st_ivas->hSpar->core_nominal_brate / FRAMES_PER_SEC );
+ }
+#endif
else
{
st->bits_frame_nominal = st_ivas->hQMetaData->bits_frame_nominal;
diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c
index eaf08a8de82753f131db0b3d2962db8d47e79496..3695bf7bd08b1989bf406e137333e3e4da119c49 100755
--- a/lib_dec/ivas_spar_decoder.c
+++ b/lib_dec/ivas_spar_decoder.c
@@ -324,14 +324,47 @@ ivas_error ivas_spar_dec(
bit_stream_orig = st0->bit_stream;
next_bit_pos_orig = st0->next_bit_pos;
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+#ifndef SBA_AND_OBJECTS
+ last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 );
+ /* the number of objects was read */
+ last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ;
+ *nb_bits_read += NO_BITS_MASA_ISM_NO_OBJ;
+#else
+ last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1];
+#endif
+ }
+ else
+ {
+ *nb_bits_read = 0;
+ last_bit_pos = 0;
+ }
+#endif
+
/* read DirAC bitstream */
if ( st_ivas->hQMetaData != NULL )
{
- ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read,
- ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands );
+#ifdef SBA_AND_OBJECTS
+ ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands );
+#else
+ ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands );
+#endif
}
- last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 );
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1];
+ }
+ else
+ {
+#endif
+ last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 );
+#ifdef SBA_AND_OBJECTS
+ }
+#endif
if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
{
last_bit_pos -= SID_FORMAT_NBITS;
@@ -1707,6 +1740,7 @@ void ivas_spar_dec_upmixer_sf(
idx_lfe = 0;
outchannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe;
+
for ( ch = 0; ch < outchannels; ch++ )
{
if ( ( st_ivas->hOutSetup.num_lfe > 0 ) && ( st_ivas->hOutSetup.index_lfe[idx_lfe] == ch ) )
@@ -1719,11 +1753,12 @@ void ivas_spar_dec_upmixer_sf(
}
else
{
- if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB
+ if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ||
+ !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
- || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM
+ || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
- ) )
+ ) )
{
for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h
old mode 100644
new mode 100755
index 7848e09fe066693b3bd3ac850a841fa26e1b4d68..1defa26d393367b67ef3ba3c10cf20b23cc8c4b8
--- a/lib_dec/ivas_stat_dec.h
+++ b/lib_dec/ivas_stat_dec.h
@@ -465,6 +465,10 @@ typedef struct dirac_output_synthesis_cov_state_structure
} DIRAC_OUTPUT_SYNTHESIS_COV_STATE;
+
+/*----------------------------------------------------------------------------------*
+ * ParamMC structures
+ *----------------------------------------------------------------------------------*/
typedef struct ivas_param_mc_diff_proto_info_structure
{
int16_t num_protos_diff;
@@ -1073,14 +1077,18 @@ typedef struct Decoder_Struct
COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */
DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Spatial parametric (DirAC rend, ParamBin, ParamISM) rendering common data handle. */
-#ifdef MASA_AND_OBJECTS
- MASA_ISM_DATA_HANDLE hMasaIsmData; /* MASA_ISM rendering structure */
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
+ MASA_ISM_DATA_HANDLE hMasaIsmData;
+#endif
+
#ifndef FIX_657_REMOVE_EDITING
uint8_t editing_ism_enabled; /* Todo Nokia: Temporary, used until proper ISM control available */
int16_t index_of_edited_ism; /* Todo Nokia: Temporary, used until proper ISM control available */
int16_t azimuth_edited; /* Todo Nokia: Temporary, used until proper ISM control available */
int16_t elevation_edited; /* Todo Nokia: Temporary, used until proper ISM control available */
#endif
+
+#ifdef MASA_AND_OBJECTS
int16_t flag_omasa_brate;
#endif
diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c
index 1019868229ad8d7ccdfb5612080c181ead59d50e..325ec91b0b4ce1b31c69fbdb3170cb0fa106be9f 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec.c
@@ -215,9 +215,11 @@ void stereo_mdct_core_dec(
set_s( ms_mask[1], 0, MAX_SFB );
initMdctStereoDecData( hCPE->hStereoMdct, sts[0]->igf, sts[0]->hIGFDec->igfData.igfInfo.grid, hCPE->element_brate, sts[0]->bwidth );
-
+#ifdef SBA_AND_OBJECTS
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#else
hCPE->hStereoMdct->isSBAStereoMode = ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
-
+#endif
if ( !bfi )
{
ivas_mdct_dec_side_bits_frame_channel( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], nTnsBitsTCX10, param, 0, 0 );
diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c
index a4de639cb976cfebe0b3cf9442f71e9a79b26c46..9debd252991819ef9a43c22a54a75634a227b314 100644
--- a/lib_dec/lib_dec.c
+++ b/lib_dec/lib_dec.c
@@ -497,6 +497,10 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat(
return IVAS_DEC_BS_MC;
case SBA_FORMAT:
return IVAS_DEC_BS_SBA;
+#ifdef SBA_AND_OBJECTS
+ case SBA_ISM_FORMAT:
+ return IVAS_DEC_BS_SBA_ISM;
+#endif
case MASA_FORMAT:
return IVAS_DEC_BS_MASA;
#ifdef MASA_AND_OBJECTS
@@ -1097,14 +1101,16 @@ ivas_error IVAS_DEC_GetNumObjects(
{
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
-
+ if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT
+#ifdef SBA_AND_OBJECTS
+ || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT
+#endif
#ifdef MASA_AND_OBJECTS
- if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT )
-#else
- if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT )
+ || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT
#endif
+ )
{
-#ifdef MASA_AND_OBJECTS
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
*numObjects = hIvasDec->st_ivas->nchan_ism;
#else
*numObjects = hIvasDec->st_ivas->hDecoderConfig->nchan_out;
@@ -1190,17 +1196,19 @@ ivas_error IVAS_DEC_GetObjectMetadata(
}
st_ivas = hIvasDec->st_ivas;
-
+ if ( st_ivas->ivas_format != ISM_FORMAT
#ifdef MASA_AND_OBJECTS
- if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT )
-#else
- if ( st_ivas->ivas_format != ISM_FORMAT )
+ && st_ivas->ivas_format != MASA_ISM_FORMAT
+#endif
+#ifdef SBA_AND_OBJECTS
+ && st_ivas->ivas_format != SBA_ISM_FORMAT
#endif
+ )
{
return IVAS_ERR_WRONG_MODE;
}
-#ifdef MASA_AND_OBJECTS
+#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS
if ( objectIdx >= st_ivas->nchan_ism )
#else
if ( objectIdx >= st_ivas->hDecoderConfig->nchan_out )
@@ -2765,6 +2773,12 @@ static ivas_error printConfigInfo_dec(
{
fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ {
+ fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism );
+ }
+#endif
else if ( st_ivas->ivas_format == MASA_FORMAT )
{
fprintf( stdout, "Input configuration: MASA - %d channel(s)\n", st_ivas->nchan_transport );
diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h
index ba6432bd303ba1f521407316824f3e78e4626a41..12ca06607f7ac5077bebd78a216dd8c6d674595d 100644
--- a/lib_dec/lib_dec.h
+++ b/lib_dec/lib_dec.h
@@ -114,6 +114,9 @@ typedef enum _IVAS_DEC_BS_FORMAT
IVAS_DEC_BS_STEREO,
IVAS_DEC_BS_MC,
IVAS_DEC_BS_SBA,
+#ifdef SBA_AND_OBJECTS
+ IVAS_DEC_BS_SBA_ISM,
+#endif
IVAS_DEC_BS_OBJ,
IVAS_DEC_BS_MASA,
#ifdef MASA_AND_OBJECTS
diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c
index 6f43073801eb2dcf7f69d0daefd2a99c23110f63..2367bcc560df898debe9681b4a86cdfcb4764b52 100644
--- a/lib_enc/ivas_corecoder_enc_reconfig.c
+++ b/lib_enc/ivas_corecoder_enc_reconfig.c
@@ -534,7 +534,11 @@ ivas_error ivas_corecoder_enc_reconfig(
st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->stereo_mode_cmdl;
#endif
initMdctStereoEncData( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct, hEncoderConfig->ivas_format, st_ivas->hCPE[st_ivas->nCPE - 1]->element_mode, st_ivas->hCPE[st_ivas->nCPE - 1]->element_brate, hEncoderConfig->max_bwidth, 0, NULL, 1 );
+#ifdef OSBA_BR_SWITCHING
+ st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT || hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#else
st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#endif
}
}
diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c
index 2d7c49c781d490e36f5a22c95ee3ff895541560f..fe3ac5535bd403b512b7675cae116841b7518034 100644
--- a/lib_enc/ivas_cpe_enc.c
+++ b/lib_enc/ivas_cpe_enc.c
@@ -376,7 +376,11 @@ ivas_error ivas_cpe_enc(
hCPE->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->mdct_stereo_mode_cmdl;
#endif
initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 0 );
+#ifdef SBA_AND_OBJECTS
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#else
hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#endif
}
}
@@ -551,7 +555,11 @@ ivas_error ivas_cpe_enc(
if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) )
{
initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 );
+#ifdef SBA_AND_OBJECTS
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#else
hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#endif
if ( hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT )
{
@@ -1090,7 +1098,11 @@ ivas_error create_cpe_enc(
hCPE->hStereoMdct->mdct_stereo_mode_cmdl = st_ivas->hEncoderConfig->mdct_stereo_mode_cmdl;
#endif
initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 1 );
+#ifdef SBA_AND_OBJECTS
+ hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#else
hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
+#endif
if ( hCPE->element_mode == IVAS_CPE_MDCT && element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT )
{
diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c
old mode 100644
new mode 100755
index 4a54136079644ac80202a7e45bbfc61977c67212..85738e1e003bf4ab99cd542e1e044a2b16d16dc8
--- a/lib_enc/ivas_enc.c
+++ b/lib_enc/ivas_enc.c
@@ -66,7 +66,11 @@ ivas_error ivas_enc(
#else
int16_t nb_bits_metadata[MAX_SCE];
#endif
+#ifdef SBA_AND_OBJECTS
+ float data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k];
+#else
float data_f[MAX_INPUT_CHANNELS][L_FRAME48k];
+#endif
int32_t ivas_total_brate;
ivas_error error;
error = IVAS_ERR_OK;
@@ -382,6 +386,148 @@ ivas_error ivas_enc(
return error;
}
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_ISM_FORMAT )
+ {
+
+#ifdef SBA_AND_OBJECTS
+ ivas_osba_enc_reconfig( st_ivas );
+#endif
+
+#ifndef SBA_AND_OBJECTS
+ if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/
+ {
+#endif
+ /* Analyze objects and determine needed audio signals */
+ ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order
+#ifdef SBA_AND_OBJECTS
+ ,
+ hEncoderConfig->input_Fs
+#endif
+ );
+#ifndef SBA_AND_OBJECTS
+ }
+#endif
+
+ if ( st_ivas->ism_mode == ISM_MODE_NONE )
+ {
+ if ( st_ivas->nchan_transport == 1 )
+ {
+ st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0];
+ hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData;
+ }
+ else
+ {
+ st = st_ivas->hCPE[0]->hCoreCoder[0];
+ hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
+ }
+
+ if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 )
+ {
+ /* Write SBA planar flag */
+ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );
+
+ /* hack to indicate OSBA bitstream at VLBR */
+ push_indice( st->hBstr, IND_SMODE, 0, SBA_ORDER_BITS );
+ }
+ else
+ {
+ /* Write SBA order */
+ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
+ }
+
+ /* write the number of objects in ISM_SBA format*/
+ push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ );
+
+ /* SBA metadata encoding and SBA metadata bitstream writing */
+ if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* core-coding of transport channels */
+ if ( st_ivas->nSCE == 1 )
+ {
+ if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */
+ {
+ if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */
+ {
+ if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ else
+ {
+
+ n = hEncoderConfig->nchan_ism;
+ st = st_ivas->hCPE[0]->hCoreCoder[0];
+ hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
+#ifdef SBA_AND_OBJECTS
+
+ if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE )
+ {
+ /* write the number of objects in ISM_SBA format*/
+ push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ );
+ }
+
+ if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st->ini_frame ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
+
+ /* Write SBA planar flag */
+ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );
+
+ /* Write SBA order */
+ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
+
+ /* SBA metadata encoding and SBA metadata bitstream writing */
+ if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* get SBA TCs */
+ ivas_sba_getTCs( &data_f[n], st_ivas, input_frame );
+
+ /* encode SBA transport channels */
+ if ( st_ivas->nchan_transport == 1 )
+ {
+ if ( ( error = ivas_sce_enc( st_ivas, hEncoderConfig->nchan_ism, data_f[n], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */
+ {
+ if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */
+ {
+ if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ }
#endif
else if ( ivas_format == MC_FORMAT )
{
diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c
index 330046a5cd99e8018a00c71825d5872ea9e18553..e9ab1849b14a66b2bf093e5553c6a8023c00a9c7 100644
--- a/lib_enc/ivas_init_enc.c
+++ b/lib_enc/ivas_init_enc.c
@@ -99,6 +99,20 @@ void ivas_write_format(
nBits += extra_bits + IVAS_COMBINED_FORMAT_SIGNALLING_BITS;
}
break;
+#endif
+#ifdef SBA_AND_OBJECTS
+ case SBA_ISM_FORMAT:
+ if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 )
+ {
+ ind = 6; /* send SBA format */
+ nBits += extra_bits;
+ }
+ else
+ {
+ ind = 11; /* 1011 */
+ nBits += extra_bits + IVAS_COMBINED_FORMAT_SIGNALLING_BITS;
+ }
+ break;
#endif
default:
assert( !"Invalid format. Aborting." );
@@ -224,6 +238,12 @@ int16_t getNumChanAnalysis(
{
n = st_ivas->hEncoderConfig->nchan_inp;
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
+ {
+ n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 );
+ }
#endif
return n;
}
@@ -343,6 +363,11 @@ void ivas_initialize_handles_enc(
st_ivas->hOMasa = NULL;
#endif
+#ifdef SBA_AND_OBJECTS
+ /* OSBA handle */
+ st_ivas->hOSba = NULL;
+#endif
+
return;
}
@@ -634,6 +659,95 @@ ivas_error ivas_init_encoder(
return error;
}
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_ISM_FORMAT )
+ {
+ int32_t element_brate_tmp[MAX_NUM_OBJECTS];
+ st_ivas->ism_mode = ISM_MODE_NONE;
+
+ if ( ivas_total_brate >= IVAS_256k )
+ {
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ }
+
+ if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* allocate and initialize SBA handles */
+ if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order );
+
+ if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( error = ivas_dirac_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( st_ivas->ism_mode == ISM_MODE_NONE )
+ {
+ sce_id = 0;
+ /* allocate and initialize SBA core-coders */
+ if ( st_ivas->nchan_transport == 1 )
+ {
+
+ if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ {
+ if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( st_ivas->nCPE > 1 )
+ {
+ if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ else
+ {
+ /* allocate and initialize MCT core coder */
+
+ st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
+
+ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
+ {
+ if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( ( error = ivas_osba_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
#endif
else if ( ivas_format == MC_FORMAT )
{
@@ -1068,6 +1182,11 @@ void ivas_destroy_enc(
ivas_omasa_enc_close( &( st_ivas->hOMasa ) );
#endif
+#ifdef SBA_AND_OBJECTS
+ /* OSBA handle */
+ ivas_osba_enc_close( &( st_ivas->hOSba ) );
+#endif
+
/* Stereo downmix for EVS encoder handle */
stereo_dmx_evs_close_encoder( &( st_ivas->hStereoDmxEVS ) );
diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c
index 6dbc40f1b48cc0d170d583b09f976dc0b563afbe..5b95543061e2947c7793d566c2214e5b9a5be312 100644
--- a/lib_enc/ivas_ism_enc.c
+++ b/lib_enc/ivas_ism_enc.c
@@ -249,7 +249,12 @@ ivas_error ivas_ism_enc(
{
#ifdef MASA_AND_OBJECTS
ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
- nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL );
+ nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame
+#endif
+ );
#else
ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag );
#endif
@@ -273,7 +278,12 @@ ivas_error ivas_ism_enc(
ism_total_brate_ref = ism_total_brate;
ivas_ism_metadata_enc( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData,
- nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, st_ivas->hMasa != NULL ? st_ivas->hMasa->data.hOmasaData->lp_noise_CPE : 0, flag_omasa_ener_brate, st_ivas->hMasa != NULL ? &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt ) : NULL );
+ nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, st_ivas->hMasa != NULL ? st_ivas->hMasa->data.hOmasaData->lp_noise_CPE : 0, flag_omasa_ener_brate, st_ivas->hMasa != NULL ? &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt ) : NULL
+#ifdef SBA_AND_OBJECTS
+ ,
+ st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame
+#endif
+ );
if ( st_ivas->hEncoderConfig->ivas_format == MASA_ISM_FORMAT )
{
@@ -297,6 +307,14 @@ ivas_error ivas_ism_enc(
ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr );
}
+#ifdef SBA_AND_OBJECTS
+ /*only metadata encoding is needed for this case*/
+ if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
+ {
+ assert( st_ivas->ism_mode != ISM_MODE_NONE );
+ return error;
+ }
+#endif
/*------------------------------------------------------------------*
* CoreCoders encoding
*-----------------------------------------------------------------*/
diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c
old mode 100644
new mode 100755
index 3154eb56a7b39de30d5305d94f7b9ccb2ad940b7..9ee8effec32422cf3e3ffb49a15226f93d5c705f
--- a/lib_enc/ivas_ism_metadata_enc.c
+++ b/lib_enc/ivas_ism_metadata_enc.c
@@ -189,6 +189,10 @@ ivas_error ivas_ism_metadata_enc(
const int16_t flag_omasa_ener_brate, /* i : less bitrate for objects in OMASA flag */
int16_t *omasa_stereo_sw_cnt
#endif
+#ifdef SBA_AND_OBJECTS
+ ,
+ const int16_t ini_frame
+#endif
)
{
int16_t i, ch, nb_bits_start = 0;
@@ -249,7 +253,11 @@ ivas_error ivas_ism_metadata_enc(
hIsmMeta[ch]->ism_metadata_flag = 1;
}
#ifdef MASA_AND_OBJECTS
- else if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC )
+ else if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC
+#ifdef SBA_AND_OBJECTS
+ || ism_mode == ISM_SBA_MODE_DISC
+#endif
+ )
#else
else if ( ism_mode == ISM_MODE_DISC )
#endif
@@ -258,8 +266,13 @@ ivas_error ivas_ism_metadata_enc(
if ( hIsmMeta[ch]->ism_metadata_flag == 1 )
{
- /* In case of low level noise for low bitrate inactive frames, do not sent metadata */
- hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly;
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode != ISM_SBA_MODE_DISC )
+#endif
+ {
+ /* In case of low level noise for low bitrate inactive frames, do not sent metadata */
+ hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly;
+ }
/* in inactive frames, send MD 1) in ISM_MD_INC_DIFF_CNT_MAX consecutive frames when MD significantly change, 2) at least every ISM_MD_FEC_DIFF frames */
if ( hIsmMeta[ch]->ism_metadata_flag == 0 )
@@ -301,8 +314,14 @@ ivas_error ivas_ism_metadata_enc(
/*----------------------------------------------------------------*
* Rate importance of particular ISM streams
*----------------------------------------------------------------*/
-
- rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode != ISM_SBA_MODE_DISC )
+ {
+ rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
+ }
+#else
+ rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp );
+#endif
#ifdef MASA_AND_OBJECTS
}
#endif
@@ -312,7 +331,11 @@ ivas_error ivas_ism_metadata_enc(
*----------------------------------------------------------------*/
#ifdef MASA_AND_OBJECTS
- if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ )
+ if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ
+#ifdef SBA_AND_OBJECTS
+ && ism_mode != ISM_SBA_MODE_DISC
+#endif
+ )
{
#endif
/* write number of objects - unary coding */
@@ -334,7 +357,11 @@ ivas_error ivas_ism_metadata_enc(
/* write extended metadata presence flag */
#ifdef MASA_AND_OBJECTS
+#ifdef SBA_AND_OBJECTS
+ if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE )
+#else
if ( ism_mode == ISM_MODE_DISC && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE )
+#endif
#else
if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE )
#endif
@@ -360,6 +387,9 @@ ivas_error ivas_ism_metadata_enc(
hIsmMeta[ch]->ism_md_lowrate_flag = lowrate_metadata_flag[ch];
}
else
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode != ISM_SBA_MODE_DISC )
+#endif
{
#endif
if ( null_metadata_flag[ch] )
@@ -386,6 +416,13 @@ ivas_error ivas_ism_metadata_enc(
}
#ifdef MASA_AND_OBJECTS
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else /*ism_mode == ISM_SBA_MODE_DISC*/
+ {
+ /* all objects are considered active*/
+ push_indice( hBstr, IND_ISM_METADATA_FLAG, 1, 1 );
+ }
#endif
}
@@ -409,7 +446,11 @@ ivas_error ivas_ism_metadata_enc(
{
hIsmMetaData = hIsmMeta[ch];
#ifdef MASA_AND_OBJECTS
- if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
+ if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ
+#ifdef SBA_AND_OBJECTS
+ || ism_mode == ISM_SBA_MODE_DISC
+#endif
+ )
#else
if ( ism_mode == ISM_MODE_DISC )
#endif
@@ -419,7 +460,6 @@ ivas_error ivas_ism_metadata_enc(
if ( hIsmMeta[ch]->ism_metadata_flag || lowrate_metadata_flag[ch] )
{
-
/*----------------------------------------------------------------*
* Quantize and encode azimuth and elevation
*----------------------------------------------------------------*/
@@ -449,7 +489,11 @@ ivas_error ivas_ism_metadata_enc(
else
{
#ifdef MASA_AND_OBJECTS
- if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
+ if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ
+#ifdef SBA_AND_OBJECTS
+ || ism_mode == ISM_SBA_MODE_DISC
+#endif
+ )
#else
if ( ism_mode == ISM_MODE_DISC )
#endif
@@ -462,27 +506,41 @@ ivas_error ivas_ism_metadata_enc(
idx_angle1_abs = hParamIsm->azi_index[ch];
idx_angle2_abs = hParamIsm->ele_index[ch];
}
-
+#ifdef SBA_AND_OBJECTS
+ encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] );
+#else
encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] );
+#endif
/*----------------------------------------------------------------*
* Quantize and encode radius, yaw, and pitch
*----------------------------------------------------------------*/
-
+#ifdef SBA_AND_OBJECTS
+ if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_extended_metadata_flag )
+#else
if ( ism_mode == ISM_MODE_DISC && ism_extended_metadata_flag )
+#endif
{
idx_angle1_abs = ism_quant_meta( hIsmMetaData->yaw, &valQ, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS );
idx_angle2_abs = ism_quant_meta( hIsmMetaData->pitch, &valQ, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS );
idx_radius_abs = usquant( hIsmMetaData->radius, &valQ, ISM_RADIUS_MIN, ISM_RADIUS_DELTA, 1 << ISM_RADIUS_NBITS );
+#ifdef SBA_AND_OBJECTS
+ encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
+#else
encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
+#endif
encode_radius( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] );
}
}
/* save number of metadata bits written */
#ifdef MASA_AND_OBJECTS
- if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
+ if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ
+#ifdef SBA_AND_OBJECTS
+ || ism_mode == ISM_SBA_MODE_DISC
+#endif
+ )
#else
if ( ism_mode == ISM_MODE_DISC )
#endif
@@ -568,6 +626,34 @@ ivas_error ivas_ism_metadata_enc(
}
}
+#ifdef SBA_AND_OBJECTS
+ if ( ism_mode == ISM_SBA_MODE_DISC )
+ {
+ int16_t md_diff_flag[MAX_NUM_OBJECTS];
+
+ set_s( md_diff_flag, 1, nchan_ism );
+ for ( ch = 0; ch < nchan_ism; ch++ )
+ {
+ hIsmMeta[ch]->last_ism_metadata_flag = hIsmMeta[ch]->ism_metadata_flag;
+
+ if ( hIsmMeta[ch]->ism_metadata_flag == 0 )
+ {
+ hIsmMeta[ch]->ism_md_fec_cnt_enc++;
+ }
+ else
+ {
+ hIsmMeta[ch]->ism_md_fec_cnt_enc = 0;
+ }
+ hIsmMeta[ch]->ism_md_inc_diff_cnt++;
+ hIsmMeta[ch]->ism_md_inc_diff_cnt = min( hIsmMeta[ch]->ism_md_inc_diff_cnt, ISM_MD_INC_DIFF_CNT_MAX );
+ }
+
+ update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag );
+
+ pop_wmops();
+ return error;
+ }
+#endif
if ( ism_mode == ISM_MODE_PARAM )
{
/* Keep the metdata transmission as is during active parts */
@@ -793,6 +879,12 @@ ivas_error ivas_ism_metadata_enc_create(
nchan_transport = MAX_PARAM_ISM_WAVE;
ivas_set_omasa_TC( st_ivas->ism_mode, n_ISms, &st_ivas->nSCE, &st_ivas->nCPE );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
+ {
+ nchan_transport = n_ISms;
+ }
+#endif
else
{
#endif
diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c
index 99eb1d9eb54c821911b006c5fcfeb7f89b2c34ad..29763d1400ba051da78c38a579475d793bd5634c 100644
--- a/lib_enc/ivas_mct_core_enc.c
+++ b/lib_enc/ivas_mct_core_enc.c
@@ -486,10 +486,20 @@ void ivas_mct_core_enc(
nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS;
nAvailBits -= MC_LS_SETUP_BITS;
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
else if ( ivas_format == SBA_FORMAT )
+#endif
{
nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED;
nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS;
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 )
+ {
+ nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS;
+ }
+#endif
}
for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ )
@@ -563,6 +573,9 @@ void ivas_mct_core_enc(
#ifdef DEBUGGING
format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS );
+#ifdef SBA_AND_OBJECTS
+ format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS );
+#endif
mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE;
assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate );
#endif
diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c
index 42ce327a4c47ea85b0f53df6a61a4a4bf336f632..e392da6aed4c8f6aea177270dd0d673e122b82de 100644
--- a/lib_enc/ivas_mct_enc.c
+++ b/lib_enc/ivas_mct_enc.c
@@ -109,7 +109,15 @@ static void map_input_to_cpe_channels(
)
{
int16_t i, n;
+#ifdef SBA_AND_OBJECTS
+ int16_t nchan_transport;
+ nchan_transport = st_ivas->nchan_transport;
+ if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ nchan_transport += st_ivas->hEncoderConfig->nchan_ism;
+ }
+#endif
i = 0;
for ( n = 0; n < LFE_CHANNEL - 1; n++ )
@@ -119,7 +127,11 @@ static void map_input_to_cpe_channels(
}
if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) )
{
+#ifndef SBA_AND_OBJECTS
for ( n = LFE_CHANNEL + 1; n < st_ivas->nchan_transport; n++ )
+#else
+ for ( n = LFE_CHANNEL + 1; n < nchan_transport; n++ )
+#endif
{
pdata[i] = data[n];
i++;
@@ -128,7 +140,11 @@ static void map_input_to_cpe_channels(
}
else
{
+#ifndef SBA_AND_OBJECTS
for ( ; n < st_ivas->nchan_transport; n++ )
+#else
+ for ( ; n < nchan_transport; n++ )
+#endif
{
pdata[i] = data[n];
i++;
@@ -136,7 +152,12 @@ static void map_input_to_cpe_channels(
}
/* odd channel CPE*/
+#ifndef SBA_AND_OBJECTS
if ( ( st_ivas->nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) )
+#else
+ if ( ( nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) )
+
+#endif
{
pdata[st_ivas->nCPE * CPE_CHANNELS - 1] = NULL;
}
@@ -304,9 +325,19 @@ ivas_error create_mct_enc(
{
hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
else if ( ivas_format == SBA_FORMAT )
+#endif
{
hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order );
+#ifdef SBA_AND_OBJECTS
+ if ( ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ hMCT->nchan_out_woLFE += st_ivas->hEncoderConfig->nchan_ism;
+ }
+#endif
}
else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC )
{
@@ -430,7 +461,11 @@ ivas_error mct_enc_reconfigure(
{
hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+#else
else if ( ivas_format == SBA_FORMAT )
+#endif
{
hMCT->nchan_out_woLFE = st_ivas->nchan_transport;
}
diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c
new file mode 100644
index 0000000000000000000000000000000000000000..d66126fe267938a98db0321e2fd8f87392a2c382
--- /dev/null
+++ b/lib_enc/ivas_osba_enc.c
@@ -0,0 +1,493 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 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
+#include
+#include
+#include "ivas_cnst.h"
+#include "ivas_prot.h"
+#include "prot.h"
+#include "ivas_rom_com.h"
+#include "ivas_rom_enc.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+#include "wmc_auto.h"
+
+#ifdef SBA_AND_OBJECTS
+
+/*-------------------------------------------------------------------------
+ * Local function prototypes
+ *------------------------------------------------------------------------*/
+
+static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_sba, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][MAX_INPUT_CHANNELS], const float interpolator[L_FRAME48k] );
+
+/*-------------------------------------------------------------------*
+ * ivas_merge_sba_transports()
+ *
+ * Merge SBA transport channels
+ *-------------------------------------------------------------------*/
+
+static void ivas_merge_sba_transports(
+ float data_in_f1[][L_FRAME48k],
+ float data_in_f2[][L_FRAME48k],
+ float data_out_f[][L_FRAME48k],
+ const int16_t input_frame,
+ const int16_t sba_analysis_order )
+{
+ int16_t i, j, nchan_sba;
+
+ nchan_sba = ( sba_analysis_order + 1 ) * ( sba_analysis_order + 1 );
+
+ for ( i = 0; i < nchan_sba; i++ )
+ {
+ for ( j = 0; j < input_frame; j++ )
+ {
+ data_out_f[i][j] = data_in_f1[i][j] + data_in_f2[i][j];
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * ivas_osba_enc_open()
+ *
+ * Allocate and initialize OMASA handle
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_osba_enc_open(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+)
+{
+ int16_t i;
+ OSBA_ENC_HANDLE hOSba;
+ int16_t input_frame;
+ ivas_error error;
+ int16_t len;
+ error = IVAS_ERR_OK;
+
+
+ if ( ( hOSba = (OSBA_ENC_HANDLE) malloc( sizeof( OSBA_ENC_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA encoder\n" ) );
+ }
+
+
+ for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
+ {
+ set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), MAX_INPUT_CHANNELS );
+ }
+
+ len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS );
+
+ for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ )
+ {
+ if ( ( hOSba->input_data_mem[i] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA input buffers" );
+ }
+ set_f( hOSba->input_data_mem[i], 0.0f, len );
+ }
+
+ for ( ; i < MAX_NUM_OBJECTS; i++ )
+ {
+ hOSba->input_data_mem[i] = NULL;
+ }
+
+ input_frame = (int16_t) ( st_ivas->hEncoderConfig->input_Fs / FRAMES_PER_SEC );
+ for ( i = 0; i < input_frame; i++ )
+ {
+ hOSba->interpolator[i] = ( (float) i ) / ( (float) input_frame );
+ }
+
+ st_ivas->hOSba = hOSba;
+
+ return error;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_omasa_enc_close()
+ *
+ * Close OMASA handle
+ *--------------------------------------------------------------------------*/
+
+void ivas_osba_enc_close(
+ OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */
+)
+{
+ if ( hOSba == NULL || *hOSba == NULL )
+ {
+ return;
+ }
+
+ for ( int16_t n = 0; n < MAX_NUM_OBJECTS; n++ )
+ {
+ if ( ( *hOSba )->input_data_mem[n] != NULL )
+ {
+ free( ( *hOSba )->input_data_mem[n] );
+ ( *hOSba )->input_data_mem[n] = NULL;
+ }
+ }
+
+ free( *hOSba );
+ ( *hOSba ) = NULL;
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_osba_enc_reconfig()
+ *
+ * oSBA encoder reconfiguration
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_osba_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+)
+{
+
+ int16_t n, nSCE_old, nCPE_old, nchan_transport_old;
+ ISM_MODE old_ism_mode;
+ int32_t ivas_total_brate;
+ ivas_error error;
+ ENCODER_CONFIG_HANDLE hEncoderConfig;
+
+ error = IVAS_ERR_OK;
+ hEncoderConfig = st_ivas->hEncoderConfig;
+ ivas_total_brate = hEncoderConfig->ivas_total_brate;
+
+ if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate )
+ {
+ DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC;
+ SPAR_ENC_HANDLE hSpar;
+ int16_t analysis_order_old;
+ int16_t spar_reconfig_flag;
+ int16_t nbands_old;
+ int16_t ndir_old;
+
+ spar_reconfig_flag = 0;
+ old_ism_mode = st_ivas->ism_mode;
+ if ( ivas_total_brate >= IVAS_256k )
+ {
+ st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ }
+ else
+ {
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ }
+ 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;
+ ndir_old = st_ivas->hQMetaData->no_directions;
+
+ if ( ( analysis_order_old != st_ivas->sba_analysis_order ) || ( old_ism_mode != st_ivas->ism_mode ) )
+ {
+ int16_t i, n_old;
+ float **old_mem_hp20_in;
+
+ n_old = st_ivas->hEncoderConfig->nchan_ism + ( analysis_order_old + 1 ) * ( analysis_order_old + 1 );
+ n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 );
+
+ if ( n > n_old )
+ {
+ /* save old mem_hp_20 pointer */
+ old_mem_hp20_in = st_ivas->mem_hp20_in;
+ st_ivas->mem_hp20_in = NULL;
+
+ if ( ( st_ivas->mem_hp20_in = (float **) malloc( n * sizeof( float * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
+ }
+
+ for ( i = 0; i < n_old; i++ )
+ {
+ st_ivas->mem_hp20_in[i] = old_mem_hp20_in[i];
+ old_mem_hp20_in[i] = NULL;
+ }
+ /* create additional hp20 memories */
+ for ( ; i < n; i++ )
+ {
+ if ( ( st_ivas->mem_hp20_in[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
+ }
+
+ set_f( st_ivas->mem_hp20_in[i], 0.0f, L_HP20_MEM );
+ }
+
+ free( old_mem_hp20_in );
+ old_mem_hp20_in = NULL;
+ }
+ else if ( n < n_old )
+ {
+ /* save old mem_hp_20 pointer */
+ old_mem_hp20_in = st_ivas->mem_hp20_in;
+ st_ivas->mem_hp20_in = NULL;
+
+ if ( ( st_ivas->mem_hp20_in = (float **) malloc( n * sizeof( float * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
+ }
+
+ for ( i = 0; i < n; i++ )
+ {
+ st_ivas->mem_hp20_in[i] = old_mem_hp20_in[i];
+ old_mem_hp20_in[i] = NULL;
+ }
+ /* remove superfluous hp20 memories */
+ for ( ; i < n_old; i++ )
+ {
+ free( old_mem_hp20_in[i] );
+ old_mem_hp20_in[i] = NULL;
+ }
+
+ free( old_mem_hp20_in );
+ old_mem_hp20_in = NULL;
+ }
+ }
+ ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ),
+ &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 );
+ hSpar = st_ivas->hSpar;
+
+ if ( st_ivas->nchan_transport == 1 )
+ {
+ hEncoderConfig->element_mode_init = IVAS_SCE;
+ }
+ else
+ {
+ hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ }
+ if ( nchan_transport_old != st_ivas->nchan_transport || ( ivas_total_brate < IVAS_512k && hEncoderConfig->last_ivas_total_brate >= IVAS_512k ) || ( ivas_total_brate >= IVAS_512k && hEncoderConfig->last_ivas_total_brate < IVAS_512k ) )
+ {
+ /* FB mixer handle */
+ if ( hDirAC->hFbMixer != NULL )
+ {
+ ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 );
+ hDirAC->hFbMixer = NULL;
+ }
+ spar_reconfig_flag = 1;
+ ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag );
+
+ if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ st_ivas->hSpar->spar_reconfig_flag = spar_reconfig_flag;
+ if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ if ( st_ivas->hQMetaData->q_direction->cfg.nbands != nbands_old || st_ivas->hQMetaData->no_directions != ndir_old )
+ {
+ int16_t dir, j, i;
+ IVAS_QDIRECTION *q_direction = st_ivas->hQMetaData->q_direction;
+ for ( dir = 0; dir < st_ivas->hQMetaData->no_directions; dir++ )
+ {
+ for ( j = 0; j < q_direction[dir].cfg.nbands; j++ )
+ {
+ for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
+ {
+ q_direction[dir].band_data[j].energy_ratio_index[i] = 0;
+ q_direction[dir].band_data[j].energy_ratio_index_mod[i] = 0;
+ }
+ }
+ }
+ }
+ hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band;
+
+ /*-----------------------------------------------------------------*
+ * Allocate, initialize, and configure SCE/CPE/MCT handles
+ *-----------------------------------------------------------------*/
+ if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nchan_transport += st_ivas->hEncoderConfig->nchan_ism;
+ st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
+ }
+ else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE )
+ {
+ nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism;
+ }
+ else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ st_ivas->nchan_transport += st_ivas->hEncoderConfig->nchan_ism;
+ st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
+ nCPE_old = st_ivas->nCPE;
+ nchan_transport_old = st_ivas->nchan_transport;
+ }
+
+ 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 )
+ {
+ return error;
+ }
+
+ if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ {
+ /*retain original value for further processing*/
+ st_ivas->nchan_transport -= st_ivas->hEncoderConfig->nchan_ism;
+ }
+ }
+
+ return error;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_osba_enc()
+ *
+ * Main OSBA encoding function
+ *--------------------------------------------------------------------------*/
+
+void ivas_osba_enc(
+ OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */
+ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */
+ float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */
+ const int16_t input_frame, /* i : Input frame size */
+ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */
+ const ISM_MODE ism_mode, /* i : ISM mode */
+ const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */
+ const int32_t input_Fs /* i : input sampling rate*/
+)
+{
+ float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k];
+ int16_t n, delay_s;
+ delay_s = NS2SA( input_Fs, IVAS_FB_ENC_DELAY_NS );
+
+ if ( ism_mode == ISM_MODE_NONE )
+ {
+ /*keep the delay buffer up to date*/
+ for ( n = 0; n < nchan_ism; n++ )
+ {
+ mvr2r( &data_in_f[n][input_frame - delay_s], hOSba->input_data_mem[n], delay_s );
+ }
+ /* Convert ISM to SBA */
+ ivas_osba_render_ism_to_sba( data_in_f, data_out_f, input_frame, sba_analysis_order, nchan_ism, hIsmMeta, hOSba->prev_object_dm_gains, hOSba->interpolator );
+
+ /* Merge SBA signals */
+ ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, sba_analysis_order );
+ }
+ else
+ {
+ int16_t azimuth, elevation;
+ /* delay ISM input channels to match the SBA encoder delay */
+ for ( n = 0; n < nchan_ism; n++ )
+ {
+ delay_signal( data_in_f[n], input_frame, hOSba->input_data_mem[n], delay_s );
+
+
+ /*keep prev gain upto date for bitrate switching*/
+ azimuth = (int16_t) floorf( hIsmMeta[n]->azimuth + 0.5f );
+ elevation = (int16_t) floorf( hIsmMeta[n]->elevation + 0.5f );
+ ivas_dirac_dec_get_response( azimuth, elevation, hOSba->prev_object_dm_gains[n], sba_analysis_order );
+ }
+ }
+
+ /* Set the number of objects */
+ hOSba->nchan_ism = nchan_ism;
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * Local functions
+ *--------------------------------------------------------------------------*/
+
+/* Render ISMs to SBA */
+static void ivas_osba_render_ism_to_sba(
+ float data_in_f[][L_FRAME48k],
+ float data_out_f[][L_FRAME48k],
+ const int16_t input_frame,
+ const int16_t sba_analysis_order,
+ const int16_t nchan_ism,
+ ISM_METADATA_HANDLE hIsmMeta[],
+ float prev_gains[][MAX_INPUT_CHANNELS],
+ const float interpolator[L_FRAME48k] )
+{
+ int16_t i, j, k;
+ int16_t azimuth, elevation;
+ float gains[MAX_INPUT_CHANNELS];
+ float g1, g2;
+ float output_gain;
+
+ int16_t nchan_sba;
+
+ nchan_sba = ( sba_analysis_order + 1 ) * ( sba_analysis_order + 1 );
+
+ for ( i = 0; i < nchan_sba; i++ )
+ {
+ set_zero( data_out_f[i], input_frame );
+ }
+
+ for ( i = 0; i < nchan_ism; i++ )
+ {
+ azimuth = (int16_t) floorf( hIsmMeta[i]->azimuth + 0.5f );
+ elevation = (int16_t) floorf( hIsmMeta[i]->elevation + 0.5f );
+
+ ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_analysis_order );
+
+ /* Render using the sh gains */
+ for ( j = 0; j < nchan_sba; j++ )
+ {
+ if ( fabsf( gains[j] ) > 0.0 || fabsf( prev_gains[i][j] ) > 0.0f )
+ {
+ for ( k = 0; k < input_frame; k++ )
+ {
+ g1 = interpolator[k];
+ g2 = 1.0f - g1;
+ data_out_f[j][k] += ( g1 * gains[j] + g2 * prev_gains[i][j] ) * data_in_f[i][k];
+ }
+ }
+ prev_gains[i][j] = gains[j];
+ }
+ }
+
+ /* Gain with loudness-matching gains */
+ output_gain = 0.7499f;
+ for ( j = 0; j < nchan_sba; j++ )
+ {
+ for ( k = 0; k < input_frame; k++ )
+ {
+ data_out_f[j][k] *= output_gain;
+ }
+ }
+
+ return;
+}
+#endif /* SBA_AND_OBJECTS */
diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c
index 8bb75ffc9d13325df899b81b1456b330ff6e63a7..0e82d0856642a0ccc2f4eed978da8db1b9f87dbb 100644
--- a/lib_enc/ivas_spar_encoder.c
+++ b/lib_enc/ivas_spar_encoder.c
@@ -337,8 +337,6 @@ ivas_error ivas_spar_enc(
error = IVAS_ERR_OK;
hEncoderConfig = st_ivas->hEncoderConfig;
- /* check last sba_mode */
-
/* front VAD */
if ( ( error = front_vad_spar( st_ivas->hSpar, data_f[0], hEncoderConfig, input_frame ) ) != IVAS_ERR_OK )
{
diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h
index 6a7dd965fd74d8ec075cb1bf68c7b51aebda6fa4..138e09b5c4f22b262465123de8a6d493ca538d40 100644
--- a/lib_enc/ivas_stat_enc.h
+++ b/lib_enc/ivas_stat_enc.h
@@ -715,6 +715,10 @@ typedef struct ivas_spar_enc_lib_t
int16_t front_vad_dtx_flag;
int16_t force_front_vad;
+#ifdef SBA_AND_OBJECTS
+ float *input_data_mem[MAX_NUM_OBJECTS];
+#endif
+
} SPAR_ENC_DATA, *SPAR_ENC_HANDLE;
@@ -929,6 +933,22 @@ typedef struct ivas_mcmasa_enc_data_structure
} MCMASA_ENC_DATA, *MCMASA_ENC_HANDLE;
+#ifdef SBA_AND_OBJECTS
+/*----------------------------------------------------------------------------------*
+ * Object SBA (OSBA) encoder structure
+ *----------------------------------------------------------------------------------*/
+
+typedef struct ivas_osba_enc_data_structure
+{
+
+ float interpolator[L_FRAME48k];
+ float prev_object_dm_gains[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS];
+
+ int16_t nchan_ism;
+ float *input_data_mem[MAX_NUM_OBJECTS];
+
+} OSBA_ENC_DATA, *OSBA_ENC_HANDLE;
+#endif
/*----------------------------------------------------------------------------------*
* Stereo CNG handle
@@ -1226,6 +1246,9 @@ typedef struct
PARAM_MC_ENC_HANDLE hParamMC; /* Parametric MC handle */
MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix; /* MC Param-Upmix handle */
MCMASA_ENC_HANDLE hMcMasa; /* Multi-channel MASA data handle */
+#ifdef SBA_AND_OBJECTS
+ OSBA_ENC_HANDLE hOSba; /* Object-SBA data handle */
+#endif
#ifdef MASA_AND_OBJECTS
OMASA_ENC_HANDLE hOMasa; /* Object-MASA data handle */
#endif
diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c
index 1d80309090970df62d0b0887a19d8ff3cd62a58d..12a80a034fbd4ac5fde00de2befd963abfadff14 100644
--- a/lib_enc/lib_enc.c
+++ b/lib_enc/lib_enc.c
@@ -454,7 +454,11 @@ ivas_error IVAS_ENC_FeedObjectMetadata(
}
#ifdef MASA_AND_OBJECTS
- if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != MASA_ISM_FORMAT )
+ if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != MASA_ISM_FORMAT
+#ifdef SBA_AND_OBJECTS
+ && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != SBA_ISM_FORMAT
+#endif
+ )
#else
if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT )
#endif
@@ -543,6 +547,57 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics(
return error;
}
+#ifdef SBA_AND_OBJECTS
+/*---------------------------------------------------------------------*
+ * IVAS_ENC_ConfigureForSBAObjects()
+ *
+ * Configure and initialize the combined SBA and ISM encoder.
+ *---------------------------------------------------------------------*/
+
+ivas_error IVAS_ENC_ConfigureForSBAObjects(
+ IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */
+ const int32_t inputFs, /* i : input sampling frequency */
+ const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */
+ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */
+ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */
+ const uint16_t numObjects, /* i : number of objects to be encoded */
+ const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */
+ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */
+ const bool Opt_PCA_ON /* i : PCA option flag */
+)
+{
+ Encoder_Struct *st_ivas;
+ ivas_error error;
+
+ if ( ( error = doCommonConfigureChecks( hIvasEnc ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( numObjects > MAX_NUM_OBJECTS )
+ {
+ return IVAS_ERR_TOO_MANY_INPUTS;
+ }
+ st_ivas = hIvasEnc->st_ivas;
+
+ st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */
+ st_ivas->hEncoderConfig->sba_planar = isPlanar;
+ st_ivas->hEncoderConfig->sba_order = order;
+
+ /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */
+ st_ivas->hEncoderConfig->nchan_inp = ivas_sba_get_nchan( st_ivas->hEncoderConfig->sba_order, isPlanar ) + numObjects;
+
+ st_ivas->hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON;
+
+ /* Currently this is true but it is already shown in descriptive metadata that there can be inequality for this. */
+ st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp - numObjects;
+ st_ivas->hEncoderConfig->ivas_format = SBA_ISM_FORMAT;
+ st_ivas->hEncoderConfig->nchan_ism = numObjects;
+
+ return configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() );
+}
+#endif
+
/*---------------------------------------------------------------------*
* IVAS_ENC_ConfigureForMasa()
@@ -865,6 +920,12 @@ static ivas_error configureEncoder(
}
}
}
+#endif
+#ifdef SBA_AND_OBJECTS
+ else if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
+ {
+ st_ivas->ism_mode = ISM_MODE_NONE;
+ }
#endif
}
else /* EVS mono */
@@ -944,6 +1005,9 @@ static ivas_error configureEncoder(
hEncoderConfig->ivas_format == MC_FORMAT
#ifdef MASA_AND_OBJECTS
|| hEncoderConfig->ivas_format == MASA_ISM_FORMAT
+#endif
+#ifdef SBA_AND_OBJECTS
+ || hEncoderConfig->ivas_format == SBA_ISM_FORMAT
#endif
) )
{
@@ -1669,6 +1733,12 @@ static ivas_error printConfigInfo_enc(
fprintf( stdout, "IVAS mode: Multi-Channel 7.1+4\n" );
}
}
+#ifdef SBA_AND_OBJECTS
+ else if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
+ {
+ fprintf( stdout, "IVAS format: combined ISM and SBA (%i ISM stream(s))\n", hEncoderConfig->nchan_ism );
+ }
+#endif
#ifdef MASA_AND_OBJECTS
else if ( hEncoderConfig->ivas_format == MASA_ISM_FORMAT )
{
diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h
index 8c015a99e4c6a74c448d525e589a6a633d316da9..95de2d3a64ec53c62b2eaccd90c3499f46f21b48 100644
--- a/lib_enc/lib_enc.h
+++ b/lib_enc/lib_enc.h
@@ -52,6 +52,9 @@ typedef enum _IVAS_ENC_INPUT_FORMAT
IVAS_ENC_INPUT_MC,
#ifdef MASA_AND_OBJECTS
IVAS_ENC_INPUT_MASA_ISM,
+#endif
+#ifdef SBA_AND_OBJECTS
+ IVAS_ENC_INPUT_SBA_ISM,
#endif
IVAS_DEC_INPUT_UNKNOWN = 0xffff
} IVAS_ENC_INPUT_FORMAT;
@@ -217,6 +220,21 @@ ivas_error IVAS_ENC_ConfigureForMASAObjects(
);
#endif
+#ifdef SBA_AND_OBJECTS
+/*! r: encoder error code */
+ivas_error IVAS_ENC_ConfigureForSBAObjects(
+ IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */
+ const int32_t inputFs, /* i : input sampling frequency */
+ const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */
+ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */
+ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */
+ const uint16_t numObjects, /* i : number of objects to be encoded */
+ const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */
+ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */
+ const bool Opt_PCA_ON /* i : PCA option flag */
+);
+#endif
+
/*! r: error code */
ivas_error IVAS_ENC_ConfigureForAmbisonics(
IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */
diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c
index 35ad9794872c2633879bf23f666509d595f8f02b..2b882468eb60f5526ba8a2a33f3c348f80d9d608 100644
--- a/lib_rend/ivas_dirac_dec_binaural_functions.c
+++ b/lib_rend/ivas_dirac_dec_binaural_functions.c
@@ -631,7 +631,11 @@ void ivas_dirac_dec_binaural(
}
ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS );
+#ifdef SBA_AND_OBJECTS
+ if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT )
+#endif
{
ivas_spar_dec_set_render_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS );
}
@@ -876,8 +880,12 @@ static void ivas_dirac_dec_binaural_internal(
Cldfb_RealBuffer_in[ch][slot],
Cldfb_ImagBuffer_in[ch][slot],
nBins, st_ivas->cldfbAnaDec[ch] );
-
+#ifdef SBA_AND_OBJECTS
+ if ( config_data.nchan_transport == 1 &&
+ ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) )
+#else
if ( config_data.nchan_transport == 1 && config_data.ivas_format == SBA_FORMAT )
+#endif
{
v_multc( Cldfb_RealBuffer_in[ch][slot], INV_SQRT_2, Cldfb_RealBuffer_in[ch][slot], nBins );
v_multc( Cldfb_ImagBuffer_in[ch][slot], INV_SQRT_2, Cldfb_ImagBuffer_in[ch][slot], nBins );
@@ -886,7 +894,11 @@ static void ivas_dirac_dec_binaural_internal(
}
}
+#ifdef SBA_AND_OBJECTS
+ if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT )
+#else
if ( config_data.ivas_format == SBA_FORMAT )
+#endif
{
hDiracDecBin->hDiffuseDist = &diffuseDistData;
@@ -1033,7 +1045,11 @@ static void ivas_dirac_dec_binaural_internal(
hDiracDecBin = st_ivas->hDiracDecBin[pos_idx];
assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" );
+#ifdef SBA_AND_OBJECTS
+ if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT )
+#else
if ( config_data.ivas_format == SBA_FORMAT )
+#endif
{
hDiracDecBin->hDiffuseDist = &diffuseDistData;
}
@@ -1249,7 +1265,11 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices(
}
}
+#ifdef SBA_AND_OBJECTS
+ if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 2 )
+#else
if ( ivas_format == SBA_FORMAT && nchan_transport == 2 )
+#endif
{
float tempRe, tempIm;
#ifdef FIX_647_SILENT_W_PARAMBIN
@@ -1669,7 +1689,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices(
}
else /* When rendering binaural, ambience has frequency dependent ICC. */
{
+#ifdef SBA_AND_OBJECTS
+ if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS )
+#else
if ( ivas_format == SBA_FORMAT && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS )
+#endif
{
float diffuseFieldCoherence;
diffuseFieldCoherence = hDiracDecBin->hDiffuseDist->diffuseRatioX[bin] * hDiracDecBin->diffuseFieldCoherenceX[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioY[bin] * hDiracDecBin->diffuseFieldCoherenceY[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioZ[bin] * hDiracDecBin->diffuseFieldCoherenceZ[bin];
@@ -2360,7 +2384,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices(
{
decorrelationReductionFactor = sqrtf( fmaxf( 0.0f, hDiracDecBin->frameMeanDiffuseness[bin] ) );
}
+#ifdef SBA_AND_OBJECTS
+ else if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 1 )
+#else
else if ( ivas_format == SBA_FORMAT && nchan_transport == 1 )
+#endif
{
decorrelationReductionFactor = 1.0f;
}
diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c
index d5bb1052c03ff0759def506ce7af1211315dde45..8d3b50613c2a5adfdb62d77391872bacaa1529da 100644
--- a/lib_rend/ivas_dirac_rend.c
+++ b/lib_rend/ivas_dirac_rend.c
@@ -241,11 +241,14 @@ ivas_error ivas_spat_hSpatParamRendCom_config(
#endif
}
- /*-----------------------------------------------------------------*
- * set input parameters
- *-----------------------------------------------------------------*/
-
+/*-----------------------------------------------------------------*
+ * set input parameters
+ *-----------------------------------------------------------------*/
+#ifdef SBA_AND_OBJECTS
+ if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && flag_config == DIRAC_RECONFIGURE )
+#else
if ( ivas_format == SBA_FORMAT && flag_config == DIRAC_RECONFIGURE )
+#endif
{
if ( hodirac_flag && hSpatParamRendCom->azimuth2 == NULL )
{
@@ -311,7 +314,13 @@ ivas_error ivas_spat_hSpatParamRendCom_config(
}
#ifdef MASA_AND_OBJECTS
- if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT || ( ivas_format == SBA_FORMAT && hodirac_flag ) )
+ if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT
+#ifdef SBA_AND_OBJECTS
+ || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag )
+#else
+ || ( ivas_format == SBA_FORMAT && hodirac_flag )
+#endif
+ )
#else
if ( ivas_format == MASA_FORMAT || ( ivas_format == SBA_FORMAT && hodirac_flag ) )
#endif
diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c
index f6abe725d107bf3ec787c1b5a551b15f5658d8f5..ccfbca98fcd3669857413e3942603954a0758d9b 100644
--- a/lib_rend/ivas_objectRenderer.c
+++ b/lib_rend/ivas_objectRenderer.c
@@ -195,7 +195,11 @@ ivas_error ivas_td_binaural_open_unwrap(
}
#ifdef MASA_AND_OBJECTS
- if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT )
+ if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT
+#ifdef SBA_AND_OBJECTS
+ || ivas_format == SBA_ISM_FORMAT
+#endif
+ )
#else
if ( ivas_format == ISM_FORMAT )
#endif
@@ -239,7 +243,11 @@ ivas_error ivas_td_binaural_open_unwrap(
*hBinRendererTd = pBinRendTd;
#ifdef MASA_AND_OBJECTS
- if ( ivas_format != MASA_ISM_FORMAT )
+ if ( ivas_format != MASA_ISM_FORMAT
+#ifdef SBA_AND_OBJECTS
+ && ivas_format != SBA_ISM_FORMAT
+#endif
+ )
{
*binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f );
}
@@ -525,7 +533,11 @@ void TDREND_Update_object_positions(
for ( nS = 0; nS < num_src; nS++ )
{
#ifdef MASA_AND_OBJECTS
- if ( in_format == ISM_FORMAT || in_format == MASA_ISM_FORMAT )
+ if ( in_format == ISM_FORMAT || in_format == MASA_ISM_FORMAT
+#ifdef SBA_AND_OBJECTS
+ || in_format == SBA_ISM_FORMAT
+#endif
+ )
#else
if ( in_format == ISM_FORMAT )
#endif
diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c
index efbb188f8bc8beb3deec9298c88d01e0106feea6..40734c6ede38dba3bc78d6006a5d822cea25fa8e 100644
--- a/lib_rend/ivas_splitRendererPre.c
+++ b/lib_rend/ivas_splitRendererPre.c
@@ -1899,9 +1899,13 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper,
const int16_t is_pcm_out )
{
ivas_error error, ch, num_ch;
+#ifndef OSBA_SPLIT_RENDERING
CLDFB_TYPE cldfbMode;
+#endif
uint8_t isCldfbNeeded = 0;
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode = CLDFB_ANALYSIS;
+#endif
if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, is_pcm_out ) ) != IVAS_ERR_OK )
{
@@ -1913,44 +1917,77 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper,
if ( is_cldfb_in == 0 )
{
isCldfbNeeded = 1;
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode = CLDFB_ANALYSIS;
+#endif
}
else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && is_cldfb_in )
{
+#ifdef OSBA_SPLIT_RENDERING
+ isCldfbNeeded = 1;
+#else
isCldfbNeeded = 1;
cldfbMode = CLDFB_SYNTHESIS;
+#endif
}
else if ( is_pcm_out && is_cldfb_in )
{
+#ifdef OSBA_SPLIT_RENDERING
+ isCldfbNeeded = 1;
+#else
isCldfbNeeded = 1;
cldfbMode = CLDFB_SYNTHESIS;
+#endif
}
hSplitRendWrapper->hCldfbHandles = NULL;
+
if ( isCldfbNeeded )
{
if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) );
}
-
num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS;
for ( ch = 0; ch < num_ch; ch++ )
{
hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
}
+#ifdef OSBA_SPLIT_RENDERING
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL;
+ }
+#endif
+
num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS;
for ( ch = 0; ch < num_ch; ch++ )
{
if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ),
+#ifndef OSBA_SPLIT_RENDERING
cldfbMode,
+#else
+ CLDFB_ANALYSIS,
+#endif
OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
{
return error;
}
}
+
+#ifdef OSBA_SPLIT_RENDERING
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ),
+ CLDFB_SYNTHESIS,
+ OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+#endif
}
if ( pSplitRendConfig->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
@@ -2015,6 +2052,18 @@ void ivas_split_renderer_close( SPLIT_REND_WRAPPER *hSplitBinRend )
hSplitBinRend->hCldfbHandles->cldfbAna[ch] = NULL;
}
}
+
+#ifdef OSBA_SPLIT_RENDERING
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ if ( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL )
+ {
+ deleteCldfb( &hSplitBinRend->hCldfbHandles->cldfbSyn[ch] );
+ hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL;
+ }
+ }
+#endif
+
free( hSplitBinRend->hCldfbHandles );
hSplitBinRend->hCldfbHandles = NULL;
}
@@ -2379,7 +2428,11 @@ ivas_error ivas_renderMultiBinToSplitBinaural(
Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx];
Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx];
}
+#ifndef OSBA_SPLIT_RENDERING
cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] );
+#else
+ cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] );
+#endif
}
if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, out ) ) != IVAS_ERR_OK )
@@ -2402,7 +2455,11 @@ ivas_error ivas_renderMultiBinToSplitBinaural(
Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx];
Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx];
}
+#ifndef OSBA_SPLIT_RENDERING
cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] );
+#else
+ cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] );
+#endif
}
pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode;
diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h
index 6e78e069b4c0cf15ba3e1cf543eaf40485048244..b6cdca9f1619d68cbe68a7eed74644f37f226e9a 100644
--- a/lib_rend/ivas_stat_rend.h
+++ b/lib_rend/ivas_stat_rend.h
@@ -689,9 +689,11 @@ typedef struct
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
HANDLE_CLDFB_FILTER_BANK cldfbAna[( 1 + MAX_HEAD_ROT_POSES ) * BINAURAL_CHANNELS];
#else
- /* TODO(sgi): rename to "cldfb" during harmonization - these handles are sometimes also used for synthesis */
HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS];
#endif
+#ifdef OSBA_SPLIT_RENDERING
+ HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS];
+#endif
} CLDFB_HANDLES_WRAPPER, *CLDFB_HANDLES_WRAPPER_HANDLE;
typedef struct
diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c
index 253c1d84b6b5caa3c53f5093cd570fa91f2ed122..31ff94083735b0c465e705ecf2cef44ddf3df85f 100644
--- a/lib_rend/lib_rend.c
+++ b/lib_rend/lib_rend.c
@@ -5160,6 +5160,9 @@ ivas_error IVAS_REND_SetHeadRotation(
hIvasRend->headRotData.headPositions[i].x = 0.0f;
hIvasRend->headRotData.headPositions[i].y = 0.0f;
hIvasRend->headRotData.headPositions[i].z = 0.0f;
+ hIvasRend->headRotData.Pos[i].x = 0.0f;
+ hIvasRend->headRotData.Pos[i].y = 0.0f;
+ hIvasRend->headRotData.Pos[i].z = 0.0f;
}
}
else
diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm
index c9b59d4f3cd244e7548e53f39e1084acf02a8289..ece3c2ed920237d4a72787e3c28f0a4780fa7ba0 100644
--- a/scripts/config/self_test.prm
+++ b/scripts/config/self_test.prm
@@ -1381,3 +1381,59 @@ networkSimulator_g192 ../scripts/dly_error_profiles/dly_error_profile_5.dat bit
../IVAS_cod -ism_masa 4 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv testv/stv2MASA2TC48c.met ../scripts/switchPaths/sw_13k2_512k_2fr_start_384k_omasatechs_4ism.bin 48 testv/stvOMASA_4ISM_2MASA2TC48c.wav bit
../IVAS_dec BINAURAL_ROOM_REVERB 48 bit testv/stvOMASA_4ISM_2MASA2TC48c.wav_BINAURAL_ROOM_REVERB_sw_48-48.tst
+
+// OSBA FOA 1ISM at 32 kbps, 48kHz in, 48kHz out, BINAURAL out
+//../IVAS_cod -ism_sba 1 1 testv/stvISM1.csv 32000 48 testv/stvOSBA_1ISM_FOA48c.wav bit
+//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_1ISM_FOA48c.wav_BINAURAL_32000_48-48.tst
+
+// OSBA FOA 2ISM at 64 kbps, 48kHz in, 48kHz out, HOA3 out
+//../IVAS_cod -ism_sba 2 1 testv/stvISM1.csv testv/stvISM2.csv 64000 48 testv/stvOSBA_2ISM_FOA48c.wav bit
+//../IVAS_dec HOA3 48 bit testv/stvOSBA_2ISM_FOA48c.wav_HOA3_64000_48-48.tst
+
+// OSBA FOA 3ISM at 128 kbps, 48kHz in, 48kHz out, 7_1_4 out
+//../IVAS_cod -ism_sba 3 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_FOA48c.wav bit
+//../IVAS_dec 7_1_4 48 bit testv/stvOSBA_3ISM_FOA48c.wav_7_1_4_128000_48-48.tst
+
+// OSBA FOA 4ISM at 256 kbps, 48kHz in, 48kHz out, EXT out
+//../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit
+//../IVAS_dec EXT 48 bit testv/stvOSBA_4ISM_FOA48c.wav_EXT_256000_48-48.tst
+
+// OSBA FOA 4ISM at 512 kbps, 48kHz in, 48kHz out, BINAURAL out
+//../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit
+//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst
+
+// OSBA 2OA 1ISM at 24.4 kbps, 48kHz in, 48kHz out, FOA out
+//../IVAS_cod -ism_sba 1 2 testv/stvISM1.csv 24400 48 testv/stvOSBA_1ISM_2OA48c.wav bit
+//../IVAS_dec FOA 48 bit testv/stvOSBA_1ISM_2OA48c.wav_FOA_24400_48-48.tst
+
+// OSBA 2OA 2ISM at 48 kbps, 48kHz in, 48kHz out, MONO out
+//../IVAS_cod -ism_sba 2 2 testv/stvISM1.csv testv/stvISM2.csv 48000 48 testv/stvOSBA_2ISM_2OA48c.wav bit
+//../IVAS_dec MONO 48 bit testv/stvOSBA_2ISM_2OA48c.wav_MONO_48000_48-48.tst
+
+// OSBA 2OA 3ISM at 96 kbps, 48kHz in, 48kHz out, STEREO out
+//../IVAS_cod -ism_sba 3 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 96000 48 testv/stvOSBA_3ISM_2OA48c.wav bit
+//../IVAS_dec STEREO 48 bit testv/stvOSBA_3ISM_2OA48c.wav_STEREO_96000_48-48.tst
+
+// OSBA 2OA 4ISM at 384 kbps, 48kHz in, 48kHz out, BINAURAL out
+//../IVAS_cod -ism_sba 4 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 384000 48 testv/stvOSBA_4ISM_2OA48c.wav bit
+//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_2OA48c.wav_BINAURAL_384000_48-48.tst
+
+// OSBA 3OA 1ISM at 512 kbps, 48kHz in, 48kHz out, EXT out
+//../IVAS_cod -ism_sba 1 3 testv/stvISM1.csv 512000 48 testv/stvOSBA_1ISM_3OA48c.wav bit
+//../IVAS_dec EXT 48 bit testv/stvOSBA_1ISM_3OA48c.wav_EXT_512000_48-48.tst
+
+// OSBA 3OA 2ISM at 256 kbps, 48kHz in, 48kHz out, 7_1 out
+//../IVAS_cod -ism_sba 2 3 testv/stvISM1.csv testv/stvISM2.csv 256000 48 testv/stvOSBA_2ISM_3OA48c.wav bit
+//../IVAS_dec 7_1 48 bit testv/stvOSBA_2ISM_3OA48c.wav_7_1_256000_48-48.tst
+
+// OSBA 3OA 3ISM at 128 kbps, 48kHz in, 48kHz out, BINAURAL out
+//../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_3OA48c.wav bit
+//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_3ISM_3OA48c.wav_BINAURAL_128000_48-48.tst
+
+// OSBA 3OA 4ISM at 16.4 kbps, 48kHz in, 48kHz out, 5_1 out
+//../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 16400 48 testv/stvOSBA_4ISM_3OA48c.wav bit
+//../IVAS_dec 5_1 48 bit testv/stvOSBA_4ISM_3OA48c.wav_5_1_16400_48-48.tst
+
+// OSBA 3OA 4ISM bitrate switching 13.2 to 512, 48kHz in, 48kHz out, BIN out
+//../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv switchPaths/sw_13k2_512k.bin 48 testv/stvOSBA_4ISM_3OA48c.wav bit
+//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_3OA48c.wav_BINAURAL_sw_13k2_512k_48-48.tst
diff --git a/scripts/testv/stvOSBA_1ISM_2OA48c.wav b/scripts/testv/stvOSBA_1ISM_2OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..29db3aa5dd4f9ff518e8b4a57a880d568cae95f2
--- /dev/null
+++ b/scripts/testv/stvOSBA_1ISM_2OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:7664fa3a3e2cabed85ee80cac657932509403f20df557f3228c81bd569da24f2
+size 19200558
diff --git a/scripts/testv/stvOSBA_1ISM_3OA48c.wav b/scripts/testv/stvOSBA_1ISM_3OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..ec3db290da7bac55a89f3c454984d7dea045a78a
--- /dev/null
+++ b/scripts/testv/stvOSBA_1ISM_3OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:79178d7cfe0601d5c30573b19718fd15681d6e98f4e54cf54608f35775c28fcc
+size 32640908
diff --git a/scripts/testv/stvOSBA_1ISM_FOA48c.wav b/scripts/testv/stvOSBA_1ISM_FOA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..e13733b9d60a6477fcbbb0ee045bb089ff8be7ff
--- /dev/null
+++ b/scripts/testv/stvOSBA_1ISM_FOA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3635635d169efb32d5c13a732961cf786fa3413261376b47b7d7a1cb05b4353b
+size 9600308
diff --git a/scripts/testv/stvOSBA_2ISM_2OA48c.wav b/scripts/testv/stvOSBA_2ISM_2OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..950224b1127d2c45d29875ef3fbd5d4788c13259
--- /dev/null
+++ b/scripts/testv/stvOSBA_2ISM_2OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:489f5e16c9c0f1539304b05d65c16e901b271e51aa9f8cf50d5a17a78b094afa
+size 21120608
diff --git a/scripts/testv/stvOSBA_2ISM_3OA48c.wav b/scripts/testv/stvOSBA_2ISM_3OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..a4705b6a4b0a25170adb8872fcbfda64af3cff03
--- /dev/null
+++ b/scripts/testv/stvOSBA_2ISM_3OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:57b26cedbb5a2e94147bb9e35030313c77a3fbbfae54c31249271c34646d6cea
+size 34560958
diff --git a/scripts/testv/stvOSBA_2ISM_FOA48c.wav b/scripts/testv/stvOSBA_2ISM_FOA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..24621227476f07a2e69533eb8c4ec32e7d9d06a9
--- /dev/null
+++ b/scripts/testv/stvOSBA_2ISM_FOA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9111e9152d64b07f664f9ec383d5025bb4dd8559c758763f4aad8850ddee07c6
+size 11520358
diff --git a/scripts/testv/stvOSBA_3ISM_2OA48c.wav b/scripts/testv/stvOSBA_3ISM_2OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..060ee4dd8adc31164a0cb57773bdc5129d1440db
--- /dev/null
+++ b/scripts/testv/stvOSBA_3ISM_2OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:95538891804a01d3cef90f791380621946729fbd7211792e64c2f4dcd644748d
+size 23040658
diff --git a/scripts/testv/stvOSBA_3ISM_3OA48c.wav b/scripts/testv/stvOSBA_3ISM_3OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..fd42874d9eb6c8a322656942e9e9696379b5117c
--- /dev/null
+++ b/scripts/testv/stvOSBA_3ISM_3OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f37e3fcdcd1b0d65955e5f85626bb726de522ce9076fd5e13290093943c1f4f7
+size 36481008
diff --git a/scripts/testv/stvOSBA_3ISM_FOA48c.wav b/scripts/testv/stvOSBA_3ISM_FOA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..5b83e7e149a2f958985555e307d8ff76a6499992
--- /dev/null
+++ b/scripts/testv/stvOSBA_3ISM_FOA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:42934c64888b445fde28d8adf15588f4d5cad2952935da6902de63eff844b01c
+size 13440408
diff --git a/scripts/testv/stvOSBA_4ISM_2OA48c.wav b/scripts/testv/stvOSBA_4ISM_2OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..5e9b98fb41bd9e8fdad81e0e29565530cb10eb93
--- /dev/null
+++ b/scripts/testv/stvOSBA_4ISM_2OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5d9bfd27855b58648e3b2d690d748ef7bc6802cc185a1ba9aa89b1e29ed5be3a
+size 24960708
diff --git a/scripts/testv/stvOSBA_4ISM_3OA48c.wav b/scripts/testv/stvOSBA_4ISM_3OA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..00505bfd777d1513000c6fb135e90b7c2d73a61f
--- /dev/null
+++ b/scripts/testv/stvOSBA_4ISM_3OA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f38c65c89564220f4e93fcefdf6e797541d2fe03066e980fd207681f3a7d4917
+size 38401058
diff --git a/scripts/testv/stvOSBA_4ISM_FOA48c.wav b/scripts/testv/stvOSBA_4ISM_FOA48c.wav
new file mode 100644
index 0000000000000000000000000000000000000000..7f1be2e75952b49ac8ad21a3f51ae999fc24f964
--- /dev/null
+++ b/scripts/testv/stvOSBA_4ISM_FOA48c.wav
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6e8a25490b47def9fe5b6f58c35ae2d103e166c397dfe48c55e1410d07c16a44
+size 15360458