Commit 325ccfda authored by vaclav's avatar vaclav
Browse files

Merge branch '45-framework-maintenance-1' into 'main'

Framework maintenance 1

See merge request !26
parents 034e82af 333851c9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@
    <ClCompile Include="..\lib_util\hrtf_file_reader.c" />
    <ClCompile Include="..\lib_util\ism_file_reader.c" />
    <ClCompile Include="..\lib_util\ism_file_writer.c" />
    <ClCompile Include="..\lib_util\jbm_file_reader.c" />
    <ClCompile Include="..\lib_util\jbm_file_writer.c" />
    <ClCompile Include="..\lib_util\ls_custom_file_reader.c" />
    <ClCompile Include="..\lib_util\masa_file_reader.c" />
@@ -168,6 +169,7 @@
    <ClInclude Include="..\lib_util\hrtf_file_reader.h" />
    <ClInclude Include="..\lib_util\ism_file_reader.h" />
    <ClInclude Include="..\lib_util\ism_file_writer.h" />
    <ClInclude Include="..\lib_util\jbm_file_reader.h" />
    <ClInclude Include="..\lib_util\jbm_file_writer.h" />
    <ClInclude Include="..\lib_util\ls_custom_file_reader.h" />
    <ClInclude Include="..\lib_util\mime_io.h" />
