├── .clang-format ├── .github └── workflows │ ├── pull_request.yml │ └── uvg266.yml ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── .travis-install.bash ├── CMakeLists.txt ├── CREDITS ├── Dockerfile ├── LICENSE ├── LICENSE.EXT.greatest ├── README.md ├── appveyor.yml ├── bin └── placeholder.txt ├── build └── placeholder.txt ├── doc ├── syntax_elements.txt ├── uvg266.1 ├── uvg266_module_hierarchy.graphmlz └── uvg266_module_hierarchy.png ├── docs.doxy ├── examples ├── README.md ├── fast_coeff_table.txt └── roi.txt ├── rdcost-weight-tool ├── README.txt ├── build.sh ├── extract_rdcosts.py ├── filter_rdcosts.c ├── invert_matrix.m ├── ols_2ndpart.c ├── rdcost_do_avg.py └── run_filter.py ├── src ├── alf.c ├── alf.h ├── bitstream.c ├── bitstream.h ├── cabac.c ├── cabac.h ├── cfg.c ├── cfg.h ├── checkpoint.c ├── checkpoint.h ├── cli.c ├── cli.h ├── constraint.c ├── constraint.h ├── context.c ├── context.h ├── cu.c ├── cu.h ├── debug.c ├── debug.h ├── dep_quant.c ├── dep_quant.h ├── encmain.c ├── encode_coding_tree.c ├── encode_coding_tree.h ├── encoder.c ├── encoder.h ├── encoder_state-bitstream.c ├── encoder_state-bitstream.h ├── encoder_state-ctors_dtors.c ├── encoder_state-ctors_dtors.h ├── encoder_state-geometry.c ├── encoder_state-geometry.h ├── encoderstate.c ├── encoderstate.h ├── encoding_resume.c ├── encoding_resume.h ├── extras │ ├── getopt.c │ ├── getopt.h │ ├── libmd5.c │ └── libmd5.h ├── fast_coeff_cost.c ├── fast_coeff_cost.h ├── filter.c ├── filter.h ├── global.h ├── gop.h ├── hashmap.c ├── hashmap.h ├── image.c ├── image.h ├── imagelist.c ├── imagelist.h ├── input_frame_buffer.c ├── input_frame_buffer.h ├── inter.c ├── inter.h ├── intra.c ├── intra.h ├── lfnst_tables.h ├── ml_classifier_intra_depth_pred.c ├── ml_classifier_intra_depth_pred.h ├── ml_intra_cu_depth_pred.c ├── ml_intra_cu_depth_pred.h ├── nal.c ├── nal.h ├── rate_control.c ├── rate_control.h ├── rdo.c ├── rdo.h ├── reshape.c ├── reshape.h ├── sao.c ├── sao.h ├── scalinglist.c ├── scalinglist.h ├── search.c ├── search.h ├── search_ibc.c ├── search_ibc.h ├── search_inter.c ├── search_inter.h ├── search_intra.c ├── search_intra.h ├── strategies │ ├── altivec │ │ ├── picture-altivec.c │ │ └── picture-altivec.h │ ├── avx2 │ │ ├── alf-avx2.c │ │ ├── alf-avx2.h │ │ ├── avx2_common_functions.h │ │ ├── dct-avx2.c │ │ ├── dct-avx2.h │ │ ├── dct_avx2_tables.h │ │ ├── depquant-avx2.c │ │ ├── depquant-avx2.h │ │ ├── encode_coding_tree-avx2.c │ │ ├── encode_coding_tree-avx2.h │ │ ├── intra-avx2.c │ │ ├── intra-avx2.h │ │ ├── intra_avx2_tables.h │ │ ├── ipol-avx2.c │ │ ├── ipol-avx2.h │ │ ├── mip_data_avx2.h │ │ ├── picture-avx2.c │ │ ├── picture-avx2.h │ │ ├── quant-avx2.c │ │ ├── quant-avx2.h │ │ ├── reg_sad_pow2_widths-avx2.h │ │ ├── sao-avx2.c │ │ └── sao-avx2.h │ ├── generic │ │ ├── alf-generic.c │ │ ├── alf-generic.h │ │ ├── dct-generic.c │ │ ├── dct-generic.h │ │ ├── depquant-generic.c │ │ ├── depquant-generic.h │ │ ├── encode_coding_tree-generic.c │ │ ├── encode_coding_tree-generic.h │ │ ├── intra-generic.c │ │ ├── intra-generic.h │ │ ├── ipol-generic.c │ │ ├── ipol-generic.h │ │ ├── mip_data_generic.h │ │ ├── nal-generic.c │ │ ├── nal-generic.h │ │ ├── picture-generic.c │ │ ├── picture-generic.h │ │ ├── quant-generic.c │ │ ├── quant-generic.h │ │ ├── sao-generic.c │ │ ├── sao-generic.h │ │ └── sao_shared_generics.h │ ├── missing-intel-intrinsics.h │ ├── optimized_sad_func_ptr_t.h │ ├── sse2 │ │ ├── picture-sse2.c │ │ └── picture-sse2.h │ ├── sse41 │ │ ├── alf-sse41.c │ │ ├── alf-sse41.h │ │ ├── picture-sse41.c │ │ ├── picture-sse41.h │ │ └── reg_sad_pow2_widths-sse41.h │ ├── sse42 │ │ ├── picture-sse42.c │ │ └── picture-sse42.h │ ├── strategies-alf.c │ ├── strategies-alf.h │ ├── strategies-common.h │ ├── strategies-dct.c │ ├── strategies-dct.h │ ├── strategies-depquant.c │ ├── strategies-depquant.h │ ├── strategies-encode.c │ ├── strategies-encode.h │ ├── strategies-intra.c │ ├── strategies-intra.h │ ├── strategies-ipol.c │ ├── strategies-ipol.h │ ├── strategies-nal.c │ ├── strategies-nal.h │ ├── strategies-picture.c │ ├── strategies-picture.h │ ├── strategies-quant.c │ ├── strategies-quant.h │ ├── strategies-sao.c │ └── strategies-sao.h ├── strategyselector.c ├── strategyselector.h ├── tables.c ├── tables.h ├── threadqueue.c ├── threadqueue.h ├── threads.h ├── threadwrapper │ ├── LICENSE │ ├── README.md │ ├── include │ │ ├── pthread.h │ │ └── semaphore.h │ └── src │ │ ├── pthread.cpp │ │ └── semaphore.cpp ├── transform.c ├── transform.h ├── uvg266.c ├── uvg266.h ├── uvg266.pc.in ├── uvg266_internal.h ├── uvg_math.h ├── version.h.in ├── videoframe.c ├── videoframe.h ├── yuv_io.c └── yuv_io.h ├── tests ├── CMakeLists.txt ├── check_cabac_state_consistency.py ├── coeff_sum_tests.c ├── dct_tests.c ├── inter_recon_bipred_tests.c ├── intra_sad_tests.c ├── mts_tests.c ├── mv_cand_tests.c ├── sad_tests.c ├── sad_tests.h ├── satd_tests.c ├── satd_tests.h ├── speed_tests.c ├── test_cabac_state.sh ├── test_external_symbols.sh ├── test_intra.sh ├── test_invalid_input.sh ├── test_lmcs.sh ├── test_monochrome.sh ├── test_mtt_both.sh ├── test_mtt_inter.sh ├── test_mtt_intra.sh ├── test_slices.sh ├── test_strategies.c ├── test_strategies.h ├── test_tools.sh ├── test_weird_shapes.sh ├── tests_main.c ├── tsan_suppressions.txt └── util.sh └── tools ├── appveyor-build.sh ├── appveyor-install.sh ├── cabac_match.py ├── estimate.m ├── generate_ref_pixel_tables.py ├── generate_tables.c ├── genmanpage.sh ├── plot-threadqueue-log.py ├── update_readme.sh └── version.sh /.clang-format: -------------------------------------------------------------------------------- 1 | # Format Style Options - Created with Clang Power Tools 2 | --- 3 | AlignAfterOpenBracket: AlwaysBreak 4 | AlignConsecutiveAssignments: AcrossEmptyLinesAndComments 5 | AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments 6 | AlignConsecutiveMacros: AcrossEmptyLines 7 | AlignOperands: AlignAfterOperator 8 | AlignTrailingComments: true 9 | AllowAllArgumentsOnNextLine: false 10 | AllowShortCaseLabelsOnASingleLine: true 11 | AllowShortFunctionsOnASingleLine: None 12 | AllowShortLoopsOnASingleLine: true 13 | BasedOnStyle: Google 14 | BinPackArguments: false 15 | BinPackParameters: false 16 | BraceWrapping: 17 | AfterCaseLabel: false 18 | AfterClass: false 19 | AfterControlStatement: true 20 | AfterEnum: false 21 | AfterFunction: false 22 | AfterNamespace: false 23 | AfterObjCDeclaration: false 24 | AfterStruct: false 25 | AfterUnion: false 26 | AfterExternBlock: false 27 | BeforeCatch: false 28 | BeforeElse: true 29 | IndentBraces: false 30 | SplitEmptyFunction: false 31 | SplitEmptyRecord: false 32 | SplitEmptyNamespace: false 33 | BeforeLambdaBody: false 34 | BeforeWhile: false 35 | BreakBeforeBraces: Linux 36 | BreakBeforeTernaryOperators: false 37 | ConstructorInitializerIndentWidth : 2 38 | ContinuationIndentWidth: 2 39 | IncludeBlocks: Preserve 40 | KeepEmptyLinesAtTheStartOfBlocks: true 41 | MaxEmptyLinesToKeep: 2 42 | ReflowComments: false 43 | SpaceAroundPointerQualifiers: Before 44 | SpacesBeforeTrailingComments: 1 45 | TabWidth: 2 46 | ... 47 | -------------------------------------------------------------------------------- /.github/workflows/uvg266.yml: -------------------------------------------------------------------------------- 1 | name: uvg266_tests 2 | 3 | on: 4 | push: 5 | pull_request: 6 | types: [closed] 7 | 8 | jobs: 9 | basic-test: 10 | runs-on: self-hosted 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: cmake 15 | run: cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) 16 | - name: make 17 | run: make install -j 18 | - name: Run tests 19 | run: export PATH="/home/docker/bin:${PATH}" && CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test 20 | 21 | test-ubsan: 22 | runs-on: self-hosted 23 | env: 24 | CC: gcc 25 | CFLAGS: -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment 26 | 27 | steps: 28 | - uses: actions/checkout@v2 29 | - name: cmake 30 | run: cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) 31 | - name: make 32 | run: make install -j 33 | - name: Run tests 34 | run: export PATH="/home/docker/bin:${PATH}" && CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test 35 | 36 | test-asan: 37 | runs-on: self-hosted 38 | env: 39 | CC: gcc 40 | CFLAGS: -fsanitize=address 41 | ASAN_OPTIONS: detect_leaks=0 42 | # AddressSanitizer adds some extra symbols so we expect a failure from 43 | # the external symbols test. 44 | XFAIL_TESTS: test_external_symbols 45 | 46 | steps: 47 | - uses: actions/checkout@v2 48 | - name: cmake 49 | run: cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) 50 | - name: make 51 | run: make install -j 52 | - name: Run tests 53 | run: export PATH="/home/docker/bin:${PATH}" && CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test 54 | 55 | # test-tsan: 56 | # runs-on: self-hosted 57 | # env: 58 | # CC: gcc 59 | # CFLAGS: -fsanitize=thread 60 | 61 | # steps: 62 | # - uses: actions/checkout@v2 63 | # - name: cmake 64 | # run: cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) 65 | # - name: make 66 | # run: make install -j 67 | # - name: Run tests 68 | # run: export PATH="/home/docker/bin:${PATH}" && CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test 69 | 70 | test-valgrind: 71 | runs-on: self-hosted 72 | 73 | env: 74 | UVG266_OVERRIDE_angular_pred: generic 75 | 76 | steps: 77 | - uses: actions/checkout@v2 78 | - name: cmake 79 | run: cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) 80 | - name: make 81 | run: make install -j 82 | - name: Run tests 83 | run: export PATH="/home/docker/bin:${PATH}" && CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test 84 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build files 2 | /bin 3 | /build/* 4 | !/build/uvg266_lib 5 | /build/uvg266_lib/* 6 | !/build/uvg266_lib/uvg266_lib.vcxproj 7 | !/build/uvg266_lib/uvg266_lib.vcxproj.filters 8 | /scons_build_* 9 | 10 | # Generated documentation 11 | /doxygen_html 12 | /doxygen 13 | 14 | # Autotools generated 15 | .deps 16 | .dirstamp 17 | .libs 18 | .vs 19 | Makefile 20 | Makefile.in 21 | /aclocal.m4 22 | /autom4te.cache 23 | /build-aux 24 | /config.h 25 | /config.h.in* 26 | /config.status 27 | /configure 28 | /libtool 29 | /m4/libtool.m4 30 | /m4/ltoptions.m4 31 | /m4/ltsugar.m4 32 | /m4/ltversion.m4 33 | /m4/lt~obsolete.m4 34 | /stamp-h1 35 | 36 | # Other files 37 | *.a 38 | *.d 39 | *.dll 40 | *.dylib 41 | *.exe 42 | *.la 43 | *.lo 44 | *.o 45 | *.trs 46 | .*.swp 47 | .*.swo 48 | .swp 49 | .swo 50 | 51 | *.log 52 | .kdev4 53 | configure.scan 54 | src/uvg266 55 | src/libuvg266.so.* 56 | src/uvg266.pc 57 | src/version.h 58 | tests/uvg266_tests 59 | tests/uvg266_tests.trs 60 | out 61 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # Use Kvazaar CI base image which includes the build tools and ffmpeg + hmdec in ${HOME}/bin 2 | image: ultravideo/kvazaar_ci_base:latest 3 | 4 | # Build and test kvazaar 5 | test-uvg266: &test-template 6 | stage: test 7 | script: 8 | - bash .travis-install.bash 9 | - export PATH="/opt/homebrew/bin/:${HOME}/bin:${PATH}" 10 | - cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./ . || (cat config.log && false) 11 | - make install 12 | - env CTEST_PARALLEL_LEVEL=8 CTEST_OUTPUT_ON_FAILURE=1 make test 13 | artifacts: 14 | paths: 15 | - bin/uvg266 16 | expire_in: 1 week 17 | 18 | test-asan: 19 | <<: *test-template 20 | variables: 21 | CFLAGS: '-fsanitize=address -g' 22 | # LeakSanitizer doesn't work inside the container because it requires 23 | # ptrace so we disable it. 24 | ASAN_OPTIONS: 'detect_leaks=0' 25 | # AddressSanitizer adds some extra symbols so we expect a failure from 26 | # the external symbols test. 27 | XFAIL_TESTS: test_external_symbols 28 | 29 | #test-tsan: 30 | # <<: *test-template 31 | # variables: 32 | # CFLAGS: '-fsanitize=thread' 33 | # # Temporarily suppress known errors or false positives. 34 | # TSAN_OPTIONS: 'suppressions=/builds/cs/ultravideo/kvazaar/tests/tsan_suppressions.txt' 35 | 36 | test-ubsan: 37 | <<: *test-template 38 | variables: 39 | CFLAGS: '-fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment -g' 40 | 41 | test-valgrind: 42 | <<: *test-template 43 | variables: 44 | UVG_TEST_VALGRIND: 1 45 | 46 | test-macos: 47 | <<: *test-template 48 | tags: 49 | - macOS 50 | 51 | test-macos-asan: 52 | <<: *test-template 53 | tags: 54 | - macOS 55 | variables: 56 | CFLAGS: '-fsanitize=address -g' 57 | # LeakSanitizer doesn't work inside the container because it requires 58 | # ptrace so we disable it. 59 | ASAN_OPTIONS: 'detect_leaks=0' 60 | # AddressSanitizer adds some extra symbols so we expect a failure from 61 | # the external symbols test. 62 | XFAIL_TESTS: test_external_symbols 63 | 64 | test-macos-ubsan: 65 | <<: *test-template 66 | tags: 67 | - macOS 68 | variables: 69 | CFLAGS: '-fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment -g' 70 | 71 | #test-distcheck: 72 | # <<: *test-template 73 | # script: 74 | # - export PATH="${HOME}/bin:${PATH}" 75 | # - ./autogen.sh 76 | # - ./configure --enable-werror || (cat config.log && false) 77 | # - make --jobs=8 VERBOSE=1 distcheck 78 | 79 | #test-10bit: 80 | # <<: *test-template 81 | # variables: 82 | # CFLAGS: '-DKVZ_BIT_DEPTH=10' 83 | # VAQ is not currently supported on the 10-bit build, so xfail it 84 | #XFAIL_TESTS: test_tools.sh 85 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "greatest"] 2 | path = greatest 3 | url = https://github.com/ultravideo/greatest.git 4 | -------------------------------------------------------------------------------- /.travis-install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Download FFmpeg and VTM decoder and place them in $PATH. 4 | 5 | set -euvo pipefail 6 | 7 | mkdir -p "${HOME}/bin" 8 | 9 | export PATH="/opt/homebrew/bin/:${PATH}" 10 | 11 | if [ "$(uname)" == "Darwin" ]; then 12 | wget http://ultravideo.fi/ffmpeg-release-7.0-static-applesilicon.tar.xz 13 | sha256sum -c - << EOF 14 | c2bf6c192fac269ec298ee20b403cc6c9b493970ca3902a2123e649813ea1aba ffmpeg-release-7.0-static-applesilicon.tar.xz 15 | EOF 16 | tar xf ffmpeg-release-7.0-static-applesilicon.tar.xz 17 | cp ffmpeg "${HOME}/bin/ffmpeg" 18 | chmod +x "${HOME}/bin/ffmpeg" 19 | 20 | wget http://ultravideo.fi/vtm-23.4-applesilicon.tar.xz 21 | sha256sum -c - << EOF 22 | 193c71adca4f4882425de20f93f63ec6e20fe84154137d6894571a354962c7e1 vtm-23.4-applesilicon.tar.xz 23 | EOF 24 | tar xf vtm-23.4-applesilicon.tar.xz 25 | cp DecoderApp "${HOME}/bin/DecoderAppStatic" 26 | chmod +x "${HOME}/bin/DecoderAppStatic" 27 | 28 | else 29 | wget http://ultravideo.fi/ffmpeg-release-4.2.1-32bit-static.tar.xz 30 | sha256sum -c - << EOF 31 | 226f55f8a94d71f3d231a20fe59fcbb7f6100cabf663f9bcb887d17b332a91c5 ffmpeg-release-4.2.1-32bit-static.tar.xz 32 | EOF 33 | tar xf ffmpeg-release-4.2.1-32bit-static.tar.xz 34 | cp ffmpeg-4.2.1-i686-static/ffmpeg "${HOME}/bin/ffmpeg" 35 | chmod +x "${HOME}/bin/ffmpeg" 36 | 37 | wget http://ultravideo.fi/ubuntu-vtm-13.0.tgz 38 | sha256sum -c - << EOF 39 | 1751bba04611791040a978015da8bb537fcd89c89453c0cdc1ec2719aac2a1a8 ubuntu-vtm-13.0.tgz 40 | EOF 41 | tar xf ubuntu-vtm-13.0.tgz 42 | cp DecoderApp "${HOME}/bin/DecoderAppStatic" 43 | chmod +x "${HOME}/bin/DecoderAppStatic" 44 | fi 45 | 46 | export PATH="${HOME}/bin:${PATH}" 47 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | This is a list of people that have contributed code to this project, ordered by 2 | date of first commit. For more details you can look at the full git version 3 | history. 4 | 5 | Name: Email: 6 | Marko Viitanen fador@iki.fi 7 | Ari Koivula ari@koivu.la 8 | Jan Ekström jeebjp@gmail.com 9 | Yusuke Nakamura muken.the.vfrmaniac@gmail.com 10 | Laurent Fasnacht l@libres.ch 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # A simple Dockerfile for building uvg266 from the git repository 2 | # Example build command when in this directory: docker build -t uvg266 . 3 | # 4 | # Example usage 5 | # Run with an input YUV file and output HEVC binary file 6 | # docker run -i -a STDIN -a STDOUT uvg266 -i - --input-res=320x240 -o - < testfile_320x240.yuv > out.265 7 | # 8 | # Use libav or ffmpeg to input (almost) any format and convert it to YUV420 for uvg266, audio is disabled 9 | # 10 | # RESOLUTION=`avconv -i input.avi 2>&1 | grep Stream | grep -oP ', \K[0-9]+x[0-9]+'` 11 | # avconv -i input.avi -an -f rawvideo -pix_fmt yuv420p - | docker run -i -a STDIN -a STDOUT uvg266 -i - --wpp --threads=8 --input-res=$RESOLUTION --preset=ultrafast -o - > output.266 12 | # or 13 | # RESOLUTION=`ffmpeg -i input.avi 2>&1 | grep Stream | grep -oP ', \K[0-9]+x[0-9]+'` 14 | # ffmpeg -i input.avi -an -f rawvideo -pix_fmt yuv420p - | docker run -i -a STDIN -a STDOUT uvg266 -i - --wpp --threads=8 --input-res=$RESOLUTION --preset=ultrafast -o - > output.266 15 | # 16 | 17 | # Use Ubuntu 22.04 as a base for now 18 | FROM ubuntu:22.04 19 | 20 | MAINTAINER Marko Viitanen 21 | 22 | # List of needed packages to be able to build uvg266 with autotools 23 | ENV REQUIRED_PACKAGES automake autoconf libtool m4 build-essential git cmake pkgconf 24 | 25 | COPY . uvg266 26 | # Run all the commands in one RUN so we don't have any extra history 27 | # data in the image. 28 | RUN apt-get update \ 29 | && apt-get install -y $REQUIRED_PACKAGES \ 30 | && cd uvg266/build \ 31 | && cmake -DUSE_SHARED_LIB=OFF .. \ 32 | && make\ 33 | && make install \ 34 | && AUTOINSTALLED_PACKAGES=`apt-mark showauto` \ 35 | && apt-get remove --purge --force-yes -y $REQUIRED_PACKAGES $AUTOINSTALLED_PACKAGES \ 36 | && apt-get autoremove -y \ 37 | && rm -rf /var/lib/{apt,dpkg,cache,log}/ 38 | 39 | ENTRYPOINT ["uvg266"] 40 | CMD ["--help"] 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /LICENSE.EXT.greatest: -------------------------------------------------------------------------------- 1 | Kvazaar uses "Greatest" C unit testing library, licensed under ISC license. 2 | A fork of the library is included in the git project as a submodule. The 3 | original can be found at https://github.com/silentbicycle/greatest . 4 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Email the author if their commit either failed to build or fixed a failed build 2 | # good -> bad, bad -> bad, bad -> good but not good -> good 3 | notifications: 4 | - provider: Email 5 | to: 6 | - '{{commitAuthorEmail}}' 7 | on_build_success: false 8 | on_build_failure: true 9 | on_build_status_changed: true 10 | 11 | 12 | # Downloading the whole history of the repository would be unnecessary 13 | clone_depth: 1 14 | 15 | image: 16 | - Visual Studio 2017 17 | - Visual Studio 2019 18 | - Visual Studio 2022 19 | 20 | # Don't bother with debug builds 21 | configuration: 22 | - Release 23 | 24 | init: 25 | - echo %APPVEYOR_BUILD_WORKER_IMAGE% 26 | - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017" ) 27 | - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" ( set generator="Visual Studio 16 2019" ) 28 | - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" ( set generator="Visual Studio 17 2022" ) 29 | - echo %generator% 30 | 31 | # Try both shared and static builds 32 | environment: 33 | matrix: 34 | - BUILD_SHARED_LIBS: 0 35 | - BUILD_SHARED_LIBS: 1 36 | 37 | install: 38 | #init and update submodules only in static build 39 | - if "%BUILD_SHARED_LIBS%" == "0" git submodule update --recursive --init 40 | 41 | before_build: 42 | - cmd: |- 43 | cd build 44 | cmake --version 45 | cmake .. -G %generator% -A x64 -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% 46 | 47 | build: 48 | project: $(APPVEYOR_BUILD_FOLDER)\build\$(APPVEYOR_PROJECT_NAME).sln 49 | verbosity: minimal 50 | parallel: true 51 | only_commits: 52 | files: 53 | - CMakeLists.txt 54 | - appveyor.yml 55 | - src/ 56 | 57 | test_script: 58 | - if "%BUILD_SHARED_LIBS%" == "0" %APPVEYOR_BUILD_FOLDER%\build\tests\%CONFIGURATION%\uvg266_tests.exe 59 | - '%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%\uvg266.exe --version' 60 | -------------------------------------------------------------------------------- /bin/placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/bin/placeholder.txt -------------------------------------------------------------------------------- /build/placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/build/placeholder.txt -------------------------------------------------------------------------------- /doc/syntax_elements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/doc/syntax_elements.txt -------------------------------------------------------------------------------- /doc/uvg266_module_hierarchy.graphmlz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/doc/uvg266_module_hierarchy.graphmlz -------------------------------------------------------------------------------- /doc/uvg266_module_hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/doc/uvg266_module_hierarchy.png -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | Examples of external files for use with Kvazaar. 4 | 5 | ## Region of interest (roi) files 6 | A simple text file can be used with the `--roi` switch to setup regions of interest for encoding. 7 | Header row of the file will tell how many regions the encoded frames are divided (columns, rows). 8 | The header must be followed by a data row with number entries equal to columns * rows. 9 | The data row will tell the encoder which delta QP value will be assigned to each region. 10 | The included example file will split frames into four regions with the top regions having a delta QP of +5 11 | ``` 12 | 2 2 13 | 5 5 0 0 14 | ``` -------------------------------------------------------------------------------- /examples/fast_coeff_table.txt: -------------------------------------------------------------------------------- 1 | 0.046152 4.874163 3.830968 6.617950 2 | 0.046152 4.874163 3.830968 6.617950 3 | 0.046152 4.874163 3.830968 6.617950 4 | 0.046152 4.874163 3.830968 6.617950 5 | 0.046152 4.874163 3.830968 6.617950 6 | 0.046152 4.874163 3.830968 6.617950 7 | 0.046152 4.874163 3.830968 6.617950 8 | 0.046152 4.874163 3.830968 6.617950 9 | 0.046152 4.874163 3.830968 6.617950 10 | 0.046152 4.874163 3.830968 6.617950 11 | 0.046152 4.874163 3.830968 6.617950 12 | 0.046152 4.874163 3.830968 6.617950 13 | 0.046152 4.874163 3.830968 6.617950 14 | 0.040648 4.920004 3.922710 6.572261 15 | 0.033854 4.982197 4.021474 6.518219 16 | 0.027073 5.056451 4.082557 6.471514 17 | 0.021064 5.125763 4.113825 6.436425 18 | 0.016605 5.170554 4.119091 6.423091 19 | 0.012953 5.196849 4.128659 6.422746 20 | 0.010218 5.194947 4.166336 6.431305 21 | 0.007970 5.177114 4.217242 6.429468 22 | 0.006442 5.138598 4.275070 6.396064 23 | 0.005184 5.093265 4.337876 6.352651 24 | 0.004134 5.046189 4.413434 6.310742 25 | 0.003239 5.001028 4.492965 6.264692 26 | 0.002689 4.959881 4.569652 6.198468 27 | 0.002280 4.920991 4.642861 6.123074 28 | 0.001940 4.886799 4.709124 6.049688 29 | 0.001631 4.858057 4.767754 5.986929 30 | 0.001409 4.839546 4.813134 5.951025 31 | 0.001223 4.823649 4.856675 5.933274 32 | 0.001055 4.806288 4.904500 5.940060 33 | 0.000899 4.789201 4.950018 5.955955 34 | 0.000781 4.776673 4.981798 5.982144 35 | 0.000683 4.766721 5.006732 6.019175 36 | 0.000603 4.757364 5.030649 6.081959 37 | 0.000529 4.746016 5.059187 6.158720 38 | 0.000460 4.729670 5.100437 6.254217 39 | 0.000397 4.711187 5.150631 6.364452 40 | 0.000345 4.692304 5.213098 6.506122 41 | 0.000300 4.674471 5.279962 6.667672 42 | 0.000264 4.660182 5.342776 6.836979 43 | 0.000237 4.649543 5.392507 6.977093 44 | 0.000237 4.649543 5.392507 6.977093 45 | 0.000237 4.649543 5.392507 6.977093 46 | 0.000237 4.649543 5.392507 6.977093 47 | 0.000237 4.649543 5.392507 6.977093 48 | 0.000237 4.649543 5.392507 6.977093 49 | 0.000237 4.649543 5.392507 6.977093 50 | 0.000237 4.649543 5.392507 6.977093 51 | 0.000237 4.649543 5.392507 6.977093 52 | -------------------------------------------------------------------------------- /examples/roi.txt: -------------------------------------------------------------------------------- 1 | 2 2 2 | 5 5 0 0 -------------------------------------------------------------------------------- /rdcost-weight-tool/README.txt: -------------------------------------------------------------------------------- 1 | To extract the block costs, build Kvazaar as usual, and edit relevant 2 | parameters in the beginning of extract_rdcosts.py and run_filter.py, most 3 | importantly the number of cores and the set of video sequences you want to 4 | encode to extract costs. Run extract_rdcosts.py, it will use Kvazaar to encode 5 | each sequence and extract the costs measured there for the quantized blocks. 6 | The costs are stored compressed and sorted by block QP, in the following 7 | format: 8 | 9 | Size (B) | Description 10 | ----------+------------ 11 | 4 | size: Coeff group size, in int16's 12 | 4 | ccc: Coeff group's coding cost 13 | size * 2 | coeffs: Coeff group data 14 | 15 | To analyze the costs by running a linear regression over them, build the two 16 | tools using: 17 | 18 | $ gcc filter_rdcosts.c -O2 -o frcosts_matrix 19 | $ gcc ols_2ndpart.c -O2 -o ols_2ndpart 20 | 21 | Then run the regression in parallel by running run_filter.py. The reason to do 22 | it this way is because the data is stored compressed, so there is no way to 23 | mmap it in Matlab/Octave/something; the data sets are absolutely huge (larger 24 | than reasonable amounts of RAM in a decent workstation), but this way we can 25 | store the data compressed and process it in O(1) memory complexity, so it can 26 | be done as widely parallelized as you have CPU cores. The result files each 27 | consist of 4 numbers, which represent an approximate linear solution to the 28 | corresponding set of costs: the price in bits of a coefficient whose absolute 29 | value is a) 0, b) 1, c) 2, d) 3 or higher. 30 | 31 | After that, run rdcost_do_avg.py. It will calculate a per-QP average of the 32 | costs over the set of the sequences having been run (ie. for each QP, take the 33 | results for that QP for each sequence, and calculate their average). This data 34 | is what you can use to fill in the default_fast_coeff_cost_wts table in 35 | src/fast_coeff_cost.h. 36 | -------------------------------------------------------------------------------- /rdcost-weight-tool/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | gcc -O2 filter_rdcosts.c -o frcosts_matrix 4 | gcc -O2 ols_2ndpart.c -o ols_2ndpart 5 | -------------------------------------------------------------------------------- /rdcost-weight-tool/invert_matrix.m: -------------------------------------------------------------------------------- 1 | A = dlmread("/dev/stdin"); 2 | B = inv(A); 3 | dlmwrite("/dev/stdout", B, " "); 4 | -------------------------------------------------------------------------------- /rdcost-weight-tool/rdcost_do_avg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import glob 4 | import sys 5 | 6 | result_path_template = "/tmp/rdcost/coeff_buckets/*-qp%02i.result" 7 | 8 | def main(): 9 | results = [] 10 | for qp in range(51): 11 | curr_sums = [0.0] * 4 12 | curr_count = 0 13 | result_files = glob.glob(result_path_template % qp) 14 | for fn in result_files: 15 | with open(fn) as f: 16 | contents = f.readlines() 17 | if (len(contents) != 4): 18 | print("Faulty file contents at %s, skipping" % fn, file=sys.stderr) 19 | continue 20 | nums = tuple(map(float, contents)) 21 | if (all(n == 0.0 for n in nums)): 22 | print("All-zero file %s, skipping" % fn) 23 | continue 24 | 25 | curr_count += 1 26 | for i in range(len(curr_sums)): 27 | curr_sums[i] += nums[i] 28 | 29 | if (curr_count > 0): 30 | curr_avgs = tuple(curr_sum / curr_count for curr_sum in curr_sums) 31 | else: 32 | curr_avgs = (0, 0, 0, 0) 33 | 34 | results.append(curr_avgs) 35 | print("\n".join(("QP %2i: " % i + ", ".join("%.6f" for _ in range(4)) % res for i, res in enumerate(results)))) 36 | 37 | if (__name__ == "__main__"): 38 | main() 39 | -------------------------------------------------------------------------------- /src/alf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/src/alf.c -------------------------------------------------------------------------------- /src/cfg.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H_ 2 | #define CONFIG_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Control 37 | * \file 38 | * Runtime configuration through defaults and parsing of arguments. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | #include "uvg266.h" 44 | 45 | /* Function definitions */ 46 | uvg_config *uvg_config_alloc(void); 47 | int uvg_config_init(uvg_config *cfg); 48 | int uvg_config_destroy(uvg_config *cfg); 49 | int uvg_config_parse(uvg_config *cfg, const char *name, const char *value); 50 | void uvg_config_process_lp_gop(uvg_config *cfg); 51 | int uvg_config_validate(const uvg_config *const cfg); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/checkpoint.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "checkpoint.h" 34 | #if defined(CHECKPOINTS) 35 | FILE* g_ckpt_file; 36 | int g_ckpt_enabled; 37 | int g_ckpt_record; 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /src/cli.h: -------------------------------------------------------------------------------- 1 | #ifndef CLI_H_ 2 | #define CLI_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \file 37 | * Command line interface 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | #include "uvg266.h" 42 | 43 | typedef struct cmdline_opts_t { 44 | /** \brief Input filename */ 45 | char *input; 46 | /** \brief Output filename */ 47 | char *output; 48 | /** \brief Debug output */ 49 | char *debug; 50 | /** \brief Number of input frames to skip */ 51 | int32_t seek; 52 | /** \brief Number of frames to encode */ 53 | int32_t frames; 54 | /** \brief Encoder configuration */ 55 | uvg_config *config; 56 | /** \brief Encoder configuration */ 57 | bool help; 58 | /** \brief Encoder configuration */ 59 | bool version; 60 | /** \brief Whether to loop input */ 61 | bool loop_input; 62 | } cmdline_opts_t; 63 | 64 | cmdline_opts_t* cmdline_opts_parse(const uvg_api *const api, int argc, char *argv[]); 65 | void cmdline_opts_free(const uvg_api *const api, cmdline_opts_t *opts); 66 | 67 | void print_usage(void); 68 | void print_version(bool); 69 | void print_help(void); 70 | void print_frame_info(const uvg_frame_info *const info, 71 | const double frame_psnr[3], 72 | const uint32_t bytes, 73 | const bool print_psnr, 74 | const double avg_qp); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/constraint.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "constraint.h" 34 | 35 | /** 36 | * \brief Allocate the constraint_t structure. 37 | * 38 | * \param state encoder state 39 | * \return the pointer of constraint_t structure 40 | */ 41 | void * uvg_init_constraint(encoder_state_t* state, const encoder_control_t * const encoder) { 42 | constraint_t* constr = NULL; 43 | // Allocate the constraint_t strucutre 44 | constr = MALLOC(constraint_t, 1); 45 | if (!constr) { 46 | fprintf(stderr, "Memory allocation failed!\n"); 47 | assert(0); 48 | } 49 | 50 | // Allocate the ml_intra_ctu_pred_t structure 51 | constr->ml_intra_depth_ctu = NULL; 52 | if (encoder->cfg.ml_pu_depth_intra) // TODO: Change this by a new param !! 53 | { 54 | constr->ml_intra_depth_ctu = uvg_init_ml_intra_depth_const(); 55 | } 56 | return constr; 57 | } 58 | 59 | /** 60 | * \brief Deallocate the constraint_t structure. 61 | * 62 | * \param state encoder state 63 | */ 64 | void uvg_constraint_free(encoder_state_t* state) { 65 | constraint_t* constr = state->constraint; 66 | if (constr->ml_intra_depth_ctu) 67 | { 68 | uvg_end_ml_intra_depth_const(constr->ml_intra_depth_ctu); 69 | } 70 | FREE_POINTER(constr); 71 | } 72 | -------------------------------------------------------------------------------- /src/constraint.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTRAINT_H_ 2 | #define CONSTRAINT_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | #include "ml_intra_cu_depth_pred.h" 36 | #include "encoderstate.h" 37 | 38 | 39 | /* Constraint structure: 40 | * Each field corresponds to a constraint technique. The encoder tests if the constraint 41 | * pointer is allocated to apply the technique. 42 | */ 43 | typedef struct { 44 | // Structure used for the CTU depth prediction using Machine Learning in All Intra 45 | ml_intra_ctu_pred_t * ml_intra_depth_ctu; 46 | } constraint_t; 47 | 48 | 49 | void * uvg_init_constraint(encoder_state_t* state, const encoder_control_t * const); 50 | void uvg_constraint_free(encoder_state_t* state); 51 | 52 | #endif -------------------------------------------------------------------------------- /src/encoder_state-bitstream.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_STATE_BITSTREAM_H_ 2 | #define ENCODER_STATE_BITSTREAM_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Bitstream 37 | * \file 38 | * Coding of HEVC bitstream elements. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | // Forward declare because including the header would lead to a cyclic 45 | // dependency. 46 | struct encoder_state_t; 47 | 48 | struct bitstream_t; 49 | 50 | void uvg_encoder_state_write_bitstream_slice_header( 51 | struct bitstream_t * const stream, 52 | struct encoder_state_t * const state, 53 | bool independent); 54 | void uvg_encoder_state_write_bitstream(struct encoder_state_t * const state); 55 | void uvg_encoder_state_write_bitstream_leaf(struct encoder_state_t * const state); 56 | void uvg_encoder_state_worker_write_bitstream(void * opaque); 57 | void uvg_encoder_state_write_parameter_sets(struct bitstream_t *stream, 58 | struct encoder_state_t * const state); 59 | 60 | #endif // ENCODER_STATE_BITSTREAM_H_ 61 | -------------------------------------------------------------------------------- /src/encoder_state-ctors_dtors.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_STATE_CTORS_DTORS_H_ 2 | #define ENCODER_STATE_CTORS_DTORS_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Control 37 | * \file 38 | * Creation and destruction of encoder_state_t. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | #include "ml_intra_cu_depth_pred.h" 43 | #include "constraint.h" 44 | 45 | // Forward declare because including the header would lead to a cyclic 46 | // dependency. 47 | struct encoder_state_t; 48 | 49 | 50 | int uvg_encoder_state_init(struct encoder_state_t *const child_state, struct encoder_state_t *const parent_state); 51 | void uvg_encoder_state_finalize(struct encoder_state_t *const state); 52 | 53 | 54 | #endif // ENCODER_STATE_CTORS_DTORS_H_ 55 | -------------------------------------------------------------------------------- /src/encoder_state-geometry.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_STATE_GEOMETRY_H_ 2 | #define ENCODER_STATE_GEOMETRY_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Control 37 | * \file 38 | * Helper functions for tiles and slices. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | // Forward declare because including the header would lead to a cyclic 45 | // dependency. 46 | struct encoder_control_t; 47 | struct encoder_state_t; 48 | 49 | 50 | int uvg_lcu_at_slice_start(const struct encoder_control_t * const encoder, int lcu_addr_in_ts); 51 | int uvg_lcu_at_slice_end(const struct encoder_control_t * const encoder, int lcu_addr_in_ts); 52 | int uvg_lcu_at_tile_start(const struct encoder_control_t * const encoder, int lcu_addr_in_ts); 53 | int uvg_lcu_at_tile_end(const struct encoder_control_t * const encoder, int lcu_addr_in_ts); 54 | int uvg_lcu_in_first_row(const struct encoder_state_t * const encoder_state, int lcu_addr_in_ts); 55 | int uvg_lcu_in_last_row(const struct encoder_state_t * const encoder_state, int lcu_addr_in_ts); 56 | int uvg_lcu_in_first_column(const struct encoder_state_t * const encoder_state, int lcu_addr_in_ts); 57 | int uvg_lcu_in_last_column(const struct encoder_state_t * const encoder_state, int lcu_addr_in_ts); 58 | 59 | 60 | #endif // ENCODER_STATE_GEOMETRY_H_ 61 | -------------------------------------------------------------------------------- /src/encoding_resume.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODING_RESUME_H_ 2 | #define ENCODING_RESUME_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \file 37 | * Allow skipping search for specific frames to speed up debugging by reading previous data from file 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | 42 | #ifdef UVG_ENCODING_RESUME 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | #include "cu.h" 49 | #include "encoderstate.h" 50 | #include "uvg266.h" 51 | 52 | #define RESUME_DIRNAME "./resume_data" 53 | 54 | #define RESUME_SLICE_COND UVG_SLICE_I 55 | //#define RESUME_POC_LTE_COND 0 56 | //#define RESUME_X_LTE_COND 0 57 | //#define RESUME_Y_LTE_COND 0 58 | //#define RESUME_NO_CHROMA_COND 1 59 | 60 | #define RESUME_SUB_FRAME_POC_COND 16 61 | #define RESUME_SUB_FRAME_LCU_IND_LT_COND 791 62 | 63 | 64 | bool uvg_can_resume_encoding(const encoder_state_t * const state, const int x, const int y, const bool chroma_only); 65 | void uvg_process_resume_encoding(const encoder_state_t * const state, const int x, const int y, const bool chroma_only, double * const cost, lcu_t* const lcu, bool read_mode); 66 | 67 | #endif 68 | 69 | #if !defined(UVG_ENCODING_RESUME) 70 | 71 | #endif 72 | 73 | 74 | 75 | #endif //ENCODER_RESUME_H_ 76 | -------------------------------------------------------------------------------- /src/extras/getopt.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2000 The NetBSD Foundation, Inc. 3 | * All rights reserved. 4 | * 5 | * This code is derived from software contributed to The NetBSD Foundation 6 | * by Dieter Baron and Thomas Klausner. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _GETOPT_H_ 31 | #define _GETOPT_H_ 32 | 33 | /* These are used to replace unistd.h include. */ 34 | extern char *optarg; 35 | extern int optind, opterr, optopt, optreset; 36 | 37 | /* 38 | * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions 39 | */ 40 | #define no_argument 0 41 | #define required_argument 1 42 | #define optional_argument 2 43 | 44 | struct option { 45 | /* name of long option */ 46 | const char *name; 47 | /* 48 | * one of no_argument, required_argument, and optional_argument: 49 | * whether option takes an argument 50 | */ 51 | int has_arg; 52 | /* if not NULL, set *flag to val when option found */ 53 | int *flag; 54 | /* if flag not NULL, value to set *flag to; else return value */ 55 | int val; 56 | }; 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | int getopt_long(int, char * const *, const char *, 63 | const struct option *, int *); 64 | 65 | /* On some platforms, this is in libc, but not in a system header */ 66 | extern int optreset; 67 | #if defined(__sgi) || defined(__sun) || defined(__GLIBC__) 68 | extern char *optarg; 69 | extern int opterr; 70 | extern int optind; 71 | extern int optopt; 72 | #endif 73 | 74 | #ifdef __cplusplus 75 | }; 76 | #endif 77 | 78 | #endif /* !_GETOPT_H_ */ 79 | -------------------------------------------------------------------------------- /src/extras/libmd5.h: -------------------------------------------------------------------------------- 1 | /* The copyright in this software is being made available under the BSD 2 | * License, included below. This software may be subject to other third party 3 | * and contributor rights, including patent rights, and no such rights are 4 | * granted under this license. 5 | * 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may 18 | * be used to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 | * THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | #pragma once 34 | #include 35 | 36 | //! \ingroup libMD5 37 | //! \{ 38 | 39 | typedef struct _context_md5_t { 40 | uint32_t buf[4]; 41 | uint32_t bits[2]; 42 | union { 43 | unsigned char b8[64]; 44 | uint32_t b32[16]; 45 | } in; 46 | } context_md5_t; 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | void uvg_md5_init(context_md5_t *ctx); 52 | void uvg_md5_update(context_md5_t *ctx, const unsigned char *buf, unsigned len); 53 | void uvg_md5_final(unsigned char digest[16], context_md5_t *ctx); 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | //! \} 59 | -------------------------------------------------------------------------------- /src/filter.h: -------------------------------------------------------------------------------- 1 | #ifndef FILTER_H_ 2 | #define FILTER_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Reconstruction 37 | * \file 38 | * Deblocking filter. 39 | */ 40 | 41 | #include "encoderstate.h" 42 | #include "global.h" // IWYU pragma: keep 43 | 44 | 45 | /** 46 | * \brief Edge direction. 47 | */ 48 | typedef enum edge_dir { 49 | EDGE_VER = 1, // vertical 50 | EDGE_HOR = 2, // horizontal 51 | } edge_dir; 52 | 53 | 54 | void uvg_filter_deblock_lcu(encoder_state_t *const state, int x_px, int y_px); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/hashmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2023, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | // The ratio of the hashmap bucket size to the maximum number of elements 40 | #define UVG_HASHMAP_RATIO 12.0 41 | // Use Hashmap for 4x4 blocks 42 | #define UVG_HASHMAP_BLOCKSIZE 8 43 | 44 | typedef struct uvg_hashmap_node { 45 | void* next; 46 | uint32_t key; 47 | uint32_t value; 48 | uint32_t size; 49 | } uvg_hashmap_node_t; 50 | 51 | typedef struct uvg_hashmap { 52 | uint32_t bucket_size; 53 | uvg_hashmap_node_t** table; 54 | } uvg_hashmap_t; 55 | 56 | uvg_hashmap_node_t* uvg_hashmap_create_node(uint32_t key, uint32_t value); 57 | 58 | uvg_hashmap_t* uvg_hashmap_create(uint32_t bucket_size); 59 | 60 | //uint32_t uvg_hashmap_hash(uint32_t key, uint32_t bucket_size); 61 | 62 | void uvg_hashmap_insert(uvg_hashmap_t* map, uint32_t key, uint32_t value); 63 | 64 | uvg_hashmap_node_t* uvg_hashmap_search(uvg_hashmap_t* map, uint32_t key); 65 | 66 | uint32_t uvg_hashmap_search_return_first(uvg_hashmap_t* map, uint32_t key); 67 | 68 | void uvg_hashmap_node_free(uvg_hashmap_node_t* node); 69 | 70 | void uvg_hashmap_free(uvg_hashmap_t* map); 71 | -------------------------------------------------------------------------------- /src/imagelist.h: -------------------------------------------------------------------------------- 1 | #ifndef PICTURE_LIST_H_ 2 | #define PICTURE_LIST_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup DataStructures 37 | * \file 38 | * Container for a list of reference pictures. 39 | */ 40 | 41 | #include "cu.h" 42 | #include "global.h" // IWYU pragma: keep 43 | #include "uvg266.h" 44 | 45 | 46 | /** 47 | * \brief Struct which contains array of picture structs 48 | */ 49 | typedef struct 50 | { 51 | struct uvg_picture* *images; //!< \brief Pointer to array of picture pointers. 52 | cu_array_t* *cu_arrays; 53 | int32_t *pocs; 54 | uint8_t (*ref_LXs)[2][16]; //!< L0 and L1 reference index list for each image 55 | uint32_t size; //!< \brief Array size. 56 | uint32_t used_size; 57 | 58 | 59 | } image_list_t; 60 | 61 | image_list_t * uvg_image_list_alloc(int size); 62 | int uvg_image_list_resize(image_list_t *list, unsigned size); 63 | int uvg_image_list_destroy(image_list_t *list); 64 | int uvg_image_list_add(image_list_t *list, uvg_picture *im, cu_array_t* cua, int32_t poc, uint8_t ref_LX[2][16]); 65 | int uvg_image_list_rem(image_list_t *const list, const unsigned n); 66 | 67 | int uvg_image_list_copy_contents(image_list_t *target, image_list_t *source); 68 | 69 | enum { REF_PIC_LIST_0 = 0, REF_PIC_LIST_1 = 1, REF_PIC_LIST_X = 100 }; 70 | 71 | #endif //PICTURE_LIST_H_ 72 | -------------------------------------------------------------------------------- /src/inter.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultravideo/uvg266/391a5642814fe9d90dc8b082fbf9827d1e9cf430/src/inter.c -------------------------------------------------------------------------------- /src/ml_classifier_intra_depth_pred.h: -------------------------------------------------------------------------------- 1 | #ifndef ML_CLASSIFIER_INTRA_DEPTH_PRED 2 | #define ML_CLASSIFIER_INTRA_DEPTH_PRED 3 | 4 | /***************************************************************************** 5 | * This file is part of uvg266 VVC encoder. 6 | * 7 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright notice, this 14 | * list of conditions and the following disclaimer. 15 | * 16 | * * Redistributions in binary form must reproduce the above copyright notice, this 17 | * list of conditions and the following disclaimer in the documentation and/or 18 | * other materials provided with the distribution. 19 | * 20 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 21 | * contributors may be used to endorse or promote products derived from 22 | * this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | ****************************************************************************/ 35 | 36 | #include "ml_intra_cu_depth_pred.h" 37 | 38 | 39 | int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 40 | int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 41 | int uvg_tree_predict_merge_depth_3(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 42 | int uvg_tree_predict_merge_depth_4(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 43 | 44 | 45 | int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 46 | int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 47 | int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 48 | int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, double* p_nb_bad); 49 | 50 | #endif -------------------------------------------------------------------------------- /src/nal.h: -------------------------------------------------------------------------------- 1 | #ifndef NAL_H_ 2 | #define NAL_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /* 36 | * \ingroup Bitstream 37 | * \file 38 | * Network Abstraction Layer (NAL) messages. 39 | */ 40 | 41 | #include "bitstream.h" 42 | #include "global.h" // IWYU pragma: keep 43 | #include "uvg266.h" 44 | 45 | 46 | #define SEI_HASH_MAX_LENGTH 16 47 | 48 | ////////////////////////////////////////////////////////////////////////// 49 | // FUNCTIONS 50 | void uvg_nal_write(bitstream_t * const bitstream, const uint8_t nal_type, 51 | const uint8_t temporal_id, const int long_start_code); 52 | void uvg_image_checksum(const uvg_picture *im, 53 | unsigned char checksum_out[][SEI_HASH_MAX_LENGTH], const uint8_t bitdepth); 54 | void uvg_image_md5(const uvg_picture *im, 55 | unsigned char checksum_out[][SEI_HASH_MAX_LENGTH], 56 | const uint8_t bitdepth); 57 | 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/scalinglist.h: -------------------------------------------------------------------------------- 1 | #ifndef SCALINGLIST_H_ 2 | #define SCALINGLIST_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Reconstruction 37 | * \file 38 | * Scaling list initialization. 39 | */ 40 | 41 | #include 42 | 43 | #include "global.h" // IWYU pragma: keep 44 | 45 | 46 | typedef struct { 47 | int8_t enable; 48 | int8_t use_default_list; 49 | int32_t scaling_list_dc [SCALING_LIST_SIZE_NUM][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; 50 | const int32_t *scaling_list_coeff[SCALING_LIST_SIZE_NUM][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; 51 | const int32_t *quant_coeff[SCALING_LIST_SIZE_NUM][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; 52 | const int32_t *de_quant_coeff[SCALING_LIST_SIZE_NUM][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; 53 | const double *error_scale[SCALING_LIST_SIZE_NUM][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; 54 | } scaling_list_t; 55 | 56 | extern const uint8_t uvg_g_scaling_list_num[SCALING_LIST_SIZE_NUM]; 57 | extern const uint16_t uvg_g_scaling_list_size[SCALING_LIST_SIZE_NUM][SCALING_LIST_SIZE_NUM]; 58 | 59 | const int32_t *uvg_scalinglist_get_default(const uint32_t size_id, const uint32_t list_id); 60 | 61 | void uvg_scalinglist_init(scaling_list_t * const scaling_list); 62 | void uvg_scalinglist_destroy(scaling_list_t * const scaling_list); 63 | 64 | int uvg_scalinglist_parse(scaling_list_t * const scaling_list, FILE *fp); 65 | void uvg_scalinglist_process(scaling_list_t * const scaling_list, uint8_t bitdepth); 66 | 67 | 68 | 69 | 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/search_ibc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Compression 37 | * \file 38 | * Inter prediction parameter search. 39 | */ 40 | 41 | #include "cu.h" 42 | #include "encoderstate.h" 43 | #include "global.h" // IWYU pragma: keep 44 | #include "inter.h" 45 | #include "uvg266.h" 46 | 47 | 48 | void uvg_search_cu_ibc(encoder_state_t * const state, 49 | const cu_loc_t * const cu_loc, 50 | lcu_t *lcu, 51 | double *inter_cost, 52 | double* inter_bitcost); 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/search_intra.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCH_INTRA_H_ 2 | #define SEARCH_INTRA_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Compression 37 | * \file 38 | * Intra prediction parameter search. 39 | */ 40 | 41 | #include "cu.h" 42 | #include "encoderstate.h" 43 | #include "global.h" // IWYU pragma: keep 44 | #include "intra.h" 45 | 46 | double uvg_luma_mode_bits(const encoder_state_t *state, const cu_info_t* const cur_cu, const cu_loc_t* 47 | const cu_loc, 48 | const lcu_t* lcu); 49 | 50 | double uvg_chroma_mode_bits(const encoder_state_t *state, 51 | int8_t chroma_mode, int8_t luma_mode); 52 | 53 | int8_t uvg_search_cu_intra_chroma( 54 | encoder_state_t * const state, 55 | const cu_loc_t* const cu_loc, 56 | lcu_t *lcu, 57 | intra_search_data_t* best_cclm, 58 | int8_t luma_mode, 59 | enum uvg_tree_type tree_type, 60 | bool is_separate); 61 | 62 | void uvg_search_cu_intra( 63 | encoder_state_t * const state, 64 | intra_search_data_t* search_data, 65 | lcu_t *lcu, 66 | enum uvg_tree_type tree_type, 67 | const cu_loc_t* const cu_loc); 68 | 69 | #endif // SEARCH_INTRA_H_ 70 | -------------------------------------------------------------------------------- /src/strategies/altivec/picture-altivec.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_PICTURE_ALTIVEC_H_ 2 | #define STRATEGIES_PICTURE_ALTIVEC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for Altivec. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_picture_altivec(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_PICTURE_ALTIVEC_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/avx2/alf-avx2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /***************************************************************************** 3 | * This file is part of uvg266 VVC encoder. 4 | * 5 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 14 | * * Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | ****************************************************************************/ 33 | 34 | /** 35 | * \ingroup Optimization 36 | * \file 37 | * Optimizations for AVX2. 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | #include "uvg266.h" 42 | 43 | int uvg_strategy_register_alf_avx2(void* opaque, uint8_t bitdepth); 44 | 45 | -------------------------------------------------------------------------------- /src/strategies/avx2/dct-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_DCT_AVX2_H_ 2 | #define STRATEGIES_DCT_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for AVX2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | int uvg_strategy_register_dct_avx2(void* opaque, uint8_t bitdepth); 44 | 45 | #endif //STRATEGIES_DCT_AVX2_H_ 46 | -------------------------------------------------------------------------------- /src/strategies/avx2/depquant-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_DEPQUANT_AVX2_H_ 2 | #define STRATEGIES_DEPQUANT_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for AVX2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_depquant_avx2(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_DEPQUANT_AVX2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/avx2/encode_coding_tree-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODE_CODING_TREE_AVX2_H_ 2 | #define ENCODE_CODING_TREE_AVX2_H_ 3 | 4 | /***************************************************************************** 5 | * This file is part of uvg266 VVC encoder. 6 | * 7 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright notice, this 14 | * list of conditions and the following disclaimer. 15 | * 16 | * * Redistributions in binary form must reproduce the above copyright notice, this 17 | * list of conditions and the following disclaimer in the documentation and/or 18 | * other materials provided with the distribution. 19 | * 20 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 21 | * contributors may be used to endorse or promote products derived from 22 | * this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | ****************************************************************************/ 35 | 36 | /** 37 | * \file 38 | * Functions for writing the coding quadtree and related syntax. 39 | */ 40 | 41 | #include "cu.h" 42 | #include "encoderstate.h" 43 | #include "global.h" 44 | 45 | void uvg_encode_coeff_nxn_avx2(encoder_state_t * const state, 46 | cabac_data_t * const cabac, 47 | const coeff_t *coeff, 48 | const cu_loc_t *loc, 49 | uint8_t type, 50 | int8_t scan_mode, 51 | int8_t tr_skip, 52 | double* bits_out); 53 | 54 | int uvg_strategy_register_encode_avx2(void* opaque, uint8_t bitdepth); 55 | 56 | #endif // ENCODE_CODING_TREE_AVX2_H_ 57 | -------------------------------------------------------------------------------- /src/strategies/avx2/intra-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_INTRA_AVX2_H_ 2 | #define STRATEGIES_INTRA_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for AVX2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_intra_avx2(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_INTRA_AVX2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/avx2/ipol-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_IPOL_AVX2_H_ 2 | #define STRATEGIES_IPOL_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for AVX2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_ipol_avx2(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_IPOL_AVX2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/avx2/picture-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_PICTURE_AVX2_H_ 2 | #define STRATEGIES_PICTURE_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for AVX2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_picture_avx2(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_PICTURE_AVX2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/avx2/quant-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_QUANT_AVX2_H_ 2 | #define STRATEGIES_QUANT_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for AVX2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_quant_avx2(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_QUANT_AVX2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/avx2/sao-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_SAO_AVX2_H_ 2 | #define STRATEGIES_SAO_AVX2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * AVX2 implementations of optimized functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_sao_avx2(void* opaque, uint8_t bitdepth); 45 | 46 | #endif //STRATEGIES_SAO_AVX2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/generic/alf-generic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /***************************************************************************** 3 | * This file is part of uvg266 VVC encoder. 4 | * 5 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 14 | * * Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | ****************************************************************************/ 33 | 34 | /** 35 | * \ingroup Optimization 36 | * \file 37 | * Generic C implementations of optimized functions. 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | 42 | int uvg_strategy_register_alf_generic(void* opaque, uint8_t bitdepth); 43 | 44 | -------------------------------------------------------------------------------- /src/strategies/generic/dct-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_DCT_GENERIC_H_ 2 | #define STRATEGIES_DCT_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | extern const int16_t uvg_g_dst_4[4][4]; 44 | extern const int16_t uvg_g_dct_4[4][4]; 45 | extern const int16_t uvg_g_dct_8[8][8]; 46 | extern const int16_t uvg_g_dct_16[16][16]; 47 | extern const int16_t uvg_g_dct_32[32][32]; 48 | 49 | extern const int16_t uvg_g_dst_4_t[4][4]; 50 | extern const int16_t uvg_g_dct_4_t[4][4]; 51 | extern const int16_t uvg_g_dct_8_t[8][8]; 52 | extern const int16_t uvg_g_dct_16_t[16][16]; 53 | extern const int16_t uvg_g_dct_32_t[32][32]; 54 | 55 | int uvg_strategy_register_dct_generic(void* opaque, uint8_t bitdepth); 56 | 57 | #endif //STRATEGIES_DCT_GENERIC_H_ 58 | -------------------------------------------------------------------------------- /src/strategies/generic/depquant-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_DEPQUANT_GENERIC_H_ 2 | #define STRATEGIES_DEPQUANT_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "cu.h" 42 | #include "encoderstate.h" 43 | #include "global.h" // IWYU pragma: keep 44 | #include "uvg266.h" 45 | #include "tables.h" 46 | 47 | 48 | int uvg_strategy_register_depquant_generic(void* opaque, uint8_t bitdepth); 49 | 50 | #endif //STRATEGIES_DEPQUANT_GENERIC_H_ 51 | -------------------------------------------------------------------------------- /src/strategies/generic/encode_coding_tree-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODE_CODING_TREE_GENERIC_H_ 2 | #define ENCODE_CODING_TREE_GENERIC_H_ 3 | 4 | /***************************************************************************** 5 | * This file is part of uvg266 VVC encoder. 6 | * 7 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright notice, this 14 | * list of conditions and the following disclaimer. 15 | * 16 | * * Redistributions in binary form must reproduce the above copyright notice, this 17 | * list of conditions and the following disclaimer in the documentation and/or 18 | * other materials provided with the distribution. 19 | * 20 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 21 | * contributors may be used to endorse or promote products derived from 22 | * this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | ****************************************************************************/ 35 | 36 | /** 37 | * \file 38 | * Functions for writing the coding quadtree and related syntax. 39 | */ 40 | 41 | #include "encoderstate.h" 42 | #include "global.h" 43 | 44 | void uvg_encode_coeff_nxn_generic(encoder_state_t * const state, 45 | cabac_data_t * const cabac, 46 | const coeff_t *coeff, 47 | const cu_loc_t * const loc, 48 | uint8_t color, 49 | int8_t scan_mode, 50 | cu_info_t* cur_cu, 51 | double* bits_out); 52 | 53 | int uvg_strategy_register_encode_generic(void* opaque, uint8_t bitdepth); 54 | 55 | #endif // ENCODE_CODING_TREE_GENERIC_H_ 56 | -------------------------------------------------------------------------------- /src/strategies/generic/intra-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_INTRA_GENERIC_H_ 2 | #define STRATEGIES_INTRA_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | int uvg_strategy_register_intra_generic(void* opaque, uint8_t bitdepth); 44 | 45 | #endif //STRATEGIES_INTRA_GENERIC_H_ 46 | -------------------------------------------------------------------------------- /src/strategies/generic/ipol-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_IPOL_GENERIC_H_ 2 | #define STRATEGIES_IPOL_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "encoder.h" 42 | #include "global.h" // IWYU pragma: keep 43 | #include "uvg266.h" 44 | 45 | int uvg_strategy_register_ipol_generic(void* opaque, uint8_t bitdepth); 46 | void uvg_sample_quarterpel_luma_generic(const encoder_control_t * const encoder, uvg_pixel *src, int16_t src_stride, int width, int height, uvg_pixel *dst, int16_t dst_stride, int8_t hor_flag, int8_t ver_flag, const mv_t mv[2]); 47 | void uvg_sample_quarterpel_luma_hi_generic(const encoder_control_t * const encoder, uvg_pixel *src, int16_t src_stride, int width, int height, int16_t *dst, int16_t dst_stride, int8_t hor_flag, int8_t ver_flag, const mv_t mv[2]); 48 | void uvg_sample_octpel_chroma_generic(const encoder_control_t * const encoder, uvg_pixel *src, int16_t src_stride, int width, int height, uvg_pixel *dst, int16_t dst_stride, int8_t hor_flag, int8_t ver_flag, const mv_t mv[2]); 49 | void uvg_sample_octpel_chroma_hi_generic(const encoder_control_t * const encoder, uvg_pixel *src, int16_t src_stride, int width, int height, int16_t *dst, int16_t dst_stride, int8_t hor_flag, int8_t ver_flag, const mv_t mv[2]); 50 | 51 | 52 | #endif //STRATEGIES_IPOL_GENERIC_H_ 53 | -------------------------------------------------------------------------------- /src/strategies/generic/nal-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_NAL_GENERIC_H_ 2 | #define STRATEGIES_NAL_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | int uvg_strategy_register_nal_generic(void* opaque, uint8_t bitdepth); 44 | 45 | #endif //STRATEGIES_NAL_GENERIC_H_ 46 | -------------------------------------------------------------------------------- /src/strategies/generic/picture-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_PICTURE_GENERIC_H_ 2 | #define STRATEGIES_PICTURE_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | #include "uvg266.h" 43 | 44 | int uvg_strategy_register_picture_generic(void* opaque, uint8_t bitdepth); 45 | 46 | // Function to clip int16_t to pixel. (0-255 or 0-1023) 47 | // Assumes PIXEL_MAX to be 2^n-1 48 | uvg_pixel uvg_fast_clip_16bit_to_pixel(int16_t value); 49 | 50 | // Function to clip int32_t to pixel. (0-255 or 0-1023) 51 | // Assumes PIXEL_MAX to be 2^n-1 52 | uvg_pixel uvg_fast_clip_32bit_to_pixel(int32_t value); 53 | 54 | unsigned uvg_satd_4x4_subblock_generic(const uvg_pixel * buf1, 55 | const int32_t stride1, 56 | const uvg_pixel * buf2, 57 | const int32_t stride2); 58 | 59 | void uvg_satd_4x4_subblock_quad_generic(const uvg_pixel *preds[4], 60 | const int stride, 61 | const uvg_pixel *orig, 62 | const int orig_stride, 63 | unsigned costs[4]); 64 | 65 | 66 | 67 | #endif //STRATEGIES_PICTURE_GENERIC_H_ 68 | -------------------------------------------------------------------------------- /src/strategies/generic/sao-generic.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_SAO_GENERIC_H_ 2 | #define STRATEGIES_SAO_GENERIC_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Generic C implementations of optimized functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | int uvg_strategy_register_sao_generic(void* opaque, uint8_t bitdepth); 44 | 45 | #endif //STRATEGIES_SAO_GENERIC_H_ 46 | -------------------------------------------------------------------------------- /src/strategies/missing-intel-intrinsics.h: -------------------------------------------------------------------------------- 1 | #ifndef MISSING_INTEL_INTRINSICS_H_ 2 | #define MISSING_INTEL_INTRINSICS_H_ 3 | 4 | #include 5 | 6 | // Old Visual Studio headers lack the bsrli variant 7 | #ifndef _mm_bsrli_si128 8 | #define _mm_bsrli_si128(a, imm8) _mm_srli_si128((a), (imm8)) 9 | #endif 10 | 11 | // GCC headers apparently won't have this at all.. sigh 12 | #ifndef _andn_u32 13 | // VS2015 headers apparently won't have this at all.. sigh 14 | #ifdef __andn_u32 15 | #define _andn_u32(x, y) (__andn_u32((x), (y))) 16 | #else 17 | #define _andn_u32(x, y) ((~(x)) & (y)) 18 | #endif // __andn_u32 19 | #endif // _andn_u32 20 | 21 | // Some Visual Studio headers apparently lack these pseudoinstructions 22 | #if COMPILE_INTEL_AVX2 23 | #ifndef _mm256_bsrli_epi128 24 | #define _mm256_bsrli_epi128(a, imm8) _mm256_srli_si256((a), (imm8)) 25 | #endif 26 | #ifndef _mm256_insert_epi32 27 | #define _mm256_insert_epi32(a, i, index) (_mm256_blend_epi32((a), _mm256_set1_epi32(i), (1 << (index)))) 28 | #endif 29 | 30 | #ifndef _mm256_extract_epi32 31 | #define _mm256_extract_epi32(a, index) (_mm_extract_epi32(_mm256_extracti128_si256((a), (index) >> 2), (index) & 3)) 32 | #endif 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/strategies/optimized_sad_func_ptr_t.h: -------------------------------------------------------------------------------- 1 | #ifndef OPTIMIZED_SAD_FUNC_T_H_ 2 | #define OPTIMIZED_SAD_FUNC_T_H_ 3 | 4 | #include "uvg266.h" 5 | 6 | /** 7 | * \param data1: Picture block pointer 8 | * \param data2: Reference block pointer 9 | * \param height: Scan block height 10 | * \param stride1: Picture block stride 11 | * \param stride2: Reference block stride 12 | */ 13 | typedef uint32_t (*optimized_sad_func_ptr_t)(const uvg_pixel * const, 14 | const uvg_pixel * const, 15 | const int32_t, 16 | const uint32_t, 17 | const uint32_t); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/strategies/sse2/picture-sse2.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_PICTURE_SSE2_H_ 2 | #define STRATEGIES_PICTURE_SSE2_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for SSE2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | 44 | int uvg_strategy_register_picture_sse2(void* opaque, unsigned char bitdepth); 45 | 46 | #endif //STRATEGIES_PICTURE_SSE2_H_ 47 | -------------------------------------------------------------------------------- /src/strategies/sse41/alf-sse41.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /***************************************************************************** 3 | * This file is part of uvg266 VVC encoder. 4 | * 5 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 14 | * * Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | ****************************************************************************/ 33 | 34 | /** 35 | * \ingroup Optimization 36 | * \file 37 | * Optimizations for SSE4.1. 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | #include "uvg266.h" 42 | 43 | int uvg_strategy_register_alf_sse41(void* opaque, uint8_t bitdepth); 44 | 45 | -------------------------------------------------------------------------------- /src/strategies/sse41/picture-sse41.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_PICTURE_SSE41_H_ 2 | #define STRATEGIES_PICTURE_SSE41_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for SSE4.1. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | #include "uvg266.h" 43 | 44 | unsigned uvg_reg_sad_sse41(const uvg_pixel * const data1, const uvg_pixel * const data2, 45 | const int width, const int height, const unsigned stride1, const unsigned stride2); 46 | 47 | int uvg_strategy_register_picture_sse41(void* opaque, uint8_t bitdepth); 48 | 49 | #endif //STRATEGIES_PICTURE_SSE41_H_ 50 | -------------------------------------------------------------------------------- /src/strategies/sse42/picture-sse42.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2022, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Optimizations for SSE4.2. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | #include "uvg266.h" 43 | 44 | 45 | int uvg_strategy_register_picture_sse42(void* opaque, uint8_t bitdepth); 46 | -------------------------------------------------------------------------------- /src/strategies/strategies-alf.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-alf.h" 34 | #include "strategies/sse41/alf-sse41.h" 35 | #include "strategies/avx2/alf-avx2.h" 36 | #include "strategies/generic/alf-generic.h" 37 | #include "strategyselector.h" 38 | 39 | 40 | // Define function pointers. 41 | alf_derive_classification_blk_func* uvg_alf_derive_classification_blk; 42 | alf_filter_5x5_blk_func* uvg_alf_filter_5x5_blk; 43 | alf_filter_7x7_blk_func* uvg_alf_filter_7x7_blk; 44 | alf_get_blk_stats_func* uvg_alf_get_blk_stats; 45 | 46 | int uvg_strategy_register_alf(void* opaque, uint8_t bitdepth) { 47 | bool success = true; 48 | 49 | success &= uvg_strategy_register_alf_generic(opaque, bitdepth); 50 | 51 | if (uvg_g_hardware_flags.intel_flags.sse41) { 52 | success &= uvg_strategy_register_alf_sse41(opaque, bitdepth); 53 | } 54 | if (uvg_g_hardware_flags.intel_flags.avx2) { 55 | success &= uvg_strategy_register_alf_avx2(opaque, bitdepth); 56 | } 57 | 58 | return success; 59 | } -------------------------------------------------------------------------------- /src/strategies/strategies-common.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_COMMON_H_ 2 | #define STRATEGIES_COMMON_H_ 3 | 4 | /** 5 | * \ingroup Optimization 6 | * \file 7 | * Common tools strategies. 8 | */ 9 | 10 | #include "global.h" // IWYU pragma: keep 11 | 12 | 13 | #endif //STRATEGIES_COMMON_H_ 14 | -------------------------------------------------------------------------------- /src/strategies/strategies-depquant.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-depquant.h" 34 | 35 | #include "strategies/avx2/depquant-avx2.h" 36 | #include "strategies/generic/depquant-generic.h" 37 | #include "strategyselector.h" 38 | 39 | 40 | // Define function pointers. 41 | dep_quant_decide_and_update_func* uvg_dep_quant_decide_and_update; 42 | find_first_non_zero_coeff_func* uvg_find_first_non_zero_coeff; 43 | 44 | 45 | int uvg_strategy_register_depquant(void *opaque, uint8_t bitdepth) 46 | { 47 | bool success = true; 48 | 49 | success &= uvg_strategy_register_depquant_generic(opaque, bitdepth); 50 | 51 | if (uvg_g_hardware_flags.intel_flags.avx2) { 52 | success &= uvg_strategy_register_depquant_avx2(opaque, bitdepth); 53 | } 54 | return success; 55 | } 56 | -------------------------------------------------------------------------------- /src/strategies/strategies-encode.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-encode.h" 34 | 35 | #include "strategies/avx2/encode_coding_tree-avx2.h" 36 | #include "strategies/generic/encode_coding_tree-generic.h" 37 | #include "strategyselector.h" 38 | 39 | 40 | // Define function pointers. 41 | encode_coeff_nxn_func *uvg_encode_coeff_nxn; 42 | 43 | 44 | int uvg_strategy_register_encode(void* opaque, uint8_t bitdepth) { 45 | bool success = true; 46 | 47 | success &= uvg_strategy_register_encode_generic(opaque, bitdepth); 48 | 49 | if (uvg_g_hardware_flags.intel_flags.avx2) { 50 | //success &= uvg_strategy_register_encode_avx2(opaque, bitdepth); 51 | } 52 | return success; 53 | } 54 | -------------------------------------------------------------------------------- /src/strategies/strategies-encode.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_ENCODE_H_ 2 | #define STRATEGIES_ENCODE_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Interface for quantization functions. 39 | */ 40 | 41 | #include "cu.h" 42 | #include "encoderstate.h" 43 | #include "global.h" // IWYU pragma: keep 44 | #include "uvg266.h" 45 | #include "tables.h" 46 | 47 | 48 | // Declare function pointers. 49 | typedef unsigned (encode_coeff_nxn_func)(encoder_state_t * const state, 50 | cabac_data_t * const cabac, 51 | const coeff_t *coeff, 52 | const cu_loc_t * const loc, 53 | uint8_t color, 54 | int8_t scan_mode, 55 | cu_info_t* cur_cu, 56 | double *bits_out); 57 | 58 | // Declare function pointers. 59 | extern encode_coeff_nxn_func *uvg_encode_coeff_nxn; 60 | 61 | int uvg_strategy_register_encode(void* opaque, uint8_t bitdepth); 62 | 63 | 64 | #define STRATEGIES_ENCODE_EXPORTS \ 65 | {"encode_coeff_nxn", (void**) &uvg_encode_coeff_nxn}, \ 66 | 67 | 68 | 69 | #endif //STRATEGIES_ENCODE_H_ 70 | -------------------------------------------------------------------------------- /src/strategies/strategies-intra.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-intra.h" 34 | 35 | #include "strategies/avx2/intra-avx2.h" 36 | #include "strategies/generic/intra-generic.h" 37 | #include "strategyselector.h" 38 | 39 | 40 | // Define function pointers. 41 | angular_pred_func *uvg_angular_pred; 42 | intra_pred_planar_func *uvg_intra_pred_planar; 43 | intra_pred_filtered_dc_func *uvg_intra_pred_filtered_dc; 44 | pdpc_planar_dc_func *uvg_pdpc_planar_dc; 45 | mip_pred_func *uvg_mip_predict; 46 | 47 | int uvg_strategy_register_intra(void* opaque, uint8_t bitdepth) { 48 | bool success = true; 49 | 50 | success &= uvg_strategy_register_intra_generic(opaque, bitdepth); 51 | 52 | if (uvg_g_hardware_flags.intel_flags.avx2) { 53 | success &= uvg_strategy_register_intra_avx2(opaque, bitdepth); 54 | } 55 | 56 | return success; 57 | } 58 | -------------------------------------------------------------------------------- /src/strategies/strategies-ipol.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-ipol.h" 34 | 35 | #include "strategies/avx2/ipol-avx2.h" 36 | #include "strategies/generic/ipol-generic.h" 37 | #include "strategyselector.h" 38 | 39 | 40 | // Define function pointers. 41 | ipol_blocks_func * uvg_filter_hpel_blocks_hor_ver_luma; 42 | ipol_blocks_func * uvg_filter_hpel_blocks_diag_luma; 43 | ipol_blocks_func * uvg_filter_qpel_blocks_hor_ver_luma; 44 | ipol_blocks_func * uvg_filter_qpel_blocks_diag_luma; 45 | epol_func *uvg_get_extended_block; 46 | epol_func *uvg_get_extended_block_wraparound; 47 | uvg_sample_quarterpel_luma_func * uvg_sample_quarterpel_luma; 48 | uvg_sample_octpel_chroma_func * uvg_sample_octpel_chroma; 49 | uvg_sample_quarterpel_luma_hi_func * uvg_sample_quarterpel_luma_hi; 50 | uvg_sample_octpel_chroma_hi_func * uvg_sample_octpel_chroma_hi; 51 | 52 | 53 | int uvg_strategy_register_ipol(void* opaque, uint8_t bitdepth) { 54 | bool success = true; 55 | 56 | success &= uvg_strategy_register_ipol_generic(opaque, bitdepth); 57 | 58 | if (uvg_g_hardware_flags.intel_flags.avx2) { 59 | success &= uvg_strategy_register_ipol_avx2(opaque, bitdepth); 60 | } 61 | return success; 62 | } 63 | -------------------------------------------------------------------------------- /src/strategies/strategies-nal.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-nal.h" 34 | 35 | #include "strategies/generic/nal-generic.h" 36 | 37 | 38 | void (*uvg_array_checksum)(const uvg_pixel* data, 39 | const int height, const int width, 40 | const int stride, 41 | unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth); 42 | void (*uvg_array_md5)(const uvg_pixel* data, 43 | const int height, const int width, 44 | const int stride, 45 | unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth); 46 | 47 | 48 | int uvg_strategy_register_nal(void* opaque, uint8_t bitdepth) { 49 | bool success = true; 50 | 51 | success &= uvg_strategy_register_nal_generic(opaque, bitdepth); 52 | 53 | return success; 54 | } 55 | -------------------------------------------------------------------------------- /src/strategies/strategies-nal.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGIES_NAL_H_ 2 | #define STRATEGIES_NAL_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Optimization 37 | * \file 38 | * Interface for hash functions. 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | #include "uvg266.h" 43 | #include "nal.h" 44 | 45 | 46 | //Function pointer to uvg_array_checksum 47 | /** 48 | * \brief Calculate checksum for one color of the picture. 49 | * \param data Beginning of the pixel data for the picture. 50 | * \param height Height of the picture. 51 | * \param width Width of the picture. 52 | * \param stride Width of one row in the pixel array. 53 | */ 54 | typedef void (*array_checksum_func)(const uvg_pixel* data, 55 | const int height, const int width, 56 | const int stride, 57 | unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth); 58 | extern array_checksum_func uvg_array_checksum; 59 | extern array_checksum_func uvg_array_md5; 60 | 61 | 62 | int uvg_strategy_register_nal(void* opaque, uint8_t bitdepth); 63 | 64 | 65 | #define STRATEGIES_NAL_EXPORTS \ 66 | {"array_checksum", (void**) &uvg_array_checksum},\ 67 | {"array_md5", (void**) &uvg_array_md5}, 68 | 69 | #endif //STRATEGIES_NAL_H_ 70 | -------------------------------------------------------------------------------- /src/strategies/strategies-quant.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-quant.h" 34 | 35 | #include "strategies/avx2/quant-avx2.h" 36 | #include "strategies/generic/quant-generic.h" 37 | #include "strategyselector.h" 38 | 39 | 40 | // Define function pointers. 41 | quant_func *uvg_quant; 42 | quant_cbcr_func *uvg_quant_cbcr_residual; 43 | quant_residual_func *uvg_quantize_residual; 44 | dequant_func *uvg_dequant; 45 | coeff_abs_sum_func *uvg_coeff_abs_sum; 46 | fast_coeff_cost_func *uvg_fast_coeff_cost; 47 | 48 | 49 | int uvg_strategy_register_quant(void *opaque, uint8_t bitdepth) 50 | { 51 | bool success = true; 52 | 53 | success &= uvg_strategy_register_quant_generic(opaque, bitdepth); 54 | 55 | if (uvg_g_hardware_flags.intel_flags.avx2) { 56 | success &= uvg_strategy_register_quant_avx2(opaque, bitdepth); 57 | } 58 | return success; 59 | } 60 | -------------------------------------------------------------------------------- /src/strategies/strategies-sao.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "strategies/strategies-sao.h" 34 | #include "strategies/avx2/sao-avx2.h" 35 | #include "strategies/generic/sao-generic.h" 36 | #include "strategyselector.h" 37 | 38 | 39 | // Define function pointers. 40 | sao_edge_ddistortion_func * uvg_sao_edge_ddistortion; 41 | calc_sao_edge_dir_func * uvg_calc_sao_edge_dir; 42 | sao_reconstruct_color_func * uvg_sao_reconstruct_color; 43 | sao_band_ddistortion_func * uvg_sao_band_ddistortion; 44 | 45 | 46 | int uvg_strategy_register_sao(void* opaque, uint8_t bitdepth) { 47 | bool success = true; 48 | 49 | success &= uvg_strategy_register_sao_generic(opaque, bitdepth); 50 | 51 | if (uvg_g_hardware_flags.intel_flags.avx2) { 52 | success &= uvg_strategy_register_sao_avx2(opaque, bitdepth); 53 | } 54 | 55 | return success; 56 | } -------------------------------------------------------------------------------- /src/threadqueue.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | #pragma once 33 | 34 | /** 35 | * \ingroup Threading 36 | * \file 37 | * Container for worker tasks. 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | 42 | #include 43 | 44 | typedef struct threadqueue_job_t threadqueue_job_t; 45 | typedef struct threadqueue_queue_t threadqueue_queue_t; 46 | 47 | threadqueue_queue_t * uvg_threadqueue_init(int thread_count); 48 | 49 | threadqueue_job_t * uvg_threadqueue_job_create(void (*fptr)(void *arg), void *arg); 50 | int uvg_threadqueue_submit(threadqueue_queue_t *const threadqueue, threadqueue_job_t *job); 51 | 52 | int uvg_threadqueue_job_dep_add(threadqueue_job_t *job, threadqueue_job_t *dependency); 53 | 54 | threadqueue_job_t *uvg_threadqueue_copy_ref(threadqueue_job_t *job); 55 | 56 | void uvg_threadqueue_free_job(threadqueue_job_t **job_ptr); 57 | 58 | int uvg_threadqueue_waitfor(threadqueue_queue_t * threadqueue, threadqueue_job_t * job); 59 | int uvg_threadqueue_stop(threadqueue_queue_t *const threadqueue); 60 | void uvg_threadqueue_free(threadqueue_queue_t * threadqueue); 61 | -------------------------------------------------------------------------------- /src/threadwrapper/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Tampere University 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /src/threadwrapper/README.md: -------------------------------------------------------------------------------- 1 | ThreadWrapper 2 | ======= 3 | Wraps pthread functions so that they actually call C++ standard functions. 4 | 5 | Only functions used by Kvazaar, an open-source HEVC encoder, are implemented. 6 | People are free to contribute if they implement other functions. 7 | -------------------------------------------------------------------------------- /src/threadwrapper/include/pthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Tampere University 3 | 4 | Permission to use, copy, modify, and/or distribute this software for 5 | any purpose with or without fee is hereby granted, provided that the 6 | above copyright notice and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #pragma once 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef void* pthread_cond_t; 24 | typedef void* pthread_cond_t; 25 | typedef void* pthread_mutex_t; 26 | typedef void* pthread_rwlock_t; 27 | typedef void* pthread_t; 28 | typedef void*(voidp_voidp_func)(void*); 29 | 30 | typedef void pthread_attr_t; 31 | typedef void pthread_condattr_t; 32 | typedef void pthread_mutexattr_t; 33 | typedef void pthread_rwlockattr_t; 34 | 35 | // Parameter names that have been commented away do nothing, 36 | // as they are always null when the functions are used in Kvazaar. 37 | 38 | int pthread_cond_broadcast(pthread_cond_t* cond); 39 | int pthread_cond_destroy(pthread_cond_t* cond); 40 | int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* /*attr*/); 41 | int pthread_cond_signal(pthread_cond_t* cond); 42 | int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex); 43 | 44 | int pthread_create(pthread_t* thread, const pthread_attr_t* /*attr*/, voidp_voidp_func executee, void* arg); 45 | void pthread_exit(void* /*value_ptr*/); 46 | int pthread_join(pthread_t thread, void** /*value_ptr*/); 47 | 48 | int pthread_mutex_destroy(pthread_mutex_t* mutex); 49 | int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* /*attr*/); 50 | int pthread_mutex_lock(pthread_mutex_t* mutex); 51 | int pthread_mutex_unlock(pthread_mutex_t* mutex); 52 | 53 | int pthread_rwlock_init(pthread_rwlock_t* lock, const pthread_rwlockattr_t * /*attr*/); 54 | int pthread_rwlock_destroy(pthread_rwlock_t *rwlock); 55 | int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); 56 | int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock); 57 | int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /src/threadwrapper/include/semaphore.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Tampere University 3 | 4 | Permission to use, copy, modify, and/or distribute this software for 5 | any purpose with or without fee is hereby granted, provided that the 6 | above copyright notice and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #pragma once 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef void* sem_t; 24 | 25 | int sem_destroy(sem_t* sem); 26 | // pshared is always 0 in Kvazaar on w32. 27 | int sem_init(sem_t* sem, int /*pshared*/, unsigned int value); 28 | int sem_post(sem_t* sem); 29 | int sem_wait(sem_t* sem); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /src/threadwrapper/src/semaphore.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Tampere University 3 | 4 | Permission to use, copy, modify, and/or distribute this software for 5 | any purpose with or without fee is hereby granted, provided that the 6 | above copyright notice and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include "semaphore.h" 18 | #include 19 | #include 20 | 21 | 22 | class Semaphore { 23 | public: 24 | 25 | Semaphore(int value): 26 | val_(value) { 27 | } 28 | 29 | void post() { 30 | std::unique_lock lck(mtx_); 31 | if (++val_ <= 0) { 32 | cvar_.notify_one(); 33 | } 34 | } 35 | 36 | void wait() { 37 | std::unique_lock lck(mtx_); 38 | if (--val_ < 0) { 39 | cvar_.wait(lck); 40 | } 41 | } 42 | 43 | 44 | private: 45 | 46 | int val_; 47 | std::condition_variable cvar_; 48 | std::mutex mtx_; 49 | 50 | }; // class Semaphore 51 | 52 | 53 | int sem_destroy(sem_t* sem) { 54 | delete static_cast(*sem); 55 | *sem = nullptr; 56 | return 0; 57 | } 58 | 59 | int sem_init(sem_t* sem, int, unsigned int value) { 60 | *sem = new Semaphore(value); 61 | return 0; 62 | } 63 | 64 | int sem_post(sem_t* sem) { 65 | static_cast(*sem)->post(); 66 | return 0; 67 | } 68 | 69 | int sem_wait(sem_t* sem) { 70 | static_cast(*sem)->wait(); 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /src/uvg266.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/lib 4 | incdir=${prefix}/include 5 | 6 | Name: libuvg266 7 | Description: @CMAKE_PROJECT_DESCRIPTION@ 8 | URL: @CMAKE_PROJECT_HOMEPAGE_URL@ 9 | Version: @PROJECT_VERSION@ 10 | Libs: -L${libdir} -luvg266 11 | Libs.private: @LIBS@ 12 | Cflags: -I${incdir} 13 | -------------------------------------------------------------------------------- /src/uvg266_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef UVG266_INTERNAL_H_ 2 | #define UVG266_INTERNAL_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \ingroup Control 37 | * \file 38 | * \brief Definitions for opaque structs in uvg266.h 39 | */ 40 | 41 | #include "global.h" // IWYU pragma: keep 42 | 43 | #include "uvg266.h" 44 | #include "input_frame_buffer.h" 45 | 46 | 47 | // Forward declarations. 48 | struct encoder_state_t; 49 | struct encoder_control_t; 50 | 51 | struct uvg_encoder { 52 | const struct encoder_control_t* control; 53 | struct encoder_state_t* states; 54 | unsigned num_encoder_states; 55 | 56 | /** 57 | * \brief Number of the current encoder state. 58 | * 59 | * The current state is the one that will be used for encoding the frame 60 | * that is started next. 61 | */ 62 | unsigned cur_state_num; 63 | 64 | /** 65 | * \brief Number of the next encoder state to be finished. 66 | */ 67 | unsigned out_state_num; 68 | 69 | /** 70 | * \brief Buffer for input frames. 71 | */ 72 | input_frame_buffer_t input_buffer; 73 | 74 | unsigned frames_started; 75 | unsigned frames_done; 76 | }; 77 | 78 | #endif // UVG266_INTERNAL_H_ 79 | -------------------------------------------------------------------------------- /src/uvg_math.h: -------------------------------------------------------------------------------- 1 | #ifndef MATH_H_ 2 | #define MATH_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | /** 36 | * \file 37 | * Generic math functions 38 | */ 39 | 40 | #include "global.h" // IWYU pragma: keep 41 | 42 | 43 | static INLINE unsigned uvg_math_floor_log2(unsigned value) 44 | { 45 | assert(value > 0); 46 | 47 | unsigned result = 0; 48 | 49 | for (int i = 4; i >= 0; --i) { 50 | unsigned bits = 1ull << i; 51 | unsigned shift = (int32_t)value >= (1 << bits) ? bits : 0; 52 | result += shift; 53 | value >>= shift; 54 | } 55 | 56 | return result; 57 | } 58 | 59 | static INLINE unsigned uvg_math_ceil_log2(unsigned value) 60 | { 61 | assert(value > 0); 62 | 63 | // The ceil_log2 is just floor_log2 + 1, except for exact powers of 2. 64 | return uvg_math_floor_log2(value) + ((value & (value - 1)) ? 1 : 0); 65 | } 66 | 67 | #endif //CHECKPOINT_H_ 68 | -------------------------------------------------------------------------------- /src/version.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /***************************************************************************** 3 | * This file is part of uvg266 VVC encoder. 4 | * 5 | * Copyright (c) 2022, Tampere University, ITU/ISO/IEC, project contributors 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 14 | * * Redistributions in binary form must reproduce the above copyright notice, this 15 | * list of conditions and the following disclaimer in the documentation and/or 16 | * other materials provided with the distribution. 17 | * 18 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | ****************************************************************************/ 33 | 34 | #ifndef UVG_VERSION 35 | #define UVG_VERSION @PROJECT_VERSION@ 36 | #endif 37 | #define UVG_COMPILER_STRING "@UVG_COMPILER_STRING@" 38 | #define UVG_COMPILE_DATE "@CMAKE_BUILD_DATE@" 39 | #define VERSION_STRING QUOTE_EXPAND(UVG_VERSION) 40 | -------------------------------------------------------------------------------- /src/yuv_io.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #ifndef YUV_IO_H_ 34 | #define YUV_IO_H_ 35 | 36 | /* 37 | * \file 38 | * \brief Functions related to reading YUV input and output. 39 | */ 40 | 41 | #include 42 | 43 | #include "global.h" // IWYU pragma: keep 44 | #include "uvg266.h" 45 | 46 | int yuv_io_read(FILE* file, 47 | unsigned input_width, unsigned input_height, 48 | unsigned from_bitdepth, unsigned to_bitdepth, 49 | uvg_picture *img_out, unsigned file_format); 50 | 51 | int yuv_io_seek(FILE* file, unsigned frames, 52 | unsigned input_width, unsigned input_height, 53 | unsigned in_bitdepth, unsigned file_format); 54 | 55 | int yuv_io_write(FILE* file, 56 | const uvg_picture *img, 57 | unsigned output_width, unsigned output_height); 58 | 59 | #endif // YUV_IO_H_ 60 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file( GLOB TEST_SOURCES "*.c" ) 2 | 3 | # ToDo: fix the tests 4 | list(REMOVE_ITEM TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/inter_recon_bipred_tests.c") 5 | 6 | add_executable(uvg266_tests ${TEST_SOURCES} ) 7 | 8 | target_include_directories(uvg266_tests PUBLIC ${PROJECT_SOURCE_DIR}) 9 | target_include_directories(uvg266_tests PUBLIC ${PROJECT_SOURCE_DIR}/src) 10 | target_include_directories(uvg266_tests PUBLIC ${PROJECT_SOURCE_DIR}/src/extras) 11 | 12 | add_definitions(-DUVG_DLL_EXPORTS) 13 | 14 | if(BUILD_SHARED_LIBS) 15 | add_definitions(-DPIC) 16 | endif() 17 | 18 | if(MSVC) 19 | target_include_directories(uvg266_tests PUBLIC ../src/threadwrapper/include) 20 | 21 | set_property( SOURCE ${TEST_SOURCES} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" ) 22 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32 -DWIN32 -DWIN64) 23 | else() 24 | list(APPEND ALLOW_AVX2 "x86_64" "AMD64") 25 | if(${CMAKE_SYSTEM_PROCESSOR} IN_LIST ALLOW_AVX2) 26 | set_property( SOURCE ${TEST_SOURCES} APPEND PROPERTY COMPILE_FLAGS "-mavx2 -mbmi -mpopcnt -mlzcnt -mbmi2" ) 27 | endif() 28 | find_package(Threads REQUIRED) 29 | target_link_libraries(uvg266_tests PUBLIC Threads::Threads) 30 | 31 | include(CheckLibraryExists) 32 | 33 | CHECK_LIBRARY_EXISTS(m sin "" HAVE_LIB_M) 34 | 35 | if (HAVE_LIB_M) 36 | set(EXTRA_LIBS ${EXTRA_LIBS} m) 37 | endif (HAVE_LIB_M) 38 | 39 | target_link_libraries(uvg266_tests PUBLIC ${EXTRA_LIBS}) 40 | endif() 41 | 42 | target_link_libraries(uvg266_tests PUBLIC uvg266) 43 | 44 | -------------------------------------------------------------------------------- /tests/coeff_sum_tests.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "greatest/greatest.h" 34 | 35 | #include "test_strategies.h" 36 | 37 | #include 38 | 39 | static coeff_t coeff_test_data[64 * 64]; 40 | static uint32_t expected_test_result; 41 | 42 | static void setup() 43 | { 44 | // Fill test data. 45 | coeff_t value = INT16_MIN; 46 | for (int i = 0; i < 64 * 64; i++) { 47 | coeff_test_data[i] = value; 48 | value += 16; 49 | } 50 | 51 | // Calculate expected result using the formula for an arithmetic sum. 52 | expected_test_result = 53 | 2048 * (16 - INT16_MIN) / 2 + 54 | 2048 * 2047 * 16 / 2; 55 | } 56 | 57 | TEST test_coeff_abs_sum() 58 | { 59 | uint32_t sum = uvg_coeff_abs_sum(coeff_test_data, 64 * 64); 60 | ASSERT_EQ(sum, expected_test_result); 61 | PASS(); 62 | } 63 | 64 | SUITE(coeff_sum_tests) 65 | { 66 | setup(); 67 | 68 | for (volatile int i = 0; i < strategies.count; ++i) { 69 | if (strcmp(strategies.strategies[i].type, "coeff_abs_sum") != 0) { 70 | continue; 71 | } 72 | 73 | uvg_coeff_abs_sum = strategies.strategies[i].fptr; 74 | RUN_TEST(test_coeff_abs_sum); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /tests/sad_tests.h: -------------------------------------------------------------------------------- 1 | #ifndef SAD_TESTS_H_ 2 | #define SAD_TESTS_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | void sad_tests(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tests/satd_tests.h: -------------------------------------------------------------------------------- 1 | #ifndef SATD_TESTS_H_ 2 | #define SATD_TESTS_H_ 3 | /***************************************************************************** 4 | * This file is part of uvg266 VVC encoder. 5 | * 6 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright notice, this 16 | * list of conditions and the following disclaimer in the documentation and/or 17 | * other materials provided with the distribution. 18 | * 19 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 20 | * contributors may be used to endorse or promote products derived from 21 | * this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | ****************************************************************************/ 34 | 35 | void satd_tests(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tests/test_cabac_state.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | . "${0%/*}/util.sh" 6 | 7 | cabacfile="$(mktemp)" 8 | 9 | valgrind_test 256x128 10 yuv420p --no-cpuid --preset veryslow --pu-depth-intra 0-8 --mtt-depth-intra 3 --mtt-depth-intra-chroma 3 --cclm --rd 3 --mip --jccr --mrl --lfnst -p 1 --owf 0 --no-wpp --cabac-debug-file="${cabacfile}" 10 | python3 check_cabac_state_consistency.py "${cabacfile}" 11 | 12 | valgrind_test 256x128 10 yuv420p --no-cpuid --preset veryslow --pu-depth-intra 0-8 --mtt-depth-intra 3 --mtt-depth-intra-chroma 3 --cclm --rd 3 --mip --jccr --mrl --lfnst --dual-tree -p 1 --owf 0 --no-wpp --cabac-debug-file="${cabacfile}" 13 | python3 check_cabac_state_consistency.py "${cabacfile}" 14 | 15 | rm -rf "${cabacfile}" 16 | 17 | -------------------------------------------------------------------------------- /tests/test_external_symbols.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Check for external symbols without uvg_ prefix (or _uvg_ on macOS). 4 | 5 | set -eu${BASH+o pipefail} 6 | 7 | if nm -go --defined-only ../lib/libuvg266.a | grep -v ' uvg_' | grep -v ' _uvg_'; then 8 | printf '%s\n' 'Only symbols prefixed with "uvg_" should be exported from libuvg266.' 9 | false 10 | fi 11 | -------------------------------------------------------------------------------- /tests/test_intra.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test all-intra coding. 4 | 5 | set -eu 6 | 7 | . "${0%/*}/util.sh" 8 | 9 | common_args='256x128 10 yuv420p -p1 --preset=ultrafast --threads=0 --no-wpp --no-tmvp --no-deblock --sao=0 --pu-depth-intra 0-4' 10 | valgrind_test $common_args --rd=1 11 | valgrind_test $common_args --rd=2 --no-transform-skip --qp 37 12 | valgrind_test $common_args --rd=2 --no-transform-skip --qp 37 --signhide --rdoq 13 | valgrind_test $common_args --rd=2 --mrl 14 | valgrind_test $common_args --rd=2 --mip 15 | valgrind_test $common_args --rd=3 16 | valgrind_test $common_args --alf=full --no-wpp --threads=0 --owf=0 17 | valgrind_test $common_args --alf=full --wpp --threads=1 18 | valgrind_test $common_args --jccr --rdoq --rd=2 --mts=intra 19 | valgrind_test $common_args --rd=3 --cclm --jccr 20 | valgrind_test $common_args --lfnst 21 | valgrind_test $common_args --lfnst --rd=3 --cclm --mip --dual-tree --fast-residual-cost 0 22 | valgrind_test $common_args --rd=2 --isp --cpuid=0 --fast-residual-cost 0 23 | valgrind_test $common_args --rd=2 --isp --cpuid=0 --lfnst --mts=intra --fast-residual-cost 0 24 | -------------------------------------------------------------------------------- /tests/test_invalid_input.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test trying to use invalid input dimensions. 4 | 5 | set -eu 6 | . "${0%/*}/util.sh" 7 | 8 | encode_test 1x65 1 yuv420p 1 9 | -------------------------------------------------------------------------------- /tests/test_lmcs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test lmcs 4 | 5 | set -eu 6 | 7 | . "${0%/*}/util.sh" 8 | 9 | common_args='256x128 10 yuv420p -p1 --preset=ultrafast --threads=0 --no-wpp --no-tmvp --no-deblock --sao=0 --cpuid=0 --pu-depth-intra 0-4 --lmcs' 10 | valgrind_test $common_args --deblock --sao=full --alf=full 11 | 12 | -------------------------------------------------------------------------------- /tests/test_monochrome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test all-intra coding. 4 | 5 | set -eu 6 | 7 | . "${0%/*}/util.sh" 8 | 9 | common_args='256x128 10 gray --hash none --preset=ultrafast --input-format P400 --threads=0 --no-wpp --no-tmvp --no-deblock --sao=0 --cpuid=0 --pu-depth-intra 0-4' 10 | valgrind_test $common_args --rd=1 -p1 11 | valgrind_test $common_args --rd=2 -p1 12 | valgrind_test $common_args --rd=2 -p1 --deblock 0:0 13 | -------------------------------------------------------------------------------- /tests/test_mtt_both.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test combined intra/inter mtt coding. 4 | 5 | set -eu 6 | 7 | . "${0%/*}/util.sh" 8 | 9 | common_args='264x130 10 yuv420p --preset=ultrafast --threads=0 --no-cpuid --no-wpp --fast-residual-cost 0' 10 | valgrind_test $common_args --rd=0 --mtt-depth-intra 1 --pu-depth-intra 2-3 --mtt-depth-inter 1 --pu-depth-inter 2-3 11 | valgrind_test $common_args --rd=3 --mtt-depth-intra 1 --pu-depth-intra 0-5 --mtt-depth-inter 1 --pu-depth-inter 0-5 12 | valgrind_test $common_args --rd=3 --mtt-depth-intra 3 --pu-depth-intra 0-8 --mtt-depth-inter 3 --pu-depth-inter 0-8 13 | valgrind_test $common_args --rd=3 --mtt-depth-intra 3 --mtt-depth-intra-chroma 3 --dual-tree --pu-depth-intra 0-8 --mtt-depth-inter 3 --pu-depth-inter 0-8 14 | valgrind_test $common_args --rd=3 --rdoq --jccr --isp --lfnst --mip --mrl --mts both --cclm --mtt-depth-intra 3 --mtt-depth-intra-chroma 3 --dual-tree --pu-depth-intra 0-8 --mtt-depth-inter 3 --pu-depth-inter 0-8 15 | -------------------------------------------------------------------------------- /tests/test_mtt_inter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test test inter mtt coding. 4 | 5 | set -eu 6 | 7 | . "${0%/*}/util.sh" 8 | 9 | common_args='264x130 10 yuv420p --preset=ultrafast --threads=0 --no-cpuid --no-wpp --fast-residual-cost 0' 10 | 11 | valgrind_test $common_args --rd=0 --mtt-depth-inter 1 --pu-depth-inter 2-3 12 | valgrind_test $common_args --rd=3 --mtt-depth-inter 1 --pu-depth-inter 0-5 13 | valgrind_test $common_args --rd=3 --mtt-depth-inter 3 --pu-depth-inter 0-8 14 | valgrind_test $common_args --rd=3 --mtt-depth-inter 3 --pu-depth-inter 0-8 --mts inter 15 | -------------------------------------------------------------------------------- /tests/test_mtt_intra.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test all-intra coding. 4 | 5 | set -eu 6 | 7 | . "${0%/*}/util.sh" 8 | 9 | common_args='264x130 10 yuv420p -p1 --preset=ultrafast --threads=0 --no-cpuid --no-wpp --fast-residual-cost 0' 10 | valgrind_test $common_args --rd=0 --mtt-depth-intra 1 --pu-depth-intra 2-3 11 | valgrind_test $common_args --rd=3 --mtt-depth-intra 1 --pu-depth-intra 0-5 12 | valgrind_test $common_args --rd=3 --mtt-depth-intra 3 --pu-depth-intra 0-8 13 | valgrind_test $common_args --rd=3 --mtt-depth-intra 3 --mtt-depth-intra-chroma 3 --dual-tree --pu-depth-intra 0-8 14 | valgrind_test $common_args --rd=3 --rdoq --jccr --isp --lfnst --mip --mrl --mts intra --cclm --mtt-depth-intra 3 --mtt-depth-intra-chroma 3 --dual-tree --pu-depth-intra 0-8 15 | -------------------------------------------------------------------------------- /tests/test_slices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | . "${0%/*}/util.sh" 5 | 6 | valgrind_test 512x256 10 yuv420p --threads=2 --owf=1 --preset=ultrafast --gop 0 --tiles=2x2 7 | #valgrind_test 264x130 10 --threads=2 --owf=1 --preset=ultrafast --slices=wpp 8 | #if [ ! -z ${GITLAB_CI+x} ];then valgrind_test 264x130 20 --threads=2 --owf=1 --preset=fast --slices=wpp --no-open-gop; fi 9 | -------------------------------------------------------------------------------- /tests/test_strategies.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "test_strategies.h" 34 | 35 | #include "src/strategyselector.h" 36 | 37 | 38 | strategy_list_t strategies; 39 | 40 | 41 | void init_test_strategies() 42 | { 43 | strategies.allocated = 0; 44 | strategies.count = 0; 45 | strategies.strategies = NULL; 46 | 47 | // Init strategyselector because it sets hardware flags. 48 | uvg_strategyselector_init(1, UVG_BIT_DEPTH); 49 | 50 | // Collect all strategies to be tested. 51 | if (!uvg_strategy_register_picture(&strategies, UVG_BIT_DEPTH)) { 52 | fprintf(stderr, "strategy_register_picture failed!\n"); 53 | return; 54 | } 55 | 56 | if (!uvg_strategy_register_dct(&strategies, UVG_BIT_DEPTH)) { 57 | fprintf(stderr, "strategy_register_dct failed!\n"); 58 | return; 59 | } 60 | 61 | if (!uvg_strategy_register_quant(&strategies, UVG_BIT_DEPTH)) { 62 | fprintf(stderr, "strategy_register_quant failed!\n"); 63 | return; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tests/test_strategies.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #ifndef TEST_STRATEGIES_H_ 34 | #define TEST_STRATEGIES_H_ 35 | 36 | #include "src/strategyselector.h" 37 | 38 | extern strategy_list_t strategies; 39 | 40 | void init_test_strategies(); 41 | 42 | #endif // TEST_STRATEGIES_H_ 43 | -------------------------------------------------------------------------------- /tests/test_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test RDOQ, SAO, deblock and signhide and subme. 4 | 5 | set -eu 6 | . "${0%/*}/util.sh" 7 | 8 | common_args='264x130 10 yuv420p -p0 -r1 --threads=2 --wpp --owf=1 --rd=0 --pu-depth-inter 0-3 --no-bipred --no-tmvp --gop=0' 9 | 10 | valgrind_test $common_args --no-rdoq --no-deblock --no-sao --no-signhide --subme=1 --pu-depth-intra=2-3 11 | valgrind_test $common_args --no-rdoq --no-signhide --subme=0 --bipred 12 | valgrind_test $common_args --rdoq --no-deblock --no-sao --subme=0 13 | valgrind_test $common_args --gop=8 --subme=4 --bipred --tmvp 14 | valgrind_test $common_args --transform-skip --tr-skip-max-size=5 15 | valgrind_test $common_args --vaq=8 16 | valgrind_test $common_args --vaq=8 --bitrate 350000 17 | valgrind_test $common_args --vaq=8 --rc-algorithm oba --bitrate 350000 18 | valgrind_test $common_args --ibc=1 -------------------------------------------------------------------------------- /tests/test_weird_shapes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | . "${0%/*}/util.sh" 5 | 6 | valgrind_test 16x16 10 yuv420p --threads=0 --no-wpp --preset=veryslow 7 | valgrind_test 256x16 10 yuv420p --threads=0 --no-wpp --preset=veryslow 8 | valgrind_test 16x256 10 yuv420p --threads=0 --no-wpp --preset=veryslow 9 | -------------------------------------------------------------------------------- /tests/tests_main.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * This file is part of uvg266 VVC encoder. 3 | * 4 | * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, this 14 | * list of conditions and the following disclaimer in the documentation and/or 15 | * other materials provided with the distribution. 16 | * 17 | * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | ****************************************************************************/ 32 | 33 | #include "greatest/greatest.h" 34 | 35 | #include "test_strategies.h" 36 | 37 | GREATEST_MAIN_DEFS(); 38 | #if UVG_BIT_DEPTH == 8 39 | extern SUITE(sad_tests); 40 | extern SUITE(intra_sad_tests); 41 | extern SUITE(satd_tests); 42 | extern SUITE(speed_tests); 43 | extern SUITE(dct_tests); 44 | extern SUITE(mts_tests); 45 | #endif //UVG_BIT_DEPTH == 8 46 | 47 | extern SUITE(coeff_sum_tests); 48 | extern SUITE(mv_cand_tests); 49 | extern SUITE(inter_recon_bipred_tests); 50 | 51 | int main(int argc, char **argv) 52 | { 53 | GREATEST_MAIN_BEGIN(); 54 | 55 | init_test_strategies(); 56 | #if UVG_BIT_DEPTH == 8 57 | RUN_SUITE(sad_tests); 58 | RUN_SUITE(intra_sad_tests); 59 | RUN_SUITE(satd_tests); 60 | RUN_SUITE(dct_tests); 61 | RUN_SUITE(mts_tests); 62 | 63 | if (greatest_info.suite_filter && 64 | greatest_name_match("speed", greatest_info.suite_filter)) 65 | { 66 | RUN_SUITE(speed_tests); 67 | } 68 | #else 69 | printf("10-bit tests are not yet supported\n"); 70 | #endif //UVG_BIT_DEPTH == 8 71 | 72 | RUN_SUITE(coeff_sum_tests); 73 | 74 | RUN_SUITE(mv_cand_tests); 75 | 76 | // Doesn't work in git 77 | //RUN_SUITE(inter_recon_bipred_tests); 78 | 79 | GREATEST_MAIN_END(); 80 | } 81 | -------------------------------------------------------------------------------- /tests/tsan_suppressions.txt: -------------------------------------------------------------------------------- 1 | # AVX2 interpolation reads some extra pixels 2 | race:kvz_ipol_8tap_hor_px_im_avx2 3 | race:kvz_filter_hpel_blocks_hor_ver_luma_avx2 4 | race:kvz_eight_tap_filter_hor_avx2 5 | -------------------------------------------------------------------------------- /tests/util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Helper functions for test scripts. 4 | 5 | set -eu${BASH+o pipefail} 6 | 7 | # Temporary files for encoder input and output. 8 | yuvfile="$(mktemp)" 9 | vvcfile="$(mktemp)" 10 | 11 | cleanup() { 12 | rm -rf "${yuvfile}" "${vvcfile}" 13 | } 14 | trap cleanup EXIT 15 | 16 | print_and_run() { 17 | printf '\n\n$ %s\n' "$*" 18 | "$@" 19 | } 20 | 21 | prepare() { 22 | cleanup 23 | print_and_run \ 24 | ffmpeg -f lavfi -i "mandelbrot=size=${1}" \ 25 | -vframes "${2}" -pix_fmt "${3}" -f yuv4mpegpipe \ 26 | "${yuvfile}" 27 | } 28 | 29 | valgrind_test() { 30 | dimensions="$1" 31 | shift 32 | frames="$1" 33 | shift 34 | format="$1" 35 | shift 36 | 37 | prepare "${dimensions}" "${frames}" "${format}" 38 | 39 | # If $UVG_TEST_VALGRIND is defined and equal to "1", run the test with 40 | # valgrind. Otherwise, run without valgrind. 41 | if [ "${UVG_TEST_VALGRIND:-0}" = '1' ]; then 42 | valgrind='valgrind --leak-check=full --error-exitcode=1 --' 43 | else 44 | valgrind='' 45 | fi 46 | 47 | # No quotes for $valgrind because it expands to multiple (or zero) 48 | # arguments. 49 | print_and_run \ 50 | $valgrind \ 51 | ../bin/uvg266 -i "${yuvfile}" "--input-res=${dimensions}" -o "${vvcfile}" "$@" 52 | 53 | print_and_run \ 54 | DecoderAppStatic -b "${vvcfile}" 55 | 56 | cleanup 57 | } 58 | 59 | encode_test() { 60 | dimensions="$1" 61 | shift 62 | frames="$1" 63 | shift 64 | format="$1" 65 | shift 66 | expected_status="$1" 67 | shift 68 | 69 | prepare "${dimensions}" "${frames}" "${format}" 70 | 71 | set +e 72 | print_and_run \ 73 | ../bin/uvg266 -i "${yuvfile}" "--input-res=${dimensions}" -o "${vvcfile}" "$@" 74 | actual_status="$?" 75 | set -e 76 | [ ${actual_status} -eq ${expected_status} ] 77 | } 78 | -------------------------------------------------------------------------------- /tools/appveyor-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | set -e 3 | 4 | export CC=gcc 5 | 6 | ./autogen.sh 7 | ./configure \ 8 | --host=$MINGW_CHOST \ 9 | --build=$MINGW_CHOST \ 10 | --target=$MINGW_CHOST \ 11 | --disable-shared --enable-static 12 | make 13 | -------------------------------------------------------------------------------- /tools/appveyor-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | set -e 3 | 4 | # Install build dependencies for kvazaar 5 | pacman -S --noconfirm --noprogressbar --needed \ 6 | $MINGW_PACKAGE_PREFIX-gcc \ 7 | $MINGW_PACKAGE_PREFIX-yasm 8 | 9 | # Delete unused packages to reduce space used in the Appveyor cache 10 | pacman -Sc --noconfirm 11 | -------------------------------------------------------------------------------- /tools/cabac_match.py: -------------------------------------------------------------------------------- 1 | file1 = "G:/tools/Kvazaar-vvc/bin/x64-Release/out.log" 2 | file2 = "G:/tools/VVCSoftware_VTM_git/bin/vs15/msvc-19.15/x86_64/release/all.vtmbmsstats" 3 | 4 | file2_line = "" 5 | file2_values = ["-1"] 6 | 7 | def check_values(val1, val2): 8 | if check_int(val1[1]) == False: 9 | return True 10 | #print("Matching..") 11 | if int(val1[1]) == int(val2[2]) and val1[2].strip() == val2[4].strip(): 12 | return True 13 | return False 14 | 15 | def check_int(s): 16 | s = str(s).strip() 17 | #print("{0} {1} 2".format(s, s.isdigit())) 18 | 19 | return s.isdigit() 20 | 21 | def RepresentsInt(s): 22 | try: 23 | int(s) 24 | return True 25 | except ValueError: 26 | return False 27 | 28 | 29 | with open(file1, "r") as fd1: 30 | with open(file2, "r") as fd2: 31 | for file1_line in fd1: 32 | file1_values = file1_line.strip().split() 33 | 34 | #print(file1_values[0]) 35 | 36 | #print("{0} {1}".format(file1_values[0], check_int(file1_values[0]))) 37 | if check_int(file1_values[0]) == False: 38 | continue 39 | #print("ok") 40 | while 1: 41 | if int(file1_values[0]) == int(file2_values[0]): 42 | if check_values(file1_values, file2_values) != True: 43 | print(file1_line) 44 | print(file2_line) 45 | print("Value mismatch at " + file1_values[0]) 46 | exit(1) 47 | break 48 | if int(file1_values[0]) < int(file2_values[0]): 49 | break 50 | file2_line = fd2.readline() 51 | file2_values = file2_line.split(" ") 52 | while check_int(file2_values[0]) == False: 53 | file2_line = fd2.readline() 54 | file2_values = file2_line.split(" ") 55 | 56 | 57 | -------------------------------------------------------------------------------- /tools/estimate.m: -------------------------------------------------------------------------------- 1 | data = dlmread("/dev/stdin", " "); 2 | coeffs = data(1:end, 1:5); 3 | costs = data(1:end, 6); 4 | [beta, sigma, r] = ols(costs, coeffs); 5 | disp(beta) 6 | -------------------------------------------------------------------------------- /tools/genmanpage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LANG=C 4 | set -e 5 | 6 | cd "$(dirname "$0")" 7 | 8 | date="$(date +"%B %Y")" 9 | version="$(awk 'match($0,/VERSION [0-9]\.[0-9]\.[0-9]/) {print $2}' ../CMakeLists.txt)" 10 | manpage_file=../doc/uvg266.1 11 | 12 | cat < $manpage_file 13 | .TH UVG266 "1" "$date" "uvg266 v$version" "User Commands" 14 | .SH NAME 15 | uvg266 \- open source VVC encoder 16 | .SH SYNOPSIS 17 | \fBuvg266 \fR\-i \-\-input\-res x \-o 18 | .SH DESCRIPTION 19 | EOF 20 | 21 | ../bin/uvg266 --help 2>&1 | tail -n+5 | \ 22 | sed 's| : |\n|g; 23 | s| :$||g; 24 | s|^ --|.TP\n\\fB--|g; 25 | s|^ -|.TP\n\\fB-|g; 26 | s|^ ||g; 27 | s|-|\\-|g; 28 | s|, \\-\\-|\\fR, \\fB\\-\\-|g;' \ 29 | >> $manpage_file 30 | 31 | for s in Required Presets Input Options "Video structure" "Compression tools" "Parallel processing" "Video Usability Information"; do 32 | sed -i "s|^${s}:|.SS \"${s}:\"|g" $manpage_file 33 | done 34 | -------------------------------------------------------------------------------- /tools/update_readme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This file is part of uvg266 VVC encoder. 3 | # 4 | # Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without modification, 8 | # are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, this 14 | # list of conditions and the following disclaimer in the documentation and/or 15 | # other materials provided with the distribution. 16 | # 17 | # * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | 32 | # This script updates parameter documentation in ../README.md file. 33 | 34 | LANG=C 35 | set -e 36 | 37 | cd "$(dirname "$0")" 38 | 39 | tmpfile="$(mktemp)" 40 | readme_file="../README.md" 41 | 42 | { 43 | sed '/BEGIN UVG266 HELP MESSAGE/q' -- "$readme_file"; 44 | printf '```\n'; 45 | ../bin/uvg266 --help 2>&1 | tail -n+2; 46 | printf '```\n'; 47 | sed -n '/END UVG266 HELP MESSAGE/{:a;p;n;ba}' -- "$readme_file"; 48 | } >> "$tmpfile" 49 | 50 | mv -- "$tmpfile" "../README.md" 51 | -------------------------------------------------------------------------------- /tools/version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "$(dirname "$0")" 4 | cd .. 5 | 6 | if type git >/dev/null 2>/dev/null && [ -d .git ]; then 7 | version="$(git describe --dirty --tags --match 'v*')" 8 | version="${version} $(git log -1 --pretty=format:%cd --date=short)" 9 | else 10 | version="v$(awk '/#define KVZ_VERSION/ { print $3 }' src/global.h)" 11 | fi 12 | 13 | printf '%s\n' "$version" 14 | --------------------------------------------------------------------------------