From dc2a9320b00f8ebc5c9f5e429c4fff799cc719af Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 17 Nov 2022 17:37:03 +0100 Subject: [PATCH 01/11] [cleanup] remove standalone renderer binaries and related files - remove DEC_TO_REND_FLOAT_DUMP and renderer vs decoder test - update test_renderer.py to run only a subset of tests (first version, test_renderer_be_comparison.py already tests exhaustively) --- .gitlab-ci.yml | 26 +- CMakeLists.txt | 14 - Makefile | 29 +- apps/renderer.c | 18 - lib_com/ivas_tools.c | 10 - scripts/ivas_pytests/build_all.bat | 7 - scripts/ivas_pytests/build_all.sh | 4 - scripts/ivas_pytests/clean_all.bat | 7 - scripts/ivas_pytests/clean_all.sh | 3 - scripts/ivas_pytests/disable_lib_com_optim.py | 23 - scripts/ivas_pytests/endofline.py | 26 - .../tests/unit_tests/crend/build.bat | 1 - .../tests/unit_tests/crend/clean.bat | 1 - .../unit_tests/crend/ivas_crend_io_parse.h | 128 -- .../unit_tests/crend/ivas_crend_public.h | 85 - .../unit_tests/crend/ivas_crend_unit_test.c | 729 ------- .../unit_tests/crend/ivas_crend_unit_test.h | 57 - .../unit_tests/crend/ivas_crend_unit_test.sln | 68 - .../crend/ivas_crend_unit_test.vcxproj | 195 -- .../unit_tests/crend/ivas_crend_utest_utils.c | 1800 ----------------- .../unit_tests/crend/ivas_dec_parse_io.h | 136 -- .../tests/unit_tests/crend/ivas_prox_mix.c | 229 --- .../tests/unit_tests/crend/ivas_prox_mix.h | 71 - .../tests/unit_tests/crend/ivas_result_t.h | 56 - .../disabled_test_crend_unittest.py | 576 ------ .../object_renderer_standalone/Makefile | 184 -- .../object_renderer_standalone.sln | 68 - .../object_renderer_standalone.vcxproj | 121 -- ...object_renderer_standalone.vcxproj.filters | 22 - .../renderer_standalone.c | 603 ------ tests/renderer/README.md | 18 +- tests/renderer/constants.py | 231 +-- .../renderer/run_test_renderer_vs_decoder.sh | 10 - tests/renderer/test_renderer.py | 117 +- tests/renderer/test_renderer_vs_decoder.py | 128 -- tests/renderer/utils.py | 250 +-- 36 files changed, 62 insertions(+), 5989 deletions(-) delete mode 100644 scripts/ivas_pytests/build_all.bat delete mode 100755 scripts/ivas_pytests/build_all.sh delete mode 100644 scripts/ivas_pytests/clean_all.bat delete mode 100755 scripts/ivas_pytests/clean_all.sh delete mode 100755 scripts/ivas_pytests/disable_lib_com_optim.py delete mode 100755 scripts/ivas_pytests/endofline.py delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/build.bat delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/clean.bat delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.h delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.sln delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_dec_parse_io.h delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h delete mode 100644 scripts/ivas_pytests/tests/unit_tests/crend/ivas_result_t.h delete mode 100644 scripts/ivas_pytests/tests/unit_tests/disabled_test_crend_unittest.py delete mode 100644 scripts/td_object_renderer/object_renderer_standalone/Makefile delete mode 100644 scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.sln delete mode 100644 scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj delete mode 100644 scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj.filters delete mode 100644 scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c delete mode 100755 tests/renderer/run_test_renderer_vs_decoder.sh delete mode 100644 tests/renderer/test_renderer_vs_decoder.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49ff0c6df1..62554b51a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -321,7 +321,7 @@ asan-on-merge-request-linux: expose_as: "Asan selftest results" # test external renderer executable -external-renderer-make-pytest: +external-renderer-pytest: extends: - .test-job-linux - .rules-merge-request @@ -329,8 +329,6 @@ external-renderer-make-pytest: stage: test script: - make -j IVAS_rend - - make -j unittests - - make -j --directory scripts/td_object_renderer/object_renderer_standalone - python3 -m pytest -q --log-level ERROR -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" @@ -386,28 +384,6 @@ external-renderer-cmake-msan-pytest: junit: - report-junit.xml -# test external renderer executable with cmake vs decoder renderer -# TODO @tmu @knj @sgi -> converted to script, decide whether to re-enable later -.external-renderer-cmake-vs-decoder-pytest: - extends: - - .test-job-linux - - .rules-merge-request - needs: ["build-codec-linux-cmake"] - stage: test - script: - - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true -DDEC_TO_REND_FLOAT_DUMP=true - - cmake --build cmake-build -- -j - - python3 -m pytest -q --log-level ERROR -n 1 -rA --junit-xml=report-junit.xml tests/renderer/test_renderer_vs_decoder.py - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - when: always - paths: - - report-junit.xml - expose_as: "external renderer cmake vs decoder results" - reports: - junit: - - report-junit.xml - # compare external renderer bitexactness between target and source branch external-renderer-pytest-on-merge-request: extends: diff --git a/CMakeLists.txt b/CMakeLists.txt index 317274ddce..ef64721d2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,10 +108,6 @@ if(WMOPS) add_definitions("-DWMOPS=1") endif() -if(DEC_TO_REND_FLOAT_DUMP) - add_compile_definitions(DEC_TO_REND_FLOAT_DUMP) -endif() - project(stereo-evs) set_property(GLOBAL PROPERTY USE_FOLDERS ON) # make Visual Studio projects look nicer include(CTest) @@ -156,14 +152,6 @@ file(GLOB libUtilSrcs "lib_util/*.c") file(GLOB libUtilHeaders "lib_util/*.h") add_library(lib_util ${libUtilSrcs} ${libUtilHeaders}) -file(GLOB unitTestCRendSrcs "scripts/ivas_pytests/tests/unit_tests/crend/*.c") -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) - -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) - add_executable(IVAS_cod apps/encoder.c) target_link_libraries(IVAS_cod lib_enc lib_util) if(WIN32) @@ -184,6 +172,4 @@ if(COPY_EXECUTABLES_FROM_BUILD_DIR) add_custom_command(TARGET IVAS_cod POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET IVAS_dec POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") - add_custom_command(TARGET IVAS_crend_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${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 "$" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/td_object_renderer/object_renderer_standalone/") endif() diff --git a/Makefile b/Makefile index 141a607b07..40508621af 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,6 @@ SRC_APP = apps BUILD = build OBJDIR = obj -# Dirs for python unittests -UTESTS_SCRIPT_DIR = scripts/ivas_pytests -UTESTS_DIR = $(UTESTS_SCRIPT_DIR)/tests/unit_tests -UTESTS_CREND_DIR = $(UTESTS_DIR)/crend - -# Source paths for python unittests -SRC_UTESTS = $(UTESTS_CREND_DIR) - - SRC_DIRS = $(sort -u $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBUTIL) $(SRC_APP) $(SRC_UTESTS)) # Name of CLI binaries @@ -33,8 +24,6 @@ LIB_LIBENC ?= libivasenc.a LIB_LIBREND ?= libivasrend.a LIB_LIBUTIL ?= libivasutil.a -CLI_UTESTS_CREND ?= IVAS_crend_unit_test - # Default tool settings CC ?= gcc RM ?= rm -f @@ -131,8 +120,6 @@ SRCS_LIBENC = $(foreach DIR,$(SRC_LIBENC),$(patsubst $(DIR)/%,%,$(wildcard $(D SRCS_LIBREND = $(foreach DIR,$(SRC_LIBREND),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) SRCS_LIBUTIL = $(foreach DIR,$(SRC_LIBUTIL),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) -SRCS_UTESTS_CREND = $(foreach DIR,$(UTESTS_CREND_DIR),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) - OBJS_LIBCOM = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.o)) OBJS_LIBDEBUG = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEBUG:.c=.o)) OBJS_LIBDEC = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEC:.c=.o)) @@ -143,11 +130,6 @@ OBJS_CLI_APIDEC = $(OBJDIR)/decoder.o OBJS_CLI_APIENC = $(OBJDIR)/encoder.o OBJS_CLI_APPREND = $(OBJDIR)/renderer.o -OBJS_CLI_UTESTS_CREND = $(addprefix $(OBJDIR)/,$(SRCS_UTESTS_CREND:.c=.o)) - -OBJS_UTESTS = $(OBJS_CLI_UTESTS_CREND) - - DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.P) $(SRCS_LIBDEBUG:.c=.P) $(SRCS_LIBDEC:.c=.P) \ $(SRCS_LIBENC:.c=.P) $(SRCS_LIBUTIL:.c=.P)) @@ -187,23 +169,14 @@ $(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(L $(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -livasdec -livasutil -livasdebug -livascom $(LDLIBS) -o $(CLI_APIREND) -$(CLI_UTESTS_CREND): $(OBJS_CLI_UTESTS_CREND) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_UTESTS_CREND) -L. -livasdec -livascom -livasutil -livasdebug $(LDLIBS) -o $(UTESTS_CREND_DIR)/$(CLI_UTESTS_CREND) - -unittests: $(CLI_UTESTS_CREND) - libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBUTIL) -clean: clean_unittests +clean: $(QUIET)$(RM) $(OBJS_LIBENC) $(OBJS_LIBDEC) $(DEPS) $(QUIET)$(RM) $(DEPS:.P=.d) $(QUIET)test ! -d $(OBJDIR) || rm -rf $(OBJDIR) $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) -clean_unittests: - $(QUIET)$(RM) $(OBJS_UTESTS) - $(QUIET)$(RM) $(UTESTS_CREND_DIR)/$(CLI_UTESTS_CREND) - $(OBJDIR)/%.o : %.c | $(OBJDIR) $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $< @cp $(OBJDIR)/$*.d $(OBJDIR)/$*.P; \ diff --git a/apps/renderer.c b/apps/renderer.c index 0d46dd05f4..edb1c67a1d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -834,10 +834,6 @@ int main( fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); exit( -1 ); } -#ifdef DEC_TO_REND_FLOAT_DUMP - printf( "Warning: Renderer executable built with DEC_TO_REND_FLOAT_DUMP enabled!\n" ); - printf( " Float dump file (./float_out.wav) will be forced as input.\n" ); -#endif inBufferSize = frameSize_smpls * totalNumInChannels; outBufferSize = frameSize_smpls * numOutChannels; @@ -888,20 +884,6 @@ int main( /* Convert from int to float and from interleaved to packed */ convertInputBuffer( inpInt16Buffer, numSamplesRead, frameSize_smpls, num_in_channels, inFloatBuffer ); -#ifdef DEC_TO_REND_FLOAT_DUMP - /* Overwrite from dump file */ - float tmp[960 * 16]; - dbgread( tmp, sizeof( float ), numSamplesRead, "./float_out.raw" ); - - /* Conversion from interleaved to packed still necessary */ - for ( int32_t i = 0; i < numSamplesRead / num_in_channels; ++i ) - { - for ( int32_t c = 0; c < num_in_channels; ++c ) - { - inFloatBuffer[c * frameSize_smpls + i] = tmp[i * num_in_channels + c]; - } - } -#endif #ifndef NOKIA_MASA_EXTERNAL_RENDERER for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index b8fbaa833f..3c941ccc77 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -144,16 +144,6 @@ uint32_t ivas_syn_output( } } -#ifdef DEC_TO_REND_FLOAT_DUMP - for ( i = 0; i < output_frame; ++i ) - { - for ( n = 0; n < n_channels; ++n ) - { - dbgwrite( &synth[n][i], sizeof( float ), 1, 1, "./float_out.raw" ); - } - } -#endif - return noClipping; } diff --git a/scripts/ivas_pytests/build_all.bat b/scripts/ivas_pytests/build_all.bat deleted file mode 100644 index 102a370b7f..0000000000 --- a/scripts/ivas_pytests/build_all.bat +++ /dev/null @@ -1,7 +0,0 @@ -cd .\scripts\ivas_pytests\tests\unit_tests\crend -call build.bat || exit /b 1 -cd ..\..\..\..\..\ - -cd .\Workspace_msvc -MSBuild.exe Workspace_msvc.sln /property:Configuration=Release /p:Platform="Win32" || exit /b 1 -cd ..\ diff --git a/scripts/ivas_pytests/build_all.sh b/scripts/ivas_pytests/build_all.sh deleted file mode 100755 index d0ee9cf858..0000000000 --- a/scripts/ivas_pytests/build_all.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/bash - -make -f Makefile all || exit -make -f Makefile unittests || exit diff --git a/scripts/ivas_pytests/clean_all.bat b/scripts/ivas_pytests/clean_all.bat deleted file mode 100644 index 1f5c18f21d..0000000000 --- a/scripts/ivas_pytests/clean_all.bat +++ /dev/null @@ -1,7 +0,0 @@ -cd .\Workspace_msvc -MSBuild.exe Workspace_msvc.sln /t:Clean /p:configuration=Release || exit /b 1 -cd ..\ - -cd .\scripts\ivas_pytests\tests\unit_tests\crend -call clean.bat -cd ..\..\..\..\..\ diff --git a/scripts/ivas_pytests/clean_all.sh b/scripts/ivas_pytests/clean_all.sh deleted file mode 100755 index 1af6eb498f..0000000000 --- a/scripts/ivas_pytests/clean_all.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -make -f Makefile clean diff --git a/scripts/ivas_pytests/disable_lib_com_optim.py b/scripts/ivas_pytests/disable_lib_com_optim.py deleted file mode 100755 index 6704b6d81a..0000000000 --- a/scripts/ivas_pytests/disable_lib_com_optim.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -""" -Disable optimization in vcxproj file for lib_com. -""" - -import fileinput -import sys -from pathlib import Path - -HERE = Path(__file__).parent.resolve() -LIB_COM_PROJECT_FILE = str(HERE.joinpath("../../Workspace_msvc/lib_com.vcxproj")) - - -def replace_config(file, search_text, replace_text): - for line in fileinput.input(file, inplace=1): - if search_text in line: - line = line.replace(search_text, replace_text) - sys.stdout.write(line) - - -TXT_OLD = "MaxSpeed" -TXT_NEW = "Disabled" -replace_config(LIB_COM_PROJECT_FILE, TXT_OLD, TXT_NEW) diff --git a/scripts/ivas_pytests/endofline.py b/scripts/ivas_pytests/endofline.py deleted file mode 100755 index c012e1e7ce..0000000000 --- a/scripts/ivas_pytests/endofline.py +++ /dev/null @@ -1,26 +0,0 @@ -import glob - -def add_newline(filename): - fixed = 0 - with open(filename, "r") as f: - lines = f.readlines() - f.close() - if lines: - last_char = lines[-1][-1] - if last_char != '\n': - fixed = 1 - print( filename+ ": Missing newline at end of file" ) - # append newline - f = open(filename, "a") - f.write("\n") - f.close() - return fixed - -#for name in glob.glob(join("./**/*.h", "./**/*.c"), recursive=True): -count = 0 -count_fixed = 0 -for name in glob.glob("./**/*.[h|c]", recursive=True): - count+=1 - count_fixed += add_newline(name) -print(count, "processed files") -print(count_fixed, "fixed files") \ No newline at end of file diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/build.bat b/scripts/ivas_pytests/tests/unit_tests/crend/build.bat deleted file mode 100644 index 2cf3a27265..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/build.bat +++ /dev/null @@ -1 +0,0 @@ -MSBuild.exe ivas_crend_unit_test.sln /property:Configuration=Release /p:Platform="Win32" \ No newline at end of file diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/clean.bat b/scripts/ivas_pytests/tests/unit_tests/crend/clean.bat deleted file mode 100644 index c535a2cc62..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/clean.bat +++ /dev/null @@ -1 +0,0 @@ -MSBuild.exe ivas_crend_unit_test.sln /t:Clean /p:configuration=Release /p:Platform="Win32" \ No newline at end of file diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h deleted file mode 100644 index bc719cd4a6..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h +++ /dev/null @@ -1,128 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/**************************************************************************** -* File description - -* This source file contains definitions specific to IVAS common renderer -****************************************************************************/ - -#ifndef IVAS_CREND_IO_PARSE_H -#define IVAS_CREND_IO_PARSE_H - -#include "ivas_cnst.h" -#include "audio_file_reader.h" -#include "audio_file_writer.h" -#include - -#define IVAS_IN_FMT_510 "510" -#define IVAS_IN_FMT_710 "710" -#define IVAS_IN_FMT_512 "512" -#define IVAS_IN_FMT_514 "514" -#define IVAS_IN_FMT_714 "714" -#define IVAS_IN_FMT_FOA "HOA1S" - -#define IVAS_MAX_NUM_CH 16 - -#define IVAS_MAX_PATH_LEN ( 2000 ) - -typedef enum ivas_in_out_fmt_struct_t -{ - MONO_1, - STEREO_2, - BIN_2, - FOA_4, - MULT_CH_5_1, - MULT_CH_7_1, - MULT_CH_5_1_2, - MULT_CH_5_1_4, - MULT_CH_7_1_4, - HOA_9, - HOA_16, - OBA, -} ivas_in_out_fmt_t, - IVAS_IN_OUT_FMT_CONFIG; - -#define CREND_MAND_ARGS 6 -/* Tests */ - -typedef enum test_types -{ - CREND_BIN_TEST = 1, - FASTCONV_BIN_TEST, - PARAM_BIN_TEST, - TD_BIN_TEST, - CREND_ACOUSTIC_PROXIMITY, - CREND_TEST_NO_DIEGETIC, - CREND_NUM_TESTS -} test_types; - -typedef struct ivas_crend_sanity_test_inp_t -{ - int32_t inp_len; - int32_t data_ch_idx; -} ivas_crend_sanity_test_inp_t; - -typedef struct ivas_crend_io_params_t -{ - test_types test; - int32_t sample_rate; - ivas_in_out_fmt_t in_fmt; - ivas_in_out_fmt_t out_fmt; -#ifdef USE_PCM_OUT - FILE *fIn[IVAS_MAX_NUM_CH]; - FILE *fOut; - FILE *fRef; -#else - AudioFileReader *fIn[IVAS_MAX_NUM_CH]; - AudioFileWriter *fOut; - AudioFileReader *fRef; -#endif - FILE *fProx; - char ref_path[IVAS_MAX_PATH_LEN]; - char in_path[IVAS_MAX_PATH_LEN]; - char out_path[IVAS_MAX_PATH_LEN]; - char prox_path[IVAS_MAX_PATH_LEN]; - char csv_path[IVAS_MAX_PATH_LEN]; - float latency_s; - int32_t use_brir; - int32_t lfe_lp_enable; - int32_t limiter_enable; - ivas_crend_sanity_test_inp_t sanity_test; - float no_diegetic_pan; - float tol; - int32_t no_delay_cmp; - int16_t renderConfigEnabled; - char renderConfigFilename[IVAS_MAX_PATH_LEN]; - OTR_TRACKING_T orientation_tracking; -} ivas_crend_io_params_t; - -#endif /* IVAS_CREND_IO_PARSE_H */ diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h deleted file mode 100644 index 057cfba10a..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/**************************************************************************** -* File description - -* This source file contains definitions specific to IVAS common renderer -****************************************************************************/ - -#include "ivas_crend_io_parse.h" -#include "ivas_dec_parse_io.h" -#include "ivas_stat_dec.h" -#include "ivas_result_t.h" - -#ifndef IVAS_CREND_PUBLIC_H -#define IVAS_CREND_PUBLIC_H - -#define FAIL 0 -#define PASS 1 - -#define TC_GLFE 1.88364908948980f -#define TC_M3DB 0.707945784384138f -#define TC_M3DB_BY2 ( TC_M3DB * 0.5f ) -#define TC_M6DB 0.501187233627272f -#define TC_TOL 3.05175781250000e-05f -#define TC_GAIN 0.2f - -/* for smart mixing test */ -#define PROXIMITY_USER_ID ( 0 ) - -#define IVAS_CREND_TOT_BIN_SANITY_TESTS ( 10 ) -#define IVAS_CREND_FOA_Z_TO_CHAN_INP_LEN ( 48000 ) -#define IVAS_CREND_CHAN_TO_BIN_INP_LEN ( 1920 ) -#define IVAS_SOFA_THR_VAL ( 1e-15f ) - -AUDIO_CONFIG ivas_crend_map_out_fmt( IVAS_IN_OUT_FMT_CONFIG fmt ); -const char * ivas_crend_map_in_fmt( IVAS_IN_OUT_FMT_CONFIG fmt ); - -ivas_result_t ivas_crend_default_io_params( ivas_crend_io_params_t *pIO_params ); -ivas_result_t ivas_crend_parse_io_params( int argc, char **argv, ivas_crend_io_params_t *pIo_params ); - -void ivas_open_files_ingest( ivas_crend_io_params_t *pIo_params ); -void ivas_open_files_crend( ivas_crend_io_params_t *pIo_params ); - -int16_t ivas_get_num_channels( const int16_t ch_format ); - -ivas_result_t ivas_crend_copy_hrtf_data( HRTFS_DATA *hHrtf, HRTFS_DATA *pCrend_hrtfs ); - -int32_t ivas_wrapper_get_frame_len( int32_t sample_rate ); - -ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, float *mixer ); - -ivas_result_t ivas_object_mixer_renderer( ivas_crend_io_params_t *pIo_params, int16_t *userLoc ); - -ivas_result_t ivas_wav_header_skip( FILE *in_file ); - -#endif /* IVAS_CREND_PUBLIC_H */ diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c deleted file mode 100644 index baa953bc7d..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c +++ /dev/null @@ -1,729 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/**************************************************************************** - * File description - - * This source file contains definitions specific to IVAS common renderer unit tests - ****************************************************************************/ - - -/*------------------------------------------------------------------------------------------* - * include header files - *------------------------------------------------------------------------------------------*/ -#include -#include -#include -#include "options.h" -#include "stdlib.h" -#include "string.h" -#include "ivas_crend_public.h" -#include "ivas_crend_unit_test.h" -#include "ivas_stat_dec.h" -#include "ivas_prox_mix.h" -#include "prot.h" -#include "ivas_prot.h" - -#if defined( __unix__ ) || defined( __unix ) || defined( __APPLE__ ) || defined( __CYGWIN__ ) -#define USE_DIRENT -#endif - -#ifdef USE_DIRENT -#include "dirent.h" -#endif - -#ifdef USE_PCM_OUT -#define FILES_CLOSE \ - if ( NULL != io_params.fIn ) \ - { \ - for ( i = 0; i < IVAS_MAX_NUM_CH; i++ ) \ - { \ - if ( NULL != io_params.fIn[i] ) \ - { \ - fclose( io_params.fIn[i] ); \ - io_params.fIn[i] = NULL; \ - } \ - } \ - } \ - if ( NULL != io_params.fRef ) \ - { \ - if ( NULL != io_params.fRef ) \ - { \ - fclose( io_params.fRef ); \ - io_params.fRef = NULL; \ - } \ - } \ - if ( io_params.fOut != NULL ) \ - { \ - fclose( io_params.fOut ); \ - } -#else -#define FILES_CLOSE \ - if ( NULL != io_params.fIn ) \ - { \ - for ( i = 0; i < IVAS_MAX_NUM_CH; i++ ) \ - { \ - if ( NULL != io_params.fIn[i] ) \ - { \ - AudioFileReader_close( &io_params.fIn[i] ); \ - io_params.fIn[i] = NULL; \ - } \ - } \ - } \ - if ( NULL != io_params.fRef ) \ - { \ - if ( NULL != io_params.fRef ) \ - { \ - AudioFileReader_close( &io_params.fRef ); \ - io_params.fRef = NULL; \ - } \ - } \ - if ( io_params.fOut != NULL ) \ - { \ - AudioFileWriter_close( &io_params.fOut ); \ - } -#endif -/* temp change : to silence the compilation error */ -int32_t frame = 0; /* Counter of frames */ -/*-----------------------------------------------------------------------------------------* - * Function description - - * Reverb test - * - * Inputs - - * ivas_crend_io_params_t io_params - * - * Outputs - - * - * This function is based on a copy of the ivas_crend_test_to_200 - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_crend_reverb_test( ivas_crend_io_params_t *pIo_params ) -{ - - char *test_case; - - if ( pIo_params->in_fmt == MULT_CH_5_1 ) - { - test_case = "CREND_510_TO_200"; - } - else - { - test_case = "CREND_710_TO_200"; - } - - /* Call CREND */ - ivas_common_mixer_renderer( pIo_params, NULL ); - - /* Compare */ - int16_t out, ref, test = PASS; - long long samples = 0; -#ifdef USE_PCM_OUT - fseek( pIo_params->fOut, 0, SEEK_SET ); - /* Compare */ - if ( pIo_params->fRef ) - { - fseek( pIo_params->fRef, 0, SEEK_SET ); - ivas_wav_header_skip( pIo_params->fRef ); - - uint32_t headerOffset = ftell( pIo_params->fRef ); - uint32_t sizeRef = 0; - uint32_t sizeOut = 0; - - fseek( pIo_params->fRef, 0, SEEK_END ); - sizeRef = ftell( pIo_params->fRef ) - headerOffset; - fseek( pIo_params->fRef, headerOffset, SEEK_SET ); - - fseek( pIo_params->fOut, 0, SEEK_END ); - sizeOut = ftell( pIo_params->fOut ); - fseek( pIo_params->fOut, 0, SEEK_SET ); - - /* Comparing the size of test output file with the size of reference file. */ - /* The data length should be identical, when the header size is taken into account. */ - if ( sizeRef != sizeOut ) - { - test = FAIL; - } - if ( test != FAIL ) - { - while ( ( fread( &out, sizeof( int16_t ), 1, pIo_params->fOut ) > 0 ) && ( fread( &ref, sizeof( int16_t ), 1, pIo_params->fRef ) > 0 ) ) - { - if ( fabs( (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ) - (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ) ) > pIo_params->tol ) - { - test = FAIL; - break; - } - samples++; - } - } - - if ( test == PASS ) - { - printf( "%s test PASSED\n\n", test_case ); - } - else - { - printf( "%s test FAILED\n\n", test_case ); - exit( -1 ); - } - } - else - { - printf( "%s test vector GENERATED\n\n", test_case ); - } -#else - AudioFileWriter_close( &pIo_params->fOut ); - AudioFileReader *fOut; - AudioFileReader_open( &fOut , pIo_params->out_path, &pIo_params->sample_rate); - int16_t numRead; - /* Compare */ - if ( pIo_params->fRef ) - { - AudioFileReader_close( &pIo_params->fRef ); - AudioFileReader *fRef; - AudioFileReader_open( &fRef, pIo_params->ref_path, &pIo_params->sample_rate ); - - if ( test != FAIL ) - { - while ( ( AudioFileReader_read( fOut, &out, 1, &numRead ) == IVAS_ERR_OK ) && ( numRead > 0 ) && ( AudioFileReader_read( fRef, &ref, 1, &numRead ) == IVAS_ERR_OK ) && ( numRead > 0 ) ) - { - if ( fabs( (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ) - (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ) ) > pIo_params->tol ) - { - test = FAIL; - break; - } - samples++; - } - } - - if ( test == PASS ) - { - printf( "%s test PASSED\n\n", test_case ); - } - else - { - printf( "%s test FAILED\n\n", test_case ); - exit( -1 ); - } - AudioFileReader_close( &fOut ); - AudioFileReader_close( &fRef ); - } - else - { - printf( "%s test vector GENERATED\n\n", test_case ); - } -#endif - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * common function call for ivas_crend_proximity_test which tests the proximity mixer - * - * Inputs - - * ivas_crend_io_params_t io_params - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_crend_proximity_test( ivas_crend_io_params_t *pIo_params ) -{ - int16_t *userLoc; - int32_t in_ch; -#ifdef USE_PCM_OUT - size_t num; -#else - int16_t num; -#endif - int16_t out = 0, test = PASS; - int16_t ref; - - float out_0f, acc_0f; - - uint8_t bitstream[MAX_BITSTREAM_LEN]; - - assert( pIo_params->in_fmt == OBA ); - assert( pIo_params->out_fmt == MONO_1 ); - - in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - - /* allocate up to in_ch users to userLoc array */ - userLoc = (int16_t *) calloc( in_ch, sizeof( int16_t ) ); - - /* load bitstream data */ - num = (int16_t)fread( bitstream, sizeof( uint8_t ), MAX_BITSTREAM_LEN, pIo_params->fProx ); - - /* using bitstream information fill in the location in the userLoc vector */ - get_users_locations( bitstream, num, userLoc ); - - /* call the object mixer-renderer */ - ivas_object_mixer_renderer( pIo_params, userLoc ); - - free( userLoc ); - -#ifdef USE_PCM_OUT - int32_t i; - for (i = 0; i < in_ch; i++) - { - fseek(pIo_params->fRef, 0, SEEK_SET); - ivas_wav_header_skip(pIo_params->fRef); - } -#endif -#ifdef USE_PCM_OUT - if ( pIo_params->fRef ) - { - fseek( pIo_params->fRef, 0, SEEK_SET ); - fseek( pIo_params->fOut, 0, SEEK_SET ); - if ( strstr( pIo_params->ref_path, ".wav" ) != NULL ) - { - ivas_wav_header_skip( pIo_params->fRef ); - } - while ( 1 ) - { - acc_0f = 0.0f; - /* read reference channel correspnding to the given user in USER_ID */ - if ( fread( &ref, sizeof( int16_t ), 1, pIo_params->fRef ) <= 0 ) - { - printf( "Ref file finished\n" ); - goto DONE; - } - acc_0f = (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* compare to output from object mixer-renderer call above */ - if ( fread( &out, sizeof( int16_t ), 1, pIo_params->fOut ) <= 0 ) - { - printf( "Output file finished\n" ); - goto DONE; - } - out_0f = (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* check if much different.. */ - if ( fabs( out_0f - acc_0f ) > TC_TOL ) - { - test = FAIL; - } - } - } -#else - if ( pIo_params->fRef ) - { - int16_t numRead; - AudioFileReader_close( &pIo_params->fRef ); - AudioFileWriter_close( &pIo_params->fOut ); - AudioFileReader *fRef, *fOut; - AudioFileReader_open( &fOut, pIo_params->out_path, &pIo_params->sample_rate ); - AudioFileReader_open( &fRef, pIo_params->ref_path, &pIo_params->sample_rate ); - while ( 1 ) - { - acc_0f = 0.0f; - /* read reference channel correspnding to the given user in USER_ID */ - if ( (AudioFileReader_read( fRef , &ref, 1, &numRead ) != IVAS_ERR_OK) || (numRead == 0) ) - { - printf( "Ref file finished\n" ); - goto DONE; - } - acc_0f = (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* compare to output from object mixer-renderer call above */ - if ( ( AudioFileReader_read( fOut, &out, 1, &numRead ) != IVAS_ERR_OK ) || ( numRead == 0 ) ) - { - printf( "Output file finished\n" ); - goto DONE; - } - out_0f = (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* check if much different.. */ - if ( fabs( out_0f - acc_0f ) > TC_TOL ) - { - test = FAIL; - } - } - AudioFileReader_close( &fOut ); - AudioFileReader_close( &fRef ); - } - - - -#endif -DONE: - if ( test == PASS ) - { - printf( "%s PASSED\n\n", "CREND_PROXIMITY" ); - } - else - { - printf( "%s FAILED\n\n", "CREND_PROXIMITY" ); - exit( -1 ); - } - if ( pIo_params->fProx ) - { - fclose( pIo_params->fProx ); - } - return IVAS_SUCCESS; -} -/*-----------------------------------------------------------------------------------------* - * Function description - - * function call for ivas_crend_binaural_test - * - * Inputs - - * ivas_crend_io_params_t io_params - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_crend_binaural_test( ivas_crend_io_params_t *pIo_params ) -{ - float *mixer = NULL; - char *test_case; - int16_t out = 0, ref = 0, test = PASS; - int32_t skip_samples = 0; - - if ( pIo_params->in_fmt == MULT_CH_5_1 ) - { - test_case = "CREND_510_TO_BIN"; - } - else if ( pIo_params->in_fmt == MULT_CH_7_1 ) - { - test_case = "CREND_710_TO_BIN"; - } - else if ( pIo_params->in_fmt == MULT_CH_5_1_2 ) - { - test_case = "CREND_512_TO_BIN"; - } - else if ( pIo_params->in_fmt == MULT_CH_5_1_4 ) - { - test_case = "CREND_514_TO_BIN"; - } - else if ( pIo_params->in_fmt == MULT_CH_7_1_4 ) - { - test_case = "CREND_714_TO_BIN"; - } - else if ( pIo_params->in_fmt == FOA_4 ) - { - test_case = "CREND_FOA_TO_BIN"; - } - else if ( pIo_params->in_fmt == HOA_9 ) - { - test_case = "CREND_HOA_9_TO_BIN"; - } - else if ( pIo_params->in_fmt == HOA_16 ) - { - test_case = "CREND_HOA_16_TO_BIN"; - } - else - { - test_case = ""; - } - /* Call CREND */ - ivas_common_mixer_renderer( pIo_params, mixer ); - -#ifdef USE_PCM_OUT - int32_t skip_bytes = 0; - /* Compare */ - if ( pIo_params->fRef ) - { - ivas_wav_header_skip( pIo_params->fRef ); - skip_samples = (int32_t)( pIo_params->latency_s * pIo_params->sample_rate ); - if ( pIo_params->no_delay_cmp == 0 ) - { - skip_bytes = skip_samples * ivas_get_num_channels( BIN_2 ) * sizeof( int16_t ); - } - /* skip intial samples based on latency */ - fseek( pIo_params->fOut, skip_bytes, SEEK_SET ); - int16_t tail = 0; - int32_t tail_zeros = 0; - while ( ( fread( &out, sizeof( int16_t ), 1, pIo_params->fOut ) > 0 ) && ( fread( &ref, sizeof( int16_t ), 1, pIo_params->fRef ) > 0 ) ) - { - if ( fabs( (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ) - (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ) ) > pIo_params->tol ) - { - tail = 1; - } - if ( tail == 1 ) - { - tail_zeros++; - if ( tail_zeros > skip_samples * ivas_get_num_channels( BIN_2 ) ) - { - test = FAIL; - } - if ( out != 0 ) - { - test = FAIL; - } - } - } - - if ( test == PASS ) - { - printf( "%s TEST PASSED\n\n", test_case ); - } - else - { - printf( "%s TEST FAILED\n\n", test_case ); - exit( -1 ); - } - } - else - { - printf( "%s TEST VECTOR GENERATED\n\n", test_case ); - } -#else - /* Compare */ - if ( pIo_params->fRef ) - { - int16_t numRead; - AudioFileReader_close( &pIo_params->fRef ); - AudioFileWriter_close( &pIo_params->fOut ); - AudioFileReader *fRef, *fOut; - AudioFileReader_open( &fOut, pIo_params->out_path, &pIo_params->sample_rate ); - AudioFileReader_open( &fRef, pIo_params->ref_path, &pIo_params->sample_rate ); - - skip_samples = (int32_t) ( pIo_params->latency_s * pIo_params->sample_rate ); - /* skip intial samples based on latency */ - int16_t tail = 0; - int32_t tail_zeros = 0; - - while ( ( AudioFileReader_read( fOut, &out, 1, &numRead ) == IVAS_ERR_OK ) && ( numRead > 0 ) && ( AudioFileReader_read( fRef, &ref, 1, &numRead ) == IVAS_ERR_OK ) && ( numRead > 0 ) ) - { - if ( fabs( (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ) - (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ) ) > pIo_params->tol ) - { - tail = 1; - } - if ( tail == 1 ) - { - tail_zeros++; - if ( tail_zeros > skip_samples * ivas_get_num_channels( BIN_2 ) ) - { - test = FAIL; - } - if ( out != 0 ) - { - test = FAIL; - } - } - } - - if ( test == PASS ) - { - printf( "%s TEST PASSED\n\n", test_case ); - } - else - { - printf( "%s TEST FAILED\n\n", test_case ); - exit( -1 ); - } - AudioFileReader_close( &fOut ); - AudioFileReader_close( &fRef ); - } - else - { - printf( "%s TEST VECTOR GENERATED\n\n", test_case ); - } -#endif - - return IVAS_SUCCESS; -} - - -/*-----------------------------------------------------------------------------------------* - * Function description - - * common function call for ivas_crend_HOA_to_200_test - * - * Inputs - - * ivas_crend_io_params_t io_params - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_crend_no_diegetic_test( ivas_crend_io_params_t *pIo_params ) -{ - char *test_case = "CREND_NO_DIEGETIC"; - int16_t out = 0, test = PASS; - int16_t ref; - float out_f, ref_f; - float no_diegetic_pan; - float mixer[2]; - - if ( pIo_params->in_fmt > MONO_1 ) - return IVAS_FAILED; - if ( pIo_params->out_fmt != STEREO_2 ) - return IVAS_FAILED; - - no_diegetic_pan = pIo_params->no_diegetic_pan; - if ( no_diegetic_pan > 1 ) - no_diegetic_pan = 1; - if ( no_diegetic_pan < -1 ) - no_diegetic_pan = -1; - - mixer[0] = ( no_diegetic_pan + 1.f ) * 0.5f; - mixer[1] = 1.f - mixer[0]; - - /* Call CREND */ - ivas_common_mixer_renderer( pIo_params, mixer ); - - if ( pIo_params->fRef == NULL ) - { - printf( "%s test vector GENERATED\n\n", test_case ); - return IVAS_SUCCESS; - } - -#ifdef USE_PCM_OUT - int32_t in_ch,i; - in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - - /* Compare */ - - for ( i = 0; i < in_ch; i++ ) - { - fseek( pIo_params->fRef, 0, SEEK_SET ); - ivas_wav_header_skip( pIo_params->fRef ); - } - - fseek( pIo_params->fOut, 0, SEEK_SET ); - - if ( pIo_params->fRef ) - { - while ( 1 ) - { - - if ( fread( &ref, sizeof( int16_t ), 1, pIo_params->fRef ) <= 0 ) - goto DONE; - ref_f = (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - if ( fread( &out, sizeof( int16_t ), 1, pIo_params->fOut ) <= 0 ) - goto DONE; - out_f = (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - if ( fabs( out_f - ref_f ) > TC_TOL ) - test = FAIL; - } - } -#else - /* Compare */ - - int16_t numRead; - AudioFileReader_close( &pIo_params->fRef ); - AudioFileWriter_close( &pIo_params->fOut ); - AudioFileReader *fRef, *fOut; - AudioFileReader_open( &fOut, pIo_params->out_path, &pIo_params->sample_rate ); - AudioFileReader_open( &fRef, pIo_params->ref_path, &pIo_params->sample_rate ); - - if ( fRef ) - { - while ( 1 ) - { - if ( ( AudioFileReader_read( fRef, &ref, 1, &numRead ) != IVAS_ERR_OK ) || ( numRead == 0 ) ) - goto DONE; - ref_f = (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - if (( AudioFileReader_read( fOut, &out, 1, &numRead ) != IVAS_ERR_OK ) || (numRead == 0) ) - goto DONE; - out_f = (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - if ( fabs( out_f - ref_f ) > TC_TOL ) - test = FAIL; - } - } - AudioFileReader_close( &fOut ); - AudioFileReader_close( &fRef ); -#endif -DONE: - - if ( test == PASS ) - { - printf( "%s PASSED\n\n", test_case ); - } - else - { - printf( "%s FAILED\n\n", test_case ); - exit( -1 ); - } - - return IVAS_SUCCESS; -} - - -/*-----------------------------------------------------------------------------------------* - * Function description - - * main process call - * - * Inputs - - * int argc - * char** argv - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -int main( int argc, char **argv ) -{ - ivas_crend_io_params_t io_params = { 0 }; - int32_t i; - - ivas_crend_default_io_params( &io_params ); - ivas_crend_parse_io_params( argc, argv, &io_params ); - - if ( io_params.in_path[0] != '\0' ) - { - if ( - io_params.test == CREND_ACOUSTIC_PROXIMITY || - io_params.test == CREND_BIN_TEST || - io_params.test == FASTCONV_BIN_TEST || - io_params.test == PARAM_BIN_TEST || - io_params.test == TD_BIN_TEST || - io_params.test == CREND_TEST_NO_DIEGETIC ) - { - ivas_open_files_crend( &io_params ); - } - } - switch ( io_params.test ) - { - case CREND_ACOUSTIC_PROXIMITY: - ivas_crend_proximity_test( &io_params ); - break; - case CREND_BIN_TEST: - case FASTCONV_BIN_TEST: - case PARAM_BIN_TEST: - case TD_BIN_TEST: - ivas_crend_binaural_test( &io_params ); - break; - case CREND_TEST_NO_DIEGETIC: - ivas_crend_no_diegetic_test( &io_params ); - break; - default: - ivas_common_mixer_renderer( &io_params, NULL ); - break; - } - - FILES_CLOSE; - -#ifdef RAM_COUNTING_TOOL - mem_count_summary( USE_DEFAULT ); -#endif - - return 0; -} diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.h deleted file mode 100644 index c26134aba1..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.h +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/**************************************************************************** -* File description - -* This source file contains definitions specific to IVAS common renderer -****************************************************************************/ - -#ifndef IVAS_CREND_UNIT_TEST_H -#define IVAS_CREND_UNIT_TEST_H - -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include -#include "ivas_stat_dec.h" -#include "ivas_result_t.h" - - -/* Tables */ - -extern float ivas_mixer_510_to_510_tc_gain[]; -extern float ivas_mixer_710_to_710_tc_gain[]; -extern float ivas_mixer_510_LFE_to_BIN_tc_gain[]; -extern float ivas_mixer_710_LFE_to_BIN_tc_gain[]; - - -#endif /* IVAS_CREND_UNIT_TEST_H */ diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.sln b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.sln deleted file mode 100644 index 549ec51076..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.sln +++ /dev/null @@ -1,68 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1500 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ivas_crend_unit_test", "ivas_crend_unit_test.vcxproj", "{32354377-ACA7-40F9-9A0E-87FC956F0B78}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_com", "..\..\..\..\..\Workspace_msvc\lib_com.vcxproj", "{39EC200D-7795-4FF8-B214-B24EDA5526AE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_dec", "..\..\..\..\..\Workspace_msvc\lib_dec.vcxproj", "{E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_debug", "..\..\..\..\..\Workspace_msvc\lib_debug.vcxproj", "{54509728-928B-44D9-A118-A6F92F08B34F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_util", "..\..\..\..\..\Workspace_msvc\lib_util.vcxproj", "{2FA8F384-0775-F3B7-F8C3-85209222FC70}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_rend", "..\..\..\..\..\Workspace_msvc\lib_rend.vcxproj", "{718DE063-A18B-BB72-9150-62B892E6FFA6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Unittests|Win32 = Unittests|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Debug|Win32.ActiveCfg = Debug|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Debug|Win32.Build.0 = Debug|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Release|Win32.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Release|Win32.Build.0 = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Unittests|Win32.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Unittests|Win32.Build.0 = Release|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Debug|Win32.ActiveCfg = Debug|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Debug|Win32.Build.0 = Debug|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Release|Win32.ActiveCfg = Release|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Release|Win32.Build.0 = Release|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Unittests|Win32.Build.0 = Unittests|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Debug|Win32.Build.0 = Debug|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Release|Win32.ActiveCfg = Release|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Release|Win32.Build.0 = Release|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Unittests|Win32.Build.0 = Unittests|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Debug|Win32.ActiveCfg = Debug|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Debug|Win32.Build.0 = Debug|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Release|Win32.ActiveCfg = Release|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Release|Win32.Build.0 = Release|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Unittests|Win32.Build.0 = Unittests|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Debug|Win32.ActiveCfg = Debug|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Debug|Win32.Build.0 = Debug|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Release|Win32.ActiveCfg = Release|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Release|Win32.Build.0 = Release|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Unittests|Win32.Build.0 = Unittests|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Debug|Win32.ActiveCfg = Debug|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Debug|Win32.Build.0 = Debug|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Release|Win32.ActiveCfg = Release|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Release|Win32.Build.0 = Release|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Unittests|Win32.Build.0 = Unittests|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {47313E68-F2E1-4EB5-81D6-46E2327E12EB} - EndGlobalSection -EndGlobal diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj deleted file mode 100644 index 2b0527648d..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - - - {e822ddaf-0f5f-4cd0-a694-38ae69de74d3} - - - {718DE063-A18B-BB72-9150-62B892E6FFA6} - - - {2fa8f384-0775-f3b7-f8c3-85209222fc70} - - - {5821967e-dd91-4b90-9b06-3b2cd896be57} - - - - - - - - - - - - - - - {32354377-ACA7-40F9-9A0E-87FC956F0B78} - evs_enc - 10.0.17763.0 - - - - Application - false - MultiByte - v141 - - - Application - false - MultiByte - v141 - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.26228.10 - - - .\ - .\Release_crend_unit_test\ - false - false - IVAS_crend_unit_test - - - .\ - .\Debug_crend_unit_test\ - false - false - IVAS_crend_unit_test - - - - - - - .\Release/vbr_enc.tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\..\..\..\..\lib_util;..\..\..\..\..\lib_dec;..\..\..\..\..\lib_rend;..\..\..\..\..\lib_com;..\..\..\..\..\lib_enc;..\..\..\..\..\lib_debug;..\..\..\..\..\lib_util;%(AdditionalIncludeDirectories) - UNIT_TEST_CREND_TD_BINAURAL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - Precise - false - - - $(IntDir)ens_enc.pdb - Level4 - true - - Default - 4100;4244;4310;%(DisableSpecificWarnings) - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - IVAS_crend_unit_test.exe - true - - false - .\Release_crend_unit_test/ivas_crend_unit_test.pdb - Console - false - - MachineX86 - libcmtd.lib - - - - - - - - .\Debug/vbr_enc.tlb - - - - Disabled - ..\..\..\..\..\lib_util;..\..\..\..\..\lib_dec;..\..\..\..\..\lib_rend;..\..\..\..\..\lib_com;..\..\..\..\..\lib_enc;..\..\..\..\..\lib_debug;..\..\..\..\..\lib_util;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - NotUsing - - $(IntDir)ivas_quant_dequant_test.pdb - Level4 - true - OldStyle - Default - 4100;4244;4310;%(DisableSpecificWarnings) - true - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - - IVAS_crend_unit_test.exe - true - - false - true - .\Debug_crend_unit_test/ivas_crend_unit_test.pdb - Console - - false - - MachineX86 - - - - - - - - - - - - - - \ No newline at end of file diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c deleted file mode 100644 index be5e483927..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c +++ /dev/null @@ -1,1800 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/**************************************************************************** - * File description - - * This source file contains utility definitions specific to IVAS common renderer unit tests - ****************************************************************************/ - - -/*------------------------------------------------------------------------------------------* - * include header files - *------------------------------------------------------------------------------------------*/ - -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include -#include -#include "options.h" -#include "ivas_dec_parse_io.h" -#include "ivas_crend_public.h" -#include "ivas_stat_dec.h" -#include "ivas_prox_mix.h" -#include "prot.h" -#include "ivas_prot.h" -#include "cmdl_tools.h" -#include "ivas_stat_dec.h" -#include "ivas_cnst.h" -#include "assert.h" -#include "ivas_rom_binaural_crend_head.h" -#include "ivas_rom_binauralRenderer.h" -#include "ivas_rom_com.h" -#include "head_rotation_file_reader.h" -#include "options.h" -#include "render_config_reader.h" - - -static ivas_result_t ivas_dec_default_io_params( ivas_dec_io_params_t *pIO_params ) -{ - memset( pIO_params, 0, sizeof( ivas_dec_io_params_t ) ); - pIO_params->quiet_mode = IVAS_DEFAULT_QUIET_MODE; - pIO_params->no_delay_cmp = IVAS_DEFAULT_NO_DELAY_COMP_MODE; - pIO_params->bs_format = IVAS_DEFAULT_BS_FORMAT; - pIO_params->out_fmt = IVAS_DEFAULT_FMT; - pIO_params->in_fmt = IVAS_DEFAULT_FMT; - pIO_params->lfe_ch_idx = IVAS_DEFAULT_LFE_CH_IDX; - pIO_params->block_offset_ms = IVAS_EXT_ADD_DELAY_MS; - pIO_params->no_diegetic_pan = 0; - pIO_params->orientation_tracking = OTR_TRACKING_NONE; - - return IVAS_SUCCESS; -} - -/*------------------------------------------------------------------------- - * ivas_hrtf_init() - * - * Initialize hHrtf handle - *------------------------------------------------------------------------*/ - -static ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ -) -{ - int16_t i, j; - - if ( hHrtf == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } - - hHrtf->latency_s = 0; - hHrtf->max_num_ir = 0; - hHrtf->max_num_iterations = 0; - hHrtf->gain_lfe = 0; - hHrtf->index_frequency_max_diffuse = 0; - - for ( i = 0; i < IVAS_MAX_NUM_CH; i++ ) - { - hHrtf->inv_diffuse_weight[i] = 0; - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = 0; - hHrtf->pIndex_frequency_max[i][j] = NULL; - hHrtf->pOut_to_bin_re[i][j] = NULL; - hHrtf->pOut_to_bin_im[i][j] = NULL; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = 0; - hHrtf->pIndex_frequency_max_diffuse[j] = NULL; - hHrtf->pOut_to_bin_diffuse_re[j] = NULL; - hHrtf->pOut_to_bin_diffuse_im[j] = NULL; - } - - return IVAS_ERR_OK; -} - -AUDIO_CONFIG ivas_crend_map_out_fmt( - IVAS_IN_OUT_FMT_CONFIG fmt ) -{ - switch ( fmt ) - { - case MONO_1: - return AUDIO_CONFIG_MONO; - case STEREO_2: - return AUDIO_CONFIG_STEREO; - case BIN_2: - return AUDIO_CONFIG_BINAURAL; - case FOA_4: - return AUDIO_CONFIG_FOA; - case HOA_9: - return AUDIO_CONFIG_HOA2; - case HOA_16: - return AUDIO_CONFIG_HOA3; - case MULT_CH_5_1: - return AUDIO_CONFIG_5_1; - case MULT_CH_7_1: - return AUDIO_CONFIG_7_1; - case MULT_CH_5_1_2: - return AUDIO_CONFIG_5_1_2; - case MULT_CH_5_1_4: - return AUDIO_CONFIG_5_1_4; - case MULT_CH_7_1_4: - return AUDIO_CONFIG_7_1_4; - default: - return -1; - } -} - -const char *ivas_crend_map_in_fmt( - IVAS_IN_OUT_FMT_CONFIG fmt ) -{ - switch ( fmt ) - { - case MONO_1: - case STEREO_2: - case MULT_CH_5_1: - case MULT_CH_7_1: - case MULT_CH_5_1_2: - case MULT_CH_5_1_4: - case MULT_CH_7_1_4: - return IVAS_IN_FMT_COMBINED; - case FOA_4: - case HOA_9: - case HOA_16: - return IVAS_IN_FMT_HOA_3; - default: - return ""; - } -} - - -int16_t ivas_get_num_channels( - const int16_t ch_format ) -{ - int16_t num_channels = 0; - - switch ( ch_format ) - { - case MONO_1: - num_channels = 1; - break; - case BIN_2: - case STEREO_2: - num_channels = 2; - break; - case FOA_4: - num_channels = FOA_CHANNELS; - break; - case MULT_CH_5_1: - num_channels = 6; - break; - case MULT_CH_7_1: - num_channels = 8; - break; - case HOA_9: - num_channels = 9; - break; - case HOA_16: - num_channels = 16; - break; - case OBA: - num_channels = 8; - break; - case MULT_CH_5_1_2: - num_channels = 8; - break; - case MULT_CH_5_1_4: - num_channels = 10; - break; - case MULT_CH_7_1_4: - num_channels = 12; - break; - default: - assert( !"Not supported Input format for Common Renderer!" ); - break; - } - - return num_channels; -} - -static ivas_result_t ivas_crend_mixer( - float ppPcm_in[][L_FRAME48k], - float ppPcm_out[][L_FRAME48k], - int32_t in_ch, - int32_t out_ch, - const float *pMixer_gain, - const int16_t frame_len ) -{ - int16_t i, j, k, offset; - - for ( i = 0; i < out_ch; i++ ) - { - offset = i * in_ch; - - for ( j = 0; j < frame_len; j++ ) - { - float temp = 0; - const float *pMixer = &pMixer_gain[offset]; - - for ( k = 0; k < in_ch; k++ ) - { - temp += ( ppPcm_in[k][j] * pMixer[k] ); - } - ppPcm_out[i][j] = temp; - } - } - - return IVAS_SUCCESS; -} - -/* prototypes */ -static void ivas_copy_io_params_to_dec_io_params( ivas_crend_io_params_t *pIo_params, ivas_dec_io_params_t *pDec_io_params ); -ivas_result_t ivas_crend_copy_latencies_to_io_params( ivas_crend_io_params_t *pIo_params, HRTFS_DATA *pCrend_hrtfs ); - - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Unit test usage details - * - * Inputs - - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -static void ivas_crend_unit_test_usage( void ) -{ - fprintf( stdout, "Usage: ivas_crend_unit_test.exe -test -sr -ifmt -ofmt [options]\n\n" ); - - fprintf( stdout, "Mandatory arguments:\n" ); - fprintf( stdout, "--------------------\n" ); - fprintf( stdout, "-test : Test case for binaural renderer to run (crend = 1, fastconv = 2, param = 3, td = 4)\n" ); - fprintf( stdout, "-sr : Sampling rate in kHz\n" ); - fprintf( stdout, "\nOptional arguments:\n" ); - fprintf( stdout, "---------------------\n" ); - fprintf( stdout, "-ifmt : Input format index\n" ); - fprintf( stdout, " (0 - MONO, 1 - STEREO, 2 - BINAURAL, 3 - FOA, 4 - 5.1, 5 - 7.1, 6 - 5.1.2, 7 - 5.1.4, 8 - 7.1.4, 9 - HOA2, 10 - HOA3)\n" ); - fprintf( stdout, "-ofmt : Output format index\n" ); - fprintf( stdout, " (0 - MONO, 1 - STEREO, 2 - BINAURAL, 3 - FOA, 4 - 5.1, 5 - 7.1, 6 - 5.1.2, 7 - 5.1.4, 8 - 7.1.4, 9 - HOA2, 10 - HOA3)\n" ); - fprintf( stdout, "-i : Input path/file\n" ); - fprintf( stdout, "-o : Output file\n" ); - fprintf( stdout, "-r : Reference path/file\n" ); - fprintf( stdout, "-otr : orientation tracker mode\n" ); - fprintf( stdout, "-t : CSV files path\n" ); - fprintf( stdout, "-prox : prox files path\n" ); - fprintf( stdout, "-zero_tol : ability to force some tests to check for bitexactness\n" ); - fprintf( stdout, "-limiter : add limiter\n" ); - fprintf( stdout, "-lp_lfe : add low pass filtering on LFE channel\n" ); - fprintf( stdout, "-no_delay_cmp : avoid delay conpensation on output wav file\n" ); - fprintf( stdout, "-brir : use default brir if available for de specified binaural renderer\n" ); - fprintf( stdout, "-render_config file : Renderer configuration file\n" ); - fprintf( stdout, "-no_diegetic_pan : panning mono no dietic sound to stereo -1<= pan <=1,\n" ); - fprintf( stdout, " left or l or 1->left, right or r or -1->right, center or c or 0->middle\n" ); - - fprintf( stdout, "\n" ); - - exit( -1 ); -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Set default IO parameters to 0 - * - * Inputs - - * ivas_crend_io_params_t *pIO_params - * - * Outputs - - * ivas_crend_io_params_t *pIO_params - * - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_crend_default_io_params( ivas_crend_io_params_t *pIO_params ) -{ - memset( pIO_params, 0, sizeof( ivas_crend_io_params_t ) ); - pIO_params->tol = TC_TOL; - pIO_params->orientation_tracking = OTR_TRACKING_NONE; - - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Get frame length - * - * Inputs - - * int32_t sample_rate - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -int32_t ivas_wrapper_get_frame_len( int32_t sample_rate ) -{ - return ( (int32_t) ( sample_rate / FRAMES_PER_SEC ) ); -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Set config parameters - * - * Inputs - - * ivas_crend_io_params_t *p_io_params - * ivas_crend_hrtfs_t *pCrend_hrtfs - * - * Outputs - - * ivas_dec_cfg_t *pDec_cfg - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_crend_set_config_params( - DECODER_CONFIG_HANDLE hDecoderConfig, - ivas_dec_io_params_t *p_io_params, - int16_t *in_format, - int16_t *lfe_ch_idx ) -{ - *in_format = p_io_params->in_fmt; - hDecoderConfig->output_config = ivas_crend_map_out_fmt( p_io_params->out_fmt ); - - *lfe_ch_idx = p_io_params->lfe_ch_idx; - - hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); - - hDecoderConfig->output_Fs = p_io_params->out_sample_rate; - hDecoderConfig->no_diegetic_pan = p_io_params->no_diegetic_pan; - - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Copy latencies to io_params - * - * Inputs - - * ivas_crend_hrtfs_t *pCrend_hrtfs - * - * Outputs - - * ivas_dec_cfg_t *pDec_cfg - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_crend_copy_latencies_to_io_params( ivas_crend_io_params_t *pIo_params, HRTFS_DATA *pCrend_hrtfs ) -{ - - pIo_params->latency_s = pCrend_hrtfs->latency_s; - - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Copy hrtf data to config parameters - * - * Inputs - - * ivas_crend_hrtfs_t *pCrend_hrtfs - * - * Outputs - - * ivas_dec_cfg_t *pDec_cfg - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_crend_copy_hrtf_data( HRTFS_DATA *hHrtf, HRTFS_DATA *pCrend_hrtfs ) -{ - int16_t i, j; - - hHrtf->latency_s = pCrend_hrtfs->latency_s; - hHrtf->max_num_ir = pCrend_hrtfs->max_num_ir; - hHrtf->max_num_iterations = pCrend_hrtfs->max_num_iterations; - hHrtf->gain_lfe = pCrend_hrtfs->gain_lfe; - - for ( i = 0; i < pCrend_hrtfs->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->pOut_to_bin_re[i][j] = pCrend_hrtfs->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = pCrend_hrtfs->pOut_to_bin_im[i][j]; - hHrtf->num_iterations[i][j] = pCrend_hrtfs->num_iterations[i][j]; - hHrtf->pIndex_frequency_max[i][j] = pCrend_hrtfs->pIndex_frequency_max[i][j]; - } - hHrtf->inv_diffuse_weight[i] = pCrend_hrtfs->inv_diffuse_weight[i]; - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->pOut_to_bin_diffuse_re[j] = pCrend_hrtfs->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = pCrend_hrtfs->pOut_to_bin_diffuse_im[j]; - hHrtf->num_iterations_diffuse[j] = pCrend_hrtfs->num_iterations_diffuse[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = pCrend_hrtfs->pIndex_frequency_max_diffuse[j]; - } - hHrtf->index_frequency_max_diffuse = pCrend_hrtfs->index_frequency_max_diffuse; - - return IVAS_SUCCESS; -} - - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Open files corresponding to the reference tests - * - * Inputs - - * ivas_crend_io_params_t *pIo_params - * - * Outputs - - * ivas_crend_io_params_t *pIo_params - * - *-----------------------------------------------------------------------------------------*/ - -void ivas_open_files_crend( ivas_crend_io_params_t *pIo_params ) -{ - /* Input File */ -#ifdef USE_PCM_OUT - if ( ( pIo_params->fIn[0] = fopen( pIo_params->in_path, "rb" ) ) == NULL ) -#else - if ( AudioFileReader_open( &pIo_params->fIn[0], pIo_params->in_path, &pIo_params->sample_rate ) != IVAS_ERR_OK ) -#endif - { - fprintf( stderr, "Error: Input audio file %s could not be opened\n\n", pIo_params->in_path ); - ivas_crend_unit_test_usage(); - } - fprintf( stdout, "Input audio file: %s\n", pIo_params->in_path ); - - /* Reference File */ -#ifdef USE_PCM_OUT - if ( ( strlen( pIo_params->ref_path ) > 0 ) && ( ( pIo_params->fRef = fopen( pIo_params->ref_path, "rb" ) ) == NULL ) ) -#else - if ( ( strlen( pIo_params->ref_path ) > 0 ) && ( AudioFileReader_open( &pIo_params->fRef, pIo_params->ref_path, &pIo_params->sample_rate ) != IVAS_ERR_OK ) ) -#endif - { - fprintf( stderr, "Error: Reference audio file %s could not be opened\n\n", pIo_params->ref_path ); - ivas_crend_unit_test_usage(); - } - fprintf( stdout, "Reference audio file: %s\n", pIo_params->ref_path ); - - - /*if (pIo_params->test == CREND_IR_GREATER_960) - { - if ((pIo_params->custom_hrtf = fopen(pIo_params->sofa_path, "rb")) == NULL) - { - fprintf(stderr, "Error: Custom HRTF file %s could not be opened\n\n", pIo_params->sofa_path); - ivas_crend_unit_test_usage(); - } - }*/ - - - if ( pIo_params->test == CREND_ACOUSTIC_PROXIMITY ) - { - /* open proximity bitstream file */ - if ( ( pIo_params->fProx = fopen( pIo_params->prox_path, "rb" ) ) == NULL ) - { - fprintf( stderr, "Error: LocSharing bitstream file %s could not be opened\n\n", pIo_params->prox_path ); - ivas_crend_unit_test_usage(); - } - } - fprintf( stdout, "prox file or path: %s\n", pIo_params->prox_path ); -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Parse the cmd line params into IO param structure - * - * Inputs - - * int argc - * char** argv - * - * Outputs - - * ivas_enc_io_params_t *pIO_params - * - * - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_crend_parse_io_params( int argc, char **argv, ivas_crend_io_params_t *pIo_params ) -{ - int i = 1; - int mandatory_args = 0; - int optional_args = 0; - int check_output_format_set = 0; - -#ifdef DEBUG_SBA - fprintf( stderr, "Number of cmd line args: %d\n", argc ); - fprintf( stderr, "CMD: " ); - while ( i < argc ) - { - /*printing with stderr so that it gets printed always*/ - fprintf( stderr, "%s ", argv[i++] ); - } - fprintf( stderr, "\n\n" ); - - i = 1; -#endif - - while ( i < argc ) - { - /*-----------------------------------------------------------------* - * Sampling rate - *-----------------------------------------------------------------*/ - if ( strcmp( to_upper( argv[i] ), "-SR" ) == 0 ) - { - pIo_params->sample_rate = atoi( argv[++i] ) * 1000; - if ( ( pIo_params->sample_rate != 8000 ) && ( pIo_params->sample_rate != 16000 ) && ( pIo_params->sample_rate != 32000 ) && ( pIo_params->sample_rate != 48000 ) ) - { - fprintf( stderr, "Error: %d kHz is not a supported sampling rate\n\n", atoi( argv[i] ) ); - ivas_crend_unit_test_usage(); - } - i++; - mandatory_args++; - } - /*-----------------------------------------------------------------* - *render config - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-RENDER_CONFIG" ) == 0 ) - { - pIo_params->renderConfigFilename[0] = '\0'; - pIo_params->renderConfigEnabled = true; - strcpy( pIo_params->renderConfigFilename, argv[++i] ); - - if ( pIo_params->renderConfigFilename[0] == '\0' ) - { - fprintf( stderr, "Error: Renderer configuration file path not specified\n\n" ); - ivas_crend_unit_test_usage(); - } - i++; - optional_args++; - } - /*-----------------------------------------------------------------* - * Input Format - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-IFMT" ) == 0 ) - { - pIo_params->in_fmt = atoi( argv[++i] ); - if ( ( pIo_params->in_fmt != MONO_1 ) && ( pIo_params->in_fmt != STEREO_2 ) && ( pIo_params->in_fmt != BIN_2 ) && ( pIo_params->in_fmt != FOA_4 ) && ( pIo_params->in_fmt != HOA_9 ) && ( pIo_params->in_fmt != HOA_16 ) && ( pIo_params->in_fmt != MULT_CH_5_1 ) && ( pIo_params->in_fmt != MULT_CH_7_1 ) && ( pIo_params->in_fmt != MULT_CH_5_1_2 ) && ( pIo_params->in_fmt != MULT_CH_5_1_4 ) && ( pIo_params->in_fmt != MULT_CH_7_1_4 ) && ( pIo_params->in_fmt != OBA ) ) - { - fprintf( stderr, "Error: Invalid input format\n\n" ); - ivas_crend_unit_test_usage(); - } - i++; - mandatory_args++; - } - /*-----------------------------------------------------------------* - * Output Format - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-OFMT" ) == 0 ) - { - pIo_params->out_fmt = atoi( argv[++i] ); - if ( ( pIo_params->out_fmt != MONO_1 ) && ( pIo_params->out_fmt != STEREO_2 ) && ( pIo_params->out_fmt != BIN_2 ) && ( pIo_params->out_fmt != FOA_4 ) && ( pIo_params->out_fmt != HOA_9 ) && ( pIo_params->out_fmt != HOA_16 ) && ( pIo_params->out_fmt != MULT_CH_5_1 ) && ( pIo_params->out_fmt != MULT_CH_7_1 ) && ( pIo_params->out_fmt != MULT_CH_5_1_2 ) && ( pIo_params->out_fmt != MULT_CH_5_1_4 ) && ( pIo_params->out_fmt != MULT_CH_7_1_4 ) ) - { - fprintf( stderr, "Error: Invalid output format\n\n" ); - ivas_crend_unit_test_usage(); - } - check_output_format_set = 1; - i++; - mandatory_args++; - } - /*-----------------------------------------------------------------* - * Input file(s) - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-I" ) == 0 ) - { - strcpy( pIo_params->in_path, argv[++i] ); - if ( pIo_params->in_path[0] == '\0' ) - { - fprintf( stderr, "Error: input folder %s could not be opened\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - i++; - mandatory_args++; - } - - /*-----------------------------------------------------------------* - * Proximity file - *------------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-PROX" ) == 0 ) - { - if ( strlen( argv[++i] ) > IVAS_MAX_PATH_LEN ) - { - fprintf( stderr, "Error: input proximity path %s too big\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - strcpy( pIo_params->prox_path, argv[i] ); - if ( pIo_params->prox_path[0] == '\0' ) - { - fprintf( stderr, "Error: input proximity folder %s could not be opened\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - i++; - optional_args++; - } - /*-----------------------------------------------------------------* - * Input csv file - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-T" ) == 0 ) - { - if ( strlen( argv[++i] ) > IVAS_MAX_PATH_LEN ) - { - fprintf( stderr, "Error: input head orientation CSV file path %s too long\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - strcpy( pIo_params->csv_path, argv[i] ); - if ( pIo_params->csv_path[0] == '\0' ) - { - fprintf( stderr, "Error: input head orientation CSV file %s could not be opened\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - - i++; - optional_args++; - } - - /*-----------------------------------------------------------------* - * Orientation tracking - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-OTR" ) == 0 ) - { - char tmp[5]; - strcpy( tmp, argv[++i] ); - if ( strcmp( to_upper( tmp ), "AVG" ) == 0 ) - { - pIo_params->orientation_tracking = OTR_TRACKING_AVG_ORIENT; - } - else if ( strcmp( to_upper( tmp ), "REF" ) == 0 ) - { - pIo_params->orientation_tracking = OTR_TRACKING_REF_ORIENT; - } - else - { - fprintf( stderr, "Error: Invalid orientation tracking type\n\n" ); - ivas_crend_unit_test_usage(); - } - i++; - optional_args++; - } - - /*-----------------------------------------------------------------* - * Output file(s) - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-O" ) == 0 ) - { - if ( check_output_format_set == 0 ) - { - fprintf( stderr, "Error: Output format flag must be set beform output file name\n\n" ); - ivas_crend_unit_test_usage(); - } - if ( pIo_params->sample_rate == 0 ) - { - fprintf( stderr, "Error: Sample rate flag must be set beform output file name\n\n" ); - ivas_crend_unit_test_usage(); - } - strcpy( pIo_params->out_path, argv[++i] ); -#ifdef USE_PCM_OUT - if ( ( pIo_params->fOut = fopen( pIo_params->out_path, "wb+" ) ) == NULL ) -#else - if ( AudioFileWriter_open( &pIo_params->fOut, pIo_params->out_path, pIo_params->sample_rate, ivas_get_num_channels( pIo_params->out_fmt ) ) != IVAS_ERR_OK ) -#endif - { - fprintf( stderr, "Error: output audio file %s could not be opened\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - fprintf( stdout, "Output audio file: %s\n", argv[i] ); - i++; - mandatory_args++; - } - /*-----------------------------------------------------------------* - * Reference file(s) path - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-R" ) == 0 ) - { - strcpy( pIo_params->ref_path, argv[++i] ); - if ( pIo_params->ref_path[0] == '\0' ) - { - fprintf( stderr, "Error: Ref folder %s could not be opened\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - i++; - optional_args++; - } - /*-----------------------------------------------------------------* - * Test to Run - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-TEST" ) == 0 ) - { - pIo_params->test = atoi( argv[++i] ); - if ( pIo_params->test < 0 || pIo_params->test >= CREND_NUM_TESTS ) - { - fprintf( stderr, "Error: Invalid Test case\n\n" ); - ivas_crend_unit_test_usage(); - } - i++; - mandatory_args++; - } - /*-----------------------------------------------------------------* - * Use BRIR Length - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-BRIR" ) == 0 ) - { - pIo_params->use_brir = 1; - i++; - optional_args++; - } - /*-----------------------------------------------------------------* - * Apply low pass filter to LFE - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-LP_LFE" ) == 0 ) - { - pIo_params->lfe_lp_enable = 1; - i++; - optional_args++; - } - /*-----------------------------------------------------------------* - * Apply limiter - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-LIMITER" ) == 0 ) - { - pIo_params->limiter_enable = 1; - i++; - optional_args++; - } - /*-----------------------------------------------------------------* - * CREND non diegetic panning value - *-----------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-NO_DIEGETIC_PAN" ) == 0 ) - { - i++; - char *param = to_upper( argv[i++] ); - if ( ( strcmp( param, "CENTER" ) == 0 ) || ( strchr( param, 'C' ) != NULL ) ) - { - pIo_params->no_diegetic_pan = 0; - } - else if ( ( strcmp( param, "LEFT" ) == 0 ) || ( strchr( param, 'L' ) != NULL ) ) - { - pIo_params->no_diegetic_pan = -1; - } - else if ( ( strcmp( param, "RIGHT" ) == 0 ) || ( strchr( param, 'R' ) != NULL ) ) - { - pIo_params->no_diegetic_pan = 1; - } - else - { - pIo_params->no_diegetic_pan = atof( param ); - } - optional_args++; - } - else if ( strcmp( to_upper( argv[i] ), "-ZERO_TOL" ) == 0 ) - { - pIo_params->tol = 0.0f; - i++; - optional_args++; - } - else if ( strcmp( to_upper( argv[i] ), "-NO_DELAY_CMP" ) == 0 ) - { - pIo_params->no_delay_cmp = 1; - i++; - optional_args++; - } - else - { - fprintf( stderr, "Error: Flag not found\n\n" ); - i++; - } - } - if ( mandatory_args != CREND_MAND_ARGS ) - { - fprintf( stderr, "Error: Not enough mandatory arguments\n\n" ); - ivas_crend_unit_test_usage(); - } - - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Skip WAV header from a WAV file - * - * Inputs - - * FILE *in_file - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_wav_header_skip( FILE *in_file ) -{ - int8_t data_start[4] = { 0 }; - int32_t check, count = 0; - int32_t length; - - check = 1; - while ( check ) - { - if ( data_start[0] == 'd' && data_start[1] == 'a' && - data_start[2] == 't' && data_start[3] == 'a' ) - { - ( fread( &length, 4, 1, in_file ) ); - check = 0; - } - else - { - data_start[0] = data_start[1]; - data_start[1] = data_start[2]; - data_start[2] = data_start[3]; - ( fread( &data_start[3], 1, 1, in_file ) ); - } - count++; - if ( count > 2000 ) - { - length = 0xffffffff; - return IVAS_FAILED; - } - } - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Read/Generate inputs - * - * Inputs - - * ivas_enc_io_params_t *pIo_params - * - * Outputs - - * ivas_enc_in_buf_t *pIn_buf - * - * - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_wrapper_get_in_buf( ivas_crend_io_params_t *pIo_params, float ppPcm_in[][L_FRAME48k] ) -{ - int32_t i = 0, j = 0, samples_read = 0, num_in_ch = 0; - int32_t offset; - int32_t input_frame_len = ivas_wrapper_get_frame_len( pIo_params->sample_rate ); - int16_t tmp, read = 0; - - num_in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - if ( pIo_params->test == CREND_BIN_TEST || pIo_params->test == FASTCONV_BIN_TEST || pIo_params->test == PARAM_BIN_TEST || pIo_params->test == TD_BIN_TEST || pIo_params->test == CREND_ACOUSTIC_PROXIMITY ) - { - /* Read in PCM */ - for ( j = 0; j < input_frame_len; j++ ) - { - for ( i = 0; i < num_in_ch; i++ ) - { -#ifdef USE_PCM_OUT - if ( ( read = (int16_t) fread( &tmp, sizeof( int16_t ), 1, pIo_params->fIn[0] ) ) > 0 ) -#else - if ( ( AudioFileReader_read( pIo_params->fIn[0], &tmp, 1, &read ) == IVAS_ERR_OK ) && ( read > 0 ) ) -#endif - { - ppPcm_in[i][j] = (float) tmp; - // ppPcm_in[i][j] *= ( 1.0 / PCM16_TO_FLT_FAC ); - samples_read += 1; - } - else - { - if ( samples_read != 0 && samples_read < input_frame_len * num_in_ch ) - { - /* Setting remaining buffer to zeros */ - offset = samples_read / num_in_ch; - for ( i = 0; i < num_in_ch; i++ ) - { - set_zero( &ppPcm_in[i][offset], input_frame_len - offset ); - } - return IVAS_SUCCESS; - } - else - { - return IVAS_READ_DONE; - } - } - } - } - } - else - { - /* Read in PCM */ - for ( i = 0; i < num_in_ch; i++ ) - { - samples_read = 0; - for ( j = 0; j < input_frame_len; j++ ) - { -#ifdef USE_PCM_OUT - if ( ( read = (int16_t) fread( &tmp, sizeof( int16_t ), 1, pIo_params->fIn[i] ) ) > 0 ) -#else - if ( ( AudioFileReader_read( pIo_params->fIn[i], &tmp, 1, &read ) == IVAS_ERR_OK ) && ( read > 0 ) ) -#endif - { - ppPcm_in[i][j] = (float) tmp; - // ppPcm_in[i][j] *= ( 1.0 / PCM16_TO_FLT_FAC ); - samples_read += 1; - } - else - { - if ( samples_read != 0 && samples_read < input_frame_len ) - { - /* Setting remaining buffer to zeros */ - offset = samples_read; - set_zero( &ppPcm_in[i][offset], input_frame_len - offset ); - break; - } - else - { - return IVAS_READ_DONE; - } - } - } - } - } - - return IVAS_SUCCESS; -} -/*---------------------------------------------------------------------* - * ivas_feed_head_track_data( ) - * - * Feed the decoder with the head tracking data - *---------------------------------------------------------------------*/ - -static ivas_result_t ivas_feed_head_track_data( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION *orientation /* i : head-tracking data */ -) -{ - HEAD_TRACK_DATA_HANDLE hHeadTrackData; - int16_t i; - - - hHeadTrackData = st_ivas->hHeadTrackData; - - if ( hHeadTrackData == NULL ) - { - return IVAS_FAILED; - } - - /* Move head-tracking data to the decoder handle */ - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - hHeadTrackData->Quaternions[i].w = orientation[i].w; - hHeadTrackData->Quaternions[i].x = orientation[i].x; - hHeadTrackData->Quaternions[i].y = orientation[i].y; - hHeadTrackData->Quaternions[i].z = orientation[i].z; - } - - st_ivas->hHeadTrackData->num_quaternions = 0; - - return IVAS_SUCCESS; -} - - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Copy io_params to dec_io_params - * - * Inputs - - * ivas_crend_io_params_t *pIo_params - * - * Outputs - - * ivas_dec_io_params_t *pDec_io_params - * - *-----------------------------------------------------------------------------------------*/ -static void ivas_copy_io_params_to_dec_io_params( ivas_crend_io_params_t *pIo_params, ivas_dec_io_params_t *pDec_io_params ) -{ - pDec_io_params->in_fmt = pIo_params->in_fmt; - pDec_io_params->out_fmt = pIo_params->out_fmt; - pDec_io_params->out_sample_rate = pIo_params->sample_rate; - pDec_io_params->no_diegetic_pan = pIo_params->no_diegetic_pan; - pDec_io_params->renderConfigEnabled = pIo_params->renderConfigEnabled; - pDec_io_params->use_brir = pIo_params->use_brir; - strcpy( pDec_io_params->renderConfigFilename, pIo_params->renderConfigFilename ); - pDec_io_params->orientation_tracking = pIo_params->orientation_tracking; - switch ( pIo_params->in_fmt ) - { - case MULT_CH_5_1: - case MULT_CH_7_1: - case MULT_CH_5_1_2: - case MULT_CH_5_1_4: - case MULT_CH_7_1_4: - pDec_io_params->lfe_ch_idx = IVAS_DEFAULT_LFE_CH_IDX; - break; - case FOA_4: - case HOA_9: - case HOA_16: - default: - pDec_io_params->lfe_ch_idx = -1; - break; - } -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Main Common Renderer block - * - * Inputs - - * ivas_enc_io_params_t io_params - * float* mixer - * int16_t delay_cmp - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, float *mixer ) -{ - ivas_result_t result = IVAS_SUCCESS; - ivas_error error; - - float ppPcm_in[IVAS_MAX_NUM_CH][L_FRAME48k]; - float ppPcm_out[IVAS_MAX_NUM_CH][L_FRAME48k]; - float *ppDelay_lines[IVAS_MAX_NUM_CH]; - const float *filt_coeff; - int16_t delay_lp = 0; - Decoder_Struct st_ivas; - HeadRotFileReader *headRotReader = NULL; - - memset( &st_ivas, 0, sizeof( Decoder_Struct ) ); - - int64_t frame_count = 0; - - int32_t i = 0, j = 0; - int32_t frame_len = 0; - - ivas_dec_io_params_t dec_io_params; - int16_t in_format; - int16_t lfe_ch_idx; - DECODER_CONFIG decConfig; - - st_ivas.hDecoderConfig = &decConfig; - memset( st_ivas.hDecoderConfig, 0, sizeof( DECODER_CONFIG ) ); - memset( &st_ivas.hOutSetup, 0, sizeof( IVAS_OUTPUT_SETUP ) ); - - ivas_dec_default_io_params( &dec_io_params ); - ivas_copy_io_params_to_dec_io_params( pIo_params, &dec_io_params ); - result = ivas_crend_set_config_params( st_ivas.hDecoderConfig, &dec_io_params, &in_format, &lfe_ch_idx ); - st_ivas.transport_config = st_ivas.intern_config = ivas_crend_map_out_fmt( in_format ); - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "Crend configuration parameters setting failed\n" ); - exit( -1 ); - } - - frame_len = ivas_wrapper_get_frame_len( pIo_params->sample_rate ); - frame_len = frame_len >> 2; -#ifdef USE_PCM_OUT - /* skip WAV header */ - for ( i = 0; i < IVAS_MAX_NUM_CH; i++ ) - { - if ( pIo_params->fIn[i] != NULL ) - { - result = ivas_wav_header_skip( pIo_params->fIn[i] ); - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "WAV header skip failed\n" ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - } - } -#endif - - ivas_render_config_open( &st_ivas.hRenderConfig ); - ivas_render_config_init_from_rom( &st_ivas.hRenderConfig, 0 ); - if ( pIo_params->renderConfigEnabled ) - { - RenderConfigReader *renderConfigReader = NULL; - if ( ( error = RenderConfigReader_open( pIo_params->renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", pIo_params->renderConfigFilename ); - exit( -1 ); - } - if ( RenderConfigReader_read( renderConfigReader, (IVAS_RENDER_CONFIG_HANDLE) st_ivas.hRenderConfig ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to read renderer configuration from file %s\n", pIo_params->renderConfigFilename ); - exit( -1 ); - } - } - - st_ivas.hRenderConfig->roomAcoustics.use_brir = pIo_params->use_brir; - - if ( ( pIo_params->in_fmt >= MULT_CH_5_1 ) && ( pIo_params->in_fmt <= MULT_CH_7_1_4 ) ) - { - st_ivas.ivas_format = MC_FORMAT; - } - else - { - st_ivas.ivas_format = SBA_FORMAT; - } - - if ( ( pIo_params->out_fmt == BIN_2 ) && ( pIo_params->in_fmt != pIo_params->out_fmt ) ) - { - if ( pIo_params->test == FASTCONV_BIN_TEST ) - { - if ( st_ivas.hRenderConfig->roomAcoustics.use_brir ) - { - st_ivas.renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL_ROOM; - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate + FASTCONV_BRIR_latency_s; - } - else - { - st_ivas.renderer_type = RENDERER_BINAURAL_FASTCONV; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; - if ( st_ivas.ivas_format == MC_FORMAT ) - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate + FASTCONV_HRIR_latency_s; - else - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate + FASTCONV_HOA3_latency_s; - } - } - else if ( pIo_params->test == TD_BIN_TEST ) - { - if ( st_ivas.ivas_format == SBA_FORMAT ) - { - fprintf( stderr, "TD Renderer configuration wrong input format\n" ); - exit( -1 ); - } - - if ( st_ivas.hRenderConfig->roomAcoustics.use_brir ) - { - st_ivas.renderer_type = RENDERER_BINAURAL_OBJECTS_TD; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; - } - else - { - st_ivas.renderer_type = RENDERER_BINAURAL_OBJECTS_TD; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; - } - pIo_params->latency_s = BINAURAL_TD_LATENCY_S; - } - else if ( pIo_params->test == PARAM_BIN_TEST ) - { - if ( st_ivas.hRenderConfig->roomAcoustics.use_brir ) - { - st_ivas.renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL_ROOM; - } - else - { - st_ivas.renderer_type = RENDERER_BINAURAL_PARAMETRIC; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; - } - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate; - } - else if ( pIo_params->test == CREND_BIN_TEST ) - { - if ( st_ivas.hRenderConfig->roomAcoustics.use_brir ) - { - st_ivas.renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL_ROOM; - } - else - { - st_ivas.renderer_type = RENDERER_BINAURAL_MIXER_CONV; - st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; - } - } - else - { - fprintf( stderr, "Crend configuration wrong renderer\n" ); - exit( -1 ); - } - } - else - { - ivas_hrtf_init( st_ivas.hHrtf ); - } - - int32_t in_ch = audioCfg2channels( st_ivas.transport_config ); - int32_t out_ch = audioCfg2channels( st_ivas.hDecoderConfig->output_config ); - - /*------------------------------------------------------------------------------------------* - * State memory allocation for Common renderer - *------------------------------------------------------------------------------------------*/ - st_ivas.hDecoderConfig->Opt_Headrotation = pIo_params->orientation_tracking != OTR_TRACKING_NONE ? 1 : 0; - /*-------------------------------------------------------------------* - * Allocate and initialize Head-Tracking handle - *--------------------------------------------------------------------*/ - - if ( st_ivas.hDecoderConfig->Opt_Headrotation ) - { - if ( ( error = ivas_headTrack_open( &( st_ivas.hHeadTrackData ) ) ) != IVAS_ERR_OK ) - { - return IVAS_FAILED; - } - if ( ( error = HeadRotationFileReader_open( pIo_params->csv_path, &headRotReader ) ) != IVAS_ERR_OK ) - { - return IVAS_FAILED; - } - } - - st_ivas.nchan_transport = audioCfg2channels( st_ivas.transport_config ); - st_ivas.hIntSetup.index_lfe[0] = lfe_ch_idx; - st_ivas.hIntSetup.num_lfe = lfe_ch_idx > 0 ? 1 : 0; - - if ( pIo_params->test == FASTCONV_BIN_TEST ) - { - ivas_output_init( &st_ivas.hIntSetup, st_ivas.transport_config ); - int16_t numCldfbAnalyses, numCldfbSyntheses; - numCldfbAnalyses = st_ivas.nchan_transport; - numCldfbSyntheses = st_ivas.hDecoderConfig->nchan_out; - - for ( i = 0; i < numCldfbAnalyses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas.cldfbAnaDec[i] ), CLDFB_ANALYSIS, dec_io_params.out_sample_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return IVAS_FAILED; - } - } - for ( ; i < MAX_INTERN_CHANNELS; i++ ) - { - st_ivas.cldfbAnaDec[i] = NULL; - } - - for ( i = 0; i < numCldfbSyntheses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas.cldfbSynDec[i] ), CLDFB_SYNTHESIS, dec_io_params.out_sample_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return IVAS_FAILED; - } - } - for ( ; i < MAX_OUTPUT_CHANNELS; i++ ) - { - st_ivas.cldfbSynDec[i] = NULL; - } - - ivas_binRenderer_open( &st_ivas ); - } - else if ( pIo_params->test == TD_BIN_TEST ) - { - ivas_output_init( &st_ivas.hIntSetup, st_ivas.transport_config ); - ivas_output_init( &st_ivas.hOutSetup, st_ivas.transport_config ); - ivas_td_binaural_open( &st_ivas ); - } - else if ( pIo_params->test == PARAM_BIN_TEST ) - { - if ( ( pIo_params->in_fmt != FOA_4 ) && ( pIo_params->in_fmt != HOA_9 ) && ( pIo_params->in_fmt != HOA_16 ) ) - { - fprintf( stderr, "PARAM renderer configuration wrong format, must be FOA or HOA up to order 3\n" ); - exit( -1 ); - } - - ivas_output_init( &st_ivas.hIntSetup, st_ivas.transport_config ); - ivas_output_init( &st_ivas.hOutSetup, st_ivas.transport_config ); - st_ivas.hOutSetup.separateChannelEnabled = 1; - int16_t numCldfbAnalyses, numCldfbSyntheses; - numCldfbAnalyses = st_ivas.nchan_transport; - numCldfbSyntheses = st_ivas.hDecoderConfig->nchan_out; - - for ( i = 0; i < numCldfbAnalyses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas.cldfbAnaDec[i] ), CLDFB_ANALYSIS, dec_io_params.out_sample_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return IVAS_FAILED; - } - } - for ( ; i < MAX_INTERN_CHANNELS; i++ ) - { - st_ivas.cldfbAnaDec[i] = NULL; - } - - for ( i = 0; i < numCldfbSyntheses; i++ ) - { - if ( ( error = openCldfb( &( st_ivas.cldfbSynDec[i] ), CLDFB_SYNTHESIS, dec_io_params.out_sample_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return IVAS_FAILED; - } - } - for ( ; i < MAX_OUTPUT_CHANNELS; i++ ) - { - st_ivas.cldfbSynDec[i] = NULL; - } - } - else - { - ivas_output_init( &st_ivas.hIntSetup, st_ivas.transport_config ); - ivas_output_init( &st_ivas.hOutSetup, st_ivas.transport_config ); - ivas_crend_open( &st_ivas ); - } - - if ( pIo_params->test == CREND_BIN_TEST ) - { - pIo_params->latency_s = st_ivas.hHrtf->latency_s; - } - if ( st_ivas.ivas_format == MC_FORMAT ) - { - ivas_create_lfe_dec( &st_ivas.hLFE, st_ivas.hDecoderConfig->output_Fs, pIo_params->latency_s ); - if ( st_ivas.hLFE->lfe_addl_delay > 0 ) - { - if ( st_ivas.hLFE->lfe_delay_buf != NULL ) - { - count_free( st_ivas.hLFE->lfe_delay_buf ); - st_ivas.hLFE->lfe_delay_buf = NULL; - } - if ( pIo_params->latency_s > 0 ) - { - st_ivas.hLFE->lfe_addl_delay = (int16_t) roundf( pIo_params->latency_s * dec_io_params.out_sample_rate ); - if ( st_ivas.hLFE->lfe_addl_delay > 0 ) - { - if ( ( st_ivas.hLFE->lfe_delay_buf = (float *) count_malloc( st_ivas.hLFE->lfe_addl_delay * sizeof( float ) ) ) == NULL ) - { - fprintf( stderr, "Can not allocate memory for LFE additional delay buffer\n" ); - return IVAS_FAILED; - } - set_zero( (float *) st_ivas.hLFE->lfe_delay_buf, st_ivas.hLFE->lfe_addl_delay ); - } - } - else - { - st_ivas.hLFE->lfe_addl_delay = 0; - } - } - /* delay input channel of latency of lp filter*/ - if ( pIo_params->lfe_lp_enable ) - { - delay_lp = (int16_t) ( ivas_lfe_lpf_delay[1] * (float) pIo_params->sample_rate ); - for ( i = 0; i < in_ch - st_ivas.hIntSetup.num_lfe; i++ ) - { - if ( ( ppDelay_lines[i] = (float *) count_malloc( delay_lp * sizeof( float ) ) ) == NULL ) - { - fprintf( stderr, "Can not allocate memory for LFE additional delay buffer\n" ); - return IVAS_FAILED; - } - set_zero( (float *) ppDelay_lines[i], delay_lp ); - } - ivas_lfe_lpf_select_filt_coeff( pIo_params->sample_rate, IVAS_FILTER_ORDER_4, &filt_coeff ); - ivas_filters_init( &st_ivas.hLFE->filter_state, filt_coeff, IVAS_FILTER_ORDER_4 ); - pIo_params->latency_s = pIo_params->latency_s + ivas_lfe_lpf_delay[1]; - } - else - { - delay_lp = 0; - } - } - - if ( pIo_params->limiter_enable ) - { - st_ivas.hLimiter = ivas_limiter_open( out_ch, pIo_params->sample_rate ); - } - - /*------------------------------------------------------------------------------------------* - * Loop for every frame of input data - * - Read the input data - * - Run the Common renderer - * - Write the parameters into output bitstream file - *------------------------------------------------------------------------------------------*/ - -#define _FIND_MAX_ -#ifdef _FIND_MAX_ - float valMax = 0; - float valEner = 0; -#endif - - /* delay adjustment */ - int32_t skip_samples = 0; - int32_t skipped_samples = 0; - int16_t write_flag = 0; - if ( ( pIo_params->out_fmt == BIN_2 ) && ( pIo_params->no_delay_cmp == 0 ) ) - { - skip_samples = NS2SA( pIo_params->sample_rate, (int32_t) ( pIo_params->latency_s * 1000000000.f ) ); - } - fprintf( stdout, "IVAS Common Renderer skip samples = %d\n", (int) skip_samples ); - - frame_len = frame_len << 2; - - int32_t frame_dec = 0; - IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { 0 }; - - /* process loop */ - while ( ( ( result = ivas_wrapper_get_in_buf( pIo_params, ppPcm_in ) ) == IVAS_SUCCESS ) && ( ( st_ivas.hDecoderConfig->Opt_Headrotation == 0 ) || ( ( st_ivas.hDecoderConfig->Opt_Headrotation == 1 ) && ( HeadRotationFileReading( headRotReader, Quaternions, frame_dec ) == IVAS_ERR_OK ) ) ) ) - { - int16_t pcm[MAX_OUTPUT_CHANNELS]; - frame_dec++; - result = IVAS_SUCCESS; - if ( ( st_ivas.hDecoderConfig->Opt_Headrotation == 1 ) && ( ivas_feed_head_track_data( &st_ivas, Quaternions ) != IVAS_SUCCESS ) ) - { - return IVAS_IO_ERROR; - } - - if ( pIo_params->lfe_lp_enable ) - { - /* ADD delay to make overall max(block_offset, 11.5)*/ - if ( st_ivas.hLFE->lfe_addl_delay > 0 ) - { - delay_signal( ppPcm_in[lfe_ch_idx], frame_len, st_ivas.hLFE->lfe_delay_buf, st_ivas.hLFE->lfe_addl_delay ); - } - - ivas_filter_process( &st_ivas.hLFE->filter_state, ppPcm_in[lfe_ch_idx], frame_len ); - } - - if ( pIo_params->test == FASTCONV_BIN_TEST ) - { - ivas_binaural_cldfb( &st_ivas, ppPcm_in ); - } - else if ( pIo_params->test == TD_BIN_TEST ) - { - ObjRenderIVASFrame( &st_ivas, ppPcm_in, frame_len ); - } - else if ( pIo_params->test == PARAM_BIN_TEST ) - { - float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - int16_t slot_idx, maxBand, ch; - float gain = powf( 10.f, -6.f / 20.f ); /* add gain to compensate loudness with decoder, but are missing when compare to other renderers*/ - - /* Implement a 5 msec loops */ - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas.hDecoderConfig->output_Fs ) / 48000 ); - - for ( slot_idx = 0; slot_idx < (int16_t) CLDFB_NO_COL_MAX; slot_idx++ ) - { - - for ( ch = 0; ch < in_ch; ch++ ) - { - cldfbAnalysis_ts( &( ppPcm_in[ch][maxBand * slot_idx] ), - Cldfb_RealBuffer[ch][slot_idx], - Cldfb_ImagBuffer[ch][slot_idx], - maxBand, st_ivas.cldfbAnaDec[ch] ); - } - } - - for ( slot_idx = 0; slot_idx < (int16_t) CLDFB_NO_COL_MAX; slot_idx++ ) - { - /* Implement binaural rendering */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - float *outSlotRePr, *outSlotImPr; /* Pointers needed for function call compatibility */ - - set_zero( RealBuffer, maxBand ); - set_zero( ImagBuffer, maxBand ); - - int16_t bandIdx, chIdx; - const float *filterTapsRealPtr, *filterTapsImagPtr; - - for ( chIdx = 0; chIdx < in_ch; chIdx++ ) - { - filterTapsRealPtr = hrtfShCoeffsRe[ch][chIdx]; - filterTapsImagPtr = hrtfShCoeffsIm[ch][chIdx]; - - for ( bandIdx = 0; bandIdx < maxBand; bandIdx++ ) - { - RealBuffer[bandIdx] += gain * ( Cldfb_RealBuffer[chIdx][slot_idx][bandIdx] * filterTapsRealPtr[bandIdx] ) - ( Cldfb_ImagBuffer[chIdx][slot_idx][bandIdx] * filterTapsImagPtr[bandIdx] ); - ImagBuffer[bandIdx] += gain * ( Cldfb_RealBuffer[chIdx][slot_idx][bandIdx] * filterTapsImagPtr[bandIdx] ) + ( Cldfb_ImagBuffer[chIdx][slot_idx][bandIdx] * filterTapsRealPtr[bandIdx] ); - } - } - outSlotRePr = &( RealBuffer[0] ); - outSlotImPr = &( ImagBuffer[0] ); - cldfbSynthesis( &outSlotRePr, &outSlotImPr, &( ppPcm_in[ch][slot_idx * maxBand] ), maxBand, st_ivas.cldfbSynDec[ch] ); - } - } - } - else - { - if ( mixer != NULL ) - { - ivas_crend_mixer( ppPcm_in, ppPcm_out, in_ch, out_ch, mixer, frame_len ); - } - else - { - ivas_crend_process( &st_ivas, ppPcm_in ); - } - } - - if ( mixer == NULL ) - { - if ( pIo_params->lfe_lp_enable ) - { - for ( i = 0; i < out_ch; i++ ) - { - delay_signal( ppPcm_in[i], frame_len, ppDelay_lines[i], delay_lp ); - } - } - - ivas_binaural_add_LFE( &st_ivas, frame_len, ppPcm_in ); - - for ( i = 0; i < out_ch; i++ ) - { - mvr2r( ppPcm_in[i], ppPcm_out[i], frame_len ); - } - if ( pIo_params->limiter_enable ) - { - ivas_limiter_dec( st_ivas.hLimiter, ppPcm_out, out_ch, frame_len, 0 ); - } - } - - - float valMaxLoc = 0; - float clip = 1.0f; - for ( j = 0; j < frame_len; j++ ) - { - if ( ( write_flag == 0 ) && ( skipped_samples == skip_samples ) ) - { - write_flag = 1; - } - for ( i = 0; i < out_ch; i++ ) - { - // float temp = roundf( ppPcm_out[i][j] * PCM16_TO_FLT_FAC ); - float temp; -#ifdef _FIND_MAX_ - valMaxLoc = ( ppPcm_out[i][j] > valMaxLoc ) ? ppPcm_out[i][j] : ( ppPcm_out[i][j] < -valMaxLoc ) ? -ppPcm_out[i][j] - : valMaxLoc; - /* if (valMaxLoc > 1.0) printf("Saturation valMax = %f at frame_len = %ld sample = %ld \n", valMaxLoc, frame_len, i); */ - if ( valMax < valMaxLoc ) - valMax = valMaxLoc; - valEner += ppPcm_out[i][j] * ppPcm_out[i][j]; -#endif - temp = ( ppPcm_out[i][j] > MAX16B_FLT ) ? MAX16B_FLT : ( ppPcm_out[i][j] < MIN16B_FLT ) ? MIN16B_FLT - : ppPcm_out[i][j]; - pcm[i] = (short) roundf( temp ); - clip = max( clip, fabsf( ppPcm_out[i][j] ) ); - } - if ( write_flag == 1 ) - { -#ifdef USE_PCM_OUT - fwrite( pcm, sizeof( int16_t ), out_ch, pIo_params->fOut ); -#else - AudioFileWriter_write( pIo_params->fOut, pcm, out_ch ); -#endif - } - if ( write_flag == 0 ) - skipped_samples++; - } - if ( clip > MAX16B_FLT ) - { - fprintf( stdout, "IVAS Common Renderer Clipped: max gain = %f\n", clip ); - } - - fprintf( stdout, "Processed frame: %ld\r", (long) frame_count ); - frame_count++; - } - - int16_t pcm[MAX_OUTPUT_CHANNELS] = { 0 }; - while ( skipped_samples > 0 ) - { - AudioFileWriter_write( pIo_params->fOut, pcm, out_ch ); - skipped_samples--; - } - -#ifdef _FIND_MAX_ - valEner = sqrt( valEner / ( frame_count * frame_len ) ); - printf( "valMax = %f valEner = %f \n", 20.f * log10( valMax ), 20.f * log10( valEner ) ); -#endif - printf( "Total Frames Processed : %lld\n", (long long int) frame_count ); - - if ( st_ivas.hLFE ) - { - ivas_lfe_dec_close( st_ivas.hLFE ); - } - - if ( st_ivas.hDirAC != NULL ) - ivas_dirac_dec_close( st_ivas.hDirAC ); - if ( st_ivas.hBinRenderer != NULL ) - ivas_binRenderer_close( &st_ivas.hBinRenderer ); - ivas_crend_close( &st_ivas ); - if ( st_ivas.hBinRendererTd != NULL ) - ivas_td_binaural_close( &st_ivas.hBinRendererTd ); - if ( st_ivas.hLimiter != NULL ) - ivas_limiter_close( &st_ivas.hLimiter ); - if ( st_ivas.hEFAPdata != NULL ) - efap_free_data( &st_ivas.hEFAPdata ); - - if ( pIo_params->lfe_lp_enable ) - { - for ( i = 0; i < in_ch - st_ivas.hIntSetup.num_lfe; i++ ) - { - count_free( ppDelay_lines[i] ); - } - } - if ( st_ivas.hRenderConfig != NULL ) - { - ivas_render_config_close( &st_ivas.hRenderConfig ); - } - - /* Head track data handle */ - if ( st_ivas.hHeadTrackData != NULL ) - { - count_free( st_ivas.hHeadTrackData ); - st_ivas.hHeadTrackData = NULL; - } - - if ( headRotReader ) - { - HeadRotationFileReader_close( &headRotReader ); - } - - -#ifdef RAM_COUNTING_TOOL - mem_count_summary( USE_DEFAULT ); -#endif - - return IVAS_SUCCESS; -} - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Object mixer renderer block - * - * Inputs - - * ivas_enc_io_params_t io_params - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_object_mixer_renderer( ivas_crend_io_params_t *pIo_params, int16_t *userLoc ) -{ - ivas_result_t result = IVAS_SUCCESS; - - float ppPcm_in[IVAS_MAX_NUM_CH][L_FRAME48k]; - float ppPcm_out[IVAS_MAX_NUM_CH][L_FRAME48k]; - DECODER_CONFIG decoder_config; - Decoder_Struct st_ivas; - - memset( &st_ivas, 0, sizeof( Decoder_Struct ) ); - - st_ivas.hDecoderConfig = &decoder_config; - memset( st_ivas.hDecoderConfig, 0, sizeof( DECODER_CONFIG ) ); - - int64_t frame_count = 0; - - int32_t i = 0, j = 0; - int32_t frame_len = 0; - - float *Smixer; - float *powvec; - ivas_dec_io_params_t dec_io_params = { 0 }; - int16_t in_format; - int16_t lfe_ch_idx; - - ivas_dec_default_io_params( &dec_io_params ); - ivas_copy_io_params_to_dec_io_params( pIo_params, &dec_io_params ); - - frame_len = ivas_wrapper_get_frame_len( pIo_params->sample_rate ); - -#ifdef USE_PCM_OUT - /* skip WAV header */ - for ( i = 0; i < IVAS_MAX_NUM_CH; i++ ) - { - if ( pIo_params->fIn[i] != NULL ) - { - result = ivas_wav_header_skip( pIo_params->fIn[i] ); - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "WAV header skip failed\n" ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - } - } -#endif - - result = ivas_crend_set_config_params( &decoder_config, &dec_io_params, &in_format, &lfe_ch_idx ); - - st_ivas.transport_config = ivas_crend_map_out_fmt( in_format ); - - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "Crend configuration parameters setting failed\n" ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - - /*------------------------------------------------------------------------------------------* - * State memory allocation for Common renderer - *------------------------------------------------------------------------------------------*/ - decoder_config.Opt_Headrotation = 0; - ivas_crend_open( &st_ivas ); - - /*------------------------------------------------------------------------------------------* - * In/out buffer memory allocation for encoder - *------------------------------------------------------------------------------------------*/ - int32_t in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - int32_t out_ch = ivas_get_num_channels( pIo_params->out_fmt ); - - Smixer = (float *) calloc( in_ch, sizeof( float ) ); - powvec = (float *) calloc( in_ch, sizeof( float ) ); - - /* init - ignore FLC */ - for ( i = 0; i < in_ch; i++ ) - { - powvec[i] = 0.0f; - } - - /*------------------------------------------------------------------------------------------* - * Loop for every frame of input data - * - Read the input data - * - Run the Common renderer - * - Write the parameters into output bitstream file - *------------------------------------------------------------------------------------------*/ - -#define _FIND_MAX_ -#ifdef _FIND_MAX_ - float valMax = 0; - float valEner = 0; -#endif - - while ( ( ( result = ivas_wrapper_get_in_buf( pIo_params, ppPcm_in ) ) == IVAS_SUCCESS ) ) /* process loop */ - { -#ifdef USE_PCM_OUT - int16_t pcm; -#else - int16_t pcm[MAX_OUTPUT_CHANNELS]; -#endif - result = IVAS_SUCCESS; - - /* get the mixing matrix.. */ - get_prox_downmix_mixer( (int16_t) PROXIMITY_USER_ID, Smixer, userLoc, in_ch, ppPcm_in, frame_len, powvec ); - - result = ivas_crend_mixer( ppPcm_in, ppPcm_out, in_ch, out_ch, Smixer, frame_len ); - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "Error: ivas_crend_process failed with %d \n\n", (int32_t) result ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - - float valMaxLoc = 0; - - for ( j = 0; j < frame_len; j++ ) - { - - for ( i = 0; i < out_ch; i++ ) - { - - // float temp = roundf( ppPcm_out[i][j] * PCM16_TO_FLT_FAC ); - float temp = roundf( ppPcm_out[i][j] ); -#ifdef _FIND_MAX_ - - valMaxLoc = ( ppPcm_out[i][j] > valMaxLoc ) ? ppPcm_out[i][j] : ( ppPcm_out[i][j] < -valMaxLoc ) ? -ppPcm_out[i][j] - : valMaxLoc; - /* if (valMaxLoc > 1.0) printf("Saturation valMax = %f at frame_len = %ld sample = %ld \n", valMaxLoc, frame_len, i); */ - - if ( valMax < valMaxLoc ) - { - valMax = valMaxLoc; - } - valEner += ppPcm_out[i][j] * ppPcm_out[i][j]; -#endif - -#ifdef USE_PCM_OUT - pcm = ( temp > MAX16B_FLT ) ? MAX16B : ( temp < MIN16B_FLT ) ? MIN16B - : (short) temp; - fwrite( &pcm, sizeof( int16_t ), 1, pIo_params->fOut ); -#else - pcm[i] = ( temp > MAX16B_FLT ) ? MAX16B : ( temp < MIN16B_FLT ) ? MIN16B - : (short) temp; - -#endif - } -#ifndef USE_PCM_OUT - AudioFileWriter_write( pIo_params->fOut, pcm, out_ch ); -#endif - } - - frame_count++; - } - free( powvec ); - free( Smixer ); - -#ifdef _FIND_MAX_ - valEner = sqrt( valEner / ( frame_count * frame_len ) ); - printf( "valMax = %f valEner = %f \n", 20.f * log10( valMax ), 20.f * log10( valEner ) ); -#endif - printf( "Total Frames Processed : %lld\n", (long long int) frame_count ); - - ivas_crend_close( &st_ivas ); - - return IVAS_SUCCESS; -} diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_dec_parse_io.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_dec_parse_io.h deleted file mode 100644 index 97962a785b..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_dec_parse_io.h +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#ifndef IVAS_DEC_PARSE_IO_H -#define IVAS_DEC_PARSE_IO_H - -/**************************************************************************** -* File description - -* This header file contains declarations for IO/cmd line params parsing of IVAS decoder -****************************************************************************/ - -/*------------------------------------------------------------------------------------------* -* include header files -*------------------------------------------------------------------------------------------*/ -#include -#include -#include -#include "ivas_cnst.h" -#include "audio_file_writer.h" - -/*------------------------------------------------------------------------------------------* -* PreProcessor -*------------------------------------------------------------------------------------------*/ - -#define IVAS_IN_FMT_COMBINED "Combined" -#define IVAS_IN_FMT_HOA_3 "HOA3S" - -#define MAX_PCM_OUT_FILES ( IVAS_MAX_NUM_CH ) -#define REQ_DEC_CMD_LINE_PARAMS ( 7 ) - -#define IVAS_MAX_PATH_LEN ( 2000 ) - -#define IVAS_EXT_ADD_DELAY_MS ( 2 ) -#define MAX_OUT_FILE_LEN ( 1000 ) -#define MAX_CH_IDX_TAG_LEN ( 10 ) - -/*------------------------------------------------------------------------------------------* -* Global variables -*------------------------------------------------------------------------------------------*/ -/* IVAS bitstream formats */ -#define IVAS_G192 ( 0 ) -#define IVAS_MIME ( 1 ) - -/* IVAS decoder output formats */ -#define IVAS_NO_RENDERER ( -1 ) /* no renderer required */ - -#define IVAS_DEFAULT_QUIET_MODE ( 0 ) -#define IVAS_DEFAULT_NO_DELAY_COMP_MODE ( 0 ) -#define IVAS_DEFAULT_BS_FORMAT ( IVAS_G192 ) -#define IVAS_DEFAULT_FMT ( IVAS_NO_RENDERER ) -#define IVAS_DEFAULT_LFE_CH_IDX ( 3 ) /* ch count starting from 0 */ -#define IVAS_DEFAULT_AGC ( 0 ) - -#define IVAS_IN_FMT_510 "510" -#define IVAS_IN_FMT_710 "710" -#define IVAS_IN_FMT_512 "512" -#define IVAS_IN_FMT_514 "514" -#define IVAS_IN_FMT_714 "714" -#define IVAS_IN_FMT_FOA "HOA1S" -#define IVAS_IN_FMT_HOA_2 "HOA2S" -#define IVAS_IN_FMT_HOA_3 "HOA3S" -#define IVAS_IN_FMT_HOA_4 "HOA4S" - -#define IVAS_MAX_NUM_CH 16 - -/*------------------------------------------------------------------------------------------* -* Structure definitions -*------------------------------------------------------------------------------------------*/ -typedef struct ivas_dec_io_params_t -{ - int32_t in_fmt; - int32_t out_sample_rate; - int32_t out_fmt; - int32_t crend_enable; - int16_t quiet_mode; - int16_t no_delay_cmp; - int16_t bs_format; - int16_t lfe_ch_idx; - int16_t block_offset_ms; -#ifdef USE_PCM_OUT - FILE *fOut[MAX_PCM_OUT_FILES]; -#else - AudioFileWriter *fOut[MAX_PCM_OUT_FILES]; -#endif - FILE *fBs; - FILE *fMd; - FILE *fPlc; - char sofa_path[IVAS_MAX_PATH_LEN]; - char csv_path[IVAS_MAX_PATH_LEN]; - int16_t orientation_tracking; - int16_t coding_tool; - float no_diegetic_pan; - int16_t renderConfigEnabled; - int16_t use_brir; - char renderConfigFilename[IVAS_MAX_PATH_LEN]; -#ifdef DEBUG_AGC - FILE *agcBitstream; /* temporary */ -#endif -#ifdef DEBUG_SBA - int8_t file_tag[50]; - int16_t dtx_on; -#endif - -} ivas_dec_io_params_t; - - -#endif diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c deleted file mode 100644 index 2bf19080e5..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c +++ /dev/null @@ -1,229 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*-----------------------------------------------------------------------------------------* -* File description - -* This file contains funciton definitions which are common between IVAS spatial decoding -* tools -*-----------------------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------------------* -* include header files -*------------------------------------------------------------------------------------------*/ -#include -#include "options.h" -#ifdef DEBUGGING -#include "debug.h" -#endif -#include "ivas_prox_mix.h" -#include "wmops.h" - -/*------------------------------------------------------------------------------------------* -* PreProcessor -*------------------------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------------------* - * Global variables - *------------------------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------------------* - * Static functions declaration - *------------------------------------------------------------------------------------------*/ - -static float get_block_power( float *vec, int32_t frame_len ); - -/*------------------------------------------------------------------------------------------* - * function definitions - *------------------------------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------------------------* - * Function description - Returns mixer to combine uplink signals in an intelligent way to - * prevent unnecessary reproduction of certain signals and prevent acoustic feedback. - * - * Inputs - - * userID: a given user ID - * bitstream: float of bitstream data containing co-located user IDs - * pMixer: a 1-d mixer to be used in ivas_crend to combine the multichannel audio data into - * a single Mono signal. - * Outputs - - * - * - * - *-----------------------------------------------------------------------------------------*/ - -ivas_result_t get_users_locations( - uint8_t *bitstream, - int32_t len, - int16_t *userLoc ) -{ - /* userID = channelID starting from index=0 */ - int16_t nrLoc = 1; - int32_t i; - - /* enter user location depending on position in userLoc array */ - for ( i = 0; i < len; i++ ) - { - - if ( bitstream[i] == LOC_BITSTREAM_DELIMITER ) - { - nrLoc++; - } - else - { - userLoc[bitstream[i]] = nrLoc; - } - } - - return IVAS_SUCCESS; -} - - -ivas_result_t get_prox_downmix_mixer( - int16_t userID, - float *sMixer, - int16_t *userLoc, - int32_t nChan, - float ppPcm_in[][L_FRAME48k], - int32_t frame_len, - float *powvec ) -{ - /* userID = channelID starting from index=0 */ - int16_t nrUsers = 0, nrLoc = 0; - int32_t i, j; - int16_t locIdx = 0; - float pow_1, pow_2; - float *pow; - - pow = (float *) calloc( nChan, sizeof( float ) ); - - /* init */ - for ( i = 0; i < nChan; i++ ) - { - pow[i] = get_block_power( ppPcm_in[i], frame_len ); - - if ( pow[i] >= powvec[i] ) - { - powvec[i] = POWER_SMOOTH_HI * ( powvec[i] - pow[i] ) + pow[i]; - } - else - { - powvec[i] = POWER_SMOOTH_LO * ( powvec[i] - pow[i] ) + pow[i]; - } - /* reset the mixer */ - sMixer[i] = 0.0f; - } - - /* first find the room where userID is located*/ - locIdx = userLoc[userID]; - - /* iterate one more time, this time ignoring the room where the user is in. */ - for ( i = 0; i < nChan; i++ ) - { - if ( ( locIdx != userLoc[i] ) && ( userLoc[i] > 0 ) ) - { - sMixer[i] = 1.0f; - - nrUsers++; - - if ( userLoc[i] > nrLoc ) - { - nrLoc = userLoc[i]; - } - } - } - - /* Check for co-located users and select user with max */ - /* nrUsers contains the number of far-end users, i.e non-co-located*/ - /* These have to be treated differently */ - for ( i = 0; i < nChan; i++ ) - { - if ( sMixer[i] > 0.0f ) - { - locIdx = userLoc[i]; - pow_1 = powvec[i]; - for ( j = i + 1; j < nChan; j++ ) - { - if ( userLoc[j] == locIdx ) - { - /* compare signal power in block.. */ - pow_2 = powvec[j]; - - if ( pow_2 > POWER_FACT * pow_1 ) - { - sMixer[i] = 0.0f; - break; - } - else - { - sMixer[j] = 0.0f; - } - } - } - } - } - - nrUsers = 0; - for ( i = 0; i < nChan; i++ ) - { - if ( sMixer[i] > 0.0f ) - { - nrUsers++; - } - } - - if ( nrUsers != 0 ) - { - for ( i = 0; i < nChan; i++ ) - { - sMixer[i] = sMixer[i] / (float) nrUsers; - } - } - free( pow ); - - return IVAS_SUCCESS; -} - - -static float get_block_power( - float *vec, - int32_t frame_len ) -{ - int32_t i; - float pow = 0.0f; - - for ( i = 0; i < frame_len; i++ ) - { - pow = pow + vec[i] * vec[i]; - } - - return pow; -} diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h deleted file mode 100644 index 8aa4b57130..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - - -#ifndef IVAS_PROX_MIX_H -#define IVAS_PROX_MIX_H - -/**************************************************************************** -* File description - -* This header file contains declarations which are common between IVAS -* spatial decoding tools -****************************************************************************/ - -/*------------------------------------------------------------------------------------------* -* include header files -*------------------------------------------------------------------------------------------*/ -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include "ivas_stat_dec.h" -#include "ivas_result_t.h" - -/*------------------------------------------------------------------------------------------* -* PreProcessor -*------------------------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------------------* - * Global variables - *------------------------------------------------------------------------------------------*/ -#define LOC_BITSTREAM_DELIMITER ( 128 ) -#define MAX_BITSTREAM_LEN ( 128 ) -#define POWER_FACT ( 1.2f ) -#define POWER_SMOOTH_HI ( 0.8f ) -#define POWER_SMOOTH_LO ( 0.95f ) - -/*------------------------------------------------------------------------------------------* - * function declarations - *------------------------------------------------------------------------------------------*/ -ivas_result_t get_users_locations( uint8_t *bitstream, int32_t len, int16_t *userLoc ); -ivas_result_t get_prox_downmix_mixer( int16_t userID, float *pMixer, int16_t *userLoc, int32_t nChan, float ppPcm_in[][L_FRAME48k], int32_t frame_len, float *powvec ); - -#endif diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_result_t.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_result_t.h deleted file mode 100644 index 7702760f4c..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_result_t.h +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#ifndef IVAS_RESULT_H -#define IVAS_RESULT_H - -/*----------------------------------------------------------------------------------* - * IVAS Error codes - *----------------------------------------------------------------------------------*/ - -typedef enum ivas_result_t -{ - IVAS_SUCCESS = 0, - IVAS_FAILED = -1, - IVAS_IO_ERROR = -2, - IVAS_MEM_ERROR = -3, - IVAS_READ_DONE = -4, - IVAS_INVALID_SOFA_FORMAT = -5, - IVAS_SOFA_UNKNOWN_VARIABLE = -6, - IVAS_SOFA_FILE_OPEN_FAILED = -7, - IVAS_SOFA_FILE_READ_FAILED = -8, - IVAS_SOFA_FILE_SEEK_FAILED = -9, - IVAS_SOFA_DATA_UNZIP_FAILED = -10, - -} ivas_result_t; - -#endif diff --git a/scripts/ivas_pytests/tests/unit_tests/disabled_test_crend_unittest.py b/scripts/ivas_pytests/tests/unit_tests/disabled_test_crend_unittest.py deleted file mode 100644 index 51345971f9..0000000000 --- a/scripts/ivas_pytests/tests/unit_tests/disabled_test_crend_unittest.py +++ /dev/null @@ -1,576 +0,0 @@ -""" - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. -""" - -import os -import subprocess -import pytest -import errno -import tempfile as tf -import sys -import shutil -from scipy.io.wavfile import read, write -import numpy as np - -unit_test_path = "/scripts/ivas_pytests" -inpath = os.getenv("TESTVECTOR_PATH_REL_GROUPB") -if not inpath: - # Assuming `data` folder is checked out at the same level as trunk - inpath = '../../../data/ivas_pytests/unit_tests/' -inpath_sh = os.getenv("TESTVECTOR_PATH_REL_TRUNK") -if not inpath_sh: - # Assuming `data` folder is checked out at the same level as trunk - inpath_sh = '/../data/ivas_pytests/unit_tests/' - -unit_test_exe = os.getenv("CREND_UNIT_TEST_BIN") -if not unit_test_exe: - if sys.platform.startswith('win32'): - unit_test_exe = 'tests/unit_tests/crend/IVAS_crend_unit_test.exe' - else: - unit_test_exe = './tests/unit_tests/crend/IVAS_crend_unit_test' - -p4EditCmd = 'p4 edit -c ' -p4AddCmd = 'p4 add -c ' -p4RevertCmd = 'p4 revert -a -c ' - - -#Input/Output formats -MONO_1 = '0' -STEREO_2 = '1' -BIN_2 = '2' -FOA_4 = '3' -MULT_CH_5_1 = '4' -MULT_CH_7_1 = '5' -MULT_CH_5_1_2 = '6' -MULT_CH_7_1_4 = '7' -HOA_9 = '8' -HOA_16 = '9' -OBA_25 = '10' - -#List of Tests -CREND_BIN_TEST = '1' -FASTCONV_BIN_TEST = '2' -PARAM_BIN_TEST = '3' -TD_BIN_TEST = '4' -CREND_ACOUSTIC_PROXIMITY = '5' -CREND_NO_DIEGETIC_TEST = '6' -CREND_REVERB = '7' - -CHECK_PASS = 1 -CHECK_FAIL = 0 -CHECK_INFMT_ERROR = 2 - -ZERO_TOL = 0 - -projects = ['/chan_stereo/','/chan_binaural/','/scen_HOA1S/','/chan_standard_510/','/chan_standard_710/'] - -out_fmt_list = [MONO_1, STEREO_2, MULT_CH_5_1, MULT_CH_7_1, MULT_CH_5_1_2, MULT_CH_7_1_4] -prox_path = inpath + 'crend/tests/proximity/bitstream/userSharingLoc.bin' -csv_path = inpath + 'crend/tests/csv/' - -rel_in_csv_file_path_crend = 'crend/tests/crend/in_csv_wav' -in_csv_file_path_crend = inpath + rel_in_csv_file_path_crend -rel_in_new_file_path_crend = 'crend/tests/crend/in_new_wav' -in_new_file_path_crend = inpath + rel_in_new_file_path_crend -rel_in_file_path_crend = 'crend/tests/crend/in_wav' -in_file_path_crend = inpath + rel_in_file_path_crend - -rel_in_file_path_reverb = 'crend/tests/reverb/in_wav' -rel_in_cfg_path_reverb = 'crend/tests/reverb' -in_file_path_reverb = inpath + rel_in_file_path_reverb -render_cfg_path = inpath + 'crend/tests/render_config' - -temp = os.getcwd() + inpath_sh + rel_in_file_path_reverb - -# D:\DEV\IVAS-Ref\trunk\scripts\ivas_pytests\testv\crend\tests - -file_list_reverb_in = os.listdir(os.getcwd() + inpath_sh + rel_in_file_path_reverb) - -in_file_path_prox = inpath + 'crend/tests/proximity/in_wav' - -rel_in_file_path_custom = 'crend/tests/custom/in_wav' -in_file_path_custom = inpath + rel_in_file_path_custom - -file_list_crend_bin = os.listdir(os.getcwd() + inpath_sh + rel_in_file_path_crend) - -file_list_crend_in = os.listdir(os.getcwd() + inpath_sh + rel_in_file_path_crend) -file_list_crend_new = os.listdir(os.getcwd() + inpath_sh + rel_in_new_file_path_crend) -file_list_crend_csv = os.listdir(os.getcwd() + inpath_sh + rel_in_csv_file_path_crend) - -file_list_crend_foa = [file for file in file_list_crend_in if "HOA" in file and ".wav" in file] - -# file_list_crend_in_new_hoa is currently unused -file_list_crend_in_new_hoa = [file for file in file_list_crend_new if "HOA" in file and ".wav" in file] - -# file_list_crend_in_48k is currently unused -file_list_crend_in_48k = [file for file in file_list_crend_in if "48k" in file and ".wav" in file] - -file_list_custom_bin = os.listdir(os.getcwd() + inpath_sh + rel_in_file_path_custom) - -# file_list_custom_bin_48k is currently unused -file_list_custom_bin_48k = [file for file in file_list_custom_bin if "48k" in file and ".wav" in file] - -file_list_custom_hoa = [file for file in file_list_custom_bin if "HOA" in file and ".wav" in file] -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - -crend_unit_test_proximity = [(OBA_25, MONO_1, '/proximity/', prox_path),] - -# bin_test_cases = [CREND_BIN_TEST, FASTCONV_BIN_TEST, PARAM_BIN_TEST, TD_BIN_TEST] -bin_test_cases = [CREND_BIN_TEST] - -#CREND_TEST_CSV -@pytest.mark.create_ref -@pytest.mark.parametrize("file", file_list_crend_csv) -def test_ivas_crend_csv(rootdir, update_ref, p4_CL, p4cmd_active, reference_path, dut_base_path, file): - os.chdir(rootdir + unit_test_path) - - if ".wav" in file: - if '32k' in file: - fs = '32' - elif '16k' in file: - fs = '16' - elif '48k' in file: - fs = '48' - else: - fs = 'NA' - - if fs != 'NA': - if reference_path: - ref_file_path_csv = f"{reference_path}/crend/otr/wav" - else: - ref_file_path_csv = inpath + 'crend/tests/otr/ref_wav' - if dut_base_path: - out_file_path_csv = f"{dut_base_path}/crend/otr/wav" - else: - out_file_path_csv = inpath + 'crend/tests/otr/out_wav' - check_and_makedir(out_file_path_csv) - if update_ref == 1: - check_and_makedir(ref_file_path_csv) - - - infile = in_csv_file_path_crend + "/" + file - reffile1 = ref_file_path_csv + "/" + file[:-4] + '_binRot_csv1_ref.wav' - reffile2 = ref_file_path_csv + "/" + file[:-4] + '_binRot_csv2_ref.wav' - reffile3 = ref_file_path_csv + "/" + file[:-4] + '_binRot_csv2_avg.wav' - outfile1 = out_file_path_csv + "/" + file[:-4] + '_binRot_csv1_ref.wav' - outfile2 = out_file_path_csv + "/" + file[:-4] + '_binRot_csv2_ref.wav' - outfile3 = out_file_path_csv + "/" + file[:-4] + '_binRot_csv2_avg.wav' - csvfile1 = csv_path + 'headrot.csv' - csvfile2 = csv_path + 'headrot_case00_3000_q.csv' - - ivas_crend_run(CHECK_PASS, '48', CREND_BIN_TEST, HOA_16, BIN_2, infile, reffile1, outfile1, 'NA', 'NA', 'NA', csvfile1, 'ref', 'NA', 'NA', 'NA', 'NA', update_ref, '', p4cmd_active) - ivas_crend_run(CHECK_PASS, '48', CREND_BIN_TEST, HOA_16, BIN_2, infile, reffile2, outfile2, 'NA', 'NA', 'NA', csvfile2, 'ref', 'NA', 'NA', 'NA', 'NA', update_ref, '', p4cmd_active) - ivas_crend_run(CHECK_PASS, '48', CREND_BIN_TEST, HOA_16, BIN_2, infile, reffile3, outfile3, 'NA', 'NA', 'NA', csvfile2, 'avg', 'NA', 'NA', 'NA', 'NA', update_ref, '', p4cmd_active) - -#CREND_REVERB -@pytest.mark.create_ref -@pytest.mark.parametrize("file", file_list_reverb_in) -def test_ivas_crend_reverb(rootdir, update_ref, p4_CL, p4cmd_active, reference_path, dut_base_path, file): - os.chdir(rootdir + unit_test_path) - - if ".wav" in file: - if '32k' in file: - fs = '32' - elif '16k' in file: - fs = '16' - elif '48k' in file: - fs = '48' - else: - fs = 'NA' - - if fs != 'NA': - if reference_path: - ref_file_path_reverb = f"{reference_path}/crend/reverb/wav" - else: - ref_file_path_reverb = inpath + 'crend/tests/reverb/ref_wav' - if dut_base_path: - out_file_path_reverb = f"{dut_base_path}/crend/reverb/wav" - else: - out_file_path_reverb = inpath + 'crend/tests/reverb/out_wav' - check_and_makedir(out_file_path_reverb) - if update_ref == 1: - check_and_makedir(ref_file_path_reverb) - - infile = in_file_path_reverb + '/' + file - reffile = ref_file_path_reverb + '/' + file[:-4] + '_reverb.wav' - outfile = out_file_path_reverb + '/' + file[:-4] + '_reverb.wav' - render_config_file_path = render_cfg_path + '/' + 'just_reverb.cfg' - - ivas_crend_run(CHECK_PASS, fs, CREND_BIN_TEST, MULT_CH_5_1, BIN_2, infile, reffile, outfile, 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', render_config_file_path, update_ref, p4_CL, p4cmd_active) - -#CREND_PROXIMITY -@pytest.mark.create_ref -@pytest.mark.parametrize("ifmt, ofmt, project, prox", crend_unit_test_proximity) -def test_ivas_crend_proximity(rootdir, update_ref, p4_CL, p4cmd_active, reference_path, dut_base_path, ifmt, ofmt, project, prox): - - project += "" # just to remove a warning about an unused argument - - os.chdir(rootdir + unit_test_path) - - if reference_path: - ref_file_path_prox = f"{reference_path}/crend/proximity/wav" - else: - ref_file_path_prox = inpath + 'crend/tests/proximity/ref_wav' - if dut_base_path: - out_file_path_prox = f"{dut_base_path}/crend/proximity/wav" - else: - out_file_path_prox = inpath + 'crend/tests/proximity/out_wav' - check_and_makedir(out_file_path_prox) - if update_ref == 1: - check_and_makedir(ref_file_path_prox) - - infile = in_file_path_prox + "/" + 'au_up_oba.wav' - reffile = ref_file_path_prox + "/" + 'au_up_oba_100_prox.wav' - outfile = out_file_path_prox + "/" + 'au_up_oba_100_prox.wav' - - ivas_crend_run(CHECK_PASS, '48', CREND_ACOUSTIC_PROXIMITY, ifmt, ofmt, infile, reffile, outfile, 'NA', prox, 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', update_ref, p4_CL, p4cmd_active) - -#CREND_NO_DIEGETIC_TEST -@pytest.mark.create_ref -def test_ivas_crend_non_diegitic(rootdir, update_ref, p4_CL, p4cmd_active, reference_path, dut_base_path): - os.chdir(rootdir + unit_test_path) - - if reference_path: - ref_file_path_crend = f"{reference_path}/crend/crend/wav" - else: - ref_file_path_crend = inpath + 'crend/tests/crend/ref_wav' - if dut_base_path: - out_file_path_crend = f"{dut_base_path}/crend/crend/wav" - else: - out_file_path_crend = inpath + 'crend/tests/crend/out_wav' - check_and_makedir(out_file_path_crend) - if update_ref == 1: - check_and_makedir(ref_file_path_crend) - - fileName = 'stv48c' - - infile = in_new_file_path_crend + "/" + fileName + '.wav' - reffile = ref_file_path_crend + "/" + fileName + '_100_48k_200_non_diegetic_1.wav' - outfile = out_file_path_crend + "/" + fileName + '_100_48k_200_no_diegetic_1.wav' - - ivas_crend_run(CHECK_PASS, '48', CREND_NO_DIEGETIC_TEST, MONO_1, STEREO_2, infile, reffile, outfile, 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', '1', 'NA', 'NA', update_ref, p4_CL, p4cmd_active) - - reffile = ref_file_path_crend + "/" + fileName + '_100_48k_200_non_diegetic_-1.wav' - outfile = out_file_path_crend + "/" + fileName + '_100_48k_200_no_diegetic_-1.wav' - - ivas_crend_run(CHECK_PASS, '48', CREND_NO_DIEGETIC_TEST, MONO_1, STEREO_2, infile, reffile, outfile, 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', '-1', 'NA', 'NA', update_ref, p4_CL, p4cmd_active) - - reffile = ref_file_path_crend + "/" + fileName + '_100_48k_200_non_diegetic_-0.5.wav' - outfile = out_file_path_crend + "/" + fileName + '_100_48k_200_no_diegetic_-0.5.wav' - - ivas_crend_run(CHECK_PASS, '48', CREND_NO_DIEGETIC_TEST, MONO_1, STEREO_2, infile, reffile, outfile, 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', '-0.5', 'NA', 'NA', update_ref, p4_CL, p4cmd_active) - - -#CREND_BIN_TEST -@pytest.mark.create_ref -def test_ivas_crend_reference_tests_bin_test(rootdir, update_ref, p4_CL, p4cmd_active, reference_path, dut_base_path): - os.chdir(rootdir + unit_test_path) - - if reference_path: - ref_file_path_crend = f"{reference_path}/crend/crend/wav" - else: - ref_file_path_crend = inpath + 'crend/tests/crend/ref_wav' - if dut_base_path: - out_file_path_crend = f"{dut_base_path}/crend/crend/wav" - else: - out_file_path_crend = inpath + 'crend/tests/crend/out_wav' - check_and_makedir(out_file_path_crend) - if update_ref == 1: - check_and_makedir(ref_file_path_crend) - - test_cases = bin_test_cases - ir_cases = ['NA','brir'] - add_to_path = '' - - for ir_case in ir_cases: - for test_case in test_cases: - if test_case == CREND_BIN_TEST: - add_to_path = add_to_path + '_' + 'crend' - if 'brir' == ir_case : - add_to_path = 'brir' - else: - add_to_path = 'hrir' - elif test_case == FASTCONV_BIN_TEST: - add_to_path = add_to_path + '_' + 'fastconv' - if 'brir' == ir_case : - add_to_path = 'brir' - else: - add_to_path = 'hrir' - elif test_case == PARAM_BIN_TEST: - if 'brir' == ir_case : - continue - add_to_path = 'hrir' - add_to_path = add_to_path + '_' + 'param' - elif test_case == TD_BIN_TEST: - if 'brir' == ir_case : - continue - add_to_path = 'hrir' - add_to_path = add_to_path + '_' + 'td' - else: - continue - for file in file_list_crend_bin: - if ".wav" in file: - if '32k' in file: - fs = '32' - elif '16k' in file: - fs = '16' - else: - fs = '48' - if '510' in file: - if PARAM_BIN_TEST == test_case : - continue - in_fmt = MULT_CH_5_1 - elif '710' in file: - if PARAM_BIN_TEST == test_case : - continue - in_fmt = MULT_CH_7_1 - elif 'HOA' in file: - if TD_BIN_TEST == test_case : - continue - if 'brir' == ir_case : - continue - in_fmt = FOA_4 - elif '512' in file: - if PARAM_BIN_TEST == test_case : - continue - in_fmt = MULT_CH_5_1_2 - elif '714' in file: - if PARAM_BIN_TEST == test_case : - continue - in_fmt = MULT_CH_7_1_4 - elif 'HOA1' in file: - if TD_BIN_TEST == test_case : - continue - if 'brir' == ir_case : - continue - in_fmt = FOA_4 - elif 'HOA2' in file: - if TD_BIN_TEST == test_case : - continue - if 'brir' in ir_case : - continue - in_fmt = HOA_9 - elif 'HOA3' in file: - if TD_BIN_TEST == test_case : - continue - if 'brir' == ir_case : - continue - in_fmt = HOA_16 - else: - continue - - infile = in_file_path_crend + "/" + file - reffile = f"{ref_file_path_crend}/{file[:-4]}_" + add_to_path + ".wav" - outfile = f"{out_file_path_crend}/{file[:-4]}_" + add_to_path + ".wav" - - ivas_crend_run(CHECK_PASS, fs, test_case, in_fmt, BIN_2, infile, reffile, outfile, ir_case, 'NA', 'NA','NA', 'NA', 'NA', 'NA', 'NA', 'NA', update_ref, p4_CL, p4cmd_active) - - -####### run cmd ####### - -def ivas_crend_run(check_pass, fs, test, in_fmt, out_fmt, infile, reffile, outfile, use_brir, path_prox, use_limiter, csvfile, orientrk, use_lp_lfe, no_diegetic_pan, zero_tol, render_config_file_path, update_ref, p4_CL, p4cmd_active): - - cmd = [ - unit_test_exe, - '-test', test, - ] - - if fs != 'NA': - cmd = cmd + ['-sr', fs] - if in_fmt != 'NA': - cmd = cmd + ['-ifmt', in_fmt] - if out_fmt != 'NA': - cmd = cmd + ['-ofmt', out_fmt] - if infile != 'NA': - cmd = cmd + ['-i', infile] - if outfile != 'NA': - cmd = cmd + ['-o', outfile] - if reffile != 'NA' and update_ref != 1: - cmd = cmd + ['-r', reffile] - if csvfile != 'NA': - cmd = cmd + ['-t', csvfile] - if orientrk != 'NA': - cmd = cmd + ['-otr', orientrk] - if use_limiter != 'NA': - cmd = cmd + ['-limiter'] - if path_prox != 'NA': - cmd = cmd + ['-prox', path_prox] - if use_brir != 'NA': - cmd = cmd + ['-brir', ] - if use_lp_lfe != 'NA': - cmd = cmd + ['-lp_lfe'] - if no_diegetic_pan != 'NA': - if no_diegetic_pan == '-1': - cmd = cmd + ['-no_diegetic_pan', 'left' ] - else: - if no_diegetic_pan == '1': - cmd = cmd + ['-no_diegetic_pan', 'right' ] - else: - if no_diegetic_pan == '0': - cmd = cmd + ['-no_diegetic_pan', 'center' ] - else: - cmd = cmd + ['-no_diegetic_pan', no_diegetic_pan ] - if zero_tol != 'NA': - cmd = cmd + ["-zero_tol"] - if render_config_file_path != 'NA': - cmd = cmd + ["-render_config", render_config_file_path] - - - - ## reference update code here - if update_ref == 1: - new_file = False - if os.path.exists(reffile) and p4cmd_active: - p4cmd = p4EditCmd + p4_CL + ' ' + reffile - assert subprocess.call(p4cmd.split(), shell=False) == 0 - else: - new_file = True - - stdoutfile = tf.NamedTemporaryFile(mode='w', suffix='.txt', prefix='stdout', dir='.', delete=False) - stderrfile = tf.NamedTemporaryFile(mode='w', suffix='.txt', prefix='stderr', dir='.', delete=False) - stdoutname = stdoutfile.name - stderrname = stderrfile.name - print(' '.join(cmd)) - test_status = subprocess.call(cmd, shell=False, stdout=stdoutfile, stderr=stderrfile) - stdoutfile.close() - stderrfile.close() - - if update_ref == 1: - assert test_status == 0 - # convert raw out to wav - shutil.copyfile(outfile, reffile) - # raw2wav(outfile, reffile, int(fs)*1000, format_chans(out_fmt)) - ##Revert if unchanged## - if p4cmd_active: - p4cmd = p4RevertCmd + p4_CL + ' ' + reffile - assert subprocess.call(p4cmd.split(), shell=False) == 0 - if new_file: - p4cmd = p4AddCmd + p4_CL + ' ' + reffile - assert subprocess.call(p4cmd.split(), shell=False) == 0 - ## ref update code ends - else: - # assert integer_frame_check(fs, outfile, out_fmt, test) - # print_error_warning(stderrname) ## print stderr msgs by default - - print("Test status: " + str(test_status)) - if check_pass == CHECK_PASS: - assert test_status == 0 - elif check_pass == CHECK_FAIL: - assert test_status != 0 - elif check_pass == CHECK_INFMT_ERROR: - assert test_status != 0 - assert find_error_warning(stderrname) == 1 - - if os.path.isfile(outfile): - os.remove(outfile) - - - if os.path.isfile(stdoutname): - os.remove(stdoutname) - - if os.path.isfile(stderrname): - os.remove(stderrname) - - - -def find_clipping_warning(filename): - f = open(filename,'r') - clipped = 0 - for line in f: - print(line) - if "IVAS Common Renderer Clipped:" in line: - clipped = 1 - print(clipped) - return clipped - f.close() -def find_error_warning(filename): - f = open(filename,'r') - clipped = 0 - for line in f: - if "Error: CREND HR may only be turned on for SPAR (FOA) inputs." in line: - clipped = 1 - print(clipped) - return clipped - f.close() - -def print_error_warning(filename): - f = open(filename,'r') - print("############Logged STDERR MSGS START##################") - for line in f: - print(line) - print("############Logged STDERR MSGS END##################") - f.close() - -def integer_frame_check(fs, outfile, out_fmt, test): - num_chan = format_chans(out_fmt) - frsz = int(fs)*1000*0.02 - samples = os.stat(outfile).st_size/num_chan/2 - if samples/frsz != samples//frsz: - print(samples, frsz, samples/frsz, samples//frsz) - return False - else: - return True - -def raw2wav(rawfile, wavfile, fs, num_ch): - x = np.fromfile(rawfile, dtype=np.int16) - # numpy fills arrays along 1st dimension before the 0th? - x = x.reshape(len(x)//num_ch, num_ch) - write(wavfile, fs, x) - -def format_chans(out_fmt): - if out_fmt == MONO_1: - num_chan = 1 - elif out_fmt == STEREO_2: - num_chan = 2 - elif out_fmt == BIN_2: - num_chan = 2 - elif out_fmt == FOA_4: - num_chan = 4 - elif out_fmt == MULT_CH_5_1: - num_chan = 6 - elif out_fmt == MULT_CH_7_1: - num_chan = 8 - elif out_fmt == MULT_CH_5_1_2: - num_chan = 8 - elif out_fmt == MULT_CH_7_1_4: - num_chan = 12 - elif out_fmt == HOA_9: - num_chan = 9 - elif out_fmt == HOA_16: - num_chan = 16 - else: - print("Invalid output format.") - assert 0 - return num_chan diff --git a/scripts/td_object_renderer/object_renderer_standalone/Makefile b/scripts/td_object_renderer/object_renderer_standalone/Makefile deleted file mode 100644 index c8a43fc6f1..0000000000 --- a/scripts/td_object_renderer/object_renderer_standalone/Makefile +++ /dev/null @@ -1,184 +0,0 @@ -# GNU Makefile - -# Paths -SRC_LIBCOM = ../../../lib_com -SRC_LIBDEBUG = ../../../lib_debug -SRC_LIBDEC = ../../../lib_dec -SRC_LIBENC = ../../../lib_enc -SRC_LIBREND = ../../../lib_rend -SRC_LIBUTIL = ../../../lib_util -SRC_APP = ./object_renderer_standalone -BUILD = build -OBJDIR = obj - -SRC_DIRS = $(sort -u $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBUTIL) $(SRC_APP)) - -# Name of CLI binaries -CLI_REN ?= renderer_standalone -LIB_LIBCOM ?= libivascom.a -LIB_LIBDEBUG ?= libivasdebug.a -LIB_LIBDEC ?= libivasdec.a -LIB_LIBENC ?= libivasenc.a -LIB_LIBREND ?= libivasrend.a -LIB_LIBUTIL ?= libivasutil.a - -# Default tool settings -CC ?= gcc -RM ?= rm -f -AR ?= ar - -# Detect system -UNAME_S := $(shell uname -s) - -# Switches for cross-platform builds (i.e. build 32 bit code on 64 bit platforms) -ifneq "$(TARGET_PLATFORM)" "" -ifeq ("$(TARGET_PLATFORM)", "$(findstring $(TARGET_PLATFORM), i386 i586 i686)") - CFLAGS += -m32 - LDFLAGS += -m32 -endif - -ifeq ("$(TARGET_PLATFORM)", "$(findstring $(TARGET_PLATFORM), x86_64)") - CFLAGS += -m64 - LDFLAGS += -m64 -endif -endif - -ifndef VERBOSE -QUIET_CC = @echo ' ' Compiling $<; -QUIET_LINK= @echo ' ' Linking $@; -QUIET_AR = @echo ' ' Archiving $@; -QUIET = @ -endif - -# C compiler flags -CFLAGS += -std=c99 -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ - -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ - -Werror-implicit-function-declaration -Wno-unused-parameter \ - -Wno-unused-function -Wno-implicit-fallthrough - -# libs to link -LDLIBS += -lm - -# Clang sanitizer compiler options -CCCLANG = clang -ifeq "$(CLANG)" "1" -CC = $(CCCLANG) -CFLAGS += -fsanitize=memory -LDFLAGS += -fsanitize=memory -endif -ifeq "$(CLANG)" "2" -CC = $(CCCLANG) -CFLAGS += -fsanitize=address -LDFLAGS += -fsanitize=address -endif -ifeq "$(CLANG)" "3" -CC = $(CCCLANG) -CFLAGS += -fsanitize=undefined -LDFLAGS += -fsanitize=undefined -endif - - -CFLAGS += -DTDREND_HRTF_TABLE_METHODS -LDFLAGS += -DTDREND_HRTF_TABLE_METHODS - -ifeq "$(RELEASE)" "1" -CFLAGS += -DRELEASE -OPTIM ?= 2 -endif - -ifneq "$(DEBUG)" "0" -CFLAGS += -g3 -LDFLAGS += -g3 -endif - -ifeq "$(GCOV)" "1" -CFLAGS += -fprofile-arcs -ftest-coverage -LDFLAGS += -fprofile-arcs -ftest-coverage -endif - -ifeq "$(STRIP)" "1" -CFLAGS += -fdata-sections -ffunction-sections -ifneq ($(UNAME_S),Darwin) -LDFLAGS += -Wl,-gc-sections -static -else -LDFLAGS += -Wl,-dead_strip -endif -endif - -OPTIM ?= 0 -CFLAGS += -O$(OPTIM) - -CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR)) - -# Source file search paths -VPATH = $(SRC_DIRS) - -############################################################################### - -SRCS_LIBCOM = $(foreach DIR,$(SRC_LIBCOM),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) -SRCS_LIBDEBUG = $(foreach DIR,$(SRC_LIBDEBUG),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) -SRCS_LIBDEC = $(foreach DIR,$(SRC_LIBDEC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) -SRCS_LIBENC = $(foreach DIR,$(SRC_LIBENC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) -SRCS_LIBREND = $(foreach DIR,$(SRC_LIBREND),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) -SRCS_LIBUTIL = $(foreach DIR,$(SRC_LIBUTIL),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) - -OBJS_LIBCOM = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.o)) -OBJS_LIBDEBUG = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEBUG:.c=.o)) -OBJS_LIBDEC = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEC:.c=.o)) -OBJS_LIBENC = $(addprefix $(OBJDIR)/,$(SRCS_LIBENC:.c=.o)) -OBJS_LIBREND = $(addprefix $(OBJDIR)/,$(SRCS_LIBREND:.c=.o)) -OBJS_LIBUTIL = $(addprefix $(OBJDIR)/,$(SRCS_LIBUTIL:.c=.o)) -OBJS_REN = $(OBJDIR)/renderer_standalone.o - - -DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.P) $(SRCS_LIBDEBUG:.c=.P) $(SRCS_LIBDEC:.c=.P) \ - $(SRCS_LIBENC:.c=.P) $(SRCS_LIBUTIL:.c=.P)) - -############################################################################### - -.PHONY: all clean clean_all - -all: $(CLI_REN) - -$(OBJDIR): - $(QUIET)mkdir -p $(OBJDIR) - -$(LIB_LIBCOM): $(OBJS_LIBCOM) - $(QUIET_AR)$(AR) rcs $@ $^ - -$(LIB_LIBDEBUG): $(OBJS_LIBDEBUG) - $(QUIET_AR)$(AR) rcs $@ $^ - -$(LIB_LIBDEC): $(OBJS_LIBDEC) $(OBJS_LIBREND) - $(QUIET_AR)$(AR) rcs $@ $^ - -$(LIB_LIBENC): $(OBJS_LIBENC) - $(QUIET_AR)$(AR) rcs $@ $^ - -$(LIB_LIBREND): $(OBJS_LIBREND) - $(QUIET_AR)$(AR) rcs $@ $^ - -$(LIB_LIBUTIL): $(OBJS_LIBUTIL) - $(QUIET_AR)$(AR) rcs $@ $^ - -$(CLI_REN): $(LIB_LIBENC) $(LIB_LIBDEC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(OBJS_REN) - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_REN) -L. -livasdebug -livasutil -livasenc -livasdec -livascom $(LDLIBS) -o $(CLI_REN) - -libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBUTIL) - -clean: - $(QUIET)$(RM) $(OBJS_LIBENC) $(OBJS_LIBDEC) $(OBJS_REN) $(DEPS) - $(QUIET)$(RM) $(DEPS:.P=.d) - $(QUIET)test ! -d $(OBJDIR) || rm -rf $(OBJDIR) - -clean_all: clean - $(QUIET)$(RM) $(CLI_REN) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) - -$(OBJDIR)/%.o : %.c | $(OBJDIR) - $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $< - @cp $(OBJDIR)/$*.d $(OBJDIR)/$*.P; \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(OBJDIR)/$*.d >> $(OBJDIR)/$*.P; \ - $(RM) $(OBJDIR)/$*.d - --include $(DEPS) diff --git a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.sln b/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.sln deleted file mode 100644 index 72b9350406..0000000000 --- a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.sln +++ /dev/null @@ -1,68 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_dec", "..\..\..\Workspace_msvc\lib_dec.vcxproj", "{E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_com", "..\..\..\Workspace_msvc\lib_com.vcxproj", "{39EC200D-7795-4FF8-B214-B24EDA5526AE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_rend", "..\..\..\Workspace_msvc\lib_rend.vcxproj", "{718DE063-A18B-BB72-9150-62B892E6FFA6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_util", "..\..\..\Workspace_msvc\lib_util.vcxproj", "{2FA8F384-0775-F3B7-F8C3-85209222FC70}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_debug", "..\..\..\Workspace_msvc\lib_debug.vcxproj", "{54509728-928B-44D9-A118-A6F92F08B34F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "object_renderer_standalone", "object_renderer_standalone.vcxproj", "{75AE3898-3FDF-4AE2-86A1-838D0E78545E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Unittests|Win32 = Unittests|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {75AE3898-3FDF-4AE2-86A1-838D0E78545E}.Debug|Win32.ActiveCfg = Debug|Win32 - {75AE3898-3FDF-4AE2-86A1-838D0E78545E}.Debug|Win32.Build.0 = Debug|Win32 - {75AE3898-3FDF-4AE2-86A1-838D0E78545E}.Release|Win32.ActiveCfg = Release|Win32 - {75AE3898-3FDF-4AE2-86A1-838D0E78545E}.Release|Win32.Build.0 = Release|Win32 - {75AE3898-3FDF-4AE2-86A1-838D0E78545E}.Unittests|Win32.ActiveCfg = Release|Win32 - {75AE3898-3FDF-4AE2-86A1-838D0E78545E}.Unittests|Win32.Build.0 = Release|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Debug|Win32.ActiveCfg = Debug|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Debug|Win32.Build.0 = Debug|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Release|Win32.ActiveCfg = Release|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Release|Win32.Build.0 = Release|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {2FA8F384-0775-F3B7-F8C3-85209222FC70}.Unittests|Win32.Build.0 = Unittests|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Debug|Win32.Build.0 = Debug|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Release|Win32.ActiveCfg = Release|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Release|Win32.Build.0 = Release|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Unittests|Win32.Build.0 = Unittests|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Debug|Win32.ActiveCfg = Debug|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Debug|Win32.Build.0 = Debug|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Release|Win32.ActiveCfg = Release|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Release|Win32.Build.0 = Release|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Unittests|Win32.Build.0 = Unittests|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Debug|Win32.ActiveCfg = Debug|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Debug|Win32.Build.0 = Debug|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Release|Win32.ActiveCfg = Release|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Release|Win32.Build.0 = Release|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {54509728-928B-44D9-A118-A6F92F08B34F}.Unittests|Win32.Build.0 = Unittests|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Debug|Win32.ActiveCfg = Debug|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Debug|Win32.Build.0 = Debug|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Release|Win32.ActiveCfg = Release|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Release|Win32.Build.0 = Release|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Unittests|Win32.ActiveCfg = Unittests|Win32 - {718DE063-A18B-BB72-9150-62B892E6FFA6}.Unittests|Win32.Build.0 = Unittests|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {16E75611-7E35-43B5-B2CA-01E9C9B952F1} - EndGlobalSection -EndGlobal diff --git a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj b/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj deleted file mode 100644 index 925450bae2..0000000000 --- a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - 15.0 - {75AE3898-3FDF-4AE2-86A1-838D0E78545E} - objectrendererstandalone - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - .\ - .\Debug_Renderer_Standalone\ - renderer_standalone - false - - - .\ - .\Release_Renderer_Standalone\ - renderer_standalone - false - - - - Level4 - Disabled - true - false - ..\..\..\lib_enc;..\..\..\lib_dec;..\..\..\lib_com;..\..\..\lib_debug;..\..\..\lib_util;..\..\..\lib_rend;%(AdditionalIncludeDirectories) - OldStyle - false - _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions);TDREND_HRTF_TABLE_METHODS - MultiThreadedDebug - .\Debug_Renderer_Standalone\renderer_standalone.pdb - - false - - - .\renderer_standalone.exe - .\Debug_Renderer_Standalone\renderer_standalone.pdb - Console - - - - - Level3 - MaxSpeed - true - true - true - true - ..\..\..\lib_enc;..\..\..\lib_dec;..\..\..\lib_com;..\..\..\lib_debug;..\..\..\lib_util;..\..\..\lib_rend;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions);OBJECT_RENDERER_EXTERNAL_METADATA - MultiThreaded - $(IntDir)renderer_standalone.pdb - - - true - true - .\renderer_standalone.exe - false - - - - - - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - - - {54509728-928b-44d9-a118-a6f92f08b34f} - - - {e822ddaf-0f5f-4cd0-a694-38ae69de74d3} - - - {718de063-a18b-bb72-9150-62b892e6ffa6} - - - {2fa8f384-0775-f3b7-f8c3-85209222fc70} - - - - - - \ No newline at end of file diff --git a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj.filters b/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj.filters deleted file mode 100644 index 880c4e60a8..0000000000 --- a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c b/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c deleted file mode 100644 index b2963093a2..0000000000 --- a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c +++ /dev/null @@ -1,603 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ -#include -#include -#include - -#define _USE_MATH_DEFINES -#include - -#include "options.h" -#include "stdint.h" -#include "prot.h" -#include "ivas_prot.h" -#include "ivas_cnst.h" -#include "ivas_stat_dec.h" -#include "cnst.h" -#include "wmops.h" -#include "hrtf_file_reader.h" -#include "ivas_error.h" - -/*------------------------------------------------------------------------------------------* - * Constants - *------------------------------------------------------------------------------------------*/ - -#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ -#define NUM_ISM_METADATA_PER_LINE 4 /* Number of ISM metadata per line in a metadata file */ - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ -static char *to_upper( char *str ); -static void usage_rend( void ); -static void readMetadata( FILE *file, ISM_METADATA_HANDLE hIsmMetaData ); - -static void ivas_binaural_add_LFE_local( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t output_frame, /* i : length of input frame */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int8_t render_lfe /* i : render lfe flag */ -); - -/*---------------------------------------------------------------------* - * usage_rend() - * - * Print the usage of the "renderer_standalone" program - *---------------------------------------------------------------------*/ - -static void usage_rend( void ) -{ - fprintf( stdout, "Usage: renderer_standalone.exe [Options] Channels Metadata Fs InputAudio OutputAudio\n\n" ); - - fprintf( stdout, "Mandatory parameters:\n" ); - fprintf( stdout, "---------------------\n" ); - fprintf( stdout, "Channels : Number of channels\n" ); - fprintf( stdout, "Metadata : Metadata files, number of files specified by Channels\n" ); - fprintf( stdout, "Fs : Sampling rate\n" ); - fprintf( stdout, "InputAudio : Audio to be rendered, interleaved Channels\n" ); - fprintf( stdout, "OutputAudio : Rendered output audio\n\n" ); - - fprintf( stdout, "Options:\n" ); - fprintf( stdout, "--------\n" ); - fprintf( stdout, "-T File : Head rotation specified by external trajectory File\n" ); - fprintf( stdout, "-hrtf File : HRTF filter file (if not specified: use default model from ROM)\n" ); - fprintf( stdout, "-mc Conf : Run renderer on multichannel input, where Conf is one of \n" ); - fprintf( stdout, " 5_1, 7_1, 5_1_2, 5_1_4 and 7_1_4. Note: In this mode the Channels\n" ); - fprintf( stdout, " and Metadata arguments are omitted.\n" ); - fprintf( stdout, "\n" ); - - exit( -1 ); -} - - -/*------------------------------------------------------------------------------------------* - * Global variables - *------------------------------------------------------------------------------------------*/ - -int32_t frame = 0; /* Counter of frames */ - - -/*------------------------------------------------------------------------------------------* - * Standalone Renderer program - * - * - *------------------------------------------------------------------------------------------*/ -int main( int argc, char *argv[] ) -{ - int16_t nFrameLength; - int16_t n, nS, nSamplesRead, i, j; - int16_t offset; - - float *MixFrame; - float output[MAX_CICP_CHANNELS][L_FRAME48k]; - int16_t NumLdspks = 2; - int16_t *MixFrameWav; - int16_t *input_buff; - int16_t nChannels; - FILE *f_input; - FILE *f_output; - FILE *f_quat_traj; - float x, y, z, w; - FILE *f_metadata[MAX_NUM_OBJECTS]; - Decoder_Struct st_ivas_static; - Decoder_Struct *st_ivas = &st_ivas_static; - - MixFrame = count_malloc( 2 * L_FRAME48k * sizeof( float ) ); - MixFrameWav = count_malloc( 2 * L_FRAME48k * sizeof( int16_t ) ); - input_buff = count_malloc( MAX_CICP_CHANNELS * L_FRAME48k * sizeof( int16_t ) ); - nChannels = 0; - - for ( i = 0; i < 2 * L_FRAME48k; i++ ) - { - MixFrame[i] = 0.0; - MixFrameWav[i] = 0; - } - for ( i = 0; i < MAX_NUM_OBJECTS; ++i ) - { - f_metadata[i] = NULL; - } - - - /*------------------------------------------------------------------------------------------* - * Struct initializations - *------------------------------------------------------------------------------------------*/ - st_ivas->hHrtfTD = NULL; - st_ivas->hRenderConfig = NULL; - st_ivas->hHeadTrackData = NULL; - st_ivas->ivas_format = ISM_FORMAT; - f_quat_traj = NULL; - if ( ( st_ivas->hDecoderConfig = (DECODER_CONFIG_HANDLE) count_malloc( sizeof( DECODER_CONFIG ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - st_ivas->hDecoderConfig->Opt_Headrotation = FALSE; - - /* ISm metadata handles */ - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) - { - st_ivas->hIsmMetaData[n] = NULL; - } - - /*------------------------------------------------------------------------------------------* - * Parse command line and initialize renderer - *------------------------------------------------------------------------------------------*/ - if ( ( argc ) < 5 ) - { - fprintf( stderr, "Not enough input arguments!\n\n" ); - usage_rend(); - } - i = 1; - /* Optional arguments */ - while ( argv[i][0] == '-' ) - { - if ( strcmp( to_upper( argv[i] ), "-HRTF" ) == 0 ) - { - i++; - ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ); - i++; - } - else if ( strcmp( to_upper( argv[i] ), "-T" ) == 0 ) - { - i++; - f_quat_traj = fopen( argv[i], "r" ); - - if ( f_quat_traj == NULL ) - { - fprintf( stderr, "\nError: Unable to open head-rotation file %s \n\n", argv[i] ); - usage_rend(); - } - i++; - } - else if ( strcmp( to_upper( argv[i] ), "-MC" ) == 0 ) - { - st_ivas->ivas_format = MC_FORMAT; - st_ivas->mc_mode = MC_MODE_MCT; - i++; - if ( strcmp( to_upper( argv[i] ), "5_1" ) == 0 ) - { - st_ivas->transport_config = AUDIO_CONFIG_5_1; - nChannels = 6; - } - else if ( strcmp( to_upper( argv[i] ), "7_1" ) == 0 ) - { - st_ivas->transport_config = AUDIO_CONFIG_7_1; - nChannels = 8; - } - else if ( strcmp( to_upper( argv[i] ), "5_1_2" ) == 0 ) - { - st_ivas->transport_config = AUDIO_CONFIG_5_1_2; - nChannels = 8; - } - else if ( strcmp( to_upper( argv[i] ), "5_1_4" ) == 0 ) - { - st_ivas->transport_config = AUDIO_CONFIG_5_1_4; - nChannels = 10; - } - else if ( strcmp( to_upper( argv[i] ), "7_1_4" ) == 0 ) - { - st_ivas->transport_config = AUDIO_CONFIG_7_1_4; - nChannels = 12; - } - else - { - fprintf( stderr, "\nError: Unknown MC configuration %s \n\n", argv[i] ); - usage_rend(); - } - st_ivas->nchan_transport = nChannels; - st_ivas->hIntSetup.num_lfe = 1; - st_ivas->hIntSetup.nchan_out_woLFE = nChannels - 1; - st_ivas->hIntSetup.index_lfe[0] = 3; - i++; - } - else - { - fprintf( stderr, "Unknown option: %s\n\n", argv[i] ); - usage_rend(); - } - } - - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - - if ( ( argc - i ) < 5 ) - { - fprintf( stderr, "Not enough input arguments!\n\n" ); - usage_rend(); - } - - /* Mandatory arguments */ - nChannels = (int16_t) atoi( argv[i] ); /* Number of channels */ - st_ivas->nSCE = nChannels; - st_ivas->nchan_transport = nChannels; - i++; - - if ( ( argc - i ) < ( 3 + nChannels ) ) - { - fprintf( stderr, "Not enough input arguments for %d channels!\n\n", nChannels ); - usage_rend(); - } - - /* Metadata files */ - for ( j = 0; j < nChannels; j++ ) - { - if ( ( f_metadata[j] = fopen( argv[i], "r" ) ) == NULL ) - { - fprintf( stderr, "\nError: Unable to open metadata file %s \n\n", argv[i] ); - exit( -1 ); - } - st_ivas->hIsmMetaData[j] = (ISM_METADATA_HANDLE) count_malloc( sizeof( ISM_METADATA_FRAME ) ); - i++; - } - } - - - /* Fs and 20ms frame length */ - st_ivas->hDecoderConfig->output_Fs = atoi( argv[i] ) * 1000; - nFrameLength = ( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / 1000 ) ) * 20; /* 20 ms frame */ - i++; - - /* Input, n-channel audio */ - if ( ( f_input = fopen( argv[i], "rb" ) ) == NULL ) - { - fprintf( stderr, "Error: input file %s cannot be opened\n\n", argv[i] ); - exit( -1 ); - } - i++; - - /* Output rendered audio */ - if ( ( f_output = fopen( argv[i], "wb" ) ) == NULL ) - { - fprintf( stderr, "Error: output file %s cannot be opened\n\n", argv[i] ); - exit( -1 ); - } - i++; - - if ( i != argc ) - { - fprintf( stderr, "Too many arguments!\n\n" ); - usage_rend(); - } - - - if ( f_quat_traj != NULL ) - { - st_ivas->hDecoderConfig->Opt_Headrotation = 1; - if ( ( st_ivas->hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) count_malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) - { - fprintf( stderr, "Can not allocate memory for head-tracking\n" ); - exit( -1 ); - } - st_ivas->hDecoderConfig->Opt_Headrotation = TRUE; - } -#ifdef EXT_RENDERER - else - { - st_ivas->hDecoderConfig->Opt_Headrotation = 0; - } -#endif - - /* Init limiter */ - st_ivas->hLimiter = ivas_limiter_open( nChannels, st_ivas->hDecoderConfig->output_Fs ); - st_ivas->hDecoderConfig->nchan_out = nChannels; - st_ivas->hLimiter->strong_saturation_count = 0; - st_ivas->hLimiter->gain = 1.f; - st_ivas->hLimiter->release_heuristic = 0.f; - - ivas_td_binaural_open( st_ivas ); - - int16_t nFrameCount = 0; - int16_t currFrameLength, currWindowLength; - - /*------------------------------------------------------------------------------------------* - * Main rendering loop - *------------------------------------------------------------------------------------------*/ - fprintf( stdout, "Rendering...\n" ); - while ( 1 ) - { - /* Read the next frame from the file */ - nSamplesRead = (int16_t) fread( input_buff, sizeof( int16_t ), nFrameLength * nChannels, f_input ); - if ( nSamplesRead <= 0 ) - { - if ( frame == 0 ) - { - fprintf( stderr, "Error: no frames processed." ); - } - break; - } - - if ( nSamplesRead % nChannels != 0 ) - { - fprintf( stderr, "Error: total number of entries in input audio was not a multiple of the number of channels.\n\n" ); - break; - } - - currWindowLength = nSamplesRead / nChannels; - if ( currWindowLength < nFrameLength ) - { - currFrameLength = currWindowLength; - } - else - { - currFrameLength = nFrameLength; - } - - - /* Renderer expects non-interleaved channels, so de-interleave here. */ - for ( nS = 0; nS < nChannels; nS++ ) - { - for ( n = 0; n < currFrameLength; n++ ) - { - output[nS][n] = input_buff[nChannels * n + nS]; - } - } - - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - /* Read metadata */ - for ( j = 0; j < nChannels; j++ ) - { - readMetadata( f_metadata[j], st_ivas->hIsmMetaData[j] ); - } - } - else /* st_ivas->ivas_format == MC_FORMAT */ - { - ivas_binaural_add_LFE_local( st_ivas, currFrameLength, output, 1 ); - } - - /* Read headrotation */ - if ( f_quat_traj != NULL ) - { - for ( i = 0; i < 4; i++ ) /* MAX_PARAM_SPATIAL_SUBFRAMES = 4 */ - { - if ( 4 == fscanf( f_quat_traj, "%f,%f,%f,%f", &w, &x, &y, &z ) ) - { - st_ivas->hHeadTrackData->num_quaternions = -1; - - st_ivas->hHeadTrackData->Quaternions[i].w = w; - st_ivas->hHeadTrackData->Quaternions[i].x = x; - st_ivas->hHeadTrackData->Quaternions[i].y = y; - st_ivas->hHeadTrackData->Quaternions[i].z = z; - - st_ivas->hHeadTrackData->num_quaternions = 0; - } - else - { - if ( feof( f_quat_traj ) ) - { - rewind( f_quat_traj ); - i--; /* Rewind and re-read the value for i */ - } - else - { - fprintf( stderr, "Incorrect format in headrotation file! \n\n" ); - exit( -1 ); - } - } - } - } - - /* Renderer */ - ObjRenderIVASFrame( st_ivas, output, currFrameLength ); - - /* Write the rendered audio to file. */ - - /* Apply limiter */ - ivas_limiter_dec( st_ivas->hLimiter, output, st_ivas->hDecoderConfig->nchan_out, nFrameLength, FALSE ); - - /* Trim first frame to compensate for delay */ - if ( nFrameCount == 0 ) - { - offset = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / 200 ); /* 240 samples for 48kHz etc */ - } - else - { - offset = 0; - } - - /* For Wav: Interleave, convert to int16_t */ - for ( n = 0; n < ( currFrameLength - offset ); n++ ) - { - for ( nS = 0; nS < NumLdspks; nS++ ) - { - MixFrameWav[n * NumLdspks + nS] = (int16_t) ( output[nS][n + offset] + 0.5f * sign( output[nS][n + offset] ) ); - } - } - fwrite( MixFrameWav, sizeof( int16_t ), ( currFrameLength - offset ) * NumLdspks, f_output ); - - nFrameCount++; - - frame++; - - fprintf( stdout, "." ); - } - fprintf( stdout, "\n" ); - - - /*------------------------------------------------------------------------------------------* - * Close and deallocate memory - *------------------------------------------------------------------------------------------*/ - - fclose( f_input ); - fclose( f_output ); - - count_free( MixFrame ); - count_free( MixFrameWav ); - count_free( input_buff ); - - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - count_free( st_ivas->hDecoderConfig ); - st_ivas->hHrtfTD = NULL; - - /* ISM metadata handles */ - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) - { - if ( st_ivas->hIsmMetaData[n] != NULL ) - { - count_free( st_ivas->hIsmMetaData[n] ); - st_ivas->hIsmMetaData[n] = NULL; - } - } - - if ( st_ivas->hHeadTrackData != NULL ) - { - count_free( st_ivas->hHeadTrackData ); - fclose( f_quat_traj ); - } - - ivas_limiter_close( &st_ivas->hLimiter ); - -#ifdef RAM_COUNTING_TOOL - mem_count_summary( USE_DEFAULT ); -#endif - -#ifdef DEBUGGING - dbgclose(); -#endif - - fprintf( stdout, "Done rendering %d frames.\n", nFrameCount ); - /* system( "pause" ); */ - return 0; -} - -/*---------------------------------------------------------------------* - * to_upper() - * - * Capitalize all letters of a string. - * (normally to_upper() function would be used but it does not work in Unix) - *---------------------------------------------------------------------*/ -static char *to_upper( - char *str ) -{ - int16_t i; - char *p = str; - - i = 0; - while ( str[i] != 0 ) - { - if ( str[i] >= 'a' && str[i] <= 'z' ) - { - str[i] -= 0x20; - } - i++; - } - - return p; -} - -/*---------------------------------------------------------------------* - * readMetadata() - * - * Read one frame of metadata - *---------------------------------------------------------------------*/ -static void readMetadata( - FILE *file, - ISM_METADATA_HANDLE hIsmMetaData ) -{ - char char_buff[META_LINE_LENGTH]; - float meta_prm[NUM_ISM_METADATA_PER_LINE]; - char *char_ptr; - int16_t j; - - if ( fgets( char_buff, META_LINE_LENGTH, file ) == NULL ) - { - fprintf( stderr, "\n!!!Error: Early EOF met while reading ISM metadata input file. Exiting!!!\n\n" ); - exit( -1 ); - } - - j = 0; - char_ptr = strtok( char_buff, "," ); - meta_prm[j++] = (float) atof( char_ptr ); - while ( char_ptr != NULL && j < NUM_ISM_METADATA_PER_LINE ) - { - char_ptr = strtok( NULL, "," ); - meta_prm[j++] = (float) atof( char_ptr ); - } - - hIsmMetaData->azimuth = meta_prm[0]; - hIsmMetaData->elevation = meta_prm[1]; - - return; -} - -/*KLUDGE: Copied here instead of moving ivas_binaural_add_LFE to a separate file. */ -static void ivas_binaural_add_LFE_local( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t output_frame, /* i : length of input frame */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int8_t render_lfe /* i : render lfe flag */ -) -{ - - if ( render_lfe ) - { - float gain; - int16_t ch, idx_lfe; - - gain = GAIN_LFE / st_ivas->hIntSetup.nchan_out_woLFE; - - /* copy lfe to all other channels */ - for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) - { - v_multc( output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain, output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); - - for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) - { - if ( st_ivas->hIntSetup.index_lfe[idx_lfe] != ch ) - { - v_add( output_f[ch], output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_f[ch], output_frame ); - } - } - } - } - - return; -} diff --git a/tests/renderer/README.md b/tests/renderer/README.md index b819e43c5c..9748d8abf1 100644 --- a/tests/renderer/README.md +++ b/tests/renderer/README.md @@ -2,24 +2,10 @@ See also the [contribution page](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/Contributions/2-external-renderer) for related presentations. -## Running Tests - -### Two testfiles are located in `tests/renderer/`: - -* `test_renderer.py` -* `test_renderer_vs_decoder.py` \ - (requires `DEC_TO_REND_FLOAT_DUMP` defined in `options.h`, cannot be run in parallel i.e. `-n 1` argument must be used for the `pytest-xdist` plugin) - ### Run tests with: `python3 -m pytest -q -n auto tests/renderer/test_renderer.py` -OR - -:warning: `DEC_TO_REND_FLOAT_DUMP` must be defined before compiling! :warning: - -`python3 -m pytest -q -n 1 tests/renderer/test_renderer_vs_decoder.py` - ### Important flags (see [pytest docs](https://docs.pytest.org/en/7.2.x/) for more information): * `-k` flag can filter test cases, e.g. `-k "test_ism_binaural_static"` @@ -37,9 +23,7 @@ this option will also report captured logs, **required for obtaining the command ├── cut -> Default location for output files for test conditions ├── data -> Input test vectors ├── ref -> Default location for output files for reference conditions -├── run_test_renderer_vs_decoder.sh -> Compiles and runs test_renderer_vs_decoder.py with CMake and DEC_TO_REND_FLOAT_DUMP defined ├── test_renderer_be_comparison.py -> Tests for CI Merge Request pipeline to compare renderer bit-exactness -├── test_renderer.py -> Comparison of renderer against standalone executables / python scripts (to be deprecated soon) -├── test_renderer_vs_decoder.py -> Comparison of renderer against decoder (to be deprecated soon) +├── test_renderer.py -> Runs the renderer for all modes └── utils.py -> Wrapper functions for executables for use in testcases ``` diff --git a/tests/renderer/constants.py b/tests/renderer/constants.py index da7302bdc2..89dbcccc69 100644 --- a/tests/renderer/constants.py +++ b/tests/renderer/constants.py @@ -42,26 +42,6 @@ TESTV_DIR = SCRIPTS_DIR.joinpath("testv") BIN_SUFFIX_MERGETARGET = "_ref" -""" Encoder commandline template """ -IVAS_COD_CMD = [ - str(TESTS_DIR.parent.parent.joinpath("IVAS_cod")), - "", # 1 -> mode - "", # 2 -> options for mode - "", # 3 -> bitrate - "48", # 4 -> input fs - "", # 5 -> input file - "", # 6 -> bitstream file -] - -""" Decoder commandline template """ -IVAS_DEC_CMD = [ - str(TESTS_DIR.parent.parent.joinpath("IVAS_dec")), - "-no_delay_cmp", - "", # 2 -> output format, - "48", # 3 -> output fs - "", # 4 -> bitstream file - "", # 5 -> output file -] """ Renderer commandline template """ RENDERER_CMD = [ @@ -81,39 +61,6 @@ RENDERER_CMD = [ "-q", ] -""" TD Object Renderer commandline template """ -TDRENDERER_CMD = [ - str( - SCRIPTS_DIR.joinpath("td_object_renderer") - .joinpath("object_renderer_standalone") - .joinpath("renderer_standalone") - ), - "48", - "", # 4 -> input file - "", # 5 -> output file -] - -""" CREND commandline template """ -CREND_CMD = [ - str( - SCRIPTS_DIR.joinpath("ivas_pytests/tests/unit_tests/crend/IVAS_crend_unit_test") - ), - "-test", - "1", - "-sr", - "48", - "-ifmt", - "", # 4 -> input format - "-ofmt", - "", # 8 -> output format - "-i", - "", # 2 -> input file - "-o", - "/dev/null", # 6 -> output file - # "-lp_lfe", - # "-limiter" - # "-no_delay_cmp" -] """ Format to file mappings """ NCHAN_TO_FILE = { @@ -188,60 +135,14 @@ FORMAT_TO_METADATA_FILES = { "MASA2": [str(TESTV_DIR.joinpath("stv_IVASMASA_2dir2TC.met"))], } -FORMAT_TO_IVAS = { - "MONO": ["", ""], - "STEREO": ["-stereo", ""], - "FOA": ["-sba", "1"], - "HOA2": ["-sba", "2"], - "HOA3": ["-sba", "3"], - "5_1": ["-mc", "5_1"], - "7_1": ["-mc", "7_1"], - "5_1_2": ["-mc", "5_1_2"], - "5_1_4": ["-mc", "5_1_4"], - "7_1_4": ["-mc", "7_1_4"], - "ISM1": ["-ism", "1"], - "ISM2": ["-ism", "2"], - "ISM3": ["-ism", "3"], - "ISM4": ["-ism", "4"], -} - -FORMAT_TO_IVAS_BR = { - "MONO": "128000", - "STEREO": "256000", - "FOA": "512000", - "HOA2": "512000", - "HOA3": "512000", - "5_1": "512000", - "7_1": "512000", - "5_1_2": "512000", - "5_1_4": "512000", - "7_1_4": "512000", - "ISM1": "256000", - "ISM2": "256000", - "ISM3": "256000", - "ISM4": "256000", -} - -FORMAT_TO_CREND_FORMAT = { - "MONO": "0", - "STEREO": "1", - "BINAURAL": "2", - "BINAURAL_ROOM": "2", - "FOA": "3", - "5_1": "4", - "7_1": "5", - "5_1_2": "6", - "5_1_4": "7", - "7_1_4": "8", - "HOA2": "9", - "HOA3": "10", -} """ Input formats """ INPUT_FORMATS_AMBI = ["FOA", "HOA2", "HOA3"] INPUT_FORMATS_MC = ["MONO", "STEREO", "5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] INPUT_FORMATS_ISM = ["ISM1", "ISM2", "ISM3", "ISM4"] -INPUT_FORMATS_MASA = ["MASA2"] #["MASA1", "MASA2"] # Disable MASA1 tests until MASA1 can be implemented properly +INPUT_FORMATS_MASA = [ + "MASA2" +] # ["MASA1", "MASA2"] # Disable MASA1 tests until MASA1 can be implemented properly """ Non binaural / parametric output formats """ OUTPUT_FORMATS = [ @@ -411,130 +312,4 @@ pass_snr = { "test_multichannel_binaural_headrotation[7_1-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 3, "test_multichannel_binaural_headrotation[7_1_4-BINAURAL_ROOM-full_circle_in_15s]": 10, "test_multichannel_binaural_headrotation[7_1_4-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 3, - ##################################### - # - # External vs Internal Renderer tests - # - ##################################### - # Failure reason: only fails for this trajectory with very high SNR, possible minor diff. in crossfade - # or due to usage of multiple TD Object Renderer instances - "test_ism_binaural_headrotation_vs_decoder[ISM2-BINAURAL-rotate_yaw_pitch_roll1]": 84, - "test_ism_binaural_headrotation_vs_decoder[ISM3-BINAURAL-rotate_yaw_pitch_roll1]": 78, - "test_ism_binaural_headrotation_vs_decoder[ISM4-BINAURAL-rotate_yaw_pitch_roll1]": 85, - # TODO needs investigation - # Failure reason: conversion to 7_1_4 could be implemented differently w.r.t decoder - "test_ism_binaural_headrotation_vs_decoder[ISM1-BINAURAL_ROOM-full_circle_in_15s]": 15, - "test_ism_binaural_headrotation_vs_decoder[ISM1-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 15, - "test_ism_binaural_headrotation_vs_decoder[ISM2-BINAURAL_ROOM-full_circle_in_15s]": 12, - "test_ism_binaural_headrotation_vs_decoder[ISM2-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 13, - "test_ism_binaural_headrotation_vs_decoder[ISM3-BINAURAL_ROOM-full_circle_in_15s]": 12, - "test_ism_binaural_headrotation_vs_decoder[ISM3-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 13, - "test_ism_binaural_headrotation_vs_decoder[ISM4-BINAURAL_ROOM-full_circle_in_15s]": 12, - "test_ism_binaural_headrotation_vs_decoder[ISM4-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 13, - "test_ism_binaural_static_vs_decoder[ISM1-BINAURAL_ROOM]": 15, - "test_ism_binaural_static_vs_decoder[ISM2-BINAURAL_ROOM]": 12, - "test_ism_binaural_static_vs_decoder[ISM3-BINAURAL_ROOM]": 12, - "test_ism_binaural_static_vs_decoder[ISM4-BINAURAL_ROOM]": 12, - # TODO harmonize panning to stereo - # Failure reason ISM to stereo panning is done via EFAP in the renderer and tangent law in decoder, harmonize - "test_ism_vs_decoder[ISM1-STEREO]": 8, - "test_ism_vs_decoder[ISM2-STEREO]": 17, - "test_ism_vs_decoder[ISM3-STEREO]": 14, - "test_ism_vs_decoder[ISM4-STEREO]": 14, - # TODO needs investigation - # Failure reason: likely differences between metadata position rounding (decoder uses ceil()) and crossfades - "test_ism_vs_decoder[ISM1-5_1_2]": 26, - "test_ism_vs_decoder[ISM1-5_1]": 26, - "test_ism_vs_decoder[ISM1-5_1_4]": 26, - "test_ism_vs_decoder[ISM1-7_1]": 26, - "test_ism_vs_decoder[ISM1-7_1_4]": 26, - "test_ism_vs_decoder[ISM1-FOA]": 26, - "test_ism_vs_decoder[ISM1-HOA2]": 26, - "test_ism_vs_decoder[ISM1-HOA3]": 26, - "test_ism_vs_decoder[ISM2-5_1_2]": 31, - "test_ism_vs_decoder[ISM2-5_1_4]": 31, - "test_ism_vs_decoder[ISM2-5_1]": 6, - "test_ism_vs_decoder[ISM2-7_1_4]": 31, - "test_ism_vs_decoder[ISM2-7_1]": 5, - "test_ism_vs_decoder[ISM2-FOA]": 31, - "test_ism_vs_decoder[ISM2-HOA2]": 30, - "test_ism_vs_decoder[ISM2-HOA3]": 29, - "test_ism_vs_decoder[ISM3-5_1_2]": 32, - "test_ism_vs_decoder[ISM3-5_1_4]": 32, - "test_ism_vs_decoder[ISM3-5_1]": 8, - "test_ism_vs_decoder[ISM3-7_1_4]": 31, - "test_ism_vs_decoder[ISM3-7_1]": 7, - "test_ism_vs_decoder[ISM3-FOA]": 32, - "test_ism_vs_decoder[ISM3-HOA2]": 31, - "test_ism_vs_decoder[ISM3-HOA3]": 29, - "test_ism_vs_decoder[ISM3-MONO]": 77, - "test_ism_vs_decoder[ISM4-5_1_2]": 31, - "test_ism_vs_decoder[ISM4-5_1_4]": 30, - "test_ism_vs_decoder[ISM4-5_1]": 8, - "test_ism_vs_decoder[ISM4-7_1_4]": 30, - "test_ism_vs_decoder[ISM4-7_1]": 7, - "test_ism_vs_decoder[ISM4-FOA]": 31, - "test_ism_vs_decoder[ISM4-HOA2]": 30, - "test_ism_vs_decoder[ISM4-HOA3]": 29, - "test_ism_vs_decoder[ISM4-MONO]": 77, - # TODO needs investigation - # Failure reason: headrotation and crossfade could have differences - "test_multichannel_binaural_headrotation_vs_decoder[5_1_2-BINAURAL-full_circle_in_15s]": 4, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_2-BINAURAL-rotate_yaw_pitch_roll1]": 0, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_4-BINAURAL-full_circle_in_15s]": 4, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_4-BINAURAL-rotate_yaw_pitch_roll1]": 0, - "test_multichannel_binaural_headrotation_vs_decoder[7_1_4-BINAURAL-full_circle_in_15s]": 4, - "test_multichannel_binaural_headrotation_vs_decoder[7_1_4-BINAURAL-rotate_yaw_pitch_roll1]": 0, - # TODO needs investigation - "test_multichannel_binaural_headrotation_vs_decoder[5_1-BINAURAL_ROOM-full_circle_in_15s]": 5, - "test_multichannel_binaural_headrotation_vs_decoder[5_1-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 0, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_2-BINAURAL_ROOM-full_circle_in_15s]": 6, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_2-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 0, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_4-BINAURAL_ROOM-full_circle_in_15s]": 7, - "test_multichannel_binaural_headrotation_vs_decoder[5_1_4-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 0, - "test_multichannel_binaural_headrotation_vs_decoder[7_1-BINAURAL_ROOM-full_circle_in_15s]": 5, - "test_multichannel_binaural_headrotation_vs_decoder[7_1-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 0, - "test_multichannel_binaural_headrotation_vs_decoder[7_1_4-BINAURAL_ROOM-full_circle_in_15s]": 5, - "test_multichannel_binaural_headrotation_vs_decoder[7_1_4-BINAURAL_ROOM-rotate_yaw_pitch_roll1]": 0, - # TODO needs investigation - "test_multichannel_binaural_static_vs_decoder[5_1_2-BINAURAL_ROOM]": 18, - "test_multichannel_binaural_static_vs_decoder[5_1_4-BINAURAL_ROOM]": 18, - "test_multichannel_binaural_static_vs_decoder[5_1-BINAURAL_ROOM]": 18, - "test_multichannel_binaural_static_vs_decoder[7_1_4-BINAURAL_ROOM]": 18, - "test_multichannel_binaural_static_vs_decoder[7_1-BINAURAL_ROOM]": 19, - # Failure reason: Mono downmix significantly different, needs a fix - "test_multichannel_vs_decoder[5_1_2-MONO]": 1, - "test_multichannel_vs_decoder[5_1_4-MONO]": 1, - "test_multichannel_vs_decoder[5_1-MONO]": 1, - "test_multichannel_vs_decoder[7_1_4-MONO]": 1, - "test_multichannel_vs_decoder[7_1-MONO]": 1, - "test_multichannel_vs_decoder[STEREO-MONO]": 17, - # Failure reason: Stereo downmix differs slightly, needs a fix - "test_multichannel_vs_decoder[5_1_2-STEREO]": 44, - "test_multichannel_vs_decoder[5_1_4-STEREO]": 48, - "test_multichannel_vs_decoder[5_1-STEREO]": 48, - "test_multichannel_vs_decoder[7_1_4-STEREO]": 46, - "test_multichannel_vs_decoder[7_1-STEREO]": 44, - # TODO needs investigation - # Failure reason: possibly due to minor differences in crossfades - "test_multichannel_vs_decoder[5_1_2-5_1_4]": 63, - "test_multichannel_vs_decoder[5_1_2-5_1]": 63, - "test_multichannel_vs_decoder[5_1_2-7_1_4]": 63, - "test_multichannel_vs_decoder[5_1_2-7_1]": 63, - "test_multichannel_vs_decoder[5_1_4-5_1_2]": 63, - "test_multichannel_vs_decoder[5_1_4-5_1]": 62, - "test_multichannel_vs_decoder[5_1_4-7_1_4]": 61, - "test_multichannel_vs_decoder[5_1_4-7_1]": 62, - "test_multichannel_vs_decoder[5_1-5_1_2]": 62, - "test_multichannel_vs_decoder[5_1-5_1_4]": 62, - "test_multichannel_vs_decoder[5_1-7_1_4]": 62, - "test_multichannel_vs_decoder[5_1-7_1]": 62, - "test_multichannel_vs_decoder[7_1_4-5_1_2]": 63, - "test_multichannel_vs_decoder[7_1_4-5_1_4]": 63, - "test_multichannel_vs_decoder[7_1_4-5_1]": 63, - "test_multichannel_vs_decoder[7_1_4-7_1]": 62, - "test_multichannel_vs_decoder[7_1-5_1_2]": 63, - "test_multichannel_vs_decoder[7_1-5_1_4]": 63, - "test_multichannel_vs_decoder[7_1-5_1]": 63, - "test_multichannel_vs_decoder[7_1-7_1_4]": 63, } diff --git a/tests/renderer/run_test_renderer_vs_decoder.sh b/tests/renderer/run_test_renderer_vs_decoder.sh deleted file mode 100755 index 215a6435b0..0000000000 --- a/tests/renderer/run_test_renderer_vs_decoder.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# WARNING! This script is a temporary helper, ideally these steps should be done manually and the pytest suite also run manually -cd ../../ -mkdir build -cmake -B build -G "Unix Makefiles" -DDEC_TO_REND_FLOAT_DUMP=true -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true -cmake --build build -- -j -python3 -m pytest -q -n 1 -rA tests/renderer/test_renderer_vs_decoder.py - -echo "WARNING! Existing executables in root were overwritten!" diff --git a/tests/renderer/test_renderer.py b/tests/renderer/test_renderer.py index 97ccf03c94..b8faad0ec5 100644 --- a/tests/renderer/test_renderer.py +++ b/tests/renderer/test_renderer.py @@ -27,31 +27,33 @@ """ +import random import pytest + from .utils import * +random.seed(42) """ Ambisonics """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) +@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1)) def test_ambisonics(test_info, in_fmt, out_fmt): - compare_renderer_vs_pyscripts(test_info, in_fmt, out_fmt) + run_renderer(in_fmt, out_fmt) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1)) def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt): - compare_renderer_vs_crend_unit_test(test_info, in_fmt, out_fmt) + run_renderer(in_fmt, out_fmt) -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) +@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1)) def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): - compare_renderer_vs_crend_unit_test( - test_info, + run_renderer( in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), @@ -61,38 +63,36 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): """ Multichannel """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2)) def test_multichannel(test_info, in_fmt, out_fmt): - compare_renderer_vs_pyscripts(test_info, in_fmt, out_fmt) + run_renderer(in_fmt, out_fmt) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2)) def test_multichannel_binaural_static(test_info, in_fmt, out_fmt): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") - compare_renderer_vs_crend_unit_test(test_info, in_fmt, out_fmt) + run_renderer(in_fmt, out_fmt) -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) +@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2)) def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") if (in_fmt == "5_1" or in_fmt == "7_1") and out_fmt == "BINAURAL": - compare_renderer_vs_td_standalone( - test_info, + run_renderer( in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), ) else: - compare_renderer_vs_crend_unit_test( - test_info, + run_renderer( in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), @@ -102,16 +102,14 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file """ ISM """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2)) def test_ism(test_info, in_fmt, out_fmt): - compare_renderer_vs_pyscripts( - test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt] - ) + run_renderer(in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt]) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2)) def test_ism_binaural_static(test_info, in_fmt, out_fmt): try: in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] @@ -119,18 +117,14 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt): in_meta_files = None if out_fmt == "BINAURAL": - compare_renderer_vs_td_standalone( - test_info, in_fmt, out_fmt, in_meta_files=in_meta_files - ) + run_renderer(in_fmt, out_fmt, in_meta_files=in_meta_files) else: - compare_renderer_vs_pyscripts( - test_info, in_fmt, out_fmt, in_meta_files=in_meta_files - ) + run_renderer(in_fmt, out_fmt, in_meta_files=in_meta_files) -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) +@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2)) def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): try: in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] @@ -138,16 +132,14 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): in_meta_files = None if out_fmt == "BINAURAL": - compare_renderer_vs_td_standalone( - test_info, + run_renderer( in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=in_meta_files, ) else: - compare_renderer_vs_pyscripts( - test_info, + run_renderer( in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), @@ -158,8 +150,8 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): """ MASA """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) +@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) +@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MASA, 1)) def test_masa(test_info, in_fmt, out_fmt): # # TODO: implement MASA in Python, compare BE # compare_renderer_vs_pyscripts( test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt] @@ -168,8 +160,8 @@ def test_masa(test_info, in_fmt, out_fmt): # MASA inputs not supported yet -# @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -# @pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST_NO_BE) +# @pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS, 2)) +# @pytest.mark.parametrize("in_fmt", random.sample(METADATA_SCENES_TO_TEST_NO_BE, 2)) # def test_metadata_masa(test_info, in_fmt, out_fmt): # # TODO: unify with test_metadata once Python supports MASA # cut, cut_fs = run_renderer( @@ -182,50 +174,44 @@ def test_masa(test_info, in_fmt, out_fmt): """ Custom loudspeaker layouts """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) +@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 1)) def test_custom_ls_input(test_info, in_layout, out_fmt): - compare_renderer_vs_pyscripts( - test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt - ) + run_renderer(CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt) -@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST) -@pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS) +@pytest.mark.parametrize("out_fmt", random.sample(CUSTOM_LS_TO_TEST, 1)) +@pytest.mark.parametrize("in_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) def test_custom_ls_output(test_info, in_fmt, out_fmt): - compare_renderer_vs_pyscripts( - test_info, + run_renderer( in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), ) -@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST) -@pytest.mark.parametrize("in_fmt", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("out_fmt", random.sample(CUSTOM_LS_TO_TEST, 1)) +@pytest.mark.parametrize("in_fmt", random.sample(CUSTOM_LS_TO_TEST, 1)) def test_custom_ls_input_output(test_info, in_fmt, out_fmt): - compare_renderer_vs_pyscripts( - test_info, + run_renderer( CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"), CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), ) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 2)) def test_custom_ls_input_binaural(test_info, in_layout, out_fmt): - compare_renderer_vs_pyscripts( - test_info, + run_renderer( CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, ) -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) +@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 2)) def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, trj_file): - compare_renderer_vs_pyscripts( - test_info, + run_renderer( CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), @@ -235,11 +221,10 @@ def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, tr """ Metadata / scene description input """ -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST) +@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 1)) +@pytest.mark.parametrize("in_fmt", random.sample(METADATA_SCENES_TO_TEST, 1)) def test_metadata(test_info, in_fmt, out_fmt): - compare_renderer_vs_pyscripts( - test_info, + run_renderer( "META", out_fmt, metadata_input=TEST_VECTOR_DIR.joinpath(f"{in_fmt}.txt"), diff --git a/tests/renderer/test_renderer_vs_decoder.py b/tests/renderer/test_renderer_vs_decoder.py deleted file mode 100644 index cd88580d9b..0000000000 --- a/tests/renderer/test_renderer_vs_decoder.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python3 - -""" - (C) 2022 Baseline Development Group with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies OY, Orange, - Panasonic Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The Baseline Development Group consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies OY, Orange, - Panasonic Corporation, Qualcomm Technologies, Inc., and VoiceAge Corporation retain full ownership - rights in their respective contributions in the software. No license of any kind, including but not - limited to patent license, of any foregoing parties is hereby granted by implication, estoppel or - otherwise. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and/or fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. -""" - -from .utils import * - -""" Ambisonics """ - - -@pytest.mark.skip("Ambisonics comparison requires CLDFB interface") -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_vs_decoder(test_info, in_fmt, out_fmt): - compare_renderer_vs_decoder(test_info, in_fmt, out_fmt) - - -@pytest.mark.skip("Ambisonics comparison requires CLDFB interface") -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_binaural_static_vs_decoder(test_info, in_fmt, out_fmt): - compare_renderer_vs_decoder(test_info, in_fmt, out_fmt) - - -@pytest.mark.skip("Ambisonics comparison requires CLDFB interface") -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_binaural_headrotation_vs_decoder( - test_info, in_fmt, out_fmt, trj_file -): - compare_renderer_vs_decoder( - test_info, - in_fmt, - out_fmt, - trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), - ) - - -""" Multichannel """ - - -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) -def test_multichannel_vs_decoder(test_info, in_fmt, out_fmt): - if in_fmt == "MONO": - pytest.skip("(EVS) Mono decoder rendering unsupported") - - if in_fmt == "STEREO" and out_fmt in ["FOA", "HOA2", "HOA3"]: - pytest.skip("Stereo to Ambisonics rendering unsupported in the decoder") - - compare_renderer_vs_decoder(test_info, in_fmt, out_fmt) - - -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) -def test_multichannel_binaural_static_vs_decoder(test_info, in_fmt, out_fmt): - if in_fmt in ["MONO", "STEREO"]: - pytest.skip("MONO or STEREO to Binaural rendering unsupported") - - compare_renderer_vs_decoder(test_info, in_fmt, out_fmt) - - -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) -def test_multichannel_binaural_headrotation_vs_decoder( - test_info, in_fmt, out_fmt, trj_file -): - if in_fmt in ["MONO", "STEREO"]: - pytest.skip("MONO or STEREO to Binaural rendering unsupported") - - compare_renderer_vs_decoder( - test_info, - in_fmt, - out_fmt, - trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), - ) - - -""" ISM """ - - -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_vs_decoder(test_info, in_fmt, out_fmt): - compare_renderer_vs_decoder(test_info, in_fmt, out_fmt) - - -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_binaural_static_vs_decoder(test_info, in_fmt, out_fmt): - compare_renderer_vs_decoder(test_info, in_fmt, out_fmt) - - -@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_binaural_headrotation_vs_decoder(test_info, in_fmt, out_fmt, trj_file): - compare_renderer_vs_decoder( - test_info, - in_fmt, - out_fmt, - trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), - ) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 8a4ecf739b..b4ab4401f4 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -100,51 +100,6 @@ def check_BE( ) -def run_enc( - in_fmt: str, - bit_file: str, - in_meta_files: Optional[list] = None, -) -> None: - - cmd = IVAS_COD_CMD[:] - cmd[1] = FORMAT_TO_IVAS[in_fmt][0] - cmd[2] = FORMAT_TO_IVAS[in_fmt][1] - cmd[3] = FORMAT_TO_IVAS_BR[in_fmt] - cmd[5] = str(FORMAT_TO_FILE[in_fmt]) - cmd[6] = bit_file - - if in_meta_files is not None: - cmd[3:3] = [*in_meta_files] - - if in_fmt == "MONO": - cmd.pop(1) - cmd.pop(1) - elif in_fmt == "STEREO": - cmd.pop(2) - - run_cmd(cmd) - - -def run_dec( - bit_file: str, - out_file: str, - out_fmt: str, - trj_file: Optional[str] = None, -) -> Tuple[np.ndarray, int]: - - cmd = IVAS_DEC_CMD[:] - cmd[2] = out_fmt - cmd[4] = bit_file - cmd[5] = out_file - - if trj_file is not None and out_fmt in ["BINAURAL", "BINAURAL_ROOM"]: - cmd[1:1] = ["-T", str(trj_file)] - - run_cmd(cmd) - - return pyaudio3dtools.audiofile.readfile(out_file) - - def run_renderer( in_fmt: str, out_fmt: str, @@ -177,7 +132,6 @@ def run_renderer( out_file = str(output_path_base.joinpath(f"{in_name}_to_{out_name}{trj_name}.wav")) - cmd = RENDERER_CMD[:] cmd[2] = str(in_file) cmd[4] = str(in_fmt) @@ -197,153 +151,6 @@ def run_renderer( return pyaudio3dtools.audiofile.readfile(out_file) -def run_renderer_ext( - in_file: str, - in_fmt: str, - out_fmt: str, - in_meta_files: Optional[list] = None, - trj_file: Optional[str] = None, -) -> Tuple[np.ndarray, int]: - """Run renderer with decoder float dump""" - if trj_file is not None: - trj_name = f"_{trj_file.stem}" - else: - trj_name = "" - - if not isinstance(out_fmt, str): - out_name = f"{out_fmt.stem}" - else: - out_name = out_fmt - - in_name = in_fmt - - out_file = str(OUTPUT_PATH_CUT.joinpath(f"{in_name}_to_{out_name}{trj_name}.wav")) - - cmd = RENDERER_CMD[:] - cmd[2] = str(in_file) - cmd[4] = str(in_fmt) - cmd[6] = str(out_file) - cmd[8] = str(out_fmt) - - if in_meta_files is not None: - cmd[5:5] = ["-im", *in_meta_files] - - if trj_file is not None: - cmd.extend(["-tf", str(trj_file)]) - - run_cmd(cmd) - - return pyaudio3dtools.audiofile.readfile(out_file) - - -def run_crend_unittest( - in_fmt: str, - out_fmt: str, - metadata_input: Optional[str] = None, - in_meta_files: Optional[list] = None, - trj_file: Optional[str] = None, -) -> Tuple[np.ndarray, int]: - """Reference creation with standalone renderer""" - if trj_file is not None: - trj_name = f"_{trj_file.stem}" - else: - trj_name = "" - - if not isinstance(out_fmt, str): - out_name = f"{out_fmt.stem}" - else: - out_name = out_fmt - - if metadata_input is not None: - in_file = metadata_input - in_name = metadata_input.stem - elif not isinstance(in_fmt, str): - in_file = FORMAT_TO_FILE[in_fmt.stem] - in_name = in_fmt.stem - else: - in_file = FORMAT_TO_FILE[in_fmt] - in_name = in_fmt - - out_file = str(OUTPUT_PATH_REF.joinpath(f"{in_name}_to_{out_name}{trj_name}.wav")) - - cmd = CREND_CMD[:] - cmd[6] = FORMAT_TO_CREND_FORMAT[str(in_fmt)] - cmd[8] = FORMAT_TO_CREND_FORMAT[str(out_fmt)] - cmd[10] = str(in_file) - cmd[12] = str(out_file) - if out_fmt == "BINAURAL_ROOM": - cmd.append("-brir") - - if trj_file is not None: - cmd.extend(["-t", str(trj_file)]) - cmd.extend(["-otr", "REF"]) - - run_cmd(cmd) - - return pyaudio3dtools.audiofile.readfile(out_file) - - -def run_td_standalone( - in_fmt: str, - out_fmt: str, - metadata_input: Optional[str] = None, - in_meta_files: Optional[list] = None, - trj_file: Optional[str] = None, -): - """Reference creation with TD Object renderer""" - if trj_file is not None: - trj_name = f"_{trj_file.stem}" - else: - trj_name = "" - - if not isinstance(out_fmt, str): - out_name = f"{out_fmt.stem}" - else: - out_name = out_fmt - - if metadata_input is not None: - in_file = metadata_input - in_name = metadata_input.stem - elif not isinstance(in_fmt, str): - in_file = FORMAT_TO_FILE[in_fmt.stem] - in_name = in_fmt.stem - else: - in_file = FORMAT_TO_FILE[in_fmt] - in_name = in_fmt - - out_file = str(OUTPUT_PATH_REF.joinpath(f"{in_name}_to_{out_name}{trj_name}.pcm")) - - in_spfmt = pyaudio3dtools.spatialaudioformat.Format(in_fmt) - - with TemporaryDirectory() as tmp_dir: - # write PCM tmp file - tmp_dir = Path(tmp_dir) - in_file_pcm = tmp_dir.joinpath(in_file.stem + ".pcm") - - in_sig, _ = pyaudio3dtools.audiofile.readfile(in_file) - pyaudio3dtools.audiofile.writefile(in_file_pcm, in_sig) - - cmd = TDRENDERER_CMD[:] - cmd[2] = str(in_file_pcm) - cmd[3] = str(out_file) - - if in_spfmt.isloudspeaker: - cmd[1:1] = ["-mc", in_spfmt.name] - else: - cmd[1:1] = str(in_spfmt.nchannels) - if in_meta_files is not None: - cmd[2:2] = in_meta_files - else: - cmd[2:2] = ["NULL"] * in_spfmt.nchannels - - if trj_file is not None: - cmd[1:1] = ["-T", str(trj_file)] - - run_cmd(cmd) - - return pyaudio3dtools.audiofile.readfile(out_file, nchannels=2) - - def run_pyscripts( in_fmt, out_fmt, @@ -389,7 +196,11 @@ def run_pyscripts( def compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, **kwargs): ref, ref_fs = run_renderer( - in_fmt, out_fmt, binary_suffix=BIN_SUFFIX_MERGETARGET, output_path_base=OUTPUT_PATH_REF, **kwargs + in_fmt, + out_fmt, + binary_suffix=BIN_SUFFIX_MERGETARGET, + output_path_base=OUTPUT_PATH_REF, + **kwargs, ) cut, cut_fs = run_renderer(in_fmt, out_fmt, **kwargs) check_BE(test_info, ref, ref_fs, cut, cut_fs) @@ -399,54 +210,3 @@ def compare_renderer_vs_pyscripts(test_info, in_fmt, out_fmt, **kwargs): ref, ref_fs = run_pyscripts(in_fmt, out_fmt, **kwargs) cut, cut_fs = run_renderer(in_fmt, out_fmt, **kwargs) check_BE(test_info, ref, ref_fs, cut, cut_fs) - - -def compare_renderer_vs_crend_unit_test(test_info, in_fmt, out_fmt, **kwargs): - ref, ref_fs = run_crend_unittest(in_fmt, out_fmt, **kwargs) - cut, cut_fs = run_renderer(in_fmt, out_fmt, **kwargs) - check_BE(test_info, ref, ref_fs, cut, cut_fs) - - -def compare_renderer_vs_td_standalone(test_info, in_fmt, out_fmt, **kwargs): - ref, ref_fs = run_td_standalone(in_fmt, out_fmt, **kwargs) - cut, cut_fs = run_renderer(in_fmt, out_fmt, **kwargs) - check_BE(test_info, ref, ref_fs, cut, cut_fs) - - -def compare_renderer_vs_decoder(test_info, in_fmt, out_fmt, **kwargs): - with TemporaryDirectory() as tmp_dir: - tmp_dir = Path(tmp_dir) - - in_meta_files = None - bit_file = str(tmp_dir.joinpath(f"{in_fmt}_to_{out_fmt}.192")) - out_file_decoder = str(OUTPUT_PATH_REF.joinpath(f"{in_fmt}_to_{out_fmt}.wav")) - - # Ref: cod -> dec (out_fmt) - if in_fmt in FORMAT_TO_METADATA_FILES.keys(): - in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] - - # encoder - run_enc(in_fmt, bit_file, in_meta_files=in_meta_files) - # decoder renderer - ref, ref_fs = run_dec(bit_file, out_file_decoder, out_fmt, **kwargs) - - # CuT cod -> dec (in_fmt) -> rend - if in_fmt in FORMAT_TO_METADATA_FILES.keys(): - tmp_fmt = "EXT" - in_meta_files = [ - str(tmp_dir.joinpath(f"{in_fmt}_to_EXT.wav.{n}.csv")) - for n in range(int(in_fmt[-1])) - ] - else: - tmp_fmt = in_fmt - - out_file_ext = str(tmp_dir.joinpath(f"{in_fmt}_to_{tmp_fmt}.wav")) - - # passthrough decoder - run_dec(bit_file, out_file_ext, tmp_fmt, **kwargs) - # external renderer - cut, cut_fs = run_renderer_ext( - out_file_ext, in_fmt, out_fmt, in_meta_files=in_meta_files, **kwargs - ) - - check_BE(test_info, ref, ref_fs, cut, cut_fs) -- GitLab From 18031bb0fde4ab460fed46e36b2c31cedc9bf3b8 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 17 Nov 2022 17:45:26 +0100 Subject: [PATCH 02/11] remove build jobs from ci --- .gitlab-ci.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62554b51a4..4e849938dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -201,26 +201,6 @@ build-codec-linux-make: # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...< - ci/check_for_warnings.py $BUILD_OUTPUT || exit $? -build-unittests-linux: - extends: - - .build-job-with-check-for-warnings - - .rules-basis - script: - - *print-common-info - - make unittests -j 2>&1 | tee $BUILD_OUTPUT - # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...< - - ci/check_for_warnings.py $BUILD_OUTPUT || exit $? - -build-td-object-renderer-standalone-linux: - extends: - - .build-job-with-check-for-warnings - - .rules-basis - script: - - *print-common-info - - make -C scripts/td_object_renderer/object_renderer_standalone -j 2>&1 | tee $BUILD_OUTPUT - # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...< - - ci/check_for_warnings.py $BUILD_OUTPUT || exit $? - build-codec-linux-cmake: extends: - .build-job-with-check-for-warnings -- GitLab From 734142ae4c30382145011786c9dd1cef5c4cf41e Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 16 Jan 2023 17:16:54 +0100 Subject: [PATCH 03/11] remove random sampling in test_renderer.py - exhaustive run takes ~5s for 312 tests --- tests/renderer/test_renderer.py | 62 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/tests/renderer/test_renderer.py b/tests/renderer/test_renderer.py index b8faad0ec5..c43dd68d19 100644 --- a/tests/renderer/test_renderer.py +++ b/tests/renderer/test_renderer.py @@ -27,31 +27,29 @@ """ -import random import pytest from .utils import * -random.seed(42) """ Ambisonics """ -@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1)) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics(test_info, in_fmt, out_fmt): run_renderer(in_fmt, out_fmt) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1)) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt): run_renderer(in_fmt, out_fmt) -@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_AMBI, 1)) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): run_renderer( in_fmt, @@ -63,14 +61,14 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): """ Multichannel """ -@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2)) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) def test_multichannel(test_info, in_fmt, out_fmt): run_renderer(in_fmt, out_fmt) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2)) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) def test_multichannel_binaural_static(test_info, in_fmt, out_fmt): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") @@ -78,9 +76,9 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt): run_renderer(in_fmt, out_fmt) -@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MC, 2)) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") @@ -102,14 +100,14 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file """ ISM """ -@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2)) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism(test_info, in_fmt, out_fmt): run_renderer(in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt]) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2)) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_binaural_static(test_info, in_fmt, out_fmt): try: in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] @@ -122,9 +120,9 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt): run_renderer(in_fmt, out_fmt, in_meta_files=in_meta_files) -@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_ISM, 2)) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): try: in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] @@ -150,8 +148,8 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): """ MASA """ -@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) -@pytest.mark.parametrize("in_fmt", random.sample(INPUT_FORMATS_MASA, 1)) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) def test_masa(test_info, in_fmt, out_fmt): # # TODO: implement MASA in Python, compare BE # compare_renderer_vs_pyscripts( test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt] @@ -160,8 +158,8 @@ def test_masa(test_info, in_fmt, out_fmt): # MASA inputs not supported yet -# @pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS, 2)) -# @pytest.mark.parametrize("in_fmt", random.sample(METADATA_SCENES_TO_TEST_NO_BE, 2)) +# @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) +# @pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST_NO_BE) # def test_metadata_masa(test_info, in_fmt, out_fmt): # # TODO: unify with test_metadata once Python supports MASA # cut, cut_fs = run_renderer( @@ -174,14 +172,14 @@ def test_masa(test_info, in_fmt, out_fmt): """ Custom loudspeaker layouts """ -@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) -@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 1)) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) +@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input(test_info, in_layout, out_fmt): run_renderer(CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt) -@pytest.mark.parametrize("out_fmt", random.sample(CUSTOM_LS_TO_TEST, 1)) -@pytest.mark.parametrize("in_fmt", random.sample(OUTPUT_FORMATS[2:], 2)) +@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS[2:]) def test_custom_ls_output(test_info, in_fmt, out_fmt): run_renderer( in_fmt, @@ -189,8 +187,8 @@ def test_custom_ls_output(test_info, in_fmt, out_fmt): ) -@pytest.mark.parametrize("out_fmt", random.sample(CUSTOM_LS_TO_TEST, 1)) -@pytest.mark.parametrize("in_fmt", random.sample(CUSTOM_LS_TO_TEST, 1)) +@pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("in_fmt", CUSTOM_LS_TO_TEST) def test_custom_ls_input_output(test_info, in_fmt, out_fmt): run_renderer( CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"), @@ -199,7 +197,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt): @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 2)) +@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input_binaural(test_info, in_layout, out_fmt): run_renderer( CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), @@ -207,9 +205,9 @@ def test_custom_ls_input_binaural(test_info, in_layout, out_fmt): ) -@pytest.mark.parametrize("trj_file", random.sample(HR_TRAJECTORIES_TO_TEST, 1)) +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) -@pytest.mark.parametrize("in_layout", random.sample(CUSTOM_LS_TO_TEST, 2)) +@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, trj_file): run_renderer( CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), @@ -221,8 +219,8 @@ def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, tr """ Metadata / scene description input """ -@pytest.mark.parametrize("out_fmt", random.sample(OUTPUT_FORMATS[2:], 1)) -@pytest.mark.parametrize("in_fmt", random.sample(METADATA_SCENES_TO_TEST, 1)) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) +@pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST) def test_metadata(test_info, in_fmt, out_fmt): run_renderer( "META", -- GitLab From 7e84a542dc71c525f55fa1dee580f6bf585693fb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 16 Jan 2023 17:25:38 +0100 Subject: [PATCH 04/11] remove run_test_bin_latencys.py from repository root --- run_test_bin_latencys.py | 204 --------------------------------------- 1 file changed, 204 deletions(-) delete mode 100644 run_test_bin_latencys.py diff --git a/run_test_bin_latencys.py b/run_test_bin_latencys.py deleted file mode 100644 index 36101cdac8..0000000000 --- a/run_test_bin_latencys.py +++ /dev/null @@ -1,204 +0,0 @@ - - -import os -import subprocess -import errno -import tempfile as tf -import sys -from scipy.io.wavfile import read, write -import numpy as np - -ivas_path = 'D:/DEV/ivas-3gpp/' - -trunk_path = ivas_path + 'ivas-codec/' -script_path = trunk_path + 'scripts/' -inpath = script_path + 'testv/' -outpath = script_path + 'testv/out/' -trajpath = script_path + 'trajectories/' - -if sys.platform.startswith('win32'): - unit_test_exe = trunk_path + 'build/IVAS_crend_unit_test.exe' - ivas_cod_exe = trunk_path + 'build/IVAS_cod.exe' - ivas_dec_exe = trunk_path + 'build/IVAS_dec.exe' - -file_name_7_1_root = 'test_8ch_' - -file_name_7_1_4_root = 'dirac_12ch_' - -sampleRates = ['48', '16', '32'] -# sampleRates = ['48'] - -for sr in sampleRates: - file_name_7_1_4 = inpath + file_name_7_1_4_root + sr + 'k' - inFileName_7_1_4 = file_name_7_1_4 + '.wav' - - file_name_7_1 = inpath + file_name_7_1_root + sr + 'k' - inFileName_7_1 = file_name_7_1 + '.wav' - - # encode 7.1.4 512kb - cmd = [ivas_cod_exe, '-MC', '7_1_4', '-max_band', 'FB', '512000', sr, - file_name_7_1_4 + '.wav', file_name_7_1_4 + '_512kb.ptk'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # encode 7.1 512kb - cmd = [ivas_cod_exe, '-MC', '7_1', '-max_band', 'FB', '512000', sr, - file_name_7_1 + '.wav', file_name_7_1 + '_512kb.ptk'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # encode 7.1.4 128kb PARAMMC - cmd = [ivas_cod_exe, '-MC', '7_1_4', '-max_band', 'FB', '128000', sr, - file_name_7_1_4 + '.wav', file_name_7_1_4 + '_128kb.ptk'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # encode 7.1 64kb PARAMMC - cmd = [ivas_cod_exe, '-MC', '7_1', '-max_band', 'FB', '64000', sr, - file_name_7_1 + '.wav', file_name_7_1 + '_64kb.ptk'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode 7_1_4 - cmd = [ivas_dec_exe, '7_1_4', sr, file_name_7_1_4 + - '_512kb.ptk', file_name_7_1_4 + '_enc_dec.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode 7_1 - cmd = [ivas_dec_exe, '7_1', sr, file_name_7_1 + - '_512kb.ptk', file_name_7_1 + '_enc_dec.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - -# -render_config testv/config_renderer.cfg -# # decode binaural crend 7.1.4 -# cmd = [ivas_dec_exe, '-render_config', 'script/testv/config_renderer_fastconv.cfg', 'BINAURAL', sr, file_name_7_1_4 + -# '_512kb.ptk', file_name_7_1_4 + '-hrir.wav'] - -# print(' '.join(cmd)) -# subprocess.call(cmd, shell=False) - -# # decode binaural room crend 7.1.4 -# cmd = [ivas_dec_exe, 'BINAURAL_ROOM', sr, -# file_name_7_1_4 + '_128kb.ptk', file_name_7_1_4 + '-parammc_brir.wav'] - -# print(' '.join(cmd)) -# subprocess.call(cmd, shell=False) - - # decode binaural crend 7.1.4 - cmd = [ivas_dec_exe, 'BINAURAL', sr, file_name_7_1_4 + - '_512kb.ptk', file_name_7_1_4 + '-hrir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural room crend 7.1.4 - cmd = [ivas_dec_exe, 'BINAURAL_ROOM', sr, - file_name_7_1_4 + '_128kb.ptk', file_name_7_1_4 + '-parammc_brir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural crend 7.1.4 - cmd = [ivas_dec_exe, 'BINAURAL', sr, file_name_7_1_4 + - '_128kb.ptk', file_name_7_1_4 + '-parammc_hrir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural room crend 7.1.4 - cmd = [ivas_dec_exe, 'BINAURAL_ROOM', sr, - file_name_7_1_4 + '_512kb.ptk', file_name_7_1_4 + '-brir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - # decode binaural crend 7.1 - cmd = [ivas_dec_exe, 'BINAURAL', sr, file_name_7_1 + - '_512kb.ptk', file_name_7_1 + '-hrir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural room crend 7.1 - cmd = [ivas_dec_exe, 'BINAURAL_ROOM', sr, file_name_7_1 + - '_512kb.ptk', file_name_7_1 + '-brir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural fastconv 7.1 - cmd = [ivas_dec_exe, 'BINAURAL', sr, file_name_7_1 + - '_64kb.ptk', file_name_7_1 + '-parammc-hrir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural room fastconv 7.1 - cmd = [ivas_dec_exe, 'BINAURAL_ROOM', sr, file_name_7_1 + - '_64kb.ptk', file_name_7_1 + '-parammc-brir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural TD 7.1.4 - cmd = [ivas_dec_exe, '-T', trajpath + '/const000.csv', 'BINAURAL', sr, - file_name_7_1_4 + '_512kb.ptk', file_name_7_1_4 + '-td-hrir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - # decode binaural TD 7.1 - cmd = [ivas_dec_exe, '-T', trajpath + '/const000.csv', 'BINAURAL', sr, - file_name_7_1 + '_512kb.ptk', file_name_7_1 + '-td-hrir.wav'] - - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - -# render CICP19 to binaural -sampleRates = ['16', '32', '48'] -# option = ['-limiter', '-lp_lfe'] -option = ['-lp_lfe'] - -for sr in sampleRates: - file_name_7_1_4 = inpath + file_name_7_1_4_root + sr + 'k' - inFileName_7_1_4 = file_name_7_1_4 + '.wav' - - file_name_7_1 = inpath + file_name_7_1_root + sr + 'k' - inFileName_7_1 = file_name_7_1 + '.wav' - - cmd = [unit_test_exe, '-test', '1', '-sr', sr, '-ifmt', '7', '-ofmt', '2', '-i', - inFileName_7_1_4, '-o', file_name_7_1_4 + '-hrir-crend-u.wav'] - cmd = cmd + option - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - cmd = [unit_test_exe, '-test', '1', '-sr', sr, '-ifmt', '7', '-ofmt', '2', '-BRIR', - '-i', inFileName_7_1_4, '-o', file_name_7_1_4 + '-brir-crend-u.wav'] - cmd = cmd + option - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - cmd = [unit_test_exe, '-test', '2', '-sr', sr, '-ifmt', '7', '-ofmt', '2', '-i', - inFileName_7_1_4, '-o', file_name_7_1_4 + '-hrir-fastconv-u.wav'] - cmd = cmd + option - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - cmd = [unit_test_exe, '-test', '2', '-sr', sr, '-ifmt', '7', '-ofmt', '2', '-BRIR', - '-i', inFileName_7_1_4, '-o', file_name_7_1_4 + '-brir-fastconv-u.wav'] - cmd = cmd + option - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) - - cmd = [unit_test_exe, '-test', '4', '-sr', sr, '-ifmt', '7', '-ofmt', '2', - '-i', inFileName_7_1_4, '-o', file_name_7_1_4 + '-hrir-td-u.wav'] - cmd = cmd + option - print(' '.join(cmd)) - subprocess.call(cmd, shell=False) -- GitLab From 522595ba0ee5caae1c8991e7e0a56de87da4f95b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 16 Jan 2023 17:27:32 +0100 Subject: [PATCH 05/11] modify cmake build commands for CI --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 715194beff..2c518c1e9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -333,7 +333,7 @@ external-renderer-cmake-asan-pytest: stage: test script: - python3 ci/disable_ram_counting.py - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan - cmake --build cmake-build -- -j - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py @@ -356,7 +356,7 @@ external-renderer-cmake-msan-pytest: stage: test script: - python3 ci/disable_ram_counting.py - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan - cmake --build cmake-build -- -j - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py -- GitLab From 58bb2889954fa6183c53dc2fc246d0973d05d312 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 17 Jan 2023 11:07:11 +0100 Subject: [PATCH 06/11] Revert "modify cmake build commands for CI" This reverts commit 522595ba0ee5caae1c8991e7e0a56de87da4f95b. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c518c1e9f..715194beff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -333,7 +333,7 @@ external-renderer-cmake-asan-pytest: stage: test script: - python3 ci/disable_ram_counting.py - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan + - 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 @@ -356,7 +356,7 @@ external-renderer-cmake-msan-pytest: stage: test script: - python3 ci/disable_ram_counting.py - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan + - 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 -- GitLab From 044efe225687da35b782a6c14b5765f8112c934b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 17 Jan 2023 12:59:16 +0100 Subject: [PATCH 07/11] update CI job to rename some tests --- .gitlab-ci.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 715194beff..11ebfa1f5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -261,7 +261,7 @@ codec-smoke-test: expose_as: "Smoke test results" # code selftest testvectors with memory-sanitizer binaries -msan-on-merge-request-linux: +codec-msan-linux: extends: - .test-job-linux - .rules-merge-request @@ -280,10 +280,10 @@ msan-on-merge-request-linux: paths: - scripts/ref/logs/ - test_output.txt - expose_as: "Msan selftest results" + expose_as: "msan selftest results" # code selftest testvectors with address-sanitizer binaries -asan-on-merge-request-linux: +codec-asan-linux: extends: - .test-job-linux - .rules-merge-request @@ -302,10 +302,10 @@ asan-on-merge-request-linux: paths: - scripts/ref/logs/ - test_output.txt - expose_as: "Asan selftest results" + expose_as: "asan selftest results" -# test external renderer executable -external-renderer-pytest: +# test renderer executable +renderer-smoke-test: extends: - .test-job-linux - .rules-merge-request @@ -319,13 +319,13 @@ external-renderer-pytest: when: always paths: - report-junit.xml - expose_as: "external renderer make pytest results" + expose_as: "renderer make pytest results" reports: junit: - report-junit.xml -# test external renderer executable with cmake + asan -external-renderer-cmake-asan-pytest: +# test renderer executable with cmake + asan +renderer-asan-pytest: extends: - .test-job-linux - .rules-merge-request @@ -342,13 +342,13 @@ external-renderer-cmake-asan-pytest: when: always paths: - report-junit.xml - expose_as: "external renderer cmake asan pytest results" + expose_as: "renderer asan pytest results" reports: junit: - report-junit.xml -# test external renderer executable with cmake + msan -external-renderer-cmake-msan-pytest: +# test renderer executable with cmake + msan +renderer-msan-pytest: extends: - .test-job-linux - .rules-merge-request @@ -365,13 +365,13 @@ external-renderer-cmake-msan-pytest: when: always paths: - report-junit.xml - expose_as: "external renderer cmake msan pytest results" + expose_as: "renderer msan pytest results" reports: junit: - report-junit.xml -# compare external renderer bitexactness between target and source branch -external-renderer-pytest-on-merge-request: +# compare renderer bitexactness between target and source branch +renderer-pytest-on-merge-request: extends: - .test-job-linux - .rules-merge-request @@ -419,7 +419,7 @@ external-renderer-pytest-on-merge-request: paths: - report-junit.xml - report.html - expose_as: "pytest external renderer results" + expose_as: "pytest renderer results" reports: junit: - report-junit.xml @@ -884,7 +884,7 @@ coverage-test-on-main-scheduled: script: - *print-common-info - make GCOV=1 -j - - cp IVAS_rend IVAS_rend_ref # Copy exec to be able to run external renderer script + - cp IVAS_rend IVAS_rend_ref # Copy exec to be able to run renderer script - python3 tests/create_short_testvectors.py - python3 -m pytest tests -v -n 0 --update_ref 1 -m create_ref --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec - python3 -m pytest tests -v -n 0 --update_ref 1 -m create_ref_part2 --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec -- GitLab From 05ae79c836cd37d058739985b300aa1128305efe Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 17 Jan 2023 13:07:25 +0100 Subject: [PATCH 08/11] more renaming --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 11ebfa1f5d..b8f4708472 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -261,7 +261,7 @@ codec-smoke-test: expose_as: "Smoke test results" # code selftest testvectors with memory-sanitizer binaries -codec-msan-linux: +codec-msan: extends: - .test-job-linux - .rules-merge-request @@ -283,7 +283,7 @@ codec-msan-linux: expose_as: "msan selftest results" # code selftest testvectors with address-sanitizer binaries -codec-asan-linux: +codec-asan: extends: - .test-job-linux - .rules-merge-request @@ -325,7 +325,7 @@ renderer-smoke-test: - report-junit.xml # test renderer executable with cmake + asan -renderer-asan-pytest: +renderer-asan: extends: - .test-job-linux - .rules-merge-request @@ -348,7 +348,7 @@ renderer-asan-pytest: - report-junit.xml # test renderer executable with cmake + msan -renderer-msan-pytest: +renderer-msan: extends: - .test-job-linux - .rules-merge-request -- GitLab From 1f721b1894e28bfd200d86619ecd35adb3376229 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 17 Jan 2023 14:08:54 +0100 Subject: [PATCH 09/11] cleanup renderer tests, and try to use long testvectors for MR BE comparison --- tests/renderer/constants.py | 33 ++++++++++++++----- tests/renderer/test_renderer.py | 3 -- tests/renderer/test_renderer_be_comparison.py | 2 ++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/renderer/constants.py b/tests/renderer/constants.py index 467d47163b..6c5295b14f 100644 --- a/tests/renderer/constants.py +++ b/tests/renderer/constants.py @@ -104,16 +104,33 @@ FORMAT_TO_FILE = { "MASA2": TESTV_DIR.joinpath("stv_IVASMASA_2dir2TC.pcm"), "META": TEST_VECTOR_DIR.joinpath("mixed_scene.txt"), "16ch_8+4+4": NCHAN_TO_FILE[16], - "4d0": NCHAN_TO_FILE[4], "4d4": NCHAN_TO_FILE[8], - "cicp1": NCHAN_TO_FILE[1], - "cicp20": NCHAN_TO_FILE[15], - "cicp2": NCHAN_TO_FILE[2], - "custom1": NCHAN_TO_FILE[11], - "itu_4+5+1": NCHAN_TO_FILE[11], "t_design_4": NCHAN_TO_FILE[12], } +FORMAT_TO_FILE_LTV = { + "MONO": TESTV_DIR.joinpath("test_mono.wav"), + "STEREO": TESTV_DIR.joinpath("test_stereo.wav"), + "5_1": TESTV_DIR.joinpath("test_MC51.wav"), + "7_1": TESTV_DIR.joinpath("test_MC71.wav"), + "5_1_2": TESTV_DIR.joinpath("test_MC51p2.wav"), + "5_1_4": TESTV_DIR.joinpath("test_MC51p4.wav"), + "7_1_4": TESTV_DIR.joinpath("test_MC71p4.wav"), + "FOA": TESTV_DIR.joinpath("test_FOA.wav"), + "HOA2": TESTV_DIR.joinpath("test_HOA2.wav"), + "HOA3": TESTV_DIR.joinpath("test_HOA3.wav"), + "ISM1": TESTV_DIR.joinpath("test_ISM_1obj.wav"), + "ISM2": TESTV_DIR.joinpath("test_ISM_2obj.wav"), + "ISM3": TESTV_DIR.joinpath("test_ISM_3obj.wav"), + "ISM4": TESTV_DIR.joinpath("test_ISM_4obj.wav"), + "MASA1": TESTV_DIR.joinpath("stv_IVASMASA_1dir1TC.pcm"), + "MASA2": TESTV_DIR.joinpath("stv_IVASMASA_2dir2TC.pcm"), + "META": TEST_VECTOR_DIR.joinpath("mixed_scene.txt"), + "16ch_8+4+4": TESTV_DIR.joinpath("test_HOA3.wav"), + "4d4": TESTV_DIR.joinpath("test_MC71.wav"), + "t_design_4": TESTV_DIR.joinpath("test_MC71p4.wav"), +} + FORMAT_TO_METADATA_FILES = { "ISM1": [str(TESTV_DIR.joinpath("stvISM1.csv"))], "ISM2": [ @@ -162,7 +179,6 @@ OUTPUT_FORMATS = [ CUSTOM_LS_TO_TEST = [ "t_design_4", "4d4", - "itu_4+5+1", "16ch_8+4+4", ] @@ -178,7 +194,8 @@ HR_TRAJECTORIES_TO_TEST = [ ] """ Per-testcase xfail SNR thresholds (dB) """ -pass_snr = { +pass_snr = dict() # not relevant for tests anymore, should be deprecated soon +_pass_snr = { #################################################################### # # External Renderer vs Standalone and pyaudio3dtools renderers tests diff --git a/tests/renderer/test_renderer.py b/tests/renderer/test_renderer.py index c43dd68d19..866d2eee2c 100644 --- a/tests/renderer/test_renderer.py +++ b/tests/renderer/test_renderer.py @@ -151,9 +151,6 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS[2:]) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) def test_masa(test_info, in_fmt, out_fmt): - # # TODO: implement MASA in Python, compare BE - # compare_renderer_vs_pyscripts( test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt] - # ) run_renderer(in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt]) diff --git a/tests/renderer/test_renderer_be_comparison.py b/tests/renderer/test_renderer_be_comparison.py index 5d89136a89..9f38d9491a 100644 --- a/tests/renderer/test_renderer_be_comparison.py +++ b/tests/renderer/test_renderer_be_comparison.py @@ -30,6 +30,8 @@ import pytest from .utils import * +# override to use long test vectors for this test +FORMAT_TO_FILE = FORMAT_TO_FILE_LTV """ Ambisonics """ -- GitLab From f586732af4b12cac0c0fdab188faf360f9ce24c9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 17 Jan 2023 18:06:12 +0100 Subject: [PATCH 10/11] actually enable long testvectors for MR BE comparison --- tests/renderer/constants.py | 4 +-- tests/renderer/test_renderer_be_comparison.py | 26 ++++++++++--------- tests/renderer/utils.py | 12 +++++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/renderer/constants.py b/tests/renderer/constants.py index 6c5295b14f..91ebd63346 100644 --- a/tests/renderer/constants.py +++ b/tests/renderer/constants.py @@ -79,7 +79,7 @@ NCHAN_TO_FILE = { 16: TEST_VECTOR_DIR.joinpath("spectral_test_16ch_48kHz.wav"), } -FORMAT_TO_FILE = { +FORMAT_TO_FILE_STV = { "MONO": NCHAN_TO_FILE[1], "STEREO": NCHAN_TO_FILE[2], "5_1": NCHAN_TO_FILE[6], @@ -194,7 +194,7 @@ HR_TRAJECTORIES_TO_TEST = [ ] """ Per-testcase xfail SNR thresholds (dB) """ -pass_snr = dict() # not relevant for tests anymore, should be deprecated soon +pass_snr = dict() # not relevant for tests anymore, should be deprecated soon _pass_snr = { #################################################################### # diff --git a/tests/renderer/test_renderer_be_comparison.py b/tests/renderer/test_renderer_be_comparison.py index 9f38d9491a..04310c176f 100644 --- a/tests/renderer/test_renderer_be_comparison.py +++ b/tests/renderer/test_renderer_be_comparison.py @@ -30,8 +30,6 @@ import pytest from .utils import * -# override to use long test vectors for this test -FORMAT_TO_FILE = FORMAT_TO_FILE_LTV """ Ambisonics """ @@ -39,13 +37,13 @@ FORMAT_TO_FILE = FORMAT_TO_FILE_LTV @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics(test_info, in_fmt, out_fmt): - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt): - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @@ -57,6 +55,7 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + use_ltv=True, ) @@ -66,7 +65,7 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) def test_multichannel(test_info, in_fmt, out_fmt): - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @@ -75,7 +74,7 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @@ -90,6 +89,7 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + use_ltv=True, ) @@ -113,7 +113,7 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt): in_meta_files = None compare_renderer_vs_mergetarget( - test_info, in_fmt, out_fmt, in_meta_files=in_meta_files + test_info, in_fmt, out_fmt, in_meta_files=in_meta_files, use_ltv=True ) @@ -132,6 +132,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=in_meta_files, + use_ltv=True, ) @@ -145,7 +146,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input(test_info, in_layout, out_fmt): compare_renderer_vs_mergetarget( - test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt + test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, use_ltv=True ) @@ -153,7 +154,7 @@ def test_custom_ls_input(test_info, in_layout, out_fmt): @pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS) def test_custom_ls_output(test_info, in_fmt, out_fmt): compare_renderer_vs_mergetarget( - test_info, in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt") + test_info, in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), use_ltv=True ) @@ -164,6 +165,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt): test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"), CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), + use_ltv=True, ) @@ -171,9 +173,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt): @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input_binaural(test_info, in_layout, out_fmt): compare_renderer_vs_mergetarget( - test_info, - CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), - out_fmt, + test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, use_ltv=True ) @@ -186,6 +186,7 @@ def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, tr CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + use_ltv=True, ) @@ -200,4 +201,5 @@ def test_metadata(test_info, in_fmt, out_fmt): "META", out_fmt, metadata_input=TEST_VECTOR_DIR.joinpath(f"{in_fmt}.txt"), + use_ltv=True, ) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index b4ab4401f4..84fe58bef0 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -108,6 +108,7 @@ def run_renderer( trj_file: Optional[str] = None, output_path_base: str = OUTPUT_PATH_CUT, binary_suffix: str = "", + use_ltv: Optional[bool] = False, ) -> Tuple[np.ndarray, int]: """CuT creation with standalone renderer""" if trj_file is not None: @@ -120,6 +121,11 @@ def run_renderer( else: out_name = out_fmt + if use_ltv: + FORMAT_TO_FILE = FORMAT_TO_FILE_LTV + else: + FORMAT_TO_FILE = FORMAT_TO_FILE_STV + if metadata_input is not None: in_file = metadata_input in_name = metadata_input.stem @@ -157,6 +163,7 @@ def run_pyscripts( metadata_input: Optional[str] = None, in_meta_files: Optional[list] = None, trj_file: Optional[str] = None, + use_ltv: Optional[bool] = False, ) -> Tuple[np.ndarray, int]: """Reference creation with pyaudio3dtools""" if trj_file is not None: @@ -169,6 +176,11 @@ def run_pyscripts( else: out_name = out_fmt + if use_ltv: + FORMAT_TO_FILE = FORMAT_TO_FILE_LTV + else: + FORMAT_TO_FILE = FORMAT_TO_FILE_STV + if metadata_input is not None: in_file = metadata_input in_name = metadata_input.stem -- GitLab From d906eb1a564defa39f68b887ff637bc6f188c27e Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 18 Jan 2023 11:00:33 +0100 Subject: [PATCH 11/11] rename file constants to be clearer about where they are used --- tests/renderer/constants.py | 4 +-- tests/renderer/test_renderer_be_comparison.py | 28 +++++++++---------- tests/renderer/utils.py | 16 +++++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/renderer/constants.py b/tests/renderer/constants.py index 91ebd63346..d71f73e5b7 100644 --- a/tests/renderer/constants.py +++ b/tests/renderer/constants.py @@ -79,7 +79,7 @@ NCHAN_TO_FILE = { 16: TEST_VECTOR_DIR.joinpath("spectral_test_16ch_48kHz.wav"), } -FORMAT_TO_FILE_STV = { +FORMAT_TO_FILE_SMOKETEST = { "MONO": NCHAN_TO_FILE[1], "STEREO": NCHAN_TO_FILE[2], "5_1": NCHAN_TO_FILE[6], @@ -108,7 +108,7 @@ FORMAT_TO_FILE_STV = { "t_design_4": NCHAN_TO_FILE[12], } -FORMAT_TO_FILE_LTV = { +FORMAT_TO_FILE_COMPARETEST = { "MONO": TESTV_DIR.joinpath("test_mono.wav"), "STEREO": TESTV_DIR.joinpath("test_stereo.wav"), "5_1": TESTV_DIR.joinpath("test_MC51.wav"), diff --git a/tests/renderer/test_renderer_be_comparison.py b/tests/renderer/test_renderer_be_comparison.py index 04310c176f..815d7fd640 100644 --- a/tests/renderer/test_renderer_be_comparison.py +++ b/tests/renderer/test_renderer_be_comparison.py @@ -37,13 +37,13 @@ from .utils import * @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics(test_info, in_fmt, out_fmt): - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, is_comparetest=True) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt): - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, is_comparetest=True) @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @@ -55,7 +55,7 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), - use_ltv=True, + is_comparetest=True, ) @@ -65,7 +65,7 @@ def test_ambisonics_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) def test_multichannel(test_info, in_fmt, out_fmt): - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, is_comparetest=True) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @@ -74,7 +74,7 @@ def test_multichannel_binaural_static(test_info, in_fmt, out_fmt): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") - compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, use_ltv=True) + compare_renderer_vs_mergetarget(test_info, in_fmt, out_fmt, is_comparetest=True) @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @@ -89,7 +89,7 @@ def test_multichannel_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), - use_ltv=True, + is_comparetest=True, ) @@ -113,7 +113,7 @@ def test_ism_binaural_static(test_info, in_fmt, out_fmt): in_meta_files = None compare_renderer_vs_mergetarget( - test_info, in_fmt, out_fmt, in_meta_files=in_meta_files, use_ltv=True + test_info, in_fmt, out_fmt, in_meta_files=in_meta_files, is_comparetest=True ) @@ -132,7 +132,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=in_meta_files, - use_ltv=True, + is_comparetest=True, ) @@ -146,7 +146,7 @@ def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file): @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input(test_info, in_layout, out_fmt): compare_renderer_vs_mergetarget( - test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, use_ltv=True + test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, is_comparetest=True ) @@ -154,7 +154,7 @@ def test_custom_ls_input(test_info, in_layout, out_fmt): @pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS) def test_custom_ls_output(test_info, in_fmt, out_fmt): compare_renderer_vs_mergetarget( - test_info, in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), use_ltv=True + test_info, in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), is_comparetest=True ) @@ -165,7 +165,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt): test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"), CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), - use_ltv=True, + is_comparetest=True, ) @@ -173,7 +173,7 @@ def test_custom_ls_input_output(test_info, in_fmt, out_fmt): @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) def test_custom_ls_input_binaural(test_info, in_layout, out_fmt): compare_renderer_vs_mergetarget( - test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, use_ltv=True + test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, is_comparetest=True ) @@ -186,7 +186,7 @@ def test_custom_ls_input_binaural_headrotation(test_info, in_layout, out_fmt, tr CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), - use_ltv=True, + is_comparetest=True, ) @@ -201,5 +201,5 @@ def test_metadata(test_info, in_fmt, out_fmt): "META", out_fmt, metadata_input=TEST_VECTOR_DIR.joinpath(f"{in_fmt}.txt"), - use_ltv=True, + is_comparetest=True, ) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 84fe58bef0..143c33b066 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -108,7 +108,7 @@ def run_renderer( trj_file: Optional[str] = None, output_path_base: str = OUTPUT_PATH_CUT, binary_suffix: str = "", - use_ltv: Optional[bool] = False, + is_comparetest: Optional[bool] = False, ) -> Tuple[np.ndarray, int]: """CuT creation with standalone renderer""" if trj_file is not None: @@ -121,10 +121,10 @@ def run_renderer( else: out_name = out_fmt - if use_ltv: - FORMAT_TO_FILE = FORMAT_TO_FILE_LTV + if is_comparetest: + FORMAT_TO_FILE = FORMAT_TO_FILE_COMPARETEST else: - FORMAT_TO_FILE = FORMAT_TO_FILE_STV + FORMAT_TO_FILE = FORMAT_TO_FILE_SMOKETEST if metadata_input is not None: in_file = metadata_input @@ -163,7 +163,7 @@ def run_pyscripts( metadata_input: Optional[str] = None, in_meta_files: Optional[list] = None, trj_file: Optional[str] = None, - use_ltv: Optional[bool] = False, + is_comparetest: Optional[bool] = False, ) -> Tuple[np.ndarray, int]: """Reference creation with pyaudio3dtools""" if trj_file is not None: @@ -176,10 +176,10 @@ def run_pyscripts( else: out_name = out_fmt - if use_ltv: - FORMAT_TO_FILE = FORMAT_TO_FILE_LTV + if is_comparetest: + FORMAT_TO_FILE = FORMAT_TO_FILE_COMPARETEST else: - FORMAT_TO_FILE = FORMAT_TO_FILE_STV + FORMAT_TO_FILE = FORMAT_TO_FILE_SMOKETEST if metadata_input is not None: in_file = metadata_input -- GitLab