Commit a2f5686f authored by sagnowski's avatar sagnowski
Browse files

Contribution 35 - LC3plus split rendering with head pose correction

parent a71af78c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ external-renderer-cmake-asan-pytest:
  needs: ["build-codec-linux-cmake"]
  stage: test
  script:
    - python3 ci/disable_ram_counting.py
    - python3 ci/comment_defines.py -d RAM_COUNTING_TOOL -f lib_com/options.h
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
@@ -373,7 +373,7 @@ external-renderer-cmake-msan-pytest:
  needs: ["build-codec-linux-cmake"]
  stage: test
  script:
    - python3 ci/disable_ram_counting.py
    - python3 ci/comment_defines.py -d RAM_COUNTING_TOOL -f lib_com/options.h
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan  -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
+22 −3
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ file(GLOB libComSrcs "lib_com/*.c")
file(GLOB libComHeaders "lib_com/*.h")
add_library(lib_com ${libComSrcs} ${libComHeaders})
if(UNIX)
  target_link_libraries(lib_com m)
  target_link_libraries(lib_com PRIVATE m)
endif()

file(GLOB libDebugSrcs "lib_debug/*.c")
@@ -142,10 +142,24 @@ file(GLOB libEncHeaders "lib_enc/*.h")
add_library(lib_enc ${libEncSrcs} ${libEncHeaders})
target_link_libraries(lib_enc lib_com lib_debug)

set(lc3plus_floating_point_dir ${CMAKE_CURRENT_SOURCE_DIR}/lib_rend/lc3plus_codec/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point)
if(NOT EXISTS ${lc3plus_floating_point_dir})
  MESSAGE(FATAL_ERROR "${lc3plus_floating_point_dir} does not exist. Please follow instructions in lib_rend/lc3plus_codec/README.md and download the LC3plus codec")
endif()
file(GLOB libLC3plusSrcs    "${lc3plus_floating_point_dir}/*.c")
file(GLOB libLC3plusHeaders "${lc3plus_floating_point_dir}/*.h")
file(GLOB libLC3plusFftSrcs    "${lc3plus_floating_point_dir}/fft/*.c")
file(GLOB libLC3plusFftHeaders "${lc3plus_floating_point_dir}/fft/*.h")
add_library(lc3plus ${libLC3plusSrcs} ${libLC3plusFftSrcs}  ${libLC3plusHeaders} ${libLC3plusFftHeaders})
target_include_directories(lc3plus PUBLIC ${floating_point_dir} PRIVATE ${floating_point_dir}/fft )

file(GLOB libCldfbTransCodecSrcs "lib_rend/ivas_cldfb_trans_codec/*.c")
file(GLOB libCldfbTransCodecHeaders "lib_rend/ivas_cldfb_trans_codec/*.h")
file(GLOB libRendSrcs "lib_rend/*.c")
file(GLOB libRendHeaders "lib_rend/*.h")
add_library(lib_rend ${libRendSrcs} ${libRendHeaders})
target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed.
add_library(lib_rend ${libRendSrcs} ${libCldfbTransCodecSrcs}  ${libRendHeaders}  ${libCldfbTransCodecHeaders})
target_link_libraries(lib_rend lib_dec lib_com lib_debug lc3plus) # Todo refactor: This dependency on lib_dec should be removed.


file(GLOB libDecSrcs "lib_dec/*.c")
file(GLOB libDecHeaders "lib_dec/*.h")
@@ -161,6 +175,10 @@ file(GLOB unitTestCRendHeaders "scripts/ivas_pytests/tests/unit_tests/crend/*.h"
add_executable(IVAS_crend_unit_test ${unitTestCRendSrcs} ${unitTestCRendHeaders})
target_link_libraries(IVAS_crend_unit_test lib_rend lib_dec lib_util lib_com lib_debug)

file(GLOB unitTestIvasLc3plusSrcs "scripts/split_rendering/lc3plus/*.c")
add_executable(ivas_lc3plus_unit_test ${unitTestIvasLc3plusSrcs})
target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_debug)

