Commit 4c2b7cc4 authored by vaclav's avatar vaclav
Browse files

resolve renderer application dependency on internal library

parent 43a6b2d3
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@
    </CustomBuildStep>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\lib_util;..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MinimalRebuild>false</MinimalRebuild>
      <ExceptionHandling />
@@ -124,7 +124,7 @@
      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
      <IntrinsicFunctions>false</IntrinsicFunctions>
      <WholeProgramOptimization>false</WholeProgramOptimization>
      <AdditionalIncludeDirectories>..\lib_util;..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <ExceptionHandling />
+7 −0
Original line number Diff line number Diff line
@@ -254,9 +254,16 @@
    <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_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" />
+5 −12
Original line number Diff line number Diff line
@@ -30,11 +30,9 @@

*******************************************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "options.h"
#include "lib_dec.h"
#include "cmdl_tools.h"
#include "audio_file_writer.h"
@@ -74,18 +72,13 @@ static

#define MIN_NUM_BITS_ACTIVE_FRAME  56
#define NUM_BITS_SID_IVAS_5K2      104
#ifdef SPLIT_REND_WITH_HEAD_ROT
#define NUM_FRAMES_PER_SEC 50
#define MAX_FRAME_SIZE     ( 48000 / NUM_FRAMES_PER_SEC )
#else
#define MAX_FRAME_SIZE ( 48000 / 50 )
#endif
#define MAX_NUM_OUTPUT_CHANNELS    16
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE )
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE )
#ifdef SPLIT_REND_WITH_HEAD_ROT
#define MAX_SPLIT_REND_BITRATE                   ( 1792000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ?*/
#define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / NUM_FRAMES_PER_SEC ) + 7 ) >> 3 )
#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 )
#define IVAS_PUBLIC_ORIENT_TRK_AVG         ( 2 )
+59 −94
Original line number Diff line number Diff line
@@ -52,8 +52,10 @@
#include "ls_custom_file_reader.h"
#include "masa_file_reader.h"
#include "masa_file_writer.h"
#include "prot.h"
#include "render_config_reader.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmc_auto.h"


@@ -66,9 +68,12 @@
#define RENDERER_MAX_METADATA_LINE_LENGTH 1024

#ifdef SPLIT_REND_WITH_HEAD_ROT
#define SPLIT_REND_BITS_BUFF_SIZE ( ( ( ( (int32_t) SPLIT_REND_MAX_BRATE / FRAMES_PER_SEC ) + 7 ) >> 3 ) + SPLIT_REND_ADDITIONAL_BYTES_TO_READ )
#define SPLIT_REND_BITS_BUFF_SIZE ( ( ( ( (int32_t) SPLIT_REND_MAX_BRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) + SPLIT_REND_ADDITIONAL_BYTES_TO_READ )
#endif

#define IVAS_MAX16B_FLT 32767.0f
#define IVAS_MIN16B_FLT ( -32768.0f )

#if !defined( DEBUGGING ) && !defined( WMOPS )
static
#endif
@@ -80,6 +85,11 @@ static
#define SEP_FOLDER '/'
#endif

#ifndef _WIN32
#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#endif


