Commit 2a69d3b5 authored by Adam Mills's avatar Adam Mills
Browse files

Moving isar_pre_rend_init() out of the pre_render API

parent eddf9a0a
Loading
Loading
Loading
Loading
Loading
+0 −61
Original line number Diff line number Diff line
@@ -1949,67 +1949,6 @@ ivas_error isar_pre_rend_open(
    return IVAS_ERR_OK;
}


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

ivas_error isar_pre_rend_init(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer,
    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, 0 ) ) != 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()
 *
+0 −10
Original line number Diff line number Diff line
@@ -46,16 +46,6 @@ ivas_error isar_pre_rend_open(
    const int16_t num_subframes,
    const int16_t mixed_td_cldfb_flag );

ivas_error isar_pre_rend_init(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer,
    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 );

void isar_pre_rend_close(
    SPLIT_REND_WRAPPER *hSplitBinRend,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer );
+62 −2
Original line number Diff line number Diff line
@@ -3548,6 +3548,66 @@ static int16_t getCldfbRendFlag(
    return isCldfbRend;
}

/*-------------------------------------------------------------------------
 * Function ivas_pre_rend_init()
 *
 *
 *------------------------------------------------------------------------*/

static ivas_error ivas_pre_rend_init(
    SPLIT_REND_WRAPPER *pSplitRendWrapper,
    IVAS_REND_AudioBuffer *pSplitRendEncBuffer,
    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, 0 ) ) != 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;
}

#endif


@@ -3582,7 +3642,7 @@ ivas_error IVAS_REND_AddInput(
        int16_t cldfb_in_flag;
        cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) );

        if ( ( error = isar_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -4419,7 +4479,7 @@ int16_t IVAS_REND_FeedRenderConfig(
        cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN );
        isar_pre_rend_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer );

        if ( ( error = isar_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
        {
            return error;
        }