Commit 4793a158 authored by bayers's avatar bayers
Browse files

fixed decoder app for variable speed decoding, added br switch profiles for ISM, cleanup

parent 6568718f
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -2394,7 +2394,7 @@ static ivas_error decodeVariableSpeed(
    int16_t numInitialBadFrames = 0; /* Number of bad frames received until first good frame is decoded */
    int16_t nOutChannels = 0;
    int16_t delayNumSamples = -1;
    int16_t delayNumSamples_orig = 0;
    int16_t delayNumSamples_orig[3];
    int16_t nOutSamples = 0;
    int32_t delayTimeScale = 0;
    ivas_error error = IVAS_ERR_UNKNOWN;
@@ -2437,6 +2437,8 @@ static ivas_error decodeVariableSpeed(
        fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" );
    }

    delayNumSamples_orig[0] = -1;

#ifdef WMOPS
    reset_stack();
    reset_wmops();
@@ -2595,7 +2597,7 @@ static ivas_error decodeVariableSpeed(
                    arg,
                    numInitialBadFrames,
                    nOutSamples,
                    &delayNumSamples_orig,
                    delayNumSamples_orig,
                    &delayNumSamples,
                    &delayTimeScale,
                    &bsFormat,
@@ -2844,7 +2846,13 @@ static ivas_error decodeVariableSpeed(

    if ( !arg.quietModeEnabled )
    {
        fprintf( stdout, "\nDecoder delay:          %-5u [samples]  - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale );
        printf( "\n\nDecoder+renderer delay: %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[1] / (float) delayTimeScale, delayNumSamples_orig[1], delayTimeScale );

        if ( delayNumSamples_orig[2] > 0 )
        {
            printf( "HRIR/BRIR delay:        %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[2] / (float) delayTimeScale, delayNumSamples_orig[2], delayTimeScale );
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * ( delayNumSamples_orig[1] + delayNumSamples_orig[2] ) / (float) delayTimeScale, delayNumSamples_orig[1] + delayNumSamples_orig[2], delayTimeScale );
        }
    }

    /* Print output metadata file name(s) */
@@ -2865,8 +2873,8 @@ static ivas_error decodeVariableSpeed(
    }

    /* add zeros at the end to have equal length of synthesized signals */
    memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK )
    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
@@ -2882,6 +2890,7 @@ cleanup:

    AudioFileWriter_close( &afWriter );
    MasaFileWriter_close( &masaWriter );
    TsmScaleFileReader_close( &tsmScaleFileReader );        
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
    {
        IsmFileWriter_close( &ismWriters[i] );
+1 −4
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@
/*#define DEBUG_MODE_INFO_PLC */                /* define to output PLC related parameters */
/*#define DEBUG_MODE_INFO_ALLRAD*/              /* define to output generated HOA decoding mtx */
/*#define DEBUG_MODE_LFE */                     /* define to output LFE relevant parameters */
/*#define DEBUG_MODE_JBM */                     /* define to output import JBM parameters  */
#endif

#ifdef DEBUG_MODE_MDCT
@@ -113,7 +112,7 @@
/*#define TDREND_HRTF_TABLE_METHODS*/           /* Enable HRTF lookup from tables, for testing & evaluation. Supply file in table format to use. Note that a suitable HR filter lookup method should be written if the filters sample point grids are not in the formats. */
/*#define TDREND_STANDALONE*/                   /* Used when renderer is built in standalone form, without IVAS encoding/decoding (see scripts/object_renderer_standalone). This is just here to ensure this is cleaned out by prepare_instrumentation.sh */

/*#define DEBUG_SBA*/                           /* debug DIRAC/SPAR in-out */
#define DEBUG_SBA                               /* debug DIRAC/SPAR in-out */
#ifdef DEBUG_SBA
/*#define DEBUG_SBA_AUDIO_DUMP */               /* SBA intermediate audio wav file dumping */
/*#define DEBUG_SBA_MD_DUMP*/                   /* SBA metadata and variable file dumping */
@@ -126,7 +125,6 @@
/*#define SPAR_HOA_DBG*/                        /* SPAR HOA debug statements */
/*#define DEBUG_BINAURAL_FILTER_DESIGN*/        /* debugging of Crend binaural filter design */
#define DEBUG_AGC_ENCODER_CMD_OPTION            /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */
/*#define DEBUG_JBM*/
#define DEBUG_JBM_CMD_OPTION                    /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */

#endif
@@ -154,7 +152,6 @@
#define VARIABLE_SPEED_DECODING                         /* FhG: variable speed decoding employing the JBM functioniality */
#define JBM_TSM_ON_TCS                                  /* FhG: run the TSM part of JBM on the TCs instead of the final output pcm waveforms */
#ifdef JBM_TSM_ON_TCS
#define TEST_BIN_RENDERER_BE
#define TMP_FIX_ISM_BR_SWITCHING                        /* */
#define JBM_DIRAC_DEBUG_BE
#endif
+1 −103
Original line number Diff line number Diff line
@@ -54,9 +54,6 @@
#else
#endif
#include "wmc_auto.h"
#ifdef DEBUG_JBM
#include "tinywaveout_c.h"
#endif


/*-------------------------------------------------------------------*
@@ -96,12 +93,6 @@ static FILE *out_fileptr[N_FILEPTR];
static char *in_filename[N_FILEPTR];
static char *out_filename[N_FILEPTR];

#ifdef DEBUG_MODE_JBM
static char *wav_out_filename[N_FILEPTR];
static WAVEFILEOUT *wav_out_fileptr[N_FILEPTR];
static int16_t wav_count;
#endif

static int16_t in_count = 0;
static int16_t out_count = 0;

@@ -210,92 +201,6 @@ int16_t dbgwrite(
    return 0;
}

#ifdef DEBUG_MODE_JBM
/*-------------------------------------------------------------------*
 * dbgwritewav()
 *
 * Writes the buffer content to the specified file. If the file is not in the
 * debug file list, it is opened before write.
 *--------------------------------------------------------------------*/

int16_t dbgwritewav(
    const int16_t input_frame,
    float **ppPcm,
    float pcm_array[MAX_OUTPUT_CHANNELS][L_FRAME48k],
    const int16_t no_channel,
    const int32_t fs,
#ifdef DEBUG_MODE_INFO_TWEAK
    const char *filename /* i  : Output file name */
#else
    const char *const filename
#endif
)
{
    int16_t index, i;

#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
    char filename_mod[FILENAME_MAX];
    int16_t textmode = 0;
    memset( filename_mod, 0, FILENAME_MAX );
    tweakdbgfolder( filename, filename_mod, &textmode );
    if ( filename_mod[0] != 0 )
    {
        filename = filename_mod;
    }
#endif
#endif

    index = lookup( filename, (const char *const *) wav_out_filename, wav_count );

    if ( index == -1 )
    {
        if ( make_dirs( filename ) != 0 )
        {
            fprintf( stderr, "dbgwrite: Could not create directory structure for %s. Exiting..\n", filename );
            exit( -1 );
        }

        index = wav_count;
        wav_out_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
        strcpy( wav_out_filename[index], filename );
        wav_out_fileptr[index] = CreateWav( (const char *) wav_out_filename[index], fs, no_channel, 32 /* const uint32_t writeWaveExt */ );

        wav_count++;
    }

    if ( wav_out_fileptr[index] != NULL )
    {
        float debug_tmp[IVAS_SPAR_MAX_CH * L_FRAME48k * 2];
        int32_t j, k;
        k = 0;
        for ( j = 0; j < input_frame; j++ )
        {
            for ( i = 0; i < no_channel; i++, k++ )
            {
                float tmp_value;
                if ( ppPcm )
                {
                    tmp_value = ppPcm[i][j];
                }
                else
                {
                    tmp_value = pcm_array[i][j];
                }
                debug_tmp[k] = tmp_value;
            }
        }
        WriteWavFloat( wav_out_fileptr[index], debug_tmp, ( no_channel * input_frame ) );
    }
    else
    {
        fprintf( stderr, "dbgwrite: Could not write to file: %s. Exiting..\n", filename );
        exit( -1 );
    }

    return 0;
}
#endif

/*-------------------------------------------------------------------*
 * dbgwrite_mat_repeat()
@@ -502,14 +407,7 @@ void dbgclose()
        free( val_name[i] );
        free( val[i] );
    }
#ifdef DEBUG_MODE_JBM
    for ( i = 0; i < wav_count; i++ )
    {
        CloseWav( wav_out_fileptr[i] );
        wav_out_fileptr[i] = NULL;
        free( wav_out_filename[i] );
    }
#endif

    return;
}

+0 −15
Original line number Diff line number Diff line
@@ -98,21 +98,6 @@ int16_t dbgwrite(
#endif
);

#ifdef DEBUG_MODE_JBM
int16_t dbgwritewav(
    const int16_t input_frame,
    float **ppPcm,
    float pcm_array[MAX_OUTPUT_CHANNELS][L_FRAME48k],
    const int16_t no_channel,
    const int32_t fs,
#ifdef DEBUG_MODE_INFO_TWEAK
    const char *filename /* i  : Output file name */
#else
    const char *const filename
#endif
);
#endif

void dbgwrite_mat_repeat(
    float *buffer,      /* i  : write buffer */
    int16_t nRow,       /* i  : matrix size (rows) */
+1 −3
Original line number Diff line number Diff line
@@ -369,9 +369,7 @@ ivas_error ivas_dec(
        /* Dump audio signal after core-decoding */
        ivas_spar_dump_signal_wav( output_frame, NULL, output, st_ivas->nchan_transport, spar_foa_dec_wav[0], "core-decoding" );
#endif
#ifdef DEBUG_MODE_JBM
        dbgwritewav( output_frame, NULL, output, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, "res/sba_tc.wav" );
#endif

        /* TCs remapping */
        nchan_remapped = st_ivas->nchan_transport;
        if ( st_ivas->sba_dirac_stereo_flag )
Loading