/*------------------------------------------------------------------------------------------*
 * Local structures
@@ -412,7 +422,7 @@ static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSa
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                ,
                                const int16_t cldfb_in,
                                HANDLE_CLDFB_FILTER_BANK *cldfbAna
                                IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna
#endif
);

@@ -420,7 +430,7 @@ static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamp
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                 ,
                                 const int16_t cldfb_in,
                                 HANDLE_CLDFB_FILTER_BANK *cldfbSyn
                                 IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn
#endif
);

@@ -629,61 +639,6 @@ static float dBToLin(
}

#ifdef SPLIT_REND_WITH_HEAD_ROT
static int16_t rend_openCldfb(
    HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS],
    HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS],
    const int16_t num_in_chs,
    const int16_t num_out_chs,
    const int32_t output_Fs )
{
    int16_t n;

    for ( n = 0; n < num_in_chs; n++ )
    {
        if ( openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK )
        {
            return -1;
        }
    }
    for ( ; n < MAX_INPUT_CHANNELS; n++ )
    {
        cldfbAna[n] = NULL;
    }

    for ( n = 0; n < num_out_chs; n++ )
    {
        if ( openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK )
        {
            return -1;
        }
    }
    for ( ; n < MAX_INPUT_CHANNELS; n++ )
    {
        cldfbSyn[n] = NULL;
    }
    return 0;
}

static void rend_closeCldfb( HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS], HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS] )
{
    int16_t n;
    for ( n = 0; n < MAX_INPUT_CHANNELS; n++ )
    {
        if ( cldfbAna[n] != NULL )
        {
            deleteCldfb( &( cldfbAna[n] ) );
            cldfbAna[n] = NULL;
        }

        if ( cldfbSyn[n] != NULL )
        {
            deleteCldfb( &( cldfbSyn[n] ) );
            cldfbSyn[n] = NULL;
        }
    }
    return;
}

static int16_t get_cldfb_in_flag( IVAS_REND_AudioConfig audioConfig, IVAS_RENDER_CONFIG_DATA *renderConfig )
{
    int16_t cldfb_in;
@@ -744,8 +699,8 @@ int main(
    RotFileReader *externalOrientationFileReader = NULL;
    RotFileReader *referenceRotReader = NULL;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS];
    HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS];
    IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS];
    IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS];
    int16_t cldfb_in, CLDFBframeSize_smpls;
    SplitRendBFIFileReader *splitRendBFIReader = NULL;
#endif
@@ -1077,7 +1032,7 @@ int main(

        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
            renderConfig.room_acoustics.override = TRUE;
            renderConfig.room_acoustics.override = 1;
        }

        if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
@@ -1322,7 +1277,7 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( cldfb_in )
    {
        rend_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate );
        IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate );
    }

    if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
@@ -1919,7 +1874,7 @@ int main(
#ifdef FIX_488_SYNC_DELAY
    if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
    {
        fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ) );
        fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) );
    }
#endif

@@ -1961,7 +1916,7 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( cldfb_in )
    {
        rend_closeCldfb( cldfbAna, cldfbSyn );
        IVAS_REND_closeCldfb( cldfbAna, cldfbSyn );
    }

    if ( hSplitRendFileReadWrite != NULL )
@@ -3349,12 +3304,20 @@ static ivas_error parseCustomLayoutFile(
    }

    pLsSetupCustom->num_spk = hLsCustomData.num_spk;
    mvr2r( hLsCustomData.azimuth, pLsSetupCustom->azimuth, hLsCustomData.num_spk );
    mvr2r( hLsCustomData.elevation, pLsSetupCustom->elevation, hLsCustomData.num_spk );

    for ( int16_t i = 0; i < hLsCustomData.num_spk; i++ )
    {
        pLsSetupCustom->azimuth[i] = hLsCustomData.azimuth[i];
        pLsSetupCustom->elevation[i] = hLsCustomData.elevation[i];
    }

    /* Loudspeaker LFE */
    pLsSetupCustom->num_lfe = hLsCustomData.num_lfe;
    mvs2s( hLsCustomData.lfe_idx, pLsSetupCustom->lfe_idx, hLsCustomData.num_lfe );

    for ( int16_t i = 0; i < hLsCustomData.num_lfe; i++ )
    {
        pLsSetupCustom->lfe_idx[i] = hLsCustomData.lfe_idx[i];
    }

    CustomLsReader_close( &hLsCustomReader );

@@ -3561,7 +3524,7 @@ static ivas_error parseLfePanMtxFile(
    const char *lfeRoutingMatrixFilePath,
    IVAS_REND_LfePanMtx *lfePanMtx )
{
    int16_t lfe_in, ch_out;
    int16_t i, lfe_in, ch_out;
    const char *tok;
    char line[200]; /* > (10 chars * IVAS_MAX_OUTPUT_CHANNELS) i.e. "-999,     " */
    FILE *mtxFile;
@@ -3582,7 +3545,10 @@ static ivas_error parseLfePanMtxFile(
       any subsequent issue in file reading will gracefully exit the function */
    for ( lfe_in = 0; lfe_in < IVAS_MAX_INPUT_LFE_CHANNELS; lfe_in++ )
    {
        set_zero( ( *lfePanMtx )[lfe_in], IVAS_MAX_OUTPUT_CHANNELS );
        for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ )
        {
            ( *lfePanMtx )[lfe_in][i] = 0.0f;
        }
    }

    for ( lfe_in = 0; lfe_in < IVAS_MAX_INPUT_LFE_CHANNELS; lfe_in++ )
@@ -3641,7 +3607,7 @@ static void convertInputBuffer(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ,
    const int16_t cldfb_in,
    HANDLE_CLDFB_FILTER_BANK *cldfbAna
    IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna
#endif
)
{
@@ -3652,11 +3618,11 @@ static void convertInputBuffer(
    if ( cldfb_in )
    {
        int16_t slotIdx, numCldfbBands, numFloatPcmSamples;
        float fIn[MAX_OUTPUT_CHANNELS][L_FRAME48k];
        float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE];
        numFloatPcmSamples = numFloatSamplesPerChannel >> 1;
        numCldfbBands = numFloatPcmSamples / CLDFB_NO_COL_MAX;
        numCldfbBands = numFloatPcmSamples / IVAS_CLDFB_NO_COL_MAX;
        /* CLDFB Analysis*/
        assert( numIntSamplesPerChannel <= MAX_OUTPUT_CHANNELS * L_FRAME48k );
        assert( numIntSamplesPerChannel <= IVAS_MAX_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE );
        for ( smpl = 0; smpl < numFloatPcmSamples; ++smpl )
        {
            for ( chnl = 0; chnl < numChannels; ++chnl )
@@ -3675,13 +3641,12 @@ static void convertInputBuffer(
        }
        for ( chnl = 0; chnl < numChannels; ++chnl )
        {
            for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ )
            for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ )
            {
                cldfbAnalysis_ts( &fIn[chnl][numCldfbBands * slotIdx],
                IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx],
                                                    &floatBuffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )],
                                                    &floatBuffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )],
                                  numCldfbBands,
                                  cldfbAna[chnl] );
                                                    numCldfbBands, cldfbAna[chnl] );
            }
        }
    }
