Skip to content
...@@ -354,7 +354,11 @@ ivas_error ivas_spar_dec( ...@@ -354,7 +354,11 @@ ivas_error ivas_spar_dec(
/* read DirAC bitstream */ /* read DirAC bitstream */
if ( st_ivas->hQMetaData != NULL ) if ( st_ivas->hQMetaData != NULL )
{ {
#ifdef NONBE_FIX_1052_SBA_EXT
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->nchan_transport, 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, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); 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 );
#endif
} }
if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
...@@ -368,7 +372,11 @@ ivas_error ivas_spar_dec( ...@@ -368,7 +372,11 @@ ivas_error ivas_spar_dec(
if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
{ {
#ifdef NONBE_FIX_1052_SBA_EXT
last_bit_pos -= ( SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS );
#else
last_bit_pos -= SID_FORMAT_NBITS; last_bit_pos -= SID_FORMAT_NBITS;
#endif
} }
nb_bits_read_orig = *nb_bits_read; nb_bits_read_orig = *nb_bits_read;
last_bit_pos -= nb_bits_read_orig; last_bit_pos -= nb_bits_read_orig;
...@@ -403,7 +411,11 @@ ivas_error ivas_spar_dec( ...@@ -403,7 +411,11 @@ ivas_error ivas_spar_dec(
if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
{ {
int16_t zero_pad_bits; int16_t zero_pad_bits;
#ifdef NONBE_FIX_1052_SBA_EXT
*nb_bits_read += SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS;
#else
*nb_bits_read += SID_FORMAT_NBITS; *nb_bits_read += SID_FORMAT_NBITS;
#endif
zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read; zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read;
assert( zero_pad_bits <= 1 ); assert( zero_pad_bits <= 1 );
*nb_bits_read += zero_pad_bits; *nb_bits_read += zero_pad_bits;
...@@ -1565,6 +1577,7 @@ void ivas_spar_dec_upmixer_sf( ...@@ -1565,6 +1577,7 @@ void ivas_spar_dec_upmixer_sf(
{ {
md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; md_idx = hSpar->render_to_md_map[ts + slot_idx_start];
ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat );
if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) )
{ {
for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
......
...@@ -2385,6 +2385,9 @@ static void ivas_parse_parameter_bitstream_dtx( ...@@ -2385,6 +2385,9 @@ static void ivas_parse_parameter_bitstream_dtx(
float pr_min_max[2]; float pr_min_max[2];
int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits; int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits;
int16_t zero_pad_bits, sid_bits_len; int16_t zero_pad_bits, sid_bits_len;
#ifdef NONBE_FIX_1052_SBA_EXT
int16_t sba_spar_bitlen;
#endif
sid_bits_len = st0->next_bit_pos; sid_bits_len = st0->next_bit_pos;
pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[0] = pSpar_md->min_max[0];
...@@ -2443,7 +2446,12 @@ static void ivas_parse_parameter_bitstream_dtx( ...@@ -2443,7 +2446,12 @@ static void ivas_parse_parameter_bitstream_dtx(
} }
sid_bits_len = st0->next_bit_pos - sid_bits_len; sid_bits_len = st0->next_bit_pos - sid_bits_len;
#ifdef NONBE_FIX_1052_SBA_EXT
sba_spar_bitlen = ivas_sba_spar_sid_bitlen( num_dmx_per_band[0] );
zero_pad_bits = sba_spar_bitlen - sid_bits_len;
#else
zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len;
#endif
assert( zero_pad_bits >= 0 ); assert( zero_pad_bits >= 0 );
if ( num_dmx_per_band[0] == 2 ) if ( num_dmx_per_band[0] == 2 )
{ {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "stat_dec.h" #include "stat_dec.h"
#include "ivas_stat_com.h" #include "ivas_stat_com.h"
#include "ivas_stat_rend.h" #include "ivas_stat_rend.h"
#include "isar_stat.h"
/*----------------------------------------------------------------------------------* /*----------------------------------------------------------------------------------*
...@@ -837,6 +838,36 @@ typedef struct ivas_binaural_rendering_struct ...@@ -837,6 +838,36 @@ typedef struct ivas_binaural_rendering_struct
} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE;
#endif #endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*----------------------------------------------------------------------------------*
* IVAS decoder specific ISAR wrapper structures
*----------------------------------------------------------------------------------*/
typedef struct
{
float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
} ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE;
typedef struct
{
float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
IVAS_AUDIO_CONFIG config;
} ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA, *ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE;
typedef struct
{
ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/
ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/
SPLIT_REND_WRAPPER splitrend;
ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/
int16_t numTdSamplesPerChannelCached;
} ISAR_DEC_SPLIT_REND_WRAPPER, *ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE;
#endif
/*----------------------------------------------------------------------------------* /*----------------------------------------------------------------------------------*
* MASA decoder structures * MASA decoder structures
...@@ -968,38 +999,6 @@ typedef struct jbm_metadata_structure ...@@ -968,38 +999,6 @@ typedef struct jbm_metadata_structure
} JBM_METADATA, *JBM_METADATA_HANDLE; } JBM_METADATA, *JBM_METADATA_HANDLE;
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*----------------------------------------------------------------------------------*
* Split rendering structures
*----------------------------------------------------------------------------------*/
typedef struct
{
float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
} IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE;
typedef struct
{
float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
AUDIO_CONFIG config;
} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE;
typedef struct
{
IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/
IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/
SPLIT_REND_WRAPPER splitrend;
IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/
int16_t numTdSamplesPerChannelCached;
} IVAS_DEC_SPLIT_REND_WRAPPER;
#endif
/*----------------------------------------------------------------------------------* /*----------------------------------------------------------------------------------*
* Decoder configuration structure * Decoder configuration structure
*----------------------------------------------------------------------------------*/ *----------------------------------------------------------------------------------*/
...@@ -1140,7 +1139,8 @@ typedef struct Decoder_Struct ...@@ -1140,7 +1139,8 @@ typedef struct Decoder_Struct
int16_t flag_omasa_brate; int16_t flag_omasa_brate;
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
IVAS_DEC_SPLIT_REND_WRAPPER hSplitBinRend; /* split binuaral rendering handle */ ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */
BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1];
#endif #endif
/* JBM module */ /* JBM module */
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "ivas_cnst.h" #include "ivas_cnst.h"
#include "ivas_prot.h" #include "ivas_prot.h"
#include "ivas_prot_rend.h" #include "ivas_prot_rend.h"
#include "isar_prot.h"
#include "lib_isar_pre_rend.h"
#include "prot.h" #include "prot.h"
#include "jbm_jb4sb.h" #include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_apa.h"
...@@ -125,6 +127,9 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, ...@@ -125,6 +127,9 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec,
static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType ); static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType );
static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset );
static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples );
static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits );
static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out );
static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out );
#endif #endif
static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize );
static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesRendered ); static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesRendered );
...@@ -248,6 +253,46 @@ ivas_error IVAS_DEC_Open( ...@@ -248,6 +253,46 @@ ivas_error IVAS_DEC_Open(
return IVAS_ERR_WRONG_PARAMS; return IVAS_ERR_WRONG_PARAMS;
} }
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*-------------------------------------------------------------------------*
* isar_set_split_rend_setup()
*
* Setup IVAS split rendering
*-------------------------------------------------------------------------*/
static ivas_error isar_set_split_rend_setup(
ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend,
const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig,
const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,
ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */
)
{
splitRendBits->bits_read = 0;
splitRendBits->bits_written = 0;
splitRendBits->buf_len = ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES;
splitRendBits->codec = ISAR_SPLIT_REND_CODEC_DEFAULT;
splitRendBits->pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE;
splitRendBits->codec_frame_size_ms = 0;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
splitRendBits->isar_frame_size_ms = 0;
splitRendBits->lc3plus_highres = 0;
#endif
if ( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" );
}
ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS );
if ( hCombinedOrientationData != NULL )
{
isar_set_split_rend_ht_setup( &hSplitBinRend->splitrend, hCombinedOrientationData->Quaternions, hCombinedOrientationData->Rmat );
}
return IVAS_ERR_OK;
}
#endif
/*---------------------------------------------------------------------* /*---------------------------------------------------------------------*
* init_decoder_config() * init_decoder_config()
...@@ -304,6 +349,11 @@ void IVAS_DEC_Close( ...@@ -304,6 +349,11 @@ void IVAS_DEC_Close(
( *phIvasDec )->hVoIP = NULL; ( *phIvasDec )->hVoIP = NULL;
} }
#ifdef SPLIT_REND_WITH_HEAD_ROT
/* destroy Split binaural renderer (ISAR) handle */
ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend );
#endif
if ( ( *phIvasDec )->st_ivas ) if ( ( *phIvasDec )->st_ivas )
{ {
ivas_destroy_dec( ( *phIvasDec )->st_ivas ); ivas_destroy_dec( ( *phIvasDec )->st_ivas );
...@@ -468,6 +518,17 @@ ivas_error IVAS_DEC_Configure( ...@@ -468,6 +518,17 @@ ivas_error IVAS_DEC_Configure(
return error; return error;
} }
#ifdef SPLIT_REND_WITH_HEAD_ROT
/* create ISAR handle */
if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
if ( ( error = ivas_create_handle_isar( &st_ivas->hSplitBinRend ) ) != IVAS_ERR_OK )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for ISAR handle" );
}
}
#endif
if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) if ( hIvasDec->mode == IVAS_DEC_MODE_EVS )
{ {
hIvasDec->st_ivas->ivas_format = MONO_FORMAT; hIvasDec->st_ivas->ivas_format = MONO_FORMAT;
...@@ -548,6 +609,15 @@ ivas_error IVAS_DEC_SetRenderFramesize( ...@@ -548,6 +609,15 @@ ivas_error IVAS_DEC_SetRenderFramesize(
hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize;
if ( hIvasDec->st_ivas->hExtOrientationData != NULL )
{
hIvasDec->st_ivas->hExtOrientationData->num_subframes = (int16_t) render_framesize;
}
if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL )
{
hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (int16_t) render_framesize;
}
return IVAS_ERR_OK; return IVAS_ERR_OK;
} }
...@@ -881,9 +951,9 @@ ivas_error IVAS_DEC_GetSamples( ...@@ -881,9 +951,9 @@ ivas_error IVAS_DEC_GetSamples(
* Binaural split rendering setup * Binaural split rendering setup
*----------------------------------------------------------------*/ *----------------------------------------------------------------*/
if ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{ {
ivas_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend, hIvasDec->st_ivas->hCombinedOrientationData ); isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat );
} }
#endif #endif
...@@ -929,9 +999,6 @@ ivas_error IVAS_DEC_GetSamples( ...@@ -929,9 +999,6 @@ ivas_error IVAS_DEC_GetSamples(
{ {
return error; return error;
} }
#ifdef SPLIT_REND_WITH_HEAD_ROT
/* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */
#endif
} }
{ {
/* check if we need to run the setup function, tc decoding and feeding the renderer */ /* check if we need to run the setup function, tc decoding and feeding the renderer */
...@@ -1038,7 +1105,7 @@ ivas_error IVAS_DEC_GetSamples( ...@@ -1038,7 +1105,7 @@ ivas_error IVAS_DEC_GetSamples(
ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_error IVAS_DEC_GetSplitBinauralBitstream(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */
uint8_t *splitRendBitsBuf, /* o : output split rendering bits */ ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */
int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */
bool *needNewFrame /* o : indication that the decoder needs a new frame */ bool *needNewFrame /* o : indication that the decoder needs a new frame */
) )
...@@ -1054,13 +1121,14 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1054,13 +1121,14 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
int16_t numSamplesPerChannelToDecode; int16_t numSamplesPerChannelToDecode;
int16_t i, j; int16_t i, j;
ivas_error error; ivas_error error;
IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend; ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend;
int16_t max_band; int16_t max_band;
int16_t pcm_out_flag; int16_t pcm_out_flag;
int16_t td_input; int16_t td_input;
int16_t numPoses; int16_t numPoses;
int16_t slots_rendered, slots_rendered_new; int16_t slots_rendered, slots_rendered_new;
int16_t ro_md_flag; int16_t ro_md_flag;
IVAS_QUATERNION Quaternion;
error = IVAS_ERR_OK; error = IVAS_ERR_OK;
st_ivas = hIvasDec->st_ivas; st_ivas = hIvasDec->st_ivas;
...@@ -1069,9 +1137,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1069,9 +1137,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC ); numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC );
*needNewFrame = false; *needNewFrame = false;
hSplitBinRend = &st_ivas->hSplitBinRend; hSplitBinRend = st_ivas->hSplitBinRend;
if ( ( error = ivas_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBitsBuf ) ) != IVAS_ERR_OK ) if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
...@@ -1079,13 +1147,14 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1079,13 +1147,14 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses;
if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS &&
( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ||
hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
{ {
numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES );
numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize;
} }
if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) == 0 )
{ {
return IVAS_ERR_WRONG_PARAMS; return IVAS_ERR_WRONG_PARAMS;
} }
...@@ -1095,9 +1164,17 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1095,9 +1164,17 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
slots_rendered = 0; slots_rendered = 0;
} }
else else
{
/* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */
if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
{
slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
}
else
{ {
slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity;
} }
}
/* Decode and render */ /* Decode and render */
...@@ -1124,9 +1201,17 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1124,9 +1201,17 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
slots_rendered_new = 0; slots_rendered_new = 0;
} }
else else
{
/* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */
if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
{
slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
}
else
{ {
slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity;
} }
}
for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i ) for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i )
{ {
...@@ -1150,12 +1235,26 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1150,12 +1235,26 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
ro_md_flag = 0; ro_md_flag = 0;
} }
if ( ( error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, if ( st_ivas->hHeadTrackData != NULL )
st_ivas->hHeadTrackData->Quaternions[0], {
Quaternion = st_ivas->hHeadTrackData->Quaternions[0];
}
else
{
Quaternion.w = -3.0f;
Quaternion.x = 0.0f;
Quaternion.y = 0.0f;
Quaternion.z = 0.0f;
}
if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend,
Quaternion,
st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate,
st_ivas->hRenderConfig->split_rend_config.codec, st_ivas->hRenderConfig->split_rend_config.codec,
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms,
#endif
st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms,
hSplitBinRend->hSplitRendBits, splitRendBits,
Cldfb_RealBuffer_Binaural, Cldfb_RealBuffer_Binaural,
Cldfb_ImagBuffer_Binaural, Cldfb_ImagBuffer_Binaural,
max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK )
...@@ -1184,7 +1283,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ...@@ -1184,7 +1283,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out );
} }
free( st_ivas->hSplitBinRend.hMultiBinCldfbData ); free( st_ivas->hSplitBinRend->hMultiBinCldfbData );
return error; return error;
} }
...@@ -1355,7 +1454,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples( ...@@ -1355,7 +1454,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples(
uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesRendered, /* o : number of samples rendered */
uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
IVAS_DEC_PCM_TYPE pcmType, const IVAS_DEC_PCM_TYPE pcmType,
void *pcmBuf void *pcmBuf
#else #else
int16_t *pcmBuf int16_t *pcmBuf
...@@ -1683,7 +1782,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( ...@@ -1683,7 +1782,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData(
IVAS_VECTOR3 Pos, /* i : listener position */ IVAS_VECTOR3 Pos, /* i : listener position */
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
const int16_t subframe_idx, /* i : subframe index */ const int16_t subframe_idx, /* i : subframe index */
const IVAS_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */
#else #else
const int16_t subframe_idx /* i : subframe index */ const int16_t subframe_idx /* i : subframe index */
#endif #endif
...@@ -2034,14 +2133,22 @@ static ivas_error copyRendererConfigStruct( ...@@ -2034,14 +2133,22 @@ static ivas_error copyRendererConfigStruct(
mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX );
mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS );
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
/* TODO: This seems wrong. Why set default instead of copying from hRCin?
* Currently seems to work because we only ever copy from a default-initialized handle anyway */
hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k;
hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.dof = 3;
hRCout->split_rend_config.hq_mode = 0; hRCout->split_rend_config.hq_mode = 0;
hRCout->split_rend_config.codec_delay_ms = 0; hRCout->split_rend_config.codec_delay_ms = 0;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
hRCout->split_rend_config.isar_frame_size_ms = 20;
#endif
hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */
hRCout->split_rend_config.codec = IVAS_SPLIT_REND_CODEC_DEFAULT; hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT;
hRCout->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB;
hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
hRCout->split_rend_config.lc3plus_highres = hRCin->split_rend_config.lc3plus_highres;
#endif
#endif #endif
hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er;
hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity;
...@@ -2099,8 +2206,12 @@ ivas_error IVAS_DEC_FeedRenderConfig( ...@@ -2099,8 +2206,12 @@ ivas_error IVAS_DEC_FeedRenderConfig(
) )
{ {
RENDER_CONFIG_HANDLE hRenderConfig; RENDER_CONFIG_HANDLE hRenderConfig;
#ifdef FIX_1053_REVERB_RECONFIGURATION
ivas_error error;
#else
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
ivas_error error; ivas_error error;
#endif
#endif #endif
if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL )
...@@ -2140,7 +2251,81 @@ ivas_error IVAS_DEC_FeedRenderConfig( ...@@ -2140,7 +2251,81 @@ ivas_error IVAS_DEC_FeedRenderConfig(
mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX );
mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX );
#ifdef FIX_1053_REVERB_RECONFIGURATION
/* Re-initialize reverb instance if already available */
#ifdef SPLIT_REND_WITH_HEAD_ROT
/* TD renderer Jot reverberator */
if ( hIvasDec->st_ivas->hReverb != NULL )
{
if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* CREND Jot reverberator */
if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL )
{
if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* FB reverberator */
if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL )
{
ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) );
if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
#else
/* TD renderer Jot reverberator */
if ( hIvasDec->st_ivas->hReverb != NULL )
{
if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* CREND Jot reverberator */
if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend->hReverb != NULL )
{
if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* DirAC CLDFB reverberator */
if ( hIvasDec->st_ivas->hDiracDecBin != NULL && hIvasDec->st_ivas->hDiracDecBin->hReverb != NULL )
{
ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin->hReverb ) );
if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
#endif
/* Fastconv CLDFB reverberator */
if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL )
{
ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) );
if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
#endif
mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS );
#ifdef CONF_DISTATT
mvr2r( renderConfig.distAtt, hRenderConfig->distAtt, 3 );
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
hRenderConfig->split_rend_config = renderConfig.split_rend_config; hRenderConfig->split_rend_config = renderConfig.split_rend_config;
...@@ -2148,10 +2333,10 @@ ivas_error IVAS_DEC_FeedRenderConfig( ...@@ -2148,10 +2333,10 @@ ivas_error IVAS_DEC_FeedRenderConfig(
/* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */
if ( hRenderConfig->split_rend_config.dof == 0 ) if ( hRenderConfig->split_rend_config.dof == 0 )
{ {
hRenderConfig->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE; hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE;
} }
if ( ( error = ivas_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
...@@ -2469,7 +2654,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( ...@@ -2469,7 +2654,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
IVAS_DEC_PCM_TYPE pcmType, const IVAS_DEC_PCM_TYPE pcmType,
void *pcmBuf, void *pcmBuf,
#else #else
int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */
...@@ -3649,35 +3834,37 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( ...@@ -3649,35 +3834,37 @@ static ivas_error IVAS_DEC_VoIP_reconfigure(
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
/*---------------------------------------------------------------------* /*---------------------------------------------------------------------*
* IVAS_DEC_GetSplitRendBits() * IVAS_DEC_GetSplitRendBitstreamHeader()
* *
* *
*---------------------------------------------------------------------*/ *---------------------------------------------------------------------*/
/*! r: decoder error code */ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader(
ivas_error IVAS_DEC_GetSplitRendBits(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
IVAS_SPLIT_REND_BITS_HANDLE splitRendBits /* o : split rendering Bits structue */ ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */
ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */
#endif
int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
,
int16_t *pLc3plusHighRes
#endif
) )
{ {
if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL /*|| hIvasDec->st_ivas->hSplitBinRend == NULL */ ) if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
{ {
return IVAS_ERR_UNEXPECTED_NULL_POINTER; return IVAS_ERR_UNEXPECTED_NULL_POINTER;
} }
splitRendBits->bits_buf = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->bits_buf; *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec;
splitRendBits->bits_read = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->bits_read; *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms;
splitRendBits->bits_written = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->bits_written; *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode;
splitRendBits->buf_len = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->buf_len; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
splitRendBits->codec = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->codec; *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms;
splitRendBits->pose_correction = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->pose_correction; *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres;
splitRendBits->codec_frame_size_ms = hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits->codec_frame_size_ms; #endif
/* data consumed, free it */
free( hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits );
hIvasDec->st_ivas->hSplitBinRend.hSplitRendBits = NULL;
return IVAS_ERR_OK; return IVAS_ERR_OK;
} }
...@@ -3685,10 +3872,9 @@ ivas_error IVAS_DEC_GetSplitRendBits( ...@@ -3685,10 +3872,9 @@ ivas_error IVAS_DEC_GetSplitRendBits(
/*---------------------------------------------------------------------* /*---------------------------------------------------------------------*
* IVAS_DEC_GetCldfbSamples() * IVAS_DEC_GetCldfbSamples()
* *
* * API function to output CLDFB samples
*---------------------------------------------------------------------*/ *---------------------------------------------------------------------*/
// ToDo: currently unused
ivas_error IVAS_DEC_GetCldfbSamples( ivas_error IVAS_DEC_GetCldfbSamples(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */
...@@ -3697,24 +3883,24 @@ ivas_error IVAS_DEC_GetCldfbSamples( ...@@ -3697,24 +3883,24 @@ ivas_error IVAS_DEC_GetCldfbSamples(
int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ int16_t *nOutSamples /* o : number of samples per channel written to output buffer */
) )
{ {
Decoder_Struct *st_ivas; ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend;
int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; int16_t ch, b, slot_idx, num_chs, maxBand, num_samples;
if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL )
{ {
return IVAS_ERR_UNEXPECTED_NULL_POINTER; return IVAS_ERR_UNEXPECTED_NULL_POINTER;
} }
st_ivas = hIvasDec->st_ivas; hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend;
num_samples = 0; num_samples = 0;
if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) if ( hSplitBinRend->hCldfbDataOut != NULL )
{ {
*audio_config = st_ivas->hSplitBinRend.hCldfbDataOut->config; *audio_config = hSplitBinRend->hCldfbDataOut->config;
if ( st_ivas->hSplitBinRend.hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID )
{ {
num_chs = audioCfg2channels( st_ivas->hSplitBinRend.hCldfbDataOut->config ); num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config );
maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 );
for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ )
{ {
...@@ -3722,8 +3908,8 @@ ivas_error IVAS_DEC_GetCldfbSamples( ...@@ -3722,8 +3908,8 @@ ivas_error IVAS_DEC_GetCldfbSamples(
{ {
for ( ch = 0; ch < num_chs; ch++ ) for ( ch = 0; ch < num_chs; ch++ )
{ {
*out_real++ = st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b];
*out_imag++ = st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b];
} }
} }
} }
...@@ -3739,10 +3925,8 @@ ivas_error IVAS_DEC_GetCldfbSamples( ...@@ -3739,10 +3925,8 @@ ivas_error IVAS_DEC_GetCldfbSamples(
return IVAS_ERR_OK; return IVAS_ERR_OK;
} }
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*---------------------------------------------------------------------* /*---------------------------------------------------------------------*
* pcm_buffer_offset() * pcm_buffer_offset()
* *
...@@ -3769,8 +3953,10 @@ static void *pcm_buffer_offset( ...@@ -3769,8 +3953,10 @@ static void *pcm_buffer_offset(
} }
break; break;
default: default:
return NULL; break;
} }
return NULL;
} }
...@@ -3831,4 +4017,117 @@ PCM_RESOLUTION pcm_type_API_to_internal( ...@@ -3831,4 +4017,117 @@ PCM_RESOLUTION pcm_type_API_to_internal(
return pcm_resolution; return pcm_resolution;
} }
/*-------------------------------------------------------------------*
* ivas_create_handle_isar()
*
* Initialize IVAS decoder split rend handle
*-------------------------------------------------------------------*/
static ivas_error ivas_create_handle_isar(
ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out /* o : ISAR split binaural rendering handle */
)
{
ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend;
if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" );
}
isar_init_split_rend_handles( &hSplitBinRend->splitrend );
hSplitBinRend->hMultiBinCldfbData = NULL;
hSplitBinRend->hCldfbDataOut = NULL;
hSplitBinRend->numTdSamplesPerChannelCached = 0;
*hSplitBinRend_out = hSplitBinRend;
return IVAS_ERR_OK;
}
/*-------------------------------------------------------------------*
* ivas_destroy_handle_isar()
*
* destroy IVAS decoder split rend handle
*-------------------------------------------------------------------*/
static void ivas_destroy_handle_isar(
ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */
)
{
if ( *hSplitBinRend != NULL )
{
ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL );
if ( ( *hSplitBinRend )->hCldfbDataOut != NULL )
{
free( ( *hSplitBinRend )->hCldfbDataOut );
( *hSplitBinRend )->hCldfbDataOut = NULL;
}
}
return;
}
/*---------------------------------------------------------------------*
* IVAS_DEC_is_split_rendering_enabled()
*
*
*---------------------------------------------------------------------*/
int16_t IVAS_DEC_is_split_rendering_enabled(
IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */
)
{
Decoder_Struct *st_ivas;
int16_t isSplitRend;
if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
{
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
st_ivas = hIvasDec->st_ivas;
isSplitRend = 0;
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
{
isSplitRend = 1;
}
return isSplitRend;
}
/*---------------------------------------------------------------------*
* IVAS_DEC_is_split_rendering_coded_out()
*
*
*---------------------------------------------------------------------*/
int16_t IVAS_DEC_is_split_rendering_coded_out(
IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */
)
{
Decoder_Struct *st_ivas;
int16_t isSplitCoded;
if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
{
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
st_ivas = hIvasDec->st_ivas;
isSplitCoded = 0;
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ||
( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
{
isSplitCoded = 1;
}
return isSplitCoded;
}
#endif #endif
...@@ -172,15 +172,24 @@ ivas_error IVAS_DEC_GetSamples( ...@@ -172,15 +172,24 @@ ivas_error IVAS_DEC_GetSamples(
ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_error IVAS_DEC_GetSplitBinauralBitstream(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */
uint8_t *splitRendBitsBuf, /* o : output split rendering bits */ ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */
int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */
bool *needNewFrame /* o : indication that the decoder needs a new frame */ bool *needNewFrame /* o : indication that the decoder needs a new frame */
); );
/*! r: decoder error code */ /*! r: decoder error code */
ivas_error IVAS_DEC_GetSplitRendBits( ivas_error IVAS_DEC_GetSplitRendBitstreamHeader(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
IVAS_SPLIT_REND_BITS_HANDLE splitRendBits /* o : split rendering Bits structure */ ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */
ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */
#endif
int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
,
int16_t *pLc3plusHighRes /* o: pointer to LC3plus High-Res setting */
#endif
); );
/*! r: decoder error code */ /*! r: decoder error code */
...@@ -191,6 +200,13 @@ ivas_error IVAS_DEC_GetCldfbSamples( ...@@ -191,6 +200,13 @@ ivas_error IVAS_DEC_GetCldfbSamples(
IVAS_AUDIO_CONFIG *audio_config, /* o : audio configuration */ IVAS_AUDIO_CONFIG *audio_config, /* o : audio configuration */
int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ int16_t *nOutSamples /* o : number of samples per channel written to output buffer */
); );
int16_t IVAS_DEC_is_split_rendering_enabled(
IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle */
);
int16_t IVAS_DEC_is_split_rendering_coded_out(
IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */
);
#endif #endif
/*! r: error code */ /*! r: error code */
...@@ -215,7 +231,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( ...@@ -215,7 +231,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData(
IVAS_VECTOR3 Pos, /* i : listener position */ IVAS_VECTOR3 Pos, /* i : listener position */
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
const int16_t subframe_idx, /* i : subframe index */ const int16_t subframe_idx, /* i : subframe index */
IVAS_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */
#else #else
const int16_t subframe_idx /* i : subframe index */ const int16_t subframe_idx /* i : subframe index */
#endif #endif
...@@ -272,7 +288,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( ...@@ -272,7 +288,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
IVAS_DEC_PCM_TYPE pcmType, const IVAS_DEC_PCM_TYPE pcmType,
void *pcmBuf, void *pcmBuf,
#else #else
int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */
......
...@@ -446,7 +446,11 @@ ivas_error ivas_corecoder_enc_reconfig( ...@@ -446,7 +446,11 @@ ivas_error ivas_corecoder_enc_reconfig(
} }
else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 )
{ {
#ifdef NONBE_FIX_ISM_XOVER_BR
if ( ( error = mct_enc_reconfigure( st_ivas, nchan_transport_old_real != nchan_transport_real ) ) != IVAS_ERR_OK )
#else
if ( ( error = mct_enc_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) if ( ( error = mct_enc_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK )
#endif
{ {
return error; return error;
} }
......
...@@ -600,6 +600,16 @@ ivas_error ivas_cpe_enc( ...@@ -600,6 +600,16 @@ ivas_error ivas_cpe_enc(
if ( sts[0]->core_brate == SID_2k40 ) if ( sts[0]->core_brate == SID_2k40 )
{ {
ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr ); ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr );
#ifdef NONBE_FIX_1052_SBA_EXT
if ( ivas_format == SBA_FORMAT )
{
/* Write SBA planar flag */
push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS );
/* Write SBA order */
push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS );
}
#endif
} }
/*----------------------------------------------------------------* /*----------------------------------------------------------------*
......
...@@ -291,6 +291,9 @@ ivas_error ivas_dirac_enc( ...@@ -291,6 +291,9 @@ ivas_error ivas_dirac_enc(
const int16_t input_frame, /* i : input frame length */ const int16_t input_frame, /* i : input frame length */
const int16_t dtx_vad, /* i : DTX vad flag */ const int16_t dtx_vad, /* i : DTX vad flag */
const IVAS_FORMAT ivas_format, /* i : ivas format */ const IVAS_FORMAT ivas_format, /* i : ivas format */
#ifdef NONBE_FIX_1052_SBA_EXT
const int16_t nchan_transport, /* i : number of transport channels */
#endif
const int16_t hodirac_flag /* i : hodirac flag */ const int16_t hodirac_flag /* i : hodirac flag */
) )
{ {
...@@ -367,7 +370,11 @@ ivas_error ivas_dirac_enc( ...@@ -367,7 +370,11 @@ ivas_error ivas_dirac_enc(
push_next_indice( hMetaData, 1, 1 ); push_next_indice( hMetaData, 1, 1 );
/* encode SID parameters */ /* encode SID parameters */
#ifdef NONBE_FIX_1052_SBA_EXT
ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, -1, nchan_transport, SBA_FORMAT );
#else
ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, -1, SBA_FORMAT ); ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, -1, SBA_FORMAT );
#endif
} }
for ( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ ) for ( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ )
......
...@@ -674,10 +674,14 @@ ivas_error ivas_init_encoder( ...@@ -674,10 +674,14 @@ ivas_error ivas_init_encoder(
{ {
st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->ism_mode = ISM_MODE_NONE;
#ifdef NONBE_FIX_ISM_XOVER_BR
st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism );
#else
if ( ivas_total_brate >= IVAS_256k ) if ( ivas_total_brate >= IVAS_256k )
{ {
st_ivas->ism_mode = ISM_SBA_MODE_DISC; st_ivas->ism_mode = ISM_SBA_MODE_DISC;
} }
#endif
if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{ {
...@@ -732,8 +736,17 @@ ivas_error ivas_init_encoder( ...@@ -732,8 +736,17 @@ ivas_error ivas_init_encoder(
else else
{ {
/* allocate and initialize MCT core coder */ /* allocate and initialize MCT core coder */
st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
#ifdef NONBE_FIX_ISM_XOVER_BR
{
int16_t n_all;
n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism;
st_ivas->nCPE = ( n_all + 1 ) >> 1;
}
#else
st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
#endif
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) 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 ) if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
......
...@@ -420,6 +420,18 @@ ivas_error ivas_masa_encode( ...@@ -420,6 +420,18 @@ ivas_error ivas_masa_encode(
{ {
if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE ) if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE )
{ {
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
/* use the MASA number of transport channels bit to signal if there are 1 or 2 objects */
if ( nchan_ism == 1 || nchan_ism == 2 )
{
push_next_indice( hMetaData, nchan_ism - 1, MASA_TRANSP_BITS );
}
else
{
/* for 3 or 4 objects write already the number of MASA directions */
push_next_indice( hMetaData, hQMetaData->no_directions - 1, MASA_TRANSP_BITS );
}
#else
/* use the MASA number of transport channels bit to signal if there are 3 or 4 objects */ /* use the MASA number of transport channels bit to signal if there are 3 or 4 objects */
if ( nchan_ism == 4 ) if ( nchan_ism == 4 )
{ {
...@@ -429,6 +441,7 @@ ivas_error ivas_masa_encode( ...@@ -429,6 +441,7 @@ ivas_error ivas_masa_encode(
{ {
push_next_indice( hMetaData, 0, MASA_TRANSP_BITS ); push_next_indice( hMetaData, 0, MASA_TRANSP_BITS );
} }
#endif
} }
else else
{ {
...@@ -440,6 +453,16 @@ ivas_error ivas_masa_encode( ...@@ -440,6 +453,16 @@ ivas_error ivas_masa_encode(
if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE ) if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE )
{ {
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
if ( nchan_ism >= 3 ) /* if 3 or 4 objects */
{
push_next_indice( hMetaData, 5 - nchan_ism, MASA_HEADER_BITS );
}
else
{
push_next_indice( hMetaData, 3, MASA_HEADER_BITS );
}
#else
if ( nchan_ism <= 3 ) if ( nchan_ism <= 3 )
{ {
push_next_indice( hMetaData, nchan_ism, MASA_HEADER_BITS ); push_next_indice( hMetaData, nchan_ism, MASA_HEADER_BITS );
...@@ -448,6 +471,7 @@ ivas_error ivas_masa_encode( ...@@ -448,6 +471,7 @@ ivas_error ivas_masa_encode(
{ {
push_next_indice( hMetaData, nchan_ism - 1, MASA_HEADER_BITS ); push_next_indice( hMetaData, nchan_ism - 1, MASA_HEADER_BITS );
} }
#endif
hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; hQMetaData->metadata_max_bits -= MASA_HEADER_BITS;
} }
else else
...@@ -457,10 +481,16 @@ ivas_error ivas_masa_encode( ...@@ -457,10 +481,16 @@ ivas_error ivas_masa_encode(
push_next_indice( hMetaData, 0, MASA_HEADER_BITS ); push_next_indice( hMetaData, 0, MASA_HEADER_BITS );
hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; hQMetaData->metadata_max_bits -= MASA_HEADER_BITS;
} }
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
if ( !( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE && nchan_ism > 2 ) )
{
#endif
/* write number of directions */ /* write number of directions */
push_next_indice( hMetaData, hQMetaData->no_directions - 1, 1 ); push_next_indice( hMetaData, hQMetaData->no_directions - 1, 1 );
hQMetaData->metadata_max_bits -= 1; hQMetaData->metadata_max_bits -= 1;
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
}
#endif
/* write subframe mode */ /* write subframe mode */
push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_SUBFRAME_BITS ); push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_SUBFRAME_BITS );
hQMetaData->metadata_max_bits -= MASA_SUBFRAME_BITS; hQMetaData->metadata_max_bits -= MASA_SUBFRAME_BITS;
...@@ -596,7 +626,11 @@ ivas_error ivas_masa_encode( ...@@ -596,7 +626,11 @@ ivas_error ivas_masa_encode(
free( h_orig_metadata ); free( h_orig_metadata );
#ifdef NONBE_FIX_1052_SBA_EXT
ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, masa_sid_descriptor, 0, ivas_format );
#else
ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, masa_sid_descriptor, ivas_format ); ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, masa_sid_descriptor, ivas_format );
#endif
/* restore old values */ /* restore old values */
hMasa->config.numCodingBands = numCodingBands; hMasa->config.numCodingBands = numCodingBands;
......
...@@ -497,7 +497,9 @@ void ivas_mct_core_enc( ...@@ -497,7 +497,9 @@ void ivas_mct_core_enc(
{ {
nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED;
nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS;
if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 )
/*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/
if ( ivas_format == SBA_ISM_FORMAT )
{ {
nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS;
} }
...@@ -574,7 +576,9 @@ void ivas_mct_core_enc( ...@@ -574,7 +576,9 @@ void ivas_mct_core_enc(
#ifdef DEBUGGING #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 ); 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 );
format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS );
format_bits += ( ivas_format == SBA_ISM_FORMAT );
mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; 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 ); assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate );
#endif #endif
......
...@@ -182,9 +182,13 @@ ivas_error ivas_osba_enc_reconfig( ...@@ -182,9 +182,13 @@ ivas_error ivas_osba_enc_reconfig(
ivas_error error; ivas_error error;
ENCODER_CONFIG_HANDLE hEncoderConfig; ENCODER_CONFIG_HANDLE hEncoderConfig;
error = IVAS_ERR_OK; error = IVAS_ERR_OK;
hEncoderConfig = st_ivas->hEncoderConfig; hEncoderConfig = st_ivas->hEncoderConfig;
ivas_total_brate = hEncoderConfig->ivas_total_brate; ivas_total_brate = hEncoderConfig->ivas_total_brate;
#ifdef NONBE_FIX_ISM_XOVER_BR
int16_t nchan_transport;
#endif
if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate )
{ {
...@@ -197,6 +201,9 @@ ivas_error ivas_osba_enc_reconfig( ...@@ -197,6 +201,9 @@ ivas_error ivas_osba_enc_reconfig(
spar_reconfig_flag = 0; spar_reconfig_flag = 0;
old_ism_mode = st_ivas->ism_mode; old_ism_mode = st_ivas->ism_mode;
#ifdef NONBE_FIX_ISM_XOVER_BR
st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism );
#else
if ( ivas_total_brate >= IVAS_256k ) if ( ivas_total_brate >= IVAS_256k )
{ {
st_ivas->ism_mode = ISM_SBA_MODE_DISC; st_ivas->ism_mode = ISM_SBA_MODE_DISC;
...@@ -205,9 +212,11 @@ ivas_error ivas_osba_enc_reconfig( ...@@ -205,9 +212,11 @@ ivas_error ivas_osba_enc_reconfig(
{ {
st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->ism_mode = ISM_MODE_NONE;
} }
#endif
nchan_transport_old = st_ivas->nchan_transport; nchan_transport_old = st_ivas->nchan_transport;
nCPE_old = st_ivas->nCPE; nCPE_old = st_ivas->nCPE;
nSCE_old = st_ivas->nSCE; nSCE_old = st_ivas->nSCE;
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); 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 ); 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; nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands;
...@@ -334,20 +343,40 @@ ivas_error ivas_osba_enc_reconfig( ...@@ -334,20 +343,40 @@ ivas_error ivas_osba_enc_reconfig(
* Allocate, initialize, and configure SCE/CPE/MCT handles * Allocate, initialize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
#ifdef NONBE_FIX_ISM_XOVER_BR
nchan_transport = st_ivas->nchan_transport;
#endif
if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{ {
#ifdef NONBE_FIX_ISM_XOVER_BR
{
nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism;
st_ivas->nCPE = ( nchan_transport + 1 ) >> 1;
}
#else
st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
#endif
} }
else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE )
{ {
nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism;
#ifdef NONBE_FIX_ISM_XOVER_BR
nchan_transport = st_ivas->nchan_transport;
#endif
} }
else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
{ {
#ifdef NONBE_FIX_ISM_XOVER_BR
nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism;
nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism;
st_ivas->nCPE = ( nchan_transport + 1 ) >> 1;
#else
st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1;
nCPE_old = st_ivas->nCPE; nCPE_old = st_ivas->nCPE;
nchan_transport_old = st_ivas->nchan_transport; nchan_transport_old = st_ivas->nchan_transport;
nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism;
#endif
} }
if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ) ) != IVAS_ERR_OK ) 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 )
......
...@@ -955,6 +955,9 @@ void ivas_qmetadata_enc_sid_encode( ...@@ -955,6 +955,9 @@ void ivas_qmetadata_enc_sid_encode(
BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */
IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */
const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure */
#ifdef NONBE_FIX_1052_SBA_EXT
const int16_t nchan_transport, /* i : number of transport channels */
#endif
const int16_t ivas_format /* i : IVAS format */ const int16_t ivas_format /* i : IVAS format */
) )
{ {
...@@ -968,10 +971,18 @@ void ivas_qmetadata_enc_sid_encode( ...@@ -968,10 +971,18 @@ void ivas_qmetadata_enc_sid_encode(
float avg_elevation[MASA_MAXIMUM_CODING_SUBBANDS]; float avg_elevation[MASA_MAXIMUM_CODING_SUBBANDS];
int16_t bits_dir, bits_diff, bits_delta; int16_t bits_dir, bits_diff, bits_delta;
int16_t metadata_sid_bits; /* bits allocated to SID for metadata */ int16_t metadata_sid_bits; /* bits allocated to SID for metadata */
#ifdef NONBE_FIX_1052_SBA_EXT
int16_t sba_spar_bitlen;
#endif
if ( ivas_format == SBA_FORMAT ) if ( ivas_format == SBA_FORMAT )
{ {
#ifdef NONBE_FIX_1052_SBA_EXT
sba_spar_bitlen = ivas_sba_spar_sid_bitlen( nchan_transport );
metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - sba_spar_bitlen - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/
#else
metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/
#endif
} }
else else
{ {
...@@ -1250,7 +1261,11 @@ void reset_metadata_spatial( ...@@ -1250,7 +1261,11 @@ void reset_metadata_spatial(
assert( hMetaData->ind_list[0].nb_bits == 1 ); assert( hMetaData->ind_list[0].nb_bits == 1 );
#endif #endif
hMetaData->ind_list[0].value = 1; hMetaData->ind_list[0].value = 1;
#ifdef NONBE_FIX_1052_SBA_EXT
metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS;
#else
metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS;
#endif
while ( hMetaData->nb_bits_tot < metadata_sid_bits ) while ( hMetaData->nb_bits_tot < metadata_sid_bits )
{ {
......
...@@ -224,6 +224,16 @@ ivas_error ivas_sce_enc( ...@@ -224,6 +224,16 @@ ivas_error ivas_sce_enc(
if ( st->core_brate == SID_2k40 ) if ( st->core_brate == SID_2k40 )
{ {
ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr ); ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr );
#ifdef NONBE_FIX_1052_SBA_EXT
if ( ivas_format == SBA_FORMAT )
{
/* Write SBA planar flag */
push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS );
/* Write SBA order */
push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS );
}
#endif
} }
/*----------------------------------------------------------------* /*----------------------------------------------------------------*
......
...@@ -354,11 +354,17 @@ ivas_error ivas_spar_enc( ...@@ -354,11 +354,17 @@ ivas_error ivas_spar_enc(
/* Write SBA planar flag */ /* Write SBA planar flag */
push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );
/* hack to indicate OSBA bitstream at VLBR */ /* hack to indicate OSBA format (SBA order = 0) at low bitrates */
push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS ); push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS );
/* additionally code the real SBA order */
push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
} }
else else
{ {
/* Write SBA planar flag */
push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );
/* Write SBA order */ /* Write SBA order */
push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
} }
...@@ -689,10 +695,18 @@ static ivas_error ivas_spar_enc_process( ...@@ -689,10 +695,18 @@ static ivas_error ivas_spar_enc_process(
hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order );
#ifdef NONBE_FIX_1052_SBA_EXT
if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, nchan_transport, hodirac_flag ) ) != IVAS_ERR_OK )
{
return error;
}
#else
if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK ) if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
#endif
/* Set Energy Ratio to 0.0 if the mono flag has been set */ /* Set Energy Ratio to 0.0 if the mono flag has been set */
if ( hQMetaData->dirac_mono_flag ) if ( hQMetaData->dirac_mono_flag )
......
...@@ -1716,6 +1716,9 @@ static void ivas_write_parameter_bitstream_dtx( ...@@ -1716,6 +1716,9 @@ static void ivas_write_parameter_bitstream_dtx(
int16_t idx; int16_t idx;
float pr_min_max[2]; float pr_min_max[2];
int16_t zero_pad_bits, sid_bits_len; int16_t zero_pad_bits, sid_bits_len;
#ifdef NONBE_FIX_1052_SBA_EXT
int16_t sba_spar_bitlen;
#endif
sid_bits_len = hMetaData->nb_bits_tot; sid_bits_len = hMetaData->nb_bits_tot;
pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[0] = pSpar_md->min_max[0];
pr_min_max[1] = pSpar_md->min_max[1]; pr_min_max[1] = pSpar_md->min_max[1];
...@@ -1771,7 +1774,12 @@ static void ivas_write_parameter_bitstream_dtx( ...@@ -1771,7 +1774,12 @@ static void ivas_write_parameter_bitstream_dtx(
} }
sid_bits_len = hMetaData->nb_bits_tot - sid_bits_len; sid_bits_len = hMetaData->nb_bits_tot - sid_bits_len;
#ifdef NONBE_FIX_1052_SBA_EXT
sba_spar_bitlen = ivas_sba_spar_sid_bitlen( num_dmx[0] );
zero_pad_bits = sba_spar_bitlen - sid_bits_len;
#else
zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len;
#endif
assert( zero_pad_bits >= 0 ); assert( zero_pad_bits >= 0 );
if ( num_dmx[0] == 2 ) if ( num_dmx[0] == 2 )
{ {
......
...@@ -33,9 +33,8 @@ ...@@ -33,9 +33,8 @@
#include "options.h" #include "options.h"
#include <stdint.h> #include <stdint.h>
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
#include "ivas_lcld_rom_tables.h" #include "isar_lcld_prot.h"
#include "ivas_lcld_prot.h" #include "isar_prot.h"
#include "ivas_prot_rend.h"
#include "wmc_auto.h" #include "wmc_auto.h"
...@@ -73,16 +72,16 @@ int32_t quantPhase( ...@@ -73,16 +72,16 @@ int32_t quantPhase(
/*-------------------------------------------------------------------* /*-------------------------------------------------------------------*
* Function cplxmult() * Function cplxmult_lcld()
* *
* *
*-------------------------------------------------------------------*/ *-------------------------------------------------------------------*/
void cplxmult( void cplxmult_lcld(
float *pr1, float *pr1,
float *pi1, float *pi1,
float r2, const float r2,
float i2 ) const float i2 )
{ {
float r1 = *pr1, i1 = *pi1; float r1 = *pr1, i1 = *pi1;
......
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
#include <math.h> #include <math.h>
#include "prot.h" #include "prot.h"
#include "ivas_lcld_prot.h" #include "isar_lcld_prot.h"
#include "ivas_prot_rend.h"
#include "wmc_auto.h" #include "wmc_auto.h"
......
...@@ -33,10 +33,9 @@ ...@@ -33,10 +33,9 @@
#include <stdint.h> #include <stdint.h>
#include "options.h" #include "options.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
#include "ivas_lcld_prot.h" #include "isar_lcld_prot.h"
#include "prot.h" #include "prot.h"
#include "ivas_prot_rend.h" #include "isar_rom_lcld_tables.h"
#include "ivas_lcld_rom_tables.h"
#include <stdio.h> #include <stdio.h>
#include "wmc_auto.h" #include "wmc_auto.h"
...@@ -46,7 +45,6 @@ ...@@ -46,7 +45,6 @@
*------------------------------------------------------------------------------------------*/ *------------------------------------------------------------------------------------------*/
#define PERCEPTUAL_MODEL_SCALE ( 64 ) #define PERCEPTUAL_MODEL_SCALE ( 64 )
#define PERCEPTUAL_MODEL_SCALE_SHIFT ( 6 )
#define PERCEPTUAL_MODEL_ALPHA_SCALE ( 614 ) #define PERCEPTUAL_MODEL_ALPHA_SCALE ( 614 )
#define PERCEPTUAL_MODEL_ALPHA_INV_SCALE ( 6827 ) #define PERCEPTUAL_MODEL_ALPHA_INV_SCALE ( 6827 )
#define PERCEPTUAL_MODEL_ALPHA_SHIFT ( 11 ) #define PERCEPTUAL_MODEL_ALPHA_SHIFT ( 11 )
...@@ -103,7 +101,6 @@ void PerceptualModel( ...@@ -103,7 +101,6 @@ void PerceptualModel(
/* Calculate sensation level offset */ /* Calculate sensation level offset */
iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT;
// iSLOffset = (iSLOffset > 0) ? iSLOffset : 0;
/* Offset envelope by sensation level offset */ /* Offset envelope by sensation level offset */
piExcitation[n] -= iSLOffset; piExcitation[n] -= iSLOffset;
...@@ -168,7 +165,6 @@ void PerceptualModelStereo( ...@@ -168,7 +165,6 @@ void PerceptualModelStereo(
/* Calculate sensation level offset */ /* Calculate sensation level offset */
iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation0[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation0[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT;
// iSLOffset = (iSLOffset > 0) ? iSLOffset : 0;
/* Offset envelope by sensation level offset */ /* Offset envelope by sensation level offset */
piExcitation0[n] -= iSLOffset; piExcitation0[n] -= iSLOffset;
...@@ -205,7 +201,6 @@ void PerceptualModelStereo( ...@@ -205,7 +201,6 @@ void PerceptualModelStereo(
/* Calculate sensation level offset */ /* Calculate sensation level offset */
iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation1[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation1[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT;
// iSLOffset = (iSLOffset > 0) ? iSLOffset : 0;
/* Offset envelope by sensation level offset */ /* Offset envelope by sensation level offset */
piExcitation1[n] -= iSLOffset; piExcitation1[n] -= iSLOffset;
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
#include <math.h> #include <math.h>
#include "prot.h" #include "prot.h"
#include "ivas_prot_rend.h" #include "isar_prot.h"
#include "ivas_lcld_prot.h" #include "isar_lcld_prot.h"
#include "ivas_lcld_rom_tables.h" #include "isar_rom_lcld_tables.h"
#include "wmc_auto.h" #include "wmc_auto.h"
/*-------------------------------------------------------------------* /*-------------------------------------------------------------------*
...@@ -64,6 +64,41 @@ ivas_error CreatePredictionDecoder( ...@@ -64,6 +64,41 @@ ivas_error CreatePredictionDecoder(
psPredictionDecoder->iNumBlocks = iNumBlocks; psPredictionDecoder->iNumBlocks = iNumBlocks;
psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks; psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks;
psPredictionDecoder->iSubSetId = 0; psPredictionDecoder->iSubSetId = 0;
/* PLC_IMPROVEMENT */
if ( ( psPredictionDecoder->ppiDecodingFailedPrev = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
}
if ( ( psPredictionDecoder->ppiDecodingFailed = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
}
if ( ( psPredictionDecoder->ppiDecodingUnresolved = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
}
for ( n = 0; n < iChannels; n++ )
{
int32_t k;
if ( ( psPredictionDecoder->ppiDecodingUnresolved[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
}
if ( ( psPredictionDecoder->ppiDecodingFailed[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
}
if ( ( psPredictionDecoder->ppiDecodingFailedPrev[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
}
for ( k = 0; k < LCLD_MAX_NUM_PRED_SUBSETS; k++ )
{
psPredictionDecoder->ppiDecodingUnresolved[n][k] = 0;
psPredictionDecoder->ppiDecodingFailed[n][k] = 0;
psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0;
}
}
if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL )
{ {
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
...@@ -182,6 +217,10 @@ void DeletePredictionDecoder( ...@@ -182,6 +217,10 @@ void DeletePredictionDecoder(
free( psPredictionDecoder->ppiA1Phase[n] ); free( psPredictionDecoder->ppiA1Phase[n] );
free( psPredictionDecoder->ppfPredStateReal[n] ); free( psPredictionDecoder->ppfPredStateReal[n] );
free( psPredictionDecoder->ppfPredStateImag[n] ); free( psPredictionDecoder->ppfPredStateImag[n] );
/* PLC_IMPROVEMENT */
free( psPredictionDecoder->ppiDecodingUnresolved[n] );
free( psPredictionDecoder->ppiDecodingFailed[n] );
free( psPredictionDecoder->ppiDecodingFailedPrev[n] );
} }
free( psPredictionDecoder->piPredChanEnable ); free( psPredictionDecoder->piPredChanEnable );
free( psPredictionDecoder->ppiPredBandEnable ); free( psPredictionDecoder->ppiPredBandEnable );
...@@ -191,6 +230,10 @@ void DeletePredictionDecoder( ...@@ -191,6 +230,10 @@ void DeletePredictionDecoder(
free( psPredictionDecoder->ppiA1Phase ); free( psPredictionDecoder->ppiA1Phase );
free( psPredictionDecoder->ppfPredStateReal ); free( psPredictionDecoder->ppfPredStateReal );
free( psPredictionDecoder->ppfPredStateImag ); free( psPredictionDecoder->ppfPredStateImag );
/* PLC_IMPROVEMENT */
free( psPredictionDecoder->ppiDecodingUnresolved );
free( psPredictionDecoder->ppiDecodingFailed );
free( psPredictionDecoder->ppiDecodingFailedPrev );
free( psPredictionDecoder ); free( psPredictionDecoder );
psPredictionDecoder = NULL; psPredictionDecoder = NULL;
...@@ -206,7 +249,7 @@ void DeletePredictionDecoder( ...@@ -206,7 +249,7 @@ void DeletePredictionDecoder(
int32_t ReadPredictors( int32_t ReadPredictors(
PredictionDecoder *psPredictionDecoder, PredictionDecoder *psPredictionDecoder,
IVAS_SPLIT_REND_BITS_HANDLE pBits ) ISAR_SPLIT_REND_BITS_HANDLE pBits )
{ {
int16_t iBitsRead = 0; int16_t iBitsRead = 0;
int32_t c; int32_t c;
...@@ -214,12 +257,12 @@ int32_t ReadPredictors( ...@@ -214,12 +257,12 @@ int32_t ReadPredictors(
int16_t iNumPredBandBits = 6; int16_t iNumPredBandBits = 6;
const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 ); const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 );
psPredictionDecoder->iNumSubSets = ivas_split_rend_bitstream_read_int32( pBits, iSubSetBits ) + 1; psPredictionDecoder->iNumSubSets = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ) + 1;
iBitsRead += iSubSetBits; iBitsRead += iSubSetBits;
if ( psPredictionDecoder->iNumSubSets > 1 ) if ( psPredictionDecoder->iNumSubSets > 1 )
{ {
psPredictionDecoder->iSubSetId = ivas_split_rend_bitstream_read_int32( pBits, iSubSetBits ); psPredictionDecoder->iSubSetId = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits );
iBitsRead += iSubSetBits; iBitsRead += iSubSetBits;
iNumPredBandBits = ( psPredictionDecoder->iNumSubSets >= 4 ? 4 : 5 ); iNumPredBandBits = ( psPredictionDecoder->iNumSubSets >= 4 ? 4 : 5 );
} }
...@@ -229,7 +272,7 @@ int32_t ReadPredictors( ...@@ -229,7 +272,7 @@ int32_t ReadPredictors(
} }
for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
{ {
psPredictionDecoder->piPredChanEnable[c] = ivas_split_rend_bitstream_read_int32( pBits, psPredictionDecoder->iNumSubSets ); psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets );
iBitsRead += (int16_t) psPredictionDecoder->iNumSubSets; iBitsRead += (int16_t) psPredictionDecoder->iNumSubSets;
if ( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) ) if ( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) )
...@@ -242,13 +285,13 @@ int32_t ReadPredictors( ...@@ -242,13 +285,13 @@ int32_t ReadPredictors(
{ {
psPredictionDecoder->ppiPredBandEnable[c][b] = 0; psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
} }
iNumPredBands = ivas_split_rend_bitstream_read_int32( pBits, iNumPredBandBits ); iNumPredBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iNumPredBandBits );
iBitsRead += iNumPredBandBits; iBitsRead += iNumPredBandBits;
iNumPredBands = iNumPredBands * psPredictionDecoder->iNumSubSets + b0; iNumPredBands = iNumPredBands * psPredictionDecoder->iNumSubSets + b0;
for ( b = b0; b < iNumPredBands; b += bstep ) for ( b = b0; b < iNumPredBands; b += bstep )
{ {
psPredictionDecoder->ppiPredBandEnable[c][b] = ivas_split_rend_bitstream_read_int32( pBits, 1 ); psPredictionDecoder->ppiPredBandEnable[c][b] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 );
iBitsRead += 1; iBitsRead += 1;
if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 ) if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
...@@ -257,9 +300,9 @@ int32_t ReadPredictors( ...@@ -257,9 +300,9 @@ int32_t ReadPredictors(
int32_t iA1Phase; int32_t iA1Phase;
float fA1Real; float fA1Real;
float fA1Imag; float fA1Imag;
iA1Mag = ivas_split_rend_bitstream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS ); iA1Mag = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS );
iBitsRead += PRED_QUNAT_FILTER_MAG_BITS; iBitsRead += PRED_QUNAT_FILTER_MAG_BITS;
iA1Phase = ivas_split_rend_bitstream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS ); iA1Phase = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS );
iBitsRead += PRED_QUANT_FILTER_PHASE_BITS; iBitsRead += PRED_QUANT_FILTER_PHASE_BITS;
psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag; psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag;
...@@ -294,6 +337,69 @@ int32_t ReadPredictors( ...@@ -294,6 +337,69 @@ int32_t ReadPredictors(
return iBitsRead; return iBitsRead;
} }
/* PLC_IMPROVEMENT */
void SetDecodingPassed( PredictionDecoder *psPredictionDecoder )
{
int32_t n, ch;
for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
{
for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
{
psPredictionDecoder->ppiDecodingFailed[ch][n] = 0;
}
}
}
int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder )
{
int32_t n, ch;
for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
{
for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
{
if ( psPredictionDecoder->ppiDecodingUnresolved[ch][n] == 1 )
{
return 1;
}
}
}
return 0;
}
void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder )
{
int32_t n, ch;
for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
{
for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
{
psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n];
}
}
}
void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder )
{
int32_t n, ch;
int32_t iCurrentSubSet = psPredictionDecoder->iSubSetId;
for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
{
/* Prediction data always available for current subset */
psPredictionDecoder->ppiDecodingUnresolved[ch][iCurrentSubSet] = 0;
for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
{
int32_t iSubSetActive = get_bit( psPredictionDecoder->piPredChanEnable[ch], n );
if ( iSubSetActive == 0 )
{
/* Prediction information available inactive subsets (e.g. no Prediction) */
psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 0;
}
}
}
}
/*-------------------------------------------------------------------* /*-------------------------------------------------------------------*
* Function ApplyInversePredictors() * Function ApplyInversePredictors()
* *
......