Commit f59e13d9 authored by vaclav's avatar vaclav
Browse files

Merge branch 'split_rendering_formal_improvements' into 'main'

Split rendering formal improvements

See merge request !860
parents f8beb0bb 26b00c11
Loading
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -172,15 +172,16 @@ if(NOT INCLUDE_SPLIT)
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*lc3plus.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_cldfb_codec.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*splitRend.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_CQMF.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*splitrenderer.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_lcld.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_Pred.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_RMSEnv.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_PerceptualModel.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_lcld_tables.*\.c$")
  list(FILTER libRendSrcs EXCLUDE REGEX ".*lib_rend\/.*ivas_lcld_rom_tables.*\.c$")
  list(FILTER libRendHeaders EXCLUDE REGEX ".*lib_rend\/.*lc3plus.*\.h$")
  list(FILTER libRendHeaders EXCLUDE REGEX ".*lib_rend\/.*splitRend.*\.h$")
  list(FILTER libRendHeaders EXCLUDE REGEX ".*lib_rend\/.*ivas_cldfb_codec.*\.h$")
  list(FILTER libRendHeaders EXCLUDE REGEX ".*lib_rend\/.*ivas_lcld_tables.*\.h$")
  list(FILTER libRendHeaders EXCLUDE REGEX ".*lib_rend\/.*ivas_lcld_rom_tables.*\.h$")
endif()

if(INCLUDE_SPLIT)
+8 −14
Original line number Diff line number Diff line
@@ -145,12 +145,12 @@
    <ClCompile Include="..\lib_rend\ivas_lc3plus_common.c" />
    <ClCompile Include="..\lib_rend\ivas_lc3plus_dec.c" />
    <ClCompile Include="..\lib_rend\ivas_lc3plus_enc.c" />
    <ClCompile Include="..\lib_rend\ivas_lcld_tables.c" />
    <ClCompile Include="..\lib_rend\ivas_lcld_decoder.c" />
    <ClCompile Include="..\lib_rend\ivas_lcld_encoder.c" />
    <ClCompile Include="..\lib_rend\ivas_lcld_rom_tables.c" />
    <ClCompile Include="..\lib_rend\ivas_sba_rendering.c" />
    <ClCompile Include="..\lib_rend\ivas_allrad_dec.c" />
    <ClCompile Include="..\lib_rend\ivas_cldfb_codec_bitstream.c" />
    <ClCompile Include="..\lib_rend\ivas_CQMFDecoder.c" />
    <ClCompile Include="..\lib_rend\ivas_CQMFEncoder.c" />
    <ClCompile Include="..\lib_rend\ivas_MSPred.c" />
    <ClCompile Include="..\lib_rend\ivas_NoiseGen.c" />
    <ClCompile Include="..\lib_rend\ivas_PerceptualModel.c" />
@@ -195,16 +195,10 @@
    <ClCompile Include="..\lib_rend\lib_rend.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_rend\ivas_CQMFDecoder.h" />
    <ClInclude Include="..\lib_rend\ivas_CQMFEncoder.h" />
    <ClInclude Include="..\lib_rend\ivas_lcld_tables.h" />
    <ClInclude Include="..\lib_rend\ivas_MSPred.h" />
    <ClInclude Include="..\lib_rend\ivas_NoiseGen.h" />
    <ClInclude Include="..\lib_rend\ivas_PerceptualModel.h" />
    <ClInclude Include="..\lib_rend\ivas_PredDecoder.h" />
    <ClInclude Include="..\lib_rend\ivas_PredEncoder.h" />
    <ClInclude Include="..\lib_rend\ivas_cldfb_codec_bitstream.h" />
    <ClInclude Include="..\lib_rend\ivas_lcld_prot.h" />
    <ClInclude Include="..\lib_rend\ivas_lcld_rom_tables.h" />
    <ClInclude Include="..\lib_rend\ivas_prot_rend.h" />
    <ClInclude Include="..\lib_rend\ivas_RMSEnvGrouping.h" />
    <ClInclude Include="..\lib_rend\ivas_rom_binauralRenderer.h" />
    <ClInclude Include="..\lib_rend\ivas_rom_binaural_crend_head.h" />
    <ClInclude Include="..\lib_rend\ivas_rom_rend.h" />