+31 −97
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "cmdl_tools.h"
#include "audio_file_reader.h"
#include "bitstream_writer.h"
#include "jbm_file_reader.h"
#include "masa_file_reader.h"
#include "ism_file_reader.h"
#include <stdio.h>
@@ -142,7 +143,6 @@ typedef struct
static void initArgStruct( EncArguments *arg );
static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg );
static void usage_enc( void );
static ivas_error readChannelAwareConfig( FILE *file, IVAS_ENC_CHANNEL_AWARE_CONFIG *caConfig );
static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter );
static bool readBitrate( FILE *file, int32_t *bitrate );
#ifdef DEBUGGING
@@ -206,7 +206,7 @@ int main(
    AudioFileReader *audioReader = NULL;
    FILE *f_bitrateProfile = NULL;
    FILE *f_bwProfile = NULL;
    FILE *f_caProfile = NULL;
    JbmFileReader *jbmReader = NULL;
    MasaFileReader *masaReader = NULL;
    IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS];
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
@@ -396,20 +396,18 @@ int main(

    if ( arg.ca_config_file )
    {
        if ( ( f_caProfile = fopen( arg.ca_config_file, "rb" ) ) == NULL )
        if ( ( jbmReader = JbmFileReader_open( arg.ca_config_file ) ) == NULL )
        {
            fprintf( stderr, "\nError: Channel aware configuration file could not be opened: %s\n\n", arg.ca_config_file );
            usage_enc();
            goto cleanup;
        }
        else
        {
            fprintf( stdout, "\nChannel-aware mode:     ON, Channel-aware config file name:  %s  \n\n", arg.ca_config_file );
        }

        fprintf( stdout, "Channel-aware mode:     ON, config file:  %s  \n", arg.ca_config_file );
    }
    else if ( arg.caConfig.channelAwareModeEnabled )
    else if ( caConfig.channelAwareModeEnabled )
    {
        fprintf( stdout, "\nChannel-aware mode:     ON, FEC indicator : %s  FEC offset: %d \n\n", ( caConfig.fec_indicator == IVAS_ENC_FEC_LO ) ? "LO" : "HI", caConfig.fec_offset );
        fprintf( stdout, "Channel-aware mode:     ON, FEC indicator : %s  FEC offset: %d \n\n", ( caConfig.fec_indicator == IVAS_ENC_FEC_LO ) ? "LO" : "HI", caConfig.fec_offset );
    }

    /*------------------------------------------------------------------------------------------*
@@ -470,7 +468,7 @@ int main(
            goto cleanup;
    }

    IVAS_ENC_PrintConfig( hIvasEnc );
    IVAS_ENC_PrintConfig( hIvasEnc, caConfig.channelAwareModeEnabled );

    /*------------------------------------------------------------------------------------------*
     * Open input metadata files
@@ -517,23 +515,9 @@ int main(
#endif

    /*------------------------------------------------------------------------------------------*
     * Compensate for encoder delay (bitstream aligned with input signal)
     * Allocate input data buffer 
     *------------------------------------------------------------------------------------------*/

    int16_t encDelayInSamples;
    if ( ( error = IVAS_ENC_GetDelay( hIvasEnc, &encDelayInSamples ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nGetDelay failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
        goto cleanup;
    }

    int16_t numInputChannels;
    if ( ( error = IVAS_ENC_GetNumInputChannels( hIvasEnc, &numInputChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nGetNumInputChannels failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
        goto cleanup;
    }

    int16_t pcmBufSize;
    if ( ( error = IVAS_ENC_GetInputBufferSize( hIvasEnc, &pcmBufSize ) ) != IVAS_ERR_OK )
    {
@@ -543,6 +527,17 @@ int main(

    pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) );

    /*------------------------------------------------------------------------------------------*
     * Compensate for encoder delay (bitstream aligned with input signal)
     *------------------------------------------------------------------------------------------*/

    int16_t encDelayInSamples;
    if ( ( error = IVAS_ENC_GetDelay( hIvasEnc, &encDelayInSamples ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nGetDelay failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
        goto cleanup;
    }

    if ( arg.delayCompensationEnabled && encDelayInSamples )
    {
        /* read samples and throw them away */
@@ -637,17 +632,17 @@ int main(
            }
        }

        if ( f_caProfile )
        if ( jbmReader )
        {
            if ( ( error = readChannelAwareConfig( f_caProfile, &caConfig ) ) != IVAS_ERR_OK )
            if ( ( error = JbmFileReader_readCAconfig( jbmReader, &caConfig ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "readChannelAwareConfig failed: %s\n", IVAS_ENC_GetErrorMessage( error ) );
                fprintf( stderr, "JbmFileReader_readCAconfig() failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
            }

            if ( ( error = IVAS_ENC_SetChannelAwareConfig( hIvasEnc, caConfig ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "IVAS_ENC_SetChannelAwareConfig failed: %s\n", IVAS_ENC_GetErrorMessage( error ) );
                fprintf( stderr, "IVAS_ENC_SetChannelAwareConfig failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }
@@ -768,6 +763,11 @@ cleanup:

    AudioFileReader_close( &audioReader );

    if ( jbmReader )
    {
        JbmFileReader_close( &jbmReader );
    }

    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
        if ( ismReaders[i] != NULL )
@@ -791,11 +791,6 @@ cleanup:
        fclose( f_bitrateProfile );
    }

    if ( f_caProfile )
    {
        fclose( f_caProfile );
    }

#ifdef DEBUGGING
    if ( f_forcedModeProfile )
    {
@@ -1049,7 +1044,7 @@ static bool parseCmdlIVAS_enc(

        else if ( strcmp( argv_to_upper, "-RF" ) == 0 )
        {
            arg->caConfig.channelAwareModeEnabled = true;
            arg->caConfig.channelAwareModeEnabled = 1;
            i++;

            if ( i < argc - 4 )
@@ -1069,12 +1064,11 @@ static bool parseCmdlIVAS_enc(
                }
                i++;


                if ( ( sscanf( argv[i], "%d", &tmp ) == 1 ) && ( i < argc - 4 ) )
                {
                    if ( tmp == 0 )
                    {
                        arg->caConfig.channelAwareModeEnabled = false;
                        arg->caConfig.channelAwareModeEnabled = 0;
                        arg->caConfig.fec_offset = 0;
                        i++;
                    }
@@ -1646,66 +1640,6 @@ static void usage_enc( void )
}


/*---------------------------------------------------------------------*
 * readChannelAwareConfig()
 *
 *
 *---------------------------------------------------------------------*/

static ivas_error readChannelAwareConfig(
    FILE *file,
    IVAS_ENC_CHANNEL_AWARE_CONFIG *caConfig )
{
    char rline[10], str[4];
    int16_t tmp;

    /* Initialize */
    caConfig->fec_offset = 0;
    caConfig->fec_indicator = IVAS_ENC_FEC_HI;

    while ( fgets( rline, 10, file ) == NULL && feof( file ) )
    {
        rewind( file );
    }

    if ( sscanf( rline, "%s %hd", str, &tmp ) != 2 )
    {
        fprintf( stderr, "Error in the RF configuration file. There is no proper configuration line.\n" );
        return IVAS_ERR_INVALID_FEC_CONFIG;
    }

    /* Read RF FEC indicator */
    to_upper( str );

    if ( strcmp( str, "HI" ) == 0 )
    {
        caConfig->fec_indicator = IVAS_ENC_FEC_HI;
    }
    else if ( strcmp( str, "LO" ) == 0 )
    {
        caConfig->fec_indicator = IVAS_ENC_FEC_LO;
    }
    else
    {
        fprintf( stderr, "Error: Incorrect FEC indicator string. Exiting the encoder.\n" );
        return IVAS_ERR_INVALID_FEC_CONFIG;
    }

    /* Read RF FEC offset */
    if ( tmp == 0 || tmp == 2 || tmp == 3 || tmp == 5 || tmp == 7 )
    {
        caConfig->fec_offset = tmp;
    }
    else
    {
        fprintf( stderr, "Error: incorrect FEC offset specified in the RF configuration file; RF offset can be 2, 3, 5, or 7. \n" );
        return IVAS_ERR_INVALID_FEC_CONFIG;
    }

    return IVAS_ERR_OK;
}


/*---------------------------------------------------------------------*
 * readBandwidth()
 *
+3 −4
Original line number Diff line number Diff line
@@ -133,9 +133,6 @@ enum{

#define MAX_V_MULT_MAT                  100             /* maximum array length for the function v_mult_mat() */

#define G192_BIN0                       (uint16_t) 0x007F
#define G192_BIN1                       (uint16_t) 0x0081


/*----------------------------------------------------------------------------------*
 * Layers
@@ -1269,6 +1266,8 @@ enum
#define MAX_LEN_MA_FILTER                   20                      /* maximum length of the MA filter for SHB TD envelope calculation */
#define TABLE_CUMSUM_MAX_N                  320                     /* maximum length of cumsum(i) and cumsum(i*i) tables */

#define NUM_BITS_FB_FRAMEGAIN_TBE           4                       /* Number of bits for framegain for FB TBE */

/*----------------------------------------------------------------------------------*
 * SWB BWE constants
 *----------------------------------------------------------------------------------*/
@@ -1282,7 +1281,7 @@ enum
#define FB_MAX_GAIN_VAR                     0.5f


#define NUM_BITS_FB_FRAMEGAIN               4                       /* Number of bits for framegain for FB */
#define NUM_BITS_FB_FRAMEGAIN               4                       /* Number of bits for framegain for FB BWE */
#define FB_BAND_BEGIN                       620                     /* == 15.5 kHz */
#define FB_BAND_BEGIN_12k8                  560                     /* == 14 kHz */
#define FB_BAND_END                         800                     /* == 20 kHz */
+16 −0
Original line number Diff line number Diff line
@@ -47,10 +47,26 @@
#define IVAS_MAX_NUM_OBJECTS       4
#define IVAS_MAX_OUTPUT_CHANNELS   16
#define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 )

/*----------------------------------------------------------------------------------*
 * Common API structures
 *----------------------------------------------------------------------------------*/

typedef enum _IVAS_ENC_FEC_INDICATOR
{
    IVAS_ENC_FEC_LO,
    IVAS_ENC_FEC_HI,
    IVAS_ENC_FEC_UNDEFINED = 0xffff
} IVAS_ENC_FEC_INDICATOR;

typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG
{
    int16_t channelAwareModeEnabled;
    IVAS_ENC_FEC_INDICATOR fec_indicator;
    int16_t fec_offset;
} IVAS_ENC_CHANNEL_AWARE_CONFIG;


typedef struct _IVAS_ISM_METADATA
{
    float azimuth;
+2 −2
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ void bands_and_bit_alloc(

            /* 2- Decide the pourcentage of bits allocated to LF (between 50-75%) depending of the temporal contribution in GSC */
            bit_fracf = ( -0.125f * Diff_len + 76.0f ) / 100;
            check_bounds( &bit_fracf, 0.50f, 0.75f );
            bit_fracf = check_bounds( bit_fracf, 0.50f, 0.75f );

            /* Adjusment of the bitrate between LF and HF base on the content type */
            /* 1 = new GSC bit alloc
@@ -236,7 +236,7 @@ void bands_and_bit_alloc(
                nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;
            }
            nb_bands_max = (int16_t) ( nb_bands_max * nb_bands_adj + 0.5f );
            check_bounds_s( &nb_bands_max, 5, nb_tot_bands );
            nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands );

            bit_fracf *= SWB_bit_budget;

Loading