Commit a0f5a842 authored by sagnowski's avatar sagnowski
Browse files

Use the function write_pose_correction_section again

parent 0642edf0
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -156,7 +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. */
#define SPLIT_REND_METADATA_SECTION_SIZE            /* FhG: prepends metadata section in the split bitstream frame with size information */
#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

+13 −0
Original line number Diff line number Diff line
@@ -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,
+20 −43
Original line number Diff line number Diff line
@@ -1843,48 +1843,6 @@ ivas_error splitRendLc3plusEncodeAndWrite(
    return IVAS_ERR_OK;
}

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
static 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;
#ifdef SPLIT_REND_METADATA_SECTION_SIZE
    int32_t md_section_start, md_section_end;

    md_section_start = pBits->bits_written;
#endif
    available_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000;

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
    /* 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;
#endif

    /* 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 );
    }

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
    /* Update metadata section size field with the actual number of bits written */
    md_section_end = pBits->bits_written;
    pBits->bits_written = md_section_start; /* Hack to 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
}
#endif


/*-------------------------------------------------------------------------
 * Function isar_renderMultiTDBinToSplitBinaural()
@@ -1909,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
@@ -1988,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;
@@ -1998,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 )
    {
+22 −10
Original line number Diff line number Diff line
@@ -312,14 +312,14 @@ void ISAR_PRE_REND_GetMultiBinPoseData(
    isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, pMultiBinPoseData, rot_axis );
}

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
/*-------------------------------------------------------------------------
 * Function write_pose_correction_section()
 *
 *
 *------------------------------------------------------------------------*/

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
static void write_pose_correction_section( SPLIT_REND_WRAPPER *hSplitBin,
void write_pose_correction_section( SPLIT_REND_WRAPPER *hSplitBin,
                                           const IVAS_QUATERNION headPosition,
                                           const int32_t SplitRendBitRate,
                                           ISAR_SPLIT_REND_BITS_HANDLE pBits,
@@ -330,19 +330,15 @@ static void write_pose_correction_section( SPLIT_REND_WRAPPER *hSplitBin,
                                           const int16_t ro_md_flag )
{
    int32_t available_md_bits;
#ifdef SPLIT_REND_METADATA_SECTION_SIZE
    int32_t md_section_start, md_section_end;

    md_section_start = pBits->bits_written;
#endif
    available_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000;

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
    /* 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;
#endif

    /* Write pose correction metadata */
    if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
@@ -350,13 +346,11 @@ static void write_pose_correction_section( SPLIT_REND_WRAPPER *hSplitBin,
        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 );
    }

#ifdef SPLIT_REND_METADATA_SECTION_SIZE
    /* Update metadata section size field with the actual number of bits written */
    md_section_end = pBits->bits_written;
    pBits->bits_written = md_section_start; /* Hack to write to the beginning of the metadata section */
    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
}
#endif

@@ -388,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
@@ -430,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
@@ -443,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 )
    {