add_executable(renderer_standalone "scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c")
target_link_libraries(renderer_standalone lib_rend lib_dec lib_util lib_com lib_debug)

@@ -186,4 +204,5 @@ if(COPY_EXECUTABLES_FROM_BUILD_DIR)
  add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:IVAS_rend>" "${CMAKE_CURRENT_SOURCE_DIR}/")
  add_custom_command(TARGET IVAS_crend_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:IVAS_crend_unit_test>" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/ivas_pytests/tests/unit_tests/crend/")
  add_custom_command(TARGET renderer_standalone POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:renderer_standalone>" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/td_object_renderer/object_renderer_standalone/")
  add_custom_command(TARGET ivas_lc3plus_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:ivas_lc3plus_unit_test>" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/split_rendering/lc3plus")
endif()
+12 −2
Original line number Diff line number Diff line
@@ -1384,7 +1384,12 @@ static ivas_error decodeG192(
                        IVAS_SPLIT_REND_BITS 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 ) != IVAS_ERR_OK )
                        if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written
#ifdef SPLIT_REND_LC3PLUS
                                                                 ,
                                                                 0
#endif
                                                                 ) != IVAS_ERR_OK )
                        {
                            fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                            exit( -1 );
@@ -1517,7 +1522,12 @@ static ivas_error decodeG192(
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( hSplitRendFileReadWrite != NULL )
            {
                if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written ) != IVAS_ERR_OK )
                if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written
#ifdef SPLIT_REND_LC3PLUS
                                                         ,
                                                         splitRendBits.codec
#endif
                                                         ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                    exit( -1 );
+13 −3
Original line number Diff line number Diff line
@@ -706,7 +706,7 @@ static int16_t get_cldfb_in_flag( IVAS_REND_AudioConfig audioConfig, IVAS_RENDER
#ifdef DEBUGGING
        cldfb_in = 1;
#endif
        if ( ( audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) )
        if ( audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
        {
            cldfb_in = 1;
        }
@@ -1237,7 +1237,12 @@ int main(
        {
            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 );
            error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten
#ifdef SPLIT_REND_LC3PLUS
                                                        ,
                                                        &bitsBuffer.config.codec
#endif
            );
            if ( error_tmp != IVAS_ERR_OK )
            {
                if ( error_tmp == IVAS_ERR_END_OF_FILE )
@@ -1463,7 +1468,12 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
        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 ) != IVAS_ERR_OK )
            if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten
#ifdef SPLIT_REND_LC3PLUS
                                                     ,
                                                     bitsBuffer.config.codec
#endif
                                                     ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                exit( -1 );

ci/comment_defines.py

0 → 100755
+47 −0
Original line number Diff line number Diff line
import re
import argparse


def process_file(file_path: str, defines_re):
    with open(file_path, "r", encoding="utf-8") as file:
        lines = file.readlines()

    num_subbed = dict()
    for name in defines_re.keys():
        num_subbed[name] = 0

    for i, line in enumerate(lines):
        for name, regex in defines_re.items():
            # Spaces are replaced with underscores to avoid matching on multiple runs
            lines[i] = regex.sub(lambda x: f"/* {x.group(0).replace(' ', '_')} */", line)

            if lines[i] != line:
                num_subbed[name] += 1

    with open(file_path, "w", encoding="utf-8") as file:
        file.writelines(lines)

    print(f"Processed {file_path}")
    for name, num in num_subbed.items():
        print(f"{name} - {num} occurences commented")
    print("")


def compile_define_re(define_name: str) -> re.Pattern[str]:
    return re.compile(f"#define\\s+{define_name}")


def main(args):
    defines_re = dict()
    for define_name in args.defines:
        defines_re[define_name] = compile_define_re(define_name)

    for file_path in args.files:
        process_file(file_path, defines_re)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Comment out preprocessor defines in c/c++ files")
    parser.add_argument("-f", "--files", nargs="+", required=True, type=str)
    parser.add_argument("-d", "--defines", nargs="+", required=True, type=str)
    main(parser.parse_args())
Loading