Commit 911026bd authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into 733-public-api-enum-names

parents ad09b997 a6c09e4c
Loading
Loading
Loading
Loading
Loading
+389 −1587

File changed.

Preview size limit exceeded, changes collapsed.

+16 −135
Original line number Diff line number Diff line
@@ -778,12 +778,7 @@ int main(
    int32_t delayTimeScale = 0;
    int16_t i, numChannels;
    ivas_error error = IVAS_ERR_OK;
#ifndef API_5MS
    IVAS_VECTOR3 Pos[RENDERER_HEAD_POSITIONS_PER_FRAME];
#endif
#ifdef API_5MS
    bool splitBinNeedsNewFrame = true;
#endif

#ifdef WMOPS
    reset_wmops();
@@ -1002,13 +997,7 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif
    const int16_t frameSize_smpls = (int16_t) (
#ifdef API_5MS
        ( args.framing_5ms ? 5 : 20 )
#else
        20
#endif
        * args.sampleRate / 1000 );
    const int16_t frameSize_smpls = (int16_t) ( ( args.framing_5ms ? 5 : 20 ) * args.sampleRate / 1000 );

    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 };
    IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS] = { 0 };
@@ -1018,12 +1007,8 @@ int main(
    IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] = { 0 };
#endif

    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain
#ifdef API_5MS
                                   ,
                                   ( args.framing_5ms ) ? 1 : 4
#endif
                                   ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain,
                                   ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
@@ -1427,9 +1412,7 @@ int main(
    bitsBuffer.config.bufLenInBytes = bitsBufferSize;
    bitsBuffer.config.codec = IVAS_SPLIT_REND_CODEC_DEFAULT;
    bitsBuffer.config.poseCorrection = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE;
#ifdef API_5MS
    bitsBuffer.config.codec_frame_size_ms = 20;
#endif
#else
    inFloatBuffer = malloc( inBufferSize * sizeof( float ) );
    outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) );
@@ -1459,35 +1442,23 @@ int main(
        fprintf( stdout, "\n\n-- Start the renderer (quiet mode) --\n\n" );
    }

#ifdef API_5MS
    ObjectPositionBuffer mtdBuffer;
#endif

    while ( 1 )
    {
        int16_t num_in_channels;
        num_in_channels = inBuffer.config.numChannels;
#ifdef API_5MS
        const bool isCurrentFrameMultipleOf20ms = !args.framing_5ms || frame % 4 == 0;
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
        numSamplesRead = 0;
        if ( ( hSplitRendFileReadWrite != NULL ) && is_split_post_rend_mode( &args )
#ifdef API_5MS
             && splitBinNeedsNewFrame
#endif
        )
        if ( ( hSplitRendFileReadWrite != NULL ) && is_split_post_rend_mode( &args ) && splitBinNeedsNewFrame )
        {
            ivas_error error_tmp;
            numSamplesRead = (int16_t) inBufferSize;
            error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten,
                                                        &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection
#ifdef API_5MS
                                                        ,
                                                        &bitsBuffer.config.codec_frame_size_ms
#endif
            );
                                                        &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection,
                                                        &bitsBuffer.config.codec_frame_size_ms );
            if ( error_tmp != IVAS_ERR_OK )
            {
                if ( error_tmp == IVAS_ERR_END_OF_FILE )
@@ -1515,11 +1486,7 @@ int main(
        }
#endif

        if ( numSamplesRead == 0
#ifdef API_5MS
             && splitBinNeedsNewFrame
#endif
        )
        if ( numSamplesRead == 0 && splitBinNeedsNewFrame )
        {
            /* end of input data */
            break;
@@ -1534,18 +1501,10 @@ int main(
        );

        int16_t num_subframes, sf_idx;
#ifdef API_5MS
        num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
#else
        num_subframes = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
#endif

#ifdef API_5MS
        if ( isCurrentFrameMultipleOf20ms )
        {
#else
        ObjectPositionBuffer mtdBuffer;
#endif
            IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer );

            if ( referenceVectorReader != NULL )
@@ -1581,14 +1540,11 @@ int main(
                    }
                }
            }
#ifdef API_5MS
        }
#endif

        /* Read from head rotation trajectory file if specified */
        if ( headRotReader != NULL )
        {
#ifdef API_5MS
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
            {
                IVAS_QUATERNION headRot;
@@ -1604,70 +1560,26 @@ int main(
                                                          ,
                                                          DEFAULT_AXIS
#endif
#ifdef API_5MS
                                                          ,
                                                          sf_idx
#endif
                                                          ) ) != IVAS_ERR_OK )
                                                          sf_idx ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
