Commit 5e0db641 authored by vaclav's avatar vaclav
Browse files

introduce function is_split_rendering_enabled() and correct return values for...

introduce function is_split_rendering_enabled() and correct return values for IVAS_DEC_is_split_rendering_enabled() and IVAS_DEC_is_split_rendering_coded_out()
parent dd6051a1
Loading
Loading
Loading
Loading
+35 −7
Original line number Diff line number Diff line
@@ -1942,6 +1942,9 @@ static ivas_error initOnFirstGoodFrame(
#endif
)
{
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t isSplitRend, isSplitCoded;
#endif
    ivas_error error = IVAS_ERR_UNKNOWN;

    /* Now delay, number of output channels and frame size are known */
@@ -1952,7 +1955,19 @@ static ivas_error initOnFirstGoodFrame(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error );
        return error;
    }

    if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error );
        return error;
    }

    if ( isSplitRend )
    {
        pFullDelayNumSamples[0] = 0;
    }
@@ -1979,7 +1994,7 @@ static ivas_error initOnFirstGoodFrame(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
    if ( isSplitRend )
    {
        /* Open split rendering metadata writer */
        int16_t delayNumSamples_temp[3];
@@ -2008,7 +2023,7 @@ static ivas_error initOnFirstGoodFrame(
            return error;
        }

        if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) )
        if ( isSplitCoded )
        {
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
            if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK )
@@ -2040,7 +2055,7 @@ static ivas_error initOnFirstGoodFrame(
        }
    }

    if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 )
    if ( !isSplitCoded )
    {
#endif
        /* Open audio writer and write all previously skipped bad frames now that frame size is known */
@@ -2278,6 +2293,19 @@ static ivas_error decodeG192(
    int16_t vec_pos_update, vec_pos_len;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    SplitFileReadWrite *splitRendWriter = NULL;
    int16_t isSplitRend, isSplitCoded;

    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error );
        return error;
    }

    if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error );
        return error;
    }
#endif

#ifdef FIX_1053_REVERB_RECONFIGURATION
@@ -2601,7 +2629,7 @@ static ivas_error decodeG192(
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
            if ( isSplitRend )
            {
                if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
                {
@@ -2681,7 +2709,7 @@ static ivas_error decodeG192(
        if ( decodedGoodFrame )
        {
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
            if ( isSplitRend )
            {
                if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK )
                {
@@ -2690,7 +2718,7 @@ static ivas_error decodeG192(
                }
            }

            if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 )
            if ( !isSplitCoded )
            {
#endif
                if ( delayNumSamples < nOutSamples )
+3 −4
Original line number Diff line number Diff line
@@ -1827,12 +1827,11 @@ ivas_error ivas_jbm_dec_flush_renderer(
#ifdef DEBUGGING
            st_ivas->noClipping +=
#endif
                ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out,
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                 (int16_t *)
                ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data );
#else
    ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data );
#endif
                                     data );

#ifdef SPLIT_REND_WITH_HEAD_ROT
            break;
        case PCM_FLOAT32:
+20 −21
Original line number Diff line number Diff line
@@ -1147,7 +1147,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize;
    }

    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) == 0 )
    if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig->split_rend_config.dof ) == 0 )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }
@@ -3540,6 +3540,7 @@ static ivas_error evs_dec_main(
        st_ivas->noClipping +=
#endif
            ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local );

        mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out );
    }
    else
@@ -4099,28 +4100,24 @@ static void ivas_destroy_handle_isar(
 *
 *---------------------------------------------------------------------*/

/*! r: flag to indicate if split rendering is enabled */
int16_t IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
/*! r: decoder error code */
ivas_error IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle                            */
    int16_t *isSplitRend      /* o  : flag to indicate if split rendering is enabled */
)
{
    Decoder_Struct *st_ivas;
    int16_t isSplitRend;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == 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;
    }
    *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig->split_rend_config.dof );

    return isSplitRend;
    return IVAS_ERR_OK;
}


@@ -4308,27 +4305,29 @@ static ivas_error ivas_dec_init_split_rend(
 *
 *---------------------------------------------------------------------*/

/*! r: flag to indicate if split rendering coded output is enabled */
int16_t IVAS_DEC_is_split_rendering_coded_out(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
/*! r: decoder error code */
ivas_error IVAS_DEC_is_split_rendering_coded_out(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle  */
    int16_t *isSplitCoded     /* o  : flag to indicate if split rendering is enabled */
)
{
    Decoder_Struct *st_ivas;
    int16_t isSplitCoded;

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

    st_ivas = hIvasDec->st_ivas;
    isSplitCoded = 0;

    *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;
        *isSplitCoded = 1;
    }

    return isSplitCoded;
    return IVAS_ERR_OK;
}
#endif
+8 −6
Original line number Diff line number Diff line
@@ -200,14 +200,16 @@ ivas_error IVAS_DEC_GetCldfbSamples(
    int16_t *nOutSamples                        /* o  : number of samples per channel written to output buffer                  */
);

/*! r: flag to indicate if split rendering is enabled */
int16_t IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec                    /* i  : IVAS decoder handle                                                     */
/*! r: decoder error code */
ivas_error IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    int16_t *isSplitRend                        /* o  : flag to indicate if split rendering is enabled                          */
);

/*! r: flag to indicate if split rendering coded output is enabled */
int16_t IVAS_DEC_is_split_rendering_coded_out(
    IVAS_DEC_HANDLE hIvasDec                    /* i/o: IVAS decoder handle                                                     */
/*! r: decoder error code */
ivas_error IVAS_DEC_is_split_rendering_coded_out(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    int16_t *isSplitCoded                       /* o  : flag to indicate if split rendering is enabled                          */
);
#endif

+26 −0
Original line number Diff line number Diff line
@@ -466,3 +466,29 @@ ivas_error ivas_output_buff_dec(

    return IVAS_ERR_OK;
}


#ifdef SPLIT_REND_WITH_HEAD_ROT
/*---------------------------------------------------------------------*
 * is_split_rendering_enabled()
 *
 * 
 *---------------------------------------------------------------------*/

/*! r: flag to indicate if split rendering is enabled */
int16_t is_split_rendering_enabled(
    const DECODER_CONFIG_HANDLE hDecoderConfig, /* i  : configuration structure                      */
    const int16_t dof                           /* i  : flag to specify if pose correction is needed */
)
{
    if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->Opt_non_diegetic_pan && dof == 0 ) )
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
#endif
Loading