Commit e51b4fce authored by vaclav's avatar vaclav
Browse files

Merge branch '1955-basop-PortMr2077-from-float-revision-of-common-api-types' into 'main'

Port MR2077 from float to BASOP - Revision of common api types

Closes #1955

See merge request !2413
parents b0ef1efb 1cdc6b59
Loading
Loading
Loading
Loading
Loading
+25 −30
Original line number Diff line number Diff line
@@ -67,19 +67,10 @@ static
#endif
    int32_t frame = 0; /* Counter of frames */

#ifdef DEBUGGING
#define MIN_NUM_BITS_ACTIVE_FRAME 56
#define NUM_BITS_SID_IVAS_5K2     104
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) * IVAS_MAX_FRAME_SIZE )

#define ORIENT_TRK_NONE        ( 0 )
#define ORIENT_TRK_REF         ( 1 )
#define ORIENT_TRK_AVG         ( 2 )
#define ORIENT_TRK_REF_VEC     ( 3 )
#define ORIENT_TRK_REF_VEC_LEV ( 4 )

#define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20
#define HEADROTATION_FETCH_FRAMESIZE_MS 5
#define DEFAULT_FETCH_FRAMESIZE_MS      20
#endif


/*------------------------------------------------------------------------------------------*
@@ -125,7 +116,7 @@ typedef struct
    IVAS_DEC_INPUT_FORMAT inputFormat;
    bool customLsOutputEnabled;
    char *customLsSetupFilename;
    int16_t orientation_tracking;
    IVAS_HEAD_ORIENT_TRK_T orientation_tracking;
    bool non_diegetic_pan_enabled;
    float non_diegetic_pan_gain;
    Word16 non_diegetic_pan_gain_fx; /* Q15 */
@@ -174,10 +165,10 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs );
#ifdef OBJ_EDITING_EXAMPLE
@@ -348,7 +339,7 @@ int main(
        }

        /* sanity check */
        if ( arg.orientation_tracking != ORIENT_TRK_REF )
        if ( arg.orientation_tracking != IVAS_HEAD_ORIENT_TRK_REF )
        {
            fprintf( stderr, "\nError: Reference rotation file can be used in '-otr ref' mode only.\n\n" );
            goto cleanup;
@@ -375,7 +366,7 @@ int main(
        }

        /* sanity check */
        if ( arg.orientation_tracking != ORIENT_TRK_REF_VEC && arg.orientation_tracking != ORIENT_TRK_REF_VEC_LEV )
        if ( arg.orientation_tracking != IVAS_HEAD_ORIENT_TRK_REF_VEC && arg.orientation_tracking != IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV )
        {
            fprintf( stderr, "\nError: Reference trajectory file can be used in '-otr ref_vec' or '-otr ref_vec_lev' mode only.\n\n" );
            goto cleanup;
@@ -674,9 +665,9 @@ int main(
    if ( arg.voipMode )
    {
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec );
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf );
#else
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf );
#endif
    }
    else
