Commit a4cacd75 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

0DOF split rendering support for non-diegetic stereo out

parent 65ebb129
Loading
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -417,7 +417,8 @@ int main(
        /* sanity check */
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
             && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
             && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
             arg.Opt_non_diegetic_pan == 0
#endif
        )
        {
@@ -608,7 +609,8 @@ int main(
        /* sanity check */
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB &&
             arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
             arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
             arg.Opt_non_diegetic_pan == 0 )
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" );
            goto cleanup;
@@ -1800,7 +1802,7 @@ static ivas_error initOnFirstGoodFrame(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
    {
        pFullDelayNumSamples[0] = 0;
    }
@@ -1827,7 +1829,7 @@ static ivas_error initOnFirstGoodFrame(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
    {
        /* Open split rendering metadata writer */
        int16_t delayNumSamples_temp[3];
@@ -1844,7 +1846,7 @@ static ivas_error initOnFirstGoodFrame(

        IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendCodecFrameSizeMs );

        if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
        if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) )
        {
            if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK )
            {
@@ -1862,7 +1864,7 @@ static ivas_error initOnFirstGoodFrame(
        }
    }

    if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
    if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 )
    {
#endif
        /* Open audio writer and write all previously skipped bad frames now that frame size is known */
@@ -2360,7 +2362,7 @@ static ivas_error decodeG192(
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
            if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
            {
                if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
                {
@@ -2442,7 +2444,7 @@ static ivas_error decodeG192(
        if ( decodedGoodFrame )
        {
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
            if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
            {
                if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK )
                {
@@ -2451,7 +2453,7 @@ static ivas_error decodeG192(
                }
            }

            if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
            if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 )
            {
#endif
                if ( delayNumSamples < nOutSamples )
+10 −4
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ static ivas_error ivas_dec_reconfig_split_rend(
        cldfb_in_flag = 1;
    }

    isar_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis );
    isar_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );

    isCldfbNeeded = 0;
#ifndef SPLIT_REND_WITH_HEAD_ROT
@@ -128,6 +128,10 @@ static ivas_error ivas_dec_reconfig_split_rend(
#endif
        }
    }
    else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
    {
        isCldfbNeeded = 1;
    }

    if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL )
    {
@@ -239,7 +243,7 @@ static ivas_error ivas_dec_init_split_rend(
        cldfb_in_flag = 1;
    }

    isar_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis );
    isar_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );

    if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) )
    {
@@ -1095,7 +1099,8 @@ ivas_error ivas_init_decoder_front(

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
         || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
         || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
#endif
    )
    {
@@ -1257,7 +1262,8 @@ ivas_error ivas_init_decoder(
     * Initialize binuaral split rendering
     *-----------------------------------------------------------------*/

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
        if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK )
        {
+60 −2
Original line number Diff line number Diff line
@@ -1073,6 +1073,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    int16_t numPoses;
    int16_t slots_rendered, slots_rendered_new;
    int16_t ro_md_flag;
    IVAS_QUATERNION Quaternion;

    error = IVAS_ERR_OK;
    st_ivas = hIvasDec->st_ivas;
@@ -1097,7 +1098,8 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES );
        numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize;
    }
    if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )

    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) == 0 )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }
@@ -1162,8 +1164,19 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        ro_md_flag = 0;
    }

    if ( st_ivas->hHeadTrackData != NULL )
    {
        Quaternion = st_ivas->hHeadTrackData->Quaternions[0];
    }
    else
    {
        Quaternion.w = -3.0f;
        Quaternion.x = 0.0f;
        Quaternion.y = 0.0f;
        Quaternion.z = 0.0f;
    }
    if ( ( error = isar_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend,
                                                       st_ivas->hHeadTrackData->Quaternions[0],
                                                       Quaternion,
                                                       st_ivas->hRenderConfig->split_rend_config.splitRendBitRate,
                                                       st_ivas->hRenderConfig->split_rend_config.codec,
                                                       st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms,
@@ -3833,4 +3846,49 @@ PCM_RESOLUTION pcm_type_API_to_internal(
    return pcm_resolution;
}

int16_t IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
)
{
    Decoder_Struct *st_ivas;
    int16_t isSplitRend;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
    st_ivas = hIvasDec->st_ivas;
    isSplitRend = 0;

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
        isSplitRend = 1;
    }

    return isSplitRend;
}

int16_t IVAS_DEC_is_split_rendering_coded_out(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
)
{
    Decoder_Struct *st_ivas;
    int16_t isSplitCoded;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
    st_ivas = hIvasDec->st_ivas;
    isSplitCoded = 0;

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
        isSplitCoded = 1;
    }

    return isSplitCoded;
}
#endif
+7 −0
Original line number Diff line number Diff line
@@ -193,6 +193,13 @@ ivas_error IVAS_DEC_GetCldfbSamples(
    IVAS_AUDIO_CONFIG *audio_config,            /* o  : audio configuration                                                     */
    int16_t *nOutSamples                        /* o  : number of samples per channel written to output buffer                  */
);

int16_t IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle  */
);
int16_t IVAS_DEC_is_split_rendering_coded_out(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
);
#endif

/*! r: error code */
+1 −1
Original line number Diff line number Diff line
@@ -1661,7 +1661,7 @@ ivas_error isar_set_split_rend_setup(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" );
    }

    isar_renderSplitGetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, hCombinedOrientationData->sr_pose_pred_axis );
    isar_renderSplitGetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS );

    if ( hCombinedOrientationData != NULL && hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
    {