Commit 5d0c233e authored by sagnowski's avatar sagnowski
Browse files

Add first draft of IVAS_DEC_GetSplitBinaural (untested)

parent 9dc8cab2
Loading
Loading
Loading
Loading
+88 −2
Original line number Diff line number Diff line
@@ -857,7 +857,7 @@ ivas_error IVAS_DEC_GetSamples(
    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 *nOutSamples,        /* o  : number of samples per channel written to output buffer                  */
    bool *needNewFrame           /* indication that the decoder needs a new frame                                */
#ifdef SPLIT_REND_WITH_HEAD_ROT
#if defined SPLIT_REND_WITH_HEAD_ROT && !defined API_5MS
    ,
    IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits /* o : bitstream output for split rendering mode*/
#endif
@@ -983,6 +983,92 @@ ivas_error IVAS_DEC_GetSamples(
}
#endif

#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
ivas_error IVAS_DEC_GetSplitBinaural(
    IVAS_DEC_HANDLE hIvasDec,                  /* i/o: IVAS decoder handle                                                     */
    bool *needNewFrame,                        /* indication that the decoder needs a new frame                                */
    IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits /* o : bitstream output for split rendering mode*/
)
{
    Decoder_Struct *st_ivas;
    AUDIO_CONFIG output_config;
    int32_t output_Fs;
    float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k];
    int16_t output_int[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; /* TODO(sgi): Need conversion */
    int16_t numSamplesPerChannel, nOutSamples;
    int16_t i, j;
    ivas_error error;

    error = IVAS_ERR_OK;
    st_ivas = hIvasDec->st_ivas;
    output_config = st_ivas->hDecoderConfig->output_config;
    output_Fs = st_ivas->hDecoderConfig->output_Fs;
    numSamplesPerChannel = output_Fs / FRAMES_PER_SEC; /* TODO(sgi): Accommodate 5ms framing */

    if ( output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM  )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }

    while ( error == IVAS_ERR_OK )
    {
        /* Decode and render */
        if ( ( error = IVAS_DEC_GetSamples(
                   hIvasDec,
                   numSamplesPerChannel,
                   output_int,
                   &nOutSamples,
                   needNewFrame ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        /*split rendering process calls*/
        IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend;
        int16_t max_band;
        int16_t pcm_out;
        int16_t numPoses;

        hSplitBinRend = &st_ivas->splitBinRend;

        ivas_set_split_rend_setup(hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits );

        numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses;

        /* [tmp] convert int back to float and change buffer layout */
        for (i = 0; i < numSamplesPerChannel; ++i)
        {
            for (j = 0; j < BINAURAL_CHANNELS * numPoses; ++j)
            {
                output[j][i] = (float) output_int[i * BINAURAL_CHANNELS * numPoses + j];
            }
        }

        max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 );
        pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;

        error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend,
                                                    st_ivas->hHeadTrackData->Quaternion,
                                                    st_ivas->hRenderConfig->split_rend_config.splitRendBitRate,
                                                    st_ivas->hRenderConfig->split_rend_config.codec,
                                                    hSplitBinRend->hSplitRendBits,
                                                    hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural,
                                                    hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural,
                                                    max_band, output, 1,
                                                    st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV,
                                                    pcm_out );
        if ( error != IVAS_ERR_OK )
        {
            return error;
        }

        free( st_ivas->splitBinRend.hMultiBinCldfbData );
    }

    return error;
}
#endif


/*---------------------------------------------------------------------*
 * IVAS_DEC_Setup( )
+9 −1
Original line number Diff line number Diff line
@@ -188,12 +188,20 @@ ivas_error IVAS_DEC_GetSamples(
    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 *nOutSamples                        /* o  : number of samples per channel written to output buffer                  */
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
#if defined SPLIT_REND_WITH_HEAD_ROT && !defined API_5MS
    ,
    IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits  /* o : bitstream output for split rendering mode*/
#endif
);

#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
ivas_error IVAS_DEC_GetSplitBinaural(
    IVAS_DEC_HANDLE hIvasDec,    /* i/o: IVAS decoder handle                                                     */
    bool *needNewFrame,           /* indication that the decoder needs a new frame                                */
    IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits  /* o : bitstream output for split rendering mode*/
);
#endif

/*! r: error code */
ivas_error IVAS_DEC_GetObjectMetadata(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
+1 −1
Original line number Diff line number Diff line
@@ -1495,7 +1495,7 @@ void ivas_renderSplitUpdateNoCorrectionPoseData(
ivas_error ivas_renderMultiBinToSplitBinaural(
    SPLIT_REND_WRAPPER *hSplitBin,
#ifdef API_5MS
	const IVAS_QUATERNION headPosition[MAX_PARAM_SPATIAL_SUBFRAMES],
	const IVAS_QUATERNION headPosition,
#else
	const IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES],
#endif
+8 −0
Original line number Diff line number Diff line
@@ -1897,7 +1897,11 @@ static ivas_error splitRendLc3plusEncodeAndWrite(

static ivas_error ivas_renderMultiTDBinToSplitBinaural(
    SPLIT_REND_WRAPPER *hSplitBin,
#ifdef API_5MS
    const IVAS_QUATERNION headPosition,
#else
    const IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES],
#endif
    const int32_t SplitRendBitRate,
    ivas_split_rend_bits_t *pBits,
    const int16_t max_bands,
@@ -2095,7 +2099,11 @@ static void lc3plusTimeAlignCldfbPoseCorr(

ivas_error ivas_renderMultiBinToSplitBinaural(
    SPLIT_REND_WRAPPER *hSplitBin,
#ifdef API_5MS
    const IVAS_QUATERNION headPosition,
#else
    const IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES],
#endif
    const int32_t SplitRendBitRate,
    IVAS_SPLIT_REND_CODEC splitCodec,
    ivas_split_rend_bits_t *pBits,