+18 −12
Original line number Diff line number Diff line
@@ -155,15 +155,21 @@
    <ClCompile Include="..\lib_rend\ivas_splitRendererPre.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_lcld_tables.c" />
    <ClCompile Include="..\lib_rend\ivas_CQMFDecoder.c" />
    <ClCompile Include="..\lib_rend\ivas_CQMFEncoder.c" />
    <ClCompile Include="..\lib_rend\ivas_shoebox.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_reflections.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_lcld_rom_tables.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_lcld_decoder.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_lcld_encoder.c">
      <Filter>rend_c</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_rend\lib_rend.h" />
@@ -194,15 +200,15 @@
    <ClInclude Include="..\lib_rend\ivas_rom_TdBinauralRenderer.h">
      <Filter>rend_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_rend\ivas_CQMFDecoder.h" />
    <ClInclude Include="..\lib_rend\ivas_CQMFEncoder.h" />
    <ClInclude Include="..\lib_rend\ivas_lcld_tables.h" />
    <ClInclude Include="..\lib_rend\ivas_MSPred.h" />
    <ClInclude Include="..\lib_rend\ivas_NoiseGen.h" />
    <ClInclude Include="..\lib_rend\ivas_PerceptualModel.h" />
    <ClInclude Include="..\lib_rend\ivas_PredDecoder.h" />
    <ClInclude Include="..\lib_rend\ivas_PredEncoder.h" />
    <ClInclude Include="..\lib_rend\ivas_RMSEnvGrouping.h" />
    <ClInclude Include="..\lib_rend\ivas_lcld_prot.h">
      <Filter>rend_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_rend\ivas_lcld_rom_tables.h">
      <Filter>rend_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_rend\ivas_cldfb_codec_bitstream.h">
      <Filter>rend_h</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Filter Include="rend_h">
+80 −70
Original line number Diff line number Diff line
@@ -74,10 +74,7 @@ static
#else
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( IVAS_MAX_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE )
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
#define MAX_SPLIT_REND_BITRATE                   ( 768000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ? */
#define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 )
#endif


#define IVAS_PUBLIC_ORIENT_TRK_NONE        ( 0 )
#define IVAS_PUBLIC_ORIENT_TRK_REF         ( 1 )
@@ -207,7 +204,7 @@ int main(
    ivas_error error = IVAS_ERR_UNKNOWN;
    int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    uint8_t splitRendBitsBuf[MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES];
    uint8_t splitRendBitsBuf[IVAS_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES];
#endif
    RenderConfigReader *renderConfigReader = NULL;
#ifdef DEBUGGING
@@ -272,7 +269,21 @@ int main(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
    {
        fprintf( stdout, "Output metadata file:   %s\n", arg.outputWavFilename );
    }
    else if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        fprintf( stdout, "Output synthesis file:  %s\n", arg.outputWavFilename );
        fprintf( stdout, "Output metadata file:   %s\n", arg.outputMdFilename );
    }
    else
#endif
    {
        fprintf( stdout, "Output synthesis file:  %s\n", arg.outputWavFilename );
    }

    /*------------------------------------------------------------------------------------------*
     * Open HRTF file
@@ -424,17 +435,28 @@ int main(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /*------------------------------------------------------------------------------------------*
     * Configure the decoder
     * Binaural split rendering sanity checks
     *------------------------------------------------------------------------------------------*/

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        arg.enableHeadRotation = true;

        if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.outputMdFilename == NULL )
        {
            fprintf( stderr, "\nError: split rendering metadata output file not specified.\n\n" );
            usage_dec();
            goto cleanup;
        }
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Configure the decoder
     *------------------------------------------------------------------------------------------*/

    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -1560,13 +1582,13 @@ static void usage_dec( void )
    fprintf( stdout, "-T File             : Head rotation specified by external trajectory File\n" );
    fprintf( stdout, "-otr tracking_type  : Head orientation tracking type: 'none', 'ref', 'avg', 'ref_vec' \n" );
    fprintf( stdout, "                      or 'ref_vec_lev' (only for binaural rendering)\n" );
    fprintf( stdout, "-rf File            : Reference rotation specified by external trajectory file\n" );
    fprintf( stdout, "-rf File            : Reference rotation specified by external trajectory File\n" );
    fprintf( stdout, "                      works only in combination with '-otr ref' mode \n" );
    fprintf( stdout, "-rvf File           : Reference vector specified by external trajectory file\n" );
    fprintf( stdout, "-rvf File           : Reference vector specified by external trajectory File\n" );
    fprintf( stdout, "                      works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" );
    fprintf( stdout, "-render_config File : Renderer configuration File\n" );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    fprintf( stdout, "-om File            : MD output file for BINAURAL_SPLIT_PCM output format\n" );
    fprintf( stdout, "-om File            : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" );