#else
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];

            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
            {
                if ( ( error = HeadRotationFileReading( headRotReader, &quatBuffer[i], &Pos[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }

            if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                      ,
                                                      DEFAULT_AXIS
#endif
                                                      ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif
        }
        else
        {
#ifdef API_5MS
            if ( ( error = IVAS_REND_DisableHeadRotation( hIvasRend ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error disabling head rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#else /* API_5MS */
            error = IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                               ,
                                               DEFAULT_AXIS
#endif
            );
            if ( error != IVAS_ERR_OK && error != IVAS_ERR_INVALID_OUTPUT_FORMAT )
            {
                fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif /* API_5MS */
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        /* Read from split renderer bfi file if specified */
        if ( splitRendBFIReader != NULL
#ifdef API_5MS
             && splitBinNeedsNewFrame
#endif
        )
        if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame )
        {
            int16_t bfi;
            SplitRendBFIFileReading( splitRendBFIReader, &bfi );
@@ -1683,11 +1595,7 @@ int main(
            int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
#ifdef API_5MS
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
#else
            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
#endif
            {
                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
                {
@@ -1695,27 +1603,15 @@ int main(
                    exit( -1 );
                }
            }
#ifdef API_5MS
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
            {
                if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx]
#ifdef API_5MS
                                                                 ,
                                                                 sf_idx
#endif
                                                                 ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx],
                                                                 sf_idx ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
#else
            if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, quatBuffer, enableHeadRotation, enableExternalOrientation, enableRotationInterpolation, numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif
        }

        /* Combine external orientations and head rotation */
@@ -1829,10 +1725,8 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
        for ( i = 0; i < args.inConfig.numBinBuses; ++i )
        {
#ifdef API_5MS
            if ( splitBinNeedsNewFrame )
            {
#endif
                if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, splitBinIds[i], &numChannels ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
@@ -1851,13 +1745,11 @@ int main(
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
#ifdef API_5MS
            }
#endif
        }
#endif

#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
#if defined SPLIT_REND_WITH_HEAD_ROT
        if ( args.inConfig.numBinBuses != 0 )
        {
            if ( ( error = IVAS_REND_GetSplitBinauralSamples( hIvasRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK )
@@ -1878,14 +1770,7 @@ int main(
        else
        {
#endif
            if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer
#ifndef API_5MS
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                 ,
                                                 &bitsBuffer
#endif
#endif
                                                 ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) );
@@ -1894,7 +1779,7 @@ int main(
#endif
                exit( -1 );
            }
#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
#if defined SPLIT_REND_WITH_HEAD_ROT
        }
#endif

@@ -1945,12 +1830,8 @@ int main(
        if ( ( hSplitRendFileReadWrite != NULL ) && is_split_pre_rend_mode( &args ) )
        {
            if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten,
                                                     bitsBuffer.config.codec, bitsBuffer.config.poseCorrection
#ifdef API_5MS
                                                     ,
                                                     bitsBuffer.config.codec_frame_size_ms
#endif
                                                     ) != IVAS_ERR_OK )
                                                     bitsBuffer.config.codec, bitsBuffer.config.poseCorrection,
                                                     bitsBuffer.config.codec_frame_size_ms ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                exit( -1 );
+10 −17
Original line number Diff line number Diff line
@@ -57,9 +57,6 @@


#define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4
#ifndef API_5MS
#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // ToDo: should it be harmonized with IVAS_MAX_PARAM_SPATIAL_SUBFRAMES?
#endif

#define IVAS_ROOM_ABS_COEFF 6
#ifdef SPLIT_REND_WITH_HEAD_ROT
@@ -179,9 +176,7 @@ typedef struct ivas_split_rend_bits_t
    int32_t buf_len; /*size of bits_buf in bytes. This field should be set by allocator of bits_buf*/
    int32_t bits_written;
    int32_t bits_read;
#ifdef API_5MS
    int16_t codec_frame_size_ms;
#endif
    IVAS_SPLIT_REND_CODEC codec;
    IVAS_SPLIT_REND_POSE_CORRECTION_MODE pose_correction;
} ivas_split_rend_bits_t, IVAS_SPLIT_REND_BITS_DATA, *IVAS_SPLIT_REND_BITS_HANDLE;
@@ -265,9 +260,7 @@ typedef struct _IVAS_SPLIT_REND_CONFIG
                                 3 - (3dof correction. By default YAW, PITCH and ROLL correction)
                                 */
    int16_t codec_delay_ms;      /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/
#ifdef API_5MS
    int16_t codec_frame_size_ms; /*Codec frame size in milliseconds, only relevant with LC3plus */
#endif
    IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode;
    IVAS_SPLIT_REND_CODEC codec;
    IVAS_SPLIT_REND_RENDERER_SELECTION rendererSelection;
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ typedef enum
} ivas_renderTypeOverride;
#endif

#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
#if defined SPLIT_REND_WITH_HEAD_ROT
typedef enum
{
    PCM_INT16,
+0 −2
Original line number Diff line number Diff line
@@ -86,10 +86,8 @@ typedef enum
    IVAS_ERR_ISM_INVALID_METADATA_VALUE,
    IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE,
    IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED,
#ifdef API_5MS
    IVAS_ERR_TSM_NOT_ENABLED,
    IVAS_ERR_FETCH_SIZE_NO_MULTIPLE_OF_5MS,
#endif
#ifdef DEBUGGING
    IVAS_ERR_INVALID_FORCE_MODE,
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
Loading