Commit 590126df authored by Adam Mills's avatar Adam Mills
Browse files

Adding ISAR pre prend API

parent 335ef7b7
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "prot.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#include "common_api_types.h"
#include "lib_isar_pre_rend.h"
#endif
#include <assert.h>
#include <math.h>
@@ -281,7 +282,7 @@ static ivas_error ivas_dec_init_split_rend(
    }
#endif

    error = isar_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize );
    error = isar_pre_rend_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize );
    return error;
}
#endif
@@ -2701,7 +2702,7 @@ void ivas_destroy_dec(

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /* Split binaural renderer handle */
    isar_split_renderer_close( &st_ivas->hSplitBinRend.splitrend );
    isar_pre_rend_close( &st_ivas->hSplitBinRend.splitrend, NULL );

    for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
    {
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "isar_prot.h"
#include "lib_isar_pre_rend.h"
#include "prot.h"
#include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h"
@@ -1199,7 +1200,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        Quaternion.y = 0.0f;
        Quaternion.z = 0.0f;
    }
    if ( ( error = isar_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend,
    if ( ( error = isar_pre_rend_MultiBinToSplitBinaural( &hSplitBinRend->splitrend,
                                                       Quaternion,
                                                       st_ivas->hRenderConfig->split_rend_config.splitRendBitRate,
                                                       st_ivas->hRenderConfig->split_rend_config.codec,
+6 −59
Original line number Diff line number Diff line
@@ -175,11 +175,6 @@ void isar_SplitRenderer_getdiagdiff(
    const int16_t min_val,
    const int16_t max_val );

void isar_renderSplitGetMultiBinPoseData(
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config,
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
    const ISAR_SPLIT_REND_ROT_AXIS rot_axis );

void isar_split_rend_get_quant_params(
    const int16_t num_md_bands,
    int16_t pred_real_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS],
@@ -232,6 +227,12 @@ void isar_rend_CldfbSplitPostRendProcess(
void isar_init_multi_bin_pose_data(
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData );

void isar_renderSplitGetMultiBinPoseData(
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config,
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
    const ISAR_SPLIT_REND_ROT_AXIS rot_axis
);

void isar_rend_CldfbSplitPreRendProcess(
    const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend,
    const IVAS_QUATERNION headPosition,
@@ -246,19 +247,6 @@ void isar_rend_CldfbSplitPreRendProcess(
void isar_init_split_post_rend_handles(
    ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper );

ivas_error isar_splitBinPreRendOpen(
    ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend,
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
    const int32_t output_Fs
#else
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData
#endif
);

void ivas_splitBinPreRendClose(
    ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend );

void isar_set_split_rend_ht_setup(
    ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend,
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData );
@@ -286,17 +274,6 @@ int32_t isar_get_lcld_bitrate(
int8_t isar_get_lc3plus_bitrate_id(
    const int32_t SplitRendBitRate );

ivas_error isar_split_renderer_open(
    SPLIT_REND_WRAPPER *hSplitBinRend,
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig,
    const int32_t output_Fs,
    const int16_t cldfb_in_flag,
    const int16_t pcm_out_flag,
    const int16_t num_subframes );

void isar_split_renderer_close(
    SPLIT_REND_WRAPPER *hSplitBinRend );

int32_t isar_get_split_rend_md_target_brate(
    const int32_t SplitRendBitRate,
    const int16_t pcm_out_flag );
@@ -309,22 +286,6 @@ ivas_error isar_split_rend_choose_default_codec(
    const int16_t num_subframes    /* i  : number of subframes                     */
);

ivas_error isar_renderMultiBinToSplitBinaural(
    SPLIT_REND_WRAPPER *hSplitBin,
    const IVAS_QUATERNION headPosition,
    const int32_t SplitRendBitRate,
    ISAR_SPLIT_REND_CODEC splitCodec,
    int16_t codec_frame_size_ms,
    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 max_bands,
    float *output[],
    const int16_t low_res_pre_rend_rot,
    const int16_t cldfb_in_flag,
    const int16_t pcm_out_flag,
    const int16_t ro_md_flag );

void ISAR_SPLIT_REND_BITStream_init(
    ISAR_SPLIT_REND_BITS_HANDLE pBits,
    const int32_t buf_len_bytes,
@@ -357,20 +318,6 @@ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType(
void isar_init_split_rend_handles(
    SPLIT_REND_WRAPPER *hSplitRendWrapper );

void closeSplitRend(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer );

ivas_error initSplitRend(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer,
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config,
    IVAS_REND_HeadRotData headRotData,
    const int32_t outputSampleRate,
    const IVAS_AUDIO_CONFIG outConfig,
    const int16_t cldfb_in_flag,
    const int16_t num_subframes );

#endif

/* clang-format on */
+102 −34
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "prot.h"
#include "ivas_cnst.h"
#include "isar_rom_post_rend.h"
#include "lib_isar_pre_rend.h"
#include "isar_prot.h"
#ifdef DEBUGGING
#include "debug.h"
@@ -50,6 +51,8 @@
#include "string.h"
#endif

#define MAX_BUFFER_LENGTH_PER_CHANNEL       ( L_FRAME48k )
#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 )

/*-------------------------------------------------------------------------
 * Local functions
@@ -1491,7 +1494,7 @@ void isar_rend_CldfbSplitPreRendProcess(
 *
 *------------------------------------------------------------------------*/

ivas_error isar_splitBinPreRendOpen(
static ivas_error isar_splitBinPreRendOpen(
    ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend,
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
@@ -1570,7 +1573,7 @@ ivas_error isar_splitBinPreRendOpen(
 *
 *------------------------------------------------------------------------*/

void ivas_splitBinPreRendClose(
static void ivas_splitBinPreRendClose(
    ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend )
{
    if ( ( *hBinHrSplitPreRend ) != NULL )
@@ -1633,6 +1636,20 @@ void isar_set_split_rend_ht_setup(
    return;
}

/*-------------------------------------------------------------------------*
 * isar_pre_rend_GetMultiBinPoseData()
 *
 *
 *-------------------------------------------------------------------------*/

void isar_pre_rend_GetMultiBinPoseData(
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config,
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
    const ISAR_SPLIT_REND_ROT_AXIS rot_axis
)
{
    isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, pMultiBinPoseData, rot_axis );
}

/*-------------------------------------------------------------------------*
 * isar_set_split_rend_setup()
@@ -1640,6 +1657,7 @@ void isar_set_split_rend_ht_setup(
 * Setup IVAS split rendering
 *-------------------------------------------------------------------------*/


ivas_error isar_set_split_rend_setup(
    ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend,
    ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig,
@@ -1710,30 +1728,6 @@ void isar_init_split_rend_handles(
    return;
}

/*-------------------------------------------------------------------------
 * Function closeSplitRend()
 *
 *
 *------------------------------------------------------------------------*/

void closeSplitRend(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer )
{
    isar_split_renderer_close( pSplitRendWrapper );

    if ( pSplitRendEncBuffer->data != NULL )
    {
        free( pSplitRendEncBuffer->data );
        pSplitRendEncBuffer->data = NULL;
    }

    pSplitRendEncBuffer->config.numChannels = 0;
    pSplitRendEncBuffer->config.numSamplesPerChannel = 0;

    return;
}

/*-------------------------------------------------------------------------
 * Function split_renderer_open_lc3plus()
 *
@@ -1804,12 +1798,12 @@ static ivas_error split_renderer_open_lc3plus(


/*-------------------------------------------------------------------------
 * Function isar_split_renderer_open()
 * Function isar_pre_rend_open()
 *
 *
 *------------------------------------------------------------------------*/

ivas_error isar_split_renderer_open(
ivas_error isar_pre_rend_open(
    SPLIT_REND_WRAPPER *hSplitRendWrapper,
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig,
    const int32_t OutSampleRate,
@@ -1944,13 +1938,74 @@ ivas_error isar_split_renderer_open(


/*-------------------------------------------------------------------------
 * Function isar_split_renderer_close()
 * Function isar_pre_rend_init()
 *
 *
 *------------------------------------------------------------------------*/

ivas_error isar_pre_rend_init(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer,
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config,
    IVAS_REND_HeadRotData headRotData,
    const int32_t outputSampleRate,
    const AUDIO_CONFIG outConfig,
    const int16_t cldfb_in_flag,
    const int16_t num_subframes )
{
    ivas_error error;
    IVAS_REND_AudioBufferConfig bufConfig;

    if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
        {
            isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis );
        }
        else if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE )
        {
            isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData );
        }

        if ( ( error = isar_pre_rend_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        /*allocate for CLDFB in and change to TD during process if needed*/
        bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL;
        bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses;
        bufConfig.is_cldfb = 1;
        pSplitRendEncBuffer->config = bufConfig;

        if ( ( pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL )
        {
            return IVAS_ERR_FAILED_ALLOC;
        }
    }
    else
    {
        IVAS_REND_AudioBufferConfig bufConfig2;

        bufConfig2.numSamplesPerChannel = 0;
        bufConfig2.numChannels = 0;
        bufConfig2.is_cldfb = 0;
        pSplitRendEncBuffer->config = bufConfig2;
        pSplitRendEncBuffer->data = NULL;
    }

    return IVAS_ERR_OK;
}

/*-------------------------------------------------------------------------
 * Function isar_pre_rend_close()
 *
 *
 *------------------------------------------------------------------------*/

void isar_split_renderer_close(
    SPLIT_REND_WRAPPER *hSplitBinRend )
void isar_pre_rend_close(
    SPLIT_REND_WRAPPER *hSplitBinRend,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer )
{
    int16_t i;

@@ -2006,6 +2061,19 @@ void isar_split_renderer_close(
        }
    }

    if ( pSplitRendEncBuffer != NULL )
    {

        if ( pSplitRendEncBuffer->data != NULL )
        {
            free( pSplitRendEncBuffer->data );
            pSplitRendEncBuffer->data = NULL;
        }

        pSplitRendEncBuffer->config.numChannels = 0;
        pSplitRendEncBuffer->config.numSamplesPerChannel = 0;
    }

    return;
}

@@ -2282,12 +2350,12 @@ static void lc3plusTimeAlignCldfbPoseCorr(


/*-------------------------------------------------------------------------
 * Function isar_renderMultiBinToSplitBinaural()
 * Function isar_pre_rend_MultiBinToSplitBinaural()
 *
 *
 *------------------------------------------------------------------------*/

ivas_error isar_renderMultiBinToSplitBinaural(
ivas_error isar_pre_rend_MultiBinToSplitBinaural(
    SPLIT_REND_WRAPPER *hSplitBin,
    const IVAS_QUATERNION headPosition,
    const int32_t SplitRendBitRate,
@@ -2307,7 +2375,7 @@ ivas_error isar_renderMultiBinToSplitBinaural(
    int32_t bit_len, target_md_bits, actual_md_bits, available_bits;

    error = IVAS_ERR_OK;
    push_wmops( "isar_renderMultiBinToSplitBinaural" );
    push_wmops( "isar_pre_rend_MultiBinToSplitBinaural" );

    if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
    {
+0 −55
Original line number Diff line number Diff line
@@ -632,61 +632,6 @@ static void clearInputSplitRend(
}


ivas_error initSplitRend(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer,
    const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config,
    IVAS_REND_HeadRotData headRotData,
    const int32_t outputSampleRate,
    const AUDIO_CONFIG outConfig,
    const int16_t cldfb_in_flag,
    const int16_t num_subframes )
{
    ivas_error error;
    IVAS_REND_AudioBufferConfig bufConfig;

    if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
        {
            isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis );
        }
        else if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE )
        {
            isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData );
        }

        if ( ( error = isar_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        /*allocate for CLDFB in and change to TD during process if needed*/
        bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL;
        bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses;
        bufConfig.is_cldfb = 1;
        pSplitRendEncBuffer->config = bufConfig;

        if ( ( pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL )
        {
            return IVAS_ERR_FAILED_ALLOC;
        }
    }
    else
    {
        IVAS_REND_AudioBufferConfig bufConfig2;

        bufConfig2.numSamplesPerChannel = 0;
        bufConfig2.numChannels = 0;
        bufConfig2.is_cldfb = 0;
        pSplitRendEncBuffer->config = bufConfig2;
        pSplitRendEncBuffer->data = NULL;
    }

    return IVAS_ERR_OK;
}


/*-------------------------------------------------------------------------
 * ISAR_POST_REND_Open()
 *
Loading