#endif
    fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" );
    fprintf( stdout, "                      left or l or 90->left, right or r or -90->right, center or c or  0->middle\n" );
@@ -1578,7 +1600,7 @@ static void usage_dec( void )
    fprintf( stdout, "                      default is OFF, if this option is not used\n" );
    fprintf( stdout, "-force R            : Force specific binaural rendering mode, R = (TDREND, CLDFBREND),\n" );
#endif
    fprintf( stdout, "-exof File          : External orientation file for external orientation trajectory\n" );
    fprintf( stdout, "-exof File          : External orientation File for external orientation trajectory\n" );
    fprintf( stdout, "-dpid ID            : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration\n" );
    fprintf( stdout, "-aeid ID            : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration\n" );
    fprintf( stdout, "-level level        : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" );
@@ -1610,6 +1632,13 @@ static int16_t app_own_random( int16_t *seed )
}
#endif


/*---------------------------------------------------------------------*
 * initOnFirstGoodFrame()
 *
 *
 *---------------------------------------------------------------------*/

static ivas_error initOnFirstGoodFrame(
    IVAS_DEC_HANDLE hIvasDec,                        /* i/o: */
    const DecArguments arg,                          /* i  : */
@@ -1638,9 +1667,9 @@ static ivas_error initOnFirstGoodFrame(
        fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
        return error;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
         ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
    if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        pFullDelayNumSamples[0] = 0;
    }
@@ -1667,8 +1696,9 @@ static ivas_error initOnFirstGoodFrame(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
    if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        /* Open split rendering metadata writer */
        int16_t delayNumSamples_temp[3];
        int32_t delayTimeScale_temp;

@@ -1678,35 +1708,27 @@ static ivas_error initOnFirstGoodFrame(
            return error;
        }

        if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
        {
            if ( ( error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp ) ) != IVAS_ERR_OK )
            {
            fprintf( stderr, "Could not open split rend metadata file %s\n", arg.outputWavFilename );
                fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename );
                return error;
            }

        *ppAfWriter = NULL;
        }
        else
        {
        if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            int16_t delayNumSamples_temp[3];
            int32_t delayTimeScale_temp;

            if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
                return error;
            }

            if ( ( error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Could not open split rend metadata file %s\n", arg.outputWavFilename );
                fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename );
                return error;
            }
        }
#endif
    }

    if ( arg.outputConfig != AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
    {
#endif
        /* Open audio writer and write all previously skipped bad frames now that frame size is known */
        if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK )
        {
@@ -1717,7 +1739,6 @@ static ivas_error initOnFirstGoodFrame(
    }
#endif


    int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) );
    memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) );

