Loading tests/format_switching/compare/cut/.gitkeep 0 → 100644 +0 −0 Empty file added. tests/format_switching/compare/ref/.gitkeep 0 → 100644 +0 −0 Empty file added. tests/format_switching/constants.py +26 −0 Original line number Diff line number Diff line Loading @@ -3,8 +3,23 @@ import pathlib HERE = pathlib.Path(__file__).parent SMOKE_TEST_DIR = HERE.joinpath("smoke-test-output") COMPARE_TEST_DIR_REF = HERE.joinpath("compare/ref") COMPARE_TEST_DIR_CUT = HERE.joinpath("compare/cut") BS_DIR = HERE.parent.parent.joinpath("scripts/testv/fmt_sw_bitstreams") class TestMode(str, Enum): SMOKE_TEST = "smoke-test" COMPARE_CREATE_REF = "create-ref" COMPARE_CREATE_CUT = "create-cut" OUTPUT_DIR = { TestMode.SMOKE_TEST: SMOKE_TEST_DIR, TestMode.COMPARE_CREATE_REF: COMPARE_TEST_DIR_REF, TestMode.COMPARE_CREATE_CUT: COMPARE_TEST_DIR_CUT, } BITSTREAM_FILES = { "MONO": BS_DIR / "MONO_48000.192", "STEREO": BS_DIR / "STEREO_48000.192", Loading Loading @@ -44,6 +59,17 @@ BITSTREAM_FILES = { "MASA2TC_ISM4": BS_DIR / "MASA2TC_ISM4_48000.192", } COMPARE_TEST_MODES_TO_KEEP = [ "MONO", "STEREO", "ISM4", "HOA3", "MASA2TC", "7_1_4", "HOA2_ISM3", "MASA1TC_ISM2", ] IVAS_IN_FORMATS = list(BITSTREAM_FILES.keys()) IVAS_OUT_FORMATS = [ "MONO", Loading tests/format_switching/smoke-test-output/.gitkeep 0 → 100644 +0 −0 Empty file added. tests/format_switching/test_format_switching.py +41 −4 Original line number Diff line number Diff line Loading @@ -3,12 +3,15 @@ import pathlib from tests.conftest import DecoderFrontend from .constants import ( BITSTREAM_FILES, SMOKE_TEST_DIR, COMPARE_TEST_MODES_TO_KEEP, BitstreamFormat, IVAS_OUT_FORMATS, IVAS_IN_FORMATS, TestMode, OUTPUT_DIR, ) from .utils import concat_files from ..cmp_pcm import cmp_pcm @pytest.mark.parametrize("output_fmt", IVAS_OUT_FORMATS) Loading @@ -17,12 +20,14 @@ from .utils import concat_files @pytest.mark.parametrize("ivas_fmt_a", IVAS_IN_FORMATS) def test_format_switching( test_info, ref_decoder_frontend: DecoderFrontend, dut_decoder_frontend: DecoderFrontend, ivas_fmt_a, ivas_fmt_b, bs_fmt, output_fmt, ): # --------- skipping logic -------------- if bs_fmt == BitstreamFormat.G192 and ( ivas_fmt_a == "MONO" or ivas_fmt_b == "MONO" ): Loading @@ -31,12 +36,44 @@ def test_format_switching( if ivas_fmt_a == ivas_fmt_b: pytest.skip("Skipping same format case") test_mode = TestMode.SMOKE_TEST if test_info.config.option.create_ref: test_mode = TestMode.COMPARE_CREATE_REF if test_info.config.option.create_cut: test_mode = TestMode.COMPARE_CREATE_CUT if ( test_mode == TestMode.COMPARE_CREATE_REF or test_mode == TestMode.COMPARE_CREATE_CUT ): if ( ivas_fmt_a not in COMPARE_TEST_MODES_TO_KEEP or ivas_fmt_b not in COMPARE_TEST_MODES_TO_KEEP ): pytest.skip("Skip this mode for COMPARE test") # --------- actual test -------------- bs_a = pathlib.Path(BITSTREAM_FILES[ivas_fmt_a]) bs_b = pathlib.Path(BITSTREAM_FILES[ivas_fmt_b]) bs_concat = SMOKE_TEST_DIR / f"{ivas_fmt_a}->{ivas_fmt_b}.192" outname_head = f"from-{ivas_fmt_a}-to-{ivas_fmt_b}" output_dir = OUTPUT_DIR[test_mode] bs_concat = output_dir / f"{outname_head}.192" if bs_fmt == BitstreamFormat.G192: concat_files([bs_a, bs_b], bs_concat) output_file = SMOKE_TEST_DIR / f"{ivas_fmt_a}->{ivas_fmt_b}.wav" dut_decoder_frontend.run(output_fmt, 48, bs_concat, output_file) output_file_name = f"{outname_head}-dec_to-{output_fmt}.wav" output_file_path = output_dir / output_file_name if test_mode == TestMode.COMPARE_CREATE_REF: ref_decoder_frontend.run(output_fmt, 48, bs_concat, output_file_path) else: dut_decoder_frontend.run(output_fmt, 48, bs_concat, output_file_path) if test_mode == TestMode.COMPARE_CREATE_CUT: ref_file = OUTPUT_DIR[TestMode.COMPARE_CREATE_REF] / output_file_name output_differs, reason = cmp_pcm(ref_file, output_file_path, output_fmt, 48) if output_differs[0]: pytest.fail(f"Output differs: ({reason[0]})") Loading
tests/format_switching/constants.py +26 −0 Original line number Diff line number Diff line Loading @@ -3,8 +3,23 @@ import pathlib HERE = pathlib.Path(__file__).parent SMOKE_TEST_DIR = HERE.joinpath("smoke-test-output") COMPARE_TEST_DIR_REF = HERE.joinpath("compare/ref") COMPARE_TEST_DIR_CUT = HERE.joinpath("compare/cut") BS_DIR = HERE.parent.parent.joinpath("scripts/testv/fmt_sw_bitstreams") class TestMode(str, Enum): SMOKE_TEST = "smoke-test" COMPARE_CREATE_REF = "create-ref" COMPARE_CREATE_CUT = "create-cut" OUTPUT_DIR = { TestMode.SMOKE_TEST: SMOKE_TEST_DIR, TestMode.COMPARE_CREATE_REF: COMPARE_TEST_DIR_REF, TestMode.COMPARE_CREATE_CUT: COMPARE_TEST_DIR_CUT, } BITSTREAM_FILES = { "MONO": BS_DIR / "MONO_48000.192", "STEREO": BS_DIR / "STEREO_48000.192", Loading Loading @@ -44,6 +59,17 @@ BITSTREAM_FILES = { "MASA2TC_ISM4": BS_DIR / "MASA2TC_ISM4_48000.192", } COMPARE_TEST_MODES_TO_KEEP = [ "MONO", "STEREO", "ISM4", "HOA3", "MASA2TC", "7_1_4", "HOA2_ISM3", "MASA1TC_ISM2", ] IVAS_IN_FORMATS = list(BITSTREAM_FILES.keys()) IVAS_OUT_FORMATS = [ "MONO", Loading
tests/format_switching/test_format_switching.py +41 −4 Original line number Diff line number Diff line Loading @@ -3,12 +3,15 @@ import pathlib from tests.conftest import DecoderFrontend from .constants import ( BITSTREAM_FILES, SMOKE_TEST_DIR, COMPARE_TEST_MODES_TO_KEEP, BitstreamFormat, IVAS_OUT_FORMATS, IVAS_IN_FORMATS, TestMode, OUTPUT_DIR, ) from .utils import concat_files from ..cmp_pcm import cmp_pcm @pytest.mark.parametrize("output_fmt", IVAS_OUT_FORMATS) Loading @@ -17,12 +20,14 @@ from .utils import concat_files @pytest.mark.parametrize("ivas_fmt_a", IVAS_IN_FORMATS) def test_format_switching( test_info, ref_decoder_frontend: DecoderFrontend, dut_decoder_frontend: DecoderFrontend, ivas_fmt_a, ivas_fmt_b, bs_fmt, output_fmt, ): # --------- skipping logic -------------- if bs_fmt == BitstreamFormat.G192 and ( ivas_fmt_a == "MONO" or ivas_fmt_b == "MONO" ): Loading @@ -31,12 +36,44 @@ def test_format_switching( if ivas_fmt_a == ivas_fmt_b: pytest.skip("Skipping same format case") test_mode = TestMode.SMOKE_TEST if test_info.config.option.create_ref: test_mode = TestMode.COMPARE_CREATE_REF if test_info.config.option.create_cut: test_mode = TestMode.COMPARE_CREATE_CUT if ( test_mode == TestMode.COMPARE_CREATE_REF or test_mode == TestMode.COMPARE_CREATE_CUT ): if ( ivas_fmt_a not in COMPARE_TEST_MODES_TO_KEEP or ivas_fmt_b not in COMPARE_TEST_MODES_TO_KEEP ): pytest.skip("Skip this mode for COMPARE test") # --------- actual test -------------- bs_a = pathlib.Path(BITSTREAM_FILES[ivas_fmt_a]) bs_b = pathlib.Path(BITSTREAM_FILES[ivas_fmt_b]) bs_concat = SMOKE_TEST_DIR / f"{ivas_fmt_a}->{ivas_fmt_b}.192" outname_head = f"from-{ivas_fmt_a}-to-{ivas_fmt_b}" output_dir = OUTPUT_DIR[test_mode] bs_concat = output_dir / f"{outname_head}.192" if bs_fmt == BitstreamFormat.G192: concat_files([bs_a, bs_b], bs_concat) output_file = SMOKE_TEST_DIR / f"{ivas_fmt_a}->{ivas_fmt_b}.wav" dut_decoder_frontend.run(output_fmt, 48, bs_concat, output_file) output_file_name = f"{outname_head}-dec_to-{output_fmt}.wav" output_file_path = output_dir / output_file_name if test_mode == TestMode.COMPARE_CREATE_REF: ref_decoder_frontend.run(output_fmt, 48, bs_concat, output_file_path) else: dut_decoder_frontend.run(output_fmt, 48, bs_concat, output_file_path) if test_mode == TestMode.COMPARE_CREATE_CUT: ref_file = OUTPUT_DIR[TestMode.COMPARE_CREATE_REF] / output_file_name output_differs, reason = cmp_pcm(ref_file, output_file_path, output_fmt, 48) if output_differs[0]: pytest.fail(f"Output differs: ({reason[0]})")