Commit dcc55520 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

split binaural rendering with fast conv renderer

parent 48dc0fbd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@
    </CustomBuildStep>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_util;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MinimalRebuild>false</MinimalRebuild>
      <ExceptionHandling />
@@ -97,7 +97,7 @@
    </CustomBuildStep>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_util;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(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_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_util;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <ExceptionHandling />
+5 −0
Original line number Diff line number Diff line
@@ -200,6 +200,11 @@
    <ClCompile Include="..\lib_rend\ivas_sba_rendering.c" />
    <ClCompile Include="..\lib_rend\ivas_allrad_dec.c" />
    <ClCompile Include="..\lib_rend\ivas_binauralRenderer.c" />
    <ClCompile Include="..\lib_rend\ivas_splitRendererPre.c" />
    <ClCompile Include="..\lib_rend\ivas_splitRendererPost.c" />
    <ClCompile Include="..\lib_rend\ivas_splitRenderer_utils.c" /> 
    <ClCompile Include="..\lib_rend\ivas_splitRend_lcld_enc.c" />
    <ClCompile Include="..\lib_rend\ivas_splitRend_lcld_dec.c" />    
    <ClCompile Include="..\lib_rend\ivas_binaural_reverb.c" />
    <ClCompile Include="..\lib_rend\ivas_crend.c" />
    <ClCompile Include="..\lib_rend\ivas_efap.c" />
+178 −8
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ static
#define MAX_NUM_OUTPUT_CHANNELS    16
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE )

#ifdef SPLIT_REND_WITH_HEAD_ROT
#define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( 3750 ) /*temp buffer size for 1.5 mbps*/
#endif

#define IVAS_PUBLIC_ORIENT_TRK_REF 0
#define IVAS_PUBLIC_ORIENT_TRK_AVG 1

@@ -114,7 +118,10 @@ typedef struct
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
#endif

#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
    IVAS_SPLIT_REND_MODE splitRendMode;
    char *postRendheadrotTrajFileName;
#endif

} DecArguments;
@@ -126,7 +133,13 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader,
#ifdef SPLIT_REND_WITH_HEAD_ROT
                              HeadRotFileReader *postRendheadRotReader,
                              uint8_t *splitRendBitsBuf,
#endif
                              IVAS_DEC_HANDLE hIvasDec,
                              int16_t *pcmBuf );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
#ifdef DEBUGGING
static int16_t app_own_random( int16_t *seed );
@@ -186,8 +199,14 @@ int main(
    LsCustomFileReader *hLsCustomReader = NULL;
    hrtfFileReader *hrtfReader = NULL;
    HeadRotFileReader *headRotReader = NULL;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    HeadRotFileReader *postRendheadRotReader = NULL;
#endif
    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];
#endif
    RenderConfigReader *renderConfigReader = NULL;
#ifdef DEBUGGING
    int32_t noClipping;