@@ -1726,11 +1747,11 @@ static ivas_error initOnFirstGoodFrame(
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( *hSplitRendFileReadWrite != NULL )
        {
            IVAS_SPLIT_REND_BITS splitRendBitsZero;
            IVAS_SPLIT_REND_BITS_DATA splitRendBitsZero;
            splitRendBitsZero.bits_written = 0;
            splitRendBitsZero.bits_read = 0;
            if ( split_rend_write_bitstream_to_file( *hSplitRendFileReadWrite, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written,
                                                     -1, IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) != IVAS_ERR_OK )

            if ( split_rend_write_bitstream_to_file( *hSplitRendFileReadWrite, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written, -1, IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                exit( -1 );
@@ -1898,12 +1919,9 @@ static ivas_error decodeG192(
    uint16_t numObj = 0;
    IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#ifdef SPLIT_REND_WITH_HEAD_ROT
    IVAS_SPLIT_REND_BITS splitRendBits;
    SplitFileReadWrite *hSplitRendFileReadWrite;
    SplitFileReadWrite *splitRendWriter = NULL;
#endif

    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
@@ -1927,14 +1945,6 @@ static ivas_error decodeG192(
    reset_wmops();
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    splitRendBits.bits_buf = splitRendBitsBuf;
    splitRendBits.bits_read = 0;
    splitRendBits.bits_written = 0;
    splitRendBits.buf_len = MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES;
    hSplitRendFileReadWrite = NULL;
#endif

    /*------------------------------------------------------------------------------------------*
     * Loop for every packet (frame) of bitstream data
     * - Read the bitstream packet
@@ -2089,7 +2099,7 @@ static ivas_error decodeG192(
        if ( ( error = IVAS_DEC_GetSamples( hIvasDec, pcmBuf, &nOutSamples
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                            ,
                                            &splitRendBits
                                            splitRendBitsBuf
#endif
                                            ) ) != IVAS_ERR_OK )
        {
@@ -2113,7 +2123,7 @@ static ivas_error decodeG192(
                                                     &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                     ,
                                                     &hSplitRendFileReadWrite
                                                     &splitRendWriter
#endif
                                                     ) ) != IVAS_ERR_OK )
                {
@@ -2130,26 +2140,25 @@ static ivas_error decodeG192(
        if ( decodedGoodFrame )
        {
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
            if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
            {
                if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written,
                                                         splitRendBits.codec, splitRendBits.pose_correction ) != IVAS_ERR_OK )
                IVAS_SPLIT_REND_BITS_DATA splitRendBits;

                if ( ( error = IVAS_DEC_GetSplitRendBits( hIvasDec, &splitRendBits ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                    exit( -1 );
                }
                    fprintf( stderr, "\nError in IVAS_DEC_SplitRendBits: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            else
            {
                if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
                {
                    if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written,
                                                             splitRendBits.codec, splitRendBits.pose_correction ) != IVAS_ERR_OK )

                if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, splitRendBits.codec, splitRendBits.pose_correction ) != IVAS_ERR_OK )
                {
                        fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                        exit( -1 );
                    fprintf( stderr, "\nError writing split rendering bitstream to file!\n" );
                    goto cleanup;
                }
            }

            if ( arg.outputConfig != AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
            {
#endif
                if ( delayNumSamples < nOutSamples )
                {
@@ -2313,10 +2322,11 @@ static ivas_error decodeG192(

cleanup:
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( hSplitRendFileReadWrite != NULL )
    if ( splitRendWriter != NULL )
    {
        split_rend_reader_writer_close( &hSplitRendFileReadWrite );
        split_rend_reader_writer_close( &splitRendWriter );
    }

    if ( afWriter != NULL )
    {
#endif
@@ -2324,6 +2334,7 @@ cleanup:
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    MasaFileWriter_close( &masaWriter );
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
    {
@@ -3154,7 +3165,6 @@ static ivas_error decodeVariableSpeed(
            if ( decodedGoodFrame )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT

                SplitFileReadWrite *hSplitRendFileReadWrite = NULL;
#endif
                error = initOnFirstGoodFrame(
+26 −8
Original line number Diff line number Diff line
@@ -665,6 +665,8 @@ static void setupWithSingleFormatInput(
        }
    }
#endif

    return;
}


@@ -674,10 +676,14 @@ static float dBToLin(
    return powf( 10.0f, gain_dB / 20.0f );
}


#ifdef SPLIT_REND_WITH_HEAD_ROT
static int16_t get_cldfb_in_flag( AUDIO_CONFIG audioConfig, IVAS_RENDER_CONFIG_DATA *renderConfig )
static int16_t get_cldfb_in_flag(
    const AUDIO_CONFIG audioConfig,
    IVAS_RENDER_CONFIG_DATA *renderConfig )
{
    int16_t cldfb_in;

    cldfb_in = 0;
    if ( renderConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV )
    {
@@ -693,12 +699,14 @@ static int16_t get_cldfb_in_flag( AUDIO_CONFIG audioConfig, IVAS_RENDER_CONFIG_D
    return cldfb_in;
}

static int16_t is_split_post_rend_mode( CmdlnArgs *args )

static int16_t is_split_post_rend_mode(
    CmdlnArgs *args )
{
    int16_t flag;

    flag = 0;
    if ( ( args->inConfig.numBinBuses > 0 ) &&
         ( ( args->inConfig.binBuses[0].audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( args->inConfig.binBuses[0].audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
    if ( args->inConfig.numBinBuses > 0 && ( args->inConfig.binBuses[0].audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args->inConfig.binBuses[0].audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        flag = 1;
    }
@@ -706,12 +714,13 @@ static int16_t is_split_post_rend_mode( CmdlnArgs *args )
    return flag;
}

static int16_t is_split_pre_rend_mode( CmdlnArgs *args )
static int16_t is_split_pre_rend_mode(
    CmdlnArgs *args )
{
    int16_t flag;

    flag = 0;
    if ( ( args->outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
         ( args->outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    if ( args->outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args->outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        flag = 1;
    }
@@ -720,6 +729,7 @@ static int16_t is_split_pre_rend_mode( CmdlnArgs *args )
}
#endif


/*------------------------------------------------------------------------------------------*
 * main()
 *
@@ -1091,6 +1101,7 @@ int main(
#endif
            exit( -1 );
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( !is_split_post_rend_mode( &args ) )
        {
@@ -1357,9 +1368,11 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    inBufferSize = frameSize_smpls * totalNumInChannels;
    outBufferSize = frameSize_smpls * numOutChannels;
    inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) );

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( cldfb_in == 0 )
    {
@@ -1464,6 +1477,7 @@ int main(
                }
            }
        }

        if ( audioReader != NULL )
        {
#endif
@@ -1538,6 +1552,7 @@ int main(
                    exit( -1 );
                }
            }

            if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                      ,
@@ -1573,6 +1588,7 @@ int main(
            IVAS_REND_SetSplitRendBFI( hIvasRend, bfi );
        }
#endif

        /* Read from external orientation file if specified */
        if ( externalOrientationFileReader != NULL )
        {
@@ -1818,11 +1834,11 @@ int main(
            }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        }

        bitsBuffer.config.bitsRead = 0;
        bitsBuffer.config.bitsWritten = 0;
#endif


        /* Write MASA metadata for MASA outputs */
        if ( args.outConfig.audioConfig == AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == AUDIO_CONFIG_MASA2 )
        {
@@ -2442,6 +2458,7 @@ static bool checkRequiredArgs(
        fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
        missingRequiredArg = true;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    const bool singleInputSpecified = args.inConfig.numAudioObjects != 0 ||
                                      args.inConfig.numAmbisonicsBuses != 0 ||
@@ -2454,6 +2471,7 @@ static bool checkRequiredArgs(
                                      args.inConfig.numMultiChannelBuses != 0 ||
                                      args.inConfig.numMasaBuses != 0;
#endif

    if ( !args.sceneDescriptionInput && !singleInputSpecified )
    {
        /* Neither scene description input nor single-type input was specified on command line */
Loading