@@ -870,7 +861,11 @@ static bool parseCmdlIVAS_dec(
    int16_t i;
    char argv_to_upper[FILENAME_MAX];

    arg->output_Fs = 48000;
    /*-----------------------------------------------------------------*
     * Set default values
     *-----------------------------------------------------------------*/

    arg->output_Fs = IVAS_MAX_SAMPLING_RATE;
    arg->outputConfig = IVAS_AUDIO_CONFIG_MONO;
    arg->decMode = IVAS_DEC_MODE_IVAS;
    arg->quietModeEnabled = false;
@@ -880,7 +875,7 @@ static bool parseCmdlIVAS_dec(

    arg->enableHeadRotation = false;
    arg->headrotTrajFileName = NULL;
    arg->orientation_tracking = ORIENT_TRK_NONE;
    arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE;
    arg->enableReferenceRotation = false;
    arg->headrotTrajFileName = NULL;
    arg->enableReferenceVectorTracking = false;
@@ -1097,23 +1092,23 @@ static bool parseCmdlIVAS_dec(

            if ( strcmp( argv_to_upper, "NONE" ) == 0 )
            {
                arg->orientation_tracking = ORIENT_TRK_NONE;
                arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE;
            }
            else if ( strcmp( argv_to_upper, "REF" ) == 0 )
            {
                arg->orientation_tracking = ORIENT_TRK_REF;
                arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_REF;
            }
            else if ( strcmp( argv_to_upper, "AVG" ) == 0 )
            {
                arg->orientation_tracking = ORIENT_TRK_AVG;
                arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_AVG;
            }
            else if ( strcmp( argv_to_upper, "REF_VEC" ) == 0 )
            {
                arg->orientation_tracking = ORIENT_TRK_REF_VEC;
                arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_REF_VEC;
            }
            else if ( strcmp( argv_to_upper, "REF_VEC_LEV" ) == 0 )
            {
                arg->orientation_tracking = ORIENT_TRK_REF_VEC_LEV;
                arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV;
            }
            else
            {
@@ -2765,14 +2760,15 @@ static ivas_error decodeVoIP(
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
    ObjectEditFileReader *objectEditFileReader,
#endif
    IVAS_DEC_HANDLE hIvasDec )
    IVAS_DEC_HANDLE hIvasDec,
    int16_t *pcmBuf )
{
    bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */
    ivas_error error = IVAS_ERR_OK;

    uint32_t nextPacketRcvTime_ms = 0;
    uint32_t systemTime_ms = 0;
    uint32_t systemTimeInc_ms = (uint32_t) JBM_FRONTEND_FETCH_FRAMESIZE_MS;
    uint32_t systemTimeInc_ms = (uint32_t) ( 1000 / IVAS_NUM_FRAMES_PER_SEC );
    int32_t nFramesFed = 0;

    uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3];
@@ -2786,7 +2782,6 @@ static ivas_error decodeVoIP(
    MasaFileWriter *masaWriter = NULL;
    uint16_t numObj = 0;

    int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE];
    AudioFileWriter *afWriter = NULL;
#ifdef SUPPORT_JBM_TRACEFILE
    JbmTraceFileWriter *jbmTraceWriter = NULL;
+21 −25
Original line number Diff line number Diff line
@@ -163,7 +163,6 @@ typedef struct
 * Local functions prototypes
 *------------------------------------------------------------------------------------------*/

static void initArgStruct( EncArguments *arg );
static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg );
static void usage_enc( void );
static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter );
@@ -208,8 +207,6 @@ int main(
    reset_mem( USE_BYTES );
#endif

    initArgStruct( &arg );

    /*------------------------------------------------------------------------------------------*
     * Parse command-line arguments
     *------------------------------------------------------------------------------------------*/
@@ -853,11 +850,26 @@ cleanup:
 * Local functions
 *-------------------------------------------------------------------*/

#define IVAS_DEFAULT_AGC ( 0 )
/*---------------------------------------------------------------------*
 * parseCmdlIVAS_enc()
 *
 * Encoder command-line parsing
 *---------------------------------------------------------------------*/

static void initArgStruct( EncArguments *arg )
static bool parseCmdlIVAS_enc(
    int16_t argc,
    char *argv[],
    EncArguments *arg )
{
    /* Set default values here */
    int16_t i, j;
    char argv_to_upper[FILENAME_MAX];
    char stmp[FILENAME_MAX];
    int32_t tmp;

    /*-----------------------------------------------------------------*
     * Set default values
     *-----------------------------------------------------------------*/

    arg->inputWavFilename = NULL;
    arg->outputBitstreamFilename = NULL;
    arg->inputFs = 0;
@@ -887,25 +899,9 @@ static void initArgStruct( EncArguments *arg )
#endif
    arg->pca = false;

    return;
}


/*---------------------------------------------------------------------*
 * parseCmdlIVAS_enc()
 *
 * Encoder command-line parsing
 *---------------------------------------------------------------------*/

static bool parseCmdlIVAS_enc(
    int16_t argc,
    char *argv[],
    EncArguments *arg )
{
    int16_t i, j;
    char argv_to_upper[FILENAME_MAX];
    char stmp[FILENAME_MAX];
    int32_t tmp;
    /*-----------------------------------------------------------------*
     * Initialization
     *-----------------------------------------------------------------*/

    if ( argc < 5 )
    {
+1 −1
Original line number Diff line number Diff line
@@ -952,7 +952,7 @@ int main(

    memset( outBuffer.data_fx, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( Word32 ) );

    bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE;
    bitsBufferSize = ISAR_SPLIT_REND_BITS_BUFF_SIZE;

    if ( bitsBufferSize > 0 )
    {
+3 −3
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ typedef struct
    char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    int8_t orientation_tracking;
    IVAS_HEAD_ORIENT_TRK_T orientation_tracking;
    int16_t Opt_Headrotation;
    int16_t Opt_ExternalOrientation;
    int16_t nonDiegeticPan;
@@ -1601,7 +1601,7 @@ int main(

    if ( is_split_pre_rend_mode( &args ) )
    {
        bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE;
        bitsBufferSize = ISAR_SPLIT_REND_BITS_BUFF_SIZE;
    }
    else
    {
@@ -2431,7 +2431,7 @@ static bool parseRenderFramesize(

static bool parseOrientationTracking(
    char *value,
    int8_t *orientation_tracking )
    IVAS_HEAD_ORIENT_TRK_T *orientation_tracking )
{
    to_upper( value );

+16 −11
Original line number Diff line number Diff line
@@ -46,24 +46,28 @@
 * Common API constants
 *----------------------------------------------------------------------------------*/

#define IVAS_NUM_FRAMES_PER_SEC 50
#define IVAS_MAX_FRAME_SIZE     ( 48000 / IVAS_NUM_FRAMES_PER_SEC )
#define IVAS_MAX_BITS_PER_FRAME ( 512000 / IVAS_NUM_FRAMES_PER_SEC )
#define IVAS_NUM_FRAMES_PER_SEC 50                                                   /* number of frames per second */
#define IVAS_MAX_SAMPLING_RATE  48000                                                /* maximum supported sampling rate in Hz */
#define IVAS_MAX_FRAME_SIZE     ( IVAS_MAX_SAMPLING_RATE / IVAS_NUM_FRAMES_PER_SEC ) /* maximum frame buffer length (per channel) in samples */
#define IVAS_MAX_BITS_PER_FRAME ( 512000 / IVAS_NUM_FRAMES_PER_SEC )                 /* maximum bits per frame; corresponds to maximum bitrate of 512 kbps */

#define IVAS_MAX_NUM_OBJECTS       4
#define IVAS_MAX_INPUT_CHANNELS    16
#define IVAS_MAX_OUTPUT_CHANNELS   16
#define IVAS_MAX_OUTPUT_CHANNELS   16 /* Note: there is an exception for OSBA and EXT otuput where it can be 20 (HOA3 + 4 ISM channels) */
#define IVAS_CLDFB_NO_COL_MAX      16
#define IVAS_CLDFB_NO_CHANNELS_MAX 60

/* Renderer constants */
#define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4
#define IVAS_ROOM_ABS_COEFF              6
#define IVAS_REVERB_PREDELAY_MAX         20 /* Max input delay for reverb module */
#define IVAS_ER_LIST_HEIGHT              1.6f
#define IVAS_ER_LIST_HEIGHT_FX           6710886 /* 1.6f in Q.22 */

/* Maximum buffer length (per channel) in samples */
#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k )
/* JBM constants for adaptive-playout */
#define IVAS_TIME_SCALE_MIN 50  /* min. time-scaling [%] */
#define IVAS_TIME_SCALE_MAX 150 /* max. time-scaling [%] */

/* Frame size required when rendering to binaural */
#define BINAURAL_RENDERING_FRAME_SIZE_MS 5

/*----------------------------------------------------------------------------------*
 * Common API enum for output audio configurations
@@ -196,7 +200,7 @@ typedef struct ivas_hrtf_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
typedef struct ivas_hrtf_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE;
typedef struct ivas_hrtf_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE;
typedef struct ivas_hrtf_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE;
typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE;
typedef struct ivas_cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE;

typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE;
typedef struct ivas_LS_setup_custom IVAS_LSSETUP_CUSTOM_STRUCT;
@@ -247,7 +251,7 @@ typedef enum _ivas_binaural_renderer_type
#define ISAR_MAX_SPLIT_REND_BITRATE                   768000
#define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (Word32) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 )
#define ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ      1
#define SPLIT_REND_BITS_BUFF_SIZE                     ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ )
#define ISAR_SPLIT_REND_BITS_BUFF_SIZE                ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ )

typedef enum
{
@@ -312,6 +316,7 @@ typedef struct _ISAR_SPLIT_REND_CONFIG

} ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE;


/*----------------------------------------------------------------------------------*
 * Renderer API structures and enums
 *----------------------------------------------------------------------------------*/
@@ -356,6 +361,7 @@ typedef struct _IVAS_RENDER_CONFIG
    Word16 directivity_fx[IVAS_MAX_NUM_OBJECTS * 3]; // has the following q-factor pattern: {6, 6, 15, 6, 6, 15, 6, 6, 15, 6, 6, 15}
    float distAtt[3];
    Word32 distAtt_fx[3]; /* {Q27, Q30, Q30} */

} IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE;

typedef struct
@@ -372,7 +378,6 @@ typedef struct
    Word16 q_factor;
    Word16 *pq_fact;
    Word32 *data_fx;
    // Word16 Q_data;

} IVAS_REND_AudioBuffer;

Loading