From 5b0210994502b4db5c9b77b801e6567b6bb02d2a Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Wed, 31 Jul 2024 13:38:55 +0300 Subject: [PATCH 1/6] [CI] Add MacOS option for the ffmpeg and vtm binary downloads --- .travis-install.bash | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.travis-install.bash b/.travis-install.bash index 1df8440f..1fbc6be3 100644 --- a/.travis-install.bash +++ b/.travis-install.bash @@ -1,11 +1,29 @@ #!/bin/bash -# Download FFmpeg and HM decoder and place them in $PATH. +# Download FFmpeg and VTM decoder and place them in $PATH. set -euvo pipefail mkdir -p "${HOME}/bin" +if [ "$(uname)" == "Darwin" ]; then +wget http://ultravideo.fi/ffmpeg-release-7.0-static-applesilicon.tar.xz +sha256sum -c - << EOF +c2bf6c192fac269ec298ee20b403cc6c9b493970ca3902a2123e649813ea1aba ffmpeg-release-7.0-static-applesilicon.tar.xz +EOF +tar xf ffmpeg-release-7.0-static-applesilicon.tar.xz +cp ffmpeg "${HOME}/bin/ffmpeg" +chmod +x "${HOME}/bin/ffmpeg" + +wget http://ultravideo.fi/vtm-23.4-applesilicon.tar.xz +sha256sum -c - << EOF +193c71adca4f4882425de20f93f63ec6e20fe84154137d6894571a354962c7e1 vtm-23.4-applesilicon.tar.xz +EOF +tar xf vtm-23.4-applesilicon.tar.xz +cp DecoderApp "${HOME}/bin/DecoderAppStatic" +chmod +x "${HOME}/bin/DecoderAppStatic" + +else wget http://ultravideo.fi/ffmpeg-release-4.2.1-32bit-static.tar.xz sha256sum -c - << EOF 226f55f8a94d71f3d231a20fe59fcbb7f6100cabf663f9bcb887d17b332a91c5 ffmpeg-release-4.2.1-32bit-static.tar.xz @@ -21,5 +39,6 @@ EOF tar xf ubuntu-vtm-13.0.tgz cp DecoderApp "${HOME}/bin/DecoderAppStatic" chmod +x "${HOME}/bin/DecoderAppStatic" +fi export PATH="${HOME}/bin:${PATH}" From 9f13c937b34c8ce9eb235982eed68077c3fb0da5 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Wed, 31 Jul 2024 13:41:26 +0300 Subject: [PATCH 2/6] [CI] Try adding a MacOS test --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1f3bd41..d111ce82 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,9 +43,11 @@ test-valgrind: variables: UVG_TEST_VALGRIND: 1 -# TODO: If someone knows YAML better, there has to be some better way to -# concatenate stuff into the test-template script than just manually copy -# pasting +test-macos: + <<: *test-template + tags: + - macOS + #test-distcheck: # <<: *test-template # script: From b74a1a5731c3d93467f401b8914f9fda55466c5c Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Wed, 31 Jul 2024 13:45:48 +0300 Subject: [PATCH 3/6] [CI] Add homebrew bins to path --- .gitlab-ci.yml | 2 +- .travis-install.bash | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d111ce82..e76e9fa4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ test-uvg266: &test-template stage: test script: - bash .travis-install.bash - - export PATH="${HOME}/bin:${PATH}" + - export PATH="/opt/homebrew/bin/:${HOME}/bin:${PATH}" - cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) - make install - env CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test diff --git a/.travis-install.bash b/.travis-install.bash index 1fbc6be3..4166a372 100644 --- a/.travis-install.bash +++ b/.travis-install.bash @@ -6,6 +6,8 @@ set -euvo pipefail mkdir -p "${HOME}/bin" +export PATH="/opt/homebrew/bin/:${PATH}" + if [ "$(uname)" == "Darwin" ]; then wget http://ultravideo.fi/ffmpeg-release-7.0-static-applesilicon.tar.xz sha256sum -c - << EOF From a97ee242549461e130cc2b0d912a69b1dbba4d93 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Wed, 31 Jul 2024 14:00:36 +0300 Subject: [PATCH 4/6] [CI] Try to stop Mac build from adding underscore to symbols --- tests/test_external_symbols.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_external_symbols.sh b/tests/test_external_symbols.sh index b9b1837f..efeedd93 100755 --- a/tests/test_external_symbols.sh +++ b/tests/test_external_symbols.sh @@ -1,10 +1,10 @@ #!/bin/sh -# Check for external symbols without uvg_ prefix. +# Check for external symbols without uvg_ prefix (or _uvg_ on macOS). set -eu${BASH+o pipefail} -if nm -go --defined-only ../lib/libuvg266.a | grep -v ' uvg_'; then +if nm -go --defined-only ../lib/libuvg266.a | grep -v ' uvg_' | grep -v ' _uvg_'; then printf '%s\n' 'Only symbols prefixed with "uvg_" should be exported from libuvg266.' false fi From 2d9827bb904a13a61ffc25a7754da2fc851eff03 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Wed, 31 Jul 2024 14:33:34 +0300 Subject: [PATCH 5/6] [CI] Add asan and ubsan tests for macos --- .gitlab-ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e76e9fa4..ef0bfa86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,26 @@ test-macos: tags: - macOS +test-macos-asan: + <<: *test-template + tags: + - macOS + variables: + CFLAGS: '-fsanitize=address -g' + # LeakSanitizer doesn't work inside the container because it requires + # ptrace so we disable it. + ASAN_OPTIONS: 'detect_leaks=0' + # AddressSanitizer adds some extra symbols so we expect a failure from + # the external symbols test. + XFAIL_TESTS: test_external_symbols + +test-macos-ubsan: + <<: *test-template + tags: + - macOS + variables: + CFLAGS: '-fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment -g' + #test-distcheck: # <<: *test-template # script: From 22490f6e48268200d9dbca2648d148b2bdc5cbe0 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Wed, 31 Jul 2024 15:00:20 +0300 Subject: [PATCH 6/6] [CI] Make clang ubsan happy by checking the overflow before getting a pointer --- src/intra.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/intra.c b/src/intra.c index 22eb93c7..31480078 100644 --- a/src/intra.c +++ b/src/intra.c @@ -584,8 +584,9 @@ static void predict_cclm( if (x_scu == 0) available_left_below = MIN(MIN(height / 2, (64 - y_scu - height * 2) / 4), (state->tile->frame->height - y0 - height * 2) / 4); for (; available_left_below < height / 2; available_left_below++) { int y_extension = y_scu + height * 2 + 4 * available_left_below; + if (y_extension >= ctu_size) break; const cu_info_t* pu = LCU_GET_CU_AT_PX(lcu, (x_scu) - 4, y_extension); - if (y_extension >= ctu_size || pu->type == CU_NOTSET || (pu->type == CU_INTRA && pu->intra.mode_chroma == -1)) break; + if (pu->type == CU_NOTSET || (pu->type == CU_INTRA && pu->intra.mode_chroma == -1)) break; if(x_scu == 32 && y_scu == 0 && pu->log2_height == 6 && pu->log2_width == 6 ) break; } for(int i = 0; i < height + available_left_below * 2; i++) {