@@ -3726,7 +3691,7 @@ static void convertOutputBuffer(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ,
    const int16_t cldfb_in,
    HANDLE_CLDFB_FILTER_BANK *cldfbSyn
    IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn
#endif
)
{
@@ -3739,15 +3704,15 @@ static void convertOutputBuffer(
    if ( cldfb_in )
    {
        int16_t slotIdx, numCldfbBands, numPcmSamples, b;
        float fIn[MAX_OUTPUT_CHANNELS][L_FRAME48k];
        float re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE];
        float re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX];
        float im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX];
        numPcmSamples = numSamplesPerChannel >> 1;
        numCldfbBands = numPcmSamples / CLDFB_NO_COL_MAX;
        numCldfbBands = numPcmSamples / IVAS_CLDFB_NO_COL_MAX;
        /* CLDFB Synthesis*/
        for ( chnl = 0; chnl < numChannels; ++chnl )
        {
            for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ )
            for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ )
            {
                for ( b = 0; b < numCldfbBands; b++ )
                {
@@ -3760,16 +3725,16 @@ static void convertOutputBuffer(
        /* Implement CLDFB synthesis */
        for ( chnl = 0; chnl < numChannels; ++chnl )
        {
            float *RealBuffer[CLDFB_NO_COL_MAX];
            float *ImagBuffer[CLDFB_NO_COL_MAX];
            float *RealBuffer[IVAS_CLDFB_NO_COL_MAX];
            float *ImagBuffer[IVAS_CLDFB_NO_COL_MAX];

            for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ )
            for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ )
            {
                RealBuffer[slotIdx] = re[chnl][slotIdx];
                ImagBuffer[slotIdx] = im[chnl][slotIdx];
            }

            cldfbSynthesis( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * CLDFB_NO_COL_MAX, cldfbSyn[chnl] );
            IVAS_REND_cldfbSynthesis_wrapper( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * IVAS_CLDFB_NO_COL_MAX, cldfbSyn[chnl] );
        }
        for ( smpl = 0; smpl < numPcmSamples; ++smpl )
        {
@@ -3789,13 +3754,13 @@ static void convertOutputBuffer(
            {
                temp = floatBuffer[chnl * numSamplesPerChannel + smpl];
                temp = (float) floor( temp + 0.5f );
                if ( temp > MAX16B_FLT )
                if ( temp > IVAS_MAX16B_FLT )
                {
                    temp = MAX16B_FLT;
                    temp = IVAS_MAX16B_FLT;
                }
                else if ( temp < MIN16B_FLT )
                else if ( temp < IVAS_MIN16B_FLT )
                {
                    temp = MIN16B_FLT;
                    temp = IVAS_MIN16B_FLT;
                }
                intBuffer[i] = (int16_t) temp;

+11 −2
Original line number Diff line number Diff line
@@ -44,13 +44,19 @@
 * 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 / 50 )
#define IVAS_MAX_NUM_OBJECTS        4
#define IVAS_MAX_INPUT_CHANNELS     16
#define IVAS_MAX_OUTPUT_CHANNELS    16
#define IVAS_CLDFB_NO_CHANNELS_MAX  ( 60 )
#define IVAS_CLDFB_NO_COL_MAX       16
#define IVAS_CLDFB_NO_CHANNELS_MAX  60
#define IVAS_MAX_INPUT_LFE_CHANNELS 4

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


/*----------------------------------------------------------------------------------*
@@ -147,6 +153,9 @@ typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE;
typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE;

typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE;


#if defined( DEBUGGING ) || defined( SPLIT_REND_WITH_HEAD_ROT ) // TODO needs refactoring to a separate enum for split rendering
typedef enum
{
Loading