@@ -284,6 +303,16 @@ int main(
            goto cleanup;
        }
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.splitRendMode == SPLIT_REND_COMB )
    {
        if ( ( error = HeadRotationFileReader_open( arg.postRendheadrotTrajFileName, &postRendheadRotReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open post renderer head-rotation file %s \n\n", arg.postRendheadrotTrajFileName );
            goto cleanup;
        }
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Open custom loudspeaker layout file
@@ -316,9 +345,18 @@ int main(
     *------------------------------------------------------------------------------------------*/

#ifdef DEBUGGING
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation,
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                       arg.splitRendMode,
#endif
                                       arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                       ,
                                       arg.enableSplitRendWithHeadRot
#endif
                                       ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -507,7 +545,11 @@ int main(
    }
    else
    {
        error = decodeG192( arg, hBsReader, headRotReader, hIvasDec, pcmBuf );
        error = decodeG192( arg, hBsReader, headRotReader,
#ifdef SPLIT_REND_WITH_HEAD_ROT
                            postRendheadRotReader, splitRendBitsBuf,
#endif
                            hIvasDec, pcmBuf );
    }

    if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -554,7 +596,9 @@ cleanup:
    CustomLsReader_close( &hLsCustomReader );
    hrtfFileReader_close( &hrtfReader );
    HeadRotationFileReader_close( &headRotReader );

#ifdef SPLIT_REND_WITH_HEAD_ROT
    HeadRotationFileReader_close( &postRendheadRotReader );
#endif
    RenderConfigReader_close( &renderConfigReader );

    if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK )
@@ -666,6 +710,43 @@ static IVAS_DEC_AUDIO_CONFIG cmdline2config(
}


#ifdef SPLIT_REND_WITH_HEAD_ROT
static int8_t parseSplitRendMode(
    char *value,
    IVAS_SPLIT_REND_MODE *SplitRendMode )
{
    int16_t temp;
    int8_t success;
    success = 1;
    to_upper( value );

    temp = (int16_t) atoi( value );
    if ( temp == 0 )
    {
        *SplitRendMode = SPLIT_REND_DISABLED;
    }
#if 0
    else if ( temp == 1 )
    {
        *SplitRendMode = SPLIT_REND_PRE;
    }
    else if ( temp == 2 )
    {
        *SplitRendMode = SPLIT_REND_POST;
    }
#endif
    else if ( temp == 3 )
    {
        *SplitRendMode = SPLIT_REND_COMB;
    }
    else
    {
        fprintf( stderr, "Error: Incorrect or unsupported value for split rendering mode specified!\n\n" );
        success = 0;
    }
    return success ? 0 : -1;
}
#endif
/*---------------------------------------------------------------------*
 * parseCmdlIVAS_dec()
 *
@@ -698,6 +779,10 @@ static bool parseCmdlIVAS_dec(

    arg->enableHeadRotation = false;
    arg->headrotTrajFileName = NULL;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    arg->postRendheadrotTrajFileName = NULL;
#endif

    arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF;

#ifdef SUPPORT_JBM_TRACEFILE
@@ -720,6 +805,10 @@ static bool parseCmdlIVAS_dec(
    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
    arg->no_diegetic_pan = 0.f;

#ifdef SPLIT_REND_WITH_HEAD_ROT
    arg->splitRendMode = SPLIT_REND_DISABLED;
#endif

    /*-----------------------------------------------------------------*
     * Initialization
     *-----------------------------------------------------------------*/
@@ -871,6 +960,41 @@ static bool parseCmdlIVAS_dec(
            arg->headrotTrajFileName = argv[i];
            i++;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        else if ( strcmp( argv_to_upper, "-SBRM" ) == 0 )
        {
            i++;

            if ( argc - i <= 4 || argv[i][0] == '-' )
            {
                fprintf( stderr, "Error: Head rotation file name not specified!\n\n" );
                usage_dec();
                return false;
            }
            if ( parseSplitRendMode( argv[i], &arg->splitRendMode ) != 0 )
            {
                fprintf( stderr, "Error: Invalid split rendering mode %s \n\n", argv[i] );
                usage_dec();
                return false;
            }
            i++;
        }
        else if ( strcmp( argv_to_upper, "-PRTF" ) == 0 )
        {
            arg->enableHeadRotation = true;
            i++;

            if ( argc - i <= 4 || argv[i][0] == '-' )
            {
                fprintf( stderr, "Error: Head rotation file name not specified!\n\n" );
                usage_dec();
                return false;
            }

            arg->postRendheadrotTrajFileName = argv[i];
            i++;
        }
#endif
        else if ( strcmp( argv_to_upper, "-OTR" ) == 0 )
        {
            if ( strlen( argv[i + 1] ) > 3 )
@@ -1079,6 +1203,10 @@ static void usage_dec( void )
    fprintf( stdout, "                      which of the two supported formats is in use.\n" );
    fprintf( stdout, "                      default bitstream file format is G.192\n" );
    fprintf( stdout, "-T File             : Head rotation specified by external trajectory File\n" );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    fprintf( stdout, "-sbrm mode          : split rendering mode (0 - disabled, 1 - PRE RENDERER, 2 - POST RENDERER, 3 - COMBINED PRE-POST RENDERING), by default disabled\n" );
    fprintf( stdout, "-prtf File          : Head rotation for post renderer specified by external trajectory File (to be used with split rendering)\n" );
#endif
    fprintf( stdout, "-hrtf File          : HRTF filter File used in ISm format and BINAURAL output configuration\n" );
#ifdef DEBUGGING
    fprintf( stdout, "-force_subframe_bin : Forces parametric binauralizer code to use 5 ms time resolution even when\n" );
@@ -1126,6 +1254,10 @@ static ivas_error decodeG192(
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
    HeadRotFileReader *headRotReader,
#ifdef SPLIT_REND_WITH_HEAD_ROT
    HeadRotFileReader *postRendheadRotReader,
    uint8_t *splitRendBitsBuf,
#endif
    IVAS_DEC_HANDLE hIvasDec,
    int16_t *pcmBuf )

@@ -1151,6 +1283,10 @@ static ivas_error decodeG192(
    uint16_t numObj = 0;
    IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;

#ifdef SPLIT_REND_WITH_HEAD_ROT
    IVAS_SPLIT_REND_BITS splitRendBits;
#endif

    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
@@ -1172,6 +1308,13 @@ 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;
#endif

    /*------------------------------------------------------------------------------------------*
     * Loop for every packet (frame) of bitstream data
     * - Read the bitstream packet
@@ -1226,15 +1369,42 @@ static ivas_error decodeG192(
                goto cleanup;
            }

            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                       ,
                                                       SPLIT_REND_PRE
#endif
                                                       ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( arg.splitRendMode == SPLIT_REND_COMB )
            {
                if ( ( error = HeadRotationFileReading( postRendheadRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError %s while reading post rendering head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                    goto cleanup;
                }

                if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions, SPLIT_REND_POST ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            }
#endif
        }

        /* Run decoder for one frame (get rendered output) */
        if ( ( error = IVAS_DEC_GetSamples( hIvasDec, pcmBuf, &nOutSamples ) ) != IVAS_ERR_OK )
        if ( ( error = IVAS_DEC_GetSamples( hIvasDec, pcmBuf, &nOutSamples
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                            ,
                                            &splitRendBits
#endif
                                            ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: could not get samples from decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
+274 −16

File changed.

Preview size limit exceeded, changes collapsed.

+19 −0
Original line number Diff line number Diff line
@@ -83,6 +83,16 @@ typedef struct

} IVAS_QUATERNION;

#ifdef SPLIT_REND_WITH_HEAD_ROT
typedef struct ivas_split_rend_bits_t
{
    uint8_t *bits_buf;
    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;
} ivas_split_rend_bits_t, IVAS_SPLIT_REND_BITS, *IVAS_SPLIT_REND_BITS_HANDLE;
#endif

typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE;
typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE;

@@ -146,5 +156,14 @@ typedef struct _IVAS_JBM_TRACE_DATA

} IVAS_JBM_TRACE_DATA;

#ifdef SPLIT_REND_WITH_HEAD_ROT
typedef enum _IVAS_SPLIT_REND_MODE
{
    SPLIT_REND_DISABLED = -1,
    SPLIT_REND_PRE,
    SPLIT_REND_POST,
    SPLIT_REND_COMB
} IVAS_SPLIT_REND_MODE;
#endif

#endif /* COMMON_API_TYPES_H */
Loading