Commit e51bd2e2 authored by bayers's avatar bayers
Browse files

all possible render paths run now with variable speed decoding, audio quality only sparsely checked

parent 6b919859
Loading
Loading
Loading
Loading
+146 −142
Original line number Diff line number Diff line
@@ -943,7 +943,7 @@ static bool parseCmdlIVAS_dec(
            i++;
            int tmp = 100;
            arg->variableSpeedMode = true;
            if ( i < argc - 4 )
            if ( i < argc - 3 )
            {
                if ( !is_digits_only( argv[i] ) )
                {
@@ -969,7 +969,7 @@ static bool parseCmdlIVAS_dec(
        {
            i++;
            int tmp;
            if ( i < argc - 4 )
            if ( i < argc - 3 )
            {
                if ( !is_digits_only( argv[i] ) )
                {
@@ -2313,7 +2313,43 @@ static ivas_error decodeVariableSpeed(
    {
        /* Read next frame if not enough samples availble */

        if ( nSamplesAvailableNext < nOutSamples )
        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                goto cleanup;
            }

            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }

        /* decode and get samples */
        do
        {
            error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples,
                                              pcmBuf, 0,
                                              &nSamplesAvailableNext
#ifdef SUPPORT_JBM_TRACEFILE
                                              ,
                                              writeJbmTraceFileFrameWrapper,
                                              jbmTraceWriter
#endif
            );
            if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED )

            {
                fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
            if ( error == IVAS_ERR_VS_FRAME_NEEDED )
            {
                if ( arg.tsmScaleFileEnabled )
                {
@@ -2357,45 +2393,15 @@ static ivas_error decodeVariableSpeed(
                    fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
                error = IVAS_ERR_VS_FRAME_NEEDED;
            }
        } while ( error != IVAS_ERR_OK );

        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                goto cleanup;
            }

            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }

        /* decode and get samples */
        error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples,
                                                 pcmBuf, 0,
                                                 &nSamplesAvailableNext
#ifdef SUPPORT_JBM_TRACEFILE
                                                 ,
                                                 writeJbmTraceFileFrameWrapper,
                                                 jbmTraceWriter
#endif
            );
        if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED )
                                               
        if ( error == IVAS_ERR_END_OF_FILE )
        {
            fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
            break;
        }

        if ( error != IVAS_ERR_VS_FRAME_NEEDED )
        {
        /* Continue checking for first good frame until it is found */
        if ( !decodedGoodFrame )
        {
@@ -2516,8 +2522,6 @@ static ivas_error decodeVariableSpeed(
#endif
    }

    }


    /*------------------------------------------------------------------------------------------*
     * Flush what is still left in the VoIP Buffers....
+109 −7
Original line number Diff line number Diff line
@@ -859,6 +859,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
void ivas_jbm_dec_tc_buffer_close(
    DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
);
void ivas_jbm_dec_td_renderers_adapt_subframes(
    Decoder_Struct *st_ivas 
);
#endif

/*----------------------------------------------------------------------------------*
@@ -1008,6 +1011,10 @@ void ivas_param_ism_dec(
);

#ifdef JBM_TSM_ON_TCS
void ivas_ism_dec_digest_tc(
    Decoder_Struct *st_ivas
);

void ivas_param_ism_dec_digest_tc(
    Decoder_Struct *st_ivas,      /* i/o: IVAS decoder handle                                          */
    const uint16_t nCldfbSlots,   /* i : number of CLFBS slots in the transport channels         */
@@ -3289,7 +3296,11 @@ void ivas_sba_getTCs(
);

ivas_error ivas_sba_linear_renderer(
#ifdef JBM_TSM_ON_TCS
    float *output_f[],                               /* i/o: synthesized core-coder transport channels/DirAC output  */
#else
    float output_f[][L_FRAME48k],                               /* i/o: synthesized core-coder transport channels/DirAC output  */
#endif
    const int16_t output_frame,                                 /* i  : output frame length per channel                         */
    const int16_t nchan_in,                                     /* i  : number of input ambisonics channels                     */
    const AUDIO_CONFIG output_config,                           /* i  : output audio configuration                              */
@@ -3324,7 +3335,11 @@ ivas_error ivas_sba_get_hoa_dec_matrix(
);

void ivas_sba_mtx_mult( 
#ifdef JBM_TSM_ON_TCS
    float *output_f[],                                          /* i/o: synthesized core-corder transport channels/DirAC output */
#else
    float output_f[][L_FRAME48k],                               /* i/o: synthesized core-corder transport channels/DirAC output */
#endif
    const int16_t output_frame,                                 /* i  : frame length per channel                                */
    const int16_t nchan_in,                                     /* i  : Number of ambisonic channels                            */
    const IVAS_OUTPUT_SETUP output_setup,                       /* i  : Output configuration                                    */
@@ -4920,8 +4935,21 @@ void ivas_binRenderer_close(
#ifdef DEBUGGING
void ivas_binaural_cldfb(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                  */
#ifdef JBM_TSM_ON_TCS
    float *output_f[]                                           /* i/o: synthesized core-coder transport channels/DirAC output  */
#else
    float output_f[][L_FRAME48k]                                /* i/o: synthesized core-coder transport channels/DirAC output  */
#endif
);

#ifdef JBM_TSM_ON_TCS
void ivas_binaural_cldfb_sf(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                                  */
    const int16_t n_samples_to_render,
    float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output  */
);
#endif

#endif
void ivas_binRenderer(
    BINAURAL_RENDERER_HANDLE hBinRenderer,                      /* i/o: fastconv binaural renderer handle                       */
@@ -4939,7 +4967,8 @@ void ivas_binaural_add_LFE(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                  */
    int16_t output_frame,                                       /* i  : length of input frame                                   */
#ifdef JBM_TSM_ON_TCS
    float *output_f[]            /* i/o: synthesized core-coder transport channels/DirAC output */
    float *input_f[],                                           /* i : transport channels                                       */
    float *output_f[]                                           /* o : synthesized core-coder transport channels/DirAC output   */
#else
    float output_f[][L_FRAME48k]                                /* i/o: synthesized core-coder transport channels/DirAC output  */
#endif
@@ -5004,7 +5033,11 @@ ivas_error ivas_headTrack_open(

void rotateFrame_shd(
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,                      /* i  : head track handle                                       */
#ifdef JBM_TSM_ON_TCS
    float *output[],                                            /* i/o: unrotated HOA3 signal buffer in TD */
#else
    float output[][L_FRAME48k],                                 /* i/o: unrotated HOA3 signal buffer in TD */
#endif
    const int16_t subframe_len,                                 /* i  : subframe length per channel                             */
    const IVAS_OUTPUT_SETUP hTransSetup,                        /* i  : format for rotation                                     */
    const int16_t subframe_idx                                  /* i  : subframe index                                          */
@@ -5012,7 +5045,11 @@ void rotateFrame_shd(

void rotateFrame_sd(
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,                      /* i  : head track handle                                       */
#ifdef JBM_TSM_ON_TCS
    float *output[],                       /* i/o: unrotated SD signal buffer in TD */
#else
    float output[][L_FRAME48k],            /* i/o: unrotated SD signal buffer in TD */
#endif 
    const int16_t subframe_len,                                 /* i  : subframe length per channel                             */
    const IVAS_OUTPUT_SETUP hTransSetup,                        /* i  : format for rotation                                     */
    const EFAP_HANDLE hEFAPdata,                                /* i  : EFAP structure                                          */
@@ -5053,10 +5090,22 @@ ivas_error ivas_ism_renderer_open(

void ivas_ism_render(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                          */
#ifdef JBM_TSM_ON_TCS
    float *output_f[],                               /* i/o: core-coder transport channels/object output     */
#else
    float output_f[][L_FRAME48k],                               /* i/o: core-coder transport channels/object output     */
#endif
    const int16_t output_frame                                  /* i  : output frame length per channel                 */
);

#ifdef JBM_TSM_ON_TCS
void ivas_ism_render_sf(
    Decoder_Struct *st_ivas,          /* i/o: IVAS decoder structure                      */
    float *output_f[],                /* i/o: core-coder transport channels/object output */
    const int16_t n_samples_to_render /* i  : output frame length per channel             */
);
#endif

void ivas_ism_get_stereo_gains(
    const float azimuth,                                        /* i  : object azimuth                                  */
    const float elevation,                                      /* i  : object elevation                                */
@@ -5090,7 +5139,11 @@ void ivas_sba2mc_cldfb(
);

void ivas_ism2sba(
#ifdef JBM_TSM_ON_TCS
    float *buffer_td[],                                         /* i/o: TD signal buffers               */
#else
    float buffer_td[][L_FRAME48k],                              /* i/o: TD signal buffers               */
#endif
    ISM_RENDERER_HANDLE hIsmRendererData,                       /* i/o: renderer data                                   */
    const ISM_METADATA_HANDLE hIsmMetaData[],                   /* i  : object metadata                                 */
    const int16_t num_objects,                                  /* i  : number of objects                               */
@@ -5098,7 +5151,17 @@ void ivas_ism2sba(
    const int16_t sba_order                                     /* i  : SBA order                                       */
);


#ifdef JBM_TSM_ON_TCS
void ivas_ism2sba_sf(
    float *buffer_in[],                       /* i  : TC buffer                       */
    float *buffer_out[],                      /* o  : TD signal buffers               */
    ISM_RENDERER_HANDLE hIsmRendererData,     /* i/o: renderer data                   */
    const int16_t num_objects,                /* i  : number of objects               */
    const int16_t n_samples_to_render,        /* i  : output frame length per channel */
    const int16_t offset,                     /* i  : offset for the interpolatr      */
    const int16_t sba_order                   /* i  : Ambisonic (SBA) order           */
);
#endif
/*----------------------------------------------------------------------------------*
 * Amplitude Panning (EFAP, VBAP) prototypes
 *----------------------------------------------------------------------------------*/
@@ -5435,10 +5498,22 @@ void ivas_td_binaural_close(

void ObjRenderIVASFrame(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
#ifdef JBM_TSM_ON_TCS
    float *output[],                                            /* i/o: SCE channels / Binaural synthesis */
#else
    float output[][L_FRAME48k],                                 /* i/o: SCE channels / Binaural synthesis */
#endif
    const int16_t output_frame                                  /* i  : output frame length                     */
);

#ifdef JBM_TSM_ON_TCS
void ObjRenderIVASSubframe(
    Decoder_Struct *st_ivas,   /* i/o: IVAS decoder structure            */
    float *output[],           /* i/o: SCE channels / Binaural synthesis */
    const int16_t output_frame /* i  : output frame length               */
);
#endif

void BSplineModelEvalAlloc(
    ModelParams_t *model,                                       /* i  : Model parameters                        */
    ModelEval_t *modelEval                                      /* i/o: Model evaluation structure              */
@@ -5796,7 +5871,29 @@ ivas_error ivas_rend_crendProcess(
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,   
    IVAS_OUTPUT_SETUP_HANDLE hIntSetup, 
    EFAP_HANDLE hEFAPdata,     
#ifdef JBM_TSM_ON_TCS
    float *output[], /* i/o: input/output audio channels     */
#else
    float output[][L_FRAME48k], /* i/o: input/output audio channels     */
#endif
    const int32_t output_Fs );
#endif

#ifdef JBM_TSM_ON_TCS
ivas_error ivas_rend_crendProcessSubframe(
    const CREND_WRAPPER *pCrend,
    const IVAS_REND_AudioConfig inConfig,
    const IVAS_REND_AudioConfig outConfig,
#ifdef FIX_197_CREND_INTERFACE
    DECODER_CONFIG_HANDLE hDecoderConfig,
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,
    IVAS_OUTPUT_SETUP_HANDLE hIntSetup,
    EFAP_HANDLE hEFAPdata,
#endif
    DECODER_TC_BUFFER_HANDLE hTcBuffer,
    float *input_f[],
    float *output[], /* i/o: input/output audio channels     */
    const int16_t n_samples_to_render,
    const int32_t output_Fs );
#endif

@@ -5838,8 +5935,13 @@ ivas_error ivas_reverb_process(
    REVERB_HANDLE hReverb,                                      /* i/o: reverb state                            */
    const AUDIO_CONFIG input_audio_config,                      /* i  : reverb. input audio configuration       */
    const int16_t mix_signals,                                  /* i  : add reverb to output signal             */
#ifdef JBM_TSM_ON_TCS
    float *pcm_in[],                                 /* i  : the PCM audio to apply reverb on        */
    float *pcm_out[],                                /* o  : the PCM audio with reverb applied       */
#else
    float pcm_in[][L_FRAME48k],                                 /* i  : the PCM audio to apply reverb on        */
    float pcm_out[][L_FRAME48k],                                /* o  : the PCM audio with reverb applied       */
#endif
    const int16_t i_ts
);

+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@
#define JBM_MASA
#define JBM_MCT
#define JBM_MCMASA
/*#define JBM_ISM*/
#define JBM_ISM
#define JBM_PARAM_ISM
/*#define JBM_DIRAC_DEBUG_BE*/
#define JBM_DEV  /*remove after all formats work...*/
+34 −4
Original line number Diff line number Diff line
@@ -210,18 +210,31 @@ ivas_error ivas_dec(
            else if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
            {
                /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
#ifdef JBM_TSM_ON_TCS
                ivas_ism_render( st_ivas, p_output, output_frame );
#else
                ivas_ism_render( st_ivas, output, output_frame );
#endif
            }
            /* TODO: BUG? RENDERER_BINAURAL_FASTCONV_ROOM seems to be missing */
            else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
            {
                /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */
#ifdef JBM_TSM_ON_TCS
                ivas_ism2sba( p_output, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_transport, output_frame, st_ivas->hIntSetup.ambisonics_order );
#else
                ivas_ism2sba( output, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_transport, output_frame, st_ivas->hIntSetup.ambisonics_order );
#endif
            }

            /* Binaural rendering */
            if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
            {
#ifdef JBM_TSM_ON_TCS
                ObjRenderIVASFrame( st_ivas, p_output, output_frame );
#else
                ObjRenderIVASFrame( st_ivas, output, output_frame );
#endif
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
            {
@@ -233,7 +246,11 @@ ivas_error ivas_dec(
                                                       NULL,
                                                       NULL,
                                                       NULL,
#ifdef JBM_TSM_ON_TCS
                                                       p_output,
#else
                                                       output,
#endif
                                                       output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
@@ -242,7 +259,7 @@ ivas_error ivas_dec(
                ivas_crend_process( st_ivas, output );
#endif
#ifdef JBM_TSM_ON_TCS
                ivas_binaural_add_LFE( st_ivas, output_frame, p_output );
                ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output );
#else
                ivas_binaural_add_LFE( st_ivas, output_frame, output );
#endif
@@ -250,7 +267,11 @@ ivas_error ivas_dec(
#ifdef DEBUGGING
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
            {
#ifdef JBM_TSM_ON_TCS
                ivas_binaural_cldfb( st_ivas, p_output );
#else
                ivas_binaural_cldfb( st_ivas, output );
#endif
            }
#endif
        }
@@ -383,7 +404,11 @@ ivas_error ivas_dec(
        {
            if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
            {
#ifdef JBM_TSM_ON_TCS
                ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
#else
                ivas_sba_linear_renderer( output, output_frame, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
#endif
            }
            else if ( st_ivas->renderer_type == RENDERER_DIRAC )
            {
@@ -451,7 +476,11 @@ ivas_error ivas_dec(
                                                       st_ivas->hHeadTrackData,
                                                       &st_ivas->hIntSetup,
                                                       st_ivas->hEFAPdata,
#ifdef JBM_TSM_ON_TCS
                                                       p_output,
#else
                                                       output,
#endif
                                                       output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
@@ -461,7 +490,7 @@ ivas_error ivas_dec(
#endif

#ifdef JBM_TSM_ON_TCS
                ivas_binaural_add_LFE( st_ivas, output_frame, p_output );
                ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output );
#else
                ivas_binaural_add_LFE( st_ivas, output_frame, output );
#endif
@@ -484,10 +513,11 @@ ivas_error ivas_dec(
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
            {
                ObjRenderIVASFrame( st_ivas, output, output_frame );
#ifdef JBM_TSM_ON_TCS
                ivas_binaural_add_LFE( st_ivas, output_frame, p_output );
                ObjRenderIVASFrame( st_ivas, p_output, output_frame );
                ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output );
#else
                ObjRenderIVASFrame( st_ivas, output, output_frame );
                ivas_binaural_add_LFE( st_ivas, output_frame, output );
#endif
            }
+4 −3
Original line number Diff line number Diff line
@@ -2026,16 +2026,17 @@ void ivas_dirac_dec_render(
)
{
    uint16_t slots_to_render, first_sf, last_sf, subframe_idx;
    uint16_t slot_size, n_samples_sf, ch;
    uint16_t slot_size, n_samples_sf, ch, nchan_intern;
    DIRAC_DEC_HANDLE hDirAC;
    float *output_f_local[MAX_OUTPUT_CHANNELS];

    hDirAC = st_ivas->hDirAC;

    nchan_intern = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
#ifdef DEBUGGING
    assert( hDirAC );
#endif
    for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
    for ( ch = 0; ch < nchan_intern; ch++ )
    {
        output_f_local[ch] = output_f[ch];
    }
@@ -2057,7 +2058,7 @@ void ivas_dirac_dec_render(
    {
        ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL );
        n_samples_sf = hDirAC->subframe_nbslots[subframe_idx] * st_ivas->hDirAC->slot_size;
        for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
        for ( ch = 0; ch < nchan_intern; ch++ )
        {
            output_f_local[ch] += n_samples_sf;
        }
Loading