From 23b9f7c5b09945a6a2f22f5cc5bcd3d576a63ed1 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 11 Nov 2022 16:15:46 +0100 Subject: [PATCH 01/12] add new IVAS SID bitrate in cut_bs.py --- scripts/cut_bs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cut_bs.py b/scripts/cut_bs.py index 261a66bc9f..6dab2e3238 100755 --- a/scripts/cut_bs.py +++ b/scripts/cut_bs.py @@ -35,7 +35,7 @@ import argparse import os.path import sys -SID_BITS = {35, 48, 88, 100} +SID_BITS = {35, 48, 104} SYNC_WORDS = {b"!k", b" k"} -- GitLab From 5c09b7625f6fc2f06194372c5d91a06d7d4fa2aa Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 14 Nov 2022 11:17:40 +0100 Subject: [PATCH 02/12] add --length option to cut_bs.py --- scripts/cut_bs.py | 48 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/scripts/cut_bs.py b/scripts/cut_bs.py index 6dab2e3238..bd1978ebe5 100755 --- a/scripts/cut_bs.py +++ b/scripts/cut_bs.py @@ -39,7 +39,28 @@ SID_BITS = {35, 48, 104} SYNC_WORDS = {b"!k", b" k"} -def cut_bs(fp, fp_out, start_frame=0, start_with_sid=False): +def cut_to_length(fp, fp_out, length): + assert length > 0 + + fr_cnt = 0 + + for f in range(length): + sync_word = fp.read(2) + if sync_word == b"": + return (fr_cnt, cut_cnt) + if sync_word not in SYNC_WORDS: + raise ValueError("Bad Sync word!") + n_bits_bs = fp.read(2) + n_bits = struct.unpack("h", n_bits_bs)[0] + fp_out.write(sync_word) + fp_out.write(n_bits_bs) + fp_out.write(fp.read(n_bits * 2)) + fr_cnt += 1 + + return fr_cnt + + +def cut_from_start(fp, fp_out, start_frame=0, start_with_sid=False): # cut until start frame fr_cnt = 0 cut_cnt = 0 @@ -92,14 +113,15 @@ def cut_bs(fp, fp_out, start_frame=0, start_with_sid=False): if __name__ == "__main__": my_parser = argparse.ArgumentParser( - description="Cut frames from the beginning of a G.192 bit stream file" + description="Cut a G.192 bit stream file" ) my_parser.add_argument( - "--sid", "-s", help="Cut until the first SID frame", action="store_true" + "--sid", "-s", help="Cut away all frames before the first SID frame", action="store_true" ) my_parser.add_argument( - "--frame", "-f", type=int, help="Number of frames to cut.", default=0 + "--frame", "-f", type=int, help="Number of frames to cut from the start of the file.", default=0 ) + my_parser.add_argument("--length", "-l", type=int, help="Cut bitstream to this length (in frames)", default=-1) my_parser.add_argument("bs_in", type=str, help="G.192 bit stream file name to cut") my_parser.add_argument("bs_out", type=str, help="Cut G.192 bit stream file name") my_args = my_parser.parse_args() @@ -113,10 +135,16 @@ if __name__ == "__main__": with open(my_args.bs_in, "rb") as fp_in: with open(my_args.bs_out, "wb") as fp_out: - fr_cnt, cut_cnt = cut_bs( - fp_in, fp_out, start_frame=my_args.frame, start_with_sid=my_args.sid - ) + if my_args.sid or my_args.frame: + fr_cnt, cut_cnt = cut_from_start( + fp_in, fp_out, start_frame=my_args.frame, start_with_sid=my_args.sid + ) + if my_args.sid and (fr_cnt == cut_cnt): + print("Warning! No SID frame found in bitstream!") + print(f"Cut {cut_cnt} of {fr_cnt} frames from {my_args.bs_in}") + elif my_args.length: + fr_cnt = cut_to_length(fp_in, fp_out, my_args.length) + if fr_cnt != my_args.length: + print(f"Warning! Could not cut to length {my_args.length} as bitstream only contained {fr_cnt} frames!") + print(f"Cut {my_args.bs_in} to {fr_cnt} frames") - if my_args.sid and (fr_cnt == cut_cnt): - print("Warning! No SID frame found in bitstream!") - print(f"Cut {cut_cnt} of {fr_cnt} frames from {my_args.bs_in}") -- GitLab From 2ef9e79d7cfcb0f4fa780f9dc2721b7e4f611d36 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 14 Nov 2022 12:04:22 +0100 Subject: [PATCH 03/12] add --bs_length option to pyivastest scripts --- scripts/pyivastest/IvasScriptsCommon.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/pyivastest/IvasScriptsCommon.py b/scripts/pyivastest/IvasScriptsCommon.py index 45631566e9..101579da9b 100644 --- a/scripts/pyivastest/IvasScriptsCommon.py +++ b/scripts/pyivastest/IvasScriptsCommon.py @@ -276,6 +276,12 @@ class IvasScriptArgParser(argparse.ArgumentParser): help="Cut frames from the beginning of the encoded bit stream until the first SID frame", action="store_true", ) + self.add_argument( + "--bs_length", + help="Cut bitstream to this (maximum) length. Is applied AFTER --sidstart processing, if this is given", + type=int, + default=-1, + ) self.add_argument( "--info", help="Ouput debug info in subfolders of /res (use with caution, this can generate a huge amount of data)", @@ -604,6 +610,18 @@ def runner_setup(runner, args): ] add_to_proc_chain(bs_proc_chain, sidstart_cmd) + if args["bs_length"] > 0: + bs_len = args["bs_length"] + bs_cut_cmd = [ + os.path.join(constants.SCRIPTS_BASE_DIR, "cut_bs.py"), + "--length", + f"{bs_len}", + "{in_file}", + "{out_file}", + f"{bs_len}frames", + ] + add_to_proc_chain(bs_proc_chain, bs_cut_cmd) + if bs_proc_chain != {}: runner.global_bitstream_processing = bs_proc_chain -- GitLab From 7ec741b77b5601e6e9076be865722bdc648127ee Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 14 Nov 2022 12:19:17 +0100 Subject: [PATCH 04/12] add job and return value for runIvasCodec.py --- .gitlab-ci.yml | 18 ++++++++++++++++++ scripts/runIvasCodec.py | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4a429c75d..82f79f6026 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -597,6 +597,24 @@ clang-format-check: name: "$ARTIFACT_BASE_NAME" expose_as: 'formatting patch' +# check for crashes if first received frame on decoder side is an SID +check-first-frame-is-sid: + extends: + - .test-job-linux + tags: + - ivas-linux + stage: test + needs: ["build-codec-linux-cmake"] + script: + - *print-common-info + - mkdir + - cmake . + - make -j + + # TODO: add SBA 24.4 kbps back once #185 is fixed + - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v "SBA_b24_4") + - scripts/runIvasCodec.py -p scripts/config/ci_linux_ltv.json -m $modes -s -bs_length 50 + # --------------------------------------------------------------- # Test jobs for main branch # --------------------------------------------------------------- diff --git a/scripts/runIvasCodec.py b/scripts/runIvasCodec.py index 4ec1da90b9..288095bb2a 100755 --- a/scripts/runIvasCodec.py +++ b/scripts/runIvasCodec.py @@ -143,6 +143,10 @@ class RunIvasCodec(IvasScriptsCommon.IvasScript): self.logger.console(r[0]) self.logger.console(" ") + encs_failed = len(runner.failed_modes["enc"]) > 0 + decs_failed = len(runner.failed_modes["dec"]) > 0 + return encs_failed or decs_failed + if __name__ == "__main__": script = RunIvasCodec() -- GitLab From 3c39d16ad00cf4c7413c802fa609749ac94eef74 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 14 Nov 2022 12:25:08 +0100 Subject: [PATCH 05/12] fix job --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 82f79f6026..0e565822be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -607,7 +607,6 @@ check-first-frame-is-sid: needs: ["build-codec-linux-cmake"] script: - *print-common-info - - mkdir - cmake . - make -j -- GitLab From 0015d8bee28b43a8a1bc7d4fad393f01aca9a081 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 14 Nov 2022 16:00:57 +0100 Subject: [PATCH 06/12] fix flag typo and increase length --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e565822be..310ba289fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -612,7 +612,7 @@ check-first-frame-is-sid: # TODO: add SBA 24.4 kbps back once #185 is fixed - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v "SBA_b24_4") - - scripts/runIvasCodec.py -p scripts/config/ci_linux_ltv.json -m $modes -s -bs_length 50 + - scripts/runIvasCodec.py -p scripts/config/ci_linux_ltv.json -m $modes -s --bs_length 100 # --------------------------------------------------------------- # Test jobs for main branch -- GitLab From 24cfe6566acd2e4b01857ecf441bd7dbe53e89c9 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 15 Nov 2022 10:53:02 +0100 Subject: [PATCH 07/12] actually return exit code from runIvasCodec.py --- scripts/runIvasCodec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/runIvasCodec.py b/scripts/runIvasCodec.py index 288095bb2a..ff4637039d 100755 --- a/scripts/runIvasCodec.py +++ b/scripts/runIvasCodec.py @@ -150,4 +150,4 @@ class RunIvasCodec(IvasScriptsCommon.IvasScript): if __name__ == "__main__": script = RunIvasCodec() - script.run() + sys.exit(script.run()) -- GitLab From 0b8e9f066df11783a7432d8eafe7e624e3b22408 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 15 Nov 2022 11:09:40 +0100 Subject: [PATCH 08/12] fix error for end-of-bitstream case --- scripts/cut_bs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cut_bs.py b/scripts/cut_bs.py index bd1978ebe5..cff74952a9 100755 --- a/scripts/cut_bs.py +++ b/scripts/cut_bs.py @@ -47,7 +47,7 @@ def cut_to_length(fp, fp_out, length): for f in range(length): sync_word = fp.read(2) if sync_word == b"": - return (fr_cnt, cut_cnt) + return fr_cnt if sync_word not in SYNC_WORDS: raise ValueError("Bad Sync word!") n_bits_bs = fp.read(2) -- GitLab From 864bdde5a3852d60427524611c8a8e34b680d92b Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 15 Nov 2022 13:56:21 +0100 Subject: [PATCH 09/12] add json file for sidstart test --- scripts/config/ci_linux_sidstart_test.json | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/config/ci_linux_sidstart_test.json diff --git a/scripts/config/ci_linux_sidstart_test.json b/scripts/config/ci_linux_sidstart_test.json new file mode 100644 index 0000000000..4fe5ae589e --- /dev/null +++ b/scripts/config/ci_linux_sidstart_test.json @@ -0,0 +1,25 @@ +{ + "afspPath": "not_needed", + "utilPath": "/tools", + "inpaths": { + "MONO": "/usr/local/testv/test_mono.wav", + "STEREO": "/usr/local/testv/test_stereo.wav", + "FOA": "/usr/local/testv/test_FOA.wav", + "HOA2": "/usr/local/testv/test_HOA2.wav", + "HOA3": "/usr/local/testv/test_HOA3.wav", + "SBA": "/usr/local/testv/test_HOA3.wav", + "MASA1TC1DIR": "/usr/local/testv/test_MASA_1dir1TC.wav", + "MASA1TC2DIR": "/usr/local/testv/test_MASA_2dir1TC.wav", + "MASA2TC1DIR": "/usr/local/testv/test_MASA_1dir2TC.wav", + "MASA2TC2DIR": "/usr/local/testv/test_MASA_2dir2TC.wav", + "5_1": "/usr/local/testv/test_MC51.wav", + "5_1_2": "/usr/local/testv/test_MC51p2.wav", + "5_1_4": "/usr/local/testv/test_MC51p4.wav", + "7_1": "/usr/local/testv/test_MC71.wav", + "7_1_4": "/usr/local/testv/test_MC71p4.wav", + "ISM1": "/usr/local/testv/test_mono.wav", + "ISM2": "/usr/local/testv/test_ISM_2obj.wav", + "ISM3": "/usr/local/testv/test_ISM_3obj.wav", + "ISM4": "/usr/local/testv/test_ISM_4obj.wav" + } +} -- GitLab From 9a9dca59619985cd99f45a50e16084bf53bb44bd Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 15 Nov 2022 14:15:46 +0100 Subject: [PATCH 10/12] add job for test, modified testvectors and config --- .gitlab-ci.yml | 12 ++++++++++-- scripts/config/ci_linux_sidstart_test.json | 8 ++++---- scripts/testv/test_MASA_1dir1TC.met | 4 ++-- scripts/testv/test_MASA_1dir1TC.wav | 4 ++-- scripts/testv/test_MASA_1dir2TC.met | 4 ++-- scripts/testv/test_MASA_1dir2TC.wav | 4 ++-- scripts/testv/test_mono.wav | 4 ++-- scripts/testv/test_stereo.wav | 4 ++-- 8 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 310ba289fc..4c67efc5fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -601,6 +601,7 @@ clang-format-check: check-first-frame-is-sid: extends: - .test-job-linux + - .rules-merge-request tags: - ivas-linux stage: test @@ -610,9 +611,16 @@ check-first-frame-is-sid: - cmake . - make -j + # TODO: for some MASA modes, we currently do not have testvectors that actually trigger DTX # TODO: add SBA 24.4 kbps back once #185 is fixed - - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v "SBA_b24_4") - - scripts/runIvasCodec.py -p scripts/config/ci_linux_ltv.json -m $modes -s --bs_length 100 + - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v "SBA_b24_4" | grep -v MASA) + - scripts/runIvasCodec.py -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 500 + artifacts: + paths: + - out/logs + when: on_failure + name: "$CI_JOB_NAME--$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--sidstart" + expose_as: "logs-sidstart" # --------------------------------------------------------------- # Test jobs for main branch diff --git a/scripts/config/ci_linux_sidstart_test.json b/scripts/config/ci_linux_sidstart_test.json index 4fe5ae589e..3436d9eaea 100644 --- a/scripts/config/ci_linux_sidstart_test.json +++ b/scripts/config/ci_linux_sidstart_test.json @@ -4,10 +4,10 @@ "inpaths": { "MONO": "/usr/local/testv/test_mono.wav", "STEREO": "/usr/local/testv/test_stereo.wav", - "FOA": "/usr/local/testv/test_FOA.wav", - "HOA2": "/usr/local/testv/test_HOA2.wav", - "HOA3": "/usr/local/testv/test_HOA3.wav", - "SBA": "/usr/local/testv/test_HOA3.wav", + "FOA": "/usr/local/ltv/ltv48_FOA.wav", + "HOA2": "/usr/local/ltv/ltv48_HOA2.wav", + "HOA3": "/usr/local/ltv/ltv48_HOA3.wav", + "SBA": "/usr/local/ltv/ltv48_HOA3.wav", "MASA1TC1DIR": "/usr/local/testv/test_MASA_1dir1TC.wav", "MASA1TC2DIR": "/usr/local/testv/test_MASA_2dir1TC.wav", "MASA2TC1DIR": "/usr/local/testv/test_MASA_1dir2TC.wav", diff --git a/scripts/testv/test_MASA_1dir1TC.met b/scripts/testv/test_MASA_1dir1TC.met index f2ce23bd20..945a81f0b4 100644 --- a/scripts/testv/test_MASA_1dir1TC.met +++ b/scripts/testv/test_MASA_1dir1TC.met @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6349efe3448d28979b80744bcdc29d57f1c025704939b42d7b913d7fc3f23ccc -size 102300 +oid sha256:64b974b376ef0ca29da837d33173c621499d753800ebf5e5587019ee5db481bd +size 684728 diff --git a/scripts/testv/test_MASA_1dir1TC.wav b/scripts/testv/test_MASA_1dir1TC.wav index 9291feeee3..880098c1b4 100644 --- a/scripts/testv/test_MASA_1dir1TC.wav +++ b/scripts/testv/test_MASA_1dir1TC.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54ea4543e4d6d43c312f1e461a75a3d8ce18e34bfb5777f15f2e494dd277d2e5 -size 288106 +oid sha256:d3e49f9bca73feee2717df5f4df1eaf7d3d564eb4ed31e6b5fd4dea0e86950dc +size 1933224 diff --git a/scripts/testv/test_MASA_1dir2TC.met b/scripts/testv/test_MASA_1dir2TC.met index 00acdae539..f6e0e439a0 100644 --- a/scripts/testv/test_MASA_1dir2TC.met +++ b/scripts/testv/test_MASA_1dir2TC.met @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a1f87bfe360dbd221a94583aa68a58ef050e968a63351730d643f2dc2cac4e1 -size 204600 +oid sha256:2ec41c82c305f075c67b51e1f0a6e97dfc272bafcfca64e38c902c9f0d2c4500 +size 684728 diff --git a/scripts/testv/test_MASA_1dir2TC.wav b/scripts/testv/test_MASA_1dir2TC.wav index aefec77efe..f25eb24353 100644 --- a/scripts/testv/test_MASA_1dir2TC.wav +++ b/scripts/testv/test_MASA_1dir2TC.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ab7437cdf41e56338c93f5e593118a112a48bae5138be2cdd301eff5da59bb06 -size 1152106 +oid sha256:97f1a7a43012ce166b929df59bd756f5d96433ea00ce0a1005380368c01619a0 +size 3855404 diff --git a/scripts/testv/test_mono.wav b/scripts/testv/test_mono.wav index b841d174c3..a29e0da33b 100644 --- a/scripts/testv/test_mono.wav +++ b/scripts/testv/test_mono.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5daeac3fb92d487fc7ded7d1a4a9e6295d2f2f27f59f19dcdaeebaae01908a86 -size 1920106 +oid sha256:712477a74d65fce8797a03d39bde669f8c285247589c1137a96c871d82fc747b +size 3782444 diff --git a/scripts/testv/test_stereo.wav b/scripts/testv/test_stereo.wav index 70dc46062e..ebea24307b 100644 --- a/scripts/testv/test_stereo.wav +++ b/scripts/testv/test_stereo.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0de400200071a7b26de03eaef88b49efce7a5df813b971336ed17b90ba02aa2 -size 3840106 +oid sha256:5038043354f9c27899d92f81b3c00702db5e341f912ed01d310c2015272e79aa +size 7564844 -- GitLab From a9394ece9b5ee870de60692f80640a53ff14560a Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 15 Nov 2022 14:34:28 +0100 Subject: [PATCH 11/12] add necessary setup to job --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c67efc5fc..1572d4b211 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -600,7 +600,7 @@ clang-format-check: # check for crashes if first received frame on decoder side is an SID check-first-frame-is-sid: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request tags: - ivas-linux @@ -608,12 +608,14 @@ check-first-frame-is-sid: needs: ["build-codec-linux-cmake"] script: - *print-common-info + - *update-ltv-repo - cmake . - make -j # TODO: for some MASA modes, we currently do not have testvectors that actually trigger DTX # TODO: add SBA 24.4 kbps back once #185 is fixed - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v "SBA_b24_4" | grep -v MASA) + - echo $modes - scripts/runIvasCodec.py -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 500 artifacts: paths: -- GitLab From 8804a81d158b45b967f225d4b3477515ab4e1363 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 1 Jun 2023 10:20:38 +0200 Subject: [PATCH 12/12] add excluded SBA mode back --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e462809b3e..c92459d239 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -674,8 +674,7 @@ check-first-frame-is-sid: - make -j # TODO: for some MASA modes, we currently do not have testvectors that actually trigger DTX - # TODO: add SBA 24.4 kbps back once #185 is fixed - - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v "SBA_b24_4" | grep -v MASA) + - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -v MASA) - echo $modes - scripts/runIvasCodec.py -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 500 artifacts: -- GitLab