diff --git a/lib_com/options.h b/lib_com/options.h index d19f0c9867857ad947ff949f3b088ae3910b9d50..b88e6f41c2f47a882eb57a5356ba88d966bf9126 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,9 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#define SPLIT_REND_METADATA_SECTION_SIZE /* FhG: In the split bitstream frame, prepends metadata section with size information */ +#endif #define FIX_NUM_SUBFRAME_UPDATE diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 2ae01bd5787e649ae784c2e50a6974b400c3243d..15e71ad53e69435591f832d02f3239e53a763255 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -109,6 +109,10 @@ typedef enum #define ISAR_SPLIT_REND_HQ_MODE_BITS 1 #define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 +#ifdef SPLIT_REND_METADATA_SECTION_SIZE +#define IVAS_SPLIT_REND_MD_SIZE_BITS 13 /* Max expected size of the MD section: 256000 kbps / 50 fps = 5120 < 2^13 = 8192 */ +#endif + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 #endif diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index ca9d86760d8ad9e7092066e7c6784b7d685c040d..2812caedb59561217a407cd6274ea8c45e723ce9 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -333,6 +333,19 @@ ivas_error isar_split_rend_choose_default_codec( const int16_t num_subframes /* i : number of subframes */ ); + +#ifdef SPLIT_REND_METADATA_SECTION_SIZE +void write_pose_correction_section( SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const int32_t SplitRendBitRate, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t pcm_out_flag, + const int16_t ro_md_flag ); +#endif + void ISAR_SPLIT_REND_BITStream_init( ISAR_SPLIT_REND_BITS_HANDLE pBits, const int32_t buf_len_bytes, diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index e03dc1d856125ac48e6a2118095982a8010a4545..d91f0bbd5efbe5157366308df380572cf6a1beb8 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -1843,6 +1843,7 @@ ivas_error splitRendLc3plusEncodeAndWrite( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * Function isar_renderMultiTDBinToSplitBinaural() * @@ -1866,7 +1867,10 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( { ivas_error error; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int32_t bit_len, available_bits, target_md_bits; + int32_t bit_len, available_bits; +#ifndef SPLIT_REND_METADATA_SECTION_SIZE + int32_t target_md_bits; +#endif #else int32_t bit_len, available_bits, target_md_bits, actual_md_bits; #endif @@ -1945,6 +1949,21 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( } } + +#ifdef SPLIT_REND_METADATA_SECTION_SIZE + if ( hSplitBin->multiBinPoseData.poseCorrectionMode != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + write_pose_correction_section( hSplitBin, + headPosition, + SplitRendBitRate, + pBits, + Cldfb_In_BinReal, + Cldfb_In_BinImag, + low_res_pre_rend_rot, + pcm_out_flag, + ro_md_flag ); + } +#else if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; @@ -1955,6 +1974,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); } +#endif if ( pcm_out_flag == 0 ) { diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 0466b264a4a9127b6f915ac1d3705949dab46555..6b1a64fbc7298ec211626a371845bcb746da3ae8 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1402,6 +1402,11 @@ static ivas_error renderSplitBinauralWithPostRot( #endif int16_t iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; const ISAR_POST_REND_HeadRotData *pHeadRotData; +#ifdef SPLIT_REND_METADATA_SECTION_SIZE + int16_t split_rend_md_section_size_bits; + + split_rend_md_section_size_bits = 0; +#endif isPostRendInputCldfb = 0; push_wmops( "renderSplitBinauralWithPostRot" ); @@ -1447,6 +1452,15 @@ static ivas_error renderSplitBinauralWithPostRot( if ( hSplitBin->first_good_frame_received == 1 ) { +#ifdef SPLIT_REND_METADATA_SECTION_SIZE + if ( bits.pose_correction != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + // This info is currently unused, but will later be needed e.g. when packing SR bitstream into RTP + split_rend_md_section_size_bits = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( &bits, IVAS_SPLIT_REND_MD_SIZE_BITS ); + (void) split_rend_md_section_size_bits; + } +#endif + if ( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { if ( !SplitRendBFI ) diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 2d4b119a809b6c2268a243f63cfd243e30c72525..49ac6a65d48cbe91aad735018ee314ce0e1511ae 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -312,6 +312,48 @@ void ISAR_PRE_REND_GetMultiBinPoseData( isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, pMultiBinPoseData, rot_axis ); } +#ifdef SPLIT_REND_METADATA_SECTION_SIZE +/*------------------------------------------------------------------------- + * Function write_pose_correction_section() + * + * + *------------------------------------------------------------------------*/ + +void write_pose_correction_section( SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const int32_t SplitRendBitRate, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t pcm_out_flag, + const int16_t ro_md_flag ) +{ + int32_t available_md_bits; + int32_t md_section_start, md_section_end; + + md_section_start = pBits->bits_written; + available_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; + + /* Skip first few bits, where the size info of the pose correction metadata section + * will be written later (it is not yet known at this point) */ + available_md_bits -= IVAS_SPLIT_REND_MD_SIZE_BITS; + pBits->bits_written += IVAS_SPLIT_REND_MD_SIZE_BITS; + + /* Write pose correction metadata */ + if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, available_md_bits, low_res_pre_rend_rot, ro_md_flag ); + } + + /* Update metadata section size field with the actual number of bits written */ + md_section_end = pBits->bits_written; + pBits->bits_written = md_section_start; /* Write to the beginning of the metadata section */ + ISAR_SPLIT_REND_BITStream_write_int32( pBits, md_section_end - md_section_start, IVAS_SPLIT_REND_MD_SIZE_BITS ); + pBits->bits_written = md_section_end; +} +#endif + /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_MultiBinToSplitBinaural() * @@ -340,7 +382,10 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( { ivas_error error; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int32_t bit_len, target_md_bits, available_bits; + int32_t bit_len, available_bits; +#ifndef SPLIT_REND_METADATA_SECTION_SIZE + int32_t target_md_bits; +#endif #else int32_t bit_len, target_md_bits, actual_md_bits, available_bits; #endif @@ -382,6 +427,20 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( lc3plusTimeAlignCldfbPoseCorr( hSplitBin, Cldfb_In_BinReal, Cldfb_In_BinImag ); } +#ifdef SPLIT_REND_METADATA_SECTION_SIZE + if ( hSplitBin->multiBinPoseData.poseCorrectionMode != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + write_pose_correction_section( hSplitBin, + headPosition, + SplitRendBitRate, + pBits, + Cldfb_In_BinReal, + Cldfb_In_BinImag, + low_res_pre_rend_rot, + pcm_out_flag, + ro_md_flag ); + } +#else #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS actual_md_bits = pBits->bits_written; #endif @@ -395,6 +454,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); } +#endif if ( pcm_out_flag == 0 ) {