Commit e4c2b005 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Adapt removed changes from old commit for G192 bitstream decoder format switching.

parent 3ce1cf5f
Loading
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -175,7 +175,11 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
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 *phIvasDec, 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, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
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 DEBUGGING
@@ -779,7 +783,11 @@ int main(
    }
    else
    {
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf );
#else
        error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf );
#endif
    }

    if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -2225,7 +2233,11 @@ static ivas_error decodeG192(
    Vector3PairFileReader *referenceVectorReader,
    ObjectEditFileReader *objectEditFileReader,
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    IVAS_DEC_HANDLE *phIvasDec,
#else
    IVAS_DEC_HANDLE hIvasDec,
#endif
    int16_t *pcmBuf )

{
@@ -2233,6 +2245,9 @@ static ivas_error decodeG192(
    uint16_t bit_stream[IVAS_MAX_BITS_PER_FRAME + 4 * 8];
    int16_t i, num_bits;
    int16_t bfi = 0;
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    IVAS_DEC_HANDLE hIvasDec = *phIvasDec;
#endif
#ifdef DEBUGGING
    int16_t fec_seed = 12558; /* FEC_SEED */
#endif
@@ -2263,6 +2278,9 @@ static ivas_error decodeG192(
    int16_t vec_pos_update, vec_pos_len;
    SplitFileReadWrite *splitRendWriter = NULL;
    int16_t isSplitRend, isSplitCoded;
#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
    bool restartNeeded;
#endif

#ifdef VARIABLE_SPEED_DECODING
    if ( arg.tsmEnabled )
@@ -2597,6 +2615,37 @@ static ivas_error decodeG192(
                /* Placeholder for memory reallocation */
                /* ... */

#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

                if ( restartNeeded )
                {
                    IVAS_DEC_BS_FORMAT tempFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error );
                        goto cleanup;
                    }
                    IVAS_DEC_MODE codecMode = ( tempFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
                    error = restartDecoder(
                        &hIvasDec,
                        codecMode,
                        &arg,
                        NULL, /* ToDo : Provide rendererConfig */
                        NULL  /* ToDo : Provide LS Custom Data */
                    );
                    if ( error != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nFailed to restart decoder\n" );
                        goto cleanup;
                    }
                    *phIvasDec = hIvasDec; /* Update for main()' s free */
                }
#endif

                /* Load HRTF binary file data */
                if ( arg.hrtfReaderEnabled )
                {
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP                /* FhG: remove dead code from tcx_ari_res_Q_spec() */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* Nokia: reintroduce format switching for g192 bitstreams */

/* #################### End BE switches ################################## */