diff --git a/.gitignore b/.gitignore index 0a82622d4..322cb5229 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ deploy .vscode/ /CMakeSettings.json /out/ +.project +.cproject \ No newline at end of file diff --git a/.gitlab-ci-internal.yml b/.gitlab-ci-internal.yml new file mode 100644 index 000000000..47ded56af --- /dev/null +++ b/.gitlab-ci-internal.yml @@ -0,0 +1,37 @@ +stages: + - build + +.build_template: + stage: build + script: + - make all + - make test + only: + - web + - schedules + - merge_requests + +build_ubuntu1804: + extends: .build_template + tags: + - ubuntu1804 + +build_ubuntu2004: + extends: .build_template + tags: + - ubuntu2004 + +build_vc191x: + extends: .build_template + tags: + - vc191x + +build_vc192x: + extends: .build_template + tags: + - vc192x + +build_macos: + extends: .build_template + tags: + - macos diff --git a/AUTHORS.md b/AUTHORS.md index 93b447df5..a31a6e78d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -7,7 +7,7 @@ * Valeri George, , Fraunhofer HHI * Ivan Zupancic, , Fraunhofer HHI * Christian Lehmann, , Fraunhofer HHI -* Christian Helmrich, , Fraunhofer HHI +* Christian Helmrich, @crhelmrich, Fraunhofer HHI * Christian Stoffers, , Fraunhofer HHI * Gabriel Hege, , Fraunhofer HHI * Jens Güther, , Fraunhofer HHI diff --git a/CMakeLists.txt b/CMakeLists.txt index 80dcfdace..072a5744a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,31 +10,94 @@ if( NOT CMAKE_VERSION VERSION_LESS 3.12.0 ) endif() # project name -project( vvenc ) - +project( vvenc VERSION 0.2.0.0 ) + +if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + # enable sse4.1 build for all source files for gcc and clang + if( UNIX OR MINGW ) + add_compile_options( "-msse4.1" ) + endif() + + # set exception handling + if( MSVC ) + add_compile_options( "/EHsc" ) + endif() + + # vvenc embedded by superproject, always include source/Lib/vvenc as first component + list( PREPEND ${PROJECT_NAME}_ADD_SUBDIRECTORIES "source/Lib/vvenc" ) + list( REMOVE_DUPLICATES ${PROJECT_NAME}_ADD_SUBDIRECTORIES ) + message( STATUS "${CMAKE_CURRENT_SOURCE_DIR}: ${PROJECT_NAME} embedded, subdirectories to be added: ${${PROJECT_NAME}_ADD_SUBDIRECTORIES}" ) + # add subdirectories the superproject asked for + foreach( subdir IN LISTS ${PROJECT_NAME}_ADD_SUBDIRECTORIES ) + add_subdirectory( ${subdir} ) + endforeach() + return() +endif() # enable install target set( VVENC_ENABLE_INSTALL ON CACHE BOOL "Enable or disable install target" ) +# enable postfix +set( VVENC_ENABLE_BUILD_TYPE_POSTFIX OFF CACHE BOOL "Enable or disable build type postfix for apps and libs" ) + +if( VVENC_ENABLE_BUILD_TYPE_POSTFIX ) + if( BUILD_SHARED_LIBS ) + # set postfixes for shared libraries + set( CMAKE_RELEASE_POSTFIX "-s" CACHE STRING "Set release library postfix" ) + set( CMAKE_DEBUG_POSTFIX "-ds" CACHE STRING "Set debug library postfix" ) + set( CMAKE_RELWITHDEBINFO_POSTFIX "-rds" CACHE STRING "Set relwithdebinfo library postfix" ) + set( CMAKE_MINSIZEREL_POSTFIX "-mrs" CACHE STRING "Set minsizerel library postfix" ) + else() + # set postfixes for static libraries + set( CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set release library postfix" ) + set( CMAKE_DEBUG_POSTFIX "-d" CACHE STRING "Set debug library postfix" ) + set( CMAKE_RELWITHDEBINFO_POSTFIX "-rd" CACHE STRING "Set relwithdebinfo library postfix" ) + set( CMAKE_MINSIZEREL_POSTFIX "-mr" CACHE STRING "Set minsizerel library postfix" ) + endif() +endif() + +# set VVENC_OUTPUT_DIR_POSTFIX +if( BUILD_SHARED_LIBS ) + set( VVENC_OUTPUT_DIR_POSTFIX shared ) +else() + set( VVENC_OUTPUT_DIR_POSTFIX static ) +endif() + +set( VVENC_ENABLE_TRACING OFF CACHE BOOL "Set ENABLE_TRACING=1 as a compiler flag" ) + +# Using CMake's default library name convention which is the same for all configurations. +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/lib/debug-${VVENC_OUTPUT_DIR_POSTFIX}" ) +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/lib/release-${VVENC_OUTPUT_DIR_POSTFIX}" ) +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/lib/relwithdebinfo-${VVENC_OUTPUT_DIR_POSTFIX}" ) +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/lib/minsizerel-${VVENC_OUTPUT_DIR_POSTFIX}" ) + +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG}" ) +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE}" ) +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO}" ) +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL}" ) + +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin/debug-${VVENC_OUTPUT_DIR_POSTFIX}" ) +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin/release-${VVENC_OUTPUT_DIR_POSTFIX}" ) +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/bin/relwithdebinfo-${VVENC_OUTPUT_DIR_POSTFIX}" ) +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/bin/minsizerel-${VVENC_OUTPUT_DIR_POSTFIX}" ) + # set default CMAKE_BUILD_TYPE to Release if not set if( NOT CMAKE_BUILD_TYPE ) set( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE ) endif() -#if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR -# CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) -# set( USE_ADDRESS_SANITIZER OFF CACHE BOOL "Compiles and links with -fsanitize=address" ) -#endif() +# address sanitizer +if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + set( VVENC_USE_ADDRESS_SANITIZER OFF CACHE BOOL "Compiles with -sanitize=address and links to libasan" ) +endif() #set( ENABLE_LINK_TIME_OPT ON CACHE BOOL "Enable link time optimization for release and profile builds" ) #set( OPT_TARGET_ARCH "native" CACHE STRING "Create code and optimize for this architecture (default native)" ) -#set( SET_ENABLE_TRACING OFF CACHE BOOL "Set ENABLE_TRACING as a compiler flag" ) -#set( ENABLE_TRACING OFF CACHE BOOL "If SET_ENABLE_TRACING is on, it will be set to this value" ) - # set c++11 -set( CMAKE_CXX_STANDARD 11 ) +set( CMAKE_CXX_STANDARD 14 ) set( CMAKE_CXX_STANDARD_REQUIRED ON ) # compile everything position independent (even static libraries) @@ -66,22 +129,26 @@ endif() # enable parallel build for Visual Studio if( MSVC ) # add compile options - add_compile_options( /wd4310) - add_compile_options( /wd4996) add_compile_options( "/MP" ) add_compile_options( "/EHsc" ) endif() +if( VVENC_ENABLE_TRACING ) + add_definitions( -DENABLE_TRACING=1 ) +endif() + # set address sanitizer compiler arguments -#if( USE_ADDRESS_SANITIZER ) -# # add compile options -# add_compile_options( "-fsanitize=address" ) -# #add_compile_options( "-fno-omit-frame-pointer" ) -# #add_compile_options( "-fsanitize=leak" ) -# add_link_options( "-fsanitize=address" ) -# #add_link_options( "-fno-omit-frame-pointer" ) -# #add_link_options( "-fsanitize=leak" ) -#endif() +if( VVENC_USE_ADDRESS_SANITIZER ) + # add compile options + add_compile_options( "-fsanitize=address" ) + add_compile_options( "-fno-omit-frame-pointer" ) + add_compile_options( "-fsanitize=undefined" ) + add_compile_options( "-fsanitize=leak" ) + add_link_options( "-fsanitize=address" ) + add_link_options( "-fno-omit-frame-pointer" ) + add_link_options( "-fsanitize=undefined" ) + add_link_options( "-fsanitize=leak" ) +endif() # use ccache find_program( CCACHE_FOUND ccache ) @@ -91,15 +158,98 @@ if( CCACHE_FOUND ) set_property( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache ) endif() +# handle rpath correctly +if( VVENC_ENABLE_INSTALL ) + if( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) + set( CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "Standard install prefix" FORCE ) + endif() + + # use GNU install dirs + include( GNUInstallDirs ) + + if( BUILD_SHARED_LIBS AND NOT WIN32 ) + set( CMAKE_SKIP_INSTALL_RPATH OFF CACHE BOOL "skip rpath" ) + if( APPLE ) + set( RPATH_BASE @loader_path ) + elseif( UNIX ) + set( RPATH_BASE $ORIGIN ) + endif() + + file( RELATIVE_PATH RPATH_REL_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} ) + + set( CMAKE_INSTALL_RPATH ${RPATH_BASE} ${RPATH_BASE}/${RPATH_REL_DIR} ) + message( STATUS "CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}" ) + endif() +endif() + add_subdirectory( "source/Lib/vvenc" ) add_subdirectory( "source/App/vvencapp" ) add_subdirectory( "source/App/vvencFFapp" ) - +add_subdirectory( "test/vvenclibtest" ) + +# enable testing with ctest +enable_testing() + +# add test +add_test( NAME Test_vvenclibtest-paramerter_range COMMAND vvenclibtest 1 ) +add_test( NAME Test_vvenclibtest-calling_order COMMAND vvenclibtest 2 ) +add_test( NAME Test_vvenclibtest-input_params COMMAND vvenclibtest 3 ) +add_test( NAME Test_vvenclibtest-output_params COMMAND vvenclibtest 4 ) + +add_test( NAME Test_vvencapp-tooltest COMMAND vvencapp --preset tooltest -s 80x44 -r 15 -i ../../test/data/RTn23_80x44p15_f15.yuv -f 8 -o out.vvc ) +set_tests_properties( Test_vvencapp-tooltest PROPERTIES TIMEOUT 90 ) +add_test( NAME Test_vvencFFapp-tooltest COMMAND vvencFFapp -c ../../cfg/randomaccess_tooltest.cfg -c ../../test/data/RTn23.cfg -f 8 -b outf.vvc ) +set_tests_properties( Test_vvencFFapp-tooltest PROPERTIES TIMEOUT 60 ) +add_test( NAME Test_compare_output-tooltest COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencFFapp-tooltest-Scalar COMMAND vvencFFapp -c ../../cfg/randomaccess_tooltest.cfg -c ../../test/data/RTn23.cfg -f 8 -b outf.vvc --SIMD=SCALAR ) +set_tests_properties( Test_vvencFFapp-tooltest-Scalar PROPERTIES TIMEOUT 70 ) +add_test( NAME Test_compare_output-tooltest-Scalar COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencFFapp-tooltesttrans COMMAND vvencFFapp -c ../../cfg/randomaccess_tooltest.cfg -c ../../test/data/RTn23.cfg -f 8 --DebugBitstream=outf.vvc --DebugPOC=3 -b out.vvc ) +set_tests_properties( Test_vvencFFapp-tooltesttrans PROPERTIES TIMEOUT 20 ) +add_test( NAME Test_output-tooltesttrans COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencapp-faster COMMAND vvencapp --preset faster -s 80x44 -r 15 -i ../../test/data/RTn23_80x44p15_f15.yuv -f 11 -o out.vvc ) +set_tests_properties( Test_vvencapp-faster PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_vvencFFapp-faster COMMAND vvencFFapp -c ../../cfg/randomaccess_faster.cfg -c ../../test/data/RTn23.cfg -f 11 -b outf.vvc ) +set_tests_properties( Test_vvencFFapp-faster PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_compare_output-faster COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencapp-fast COMMAND vvencapp --preset fast -s 80x44 -r 15 -i ../../test/data/RTn23_80x44p15_f15.yuv -f 8 -o out.vvc ) +set_tests_properties( Test_vvencapp-fast PROPERTIES TIMEOUT 40 ) +add_test( NAME Test_vvencFFapp-fast COMMAND vvencFFapp -c ../../cfg/randomaccess_fast.cfg -c ../../test/data/RTn23.cfg -f 8 -b outf.vvc ) +set_tests_properties( Test_vvencFFapp-fast PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_compare_output-fast COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencFFapp-transcoding COMMAND vvencFFapp -c ../../cfg/randomaccess_fast.cfg -c ../../test/data/RTn23.cfg -f 8 --DebugBitstream=outf.vvc --DebugPOC=3 -b out.vvc ) +set_tests_properties( Test_vvencFFapp-transcoding PROPERTIES TIMEOUT 20 ) +add_test( NAME Test_output-transcoding COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencapp-medium COMMAND vvencapp --preset medium -s 80x44 -r 15 -i ../../test/data/RTn23_80x44p15_f15.yuv -f 5 -o out.vvc ) +set_tests_properties( Test_vvencapp-medium PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_vvencFFapp-medium COMMAND vvencFFapp -c ../../cfg/randomaccess_medium.cfg -c ../../test/data/RTn23.cfg -f 5 -b outf.vvc ) +set_tests_properties( Test_vvencFFapp-medium PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_compare_output-medium COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencapp-slow COMMAND vvencapp --preset slow -s 80x44 -r 15 -i ../../test/data/RTn23_80x44p15_f15.yuv -f 3 -o out.vvc ) +set_tests_properties( Test_vvencapp-slow PROPERTIES TIMEOUT 90 ) +add_test( NAME Test_vvencFFapp-slow COMMAND vvencFFapp -c ../../cfg/randomaccess_slow.cfg -c ../../test/data/RTn23.cfg -f 3 -b outf.vvc ) +set_tests_properties( Test_vvencFFapp-slow PROPERTIES TIMEOUT 90 ) +add_test( NAME Test_compare_output-slow COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_vvencapp-medium_noqpa_0thr COMMAND vvencapp --preset medium --qpa 0 -threads 0 -s 80x44 -r 15 -i ../../test/data/RTn23_80x44p15_f15.yuv -f 5 -o out.vvc ) +set_tests_properties( Test_vvencapp-medium_noqpa_0thr PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_vvencFFapp-medium_noqpa_0thr COMMAND vvencFFapp -c ../../cfg/randomaccess_medium.cfg -c ../../test/data/RTn23.cfg -qpa 0 --WppBitEqual=0 --NumWppThreads=0 -f 5 -b outf.vvc ) +set_tests_properties( Test_vvencFFapp-medium_noqpa_0thr PROPERTIES TIMEOUT 30 ) +add_test( NAME Test_compare_output-medium_noqpa_0thr COMMAND ${CMAKE_COMMAND} -E compare_files out.vvc outf.vvc ) + +add_test( NAME Test_remove_temp_files COMMAND ${CMAKE_COMMAND} -E remove out.vvc tout.vvc rec.yuv ) + if( VVENC_ENABLE_INSTALL ) - set( CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "Standard install prefix" FORCE ) - include( cmake/modules/VVEncLibInstall.cmake ) + # include installer + include( cmake/modules/vvencInstall.cmake ) endif() - diff --git a/LICENSE.txt b/LICENSE.txt index 893a68a19..67a1cc4f6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,47 +1,53 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc - -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -3. LIMITED PATENT LICENSE +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ -The Fraunhofer Versatile Video Encoding Library is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. -The VVC Test Model (VTM) reference software is licensed under the following 3-Clause BSD License: +The Fraunhofer Versatile Video Encoding Library is based on the official ITU/ISO/IEC VVC +Test Model (VTM) reference software whose copyright holders are indicated in the copyright +notices of its source files. The VVC Test Model (VTM) reference software is licensed under +the following 3-Clause BSD License: /* ----------------------------------------------------------------------------- The copyright in this software is being made available under the BSD @@ -75,4 +81,4 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ */ +----------------------------------------------------------------------------- */ \ No newline at end of file diff --git a/Makefile b/Makefile index a6a3ad6e5..7ace1c7ed 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,25 @@ ifneq ($(verbose),) CONFIG_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE=ON endif +ifneq ($(enable-tracing),) +CONFIG_OPTIONS += -DVVENC_ENABLE_TRACING=$(enable-tracing) +endif + +ifneq ($(address-sanitizer),) +CONFIG_OPTIONS += -DVVENC_USE_ADDRESS_SANITIZER=$(address-sanitizer) +endif + +ifneq ($(enable-build-type-postfix),) +CONFIG_OPTIONS += -DVVENC_ENABLE_BUILD_TYPE_POSTFIX=ON +endif + +ifneq ($(install-prefix),) +CONFIG_OPTIONS += -DCMAKE_INSTALL_PREFIX=$(install-prefix) +endif + ifeq ($(j),) # Query cmake for the number of cores -NUM_JOBS := $(shell cmake -P cmake/modules/VVEncNumCores.cmake) +NUM_JOBS := $(shell cmake -P cmake/modules/vvencNumCores.cmake) NUM_JOBS := $(lastword $(NUM_JOBS)) else NUM_JOBS := $(j) @@ -194,10 +210,13 @@ configure: configure-static configure-shared install-static: $(foreach t,$(DEFAULT_BUILD_TARGETS_STATIC),install-$(t)) install-shared: $(foreach t,$(DEFAULT_BUILD_TARGETS_SHARED),install-$(t)) -install: install-static install-shared +install-all: install-static install-shared + +# default distribution target +install: install-release-shared clean: - $(RM) -rf build + $(RM) -rf build bin lib realclean: clean $(RM) -rf install @@ -228,6 +247,17 @@ install-ds: install-debug-shared install-p: install-relwithdebinfo install-ps: install-relwithdebinfo-shared + +ifeq ($(CMAKE_MCONFIG),) +TEST_TARGET := test +else +TEST_TARGET := RUN_TESTS +endif + +# test target +test: release + cmake $(BUILD_OPTIONS-release) --target $(TEST_TARGET) $(BUILD_TOOL_OPTIONS) + # # project specific targets # diff --git a/README.md b/README.md index 9097de44f..31e042bd0 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,29 @@ # Fraunhofer Versatile Video Encoder (VVenC) -Versatile Video Coding (VVC) is the most recent international video coding standard, developped by the Joint Video Experts Team (JVET) of the ITU-T Video Coding Experts Group (VCEG) and the ISO/IEC Moving Picture Experts Group (MPEG). VVC is the successor of the High Efficiency Video Coding (HEVC) standard and will be released by ITU-T as H.266 and by ISO/IEC as MPEG-I Part 3 (ISO/IEC 23090-3). The new standard targets a 50% bit-rate reduction over HEVC at the same visual quality. In addition, VVC proves to be truly versatile by including tools for efficient coding of video content in emerging applications, e.g. high dynamic range (HDR), adaptive streaming, computer generated content as well as immersive applications like 360 degree video and augmented reality (AR). +Versatile Video Coding (VVC) is the most recent international video coding standard, developed by the Joint Video Experts Team (JVET) of the ITU-T Video Coding Experts Group (VCEG) and the ISO/IEC Moving Picture Experts Group (MPEG). VVC is the successor of the High Efficiency Video Coding (HEVC) standard and will be released by ITU-T as H.266 and by ISO/IEC as MPEG-I Part 3 (ISO/IEC 23090-3). The new standard targets a 50% bit-rate reduction over HEVC at the same visual quality. In addition, VVC proves to be truly versatile by including tools for efficient coding of video content in emerging applications, e.g. high dynamic range (HDR), adaptive streaming, computer generated content as well as immersive applications like 360-degree video and augmented reality (AR). The Fraunhofer Versatile Video Encoder (VVenC) is a fast and efficient "real-world" VVC encoder implementation with the following main features: - Easy to use encoder implementation with four predefined quality/speed presets; - Perceptual optimization to improve subjective video quality; -- Frame-level rate control supporting VBR encoding; +- Frame-level rate control supporting variable bit-rate (VBR) encoding; - Expert mode encoder interface available, allowing fine-grained control of the encoding process. # How to build VVenC? -The software uses CMake to create platform-specific build files. +The software uses CMake to create platform-specific build files. A working CMake installation is required for building the software. Download CMake from http://www.cmake.org/ and install it. The following targets are supported: Windows (Visual Studio), Linux (gcc) and MacOS (clang). ## How to build for Windows? -In order to compile the software for Windows, Visual Studio 15 2017 or higher and cmake Version 3.12 or higher are required. Install gnuwin32 that provides make for Windows. To build the software open a command prompt window, change into the project directory and use: +In order to compile the software for Windows, Visual Studio 15 2017 or higher and cmake version 3.12 or higher are required. Install gnuwin32 that provides make for Windows. To build the software open a command prompt window, change into the project directory and use: make install-release This will create the statically linked release version of the encoder applications in the install/bin/release-static/ subdirectory. ## How to build for Linux/MacOS? -In order to compile the software for Linux, gcc-7.0 or higher and cmake Version 3.12 or higher are required. For MacOS Xcode and cmake Version 3.12 or higher are required. To simplify the build process a Makefile with predefined targets is available. To build the VVenC encoder applications open a terminal, change into the project directory and use: +In order to compile the software for Linux, gcc version 7.0 or higher and cmake version 3.12 or higher are required. For MacOS, Xcode and cmake version 3.12 or higher are required. To simplify the build process a Makefile with predefined targets is available. To build the VVenC encoder applications open a terminal, change into the project directory and use: make install-release @@ -37,34 +37,36 @@ The encoder project includes two encoder executables, a standard encoder (vvenca ## How to use the standard encoder? The standard encoder (**vvencapp**) can be used in one of four predefined presets. Each preset represents a different tradeoff between encoder runtime and video quality. In the slowest preset, the encoder reaches the highest compression gain, whilst in the fastest preset the runtime is significantly decreased. A list of the main encoder command line parameters is shown in the following table. -| OPTION | DEFAULT | DESCRIPTION | -|-------------------|----------------------------------|----------------------------------------------------------------------------------------------------| -| --help,-h | - | Show basic help | -| --input | - | Raw yuv input file | -| --size | 1920x1080 | Input file resolution (width x height) | -| --framerate | 60 | Temporal rate of input file. Required for VBR encoding and calculation of output bit-rate | -| --format | yuv420 | Set input format to YUV 4:2:0 8bit (yuv420) or YUV 4:2:0 10bit (yuv420_10) | -| --output | not set | Bit-stream output file | -| --preset | medium | Select preset for specific encoding setting (faster, fast, medium, slow) | -| --qp | 32 | Quantization parameter (0..51) | -| --bitrate | 0 | Bitrate for rate control (0 constant QP encoding rate control off, otherwise bits per second). Rate control requires correct framerate. | -| --qpa | 2 | Perceptual QP adaption (0: off, on for 1: SDR(WPSNR), 2: SDR(XPSNR), 3: HDR(WPSNR), 4: HDR(XPSNR)) | -| --threads | size<=HD: 4
else : 6 | Number of threads (1-N) | +| OPTION | DEFAULT | DESCRIPTION | +|------------------------|----------------------------------|------------------------------------------------------------------------------------------------------| +| --help,-h | - | Show basic help | +| --input,-i | - | Raw yuv input file | +| --size,-s | 1920x1080 | Input file resolution (width x height) | +| --framerate,-r | 60 | Temporal rate of input file. Required for VBR encoding and calculation of output bit-rate. Also recommended for perceptual QP adaptation modes 2 and 4 (see `--qpa` option below). | +| --format,-c | yuv420 | Set input format to YUV 4:2:0 8bit (yuv420) or YUV 4:2:0 10bit (yuv420_10) | +| --output,-o | not set | Bit-stream output file | +| --preset | medium | Select preset for specific encoding setting (faster, fast, medium, slow, slower) | +| --qp,-q | 32 | Quantization parameter (0..51) | +| --bitrate | 0 | Bitrate for rate control (0 constant QP encoding rate control off, otherwise bits per second). Rate control requires correct framerate. | +| --passes,-p | 1 | Set number of rate control passes (1: one-pass rate control, 2: two-pass rate control). | +| --qpa | 2 | Perceptual QP adaptation (0: off, on for 1: SDR(WPSNR), 2: SDR(XPSNR), 3: HDR(WPSNR), 4: HDR(XPSNR)) | +| --refreshsec,-rs | 1 | Intra period/refresh in seconds | +| --threads ,-t | size<=HD: 4
else : 6 | Number of threads (1-N) | **Example usage:** Given a YUV 4:2:0 input file with a bit-depth of 8bit and a resolution of 176x144 pixels, the following call will encode the input file with the medium speedup preset: vvencapp --preset medium -i BUS_176x144_75@15.yuv -s 176x144 -o str.266 ## How to use the full featured expert mode encoder? -The expert mode encoder (**vvencFFapp**) is based on the [VVC test model (VTM)](https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM) reference software configuration scheme. Most of the parameters have been kept similar to VTM, but for some parameters, additional modes are available. Furthermore, not supported options have been removed. The following wxample configuration files for the expert mode encoder can be found in the cfg sub-directory: - -| CONFIGURATION FILE | DESCRIPTION | -|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| sequence.cfg | Sequence specific configuration parameters. Must be always adapted to the input sequence. | -| randomaccess_faster.cfg
randomaccess_fast.cfg
randomaccess_medium.cfg
randomaccess_slow.cfg | Random access configuration for different presets. Each configuration file corresponds to one of the 4 preset modes. | -| qpa.cfg | Perceptually optimized QPA configuration file. | -| gop32.cfg | Experimental. Additional GOP size 32 configuration, replacing the default GOP size 16 configuration. Must be given at the command line after the random access configuration file. | -| frc.cfg | Frame level rate control configuration, overriding default fix QP setup. Note: Currently incompatible with GOP 32. | +The expert mode encoder (**vvencFFapp**) is based on the [VVC test model (VTM)](https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM) reference software configuration scheme. Most of the parameters have been kept similar to VTM, but for some parameters, additional modes are available. Furthermore, not supported options have been removed. The following example configuration files for the expert mode encoder can be found in the cfg sub-directory: + +| CONFIGURATION FILE | DESCRIPTION | +|---------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| +| sequence.cfg | Sequence specific configuration parameters. Must be always adapted to the input sequence. | +| randomaccess_faster.cfg
randomaccess_fast.cfg
randomaccess_medium.cfg
randomaccess_slow.cfg
randomaccess_slower.cfg | Random access configuration for different presets. Each configuration file corresponds to one of the 5 preset modes. | +| qpa.cfg | Perceptually optimized QPA configuration file. | +| frc.cfg | Frame level single pass rate control configuration, overriding default fix QP setup. | +| rc2p.cfg | Frame level two pass rate control configuration, overriding default fix QP setup. | **Example usage:** In order to start your first experiments with the expert mode encoder, adapt the sequence.cfg configuration file to your input YUV source file and use the following command: diff --git a/cfg/frc.cfg b/cfg/frc.cfg index db9c2d42e..99887f6ca 100644 --- a/cfg/frc.cfg +++ b/cfg/frc.cfg @@ -5,3 +5,4 @@ KeepHierarchicalBit : 2 # Rate control: 0: equal RCLCUSeparateModel : 1 # Rate control: use LCU level separate R-lambda model InitialQP : 0 # Rate control: initial QP RCForceIntraQP : 0 # Rate control: force intra QP to be equal to initial QP +NumPasses : 1 # Rate control: number of passes diff --git a/cfg/randomaccess_fast.cfg b/cfg/randomaccess_fast.cfg index 360f6a4d4..7ffb29da9 100644 --- a/cfg/randomaccess_fast.cfg +++ b/cfg/randomaccess_fast.cfg @@ -8,27 +8,43 @@ Profile : auto #======== Coding Structure ============= IntraPeriod : 32 # Period of I-Frame ( -1 = only first) DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) +GOPSize : 32 # GOP Size (number of B slice = GOPSize-1) IntraQPOffset : -3 LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled # Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 +Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 64 48 2 2 32 64 +Frame2 : B 16 0 -4.9309 0.2265 0 0 1.0 0 0 0 0 0 0 1 2 2 16 32 2 2 -16 16 +Frame3 : B 8 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 +Frame4 : B 4 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 3 -4 -12 -28 +Frame5 : B 2 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 4 -2 -6 -14 -30 +Frame6 : B 1 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 -1 2 5 -1 -3 -7 -15 -31 +Frame7 : B 3 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 3 2 4 -1 -5 -13 -29 +Frame8 : B 6 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 6 2 3 -2 -10 -26 +Frame9 : B 5 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 5 2 4 -1 -3 -11 -27 +Frame10 : B 7 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 7 2 3 -1 -9 -25 +Frame11 : B 12 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 12 2 2 -4 -20 +Frame12 : B 10 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 10 2 3 -2 -6 -22 +Frame13 : B 9 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 9 2 4 -1 -3 -7 -23 +Frame14 : B 11 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 11 2 3 -1 -5 -21 +Frame15 : B 14 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 14 2 2 -2 -18 +Frame16 : B 13 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 13 2 3 -1 -3 -19 +Frame17 : B 15 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 15 2 2 -1 -17 +Frame18 : B 24 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 +Frame19 : B 20 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 2 -4 -12 +Frame20 : B 18 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 3 -2 -6 -14 +Frame21 : B 17 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 17 2 4 -1 -3 -7 -15 +Frame22 : B 19 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 19 2 3 -1 -5 -13 +Frame23 : B 22 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 22 2 2 -2 -10 +Frame24 : B 21 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 21 2 3 -1 -3 -11 +Frame25 : B 23 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 23 2 2 -1 -9 +Frame26 : B 28 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 3 4 12 28 2 2 -4 4 +Frame27 : B 26 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 10 26 2 2 -2 -6 +Frame28 : B 25 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 9 25 2 3 -1 -3 -7 +Frame29 : B 27 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 11 27 2 2 -1 -5 +Frame30 : B 30 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 14 30 2 2 -2 2 +Frame31 : B 29 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 13 29 2 2 -1 -3 +Frame32 : B 31 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 15 31 2 2 -1 1 #=========== Motion Search ============= FastSearch : 4 # 0:Full search 1:TZ search @@ -62,10 +78,7 @@ DeblockingFilterMetric : 0 # blockiness metric (automatically c InternalBitDepth : 10 # codec operating bit-depth #=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -#TransformSkip : 0 # Transform skipping (0: OFF, 1: ON) #TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -#TransformSkipLog2MaxSize : 5 #SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) #============ VTM settings ====================== @@ -85,54 +98,56 @@ LCTUFast : 1 DualITree : 1 # separate partitioning of luma and chroma channels for I-slices MinQTLumaISlice : 8 MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree -MinQTNonISlice : 8 +MinQTNonISlice : 16 MaxMTTHierarchyDepth : 1 -MaxMTTHierarchyDepthISliceL : 2 -MaxMTTHierarchyDepthISliceC : 2 +MaxMTTHierarchyDepthISliceL : 1 +MaxMTTHierarchyDepthISliceC : 1 # tools not supported by vvc -#MTS : 0 -#MTSIntraMaxCand : 4 -#MTSInterMaxCand : 4 -#ISP : 0 #BCW : 0 #BcwFast : 1 -#IBC : 0 # turned off in CTC +#IBC : 0 # turned off in CTC #AffineAmvr : 0 -#ChromaTS : 0 # tools supported by vvc -MRL : 0 # MultiRefernceLines -MaxNumMergeCand : 6 -LMCSEnable : 0 # LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -LMCSOffset : 6 # chroma residual scaling offset -EncDbOpt : 0 # Encoder optimization with deblocking filter 1:default 2:fast -TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only -LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +Affine : 0 # Affine prediction: 0: disabled, 1: vtm, 2: fast +ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled +AllowDisFracMMVD : 0 # Disable fractional MVD in MMVD mode adaptively +BDPCM : 1 # BDPCM (0:off, 1:luma and chroma) +BIO : 0 # Bi-directional optical flow: 0: disabled, 1: enabled +CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled +ChromaTS : 0 # Chroma transform skip: 0: disabled, 1: enabled +CIIP : 0 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster DepQuant : 0 # Dependent quantization: 0: disabled, 1: enabled -MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled -BIO : 1 # Bi-directional optical flow: 0: disabled, 1: enabled DMVR : 1 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled -JointCbCr : 0 # Joint coding of chroma residuals: 0: disabled, 1: enabled +EncDbOpt : 0 # Encoder optimization with deblocking filter 1:default 2:fast +Geo : 0 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast IMV : 0 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes -ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled -CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled -UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled -Affine : 0 # Affine prediction: 0: disabled, 1: vtm, 2: fast -PROF : 0 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +ISP : 0 # Intra subpartitions: 0: disabled, 1: enabled, 2: fast, 3: faster +JointCbCr : 0 # Joint coding of chroma residuals: 0: disabled, 1: enabled +LFNST : 0 # LFNST: 0: disabled, 1: enabled +LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +LMCSEnable : 0 # LMCS: 0: disable, 1:enable +LMCSOffset : 6 # chroma residual scaling offset +LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG +LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP +MaxNumMergeCand : 6 +MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames MIP : 0 # Matrix-based intra prediction: 0: disabled, 1: enabled MMVD : 0 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes -AllowDisFracMMVD : 0 # Disable fractional MVD in MMVD mode adaptively -SMVD : 0 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast -SbTMVP : 0 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled -Geo : 0 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast -CIIP : 0 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +MRL : 0 # MultiRefernceLines +MTS : 0 # Multiple transform selection: 0: disabled, 1: enabled +MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +PROF : 0 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +SAO : 1 # Sample adaptive offset, 0: disabled, 1: enabled SBT : 0 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster -LFNST : 0 # LFNST: 0: disabled, 1: enabled -MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames +SbTMVP : 0 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled +SMVD : 0 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast +TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only +TransformSkip : 2 # Transform skipping, 0: disabled, 1: enabled, 2: adaptive +TransformSkipLog2MaxSize : 3 +UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled +UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled # Fast tools QtbttExtraFast : 1 # Non-VTM compatible QTBTT speed-ups: 0: disabled, 1: enabled diff --git a/cfg/randomaccess_faster.cfg b/cfg/randomaccess_faster.cfg index 99b86a115..c8d28531b 100644 --- a/cfg/randomaccess_faster.cfg +++ b/cfg/randomaccess_faster.cfg @@ -8,27 +8,43 @@ Profile : auto #======== Coding Structure ============= IntraPeriod : 32 # Period of I-Frame ( -1 = only first) DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) +GOPSize : 32 # GOP Size (number of B slice = GOPSize-1) IntraQPOffset : -3 LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled # Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 +Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 64 48 2 2 32 64 +Frame2 : B 16 0 -4.9309 0.2265 0 0 1.0 0 0 0 0 0 0 1 2 2 16 32 2 2 -16 16 +Frame3 : B 8 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 +Frame4 : B 4 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 3 -4 -12 -28 +Frame5 : B 2 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 4 -2 -6 -14 -30 +Frame6 : B 1 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 -1 2 5 -1 -3 -7 -15 -31 +Frame7 : B 3 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 3 2 4 -1 -5 -13 -29 +Frame8 : B 6 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 6 2 3 -2 -10 -26 +Frame9 : B 5 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 5 2 4 -1 -3 -11 -27 +Frame10 : B 7 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 7 2 3 -1 -9 -25 +Frame11 : B 12 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 12 2 2 -4 -20 +Frame12 : B 10 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 10 2 3 -2 -6 -22 +Frame13 : B 9 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 9 2 4 -1 -3 -7 -23 +Frame14 : B 11 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 11 2 3 -1 -5 -21 +Frame15 : B 14 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 14 2 2 -2 -18 +Frame16 : B 13 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 13 2 3 -1 -3 -19 +Frame17 : B 15 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 15 2 2 -1 -17 +Frame18 : B 24 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 +Frame19 : B 20 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 2 -4 -12 +Frame20 : B 18 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 3 -2 -6 -14 +Frame21 : B 17 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 17 2 4 -1 -3 -7 -15 +Frame22 : B 19 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 19 2 3 -1 -5 -13 +Frame23 : B 22 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 22 2 2 -2 -10 +Frame24 : B 21 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 21 2 3 -1 -3 -11 +Frame25 : B 23 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 23 2 2 -1 -9 +Frame26 : B 28 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 3 4 12 28 2 2 -4 4 +Frame27 : B 26 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 10 26 2 2 -2 -6 +Frame28 : B 25 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 9 25 2 3 -1 -3 -7 +Frame29 : B 27 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 11 27 2 2 -1 -5 +Frame30 : B 30 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 14 30 2 2 -2 2 +Frame31 : B 29 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 13 29 2 2 -1 -3 +Frame32 : B 31 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 15 31 2 2 -1 1 #=========== Motion Search ============= FastSearch : 4 # 0:Full search 1:TZ search @@ -62,10 +78,7 @@ DeblockingFilterMetric : 0 # blockiness metric (automatically c InternalBitDepth : 10 # codec operating bit-depth #=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -#TransformSkip : 0 # Transform skipping (0: OFF, 1: ON) #TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -#TransformSkipLog2MaxSize : 5 #SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) #============ VTM settings ====================== @@ -84,65 +97,67 @@ LCTUFast : 1 DualITree : 1 # separate partitioning of luma and chroma channels for I-slices MinQTLumaISlice : 8 -MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree -MinQTNonISlice : 8 +MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree +MinQTNonISlice : 32 MaxMTTHierarchyDepth : 1 -MaxMTTHierarchyDepthISliceL : 2 -MaxMTTHierarchyDepthISliceC : 2 +MaxMTTHierarchyDepthISliceL : 1 +MaxMTTHierarchyDepthISliceC : 1 # tools not supported by vvc -#MTS : 0 -#MTSIntraMaxCand : 4 -#MTSInterMaxCand : 4 -#ISP : 0 #BCW : 0 #BcwFast : 1 #IBC : 0 # turned off in CTC #AffineAmvr : 0 -#ChromaTS : 0 # tools supported by vvc -MRL : 0 # MultiRefernceLines -MaxNumMergeCand : 6 -LMCSEnable : 0 # LMCS: 0: disable, 1:enable# LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG# Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP# LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -LMCSOffset : 6 # chroma residual scaling offset# chroma residual scaling offset -EncDbOpt : 0 # Encoder optimization with deblocking filter 1:default 2:fast -TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only -LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled -DepQuant : 0 # Dependent quantization: 0: disabled, 1: enabled -MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled -BIO : 0 # Bi-directional optical flow: 0: disabled, 1: enabled -DMVR : 0 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled -JointCbCr : 0 # Joint coding of chroma residuals: 0: disabled, 1: enabled -IMV : 0 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes -ALF : 0 # Adpative Loop Filter: 0: disabled, 1: enabled -CCALF : 0 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled -UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled Affine : 0 # Affine prediction: 0: disabled, 1: vtm, 2: fast -PROF : 0 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled -MIP : 0 # Matrix-based intra prediction: 0: disabled, 1: enabled -MMVD : 0 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes +ALF : 0 # Adpative Loop Filter: 0: disabled, 1: enabled AllowDisFracMMVD : 0 # Disable fractional MVD in MMVD mode adaptively -SMVD : 0 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast -SbTMVP : 0 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled -Geo : 0 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast +BDPCM : 1 # BDPCM (0:off, 1:luma and chroma) +BIO : 0 # Bi-directional optical flow: 0: disabled, 1: enabled +CCALF : 0 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled +ChromaTS : 0 # Chroma transform skip: 0: disabled, 1: enabled CIIP : 0 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster -SBT : 0 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster +DepQuant : 0 # Dependent quantization: 0: disabled, 1: enabled +DMVR : 1 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled +EncDbOpt : 0 # Encoder optimization with deblocking filter 1:default 2:fast +Geo : 0 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast +IMV : 0 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes +ISP : 0 # Intra subpartitions: 0: disabled, 1: enabled, 2: fast, 3: faster +JointCbCr : 0 # Joint coding of chroma residuals: 0: disabled, 1: enabled LFNST : 0 # LFNST: 0: disabled, 1: enabled +LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +LMCSEnable : 0 # LMCS: 0: disable, 1:enable +LMCSOffset : 6 # chroma residual scaling offset +LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG +LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP +MaxNumMergeCand : 6 MCTF : 0 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames +MIP : 0 # Matrix-based intra prediction: 0: disabled, 1: enabled +MMVD : 0 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes +MRL : 0 # MultiRefernceLines +MTS : 0 # Multiple transform selection: 0: disabled, 1: enabled +MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +PROF : 0 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +SAO : 1 # Sample adaptive offset, 0: disabled, 1: enabled +SBT : 0 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster +SbTMVP : 0 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled +SMVD : 0 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast +TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only +TransformSkip : 2 # Transform skipping, 0: disabled, 1: enabled, 2: adaptive +TransformSkipLog2MaxSize : 3 +UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled +UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -# Fast tools +# Fast tools QtbttExtraFast : 1 # Non-VTM compatible QTBTT speed-ups: 0: disabled, 1: enabled ContentBasedFastQtbt : 1 # Signal based QTBT speed-up: 0: disabled, 1: enabled PBIntraFast : 1 # Fast assertion if the intra mode is probable: 0: disabled, 1: enabled -#ISPFast : 0 +#ISPFast : 0 FastMrg : 2 # Fast methods for inter merge: 0: disabled, 1: vtm, 2: fast AMaxBT : 1 # Adaptive maximal BT-size: 0: disabled, 1: enable FastMIP : 0 # Fast encoder search for MIP 0: disable, 1:vtm, 2-4: fast -#FastLFNST : 0 +#FastLFNST : 0 FastLocalDualTreeMode : 1 # Fast intra pass coding for local dual-tree in intra coding region: 0: disable, 1: use threshold, 2: one intra mode only FastSubPel : 1 # Fast sub-pel ME: 0: disabled, 1: enabled diff --git a/cfg/randomaccess_medium.cfg b/cfg/randomaccess_medium.cfg index fdd779344..620fcf21a 100644 --- a/cfg/randomaccess_medium.cfg +++ b/cfg/randomaccess_medium.cfg @@ -8,27 +8,43 @@ Profile : auto #======== Coding Structure ============= IntraPeriod : 32 # Period of I-Frame ( -1 = only first) DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) +GOPSize : 32 # GOP Size (number of B slice = GOPSize-1) IntraQPOffset : -3 LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled # Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 +Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 64 48 2 2 32 64 +Frame2 : B 16 0 -4.9309 0.2265 0 0 1.0 0 0 0 0 0 0 1 2 2 16 32 2 2 -16 16 +Frame3 : B 8 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 +Frame4 : B 4 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 3 -4 -12 -28 +Frame5 : B 2 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 4 -2 -6 -14 -30 +Frame6 : B 1 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 -1 2 5 -1 -3 -7 -15 -31 +Frame7 : B 3 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 3 2 4 -1 -5 -13 -29 +Frame8 : B 6 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 6 2 3 -2 -10 -26 +Frame9 : B 5 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 5 2 4 -1 -3 -11 -27 +Frame10 : B 7 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 7 2 3 -1 -9 -25 +Frame11 : B 12 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 12 2 2 -4 -20 +Frame12 : B 10 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 10 2 3 -2 -6 -22 +Frame13 : B 9 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 9 2 4 -1 -3 -7 -23 +Frame14 : B 11 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 11 2 3 -1 -5 -21 +Frame15 : B 14 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 14 2 2 -2 -18 +Frame16 : B 13 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 13 2 3 -1 -3 -19 +Frame17 : B 15 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 15 2 2 -1 -17 +Frame18 : B 24 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 +Frame19 : B 20 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 2 -4 -12 +Frame20 : B 18 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 3 -2 -6 -14 +Frame21 : B 17 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 17 2 4 -1 -3 -7 -15 +Frame22 : B 19 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 19 2 3 -1 -5 -13 +Frame23 : B 22 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 22 2 2 -2 -10 +Frame24 : B 21 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 21 2 3 -1 -3 -11 +Frame25 : B 23 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 23 2 2 -1 -9 +Frame26 : B 28 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 3 4 12 28 2 2 -4 4 +Frame27 : B 26 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 10 26 2 2 -2 -6 +Frame28 : B 25 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 9 25 2 3 -1 -3 -7 +Frame29 : B 27 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 11 27 2 2 -1 -5 +Frame30 : B 30 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 14 30 2 2 -2 2 +Frame31 : B 29 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 13 29 2 2 -1 -3 +Frame32 : B 31 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 15 31 2 2 -1 1 #=========== Motion Search ============= FastSearch : 4 # 0:Full search 1:TZ search @@ -62,10 +78,7 @@ DeblockingFilterMetric : 0 # blockiness metric (automatically c InternalBitDepth : 10 # codec operating bit-depth #=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -#TransformSkip : 0 # Transform skipping (0: OFF, 1: ON) #TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -#TransformSkipLog2MaxSize : 5 #SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) #============ VTM settings ====================== @@ -84,65 +97,67 @@ LCTUFast : 1 DualITree : 1 # separate partitioning of luma and chroma channels for I-slices MinQTLumaISlice : 8 -MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree +MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree MinQTNonISlice : 8 MaxMTTHierarchyDepth : 1 MaxMTTHierarchyDepthISliceL : 2 MaxMTTHierarchyDepthISliceC : 2 # tools not supported by vvc -#MTS : 0 -#MTSIntraMaxCand : 4 -#MTSInterMaxCand : 4 -#ISP : 0 #BCW : 0 #BcwFast : 1 #IBC : 0 # turned off in CTC #AffineAmvr : 0 -#ChromaTS : 0 # tools supported by vvc -MRL : 1 # MultiRefernceLines -MaxNumMergeCand : 6 -LMCSEnable : 1 # LMCS: 0: disable, 1:enable# LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG# Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP# LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -LMCSOffset : 6 # chroma residual scaling offset# chroma residual scaling offset -EncDbOpt : 1 # Encoder optimization with deblocking filter 1:default 2:fast -TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only -LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled -DepQuant : 1 # Dependent quantization: 0: disabled, 1: enabled -MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +Affine : 2 # Affine prediction: 0: disabled, 1: vtm, 2: fast +ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled +AllowDisFracMMVD : 1 # Disable fractional MVD in MMVD mode adaptively +BDPCM : 1 # BDPCM (0:off, 1:luma and chroma) BIO : 1 # Bi-directional optical flow: 0: disabled, 1: enabled +CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled +ChromaTS : 0 # Chroma transform skip: 0: disabled, 1: enabled +CIIP : 0 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +DepQuant : 1 # Dependent quantization: 0: disabled, 1: enabled DMVR : 1 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled -JointCbCr : 1 # Joint coding of chroma residuals: 0: disabled, 1: enabled +EncDbOpt : 2 # Encoder optimization with deblocking filter 1:default 2:fast +Geo : 3 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast IMV : 5 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes -ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled -CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled -UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled -Affine : 2 # Affine prediction: 0: disabled, 1: vtm, 2: fast -PROF : 1 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +ISP : 0 # Intra subpartitions: 0: disabled, 1: enabled, 2: fast, 3: faster +JointCbCr : 1 # Joint coding of chroma residuals: 0: disabled, 1: enabled +LFNST : 1 # LFNST: 0: disabled, 1: enabled +LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +LMCSEnable : 1 # LMCS: 0: disable, 1:enable +LMCSOffset : 6 # chroma residual scaling offset +LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG +LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP +MaxNumMergeCand : 6 +MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames MIP : 1 # Matrix-based intra prediction: 0: disabled, 1: enabled MMVD : 3 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes -AllowDisFracMMVD : 1 # Disable fractional MVD in MMVD mode adaptively -SMVD : 3 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast -SbTMVP : 1 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled -Geo : 3 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast -CIIP : 0 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +MRL : 1 # MultiRefernceLines +MTS : 0 # Multiple transform selection: 0: disabled, 1: enabled +MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +PROF : 1 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +SAO : 1 # Sample adaptive offset, 0: disabled, 1: enabled SBT : 0 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster -LFNST : 1 # LFNST: 0: disabled, 1: enabled -MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames +SbTMVP : 1 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled +SMVD : 3 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast +TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only +TransformSkip : 2 # Transform skipping, 0: disabled, 1: enabled, 2: adaptive +TransformSkipLog2MaxSize : 3 +UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled +UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -# Fast tools +# Fast tools QtbttExtraFast : 1 # Non-VTM compatible QTBTT speed-ups: 0: disabled, 1: enabled ContentBasedFastQtbt : 1 # Signal based QTBT speed-up: 0: disabled, 1: enabled PBIntraFast : 1 # Fast assertion if the intra mode is probable: 0: disabled, 1: enabled -#ISPFast : 0 +#ISPFast : 0 FastMrg : 2 # Fast methods for inter merge: 0: disabled, 1: vtm, 2: fast AMaxBT : 1 # Adaptive maximal BT-size: 0: disabled, 1: enable FastMIP : 4 # Fast encoder search for MIP 0: disable, 1:vtm, 2-4: fast -#FastLFNST : 0 +#FastLFNST : 0 FastLocalDualTreeMode : 1 # Fast intra pass coding for local dual-tree in intra coding region: 0: disable, 1: use threshold, 2: one intra mode only FastSubPel : 1 # Fast sub-pel ME: 0: disabled, 1: enabled diff --git a/cfg/randomaccess_slow.cfg b/cfg/randomaccess_slow.cfg index 5d1fcd067..6a62b7fb9 100644 --- a/cfg/randomaccess_slow.cfg +++ b/cfg/randomaccess_slow.cfg @@ -8,27 +8,43 @@ Profile : auto #======== Coding Structure ============= IntraPeriod : 32 # Period of I-Frame ( -1 = only first) DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) +GOPSize : 32 # GOP Size (number of B slice = GOPSize-1) IntraQPOffset : -3 LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled # Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 +Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 64 48 2 2 32 64 +Frame2 : B 16 0 -4.9309 0.2265 0 0 1.0 0 0 0 0 0 0 1 2 2 16 32 2 2 -16 16 +Frame3 : B 8 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 +Frame4 : B 4 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 3 -4 -12 -28 +Frame5 : B 2 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 4 -2 -6 -14 -30 +Frame6 : B 1 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 -1 2 5 -1 -3 -7 -15 -31 +Frame7 : B 3 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 3 2 4 -1 -5 -13 -29 +Frame8 : B 6 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 6 2 3 -2 -10 -26 +Frame9 : B 5 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 5 2 4 -1 -3 -11 -27 +Frame10 : B 7 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 7 2 3 -1 -9 -25 +Frame11 : B 12 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 12 2 2 -4 -20 +Frame12 : B 10 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 10 2 3 -2 -6 -22 +Frame13 : B 9 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 9 2 4 -1 -3 -7 -23 +Frame14 : B 11 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 11 2 3 -1 -5 -21 +Frame15 : B 14 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 14 2 2 -2 -18 +Frame16 : B 13 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 13 2 3 -1 -3 -19 +Frame17 : B 15 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 15 2 2 -1 -17 +Frame18 : B 24 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 +Frame19 : B 20 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 2 -4 -12 +Frame20 : B 18 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 3 -2 -6 -14 +Frame21 : B 17 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 17 2 4 -1 -3 -7 -15 +Frame22 : B 19 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 19 2 3 -1 -5 -13 +Frame23 : B 22 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 22 2 2 -2 -10 +Frame24 : B 21 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 21 2 3 -1 -3 -11 +Frame25 : B 23 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 23 2 2 -1 -9 +Frame26 : B 28 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 3 4 12 28 2 2 -4 4 +Frame27 : B 26 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 10 26 2 2 -2 -6 +Frame28 : B 25 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 9 25 2 3 -1 -3 -7 +Frame29 : B 27 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 11 27 2 2 -1 -5 +Frame30 : B 30 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 14 30 2 2 -2 2 +Frame31 : B 29 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 13 29 2 2 -1 -3 +Frame32 : B 31 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 15 31 2 2 -1 1 #=========== Motion Search ============= FastSearch : 4 # 0:Full search 1:TZ search @@ -62,10 +78,7 @@ DeblockingFilterMetric : 0 # blockiness metric (automatically c InternalBitDepth : 10 # codec operating bit-depth #=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -#TransformSkip : 0 # Transform skipping (0: OFF, 1: ON) #TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -#TransformSkipLog2MaxSize : 5 #SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) #============ VTM settings ====================== @@ -84,65 +97,67 @@ LCTUFast : 1 DualITree : 1 # separate partitioning of luma and chroma channels for I-slices MinQTLumaISlice : 8 -MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree +MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree MinQTNonISlice : 8 MaxMTTHierarchyDepth : 2 MaxMTTHierarchyDepthISliceL : 3 MaxMTTHierarchyDepthISliceC : 3 # tools not supported by vvc -#MTS : 0 -#MTSIntraMaxCand : 4 -#MTSInterMaxCand : 4 -#ISP : 0 #BCW : 0 #BcwFast : 1 #IBC : 0 # turned off in CTC #AffineAmvr : 0 -#ChromaTS : 0 # tools supported by vvc -MRL : 1 # MultiRefernceLines -MaxNumMergeCand : 6 -LMCSEnable : 1 # LMCS: 0: disable, 1:enable# LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG# Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP# LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -LMCSOffset : 6 # chroma residual scaling offset# chroma residual scaling offset -EncDbOpt : 1 # Encoder optimization with deblocking filter 1:default 2:fast -TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only -LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled -DepQuant : 1 # Dependent quantization: 0: disabled, 1: enabled -MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +Affine : 2 # Affine prediction: 0: disabled, 1: vtm, 2: fast +ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled +AllowDisFracMMVD : 1 # Disable fractional MVD in MMVD mode adaptively +BDPCM : 1 # BDPCM (0:off, 1:luma and chroma) BIO : 1 # Bi-directional optical flow: 0: disabled, 1: enabled +CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled +ChromaTS : 0 # Chroma transform skip: 0: disabled, 1: enabled +CIIP : 1 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +DepQuant : 1 # Dependent quantization: 0: disabled, 1: enabled DMVR : 1 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled -JointCbCr : 1 # Joint coding of chroma residuals: 0: disabled, 1: enabled +EncDbOpt : 2 # Encoder optimization with deblocking filter 1:default 2:fast +Geo : 1 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast IMV : 1 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes -ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled -CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled -UseNonLinearAlfLuma : 1 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -UseNonLinearAlfChroma : 1 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled -Affine : 2 # Affine prediction: 0: disabled, 1: vtm, 2: fast -PROF : 1 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +ISP : 3 # Intra subpartitions: 0: disabled, 1: enabled, 2: fast, 3: faster +JointCbCr : 1 # Joint coding of chroma residuals: 0: disabled, 1: enabled +LFNST : 1 # LFNST: 0: disabled, 1: enabled +LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +LMCSEnable : 1 # LMCS: 0: disable, 1:enable +LMCSOffset : 6 # chroma residual scaling offset +LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG +LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP +MaxNumMergeCand : 6 +MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames MIP : 1 # Matrix-based intra prediction: 0: disabled, 1: enabled MMVD : 3 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes -AllowDisFracMMVD : 1 # Disable fractional MVD in MMVD mode adaptively -SMVD : 3 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast -SbTMVP : 1 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled -Geo : 1 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast -CIIP : 1 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +MRL : 1 # MultiRefernceLines +MTS : 0 # Multiple transform selection: 0: disabled, 1: enabled +MTSImplicit : 1 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +PROF : 1 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +SAO : 1 # Sample adaptive offset, 0: disabled, 1: enabled SBT : 1 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster -LFNST : 1 # LFNST: 0: disabled, 1: enabled -MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames +SbTMVP : 1 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled +SMVD : 3 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast +TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only +TransformSkip : 2 # Transform skipping, 0: disabled, 1: enabled, 2: adaptive +TransformSkipLog2MaxSize : 3 +UseNonLinearAlfChroma : 0 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled +UseNonLinearAlfLuma : 0 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled -# Fast tools +# Fast tools QtbttExtraFast : 1 # Non-VTM compatible QTBTT speed-ups: 0: disabled, 1: enabled ContentBasedFastQtbt : 0 # Signal based QTBT speed-up: 0: disabled, 1: enabled PBIntraFast : 1 # Fast assertion if the intra mode is probable: 0: disabled, 1: enabled -#ISPFast : 0 +#ISPFast : 0 FastMrg : 2 # Fast methods for inter merge: 0: disabled, 1: vtm, 2: fast AMaxBT : 1 # Adaptive maximal BT-size: 0: disabled, 1: enable FastMIP : 4 # Fast encoder search for MIP 0: disable, 1:vtm, 2-4: fast -#FastLFNST : 0 +#FastLFNST : 0 FastLocalDualTreeMode : 1 # Fast intra pass coding for local dual-tree in intra coding region: 0: disable, 1: use threshold, 2: one intra mode only FastSubPel : 1 # Fast sub-pel ME: 0: disabled, 1: enabled diff --git a/cfg/gop32.cfg b/cfg/randomaccess_slower.cfg similarity index 54% rename from cfg/gop32.cfg rename to cfg/randomaccess_slower.cfg index b006e5a01..7916138ca 100644 --- a/cfg/gop32.cfg +++ b/cfg/randomaccess_slower.cfg @@ -1,9 +1,21 @@ +#======== File I/O ===================== +BitstreamFile : str.bin +ReconFile : rec.yuv + +#======== Profile ================ +Profile : auto + +#======== Coding Structure ============= +IntraPeriod : 32 # Period of I-Frame ( -1 = only first) +DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI GOPSize : 32 # GOP Size (number of B slice = GOPSize-1) +IntraQPOffset : -3 +LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled # Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 48 64 2 2 32 48 +Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 64 48 2 2 32 64 Frame2 : B 16 0 -4.9309 0.2265 0 0 1.0 0 0 0 0 0 0 1 2 2 16 32 2 2 -16 16 -Frame3 : B 8 1 -5.4095 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 +Frame3 : B 8 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 Frame4 : B 4 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 3 -4 -12 -28 Frame5 : B 2 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 4 -2 -6 -14 -30 Frame6 : B 1 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 -1 2 5 -1 -3 -7 -15 -31 @@ -18,7 +30,7 @@ Frame14 : B 11 6 -5.4429 0.242 Frame15 : B 14 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 14 2 2 -2 -18 Frame16 : B 13 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 13 2 3 -1 -3 -19 Frame17 : B 15 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 15 2 2 -1 -17 -Frame18 : B 24 1 -5.4095 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 +Frame18 : B 24 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 Frame19 : B 20 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 2 -4 -12 Frame20 : B 18 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 3 -2 -6 -14 Frame21 : B 17 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 17 2 4 -1 -3 -7 -15 @@ -34,6 +46,126 @@ Frame30 : B 30 5 -4.4895 0.194 Frame31 : B 29 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 13 29 2 2 -1 -3 Frame32 : B 31 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 15 31 2 2 -1 1 +#=========== Motion Search ============= +FastSearch : 1 # 0:Full search 1:TZ search +SearchRange : 384 # (0: Search range is a Full frame) +ASR : 1 # Adaptive motion search range +MinSearchWindow : 96 # Minimum motion search window size for the adaptive window ME +BipredSearchRange : 4 # Search range for bi-prediction refinement +HadamardME : 1 # Use of hadamard measure for fractional ME +FEN : 1 # Fast encoder decision +FDM : 1 # Fast Decision for Merge RD cost + +#======== Quantization ============= +QP : 32 # Quantization parameter(0-51) +MaxCuDQPSubdiv : 0 # Maximum subdiv for CU luma Qp adjustment +RDOQ : 1 # RDOQ +RDOQTS : 1 # RDOQ for transform skip +SignHideFlag : 0 + +#=========== Deblock Filter ============ +LoopFilterOffsetInPPS : 1 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1 (default) =constant params in PPS, param = base_param) +LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter) +LoopFilterBetaOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterTcOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCbBetaOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCbTcOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCrBetaOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCrTcOffset_div2 : 0 # base_param: -12 ~ 12 +DeblockingFilterMetric : 0 # blockiness metric (automatically configures deblocking parameters in bitstream). Applies slice-level loop filter offsets (LoopFilterOffsetInPPS and LoopFilterDisable must be 0) + +#=========== Misc. ============ +InternalBitDepth : 10 # codec operating bit-depth + +#=========== Coding Tools ================= +#TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) +#SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) + +#============ VTM settings ====================== +SEIDecodedPictureHash : 0 +CbQpOffset : 0 +CrQpOffset : 0 +SameCQPTablesForAllChroma : 1 +QpInValCb : 17 22 34 42 +QpOutValCb : 17 23 35 39 +ReWriteParamSets : 1 +#============ NEXT ==================== + +# General +CTUSize : 128 +LCTUFast : 1 + +DualITree : 1 # separate partitioning of luma and chroma channels for I-slices +MinQTLumaISlice : 8 +MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree +MinQTNonISlice : 8 +MaxMTTHierarchyDepth : 3 +MaxMTTHierarchyDepthISliceL : 3 +MaxMTTHierarchyDepthISliceC : 3 + +# tools not supported by vvc +#BCW : 0 +#BcwFast : 1 +#IBC : 0 # turned off in CTC +#AffineAmvr : 0 + +# tools supported by vvc +Affine : 1 # Affine prediction: 0: disabled, 1: vtm, 2: fast +ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled +AllowDisFracMMVD : 1 # Disable fractional MVD in MMVD mode adaptively +BDPCM : 1 # BDPCM (0:off, 1:luma and chroma) +BIO : 1 # Bi-directional optical flow: 0: disabled, 1: enabled +CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled +ChromaTS : 0 # Chroma transform skip: 0: disabled, 1: enabled +CIIP : 1 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +DepQuant : 1 # Dependent quantization: 0: disabled, 1: enabled +DMVR : 1 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled +EncDbOpt : 2 # Encoder optimization with deblocking filter 1:default 2:fast +Geo : 1 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast +IMV : 1 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes +ISP : 1 # Intra subpartitions: 0: disabled, 1: enabled, 2: fast, 3: faster +JointCbCr : 1 # Joint coding of chroma residuals: 0: disabled, 1: enabled +LFNST : 1 # LFNST: 0: disabled, 1: enabled +LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +LMCSEnable : 1 # LMCS: 0: disable, 1:enable +LMCSOffset : 6 # chroma residual scaling offset +LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG +LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP +MaxNumMergeCand : 6 +MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames +MIP : 1 # Matrix-based intra prediction: 0: disabled, 1: enabled +MMVD : 1 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes +MRL : 1 # MultiRefernceLines +MTS : 1 # Multiple transform selection: 0: disabled, 1: enabled +MTSImplicit : 0 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +PROF : 1 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +SAO : 1 # Sample adaptive offset, 0: disabled, 1: enabled +SBT : 1 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster +SbTMVP : 1 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled +SMVD : 1 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast +TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only +TransformSkip : 2 # Transform skipping, 0: disabled, 1: enabled, 2: adaptive +TransformSkipLog2MaxSize : 3 +UseNonLinearAlfChroma : 1 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled +UseNonLinearAlfLuma : 1 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled + +# Fast tools +QtbttExtraFast : 0 # Non-VTM compatible QTBTT speed-ups: 0: disabled, 1: enabled +ContentBasedFastQtbt : 0 # Signal based QTBT speed-up: 0: disabled, 1: enabled +PBIntraFast : 1 # Fast assertion if the intra mode is probable: 0: disabled, 1: enabled +#ISPFast : 0 +FastMrg : 1 # Fast methods for inter merge: 0: disabled, 1: vtm, 2: fast +AMaxBT : 1 # Adaptive maximal BT-size: 0: disabled, 1: enable +FastMIP : 0 # Fast encoder search for MIP 0: disable, 1:vtm, 2-4: fast +#FastLFNST : 0 +FastLocalDualTreeMode : 1 # Fast intra pass coding for local dual-tree in intra coding region: 0: disable, 1: use threshold, 2: one intra mode only +FastSubPel : 0 # Fast sub-pel ME: 0: disabled, 1: enabled + +# Encoder optimization tools +#AffineAmvrEncOpt : 1 +#MmvdDisNum : 6 +### DO NOT ADD ANYTHING BELOW THIS LINE ### +### DO NOT DELETE THE EMPTY LINE BELOW ### diff --git a/cfg/randomaccess_tooltest.cfg b/cfg/randomaccess_tooltest.cfg new file mode 100644 index 000000000..bbe8c3f66 --- /dev/null +++ b/cfg/randomaccess_tooltest.cfg @@ -0,0 +1,171 @@ +#======== File I/O ===================== +BitstreamFile : str.bin +ReconFile : rec.yuv + +#======== Profile ================ +Profile : auto + +#======== Coding Structure ============= +IntraPeriod : 32 # Period of I-Frame ( -1 = only first) +DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI +GOPSize : 32 # GOP Size (number of B slice = GOPSize-1) + +IntraQPOffset : -3 +LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled +# Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 +Frame1 : B 32 -1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 32 64 48 2 2 32 64 +Frame2 : B 16 0 -4.9309 0.2265 0 0 1.0 0 0 0 0 0 0 1 2 2 16 32 2 2 -16 16 +Frame3 : B 8 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 -24 +Frame4 : B 4 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 3 -4 -12 -28 +Frame5 : B 2 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 4 -2 -6 -14 -30 +Frame6 : B 1 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 -1 2 5 -1 -3 -7 -15 -31 +Frame7 : B 3 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 3 2 4 -1 -5 -13 -29 +Frame8 : B 6 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 6 2 3 -2 -10 -26 +Frame9 : B 5 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 5 2 4 -1 -3 -11 -27 +Frame10 : B 7 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 7 2 3 -1 -9 -25 +Frame11 : B 12 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 12 2 2 -4 -20 +Frame12 : B 10 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 10 2 3 -2 -6 -22 +Frame13 : B 9 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 9 2 4 -1 -3 -7 -23 +Frame14 : B 11 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 11 2 3 -1 -5 -21 +Frame15 : B 14 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 14 2 2 -2 -18 +Frame16 : B 13 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 13 2 3 -1 -3 -19 +Frame17 : B 15 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 15 2 2 -1 -17 +Frame18 : B 24 0 -4.5000 0.2353 0 0 1.0 0 0 0 0 0 0 2 2 2 8 24 2 2 -8 8 +Frame19 : B 20 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 2 4 20 2 2 -4 -12 +Frame20 : B 18 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 2 2 18 2 3 -2 -6 -14 +Frame21 : B 17 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 2 1 17 2 4 -1 -3 -7 -15 +Frame22 : B 19 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 3 19 2 3 -1 -5 -13 +Frame23 : B 22 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 6 22 2 2 -2 -10 +Frame24 : B 21 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 5 21 2 3 -1 -3 -11 +Frame25 : B 23 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 7 23 2 2 -1 -9 +Frame26 : B 28 3 -5.4095 0.2571 0 0 1.0 0 0 0 0 0 0 3 2 3 4 12 28 2 2 -4 4 +Frame27 : B 26 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 10 26 2 2 -2 -6 +Frame28 : B 25 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 9 25 2 3 -1 -3 -7 +Frame29 : B 27 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 11 27 2 2 -1 -5 +Frame30 : B 30 5 -4.4895 0.1947 0 0 1.0 0 0 0 0 0 0 4 2 3 2 14 30 2 2 -2 2 +Frame31 : B 29 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 3 1 13 29 2 2 -1 -3 +Frame32 : B 31 6 -5.4429 0.2429 0 0 1.0 0 0 0 0 0 0 5 2 4 1 3 15 31 2 2 -1 1 + +#=========== Motion Search ============= +FastSearch : 4 # 0:Full search 1:TZ search +SearchRange : 384 # (0: Search range is a Full frame) +ASR : 1 # Adaptive motion search range +MinSearchWindow : 96 # Minimum motion search window size for the adaptive window ME +BipredSearchRange : 4 # Search range for bi-prediction refinement +HadamardME : 1 # Use of hadamard measure for fractional ME +FEN : 1 # Fast encoder decision +FDM : 1 # Fast Decision for Merge RD cost + +#======== Quantization ============= +QP : 32 # Quantization parameter(0-51) +MaxCuDQPSubdiv : 0 # Maximum subdiv for CU luma Qp adjustment +RDOQ : 1 # RDOQ +RDOQTS : 1 # RDOQ for transform skip +SignHideFlag : 0 + +#=========== Deblock Filter ============ +LoopFilterOffsetInPPS : 1 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1 (default) =constant params in PPS, param = base_param) +LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter) +LoopFilterBetaOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterTcOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCbBetaOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCbTcOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCrBetaOffset_div2 : 0 # base_param: -12 ~ 12 +LoopFilterCrTcOffset_div2 : 0 # base_param: -12 ~ 12 +DeblockingFilterMetric : 0 # blockiness metric (automatically configures deblocking parameters in bitstream). Applies slice-level loop filter offsets (LoopFilterOffsetInPPS and LoopFilterDisable must be 0) + +#=========== Misc. ============ +InternalBitDepth : 10 # codec operating bit-depth + +#=========== Coding Tools ================= +#TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) +#SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) + +#============ VTM settings ====================== +SEIDecodedPictureHash : 0 +CbQpOffset : 0 +CrQpOffset : 0 +SameCQPTablesForAllChroma : 1 +QpInValCb : 17 22 34 42 +QpOutValCb : 17 23 35 39 +ReWriteParamSets : 1 +#============ NEXT ==================== + +# General +CTUSize : 128 +LCTUFast : 1 + +DualITree : 1 # separate partitioning of luma and chroma channels for I-slices +MinQTLumaISlice : 8 +MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree +MinQTNonISlice : 8 +MaxMTTHierarchyDepth : 1 +MaxMTTHierarchyDepthISliceL : 2 +MaxMTTHierarchyDepthISliceC : 2 + +# tools not supported by vvc +#BCW : 0 +#BcwFast : 1 +#IBC : 0 # turned off in CTC +#AffineAmvr : 0 + +# tools supported by vvc +Affine : 2 # Affine prediction: 0: disabled, 1: vtm, 2: fast +ALF : 1 # Adpative Loop Filter: 0: disabled, 1: enabled +AllowDisFracMMVD : 1 # Disable fractional MVD in MMVD mode adaptively +BDPCM : 1 # BDPCM (0:off, 1:luma and chroma) +BIO : 1 # Bi-directional optical flow: 0: disabled, 1: enabled +CCALF : 1 # Cross-component Adaptive Loop Filter: 0: disabled, 1: enabled +ChromaTS : 0 # Chroma transform skip: 0: disabled, 1: enabled +CIIP : 3 # CIIP mode: 0: disable, 1: vtm, 2: fast, 3: faster +DepQuant : 1 # Dependent quantization: 0: disabled, 1: enabled +DMVR : 1 # Decoder-side Motion Vector Refinement: 0: disabled, 1: enabled +EncDbOpt : 1 # Encoder optimization with deblocking filter 1:default 2:fast +Geo : 2 # Geometric partitioning mode: 0: disabled, 1: vtm, 2: good quality, 3: fast +IMV : 3 # Adaptive MV precision Mode (IMV): 0: disabled, 1:vtm, 2-7: fast modes +ISP : 2 # Intra subpartitions: 0: disabled, 1: enabled, 2: fast, 3: faster +JointCbCr : 1 # Joint coding of chroma residuals: 0: disabled, 1: enabled +LFNST : 1 # LFNST: 0: disabled, 1: enabled +LMChroma : 1 # LMChroma prediction: 0: disabled, 1: enabled +LMCSEnable : 1 # LMCS: 0: disable, 1:enable +LMCSOffset : 6 # chroma residual scaling offset +LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG +LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP +MaxNumMergeCand : 6 +MCTF : 2 # GOP based Motion compensated temporal filter: 0: disabled, 1: filter all but the first and last frame, 2: filter all frames +MIP : 1 # Matrix-based intra prediction: 0: disabled, 1: enabled +MMVD : 2 # Merge mode with Motion Vector Difference: 0: disabled, 1: vtm, 2-4 fast modes +MRL : 1 # MultiRefernceLines +MTS : 1 # Multiple transform selection: 0: disabled, 1: enabled +MTSImplicit : 0 # Implicit MTS (when explicit MTS is off): 0: disabled, 1: enabled +PROF : 1 # Prediction refinement with optical flow for affine mode: 0: disabled, 1: enabled +SAO : 1 # Sample adaptive offset, 0: disabled, 1: enabled +SBT : 2 # Sub-Block Transform for inter blocks: 0: disable, 1: vtm, 2: fast, 3: faster +SbTMVP : 1 # Subblock Temporal Motion Vector Prediction: 0: disabled, 1: enabled +SMVD : 3 # Symmetric MVD 0: disable, 1: vtm, 2: good quality, 3: fast +TMVPMode : 1 # TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices 2: TMVP enable for certain slices only +TransformSkip : 1 # Transform skipping, 0: disabled, 1: enabled, 2: adaptive +TransformSkipLog2MaxSize : 3 +UseNonLinearAlfChroma : 1 # Non-linear adaptive loop filters for Chroma Channels: 0: disabled, 1: enabled +UseNonLinearAlfLuma : 1 # Non-linear adaptive loop filters for Luma Channel: 0: disabled, 1: enabled + +# Fast tools +QtbttExtraFast : 1 # Non-VTM compatible QTBTT speed-ups: 0: disabled, 1: enabled +ContentBasedFastQtbt : 1 # Signal based QTBT speed-up: 0: disabled, 1: enabled +PBIntraFast : 1 # Fast assertion if the intra mode is probable: 0: disabled, 1: enabled +#ISPFast : 0 +FastMrg : 2 # Fast methods for inter merge: 0: disabled, 1: vtm, 2: fast +AMaxBT : 1 # Adaptive maximal BT-size: 0: disabled, 1: enable +FastMIP : 4 # Fast encoder search for MIP 0: disable, 1:vtm, 2-4: fast +#FastLFNST : 0 +FastLocalDualTreeMode : 1 # Fast intra pass coding for local dual-tree in intra coding region: 0: disable, 1: use threshold, 2: one intra mode only +FastSubPel : 1 # Fast sub-pel ME: 0: disabled, 1: enabled + +# Encoder optimization tools +#AffineAmvrEncOpt : 1 +#MmvdDisNum : 6 +### DO NOT ADD ANYTHING BELOW THIS LINE ### +### DO NOT DELETE THE EMPTY LINE BELOW ### + + + diff --git a/cfg/rc2p.cfg b/cfg/rc2p.cfg new file mode 100644 index 000000000..4440a2949 --- /dev/null +++ b/cfg/rc2p.cfg @@ -0,0 +1,8 @@ +#============ Rate Control ====================== +RateControl : 2 # Rate control: enable rate control +TargetBitrate : 1000000 # Rate control: target bitrate, in bps +KeepHierarchicalBit : 2 # Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation +RCLCUSeparateModel : 1 # Rate control: use LCU level separate R-lambda model +InitialQP : 0 # Rate control: initial QP +RCForceIntraQP : 0 # Rate control: force intra QP to be equal to initial QP +NumPasses : 2 # Rate control: number of passes diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 000000000..41b6a841c --- /dev/null +++ b/changelog.txt @@ -0,0 +1,60 @@ +///////////////////////////////////////// +tag 0.2.0.0 + +* new license + - switched to modified 3-clause BSD + +* bugfixes: + - access unit delimiter (AUD) generation + - DPH-SEI syntax + +* new features: + - ISP + - TS (with automatic screen-content detection) + - BDPCM + - 2-pass rate control + - 1-pass rate control with GOP32 + +* libvvenc: + - added "slower" preset + - redefined the presets according to current pareto-set + - removed PredictionUnit type + - various memory reductions (Rom.cpp, scaling list memory) + - verious optimizations (SIMD for MCTF, forward transformation, single column IF; memory accesses for DMVR) + - changed MCTF algorithm to do intermediate rounding between hor/ver filtering + +* vvencapp: + - new parameter --refreshsec,-rs to define the intra refresh rate in seconds depending on the given frame rate. + Internally, the refresh rate in seconds is translated into the frames where the refresh is set. + --internal-bitdepth to define the internal bit-depth used in bitstream (default: 10). + --passes to control number of passes for rate-control + --segment to control chunkwise encoding configuration + - changed parameter --intraperiod,-ip is 0 per default because --refreshsec is used for that purpose instead. + In case of a value greater than 0, intraperiod overwrites refreshsec. + Abbreviation -q is now supported in addition to --qp. + --gopsize default changed to 32 + - fullhelp changed All internal encoding parameters are now shown as strings when --fullhelp is called. + +* build system: + - using GnuInstallDirs + - added basic tests + - versioning using CMake + - added support for address sanitizer + +///////////////////////////////////////// +tag 0.1.0.1 + +* libvvenc: + - VVEnc::init() correctly initializes SIMD for transformation (TrafoX86) and sample operations (BufferX86). + +* vvencapp: + - Improved speed because of the bugfix to libvvenc. + +///////////////////////////////////////// +tag 0.1.0.0 + +* initial version + +///////////////////////////////////////// + + diff --git a/cmake/install/VVEncConfig.cmake b/cmake/install/VVEncConfig.cmake deleted file mode 100644 index e08396b06..000000000 --- a/cmake/install/VVEncConfig.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# VVEncConfig.cmake - package configuration file - -# get current directory -get_filename_component( SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) - -if( DEFINED VVEnc_USE_SHARED_LIBS ) - if( VVEnc_USE_SHARED_LIBS ) - include( ${SELF_DIR}/shared/VVEncTargets.cmake ) - else() - include( ${SELF_DIR}/static/VVEncTargets.cmake ) - endif() -else() - if( BUILD_SHARED_LIBS ) - include( ${SELF_DIR}/shared/VVEncTargets.cmake ) - else() - include( ${SELF_DIR}/static/VVEncTargets.cmake ) - endif() -endif() diff --git a/cmake/install/vvencConfig.cmake b/cmake/install/vvencConfig.cmake new file mode 100644 index 000000000..c9f59e395 --- /dev/null +++ b/cmake/install/vvencConfig.cmake @@ -0,0 +1,33 @@ +# vvencConfig.cmake - package configuration file + +# get current directory +get_filename_component( SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) + +# detect state +if( DEFINED vvenc_USE_SHARED_LIBS ) + if( vvenc_USE_SHARED_LIBS ) + set( USE_SHARED TRUE ) + else() + set( USE_SHARED FALSE ) + endif() +else() + if( BUILD_SHARED_LIBS ) + set( USE_SHARED TRUE ) + else() + set( USE_SHARED FALSE ) + endif() +endif() + +if( USE_SHARED ) + if( EXISTS ${SELF_DIR}/vvencTargets-shared.cmake ) + include( ${SELF_DIR}/vvencTargets-shared.cmake ) + else() + include( ${SELF_DIR}/vvencTargets-static.cmake ) + endif() +else() + if( EXISTS ${SELF_DIR}/vvencTargets-static.cmake ) + include( ${SELF_DIR}/vvencTargets-static.cmake ) + else() + include( ${SELF_DIR}/vvencTargets-shared.cmake ) + endif() +endif() diff --git a/cmake/install/VVEncConfigVersion.cmake.in b/cmake/install/vvencConfigVersion.cmake.in similarity index 88% rename from cmake/install/VVEncConfigVersion.cmake.in rename to cmake/install/vvencConfigVersion.cmake.in index 5683e10dc..85e1e43f6 100644 --- a/cmake/install/VVEncConfigVersion.cmake.in +++ b/cmake/install/vvencConfigVersion.cmake.in @@ -1,4 +1,4 @@ -# VVEncConfigVersion.cmake - checks version: major must match, minor must be less than or equal +# vvencConfigVersion.cmake - checks version: major must match, minor must be less than or equal set( PACKAGE_VERSION @PROJECT_VERSION@ ) diff --git a/cmake/modules/VVEncLibInstall.cmake b/cmake/modules/vvencInstall.cmake similarity index 67% rename from cmake/modules/VVEncLibInstall.cmake rename to cmake/modules/vvencInstall.cmake index a48f848eb..8a4dd686e 100644 --- a/cmake/modules/VVEncLibInstall.cmake +++ b/cmake/modules/vvencInstall.cmake @@ -1,21 +1,15 @@ -# VVEncInstall - -if( BUILD_SHARED_LIBS ) - set( CONFIG_POSTFIX shared ) -else() - set( CONFIG_POSTFIX static ) -endif() +# vvencInstall # set destination directories -set( RUNTIME_DEST bin/$>-${CONFIG_POSTFIX} ) -set( LIBRARY_DEST lib/$>-${CONFIG_POSTFIX} ) -set( ARCHIVE_DEST lib/$>-${CONFIG_POSTFIX} ) +set( RUNTIME_DEST ${CMAKE_INSTALL_BINDIR} ) +set( LIBRARY_DEST ${CMAKE_INSTALL_LIBDIR} ) +set( ARCHIVE_DEST ${CMAKE_INSTALL_LIBDIR} ) # install targets macro( install_targets config_ ) string( TOLOWER ${config_} config_lc_ ) install( TARGETS vvenc vvencapp vvencFFapp - EXPORT VVEncTargets-${config_lc_} + EXPORT vvencTargets-${config_lc_} CONFIGURATIONS ${config_} RUNTIME DESTINATION ${RUNTIME_DEST} LIBRARY DESTINATION ${LIBRARY_DEST} @@ -49,10 +43,11 @@ macro( install_exe_pdb exe_ ) endmacro( install_exe_pdb ) # set interface include directories -target_include_directories( vvenc SYSTEM INTERFACE $ ) +target_include_directories( vvenc SYSTEM INTERFACE $ ) # install headers -install( DIRECTORY include/vvenc DESTINATION include ) +install( FILES ${CMAKE_BINARY_DIR}/vvenc/version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vvenc ) +install( DIRECTORY include/vvenc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # install targets install_targets( Release ) @@ -65,12 +60,19 @@ install_exe_pdb( vvencapp ) install_exe_pdb( vvencFFapp ) # configure version file -configure_file( cmake/install/VVEncConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/VVEncConfigVersion.cmake @ONLY ) +configure_file( cmake/install/vvencConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/vvencConfigVersion.cmake @ONLY ) # install cmake releated files -install( FILES cmake/install/VVEncConfig.cmake DESTINATION lib/cmake/VVEnc ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/VVEncConfigVersion.cmake DESTINATION lib/cmake/VVEnc ) +install( FILES cmake/install/vvencConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvenc ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/vvencConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvenc ) + +# set config postfix +if( BUILD_SHARED_LIBS ) + set( CONFIG_POSTFIX shared ) +else() + set( CONFIG_POSTFIX static ) +endif() # create target cmake files -install( EXPORT VVEncTargets-release NAMESPACE vvenc:: FILE VVEncTargets.cmake CONFIGURATIONS Release DESTINATION lib/cmake/VVEnc/${CONFIG_POSTFIX} ) -install( EXPORT VVEncTargets-debug NAMESPACE vvenc:: FILE VVEncTargets.cmake CONFIGURATIONS Debug DESTINATION lib/cmake/VVEnc/${CONFIG_POSTFIX} ) -install( EXPORT VVEncTargets-relwithdebinfo NAMESPACE vvenc:: FILE VVEncTargets.cmake CONFIGURATIONS RelWithDebInfo DESTINATION lib/cmake/VVEnc/${CONFIG_POSTFIX} ) +install( EXPORT vvencTargets-release NAMESPACE vvenc:: FILE vvencTargets-${CONFIG_POSTFIX}.cmake CONFIGURATIONS Release DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvenc ) +install( EXPORT vvencTargets-debug NAMESPACE vvenc:: FILE vvencTargets-${CONFIG_POSTFIX}.cmake CONFIGURATIONS Debug DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvenc ) +install( EXPORT vvencTargets-relwithdebinfo NAMESPACE vvenc:: FILE vvencTargets-${CONFIG_POSTFIX}.cmake CONFIGURATIONS RelWithDebInfo DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/vvenc ) diff --git a/cmake/modules/VVEncNumCores.cmake b/cmake/modules/vvencNumCores.cmake similarity index 100% rename from cmake/modules/VVEncNumCores.cmake rename to cmake/modules/vvencNumCores.cmake diff --git a/include/vvenc/Basics.h b/include/vvenc/Basics.h index e082a7a36..d11152260 100644 --- a/include/vvenc/Basics.h +++ b/include/vvenc/Basics.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Basics.h \brief encoder lib basic defines */ @@ -48,6 +52,8 @@ vvc@hhi.fraunhofer.de #include #include #include +#include "vvenc/vvencDecl.h" + //! \ingroup Interface //! \{ @@ -61,11 +67,7 @@ static const int MAX_NUM_REF_PICS = 29; ///< max. number of pictu static const int MAX_TLAYER = 7; ///< Explicit temporal layer QP offset - max number of temporal layer static const int MAX_NUM_CQP_MAPPING_TABLES = 3; ///< Maximum number of chroma QP mapping tables (Cb, Cr and joint Cb-Cr) static const int MAX_NUM_ALF_ALTERNATIVES_CHROMA = 8; - - -// ==================================================================================================================== - -typedef void (*MsgFnc) ( int level, const char* fmt, va_list args ); +static const int MCTF_RANGE = 2; ///< max number of frames used for MCTF filtering in forward / backward direction // ==================================================================================================================== @@ -93,7 +95,7 @@ namespace Profile MULTILAYER_MAIN_10_STILL_PICTURE = 6, MULTILAYER_MAIN_10_444 = 7, MULTILAYER_MAIN_10_444_STILL_PICTURE = 8, - AUTO + AUTO }; } @@ -103,6 +105,7 @@ namespace Level { MAIN = 0, HIGH = 1, + NUMBER_OF_TIERS }; enum Name @@ -121,6 +124,7 @@ namespace Level LEVEL6 = 96, LEVEL6_1 = 99, LEVEL6_2 = 102, + LEVEL6_3 = 105, LEVEL15_5 = 255, }; } @@ -231,9 +235,21 @@ enum NalUnitType NAL_UNIT_INVALID }; +enum PresetMode +{ + NONE = -1, + FASTER = 0, + FAST = 1, + MEDIUM = 2, + SLOW = 3, + SLOWER = 4, + FIRSTPASS = 254, + TOOLTEST = 255, +}; + // ==================================================================================================================== -struct YUVPlane +struct VVENC_DECL YUVPlane { int16_t* planeBuf; int width; @@ -249,7 +265,7 @@ struct YUVPlane } }; -struct YUVBuffer +struct VVENC_DECL YUVBuffer { YUVPlane yuvPlanes[ MAX_NUM_COMP ]; uint64_t sequenceNumber; ///< sequence number of the picture @@ -266,7 +282,7 @@ struct YUVBuffer // ==================================================================================================================== -struct ChromaQpMappingTableParams +struct VVENC_DECL ChromaQpMappingTableParams { int m_numQpTables; int m_qpBdOffset; @@ -286,7 +302,7 @@ struct ChromaQpMappingTableParams } }; -struct ReshapeCW +struct VVENC_DECL ReshapeCW { std::vector binCW; int updateCtrl; diff --git a/include/vvenc/EncCfg.h b/include/vvenc/EncCfg.h index 85c24a849..4f17730b1 100644 --- a/include/vvenc/EncCfg.h +++ b/include/vvenc/EncCfg.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncCfg.h \brief encoder configuration class (header) */ @@ -49,717 +53,90 @@ vvc@hhi.fraunhofer.de #include #include #include -#include "../vvenc/Basics.h" -#include "../vvenc/vvencDecl.h" +#include "vvenc/vvencDecl.h" +#include "vvenc/Basics.h" +#include "vvenc/EncCfgExpert.h" //! \ingroup Interface //! \{ namespace vvenc { -// ==================================================================================================================== - -struct GOPEntry -{ - int m_POC; - int m_QPOffset; - double m_QPOffsetModelOffset; - double m_QPOffsetModelScale; - int m_CbQPoffset; - int m_CrQPoffset; - double m_QPFactor; - int m_tcOffsetDiv2; - int m_betaOffsetDiv2; - int m_CbTcOffsetDiv2; - int m_CbBetaOffsetDiv2; - int m_CrTcOffsetDiv2; - int m_CrBetaOffsetDiv2; - int m_temporalId; - bool m_refPic; - int8_t m_sliceType; - int m_numRefPicsActive[ 2 ]; - int m_numRefPics[ 2 ]; - int m_deltaRefPics[ 2 ][ MAX_NUM_REF_PICS ]; - bool m_isEncoded; - bool m_ltrp_in_slice_header_flag; -GOPEntry() - : m_POC ( -1 ) - , m_QPOffset ( 0 ) - , m_QPOffsetModelOffset ( 0 ) - , m_QPOffsetModelScale ( 0 ) - , m_CbQPoffset ( 0 ) - , m_CrQPoffset ( 0 ) - , m_QPFactor ( 0 ) - , m_tcOffsetDiv2 ( 0 ) - , m_betaOffsetDiv2 ( 0 ) - , m_CbTcOffsetDiv2 ( 0 ) - , m_CbBetaOffsetDiv2 ( 0 ) - , m_CrTcOffsetDiv2 ( 0 ) - , m_CrBetaOffsetDiv2 ( 0 ) - , m_temporalId ( 0 ) - , m_refPic ( false ) - , m_sliceType ( 'P' ) - , m_numRefPicsActive { 0 } - , m_numRefPics { 0 } - , m_isEncoded(false) - , m_ltrp_in_slice_header_flag(false) - { - std::memset( m_deltaRefPics, 0, sizeof( m_deltaRefPics ) ); - } -}; - -inline std::istringstream& operator>> ( std::istringstream& in, GOPEntry& entry ) -{ - in >> entry.m_sliceType; - in >> entry.m_POC; - in >> entry.m_QPOffset; - in >> entry.m_QPOffsetModelOffset; - in >> entry.m_QPOffsetModelScale; - in >> entry.m_CbQPoffset; - in >> entry.m_CrQPoffset; - in >> entry.m_QPFactor; - in >> entry.m_tcOffsetDiv2; - in >> entry.m_betaOffsetDiv2; - in >> entry.m_CbTcOffsetDiv2; - in >> entry.m_CbBetaOffsetDiv2; - in >> entry.m_CrTcOffsetDiv2; - in >> entry.m_CrBetaOffsetDiv2; - in >> entry.m_temporalId; - - for( int l = 0; l < 2; l++) - { - in >> entry.m_numRefPicsActive[l]; - in >> entry.m_numRefPics[l]; - for ( int i = 0; i < entry.m_numRefPics[l]; i++ ) - { - in >> entry.m_deltaRefPics[l][i]; - } - } - - return in; -} - -// ==================================================================================================================== - -struct RPLEntry -{ - int m_POC; - int m_temporalId; - bool m_refPic; - bool m_ltrp_in_slice_header_flag; - int m_numRefPicsActive; - int8_t m_sliceType; - int m_numRefPics; - int m_deltaRefPics[ MAX_NUM_REF_PICS ]; - - RPLEntry() - : m_POC ( -1 ) - , m_temporalId ( 0 ) - , m_refPic ( false ) - , m_ltrp_in_slice_header_flag(false) - , m_numRefPicsActive ( 0 ) - , m_sliceType ( 'P' ) - , m_numRefPics ( 0 ) - { - ::memset( m_deltaRefPics, 0, sizeof( m_deltaRefPics ) ); - } -}; - -struct WCGChromaQPControl -{ - WCGChromaQPControl() - : enabled (false) - , chromaCbQpScale (1.0) , chromaCrQpScale (1.0) - , chromaQpScale (0.0) , chromaQpOffset (0.0) - {} - - bool enabled; ///< Enabled flag (0:default) - double chromaCbQpScale; ///< Chroma Cb QP Scale (1.0:default) - double chromaCrQpScale; ///< Chroma Cr QP Scale (1.0:default) - double chromaQpScale; ///< Chroma QP Scale (0.0:default) - double chromaQpOffset; ///< Chroma QP Offset (0.0:default) -}; - -// ==================================================================================================================== - -/// encoder configuration class -class VVENC_DECL EncCfg +class VVENC_DECL EncCfg : public EncCfgExpert { public: - bool m_confirmFailed; - int m_verbosity; - - bool m_listTracingChannels; - std::string m_traceRule; - std::string m_traceFile; - - int m_conformanceWindowMode; - int m_confWinLeft; - int m_confWinRight; - int m_confWinTop; - int m_confWinBottom; - + bool m_confirmFailed; ///< state variable + int m_verbosity; ///< encoder verbosity int m_framesToBeEncoded; ///< number of encoded frames int m_FrameRate; ///< source frame-rates (Hz) int m_FrameSkip; ///< number of skipped frames from the beginning - unsigned m_temporalSubsampleRatio; ///< temporal subsample ratio, 2 means code every two frames int m_SourceWidth; ///< source width in pixel int m_SourceHeight; ///< source height in pixel (when interlaced = field height) - int m_TicksPerSecond; ///< ticks per second e.g. 90000 for dts generation (no default || 1..27000000) - - int m_aiPad[ 2 ]; ///< number of padded pixels for width and height - bool m_enablePictureHeaderInSliceHeader; bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units - bool m_printMSEBasedSequencePSNR; - bool m_printHexPsnr; - bool m_printFrameMSE; - bool m_printSequenceMSE; - bool m_cabacZeroWordPaddingEnabled; - Profile::Name m_profile; Level::Tier m_levelTier; Level::Name m_level; - unsigned m_subProfile; - - unsigned m_bitDepthConstraintValue; - bool m_intraOnlyConstraintFlag; int m_IntraPeriod; ///< period of I-slice (random access period) int m_DecodingRefreshType; ///< random access type int m_GOPSize; ///< GOP size of hierarchical structure - int m_InputQueueSize; ///< Size of frame input queue - bool m_rewriteParamSets; ///< Flag to enable rewriting of parameter sets at random access points - bool m_idrRefParamList; ///< indicates if reference picture list syntax elements are present in slice headers of IDR pictures - RPLEntry m_RPLList0[ MAX_GOP ]; ///< the RPL entries from the config file - RPLEntry m_RPLList1[ MAX_GOP ]; ///< the RPL entries from the config file - GOPEntry m_GOPList [ MAX_GOP ]; ///< the coding structure entries from the config file - int m_maxDecPicBuffering[ MAX_TLAYER ]; ///< total number of pictures in the decoded picture buffer - int m_numReorderPics [ MAX_TLAYER ]; ///< total number of reorder pictures - int m_maxTempLayer; ///< Max temporal layer - int m_numRPLList0; - int m_numRPLList1; int m_QP; ///< QP value of key-picture (integer) - bool m_useSameChromaQPTables; - ChromaQpMappingTableParams m_chromaQpMappingTableParams; - int m_intraQPOffset; ///< QP offset for intra slice (integer) - bool m_lambdaFromQPEnable; ///< enable flag for QP:lambda fix - double m_adLambdaModifier[ MAX_TLAYER ]; ///< Lambda modifier array for each temporal layer - std::vector m_adIntraLambdaModifier; ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier. - double m_dIntraQpFactor; ///< Intra Q Factor. If negative, use a default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(double)(isField ? (GopSize-1)/2 : GopSize-1) )) - std::vector m_qpInValsCb; ///< qp input values used to derive the chroma QP mapping table - std::vector m_qpInValsCr; ///< qp input values used to derive the chroma QP mapping table - std::vector m_qpInValsCbCr; ///< qp input values used to derive the chroma QP mapping table - std::vector m_qpOutValsCb; ///< qp output values used to derive the chroma QP mapping table - std::vector m_qpOutValsCr; ///< qp output values used to derive the chroma QP mapping table - std::vector m_qpOutValsCbCr; ///< qp output values used to derive the chroma QP mapping table - int m_cuQpDeltaSubdiv; ///< Maximum subdiv for CU luma Qp adjustment (0:default) - int m_cuChromaQpOffsetSubdiv; ///< If negative, then do not apply chroma qp offsets. - int m_chromaCbQpOffset; ///< Chroma Cb QP Offset (0:default) - int m_chromaCrQpOffset; ///< Chroma Cr QP Offset (0:default) - int m_chromaCbQpOffsetDualTree; ///< Chroma Cb QP Offset for dual tree (overwrite m_chromaCbQpOffset for dual tree) - int m_chromaCrQpOffsetDualTree; ///< Chroma Cr QP Offset for dual tree (overwrite m_chromaCrQpOffset for dual tree) - int m_chromaCbCrQpOffset; ///< QP Offset for joint Cb-Cr mode - int m_chromaCbCrQpOffsetDualTree; ///< QP Offset for joint Cb-Cr mode (overwrite m_chromaCbCrQpOffset for dual tree) - unsigned m_sliceChromaQpOffsetPeriodicity; ///< Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature. - int m_sliceChromaQpOffsetIntraOrPeriodic[ 2 ]; ///< Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table. unsigned m_usePerceptQPA; ///< Mode of perceptually motivated input-adaptive QP modification, abbrev. perceptual QP adaptation (QPA). (0 = off, 1 = on for SDR, 2 = on for HDR) bool m_usePerceptQPATempFiltISlice; ///< Flag indicating if temporal high-pass filtering in visual activity calculation in QPA should (true) or shouldn't (false) be applied for I-slices - bool m_lumaLevelToDeltaQPEnabled; - WCGChromaQPControl m_wcgChromaQpControl; - bool m_sdr; - bool m_calculateHdrMetrics; - int m_cropOffsetLeft; - int m_cropOffsetTop; - int m_cropOffsetRight; - int m_cropOffsetBottom; - - ChromaFormat m_internChromaFormat; - bool m_useIdentityTableForNon420Chroma; int m_inputBitDepth [ MAX_NUM_CH ]; ///< bit-depth of input file int m_internalBitDepth[ MAX_NUM_CH ]; ///< bit-depth codec operates at (input/output files will be converted) - int m_outputBitDepth[ MAX_NUM_CH ]; ///< bit-depth of output file - int m_MSBExtendedBitDepth[ MAX_NUM_CH ]; ///< bit-depth of input samples after MSB extension - CostMode m_costMode; ///< Cost mode to use - HashType m_decodedPictureHashSEIType; ///< Checksum mode for decoded picture hash SEI message - - bool m_tileUniformSpacingFlag; - int m_numTileColumnsMinus1; - int m_numTileRowsMinus1; - std::vector m_tileColumnWidth; - std::vector m_tileRowHeight; - bool m_entropyCodingSyncEnabled; - bool m_entryPointsPresent; - bool m_rectSliceFlag; - int m_numSlicesInPicMinus1; - std::vector m_topLeftBrickIdx; - std::vector m_bottomRightBrickIdx; - bool m_signalledSliceIdFlag; - int m_signalledSliceIdLengthMinus1; - std::vector m_rectSliceBoundary; - std::vector m_signalledSliceId; - std::vector m_sliceId; - unsigned m_CTUSize; - unsigned m_MinQT[ 3 ]; ///< 0: I slice luma; 1: P/B slice; 2: I slice chroma - unsigned m_maxMTTDepth; - unsigned m_maxMTTDepthI; - unsigned m_maxMTTDepthIChroma; - unsigned m_maxBT[3]; - unsigned m_maxTT[3]; - bool m_dualITree; - unsigned m_MaxCodingDepth; ///< max. total CU depth - includes depth of transform-block structure - unsigned m_log2DiffMaxMinCodingBlockSize; ///< difference between largest and smallest CU depth - int m_log2MaxTbSize; - - bool m_bUseASR; ///< flag for using adaptive motion search range - bool m_bUseHADME; ///< flag for using HAD in sub-pel ME - int m_RDOQ; ///< flag for using RD optimized quantization - bool m_useRDOQTS; ///< flag for using RD optimized quantization for transform skip - bool m_useSelectiveRDOQ; ///< flag for using selective RDOQ - - bool m_JointCbCrMode; - bool m_cabacInitPresent; - bool m_useFastLCTU; - bool m_usePbIntraFast; - int m_useFastMrg; - bool m_useAMaxBT; - bool m_fastQtBtEnc; - bool m_contentBasedFastQtbt; - int m_fastInterSearchMode; ///< Parameter that controls fast encoder settings - bool m_bUseEarlyCU; ///< flag for using Early CU setting - bool m_useFastDecisionForMerge; ///< flag for using Fast Decision Merge RD-Cost - bool m_useEarlySkipDetection; ///< flag for using Early SKIP Detection - - bool m_bDisableIntraPUsInInterSlices; ///< Flag for disabling intra predicted PUs in inter slices. - bool m_bUseConstrainedIntraPred; ///< flag for using constrained intra prediction - bool m_bFastUDIUseMPMEnabled; - bool m_bFastMEForGenBLowDelayEnabled; - - bool m_MTSImplicit; - int m_TMVPModeId; - bool m_DepQuantEnabled; - bool m_SignDataHidingEnabled; - bool m_MIP; - int m_useFastMIP; - - unsigned m_maxNumMergeCand; ///< Max number of merge candidates - unsigned m_maxNumAffineMergeCand; ///< Max number of affine merge candidates -// unsigned m_maxNumIBCMergeCand; ///< Max number of IBC merge candidates - int m_Geo; - unsigned m_maxNumGeoCand; - int m_RCRateControlMode; - int m_RCTargetBitrate; - int m_RCKeepHierarchicalBit; - bool m_RCUseLCUSeparateModel; - int m_RCInitialQP; - bool m_RCForceIntraQP; - int m_motionEstimationSearchMethod; - bool m_bRestrictMESampling; ///< Restrict sampling for the Selective ME - int m_SearchRange; ///< ME search range - int m_bipredSearchRange; ///< ME search range for bipred refinement - int m_minSearchWindow; ///< ME minimum search window size for the Adaptive Window ME - bool m_bClipForBiPredMeEnabled; ///< Enables clipping for Bi-Pred ME. - bool m_bFastMEAssumingSmootherMVEnabled; ///< Enables fast ME assuming a smoother MV. - int m_fastSubPel; - int m_SMVD; - int m_AMVRspeed; - bool m_LMChroma; - bool m_horCollocatedChromaFlag; - bool m_verCollocatedChromaFlag; - bool m_MRL; - bool m_BDOF; - bool m_DMVR; - int m_EDO; - bool m_lumaReshapeEnable; - int m_reshapeSignalType; - int m_updateCtrl; - int m_adpOption; - int m_initialCW; - int m_LMCSOffset; - ReshapeCW m_reshapeCW; - int m_Affine; - bool m_PROF; - bool m_AffineType; - int m_MMVD; - int m_MmvdDisNum; - bool m_allowDisFracMMVD; - int m_CIIP; - bool m_SbTMVP; - int m_SBT; ///< Sub-Block Transform for inter blocks - int m_LFNST; - int m_MTS; - int m_MTSIntraMaxCand; - - bool m_bLoopFilterDisable; ///< flag for using deblocking filter - bool m_loopFilterOffsetInPPS; ///< offset for deblocking filter in 0 = slice header, 1 = PPS - int m_loopFilterBetaOffsetDiv2[3]; ///< beta offset for deblocking filter - int m_loopFilterTcOffsetDiv2[3]; ///< tc offset for deblocking filter - int m_deblockingFilterMetric; - - bool m_bLFCrossTileBoundaryFlag; - bool m_bLFCrossSliceBoundaryFlag; ///< 1: filter across slice boundaries 0: do not filter across slice boundaries - bool m_loopFilterAcrossSlicesEnabled; - - bool m_bUseSAO; - double m_saoEncodingRate; ///< When >0 SAO early picture termination is enabled for luma and chroma - double m_saoEncodingRateChroma; ///< The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma. - unsigned m_log2SaoOffsetScale[ MAX_NUM_CH ]; ///< number of bits for the upward bit shift operation on the decoded SAO offsets - int m_saoOffsetBitShift[ MAX_NUM_CH ]; - - bool m_decodingParameterSetEnabled; ///< enable decoding parameter set - bool m_vuiParametersPresent; ///< enable generation of VUI parameters - bool m_aspectRatioInfoPresent; ///< Signals whether aspect_ratio_idc is present - int m_aspectRatioIdc; ///< aspect_ratio_idc - int m_sarWidth; ///< horizontal size of the sample aspect ratio - int m_sarHeight; ///< vertical size of the sample aspect ratio - bool m_colourDescriptionPresent; ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present - int m_colourPrimaries; ///< Indicates chromaticity coordinates of the source primaries - int m_transferCharacteristics; ///< Indicates the opto-electronic transfer characteristics of the source - int m_matrixCoefficients; ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries - bool m_chromaLocInfoPresent; ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present - int m_chromaSampleLocTypeTopField; ///< Specifies the location of chroma samples for top field - int m_chromaSampleLocTypeBottomField; ///< Specifies the location of chroma samples for bottom field - int m_chromaSampleLocType; ///< Specifies the location of chroma samples for progressive content - bool m_overscanInfoPresent; ///< Signals whether overscan_appropriate_flag is present - bool m_overscanAppropriateFlag; ///< Indicates whether conformant decoded pictures are suitable for display using overscan - bool m_videoSignalTypePresent; ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present - bool m_videoFullRangeFlag; ///< Indicates the black level and range of luma and chroma signals - - std::string m_summaryOutFilename; ///< filename to use for producing summary output file. - std::string m_summaryPicFilenameBase; ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. - unsigned m_summaryVerboseness; ///< Specifies the level of the verboseness of the text output. - - std::string m_decodeBitstreams[ 2 ]; ///< filename for decode bitstreams. -#if REMOVE_DBG_CTU - int m_debugCTU; ///< dbg ctu -#endif - int m_switchPOC; ///< dbg poc. - int m_switchDQP; ///< switch DQP. - int m_fastForwardToPOC; ///< get to encoding the specified POC as soon as possible by skipping temporal layers irrelevant for the specified POC - bool m_stopAfterFFtoPOC; - bool m_bs2ModPOCAndType; - bool m_forceDecodeBitstream1; - - bool m_alf; ///> Adaptive Loop Filter - bool m_useNonLinearAlfLuma; - bool m_useNonLinearAlfChroma; - unsigned m_maxNumAlfAlternativesChroma; - bool m_ccalf; - int m_ccalfQpThreshold; - int m_MCTF; - bool m_MCTFFutureReference; - int m_MCTFNumLeadFrames; - int m_MCTFNumTrailFrames; - std::vector m_MCTFFrames; - std::vector m_MCTFStrengths; - - int m_dqThresholdVal; - bool m_qtbttSpeedUp; - - int m_fastLocalDualTreeMode; - bool m_frameParallel; - int m_numFppThreads; - bool m_ensureFppBitEqual; - int m_numWppThreads; - int m_ensureWppBitEqual; - bool m_picPartitionFlag; + int m_numWppThreads; ///< number of wpp threads + int m_ensureWppBitEqual; ///< Flag indicating bit equalitiy for single thread runs respecting multithread restrictions public: EncCfg() - - : m_confirmFailed ( false ) - - , m_verbosity ( VERBOSE ) - - , m_listTracingChannels ( false ) - , m_traceRule ( "" ) - , m_traceFile ( "" ) - - , m_conformanceWindowMode ( 0 ) - , m_confWinLeft ( 0 ) - , m_confWinRight ( 0 ) - , m_confWinTop ( 0 ) - , m_confWinBottom ( 0 ) - - , m_framesToBeEncoded ( 0 ) - , m_FrameRate ( 0 ) - , m_FrameSkip ( 0 ) - , m_temporalSubsampleRatio ( 1 ) - , m_SourceWidth ( 0 ) - , m_SourceHeight ( 0 ) - - , m_TicksPerSecond ( 90000 ) - - , m_aiPad { 0, 0 } - , m_enablePictureHeaderInSliceHeader ( true ) - , m_AccessUnitDelimiter ( false ) - - , m_printMSEBasedSequencePSNR ( false ) - , m_printHexPsnr ( false ) - , m_printFrameMSE ( false ) - , m_printSequenceMSE ( false ) - , m_cabacZeroWordPaddingEnabled ( true ) - - , m_profile ( Profile::NONE ) - , m_levelTier ( Level::MAIN ) - , m_level ( Level::NONE ) - , m_subProfile ( 0 ) - , m_bitDepthConstraintValue ( 10 ) - , m_intraOnlyConstraintFlag ( false ) - - , m_IntraPeriod ( -1 ) - , m_DecodingRefreshType ( 0 ) - , m_GOPSize ( 1 ) - , m_InputQueueSize ( 0 ) - , m_rewriteParamSets ( false ) - , m_idrRefParamList ( false ) - , m_maxDecPicBuffering { 0, 0, 0, 0, 0, 0, 0 } // not set -> derived - , m_numReorderPics { 0, 0, 0, 0, 0, 0, 0 } // not set -> derived - , m_maxTempLayer ( 0 ) // not set -> derived - , m_numRPLList0 ( 0 ) // not set -> derived - , m_numRPLList1 ( 0 ) // not set -> derived - - , m_QP ( 32 ) - , m_useSameChromaQPTables ( true ) - , m_chromaQpMappingTableParams () - , m_intraQPOffset ( 0 ) - , m_lambdaFromQPEnable ( false ) - , m_adLambdaModifier { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 } - , m_adIntraLambdaModifier () - , m_dIntraQpFactor ( -1.0 ) - , m_qpInValsCb { 25, 33, 43 } - , m_qpInValsCr { 0 } - , m_qpInValsCbCr { 0 } - , m_qpOutValsCb { 25, 32, 37 } - , m_qpOutValsCr { 0 } - , m_qpOutValsCbCr { 0 } - , m_cuQpDeltaSubdiv ( 0 ) - , m_cuChromaQpOffsetSubdiv ( -1 ) - , m_chromaCbQpOffset ( 0 ) - , m_chromaCrQpOffset ( 0 ) - , m_chromaCbQpOffsetDualTree ( 0 ) - , m_chromaCrQpOffsetDualTree ( 0 ) - , m_chromaCbCrQpOffset ( -1 ) - , m_chromaCbCrQpOffsetDualTree ( 0 ) - , m_sliceChromaQpOffsetPeriodicity ( 0 ) - , m_sliceChromaQpOffsetIntraOrPeriodic { 0 , 0 } - , m_usePerceptQPA ( 0 ) - , m_usePerceptQPATempFiltISlice ( false ) - - , m_lumaLevelToDeltaQPEnabled (false) - , m_wcgChromaQpControl () - , m_sdr (false) - , m_calculateHdrMetrics (false) - , m_cropOffsetLeft (0) - , m_cropOffsetTop (0) - , m_cropOffsetRight (0) - , m_cropOffsetBottom (0) - - , m_internChromaFormat ( NUM_CHROMA_FORMAT ) - , m_useIdentityTableForNon420Chroma ( true ) - , m_inputBitDepth { 8, 0 } - , m_internalBitDepth { 0, 0 } - , m_outputBitDepth { 0, 0 } - , m_MSBExtendedBitDepth { 0, 0 } - , m_costMode ( COST_STANDARD_LOSSY ) - , m_decodedPictureHashSEIType ( HASHTYPE_NONE ) - - , m_tileUniformSpacingFlag ( false ) - , m_numTileColumnsMinus1 ( 0 ) - , m_numTileRowsMinus1 ( 0 ) - , m_tileColumnWidth () - , m_tileRowHeight () - , m_entropyCodingSyncEnabled ( false ) - , m_entryPointsPresent ( true ) - , m_rectSliceFlag ( true ) - , m_numSlicesInPicMinus1 ( 0 ) - , m_topLeftBrickIdx () // not set -> derived - , m_bottomRightBrickIdx () // not set -> derived - , m_signalledSliceIdFlag ( false ) - , m_signalledSliceIdLengthMinus1 ( 0 ) - , m_rectSliceBoundary () - , m_signalledSliceId () - , m_sliceId () // not set -> derived - - , m_CTUSize ( 128 ) - , m_MinQT { 8, 8, 4 } - , m_maxMTTDepth ( 3 ) - , m_maxMTTDepthI ( 3 ) - , m_maxMTTDepthIChroma ( 3 ) - , m_maxBT {32, 128, 64} - , m_maxTT {32, 64, 32} - , m_dualITree ( true ) - , m_MaxCodingDepth ( 0 ) // not set -> derived - , m_log2DiffMaxMinCodingBlockSize ( 0 ) // not set -> derived - , m_log2MaxTbSize ( 6 ) - - , m_bUseASR ( false ) - , m_bUseHADME ( true ) - , m_RDOQ ( 1 ) - , m_useRDOQTS ( true ) - , m_useSelectiveRDOQ ( false) - - , m_JointCbCrMode ( false ) - , m_cabacInitPresent ( true ) - , m_useFastLCTU ( false ) - , m_usePbIntraFast ( false ) - , m_useFastMrg ( 0 ) - , m_useAMaxBT ( false ) - , m_fastQtBtEnc ( true ) - , m_contentBasedFastQtbt ( false ) - , m_fastInterSearchMode ( FASTINTERSEARCH_DISABLED ) - , m_bUseEarlyCU ( false ) - , m_useFastDecisionForMerge ( true ) - , m_useEarlySkipDetection ( false ) - - , m_bDisableIntraPUsInInterSlices ( false ) - , m_bUseConstrainedIntraPred ( false ) - , m_bFastUDIUseMPMEnabled ( true ) - , m_bFastMEForGenBLowDelayEnabled ( true ) - - , m_MTSImplicit ( false ) - , m_TMVPModeId ( 1 ) - , m_DepQuantEnabled ( true ) - , m_SignDataHidingEnabled ( false ) - - , m_MIP ( false ) - , m_useFastMIP ( 0 ) - , m_maxNumMergeCand ( 5 ) - , m_maxNumAffineMergeCand ( 5 ) -// , m_maxNumIBCMergeCand ( 6 ) - , m_Geo ( 0 ) - , m_maxNumGeoCand ( 5 ) - , m_RCRateControlMode ( 0 ) - , m_RCTargetBitrate ( 0 ) - , m_RCKeepHierarchicalBit ( 0 ) - , m_RCUseLCUSeparateModel ( false ) - , m_RCInitialQP ( 0 ) - , m_RCForceIntraQP ( false ) - , m_motionEstimationSearchMethod ( 1 ) - , m_bRestrictMESampling ( false ) - , m_SearchRange ( 96 ) - , m_bipredSearchRange ( 4 ) - , m_minSearchWindow ( 8 ) - , m_bClipForBiPredMeEnabled ( false ) - , m_bFastMEAssumingSmootherMVEnabled ( true ) - , m_fastSubPel ( 0 ) - , m_SMVD ( 0 ) - , m_AMVRspeed ( 0 ) - , m_LMChroma ( false ) - , m_horCollocatedChromaFlag ( true ) - , m_verCollocatedChromaFlag ( false ) - , m_MRL ( true ) - , m_BDOF ( false ) - , m_DMVR ( false ) - , m_EDO ( 0 ) - , m_lumaReshapeEnable ( false ) - , m_reshapeSignalType ( 0 ) - , m_updateCtrl ( 0 ) - , m_adpOption ( 0 ) - , m_initialCW ( 0 ) - , m_LMCSOffset ( 0 ) - , m_reshapeCW ( ) - , m_Affine ( 0 ) - , m_PROF ( false ) - , m_AffineType ( true ) - , m_MMVD ( 0 ) - , m_MmvdDisNum ( 6 ) - , m_allowDisFracMMVD ( false ) - , m_CIIP ( 0 ) - , m_SbTMVP ( false ) - , m_SBT ( 0 ) - , m_LFNST ( 0 ) - , m_MTS ( 0 ) - , m_MTSIntraMaxCand ( 3 ) - - , m_bLoopFilterDisable ( false ) - , m_loopFilterOffsetInPPS ( true ) - , m_loopFilterBetaOffsetDiv2 { 0 } - , m_loopFilterTcOffsetDiv2 { 0 } - , m_deblockingFilterMetric ( 0 ) - - , m_bLFCrossTileBoundaryFlag ( true ) - , m_bLFCrossSliceBoundaryFlag ( true ) - , m_loopFilterAcrossSlicesEnabled ( false ) - - , m_bUseSAO ( true ) - , m_saoEncodingRate ( 0.75 ) - , m_saoEncodingRateChroma ( 0.5 ) - , m_log2SaoOffsetScale { 0, 0 } // not set -> derived - , m_saoOffsetBitShift { 0, 0 } - - , m_decodingParameterSetEnabled ( false ) - , m_vuiParametersPresent ( false ) - , m_aspectRatioInfoPresent ( false ) - , m_aspectRatioIdc ( 0 ) - , m_sarWidth ( 0 ) - , m_sarHeight ( 0 ) - , m_colourDescriptionPresent ( false ) - , m_colourPrimaries ( 2 ) - , m_transferCharacteristics ( 2 ) - , m_matrixCoefficients ( 2 ) - , m_chromaLocInfoPresent ( false ) - , m_chromaSampleLocTypeTopField ( 0 ) - , m_chromaSampleLocTypeBottomField ( 0 ) - , m_chromaSampleLocType ( 0 ) - , m_overscanInfoPresent ( false ) - , m_overscanAppropriateFlag ( false ) - , m_videoSignalTypePresent ( false ) - , m_videoFullRangeFlag ( false ) - - , m_summaryOutFilename ( "" ) - , m_summaryPicFilenameBase ( "" ) - , m_summaryVerboseness ( 0 ) - - , m_decodeBitstreams { "", "" } -#if REMOVE_DBG_CTU - , m_debugCTU ( -1 ) -#endif - , m_switchPOC ( -1 ) - , m_switchDQP ( 0 ) - , m_fastForwardToPOC ( -1 ) - , m_stopAfterFFtoPOC ( false ) - , m_bs2ModPOCAndType ( false ) - , m_forceDecodeBitstream1 ( false ) - - , m_alf ( false ) - , m_useNonLinearAlfLuma ( true ) - , m_useNonLinearAlfChroma ( true ) - , m_maxNumAlfAlternativesChroma ( MAX_NUM_ALF_ALTERNATIVES_CHROMA ) - , m_ccalf ( false ) - , m_ccalfQpThreshold ( 37 ) - - , m_MCTF ( 0 ) - , m_MCTFFutureReference ( true ) - , m_MCTFNumLeadFrames ( 0 ) - , m_MCTFNumTrailFrames ( 0 ) - - , m_dqThresholdVal ( 8 ) - , m_qtbttSpeedUp ( false ) - - , m_fastLocalDualTreeMode ( 0 ) - , m_frameParallel ( false ) - , m_numFppThreads ( -1 ) - , m_ensureFppBitEqual ( false ) - , m_numWppThreads ( 0 ) - , m_ensureWppBitEqual ( 0 ) - , m_picPartitionFlag ( false ) + : m_confirmFailed ( false ) + , m_verbosity ( VERBOSE ) + , m_framesToBeEncoded ( 0 ) + , m_FrameRate ( 0 ) + , m_FrameSkip ( 0 ) + , m_SourceWidth ( 0 ) + , m_SourceHeight ( 0 ) + , m_TicksPerSecond ( 90000 ) + , m_AccessUnitDelimiter ( false ) + + , m_profile ( Profile::MAIN_10 ) + , m_levelTier ( Level::MAIN ) + , m_level ( Level::LEVEL4_1 ) + + , m_IntraPeriod ( 32 ) + , m_DecodingRefreshType ( 1 ) + , m_GOPSize ( 32 ) + + , m_QP ( 32 ) + , m_usePerceptQPA ( 0 ) + , m_usePerceptQPATempFiltISlice ( false ) + + , m_inputBitDepth { 8, 0 } + , m_internalBitDepth { 10, 0 } + + , m_numWppThreads ( 0 ) + , m_ensureWppBitEqual ( 0 ) { } - virtual ~EncCfg() { } - bool confirmParameter( bool bflag, const char* message ); + bool checkExperimental( bool bflag, const char* message ); + bool confirmParameter ( bool bflag, const char* message ); bool initCfgParameter(); void setCfgParameter( const EncCfg& encCfg ); + int initPreset( PresetMode preset ); + virtual void printCfg() const; }; + } // namespace vvenc //! \} diff --git a/include/vvenc/EncCfgExpert.h b/include/vvenc/EncCfgExpert.h new file mode 100644 index 000000000..083cf6027 --- /dev/null +++ b/include/vvenc/EncCfgExpert.h @@ -0,0 +1,746 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ +/** \file EncCfgExpert.h + \brief encoder configuration class (header) +*/ + +#pragma once + +#include +#include +#include +#include +#include "vvenc/vvencDecl.h" +#include "vvenc/Basics.h" + +//! \ingroup Interface +//! \{ + +namespace vvenc { + +// ==================================================================================================================== + +struct VVENC_DECL GOPEntry +{ + int m_POC; + int m_QPOffset; + double m_QPOffsetModelOffset; + double m_QPOffsetModelScale; + int m_CbQPoffset; + int m_CrQPoffset; + double m_QPFactor; + int m_tcOffsetDiv2; + int m_betaOffsetDiv2; + int m_CbTcOffsetDiv2; + int m_CbBetaOffsetDiv2; + int m_CrTcOffsetDiv2; + int m_CrBetaOffsetDiv2; + int m_temporalId; + bool m_refPic; + int8_t m_sliceType; + int m_numRefPicsActive[ 2 ]; + int m_numRefPics[ 2 ]; + int m_deltaRefPics[ 2 ][ MAX_NUM_REF_PICS ]; + bool m_isEncoded; + bool m_ltrp_in_slice_header_flag; +GOPEntry() + : m_POC ( -1 ) + , m_QPOffset ( 0 ) + , m_QPOffsetModelOffset ( 0 ) + , m_QPOffsetModelScale ( 0 ) + , m_CbQPoffset ( 0 ) + , m_CrQPoffset ( 0 ) + , m_QPFactor ( 0 ) + , m_tcOffsetDiv2 ( 0 ) + , m_betaOffsetDiv2 ( 0 ) + , m_CbTcOffsetDiv2 ( 0 ) + , m_CbBetaOffsetDiv2 ( 0 ) + , m_CrTcOffsetDiv2 ( 0 ) + , m_CrBetaOffsetDiv2 ( 0 ) + , m_temporalId ( 0 ) + , m_refPic ( false ) + , m_sliceType ( 'P' ) + , m_numRefPicsActive { 0 } + , m_numRefPics { 0 } + , m_isEncoded(false) + , m_ltrp_in_slice_header_flag(false) + { + std::memset( m_deltaRefPics, 0, sizeof( m_deltaRefPics ) ); + } +}; + +inline std::ostream& operator<< ( std::ostream& os, const GOPEntry& entry ) +{ + os << entry.m_sliceType; + os << entry.m_POC; + os << entry.m_QPOffset; + os << entry.m_QPOffsetModelOffset; + os << entry.m_QPOffsetModelScale; + os << entry.m_CbQPoffset; + os << entry.m_CrQPoffset; + os << entry.m_QPFactor; + os << entry.m_tcOffsetDiv2; + os << entry.m_betaOffsetDiv2; + os << entry.m_CbTcOffsetDiv2; + os << entry.m_CbBetaOffsetDiv2; + os << entry.m_CrTcOffsetDiv2; + os << entry.m_CrBetaOffsetDiv2; + os << entry.m_temporalId; + + for( int l = 0; l < 2; l++) + { + os << entry.m_numRefPicsActive[l]; + os << entry.m_numRefPics[l]; + for ( int i = 0; i < entry.m_numRefPics[l]; i++ ) + { + os << entry.m_deltaRefPics[l][i]; + } + } + + return os; +} + +inline std::istream& operator>> ( std::istream& in, GOPEntry& entry ) +{ + in >> entry.m_sliceType; + in >> entry.m_POC; + in >> entry.m_QPOffset; + in >> entry.m_QPOffsetModelOffset; + in >> entry.m_QPOffsetModelScale; + in >> entry.m_CbQPoffset; + in >> entry.m_CrQPoffset; + in >> entry.m_QPFactor; + in >> entry.m_tcOffsetDiv2; + in >> entry.m_betaOffsetDiv2; + in >> entry.m_CbTcOffsetDiv2; + in >> entry.m_CbBetaOffsetDiv2; + in >> entry.m_CrTcOffsetDiv2; + in >> entry.m_CrBetaOffsetDiv2; + in >> entry.m_temporalId; + + for( int l = 0; l < 2; l++) + { + in >> entry.m_numRefPicsActive[l]; + in >> entry.m_numRefPics[l]; + for ( int i = 0; i < entry.m_numRefPics[l]; i++ ) + { + in >> entry.m_deltaRefPics[l][i]; + } + } + + return in; +} + +// ==================================================================================================================== + +struct VVENC_DECL RPLEntry +{ + int m_POC; + int m_temporalId; + bool m_refPic; + bool m_ltrp_in_slice_header_flag; + int m_numRefPicsActive; + int8_t m_sliceType; + int m_numRefPics; + int m_deltaRefPics[ MAX_NUM_REF_PICS ]; + + RPLEntry() + : m_POC ( -1 ) + , m_temporalId ( 0 ) + , m_refPic ( false ) + , m_ltrp_in_slice_header_flag(false) + , m_numRefPicsActive ( 0 ) + , m_sliceType ( 'P' ) + , m_numRefPics ( 0 ) + { + ::memset( m_deltaRefPics, 0, sizeof( m_deltaRefPics ) ); + } +}; + +struct VVENC_DECL WCGChromaQPControl +{ + WCGChromaQPControl() + : enabled (false) + , chromaCbQpScale (1.0) , chromaCrQpScale (1.0) + , chromaQpScale (0.0) , chromaQpOffset (0.0) + {} + + bool enabled; ///< Enabled flag (0:default) + double chromaCbQpScale; ///< Chroma Cb QP Scale (1.0:default) + double chromaCrQpScale; ///< Chroma Cr QP Scale (1.0:default) + double chromaQpScale; ///< Chroma QP Scale (0.0:default) + double chromaQpOffset; ///< Chroma QP Offset (0.0:default) +}; + +// ==================================================================================================================== + +/// encoder configuration class +class VVENC_DECL EncCfgExpert +{ +public: + + bool m_listTracingChannels; + std::string m_traceRule; + std::string m_traceFile; + + int m_conformanceWindowMode; + int m_confWinLeft; + int m_confWinRight; + int m_confWinTop; + int m_confWinBottom; + + unsigned m_temporalSubsampleRatio; ///< temporal subsample ratio, 2 means code every two frames + + int m_aiPad[ 2 ]; ///< number of padded pixels for width and height + bool m_enablePictureHeaderInSliceHeader; + bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units + + bool m_printMSEBasedSequencePSNR; + bool m_printHexPsnr; + bool m_printFrameMSE; + bool m_printSequenceMSE; + bool m_cabacZeroWordPaddingEnabled; + + unsigned m_subProfile; + + unsigned m_bitDepthConstraintValue; + bool m_intraOnlyConstraintFlag; + + int m_InputQueueSize; ///< Size of frame input queue + bool m_rewriteParamSets; ///< Flag to enable rewriting of parameter sets at random access points + bool m_idrRefParamList; ///< indicates if reference picture list syntax elements are present in slice headers of IDR pictures + RPLEntry m_RPLList0[ MAX_GOP ]; ///< the RPL entries from the config file + RPLEntry m_RPLList1[ MAX_GOP ]; ///< the RPL entries from the config file + GOPEntry m_GOPList [ MAX_GOP ]; ///< the coding structure entries from the config file + int m_maxDecPicBuffering[ MAX_TLAYER ]; ///< total number of pictures in the decoded picture buffer + int m_maxNumReorderPics [ MAX_TLAYER ]; ///< total number of reorder pictures + int m_maxTempLayer; ///< Max temporal layer + int m_numRPLList0; + int m_numRPLList1; + + bool m_useSameChromaQPTables; + ChromaQpMappingTableParams m_chromaQpMappingTableParams; + int m_intraQPOffset; ///< QP offset for intra slice (integer) + bool m_lambdaFromQPEnable; ///< enable flag for QP:lambda fix + double m_adLambdaModifier[ MAX_TLAYER ]; ///< Lambda modifier array for each temporal layer + std::vector m_adIntraLambdaModifier; ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier. + double m_dIntraQpFactor; ///< Intra Q Factor. If negative, use a default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(double)(isField ? (GopSize-1)/2 : GopSize-1) )) + std::vector m_qpInValsCb; ///< qp input values used to derive the chroma QP mapping table + std::vector m_qpInValsCr; ///< qp input values used to derive the chroma QP mapping table + std::vector m_qpInValsCbCr; ///< qp input values used to derive the chroma QP mapping table + std::vector m_qpOutValsCb; ///< qp output values used to derive the chroma QP mapping table + std::vector m_qpOutValsCr; ///< qp output values used to derive the chroma QP mapping table + std::vector m_qpOutValsCbCr; ///< qp output values used to derive the chroma QP mapping table + int m_cuQpDeltaSubdiv; ///< Maximum subdiv for CU luma Qp adjustment (0:default) + int m_cuChromaQpOffsetSubdiv; ///< If negative, then do not apply chroma qp offsets. + int m_chromaCbQpOffset; ///< Chroma Cb QP Offset (0:default) + int m_chromaCrQpOffset; ///< Chroma Cr QP Offset (0:default) + int m_chromaCbQpOffsetDualTree; ///< Chroma Cb QP Offset for dual tree (overwrite m_chromaCbQpOffset for dual tree) + int m_chromaCrQpOffsetDualTree; ///< Chroma Cr QP Offset for dual tree (overwrite m_chromaCrQpOffset for dual tree) + int m_chromaCbCrQpOffset; ///< QP Offset for joint Cb-Cr mode + int m_chromaCbCrQpOffsetDualTree; ///< QP Offset for joint Cb-Cr mode (overwrite m_chromaCbCrQpOffset for dual tree) + unsigned m_sliceChromaQpOffsetPeriodicity; ///< Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature. + int m_sliceChromaQpOffsetIntraOrPeriodic[ 2 ]; ///< Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table. + bool m_lumaLevelToDeltaQPEnabled; + WCGChromaQPControl m_wcgChromaQpControl; + bool m_sdr; + bool m_calculateHdrMetrics; + int m_cropOffsetLeft; + int m_cropOffsetTop; + int m_cropOffsetRight; + int m_cropOffsetBottom; + + + ChromaFormat m_internChromaFormat; + bool m_useIdentityTableForNon420Chroma; + int m_outputBitDepth[ MAX_NUM_CH ]; ///< bit-depth of output file + int m_MSBExtendedBitDepth[ MAX_NUM_CH ]; ///< bit-depth of input samples after MSB extension + CostMode m_costMode; ///< Cost mode to use + HashType m_decodedPictureHashSEIType; ///< Checksum mode for decoded picture hash SEI message + bool m_bufferingPeriodSEIEnabled; + bool m_pictureTimingSEIEnabled; + bool m_decodingUnitInfoSEIEnabled; + bool m_entropyCodingSyncEnabled; + bool m_entryPointsPresent; + bool m_signalledSliceIdFlag; + int m_signalledSliceIdLengthMinus1; + std::vector m_rectSliceBoundary; + std::vector m_signalledSliceId; + std::vector m_sliceId; + + unsigned m_CTUSize; + unsigned m_MinQT[ 3 ]; ///< 0: I slice luma; 1: P/B slice; 2: I slice chroma + unsigned m_maxMTTDepth; + unsigned m_maxMTTDepthI; + unsigned m_maxMTTDepthIChroma; + unsigned m_maxBT[3]; + unsigned m_maxTT[3]; + bool m_dualITree; + unsigned m_MaxCodingDepth; ///< max. total CU depth - includes depth of transform-block structure + unsigned m_log2DiffMaxMinCodingBlockSize; ///< difference between largest and smallest CU depth + int m_log2MaxTbSize; + + bool m_bUseASR; ///< flag for using adaptive motion search range + bool m_bUseHADME; ///< flag for using HAD in sub-pel ME + int m_RDOQ; ///< flag for using RD optimized quantization + bool m_useRDOQTS; ///< flag for using RD optimized quantization for transform skip + bool m_useSelectiveRDOQ; ///< flag for using selective RDOQ + + bool m_JointCbCrMode; + bool m_cabacInitPresent; + bool m_useFastLCTU; + bool m_usePbIntraFast; + int m_useFastMrg; + bool m_useAMaxBT; + bool m_fastQtBtEnc; + bool m_contentBasedFastQtbt; + int m_fastInterSearchMode; ///< Parameter that controls fast encoder settings + bool m_bUseEarlyCU; ///< flag for using Early CU setting + bool m_useFastDecisionForMerge; ///< flag for using Fast Decision Merge RD-Cost + bool m_useEarlySkipDetection; ///< flag for using Early SKIP Detection + + bool m_bDisableIntraCUsInInterSlices; ///< Flag for disabling intra predicted CUs in inter slices. + bool m_bUseConstrainedIntraPred; ///< flag for using constrained intra prediction + bool m_bFastUDIUseMPMEnabled; + bool m_bFastMEForGenBLowDelayEnabled; + + bool m_MTSImplicit; + int m_TMVPModeId; + bool m_DepQuantEnabled; + bool m_SignDataHidingEnabled; + bool m_MIP; + int m_useFastMIP; + + unsigned m_maxNumMergeCand; ///< Max number of merge candidates + unsigned m_maxNumAffineMergeCand; ///< Max number of affine merge candidates +// unsigned m_maxNumIBCMergeCand; ///< Max number of IBC merge candidates + int m_Geo; + unsigned m_maxNumGeoCand; + int m_RCRateControlMode; + int m_RCNumPasses; + int m_RCTargetBitrate; + int m_RCKeepHierarchicalBit; + bool m_RCUseLCUSeparateModel; + int m_RCInitialQP; + bool m_RCForceIntraQP; + int m_motionEstimationSearchMethod; + bool m_bRestrictMESampling; ///< Restrict sampling for the Selective ME + int m_SearchRange; ///< ME search range + int m_bipredSearchRange; ///< ME search range for bipred refinement + int m_minSearchWindow; ///< ME minimum search window size for the Adaptive Window ME + bool m_bClipForBiPredMeEnabled; ///< Enables clipping for Bi-Pred ME. + bool m_bFastMEAssumingSmootherMVEnabled; ///< Enables fast ME assuming a smoother MV. + int m_fastSubPel; + int m_SMVD; + int m_AMVRspeed; + bool m_LMChroma; + bool m_horCollocatedChromaFlag; + bool m_verCollocatedChromaFlag; + bool m_MRL; + bool m_BDOF; + bool m_DMVR; + int m_EDO; + bool m_lumaReshapeEnable; + int m_reshapeSignalType; + int m_updateCtrl; + int m_adpOption; + int m_initialCW; + int m_LMCSOffset; + ReshapeCW m_reshapeCW; + int m_Affine; + bool m_PROF; + bool m_AffineType; + int m_MMVD; + int m_MmvdDisNum; + bool m_allowDisFracMMVD; + int m_CIIP; + bool m_SbTMVP; + int m_SBT; ///< Sub-Block Transform for inter blocks + int m_LFNST; + int m_MTS; + int m_MTSIntraMaxCand; + int m_ISP; + int m_TS; + int m_TSsize; + int m_useChromaTS; + int m_useBDPCM; + + bool m_bLoopFilterDisable; ///< flag for using deblocking filter + bool m_loopFilterOffsetInPPS; ///< offset for deblocking filter in 0 = slice header, 1 = PPS + int m_loopFilterBetaOffsetDiv2[3]; ///< beta offset for deblocking filter + int m_loopFilterTcOffsetDiv2[3]; ///< tc offset for deblocking filter + int m_deblockingFilterMetric; + + bool m_bLFCrossTileBoundaryFlag; + bool m_bLFCrossSliceBoundaryFlag; ///< 1: filter across slice boundaries 0: do not filter across slice boundaries + bool m_loopFilterAcrossSlicesEnabled; + + bool m_bUseSAO; + double m_saoEncodingRate; ///< When >0 SAO early picture termination is enabled for luma and chroma + double m_saoEncodingRateChroma; ///< The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma. + unsigned m_log2SaoOffsetScale[ MAX_NUM_CH ]; ///< number of bits for the upward bit shift operation on the decoded SAO offsets + int m_saoOffsetBitShift[ MAX_NUM_CH ]; + + bool m_decodingParameterSetEnabled; ///< enable decoding parameter set + bool m_vuiParametersPresent; ///< enable generation of VUI parameters + bool m_hrdParametersPresent; ///< enable generation or HRD parameters + bool m_aspectRatioInfoPresent; ///< Signals whether aspect_ratio_idc is present + int m_aspectRatioIdc; ///< aspect_ratio_idc + int m_sarWidth; ///< horizontal size of the sample aspect ratio + int m_sarHeight; ///< vertical size of the sample aspect ratio + bool m_colourDescriptionPresent; ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present + int m_colourPrimaries; ///< Indicates chromaticity coordinates of the source primaries + int m_transferCharacteristics; ///< Indicates the opto-electronic transfer characteristics of the source + int m_matrixCoefficients; ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries + bool m_chromaLocInfoPresent; ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present + int m_chromaSampleLocTypeTopField; ///< Specifies the location of chroma samples for top field + int m_chromaSampleLocTypeBottomField; ///< Specifies the location of chroma samples for bottom field + int m_chromaSampleLocType; ///< Specifies the location of chroma samples for progressive content + bool m_overscanInfoPresent; ///< Signals whether overscan_appropriate_flag is present + bool m_overscanAppropriateFlag; ///< Indicates whether conformant decoded pictures are suitable for display using overscan + bool m_videoSignalTypePresent; ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present + bool m_videoFullRangeFlag; ///< Indicates the black level and range of luma and chroma signals + + std::string m_summaryOutFilename; ///< filename to use for producing summary output file. + std::string m_summaryPicFilenameBase; ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. + unsigned m_summaryVerboseness; ///< Specifies the level of the verboseness of the text output. + + std::string m_decodeBitstreams[ 2 ]; ///< filename for decode bitstreams. + int m_switchPOC; ///< dbg poc. + int m_switchDQP; ///< switch DQP. + int m_fastForwardToPOC; ///< get to encoding the specified POC as soon as possible by skipping temporal layers irrelevant for the specified POC + bool m_stopAfterFFtoPOC; + bool m_bs2ModPOCAndType; + bool m_forceDecodeBitstream1; + + bool m_alf; ///> Adaptive Loop Filter + bool m_useNonLinearAlfLuma; + bool m_useNonLinearAlfChroma; + unsigned m_maxNumAlfAlternativesChroma; + bool m_ccalf; + int m_ccalfQpThreshold; + int m_MCTF; + bool m_MCTFFutureReference; + int m_MCTFNumLeadFrames; + int m_MCTFNumTrailFrames; + std::vector m_MCTFFrames; + std::vector m_MCTFStrengths; + + int m_dqThresholdVal; + bool m_qtbttSpeedUp; + + int m_fastLocalDualTreeMode; + bool m_frameParallel; + int m_numFppThreads; + bool m_ensureFppBitEqual; + bool m_picPartitionFlag; +public: + + EncCfgExpert() + + : m_listTracingChannels ( false ) + , m_traceRule ( "" ) + , m_traceFile ( "" ) + + , m_conformanceWindowMode ( 1 ) + , m_confWinLeft ( 0 ) + , m_confWinRight ( 0 ) + , m_confWinTop ( 0 ) + , m_confWinBottom ( 0 ) + + , m_temporalSubsampleRatio ( 1 ) + + , m_aiPad { 0, 0 } + , m_enablePictureHeaderInSliceHeader ( true ) + , m_AccessUnitDelimiter ( false ) + + , m_printMSEBasedSequencePSNR ( false ) + , m_printHexPsnr ( false ) + , m_printFrameMSE ( false ) + , m_printSequenceMSE ( false ) + , m_cabacZeroWordPaddingEnabled ( true ) + + , m_subProfile ( 0 ) + , m_bitDepthConstraintValue ( 10 ) + , m_intraOnlyConstraintFlag ( false ) + + , m_InputQueueSize ( 0 ) + , m_rewriteParamSets ( false ) + , m_idrRefParamList ( false ) + , m_maxDecPicBuffering { 0, 0, 0, 0, 0, 0, 0 } // not set -> derived + , m_maxNumReorderPics { 0, 0, 0, 0, 0, 0, 0 } // not set -> derived + , m_maxTempLayer ( 0 ) // not set -> derived + , m_numRPLList0 ( 0 ) // not set -> derived + , m_numRPLList1 ( 0 ) // not set -> derived + + , m_useSameChromaQPTables ( true ) + , m_chromaQpMappingTableParams () + , m_intraQPOffset ( 0 ) + , m_lambdaFromQPEnable ( false ) + , m_adLambdaModifier { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 } + , m_adIntraLambdaModifier () + , m_dIntraQpFactor ( -1.0 ) + , m_qpInValsCb { 25, 33, 43 } + , m_qpInValsCr { 0 } + , m_qpInValsCbCr { 0 } + , m_qpOutValsCb { 25, 32, 37 } + , m_qpOutValsCr { 0 } + , m_qpOutValsCbCr { 0 } + , m_cuQpDeltaSubdiv ( 0 ) + , m_cuChromaQpOffsetSubdiv ( -1 ) + , m_chromaCbQpOffset ( 0 ) + , m_chromaCrQpOffset ( 0 ) + , m_chromaCbQpOffsetDualTree ( 0 ) + , m_chromaCrQpOffsetDualTree ( 0 ) + , m_chromaCbCrQpOffset ( -1 ) + , m_chromaCbCrQpOffsetDualTree ( 0 ) + , m_sliceChromaQpOffsetPeriodicity ( 0 ) + , m_sliceChromaQpOffsetIntraOrPeriodic { 0 , 0 } + + , m_lumaLevelToDeltaQPEnabled (false) + , m_wcgChromaQpControl () + , m_sdr (false) + , m_calculateHdrMetrics (false) + , m_cropOffsetLeft (0) + , m_cropOffsetTop (0) + , m_cropOffsetRight (0) + , m_cropOffsetBottom (0) + + , m_internChromaFormat ( NUM_CHROMA_FORMAT ) + , m_useIdentityTableForNon420Chroma ( true ) + , m_outputBitDepth { 0, 0 } + , m_MSBExtendedBitDepth { 0, 0 } + , m_costMode ( COST_STANDARD_LOSSY ) + , m_decodedPictureHashSEIType ( HASHTYPE_NONE ) + , m_bufferingPeriodSEIEnabled ( false ) + , m_pictureTimingSEIEnabled ( false ) + , m_decodingUnitInfoSEIEnabled ( false ) + , m_entropyCodingSyncEnabled ( false ) + , m_entryPointsPresent ( true ) + , m_signalledSliceIdFlag ( false ) + , m_signalledSliceIdLengthMinus1 ( 0 ) + , m_rectSliceBoundary () + , m_signalledSliceId () + , m_sliceId () // not set -> derived + + , m_CTUSize ( 128 ) + , m_MinQT { 8, 8, 4 } + , m_maxMTTDepth ( 3 ) + , m_maxMTTDepthI ( 3 ) + , m_maxMTTDepthIChroma ( 3 ) + , m_maxBT {32, 128, 64} + , m_maxTT {32, 64, 32} + , m_dualITree ( true ) + , m_MaxCodingDepth ( 0 ) // not set -> derived + , m_log2DiffMaxMinCodingBlockSize ( 0 ) // not set -> derived + , m_log2MaxTbSize ( 6 ) + + , m_bUseASR ( false ) + , m_bUseHADME ( true ) + , m_RDOQ ( 1 ) + , m_useRDOQTS ( true ) + , m_useSelectiveRDOQ ( false) + + , m_JointCbCrMode ( false ) + , m_cabacInitPresent ( true ) + , m_useFastLCTU ( false ) + , m_usePbIntraFast ( false ) + , m_useFastMrg ( 0 ) + , m_useAMaxBT ( false ) + , m_fastQtBtEnc ( true ) + , m_contentBasedFastQtbt ( false ) + , m_fastInterSearchMode ( FASTINTERSEARCH_DISABLED ) + , m_bUseEarlyCU ( false ) + , m_useFastDecisionForMerge ( true ) + , m_useEarlySkipDetection ( false ) + + , m_bDisableIntraCUsInInterSlices ( false ) + , m_bUseConstrainedIntraPred ( false ) + , m_bFastUDIUseMPMEnabled ( true ) + , m_bFastMEForGenBLowDelayEnabled ( true ) + + , m_MTSImplicit ( false ) + , m_TMVPModeId ( 1 ) + , m_DepQuantEnabled ( true ) + , m_SignDataHidingEnabled ( false ) + + , m_MIP ( false ) + , m_useFastMIP ( 0 ) + , m_maxNumMergeCand ( 5 ) + , m_maxNumAffineMergeCand ( 5 ) +// , m_maxNumIBCMergeCand ( 6 ) + , m_Geo ( 0 ) + , m_maxNumGeoCand ( 5 ) + , m_RCRateControlMode ( 0 ) + , m_RCNumPasses ( 1 ) + , m_RCTargetBitrate ( 0 ) + , m_RCKeepHierarchicalBit ( 0 ) + , m_RCUseLCUSeparateModel ( false ) + , m_RCInitialQP ( 0 ) + , m_RCForceIntraQP ( false ) + , m_motionEstimationSearchMethod ( 1 ) + , m_bRestrictMESampling ( false ) + , m_SearchRange ( 96 ) + , m_bipredSearchRange ( 4 ) + , m_minSearchWindow ( 8 ) + , m_bClipForBiPredMeEnabled ( false ) + , m_bFastMEAssumingSmootherMVEnabled ( true ) + , m_fastSubPel ( 0 ) + , m_SMVD ( 0 ) + , m_AMVRspeed ( 0 ) + , m_LMChroma ( false ) + , m_horCollocatedChromaFlag ( true ) + , m_verCollocatedChromaFlag ( false ) + , m_MRL ( true ) + , m_BDOF ( false ) + , m_DMVR ( false ) + , m_EDO ( 0 ) + , m_lumaReshapeEnable ( false ) + , m_reshapeSignalType ( 0 ) + , m_updateCtrl ( 0 ) + , m_adpOption ( 0 ) + , m_initialCW ( 0 ) + , m_LMCSOffset ( 0 ) + , m_reshapeCW ( ) + , m_Affine ( 0 ) + , m_PROF ( false ) + , m_AffineType ( true ) + , m_MMVD ( 0 ) + , m_MmvdDisNum ( 6 ) + , m_allowDisFracMMVD ( false ) + , m_CIIP ( 0 ) + , m_SbTMVP ( false ) + , m_SBT ( 0 ) + , m_LFNST ( 0 ) + , m_MTS ( 0 ) + , m_MTSIntraMaxCand ( 3 ) + , m_ISP(0) + , m_TS ( 0 ) + , m_TSsize ( 3 ) + , m_useChromaTS ( 0 ) + , m_useBDPCM ( 0 ) + + , m_bLoopFilterDisable ( false ) + , m_loopFilterOffsetInPPS ( true ) + , m_loopFilterBetaOffsetDiv2 { 0 } + , m_loopFilterTcOffsetDiv2 { 0 } + , m_deblockingFilterMetric ( 0 ) + + , m_bLFCrossTileBoundaryFlag ( true ) + , m_bLFCrossSliceBoundaryFlag ( true ) + , m_loopFilterAcrossSlicesEnabled ( false ) + + , m_bUseSAO ( true ) + , m_saoEncodingRate ( 0.75 ) + , m_saoEncodingRateChroma ( 0.5 ) + , m_log2SaoOffsetScale { 0, 0 } // not set -> derived + , m_saoOffsetBitShift { 0, 0 } + + , m_decodingParameterSetEnabled ( false ) + , m_vuiParametersPresent ( false ) + , m_hrdParametersPresent ( false ) + , m_aspectRatioInfoPresent ( false ) + , m_aspectRatioIdc ( 0 ) + , m_sarWidth ( 0 ) + , m_sarHeight ( 0 ) + , m_colourDescriptionPresent ( false ) + , m_colourPrimaries ( 2 ) + , m_transferCharacteristics ( 2 ) + , m_matrixCoefficients ( 2 ) + , m_chromaLocInfoPresent ( false ) + , m_chromaSampleLocTypeTopField ( 0 ) + , m_chromaSampleLocTypeBottomField ( 0 ) + , m_chromaSampleLocType ( 0 ) + , m_overscanInfoPresent ( false ) + , m_overscanAppropriateFlag ( false ) + , m_videoSignalTypePresent ( false ) + , m_videoFullRangeFlag ( false ) + + , m_summaryOutFilename ( "" ) + , m_summaryPicFilenameBase ( "" ) + , m_summaryVerboseness ( 0 ) + + , m_decodeBitstreams { "", "" } + , m_switchPOC ( -1 ) + , m_switchDQP ( 0 ) + , m_fastForwardToPOC ( -1 ) + , m_stopAfterFFtoPOC ( false ) + , m_bs2ModPOCAndType ( false ) + , m_forceDecodeBitstream1 ( false ) + + , m_alf ( false ) + , m_useNonLinearAlfLuma ( true ) + , m_useNonLinearAlfChroma ( true ) + , m_maxNumAlfAlternativesChroma ( MAX_NUM_ALF_ALTERNATIVES_CHROMA ) + , m_ccalf ( false ) + , m_ccalfQpThreshold ( 37 ) + + , m_MCTF ( 0 ) + , m_MCTFFutureReference ( true ) + , m_MCTFNumLeadFrames ( 0 ) + , m_MCTFNumTrailFrames ( 0 ) + + , m_dqThresholdVal ( 8 ) + , m_qtbttSpeedUp ( false ) + + , m_fastLocalDualTreeMode ( 0 ) + , m_frameParallel ( false ) + , m_numFppThreads ( -1 ) + , m_ensureFppBitEqual ( false ) + , m_picPartitionFlag ( false ) + { + } + + virtual ~EncCfgExpert() + { + } +}; + + +} // namespace vvenc + +//! \} + diff --git a/include/vvenc/EncoderIf.h b/include/vvenc/EncoderIf.h index a48916492..b4f017cf3 100644 --- a/include/vvenc/EncoderIf.h +++ b/include/vvenc/EncoderIf.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncoderIf.h \brief encoder lib interface */ @@ -46,8 +50,9 @@ vvc@hhi.fraunhofer.de #pragma once #include -#include "../vvenc/Basics.h" -#include "../vvenc/vvencDecl.h" +#include +#include "vvenc/vvencDecl.h" +#include "vvenc/Basics.h" //! \ingroup Interface //! \{ @@ -68,7 +73,7 @@ class VVENC_DECL YUVWriterIf virtual ~YUVWriterIf() {} public: - virtual void outputYuv( const YUVBuffer& yuvOutBuf ) + virtual void outputYuv( const YUVBuffer& /*yuvOutBuf*/ ) { } }; @@ -85,18 +90,20 @@ class VVENC_DECL EncoderIf ~EncoderIf(); - void createEncoderLib ( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf = nullptr ); - void destroyEncoderLib(); - void encodePicture ( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& au, bool& isQueueEmpty ); - void printSummary (); + void initEncoderLib ( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf = nullptr ); + void initPass ( int pass = 0 ); + void encodePicture ( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& au, bool& isQueueEmpty ); + void uninitEncoderLib(); + void printSummary (); }; // ==================================================================================================================== -void VVENC_DECL setMsgFnc( MsgFnc msgFnc ); ///< set message output function for encoder lib. if not set, no messages will be printed. -std::string VVENC_DECL setSIMDExtension( const std::string& simdId ); ///< tries to set given simd extensions used. if not supported by cpu, highest possible extension level will be set and returned. -bool VVENC_DECL isTracingEnabled(); ///< checks if library has tracing supported enabled (see ENABLE_TRACING). -std::string VVENC_DECL getCompileInfoString(); ///< creates compile info string containing OS, Compiler and Bit-depth (e.g. 32 or 64 bit). +void VVENC_DECL registerMsgCbf( std::function msgFnc ); ///< set message output function for encoder lib. if not set, no messages will be printed. +std::string VVENC_DECL setSIMDExtension( const std::string& simdId ); ///< tries to set given simd extensions used. if not supported by cpu, highest possible extension level will be set and returned. +bool VVENC_DECL isTracingEnabled(); ///< checks if library has tracing supported enabled (see ENABLE_TRACING). +std::string VVENC_DECL getCompileInfoString(); ///< creates compile info string containing OS, Compiler and Bit-depth (e.g. 32 or 64 bit). +void VVENC_DECL decodeBitstream( const std::string& FileName); ///< decode bitstream with limited build in decoder } // namespace vvenc diff --git a/include/vvenc/FileIO.h b/include/vvenc/FileIO.h index 8c1ed3894..ac5802ad5 100644 --- a/include/vvenc/FileIO.h +++ b/include/vvenc/FileIO.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file FileIO.h \brief file I/O class (header) */ @@ -47,8 +51,8 @@ vvc@hhi.fraunhofer.de #include #include -#include "../vvenc/Basics.h" -#include "../vvenc/vvencDecl.h" +#include "vvenc/vvencDecl.h" +#include "vvenc/Basics.h" //! \ingroup Interface //! \{ diff --git a/include/vvenc/Nal.h b/include/vvenc/Nal.h index 1f24db8e7..d96e6f50b 100644 --- a/include/vvenc/Nal.h +++ b/include/vvenc/Nal.h @@ -1,49 +1,54 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include #include -#include "../vvenc/Basics.h" +#include "vvenc/vvencDecl.h" +#include "vvenc/Basics.h" //! \ingroup Interface //! \{ @@ -53,7 +58,7 @@ namespace vvenc { /** * Represents a single NALunit header and the associated RBSPayload */ -struct NALUnit +struct VVENC_DECL NALUnit { NalUnitType m_nalUnitType; ///< nal_unit_type uint32_t m_temporalId; ///< temporal_id @@ -125,7 +130,7 @@ struct OutputNALUnit; /** * A single NALunit, with complete payload in EBSP format. */ -struct NALUnitEBSP : public NALUnit +struct VVENC_DECL NALUnitEBSP : public NALUnit { std::ostringstream m_nalUnitData; @@ -152,27 +157,50 @@ struct NALUnitEBSP : public NALUnit * The AccessUnit owns all pointers stored within. Destroying the * AccessUnit will delete all contained objects. */ -class AccessUnit : public std::list // NOTE: Should not inherit from STL. +class VVENC_DECL AccessUnit : public std::list // NOTE: Should not inherit from STL. { public: + AccessUnit() + { + clearAu(); + } + ~AccessUnit() { + clearAu(); + } + + void clearAu() + { + m_uiCts = 0; + m_uiDts = 0; + m_uiPOC = 0; + m_eSliceType = NUMBER_OF_SLICE_TYPES; + m_iTemporalLayer = 0; + m_iStatus = 0; + m_bCtsValid = false; + m_bDtsValid = false; + m_bRAP = false; + m_bRefPic = false; + m_cInfo.clear(); + for (AccessUnit::iterator it = this->begin(); it != this->end(); it++) { delete *it; } + std::list::clear(); } - uint64_t m_uiCts = 0; ///< composition time stamp - uint64_t m_uiDts = 0; ///< decoding time stamp - uint64_t m_uiPOC = 0; ///< picture order count - SliceType m_eSliceType = NUMBER_OF_SLICE_TYPES; ///< slice type (I/P/B) */ - int m_iTemporalLayer = 0; ///< temporal layer - int m_iStatus = 0; - bool m_bCtsValid = false; ///< composition time stamp valid flag - bool m_bDtsValid = false; ///< decoding time stamp valid flag - bool m_bRAP = false; ///< random access point flag - bool m_bRefPic = false; ///< reference picture + uint64_t m_uiCts; ///< composition time stamp + uint64_t m_uiDts; ///< decoding time stamp + uint64_t m_uiPOC; ///< picture order count + SliceType m_eSliceType; ///< slice type (I/P/B) */ + int m_iTemporalLayer; ///< temporal layer + int m_iStatus; + bool m_bCtsValid; ///< composition time stamp valid flag + bool m_bDtsValid; ///< decoding time stamp valid flag + bool m_bRAP; ///< random access point flag + bool m_bRefPic; ///< reference picture std::string m_cInfo; }; diff --git a/include/vvenc/ParcatSegmentFilter.h b/include/vvenc/ParcatSegmentFilter.h index 8047b6330..b231b722f 100644 --- a/include/vvenc/ParcatSegmentFilter.h +++ b/include/vvenc/ParcatSegmentFilter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup VVEncExternalInterfaces \file ParcatSegmentFilter.h diff --git a/include/vvenc/version.h b/include/vvenc/version.h deleted file mode 100644 index eb3473aed..000000000 --- a/include/vvenc/version.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc - -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ - -#if !defined( VVENC_VERSION ) - -#define VVENC_VERSION "0.1.0.1" - -#ifdef _WIN32 -#define VVENC_VS_VERSION 0.1.0.1 -#define VVENC_VS_VERSION_STR "0.1.0.1" -#endif - -#endif diff --git a/include/vvenc/vvenc.h b/include/vvenc/vvenc.h index e89f83eca..f793bef76 100644 --- a/include/vvenc/vvenc.h +++ b/include/vvenc/vvenc.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup vvencExternalInterfaces \file vvenc.h @@ -49,10 +53,10 @@ vvc@hhi.fraunhofer.de #pragma once +#include #include "stdint.h" #include -#include "../vvenc/vvencDecl.h" -#include "../vvenc/Basics.h" +#include "vvenc/vvencDecl.h" namespace vvenc { @@ -170,6 +174,7 @@ enum VvcLevel VVC_LEVEL_6 = 96, VVC_LEVEL_6_1 = 99, VVC_LEVEL_6_2 = 102, + VVC_LEVEL_6_3 = 105, VVC_LEVEL_15_5 = 255, }; @@ -216,6 +221,14 @@ enum VvcNalType VVC_NAL_UNIT_INVALID }; +enum VvcSegmentMode +{ + VVC_SEG_OFF, + VVC_SEG_FIRST, + VVC_SEG_MID, + VVC_SEG_LAST +}; + /** \ingroup VVEncExternalInterfaces The struct AccessUnit contains attributes that are assigned to the compressed output of the encoder for a specific input picture. @@ -307,23 +320,34 @@ typedef struct VVENC_DECL VVEncParameter { VVEncParameter() ///< default constructor, sets member attributes to default values {} - int m_iQp = 30; ///< quantization parameter (no default || 0-51) + int m_iQp = 32; ///< quantization parameter (no default || 0-51) int m_iWidth = 0; ///< luminance width of input picture (no default || 2..4096) int m_iHeight = 0; ///< luminance height of input picture (no default || 2/4..2160) - int m_iGopSize = 16; ///< gop size (default: 16 || 1: low delay, 16,32: hierarchical b frames) - VvcDecodingRefreshType m_eDecodingRefreshType = VVC_DRT_IDR; ///< intra period refresh type (default: VVC_DRT_IDR ) - int m_iIDRPeriod = 0; ///< intra period for IDR/CRA intra refresh/RAP flag (default: 0 || 0: only the first pic, otherwise factor of m_iGopSize + int m_iGopSize = 32; ///< gop size (default: 16 || 1: low delay, 16,32: hierarchical b frames) + VvcDecodingRefreshType m_eDecodingRefreshType = VVC_DRT_IDR; ///< intra period refresh type (default: VVC_DRT_IDR ) + int m_iIDRPeriodSec = 1; ///< intra period for IDR/CRA intra refresh/RAP flag in seconds (default: 1 || -1: only the first pic, otherwise refresh in seconds + int m_iIDRPeriod = 0; ///< intra period for IDR/CRA intra refresh/RAP flag in frames (default: 0 || -1: only the first pic, otherwise factor of m_iGopSize LogLevel m_eLogLevel = LL_INFO; ///< log level (default: 0 || 0: no logging, > 4 (LL_VERBOSE,LL_DETAILS)enables psnr/rate output 0: silent, 1: error, 2: warning, 3: info, 4: notice: 5, verbose, 6: details - int m_iTemporalRate = 0; ///< temporal rate /numerator for fps (no default || e.g. 50, 60000 -> 1-60 fps) - int m_iTemporalScale = 0; ///< temporal scale /denominator for fps (no default || 1, 1001) + int m_iTemporalRate = 60; ///< temporal rate /numerator for fps (no default || e.g. 50, 60000 -> 1-60 fps) + int m_iTemporalScale = 1; ///< temporal scale /denominator for fps (no default || 1, 1001) int m_iTicksPerSecond = 90000; ///< ticks per second e.g. 90000 for dts generation (no default || 1..27000000) - int m_iThreadCount = 1; ///< number of worker threads (no default || should not exceed the number of physical cpu's) - int m_iQuality = 2; ///< encoding quality vs speed (no default || 2 0: faster, 1: fast, 2: medium, 3: slow - int m_iPerceptualQPA = 0; ///< perceptual qpa usage (default: 0 || Mode of perceptually motivated input-adaptive QP modification, abbrev. perceptual QP adaptation (QPA). (0 = off, 1 = SDR WPSNR based, 2 = SDR XPSNR based, 3 = HDR WPSNR based, 4 = HDR XPSNR based, 5 = HDR mean-luma based)) + int m_iMaxFrames = 0; ///< max number of frames to be encoded (default 0: encode all frames) + int m_iFrameSkip = 0; ///< number of frames to skip before start encoding (default 0: off) + int m_iThreadCount = -1; ///< number of worker threads (no default || should not exceed the number of physical cpu's) + int m_iQuality = 2; ///< encoding quality vs speed (no default || 2 0: faster, 1: fast, 2: medium, 3: slow, 4: slower + int m_iPerceptualQPA = 2; ///< perceptual qpa usage (default: 0 || Mode of perceptually motivated input-adaptive QP modification, abbrev. perceptual QP adaptation (QPA). (0 = off, 1 = SDR WPSNR based, 2 = SDR XPSNR based, 3 = HDR WPSNR based, 4 = HDR XPSNR based, 5 = HDR mean-luma based)) int m_iTargetBitRate = 0; ///< target bit rate in bps (no default || 0 : VBR, otherwise bitrate [bits per sec] + int m_iNumPasses = 1; ///< number of rate control passes (default: 1) + int m_iInputBitDepth = 8; ///< input bit-depth (default: 8) + int m_iInternalBitDepth = 10; ///< internal bit-depth (default: 10) VvcProfile m_eProfile = VVC_PROFILE_MAIN_10; ///< vvc profile (default: main_10) - VvcLevel m_eLevel = VVC_LEVEL_5_1; ///< vvc level_idc (default: 5.1 ) - VvcTier m_eTier = VVC_TIER_MAIN; ///< vvc tier (default: main ) + VvcLevel m_eLevel = VVC_LEVEL_5_1; ///< vvc level_idc (default: 5.1) + VvcTier m_eTier = VVC_TIER_MAIN; ///< vvc tier (default: main) + VvcSegmentMode m_eSegMode = VVC_SEG_OFF; ///< segment mode (default: off) + bool m_bAccessUnitDelimiter = false; ///< enable aud (default: off) + bool m_bHrdParametersPresent = false; ///< enable hrd (default: off) + bool m_bBufferingPeriodSEIEnabled = false; ///< enable bp sei (default: off) + bool m_bPictureTimingSEIEnabled = false; ///< enable pt sei (default: off) } VVEncParameter_t; @@ -362,6 +386,11 @@ class VVENC_DECL VVEnc */ int init( const VVEncParameter& rcVVEncParameter ); + /** + This method initializes the encoder instance in dependency to the encoder pass. + */ + int initPass( int pass ); + /** This method resets the encoder instance. This method clears the encoder and releases all internally allocated memory. @@ -372,7 +401,6 @@ class VVENC_DECL VVEnc */ int uninit(); - bool isInitialized(); /** @@ -440,7 +468,7 @@ class VVENC_DECL VVEnc This method reconfigures the encoder instance. This method is used to change encoder settings during the encoding process when the encoder was already initialized. Some parameter changes might require an internal encoder restart, especially when previously used parameter sets VPS, SPS or PPS - become invalid after the parameter change. If changes are limited to TargetBitRate, QP or LogLevel changes then the encoder continues encoding + become invalid after the parameter change. If changes are limited to TargetBitRate or QP changes then the encoder continues encoding without interruption, using the new parameters. Some parameters e.g. NumTheads are not reconfigurable - in this case the encoder returns an Error. The method fails if the encoder is not initialized or if the assigned parameter set given in VVCEncoderParameter struct does not pass the consistency and parameter check. @@ -450,6 +478,14 @@ class VVENC_DECL VVEnc */ int reconfig( const VVEncParameter& rcVVEncParameter ); + /** + This method checks the passed configuration. + The method fails if the encoder is not initialized. + \param[in] rcVVCEncParameter reference to an VVCEncParameter struct that returns the current encoder setup. + \retval int VVENC_ERR_PARAMETER indicates a parameter error, otherwise the return value VVENC_OK indicates success. + */ + int checkConfig( const VVEncParameter& rcVVEncParameter ); + /** This method returns the last occurred error as a string. \param None @@ -460,6 +496,10 @@ class VVENC_DECL VVEnc const char* getEncoderInfo() const; + int getNumLeadFrames() const; + + int getNumTrailFrames() const; + /** This method returns the encoder version number as a string. \param None @@ -474,6 +514,20 @@ class VVENC_DECL VVEnc */ static const char* getErrorMsg( int nRet ); + /** + This static function returns a string according to the passed parameter iQuality. + \param[in] iQuality Quality (preset) as integer + \retval[ ] std::string enabled encoding parameter as string + */ + static const char* getPresetParamsAsStr( int iQuality ); + + /** + This method registers a log message callback function to the encoder library. + If no such function has been registered, the library will omit all messages. + \param Log message callback function. + */ + static void registerMsgCbf( std::function msgCbf ); + private: VVEncImpl* m_pcVVEncImpl; }; diff --git a/include/vvenc/vvencDecl.h b/include/vvenc/vvencDecl.h index 4c97a6298..6ab31b7bc 100644 --- a/include/vvenc/vvencDecl.h +++ b/include/vvenc/vvencDecl.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup VVEncExternalInterfaces \file vvencDecl.h diff --git a/source/App/vvencFFapp/CMakeLists.txt b/source/App/vvencFFapp/CMakeLists.txt index bb4bb2d07..0230db971 100644 --- a/source/App/vvencFFapp/CMakeLists.txt +++ b/source/App/vvencFFapp/CMakeLists.txt @@ -7,19 +7,33 @@ file( GLOB SRC_FILES "*.cpp" ) # get include files file( GLOB INC_FILES "*.h" ) +# get address sanitizer libs for gcc +if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) + if( VVENC_USE_ADDRESS_SANITIZER ) + set( ADDITIONAL_LIBS asan ) + endif() +endif() + # set resource file for MSVC compilers if( MSVC ) set( RESOURCE_FILE ${EXE_NAME}.rc ) - file( GLOB NATVIS_FILES "../../VisualStudio/*.natvis" ) + file( GLOB NATVIS_FILES "../../VisualStudio/*.natvis" ) # extend the stack size on windows to 2MB set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:0x200000" ) endif() # add executable add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${RESOURCE_FILE} ) -target_link_libraries( ${EXE_NAME} Threads::Threads - vvenc - ) +set_target_properties( ${EXE_NAME} PROPERTIES RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}" ) + +target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall -Werror> + $<$:-Wall -Werror -fdiagnostics-show-option> + $<$:/W4 /WX /wd4100 /wd4244 /wd4251 /wd4459 /wd4996>) + +target_link_libraries( ${EXE_NAME} Threads::Threads vvenc ) # example: place header files in different folders source_group( "Header Files" FILES ${INC_FILES} ) diff --git a/source/App/vvencFFapp/EncApp.cpp b/source/App/vvencFFapp/EncApp.cpp index 2cf902d35..a6b451a30 100644 --- a/source/App/vvencFFapp/EncApp.cpp +++ b/source/App/vvencFFapp/EncApp.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncApp.cpp @@ -54,7 +58,7 @@ vvc@hhi.fraunhofer.de #include #include -#include "../../../include/vvenc/Nal.h" +#include "vvenc/Nal.h" #include "../vvencFFapp/ParseArg.h" using namespace std; @@ -93,13 +97,16 @@ bool EncApp::parseCfg( int argc, char* argv[] ) return false; } } - catch ( VVCEncoderFFApp::df::program_options_lite::ParseFailure &e ) + catch( VVCEncoderFFApp::df::program_options_lite::ParseFailure &e ) { msgApp( ERROR, "Error parsing option \"%s\" with argument \"%s\".\n", e.arg.c_str(), e.val.c_str() ); return false; } - m_cEncAppCfg.printCfg(); + if( ! m_cEncAppCfg.m_decode ) + { + m_cEncAppCfg.printCfg(); + } return true; } @@ -109,11 +116,19 @@ bool EncApp::parseCfg( int argc, char* argv[] ) */ void EncApp::encode() { - if ( ! openFileIO() ) + if( m_cEncAppCfg.m_decode ) + { + vvenc::decodeBitstream( m_cEncAppCfg.m_bitstreamFileName ); return; + } - // create encoder lib - m_cEncoderIf.createEncoderLib( m_cEncAppCfg, this ); + if( ! openFileIO() ) + { + return; + } + + // initialize encoder lib + m_cEncoderIf.initEncoderLib( m_cEncAppCfg, this ); printChromaFormat(); @@ -121,61 +136,82 @@ void EncApp::encode() YUVBufferStorage yuvInBuf( m_cEncAppCfg.m_internChromaFormat, m_cEncAppCfg.m_SourceWidth, m_cEncAppCfg.m_SourceHeight ); // main loop - int framesRcvd = 0; - int iTempRate = m_cEncAppCfg.m_FrameRate; - int iTempScale = 1; + int tempRate = m_cEncAppCfg.m_FrameRate; + int tempScale = 1; switch( m_cEncAppCfg.m_FrameRate ) { - case 23: iTempRate = 24000; iTempScale = 1001; break; - case 29: iTempRate = 30000; iTempScale = 1001; break; - case 59: iTempRate = 60000; iTempScale = 1001; break; - default: break; + case 23: tempRate = 24000; tempScale = 1001; break; + case 29: tempRate = 30000; tempScale = 1001; break; + case 59: tempRate = 60000; tempScale = 1001; break; + default: break; } - bool inputDone = false; - bool encDone = false; - while ( ! inputDone || ! encDone ) + int framesRcvd = 0; + for( int pass = 0; pass < m_cEncAppCfg.m_RCNumPasses; pass++ ) { - // check for more input pictures - inputDone = ( m_cEncAppCfg.m_framesToBeEncoded > 0 && framesRcvd >= ( m_cEncAppCfg.m_framesToBeEncoded + m_cEncAppCfg.m_MCTFNumLeadFrames + m_cEncAppCfg.m_MCTFNumTrailFrames ) ) || m_yuvInputFile.isEof(); + // open input YUV + m_yuvInputFile.open( m_cEncAppCfg.m_inputFileName, false, m_cEncAppCfg.m_inputBitDepth, m_cEncAppCfg.m_MSBExtendedBitDepth, m_cEncAppCfg.m_internalBitDepth ); + const int skipFrames = m_cEncAppCfg.m_FrameSkip - m_cEncAppCfg.m_MCTFNumLeadFrames; + if( skipFrames > 0 ) + { + m_yuvInputFile.skipYuvFrames( skipFrames, m_cEncAppCfg.m_inputFileChromaFormat, m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ], m_cEncAppCfg.m_SourceHeight - m_cEncAppCfg.m_aiPad[ 1 ] ); + } + + // initialize encoder pass + m_cEncoderIf.initPass( pass ); - // read input YUV - if ( ! inputDone ) + // loop over input YUV data + bool inputDone = false; + bool encDone = false; + framesRcvd = 0; + while( ! inputDone || ! encDone ) { - inputDone = ! m_yuvInputFile.readYuvBuf( yuvInBuf, m_cEncAppCfg.m_inputFileChromaFormat, m_cEncAppCfg.m_internChromaFormat, m_cEncAppCfg.m_aiPad, m_cEncAppCfg.m_bClipInputVideoToRec709Range ); - if ( ! inputDone ) + // check for more input pictures + inputDone = ( m_cEncAppCfg.m_framesToBeEncoded > 0 + && framesRcvd >= ( m_cEncAppCfg.m_framesToBeEncoded + m_cEncAppCfg.m_MCTFNumLeadFrames + m_cEncAppCfg.m_MCTFNumTrailFrames ) ) + || m_yuvInputFile.isEof(); + + // read input YUV + if( ! inputDone ) { - if( m_cEncAppCfg.m_FrameRate > 0 ) + inputDone = ! m_yuvInputFile.readYuvBuf( yuvInBuf, m_cEncAppCfg.m_inputFileChromaFormat, m_cEncAppCfg.m_internChromaFormat, m_cEncAppCfg.m_aiPad, m_cEncAppCfg.m_bClipInputVideoToRec709Range ); + if( ! inputDone ) { - yuvInBuf.cts = framesRcvd * m_cEncAppCfg.m_TicksPerSecond * iTempScale / iTempRate; - yuvInBuf.ctsValid = true; - } + if( m_cEncAppCfg.m_FrameRate > 0 ) + { + yuvInBuf.cts = framesRcvd * m_cEncAppCfg.m_TicksPerSecond * tempScale / tempRate; + yuvInBuf.ctsValid = true; + } - framesRcvd += 1; + framesRcvd += 1; + } } - } - // encode picture - AccessUnit au; - m_cEncoderIf.encodePicture( inputDone, yuvInBuf, au, encDone ); + // encode picture + AccessUnit au; + m_cEncoderIf.encodePicture( inputDone, yuvInBuf, au, encDone ); - // write out encoded access units - if ( au.size() ) - { - outputAU( au ); - } + // write out encoded access units + if( au.size() ) + { + outputAU( au ); + } - // temporally skip frames - if ( ! inputDone && m_cEncAppCfg.m_temporalSubsampleRatio > 1 ) - { - m_yuvInputFile.skipYuvFrames( m_cEncAppCfg.m_temporalSubsampleRatio - 1, m_cEncAppCfg.m_inputFileChromaFormat, m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ], m_cEncAppCfg.m_SourceHeight - m_cEncAppCfg.m_aiPad[ 1 ] ); + // temporally skip frames + if( ! inputDone && m_cEncAppCfg.m_temporalSubsampleRatio > 1 ) + { + m_yuvInputFile.skipYuvFrames( m_cEncAppCfg.m_temporalSubsampleRatio - 1, m_cEncAppCfg.m_inputFileChromaFormat, m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ], m_cEncAppCfg.m_SourceHeight - m_cEncAppCfg.m_aiPad[ 1 ] ); + } } + + // close input YUV + m_yuvInputFile.close(); } printRateSummary( framesRcvd - ( m_cEncAppCfg.m_MCTFNumLeadFrames + m_cEncAppCfg.m_MCTFNumTrailFrames ) ); - // destroy encoder lib - m_cEncoderIf.destroyEncoderLib(); + // cleanup encoder lib + m_cEncoderIf.uninitEncoderLib(); closeFileIO(); } @@ -201,25 +237,17 @@ void EncApp::outputYuv( const YUVBuffer& yuvOutBuf ) bool EncApp::openFileIO() { - // input YUV - m_yuvInputFile.open( m_cEncAppCfg.m_inputFileName, false, m_cEncAppCfg.m_inputBitDepth, m_cEncAppCfg.m_MSBExtendedBitDepth, m_cEncAppCfg.m_internalBitDepth ); - const int skipFrames = m_cEncAppCfg.m_FrameSkip - m_cEncAppCfg.m_MCTFNumLeadFrames; - if ( skipFrames > 0 ) - { - m_yuvInputFile.skipYuvFrames( skipFrames, m_cEncAppCfg.m_inputFileChromaFormat, m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ], m_cEncAppCfg.m_SourceHeight - m_cEncAppCfg.m_aiPad[ 1 ] ); - } - // output YUV - if ( ! m_cEncAppCfg.m_reconFileName.empty() ) + if( ! m_cEncAppCfg.m_reconFileName.empty() ) { - if ( m_cEncAppCfg.m_packedYUVMode && ( ( m_cEncAppCfg.m_outputBitDepth[ CH_L ] != 10 && m_cEncAppCfg.m_outputBitDepth[ CH_L ] != 12 ) - || ( ( ( m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ] ) & ( 1 + ( m_cEncAppCfg.m_outputBitDepth[ CH_L ] & 3 ) ) ) != 0 ) ) ) + if( m_cEncAppCfg.m_packedYUVMode && ( ( m_cEncAppCfg.m_outputBitDepth[ CH_L ] != 10 && m_cEncAppCfg.m_outputBitDepth[ CH_L ] != 12 ) + || ( ( ( m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ] ) & ( 1 + ( m_cEncAppCfg.m_outputBitDepth[ CH_L ] & 3 ) ) ) != 0 ) ) ) { msgApp( ERROR, "Invalid output bit-depth or image width for packed YUV output, aborting\n" ); return false; } - if ( m_cEncAppCfg.m_packedYUVMode && ( m_cEncAppCfg.m_internChromaFormat != CHROMA_400 ) && ( ( m_cEncAppCfg.m_outputBitDepth[ CH_C ] != 10 && m_cEncAppCfg.m_outputBitDepth[ CH_C ] != 12 ) - || ( ( getWidthOfComponent( m_cEncAppCfg.m_internChromaFormat, m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ], 1 ) & ( 1 + ( m_cEncAppCfg.m_outputBitDepth[ CH_C ] & 3 ) ) ) != 0 ) ) ) + if( m_cEncAppCfg.m_packedYUVMode && ( m_cEncAppCfg.m_internChromaFormat != CHROMA_400 ) && ( ( m_cEncAppCfg.m_outputBitDepth[ CH_C ] != 10 && m_cEncAppCfg.m_outputBitDepth[ CH_C ] != 12 ) + || ( ( getWidthOfComponent( m_cEncAppCfg.m_internChromaFormat, m_cEncAppCfg.m_SourceWidth - m_cEncAppCfg.m_aiPad[ 0 ], 1 ) & ( 1 + ( m_cEncAppCfg.m_outputBitDepth[ CH_C ] & 3 ) ) ) != 0 ) ) ) { msgApp( ERROR, "Invalid chroma output bit-depth or image width for packed YUV output, aborting\n" ); return false; @@ -230,7 +258,7 @@ bool EncApp::openFileIO() // output bitstream m_bitstream.open( m_cEncAppCfg.m_bitstreamFileName.c_str(), fstream::binary | fstream::out ); - if ( ! m_bitstream ) + if( ! m_bitstream ) { msgApp( ERROR, "Failed to open bitstream file %s for writing\n", m_cEncAppCfg.m_bitstreamFileName.c_str() ); return false; @@ -251,28 +279,28 @@ void EncApp::rateStatsAccum(const AccessUnit& au, const std::vector& a AccessUnit::const_iterator it_au = au.begin(); vector::const_iterator it_stats = annexBsizes.begin(); - for (; it_au != au.end(); it_au++, it_stats++) + for( ; it_au != au.end(); it_au++, it_stats++ ) { - switch ((*it_au)->m_nalUnitType) + switch( (*it_au)->m_nalUnitType ) { - case NAL_UNIT_CODED_SLICE_TRAIL: - case NAL_UNIT_CODED_SLICE_STSA: - case NAL_UNIT_CODED_SLICE_IDR_W_RADL: - case NAL_UNIT_CODED_SLICE_IDR_N_LP: - case NAL_UNIT_CODED_SLICE_CRA: - case NAL_UNIT_CODED_SLICE_GDR: - case NAL_UNIT_CODED_SLICE_RADL: - case NAL_UNIT_CODED_SLICE_RASL: - case NAL_UNIT_DCI: - case NAL_UNIT_VPS: - case NAL_UNIT_SPS: - case NAL_UNIT_PPS: - case NAL_UNIT_PREFIX_APS: - case NAL_UNIT_SUFFIX_APS: - m_essentialBytes += *it_stats; - break; - default: - break; + case NAL_UNIT_CODED_SLICE_TRAIL: + case NAL_UNIT_CODED_SLICE_STSA: + case NAL_UNIT_CODED_SLICE_IDR_W_RADL: + case NAL_UNIT_CODED_SLICE_IDR_N_LP: + case NAL_UNIT_CODED_SLICE_CRA: + case NAL_UNIT_CODED_SLICE_GDR: + case NAL_UNIT_CODED_SLICE_RADL: + case NAL_UNIT_CODED_SLICE_RASL: + case NAL_UNIT_DCI: + case NAL_UNIT_VPS: + case NAL_UNIT_SPS: + case NAL_UNIT_PPS: + case NAL_UNIT_PREFIX_APS: + case NAL_UNIT_SUFFIX_APS: + m_essentialBytes += *it_stats; + break; + default: + break; } m_totalBytes += *it_stats; @@ -285,7 +313,7 @@ void EncApp::printRateSummary( int framesRcvd ) double time = (double) framesRcvd / m_cEncAppCfg.m_FrameRate * m_cEncAppCfg.m_temporalSubsampleRatio; msgApp( DETAILS,"Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time ); - if (m_cEncAppCfg.m_summaryVerboseness > 0) + if( m_cEncAppCfg.m_summaryVerboseness > 0 ) { msgApp( DETAILS, "Bytes for SPS/PPS/APS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time ); } @@ -293,32 +321,30 @@ void EncApp::printRateSummary( int framesRcvd ) void EncApp::printChromaFormat() { - if ( m_cEncAppCfg.m_verbosity >= DETAILS ) + if( m_cEncAppCfg.m_verbosity >= DETAILS ) { std::stringstream ssOut; ssOut << std::setw(43) << "Input ChromaFormat = "; - switch ( m_cEncAppCfg.m_inputFileChromaFormat ) + switch( m_cEncAppCfg.m_inputFileChromaFormat ) { - case CHROMA_400: ssOut << " YUV 400"; break; - case CHROMA_420: ssOut << " 420"; break; - case CHROMA_422: ssOut << " 422"; break; - case CHROMA_444: ssOut << " 444"; break; - default: - msgApp( ERROR, "invalid chroma format" ); - return; + case CHROMA_400: ssOut << " YUV 400"; break; + case CHROMA_420: ssOut << " 420"; break; + case CHROMA_422: ssOut << " 422"; break; + case CHROMA_444: ssOut << " 444"; break; + default: msgApp( ERROR, "invalid chroma format" ); + return; } ssOut << std::endl; ssOut << std::setw(43) << "Output (intern) ChromaFormat = "; - switch ( m_cEncAppCfg.m_internChromaFormat ) + switch( m_cEncAppCfg.m_internChromaFormat ) { - case CHROMA_400: ssOut << " 400"; break; - case CHROMA_420: ssOut << " 420"; break; - case CHROMA_422: ssOut << " 422"; break; - case CHROMA_444: ssOut << " 444"; break; - default: - msgApp( ERROR, "invalid chroma format" ); - return; + case CHROMA_400: ssOut << " 400"; break; + case CHROMA_420: ssOut << " 420"; break; + case CHROMA_422: ssOut << " 422"; break; + case CHROMA_444: ssOut << " 444"; break; + default: msgApp( ERROR, "invalid chroma format" ); + return; } msgApp( DETAILS, "%s\n", ssOut.str().c_str() ); } diff --git a/source/App/vvencFFapp/EncApp.h b/source/App/vvencFFapp/EncApp.h index cb58239c9..da5e64701 100644 --- a/source/App/vvencFFapp/EncApp.h +++ b/source/App/vvencFFapp/EncApp.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncApp.h \brief Encoder application class (header) */ @@ -48,8 +52,8 @@ vvc@hhi.fraunhofer.de #include #include -#include "../../../include/vvenc/EncoderIf.h" -#include "../../../include/vvenc/FileIO.h" +#include "vvenc/EncoderIf.h" +#include "vvenc/FileIO.h" #include "../vvencFFapp/EncAppCfg.h" //! \ingroup EncoderApp diff --git a/source/App/vvencFFapp/EncAppCfg.cpp b/source/App/vvencFFapp/EncAppCfg.cpp index 594b7d252..c79a9380e 100644 --- a/source/App/vvencFFapp/EncAppCfg.cpp +++ b/source/App/vvencFFapp/EncAppCfg.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -3. LIMITED PATENT LICENSE +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -4. DISCLAIMER -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncAppCfg.cpp @@ -77,6 +81,100 @@ struct SVPair E value; }; +template +class IStreamToRefVec +{ + public: + IStreamToRefVec( std::vector v, bool _allRequired, char _sep = 'x' ) + : valVec( v ) + , sep( _sep) + , allRequired( _allRequired) + { + } + + ~IStreamToRefVec() + { + } + + template + friend std::istream& operator >> ( std::istream& in, IStreamToRefVec& toVec ); + + template + friend std::ostream& operator << ( std::ostream& os, const IStreamToRefVec& toVec ); + + private: + std::vector valVec; + char sep; + bool allRequired; +}; + +template +inline std::istream& operator >> ( std::istream& in, IStreamToRefVec& toVec ) +{ + const size_t maxSize = toVec.valVec.size(); + size_t idx = 0; + bool fail = false; + // split into multiple lines if any + while ( ! in.eof() ) + { + string line; + std::getline( in, line ); + // treat all whitespaces and commas as valid separators + if( toVec.sep == 'x') + std::replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == 'x'; }, ' ' ); + else + std::replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == ','; }, ' ' ); + std::stringstream tokenStream( line ); + std::string token; + // split into multiple tokens if any + while( std::getline( tokenStream, token, ' ' ) ) + { + if ( ! token.length() ) + continue; + // convert to value + std::stringstream convStream( token ); + T val; + convStream >> val; + fail |= convStream.fail(); + if( idx >= maxSize ) + { + fail = true;//try to write behind buffer + } + else + { + *toVec.valVec[idx++] = val; + } + } + } + + if ( fail || (toVec.allRequired && idx != maxSize) ) + { + in.setstate( ios::failbit ); + } + + return in; +} + +template +inline std::ostream& operator << ( std::ostream& os, const IStreamToRefVec& toVec ) +{ + bool bfirst = true; + for( auto& e: toVec.valVec ) + { + if( bfirst ) + { + bfirst = false; + } + else + { + os << toVec.sep; + } + os << *e; + } + return os; +} + + template class IStreamToEnum { @@ -91,6 +189,9 @@ class IStreamToEnum { } + template + friend std::ostream& operator << ( std::ostream& os, const IStreamToEnum& toEnum ); + template friend std::istream& operator >> ( std::istream& in, IStreamToEnum& toEnum ); @@ -132,10 +233,116 @@ inline std::istream& operator >> ( std::istream& in, IStreamToEnum& toEnum ) return in; } +template +inline std::ostream& operator << ( std::ostream& os, const IStreamToEnum& toEnum ) +{ + for ( const auto& map : *toEnum.toMap ) + { + if ( *toEnum.dstVal == map.value ) + { + os << map.str; + return os; + } + } + + /* not found */ + os.setstate( ios::failbit ); + return os; +} + +typedef void (*setParamFunc) (EncCfg*, int); + +template +class IStreamToFunc +{ + public: + IStreamToFunc( setParamFunc func, EncCfg* encCfg, const std::vector>* m, const E _default ) + : mfunc( func ) + , mencCfg( encCfg ) + , toMap( m ) + , dstVal( _default ) + { + } + + ~IStreamToFunc() + { + } + + template + friend std::istream& operator >> ( std::istream& in, IStreamToFunc& toEnum ); + + template + friend std::ostream& operator << ( std::ostream& in, const IStreamToFunc& toEnum ); + + const char* to_string() const + { + return ""; + } + + private: + setParamFunc mfunc; + EncCfg* mencCfg; + const std::vector>* toMap; + E dstVal; +}; + +template +inline std::istream& operator >> ( std::istream& in, IStreamToFunc& toEnum ) +{ + std::string str; + in >> str; + + for ( const auto& map : *toEnum.toMap ) + { + if ( str == map.str ) + { + toEnum.dstVal = map.value; + toEnum.mfunc(toEnum.mencCfg, map.value); + return in; + } + } + + /* not found */ + in.setstate( ios::failbit ); + return in; +} + +template +inline std::ostream& operator << ( std::ostream& os, const IStreamToFunc& toEnum ) +{ + for ( const auto& map : *toEnum.toMap ) + { + if ( toEnum.dstVal == map.value ) + { + os << map.str; + return os; + } + } + + /* not found */ + os.setstate( ios::failbit ); + return os; +} + +void setPresets( EncCfg* cfg, int preset ) +{ + cfg->initPreset( (PresetMode)preset ); +} // ==================================================================================================================== // string <-> enum fixed mappings // ==================================================================================================================== +const std::vector> PresetToEnumMap = +{ + { "none", PresetMode::NONE }, + { "faster", PresetMode::FASTER }, + { "fast", PresetMode::FAST }, + { "medium", PresetMode::MEDIUM }, + { "slow", PresetMode::SLOW }, + { "slower", PresetMode::SLOWER }, + { "firstpass", PresetMode::FIRSTPASS }, + { "tooltest", PresetMode::TOOLTEST }, +}; const std::vector> ProfileToEnumMap = @@ -168,6 +375,7 @@ const std::vector> LevelToEnumMap = { "6", Level::LEVEL6 }, { "6.1", Level::LEVEL6_1 }, { "6.2", Level::LEVEL6_2 }, + { "6.3", Level::LEVEL6_3 }, }; const std::vector> TierToEnumMap = @@ -227,6 +435,9 @@ class IStreamToVec template friend std::istream& operator >> ( std::istream& in, IStreamToVec& toVec ); + template + friend std::ostream& operator << ( std::ostream& in, const IStreamToVec& toVec ); + private: std::vector* valVec; }; @@ -269,6 +480,25 @@ inline std::istream& operator >> ( std::istream& in, IStreamToVec& toVec ) return in; } +template +inline std::ostream& operator << ( std::ostream& os, const IStreamToVec& toVec ) +{ + bool bfirst = true; + for( auto& e : (*(toVec.valVec))) + { + if( bfirst ) + { + bfirst = false; + } + else + { + os << ","; + } + os << e; + } + + return os; +} // ==================================================================================================================== // Public member functions @@ -285,11 +515,15 @@ EncAppCfg::~EncAppCfg() bool EncAppCfg::parseCfg( int argc, char* argv[] ) { bool do_help = false; + bool do_expert_help = false; int warnUnknowParameter = 0; // // link custom formated configuration parameters with istream reader // + IStreamToFunc toPreset ( setPresets, this, &PresetToEnumMap,PresetMode::MEDIUM); + IStreamToRefVec toSourceSize ( { &m_SourceWidth, &m_SourceHeight }, true, 'x' ); + IStreamToRefVec toLambdaModifier ( { &m_adLambdaModifier[0], &m_adLambdaModifier[1], &m_adLambdaModifier[2], &m_adLambdaModifier[3], &m_adLambdaModifier[4], &m_adLambdaModifier[5], &m_adLambdaModifier[6] }, false ); IStreamToEnum toProfile ( &m_profile, &ProfileToEnumMap ); IStreamToEnum toLevelTier ( &m_levelTier, &TierToEnumMap ); @@ -305,8 +539,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) IStreamToVec toQpInCbCr ( &m_qpInValsCbCr ); IStreamToVec toQpOutCbCr ( &m_qpOutValsCbCr ); IStreamToVec toIntraLambdaModifier ( &m_adIntraLambdaModifier ); - IStreamToVec toTileColumnWidth ( &m_tileColumnWidth ); - IStreamToVec toTileRowHeight ( &m_tileRowHeight ); IStreamToVec toRectSliceBoundary ( &m_rectSliceBoundary ); IStreamToVec toSignalledSliceId ( &m_signalledSliceId ); @@ -319,115 +551,121 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) std::string ignore; po::Options opts; + + opts.addOptions() + + ("help", do_help, "this help text") + ("fullhelp", do_expert_help, "expert help text") + + ("InputFile,i", m_inputFileName, "Original YUV input file name") + ("BitstreamFile,b", m_bitstreamFileName, "Bitstream output file name") + ("ReconFile,o", m_reconFileName, "Reconstructed YUV output file name") + + ("FramesToBeEncoded,f", m_framesToBeEncoded, "Number of frames to be encoded (default=all)") + ("FrameRate,-fr", m_FrameRate, "Frame rate") + ("FrameSkip,-fs", m_FrameSkip, "Number of frames to skip at start of input YUV") + ("TicksPerSecond", m_TicksPerSecond, "Ticks Per Second for dts generation, ( 1..27000000)") + + ("Profile", toProfile, "Profile name to use for encoding. Use [multilayer_]main_10[_444][_still_picture], auto, or none") + ("Tier", toLevelTier, "Tier to use for interpretation of level (main or high)") + ("Level", toLevel, "Level limit to be used, eg 5.1, or none") + + ("IntraPeriod,-ip", m_IntraPeriod, "Intra period in frames, (-1: only first frame)") + ("DecodingRefreshType,-dr", m_DecodingRefreshType, "Intra refresh type (0:none, 1:CRA, 2:IDR, 3:RecPointSEI)") + ("GOPSize,g", m_GOPSize, "GOP size of temporal structure") + + ("InputBitDepth", m_inputBitDepth[ CH_L ], "Bit-depth of input file") + ("OutputBitDepth", m_outputBitDepth[ CH_L ], "Bit-depth of output file") + + ("PerceptQPA,-qpa", m_usePerceptQPA, "Mode of perceptually motivated QP adaptation (0:off, 1:SDR-WPSNR, 2:SDR-XPSNR, 3:HDR-WPSNR, 4:HDR-XPSNR 5:HDR-MeanLuma)") + ("PerceptQPATempFiltIPic", m_usePerceptQPATempFiltISlice, "Temporal high-pass filter in QPA activity calculation for I Pictures (0:off, 1:on)") + + ("Verbosity,v", m_verbosity, "Specifies the level of the verboseness") + ("Size,-s", toSourceSize, "Input resolution (WidthxHeight)") + ("Threads,-t", m_numWppThreads, "Number of threads") + ("preset", toPreset, "select preset for specific encoding setting (faster, fast, medium, slow, slower)") + ; + + po::setDefaults( opts ); + std::ostringstream easyOpts; + po::doHelp( easyOpts, opts ); opts.addOptions() - ("help", do_help, "this help text") - ("c", po::parseConfigFile, "configuration file name") - ("WarnUnknowParameter,w", warnUnknowParameter, "warn for unknown configuration parameters instead of failing") - ("SIMD", ignore, "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension"); + ("c", po::parseConfigFile, "configuration file name") + ("WarnUnknowParameter,w", warnUnknowParameter, "warn for unknown configuration parameters instead of failing") + ("SIMD", ignore, "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension") // file, i/o and source parameters - opts.addOptions() - ("InputFile,i", m_inputFileName, "Original YUV input file name") - ("BitstreamFile,b", m_bitstreamFileName, "Bitstream output file name") - ("ReconFile,o", m_reconFileName, "Reconstructed YUV output file name") - ("ClipInputVideoToRec709Range", m_bClipInputVideoToRec709Range, "If true then clip input video to the Rec. 709 Range on loading when InternalBitDepth is less than MSBExtendedBitDepth") - ("ClipOutputVideoToRec709Range", m_bClipOutputVideoToRec709Range, "If true then clip output video to the Rec. 709 Range on saving when OutputBitDepth is less than InternalBitDepth") - ("PYUV", m_packedYUVMode, "If true then output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data. Ignored for interlaced output."); + ("SourceWidth,-wdt", m_SourceWidth, "Source picture width") + ("SourceHeight,-hgt", m_SourceHeight, "Source picture height"); if ( vvenc::isTracingEnabled() ) { - opts.addOptions() - ("TraceChannelsList", m_listTracingChannels, "List all available tracing channels") - ("TraceRule", m_traceRule, "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")") - ("TraceFile", m_traceFile, "Tracing file"); + opts.addOptions() + ("TraceChannelsList", m_listTracingChannels, "List all available tracing channels") + ("TraceRule", m_traceRule, "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")") + ("TraceFile", m_traceFile, "Tracing file"); } - opts.addOptions() - ("Verbosity,v", m_verbosity, "Specifies the level of the verboseness") - - ("ConformanceWindowMode", m_conformanceWindowMode, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance") - ("ConfWinLeft", m_confWinLeft, "Left offset for window conformance mode 3") - ("ConfWinRight", m_confWinRight, "Right offset for window conformance mode 3") - ("ConfWinTop", m_confWinTop, "Top offset for window conformance mode 3") - ("ConfWinBottom", m_confWinBottom, "Bottom offset for window conformance mode 3") - - ("FramesToBeEncoded,f", m_framesToBeEncoded, "Number of frames to be encoded (default=all)") - ("FrameRate,-fr", m_FrameRate, "Frame rate") - ("FrameSkip,-fs", m_FrameSkip, "Number of frames to skip at start of input YUV") - ("TemporalSubsampleRatio,-ts", m_temporalSubsampleRatio, "Temporal sub-sample ratio when reading input YUV") - - ("SourceWidth,-wdt", m_SourceWidth, "Source picture width") - ("SourceHeight,-hgt", m_SourceHeight, "Source picture height") + ("ConformanceWindowMode", m_conformanceWindowMode, "Window conformance mode (0:off, 1:automatic padding, 2:padding, 3:conformance") + ("ConfWinLeft", m_confWinLeft, "Left offset for window conformance mode 3") + ("ConfWinRight", m_confWinRight, "Right offset for window conformance mode 3") + ("ConfWinTop", m_confWinTop, "Top offset for window conformance mode 3") + ("ConfWinBottom", m_confWinBottom, "Bottom offset for window conformance mode 3") - ("TicksPerSecond", m_TicksPerSecond, "Ticks Per Second for dts generation, default 90000 ( 1..27000000)") + ("TemporalSubsampleRatio,-ts", m_temporalSubsampleRatio, "Temporal sub-sample ratio when reading input YUV") - ("HorizontalPadding,-pdx", m_aiPad[0], "Horizontal source padding for conformance window mode 2") - ("VerticalPadding,-pdy", m_aiPad[1], "Vertical source padding for conformance window mode 2") - ("EnablePictureHeaderInSliceHeader", m_enablePictureHeaderInSliceHeader, "Enable Picture Header in Slice Header") - ("AccessUnitDelimiter", m_AccessUnitDelimiter, "Enable Access Unit Delimiter NALUs") + ("HorizontalPadding,-pdx", m_aiPad[0], "Horizontal source padding for conformance window mode 2") + ("VerticalPadding,-pdy", m_aiPad[1], "Vertical source padding for conformance window mode 2") + ("EnablePictureHeaderInSliceHeader", m_enablePictureHeaderInSliceHeader, "Enable Picture Header in Slice Header") + ("AccessUnitDelimiter", m_AccessUnitDelimiter, "Enable Access Unit Delimiter NALUs") - ("MSEBasedSequencePSNR", m_printMSEBasedSequencePSNR, "0 (default) emit sequence PSNR only as a linear average of the frame PSNRs, 1 = also emit a sequence PSNR based on an average of the frame MSEs") - ("PrintHexPSNR", m_printHexPsnr, "0 (default) don't emit hexadecimal PSNR for each frame, 1 = also emit hexadecimal PSNR values") - ("PrintFrameMSE", m_printFrameMSE, "0 (default) emit only bit count and PSNRs for each frame, 1 = also emit MSE values") - ("PrintSequenceMSE", m_printSequenceMSE, "0 (default) emit only bit rate and PSNRs for the whole sequence, 1 = also emit MSE values") - ("CabacZeroWordPaddingEnabled", m_cabacZeroWordPaddingEnabled, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required") + ("MSEBasedSequencePSNR", m_printMSEBasedSequencePSNR, "Emit sequence PSNR (0: only as a linear average of the frame PSNRs, 1: also based on an average of the frame MSEs") + ("PrintHexPSNR", m_printHexPsnr, "Emit hexadecimal PSNR for each frame (0: off , 1:on") + ("PrintFrameMSE", m_printFrameMSE, "Emit MSE values for each frame (0: off , 1:on") + ("PrintSequenceMSE", m_printSequenceMSE, "Emit MSE values for the whole sequence (0: off , 1:on)") + ("CabacZeroWordPaddingEnabled", m_cabacZeroWordPaddingEnabled, "Add conforming cabac-zero-words to bit streams (0: do not add, 1: add as required)") // Profile and level - ("Profile", toProfile, "Profile name to use for encoding. Use [multilayer_]main_10[_444][_still_picture], auto, or none") - ("Tier", toLevelTier, "Tier to use for interpretation of --Level (main or high only)") - ("Level", toLevel, "Level limit to be used, eg 5.1, or none") - ("SubProfile", m_subProfile, "Sub-profile idc") - ("MaxBitDepthConstraint", m_bitDepthConstraintValue, "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters") - ("IntraConstraintFlag", m_intraOnlyConstraintFlag, "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)") + ("SubProfile", m_subProfile, "Sub-profile idc") + ("MaxBitDepthConstraint", m_bitDepthConstraintValue, "Bit depth to use for profile-constraint for RExt profiles. (0: automatically choose based upon other parameters)") + ("IntraConstraintFlag", m_intraOnlyConstraintFlag, "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)") // Coding structure paramters - ("IntraPeriod,-ip", m_IntraPeriod, "Intra period in frames, (-1: only first frame)") - ("DecodingRefreshType,-dr", m_DecodingRefreshType, "Intra refresh type (0:none 1:CRA 2:IDR 3:RecPointSEI)") - ("GOPSize,g", m_GOPSize, "GOP size of temporal structure") - ("InputQueueSize", m_InputQueueSize, "Size of input frames queue (default: 0, use gop size)") - ("ReWriteParamSets", m_rewriteParamSets, "Enable rewriting of Parameter sets before every (intra) random access point") - ("IDRRefParamList", m_idrRefParamList, "Enable indication of reference picture list syntax elements in slice headers of IDR pictures") + ("InputQueueSize", m_InputQueueSize, "Size of input frames queue (use gop size)") + ("ReWriteParamSets", m_rewriteParamSets, "Enable rewriting of Parameter sets before every (intra) random access point") + ("IDRRefParamList", m_idrRefParamList, "Enable indication of reference picture list syntax elements in slice headers of IDR pictures") /* Quantization parameters */ - ("QP,q", m_QP, "Qp value") - ("SameCQPTablesForAllChroma", m_useSameChromaQPTables, "0: Different tables for Cb, Cr and joint Cb-Cr components, 1 (default): Same tables for all three chroma components") - ("IntraQPOffset", m_intraQPOffset, "Qp offset value for intra slice, typically determined based on GOP size") - ("LambdaFromQpEnable", m_lambdaFromQPEnable, "Enable flag for derivation of lambda from QP") - ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], "Lambda modifier for temporal layer 0. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], "Lambda modifier for temporal layer 1. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], "Lambda modifier for temporal layer 2. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], "Lambda modifier for temporal layer 3. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], "Lambda modifier for temporal layer 4. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], "Lambda modifier for temporal layer 5. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], "Lambda modifier for temporal layer 6. If LambdaModifierI is used, this will not affect intra pictures") - ("LambdaModifierI,-LMI", toIntraLambdaModifier, "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.") - ("IQPFactor,-IQF", m_dIntraQpFactor, "Intra QP Factor for Lambda Computation. If negative, the default will scale lambda based on GOP size (unless LambdaFromQpEnable then IntraQPOffset is used instead)") - ("QpInValCb", toQpInCb, "Input coordinates for the QP table for Cb component") - ("QpInValCr", toQpInCr, "Input coordinates for the QP table for Cr component") - ("QpInValCbCr", toQpInCbCr, "Input coordinates for the QP table for joint Cb-Cr component") - ("QpOutValCb", toQpOutCb, "Output coordinates for the QP table for Cb component") - ("QpOutValCr", toQpOutCr, "Output coordinates for the QP table for Cr component") - ("QpOutValCbCr", toQpOutCbCr, "Output coordinates for the QP table for joint Cb-Cr component") - ("MaxCuDQPSubdiv,-dqd", m_cuQpDeltaSubdiv, "Maximum subdiv for CU luma Qp adjustment") - ("MaxCuChromaQpOffsetSubdiv", m_cuChromaQpOffsetSubdiv, "Maximum subdiv for CU chroma Qp adjustment - set less than 0 to disable") - ("CbQpOffset,-cbqpofs", m_chromaCbQpOffset, "Chroma Cb QP Offset") - ("CrQpOffset,-crqpofs", m_chromaCrQpOffset, "Chroma Cr QP Offset") - ("CbQpOffsetDualTree", m_chromaCbQpOffsetDualTree, "Chroma Cb QP Offset for dual tree") - ("CrQpOffsetDualTree", m_chromaCrQpOffsetDualTree, "Chroma Cr QP Offset for dual tree") - ("CbCrQpOffset,-cbcrqpofs", m_chromaCbCrQpOffset, "QP Offset for joint Cb-Cr mode") - ("CbCrQpOffsetDualTree", m_chromaCbCrQpOffsetDualTree, "QP Offset for joint Cb-Cr mode in dual tree") - ("SliceChromaQPOffsetPeriodicity", m_sliceChromaQpOffsetPeriodicity, "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.") - ("SliceCbQpOffsetIntraOrPeriodic", m_sliceChromaQpOffsetIntraOrPeriodic[0], "Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.") - ("SliceCrQpOffsetIntraOrPeriodic", m_sliceChromaQpOffsetIntraOrPeriodic[1], "Chroma Cr QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.") - - ("PerceptQPA,-qpa", m_usePerceptQPA, "Mode of perceptually motivated QP adaptation\n\t0: off (default)\n\t1: SDR, WPSNR based\n\t2: SDR, XPSNR based\n\t3: HDR, WPSNR based\n\t4: HDR, XPSNR based\n\t5: HDR, mean-luma based.") - ("PerceptQPATempFiltIPic", m_usePerceptQPATempFiltISlice, "Flag indicating if temporal high-pass filter in activity calculation in QPA should (1) or shouldn't (0, default) be applied in I-pictures") - - ("LumaLevelToDeltaQPMode", m_lumaLevelToDeltaQPEnabled, "Luma based Delta QP 0(default): not used. 1: Based on CTU average") + ("QP,q", m_QP, "Qp value") + ("SameCQPTablesForAllChroma", m_useSameChromaQPTables, "0: Different tables for Cb, Cr and joint Cb-Cr components, 1 (default): Same tables for all three chroma components") + ("IntraQPOffset", m_intraQPOffset, "Qp offset value for intra slice, typically determined based on GOP size") + ("LambdaFromQpEnable", m_lambdaFromQPEnable, "Enable flag for derivation of lambda from QP") + ("LambdaModifier,-LM", toLambdaModifier, "Lambda modifier list for temporal layers. If LambdaModifierI is used, this will not affect intra pictures") + ("LambdaModifierI,-LMI", toIntraLambdaModifier, "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.") + ("IQPFactor,-IQF", m_dIntraQpFactor, "Intra QP Factor for Lambda Computation. If negative, the default will scale lambda based on GOP size (unless LambdaFromQpEnable then IntraQPOffset is used instead)") + ("QpInValCb", toQpInCb, "Input coordinates for the QP table for Cb component") + ("QpInValCr", toQpInCr, "Input coordinates for the QP table for Cr component") + ("QpInValCbCr", toQpInCbCr, "Input coordinates for the QP table for joint Cb-Cr component") + ("QpOutValCb", toQpOutCb, "Output coordinates for the QP table for Cb component") + ("QpOutValCr", toQpOutCr, "Output coordinates for the QP table for Cr component") + ("QpOutValCbCr", toQpOutCbCr, "Output coordinates for the QP table for joint Cb-Cr component") + ("MaxCuDQPSubdiv,-dqd", m_cuQpDeltaSubdiv, "Maximum subdiv for CU luma Qp adjustment") + ("MaxCuChromaQpOffsetSubdiv", m_cuChromaQpOffsetSubdiv, "Maximum subdiv for CU chroma Qp adjustment - set less than 0 to disable") + ("CbQpOffset,-cbqpofs", m_chromaCbQpOffset, "Chroma Cb QP Offset") + ("CrQpOffset,-crqpofs", m_chromaCrQpOffset, "Chroma Cr QP Offset") + ("CbQpOffsetDualTree", m_chromaCbQpOffsetDualTree, "Chroma Cb QP Offset for dual tree") + ("CrQpOffsetDualTree", m_chromaCrQpOffsetDualTree, "Chroma Cr QP Offset for dual tree") + ("CbCrQpOffset,-cbcrqpofs", m_chromaCbCrQpOffset, "QP Offset for joint Cb-Cr mode") + ("CbCrQpOffsetDualTree", m_chromaCbCrQpOffsetDualTree, "QP Offset for joint Cb-Cr mode in dual tree") + ("SliceChromaQPOffsetPeriodicity", m_sliceChromaQpOffsetPeriodicity, "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.") + ("SliceCbQpOffsetIntraOrPeriodic", m_sliceChromaQpOffsetIntraOrPeriodic[0], "Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.") + ("SliceCrQpOffsetIntraOrPeriodic", m_sliceChromaQpOffsetIntraOrPeriodic[1], "Chroma Cr QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.") + + ("LumaLevelToDeltaQPMode", m_lumaLevelToDeltaQPEnabled, "Luma based Delta QP 0(default): not used. 1: Based on CTU average") ("isSDR", m_sdr, "compatibility") ("WCGPPSEnable", m_wcgChromaQpControl.enabled, "1: Enable the WCG PPS chroma modulation scheme. 0 (default) disabled") ("WCGPPSCbQpScale", m_wcgChromaQpControl.chromaCbQpScale, "WCG PPS Chroma Cb QP Scale") @@ -443,243 +681,248 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) opts.addOptions() - ("InputChromaFormat", toInputFileCoFormat, "input file chroma format (400|420|422|444) default [420]") - ("ChromaFormatIDC,-cf", toInternCoFormat, "intern chroma format (400|420|422|444) or set to 0 (default), same as InputChromaFormat") - ("UseIdentityTableForNon420Chroma", m_useIdentityTableForNon420Chroma, "True: Indicates that 422/444 chroma uses identity chroma QP mapping tables; False: explicit Qp table may be specified in config") - ("InputBitDepth", m_inputBitDepth[ CH_L ], "Bit-depth of input file") - ("InputBitDepthC", m_inputBitDepth[ CH_C ], "As per InputBitDepth but for chroma component. (default:InputBitDepth)") - ("InternalBitDepth", m_internalBitDepth[ CH_L ], "Bit-depth the codec operates at. (default: MSBExtendedBitDepth). If different to MSBExtendedBitDepth, source data will be converted") -// ("InternalBitDepthC", m_internalBitDepth[ CH_C ], "As per InternalBitDepth but for chroma component. (default:InternalBitDepth)") - ("OutputBitDepth", m_outputBitDepth[ CH_L ], "Bit-depth of output file (default:InternalBitDepth)") - ("OutputBitDepthC", m_outputBitDepth[ CH_C ], "As per OutputBitDepth but for chroma component. (default: use luma output bit-depth)") - ("MSBExtendedBitDepth", m_MSBExtendedBitDepth[ CH_L ], "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)") - ("MSBExtendedBitDepthC", m_MSBExtendedBitDepth[ CH_C ], "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)") - ("CostMode", toCostMode, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).") - ("SEIDecodedPictureHash,-dph", toHashType, "Control generation of decode picture hash SEI messages, options are: 1:md5, 2:crc, 3:checksum, 0:off (default)" ) - ("TileUniformSpacing", m_tileUniformSpacingFlag, "Indicates that tile columns and rows are distributed uniformly") - ("NumTileColumnsMinus1", m_numTileColumnsMinus1, "Number of tile columns in a picture minus 1") - ("NumTileRowsMinus1", m_numTileRowsMinus1, "Number of rows in a picture minus 1") - ("TileColumnWidthArray", toTileColumnWidth, "Array containing tile column width values in units of CTU") - ("TileRowHeightArray", toTileRowHeight, "Array containing tile row height values in units of CTU") - ("WaveFrontSynchro", m_entropyCodingSyncEnabled, "0: entropy coding sync disabled; 1 entropy coding sync enabled") - ("EntryPointsPresent", m_entryPointsPresent, "0: entry points is not present; 1 entry points may be present in slice header") - ("RectSliceFlag", m_rectSliceFlag, "Rectangular slice flag") - ("NumRectSlicesInPicMinus1", m_numSlicesInPicMinus1, "Number slices in pic minus 1") - ("SignalledIdFlag", m_signalledSliceIdFlag, "Signalled Slice ID Flag") - ("SignalledSliceIdLengthMinus1", m_signalledSliceIdLengthMinus1, "Signalled Tile Group Length minus 1") - ("RectSlicesBoundaryArray", toRectSliceBoundary, "Rectangular slices boundaries in Pic") - ("SignalledSliceId", toSignalledSliceId, "Signalled rectangular slice ID") - - ("CTUSize", m_CTUSize, "CTUSize (specifies the CTU size if QTBT is on) [default: 128]") - ("MinQTISlice", m_MinQT[0], "MinQTISlice") - ("MinQTLumaISlice", m_MinQT[0], "MinQTLumaISlice") - ("MinQTNonISlice", m_MinQT[1], "MinQTNonISlice") - ("MinQTChromaISliceInChromaSamples", m_MinQT[2], "MinQTChromaISlice") - ("MaxMTTDepth", m_maxMTTDepth, "maxMTTDepth") - ("MaxMTTDepthI", m_maxMTTDepthI, "maxMTTDepthI") - ("MaxMTTDepthISliceL", m_maxMTTDepthI, "maxMTTDepthISliceL") - ("MaxMTTDepthISliceC", m_maxMTTDepthIChroma, "maxMTTDepthISliceC") + ("InputChromaFormat", toInputFileCoFormat, "input file chroma format (400, 420, 422, 444)") + ("ChromaFormatIDC,-cf", toInternCoFormat, "intern chroma format (400, 420, 422, 444) or set to 0 (default), same as InputChromaFormat") + ("UseIdentityTableForNon420Chroma", m_useIdentityTableForNon420Chroma, "True: Indicates that 422/444 chroma uses identity chroma QP mapping tables; False: explicit Qp table may be specified in config") + ("InputBitDepthC", m_inputBitDepth[ CH_C ], "As per InputBitDepth but for chroma component. (default:InputBitDepth)") + ("InternalBitDepth", m_internalBitDepth[ CH_L ], "Bit-depth the codec operates at. (default: MSBExtendedBitDepth). If different to MSBExtendedBitDepth, source data will be converted") + ("OutputBitDepthC", m_outputBitDepth[ CH_C ], "As per OutputBitDepth but for chroma component. (default: use luma output bit-depth)") + ("MSBExtendedBitDepth", m_MSBExtendedBitDepth[ CH_L ], "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)") + ("MSBExtendedBitDepthC", m_MSBExtendedBitDepth[ CH_C ], "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)") + ("CostMode", toCostMode, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).") + ("SEIDecodedPictureHash,-dph", toHashType, "Control generation of decode picture hash SEI messages, (0:off, 1:md5, 2:crc, 3:checksum)" ) + ("SEIBufferingPeriod", m_bufferingPeriodSEIEnabled, "Control generation of buffering period SEI messages") + ("SEIPictureTiming", m_pictureTimingSEIEnabled, "Control generation of picture timing SEI messages") + ("SEIDecodingUnitInfo", m_decodingUnitInfoSEIEnabled, "Control generation of decoding unit information SEI message.") + ("WaveFrontSynchro", m_entropyCodingSyncEnabled, "Enable entropy coding sync") + ("EntryPointsPresent", m_entryPointsPresent, "Enable entry points in slice header") + ("SignalledIdFlag", m_signalledSliceIdFlag, "Signalled Slice ID Flag") + ("SignalledSliceIdLengthMinus1", m_signalledSliceIdLengthMinus1, "Signalled Tile Group Length minus 1") + ("RectSlicesBoundaryArray", toRectSliceBoundary, "Rectangular slices boundaries in Pic") + ("SignalledSliceId", toSignalledSliceId, "Signalled rectangular slice ID") + + ("CTUSize", m_CTUSize, "CTUSize") + ("MinQTISlice", m_MinQT[0], "MinQTISlice") + ("MinQTLumaISlice", m_MinQT[0], "MinQTLumaISlice") + ("MinQTNonISlice", m_MinQT[1], "MinQTNonISlice") + ("MinQTChromaISliceInChromaSamples", m_MinQT[2], "MinQTChromaISlice") + ("MaxMTTDepth", m_maxMTTDepth, "maxMTTDepth") + ("MaxMTTDepthI", m_maxMTTDepthI, "maxMTTDepthI") + ("MaxMTTDepthISliceL", m_maxMTTDepthI, "maxMTTDepthISliceL") + ("MaxMTTDepthISliceC", m_maxMTTDepthIChroma, "maxMTTDepthISliceC") // --> deprecated - ("MaxMTTHierarchyDepth", m_maxMTTDepth, "maxMTTDepth") - ("MaxMTTHierarchyDepthI", m_maxMTTDepthI, "maxMTTDepthI") - ("MaxMTTHierarchyDepthISliceL", m_maxMTTDepthI, "maxMTTDepthISliceL") - ("MaxMTTHierarchyDepthISliceC", m_maxMTTDepthIChroma, "maxMTTDepthISliceC") + ("MaxMTTHierarchyDepth", m_maxMTTDepth, "maxMTTDepth") + ("MaxMTTHierarchyDepthI", m_maxMTTDepthI, "maxMTTDepthI") + ("MaxMTTHierarchyDepthISliceL", m_maxMTTDepthI, "maxMTTDepthISliceL") + ("MaxMTTHierarchyDepthISliceC", m_maxMTTDepthIChroma, "maxMTTDepthISliceC") // <-- deprecated - ("MaxBTLumaISlice", m_maxBT[0], "MaxBTLumaISlice") - ("MaxBTChromaISlice", m_maxBT[2], "MaxBTChromaISlice") - ("MaxBTNonISlice", m_maxBT[1], "MaxBTNonISlice") - ("MaxTTLumaISlice", m_maxTT[0], "MaxTTLumaISlice") - ("MaxTTChromaISlice", m_maxTT[2], "MaxTTChromaISlice") - ("MaxTTNonISlice", m_maxTT[1], "MaxTTNonISlice") - ("DualITree", m_dualITree, "Use separate QTBT trees for intra slice luma and chroma channel types") - ("Log2MaxTbSize", m_log2MaxTbSize, "Maximum transform block size in logarithm base 2 (Default: 6)") - - ("ASR", m_bUseASR, "Adaptive motion search range") - ("HadamardME", m_bUseHADME, "Hadamard ME for fractional-pel") - ("RDOQ", m_RDOQ, "Rate-Distortion Optimized Quantization mode") - ("RDOQTS", m_useRDOQTS, "") - ("SelectiveRDOQ", m_useSelectiveRDOQ, "Enable selective RDOQ") - - ("JointCbCr", m_JointCbCrMode, "Enable joint coding of chroma residuals (JointCbCr, 0:off, 1:on)") - ("CabacInitPresent", m_cabacInitPresent, "Enable cabac table index selection based on previous frame") - ("LCTUFast", m_useFastLCTU, "Fast methods for large CTU") - ("PBIntraFast", m_usePbIntraFast, "Fast assertion if the intra mode is probable") - ("FastMrg", m_useFastMrg, "Fast methods for inter merge") - ("AMaxBT", m_useAMaxBT, "Adaptive maximal BT-size") - ("FastQtBtEnc", m_fastQtBtEnc, "Fast encoding setting for QTBT (proposal E0023)") - ("ContentBasedFastQtbt", m_contentBasedFastQtbt, "Signal based QTBT speed-up") - ("FEN", m_fastInterSearchMode, "fast encoder setting") - ("ECU", m_bUseEarlyCU, "Early CU setting") - ("FDM", m_useFastDecisionForMerge, "Fast decision for Merge RD Cost") - ("ESD", m_useEarlySkipDetection, "Early SKIP detection setting") - - ("DisableIntraInInter", m_bDisableIntraPUsInInterSlices, "Flag to disable intra PUs in inter slices") - ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, "Constrained Intra Prediction") - ("FastUDIUseMPMEnabled", m_bFastUDIUseMPMEnabled, "If enabled, adapt intra direction search, accounting for MPM") - ("FastMEForGenBLowDelayEnabled", m_bFastMEForGenBLowDelayEnabled, "If enabled use a fast ME for generalised B Low Delay slices") - - ("MTSImplicit", m_MTSImplicit, "Enable implicit MTS (when explicit MTS is off)\n") - ("TMVPMode", m_TMVPModeId, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only") - ("DepQuant", m_DepQuantEnabled, "Enable dependent quantization" ) - ("DQThrVal", m_dqThresholdVal, "Quantization threshold value for DQ last coefficient search" ) - ("SignHideFlag,-SBH", m_SignDataHidingEnabled, "Enable sign data hiding" ) - ("MIP", m_MIP, "Enable MIP (matrix-based intra prediction)") - ("FastMIP", m_useFastMIP, "Fast encoder search for MIP (matrix-based intra prediction)") - ("MaxNumMergeCand", m_maxNumMergeCand, "Maximum number of merge candidates") - ("MaxNumAffineMergeCand", m_maxNumAffineMergeCand, "Maximum number of affine merge candidates") -// ("MaxNumIBCMergeCand", m_maxNumIBCMergeCand, "Maximum number of IBC merge candidates") - ("Geo", m_Geo, "Enable geometric partitioning mode (0:off, 1:on)") - ("MaxNumGeoCand", m_maxNumGeoCand, "Maximum number of geometric partitioning mode candidates") - ("RateControl", m_RCRateControlMode, "Rate control: enable rate control; 1: CTU-level RC; 2: picture-level RC; 3: GOP-level RC" ) - ("TargetBitrate", m_RCTargetBitrate, "Rate control: target bit-rate" ) - ("KeepHierarchicalBit", m_RCKeepHierarchicalBit, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" ) - ("RCLCUSeparateModel", m_RCUseLCUSeparateModel, "Rate control: use CTU level separate R-lambda model" ) - ("InitialQP", m_RCInitialQP, "Rate control: initial QP" ) - ("RCForceIntraQP", m_RCForceIntraQP, "Rate control: force intra QP to be equal to initial QP" ) + ("MaxBTLumaISlice", m_maxBT[0], "MaxBTLumaISlice") + ("MaxBTChromaISlice", m_maxBT[2], "MaxBTChromaISlice") + ("MaxBTNonISlice", m_maxBT[1], "MaxBTNonISlice") + ("MaxTTLumaISlice", m_maxTT[0], "MaxTTLumaISlice") + ("MaxTTChromaISlice", m_maxTT[2], "MaxTTChromaISlice") + ("MaxTTNonISlice", m_maxTT[1], "MaxTTNonISlice") + ("DualITree", m_dualITree, "Use separate luma and chroma QTBT trees for intra slice") + ("Log2MaxTbSize", m_log2MaxTbSize, "Maximum transform block size in logarithm base 2") + + ("ASR", m_bUseASR, "Adaptive motion search range") + ("HadamardME", m_bUseHADME, "Hadamard ME for fractional-pel") + ("RDOQ", m_RDOQ, "Rate-Distortion Optimized Quantization mode") + ("RDOQTS", m_useRDOQTS, "Rate-Distortion Optimized Quantization mode for TransformSkip") + ("SelectiveRDOQ", m_useSelectiveRDOQ, "Enable selective RDOQ") + + ("JointCbCr", m_JointCbCrMode, "Enable joint coding of chroma residuals (0:off, 1:on)") + ("CabacInitPresent", m_cabacInitPresent, "Enable cabac table index selection based on previous frame") + ("LCTUFast", m_useFastLCTU, "Fast methods for large CTU") + ("PBIntraFast", m_usePbIntraFast, "Fast assertion if the intra mode is probable") + ("FastMrg", m_useFastMrg, "Fast methods for inter merge") + ("AMaxBT", m_useAMaxBT, "Adaptive maximal BT-size") + ("FastQtBtEnc", m_fastQtBtEnc, "Fast encoding setting for QTBT") + ("ContentBasedFastQtbt", m_contentBasedFastQtbt, "Signal based QTBT speed-up") + ("FEN", m_fastInterSearchMode, "fast encoder setting") + ("ECU", m_bUseEarlyCU, "Early CU setting") + ("FDM", m_useFastDecisionForMerge, "Fast decision for Merge RD Cost") + ("ESD", m_useEarlySkipDetection, "Early SKIP detection setting") + + ("DisableIntraInInter", m_bDisableIntraCUsInInterSlices, "Flag to disable intra CUs in inter slices") + ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, "Constrained Intra Prediction") + ("FastUDIUseMPMEnabled", m_bFastUDIUseMPMEnabled, "If enabled, adapt intra direction search, accounting for MPM") + ("FastMEForGenBLowDelayEnabled", m_bFastMEForGenBLowDelayEnabled, "If enabled use a fast ME for generalised B Low Delay slices") + + ("MTSImplicit", m_MTSImplicit, "Enable implicit MTS when explicit MTS is off\n") + ("TMVPMode", m_TMVPModeId, "TMVP mode enable(0: off 1: for all slices 2: for certain slices only)") + ("DepQuant", m_DepQuantEnabled, "Enable dependent quantization" ) + ("DQThrVal", m_dqThresholdVal, "Quantization threshold value for DQ last coefficient search" ) + ("SignHideFlag,-SBH", m_SignDataHidingEnabled, "Enable sign data hiding" ) + ("MIP", m_MIP, "Enable MIP (matrix-based intra prediction)") + ("FastMIP", m_useFastMIP, "Fast encoder search for MIP (matrix-based intra prediction)") + ("MaxNumMergeCand", m_maxNumMergeCand, "Maximum number of merge candidates") + ("MaxNumAffineMergeCand", m_maxNumAffineMergeCand, "Maximum number of affine merge candidates") +// ("MaxNumIBCMergeCand", m_maxNumIBCMergeCand, "Maximum number of IBC merge candidates") + ("Geo", m_Geo, "Enable geometric partitioning mode (0:off, 1:on)") + ("MaxNumGeoCand", m_maxNumGeoCand, "Maximum number of geometric partitioning mode candidates") + ("RateControl", m_RCRateControlMode, "Rate control: enable rate control (0:off 1:CTU-level RC; 2:picture-level RC; 3:GOP-level RC)" ) + ("NumPasses", m_RCNumPasses, "Rate control: number of passes; 1: one-pass rate control; 2: two-pass rate control" ) + ("TargetBitrate", m_RCTargetBitrate, "Rate control: target bit-rate [bps]" ) + ("KeepHierarchicalBit", m_RCKeepHierarchicalBit, "Rate control: (0:equal bit allocation, 1:fixed ratio bit allocation, 2:adaptive ratio bit allocation" ) + ("RCLCUSeparateModel", m_RCUseLCUSeparateModel, "Rate control: use CTU level separate R-lambda model" ) + ("InitialQP", m_RCInitialQP, "Rate control: initial QP" ) + ("RCForceIntraQP", m_RCForceIntraQP, "Rate control: force intra QP to be equal to initial QP" ) // motion search options - ("FastSearch", m_motionEstimationSearchMethod, "0:Full search 1:Diamond 2:Selective 3:Enhanced Diamond") - ("RestrictMESampling", m_bRestrictMESampling, "Restrict ME Sampling for selective inter motion search") - ("SearchRange,-sr", m_SearchRange, "Motion search range") - ("BipredSearchRange", m_bipredSearchRange, "Motion search range for bipred refinement") - ("MinSearchWindow", m_minSearchWindow, "Minimum motion search window size for the adaptive window ME") - ("ClipForBiPredMEEnabled", m_bClipForBiPredMeEnabled, "Enables clipping in the Bi-Pred ME. It is disabled to reduce encoder run-time") - ("FastMEAssumingSmootherMVEnabled", m_bFastMEAssumingSmootherMVEnabled, "Enables fast ME assuming a smoother MV.") - ("FastSubPel", m_fastSubPel, "Enables fast sub-pel ME"); + ("FastSearch", m_motionEstimationSearchMethod, "Serach mode (0:Full search 1:Diamond 2:Selective 3:Enhanced Diamond)") + ("RestrictMESampling", m_bRestrictMESampling, "Enable restrict ME Sampling for selective inter motion search") + ("SearchRange,-sr", m_SearchRange, "Motion search range") + ("BipredSearchRange", m_bipredSearchRange, "Motion search range for bipred refinement") + ("MinSearchWindow", m_minSearchWindow, "Minimum motion search window size for the adaptive window ME") + ("ClipForBiPredMEEnabled", m_bClipForBiPredMeEnabled, "Enable clipping in the Bi-Pred ME.") + ("FastMEAssumingSmootherMVEnabled", m_bFastMEAssumingSmootherMVEnabled, "Enable fast ME assuming a smoother MV.") + ("FastSubPel", m_fastSubPel, "Enable fast sub-pel ME"); opts.addOptions() // Deblocking filter parameters - ("LoopFilterDisable", m_bLoopFilterDisable, "") - ("LoopFilterOffsetInPPS", m_loopFilterOffsetInPPS, "") - ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2[0], "") - ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2[0], "") - ("LoopFilterCbBetaOffset_div2", m_loopFilterBetaOffsetDiv2[1], "") - ("LoopFilterCbTcOffset_div2", m_loopFilterTcOffsetDiv2[1], "") - ("LoopFilterCrBetaOffset_div2", m_loopFilterBetaOffsetDiv2[2], "") - ("LoopFilterCrTcOffset_div2", m_loopFilterTcOffsetDiv2[2], "") - ("DeblockingFilterMetric", m_deblockingFilterMetric, "") - - ("LFCrossTileBoundaryFlag", m_bLFCrossTileBoundaryFlag, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering") - ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, "") - ("LoopFilterAcrossTileGroupsEnabled", m_loopFilterAcrossSlicesEnabled, "Loop Filter Across Tile Groups Flag") - - ("SAO", m_bUseSAO, "Enable Sample Adaptive Offset") - ("SaoEncodingRate", m_saoEncodingRate, "When >0 SAO early picture termination is enabled for luma and chroma") - ("SaoEncodingRateChroma", m_saoEncodingRateChroma, "The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma") - ("SaoLumaOffsetBitShift", m_saoOffsetBitShift[ CH_L ], "Specify the luma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP") - ("SaoChromaOffsetBitShift", m_saoOffsetBitShift[ CH_C ], "Specify the chroma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP") - - ("EnableDecodingParameterSet", m_decodingParameterSetEnabled, "Enables writing of Decoding Parameter Set") - ("VuiParametersPresent,-vui", m_vuiParametersPresent, "Enable generation of vui_parameters()") - ("AspectRatioInfoPresent", m_aspectRatioInfoPresent, "Signals whether aspect_ratio_idc is present") - ("AspectRatioIdc", m_aspectRatioIdc, "aspect_ratio_idc") - ("SarWidth", m_sarWidth, "horizontal size of the sample aspect ratio") - ("SarHeight", m_sarHeight, "vertical size of the sample aspect ratio") - ("ColourDescriptionPresent", m_colourDescriptionPresent, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present") - ("ColourPrimaries", m_colourPrimaries, "Indicates chromaticity coordinates of the source primaries") - ("TransferCharacteristics", m_transferCharacteristics, "Indicates the opto-electronic transfer characteristics of the source") - ("MatrixCoefficients", m_matrixCoefficients, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries") - ("ChromaLocInfoPresent", m_chromaLocInfoPresent, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present") - ("ChromaSampleLocTypeTopField", m_chromaSampleLocTypeTopField, "Specifies the location of chroma samples for top field") - ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField, "Specifies the location of chroma samples for bottom field") - ("ChromaSampleLocType", m_chromaSampleLocType, "Specifies the location of chroma samples for progressive content") - ("OverscanInfoPresent", m_overscanInfoPresent, "Indicates whether conformant decoded pictures are suitable for display using overscan\n") - ("OverscanAppropriate", m_overscanAppropriateFlag, "Indicates whether conformant decoded pictures are suitable for display using overscan\n") - ("VideoSignalTypePresent", m_videoSignalTypePresent, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present") - ("VideoFullRange", m_videoFullRangeFlag, "Indicates the black level and range of luma and chroma signals") - - ("SummaryOutFilename", m_summaryOutFilename, "Filename to use for producing summary output file. If empty, do not produce a file.") - ("SummaryPicFilenameBase", m_summaryPicFilenameBase, "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.") - ("SummaryVerboseness", m_summaryVerboseness, "Specifies the level of the verboseness of the text output") - - ("DebugBitstream", m_decodeBitstreams[0], "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." ) - ("DecodeBitstream1", m_decodeBitstreams[0], "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." ) - ("DecodeBitstream2", m_decodeBitstreams[1], "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." ) - ("DebugPOC", m_switchPOC, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC, return to normal encoding." ) - ("SwitchPOC", m_switchPOC, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC, return to normal encoding." ) - ("SwitchDQP", m_switchDQP, "delta QP applied to picture with switchPOC and subsequent pictures." ) - ("FastForwardToPOC", m_fastForwardToPOC, "Get to encoding the specified POC as soon as possible by skipping temporal layers irrelevant for the specified POC." ) - ("StopAfterFFtoPOC", m_stopAfterFFtoPOC, "If using fast forward to POC, after the POC of interest has been hit, stop further encoding.") - ("DecodeBitstream2ModPOCAndType", m_bs2ModPOCAndType, "Modify POC and NALU-type of second input bitstream, to use second BS as closing I-slice") - ("ForceDecodeBitstream1", m_forceDecodeBitstream1, "force decoding of bitstream 1 - use this only if you are realy sure about what you are doing ") - ("SMVD", m_SMVD, "Enable Symmetric MVD 1:default 2:good quality 3:fast\n") - ("AMVR", m_AMVRspeed, "Enable Adaptive MV precision Mode (IMV)") + ("LoopFilterDisable", m_bLoopFilterDisable, "") + ("LoopFilterOffsetInPPS", m_loopFilterOffsetInPPS, "") + ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2[0], "") + ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2[0], "") + ("LoopFilterCbBetaOffset_div2", m_loopFilterBetaOffsetDiv2[1], "") + ("LoopFilterCbTcOffset_div2", m_loopFilterTcOffsetDiv2[1], "") + ("LoopFilterCrBetaOffset_div2", m_loopFilterBetaOffsetDiv2[2], "") + ("LoopFilterCrTcOffset_div2", m_loopFilterTcOffsetDiv2[2], "") + ("DeblockingFilterMetric", m_deblockingFilterMetric, "") + + ("LFCrossTileBoundaryFlag", m_bLFCrossTileBoundaryFlag, "Enable cross-tile-boundary loop filtering") + ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, "Enable cross-slice-boundary loop filtering") + ("LoopFilterAcrossTileGroupsEnabled", m_loopFilterAcrossSlicesEnabled, "Enable loop filtering across tile groups") + + ("SAO", m_bUseSAO, "Enable Sample Adaptive Offset") + ("SaoEncodingRate", m_saoEncodingRate, "When >0 SAO early picture termination is enabled for luma and chroma") + ("SaoEncodingRateChroma", m_saoEncodingRateChroma, "The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma") + ("SaoLumaOffsetBitShift", m_saoOffsetBitShift[ CH_L ], "Specify the luma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP") + ("SaoChromaOffsetBitShift", m_saoOffsetBitShift[ CH_C ], "Specify the chroma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP") + + ("EnableDecodingParameterSet", m_decodingParameterSetEnabled, "Enable writing of Decoding Parameter Set") + ("VuiParametersPresent,-vui", m_vuiParametersPresent, "Enable generation of vui_parameters()") + ("HrdParametersPresent,-hrd", m_hrdParametersPresent, "Enable generation of hrd_parameters()") + ("AspectRatioInfoPresent", m_aspectRatioInfoPresent, "Signals whether aspect_ratio_idc is present") + ("AspectRatioIdc", m_aspectRatioIdc, "aspect_ratio_idc") + ("SarWidth", m_sarWidth, "horizontal size of the sample aspect ratio") + ("SarHeight", m_sarHeight, "vertical size of the sample aspect ratio") + ("ColourDescriptionPresent", m_colourDescriptionPresent, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present") + ("ColourPrimaries", m_colourPrimaries, "Indicates chromaticity coordinates of the source primaries") + ("TransferCharacteristics", m_transferCharacteristics, "Indicates the opto-electronic transfer characteristics of the source") + ("MatrixCoefficients", m_matrixCoefficients, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries") + ("ChromaLocInfoPresent", m_chromaLocInfoPresent, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present") + ("ChromaSampleLocTypeTopField", m_chromaSampleLocTypeTopField, "Specifies the location of chroma samples for top field") + ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField, "Specifies the location of chroma samples for bottom field") + ("ChromaSampleLocType", m_chromaSampleLocType, "Specifies the location of chroma samples for progressive content") + ("OverscanInfoPresent", m_overscanInfoPresent, "Indicates whether conformant decoded pictures are suitable for display using overscan") + ("OverscanAppropriate", m_overscanAppropriateFlag, "Indicates whether conformant decoded pictures are suitable for display using overscan") + ("VideoSignalTypePresent", m_videoSignalTypePresent, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present") + ("VideoFullRange", m_videoFullRangeFlag, "Indicates the black level and range of luma and chroma signals") + + ("SummaryOutFilename", m_summaryOutFilename, "Filename to use for producing summary output file. If empty, do not produce a file.") + ("SummaryPicFilenameBase", m_summaryPicFilenameBase, "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.") + ("SummaryVerboseness", m_summaryVerboseness, "Specifies the level of the verboseness of the text output") + + ("DebugBitstream", m_decodeBitstreams[0], "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." ) + ("DecodeBitstream1", m_decodeBitstreams[0], "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." ) + ("DecodeBitstream2", m_decodeBitstreams[1], "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." ) + ("DebugPOC", m_switchPOC, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC, return to normal encoding." ) + ("SwitchPOC", m_switchPOC, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC, return to normal encoding." ) + ("SwitchDQP", m_switchDQP, "delta QP applied to picture with switchPOC and subsequent pictures." ) + ("FastForwardToPOC", m_fastForwardToPOC, "Get to encoding the specified POC as soon as possible by skipping temporal layers irrelevant for the specified POC." ) + ("StopAfterFFtoPOC", m_stopAfterFFtoPOC, "If using fast forward to POC, after the POC of interest has been hit, stop further encoding.") + ("DecodeBitstream2ModPOCAndType", m_bs2ModPOCAndType, "Modify POC and NALU-type of second input bitstream, to use second BS as closing I-slice") + ("ForceDecodeBitstream1", m_forceDecodeBitstream1, "force decoding of bitstream 1 - use this only if you are realy sure about what you are doing ") + ("SMVD", m_SMVD, "Enable Symmetric MVD (0:off 1:vtm 2:fast 3:faster\n") + ("AMVR", m_AMVRspeed, "Enable Adaptive MV precision Mode (IMV)") // added for backward compatibility with VTM - ("IMV", m_AMVRspeed, "Enable Adaptive MV precision Mode (IMV)") - ("LMChroma", m_LMChroma, " LMChroma prediction " - "\t0: Disable LMChroma\n" - "\t1: Enable LMChroma\n") - ("HorCollocatedChroma", m_horCollocatedChromaFlag, "Specifies location of a chroma sample relatively to the luma sample in horizontal direction in the reference picture resampling\n" - "\t0: horizontally shifted by 0.5 units of luma samples\n" - "\t1: collocated (default)\n") - ("VerCollocatedChroma", m_verCollocatedChromaFlag, "Specifies location of a chroma sample relatively to the luma sample in vertical direction in the cross-component linear model intra prediction and the reference picture resampling\n" - "\t0: horizontally co-sited, vertically shifted by 0.5 units of luma samples\n" - "\t1: collocated\n") - ("MRL", m_MRL, "MultiRefernceLines") - ("BDOF", m_BDOF, "Enable bi-directional optical flow") + ("IMV", m_AMVRspeed, "Enable Adaptive MV precision Mode (IMV)") + ("LMChroma", m_LMChroma, "Enable LMChroma prediction") + ("MRL", m_MRL, "MultiRefernceLines") + ("BDOF", m_BDOF, "Enable bi-directional optical flow") // added for backward compatibility with VTM - ("BIO", m_BDOF, "Enable bi-directional optical flow") - ("DMVR", m_DMVR, "Decoder-side Motion Vector Refinement") - ("EncDbOpt", m_EDO, "Encoder optimization with deblocking filter 1:default 2:fast") - ("EDO", m_EDO, "Encoder optimization with deblocking filter 1:default 2:fast") - ("LMCSEnable", m_lumaReshapeEnable, "Enable LMCS (luma mapping with chroma scaling") - ("LMCS", m_lumaReshapeEnable, "Enable LMCS (luma mapping with chroma scaling") - ("LMCSSignalType", m_reshapeSignalType, "Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG") - ("LMCSUpdateCtrl", m_updateCtrl, "LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP") - ("LMCSAdpOption", m_adpOption, "LMCS adaptation options: 0:automatic(default)," - "1: rsp both (CW66 for QP<=22), 2: rsp TID0 (for all QP)," - "3: rsp inter(CW66 for QP<=22), 4: rsp inter(for all QP).") - ("LMCSInitialCW", m_initialCW, "LMCS initial total codeword (0~1023) when LMCSAdpOption > 0") - ("LMCSOffset", m_LMCSOffset, "LMCS chroma residual scaling offset") - ("ALF", m_alf, "Adpative Loop Filter\n" ) - ("CCALF", m_ccalf, "Cross-component Adaptive Loop Filter" ) - ("CCALFQpTh", m_ccalfQpThreshold, "QP threshold above which encoder reduces CCALF usage") - ("UseNonLinearAlfLuma", m_useNonLinearAlfLuma, "Non-linear adaptive loop filters for Luma Channel") - ("UseNonLinearAlfChroma", m_useNonLinearAlfChroma, "Non-linear adaptive loop filters for Chroma Channels") - ("MaxNumAlfAlternativesChroma", m_maxNumAlfAlternativesChroma, std::string("Maximum number of alternative Chroma filters (1-") + std::to_string(MAX_NUM_ALF_ALTERNATIVES_CHROMA) + std::string (", inclusive)") ) - ("PROF", m_PROF, "Enable prediction refinement with optical flow for affine mode") - ("Affine", m_Affine, "Enable affine prediction") - ("AffineType", m_AffineType, "Enable affine type prediction") - ("MMVD", m_MMVD, "Enable Merge mode with Motion Vector Difference") - ("MmvdDisNum", m_MmvdDisNum, "Number of MMVD Distance Entries") - ("AllowDisFracMMVD", m_allowDisFracMMVD, "Disable fractional MVD in MMVD mode adaptively") - ("MCTF", m_MCTF, "Enable GOP based temporal filter. Disabled per default 1: filter all but the first and last frame, 2: Filter all frames") - ("MCTFFutureReference", m_MCTFFutureReference, "Enable referencing of future frames in the GOP based temporal filter. This is typically disabled for Low Delay configurations.") - ("MCTFNumLeadFrames", m_MCTFNumLeadFrames, "Number of additional MCTF lead frames, which will not be encoded, but can used for MCTF filtering") - ("MCTFNumTrailFrames", m_MCTFNumTrailFrames, "Number of additional MCTF trail frames, which will not be encoded, but can used for MCTF filtering") - ("MCTFFrame", toMCTFFrames, "Frame to filter Strength for frame in GOP based temporal filter") - ("MCTFStrength", toMCTFStrengths, "Strength for frame in GOP based temporal filter.") - - ("FastLocalDualTreeMode", m_fastLocalDualTreeMode, "Fast intra pass coding for local dual-tree in intra coding region, 0: off, 1: use threshold, 2: one intra mode only") - ("QtbttExtraFast", m_qtbttSpeedUp, "Non-VTM compatible QTBTT speed-ups" ) - - ("FrameParallel", m_frameParallel, "Encode multiple frames in parallel (if permitted by GOP structure)") - ("NumFppThreads", m_numFppThreads, "Number of frame parallel processing threads") - ("FppBitEqual", m_ensureFppBitEqual, "Ensure bit equality with frame parallel processing case") - ("NumWppThreads", m_numWppThreads, "Number of parallel wpp threads") - ("WppBitEqual", m_ensureWppBitEqual, "Ensure bit equality with WPP case, 0: off (sequencial mode), 1: copy from wpp line above, 2: line wise reset") - ("EnablePicPartitioning", m_picPartitionFlag, "Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used)") - ("SbTMVP", m_SbTMVP, "Enable Subblock Temporal Motion Vector Prediction (0: off, 1: on) [default: off]") - - ("CIIP", m_CIIP, "Enable CIIP mode, 0: off, 1: vtm, 2: fast, 3: faster ") - ("SBT", m_SBT, "Enable Sub-Block Transform for inter blocks 0: off 1: vtm, 2: fast, 3: faster\n" ) - ("LFNST", m_LFNST, "Enable LFNST (0:off, 1:on) [default: off]" ) - ("MTS", m_MTS, "Multiple Transform Set (MTS)\n" ) - ("MTSIntraMaxCand", m_MTSIntraMaxCand, "Number of additional candidates to test in encoder search for MTS in intra slices\n") - ; + ("BIO", m_BDOF, "Enable bi-directional optical flow") + ("DMVR", m_DMVR, "Decoder-side Motion Vector Refinement") + ("EncDbOpt", m_EDO, "Encoder optimization with deblocking filter 0:off 1:vtm 2:fast") + ("EDO", m_EDO, "Encoder optimization with deblocking filter 0:off 1:vtm 2:fast") + ("LMCSEnable", m_lumaReshapeEnable, "Enable LMCS (luma mapping with chroma scaling") + ("LMCS", m_lumaReshapeEnable, "Enable LMCS (luma mapping with chroma scaling") + ("LMCSSignalType", m_reshapeSignalType, "Input signal type (0:SDR, 1:HDR-PQ, 2:HDR-HLG)") + ("LMCSUpdateCtrl", m_updateCtrl, "LMCS model update control (0:RA, 1:AI, 2:LDB/LDP)") + ("LMCSAdpOption", m_adpOption, "LMCS adaptation options: 0:automatic," + "1: rsp both (CW66 for QP<=22), 2: rsp TID0 (for all QP)," + "3: rsp inter(CW66 for QP<=22), 4: rsp inter(for all QP).") + ("LMCSInitialCW", m_initialCW, "LMCS initial total codeword (0~1023) when LMCSAdpOption > 0") + ("LMCSOffset", m_LMCSOffset, "LMCS chroma residual scaling offset") + ("ALF", m_alf, "Adpative Loop Filter\n" ) + ("CCALF", m_ccalf, "Cross-component Adaptive Loop Filter" ) + ("CCALFQpTh", m_ccalfQpThreshold, "QP threshold above which encoder reduces CCALF usage") + ("UseNonLinearAlfLuma", m_useNonLinearAlfLuma, "Non-linear adaptive loop filters for Luma Channel") + ("UseNonLinearAlfChroma", m_useNonLinearAlfChroma, "Non-linear adaptive loop filters for Chroma Channels") + ("MaxNumAlfAlternativesChroma", m_maxNumAlfAlternativesChroma, std::string("Maximum number of alternative Chroma filters (1-") + std::to_string(MAX_NUM_ALF_ALTERNATIVES_CHROMA) + std::string (", inclusive)") ) + ("PROF", m_PROF, "Enable prediction refinement with optical flow for affine mode") + ("Affine", m_Affine, "Enable affine prediction") + ("AffineType", m_AffineType, "Enable affine type prediction") + ("MMVD", m_MMVD, "Enable Merge mode with Motion Vector Difference") + ("MmvdDisNum", m_MmvdDisNum, "Number of MMVD Distance Entries") + ("AllowDisFracMMVD", m_allowDisFracMMVD, "Disable fractional MVD in MMVD mode adaptively") + ("MCTF", m_MCTF, "Enable GOP based temporal filter. (0:off, 1:filter all but the first and last frame, 2:filter all frames") + ("MCTFFutureReference", m_MCTFFutureReference, "Enable referencing of future frames in the GOP based temporal filter. This is typically disabled for Low Delay configurations.") + ("MCTFNumLeadFrames", m_MCTFNumLeadFrames, "Number of additional MCTF lead frames, which will not be encoded, but can used for MCTF filtering") + ("MCTFNumTrailFrames", m_MCTFNumTrailFrames, "Number of additional MCTF trail frames, which will not be encoded, but can used for MCTF filtering") + ("MCTFFrame", toMCTFFrames, "Frame to filter Strength for frame in GOP based temporal filter") + ("MCTFStrength", toMCTFStrengths, "Strength for frame in GOP based temporal filter.") + + ("FastLocalDualTreeMode", m_fastLocalDualTreeMode, "Fast intra pass coding for local dual-tree in intra coding region (0:off, 1:use threshold, 2:one intra mode only)") + ("QtbttExtraFast", m_qtbttSpeedUp, "Non-VTM compatible QTBTT speed-ups" ) + + ("NumWppThreads", m_numWppThreads, "Number of parallel wpp threads") + ("WppBitEqual", m_ensureWppBitEqual, "Ensure bit equality with WPP case (0:off (sequencial mode), 1:copy from wpp line above, 2:line wise reset)") + ("FrameParallel", m_frameParallel, "Encode multiple frames in parallel (if permitted by GOP structure)") + ("NumFppThreads", m_numFppThreads, "Number of frame parallel processing threads") + ("FppBitEqual", m_ensureFppBitEqual, "Ensure bit equality with frame parallel processing case") + ("EnablePicPartitioning", m_picPartitionFlag, "Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices)") + ("SbTMVP", m_SbTMVP, "Enable Subblock Temporal Motion Vector Prediction (0: off, 1: on)") + + ("CIIP", m_CIIP, "Enable CIIP mode, 0: off, 1: vtm, 2: fast, 3: faster ") + ("SBT", m_SBT, "Enable Sub-Block Transform for inter blocks (0: off 1: vtm, 2: fast, 3: faster)" ) + ("LFNST", m_LFNST, "Enable LFNST (0: off, 1: on)" ) + ("MTS", m_MTS, "Multiple Transform Set (MTS)" ) + ("MTSIntraMaxCand", m_MTSIntraMaxCand, "Number of additional candidates to test for MTS in intra slices") + ("ISP", m_ISP, "Intra Sub-Partitions Mode (0: off, 1: vtm, 2: fast, 3: faster)") + ("TransformSkip", m_TS, "Intra transform skipping, 0: off, 1: TS, 2: TS with SC detection ") + ("TransformSkipLog2MaxSize", m_TSsize, "Specify transform-skip maximum size. Minimum 2, Maximum 5") + ("ChromaTS", m_useChromaTS, "Enable encoder search of chromaTS") + ("BDPCM", m_useBDPCM, "BDPCM (0:off, 1:luma and chroma)") + + ("HorCollocatedChroma", m_horCollocatedChromaFlag, "Specifies location of a chroma sample relatively to the luma sample in horizontal direction in the reference picture resampling" + "(0: horizontally shifted by 0.5 units of luma samples, 1: collocated)") + ("VerCollocatedChroma", m_verCollocatedChromaFlag, "Specifies location of a chroma sample relatively to the luma sample in vertical direction in the cross-component linear model intra prediction and the reference picture resampling" + "(0: horizontally co-sited, vertically shifted by 0.5 units of luma samples, 1: collocated)") + ("ClipInputVideoToRec709Range", m_bClipInputVideoToRec709Range, "Enable clipping input video to the Rec. 709 Range on loading when InternalBitDepth is less than MSBExtendedBitDepth") + ("ClipOutputVideoToRec709Range", m_bClipOutputVideoToRec709Range, "Enable clipping output video to the Rec. 709 Range on saving when OutputBitDepth is less than InternalBitDepth") + ("PYUV", m_packedYUVMode, "Enable output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data. Ignored for interlaced output.") + ; + + po::setDefaults( opts ); + std::ostringstream fullOpts; + po::doHelp( fullOpts, opts ); - for ( int i = 1; i < MAX_GOP + 1; i++ ) + for ( int i = 0; i < MAX_GOP; i++ ) { std::ostringstream cOSS; - cOSS << "Frame" << i; - opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry()); + cOSS << "Frame" << i+1; + opts.addOptions()(cOSS.str(), m_GOPList[i], GOPEntry()); } + opts.addOptions()("decode", m_decode, "decode only"); // // parse command line parameters and read configuration files // - + po::setDefaults( opts ); po::ErrorReporter err; const list& argv_unhandled = po::scanArgv( opts, argc, (const char**) argv, err ); @@ -690,7 +933,13 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) if ( argc == 1 || do_help ) { /* argc == 1: no options have been specified */ - po::doHelp( cout, opts ); + cout << easyOpts.str(); + return false; + } + if ( argc == 1 || do_expert_help ) + { + /* argc == 1: no options have been specified */ + cout << fullOpts.str(); return false; } if ( err.is_errored && ! warnUnknowParameter ) @@ -699,22 +948,22 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) return false; } + if( m_decode ) + { + m_confirmFailed = false; + confirmParameter( m_bitstreamFileName.empty(), "A bitstream file name must be specified (BitstreamFile)" ); + return !m_confirmFailed; + } + // // check own parameters // - if( m_alf ) - { - confirmParameter( m_maxNumAlfAlternativesChroma < 1 || m_maxNumAlfAlternativesChroma > MAX_NUM_ALF_ALTERNATIVES_CHROMA, std::string( std::string( "The maximum number of ALF Chroma filter alternatives must be in the range (1-" ) + std::to_string( MAX_NUM_ALF_ALTERNATIVES_CHROMA ) + std::string( ", inclusive)" ) ).c_str() ); - } m_confirmFailed = false; confirmParameter( m_bitstreamFileName.empty(), "A bitstream file name must be specified (BitstreamFile)" ); confirmParameter( m_decodeBitstreams[0] == m_bitstreamFileName, "Debug bitstream and the output bitstream cannot be equal" ); confirmParameter( m_decodeBitstreams[1] == m_bitstreamFileName, "Decode2 bitstream and the output bitstream cannot be equal" ); confirmParameter( m_inputFileChromaFormat < 0 || m_inputFileChromaFormat >= NUM_CHROMA_FORMAT, "Intern chroma format must be either 400, 420, 422 or 444" ); - confirmParameter( m_RCRateControlMode < 0 || m_RCRateControlMode > 3, "Invalid rate control mode"); - confirmParameter( m_RCRateControlMode == 1 && m_usePerceptQPA > 0, "CTU-level rate control cannot be combined with QPA" ); - confirmParameter( m_RCRateControlMode > 1 && m_GOPSize == 32, "Rate control is currently not supported for GOP size 32" ); if ( m_confirmFailed ) { return false; @@ -741,162 +990,13 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) return true; } -void EncAppCfg::printCfg() +void EncAppCfg::printCfg() const { - //msgApp( DETAILS, "\n" ); msgApp( DETAILS, "Input File : %s\n", m_inputFileName.c_str() ); msgApp( DETAILS, "Bitstream File : %s\n", m_bitstreamFileName.c_str() ); msgApp( DETAILS, "Reconstruction File : %s\n", m_reconFileName.c_str() ); - msgApp( DETAILS, "Real Format : %dx%d %gHz\n", m_SourceWidth - m_confWinLeft - m_confWinRight, m_SourceHeight - m_confWinTop - m_confWinBottom, (double)m_FrameRate / m_temporalSubsampleRatio ); - msgApp( DETAILS, "Internal Format : %dx%d %gHz\n", m_SourceWidth, m_SourceHeight, (double)m_FrameRate / m_temporalSubsampleRatio ); - msgApp( DETAILS, "Sequence PSNR output : %s\n", ( m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only" ) ); - msgApp( DETAILS, "Hexadecimal PSNR output : %s\n", ( m_printHexPsnr ? "Enabled" : "Disabled" ) ); - msgApp( DETAILS, "Sequence MSE output : %s\n", ( m_printSequenceMSE ? "Enabled" : "Disabled" ) ); - msgApp( DETAILS, "Frame MSE output : %s\n", ( m_printFrameMSE ? "Enabled" : "Disabled" ) ); - msgApp( DETAILS, "Cabac-zero-word-padding : %s\n", ( m_cabacZeroWordPaddingEnabled ? "Enabled" : "Disabled" ) ); - msgApp( DETAILS, "Frame/Field : Frame based coding\n" ); - if ( m_framesToBeEncoded > 0 ) - msgApp( DETAILS, "Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip + m_framesToBeEncoded - 1, m_framesToBeEncoded ); - else - msgApp( DETAILS, "Frame index : %u - .. (all frames)\n", m_FrameSkip ); - const IStreamToEnum toProfile( &m_profile, &ProfileToEnumMap ); - msgApp( DETAILS, "Profile : %s\n", toProfile.to_string() ); - msgApp( DETAILS, "CU size / total-depth : %d / %d\n", m_CTUSize, m_MaxCodingDepth ); - msgApp( DETAILS, "Max TB size : %d \n", 1 << m_log2MaxTbSize ); - msgApp( DETAILS, "Motion search range : %d\n", m_SearchRange ); - msgApp( DETAILS, "Intra period : %d\n", m_IntraPeriod ); - msgApp( DETAILS, "Decoding refresh type : %d\n", m_DecodingRefreshType ); - msgApp( DETAILS, "QP : %d\n", m_QP); - msgApp( DETAILS, "Max dQP signaling subdiv : %d\n", m_cuQpDeltaSubdiv); - - msgApp( DETAILS, "Cb QP Offset (dual tree) : %d (%d)\n", m_chromaCbQpOffset, m_chromaCbQpOffsetDualTree); - msgApp( DETAILS, "Cr QP Offset (dual tree) : %d (%d)\n", m_chromaCrQpOffset, m_chromaCrQpOffsetDualTree); - msgApp( DETAILS, "GOP size : %d\n", m_GOPSize ); - msgApp( DETAILS, "Input queue size : %d\n", m_InputQueueSize ); - msgApp( DETAILS, "Input bit depth : (Y:%d, C:%d)\n", m_inputBitDepth[ CH_L ], m_inputBitDepth[ CH_C ] ); - msgApp( DETAILS, "MSB-extended bit depth : (Y:%d, C:%d)\n", m_MSBExtendedBitDepth[ CH_L ], m_MSBExtendedBitDepth[ CH_C ] ); - msgApp( DETAILS, "Internal bit depth : (Y:%d, C:%d)\n", m_internalBitDepth[ CH_L ], m_internalBitDepth[ CH_C ] ); - msgApp( DETAILS, "cu_chroma_qp_offset_subdiv : %d\n", m_cuChromaQpOffsetSubdiv); - if (m_bUseSAO) - { - msgApp( DETAILS, "log2_sao_offset_scale_luma : %d\n", m_log2SaoOffsetScale[ CH_L ] ); - msgApp( DETAILS, "log2_sao_offset_scale_chroma : %d\n", m_log2SaoOffsetScale[ CH_C ] ); - } - - switch (m_costMode) - { - case COST_STANDARD_LOSSY: msgApp( DETAILS, "Cost function: : Lossy coding (default)\n"); break; - case COST_SEQUENCE_LEVEL_LOSSLESS: msgApp( DETAILS, "Cost function: : Sequence_level_lossless coding\n"); break; - case COST_LOSSLESS_CODING: msgApp( DETAILS, "Cost function: : Lossless coding with fixed QP\n"); break; - case COST_MIXED_LOSSLESS_LOSSY_CODING: msgApp( DETAILS, "Cost function: : Mixed_lossless_lossy coding for lossless evaluation\n"); break; - default: msgApp( DETAILS, "Cost function: : Unknown\n"); break; - } - - msgApp( DETAILS, "\n"); - - msgApp( VERBOSE, "TOOL CFG: "); - msgApp( VERBOSE, "IBD:%d ", ((m_internalBitDepth[ CH_L ] > m_MSBExtendedBitDepth[ CH_L ]) || (m_internalBitDepth[ CH_C ] > m_MSBExtendedBitDepth[ CH_C ]))); - msgApp( VERBOSE, "HAD:%d ", m_bUseHADME ); - msgApp( VERBOSE, "RDQ:%d ", m_RDOQ ); - msgApp( VERBOSE, "RDQTS:%d ", m_useRDOQTS ); - msgApp( VERBOSE, "ASR:%d ", m_bUseASR ); - msgApp( VERBOSE, "MinSearchWindow:%d ", m_minSearchWindow ); - msgApp( VERBOSE, "RestrictMESampling:%d ", m_bRestrictMESampling ); - msgApp( VERBOSE, "FEN:%d ", m_fastInterSearchMode ); - msgApp( VERBOSE, "ECU:%d ", m_bUseEarlyCU ); - msgApp( VERBOSE, "FDM:%d ", m_useFastDecisionForMerge ); - msgApp( VERBOSE, "ESD:%d ", m_useEarlySkipDetection ); - msgApp( VERBOSE, "Tiles:%dx%d ", m_numTileColumnsMinus1 + 1, m_numTileRowsMinus1 + 1 ); - msgApp( VERBOSE, "CIP:%d ", m_bUseConstrainedIntraPred); - msgApp( VERBOSE, "SAO:%d ", (m_bUseSAO)?(1):(0)); - msgApp( VERBOSE, "ALF:%d ", m_alf ? 1 : 0 ); - if( m_alf ) - { - msgApp(VERBOSE, "(NonLinLuma:%d ", m_useNonLinearAlfLuma ); - msgApp(VERBOSE, "NonLinChr:%d) ", m_useNonLinearAlfChroma ); - } - msgApp( VERBOSE, "CCALF:%d ", m_ccalf ? 1 : 0 ); - const int iWaveFrontSubstreams = m_entropyCodingSyncEnabled ? (m_SourceHeight + m_CTUSize - 1) / m_CTUSize : 1; - msgApp( VERBOSE, "WaveFrontSynchro:%d WaveFrontSubstreams:%d ", m_entropyCodingSyncEnabled?1:0, iWaveFrontSubstreams); - msgApp( VERBOSE, "TMVPMode:%d ", m_TMVPModeId ); - - msgApp( VERBOSE, "DQ:%d ", m_DepQuantEnabled); - if( m_DepQuantEnabled ) { if( m_dqThresholdVal & 1 ) msgApp( VERBOSE, "(Thr: %d.5) ", m_dqThresholdVal >> 1 ); else msgApp( VERBOSE, "(Thr: %d) ", m_dqThresholdVal >> 1 ); } - msgApp( VERBOSE, "SignBitHidingFlag:%d ", m_SignDataHidingEnabled); - msgApp( VERBOSE, "Perceptual QPA:%d ", m_usePerceptQPA ); - -// if( m_profile == Profile::AUTO ) - { - msgApp( VERBOSE, "\nNEXT TOOL CFG: " ); - msgApp( VERBOSE, "DualITree:%d ", m_dualITree ); - msgApp( VERBOSE, "BIO:%d ", m_BDOF ); - msgApp( VERBOSE, "DMVR:%d ", m_DMVR ); - msgApp( VERBOSE, "MTSImplicit:%d ", m_MTSImplicit ); - msgApp( VERBOSE, "SBT:%d ", m_SBT ); - msgApp( VERBOSE, "JointCbCr:%d ", m_JointCbCrMode ); - msgApp( VERBOSE, "CabacInitPresent:%d ", m_cabacInitPresent ); - msgApp( VERBOSE, "AMVRspeed:%d ", m_AMVRspeed ); - msgApp( VERBOSE, "SMVD:%d ", m_SMVD ); - - msgApp(VERBOSE, "Reshape:%d ", m_lumaReshapeEnable); - if (m_lumaReshapeEnable) - { - msgApp(VERBOSE, "(Signal:%s ", m_reshapeSignalType == 0 ? "SDR" : (m_reshapeSignalType == 2 ? "HDR-HLG" : "HDR-PQ")); - msgApp(VERBOSE, "Opt:%d", m_adpOption); - if (m_adpOption > 0) { msgApp(VERBOSE, " CW:%d", m_initialCW); } - msgApp(VERBOSE, ") "); - } - msgApp(VERBOSE, "CIIP:%d ", m_CIIP); - msgApp(VERBOSE, "MIP:%d ", m_MIP); - msgApp(VERBOSE, "EncDbOpt:%d ", m_EDO); - msgApp(VERBOSE, "MCTF:%d ", m_MCTF); - if ( m_MCTF ) - { - msgApp(VERBOSE, "[L:%d, T:%d] ", m_MCTFNumLeadFrames, m_MCTFNumTrailFrames); - } - msgApp( VERBOSE, "Affine:%d ", m_Affine); - msgApp( VERBOSE, "Affine_Prof:%d ", m_PROF); - msgApp( VERBOSE, "Affine_Type:%d ", m_AffineType); - msgApp( VERBOSE, "MMVD:%d ", m_MMVD); - msgApp( VERBOSE, "DisFracMMVD:%d ", m_allowDisFracMMVD); - msgApp( VERBOSE, "FastSearch:%d ", m_motionEstimationSearchMethod); - msgApp( VERBOSE, "SbTMVP:%d ", m_SbTMVP); - msgApp( VERBOSE, "Geo:%d ", m_Geo); - msgApp( VERBOSE, "LFNST:%d ", m_LFNST); - msgApp(VERBOSE, "MTS:%d ", m_MTS); - msgApp(VERBOSE, "MTSIntraCand:%d ", m_MTSIntraMaxCand); - } - - msgApp( VERBOSE, "\nFAST TOOL CFG: " ); - msgApp( VERBOSE, "LCTUFast:%d ", m_useFastLCTU ); - msgApp( VERBOSE, "FastMrg:%d ", m_useFastMrg ); - msgApp( VERBOSE, "PBIntraFast:%d ", m_usePbIntraFast ); - msgApp( VERBOSE, "AMaxBT:%d ", m_useAMaxBT ); - msgApp( VERBOSE, "FastQtBtEnc:%d ", m_fastQtBtEnc ); - msgApp( VERBOSE, "ContentBasedFastQtbt:%d ", m_contentBasedFastQtbt ); - if( m_MIP ) msgApp(VERBOSE, "FastMIP:%d ", m_useFastMIP); - msgApp( VERBOSE, "FastLocalDualTree:%d ", m_fastLocalDualTreeMode ); - msgApp( VERBOSE, "FastSubPel:%d ", m_fastSubPel ); - msgApp( VERBOSE, "QtbttExtraFast:%d ", m_qtbttSpeedUp ); - - msgApp( VERBOSE, "RateControl:%d ", m_RCRateControlMode ); - if ( m_RCRateControlMode ) - { - msgApp( VERBOSE, "TargetBitrate:%d ", m_RCTargetBitrate ); - msgApp( VERBOSE, "KeepHierarchicalBit:%d ", m_RCKeepHierarchicalBit ); - msgApp( VERBOSE, "RCLCUSeparateModel:%d ", m_RCUseLCUSeparateModel ); - msgApp( VERBOSE, "InitialQP:%d ", m_RCInitialQP ); - msgApp( VERBOSE, "RCForceIntraQP:%d ", m_RCForceIntraQP ); - } - msgApp( VERBOSE, "\nPARALLEL PROCESSING CFG: " ); - msgApp( VERBOSE, "FPP:%d ", m_frameParallel ); - msgApp( VERBOSE, "NumFppThreads:%d ", m_numFppThreads ); - msgApp( VERBOSE, "FppBitEqual:%d ", m_ensureFppBitEqual ); - msgApp( VERBOSE, "WPP:%d ", m_numWppThreads ); - msgApp( VERBOSE, "WppBitEqual:%d ", m_ensureWppBitEqual ); - msgApp( VERBOSE, "WF:%d ", m_entropyCodingSyncEnabled ); - msgApp( VERBOSE, "\n"); + EncCfg::printCfg(); msgApp( NOTICE, "\n"); diff --git a/source/App/vvencFFapp/EncAppCfg.h b/source/App/vvencFFapp/EncAppCfg.h index 066ca75a6..3b27fba75 100644 --- a/source/App/vvencFFapp/EncAppCfg.h +++ b/source/App/vvencFFapp/EncAppCfg.h @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncAppCfg.h \brief Handle encoder configuration parameters (header) */ #pragma once -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" using namespace vvenc; @@ -67,6 +71,7 @@ class EncAppCfg : public EncCfg bool m_bClipInputVideoToRec709Range; bool m_bClipOutputVideoToRec709Range; bool m_packedYUVMode; ///< If true, output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data + bool m_decode; public: @@ -75,6 +80,7 @@ class EncAppCfg : public EncCfg , m_bClipInputVideoToRec709Range ( false ) , m_bClipOutputVideoToRec709Range ( false ) , m_packedYUVMode ( false ) + , m_decode ( false ) { } @@ -82,7 +88,7 @@ class EncAppCfg : public EncCfg public: bool parseCfg( int argc, char* argv[] ); ///< parse configuration file to fill member variables - void printCfg(); + virtual void printCfg() const; }; //! \} diff --git a/source/App/vvencFFapp/ParseArg.cpp b/source/App/vvencFFapp/ParseArg.cpp index 1b76ddf71..c3bc3b6da 100644 --- a/source/App/vvencFFapp/ParseArg.cpp +++ b/source/App/vvencFFapp/ParseArg.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ #include "../vvencFFapp/ParseArg.h" @@ -162,6 +166,7 @@ namespace df { out << "--" << entry.opt_long.front(); } + out << entry.opt->getDefault(); } /* format the help text */ @@ -177,7 +182,7 @@ namespace df max_width = std::max(max_width, (unsigned) line.tellp()); } - unsigned opt_width = std::min(max_width+2, 28u + pad_short) + 2; + unsigned opt_width = std::min(max_width+2, 32u + pad_short) + 2; unsigned desc_width = columns - opt_width; /* second pass: write out formatted option and help text. diff --git a/source/App/vvencFFapp/ParseArg.h b/source/App/vvencFFapp/ParseArg.h index 043f6d6ff..55717e4f1 100644 --- a/source/App/vvencFFapp/ParseArg.h +++ b/source/App/vvencFFapp/ParseArg.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include @@ -92,7 +96,7 @@ namespace df std::stringstream dest; }; - void doHelp(std::ostream& out, Options& opts, unsigned columns = 80); + void doHelp(std::ostream& out, Options& opts, unsigned columns = 120); std::list scanArgv(Options& opts, unsigned argc, const char* argv[], ErrorReporter& error_reporter = default_error_reporter); void setDefaults(Options& opts); void parseConfigFile(Options& opts, const std::string& filename, ErrorReporter& error_reporter = default_error_reporter); @@ -112,6 +116,7 @@ namespace df virtual void parse(const std::string& arg, ErrorReporter&) = 0; /* set the argument to the default value */ virtual void setDefault() = 0; + virtual const std::string getDefault() { return std::string(); } std::string opt_string; std::string opt_desc; @@ -131,11 +136,21 @@ namespace df { opt_storage = opt_default_val; } + virtual const std::string getDefault(); T& opt_storage; T opt_default_val; }; + template + inline + const std::string Option::getDefault() + { + std::ostringstream oss; + oss << " [" << opt_default_val << "] "; + return oss.str(); + } + /* Generic parsing */ template inline void diff --git a/source/App/vvencFFapp/encmain.cpp b/source/App/vvencFFapp/encmain.cpp index 621d4491c..5d4f59cd3 100644 --- a/source/App/vvencFFapp/encmain.cpp +++ b/source/App/vvencFFapp/encmain.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file encmain.cpp @@ -50,7 +54,7 @@ vvc@hhi.fraunhofer.de #include #include -#include "../../../include/vvenc/version.h" +#include "vvenc/version.h" #include "../vvencFFapp/EncApp.h" #include "../vvencFFapp/ParseArg.h" @@ -70,7 +74,7 @@ vvc@hhi.fraunhofer.de int main(int argc, char* argv[]) { - vvenc::setMsgFnc( &msgFnc ); + vvenc::registerMsgCbf( msgFnc ); std::string simdOpt; VVCEncoderFFApp::df::program_options_lite::Options opts; diff --git a/source/App/vvencFFapp/resource.h b/source/App/vvencFFapp/resource.h index 9f3a0341d..58b3a0418 100644 --- a/source/App/vvencFFapp/resource.h +++ b/source/App/vvencFFapp/resource.h @@ -1,60 +1,65 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -4. DISCLAIMER +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. -5. CONTACT INFORMATION +------------------------------------------------------------------------------------------- */ -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ /** - \ingroup VVEncoderFFApp - \file /VVEncoderFFApp/resource.h + \ingroup vvencFFapp + \file /vvencFFapp/resource.h */ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by VVEncoderApp.rc +// Used by vvencFFapp.rc // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif +# ifndef APSTUDIO_READONLY_SYMBOLS +# define _APS_NEXT_RESOURCE_VALUE 101 +# define _APS_NEXT_COMMAND_VALUE 40001 +# define _APS_NEXT_CONTROL_VALUE 1001 +# define _APS_NEXT_SYMED_VALUE 101 +# endif #endif diff --git a/source/App/vvencFFapp/resource_version.h b/source/App/vvencFFapp/resource_version.h index 6e57bae64..777af304e 100644 --- a/source/App/vvencFFapp/resource_version.h +++ b/source/App/vvencFFapp/resource_version.h @@ -1,52 +1,56 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -4. DISCLAIMER +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. -5. CONTACT INFORMATION +------------------------------------------------------------------------------------------- */ -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ #if !defined( resource_version_h ) -#define resource_version_h +# define resource_version_h // pick up top level version information. -#include "vvenc/version.h" - -#define VS_FILE_VERSION VVENC_VS_VERSION -#define VS_FILE_VERSION_STR VVENC_VS_VERSION_STR +# include "vvenc/version.h" +# define VS_FILE_VERSION VVENC_VS_VERSION +# define VS_FILE_VERSION_STR VVENC_VS_VERSION_STR #endif diff --git a/source/App/vvencFFapp/vvencFFapp.rc b/source/App/vvencFFapp/vvencFFapp.rc index c1a44adcd..930b33bc4 100644 --- a/source/App/vvencFFapp/vvencFFapp.rc +++ b/source/App/vvencFFapp/vvencFFapp.rc @@ -1,5 +1,53 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + // Microsoft Visual C++ generated resource script. // +#pragma code_page(65001) + #include "resource.h" #include "resource_version.h" @@ -14,38 +62,10 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END +// Neutral (Default) (unknown sub-lang: 0x8) resources -#endif // APSTUDIO_INVOKED +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ZZZ) +LANGUAGE LANG_NEUTRAL, 0x8 ///////////////////////////////////////////////////////////////////////////// // @@ -62,29 +82,64 @@ VS_VERSION_INFO VERSIONINFO FILEFLAGS 0x0L #endif FILEOS 0x40004L - FILETYPE 0x2L + FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "040904b0" + BLOCK "200004b0" BEGIN VALUE "CompanyName", "Fraunhofer Heinrich Hertz Institute" - VALUE "FileDescription", "VVEncoderFFApp Application" + VALUE "FileDescription", "vvencFFapp Application" VALUE "FileVersion", VS_FILE_VERSION_STR - VALUE "InternalName", "VVEncoderFFApp.exe" - VALUE "LegalCopyright", "Copyright (C) 2019 Fraunhofer Heinrich Hertz Institute" - VALUE "OriginalFilename", "VVEncoderFFApp.exe" - VALUE "ProductName", "VVEncoderFFApp" + VALUE "InternalName", "vvencFFapp.exe" + VALUE "LegalCopyright", "(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V" + VALUE "OriginalFilename", "vvencFFapp.exe" + VALUE "ProductName", "vvencFFapp" VALUE "ProductVersion", VS_FILE_VERSION_STR END END BLOCK "VarFileInfo" BEGIN - VALUE "Translation", 0x409, 1200 + VALUE "Translation", 0x2000, 1200 END END +#endif // Neutral (Default) (unknown sub-lang: 0x8) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/source/App/vvencapp/BinFileWriter.h b/source/App/vvencapp/BinFileWriter.h index 44b7a91db..ad6caa97f 100644 --- a/source/App/vvencapp/BinFileWriter.h +++ b/source/App/vvencapp/BinFileWriter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup VVEncoderApp \file BinFileWriter.h diff --git a/source/App/vvencapp/CMakeLists.txt b/source/App/vvencapp/CMakeLists.txt index 8f8265e9a..d7e2a512a 100644 --- a/source/App/vvencapp/CMakeLists.txt +++ b/source/App/vvencapp/CMakeLists.txt @@ -7,6 +7,13 @@ file( GLOB SRC_FILES "*.cpp" ) # get include files file( GLOB INC_FILES "*.h" ) +# get address sanitizer libs for gcc +if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) + if( VVENC_USE_ADDRESS_SANITIZER ) + set( ADDITIONAL_LIBS asan ) + endif() +endif() + # set resource file for MSVC compilers if( MSVC ) set( RESOURCE_FILE ${EXE_NAME}.rc ) @@ -14,15 +21,21 @@ endif() # add executable add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${RESOURCE_FILE} ) -target_link_libraries( ${EXE_NAME} Threads::Threads - vvenc - ) +set_target_properties( ${EXE_NAME} PROPERTIES RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}" ) + +target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall -Werror> + $<$:-Wall -Werror -fdiagnostics-show-option> + $<$:/W4 /WX /wd4244 /wd4251 /wd4996>) + +target_link_libraries( ${EXE_NAME} Threads::Threads vvenc ) # example: place header files in different folders source_group( "Header Files" FILES ${INC_FILES} ) source_group( "Resource Files" FILES ${RESOURCE_FILE} ) -target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall -Wno-unused-value>) # set the folder where to place the projects set_target_properties( ${EXE_NAME} PROPERTIES FOLDER app ) diff --git a/source/App/vvencapp/CmdLineParser.h b/source/App/vvencapp/CmdLineParser.h index fcda2f6f4..7d43698d5 100644 --- a/source/App/vvencapp/CmdLineParser.h +++ b/source/App/vvencapp/CmdLineParser.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup VVEncoderApp \file CmdLineParser.h @@ -76,60 +80,89 @@ class CmdLineParser "\n" " File input Options\n" "\n" - "\t [--input,-i ] : raw yuv input file\n" - "\t [--size,-s ] : specify input resolution (width x height) ["<< rcParams.m_iWidth << "x" << rcParams.m_iHeight <<"]\n" - "\t [--format,-c ] : set input format (yuv420, yuv420_10) [yuv420]\n" - "\t [--framerate,-r ] : temporal rate (framerate) e.g. 25,29,30,50,59,60 ["<< rcParams.m_iTemporalRate/rcParams.m_iTemporalScale <<"]\n" - "\t [--tickspersec ] : ticks per second e.g. 90000 for dts generation [1..27000000]\n"; + "\t [--input,-i ] : raw yuv input file\n" + "\t [--size,-s ] : specify input resolution (width x height) ["<< rcParams.m_iWidth << "x" << rcParams.m_iHeight <<"]\n" + "\t [--format,-c ] : set input format (yuv420, yuv420_10) [yuv420]\n" + "\t [--framerate,-r ] : temporal rate (framerate) e.g. 25,29,30,50,59,60 ["<< rcParams.m_iTemporalRate/rcParams.m_iTemporalScale <<"]\n" + "\t [--tickspersec ] : ticks per second e.g. 90000 for dts generation [1..27000000]\n"; + if ( bFullHelp ) + { + std::cout << + "\t 29.97 fps = 30000/1001 Hz = 29\n" + "\t 59.94 fps = 60000/1001 Hz = 59\n"; + } + std::cout << + "\t [--frames,-f ] : max. frames to encode (default: -1 all frames)\n" + "\t [--frameskip ] : number of frames to encode skip (default: 0 off)\n"; if ( bFullHelp ) { std::cout << - "\t 29.97 fps = 30000/1001 Hz = 29\n" - "\t 59.94 fps = 60000/1001 Hz = 59\n"; + "\t [--segment ] : when encoding multiple separate segments, specify segment position to enable segment concatenation (first, mid, last) [off]\n" + "\t first : first segment\n" + "\t mid : all segments between first and last segment\n" + "\t last : last segment\n"; } std::cout << - "\t [--frames,-f ] : max. frames to encode (default: -1 all frames) \n" "\n" " Bitstream output options\n" "\n" - "\t [--output,-o ] : bitstream output file (default: not set)\n" + "\t [--output,-o ] : bitstream output file (default: not set)\n" "\n" " Encoder Options\n" "\n" - "\t [--preset ] : select preset for specific encoding setting ( faster, fast, medium, slow ) default: [" << rcPreset << "]\n"; + "\t [--preset ] : select preset for specific encoding setting ( faster, fast, medium, slow, slower ) default: [" << rcPreset << "]\n"; if ( bFullHelp ) { std::cout << - "\t faster : best speed : quality=0 \n" - "\t fast : fast mode : quality=1 \n" - "\t medium : default quality : quality=2 \n" - "\t slow : best quality : quality=3 \n"; + "\t faster : best speed : quality=0 :\n" + "\t " << vvenc::VVEnc::getPresetParamsAsStr(0) << "\n\n"; + std::cout << + "\t fast : fast mode : quality=1 :\n" + "\t " << vvenc::VVEnc::getPresetParamsAsStr(1) << "\n\n"; + std::cout << + "\t medium : default quality : quality=2 :\n" + "\t " << vvenc::VVEnc::getPresetParamsAsStr(2) << "\n\n"; + std::cout << + "\t slow : better quality : quality=3 :\n" + "\t " << vvenc::VVEnc::getPresetParamsAsStr(3) << "\n\n"; + std::cout << + "\t slower : best quality : quality=4 :\n" + "\t " << vvenc::VVEnc::getPresetParamsAsStr(4) << "\n\n"; } std::cout << - "\t [--bitrate,-b ] : Bitrate for rate control (0 constant QP encoding rate control off, otherwise bits per second) [" << rcParams.m_iTargetBitRate << "]\n" - "\t [--qp ] : QP (0-51) [" << rcParams.m_iQp << "]\n" - "\t [--qpa ] : Perceptual QP adaption (0: off, on for 1: SDR(WPSNR), 2: SDR(XPSNR), 3: HDR(WPSNR), 4: HDR(XPSNR), 5: HDR(MeanLuma)) [" << rcParams.m_iPerceptualQPA << "]\n" - "\t [--threads,-t ] : number of threads (1-n) default: size <= HD:" << rcParams.m_iThreadCount << "; UHD:6\n" + "\t [--bitrate,-b ] : bitrate for rate control (0: constant-QP encoding without rate control, otherwise bits/second) default: [" << rcParams.m_iTargetBitRate << "]\n" + "\t [--passes,-p ] : number of rate control passes (1,2) default: [" << rcParams.m_iNumPasses << "]\n" + "\t [--qp,-q ] : quantization parameter, QP (0-51) default: [" << rcParams.m_iQp << "]\n" + "\t [--qpa ] : perceptual QP adaptation to improve visual coding quality (0: off, on for 1: SDR (WPSNR), 2: SDR (XPSNR),\n" + "\t 3: HDR (WPSNR), 4: HDR (XPSNR), 5: HDR (mean luma based)) default: [" << rcParams.m_iPerceptualQPA << "]\n" + "\t [--threads,-t ] : number of threads (1-n) default: [" << rcParams.m_iThreadCount << ": size <= HD: 4, UHD: 6]\n" "\n" - "\t [--gopsize,-g ] : GOP size of temporal structure (16) [" << rcParams.m_iGopSize << "]\n" - "\t [--refreshtype,-rt ] : intra refresh type (idr,cra)\n" - "\t [--intraperiod,-ip ] : Intra period in frames (-1, only first frame, else idr: gopsize+1, cra: gopsize ) [" << rcParams.m_iIDRPeriod << "]\n" + "\t [--gopsize,-g ] : GOP size of temporal structure (16,32) [" << rcParams.m_iGopSize << "]\n" + "\t [--refreshtype,-rt ] : intra refresh type (idr,cra)\n" + "\t [--refreshsec,-rs ] : Intra period/refresh in seconds [" << rcParams.m_iIDRPeriodSec << "]\n" + "\t [--intraperiod,-ip ] : Intra period in frames (0: use intra period in seconds (refreshsec), else: n*gopsize) [" << rcParams.m_iIDRPeriod << "]\n"; + if ( bFullHelp ) + { + std::cout << + "\t [--internal-bitdepth ] : internal bitdepth (8,10) [" << rcParams.m_iInternalBitDepth << "]\n"; + } + + std::cout << "\n" - "\t [--profile ] : select profile ( main10, main10_stillpic) default: [" << rcProfile << "]\n" - "\t [--level ] : select level ( 1.0, 2.0,2.1, 3.0,3.1, 4.0,4.1, 5.0,5.1,5.2, 6.0,6.1,6.2, 15.5 ) default: [" << rcLevel << "]\n" - "\t [--tier ] : select tier ( main, high ) default: [" << rcTier << "]\n" + "\t [--profile ] : select profile (main10, main10_stillpic) default: [" << rcProfile << "]\n" + "\t [--level ] : select level (1.0, 2.0,2.1, 3.0,3.1, 4.0,4.1, 5.0,5.1,5.2, 6.0,6.1,6.2,6.3 15.5) default: [" << rcLevel << "]\n" + "\t [--tier ] : select tier (main, high) default: [" << rcTier << "]\n" "\n" " General Options\n" "\n" - "\t [--verbosity,-v ] : verbosity level (0: silent, 1: error, 2: warning, 3: info, 4: notice: 5, verbose, 6: debug) (default: " << (int)rcParams.m_eLogLevel << ")\n" - "\t [--help,-h ] : show basic help\n" - "\t [--fullhelp ] : show full help\n" + "\t [--verbosity,-v ] : verbosity level (0: silent, 1: error, 2: warning, 3: info, 4: notice, 5: verbose, 6: debug) default: [" << (int)rcParams.m_eLogLevel << "]\n" + "\t [--help,-h ] : show basic help\n" + "\t [--fullhelp ] : show full help\n" "\n" ; std::cout << std::endl; } - static int parse_command_line( int argc, char* argv[] , vvenc::VVEncParameter& rcParams, std::string& rcInputFile, std::string& rcBitstreamFile, - int& riFrames, int& riInputBitdepth, bool& rbThreadCountSet ) + static int parse_command_line( int argc, char* argv[] , vvenc::VVEncParameter& rcParams, std::string& rcInputFile, std::string& rcBitstreamFile ) { int iRet = 0; /* Check command line parameters */ @@ -143,7 +176,7 @@ class CmdLineParser i_arg++; int iLogLevel = atoi( argv[i_arg++] ); if( iLogLevel < 0 ) iLogLevel = 0; - if( iLogLevel > (int)vvenc::LogLevel::LL_DETAILS ) iLogLevel = (int)vvenc::LogLevel::LL_DETAILS ; + if( iLogLevel > (int)vvenc::LL_DETAILS ) iLogLevel = (int)vvenc::LL_DETAILS; rcParams.m_eLogLevel = (vvenc::LogLevel)iLogLevel; if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) @@ -158,7 +191,6 @@ class CmdLineParser case vvenc::LL_NOTICE : cll = "NOTICE"; break; case vvenc::LL_VERBOSE: cll = "VERBOSE"; break; case vvenc::LL_DETAILS: cll = "DETAILS"; break; - case vvenc::LL_DEBUG_PLUS_INTERNAL_LOGS: cll = "DEBUG_PLUS_INTERNAL_LOGS"; break; default: cll = "UNKNOWN"; break; }; fprintf( stdout, "[verbosity] : %d - %s\n", (int)rcParams.m_eLogLevel, cll.c_str() ); @@ -255,9 +287,49 @@ class CmdLineParser else if( (!strcmp( (const char*)argv[i_arg], "-f" )) || !strcmp( (const char*)argv[i_arg], "--frames" ) ) { i_arg++; - riFrames = atoi( argv[i_arg++] ); + rcParams.m_iMaxFrames = atoi( argv[i_arg++] ); + if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) + fprintf( stdout, "[frames] : %d\n", rcParams.m_iMaxFrames ); + } + else if( !strcmp( (const char*)argv[i_arg], "--frameskip" ) ) + { + i_arg++; + rcParams.m_iFrameSkip= atoi( argv[i_arg++] ); if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) - fprintf( stdout, "[frames] : %d\n", riFrames ); + fprintf( stdout, "[frameskip] : %d\n", rcParams.m_iFrameSkip ); + } + else if( !strcmp( (const char*)argv[i_arg], "--segment" ) ) + { + i_arg++; + if( i_arg < argc && strlen( argv[i_arg] ) > 0 ) + { + if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) + fprintf( stdout, "[segment] : %s\n", argv[i_arg] ); + std::string cSegMode = argv[i_arg++]; + std::transform( cSegMode.begin(), cSegMode.end(), cSegMode.begin(), ::tolower ); + + if( "off" == cSegMode) + { + rcParams.m_eSegMode = vvenc::VVC_SEG_OFF; + } + else if( "first" == cSegMode ) + { + rcParams.m_eSegMode = vvenc::VVC_SEG_FIRST; + } + else if( "mid" == cSegMode ) + { + rcParams.m_eSegMode = vvenc::VVC_SEG_MID; + } + else if( "last" == cSegMode ) + { + rcParams.m_eSegMode = vvenc::VVC_SEG_LAST; + } + else + { + std::cerr << "wrong segment mode! use: --segment off, first, mid, last" << std::endl; + return -1; + } + } } else if( (!strcmp( (const char*)argv[i_arg], "-c" )) || !strcmp( (const char*)argv[i_arg], "--format" ) ) { @@ -271,11 +343,11 @@ class CmdLineParser if( "yuv420" == cColorSpace || "yuv420p" == cColorSpace ) { - riInputBitdepth = 8; + rcParams.m_iInputBitDepth = 8; } else if( "yuv420_10" == cColorSpace ) { - riInputBitdepth = 10; + rcParams.m_iInputBitDepth = 10; } else { @@ -291,7 +363,6 @@ class CmdLineParser if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) fprintf( stdout, "[threads] : %d\n", iThreads ); rcParams.m_iThreadCount = iThreads; - rbThreadCountSet = true; } else if( !strcmp( (const char*)argv[i_arg], "--preset") ) { @@ -303,7 +374,15 @@ class CmdLineParser std::string cPreset = argv[i_arg++]; std::transform( cPreset.begin(), cPreset.end(), cPreset.begin(), ::tolower ); - if( "slow" == cPreset) + if( "tooltest" == cPreset) + { + rcParams.m_iQuality = 255; + } + else if( "slower" == cPreset) + { + rcParams.m_iQuality = 4; + } + else if( "slow" == cPreset) { rcParams.m_iQuality = 3; } @@ -321,7 +400,7 @@ class CmdLineParser } else { - std::cerr << "wrong preset! use: --preset faster, fast, medium, slow" << std::endl; + std::cerr << "wrong preset! use: --preset faster, fast, medium, slow, slower" << std::endl; return -1; } } @@ -333,7 +412,14 @@ class CmdLineParser if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) fprintf( stdout, "[bitrate] : %d bits per second\n", rcParams.m_iTargetBitRate ); } - else if( !strcmp( (const char*)argv[i_arg], "--qp" ) ) + else if( (!strcmp( (const char*)argv[i_arg], "-p" )) || !strcmp( (const char*)argv[i_arg], "--passes" ) ) + { + i_arg++; + rcParams.m_iNumPasses = atoi( argv[i_arg++] ); + if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) + fprintf( stdout, "[passes] : %d\n", rcParams.m_iNumPasses ); + } + else if( (!strcmp( (const char*)argv[i_arg], "-q" )) || !strcmp( (const char*)argv[i_arg], "--qp" ) ) { i_arg++; rcParams.m_iQp = atoi( argv[i_arg++] ); @@ -353,12 +439,13 @@ class CmdLineParser rcParams.m_iGopSize = atoi( argv[i_arg++] ); if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) fprintf( stdout, "[gopsize] : %d\n", rcParams.m_iGopSize ); - - if( rcParams.m_iGopSize != 16 ) - { - std::cerr << "unsupported gopsize " << rcParams.m_iGopSize << ". use: --gopsize 16" << std::endl; - return -1; - } + } + else if( (!strcmp( (const char*)argv[i_arg], "-rs" )) || !strcmp( (const char*)argv[i_arg], "--refreshsec" ) ) + { + i_arg++; + rcParams.m_iIDRPeriodSec = atoi( argv[i_arg++] ); + if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) + fprintf( stdout, "[refreshsec] : %d\n", rcParams.m_iIDRPeriodSec ); } else if( (!strcmp( (const char*)argv[i_arg], "-ip" )) || !strcmp( (const char*)argv[i_arg], "--intraperiod" ) ) { @@ -392,6 +479,13 @@ class CmdLineParser } } } + else if( !strcmp( (const char*)argv[i_arg], "--internal-bitdepth" ) ) + { + i_arg++; + rcParams.m_iInternalBitDepth = atoi( argv[i_arg++] ); + if( rcParams.m_eLogLevel > vvenc::LL_VERBOSE ) + fprintf( stdout, "[internal-bitdepth] : %d\n", rcParams.m_iInternalBitDepth ); + } else if( !strcmp( (const char*)argv[i_arg], "--profile") ) { i_arg++; @@ -479,6 +573,10 @@ class CmdLineParser { rcParams.m_eLevel = vvenc::VVC_LEVEL_6_2; } + else if( "6.3" == cLevel ) + { + rcParams.m_eLevel = vvenc::VVC_LEVEL_6_3; + } else if( "15.5" == cLevel ) { rcParams.m_eLevel = vvenc::VVC_LEVEL_15_5; diff --git a/source/App/vvencapp/YuvFileReader.h b/source/App/vvencapp/YuvFileReader.h index 52042063e..fce509f7b 100644 --- a/source/App/vvencapp/YuvFileReader.h +++ b/source/App/vvencapp/YuvFileReader.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup VVCUtilitiesExternalInterfaces \file YuvFileReader.h @@ -108,18 +112,21 @@ class YuvFileReader { m_iReadWidth = m_iWidth*10/16; m_iPicSize = 2*m_iReadWidth * iHeight * 3 / 2; - int iRet = allocBuffer( m_cReadBuffer, true ); + int iRet = allocBuffer( m_cReadBuffer ); m_cReadBuffer.m_iWidth = m_iReadWidth; m_cReadBuffer.m_iStride = m_iReadWidth; if( iRet ) { return iRet; } } // delete buffer if any - delete [] m_psBuffer; - m_psBuffer = NULL; + if( m_psBuffer ) + { + delete [] m_psBuffer; + m_psBuffer = nullptr; + } // allocate some conversion memory in case we need some - if( iFileBitDepth != iDestBitDepth ) + if( ! ( iFileBitDepth == iDestBitDepth && iDestBitDepth > 8 ) ) { m_psBuffer = new short[iWidth + 16]; } @@ -145,11 +152,11 @@ class YuvFileReader } template< class PicBufferLocal > - int allocBuffer( PicBufferLocal& rcPicBuffer, bool bFrameBuffer ) + int allocBuffer( PicBufferLocal& rcPicBuffer ) { if( !m_bInitialized ){ assert( m_bInitialized ); return -1; } - const int iSizeFactor = (m_iDestBitDepth>8) ? 2 : 1; + const int iSizeFactor = 2; const int iAlignmentGuard =16; rcPicBuffer.m_iBitDepth = m_iDestBitDepth; rcPicBuffer.m_iWidth = m_iWidth; @@ -233,7 +240,7 @@ class YuvFileReader const int iCHeight = m_iHeight>>1; const int iCStride = rcPicBuffer.m_iStride>>1; assert( rcPicBuffer.m_iBitDepth == m_iDestBitDepth ); - + rcPicBuffer.m_iWidth = m_iWidth; rcPicBuffer.m_iHeight = m_iHeight; @@ -250,21 +257,38 @@ class YuvFileReader { if( m_iFileBitDepth == m_iDestBitDepth ) { - const int iFactor = 1 + !!(m_iFileBitDepth > 8); - if( iStride == iWidth ) + if( m_iFileBitDepth > 8 ) { - const int iReadSize = iWidth * iHeight * iFactor; - m_cIS.read( (char*)pvBuffer, iReadSize); + const int iFactor = 2; + if( iStride == iWidth ) + { + const int iReadSize = iWidth * iHeight * iFactor; + m_cIS.read( (char*)pvBuffer, iReadSize); + } + else + { + char* pc = (char*)pvBuffer; + const int iReadSize = iFactor * iWidth; + const int iLineOffset = iStride * iFactor; + for( int y = 0; y < iHeight; y++) + { + m_cIS.read( pc, iReadSize ); + pc += iLineOffset; + } + } } else { - char* pc = (char*)pvBuffer; - const int iReadSize = iFactor * iWidth; - const int iLineOffset = iStride * iFactor; + short* ps = (short*)pvBuffer; + unsigned char* pucTemp = (unsigned char*) m_psBuffer; for( int y = 0; y < iHeight; y++) { - m_cIS.read( pc, iReadSize ); - pc += iLineOffset; + m_cIS.read( (char*)pucTemp, iWidth ); + for( int x = 0; x < iWidth; x++) + { + ps[x] = pucTemp[x]; + } + ps += iStride; } } } @@ -287,16 +311,16 @@ class YuvFileReader { const int iShift = m_iFileBitDepth - 8; const short sAdd = 1<<(iShift-1); - unsigned char* puc = (unsigned char*)pvBuffer; + short* ps = (short*)pvBuffer; short* psTemp = m_psBuffer; for( int y = 0; y < iHeight; y++) { m_cIS.read( (char*)psTemp, 2*iWidth ); for( int x = 0; x < iWidth; x++) { - puc[x] = (psTemp[x] + sAdd) >> iShift; + ps[x] = (psTemp[x] + sAdd) >> iShift; } - puc += iStride; + ps += iStride; } } else if( m_iDestBitDepth > m_iFileBitDepth ) diff --git a/source/App/vvencapp/resource.h b/source/App/vvencapp/resource.h index b4c93c719..24b8b9542 100644 --- a/source/App/vvencapp/resource.h +++ b/source/App/vvencapp/resource.h @@ -1,60 +1,65 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -4. DISCLAIMER +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. -5. CONTACT INFORMATION +------------------------------------------------------------------------------------------- */ -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ /** - \ingroup VVEncoderApp - \file /VVEncoderApp/resource.h + \ingroup vvencapp + \file /vvencapp/resource.h */ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by VVEncoderApp.rc +// Used by vvencapp.rc // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif +# ifndef APSTUDIO_READONLY_SYMBOLS +# define _APS_NEXT_RESOURCE_VALUE 101 +# define _APS_NEXT_COMMAND_VALUE 40001 +# define _APS_NEXT_CONTROL_VALUE 1001 +# define _APS_NEXT_SYMED_VALUE 101 +# endif #endif diff --git a/source/App/vvencapp/resource_version.h b/source/App/vvencapp/resource_version.h index 4d01955da..777af304e 100644 --- a/source/App/vvencapp/resource_version.h +++ b/source/App/vvencapp/resource_version.h @@ -1,51 +1,56 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -4. DISCLAIMER +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. -5. CONTACT INFORMATION +------------------------------------------------------------------------------------------- */ -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ #if !defined( resource_version_h ) -#define resource_version_h +# define resource_version_h // pick up top level version information. -#include "vvenc/version.h" +# include "vvenc/version.h" -#define VS_FILE_VERSION VVENC_VS_VERSION -#define VS_FILE_VERSION_STR VVENC_VS_VERSION_STR +# define VS_FILE_VERSION VVENC_VS_VERSION +# define VS_FILE_VERSION_STR VVENC_VS_VERSION_STR #endif diff --git a/source/App/vvencapp/vvencapp.cpp b/source/App/vvencapp/vvencapp.cpp index c149aa03d..a407e9485 100644 --- a/source/App/vvencapp/vvencapp.cpp +++ b/source/App/vvencapp/vvencapp.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \ingroup VVEncoderApp @@ -65,9 +69,34 @@ vvc@hhi.fraunhofer.de #include "CmdLineParser.h" #include "YuvFileReader.h" -int main( int argc, char* argv[] ) +int g_verbosity = vvenc::LL_VERBOSE; + +void msgFnc( int level, const char* fmt, va_list args ) { + if ( g_verbosity >= level ) + { + vfprintf( level == 1 ? stderr : stdout, fmt, args ); + } +} +void printVVEncErrorMsg( const std::string cAppname, const std::string cMessage, int code, const std::string cErr ) +{ + std::cout << cAppname << " [error]: " << cMessage << ", "; + switch( code ) + { + case vvenc::VVENC_ERR_CPU : std::cout << "SSE 4.1 cpu support required."; break; + case vvenc::VVENC_ERR_PARAMETER : std::cout << "invalid parameter."; break; + default : std::cout << "error " << code; break; + }; + if( !cErr.empty() ) + { + std::cout << " - " << cErr; + } + std::cout << std::endl; +} + +int main( int argc, char* argv[] ) +{ std::string cAppname = argv[0]; std::size_t iPos = (int)cAppname.find_last_of("/"); if( std::string::npos != iPos ) @@ -80,32 +109,34 @@ int main( int argc, char* argv[] ) vvenc::VVEncParameter cVVEncParameter; // set desired encoding options - cVVEncParameter.m_iQp = 32; // quantization parameter 0-51 - cVVEncParameter.m_iWidth = 1920; // luminance width of input picture - cVVEncParameter.m_iHeight = 1080; // luminance height of input picture - cVVEncParameter.m_iGopSize = 16; // gop size (1: intra only, 16: hierarchical b frames) - cVVEncParameter.m_eDecodingRefreshType = vvenc::VVC_DRT_CRA; // intra period refresh type - cVVEncParameter.m_iIDRPeriod = 32; // intra period for IDR/CDR intra refresh/RAP flag (should be a factor of m_iGopSize) - cVVEncParameter.m_eLogLevel = vvenc::LL_VERBOSE; // log level > 4 (VERBOSE) enables psnr/rate output - cVVEncParameter.m_iTemporalRate = 60; // temporal rate (fps) - cVVEncParameter.m_iTemporalScale = 1; // temporal scale (fps) - cVVEncParameter.m_iTicksPerSecond = 90000; // ticks per second e.g. 90000 for dts generation - cVVEncParameter.m_iThreadCount = 4; // number of worker threads (should not exceed the number of physical cpu's) - cVVEncParameter.m_iQuality = 2; // encoding quality (vs speed) 0: faster, 1: fast, 2: medium, 3: slow - cVVEncParameter.m_iPerceptualQPA = 2; // percepual qpa adaption, 0 off, 1 on for sdr(wpsnr), 2 on for sdr(xpsnr), 3 on for hdr(wpsrn), 4 on for hdr(xpsnr), on for hdr(MeanLuma) - cVVEncParameter.m_eProfile = vvenc::VVC_PROFILE_MAIN_10; // profile: use main_10 or main_10_still_picture - cVVEncParameter.m_eLevel = vvenc::VVC_LEVEL_4_1; // level - cVVEncParameter.m_eTier = vvenc::VVC_TIER_MAIN; // tier + cVVEncParameter.m_iQp = 32; // quantization parameter 0-51 + cVVEncParameter.m_iWidth = 1920; // luminance width of input picture + cVVEncParameter.m_iHeight = 1080; // luminance height of input picture + cVVEncParameter.m_iGopSize = 32; // gop size (1: intra only, 16, 32: hierarchical b frames) + cVVEncParameter.m_eDecodingRefreshType = vvenc::VVC_DRT_CRA; // intra period refresh type + cVVEncParameter.m_iIDRPeriodSec = 1; // intra period in seconds for IDR/CDR intra refresh/RAP flag (should be > 0) + cVVEncParameter.m_iIDRPeriod = 0; // intra period in frames for IDR/CDR intra refresh/RAP flag (should be a factor of m_iGopSize) + cVVEncParameter.m_eLogLevel = vvenc::LL_VERBOSE; // log level > 4 (VERBOSE) enables psnr/rate output + cVVEncParameter.m_iTemporalRate = 60; // temporal rate (fps) + cVVEncParameter.m_iTemporalScale = 1; // temporal scale (fps) + cVVEncParameter.m_iTicksPerSecond = 90000; // ticks per second e.g. 90000 for dts generation + cVVEncParameter.m_iMaxFrames = 0; // max number of frames to be encoded + cVVEncParameter.m_iFrameSkip = 0; // number of frames to skip before start encoding + cVVEncParameter.m_iThreadCount = -1; // number of worker threads (should not exceed the number of physical cpu's) + cVVEncParameter.m_iQuality = 2; // encoding quality (vs speed) 0: faster, 1: fast, 2: medium, 3: slow, 4: slower + cVVEncParameter.m_iPerceptualQPA = 2; // percepual qpa adaptation, 0 off, 1 on for sdr(wpsnr), 2 on for sdr(xpsnr), 3 on for hdr(wpsrn), 4 on for hdr(xpsnr), on for hdr(MeanLuma) + cVVEncParameter.m_iInputBitDepth = 8; // input bitdepth + cVVEncParameter.m_iInternalBitDepth = 10; // internal bitdepth + cVVEncParameter.m_eProfile = vvenc::VVC_PROFILE_MAIN_10; // profile: use main_10 or main_10_still_picture + cVVEncParameter.m_eLevel = vvenc::VVC_LEVEL_4_1; // level + cVVEncParameter.m_eTier = vvenc::VVC_TIER_MAIN; // tier + cVVEncParameter.m_eSegMode = vvenc::VVC_SEG_OFF; // segment mode std::string cPreset = "medium"; std::string cProfile = "main10"; std::string cLevel = "4.1"; std::string cTier = "main"; - - int iMaxFrames = 0; - int iInputBitdepth = 8; - if( argc > 1 && (!strcmp( (const char*) argv[1], "--help" ) || !strcmp( (const char*) argv[1], "-h" )) ) { std::cout << cAppname << " version: " << VVENC_VERSION << std::endl; @@ -119,10 +150,12 @@ int main( int argc, char* argv[] ) return 0; } - bool bThreadCountSet = false; - int iRet = vvcutilities::CmdLineParser::parse_command_line( argc, argv, cVVEncParameter, cInputFile, cOutputfile, iMaxFrames, iInputBitdepth, bThreadCountSet ); + int iRet = vvcutilities::CmdLineParser::parse_command_line( argc, argv, cVVEncParameter, cInputFile, cOutputfile ); - if( iRet != 0 ) + vvenc::VVEnc::registerMsgCbf( msgFnc ); + g_verbosity = cVVEncParameter.m_eLogLevel; + + if( iRet != 0 ) { if( iRet == 2 || iRet == 3 ) { @@ -154,9 +187,16 @@ int main( int argc, char* argv[] ) std::cout << cAppname << " version " << vvenc::VVEnc::getVersionNumber() << std::endl; } - if( !bThreadCountSet && ( cVVEncParameter.m_iWidth > 1920 || cVVEncParameter.m_iHeight > 1080) ) + if( cVVEncParameter.m_iThreadCount < 0 ) { - cVVEncParameter.m_iThreadCount = 6; + if( cVVEncParameter.m_iWidth > 1920 || cVVEncParameter.m_iHeight > 1080) + { + cVVEncParameter.m_iThreadCount = 6; + } + else + { + cVVEncParameter.m_iThreadCount = 4; + } } vvenc::VVEnc cVVEnc; @@ -165,21 +205,8 @@ int main( int argc, char* argv[] ) iRet = cVVEnc.init( cVVEncParameter ); if( 0 != iRet ) { - std::cout << cAppname << " [error]: cannot init encoder, "; - switch( iRet ) - { - case vvenc::VVENC_ERR_CPU : std::cout << "SSE 4.1 cpu support required."; break; - case vvenc::VVENC_ERR_PARAMETER : std::cout << "invalid parameter."; break; - default : std::cout << "error " << iRet; break; - }; - std::string cErr = cVVEnc.getLastError(); - if ( !cErr.empty() ) - { - std::cout << " - " << cErr; - } - - std::cout << std::endl; - return -1; + printVVEncErrorMsg( cAppname, "cannot create encoder", iRet, cVVEnc.getLastError() ); + return iRet; } if( cVVEncParameter.m_eLogLevel > vvenc::LL_WARNING ) @@ -187,14 +214,6 @@ int main( int argc, char* argv[] ) std::cout << "VVEnc info: " << cVVEnc.getEncoderInfo() << std::endl; } - // open the input file - vvcutilities::YuvFileReader cYuvFileReader; - if( 0 != cYuvFileReader.open( cInputFile.c_str(), iInputBitdepth, 10, cVVEncParameter.m_iWidth, cVVEncParameter.m_iHeight ) ) - { - std::cout << cAppname << " [error]: failed to open input file " << cInputFile << std::endl; - return -1; - } - // open output file vvcutilities::BinFileWriter cBinFileWriter; if( !cOutputfile.empty() ) @@ -206,7 +225,6 @@ int main( int argc, char* argv[] ) } } - // --- allocate memory for output packets vvenc::VvcAccessUnit cAccessUnit; cAccessUnit.m_iBufSize = cVVEncParameter.m_iWidth * cVVEncParameter.m_iHeight; @@ -214,19 +232,17 @@ int main( int argc, char* argv[] ) vvenc::InputPicture cInputPicture; iRet = cVVEnc.getPreferredBuffer( cInputPicture.m_cPicBuffer ); - if( iRet ) + if( 0 != iRet ) { - std::cout << cAppname << " [error]: Encoder failed to get preferredBuffer " << std::endl; + printVVEncErrorMsg( cAppname, "failed to get preferred buffer", iRet, cVVEnc.getLastError() ); return iRet; } const unsigned char* pucDeletePicBuffer = cInputPicture.m_cPicBuffer.m_pucDeletePicBuffer; cInputPicture.m_cPicBuffer.m_pucDeletePicBuffer = NULL; + // --- start timer std::chrono::steady_clock::time_point cTPStart; std::chrono::steady_clock::time_point cTPEnd; - unsigned int uiFrames = 0; - unsigned int uiFramesTmp = 0; - cVVEnc.clockStartTime(); cTPStart = std::chrono::steady_clock::now(); std::time_t startTime2 = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); @@ -235,117 +251,130 @@ int main( int argc, char* argv[] ) std::cout << "started @ " << std::ctime(&startTime2) << std::endl; } - bool bEof = false; - int64_t iSeqNumber = 0; - while( !bEof ) + unsigned int uiFrames = 0; + + for( int pass = 0; pass < cVVEncParameter.m_iNumPasses; pass++ ) { - iRet = cYuvFileReader.readPicture( cInputPicture.m_cPicBuffer ); - if( iRet ) + // initialize the encoder pass + iRet = cVVEnc.initPass( pass ); + if( 0 != iRet ) { - if( cVVEncParameter.m_eLogLevel > vvenc::LL_ERROR && cVVEncParameter.m_eLogLevel < vvenc::LL_NOTICE ) - { - std::cout << "EOF reached" << std::endl; - } - bEof = true; + printVVEncErrorMsg( cAppname, "cannot init encoder", iRet, cVVEnc.getLastError() ); + return iRet; } - if( !bEof ) + // open the input file + vvcutilities::YuvFileReader cYuvFileReader; + if( 0 != cYuvFileReader.open( cInputFile.c_str(), cVVEncParameter.m_iInputBitDepth, cVVEncParameter.m_iInternalBitDepth, cVVEncParameter.m_iWidth, cVVEncParameter.m_iHeight ) ) { - // set sequence number and cts - cInputPicture.m_cPicBuffer.m_uiSequenceNumber = iSeqNumber; - cInputPicture.m_cPicBuffer.m_uiCts = iSeqNumber * cVVEncParameter.m_iTicksPerSecond * cVVEncParameter.m_iTemporalScale / cVVEncParameter.m_iTemporalRate; - cInputPicture.m_cPicBuffer.m_bCtsValid = true; + std::cout << cAppname << " [error]: failed to open input file " << cInputFile << std::endl; + return -1; + } - //std::cout << "process picture " << cInputPicture.m_cPicBuffer.m_uiSequenceNumber << " cts " << cInputPicture.m_cPicBuffer.m_uiCts << std::endl; - // call encode - iRet = cVVEnc.encode( &cInputPicture, cAccessUnit ); + const int64_t iFrameSkip = std::max( cVVEncParameter.m_iFrameSkip - cVVEnc.getNumLeadFrames(), 0 ); + const int64_t iMaxFrames = cVVEncParameter.m_iMaxFrames + cVVEnc.getNumLeadFrames() + cVVEnc.getNumTrailFrames(); + int64_t iSeqNumber = 0; + bool bEof = false; + unsigned int uiFramesTmp = 0; + uiFrames = 0; - // check success - if( iRet != 0 ) + while( !bEof ) + { + iRet = cYuvFileReader.readPicture( cInputPicture.m_cPicBuffer ); + if( iRet ) { - std::string cErr = cVVEnc.getLastError(); - std::cout << cAppname << " [error]: encoding failed (" << iRet << "): " << cErr << std::endl; - break; + if( cVVEncParameter.m_eLogLevel > vvenc::LL_ERROR && cVVEncParameter.m_eLogLevel < vvenc::LL_NOTICE ) + { + std::cout << "EOF reached" << std::endl; + } + bEof = true; } - if( 0 != cAccessUnit.m_iUsedSize ) + if( !bEof && iSeqNumber >= iFrameSkip ) { - if( cBinFileWriter.isOpen()) + // set sequence number and cts + cInputPicture.m_cPicBuffer.m_uiSequenceNumber = iSeqNumber; + cInputPicture.m_cPicBuffer.m_uiCts = iSeqNumber * cVVEncParameter.m_iTicksPerSecond * cVVEncParameter.m_iTemporalScale / cVVEncParameter.m_iTemporalRate; + cInputPicture.m_cPicBuffer.m_bCtsValid = true; + + //std::cout << "process picture " << cInputPicture.m_cPicBuffer.m_uiSequenceNumber << " cts " << cInputPicture.m_cPicBuffer.m_uiCts << std::endl; + // call encode + iRet = cVVEnc.encode( &cInputPicture, cAccessUnit ); + if( 0 != iRet ) { - // write output - cBinFileWriter.writeAU( cAccessUnit ); + printVVEncErrorMsg( cAppname, "encoding failed", iRet, cVVEnc.getLastError() ); + return iRet; } - if( ! cAccessUnit.m_cInfo.empty() ) // print debug info + if( 0 != cAccessUnit.m_iUsedSize ) { - printf( "\n %s ", cAccessUnit.m_cInfo.c_str() ); - } - uiFrames++; - uiFramesTmp++; + if( cBinFileWriter.isOpen()) + { + // write output + cBinFileWriter.writeAU( cAccessUnit ); + } - if( uiFrames && cVVEncParameter.m_eLogLevel > vvenc::LL_WARNING && cVVEncParameter.m_eLogLevel < vvenc::LL_NOTICE) - { - cTPEnd = std::chrono::steady_clock::now(); - double dTimeMs = (double)std::chrono::duration_cast((cTPEnd)-(cTPStart)).count(); - if( dTimeMs > 1000.0 ) + uiFrames++; + uiFramesTmp++; + + if( uiFrames && cVVEncParameter.m_eLogLevel > vvenc::LL_WARNING && cVVEncParameter.m_eLogLevel < vvenc::LL_NOTICE) { - if( cVVEncParameter.m_eLogLevel > vvenc::LL_INFO ){ std::cout << std::endl;} - std::cout << "encoded Frames: " << uiFrames << " Fps: " << uiFramesTmp << std::endl; - cTPStart = std::chrono::steady_clock::now(); - uiFramesTmp = 0; + cTPEnd = std::chrono::steady_clock::now(); + double dTimeMs = (double)std::chrono::duration_cast((cTPEnd)-(cTPStart)).count(); + if( dTimeMs > 1000.0 ) + { + if( cVVEncParameter.m_eLogLevel > vvenc::LL_INFO ){ std::cout << std::endl;} + std::cout << "encoded Frames: " << uiFrames << " Fps: " << uiFramesTmp << std::endl; + cTPStart = std::chrono::steady_clock::now(); + uiFramesTmp = 0; + } } } } - } - iSeqNumber++; + iSeqNumber++; - if( iMaxFrames > 0 && iSeqNumber >= iMaxFrames ){ break; } - }; - - // flush the encoder - bool bFlushEncder = true; - while( bFlushEncder) - { - iRet = cVVEnc.flush( cAccessUnit ); - if( iRet != 0 ) - { - std::string cErr = cVVEnc.getLastError(); - std::cout << cAppname << " [error]: encoding failed (" << iRet << "): " << cErr << std::endl; - break; + if( iMaxFrames > 0 && iSeqNumber >= ( iFrameSkip + iMaxFrames ) ){ break; } } - if( 0 == cAccessUnit.m_iUsedSize ) + // flush the encoder + while( true ) { - bFlushEncder = false; - break; - } + iRet = cVVEnc.flush( cAccessUnit ); + if( 0 != iRet ) + { + printVVEncErrorMsg( cAppname, "flush encoder failed", iRet, cVVEnc.getLastError() ); + return iRet; + } - if( ! cAccessUnit.m_cInfo.empty() ) // print debug info - { - printf( "\n %s ", cAccessUnit.m_cInfo.c_str() ); - } + if( 0 == cAccessUnit.m_iUsedSize ) + { + break; + } - uiFrames++; + uiFrames++; - if( uiFrames && cVVEncParameter.m_eLogLevel > vvenc::LL_WARNING && cVVEncParameter.m_eLogLevel < vvenc::LL_NOTICE ) - { - cTPEnd = std::chrono::steady_clock::now(); - double dTimeMs = (double)std::chrono::duration_cast((cTPEnd)-(cTPStart)).count(); - if( dTimeMs > 1000.0 ) + if( uiFrames && cVVEncParameter.m_eLogLevel > vvenc::LL_WARNING && cVVEncParameter.m_eLogLevel < vvenc::LL_NOTICE ) { - if( cVVEncParameter.m_eLogLevel > vvenc::LL_INFO ){ std::cout << std::endl;} - std::cout << "encoded Frames: " << uiFrames << " Fps: " << uiFramesTmp << std::endl; - cTPStart = std::chrono::steady_clock::now(); - uiFramesTmp = 0; + cTPEnd = std::chrono::steady_clock::now(); + double dTimeMs = (double)std::chrono::duration_cast((cTPEnd)-(cTPStart)).count(); + if( dTimeMs > 1000.0 ) + { + if( cVVEncParameter.m_eLogLevel > vvenc::LL_INFO ){ std::cout << std::endl;} + std::cout << "encoded Frames: " << uiFrames << " Fps: " << uiFramesTmp << std::endl; + cTPStart = std::chrono::steady_clock::now(); + uiFramesTmp = 0; + } } - } - if( cBinFileWriter.isOpen()) - { - // write output - cBinFileWriter.writeAU( cAccessUnit ); + if( cBinFileWriter.isOpen() ) + { + // write output + cBinFileWriter.writeAU( cAccessUnit ); + } } - }; + + cYuvFileReader.close(); + } cVVEnc.clockEndTime(); double dTimeSec = cVVEnc.clockGetTimeDiffMs() / 1000; @@ -353,7 +382,6 @@ int main( int argc, char* argv[] ) delete[] cAccessUnit.m_pucBuffer; delete[] pucDeletePicBuffer; - cYuvFileReader.close(); if( cBinFileWriter.isOpen()) { cBinFileWriter.close(); @@ -361,7 +389,11 @@ int main( int argc, char* argv[] ) // un-initialize the encoder iRet = cVVEnc.uninit(); - if( 0 != iRet ) { std::cout << cAppname << " [error]: cannot uninit encoder (" << iRet << ")" << std::endl; return iRet; } + if( 0 != iRet ) + { + printVVEncErrorMsg( cAppname, "destroyencoder failed", iRet, cVVEnc.getLastError() ); + return iRet; + } if( 0 == uiFrames ) { @@ -380,6 +412,6 @@ int main( int argc, char* argv[] ) std::cout << "Total Time: " << dTimeSec << " sec. Fps(avg): " << dFps << " encoded Frames " << uiFrames << std::endl; } - return 0; } + diff --git a/source/App/vvencapp/vvencapp.rc b/source/App/vvencapp/vvencapp.rc index 00259d0bb..d2f91ca10 100644 --- a/source/App/vvencapp/vvencapp.rc +++ b/source/App/vvencapp/vvencapp.rc @@ -1,5 +1,53 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + // Microsoft Visual C++ generated resource script. // +#pragma code_page(65001) + #include "resource.h" #include "resource_version.h" @@ -14,38 +62,10 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END +// Neutral (Default) (unknown sub-lang: 0x8) resources -#endif // APSTUDIO_INVOKED +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ZZZ) +LANGUAGE LANG_NEUTRAL, 0x8 ///////////////////////////////////////////////////////////////////////////// // @@ -62,29 +82,64 @@ VS_VERSION_INFO VERSIONINFO FILEFLAGS 0x0L #endif FILEOS 0x40004L - FILETYPE 0x2L + FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "040904b0" + BLOCK "200004b0" BEGIN VALUE "CompanyName", "Fraunhofer Heinrich Hertz Institute" - VALUE "FileDescription", "VVEncoderApp Application" + VALUE "FileDescription", "vvencapp Application" VALUE "FileVersion", VS_FILE_VERSION_STR - VALUE "InternalName", "VVEncoderApp.exe" - VALUE "LegalCopyright", "Copyright (C) 2019 Fraunhofer Heinrich Hertz Institute" - VALUE "OriginalFilename", "VVEncoderApp.exe" - VALUE "ProductName", "VVEncoderApp" + VALUE "InternalName", "vvencapp.exe" + VALUE "LegalCopyright", "(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V" + VALUE "OriginalFilename", "vvencapp.exe" + VALUE "ProductName", "vvencapp" VALUE "ProductVersion", VS_FILE_VERSION_STR END END BLOCK "VarFileInfo" BEGIN - VALUE "Translation", 0x409, 1200 + VALUE "Translation", 0x2000, 1200 END END +#endif // Neutral (Default) (unknown sub-lang: 0x8) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp index 453698ea2..f65fe727f 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file AdaptiveLoopFilter.cpp @@ -133,7 +137,7 @@ bool AdaptiveLoopFilter::isCrossedByVirtualBoundaries( const CodingStructure& cs int ctuSize = slice.sps->CTUSize; const Position currCtuPos(xPos, yPos); const CodingUnit *currCtu = cs.getCU(currCtuPos, CH_L, TREE_D); - SubPic curSubPic = slice.pps->getSubPicFromPos(currCtuPos); + const SubPic& curSubPic = slice.pps->getSubPicFromPos(currCtuPos); bool loopFilterAcrossSubPicEnabled = curSubPic.loopFilterAcrossSubPicEnabled; //top if (yPos >= ctuSize && clipTop == false) diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.h b/source/Lib/CommonLib/AdaptiveLoopFilter.h index a9f190ff8..972fcce94 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.h +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file AdaptiveLoopFilter.h \brief adaptive loop filter class (header) */ diff --git a/source/Lib/CommonLib/AffineGradientSearch.cpp b/source/Lib/CommonLib/AffineGradientSearch.cpp index 396a3efa8..11b034e37 100644 --- a/source/Lib/CommonLib/AffineGradientSearch.cpp +++ b/source/Lib/CommonLib/AffineGradientSearch.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** diff --git a/source/Lib/CommonLib/AffineGradientSearch.h b/source/Lib/CommonLib/AffineGradientSearch.h index 998ee8a80..cdf52f79e 100644 --- a/source/Lib/CommonLib/AffineGradientSearch.h +++ b/source/Lib/CommonLib/AffineGradientSearch.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** * \file * \brief Declaration of AffineGradientSearch class diff --git a/source/Lib/CommonLib/AlfParameters.h b/source/Lib/CommonLib/AlfParameters.h index 3d0992802..f2270a61a 100644 --- a/source/Lib/CommonLib/AlfParameters.h +++ b/source/Lib/CommonLib/AlfParameters.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file AlfParameters.h \brief Define types for storing ALF parameters */ diff --git a/source/Lib/CommonLib/BitStream.cpp b/source/Lib/CommonLib/BitStream.cpp index 88549c7dc..77ca898a1 100644 --- a/source/Lib/CommonLib/BitStream.cpp +++ b/source/Lib/CommonLib/BitStream.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file BitStream.cpp diff --git a/source/Lib/CommonLib/BitStream.h b/source/Lib/CommonLib/BitStream.h index 04af5a079..8ba7b9968 100644 --- a/source/Lib/CommonLib/BitStream.h +++ b/source/Lib/CommonLib/BitStream.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file BitStream.h \brief class for handling bitstream (header) */ diff --git a/source/Lib/CommonLib/Buffer.cpp b/source/Lib/CommonLib/Buffer.cpp index 62aa6b5ac..2fc326767 100644 --- a/source/Lib/CommonLib/Buffer.cpp +++ b/source/Lib/CommonLib/Buffer.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Buffer.cpp @@ -51,7 +55,7 @@ vvc@hhi.fraunhofer.de #include "Unit.h" #include "Slice.h" #include "InterpolationFilter.h" -#include "../../../include/vvenc/Basics.h" +#include "vvenc/Basics.h" //! \ingroup CommonLib //! \{ @@ -87,13 +91,13 @@ void mipMatrixMulCore( Pel* res, const Pel* input, const uint8_t* weight, const Pel buffer[ outputSize*outputSize]; int sum = 0; - for( int i = 0; i < inputSize; i++ ) - { - sum += input[i]; + for( int i = 0; i < inputSize; i++ ) + { + sum += input[i]; } const int offset = (1 << (MIP_SHIFT_MATRIX - 1)) - MIP_OFFSET_MATRIX * sum + (inputOffset << MIP_SHIFT_MATRIX); CHECK( inputSize != 4 * (inputSize >> 2), "Error, input size not divisible by four" ); - + Pel* mat = transpose ? buffer : res; unsigned posRes = 0; for( unsigned n = 0; n < outputSize*outputSize; n++ ) @@ -126,76 +130,6 @@ void mipMatrixMulCore( Pel* res, const Pel* input, const uint8_t* weight, const } } -template -void gradFilterCore(const Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth) -{ - const Pel* srcTmp = pSrc + srcStride + 1; - Pel* gradXTmp = gradX + gradStride + 1; - Pel* gradYTmp = gradY + gradStride + 1; - int shift1 = std::max(6, (bitDepth - 6)); - - for (int y = 0; y < (height - 2 * BDOF_EXTEND_SIZE); y++) - { - for (int x = 0; x < (width - 2 * BDOF_EXTEND_SIZE); x++) - { - gradYTmp[x] = (srcTmp[x + srcStride] >> shift1) - (srcTmp[x - srcStride] >> shift1); - gradXTmp[x] = (srcTmp[x + 1] >> shift1) - (srcTmp[x - 1] >> shift1); - } - gradXTmp += gradStride; - gradYTmp += gradStride; - srcTmp += srcStride; - } - - if (PAD) - { - gradXTmp = gradX + gradStride + 1; - gradYTmp = gradY + gradStride + 1; - for (int y = 0; y < (height - 2 * BDOF_EXTEND_SIZE); y++) - { - gradXTmp[-1] = gradXTmp[0]; - gradXTmp[width - 2 * BDOF_EXTEND_SIZE] = gradXTmp[width - 2 * BDOF_EXTEND_SIZE - 1]; - gradXTmp += gradStride; - - gradYTmp[-1] = gradYTmp[0]; - gradYTmp[width - 2 * BDOF_EXTEND_SIZE] = gradYTmp[width - 2 * BDOF_EXTEND_SIZE - 1]; - gradYTmp += gradStride; - } - - gradXTmp = gradX + gradStride; - gradYTmp = gradY + gradStride; - ::memcpy(gradXTmp - gradStride, gradXTmp, sizeof(Pel)*(width)); - ::memcpy(gradXTmp + (height - 2 * BDOF_EXTEND_SIZE)*gradStride, gradXTmp + (height - 2 * BDOF_EXTEND_SIZE - 1)*gradStride, sizeof(Pel)*(width)); - ::memcpy(gradYTmp - gradStride, gradYTmp, sizeof(Pel)*(width)); - ::memcpy(gradYTmp + (height - 2 * BDOF_EXTEND_SIZE)*gradStride, gradYTmp + (height - 2 * BDOF_EXTEND_SIZE - 1)*gradStride, sizeof(Pel)*(width)); - } -} - - -void applyPROFCore(Pel* dst, int dstStride, const Pel* src, int srcStride, int width, int height, const Pel* gradX, const Pel* gradY, int gradStride, const int* dMvX, const int* dMvY, int dMvStride, const bool& bi, int shiftNum, Pel offset, const ClpRng& clpRng) -{ - int idx = 0; - const int dILimit = 1 << std::max(clpRng.bd + 1, 13); - for (int h = 0; h < height; h++) - { - for (int w = 0; w < width; w++) - { - int32_t dI = dMvX[idx] * gradX[w] + dMvY[idx] * gradY[w]; - dI = Clip3(-dILimit, dILimit - 1, dI); - dst[w] = src[w] + dI; - if (!bi) - { - dst[w] = (dst[w] + offset) >> shiftNum; - dst[w] = ClipPel(dst[w], clpRng); - } - idx++; - } - gradX += gradStride; - gradY += gradStride; - dst += dstStride; - src += srcStride; - } -} - template< typename T > void addAvgCore( const T* src1, int src1Stride, const T* src2, int src2Stride, T* dest, int dstStride, int width, int height, unsigned rshift, int offset, const ClpRng& clpRng ) { @@ -244,7 +178,7 @@ void reconstructCore( const T* src1, int src1Stride, const T* src2, int src2Stri template void recoCore( const T* src1, const T* src2, T* dest, int numSamples, const ClpRng& clpRng ) { - for( int n = 0; n < numSamples; n+=2) + for( int n = 0; n < numSamples; n+=2) { dest[n] = ClipPel( src1[n] + src2[n], clpRng ); dest[n+1] = ClipPel( src1[n+1] + src2[n+1], clpRng ); @@ -254,7 +188,7 @@ void recoCore( const T* src1, const T* src2, T* dest, int numSamples, const ClpR template void copyClipCore( const T* src, Pel* dst, int numSamples, const ClpRng& clpRng ) { - for( int n = 0; n < numSamples; n+=2) + for( int n = 0; n < numSamples; n+=2) { dst[n] = ClipPel( src[n] , clpRng ); dst[n+1] = ClipPel( src[n+1] , clpRng ); @@ -264,7 +198,7 @@ void copyClipCore( const T* src, Pel* dst, int numSamples, const ClpRng& clpRng template< typename T > void addAvgCore( const T* src1, const T* src2, T* dest, int numSamples, unsigned rshift, int offset, const ClpRng& clpRng ) { - for( int n = 0; n < numSamples; n+=2) + for( int n = 0; n < numSamples; n+=2) { dest[n] = ClipPel( rightShiftU( ( src1[n] + src2[n] + offset ), rshift ), clpRng ); dest[n+1] = ClipPel( rightShiftU( ( src1[n+1] + src2[n+1] + offset ), rshift ), clpRng ); @@ -428,8 +362,6 @@ PelBufferOps::PelBufferOps() transpose4x4 = transposeNxNCore; transpose8x8 = transposeNxNCore; - profGradFilter = gradFilterCore ; - applyPROF = applyPROFCore; mipMatrixMul_4_4 = mipMatrixMulCore<4,4>; mipMatrixMul_8_4 = mipMatrixMulCore<8,4>; mipMatrixMul_8_8 = mipMatrixMulCore<8,8>; @@ -559,7 +491,7 @@ void AreaBuf::addAvg( const AreaBuf& other1, const AreaBuf 2 && height > 2 && width == destStride ) + else if( width > 2 && height > 2 && width == destStride ) { g_pelBufOP.addAvg16(src0, src1Stride<<2, src2, src2Stride<<2, dest, destStride<<2, width<<2, height>>2, shiftNum, offset, clpRng); } @@ -643,7 +575,7 @@ void AreaBuf::reconstruct( const AreaBuf& pred, const AreaBuf::reconstruct( const AreaBuf& pred, const AreaBuf::linearTransform( const int scale, const unsigned shift, const dst[1] = ( Pel ) ClipPel( rightShiftU( scale * src[1], shift ) + offset, clpRng ); src += stride; dst += stride; - } + } } else { @@ -701,7 +646,7 @@ void AreaBuf::linearTransform( const int scale, const unsigned shift, const dst[1] = ( Pel ) ( rightShiftU( scale * src[1], shift ) + offset ); src += stride; dst += stride; - } + } } } } @@ -969,9 +914,6 @@ const CPelBuf PelStorage::getBuf( const ComponentID CompID ) const PelBuf PelStorage::getBuf( const CompArea& blk ) { const PelBuf& r = bufs[blk.compID]; - - CHECKD( rsAddr( blk.bottomRight(), r.stride ) >= ( ( r.height - 1 ) * r.stride + r.width ), "Trying to access a buf outside of bound!" ); - return PelBuf( r.buf + rsAddr( blk, r.stride ), r.stride, blk ); } @@ -1061,8 +1003,6 @@ void setupYuvBuffer ( const PelUnitBuf& pelUnitBuf, YUVBuffer& yuvBuffer, const { const ChromaFormat chFmt = pelUnitBuf.chromaFormat; const int numComp = getNumberValidComponents( chFmt ); - const Window zeroWindow; - const Window* cw = confWindow && confWindow->enabledFlag ? confWindow : &zeroWindow; for ( int i = 0; i < numComp; i++ ) { const ComponentID compId = ComponentID( i ); @@ -1071,9 +1011,9 @@ void setupYuvBuffer ( const PelUnitBuf& pelUnitBuf, YUVBuffer& yuvBuffer, const const int sy = getComponentScaleY( compId, chFmt ); YUVPlane& yuvPlane = yuvBuffer.yuvPlanes[ i ]; CHECK( yuvPlane.planeBuf != nullptr, "yuvBuffer already in use" ); - yuvPlane.planeBuf = area.bufAt( cw->winLeftOffset >> sx, cw->winTopOffset >> sy ); - yuvPlane.width = ( ( area.width << sx ) - ( cw->winLeftOffset + cw->winRightOffset ) ) >> sx; - yuvPlane.height = ( ( area.height << sy ) - ( cw->winTopOffset + cw->winBottomOffset ) ) >> sy; + yuvPlane.planeBuf = area.bufAt( confWindow->winLeftOffset >> sx, confWindow->winTopOffset >> sy ); + yuvPlane.width = ( ( area.width << sx ) - ( confWindow->winLeftOffset + confWindow->winRightOffset ) ) >> sx; + yuvPlane.height = ( ( area.height << sy ) - ( confWindow->winTopOffset + confWindow->winBottomOffset ) ) >> sy; yuvPlane.stride = area.stride; } } diff --git a/source/Lib/CommonLib/Buffer.h b/source/Lib/CommonLib/Buffer.h index e31ab11de..7f53e5b6e 100644 --- a/source/Lib/CommonLib/Buffer.h +++ b/source/Lib/CommonLib/Buffer.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Buffer.h * \brief Low-overhead class describing 2D memory layout */ @@ -99,8 +103,6 @@ struct PelBufferOps void ( *transpose4x4 ) ( const Pel* src, int srcStride, Pel* dst, int dstStride ); void ( *transpose8x8 ) ( const Pel* src, int srcStride, Pel* dst, int dstStride ); void ( *roundIntVector) ( int* v, int size, unsigned int nShift, const int dmvLimit); - void ( *profGradFilter) ( const Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth); - void ( *applyPROF) ( Pel* dst, int dstStride, const Pel* src, int srcStride, int width, int height, const Pel* gradX, const Pel* gradY, int gradStride, const int* dMvX, const int* dMvY, int dMvStride, const bool& bi, int shiftNum, Pel offset, const ClpRng& clpRng); void ( *mipMatrixMul_4_4)( Pel* res, const Pel* input, const uint8_t* weight, const int maxVal, const int offset, bool transpose ); void ( *mipMatrixMul_8_4)( Pel* res, const Pel* input, const uint8_t* weight, const int maxVal, const int offset, bool transpose ); void ( *mipMatrixMul_8_8)( Pel* res, const Pel* input, const uint8_t* weight, const int maxVal, const int offset, bool transpose ); @@ -692,7 +694,7 @@ struct UnitBuf bool valid () const { return bufs.size() != 0; } void fill ( const T& val ); - void copyFrom ( const UnitBuf &other, const bool lumaOnly = false, const bool chromaOnly = false ); + void copyFrom ( const UnitBuf &other ); void reconstruct ( const UnitBuf& pred, const UnitBuf& resi, const ClpRngs& clpRngs ); void copyClip ( const UnitBuf &src, const ClpRngs& clpRngs, const bool lumaOnly = false, const bool chromaOnly = false ); void subtract ( const UnitBuf& minuend, const UnitBuf& subtrahend ); @@ -727,16 +729,14 @@ void UnitBuf::fill( const T &val ) } template -void UnitBuf::copyFrom(const UnitBuf &other, const bool lumaOnly, const bool chromaOnly) +void UnitBuf::copyFrom(const UnitBuf &other) { CHECK( chromaFormat != other.chromaFormat, "Incompatible formats" ); - CHECK(lumaOnly && chromaOnly, "Not allowed to have both lumaOnly and chromaOnly selected"); - const size_t compStart = chromaOnly ? 1 : 0; - const size_t compEnd = lumaOnly ? 1 : (unsigned)bufs.size(); - for(size_t i = compStart; i < compEnd; i++) + for(size_t i = 0; i < bufs.size(); i++) { - bufs[i].copyFrom( other.bufs[i] ); + if( bufs[ i ].buf != nullptr && other.bufs[ i ].buf != nullptr ) + bufs[i].copyFrom( other.bufs[i] ); } } @@ -812,7 +812,8 @@ void UnitBuf::extendBorderPelTop ( int x, int size, int margin ) for( size_t i = 0; i < bufs.size(); i++ ) { int csx = getComponentScaleX(ComponentID(i), chromaFormat); - bufs[i].extendBorderPelTop( x>>csx, size>>csx, margin ); + int csy = getComponentScaleY(ComponentID(i), chromaFormat); + bufs[i].extendBorderPelTop( x>>csx, size>>csx, margin>>csy ); } } @@ -822,7 +823,8 @@ void UnitBuf::extendBorderPelBot ( int x, int size, int margin ) for( size_t i = 0; i < bufs.size(); i++ ) { int csx = getComponentScaleX(ComponentID(i), chromaFormat); - bufs[i].extendBorderPelBot( x>>csx, size>>csx, margin ); + int csy = getComponentScaleY(ComponentID(i), chromaFormat); + bufs[i].extendBorderPelBot( x>>csx, size>>csx, margin>>csy ); } } @@ -831,8 +833,9 @@ void UnitBuf::extendBorderPelLft ( int y, int size, int margin ) { for( size_t i = 0; i < bufs.size(); i++ ) { + int csx = getComponentScaleX(ComponentID(i), chromaFormat); int csy = getComponentScaleY(ComponentID(i), chromaFormat); - bufs[i].extendBorderPelLft( y>>csy, size>>csy, margin ); + bufs[i].extendBorderPelLft( y>>csy, size>>csy, margin>>csx ); } } @@ -841,8 +844,9 @@ void UnitBuf::extendBorderPelRgt ( int y, int size, int margin ) { for( size_t i = 0; i < bufs.size(); i++ ) { + int csx = getComponentScaleX(ComponentID(i), chromaFormat); int csy = getComponentScaleY(ComponentID(i), chromaFormat); - bufs[i].extendBorderPelRgt( y>>csy, size>>csy, margin ); + bufs[i].extendBorderPelRgt( y>>csy, size>>csy, margin>>csx ); } } diff --git a/source/Lib/CommonLib/CodingStructure.cpp b/source/Lib/CommonLib/CodingStructure.cpp index 8e41f9cb7..f03924dc8 100644 --- a/source/Lib/CommonLib/CodingStructure.cpp +++ b/source/Lib/CommonLib/CodingStructure.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file CodingStructure.h @@ -78,7 +82,6 @@ CodingStructure::CodingStructure( XUCache& unitCache, std::mutex* mutex ) , picHeader ( nullptr ) , m_isTuEnc ( false ) , m_cuCache ( unitCache.cuCache ) - , m_puCache ( unitCache.puCache ) , m_tuCache ( unitCache.tuCache ) , m_unitCacheMutex( mutex ) , bestParent ( nullptr ) @@ -86,17 +89,13 @@ CodingStructure::CodingStructure( XUCache& unitCache, std::mutex* mutex ) for( uint32_t i = 0; i < MAX_NUM_COMP; i++ ) { m_coeffs[ i ] = nullptr; - m_pcmbuf[ i ] = nullptr; m_offsets[ i ] = 0; } for( uint32_t i = 0; i < MAX_NUM_CH; i++ ) { - m_runType [ i ] = nullptr; m_cuPtr [ i ] = nullptr; - m_puPtr [ i ] = nullptr; m_tuPtr [ i ] = nullptr; - m_isDecomp[ i ] = nullptr; } for( int i = 0; i < NUM_EDGE_DIR; i++ ) @@ -125,15 +124,9 @@ void CodingStructure::destroy() for( uint32_t i = 0; i < MAX_NUM_CH; i++ ) { - delete[] m_isDecomp[ i ]; - m_isDecomp[ i ] = nullptr; - delete[] m_cuPtr[ i ]; m_cuPtr[ i ] = nullptr; - delete[] m_puPtr[ i ]; - m_puPtr[ i ] = nullptr; - delete[] m_tuPtr[ i ]; m_tuPtr[ i ] = nullptr; } @@ -151,7 +144,6 @@ void CodingStructure::destroy() if ( m_unitCacheMutex ) m_unitCacheMutex->lock(); m_tuCache.cache( tus ); - m_puCache.cache( pus ); m_cuCache.cache( cus ); if ( m_unitCacheMutex ) m_unitCacheMutex->unlock(); @@ -160,61 +152,9 @@ void CodingStructure::destroy() void CodingStructure::releaseIntermediateData() { clearTUs(); - clearPUs(); clearCUs(); } -bool CodingStructure::isDecomp( const Position& pos, const ChannelType effChType ) -{ - if( area.blocks[effChType].contains( pos ) ) - { - return m_isDecomp[effChType][rsAddr( pos, area.blocks[effChType], area.blocks[effChType].width, unitScale[effChType] )]; - } - else if( parent ) - { - return parent->isDecomp( pos, effChType ); - } - else - { - return false; - } -} - -bool CodingStructure::isDecomp( const Position& pos, const ChannelType effChType ) const -{ - if( area.blocks[effChType].contains( pos ) ) - { - return m_isDecomp[effChType][rsAddr( pos, area.blocks[effChType], area.blocks[effChType].width, unitScale[effChType] )]; - } - else if( parent ) - { - return parent->isDecomp( pos, effChType ); - } - else - { - return false; - } -} - -void CodingStructure::setDecomp(const CompArea& _area, const bool _isCoded /*= true*/) -{ - const UnitScale& scale = unitScale[_area.compID]; - - AreaBuf isCodedBlk( m_isDecomp[toChannelType( _area.compID )] + rsAddr( _area, area.blocks[_area.compID].pos(), area.blocks[_area.compID].width, scale ), - area.blocks[_area.compID].width >> scale.posx, - _area.width >> scale.posx, - _area.height >> scale.posy); - isCodedBlk.fill( _isCoded ); -} - -void CodingStructure::setDecomp(const UnitArea& _area, const bool _isCoded /*= true*/) -{ - for( uint32_t i = 0; i < _area.blocks.size(); i++ ) - { - if( _area.blocks[i].valid() ) setDecomp( _area.blocks[i], _isCoded ); - } -} - const int CodingStructure::signalModeCons( const PartSplit split, Partitioner &partitioner, const ModeType modeTypeParent ) const { if (CS::isDualITree(*this) || modeTypeParent != MODE_TYPE_ALL || partitioner.currArea().chromaFormat == CHROMA_444 || partitioner.currArea().chromaFormat == CHROMA_400 ) @@ -245,70 +185,37 @@ CodingUnit* CodingStructure::getLumaCU( const Position& pos ) CodingUnit* CodingStructure::getCU( const Position& pos, const ChannelType effChType, const TreeType _treeType ) { - const CompArea& _blk = area.blocks[effChType]; + CHECKD(_treeType == TREE_C && effChType == CH_L && parent == nullptr && _treeType == TREE_C && effChType == CH_L, "parent shall be valid; consider using function getLumaCU()"); + + CodingStructure* cs = _treeType == TREE_C && effChType == CH_L ? parent : this; + while (cs && !cs->area.blocks[effChType].contains(pos)) cs = cs->parent; - if( !_blk.contains( pos ) || (_treeType == TREE_C && effChType == CH_L) ) + if (!cs) { - //keep this check, which is helpful to identify bugs - if( _treeType == TREE_C && effChType == CH_L ) - { - CHECK( parent == nullptr, "parent shall be valid; consider using function getLumaCU()" ); - } - if( parent ) return parent->getCU( pos, effChType, TREE_D ); - else return nullptr; + return nullptr; } else { - return m_cuPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; + const Area& _blk = cs->area.blocks[effChType]; + return cs->m_cuPtr[effChType][rsAddr(pos, _blk.pos(), _blk.width, unitScale[effChType])]; } } const CodingUnit* CodingStructure::getCU( const Position& pos, const ChannelType effChType, const TreeType _treeType ) const { - const CompArea& _blk = area.blocks[effChType]; - - if( !_blk.contains( pos ) || (_treeType == TREE_C && effChType == CH_L) ) - { - if( _treeType == TREE_C && effChType == CH_L ) - { - CHECK( parent == nullptr, "parent shall be valid; consider using function getLumaCU()" ); - } - if( parent ) return parent->getCU( pos, effChType, TREE_D ); - else return nullptr; - } - else - { - return m_cuPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; - } -} + CHECKD(_treeType == TREE_C && effChType == CH_L && parent == nullptr && _treeType == TREE_C && effChType == CH_L, "parent shall be valid; consider using function getLumaCU()"); -PredictionUnit* CodingStructure::getPU( const Position& pos, const ChannelType effChType ) -{ - const CompArea& _blk = area.blocks[effChType]; + const CodingStructure* cs = _treeType == TREE_C && effChType == CH_L ? parent : this; + while (cs && !cs->area.blocks[effChType].contains(pos)) cs = cs->parent; - if( !_blk.contains( pos ) ) + if (!cs) { - if( parent ) return parent->getPU( pos, effChType ); - else return nullptr; + return nullptr; } else { - return m_puPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; - } -} - -const PredictionUnit * CodingStructure::getPU( const Position& pos, const ChannelType effChType ) const -{ - const CompArea& _blk = area.blocks[effChType]; - - if( !_blk.contains( pos ) ) - { - if( parent ) return parent->getPU( pos, effChType ); - else return nullptr; - } - else - { - return m_puPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; + const Area& _blk = cs->area.blocks[effChType]; + return cs->m_cuPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; } } @@ -323,45 +230,34 @@ TransformUnit* CodingStructure::getTU( const Position& pos, const ChannelType ef } else { -#if 1 - TransformUnit *ptu = m_tuPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; - - if( !ptu && m_isTuEnc ) return parent->getTU( pos, effChType ); - else return ptu; -#else - // TODO: fix when implementing ISP, see in the decoder impl - const unsigned idx = m_tuIdx[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; - - if( idx != 0 ) + TransformUnit* ptu = m_tuPtr[effChType][rsAddr(pos, _blk.pos(), _blk.width, unitScale[effChType])]; + unsigned idx = ptu->idx; + if (!ptu && m_isTuEnc) + return parent->getTU(pos, effChType); + else { - unsigned extraIdx = 0; - if( isLuma( effChType ) ) + if (isLuma(effChType)) { const TransformUnit& tu = *tus[idx - 1]; - - if( tu.cu->ispMode ) // Intra SubPartitions mode + if (tu.cu->ispMode) { - //we obtain the offset to index the corresponding sub-partition - if( subTuIdx != -1 ) - { - extraIdx = subTuIdx; - } - else + if (subTuIdx == -1) { - while( !tus[idx - 1 + extraIdx]->blocks[getFirstComponentOfChannel( effChType )].contains( pos ) ) + unsigned extraIdx = 0; + while (!tus[idx - 1 + extraIdx]->blocks[getFirstComponentOfChannel(effChType)].contains(pos)) { extraIdx++; - CHECK( tus[idx - 1 + extraIdx]->cu->treeType == TREE_C, "tu searched by position points to a chroma tree CU" ); - CHECK( extraIdx > 3, "extraIdx > 3" ); + CHECK(tus[idx - 1 + extraIdx]->cu->treeType == TREE_C, + "tu searched by position points to a chroma tree CU"); + CHECK(extraIdx > 3, "extraIdx > 3"); } + return tus[idx - 1 + extraIdx]; } + return tus[idx - 1 + subTuIdx]; } } - return tus[idx - 1 + extraIdx]; + return ptu; } - else if( m_isTuEnc ) return parent->getTU( pos, effChType ); - else return nullptr; -#endif } } @@ -376,43 +272,34 @@ const TransformUnit * CodingStructure::getTU( const Position& pos, const Channel } else { -#if 1 - TransformUnit *ptu = m_tuPtr[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; - - if( !ptu && m_isTuEnc ) return parent->getTU( pos, effChType ); - else return ptu; -#else - // TODO: fix when implementing ISP, see in the decoder impl - const unsigned idx = m_tuIdx[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )]; - if( idx != 0 ) + TransformUnit* ptu = m_tuPtr[effChType][rsAddr(pos, _blk.pos(), _blk.width, unitScale[effChType])]; + unsigned idx = ptu->idx; + if (!ptu && m_isTuEnc) + return parent->getTU(pos, effChType); + else { - unsigned extraIdx = 0; - if( isLuma( effChType ) ) + if (isLuma(effChType)) { const TransformUnit& tu = *tus[idx - 1]; - if( tu.cu->ispMode ) // Intra SubPartitions mode + if (tu.cu->ispMode) { - //we obtain the offset to index the corresponding sub-partition - if( subTuIdx != -1 ) + if (subTuIdx == -1) { - extraIdx = subTuIdx; - } - else - { - while ( !tus[idx - 1 + extraIdx]->blocks[getFirstComponentOfChannel( effChType )].contains(pos) ) + unsigned extraIdx = 0; + while (!tus[idx - 1 + extraIdx]->blocks[getFirstComponentOfChannel(effChType)].contains(pos)) { extraIdx++; - CHECK( tus[idx - 1 + extraIdx]->cu->treeType == TREE_C, "tu searched by position points to a chroma tree CU" ); - CHECK( extraIdx > 3, "extraIdx > 3" ); + CHECK(tus[idx - 1 + extraIdx]->cu->treeType == TREE_C, + "tu searched by position points to a chroma tree CU"); + CHECK(extraIdx > 3, "extraIdx > 3"); } + return tus[idx - 1 + extraIdx]; } + return tus[idx - 1 + subTuIdx]; } } - return tus[idx - 1 + extraIdx]; + return ptu; } - else if( m_isTuEnc ) return parent->getTU( pos, effChType ); - else return nullptr; -#endif } } @@ -429,7 +316,6 @@ CodingUnit& CodingStructure::addCU( const UnitArea& unit, const ChannelType chTy cu->cs = this; cu->slice = nullptr; cu->next = nullptr; - cu->pu = nullptr; cu->firstTU = nullptr; cu->lastTU = nullptr; cu->chType = chType; @@ -445,6 +331,13 @@ CodingUnit& CodingStructure::addCU( const UnitArea& unit, const ChannelType chTy uint32_t idx = ++m_numCUs; cu->idx = idx; + cu->mvdL0SubPu = nullptr; + if( isLuma( chType ) && unit.lheight() >= 8 && unit.lwidth() >= 8 && unit.Y().area() >= 128 ) + { + CHECKD( m_dmvrMvCacheOffset >= m_dmvrMvCache.size(), "dmvr cache offset out of bounds" ) + cu->mvdL0SubPu = &m_dmvrMvCache[m_dmvrMvCacheOffset]; + m_dmvrMvCacheOffset += std::max( 1, unit.lwidth() >> DMVR_SUBCU_SIZE_LOG2 ) * std::max( 1, unit.lheight() >> DMVR_SUBCU_SIZE_LOG2 ); + } uint32_t numCh = getNumberValidChannels( area.chromaFormat ); @@ -469,52 +362,6 @@ CodingUnit& CodingStructure::addCU( const UnitArea& unit, const ChannelType chTy return *cu; } -PredictionUnit& CodingStructure::addPU( const UnitArea& unit, const ChannelType chType, CodingUnit* cu ) -{ - if ( m_unitCacheMutex ) m_unitCacheMutex->lock(); - - PredictionUnit *pu = m_puCache.get(); - - if ( m_unitCacheMutex ) m_unitCacheMutex->unlock(); - - pu->UnitArea::operator=( unit ); - pu->initData(); - pu->cs = this; - pu->cu = m_isTuEnc ? cus[0] : cu ; - pu->chType = chType; - - pus.push_back( pu ); - - if( pu->cu->pu == nullptr ) - { - pu->cu->pu = pu; - } - - uint32_t idx = ++m_numPUs; - pu->idx = idx; - - uint32_t numCh = getNumberValidChannels( area.chromaFormat ); - for( uint32_t i = 0; i < numCh; i++ ) - { - if( !pu->blocks[i].valid() ) - { - continue; - } - - const CompArea& _selfBlk = area.blocks[i]; - const CompArea &_blk = pu-> blocks[i]; - - const UnitScale& scale = unitScale[_blk.compID]; - const Area scaledSelf = scale.scale( _selfBlk ); - const Area scaledBlk = scale.scale( _blk ); - PredictionUnit **puPtr = m_puPtr[i] + rsAddr( scaledBlk.pos(), scaledSelf.pos(), scaledSelf.width ); - CHECK( *puPtr, "Overwriting a pre-existing value, should be '0'!" ); - g_pelBufOP.fillPtrMap( ( void** ) puPtr, scaledSelf.width, scaledBlk.width, scaledBlk.height, ( void* ) pu ); - } - - return *pu; -} - TransformUnit& CodingStructure::addTU( const UnitArea& unit, const ChannelType chType, CodingUnit* cu ) { if ( m_unitCacheMutex ) m_unitCacheMutex->lock(); @@ -528,7 +375,7 @@ TransformUnit& CodingStructure::addTU( const UnitArea& unit, const ChannelType c tu->next = nullptr; tu->prev = nullptr; tu->cs = this; - tu->cu = m_isTuEnc ? cus[0] : cu; + tu->cu = cu; tu->chType = chType; TransformUnit *prevTU = m_numTUs > 0 ? tus.back() : nullptr; @@ -554,8 +401,6 @@ TransformUnit& CodingStructure::addTU( const UnitArea& unit, const ChannelType c tu->idx = idx; TCoeff *coeffs[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; - Pel *pcmbuf[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; - bool *runType[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; uint32_t numCh = getNumberValidComponents( area.chromaFormat ); @@ -591,17 +436,12 @@ TransformUnit& CodingStructure::addTU( const UnitArea& unit, const ChannelType c } coeffs[i] = m_coeffs[i] + m_offsets[i]; - pcmbuf[i] = m_pcmbuf[i] + m_offsets[i]; - if (i < MAX_NUM_CH) - { - if (m_runType[i] != nullptr) runType[i] = m_runType[i] + m_offsets[i]; - } unsigned areaSize = tu->blocks[i].area(); m_offsets[i] += areaSize; } - tu->init( coeffs, pcmbuf, runType); + tu->init( coeffs ); return *tu; } @@ -709,7 +549,10 @@ cCUSecureTraverser CodingStructure::secureTraverseCUs( const UnitArea& unit, con } else { - do { lastCU = lastCU->next; } while( lastCU->next && unit.contains( *lastCU->next ) ); + if(lastCU->next) + { + do { lastCU = lastCU->next; } while( lastCU->next && unit.contains( *lastCU->next ) ); + } } return cCUSecureTraverser( firstCU, lastCU ); @@ -766,7 +609,6 @@ void CodingStructure::allocateVectorsAtPicLevel() size_t allocSize = twice * unitScale[0].scale( area.blocks[0].size() ).area(); cus.reserve( allocSize ); - pus.reserve( allocSize ); tus.reserve( allocSize ); } @@ -818,15 +660,13 @@ void CodingStructure::createInternals( const UnitArea& _unit, const bool isTopLa unsigned _area = unitScale[i].scale( area.blocks[i].size() ).area(); m_cuPtr[i] = _area > 0 ? new CodingUnit* [_area] : nullptr; - m_puPtr[i] = _area > 0 ? new PredictionUnit*[_area] : nullptr; m_tuPtr[i] = _area > 0 ? new TransformUnit* [_area] : nullptr; - m_isDecomp[i] = _area > 0 ? new bool [_area] : nullptr; } - for( unsigned i = 0; i < NUM_EDGE_DIR; i++ ) - { + for( unsigned i = 0; i < NUM_EDGE_DIR; i++ ) + { m_lfParam[i] = ( isTopLayer && m_mapSize[0].area() > 0 ) ? ( LoopFilterParam* ) xMalloc( LoopFilterParam, m_mapSize[0].area() ) : nullptr; - } + } numCh = getNumberValidComponents(area.chromaFormat); @@ -846,6 +686,10 @@ void CodingStructure::createInternals( const UnitArea& _unit, const bool isTopLa unsigned _lumaAreaScaled = g_miScaling.scale( area.lumaSize() ).area(); m_motionBuf = new MotionInfo[_lumaAreaScaled]; + + unsigned _maxNumDmvrMvs = ( area.lwidth() >> 3 ) * ( area.lheight() >> 3 ); + m_dmvrMvCache.resize( _maxNumDmvrMvs ); + initStructData(); } @@ -894,14 +738,6 @@ void CodingStructure::createCoeffs() unsigned _area = area.blocks[i].area(); m_coeffs[i] = _area > 0 ? ( TCoeff* ) xMalloc( TCoeff, _area ) : nullptr; - m_pcmbuf[i] = _area > 0 ? ( Pel* ) xMalloc( Pel, _area ) : nullptr; - } - - const unsigned numCh = getNumberValidChannels( area.chromaFormat ); - for( unsigned i = 0; i < numCh; i++ ) - { - unsigned _area = area.blocks[i].area(); - m_runType[i] = _area > 0 ? ( bool* ) xMalloc( bool, _area ) : nullptr; } } @@ -910,11 +746,6 @@ void CodingStructure::destroyCoeffs() for( uint32_t i = 0; i < MAX_NUM_COMP; i++ ) { if( m_coeffs[i] ) { xFree( m_coeffs[i] ); m_coeffs[i] = nullptr; } - if( m_pcmbuf[i] ) { xFree( m_pcmbuf[i] ); m_pcmbuf[i] = nullptr; } -} - for (uint32_t i = 0; i < MAX_NUM_CH; i++) - { - if (m_runType[i]) { xFree(m_runType[i]); m_runType[i] = nullptr; } } } @@ -983,19 +814,6 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe cu = *pcu; } - - for( const auto &ppu : pus ) - { - PredictionUnit &pu = subStruct.addPU( *ppu, _chType, nullptr ); - - pu = *ppu; - } - - unsigned numComp = getNumberValidChannels( area.chromaFormat ); - for( unsigned i = 0; i < numComp; i++) - { - ::memcpy( subStruct.m_isDecomp[i], m_isDecomp[i], (unitScale[i].scale( area.blocks[i].size() ).area() * sizeof( bool ) ) ); - } } } @@ -1003,8 +821,6 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C { UnitArea clippedArea = clipArea( subArea, *picture ); - setDecomp( clippedArea ); - if( cpyReco ) { CPelUnitBuf subRecoBuf = subStruct.getRecoBuf( clippedArea ); @@ -1066,23 +882,6 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C } } - // copy the PUs over - if( subStruct.m_isTuEnc ) - { - // don't copy if the substruct was created for encoding of the TUs - } - else - { - for( const auto &ppu : subStruct.pus ) - { - // add an analogue PU into own PU store - const UnitArea& puPatch = *ppu; - PredictionUnit &pu = addPU( puPatch, ppu->chType, getCU( puPatch.blocks[ppu->chType].pos(), ppu->chType, _treeType ) ); - - // copy the PU info from subPatch - pu = *ppu; - } - } // copy the TUs over for( const auto &ptu : subStruct.tus ) { @@ -1121,22 +920,6 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel cu = *pcu; } - // copy the PUs over - for (const auto &ppu : other.pus) - { - if( !dualITreeArea.contains( *ppu ) ) - { - continue; - } - // add an analogue PU into own PU store - const UnitArea& puPatch = *ppu; - - PredictionUnit &pu = addPU(puPatch, ppu->chType, getCU( puPatch.blocks[ppu->chType], ppu->chType, _treeType)); - - // copy the PU info from subPatch - pu = *ppu; - } - if (!other.slice->isIntra() || other.slice->sps->IBC) { // copy motion buffer @@ -1184,7 +967,6 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel void CodingStructure::initStructData( const int QP, const bool skipMotBuf ) { - clearPUs(); clearTUs(); clearCUs(); @@ -1198,6 +980,8 @@ void CodingStructure::initStructData( const int QP, const bool skipMotBuf ) getMotionBuf() .memset( 0 ); } + m_dmvrMvCacheOffset = 0; + fracBits = 0; dist = 0; cost = MAX_DOUBLE; @@ -1214,8 +998,7 @@ void CodingStructure::clearTUs() { size_t _area = ( area.blocks[i].area() >> unitScale[i].area ); - memset( m_isDecomp[i], false, sizeof( *m_isDecomp[0] ) * _area ); - memset( m_tuPtr [i], 0, sizeof( *m_tuPtr [0] ) * _area ); + memset( m_tuPtr[i], 0, sizeof( *m_tuPtr[0] ) * _area ); } numCh = getNumberValidComponents( area.chromaFormat ); @@ -1236,26 +1019,6 @@ void CodingStructure::clearTUs() m_numTUs = 0; } -void CodingStructure::clearPUs() -{ - int numCh = getNumberValidChannels( area.chromaFormat ); - for( int i = 0; i < numCh; i++ ) - { - memset( m_puPtr[i], 0, sizeof( *m_puPtr[0] ) * unitScale[i].scaleArea( area.blocks[i].area() ) ); - } - - if ( m_unitCacheMutex ) m_unitCacheMutex->lock(); - m_puCache.cache( pus ); - if ( m_unitCacheMutex ) m_unitCacheMutex->unlock(); - - m_numPUs = 0; - - for( auto &pcu : cus ) - { - pcu->pu = nullptr; - } -} - void CodingStructure::clearCUs() { int numCh = getNumberValidChannels( area.chromaFormat ); @@ -1335,6 +1098,10 @@ PelBuf CodingStructure::getBuf( const CompArea& blk, const PictureType type ) { buf = m_rsporg; } + else if (type == PIC_ORIGINAL_RSP_REC) + { + buf = &m_rspreco; + } CHECK( !buf, "Unknown buffer requested" ); @@ -1370,6 +1137,10 @@ const CPelBuf CodingStructure::getBuf( const CompArea& blk, const PictureType ty { buf = m_rsporg; } + else if (type == PIC_ORIGINAL_RSP_REC) + { + buf = &m_rspreco; + } CHECK( !buf, "Unknown buffer requested" ); @@ -1440,19 +1211,6 @@ const CodingUnit* CodingStructure::getCURestricted( const Position& pos, const P return ( cu && cu->slice->independentSliceIdx == curSliceIdx && cu->tileIdx == curTileIdx ) ? cu : nullptr; } -const PredictionUnit* CodingStructure::getPURestricted( const Position& pos, const PredictionUnit& curPu, const ChannelType _chType ) const -{ - if( sps->entropyCodingSyncEnabled ) - { - const int xshift = pcv->maxCUSizeLog2 - getChannelTypeScaleX( _chType, curPu.chromaFormat ); - const int yshift = pcv->maxCUSizeLog2 - getChannelTypeScaleY( _chType, curPu.chromaFormat ); - if( (pos.x >> xshift) > (curPu.blocks[_chType].x >> xshift) || (pos.y >> yshift) > (curPu.blocks[_chType].y >> yshift) ) - return nullptr; - } - const PredictionUnit* pu = getPU( pos, _chType ); - return ( pu && CU::isSameSliceAndTile( *pu->cu, *curPu.cu ) && ( pu->cs != curPu.cs || pu->idx <= curPu.idx ) ) ? pu : nullptr; -} - const TransformUnit* CodingStructure::getTURestricted( const Position& pos, const TransformUnit& curTu, const ChannelType _chType ) const { if( sps->entropyCodingSyncEnabled ) diff --git a/source/Lib/CommonLib/CodingStructure.h b/source/Lib/CommonLib/CodingStructure.h index fb3abd7d4..a85176efc 100644 --- a/source/Lib/CommonLib/CodingStructure.h +++ b/source/Lib/CommonLib/CodingStructure.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file CodingStructure.h * \brief A class managing the coding information for a specific image part */ @@ -72,6 +76,7 @@ enum PictureType PIC_SAO_TEMP, NUM_PIC_TYPES, PIC_ORIGINAL_LOCAL, + PIC_ORIGINAL_RSP_REC, }; // --------------------------------------------------------------------------- @@ -121,35 +126,24 @@ class CodingStructure // global accessors // --------------------------------------------------------------------------- - bool isDecomp (const Position& pos, const ChannelType _chType) const; - bool isDecomp (const Position& pos, const ChannelType _chType); - void setDecomp(const CompArea& area, const bool _isCoded = true); - void setDecomp(const UnitArea& area, const bool _isCoded = true); - - const CodingUnit *getCU(const Position& pos, const ChannelType _chType, const TreeType _treeType) const; - const PredictionUnit *getPU(const Position& pos, const ChannelType _chType) const; - const TransformUnit *getTU(const Position& pos, const ChannelType _chType, const int subTuIdx = -1) const; + const CodingUnit* getCU(const Position& pos, const ChannelType _chType, const TreeType _treeType) const; + const TransformUnit* getTU(const Position& pos, const ChannelType _chType, const int subTuIdx = -1) const; - CodingUnit *getCU(const Position& pos, const ChannelType _chType, const TreeType _treeType); - CodingUnit *getLumaCU( const Position& pos ); - PredictionUnit *getPU(const Position& pos, const ChannelType _chType); - TransformUnit *getTU(const Position& pos, const ChannelType _chType, const int subTuIdx = -1); + CodingUnit* getCU(const Position& pos, const ChannelType _chType, const TreeType _treeType); + CodingUnit* getLumaCU( const Position& pos ); + TransformUnit* getTU(const Position& pos, const ChannelType _chType, const int subTuIdx = -1); - const CodingUnit *getCU(const ChannelType& _chType, const TreeType _treeType) const { return getCU(area.blocks[_chType].pos(), _chType, _treeType); } - const PredictionUnit *getPU(const ChannelType& _chType) const { return getPU(area.blocks[_chType].pos(), _chType); } - const TransformUnit *getTU(const ChannelType& _chType) const { return getTU(area.blocks[_chType].pos(), _chType); } + const CodingUnit* getCU(const ChannelType& _chType, const TreeType _treeType) const { return getCU(area.blocks[_chType].pos(), _chType, _treeType); } + const TransformUnit* getTU(const ChannelType& _chType) const { return getTU(area.blocks[_chType].pos(), _chType); } - CodingUnit *getCU(const ChannelType& _chType, const TreeType _treeType ) { return getCU(area.blocks[_chType].pos(), _chType, _treeType); } - PredictionUnit *getPU(const ChannelType& _chType ) { return getPU(area.blocks[_chType].pos(), _chType); } - TransformUnit *getTU(const ChannelType& _chType ) { return getTU(area.blocks[_chType].pos(), _chType); } + CodingUnit* getCU(const ChannelType& _chType, const TreeType _treeType ) { return getCU(area.blocks[_chType].pos(), _chType, _treeType); } + TransformUnit* getTU(const ChannelType& _chType ) { return getTU(area.blocks[_chType].pos(), _chType); } - const CodingUnit *getCURestricted(const Position& pos, const Position curPos, const unsigned curSliceIdx, const unsigned curTileIdx, const ChannelType _chType, const TreeType treeType) const; - const CodingUnit *getCURestricted(const Position& pos, const CodingUnit& curCu, const ChannelType _chType) const; - const PredictionUnit *getPURestricted(const Position& pos, const PredictionUnit& curPu, const ChannelType _chType) const; - const TransformUnit *getTURestricted(const Position& pos, const TransformUnit& curTu, const ChannelType _chType) const; + const CodingUnit* getCURestricted(const Position& pos, const Position curPos, const unsigned curSliceIdx, const unsigned curTileIdx, const ChannelType _chType, const TreeType treeType) const; + const CodingUnit* getCURestricted(const Position& pos, const CodingUnit& curCu, const ChannelType _chType) const; + const TransformUnit* getTURestricted(const Position& pos, const TransformUnit& curTu, const ChannelType _chType) const; CodingUnit& addCU(const UnitArea& unit, const ChannelType _chType); - PredictionUnit& addPU(const UnitArea& unit, const ChannelType _chType, CodingUnit* cu); TransformUnit& addTU(const UnitArea& unit, const ChannelType _chType, CodingUnit* cu); void addEmptyTUs( Partitioner &partitioner, CodingUnit* cu ); @@ -179,7 +173,6 @@ class CodingStructure void useSubStructure (const CodingStructure& cs, const ChannelType chType, const TreeType treeType, const UnitArea& subArea, const bool cpyReco ); void clearTUs(); - void clearPUs(); void clearCUs(); const int signalModeCons( const PartSplit split, Partitioner &partitioner, const ModeType modeTypeParent ) const; @@ -190,7 +183,6 @@ class CodingStructure std::vector< CodingUnit*> cus; - std::vector pus; std::vector< TransformUnit*> tus; LutMotionCand motionLut; @@ -202,39 +194,36 @@ class CodingStructure // needed for TU encoding bool m_isTuEnc; - CodingUnit **m_cuPtr [MAX_NUM_CH]; - PredictionUnit **m_puPtr [MAX_NUM_CH]; - TransformUnit **m_tuPtr [MAX_NUM_CH]; - bool *m_isDecomp[MAX_NUM_CH]; + CodingUnit** m_cuPtr [MAX_NUM_CH]; + TransformUnit** m_tuPtr [MAX_NUM_CH]; unsigned m_numCUs; - unsigned m_numPUs; unsigned m_numTUs; CUCache& m_cuCache; - PUCache& m_puCache; TUCache& m_tuCache; std::mutex* m_unitCacheMutex; std::vector m_sao; - PelStorage m_pred; - PelStorage m_resi; - PelStorage m_reco; - PelStorage m_rspreco; + PelStorage m_pred; + PelStorage m_resi; + PelStorage m_reco; + PelStorage m_rspreco; PelStorage* m_org; PelStorage* m_rsporg; - TCoeff *m_coeffs [MAX_NUM_COMP]; - Pel *m_pcmbuf [MAX_NUM_COMP]; - bool *m_runType[MAX_NUM_CH]; + TCoeff* m_coeffs [MAX_NUM_COMP]; int m_offsets[MAX_NUM_COMP]; - MotionInfo *m_motionBuf; + std::vector m_dmvrMvCache; + int m_dmvrMvCacheOffset; - LoopFilterParam *m_lfParam[NUM_EDGE_DIR]; + MotionInfo* m_motionBuf; - Size m_mapSize[MAX_NUM_CH]; + LoopFilterParam* m_lfParam[NUM_EDGE_DIR]; + + Size m_mapSize[MAX_NUM_CH]; public: @@ -294,6 +283,9 @@ class CodingStructure PelBuf getRspOrgBuf(const CompArea& blk) { return getBuf(blk, PIC_ORIGINAL_RSP); } const CPelBuf getRspOrgBuf(const CompArea& blk) const { return getBuf(blk, PIC_ORIGINAL_RSP); } + PelBuf getRspRecoBuf(const CompArea &blk) { return getBuf(blk, PIC_ORIGINAL_RSP_REC); } + const CPelBuf getRspRecoBuf(const CompArea &blk) const { return getBuf(blk, PIC_ORIGINAL_RSP_REC); } + PelUnitBuf& getRecoBufRef() { return m_reco; } PelBuf& getRspRecoBuf() { return m_rspreco.Y(); } const CPelBuf getRspRecoBuf() const { return m_rspreco.Y(); } diff --git a/source/Lib/CommonLib/Common.h b/source/Lib/CommonLib/Common.h index dc751664b..d8528e94d 100644 --- a/source/Lib/CommonLib/Common.h +++ b/source/Lib/CommonLib/Common.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Common.h * \brief Common 2D-geometrical structures */ @@ -134,24 +138,24 @@ struct UnitScale Area scale( const Area &_area ) const { return Area( scale( _area.pos() ), scale( _area.size() ) ); } }; -inline size_t rsAddr(const Position& pos, const uint32_t stride, const UnitScale &unitScale ) +inline ptrdiff_t rsAddr(const Position& pos, const uint32_t stride, const UnitScale &unitScale ) { - return (size_t)(stride >> unitScale.posx) * (size_t)(pos.y >> unitScale.posy) + (size_t)(pos.x >> unitScale.posx); + return (ptrdiff_t)(stride >> unitScale.posx) * (ptrdiff_t)(pos.y >> unitScale.posy) + (ptrdiff_t)(pos.x >> unitScale.posx); } -inline size_t rsAddr(const Position& pos, const Position& origin, const uint32_t stride, const UnitScale &unitScale ) +inline ptrdiff_t rsAddr(const Position& pos, const Position& origin, const uint32_t stride, const UnitScale &unitScale ) { - return (stride >> unitScale.posx) * ((pos.y - origin.y) >> unitScale.posy) + ((pos.x - origin.x) >> unitScale.posx); + return (ptrdiff_t)(stride >> unitScale.posx) * (ptrdiff_t)((pos.y - origin.y) >> unitScale.posy) + (ptrdiff_t)((pos.x - origin.x) >> unitScale.posx); } -inline size_t rsAddr(const Position& pos, const uint32_t stride ) +inline ptrdiff_t rsAddr(const Position& pos, const uint32_t stride ) { - return stride * (size_t)pos.y + (size_t)pos.x; + return (ptrdiff_t)stride * (ptrdiff_t)pos.y + (ptrdiff_t)pos.x; } -inline size_t rsAddr(const Position& pos, const Position& origin, const uint32_t stride ) +inline ptrdiff_t rsAddr(const Position& pos, const Position& origin, const uint32_t stride ) { - return stride * (pos.y - origin.y) + (pos.x - origin.x); + return (ptrdiff_t)stride * (ptrdiff_t)(pos.y - origin.y) + (ptrdiff_t)(pos.x - origin.x); } inline Area clipArea(const Area& _area, const Area& boundingBox) diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 297ea57e5..d0879693b 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file CommonDef.h \brief Defines version information, constants and small in-line functions */ @@ -50,6 +54,7 @@ vvc@hhi.fraunhofer.de #include #include #include +#include #if _MSC_VER > 1000 // disable "signed and unsigned mismatch" @@ -58,7 +63,7 @@ vvc@hhi.fraunhofer.de #pragma warning( disable : 4800 ) #endif // _MSC_VER > 1000 -#include "../../../include/vvenc/Basics.h" +#include "vvenc/Basics.h" #define __IN_COMMONDEF_H__ #include "TypeDef.h" @@ -84,10 +89,13 @@ vvc@hhi.fraunhofer.de _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\""); # define GCC_WARNING_DISABLE_class_memaccess _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wclass-memaccess\""); +# define GCC_WARNING_DISABLE_array_bounds _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Warray-bounds\""); # define GCC_WARNING_RESET _Pragma("GCC diagnostic pop"); #else # define GCC_WARNING_DISABLE_maybe_uninitialized # define GCC_WARNING_DISABLE_class_memaccess +# define GCC_WARNING_DISABLE_array_bounds # define GCC_WARNING_RESET #endif @@ -364,8 +372,10 @@ static const int RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION = 0; ///< Addi static const int MAX_TIMECODE_SEI_SETS = 3; ///< Maximum number of time sets + static const int MAX_CU_DEPTH = 7; ///< log2(CTUSize) static const int MAX_CU_SIZE_IDX = MAX_CU_DEPTH + 1; ///< 1+log2(CTUSize) +static const int MAX_TU_SIZE_IDX = MAX_TB_LOG2_SIZEY + 1; ///< 1+log2(MaxTuSize) static const int MAX_CU_SIZE = 1< inline void Check3( T minVal, T maxVal, T a) CHECK( ( a > maxVal ) || ( a < minVal ), "ERROR: Range check " << minVal << " >= " << a << " <= " << maxVal << " failed" ); } ///< general min/max clip -extern MsgFnc g_msgFnc; +extern std::function g_msgFnc; inline void msg( int level, const char* fmt, ... ) { @@ -598,7 +607,7 @@ inline void msg( int level, const char* fmt, ... ) std::unique_lock _lock( _msgMutex ); va_list args; va_start( args, fmt ); - (*g_msgFnc)( level, fmt, args ); + g_msgFnc( level, fmt, args ); va_end( args ); } } diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index a6b26e22a..71ce81237 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file ContextModelling.cpp @@ -55,7 +59,7 @@ vvc@hhi.fraunhofer.de namespace vvenc { -static const int prefix_ctx[8] = { 0, 0, 0, 3, 6, 10, 15, 21 }; +static const int prefix_ctx[7] = { 0, 0, 0, 3, 6, 10, 15 }; CoeffCodingContext::CoeffCodingContext( const TransformUnit& tu, ComponentID component, bool signHide, bool bdpcm ) : m_compID (component) @@ -227,35 +231,35 @@ void DeriveCtx::CtxSplit( const Partitioner& partitioner, unsigned& ctxSpl, unsi -void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) const +void MergeCtx::setMergeInfo( CodingUnit& cu, int candIdx ) const { CHECK( candIdx >= numValidMergeCand, "Merge candidate does not exist" ); - pu.regularMergeFlag = !(pu.ciip || pu.cu->geo); - pu.mergeFlag = true; - pu.mmvdMergeFlag = false; - pu.interDir = interDirNeighbours[candIdx]; - pu.cu->imv = (!pu.cu->geo && useAltHpelIf[candIdx]) ? IMV_HPEL : 0; - pu.mergeIdx = candIdx; - pu.mergeType = mrgTypeNeighbours[candIdx]; - pu.mv [REF_PIC_LIST_0] = mvFieldNeighbours[(candIdx << 1) + 0].mv; - pu.mv [REF_PIC_LIST_1] = mvFieldNeighbours[(candIdx << 1) + 1].mv; - pu.mvd [REF_PIC_LIST_0] = Mv(); - pu.mvd [REF_PIC_LIST_1] = Mv(); - pu.refIdx [REF_PIC_LIST_0] = mvFieldNeighbours[( candIdx << 1 ) + 0].refIdx; - pu.refIdx [REF_PIC_LIST_1] = mvFieldNeighbours[( candIdx << 1 ) + 1].refIdx; - pu.mvpIdx [REF_PIC_LIST_0] = NOT_VALID; - pu.mvpIdx [REF_PIC_LIST_1] = NOT_VALID; - pu.mvpNum [REF_PIC_LIST_0] = NOT_VALID; - pu.mvpNum [REF_PIC_LIST_1] = NOT_VALID; - pu.cu->BcwIdx = ( interDirNeighbours[candIdx] == 3 ) ? BcwIdx[candIdx] : BCW_DEFAULT; - - PU::restrictBiPredMergeCandsOne(pu); - pu.mcControl = 0; + cu.regularMergeFlag = !(cu.ciip || cu.geo); + cu.mergeFlag = true; + cu.mmvdMergeFlag = false; + cu.interDir = interDirNeighbours[candIdx]; + cu.imv = (!cu.geo && useAltHpelIf[candIdx]) ? IMV_HPEL : 0; + cu.mergeIdx = candIdx; + cu.mergeType = mrgTypeNeighbours[candIdx]; + cu.mv [REF_PIC_LIST_0] = mvFieldNeighbours[(candIdx << 1) + 0].mv; + cu.mv [REF_PIC_LIST_1] = mvFieldNeighbours[(candIdx << 1) + 1].mv; + cu.mvd [REF_PIC_LIST_0] = Mv(); + cu.mvd [REF_PIC_LIST_1] = Mv(); + cu.refIdx [REF_PIC_LIST_0] = mvFieldNeighbours[( candIdx << 1 ) + 0].refIdx; + cu.refIdx [REF_PIC_LIST_1] = mvFieldNeighbours[( candIdx << 1 ) + 1].refIdx; + cu.mvpIdx [REF_PIC_LIST_0] = NOT_VALID; + cu.mvpIdx [REF_PIC_LIST_1] = NOT_VALID; + cu.mvpNum [REF_PIC_LIST_0] = NOT_VALID; + cu.mvpNum [REF_PIC_LIST_1] = NOT_VALID; + cu.BcwIdx = ( interDirNeighbours[candIdx] == 3 ) ? BcwIdx[candIdx] : BCW_DEFAULT; + + CU::restrictBiPredMergeCandsOne(cu); + cu.mcControl = 0; } -void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const +void MergeCtx::setMmvdMergeCandiInfo(CodingUnit& cu, int candIdx) const { - const Slice &slice = *pu.cs->slice; + const Slice &slice = *cu.cs->slice; const int mvShift = MV_FRACTIONAL_BITS_DIFF; const int refMvdCands[8] = { 1 << mvShift , 2 << mvShift , 4 << mvShift , 8 << mvShift , 16 << mvShift , 32 << mvShift, 64 << mvShift , 128 << mvShift }; int fPosGroup = 0; @@ -273,7 +277,7 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const fPosStep = tempIdx / 4; fPosPosition = tempIdx - fPosStep * (4); int offset = refMvdCands[fPosStep]; - if ( pu.cu->slice->picHeader->disFracMMVD ) + if ( cu.slice->picHeader->disFracMMVD ) { offset <<= 2; } @@ -307,7 +311,7 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const } else if (abs(poc1 - currPoc) > abs(poc0 - currPoc)) { - const int scale = PU::getDistScaleFactor(currPoc, poc0, currPoc, poc1); + const int scale = CU::getDistScaleFactor(currPoc, poc0, currPoc, poc1); tempMv[1] = tempMv[0]; const bool isL0RefLongTerm = slice.getRefPic(REF_PIC_LIST_0, refList0)->isLongTerm; const bool isL1RefLongTerm = slice.getRefPic(REF_PIC_LIST_1, refList1)->isLongTerm; @@ -327,7 +331,7 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const } else { - const int scale = PU::getDistScaleFactor(currPoc, poc1, currPoc, poc0); + const int scale = CU::getDistScaleFactor(currPoc, poc1, currPoc, poc0); const bool isL0RefLongTerm = slice.getRefPic(REF_PIC_LIST_0, refList0)->isLongTerm; const bool isL1RefLongTerm = slice.getRefPic(REF_PIC_LIST_1, refList1)->isLongTerm; if (isL0RefLongTerm || isL1RefLongTerm) @@ -345,11 +349,11 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const tempMv[1] = tempMv[0].scaleMv(scale); } - pu.interDir = 3; - pu.mv[REF_PIC_LIST_0] = mmvdBaseMv[fPosBaseIdx][0].mv + tempMv[0]; - pu.refIdx[REF_PIC_LIST_0] = refList0; - pu.mv[REF_PIC_LIST_1] = mmvdBaseMv[fPosBaseIdx][1].mv + tempMv[1]; - pu.refIdx[REF_PIC_LIST_1] = refList1; + cu.interDir = 3; + cu.mv[REF_PIC_LIST_0] = mmvdBaseMv[fPosBaseIdx][0].mv + tempMv[0]; + cu.refIdx[REF_PIC_LIST_0] = refList0; + cu.mv[REF_PIC_LIST_1] = mmvdBaseMv[fPosBaseIdx][1].mv + tempMv[1]; + cu.refIdx[REF_PIC_LIST_1] = refList1; } else if (refList0 != -1) { @@ -369,11 +373,11 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const { tempMv[0] = Mv(0, -offset); } - pu.interDir = 1; - pu.mv[REF_PIC_LIST_0] = mmvdBaseMv[fPosBaseIdx][0].mv + tempMv[0]; - pu.refIdx[REF_PIC_LIST_0] = refList0; - pu.mv[REF_PIC_LIST_1] = Mv(0, 0); - pu.refIdx[REF_PIC_LIST_1] = -1; + cu.interDir = 1; + cu.mv[REF_PIC_LIST_0] = mmvdBaseMv[fPosBaseIdx][0].mv + tempMv[0]; + cu.refIdx[REF_PIC_LIST_0] = refList0; + cu.mv[REF_PIC_LIST_1] = Mv(0, 0); + cu.refIdx[REF_PIC_LIST_1] = -1; } else if (refList1 != -1) { @@ -393,39 +397,39 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) const { tempMv[1] = Mv(0, -offset); } - pu.interDir = 2; - pu.mv[REF_PIC_LIST_0] = Mv(0, 0); - pu.refIdx[REF_PIC_LIST_0] = -1; - pu.mv[REF_PIC_LIST_1] = mmvdBaseMv[fPosBaseIdx][1].mv + tempMv[1]; - pu.refIdx[REF_PIC_LIST_1] = refList1; + cu.interDir = 2; + cu.mv[REF_PIC_LIST_0] = Mv(0, 0); + cu.refIdx[REF_PIC_LIST_0] = -1; + cu.mv[REF_PIC_LIST_1] = mmvdBaseMv[fPosBaseIdx][1].mv + tempMv[1]; + cu.refIdx[REF_PIC_LIST_1] = refList1; } - pu.mmvdMergeFlag = true; - pu.mmvdMergeIdx = candIdx; - pu.mergeFlag = true; - pu.regularMergeFlag = true; - pu.mergeIdx = candIdx; - pu.mergeType = MRG_TYPE_DEFAULT_N; - pu.mvd[REF_PIC_LIST_0] = Mv(); - pu.mvd[REF_PIC_LIST_1] = Mv(); - pu.mvpIdx[REF_PIC_LIST_0] = NOT_VALID; - pu.mvpIdx[REF_PIC_LIST_1] = NOT_VALID; - pu.mvpNum[REF_PIC_LIST_0] = NOT_VALID; - pu.mvpNum[REF_PIC_LIST_1] = NOT_VALID; - pu.cu->imv = mmvdUseAltHpelIf[fPosBaseIdx] ? IMV_HPEL : 0; - - pu.cu->BcwIdx = (interDirNeighbours[fPosBaseIdx] == 3) ? BcwIdx[fPosBaseIdx] : BCW_DEFAULT; + cu.mmvdMergeFlag = true; + cu.mmvdMergeIdx = candIdx; + cu.mergeFlag = true; + cu.regularMergeFlag = true; + cu.mergeIdx = candIdx; + cu.mergeType = MRG_TYPE_DEFAULT_N; + cu.mvd[REF_PIC_LIST_0] = Mv(); + cu.mvd[REF_PIC_LIST_1] = Mv(); + cu.mvpIdx[REF_PIC_LIST_0] = NOT_VALID; + cu.mvpIdx[REF_PIC_LIST_1] = NOT_VALID; + cu.mvpNum[REF_PIC_LIST_0] = NOT_VALID; + cu.mvpNum[REF_PIC_LIST_1] = NOT_VALID; + cu.imv = mmvdUseAltHpelIf[fPosBaseIdx] ? IMV_HPEL : 0; + + cu.BcwIdx = (interDirNeighbours[fPosBaseIdx] == 3) ? BcwIdx[fPosBaseIdx] : BCW_DEFAULT; for (int refList = 0; refList < 2; refList++) { - if (pu.refIdx[refList] >= 0) + if (cu.refIdx[refList] >= 0) { - pu.mv[refList].clipToStorageBitDepth(); + cu.mv[refList].clipToStorageBitDepth(); } } - PU::restrictBiPredMergeCandsOne(pu); + CU::restrictBiPredMergeCandsOne(cu); } unsigned DeriveCtx::CtxMipFlag( const CodingUnit& cu ) const diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h index 28becb754..c1f8c9ba7 100644 --- a/source/Lib/CommonLib/ContextModelling.h +++ b/source/Lib/CommonLib/ContextModelling.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file ContextModelling.h * \brief Classes providing probability descriptions and contexts (header) */ @@ -63,7 +67,7 @@ struct CoeffCodingContext public: CoeffCodingContext( const TransformUnit& tu, ComponentID component, bool signHide, bool bdpcm = false ); public: - void initSubblock ( int SubsetId, bool sigGroupFlag = false ); + void initSubblock ( int SubsetId, bool sigGroupFlag = false ); public: void resetSigGroup () { m_sigCoeffGroupFlag.reset( m_subSetPos ); } void setSigGroup () { m_sigCoeffGroupFlag.set( m_subSetPos ); } @@ -451,8 +455,8 @@ struct MergeCtx { MergeCtx() : numValidMergeCand( 0 ), hasMergedCandList( false ) { for( unsigned i = 0; i < MRG_MAX_NUM_CANDS; i++ ) mrgTypeNeighbours[i] = MRG_TYPE_DEFAULT_N; } - void setMmvdMergeCandiInfo ( PredictionUnit& pu, int candIdx) const; - void setMergeInfo ( PredictionUnit& pu, int candIdx) const; + void setMmvdMergeCandiInfo ( CodingUnit& cu, int candIdx) const; + void setMergeInfo ( CodingUnit& cu, int candIdx) const; MvField mvFieldNeighbours [ MRG_MAX_NUM_CANDS << 1 ]; // double length for mv of both lists uint8_t BcwIdx [ MRG_MAX_NUM_CANDS ]; @@ -493,7 +497,7 @@ struct DeriveCtx inline static unsigned CtxQtCbf ( const ComponentID compID, const bool prevCbf = false, const int ispIdx = 0 ) { return ( ispIdx && isLuma( compID ) ) ? (2 + (int)prevCbf) : (((compID == COMP_Cr) && prevCbf) ? 1 : 0); } void CtxSplit ( const Partitioner& partitioner, unsigned& ctxSpl, unsigned& ctxQt, unsigned& ctxHv, unsigned& ctxHorBt, unsigned& ctxVerBt, const bool canSplit[6] ) const; unsigned CtxMipFlag ( const CodingUnit& cu ) const; - unsigned CtxInterDir ( const PredictionUnit& pu ) const { return ( 7 - ((Log2(pu.lumaSize().area()) + 1) >> 1) ); } + unsigned CtxInterDir ( const CodingUnit& cu ) const { return ( 7 - ((Log2(cu.lumaSize().area()) + 1) >> 1) ); } unsigned CtxModeConsFlag() const { diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 57f90a63a..4820454af 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Contexts.cpp diff --git a/source/Lib/CommonLib/Contexts.h b/source/Lib/CommonLib/Contexts.h index f5d026f67..159bbd73b 100644 --- a/source/Lib/CommonLib/Contexts.h +++ b/source/Lib/CommonLib/Contexts.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Contexts.h * \brief Classes providing probability descriptions and contexts (header) */ diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index e3e2b6402..247564dac 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -1,50 +1,54 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +------------------------------------------------------------------------------------------- */ + #include "DepQuant.h" #include "TrQuant.h" #include "CodingStructure.h" #include "UnitTools.h" +#include "CommonDefX86.h" #include @@ -149,9 +153,9 @@ namespace DQIntern void xUninitScanArrays (); private: bool m_scansInitialized; - NbInfoSbb* m_scanId2NbInfoSbbArray[ MAX_CU_SIZE_IDX ][ MAX_CU_SIZE_IDX ]; - NbInfoOut* m_scanId2NbInfoOutArray[ MAX_CU_SIZE_IDX ][ MAX_CU_SIZE_IDX ]; - TUParameters* m_tuParameters [ MAX_CU_SIZE_IDX ][ MAX_CU_SIZE_IDX ][ MAX_NUM_CH ]; + NbInfoSbb* m_scanId2NbInfoSbbArray[ MAX_TU_SIZE_IDX ][ MAX_TU_SIZE_IDX ]; + NbInfoOut* m_scanId2NbInfoOutArray[ MAX_TU_SIZE_IDX ][ MAX_TU_SIZE_IDX ]; + TUParameters* m_tuParameters [ MAX_TU_SIZE_IDX ][ MAX_TU_SIZE_IDX ][ MAX_NUM_CH ]; }; void Rom::xInitScanArrays() @@ -167,9 +171,9 @@ namespace DQIntern uint32_t raster2id[ MAX_CU_SIZE * MAX_CU_SIZE ]; ::memset(raster2id, 0, sizeof(raster2id)); - for( int hd = 0; hd < MAX_CU_SIZE_IDX; hd++ ) + for( int hd = 0; hd < MAX_TU_SIZE_IDX; hd++ ) { - for( int vd = 0; vd < MAX_CU_SIZE_IDX; vd++ ) + for( int vd = 0; vd < MAX_TU_SIZE_IDX; vd++ ) { if( (hd == 0 && vd <= 1) || (hd <= 1 && vd == 0) ) { @@ -312,9 +316,9 @@ namespace DQIntern { return; } - for( int hd = 0; hd < MAX_CU_SIZE_IDX; hd++ ) + for( int hd = 0; hd < MAX_TU_SIZE_IDX; hd++ ) { - for( int vd = 0; vd < MAX_CU_SIZE_IDX; vd++ ) + for( int vd = 0; vd < MAX_TU_SIZE_IDX; vd++ ) { NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd]; NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd]; @@ -1465,7 +1469,6 @@ namespace DQIntern } } - void DepQuant::quant( TransformUnit& tu, const CCoeffBuf& srcCoeff, const ComponentID compID, const QpParam& cQP, const double lambda, const Ctx& ctx, TCoeff& absSum, bool enableScalingLists, int* quantCoeff ) { CHECKD( tu.cs->sps->spsRExt.extendedPrecisionProcessing, "ext precision is not supported" ); @@ -1500,7 +1503,7 @@ namespace DQIntern } zeroOutforThres = zeroOut || ( 32 < tuPars.m_height || 32 < tuPars.m_width ); //===== find first test position ===== - int firstTestPos = numCoeff - 1; + int firstTestPos = std::min( tuPars.m_width, JVET_C0024_ZERO_OUT_TH ) * std::min( tuPars.m_height, JVET_C0024_ZERO_OUT_TH ) - 1; if( lfnstIdx > 0 && tu.mtsIdx[compID] != MTS_SKIP && width >= 4 && height >= 4 ) { firstTestPos = ( ( width == 4 && height == 4 ) || ( width == 8 && height == 8 ) ) ? 7 : 15 ; @@ -1524,8 +1527,62 @@ namespace DQIntern } else { - const TCoeff defaultTh = TCoeff( thres / ( defaultQuantisationCoefficient << 2 ) ); + const TCoeff defaultTh = TCoeff( thres / ( defaultQuantisationCoefficient << 2 ) ); + +#if ENABLE_SIMD_OPT_QUANT && defined( TARGET_SIMD_X86 ) + // if more than one 4x4 coding subblock is available, use SIMD to find first subblock with coefficient larger than threshold + if( firstTestPos >= 16 && tuPars.m_log2SbbWidth == 2 && tuPars.m_log2SbbHeight == 2 && read_x86_extension_flags() > SCALAR ) + { + const int sbbSize = tuPars.m_sbbSize; + // move the pointer to the beginning of the current subblock + firstTestPos -= ( sbbSize - 1 ); + + const __m128i xdfTh = _mm_set1_epi32( defaultTh ); + + // for each subblock + for( ; firstTestPos >= 0; firstTestPos -= sbbSize ) + { + // skip zeroed out blocks + // for 64-point transformation the coding order takes care of that + if( zeroOutforThres && ( tuPars.m_scanId2BlkPos[firstTestPos].x >= zeroOutWidth || tuPars.m_scanId2BlkPos[firstTestPos].y >= zeroOutHeight ) ) + { + continue; + } + // read first line of the subblock and check for coefficients larger than the threshold + // assumming the subblocks are dense 4x4 blocks in raster scan order with the stride of tuPars.m_width + int pos = tuPars.m_scanId2BlkPos[firstTestPos].idx; + __m128i xl0 = _mm_abs_epi32( _mm_loadu_si128( ( const __m128i* ) &tCoeff[pos] ) ); + __m128i xdf = _mm_cmpgt_epi32( xl0, xdfTh ); + + // same for the next line in the subblock + pos += tuPars.m_width; + xl0 = _mm_abs_epi32( _mm_loadu_si128( ( const __m128i* ) &tCoeff[pos] ) ); + xdf = _mm_or_si128( xdf, _mm_cmpgt_epi32( xl0, xdfTh ) ); + + // and the third line + pos += tuPars.m_width; + xl0 = _mm_abs_epi32( _mm_loadu_si128( ( const __m128i* ) &tCoeff[pos] ) ); + xdf = _mm_or_si128( xdf, _mm_cmpgt_epi32( xl0, xdfTh ) ); + + // and the last line + pos += tuPars.m_width; + xl0 = _mm_abs_epi32( _mm_loadu_si128( ( const __m128i* ) &tCoeff[pos] ) ); + xdf = _mm_or_si128( xdf, _mm_cmpgt_epi32( xl0, xdfTh ) ); + + // if any of the 16 comparisons were true, break, because this subblock contains a coefficient larger than threshold + if( !_mm_testz_si128( xdf, xdf ) ) break; + } + + if( firstTestPos >= 0 ) + { + // if a coefficient was found, advance the pointer to the end of the current subblock + // for the subsequent coefficient-wise refinement (C-impl after endif) + firstTestPos += sbbSize - 1; + } + } + +#endif for( ; firstTestPos >= 0; firstTestPos-- ) { if( zeroOutforThres && ( tuPars.m_scanId2BlkPos[firstTestPos].x >= zeroOutWidth || tuPars.m_scanId2BlkPos[firstTestPos].y >= zeroOutHeight ) ) continue; @@ -1547,16 +1604,15 @@ namespace DQIntern m_allStates[k].init(); } m_startState.init(); - - - int effectWidth = std::min(32, effWidth); - int effectHeight = std::min(32, effHeight); + + int effectWidth = std::min( 32, effWidth ); + int effectHeight = std::min( 32, effHeight ); for (int k = 0; k < 12; k++) { - m_allStates[k].effWidth = effectWidth; + m_allStates[k].effWidth = effectWidth; m_allStates[k].effHeight = effectHeight; } - m_startState.effWidth = effectWidth; + m_startState.effWidth = effectWidth; m_startState.effHeight = effectHeight; //===== populate trellis ===== @@ -1631,7 +1687,7 @@ void DepQuant::quant( TransformUnit& tu, const ComponentID compID, const CCoeffB CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = Log2(width); const uint32_t log2TrHeight = Log2(height); - const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); + const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (CU::isSepTree(*tu.cu) ? true : isLuma(compID)); const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied); static_cast(p)->quant( tu, pSrc, compID, cQP, Quant::m_dLambda, ctx, uiAbsSum, enableScalingLists, Quant::getQuantCoeff(scalingListType, qpRem, log2TrWidth, log2TrHeight) ); } @@ -1655,7 +1711,7 @@ void DepQuant::dequant( const TransformUnit& tu, CoeffBuf& dstCoeff, const Compo CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = Log2(width); const uint32_t log2TrHeight = Log2(height); - const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); + const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (CU::isSepTree(*tu.cu) ? true : isLuma(compID)); const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied); static_cast(p)->dequant( tu, dstCoeff, compID, cQP, enableScalingLists, Quant::getDequantCoeff(scalingListType, qpRem, log2TrWidth, log2TrHeight) ); } diff --git a/source/Lib/CommonLib/DepQuant.h b/source/Lib/CommonLib/DepQuant.h index d775986c2..70ac6bd17 100644 --- a/source/Lib/CommonLib/DepQuant.h +++ b/source/Lib/CommonLib/DepQuant.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include "CommonDef.h" diff --git a/source/Lib/CommonLib/HRD.h b/source/Lib/CommonLib/HRD.h new file mode 100644 index 000000000..f5e7c1926 --- /dev/null +++ b/source/Lib/CommonLib/HRD.h @@ -0,0 +1,162 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Frderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + + +#pragma once + +#include "Common.h" +#include "SEI.h" + +namespace vvenc { + +struct OlsHrdParams +{ + bool fixedPicRateGeneralFlag; + bool fixedPicRateWithinCvsFlag; + bool lowDelayHrdFlag; + + uint32_t elementDurationInTcMinus1; + uint32_t bitRateValueMinus1[MAX_CPB_CNT][2]; + uint32_t cpbSizeValueMinus1[MAX_CPB_CNT][2]; + uint32_t duCpbSizeValueMinus1[MAX_CPB_CNT][2]; + uint32_t duBitRateValueMinus1[MAX_CPB_CNT][2]; + bool cbrFlag[MAX_CPB_CNT][2]; + + OlsHrdParams() + : fixedPicRateGeneralFlag (false) + , fixedPicRateWithinCvsFlag (false) + , lowDelayHrdFlag (false) + , elementDurationInTcMinus1 (0) + { + memset( bitRateValueMinus1, 0, sizeof(bitRateValueMinus1)); + memset( cpbSizeValueMinus1, 0, sizeof(cpbSizeValueMinus1)); + memset( duCpbSizeValueMinus1, 0, sizeof(duCpbSizeValueMinus1)); + memset( duBitRateValueMinus1, 0, sizeof(duBitRateValueMinus1)); + memset( cbrFlag, 0, sizeof(cbrFlag)); + } +}; + +struct GeneralHrdParams +{ + uint32_t numUnitsInTick; + uint32_t timeScale; + bool generalNalHrdParamsPresent; + bool generalVclHrdParamsPresent; + bool generalSamePicTimingInAllOlsFlag; + uint32_t tickDivisorMinus2; + bool generalDecodingUnitHrdParamsPresent; + uint32_t bitRateScale; + uint32_t cpbSizeScale; + uint32_t cpbSizeDuScale; + uint32_t hrdCpbCntMinus1; + + GeneralHrdParams() + : generalNalHrdParamsPresent (false) + , generalVclHrdParamsPresent (false) + , generalSamePicTimingInAllOlsFlag (true) + , tickDivisorMinus2 (0) + , generalDecodingUnitHrdParamsPresent (false) + , bitRateScale (0) + , cpbSizeScale (0) + , cpbSizeDuScale (0) + , hrdCpbCntMinus1 (0) + {} + + bool operator==(const GeneralHrdParams& other) const + { + return (numUnitsInTick == other.numUnitsInTick + && timeScale == other.timeScale + && generalNalHrdParamsPresent == other.generalNalHrdParamsPresent + && generalVclHrdParamsPresent == other.generalVclHrdParamsPresent + && generalSamePicTimingInAllOlsFlag == other.generalSamePicTimingInAllOlsFlag + && generalDecodingUnitHrdParamsPresent == other.generalDecodingUnitHrdParamsPresent + && (generalDecodingUnitHrdParamsPresent ? (tickDivisorMinus2 == other.tickDivisorMinus2): 1) + && bitRateScale == other.bitRateScale + && cpbSizeScale == other.cpbSizeScale + && (generalDecodingUnitHrdParamsPresent ? (cpbSizeDuScale == other.cpbSizeDuScale) : 1) + && hrdCpbCntMinus1 == other.hrdCpbCntMinus1 + ); + } + + GeneralHrdParams& operator=(const GeneralHrdParams& input) + { + numUnitsInTick = input.numUnitsInTick; + timeScale = input.timeScale; + generalNalHrdParamsPresent = input.generalNalHrdParamsPresent; + generalVclHrdParamsPresent = input.generalVclHrdParamsPresent; + generalSamePicTimingInAllOlsFlag = input.generalSamePicTimingInAllOlsFlag; + generalDecodingUnitHrdParamsPresent = input.generalDecodingUnitHrdParamsPresent; + if (input.generalDecodingUnitHrdParamsPresent) + { + tickDivisorMinus2 = input.tickDivisorMinus2; + } + bitRateScale = input.bitRateScale; + cpbSizeScale = input.cpbSizeScale; + if (input.generalDecodingUnitHrdParamsPresent) + { + cpbSizeDuScale = input.cpbSizeDuScale; + } + hrdCpbCntMinus1 = input.hrdCpbCntMinus1; + return *this; + } +}; + +struct HRD +{ + HRD() + : bufferingPeriodInitialized (false) + , pictureTimingAvailable (false) + {}; + + GeneralHrdParams generalHrdParams; + OlsHrdParams olsHrdParams[MAX_TLAYER]; + bool bufferingPeriodInitialized; + bool pictureTimingAvailable; + SEIBufferingPeriod bufferingPeriodSEI; + SEIPictureTiming pictureTimingSEI; +}; + +} // namespace vvenc diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index e0f9ba809..7a8c5c32d 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Prediction.cpp @@ -85,6 +89,31 @@ void addBDOFAvgCore(const Pel* src0, int src0Stride, const Pel* src1, int src1St } } +void applyPROFCore(Pel* dst, int dstStride, const Pel* src, int srcStride, int width, int height, const Pel* gradX, const Pel* gradY, int gradStride, const int* dMvX, const int* dMvY, int dMvStride, const bool& bi, int shiftNum, Pel offset, const ClpRng& clpRng) +{ + int idx = 0; + const int dILimit = 1 << std::max(clpRng.bd + 1, 13); + for (int h = 0; h < height; h++) + { + for (int w = 0; w < width; w++) + { + int32_t dI = dMvX[idx] * gradX[w] + dMvY[idx] * gradY[w]; + dI = Clip3(-dILimit, dILimit - 1, dI); + dst[w] = src[w] + dI; + if (!bi) + { + dst[w] = (dst[w] + offset) >> shiftNum; + dst[w] = ClipPel(dst[w], clpRng); + } + idx++; + } + gradX += gradStride; + gradY += gradStride; + dst += dstStride; + src += srcStride; + } +} + template void gradFilterCore(const Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth) { @@ -212,30 +241,30 @@ void InterPrediction::init( RdCost* pcRdCost, ChromaFormat chFormat, const int c // Public member functions // ==================================================================================================================== -bool InterPrediction::xCheckIdenticalMotion( const PredictionUnit &pu ) const +bool InterPrediction::xCheckIdenticalMotion( const CodingUnit& cu ) const { - const Slice &slice = *pu.cs->slice; + const Slice &slice = *cu.cs->slice; - if( slice.isInterB() && !pu.cs->pps->weightedBiPred ) + if( slice.isInterB() && !cu.cs->pps->weightedBiPred ) { - if( pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 ) + if( cu.refIdx[0] >= 0 && cu.refIdx[1] >= 0 ) { - int RefPOCL0 = slice.getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->getPOC(); - int RefPOCL1 = slice.getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->getPOC(); + int RefPOCL0 = slice.getRefPic( REF_PIC_LIST_0, cu.refIdx[0] )->getPOC(); + int RefPOCL1 = slice.getRefPic( REF_PIC_LIST_1, cu.refIdx[1] )->getPOC(); if( RefPOCL0 == RefPOCL1 ) { - if( !pu.cu->affine ) + if( !cu.affine ) { - if( pu.mv[0] == pu.mv[1] ) + if( cu.mv[0] == cu.mv[1] ) { return true; } } else { - if ( (pu.cu->affineType == AFFINEMODEL_4PARAM && (pu.mvAffi[0][0] == pu.mvAffi[1][0]) && (pu.mvAffi[0][1] == pu.mvAffi[1][1])) - || (pu.cu->affineType == AFFINEMODEL_6PARAM && (pu.mvAffi[0][0] == pu.mvAffi[1][0]) && (pu.mvAffi[0][1] == pu.mvAffi[1][1]) && (pu.mvAffi[0][2] == pu.mvAffi[1][2])) ) + if ( (cu.affineType == AFFINEMODEL_4PARAM && (cu.mvAffi[0][0] == cu.mvAffi[1][0]) && (cu.mvAffi[0][1] == cu.mvAffi[1][1])) + || (cu.affineType == AFFINEMODEL_6PARAM && (cu.mvAffi[0][0] == cu.mvAffi[1][0]) && (cu.mvAffi[0][1] == cu.mvAffi[1][1]) && (cu.mvAffi[0][2] == cu.mvAffi[1][2])) ) { return true; } @@ -247,23 +276,21 @@ bool InterPrediction::xCheckIdenticalMotion( const PredictionUnit &pu ) const return false; } -void InterPrediction::xSubPuBDOF( const PredictionUnit& pu, PelUnitBuf& predBuf, const RefPicList& refPicList /*= REF_PIC_LIST_X*/) +void InterPrediction::xSubPuBDOF( const CodingUnit& cu, PelUnitBuf& predBuf, const RefPicList& refPicList /*= REF_PIC_LIST_X*/) { - // compute the location of the current PU - Position puPos = pu.lumaPos(); - Size puSize = pu.lumaSize(); - - PredictionUnit subPu; - subPu.cs = pu.cs; - subPu.cu = pu.cu; - subPu.mergeType = pu.mergeType; - subPu.mmvdMergeFlag = pu.mmvdMergeFlag; - subPu.mcControl = pu.mcControl; - subPu.mergeFlag = pu.mergeFlag; - subPu.ciip = pu.ciip; - subPu.mvRefine = pu.mvRefine; - subPu.refIdx[0] = pu.refIdx[0]; - subPu.refIdx[1] = pu.refIdx[1]; + Position puPos = cu.lumaPos(); + Size puSize = cu.lumaSize(); + + CodingUnit subCu = cu; // th we do not need all that stuff + subCu.cs = cu.cs; + subCu.mergeType = cu.mergeType; + subCu.mmvdMergeFlag = cu.mmvdMergeFlag; + subCu.mcControl = cu.mcControl; + subCu.mergeFlag = cu.mergeFlag; + subCu.ciip = cu.ciip; + subCu.mvRefine = cu.mvRefine; + subCu.refIdx[0] = cu.refIdx[0]; + subCu.refIdx[1] = cu.refIdx[1]; const int yEnd = puPos.y + puSize.height; const int xEnd = puPos.x + puSize.width; @@ -273,120 +300,120 @@ void InterPrediction::xSubPuBDOF( const PredictionUnit& pu, PelUnitBuf& predBuf, { for (int x = puPos.x; x < xEnd; x += dx) { - const MotionInfo &curMi = pu.getMotionInfo(Position{ x, y }); + const MotionInfo &curMi = cu.getMotionInfo(Position{ x, y }); - subPu.UnitArea::operator=(UnitArea(pu.chromaFormat, Area(x, y, dx, dy))); - subPu = curMi; - PelUnitBuf subPredBuf = predBuf.subBuf(UnitAreaRelative(pu, subPu)); + subCu.UnitArea::operator=(UnitArea(cu.chromaFormat, Area(x, y, dx, dy))); + subCu = curMi; + PelUnitBuf subPredBuf = predBuf.subBuf(UnitAreaRelative(cu, subCu)); - motionCompensation(subPu, subPredBuf, refPicList); + motionCompensation(subCu, subPredBuf, refPicList); } } } -void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& refPicList, PelUnitBuf& pcYuvPred, const bool bi, const bool bdofApplied) +void InterPrediction::xPredInterUni(const CodingUnit& cu, const RefPicList& refPicList, PelUnitBuf& pcYuvPred, const bool bi, const bool bdofApplied) { - int iRefIdx = pu.refIdx[refPicList]; + int iRefIdx = cu.refIdx[refPicList]; Mv mv[3]; bool isIBC = false; - if (pu.cu->affine) + if (cu.affine) { CHECK(iRefIdx < 0, "iRefIdx incorrect."); - mv[0] = pu.mvAffi[refPicList][0]; - mv[1] = pu.mvAffi[refPicList][1]; - mv[2] = pu.mvAffi[refPicList][2]; + mv[0] = cu.mvAffi[refPicList][0]; + mv[1] = cu.mvAffi[refPicList][1]; + mv[2] = cu.mvAffi[refPicList][2]; } else { - mv[0] = pu.mv[refPicList]; - clipMv(mv[0], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + mv[0] = cu.mv[refPicList]; + clipMv(mv[0], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); } for( uint32_t comp = COMP_Y; comp < pcYuvPred.bufs.size(); comp++ ) { - bool luma = pu.mcControl > 3 ? false : true; - bool chroma = (pu.mcControl >> 1) == 1 ? false : true; + bool luma = cu.mcControl > 3 ? false : true; + bool chroma = (cu.mcControl >> 1) == 1 ? false : true; const ComponentID compID = ComponentID( comp ); if (compID == COMP_Y && !luma) continue; if (compID != COMP_Y && !chroma) continue; - if (pu.cu->affine) + if (cu.affine) { - xPredAffineBlk(compID, pu, pu.cu->slice->getRefPic(refPicList, iRefIdx), mv, pcYuvPred, bi, pu.cu->slice->clpRngs[compID], refPicList); + xPredAffineBlk(compID, cu, cu.slice->getRefPic(refPicList, iRefIdx), mv, pcYuvPred, bi, cu.slice->clpRngs[compID], refPicList); } else { - xPredInterBlk(compID, pu, pu.cu->slice->getRefPic(refPicList, iRefIdx), mv[0], pcYuvPred, bi, pu.cu->slice->clpRngs[compID], bdofApplied, isIBC, refPicList); + xPredInterBlk(compID, cu, cu.slice->getRefPic(refPicList, iRefIdx), mv[0], pcYuvPred, bi, cu.slice->clpRngs[compID], bdofApplied, isIBC, refPicList); } } } -void InterPrediction::xPredInterBi( const PredictionUnit& pu, PelUnitBuf& yuvPred, const bool bdofApplied ) +void InterPrediction::xPredInterBi( const CodingUnit& cu, PelUnitBuf& yuvPred, const bool bdofApplied ) { - CHECK( !pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && ( pu.lwidth() + pu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" ); + CHECK( !cu.affine && cu.refIdx[0] >= 0 && cu.refIdx[1] >= 0 && ( cu.lwidth() + cu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" ); PelUnitBuf puBuf[NUM_REF_PIC_LIST_01]; for (uint32_t refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) { - if( pu.refIdx[refList] < 0) + if( cu.refIdx[refList] < 0) { continue; } RefPicList refPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); - CHECK(CU::isIBC(*pu.cu) && refPicList != REF_PIC_LIST_0, "Invalid interdir for ibc mode"); - CHECK(CU::isIBC(*pu.cu) && pu.refIdx[refList] != MAX_NUM_REF, "Invalid reference index for ibc mode"); - CHECK((CU::isInter(*pu.cu) && pu.refIdx[refList] >= pu.cs->slice->numRefIdx[ refPicList ]), "Invalid reference index"); + CHECK(CU::isIBC(cu) && refPicList != REF_PIC_LIST_0, "Invalid interdir for ibc mode"); + CHECK(CU::isIBC(cu) && cu.refIdx[refList] != MAX_NUM_REF, "Invalid reference index for ibc mode"); + CHECK((CU::isInter(cu) && cu.refIdx[refList] >= cu.cs->slice->numRefIdx[ refPicList ]), "Invalid reference index"); - puBuf[refList] = m_yuvPred[refList].getCompactBuf( pu ); + puBuf[refList] = m_yuvPred[refList].getCompactBuf( cu ); - if( pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 ) + if( cu.refIdx[0] >= 0 && cu.refIdx[1] >= 0 ) { - xPredInterUni ( pu, refPicList, puBuf[refList], true, bdofApplied ); + xPredInterUni ( cu, refPicList, puBuf[refList], true, bdofApplied ); } else { - xPredInterUni( pu, refPicList, puBuf[refList], pu.cu->geo, bdofApplied ); + xPredInterUni( cu, refPicList, puBuf[refList], cu.geo, bdofApplied ); } } - xWeightedAverage( pu, puBuf[0], puBuf[1], yuvPred, bdofApplied ); + xWeightedAverage( cu, puBuf[0], puBuf[1], yuvPred, bdofApplied ); } -void InterPrediction::motionCompensationIBC( PredictionUnit &pu, PelUnitBuf& predBuf ) +void InterPrediction::motionCompensationIBC( CodingUnit& cu, PelUnitBuf& predBuf ) { // dual tree handling for IBC as the only ref - xPredInterUni(pu, REF_PIC_LIST_0, predBuf, false, false ); + xPredInterUni(cu, REF_PIC_LIST_0, predBuf, false, false ); } -bool InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf& predBuf, const RefPicList refPicList) +bool InterPrediction::motionCompensation( CodingUnit& cu, PelUnitBuf& predBuf, const RefPicList refPicList) { bool ret = false; if( refPicList != REF_PIC_LIST_X ) { - xPredInterUni( pu, refPicList, predBuf, false, false ); + xPredInterUni( cu, refPicList, predBuf, false, false ); } else { - CHECK( !pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && ( pu.lwidth() + pu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" ); + CHECK( !cu.affine && cu.refIdx[0] >= 0 && cu.refIdx[1] >= 0 && ( cu.lwidth() + cu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" ); bool bdofApplied = false; - if( pu.cs->sps->BDOF && ( !pu.cs->picHeader->disBdofFlag ) ) + if( cu.cs->sps->BDOF && ( !cu.cs->picHeader->disBdofFlag ) ) { - if (pu.cu->affine || m_subPuMC || pu.ciip ) + if (cu.affine || m_subPuMC || cu.ciip ) { bdofApplied = false; } else { - if (PU::isBiPredFromDifferentDirEqDistPoc(pu) - && (pu.Y().height >= 8) - && (pu.Y().width >= 8) - && ((pu.Y().height * pu.Y().width) >= 128) - && !(pu.cu->smvdMode) - && !(pu.cu->cs->sps->BCW && pu.cu->BcwIdx != BCW_DEFAULT) - && !(((pu.mcControl & 1) == 1) && pu.mmvdMergeFlag) + if (CU::isBiPredFromDifferentDirEqDistPoc(cu) + && (cu.Y().height >= 8) + && (cu.Y().width >= 8) + && ((cu.Y().height * cu.Y().width) >= 128) + && !(cu.smvdMode) + && !(cu.cs->sps->BCW && cu.BcwIdx != BCW_DEFAULT) + && !(((cu.mcControl & 1) == 1) && cu.mmvdMergeFlag) ) { bdofApplied = true; @@ -395,43 +422,42 @@ bool InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf& predBu } bool dmvrApplied = false; - dmvrApplied = (pu.mvRefine) && PU::checkDMVRCondition(pu); - if ((pu.lumaSize().width > MAX_BDOF_APPLICATION_REGION || pu.lumaSize().height > MAX_BDOF_APPLICATION_REGION) && pu.mergeType != MRG_TYPE_SUBPU_ATMVP && (bdofApplied && !dmvrApplied)) + dmvrApplied = (cu.mvRefine) && CU::checkDMVRCondition(cu); + if ((cu.lumaSize().width > MAX_BDOF_APPLICATION_REGION || cu.lumaSize().height > MAX_BDOF_APPLICATION_REGION) && cu.mergeType != MRG_TYPE_SUBPU_ATMVP && (bdofApplied && !dmvrApplied)) { - xSubPuBDOF( pu, predBuf, refPicList ); + xSubPuBDOF( cu, predBuf, refPicList ); } - else if (pu.mergeType != MRG_TYPE_DEFAULT_N /*&& pu.mergeType != MRG_TYPE_IBC*/) + else if (cu.mergeType != MRG_TYPE_DEFAULT_N /*&& cu.mergeType != MRG_TYPE_IBC*/) { - xSubPuMC(pu, predBuf, refPicList); + xSubPuMC(cu, predBuf, refPicList); } - else if( xCheckIdenticalMotion( pu ) ) + else if( xCheckIdenticalMotion( cu ) ) { - xPredInterUni( pu, REF_PIC_LIST_0, predBuf, false, false ); + xPredInterUni( cu, REF_PIC_LIST_0, predBuf, false, false ); } else if (dmvrApplied) { - xProcessDMVR( pu, predBuf, pu.cu->slice->clpRngs, bdofApplied ); + xProcessDMVR( cu, predBuf, cu.slice->clpRngs, bdofApplied ); } else { - xPredInterBi( pu, predBuf, bdofApplied ); + xPredInterBi( cu, predBuf, bdofApplied ); } DTRACE( g_trace_ctx, D_MOT_COMP, "BIDOF=%d, DMVR=%d\n", bdofApplied, dmvrApplied ); ret = bdofApplied || dmvrApplied; } - DTRACE( g_trace_ctx, D_MOT_COMP, "MV=%d,%d\n", pu.mv[0].hor, pu.mv[0].ver ); - DTRACE( g_trace_ctx, D_MOT_COMP, "MV=%d,%d\n", pu.mv[1].hor, pu.mv[1].ver ); - DTRACE_PEL_BUF( D_MOT_COMP, predBuf.Y(), pu, pu.cu->predMode, COMP_Y ); - DTRACE_PEL_BUF( D_MOT_COMP, predBuf.Cb(), pu, pu.cu->predMode, COMP_Cb ); - DTRACE_PEL_BUF( D_MOT_COMP, predBuf.Cr(), pu, pu.cu->predMode, COMP_Cr ); + DTRACE( g_trace_ctx, D_MOT_COMP, "MV=%d,%d\n", cu.mv[0].hor, cu.mv[0].ver ); + DTRACE( g_trace_ctx, D_MOT_COMP, "MV=%d,%d\n", cu.mv[1].hor, cu.mv[1].ver ); + DTRACE_PEL_BUF( D_MOT_COMP, predBuf.Y(), cu, cu.predMode, COMP_Y ); + DTRACE_PEL_BUF( D_MOT_COMP, predBuf.Cb(), cu, cu.predMode, COMP_Cb ); + DTRACE_PEL_BUF( D_MOT_COMP, predBuf.Cr(), cu, cu.predMode, COMP_Cr ); return ret; } -void InterPrediction::xSubPuMC(PredictionUnit& pu, PelUnitBuf& predBuf, const RefPicList& eRefPicList /*= REF_PIC_LIST_X*/) +void InterPrediction::xSubPuMC(CodingUnit& cu, PelUnitBuf& predBuf, const RefPicList& eRefPicList /*= REF_PIC_LIST_X*/) { - // compute the location of the current PU - Position puPos = pu.lumaPos(); - Size puSize = pu.lumaSize(); + Position puPos = cu.lumaPos(); + Size puSize = cu.lumaSize(); int numPartLine, numPartCol, puHeight, puWidth; { @@ -441,14 +467,12 @@ void InterPrediction::xSubPuMC(PredictionUnit& pu, PelUnitBuf& predBuf, const Re puWidth = numPartLine == 1 ? puSize.width : 1 << ATMVP_SUB_BLOCK_SIZE; } - PredictionUnit subPu; + CodingUnit subCu = cu; + subCu.cs = cu.cs; + subCu.mergeType = MRG_TYPE_DEFAULT_N; - subPu.cs = pu.cs; - subPu.cu = pu.cu; - subPu.mergeType = MRG_TYPE_DEFAULT_N; - - bool isAffine = pu.cu->affine; - subPu.cu->affine = false; + bool isAffine = cu.affine; + subCu.affine = false; // join sub-pus containing the same motion bool verMC = puSize.height > puSize.width; @@ -459,9 +483,9 @@ void InterPrediction::xSubPuMC(PredictionUnit& pu, PelUnitBuf& predBuf, const Re int fstStep = (!verMC ? puHeight : puWidth); int secStep = (!verMC ? puWidth : puHeight); - pu.refIdx[0] = 0; - pu.refIdx[1] = pu.cs->slice->sliceType == B_SLICE ? 0 : -1; - bool scaled = false;//!PU::isRefPicSameSize(pu); + cu.refIdx[0] = 0; + cu.refIdx[1] = cu.cs->slice->sliceType == B_SLICE ? 0 : -1; + bool scaled = false;//!CU::isRefPicSameSize(cu); m_subPuMC = true; @@ -471,14 +495,14 @@ void InterPrediction::xSubPuMC(PredictionUnit& pu, PelUnitBuf& predBuf, const Re { int x = !verMC ? secDim : fstDim; int y = !verMC ? fstDim : secDim; - const MotionInfo &curMi = pu.getMotionInfo(Position{ x, y }); + const MotionInfo &curMi = cu.getMotionInfo(Position{ x, y }); int length = secStep; int later = secDim + secStep; while (later < secEnd) { - const MotionInfo &laterMi = !verMC ? pu.getMotionInfo(Position{ later, fstDim }) : pu.getMotionInfo(Position{ fstDim, later }); + const MotionInfo &laterMi = !verMC ? cu.getMotionInfo(Position{ later, fstDim }) : cu.getMotionInfo(Position{ fstDim, later }); if (!scaled && laterMi == curMi) { length += secStep; @@ -492,18 +516,18 @@ void InterPrediction::xSubPuMC(PredictionUnit& pu, PelUnitBuf& predBuf, const Re int dx = !verMC ? length : puWidth; int dy = !verMC ? puHeight : length; - subPu.UnitArea::operator=(UnitArea(pu.chromaFormat, Area(x, y, dx, dy))); - subPu = curMi; - PelUnitBuf subPredBuf = predBuf.subBuf(UnitAreaRelative(pu, subPu)); - subPu.mcControl = (pu.mcControl >> 1) << 1; - subPu.mvRefine = false; - motionCompensation(subPu, subPredBuf, eRefPicList); + subCu.UnitArea::operator=(UnitArea(cu.chromaFormat, Area(x, y, dx, dy))); + subCu = curMi; + PelUnitBuf subPredBuf = predBuf.subBuf(UnitAreaRelative(cu, subCu)); + subCu.mcControl = (cu.mcControl >> 1) << 1; + subCu.mvRefine = false; + motionCompensation(subCu, subPredBuf, eRefPicList); secDim = later - secStep; } } m_subPuMC = false; - pu.cu->affine = isAffine; + cu.affine = isAffine; } InterPredInterpolation::InterPredInterpolation() @@ -559,10 +583,12 @@ void InterPredInterpolation::init() for( uint32_t i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS_SIGNAL; i++ ) { m_filteredBlockTmp[i][c] = ( Pel* ) xMalloc( Pel, ( extWidth + 4 ) * ( extHeight + 7 + 4 ) ); + VALGRIND_MEMCLEAR( m_filteredBlockTmp[i][c], sizeof( Pel ) * (extWidth + 4) * (extHeight + 7 + 4) ); for( uint32_t j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS_SIGNAL; j++ ) { m_filteredBlock[i][j][c] = ( Pel* ) xMalloc( Pel, extWidth * extHeight ); + VALGRIND_MEMCLEAR( m_filteredBlock[i][j][c], sizeof( Pel ) * extWidth * extHeight ); } } } @@ -572,11 +598,17 @@ void InterPredInterpolation::init() m_gradX1 = (Pel*)xMalloc(Pel, BDOF_TEMP_BUFFER_SIZE); m_gradY1 = (Pel*)xMalloc(Pel, BDOF_TEMP_BUFFER_SIZE); + VALGRIND_MEMCLEAR( m_gradX0, sizeof( Pel ) * BDOF_TEMP_BUFFER_SIZE ); + VALGRIND_MEMCLEAR( m_gradY0, sizeof( Pel ) * BDOF_TEMP_BUFFER_SIZE ); + VALGRIND_MEMCLEAR( m_gradX1, sizeof( Pel ) * BDOF_TEMP_BUFFER_SIZE ); + VALGRIND_MEMCLEAR( m_gradY1, sizeof( Pel ) * BDOF_TEMP_BUFFER_SIZE ); + m_if.initInterpolationFilter( true ); - xFpAddBDOFAvg4 = addBDOFAvgCore; xFpBDOFGradFilter = gradFilterCore; - xFpCalcBDOFSums = calcBDOFSumsCore; + xFpProfGradFilter = gradFilterCore; + xFpApplyPROF = applyPROFCore; + #if ENABLE_SIMD_OPT_BDOF initInterPredictionX86(); #endif @@ -585,10 +617,11 @@ void InterPredInterpolation::init() { const int MVBUFFER_SIZE = MAX_CU_SIZE / MIN_PU_SIZE; m_storedMv = new Mv[MVBUFFER_SIZE*MVBUFFER_SIZE]; + VALGRIND_MEMCLEAR( m_storedMv, sizeof( Mv ) * MVBUFFER_SIZE * MVBUFFER_SIZE ); } } -void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const PredictionUnit& pu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng +void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const CodingUnit& cu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng , const bool bdofApplied , const bool isIBC , const RefPicList refPicList @@ -599,7 +632,7 @@ void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const Pre , const int32_t srcPadStride ) { - const ChromaFormat chFmt = pu.chromaFormat; + const ChromaFormat chFmt = cu.chromaFormat; const bool rndRes = !bi; int shiftHor = MV_FRACTIONAL_BITS_INTERNAL + getComponentScaleX(compID, chFmt); @@ -607,9 +640,9 @@ void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const Pre bool wrapRef = false; Mv mv(_mv); - if( !isIBC && pu.cs->pcv->wrapArround ) + if( !isIBC && cu.cs->pcv->wrapArround ) { - wrapRef = wrapClipMv( mv, pu.blocks[0].pos(), pu.blocks[0].size(), *pu.cs); + wrapRef = wrapClipMv( mv, cu.blocks[0].pos(), cu.blocks[0].size(), *cu.cs); } int xFrac = mv.hor & ((1 << shiftHor) - 1); @@ -627,7 +660,7 @@ void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const Pre } else { - Position offset = pu.blocks[compID].pos().offset( mv.hor >> shiftHor, mv.ver >> shiftVer ); + Position offset = cu.blocks[compID].pos().offset( mv.hor >> shiftHor, mv.ver >> shiftVer ); refBuf = (wrapRef) ? refPic->getRecoWrapBuf( compID ) : refPic->getRecoBuf( compID ); refBuf.buf += offset.x; refBuf.buf += offset.y * refBuf.stride; @@ -653,7 +686,7 @@ void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const Pre dstBuf.stride = width; dstBuf.buf = m_filteredBlockTmp[2 + refPicList][compID] + 2 * dstBuf.stride + 2; } - bool useAltHpelIf = pu.cu->imv == IMV_HPEL; + bool useAltHpelIf = cu.imv == IMV_HPEL; if( yFrac == 0 ) { @@ -687,7 +720,7 @@ void InterPredInterpolation::xPredInterBlk ( const ComponentID compID, const Pre } else { - PelBuf tmpBuf( m_filteredBlockTmp[0][compID], dmvrWidth ? dmvrWidth : dstBuf.stride, dmvrWidth ? Size( dmvrWidth, dmvrHeight ) : pu.blocks[compID].size() ); + PelBuf tmpBuf( m_filteredBlockTmp[0][compID], dmvrWidth ? dmvrWidth : dstBuf.stride, dmvrWidth ? Size( dmvrWidth, dmvrHeight ) : cu.blocks[compID].size() ); m_if.filterHor(compID, (Pel*)refBuf.buf - ((vFilterSize >> 1) - 1) * refBuf.stride, refBuf.stride, tmpBuf.buf, tmpBuf.stride, backupWidth, backupHeight + vFilterSize - 1, xFrac, false, chFmt, clpRng, useAltHpelIf, bilinearMC, bilinearMC); m_if.filterVer(compID, (Pel*)tmpBuf.buf + ((vFilterSize >> 1) - 1) * tmpBuf.stride, tmpBuf.stride, dstBuf.buf, dstBuf.stride, backupWidth, backupHeight, yFrac, false, rndRes, chFmt, clpRng, useAltHpelIf, bilinearMC, bilinearMC); @@ -791,6 +824,12 @@ void InterPredInterpolation::xApplyBDOF( PelBuf& yuvDst, const ClpRng& clpRng ) const int offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS; const int limit = (1 << 4) - 1; + if( xFpBiDirOptFlow ) + { + xFpBiDirOptFlow( srcY0, srcY1, gradX0, gradX1, gradY0, gradY1, width, height, dstY, dstStride, shiftNum, offset, limit, clpRng, bitDepth ); + return; + } + int xUnit = (width >> 2); int yUnit = (height >> 2); @@ -813,7 +852,7 @@ void InterPredInterpolation::xApplyBDOF( PelBuf& yuvDst, const ClpRng& clpRng ) const Pel* SrcY1Tmp = srcY1 + (xu << 2) + (yu << 2) * src1Stride; const Pel* SrcY0Tmp = srcY0 + (xu << 2) + (yu << 2) * src0Stride; - xFpCalcBDOFSums(SrcY0Tmp, SrcY1Tmp, pGradX0Tmp, pGradX1Tmp, pGradY0Tmp, pGradY1Tmp, xu, yu, src0Stride, src1Stride, widthG, bitDepth, &sumAbsGX, &sumAbsGY, &sumDIX, &sumDIY, &sumSignGY_GX); + calcBDOFSumsCore(SrcY0Tmp, SrcY1Tmp, pGradX0Tmp, pGradX1Tmp, pGradY0Tmp, pGradY1Tmp, xu, yu, src0Stride, src1Stride, widthG, bitDepth, &sumAbsGX, &sumAbsGY, &sumDIX, &sumDIY, &sumSignGY_GX); tmpx = (sumAbsGX == 0 ? 0 : xRightShiftMSB(sumDIX << 2, sumAbsGX)); tmpx = Clip3(-limit, limit, tmpx); @@ -832,20 +871,20 @@ void InterPredInterpolation::xApplyBDOF( PelBuf& yuvDst, const ClpRng& clpRng ) gradY1 = m_gradY1 + offsetPos + ((yu*widthG + xu) << 2); dstY0 = dstY + ((yu*dstStride + xu) << 2); - xFpAddBDOFAvg4(srcY0Temp, src0Stride, srcY1Temp, src1Stride, dstY0, dstStride, gradX0, gradX1, gradY0, gradY1, widthG, (1 << 2), (1 << 2), tmpx, tmpy, shiftNum, offset, clpRng); + addBDOFAvgCore(srcY0Temp, src0Stride, srcY1Temp, src1Stride, dstY0, dstStride, gradX0, gradX1, gradY0, gradY1, widthG, (1 << 2), (1 << 2), tmpx, tmpy, shiftNum, offset, clpRng); } // xu } // yu } -void InterPredInterpolation::xWeightedAverage( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const bool bdofApplied ) +void InterPredInterpolation::xWeightedAverage( const CodingUnit& cu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const bool bdofApplied ) { - const bool lumaOnly = (pu.mcControl >> 1) == 1; - const bool chromaOnly = pu.mcControl > 3; + const bool lumaOnly = (cu.mcControl >> 1) == 1; + const bool chromaOnly = cu.mcControl > 3; CHECK((chromaOnly && lumaOnly), "should not happen"); - const ClpRngs& clpRngs = pu.cu->slice->clpRngs; - const int iRefIdx0 = pu.refIdx[0]; - const int iRefIdx1 = pu.refIdx[1]; + const ClpRngs& clpRngs = cu.slice->clpRngs; + const int iRefIdx0 = cu.refIdx[0]; + const int iRefIdx1 = cu.refIdx[1]; if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) { @@ -864,7 +903,7 @@ void InterPredInterpolation::xWeightedAverage( const PredictionUnit& pu, const C } else if( iRefIdx0 >= 0 && iRefIdx1 < 0 ) { - if (pu.cu->geo) + if (cu.geo) { pcYuvDst.copyFrom(pcYuvSrc0); } @@ -875,7 +914,7 @@ void InterPredInterpolation::xWeightedAverage( const PredictionUnit& pu, const C } else if( iRefIdx0 < 0 && iRefIdx1 >= 0 ) { - if (pu.cu->geo) + if (cu.geo) { pcYuvDst.copyFrom(pcYuvSrc1); } @@ -886,50 +925,50 @@ void InterPredInterpolation::xWeightedAverage( const PredictionUnit& pu, const C } } -void InterPrediction::motionCompensationGeo(PredictionUnit &pu, PelUnitBuf& predBuf, const MergeCtx &geoMrgCtx) +void InterPrediction::motionCompensationGeo(CodingUnit& cu, PelUnitBuf& predBuf, const MergeCtx &geoMrgCtx) { - const ClpRngs & clpRngs = pu.cu->slice->clpRngs; - const UnitArea localUnitArea(pu.chromaFormat, Area(0, 0, pu.lwidth(), pu.lheight())); + const ClpRngs & clpRngs = cu.slice->clpRngs; + const UnitArea localUnitArea(cu.chromaFormat, Area(0, 0, cu.lwidth(), cu.lheight())); PelUnitBuf tmpGeoBuf0 = m_geoPartBuf[0].getBuf(localUnitArea); PelUnitBuf tmpGeoBuf1 = m_geoPartBuf[1].getBuf(localUnitArea); - geoMrgCtx.setMergeInfo(pu, pu.geoMergeIdx0); - PU::spanMotionInfo(pu); - motionCompensation(pu, tmpGeoBuf0, REF_PIC_LIST_X); // TODO: check 4:0:0 interaction with weighted prediction. + geoMrgCtx.setMergeInfo(cu, cu.geoMergeIdx0); + CU::spanMotionInfo(cu); + motionCompensation(cu, tmpGeoBuf0, REF_PIC_LIST_X); // TODO: check 4:0:0 interaction with weighted prediction. - geoMrgCtx.setMergeInfo(pu, pu.geoMergeIdx1); - PU::spanMotionInfo(pu); - motionCompensation(pu, tmpGeoBuf1, REF_PIC_LIST_X); // TODO: check 4:0:0 interaction with weighted prediction. + geoMrgCtx.setMergeInfo(cu, cu.geoMergeIdx1); + CU::spanMotionInfo(cu); + motionCompensation(cu, tmpGeoBuf1, REF_PIC_LIST_X); // TODO: check 4:0:0 interaction with weighted prediction. - weightedGeoBlk(clpRngs, pu, pu.geoSplitDir, isChromaEnabled(pu.chromaFormat) ? MAX_NUM_CH : CH_L, predBuf, tmpGeoBuf0, + weightedGeoBlk(clpRngs, cu, cu.geoSplitDir, isChromaEnabled(cu.chromaFormat) ? MAX_NUM_CH : CH_L, predBuf, tmpGeoBuf0, tmpGeoBuf1); } -void InterPredInterpolation::weightedGeoBlk(const ClpRngs &clpRngs, PredictionUnit &pu, const uint8_t splitDir, +void InterPredInterpolation::weightedGeoBlk(const ClpRngs &clpRngs, CodingUnit& cu, const uint8_t splitDir, int32_t channel, PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1) { if (channel == CH_L) { - m_if.weightedGeoBlk(clpRngs,pu, pu.lumaSize().width, pu.lumaSize().height, COMP_Y, splitDir, predDst, predSrc0, + m_if.weightedGeoBlk(clpRngs,cu, cu.lumaSize().width, cu.lumaSize().height, COMP_Y, splitDir, predDst, predSrc0, predSrc1); } else if (channel == CH_C) { - m_if.weightedGeoBlk(clpRngs, pu, pu.chromaSize().width, pu.chromaSize().height, COMP_Cb, splitDir, predDst, predSrc0, + m_if.weightedGeoBlk(clpRngs, cu, cu.chromaSize().width, cu.chromaSize().height, COMP_Cb, splitDir, predDst, predSrc0, predSrc1); - m_if.weightedGeoBlk(clpRngs, pu, pu.chromaSize().width, pu.chromaSize().height, COMP_Cr, splitDir, predDst, predSrc0, + m_if.weightedGeoBlk(clpRngs, cu, cu.chromaSize().width, cu.chromaSize().height, COMP_Cr, splitDir, predDst, predSrc0, predSrc1); } else { - m_if.weightedGeoBlk(clpRngs, pu, pu.lumaSize().width, pu.lumaSize().height, COMP_Y, splitDir, predDst, predSrc0, + m_if.weightedGeoBlk(clpRngs, cu, cu.lumaSize().width, cu.lumaSize().height, COMP_Y, splitDir, predDst, predSrc0, predSrc1); - if (isChromaEnabled(pu.chromaFormat)) + if (isChromaEnabled(cu.chromaFormat)) { - m_if.weightedGeoBlk(clpRngs, pu, pu.chromaSize().width, pu.chromaSize().height, COMP_Cb, splitDir, predDst, + m_if.weightedGeoBlk(clpRngs, cu, cu.chromaSize().width, cu.chromaSize().height, COMP_Cb, splitDir, predDst, predSrc0, predSrc1); - m_if.weightedGeoBlk(clpRngs, pu, pu.chromaSize().width, pu.chromaSize().height, COMP_Cr, splitDir, predDst, + m_if.weightedGeoBlk(clpRngs, cu, cu.chromaSize().width, cu.chromaSize().height, COMP_Cr, splitDir, predDst, predSrc0, predSrc1); } } @@ -951,7 +990,6 @@ void DMVR::destroy() m_yuvPred[i].destroy(); m_yuvPad[i].destroy(); m_yuvTmp[i].destroy(); - m_yuvRef[i].destroy(); } m_pcRdCost = nullptr; } @@ -969,70 +1007,60 @@ void DMVR::init( RdCost* pcRdCost, const ChromaFormat chFormat ) m_yuvPred[i].create( chFormat, predArea ); m_yuvTmp[i].create( CHROMA_400, refArea, 0, DMVR_NUM_ITERATION ); m_yuvPad[i].create( chFormat, predArea, 0, DMVR_NUM_ITERATION + (NTAPS_LUMA>>1), 32 ); - m_yuvRef[i].create( chFormat, refArea, 0, DMVR_NUM_ITERATION + (NTAPS_LUMA>>1), 32 ); } } } -void DMVR::xPrefetch( const PredictionUnit& pu, PelUnitBuf& dstBuf, RefPicList refId, bool isPadding, bool forLuma, bool forChroma ) +void DMVR::xCopyAndPad( const CodingUnit& cu, PelUnitBuf& pcPad, RefPicList refId, bool forLuma) { - const Picture* refPic = pu.cu->slice->getRefPic(refId, pu.refIdx[refId]); - int mvShift = (MV_FRACTIONAL_BITS_INTERNAL); - int start = forLuma ? 0 : 1; - int end = forChroma ? MAX_NUM_COMP : 1; + int width, height; + Mv cMv; + + const Picture* refPic = cu.slice->getRefPic(refId, cu.refIdx[refId]); + + static constexpr int mvShift = MV_FRACTIONAL_BITS_INTERNAL; + + const int start = forLuma ? 0 : 1; + const int end = forLuma ? 1 : MAX_NUM_COMP; for (int compID = start; compID < end; compID++) { - int mvshiftTemp = mvShift + getComponentScaleX((ComponentID)compID, pu.chromaFormat); - int filtersize = (compID == (COMP_Y)) ? NTAPS_LUMA : NTAPS_CHROMA; - int width = dstBuf.bufs[compID].width + (filtersize - 1); - int height = dstBuf.bufs[compID].height + (filtersize - 1); - int leftTopFilterExt = ( filtersize >> 1 ) - 1; - Mv cMv = Mv( pu.mv[refId].hor, pu.mv[refId].ver ); - cMv += Mv(-(leftTopFilterExt << mvshiftTemp), -(leftTopFilterExt << mvshiftTemp)); - bool wrapRef = false; - if( pu.cs->pcv->wrapArround ) + int filtersize = compID == COMP_Y ? NTAPS_LUMA : NTAPS_CHROMA; + cMv = cu.mv[refId]; + width = pcPad.bufs[compID].width; + height = pcPad.bufs[compID].height; + + int mvshiftTemp = mvShift + getComponentScaleX((ComponentID)compID, cu.chromaFormat); + + width += filtersize - 1; + height += filtersize - 1; + cMv += Mv(-(((filtersize >> 1) - 1) << mvshiftTemp), -(((filtersize >> 1) - 1) << mvshiftTemp)); + bool wrapRef = false; + + if (cu.cs->sps->wrapAroundEnabled) { - wrapRef = wrapClipMv( cMv, pu.blocks[COMP_Y].pos(), pu.blocks[COMP_Y].size(), *pu.cs); + wrapRef = wrapClipMv(cMv, cu.lumaPos(), cu.lumaSize(), *cu.cs); } else { - clipMv( cMv, pu.lumaPos(), pu.lumaSize(),*pu.cs->pcv ); + clipMv(cMv, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); } + /* Pre-fetch similar to HEVC*/ { - Position recOffset = pu.blocks[compID].pos().offset( cMv.hor >> mvshiftTemp, cMv.ver >> mvshiftTemp ); - CompArea ca((ComponentID)compID, pu.chromaFormat, recOffset, pu.blocks[compID].size()); - CPelBuf refBuf = wrapRef ? refPic->getRecoWrapBuf(ca) : refPic->getRecoBuf(ca); - PelBuf& padBuf = dstBuf.bufs[compID]; - int padOffset = leftTopFilterExt * padBuf.stride + leftTopFilterExt; - g_pelBufOP.copyBuffer( ( const char * ) refBuf.buf, refBuf.stride * sizeof( Pel ), ( char* ) ( padBuf.buf - padOffset ), padBuf.stride * sizeof( Pel ), width * sizeof( Pel ), height ); - if( isPadding ) - { - const int padSize = (DMVR_NUM_ITERATION) >> getComponentScaleX((ComponentID)compID, pu.chromaFormat); - g_pelBufOP.padding( padBuf.buf - padOffset, padBuf.stride, width, height, padSize ); - } - } - } -} + CPelBuf refBuf = wrapRef ? refPic->getRecoWrapBuf(ComponentID(compID)) : refPic->getRecoBuf(ComponentID(compID)); + Position Rec_offset = cu.blocks[compID].pos().offset(cMv.hor >> mvshiftTemp, cMv.ver >> mvshiftTemp); + const Pel* refBufPtr = refBuf.bufAt(Rec_offset); -void DMVR::xCopyAndPad( const PredictionUnit& pu, const PelUnitBuf& srcBuf, const PelUnitBuf& dstBuf ) -{ - for( int compID = 0; compID < MAX_NUM_COMP; compID++ ) - { - const int filtersize = ( compID == ( COMP_Y ) ) ? NTAPS_LUMA : NTAPS_CHROMA; - - const int width = dstBuf.bufs[compID].width + filtersize - 1; - const int height = dstBuf.bufs[compID].height + filtersize - 1; - - const PelBuf& refBuf = srcBuf.bufs[compID]; - const PelBuf& padBuf = dstBuf.bufs[compID]; - const int leftTopFilterExt = ( ( filtersize >> 1 ) - 1 ); - const int refOffset = leftTopFilterExt * refBuf.stride + leftTopFilterExt; - const int padOffset = leftTopFilterExt * padBuf.stride + leftTopFilterExt; - const int padSize = ( DMVR_NUM_ITERATION ) >> getComponentScaleX( ( ComponentID ) compID, pu.chromaFormat ); - g_pelBufOP.copyBuffer( ( const char* ) ( refBuf.buf - refOffset ), refBuf.stride * sizeof( Pel ), ( char* ) ( padBuf.buf - padOffset ), padBuf.stride * sizeof( Pel ), width * sizeof( Pel ), height ); - g_pelBufOP.padding( padBuf.buf - padOffset, padBuf.stride, width, height, padSize ); + PelBuf& dstBuf = pcPad.bufs[compID]; + + const int leftTopFilterExt = ((filtersize >> 1) - 1); + const int padOffset = leftTopFilterExt * dstBuf.stride + leftTopFilterExt; + const int padSize = (DMVR_NUM_ITERATION) >> getComponentScaleX((ComponentID)compID, cu.chromaFormat); + + g_pelBufOP.copyBuffer((const char*)refBufPtr, refBuf.stride * sizeof(Pel), (char*)(dstBuf.buf - padOffset), dstBuf.stride * sizeof(Pel), width * sizeof(Pel), height); + g_pelBufOP.padding (dstBuf.buf - padOffset, dstBuf.stride, width, height, padSize); + } } } @@ -1093,7 +1121,7 @@ void xSubPelErrorSrfc(uint64_t *sadBuffer, int32_t *deltaMv) } } -void DMVR::xFinalPaddedMCForDMVR( const PredictionUnit& pu, PelUnitBuf* dstBuf, const PelUnitBuf *refBuf, const bool bioApplied, const Mv mergeMv[NUM_REF_PIC_LIST_01], const Mv& refMv ) +void DMVR::xFinalPaddedMCForDMVR( const CodingUnit& cu, PelUnitBuf* dstBuf, const PelUnitBuf *refBuf, const bool bioApplied, const Mv mergeMv[NUM_REF_PIC_LIST_01], const Mv& refMv ) { int mvShift = MV_FRACTIONAL_BITS_INTERNAL; Mv mv[2]; @@ -1105,21 +1133,30 @@ void DMVR::xFinalPaddedMCForDMVR( const PredictionUnit& pu, PelUnitBuf* dstBuf, RefPicList refId = (RefPicList)k; const Mv& cMv = mv[refId]; Mv cMvClipped( cMv ); - clipMv(cMvClipped, pu.lumaPos(), pu.lumaSize(), *pu.cs->pcv); - + clipMv(cMvClipped, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + const Picture* refPic = cu.slice->getRefPic(refId, cu.refIdx[refId]); const Mv& startMv = mergeMv[refId]; for (int compID = 0; compID < MAX_NUM_COMP; compID++) { - int mvshiftTemp = mvShift + getComponentScaleX((ComponentID)compID, pu.chromaFormat); + int mvshiftTemp = mvShift + getComponentScaleX((ComponentID)compID, cu.chromaFormat); int deltaIntMvX = (cMv.hor >> mvshiftTemp) - (startMv.hor >> mvshiftTemp); int deltaIntMvY = (cMv.ver >> mvshiftTemp) - (startMv.ver >> mvshiftTemp); + CHECK((abs(deltaIntMvX) > DMVR_NUM_ITERATION) || (abs(deltaIntMvY) > DMVR_NUM_ITERATION), "not expected DMVR movement"); - const PelBuf& srcBuf = refBuf[refId].bufs[compID]; - int offset = (deltaIntMvY) * srcBuf.stride + (deltaIntMvX); + if (deltaIntMvX || deltaIntMvY) + { + const PelBuf& srcBuf = refBuf[refId].bufs[compID]; + int offset = (deltaIntMvY)*srcBuf.stride + (deltaIntMvX); - xPredInterBlk( (ComponentID)compID, pu, nullptr, cMvClipped, dstBuf[refId], true, pu.cs->slice->clpRngs.comp[compID], - bioApplied, false, refId, 0, 0, 0, srcBuf.buf + offset, srcBuf.stride ); + xPredInterBlk((ComponentID)compID, cu, nullptr, cMvClipped, dstBuf[refId], true, cu.cs->slice->clpRngs.comp[compID], + bioApplied, false, refId, 0, 0, 0, srcBuf.buf + offset, srcBuf.stride); + } + else + { + xPredInterBlk((ComponentID)compID, cu, refPic, cMvClipped, dstBuf[refId], true, cu.cs->slice->clpRngs.comp[compID], + bioApplied, false, refId, 0, 0, 0); + } } } } @@ -1144,53 +1181,68 @@ void xDMVRSubPixelErrorSurface( bool notZeroCost, int16_t *totalDeltaMV, int16_t } } -void DMVR::xProcessDMVR( const PredictionUnit& pu, PelUnitBuf& pcYuvDst, const ClpRngs &clpRngs, const bool bioApplied ) +void DMVR::xProcessDMVR( const CodingUnit& cu, PelUnitBuf& pcYuvDst, const ClpRngs &clpRngs, const bool bioApplied ) { PROFILER_SCOPE_AND_STAGE( 1, g_timeProfiler, P_INTER_MRG_DMVR ); int iterationCount = 1; /*Always High Precision*/ - const int mvShift = MV_FRACTIONAL_BITS_INTERNAL; + const int mvShift = MV_FRACTIONAL_BITS_INTERNAL; + const int mvShiftC = mvShift + getChannelTypeScaleX(CH_C, cu.chromaFormat); /*use merge MV as starting MV*/ - const Mv mergeMv[] = { pu.mv[REF_PIC_LIST_0] , pu.mv[REF_PIC_LIST_1] }; + const Mv mergeMv[] = { cu.mv[REF_PIC_LIST_0] , cu.mv[REF_PIC_LIST_1] }; - const int dy = std::min(pu.lumaSize().height, DMVR_SUBCU_SIZE); - const int dx = std::min(pu.lumaSize().width, DMVR_SUBCU_SIZE); - const bool usingSubPU = pu.lwidth() > DMVR_SUBCU_SIZE || pu.lheight() > DMVR_SUBCU_SIZE; + const int dy = std::min(cu.lumaSize().height, DMVR_SUBCU_SIZE); + const int dx = std::min(cu.lumaSize().width, DMVR_SUBCU_SIZE); - const Position& puPos = pu.lumaPos(); + const Position& puPos = cu.lumaPos(); bool bioAppliedType[MAX_NUM_SUBCU_DMVR]; - const int refBufStride = pu.Y().width + 2 * ( DMVR_NUM_ITERATION + ( NTAPS_LUMA >> 1 ) ); - const int refBufStrideCr = pu.Cb().width + 2 * ( DMVR_NUM_ITERATION + ( NTAPS_CHROMA >> 1 ) ); - PelUnitBuf yuvRefPu[NUM_REF_PIC_LIST_01]; - for( int i = 0; i < NUM_REF_PIC_LIST_01; i++ ) - yuvRefPu[i] = m_yuvRef[i].getBuf( refBufStride, refBufStrideCr, refBufStrideCr, pu ); // Do refinement search { - const int bilinearBufStride = (pu.Y().width + (2 * DMVR_NUM_ITERATION)); + const int bilinearBufStride = (cu.Y().width + (2 * DMVR_NUM_ITERATION)); const int padSize = DMVR_NUM_ITERATION << 1; - const int srcOffset = -( DMVR_NUM_ITERATION * yuvRefPu[L0].bufs[COMP_Y].stride + DMVR_NUM_ITERATION ); const int dstOffset = -( DMVR_NUM_ITERATION * bilinearBufStride + DMVR_NUM_ITERATION ); - for( int i = 0; i < NUM_REF_PIC_LIST_01; i++ ) + /*use merge MV as starting MV*/ + Mv mergeMVL0 = cu.mv[L0]; + Mv mergeMVL1 = cu.mv[L1]; + + /*Clip the starting MVs*/ + clipMv(mergeMVL0, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + clipMv(mergeMVL1, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + + /*L0 MC for refinement*/ + { + const Picture* refPic = cu.slice->getRefPic(L0, cu.refIdx[L0]); + + PelUnitBuf yuvTmp = PelUnitBuf(cu.chromaFormat, PelBuf(m_yuvTmp[L0].getBuf(COMP_Y).buf + dstOffset, bilinearBufStride, cu.lwidth() + padSize, cu.lheight() + padSize)); + + mergeMVL0.hor -= (DMVR_NUM_ITERATION << MV_FRACTIONAL_BITS_INTERNAL); + mergeMVL0.ver -= (DMVR_NUM_ITERATION << MV_FRACTIONAL_BITS_INTERNAL); + + xPredInterBlk(COMP_Y, cu, refPic, mergeMVL0, yuvTmp, true, clpRngs.comp[COMP_Y], false, false, L0, cu.lwidth() + padSize, cu.lheight() + padSize, true); + } + + /*L1 MC for refinement*/ { - RefPicList refId = (RefPicList)i; - xPrefetch( pu, yuvRefPu[i], RefPicList( i ), !usingSubPU ); + const Picture* refPic = cu.slice->getRefPic(L1, cu.refIdx[L1]); + + PelUnitBuf yuvTmp = PelUnitBuf(cu.chromaFormat, PelBuf(m_yuvTmp[L1].getBuf(COMP_Y).buf + dstOffset, bilinearBufStride, cu.lwidth() + padSize, cu.lheight() + padSize)); + + mergeMVL1.hor -= (DMVR_NUM_ITERATION << MV_FRACTIONAL_BITS_INTERNAL); + mergeMVL1.ver -= (DMVR_NUM_ITERATION << MV_FRACTIONAL_BITS_INTERNAL); - // generate bilinear interpolated reference for the search - const PelBuf& srcBuf = yuvRefPu[refId].bufs[COMP_Y]; - PelUnitBuf yuvTmp = PelUnitBuf( pu.chromaFormat, PelBuf( m_yuvTmp[refId].getBuf( COMP_Y ).buf + dstOffset, bilinearBufStride, pu.lwidth() + padSize, pu.lheight() + padSize ) ); - xPredInterBlk( COMP_Y, pu, nullptr, mergeMv[refId], yuvTmp, true, clpRngs.comp[COMP_Y], false, false, refId, pu.lwidth() + padSize, pu.lheight() + padSize, true, srcBuf.buf + srcOffset, srcBuf.stride ); + xPredInterBlk(COMP_Y, cu, refPic, mergeMVL1, yuvTmp, true, clpRngs.comp[COMP_Y], false, false, L1, cu.lwidth() + padSize, cu.lheight() + padSize, true); } // point mc buffer to center point to avoid multiplication to reach each iteration to the beginning const Pel* biLinearPredL0 = m_yuvTmp[0].getBuf( COMP_Y ).buf; const Pel* biLinearPredL1 = m_yuvTmp[1].getBuf( COMP_Y ).buf; const int bioEnabledThres = 2 * dy * dx; - const int bd = pu.cs->slice->clpRngs.comp[COMP_Y].bd; + const int bd = cu.cs->slice->clpRngs.comp[COMP_Y].bd; DistParam distParam = m_pcRdCost->setDistParam( nullptr, nullptr, bilinearBufStride, bilinearBufStride, bd, COMP_Y, dx, dy, 1 ); @@ -1198,9 +1250,9 @@ void DMVR::xProcessDMVR( const PredictionUnit& pu, PelUnitBuf& pcYuvDst, const C int yStart = 0; uint64_t sadArray[((2 * DMVR_NUM_ITERATION) + 1) * ((2 * DMVR_NUM_ITERATION) + 1)]; - for (int y = puPos.y; y < (puPos.y + pu.lumaSize().height); y = y + dy, yStart = yStart + dy) + for (int y = puPos.y; y < (puPos.y + cu.lumaSize().height); y = y + dy, yStart = yStart + dy) { - for (int x = puPos.x, xStart = 0; x < (puPos.x + pu.lumaSize().width); x = x + dx, xStart = xStart + dx) + for (int x = puPos.x, xStart = 0; x < (puPos.x + cu.lumaSize().width); x = x + dx, xStart = xStart + dx) { uint64_t minCost = MAX_UINT64; bool notZeroCost = true; @@ -1277,7 +1329,7 @@ void DMVR::xProcessDMVR( const PredictionUnit& pu, PelUnitBuf& pcYuvDst, const C totalDeltaMV[1] = (totalDeltaMV[1] << mvShift); xDMVRSubPixelErrorSurface(notZeroCost, totalDeltaMV, deltaMV, pSADsArray); - pu.mvdL0SubPu[num] = Mv(totalDeltaMV[0], totalDeltaMV[1]); + cu.mvdL0SubPu[num] = Mv(totalDeltaMV[0], totalDeltaMV[1]); num++; } @@ -1285,65 +1337,58 @@ void DMVR::xProcessDMVR( const PredictionUnit& pu, PelUnitBuf& pcYuvDst, const C } // Final MC - if( usingSubPU ) + CodingUnit subCu = cu; + subCu.UnitArea::operator=(UnitArea(cu.chromaFormat, Area(puPos.x, puPos.y, dx, dy))); + PelUnitBuf subPredBuf = pcYuvDst.subBuf(UnitAreaRelative(cu, subCu)); + + PelUnitBuf predBuf[NUM_REF_PIC_LIST_01]; + predBuf[L0] = m_yuvPred[L0].getCompactBuf( subCu ); + predBuf[L1] = m_yuvPred[L1].getCompactBuf( subCu ); + /* For padding */ + PelUnitBuf padBuf[NUM_REF_PIC_LIST_01]; + padBuf[L0] = m_yuvPad[L0].getBufPart(subCu); + padBuf[L1] = m_yuvPad[L1].getBufPart(subCu); + + int x = 0, y = 0; + int xStart = 0, yStart = 0; + int num = 0; + const int scaleX = getComponentScaleX(COMP_Cb, cu.chromaFormat); + const int scaleY = getComponentScaleY(COMP_Cb, cu.chromaFormat); + + const ptrdiff_t dstStride[MAX_NUM_COMP] = { pcYuvDst.bufs[COMP_Y].stride, pcYuvDst.bufs[COMP_Cb].stride, pcYuvDst.bufs[COMP_Cr].stride }; + for (y = puPos.y; y < (puPos.y + cu.lumaSize().height); y = y + dy, yStart = yStart + dy) { - PredictionUnit subPu = pu; - subPu.UnitArea::operator=(UnitArea(pu.chromaFormat, Area(puPos.x, puPos.y, dx, dy))); - PelUnitBuf subPredBuf = pcYuvDst.subBuf(UnitAreaRelative(pu, subPu)); + for (x = puPos.x, xStart = 0; x < (puPos.x + cu.lumaSize().width); x = x + dx, xStart = xStart + dx) + { + new (&subCu) UnitArea(cu.chromaFormat, Area(x, y, dx, dy)); - PelUnitBuf predBuf[NUM_REF_PIC_LIST_01]; - PelUnitBuf padBuf[NUM_REF_PIC_LIST_01]; - predBuf[L0] = m_yuvPred[L0].getCompactBuf( subPu ); - predBuf[L1] = m_yuvPred[L1].getCompactBuf( subPu ); + Mv mv0 = mergeMv[REF_PIC_LIST_0] + cu.mvdL0SubPu[num]; mv0.clipToStorageBitDepth(); + Mv mv1 = mergeMv[REF_PIC_LIST_1] - cu.mvdL0SubPu[num]; mv1.clipToStorageBitDepth(); - /* For padding */ - padBuf[L0] = m_yuvPad[L0].getBufPart( subPu ); - padBuf[L1] = m_yuvPad[L1].getBufPart( subPu ); + bool padBufL0 = (mv0.hor >> mvShift) != (mergeMv[0].hor >> mvShift) || (mv0.ver >> mvShift) != (mergeMv[0].ver >> mvShift); + bool padBufL0C = (mv0.hor >> mvShiftC) != (mergeMv[0].hor >> mvShiftC) || (mv0.ver >> mvShiftC) != (mergeMv[0].ver >> mvShiftC); + + bool padBufL1 = (mv1.hor >> mvShift) != (mergeMv[1].hor >> mvShift) || (mv1.ver >> mvShift) != (mergeMv[1].ver >> mvShift); + bool padBufL1C = (mv1.hor >> mvShiftC) != (mergeMv[1].hor >> mvShiftC) || (mv1.ver >> mvShiftC) != (mergeMv[1].ver >> mvShiftC); - int x = 0, y = 0; - int xStart = 0, yStart = 0; - int num = 0; - const int scaleX = getComponentScaleX(COMP_Cb, pu.chromaFormat); - const int scaleY = getComponentScaleY(COMP_Cb, pu.chromaFormat); + padBufL0C &= cu.chromaFormat != CHROMA_400; + padBufL1C &= cu.chromaFormat != CHROMA_400; - const ptrdiff_t dstStride[MAX_NUM_COMP] = { pcYuvDst.bufs[COMP_Y].stride, pcYuvDst.bufs[COMP_Cb].stride, pcYuvDst.bufs[COMP_Cr].stride }; - for (y = puPos.y; y < (puPos.y + pu.lumaSize().height); y = y + dy, yStart = yStart + dy) - { - for (x = puPos.x, xStart = 0; x < (puPos.x + pu.lumaSize().width); x = x + dx, xStart = xStart + dx) - { - subPu.UnitArea::operator=(UnitArea(pu.chromaFormat, Area(x, y, dx, dy))); - PelUnitBuf yuvRefSubPu[NUM_REF_PIC_LIST_01]; - yuvRefSubPu[L0] = yuvRefPu[L0].subBuf(UnitAreaRelative(pu, subPu)); - yuvRefSubPu[L1] = yuvRefPu[L1].subBuf(UnitAreaRelative(pu, subPu)); + if (padBufL0) xCopyAndPad(subCu, padBuf[L0], L0, true); + if (padBufL0C) xCopyAndPad(subCu, padBuf[L0], L0, false); + if (padBufL1) xCopyAndPad(subCu, padBuf[L1], L1, true); + if (padBufL1C) xCopyAndPad(subCu, padBuf[L1], L1, false); - if( pu.mvdL0SubPu[num] != Mv(0, 0) ) - { - xCopyAndPad( subPu, yuvRefSubPu[L0], padBuf[L0] ); - xCopyAndPad( subPu, yuvRefSubPu[L1], padBuf[L1] ); - xFinalPaddedMCForDMVR( subPu, predBuf, padBuf, bioAppliedType[num], mergeMv, pu.mvdL0SubPu[num] ); - } - else - { - xFinalPaddedMCForDMVR( subPu, predBuf, yuvRefSubPu, bioAppliedType[num], mergeMv, pu.mvdL0SubPu[num] ); - } + xFinalPaddedMCForDMVR( subCu, predBuf, padBuf, bioAppliedType[num], mergeMv, cu.mvdL0SubPu[num] ); - subPredBuf.bufs[COMP_Y].buf = pcYuvDst.bufs[COMP_Y].buf + xStart + yStart * dstStride[COMP_Y]; - subPredBuf.bufs[COMP_Cb].buf = pcYuvDst.bufs[COMP_Cb].buf + (xStart >> scaleX) + ((yStart >> scaleY) * dstStride[COMP_Cb]); - subPredBuf.bufs[COMP_Cr].buf = pcYuvDst.bufs[COMP_Cr].buf + (xStart >> scaleX) + ((yStart >> scaleY) * dstStride[COMP_Cr]); + subPredBuf.bufs[COMP_Y].buf = pcYuvDst.bufs[COMP_Y].buf + xStart + yStart * dstStride[COMP_Y]; + subPredBuf.bufs[COMP_Cb].buf = pcYuvDst.bufs[COMP_Cb].buf + (xStart >> scaleX) + ((yStart >> scaleY) * dstStride[COMP_Cb]); + subPredBuf.bufs[COMP_Cr].buf = pcYuvDst.bufs[COMP_Cr].buf + (xStart >> scaleX) + ((yStart >> scaleY) * dstStride[COMP_Cr]); - xWeightedAverage(subPu, predBuf[L0], predBuf[L1], subPredBuf, bioAppliedType[num] ); - num++; - } + xWeightedAverage(subCu, predBuf[L0], predBuf[L1], subPredBuf, bioAppliedType[num] ); + num++; } } - else - { - PelUnitBuf predBuf[NUM_REF_PIC_LIST_01]; - predBuf[L0] = m_yuvPred[L0].getCompactBuf( pu ); - predBuf[L1] = m_yuvPred[L1].getCompactBuf( pu ); - xFinalPaddedMCForDMVR( pu, predBuf, yuvRefPu, bioAppliedType[0], mergeMv, pu.mvdL0SubPu[0] ); - xWeightedAverage( pu, predBuf[L0], predBuf[L1], pcYuvDst, bioAppliedType[0] ); - } } bool InterPredInterpolation::isSubblockVectorSpreadOverLimit(int a, int b, int c, int d, int predType) @@ -1386,9 +1431,9 @@ bool InterPredInterpolation::isSubblockVectorSpreadOverLimit(int a, int b, int c return false; } -void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng, const RefPicList refPicList) +void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const CodingUnit& cu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng, const RefPicList refPicList) { - const ChromaFormat chFmt = pu.chromaFormat; + const ChromaFormat chFmt = cu.chromaFormat; int iScaleX = getComponentScaleX(compID, chFmt); int iScaleY = getComponentScaleY(compID, chFmt); @@ -1397,8 +1442,8 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred Mv mvLB = _mv[2]; // get affine sub-block width and height - const int width = pu.Y().width; - const int height = pu.Y().height; + const int width = cu.Y().width; + const int height = cu.Y().height; int blockWidth = AFFINE_MIN_BLOCK_SIZE; int blockHeight = AFFINE_MIN_BLOCK_SIZE; @@ -1419,7 +1464,7 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred iDMvHorX = (mvRT - mvLT).hor << (iBit - Log2(cxWidth)); iDMvHorY = (mvRT - mvLT).ver << (iBit - Log2(cxWidth)); - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { iDMvVerX = (mvLB - mvLT).hor << (iBit - Log2(cxHeight)); iDMvVerY = (mvLB - mvLT).ver << (iBit - Log2(cxHeight)); @@ -1432,24 +1477,24 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred int iMvScaleHor = mvLT.hor << iBit; int iMvScaleVer = mvLT.ver << iBit; - const PPS &pps = *pu.cs->pps; - const SPS &sps = *pu.cs->sps; + const PPS &pps = *cu.cs->pps; + const SPS &sps = *cu.cs->sps; const int iMvShift = 4; const int iOffset = 8; - const int iHorMax = (pps.picWidthInLumaSamples + iOffset - pu.Y().x - 1) << iMvShift; - const int iHorMin = (-(int)pu.cs->pcv->maxCUSize - iOffset - (int)pu.Y().x + 1) << iMvShift; - const int iVerMax = (pps.picHeightInLumaSamples + iOffset - pu.Y().y - 1) << iMvShift; - const int iVerMin = (-(int)pu.cs->pcv->maxCUSize - iOffset - (int)pu.Y().y + 1) << iMvShift; + const int iHorMax = (pps.picWidthInLumaSamples + iOffset - cu.Y().x - 1) << iMvShift; + const int iHorMin = (-(int)cu.cs->pcv->maxCUSize - iOffset - (int)cu.Y().x + 1) << iMvShift; + const int iVerMax = (pps.picHeightInLumaSamples + iOffset - cu.Y().y - 1) << iMvShift; + const int iVerMin = (-(int)cu.cs->pcv->maxCUSize - iOffset - (int)cu.Y().y + 1) << iMvShift; const int shift = iBit - 4 + MV_FRACTIONAL_BITS_INTERNAL; bool wrapRef = false; - const bool subblkMVSpreadOverLimit = isSubblockVectorSpreadOverLimit(iDMvHorX, iDMvHorY, iDMvVerX, iDMvVerY, pu.interDir); + const bool subblkMVSpreadOverLimit = isSubblockVectorSpreadOverLimit(iDMvHorX, iDMvHorY, iDMvVerX, iDMvVerY, cu.interDir); bool enablePROF = sps.PROF && (!m_skipPROF) && (compID == COMP_Y); - enablePROF &= !((pu.cu->affineType == AFFINEMODEL_6PARAM && _mv[0] == _mv[1] && _mv[0] == _mv[2]) || (pu.cu->affineType == AFFINEMODEL_4PARAM && _mv[0] == _mv[1])); + enablePROF &= !((cu.affineType == AFFINEMODEL_6PARAM && _mv[0] == _mv[1] && _mv[0] == _mv[2]) || (cu.affineType == AFFINEMODEL_4PARAM && _mv[0] == _mv[1])); enablePROF &= !subblkMVSpreadOverLimit; const int profThres = 1 << (iBit + (m_isBi ? 1 : 0)); - enablePROF &= !m_encOnly || pu.cu->slice->checkLDC || iDMvHorX > profThres || iDMvHorY > profThres || iDMvVerX > profThres || iDMvVerY > profThres || iDMvHorX < -profThres || iDMvHorY < -profThres || iDMvVerX < -profThres || iDMvVerY < -profThres; + enablePROF &= !m_encOnly || cu.slice->checkLDC || iDMvHorX > profThres || iDMvHorY > profThres || iDMvVerX > profThres || iDMvVerY > profThres || iDMvHorX < -profThres || iDMvHorY < -profThres || iDMvVerX < -profThres || iDMvVerY < -profThres; enablePROF &= pps.picWidthInLumaSamples == refPic->cs->pps->picWidthInLumaSamples && pps.picHeightInLumaSamples == refPic->cs->pps->picHeightInLumaSamples; bool isLast = enablePROF ? false : !bi; @@ -1523,7 +1568,7 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred int scaleXLuma = getComponentScaleX(COMP_Y, chFmt); int scaleYLuma = getComponentScaleY(COMP_Y, chFmt); - if ((pu.mcControl > 3) && (compID == COMP_Cb) && pu.chromaFormat != CHROMA_444) + if ((cu.mcControl > 3) && (compID == COMP_Cb) && cu.chromaFormat != CHROMA_444) { CHECK(compID == COMP_Y, "Chroma only subblock MV calculation should not apply to Luma"); int lumaBlockWidth = AFFINE_MIN_BLOCK_SIZE; @@ -1540,7 +1585,7 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred int dMvHorXLuma, dMvHorYLuma, dMvVerXLuma, dMvVerYLuma; dMvHorXLuma = (mvRT - mvLT).hor << (iBit - floorLog2(cxWidthLuma)); dMvHorYLuma = (mvRT - mvLT).ver << (iBit - floorLog2(cxWidthLuma)); - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { dMvVerXLuma = (mvLB - mvLT).hor << (iBit - floorLog2(cxHeightLuma)); dMvVerYLuma = (mvLB - mvLT).ver << (iBit - floorLog2(cxHeightLuma)); @@ -1551,7 +1596,7 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred dMvVerYLuma = dMvHorXLuma; } - const bool subblkMVSpreadOverLimitLuma = isSubblockVectorSpreadOverLimit(dMvHorXLuma, dMvHorYLuma, dMvVerXLuma, dMvVerYLuma, pu.interDir); + const bool subblkMVSpreadOverLimitLuma = isSubblockVectorSpreadOverLimit(dMvHorXLuma, dMvHorYLuma, dMvVerXLuma, dMvVerYLuma, cu.interDir); // get luma MV block by block for (int h = 0; h < cxHeightLuma; h += lumaBlockHeight) @@ -1584,15 +1629,15 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred const CPelBuf refBuf = refPic->getRecoBuf(compID); const CPelBuf refBufWrap; //no support = refPic->getRecoWrapBuf(compID); - const int puX = pu.blocks[compID].x; - const int puY = pu.blocks[compID].y; + const int puX = cu.blocks[compID].x; + const int puY = cu.blocks[compID].y; for (int h = 0; h < cxHeight; h += blockHeight) { for (int w = 0; w < cxWidth; w += blockWidth) { int iMvScaleTmpHor, iMvScaleTmpVer; - if (compID == COMP_Y || pu.chromaFormat == CHROMA_444) + if (compID == COMP_Y || cu.chromaFormat == CHROMA_444) { if (!subblkMVSpreadOverLimit) { @@ -1612,11 +1657,11 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred iMvScaleTmpVer = tmpMv.ver; // clip and scale - if( pu.cs->sps->wrapAroundEnabled ) + if( cu.cs->sps->wrapAroundEnabled ) { m_storedMv[h / AFFINE_MIN_BLOCK_SIZE * MVBUFFER_SIZE + w / AFFINE_MIN_BLOCK_SIZE].set(iMvScaleTmpHor, iMvScaleTmpVer); Mv tmpMv(iMvScaleTmpHor, iMvScaleTmpVer); - wrapRef = wrapClipMv(tmpMv, Position(pu.Y().x + w, pu.Y().y + h), Size(blockWidth, blockHeight), *pu.cs); + wrapRef = wrapClipMv(tmpMv, Position(cu.Y().x + w, cu.Y().y + h), Size(blockWidth, blockHeight), *cu.cs); iMvScaleTmpHor = tmpMv.hor; iMvScaleTmpVer = tmpMv.ver; } @@ -1636,9 +1681,9 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] + m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + iScaleY)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + iScaleX)]; roundAffineMv(curMv.hor, curMv.ver, 1); - if (pu.cs->sps->wrapAroundEnabled) + if (cu.cs->sps->wrapAroundEnabled) { - wrapRef = wrapClipMv(curMv, Position(pu.Y().x + (w << iScaleX), pu.Y().y + (h << iScaleY)), Size(blockWidth << iScaleX, blockHeight << iScaleY), *pu.cs); + wrapRef = wrapClipMv(curMv, Position(cu.Y().x + (w << iScaleX), cu.Y().y + (h << iScaleY)), Size(blockWidth << iScaleX, blockHeight << iScaleY), *cu.cs); } else { @@ -1735,7 +1780,8 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred PelBuf gradXBuf = gradXExt.subBuf(0, 0, blockWidth + 2, blockHeight + 2); PelBuf gradYBuf = gradYExt.subBuf(0, 0, blockWidth + 2, blockHeight + 2); - g_pelBufOP.profGradFilter(dstExtBuf.buf, dstExtBuf.stride, blockWidth + 2, blockHeight + 2, gradXBuf.stride, gradXBuf.buf, gradYBuf.buf, clpRng.bd); + xFpProfGradFilter(dstExtBuf.buf, dstExtBuf.stride, blockWidth + 2, blockHeight + 2, gradXBuf.stride, gradXBuf.buf, gradYBuf.buf, clpRng.bd); + const int shiftNum = std::max(2, (IF_INTERNAL_PREC - clpRng.bd)); const Pel offset = (1 << (shiftNum - 1)) + IF_INTERNAL_OFFS; Pel* src = dstExtBuf.bufAt(PROF_BORDER_EXT_W, PROF_BORDER_EXT_H); @@ -1744,7 +1790,7 @@ void InterPredInterpolation::xPredAffineBlk(const ComponentID compID, const Pred Pel* dstY = dstBuf.bufAt(w, h); - g_pelBufOP.applyPROF(dstY, dstBuf.stride, src, dstExtBuf.stride, blockWidth, blockHeight, gX, gY, gradXBuf.stride, dMvScaleHor, dMvScaleVer, blockWidth, bi, shiftNum, offset, clpRng); + xFpApplyPROF(dstY, dstBuf.stride, src, dstExtBuf.stride, blockWidth, blockHeight, gX, gY, gradXBuf.stride, dMvScaleHor, dMvScaleVer, blockWidth, bi, shiftNum, offset, clpRng); } } } diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index 67c5d82a0..c5b714917 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file InterPrediction.h \brief inter prediction class (header) */ @@ -84,9 +88,10 @@ class InterPredInterpolation private: int xRightShiftMSB ( int numer, int denom ); void xApplyBDOF ( PelBuf& yuvDst, const ClpRng& clpRng ); - void(*xFpAddBDOFAvg4) ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel*gradY1, int gradStride, int width, int height, int tmpx, int tmpy, unsigned shift, int offset, const ClpRng& clpRng); - void(*xFpBDOFGradFilter) ( const Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth); - void(*xFpCalcBDOFSums) ( const Pel* srcY0Tmp, const Pel* srcY1Tmp, Pel* gradX0, Pel* gradX1, Pel* gradY0, Pel* gradY1, int xu, int yu, const int src0Stride, const int src1Stride, const int widthG, const int bitDepth, int* sumAbsGX, int* sumAbsGY, int* sumDIX, int* sumDIY, int* sumSignGY_GX); + void(*xFpBiDirOptFlow) ( const Pel* srcY0, const Pel* srcY1, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, const int width, const int height, Pel* dstY, const ptrdiff_t dstStride, const int shiftNum, const int offset, const int limit, const ClpRng& clpRng, const int bitDepth ) = nullptr; + void(*xFpBDOFGradFilter) ( const Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth ); + void(*xFpProfGradFilter) ( const Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth ); + void(*xFpApplyPROF) ( Pel* dst, int dstStride, const Pel* src, int srcStride, int width, int height, const Pel* gradX, const Pel* gradY, int gradStride, const int* dMvX, const int* dMvY, int dMvStride, const bool& bi, int shiftNum, Pel offset, const ClpRng& clpRng ); #if ENABLE_SIMD_OPT_BDOF void initInterPredictionX86(); @@ -95,9 +100,9 @@ class InterPredInterpolation #endif protected: - void xWeightedAverage ( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const bool bdofApplied ); - void xPredAffineBlk ( const ComponentID compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng, const RefPicList refPicList = REF_PIC_LIST_X); - void xPredInterBlk ( const ComponentID compID, const PredictionUnit& pu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng + void xWeightedAverage ( const CodingUnit& cu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const bool bdofApplied ); + void xPredAffineBlk ( const ComponentID compID, const CodingUnit& cu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng, const RefPicList refPicList = REF_PIC_LIST_X); + void xPredInterBlk ( const ComponentID compID, const CodingUnit& cu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool bi, const ClpRng& clpRng , const bool bdofApplied , const bool isIBC , const RefPicList refPicList = REF_PIC_LIST_X @@ -114,7 +119,7 @@ class InterPredInterpolation void destroy (); void init (); - void weightedGeoBlk ( const ClpRngs &clpRngs, PredictionUnit &pu, const uint8_t splitDir, int32_t channel, + void weightedGeoBlk ( const ClpRngs &clpRngs, CodingUnit& cu, const uint8_t splitDir, int32_t channel, PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1); static bool isSubblockVectorSpreadOverLimit(int a, int b, int c, int d, int predType); @@ -127,23 +132,21 @@ class DMVR : public InterPredInterpolation PelStorage m_yuvPred[NUM_REF_PIC_LIST_01]; PelStorage m_yuvTmp[NUM_REF_PIC_LIST_01]; PelStorage m_yuvPad[NUM_REF_PIC_LIST_01]; - PelStorage m_yuvRef[NUM_REF_PIC_LIST_01]; const Mv m_pSearchOffset[25] = { Mv(-2,-2), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(2,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2, 0), Mv(-1, 0), Mv(0, 0), Mv(1, 0), Mv(2, 0), Mv(-2, 1), Mv(-1, 1), Mv(0, 1), Mv(1, 1), Mv(2, 1), Mv(-2, 2), Mv(-1, 2), Mv(0, 2), Mv(1, 2), Mv(2, 2) }; private: - void xPrefetch ( const PredictionUnit& pu, PelUnitBuf& pcPad, RefPicList refId, bool isPadding = false, bool forLuma = true, bool forChroma = true ); - void xCopyAndPad ( const PredictionUnit& pu, const PelUnitBuf& srcBuf, const PelUnitBuf& pcPad ); - void xFinalPaddedMCForDMVR( const PredictionUnit& pu, PelUnitBuf* dstBuf, const PelUnitBuf *refBuf, const bool bioApplied, const Mv startMV[NUM_REF_PIC_LIST_01], const Mv& refMV ); + void xCopyAndPad ( const CodingUnit& cu, PelUnitBuf& pcPad, RefPicList refId, bool forLuma); + void xFinalPaddedMCForDMVR( const CodingUnit& cu, PelUnitBuf* dstBuf, const PelUnitBuf *refBuf, const bool bioApplied, const Mv startMV[NUM_REF_PIC_LIST_01], const Mv& refMV ); protected: DMVR(); virtual ~DMVR(); void destroy(); void init ( RdCost* pcRdCost, const ChromaFormat chFormat ); - void xProcessDMVR ( const PredictionUnit& pu, PelUnitBuf& pcYuvDst, const ClpRngs &clpRngs, const bool bioApplied ); + void xProcessDMVR ( const CodingUnit& cu, PelUnitBuf& pcYuvDst, const ClpRngs &clpRngs, const bool bioApplied ); }; class InterPrediction : public DMVR @@ -156,10 +159,10 @@ class InterPrediction : public DMVR bool m_subPuMC; PelStorage m_geoPartBuf[2]; - void xPredInterUni ( const PredictionUnit& pu, const RefPicList& refPicList, PelUnitBuf& pcYuvPred, const bool bi, const bool bdofApplied ); - void xPredInterBi ( const PredictionUnit& pu, PelUnitBuf& yuvPred, const bool bdofApplied = false ); - void xSubPuBDOF ( const PredictionUnit& pu, PelUnitBuf& predBuf, const RefPicList& refPicList = REF_PIC_LIST_X ); - bool xCheckIdenticalMotion ( const PredictionUnit& pu ) const; + void xPredInterUni ( const CodingUnit& cu, const RefPicList& refPicList, PelUnitBuf& pcYuvPred, const bool bi, const bool bdofApplied ); + void xPredInterBi ( const CodingUnit& cu, PelUnitBuf& yuvPred, const bool bdofApplied = false ); + void xSubPuBDOF ( const CodingUnit& cu, PelUnitBuf& predBuf, const RefPicList& refPicList = REF_PIC_LIST_X ); + bool xCheckIdenticalMotion ( const CodingUnit& cu ) const; public: InterPrediction(); @@ -169,10 +172,10 @@ class InterPrediction : public DMVR void destroy (); // inter - bool motionCompensation ( PredictionUnit& pu, PelUnitBuf& predBuf, const RefPicList refPicList = REF_PIC_LIST_X ); - void motionCompensationIBC ( PredictionUnit& pu, PelUnitBuf& predBuf ); - void xSubPuMC ( PredictionUnit& pu, PelUnitBuf& predBuf, const RefPicList& eRefPicList = REF_PIC_LIST_X ); - void motionCompensationGeo ( PredictionUnit& pu, PelUnitBuf& predBuf, const MergeCtx& geoMrgCtx ); + bool motionCompensation ( CodingUnit& cu, PelUnitBuf& predBuf, const RefPicList refPicList = REF_PIC_LIST_X ); + void motionCompensationIBC ( CodingUnit& cu, PelUnitBuf& predBuf ); + void xSubPuMC ( CodingUnit& cu, PelUnitBuf& predBuf, const RefPicList& eRefPicList = REF_PIC_LIST_X ); + void motionCompensationGeo ( CodingUnit& cu, PelUnitBuf& predBuf, const MergeCtx& geoMrgCtx ); }; } // namespace vvenc diff --git a/source/Lib/CommonLib/InterpolationFilter.cpp b/source/Lib/CommonLib/InterpolationFilter.cpp index 1bbad0798..adc2f23ff 100644 --- a/source/Lib/CommonLib/InterpolationFilter.cpp +++ b/source/Lib/CommonLib/InterpolationFilter.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** @@ -930,15 +934,15 @@ void InterpolationFilter::filterXxY_N8( const ClpRng& clpRng, const Pel* src, in } } -void InterpolationFilter::weightedGeoBlk(const ClpRngs &clpRngs, const PredictionUnit &pu, const uint32_t width, +void InterpolationFilter::weightedGeoBlk(const ClpRngs &clpRngs, const CodingUnit& cu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir,PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1) { - m_weightedGeoBlk(clpRngs, pu, width, height, compIdx, splitDir, predDst, predSrc0, predSrc1); + m_weightedGeoBlk(clpRngs, cu, width, height, compIdx, splitDir, predDst, predSrc0, predSrc1); } -void InterpolationFilter::xWeightedGeoBlk(const ClpRngs &clpRngs, const PredictionUnit &pu, const uint32_t width, +void InterpolationFilter::xWeightedGeoBlk(const ClpRngs &clpRngs, const CodingUnit& cu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir,PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1) @@ -951,22 +955,22 @@ void InterpolationFilter::xWeightedGeoBlk(const ClpRngs &clpRngs, const Predicti int32_t strideSrc1 = predSrc1.get(compIdx).stride - width; const char log2WeightBase = 3; - // const ClpRng clipRng = pu.cu->cs->slice->clpRngs[compIdx] // pu.cu->slice->clpRngs().comp[compIdx]; + // const ClpRng clipRng = cu.cs->slice->clpRngs[compIdx] // cu.slice->clpRngs().comp[compIdx]; const int32_t clipbd = clpRngs[compIdx].bd; const int32_t shiftWeighted = std::max(2, (IF_INTERNAL_PREC - clipbd)) + log2WeightBase; const int32_t offsetWeighted = (1 << (shiftWeighted - 1)) + (IF_INTERNAL_OFFS << log2WeightBase); - const uint32_t scaleX = getComponentScaleX(compIdx, pu.chromaFormat); - const uint32_t scaleY = getComponentScaleY(compIdx, pu.chromaFormat); + const uint32_t scaleX = getComponentScaleX(compIdx, cu.chromaFormat); + const uint32_t scaleY = getComponentScaleY(compIdx, cu.chromaFormat); int16_t angle = g_GeoParams[splitDir][0]; - int16_t wIdx = floorLog2(pu.lwidth()) - GEO_MIN_CU_LOG2; - int16_t hIdx = floorLog2(pu.lheight()) - GEO_MIN_CU_LOG2; + int16_t wIdx = floorLog2(cu.lwidth()) - GEO_MIN_CU_LOG2; + int16_t hIdx = floorLog2(cu.lheight()) - GEO_MIN_CU_LOG2; int16_t stepX = 1 << scaleX; int16_t stepY = 0; int16_t *weight = nullptr; if (g_angle2mirror[angle] == 2) { - stepY = -(int) ((GEO_WEIGHT_MASK_SIZE << scaleY) + pu.lwidth()); + stepY = -(int) ((GEO_WEIGHT_MASK_SIZE << scaleY) + cu.lwidth()); weight = &g_globalGeoWeights[g_angle2mask[angle]] [(GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffset[hIdx][wIdx][splitDir][1]) * GEO_WEIGHT_MASK_SIZE @@ -975,14 +979,14 @@ void InterpolationFilter::xWeightedGeoBlk(const ClpRngs &clpRngs, const Predicti else if (g_angle2mirror[angle] == 1) { stepX = -1 << scaleX; - stepY = (GEO_WEIGHT_MASK_SIZE << scaleY) + pu.lwidth(); + stepY = (GEO_WEIGHT_MASK_SIZE << scaleY) + cu.lwidth(); weight = &g_globalGeoWeights[g_angle2mask[angle]][g_weightOffset[hIdx][wIdx][splitDir][1] * GEO_WEIGHT_MASK_SIZE + (GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffset[hIdx][wIdx][splitDir][0])]; } else { - stepY = (GEO_WEIGHT_MASK_SIZE << scaleY) - pu.lwidth(); + stepY = (GEO_WEIGHT_MASK_SIZE << scaleY) - cu.lwidth(); weight = &g_globalGeoWeights[g_angle2mask[angle]][g_weightOffset[hIdx][wIdx][splitDir][1] * GEO_WEIGHT_MASK_SIZE + g_weightOffset[hIdx][wIdx][splitDir][0]]; } diff --git a/source/Lib/CommonLib/InterpolationFilter.h b/source/Lib/CommonLib/InterpolationFilter.h index e139d5e90..54a0e08e3 100644 --- a/source/Lib/CommonLib/InterpolationFilter.h +++ b/source/Lib/CommonLib/InterpolationFilter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** * \file * \brief Declaration of InterpolationFilter class @@ -88,10 +92,10 @@ class InterpolationFilter template static void filterXxY_N8 (const ClpRng& clpRng, Pel const *src, int srcStride, Pel* dst, int dstStride, int width, int height, TFilterCoeff const *coeffH, TFilterCoeff const *coeffV); - static void xWeightedGeoBlk(const ClpRngs &clpRngs, const PredictionUnit &pu, const uint32_t width, + static void xWeightedGeoBlk(const ClpRngs &clpRngs, const CodingUnit& cu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1); - void weightedGeoBlk(const ClpRngs &clpRngs, const PredictionUnit &pu, const uint32_t width, const uint32_t height, + void weightedGeoBlk(const ClpRngs &clpRngs, const CodingUnit& cu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1); InterpolationFilter(); @@ -103,7 +107,7 @@ class InterpolationFilter void( *m_filter4x4 [2][2] ) ( const ClpRng& clpRng, Pel const *src, int srcStride, Pel* dst, int dstStride, int width, int height, TFilterCoeff const *coeffH, TFilterCoeff const *coeffV ); void( *m_filter8x8 [3][2] ) ( const ClpRng& clpRng, Pel const *src, int srcStride, Pel* dst, int dstStride, int width, int height, TFilterCoeff const *coeffH, TFilterCoeff const *coeffV ); void( *m_filter16x16[3][2] ) ( const ClpRng& clpRng, Pel const *src, int srcStride, Pel* dst, int dstStride, int width, int height, TFilterCoeff const *coeffH, TFilterCoeff const *coeffV ); - void (*m_weightedGeoBlk)(const ClpRngs &clpRngs, const PredictionUnit &pu, const uint32_t width, const uint32_t height, + void (*m_weightedGeoBlk)(const ClpRngs &clpRngs, const CodingUnit& cu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1); diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index 792f31721..869d0e1cb 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Prediction.cpp @@ -342,13 +346,13 @@ int IntraPrediction::getWideAngle( int width, int height, int predMode ) return predMode; } -void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf& piPred, const PredictionUnit &pu) +void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf& piPred, const CodingUnit& cu) { const ComponentID compID = compId; const ChannelType channelType = toChannelType( compID ); - const uint32_t uiDirMode = /*isLuma( compId ) && pu.cu->bdpcmMode ? BDPCM_IDX : */PU::getFinalIntraMode( pu, channelType ); + const uint32_t uiDirMode = cu.bdpcmM[channelType] ? BDPCM_IDX : CU::getFinalIntraMode(cu, channelType); - CHECK( Log2(piPred.width) < 2 && pu.cs->pcv->noChroma2x2, "Size not allowed" ); + CHECK( Log2(piPred.width) < 2 && cu.cs->pcv->noChroma2x2, "Size not allowed" ); CHECK( Log2(piPred.width) > 7, "Size not allowed" ); // const int multiRefIdx = m_ipaParam.multiRefIndex; @@ -356,13 +360,13 @@ void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf& piPred, co const int srcHStride = 2; const CPelBuf& srcBuf = CPelBuf(getPredictorPtr(compID), srcStride, srcHStride); - const ClpRng& clpRng(pu.cu->cs->slice->clpRngs[compID]); + const ClpRng& clpRng(cu.cs->slice->clpRngs[compID]); switch (uiDirMode) { - case(PLANAR_IDX): xPredIntraPlanar( piPred, srcBuf); break; + case(PLANAR_IDX): xPredIntraPlanar(piPred, srcBuf); break; case(DC_IDX): xPredIntraDc ( piPred, srcBuf ); break; -// case(BDPCM_IDX): xPredIntraBDPCM ( piPred, srcBuf, pu.cu->bdpcmMode, clpRng); break; + case(BDPCM_IDX): xPredIntraBDPCM ( piPred, srcBuf, cu.bdpcmM[channelType], clpRng); break; default: xPredIntraAng ( piPred, srcBuf, channelType, clpRng); break; } @@ -375,18 +379,18 @@ void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf& piPred, co } } -void IntraPrediction::predIntraChromaLM(const ComponentID compID, PelBuf& piPred, const PredictionUnit &pu, const CompArea& chromaArea, int intraDir) +void IntraPrediction::predIntraChromaLM(const ComponentID compID, PelBuf& piPred, const CodingUnit& cu, const CompArea& chromaArea, int intraDir) { CHECK( piPred.width > MAX_TB_SIZEY || piPred.height > MAX_TB_SIZEY, "not enough memory"); const int iLumaStride = 2 * MAX_TB_SIZEY + 1; PelBuf Temp = PelBuf(m_pMdlmTemp + iLumaStride + 1, iLumaStride, Size(chromaArea)); int a, b, iShift; - xGetLMParameters(pu, compID, chromaArea, a, b, iShift); // th shift result is unsigned + xGetLMParameters(cu, compID, chromaArea, a, b, iShift); // th shift result is unsigned ////// final prediction piPred.copyFrom(Temp); - piPred.linearTransform(a, iShift, b, true, pu.cs->slice->clpRngs[compID]); + piPred.linearTransform(a, iShift, b, true, cu.cs->slice->clpRngs[compID]); } /** Function for deriving planar intra prediction. This function derives the prediction samples for planar mode (intra coding). @@ -399,21 +403,21 @@ void IntraPrediction::xPredIntraDc( PelBuf& pDst, const CPelBuf& pSrc ) } // Function for initialization of intra prediction parameters -void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompArea area, const SPS& sps) +void IntraPrediction::initPredIntraParams(const CodingUnit& cu, const CompArea area, const SPS& sps) { const ComponentID compId = area.compID; const ChannelType chType = toChannelType(compId); - const bool useISP = NOT_INTRA_SUBPARTITIONS != pu.cu->ispMode && isLuma( chType ); + const bool useISP = NOT_INTRA_SUBPARTITIONS != cu.ispMode && isLuma( chType ); - const Size cuSize = Size( pu.cu->blocks[compId].width, pu.cu->blocks[compId].height ); + const Size cuSize = Size( cu.blocks[compId].width, cu.blocks[compId].height ); const Size puSize = Size( area.width, area.height ); const Size& blockSize = useISP ? cuSize : puSize; - const int dirMode = PU::getFinalIntraMode(pu, chType); + const int dirMode = CU::getFinalIntraMode(cu, chType); const int predMode = getWideAngle( blockSize.width, blockSize.height, dirMode ); m_ipaParam.isModeVer = predMode >= DIA_IDX; - m_ipaParam.multiRefIndex = isLuma (chType) ? pu.multiRefIdx : 0 ; + m_ipaParam.multiRefIndex = isLuma (chType) ? cu.multiRefIdx : 0 ; m_ipaParam.refFilterFlag = false; m_ipaParam.interpolationFlag = false; m_ipaParam.applyPDPC = (puSize.width >= MIN_TB_SIZEY && puSize.height >= MIN_TB_SIZEY) && m_ipaParam.multiRefIndex == 0; @@ -454,13 +458,13 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA if( sps.spsRExt.intraSmoothingDisabled || !isLuma( chType ) || useISP - || PU::isMIP( pu, chType ) //th remove this + || CU::isMIP( cu, chType ) //th remove this || m_ipaParam.multiRefIndex || DC_IDX == dirMode ) { } - else if (isLuma( chType ) && pu.cu->bdpcmMode) // BDPCM + else if (cu.bdpcmM[chType]) { m_ipaParam.refFilterFlag = false; } @@ -540,10 +544,10 @@ void IntraPrediction::xPredIntraAng( PelBuf& pDst, const CPelBuf& pSrc, const Ch } else { - memcpy(&refAbove[0],pSrc.buf,((width<<1) + multiRefIdx+1)*sizeof(Pel)); - for (int y = 0; y <= 2 * height + multiRefIdx; y++) + memcpy(&refAbove[0], pSrc.buf, ((m_topRefLength)+multiRefIdx + 1) * sizeof(Pel)); + for (int y = 0; y <= m_leftRefLength + multiRefIdx; y++) { - refLeft[y] = pSrc.at(y,1); + refLeft[y] = pSrc.at(y, 1); } refMain = bIsModeVer ? refAbove : refLeft; @@ -553,7 +557,7 @@ void IntraPrediction::xPredIntraAng( PelBuf& pDst, const CPelBuf& pSrc, const Ch const int log2Ratio = Log2(width) - Log2(height); const int s = std::max(0, bIsModeVer ? log2Ratio : -log2Ratio); const int maxIndex = (multiRefIdx << s) + 2; - const int refLength = 2* (bIsModeVer ? width : height); + const int refLength = bIsModeVer ? m_topRefLength : m_leftRefLength; const Pel val = refMain[refLength + multiRefIdx]; for (int z = 1; z <= maxIndex; z++) { @@ -594,12 +598,51 @@ void IntraPrediction::xPredIntraAng( PelBuf& pDst, const CPelBuf& pSrc, const Ch } else { - if ( !isIntegerSlope( abs(intraPredAngle) ) ) + if( !isIntegerSlope( abs( intraPredAngle ) ) ) { - int deltaPos = intraPredAngle * (1 + multiRefIdx); - if( isLuma(channelType) ) + int deltaPos = intraPredAngle * ( 1 + multiRefIdx ); + if( isLuma( channelType ) ) { - IntraPredAngleLuma( pDstBuf,dstStride,refMain,width,height,deltaPos,intraPredAngle,nullptr,!m_ipaParam.interpolationFlag,clpRng ); + if( width <= 2 ) + { + for( int y = 0, deltaPos = intraPredAngle * ( 1 + multiRefIdx ); + y < height; + y++, deltaPos += intraPredAngle, pDsty += dstStride ) + { + const int deltaInt = deltaPos >> 5; + const int deltaFract = deltaPos & 31; + + if( !isIntegerSlope( abs( intraPredAngle ) ) ) + { + const bool useCubicFilter = !m_ipaParam.interpolationFlag; + + const TFilterCoeff intraSmoothingFilter[4] = { TFilterCoeff( 16 - ( deltaFract >> 1 ) ), + TFilterCoeff( 32 - ( deltaFract >> 1 ) ), + TFilterCoeff( 16 + ( deltaFract >> 1 ) ), + TFilterCoeff( ( deltaFract >> 1 ) ) }; + const TFilterCoeff* const f = + ( useCubicFilter ) ? InterpolationFilter::getChromaFilterTable( deltaFract ) : intraSmoothingFilter; + + for( int x = 0; x < width; x++ ) + { + Pel p[4]; + + p[0] = refMain[deltaInt + x + 0]; + p[1] = refMain[deltaInt + x + 1]; + p[2] = refMain[deltaInt + x + 2]; + p[3] = refMain[deltaInt + x + 3]; + + Pel val = ( f[0] * p[0] + f[1] * p[1] + f[2] * p[2] + f[3] * p[3] + 32 ) >> 6; + + pDsty[x] = ClipPel( val, clpRng ); // always clip even though not always needed + } + } + } + } + else + { + IntraPredAngleLuma(pDstBuf, dstStride, refMain, width, height, deltaPos, intraPredAngle, nullptr, !m_ipaParam.interpolationFlag, clpRng); + } } else { @@ -630,12 +673,48 @@ void IntraPrediction::xPredIntraAng( PelBuf& pDst, const CPelBuf& pSrc, const Ch } } +void IntraPrediction::xPredIntraBDPCM(PelBuf& pDst, const CPelBuf& pSrc, const uint32_t dirMode, const ClpRng& clpRng) +{ + const int wdt = pDst.width; + const int hgt = pDst.height; + + const int strideP = pDst.stride; + const int strideS = pSrc.stride; + + CHECK(!(dirMode == 1 || dirMode == 2), "Incorrect BDPCM mode parameter."); + + Pel* pred = &pDst.buf[0]; + if (dirMode == 1) + { + Pel val; + for (int y = 0; y < hgt; y++) + { + val = pSrc.buf[(y + 1) + strideS]; + for (int x = 0; x < wdt; x++) + { + pred[x] = val; + } + pred += strideP; + } + } + else + { + for (int y = 0; y < hgt; y++) + { + for (int x = 0; x < wdt; x++) + { + pred[x] = pSrc.buf[x + 1]; + } + pred += strideP; + } + } +} inline bool isAboveLeftAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLT ); -inline int isAboveAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t uiNumUnitsInPU, const uint32_t unitWidth, bool *validFlags ); -inline int isLeftAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t uiNumUnitsInPU, const uint32_t unitWidth, bool *validFlags ); -inline int isAboveRightAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posRT, const uint32_t uiNumUnitsInPU, const uint32_t unitHeight, bool *validFlags ); -inline int isBelowLeftAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLB, const uint32_t uiNumUnitsInPU, const uint32_t unitHeight, bool *validFlags ); +inline int isAboveAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t numUnits, const uint32_t unitWidth, bool *validFlags ); +inline int isLeftAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t numUnits, const uint32_t unitWidth, bool *validFlags ); +inline int isAboveRightAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posRT, const uint32_t numUnits, const uint32_t unitHeight, bool *validFlags ); +inline int isBelowLeftAvailable ( const CodingUnit &cu, const ChannelType& chType, const Position& posLB, const uint32_t numUnits, const uint32_t unitHeight, bool *validFlags ); void IntraPrediction::initIntraPatternChType(const CodingUnit &cu, const CompArea& area, const bool forceRefFilterFlag) { @@ -643,18 +722,20 @@ void IntraPrediction::initIntraPatternChType(const CodingUnit &cu, const CompAre if (!forceRefFilterFlag) { - initPredIntraParams(*cu.pu, area, *cs.sps); + initPredIntraParams(cu, area, *cs.sps); } Pel *refBufUnfiltered = m_refBuffer[area.compID][PRED_BUF_UNFILTERED]; Pel *refBufFiltered = m_refBuffer[area.compID][PRED_BUF_FILTERED]; + setReferenceArrayLengths(area); + // ----- Step 1: unfiltered reference samples ----- xFillReferenceSamples( cs.picture->getRecoBuf( area ), refBufUnfiltered, area, cu ); // ----- Step 2: filtered reference samples ----- if( m_ipaParam.refFilterFlag || forceRefFilterFlag ) { - xFilterReferenceSamples( refBufUnfiltered, refBufFiltered, area, *cs.sps, cu.pu->multiRefIdx ); + xFilterReferenceSamples( refBufUnfiltered, refBufFiltered, area, *cs.sps, cu.multiRefIdx ); } } @@ -671,12 +752,12 @@ void IntraPrediction::xFillReferenceSamples( const CPelBuf& recoBuf, Pel* refBuf const SPS &sps = *cs.sps; const PreCalcValues &pcv = *cs.pcv; - const int multiRefIdx = (area.compID == COMP_Y) ? cu.pu->multiRefIdx : 0; + const int multiRefIdx = (area.compID == COMP_Y) ? cu.multiRefIdx : 0; const int tuWidth = area.width; const int tuHeight = area.height; - const int predSize = 2*area.width; - const int predHSize = 2*area.height; + const int predSize = m_topRefLength; + const int predHSize = m_leftRefLength; const int predStride = predSize + 1 + multiRefIdx; m_refBufferStride[area.compID] = predStride; @@ -913,8 +994,8 @@ void IntraPrediction::xFilterReferenceSamples( const Pel* refBufUnfiltered, Pel* { multiRefIdx = 0; } - const int predSize = 2*area.width + multiRefIdx; - const int predHSize = 2*area.height + multiRefIdx; + const int predSize = m_topRefLength + multiRefIdx; + const int predHSize = m_leftRefLength + multiRefIdx; const int predStride = stride == 0 ? predSize + 1 : stride; @@ -947,21 +1028,16 @@ bool isAboveLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const const CodingStructure& cs = *cu.cs; const Position refPos = posLT.offset(-1, -1); - if (!cs.isDecomp(refPos, chType)) - { - return false; - } - return (cs.getCURestricted(refPos, cu, chType) != NULL); } -int isAboveAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t uiNumUnitsInPU, const uint32_t unitWidth, bool *bValidFlags) +int isAboveAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t numUnits, const uint32_t unitWidth, bool *bValidFlags) { const CodingStructure& cs = *cu.cs; bool * validFlags = bValidFlags; int numIntra = 0; - const int maxDx = uiNumUnitsInPU * unitWidth; + const int maxDx = numUnits * unitWidth; unsigned checkPosX = 0; bool valid = false; @@ -971,11 +1047,6 @@ int isAboveAvailable(const CodingUnit &cu, const ChannelType& chType, const Posi { const Position refPos = posLT.offset(dx, -1); - if (!cs.isDecomp(refPos, chType)) - { - break; - } - const CodingUnit* cuN = cs.getCURestricted(refPos, cu, chType); valid = (cuN != NULL); if( cuN ) checkPosX = chType == CH_C ? (cuN->Cb().x + cuN->Cb().width - posLT.x) : (cuN->Y().x + cuN->Y().width - posLT.x); @@ -990,13 +1061,13 @@ int isAboveAvailable(const CodingUnit &cu, const ChannelType& chType, const Posi return numIntra; } -int isLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t uiNumUnitsInPU, const uint32_t unitHeight, bool *bValidFlags) +int isLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posLT, const uint32_t numUnits, const uint32_t unitHeight, bool *bValidFlags) { const CodingStructure& cs = *cu.cs; bool * validFlags = bValidFlags; int numIntra = 0; - const int maxDy = uiNumUnitsInPU * unitHeight; + const int maxDy = numUnits * unitHeight; unsigned checkPosY = 0; bool valid = false; @@ -1006,11 +1077,6 @@ int isLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const Posit { const Position refPos = posLT.offset(-1, dy); - if (!cs.isDecomp(refPos, chType)) - { - break; - } - const CodingUnit* cuN = cs.getCURestricted(refPos, cu, chType); valid = (cuN != NULL); if( cuN ) checkPosY = chType == CH_C ? (cuN->Cb().y + cuN->Cb().height - posLT.y) : (cuN->Y().y + cuN->Y().height - posLT.y); @@ -1024,13 +1090,13 @@ int isLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const Posit return numIntra; } -int isAboveRightAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posRT, const uint32_t uiNumUnitsInPU, const uint32_t unitWidth, bool *bValidFlags ) +int isAboveRightAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posRT, const uint32_t numUnits, const uint32_t unitWidth, bool *bValidFlags ) { const CodingStructure& cs = *cu.cs; bool * validFlags = bValidFlags; int numIntra = 0; - const int maxDx = uiNumUnitsInPU * unitWidth; + const int maxDx = numUnits * unitWidth; unsigned checkPosX = 0; bool valid = false; @@ -1040,11 +1106,6 @@ int isAboveRightAvailable(const CodingUnit &cu, const ChannelType& chType, const { const Position refPos = posRT.offset(unitWidth + dx, -1); - if (!cs.isDecomp(refPos, chType)) - { - break; - } - const CodingUnit* cuN = cs.getCURestricted(refPos, cu, chType); valid = (cuN != NULL); if(cuN) checkPosX = chType == CH_C ? (cuN->Cb().x + cuN->Cb().width - (posRT.x + unitWidth)) : (cuN->Y().x + cuN->Y().width - (posRT.x + unitWidth)); @@ -1058,13 +1119,13 @@ int isAboveRightAvailable(const CodingUnit &cu, const ChannelType& chType, const return numIntra; } -int isBelowLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posLB, const uint32_t uiNumUnitsInPU, const uint32_t unitHeight, bool *bValidFlags ) +int isBelowLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const Position& posLB, const uint32_t numUnits, const uint32_t unitHeight, bool *bValidFlags ) { const CodingStructure& cs = *cu.cs; bool * validFlags = bValidFlags; int numIntra = 0; - const int maxDy = uiNumUnitsInPU * unitHeight; + const int maxDy = numUnits * unitHeight; unsigned checkPosY = 0; bool valid = false; @@ -1074,11 +1135,6 @@ int isBelowLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const { const Position refPos = posLB.offset(-1, unitHeight + dy); - if (!cs.isDecomp(refPos, chType)) - { - break; - } - const CodingUnit* cuN = cs.getCURestricted(refPos, cu, chType); valid = (cuN != NULL); if( cuN ) checkPosY = chType == CH_C ? (cuN->Cb().y + cuN->Cb().height - (posLB.y + unitHeight)) : (cuN->Y().y + cuN->Y().height - (posLB.y + unitHeight)); @@ -1093,31 +1149,28 @@ int isBelowLeftAvailable(const CodingUnit &cu, const ChannelType& chType, const } // LumaRecPixels -void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea& chromaArea ) +void IntraPrediction::loadLMLumaRecPels(const CodingUnit& cu, const CompArea& chromaArea ) { int iDstStride = 2 * MAX_TB_SIZEY + 1; Pel* pDst0 = m_pMdlmTemp + iDstStride + 1; //assert 420 chroma subsampling - CompArea lumaArea = CompArea( COMP_Y, pu.chromaFormat, chromaArea.lumaPos(), recalcSize( pu.chromaFormat, CH_C, CH_L, chromaArea.size() ) );//needed for correct pos/size (4x4 Tus) + CompArea lumaArea = CompArea( COMP_Y, cu.chromaFormat, chromaArea.lumaPos(), recalcSize( cu.chromaFormat, CH_C, CH_L, chromaArea.size() ) );//needed for correct pos/size (4x4 Tus) - CHECK(lumaArea.width == chromaArea.width && CHROMA_444 != pu.chromaFormat, ""); - CHECK(lumaArea.height == chromaArea.height && CHROMA_444 != pu.chromaFormat && CHROMA_422 != pu.chromaFormat, ""); + CHECK(lumaArea.width == chromaArea.width && CHROMA_444 != cu.chromaFormat, ""); + CHECK(lumaArea.height == chromaArea.height && CHROMA_444 != cu.chromaFormat && CHROMA_422 != cu.chromaFormat, ""); const SizeType uiCWidth = chromaArea.width; const SizeType uiCHeight = chromaArea.height; - const CPelBuf Src = pu.cs->picture->getRecoBuf( lumaArea ); + const CPelBuf Src = cu.cs->picture->getRecoBuf( lumaArea ); Pel const* pRecSrc0 = Src.bufAt( 0, 0 ); int iRecStride = Src.stride; - int logSubWidthC = getChannelTypeScaleX(CH_C, pu.chromaFormat); - int logSubHeightC = getChannelTypeScaleY(CH_C, pu.chromaFormat); + int logSubWidthC = getChannelTypeScaleX(CH_C, cu.chromaFormat); + int logSubHeightC = getChannelTypeScaleY(CH_C, cu.chromaFormat); int iRecStride2 = iRecStride << logSubHeightC; - const CodingUnit& lumaCU = isChroma( pu.chType ) ? *pu.cs->picture->cs->getCU( lumaArea.pos(), CH_L, TREE_D ) : *pu.cu; - const CodingUnit& cu = *pu.cu; - - const CompArea& area = isChroma( pu.chType ) ? chromaArea : lumaArea; + const CompArea& area = isChroma( cu.chType ) ? chromaArea : lumaArea; const uint32_t uiTuWidth = area.width; const uint32_t uiTuHeight = area.height; @@ -1149,44 +1202,43 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea bool bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1]; memset(bNeighborFlags, 0, totalUnits); bool aboveIsAvailable, leftIsAvailable; - const CodingUnit& chromaCU = isChroma( pu.chType ) ? cu : lumaCU; const ChannelType areaCh = toChannelType( area.compID ); - int availlableUnit = isLeftAvailable(chromaCU, areaCh, area.pos(), iLeftUnits, unitHeight, (bNeighborFlags + iLeftUnits + leftBelowUnits - 1)); + int availlableUnit = isLeftAvailable(cu, areaCh, area.pos(), iLeftUnits, unitHeight, (bNeighborFlags + iLeftUnits + leftBelowUnits - 1)); leftIsAvailable = availlableUnit == iTUHeightInUnits; - availlableUnit = isAboveAvailable(chromaCU, areaCh, area.pos(), iAboveUnits, unitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + 1)); + availlableUnit = isAboveAvailable(cu, areaCh, area.pos(), iAboveUnits, unitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + 1)); aboveIsAvailable = availlableUnit == iTUWidthInUnits; if (leftIsAvailable) // if left is not available, then the below left is not available { - avaiLeftBelowUnits = isBelowLeftAvailable(chromaCU, areaCh, area.bottomLeftComp(area.compID), leftBelowUnits, unitHeight, (bNeighborFlags + leftBelowUnits - 1)); + avaiLeftBelowUnits = isBelowLeftAvailable(cu, areaCh, area.bottomLeftComp(area.compID), leftBelowUnits, unitHeight, (bNeighborFlags + leftBelowUnits - 1)); } if (aboveIsAvailable) // if above is not available, then the above right is not available. { - avaiAboveRightUnits = isAboveRightAvailable(chromaCU, areaCh, area.topRightComp(area.compID), aboveRightUnits, unitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + iAboveUnits + 1)); + avaiAboveRightUnits = isAboveRightAvailable(cu, areaCh, area.topRightComp(area.compID), aboveRightUnits, unitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + iAboveUnits + 1)); } Pel* pDst = nullptr; Pel const* piSrc = nullptr; - bool isFirstRowOfCtu = (lumaArea.y & ((pu.cs->sps)->CTUSize - 1)) == 0; + bool isFirstRowOfCtu = (lumaArea.y & ((cu.cs->sps)->CTUSize - 1)) == 0; if (aboveIsAvailable) { pDst = pDst0 - iDstStride; int addedAboveRight = 0; - if ((pu.intraDir[1] == MDLM_L_IDX) || (pu.intraDir[1] == MDLM_T_IDX)) + if ((cu.intraDir[1] == MDLM_L_IDX) || (cu.intraDir[1] == MDLM_T_IDX)) { addedAboveRight = avaiAboveRightUnits*chromaUnitWidth; } for (int i = 0; i < uiCWidth + addedAboveRight; i++) { const bool leftPadding = i == 0 && !leftIsAvailable; - if (pu.chromaFormat == CHROMA_444) + if (cu.chromaFormat == CHROMA_444) { piSrc = pRecSrc0 - iRecStride; pDst[i] = piSrc[i]; @@ -1196,7 +1248,7 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea piSrc = pRecSrc0 - iRecStride; pDst[i] = (piSrc[2 * i] * 2 + piSrc[2 * i - (leftPadding ? 0 : 1)] + piSrc[2 * i + 1] + 2) >> 2; } - else if (pu.chromaFormat == CHROMA_422) + else if (cu.chromaFormat == CHROMA_422) { piSrc = pRecSrc0 - iRecStride2; @@ -1206,7 +1258,7 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea s += piSrc[2 * i + 1]; pDst[i] = s >> 2; } - else if (pu.cs->sps->verCollocatedChroma ) + else if (cu.cs->sps->verCollocatedChroma ) { piSrc = pRecSrc0 - iRecStride2; @@ -1239,18 +1291,18 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea piSrc = pRecSrc0 - 1 - logSubWidthC; int addedLeftBelow = 0; - if ((pu.intraDir[1] == MDLM_L_IDX) || (pu.intraDir[1] == MDLM_T_IDX)) + if ((cu.intraDir[1] == MDLM_L_IDX) || (cu.intraDir[1] == MDLM_T_IDX)) { addedLeftBelow = avaiLeftBelowUnits*chromaUnitHeight; } for (int j = 0; j < uiCHeight + addedLeftBelow; j++) { - if (pu.chromaFormat == CHROMA_444) + if (cu.chromaFormat == CHROMA_444) { pDst[0] = piSrc[0]; } - else if (pu.chromaFormat == CHROMA_422) + else if (cu.chromaFormat == CHROMA_422) { int s = 2; s += piSrc[0] * 2; @@ -1258,7 +1310,7 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea s += piSrc[1]; pDst[0] = s >> 2; } - else if (pu.cs->sps->verCollocatedChroma) + else if (cu.cs->sps->verCollocatedChroma) { const bool abovePadding = j == 0 && !aboveIsAvailable; @@ -1292,11 +1344,11 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea { for( int i = 0; i < uiCWidth; i++ ) { - if (pu.chromaFormat == CHROMA_444) + if (cu.chromaFormat == CHROMA_444) { pDst0[i] = pRecSrc0[i]; } - else if (pu.chromaFormat == CHROMA_422) + else if (cu.chromaFormat == CHROMA_422) { const bool leftPadding = i == 0 && !leftIsAvailable; @@ -1306,7 +1358,7 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea s += pRecSrc0[2 * i + 1]; pDst0[i] = s >> 2; } - else if (pu.cs->sps->verCollocatedChroma) + else if (cu.cs->sps->verCollocatedChroma) { const bool leftPadding = i == 0 && !leftIsAvailable; const bool abovePadding = j == 0 && !aboveIsAvailable; @@ -1321,7 +1373,7 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea } else { - CHECK(pu.chromaFormat != CHROMA_420, "Chroma format must be 4:2:0 for vertical filtering"); + CHECK(cu.chromaFormat != CHROMA_420, "Chroma format must be 4:2:0 for vertical filtering"); const bool leftPadding = i == 0 && !leftIsAvailable; int s = 4; @@ -1340,7 +1392,7 @@ void IntraPrediction::loadLMLumaRecPels(const PredictionUnit &pu, const CompArea } } -void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const ComponentID compID, +void IntraPrediction::xGetLMParameters(const CodingUnit& cu, const ComponentID compID, const CompArea& chromaArea, int& a, int& b, int& iShift) { @@ -1351,8 +1403,7 @@ void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const Component const Position posLT = chromaArea; - CodingStructure & cs = *(pu.cs); - const CodingUnit &cu = *(pu.cu); + CodingStructure & cs = *(cu.cs); const SPS & sps = *cs.sps; const uint32_t tuWidth = chromaArea.width; @@ -1380,7 +1431,7 @@ void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const Component int avaiAboveUnits = 0; int avaiLeftUnits = 0; - const int curChromaMode = pu.intraDir[1]; + const int curChromaMode = cu.intraDir[1]; bool neighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1]; memset(neighborFlags, 0, totalUnits); @@ -1540,9 +1591,9 @@ void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const Component } } -void IntraPrediction::initIntraMip( const PredictionUnit &pu ) +void IntraPrediction::initIntraMip( const CodingUnit& cu ) { - CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" ); + CHECK( cu.lwidth() > cu.cs->sps->getMaxTbSize() || cu.lheight() > cu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" ); // prepare input (boundary) data for prediction CHECK(m_ipaParam.refFilterFlag, "ERROR: unfiltered refs expected for MIP"); @@ -1550,20 +1601,150 @@ void IntraPrediction::initIntraMip( const PredictionUnit &pu ) const int srcStride = m_refBufferStride[COMP_Y]; const int srcHStride = 2; - m_matrixIntraPred.prepareInputForPred(CPelBuf(ptrSrc, srcStride, srcHStride), pu.Y(), pu.cu->slice->sps->bitDepths[CH_L]); + m_matrixIntraPred.prepareInputForPred(CPelBuf(ptrSrc, srcStride, srcHStride), cu.Y(), cu.slice->sps->bitDepths[CH_L]); } -void IntraPrediction::predIntraMip( PelBuf &piPred, const PredictionUnit &pu ) +void IntraPrediction::predIntraMip( PelBuf &piPred, const CodingUnit& cu ) { - CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" ); - CHECK( pu.lwidth() != (1 << floorLog2(pu.lwidth())) || pu.lheight() != (1 << floorLog2(pu.lheight())), "Error: expecting blocks of size 2^M x 2^N" ); + CHECK( cu.lwidth() > cu.cs->sps->getMaxTbSize() || cu.lheight() > cu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" ); + CHECK( cu.lwidth() != (1 << floorLog2(cu.lwidth())) || cu.lheight() != (1 << floorLog2(cu.lheight())), "Error: expecting blocks of size 2^M x 2^N" ); // generate mode-specific prediction - const int bitDepth = pu.cu->slice->sps->bitDepths[CH_L]; + const int bitDepth = cu.slice->sps->bitDepths[CH_L]; - CHECK( pu.lwidth() != piPred.stride, " no support yet" ); + CHECK( cu.lwidth() != piPred.stride, " no support yet" ); - m_matrixIntraPred.predBlock(piPred.buf, pu.intraDir[CH_L], pu.mipTransposedFlag, bitDepth); + m_matrixIntraPred.predBlock(piPred.buf, cu.intraDir[CH_L], cu.mipTransposedFlag, bitDepth); +} + +void IntraPrediction::initIntraPatternChTypeISP(const CodingUnit& cu, const CompArea& area, PelBuf& recBuf, + const bool forceRefFilterFlag) +{ + const CodingStructure& cs = *cu.cs; + + if (!forceRefFilterFlag) + { + initPredIntraParams(cu, area, *cs.sps); + } + + const Position posLT = area; + bool isLeftAvail = + (cs.getCURestricted(posLT.offset(-1, 0), cu, CH_L) != NULL); + bool isAboveAvail = + (cs.getCURestricted(posLT.offset(0, -1), cu, CH_L) != NULL); + // ----- Step 1: unfiltered reference samples ----- + if (cu.blocks[area.compID].x == area.x && cu.blocks[area.compID].y == area.y) + { + Pel* refBufUnfiltered = m_refBuffer[area.compID][PRED_BUF_UNFILTERED]; + // With the first subpartition all the CU reference samples are fetched at once in a single call to + // xFillReferenceSamples + if (cu.ispMode == HOR_INTRA_SUBPARTITIONS) + { + m_leftRefLength = cu.Y().height << 1; + m_topRefLength = cu.Y().width + area.width; + } + else // if (cu.ispMode == VER_INTRA_SUBPARTITIONS) + { + m_leftRefLength = cu.Y().height + area.height; + m_topRefLength = cu.Y().width << 1; + } + + xFillReferenceSamples(cs.picture->getRecoBuf(cu.Y()), refBufUnfiltered, cu.Y(), cu); + + // After having retrieved all the CU reference samples, the number of reference samples is now adjusted for the + // current subpartition + m_topRefLength = cu.blocks[area.compID].width + area.width; + m_leftRefLength = cu.blocks[area.compID].height + area.height; + } + else + { + m_topRefLength = cu.blocks[area.compID].width + area.width; + m_leftRefLength = cu.blocks[area.compID].height + area.height; + + const int predSizeHor = m_topRefLength; + const int predSizeVer = m_leftRefLength; + if (cu.ispMode == HOR_INTRA_SUBPARTITIONS) + { + Pel* src = recBuf.bufAt(0, -1); + Pel* ref = m_refBuffer[area.compID][PRED_BUF_UNFILTERED] + m_refBufferStride[area.compID]; + if (isLeftAvail) + { + for (int i = 0; i <= 2 * cu.blocks[area.compID].height - area.height; i++) + { + ref[i] = ref[i + area.height]; + } + } + else + { + for (int i = 0; i <= predSizeVer; i++) + { + ref[i] = src[0]; + } + } + Pel* dst = m_refBuffer[area.compID][PRED_BUF_UNFILTERED] + 1; + dst[-1] = ref[0]; + for (int i = 0; i < area.width; i++) + { + dst[i] = src[i]; + } + Pel sample = src[area.width - 1]; + dst += area.width; + for (int i = 0; i < predSizeHor - area.width; i++) + { + dst[i] = sample; + } + } + else + { + Pel* src = recBuf.bufAt(-1, 0); + Pel* ref = m_refBuffer[area.compID][PRED_BUF_UNFILTERED]; + if (isAboveAvail) + { + for (int i = 0; i <= 2 * cu.blocks[area.compID].width - area.width; i++) + { + ref[i] = ref[i + area.width]; + } + } + else + { + for (int i = 0; i <= predSizeHor; i++) + { + ref[i] = src[0]; + } + } + Pel* dst = m_refBuffer[area.compID][PRED_BUF_UNFILTERED] + m_refBufferStride[area.compID] + 1; + dst[-1] = ref[0]; + for (int i = 0; i < area.height; i++) + { + *dst = *src; + src += recBuf.stride; + dst++; + } + Pel sample = src[-recBuf.stride]; + for (int i = 0; i < predSizeVer - area.height; i++) + { + *dst = sample; + dst++; + } + } + } + // ----- Step 2: filtered reference samples ----- + if (m_ipaParam.refFilterFlag || forceRefFilterFlag) + { + Pel* refBufUnfiltered = m_refBuffer[area.compID][PRED_BUF_UNFILTERED]; + Pel* refBufFiltered = m_refBuffer[area.compID][PRED_BUF_FILTERED]; + xFilterReferenceSamples(refBufUnfiltered, refBufFiltered, area, *cs.sps, cu.multiRefIdx); + } +} + +void IntraPrediction::setReferenceArrayLengths(const CompArea& area) +{ + // set Top and Left reference samples length + const int width = area.width; + const int height = area.height; + + m_leftRefLength = (height << 1); + m_topRefLength = (width << 1); } } // namespace vvenc diff --git a/source/Lib/CommonLib/IntraPrediction.h b/source/Lib/CommonLib/IntraPrediction.h index 2766b5cf5..daf08ef5c 100644 --- a/source/Lib/CommonLib/IntraPrediction.h +++ b/source/Lib/CommonLib/IntraPrediction.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file IntraPrediction.h \brief prediction class (header) */ @@ -111,6 +115,10 @@ class IntraPrediction protected: ChromaFormat m_currChromaFormat; + int m_topRefLength; + int m_leftRefLength; + void setReferenceArrayLengths(const CompArea& area); + private: static bool isIntegerSlope ( const int absAng) { return (0 == (absAng & 0x1F)); } static int getWideAngle ( int width, int height, int predMode ); @@ -120,10 +128,11 @@ class IntraPrediction void xPredIntraDc ( PelBuf& pDst, const CPelBuf& pSrc ); void xPredIntraAng ( PelBuf& pDst, const CPelBuf& pSrc, const ChannelType channelType, const ClpRng& clpRng); Pel xGetPredValDc ( const CPelBuf& pSrc, const Size& dstSize ); + void xPredIntraBDPCM ( PelBuf& pDst, const CPelBuf& pSrc, const uint32_t dirMode, const ClpRng& clpRng ); void xFillReferenceSamples ( const CPelBuf& recoBuf, Pel* refBufUnfiltered, const CompArea& area, const CodingUnit &cu ); void xFilterReferenceSamples ( const Pel* refBufUnfiltered, Pel* refBufFiltered, const CompArea& area, const SPS &sps, int multiRefIdx, int predStride = 0 ); - void xGetLMParameters(const PredictionUnit &pu, const ComponentID compID, const CompArea& chromaArea, int& a, int& b, int& iShift); + void xGetLMParameters(const CodingUnit& cu, const ComponentID compID, const CompArea& chromaArea, int& a, int& b, int& iShift); void ( *IntraPredAngleLuma ) ( Pel* pDstBuf, const ptrdiff_t dstStride, Pel* refMain, int width, int height, int deltaPos, int intraPredAngle, const TFilterCoeff *ff, const bool useCubicFilter, const ClpRng& clpRng); void ( *IntraPredAngleChroma ) ( Pel* pDst, const ptrdiff_t dstStride, Pel* pBorder, int width, int height, int deltaPos, int intraPredAngle); @@ -145,32 +154,33 @@ class IntraPrediction void reset (); void destroy (); - void initPredIntraParams ( const PredictionUnit & pu, const CompArea compArea, const SPS& sps ); + void initPredIntraParams ( const CodingUnit& cu, const CompArea compArea, const SPS& sps ); // Angular Intra - void predIntraAng ( const ComponentID compId, PelBuf& piPred, const PredictionUnit &pu); + void predIntraAng ( const ComponentID compId, PelBuf& piPred, const CodingUnit& cu); Pel* getPredictorPtr ( const ComponentID compId ) { return m_refBuffer[compId][m_ipaParam.refFilterFlag ? PRED_BUF_FILTERED : PRED_BUF_UNFILTERED]; } // Cross-component Chroma - void predIntraChromaLM ( const ComponentID compID, PelBuf& piPred, const PredictionUnit &pu, const CompArea& chromaArea, int intraDir); - void loadLMLumaRecPels ( const PredictionUnit &pu, const CompArea& chromaArea ); + void predIntraChromaLM ( const ComponentID compID, PelBuf& piPred, const CodingUnit& cu, const CompArea& chromaArea, int intraDir); + void loadLMLumaRecPels ( const CodingUnit& cu, const CompArea& chromaArea ); /// set parameters from CU data for accessing intra data void initIntraPatternChType ( const CodingUnit &cu, const CompArea& area, const bool forceRefFilterFlag = false); // use forceRefFilterFlag to get both filtered and unfiltered buffers + void initIntraPatternChTypeISP( const CodingUnit& cu, const CompArea& area, PelBuf& piReco, const bool forceRefFilterFlag = false ); // Matrix-based intra prediction - void initIntraMip ( const PredictionUnit &pu); - void predIntraMip ( PelBuf &piPred, const PredictionUnit &pu); + void initIntraMip ( const CodingUnit& cu); + void predIntraMip ( PelBuf &piPred, const CodingUnit& cu); - int getNumIntraCiip ( const PredictionUnit& pu ) + int getNumIntraCiip ( const CodingUnit& cu ) { - const Position posBL = pu.Y().bottomLeft(); - const Position posTR = pu.Y().topRight(); - const PredictionUnit *neigh0 = pu.cs->getPURestricted(posBL.offset(-1, 0), pu, CH_L); - const PredictionUnit *neigh1 = pu.cs->getPURestricted(posTR.offset(0, -1), pu, CH_L); + const Position posBL = cu.Y().bottomLeft(); + const Position posTR = cu.Y().topRight(); + const CodingUnit *neigh0 = cu.cs->getCURestricted(posBL.offset(-1, 0), cu, CH_L); + const CodingUnit *neigh1 = cu.cs->getCURestricted(posTR.offset(0, -1), cu, CH_L); int numIntra = 0; - numIntra += (neigh0 && (neigh0->cu->predMode == MODE_INTRA))?1:0; - numIntra += (neigh1 && (neigh1->cu->predMode == MODE_INTRA))?1:0; + numIntra += (neigh0 && (neigh0->predMode == MODE_INTRA))?1:0; + numIntra += (neigh1 && (neigh1->predMode == MODE_INTRA))?1:0; return numIntra; } diff --git a/source/Lib/CommonLib/LoopFilter.cpp b/source/Lib/CommonLib/LoopFilter.cpp index 3439c49d3..66e97aef9 100644 --- a/source/Lib/CommonLib/LoopFilter.cpp +++ b/source/Lib/CommonLib/LoopFilter.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file LoopFilter.cpp @@ -808,13 +812,11 @@ void LoopFilter::calcFilterStrengths( const CodingUnit& cu, bool clearLF ) static constexpr int subBlockSize = 8; - const PredictionUnit& currPU = *cu.pu; - const Area& areaPu = area; LFCUParam stLFCUParam { xGetLoopfilterParam( cu ) }; const UnitScale scaling = cu.cs->getScaling( UnitScale::LF_PARAM_MAP, cu.chType ); // for SUBPU ATMVP and Affine, more PU deblocking needs to be found, for ISP the chroma block will be deferred to the last luma block, // so the processing order is different. For all other cases the boundary strenght can be directly obtained in the TU loop. - const bool refineBs = ( currPU.mergeFlag && currPU.mergeType == MRG_TYPE_SUBPU_ATMVP ) || cu.affine || cu.ispMode; + const bool refineBs = ( cu.mergeFlag && cu.mergeType == MRG_TYPE_SUBPU_ATMVP ) || cu.affine || cu.ispMode; const int maskBlkX = ~( ( 1 << scaling.posx ) - 1 ); const int maskBlkY = ~( ( 1 << scaling.posy ) - 1 ); @@ -840,11 +842,11 @@ void LoopFilter::calcFilterStrengths( const CodingUnit& cu, bool clearLF ) if( !refineBs ) return; - if( ( currPU.mergeFlag && currPU.mergeType == MRG_TYPE_SUBPU_ATMVP ) || cu.affine ) + if( ( cu.mergeFlag && cu.mergeType == MRG_TYPE_SUBPU_ATMVP ) || cu.affine ) { CHECK( cu.chType != CH_L, "This path is only valid for single tree blocks!" ); - for( int off = subBlockSize; off < areaPu.width; off += subBlockSize ) + for( int off = subBlockSize; off < area.width; off += subBlockSize ) { const Area mvBlockV( cu.Y().x + off, cu.Y().y, subBlockSize, cu.Y().height ); verEdgeFilter = true; @@ -861,7 +863,7 @@ void LoopFilter::calcFilterStrengths( const CodingUnit& cu, bool clearLF ) xSetMaxFilterLengthPQForCodingSubBlocks( cu ); - for( int off = subBlockSize; off < areaPu.height; off += subBlockSize ) + for( int off = subBlockSize; off < area.height; off += subBlockSize ) { const Area mvBlockH( cu.Y().x, cu.Y().y + off, cu.Y().width, subBlockSize ); horEdgeFilter = true; @@ -1259,7 +1261,7 @@ void xGetBoundaryStrengthSingle( LoopFilterParam& lfp, const CodingUnit& cuQ, co if( cuPcIsIntra ) { - chrmBS = ( MODE_INTRA == cuPc.predMode && cuPc.bdpcmModeChroma ) && ( MODE_INTRA == cuQ.predMode && cuQ.bdpcmModeChroma ) ? 0 : 2; + chrmBS = ( MODE_INTRA == cuPc.predMode && cuPc.bdpcmM[CH_C] ) && ( MODE_INTRA == cuQ.predMode && cuQ.bdpcmM[CH_C] ) ? 0 : 2; } } @@ -1273,7 +1275,7 @@ void xGetBoundaryStrengthSingle( LoopFilterParam& lfp, const CodingUnit& cuQ, co { const int edgeIdx = ( perpPos( localPos ) - perpPos( cuPos ) ) / 4; - int bsY = ( MODE_INTRA == cuP.predMode && cuP.bdpcmMode ) && ( MODE_INTRA == cuQ.predMode && cuQ.bdpcmMode ) ? 0 : 2; + int bsY = ( MODE_INTRA == cuP.predMode && cuP.bdpcmM[CH_L] ) && ( MODE_INTRA == cuQ.predMode && cuQ.bdpcmM[CH_L] ) ? 0 : 2; if( cuQ.ispMode && edgeIdx ) { @@ -1291,7 +1293,7 @@ void xGetBoundaryStrengthSingle( LoopFilterParam& lfp, const CodingUnit& cuQ, co lfp.bs |= ( BsSet( chrmBS, COMP_Cb ) + BsSet( chrmBS, COMP_Cr ) ); } - if( ( lfp.bs & bsMask ) && ( cuP.pu->ciip || cuQ.pu->ciip ) ) + if( ( lfp.bs & bsMask ) && ( cuP.ciip || cuQ.ciip ) ) { lfp.bs |= ( BsSet( 2, COMP_Y ) + BsSet( 2, COMP_Cb ) + BsSet( 2, COMP_Cr ) ) & bsMask; @@ -1315,7 +1317,7 @@ void xGetBoundaryStrengthSingle( LoopFilterParam& lfp, const CodingUnit& cuQ, co return; } - if( cuP.pu->ciip || cuQ.pu->ciip ) + if( cuP.ciip || cuQ.ciip ) { lfp.bs |= 1 & bsMask; diff --git a/source/Lib/CommonLib/LoopFilter.h b/source/Lib/CommonLib/LoopFilter.h index 0ebacae25..8bf836554 100644 --- a/source/Lib/CommonLib/LoopFilter.h +++ b/source/Lib/CommonLib/LoopFilter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file LoopFilter.h \brief deblocking filter (header) */ diff --git a/source/Lib/CommonLib/MCTF.cpp b/source/Lib/CommonLib/MCTF.cpp index fcbc1be82..0936a326d 100644 --- a/source/Lib/CommonLib/MCTF.cpp +++ b/source/Lib/CommonLib/MCTF.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file MCTF.cpp @@ -125,8 +129,9 @@ int motionErrorLumaInt( const Pel* origOrigin, const ptrdiff_t origStride, const int motionErrorLumaFrac( const Pel* origOrigin, const ptrdiff_t origStride, const Pel* buffOrigin, const ptrdiff_t buffStride, const int bs, const int x, const int y, const int dx, const int dy, const int16_t* xFilter, const int16_t* yFilter, const int bitDepth, const int besterror ) { int error = 0; - int tempArray[64 + 8][64]; + Pel tempArray[64 + 8][64]; int sum, base; + const Pel maxSampleValue = ( 1 << bitDepth ) - 1; for( int y1 = 1; y1 < bs + 7; y1++ ) { @@ -145,11 +150,13 @@ int motionErrorLumaFrac( const Pel* origOrigin, const ptrdiff_t origStride, cons sum += xFilter[5] * rowStart[5]; sum += xFilter[6] * rowStart[6]; + sum = ( sum + ( 1 << 5 ) ) >> 6; + sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); + tempArray[y1][x1] = sum; } } - const Pel maxSampleValue = ( 1 << bitDepth ) - 1; for( int y1 = 0; y1 < bs; y1++ ) { const Pel* origRow = origOrigin + ( y + y1 )*origStride + 0; @@ -163,7 +170,7 @@ int motionErrorLumaFrac( const Pel* origOrigin, const ptrdiff_t origStride, cons sum += yFilter[5] * tempArray[y1 + 5][x1]; sum += yFilter[6] * tempArray[y1 + 6][x1]; - sum = ( sum + ( 1 << 11 ) ) >> 12; + sum = ( sum + ( 1 << 5 ) ) >> 6; sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); error += ( sum - origRow[x + x1] ) * ( sum - origRow[x + x1] ); @@ -417,7 +424,7 @@ void MCTF::filter( Picture* pic ) bilateralFilter( origBuf, srcFrameInfo, fltrBuf, overallStrength ); } - fltrPic->isMctfFiltered = true; + fltrPic->isMctfProcessed = true; } // ==================================================================================================================== diff --git a/source/Lib/CommonLib/MCTF.h b/source/Lib/CommonLib/MCTF.h index da9fc686d..a2907b6c5 100644 --- a/source/Lib/CommonLib/MCTF.h +++ b/source/Lib/CommonLib/MCTF.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file MCTF.h \brief MCTF class (header) */ diff --git a/source/Lib/CommonLib/MD5.h b/source/Lib/CommonLib/MD5.h new file mode 100644 index 000000000..1dd5fc146 --- /dev/null +++ b/source/Lib/CommonLib/MD5.h @@ -0,0 +1,321 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ +#pragma once + +#include +#include +#include +#include + +//! \ingroup CommonLib +//! \{ + +namespace vvenc { + +static const uint32_t MD5_DIGEST_STRING_LENGTH=16; + + +#ifndef __BIG_ENDIAN__ +# define byteReverse(buf, len) /* Nothing */ +#else +void byteReverse(uint32_t *buf, unsigned len); +/* + * Note: this code is harmless on little-endian machines. + */ +void byteReverse(uint32_t *buf, unsigned len) +{ + uint32_t t; + do { + char* bytes = (char *) buf; + t = ((unsigned) bytes[3] << 8 | bytes[2]) << 16 | + ((unsigned) bytes[1] << 8 | bytes[0]); + *buf = t; + buf++; + } while (--len); +} +#endif + + +class MD5 +{ + +public: + typedef struct _context_md5_t { + uint32_t buf[4]; + uint32_t bits[2]; + union { + unsigned char b8[64]; + uint32_t b32[16]; + } in; + } context_md5_t; + + +public: + /** + * initialize digest state + */ + MD5() + { + ctx.buf[0] = 0x67452301; + ctx.buf[1] = 0xefcdab89; + ctx.buf[2] = 0x98badcfe; + ctx.buf[3] = 0x10325476; + + ctx.bits[0] = 0; + ctx.bits[1] = 0; + } + + /** + * compute digest over buf of length len. + * multiple calls may extend the digest over more data. + */ + void update(unsigned char *buf, unsigned len) + { + uint32_t t; + + /* Update bitcount */ + + t = ctx.bits[0]; + if ((ctx.bits[0] = t + ((uint32_t) len << 3)) < t) + ctx.bits[1]++; /* Carry from low to high */ + ctx.bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + + /* Handle any leading odd-sized chunks */ + + if (t) { + unsigned char *p = ctx.in.b8 + t; + + t = 64 - t; + if (len < t) { + ::memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx.in.b32, 16); + MD5Transform(ctx.buf, ctx.in.b32); + buf += t; + len -= t; + } + /* Process data in 64-byte chunks */ + + while (len >= 64) { + memcpy(ctx.in.b8, buf, 64); + byteReverse(ctx.in.b32, 16); + MD5Transform(ctx.buf, ctx.in.b32); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + + memcpy(ctx.in.b8, buf, len); + } + + /** + * flush any outstanding MD5 data, write the digest into digest. + */ + void finalize(unsigned char digest[MD5_DIGEST_STRING_LENGTH]) + { + unsigned count; + unsigned char *p; + + /* Compute number of bytes mod 64 */ + count = (ctx.bits[0] >> 3) & 0x3F; + + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx.in.b8 + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx.in.b32, 16); + MD5Transform(ctx.buf, ctx.in.b32); + + /* Now fill the next block with 56 bytes */ + memset(ctx.in.b8, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + byteReverse(ctx.in.b32, 14); + + /* Append length in bits and transform */ + ctx.in.b32[14] = ctx.bits[0]; + ctx.in.b32[15] = ctx.bits[1]; + + MD5Transform(ctx.buf, ctx.in.b32); + byteReverse((uint32_t *) ctx.buf, 4); + memcpy(digest, ctx.buf, 16); + + memset(&ctx, 0, sizeof( ctx)); /* In case it's sensitive */ + /* The original version of this code omitted the asterisk. In + effect, only the first part of ctx was wiped with zeros, not + the whole thing. Bug found by Derek Jones. Original line: */ + // memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + } + + +private: + + + /* The four core functions - F1 is optimized somewhat */ + + /* #define F1(x, y, z) (x & y | ~x & z) */ + #define F1(x, y, z) (z ^ (x & (y ^ z))) + #define F2(x, y, z) F1(z, x, y) + #define F3(x, y, z) (x ^ y ^ z) + #define F4(x, y, z) (y ^ (x | ~z)) + + /* This is the central step in the MD5 algorithm. */ + #define MD5STEP(f, w, x, y, z, data, s) \ + ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) + + + /* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ + static void MD5Transform(uint32_t buf[4], uint32_t const in[16]) + { + register uint32_t a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; + } + +private: + context_md5_t ctx; +}; + + +} // namespace vvenc + +//! \} + diff --git a/source/Lib/CommonLib/MatrixIntraPrediction.cpp b/source/Lib/CommonLib/MatrixIntraPrediction.cpp index 929136f48..6a833cc5d 100644 --- a/source/Lib/CommonLib/MatrixIntraPrediction.cpp +++ b/source/Lib/CommonLib/MatrixIntraPrediction.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file MatrixIntraPrediction.cpp diff --git a/source/Lib/CommonLib/MatrixIntraPrediction.h b/source/Lib/CommonLib/MatrixIntraPrediction.h index 3d5e8acee..43ec049ec 100644 --- a/source/Lib/CommonLib/MatrixIntraPrediction.h +++ b/source/Lib/CommonLib/MatrixIntraPrediction.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file MatrixIntraPrediction.h \brief matrix-based intra prediction class (header) */ diff --git a/source/Lib/CommonLib/MipData.h b/source/Lib/CommonLib/MipData.h index 9b95da049..ab20841d9 100644 --- a/source/Lib/CommonLib/MipData.h +++ b/source/Lib/CommonLib/MipData.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file MipData.h \brief weight and bias data for matrix-based intra prediction (MIP) */ diff --git a/source/Lib/CommonLib/MotionInfo.h b/source/Lib/CommonLib/MotionInfo.h index 26a9b8ff5..f9e8b14ad 100644 --- a/source/Lib/CommonLib/MotionInfo.h +++ b/source/Lib/CommonLib/MotionInfo.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file MotionInfo.h \brief motion information handling classes (header) \todo MvField seems to be better to be inherited from Mv diff --git a/source/Lib/CommonLib/Mv.cpp b/source/Lib/CommonLib/Mv.cpp index 1359c837a..a517c8120 100644 --- a/source/Lib/CommonLib/Mv.cpp +++ b/source/Lib/CommonLib/Mv.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Mv.cpp diff --git a/source/Lib/CommonLib/Mv.h b/source/Lib/CommonLib/Mv.h index d844990e8..fc34ecb58 100644 --- a/source/Lib/CommonLib/Mv.h +++ b/source/Lib/CommonLib/Mv.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Mv.h \brief motion vector class (header) */ diff --git a/source/Lib/CommonLib/PicYuvMD5.cpp b/source/Lib/CommonLib/PicYuvMD5.cpp index 38f73cddd..d66193040 100644 --- a/source/Lib/CommonLib/PicYuvMD5.cpp +++ b/source/Lib/CommonLib/PicYuvMD5.cpp @@ -1,50 +1,53 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ #include "PicYuvMD5.h" #include "Picture.h" -#include "SEI.h" -#include "libmd5/MD5.h" +#include "MD5.h" //! \ingroup CommonLib //! \{ @@ -286,7 +289,7 @@ int calcAndPrintHashStatus(const CPelUnitBuf& pic, const SEIDecodedPictureHash* if (pictureHashSEI) { ok = "(OK)"; - if (recon_digest != pictureHashSEI->m_pictureHash) + if (recon_digest != pictureHashSEI->pictureHash) { ok = "(***ERROR***)"; mismatch = true; @@ -297,7 +300,7 @@ int calcAndPrintHashStatus(const CPelUnitBuf& pic, const SEIDecodedPictureHash* if (mismatch) { - msg( msgl, "[rx%s:%s] ", hashType, hashToString(pictureHashSEI->m_pictureHash, numChar).c_str()); + msg( msgl, "[rx%s:%s] ", hashType, hashToString(pictureHashSEI->pictureHash, numChar).c_str()); } return mismatch; } diff --git a/source/Lib/CommonLib/PicYuvMD5.h b/source/Lib/CommonLib/PicYuvMD5.h index 00ada7fd9..976781089 100644 --- a/source/Lib/CommonLib/PicYuvMD5.h +++ b/source/Lib/CommonLib/PicYuvMD5.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include "Unit.h" diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index 7f4ee2072..e15ff7faf 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Picture.cpp @@ -152,7 +156,7 @@ Picture::Picture() , vps ( nullptr ) , dci ( nullptr ) , picApsMap ( MAX_NUM_APS * MAX_NUM_APS_TYPE ) - , isMctfFiltered ( false ) + , isMctfProcessed ( false ) , isInitDone ( false ) , isReconstructed ( false ) , isBorderExtended ( false ) @@ -173,6 +177,7 @@ Picture::Picture() , ctsValid ( false ) , m_bufsOrigPrev { nullptr, nullptr } , picInitialQP ( 0 ) + , useSC ( 0 ) { } @@ -187,6 +192,7 @@ void Picture::create( ChromaFormat _chromaFormat, const Size& size, unsigned _ma if( _decoder ) { m_bufs[ PIC_RESIDUAL ].create( _chromaFormat, Area( 0, 0, _maxCUSize, _maxCUSize ) ); + m_bufs[PIC_PREDICTION].create( _chromaFormat, Area( 0, 0, _maxCUSize, _maxCUSize ) ); } else { @@ -236,7 +242,7 @@ const CPelBuf Picture::getOrigBufPrev (const CompArea &blk, const bool minus const CPelUnitBuf Picture::getOrigBufPrev (const bool minus2) const { return (m_bufsOrigPrev[minus2 ? 1 : 0] ? *m_bufsOrigPrev[minus2 ? 1 : 0] : PelUnitBuf()); } const CPelBuf Picture::getOrigBufPrev (const ComponentID compID, const bool minus2) const { return (m_bufsOrigPrev[minus2 ? 1 : 0] ? m_bufsOrigPrev[minus2 ? 1 : 0]->getBuf (compID) : PelBuf()); } -void Picture::finalInit( const VPS& _vps, const SPS& sps, const PPS& pps, PicHeader& picHeader, XUCache& unitCache, std::mutex* mutex, APS** alfAps, APS* lmcsAps ) +void Picture::finalInit( const VPS& _vps, const SPS& sps, const PPS& pps, PicHeader* picHeader, XUCache& unitCache, std::mutex* mutex, APS** alfAps, APS* lmcsAps ) { for( auto &sei : SEIs ) { @@ -272,7 +278,7 @@ void Picture::finalInit( const VPS& _vps, const SPS& sps, const PPS& pps, PicHea cs->refCS = cs; cs->slice = nullptr; // the slices for this picture have not been set at this point. update cs->slice after swapSliceObject() cs->pps = &pps; - cs->picHeader = &picHeader; + cs->picHeader = picHeader; if ( alfAps ) { memcpy(cs->alfAps, alfAps, sizeof(cs->alfAps)); diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 2efbcae23..87e535ace 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Picture.h * \brief Description of a coded picture */ @@ -147,7 +151,7 @@ struct Picture : public UnitArea void destroyTempBuffers(); void extendPicBorder(); - void finalInit( const VPS& vps, const SPS& sps, const PPS& pps, PicHeader& picHeader, XUCache& unitCache, std::mutex* mutex, APS** alfAps, APS* lmcsAps ); + void finalInit( const VPS& vps, const SPS& sps, const PPS& pps, PicHeader* picHeader, XUCache& unitCache, std::mutex* mutex, APS** alfAps, APS* lmcsAps ); int getPOC() const { return poc; } Pel* getOrigin( const PictureType& type, const ComponentID compID ) const; @@ -208,7 +212,7 @@ struct Picture : public UnitArea BlkStat picBlkStat; std::vector sliceDataStreams; - bool isMctfFiltered; + bool isMctfProcessed; bool isInitDone; bool isReconstructed; bool isBorderExtended; @@ -237,6 +241,7 @@ struct Picture : public UnitArea std::mutex wppMutex; int picInitialQP; StopClock encTime; + bool useSC; private: std::vector m_sao[ 2 ]; diff --git a/source/Lib/CommonLib/ProfileLevelTier.cpp b/source/Lib/CommonLib/ProfileLevelTier.cpp new file mode 100644 index 000000000..30b194e2e --- /dev/null +++ b/source/Lib/CommonLib/ProfileLevelTier.cpp @@ -0,0 +1,198 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Frderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +/** \file ProfileLevelTier.cpp + \brief Handle profile, level and tier information. +*/ + + +#include "ProfileLevelTier.h" +#include "CommonLib/Slice.h" +#include + +namespace vvenc { + +uint32_t LevelTierFeatures::getMaxPicWidthInLumaSamples() const +{ + return uint32_t(sqrt(maxLumaPs*8.0)); +} + +uint32_t LevelTierFeatures::getMaxPicHeightInLumaSamples() const +{ + return uint32_t(sqrt(maxLumaPs*8.0)); +} + +static const uint64_t MAX_CNFUINT64 = std::numeric_limits::max(); + +static const LevelTierFeatures mainLevelTierInfo[] = +{ + // level, maxlumaps, maxcpb[tier],, maxSlicesPerAu,maxTilesPerAu,cols, maxLumaSr, maxBr[tier],, minCr[tier],, + { Level::LEVEL1 , 36864, { 350, 0 }, 16, 1, 1, 552960ULL, { 128, 0 }, { 2, 2} }, + { Level::LEVEL2 , 122880, { 1500, 0 }, 16, 1, 1, 3686400ULL, { 1500, 0 }, { 2, 2} }, + { Level::LEVEL2_1, 245760, { 3000, 0 }, 20, 1, 1, 7372800ULL, { 3000, 0 }, { 2, 2} }, + { Level::LEVEL3 , 552960, { 6000, 0 }, 30, 4, 2, 16588800ULL, { 6000, 0 }, { 2, 2} }, + { Level::LEVEL3_1, 983040, { 10000, 0 }, 40, 9, 3, 33177600ULL, { 10000, 0 }, { 2, 2} }, + { Level::LEVEL4 , 2228224, { 12000, 30000 }, 75, 25, 5, 66846720ULL, { 12000, 30000 }, { 4, 4} }, + { Level::LEVEL4_1, 2228224, { 20000, 50000 }, 75, 25, 5, 133693440ULL, { 20000, 50000 }, { 4, 4} }, + { Level::LEVEL5 , 8912896, { 25000, 100000 }, 200, 110, 10, 267386880ULL, { 25000, 100000 }, { 6, 4} }, + { Level::LEVEL5_1, 8912896, { 40000, 160000 }, 200, 110, 10, 534773760ULL, { 40000, 160000 }, { 8, 4} }, + { Level::LEVEL5_2, 8912896, { 60000, 240000 }, 200, 110, 10, 1069547520ULL, { 60000, 240000 }, { 8, 4} }, + { Level::LEVEL6 , 35651584, { 80000, 240000 }, 600, 440, 20, 1069547520ULL, { 60000, 240000 }, { 8, 4} }, + { Level::LEVEL6_1, 35651584, { 120000, 480000 }, 600, 440, 20, 2139095040ULL, { 120000, 480000 }, { 8, 4} }, + { Level::LEVEL6_2, 35651584, { 180000, 800000 }, 600, 440, 20, 4278190080ULL, { 240000, 800000 }, { 8, 4} }, + { Level::LEVEL6_3, 80216064, { 240000, 800000 }, 1000, 990, 30, 4812963840ULL, { 320000, 800000 }, { 8, 4} }, + { Level::LEVEL15_5, MAX_UINT,{ MAX_UINT, MAX_UINT }, MAX_UINT, MAX_UINT, MAX_UINT, MAX_CNFUINT64, {MAX_UINT, MAX_UINT }, { 0, 0} }, + { Level::NONE } +}; + +static const ProfileFeatures validProfiles[] = { +// profile, pNameString, maxBitDepth, maxChrFmt, lvl15.5, cpbvcl, cpbnal, fcf*1000, mincr*100, levelInfo +// most constrained profiles must appear first. + { Profile::MAIN_10_STILL_PICTURE, "Main_10_Still_Picture", 10, CHROMA_420, true, 1000, 1100, 1875, 100, + mainLevelTierInfo, true }, + { Profile::MULTILAYER_MAIN_10_STILL_PICTURE, "Multilayer_Main_10_Still_Picture", 10, CHROMA_420, true, 1000, 1100, + 1875, 100, mainLevelTierInfo, true }, + { Profile::MAIN_10_444_STILL_PICTURE, "Main_444_10_Still_Picture", 10, CHROMA_444, true, 2500, 2750, 3750, 75, + mainLevelTierInfo, true }, + { Profile::MULTILAYER_MAIN_10_444_STILL_PICTURE, "Multilayer_Main_444_10_Still_Picture", 10, CHROMA_444, true, 2500, + 2750, 3750, 75, mainLevelTierInfo, true }, + { Profile::MAIN_10, "Main_10", 10, CHROMA_420, false, 1000, 1100, 1875, 100, mainLevelTierInfo, false }, + { Profile::MULTILAYER_MAIN_10, "Multilayer_Main_10", 10, CHROMA_420, false, 1000, 1100, 1875, 100, mainLevelTierInfo, + false }, + { Profile::MAIN_10_444, "Main_444_10", 10, CHROMA_444, false, 2500, 2750, 3750, 75, mainLevelTierInfo, false }, + { Profile::MULTILAYER_MAIN_10_444, "Multilayer_Main_444_10", 10, CHROMA_444, false, 2500, 2750, 3750, 75, + mainLevelTierInfo, false }, + { Profile::NONE, 0 }, +}; + +const ProfileFeatures *ProfileFeatures::getProfileFeatures(const Profile::Name p) +{ + int i; + for (i = 0; validProfiles[i].profile != Profile::NONE; i++) + { + if (validProfiles[i].profile == p) + { + return &validProfiles[i]; + } + } + + return &validProfiles[i]; +} + +void ProfileLevelTierFeatures::extractPTLInformation(const SPS &sps) +{ + const ProfileTierLevel &spsPtl = sps.profileTierLevel; + + m_pProfile = nullptr; + m_pLevelTier = nullptr; + m_tier = spsPtl.tierFlag; + + // Identify the profile from the profile Idc, and possibly other constraints. + for(int32_t i=0; validProfiles[i].profile != Profile::NONE; i++) + { + if (spsPtl.profileIdc == validProfiles[i].profile) + { + m_pProfile = &(validProfiles[i]); + break; + } + } + + if (m_pProfile != nullptr) + { + // Now identify the level: + const LevelTierFeatures *pLTF = m_pProfile->pLevelTiersListInfo; + const Level::Name spsLevelName = spsPtl.levelIdc; + if (spsLevelName!=Level::LEVEL15_5 || m_pProfile->canUseLevel15p5) + { + for(int i=0; pLTF[i].level!=Level::NONE; i++) + { + if (pLTF[i].level == spsLevelName) + { + m_pLevelTier = &(pLTF[i]); + break; + } + } + } + } +} + +double ProfileLevelTierFeatures::getMinCr() const +{ + return (m_pLevelTier!=0 && m_pProfile!=0) ? (m_pProfile->minCrScaleFactorx100 * m_pLevelTier->minCrBase[m_tier?1:0])/100.0 : 0.0 ; +} + +uint64_t ProfileLevelTierFeatures::getCpbSizeInBits() const +{ + return (m_pLevelTier!=0 && m_pProfile!=0) ? uint64_t(m_pProfile->cpbVclFactor) * m_pLevelTier->maxCpb[m_tier?1:0] : uint64_t(0); +} + +uint32_t ProfileLevelTierFeatures::getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const +{ + const uint32_t maxDpbPicBuf = 8; + uint32_t maxDpbSize; + + if (m_pLevelTier->level == Level::LEVEL15_5) + { + // maxDpbSize is unconstrained in this case + maxDpbSize = std::numeric_limits::max(); + } + else if (2 * picSizeMaxInSamplesY <= m_pLevelTier->maxLumaPs) + { + maxDpbSize = 2 * maxDpbPicBuf; + } + else if (3 * picSizeMaxInSamplesY <= 2 * m_pLevelTier->maxLumaPs) + { + maxDpbSize = 3 * maxDpbPicBuf / 2; + } + else + { + maxDpbSize = maxDpbPicBuf; + } + + return maxDpbSize; +} + +} //namespace \ No newline at end of file diff --git a/source/Lib/CommonLib/ProfileLevelTier.h b/source/Lib/CommonLib/ProfileLevelTier.h new file mode 100644 index 000000000..4b1eee1f2 --- /dev/null +++ b/source/Lib/CommonLib/ProfileLevelTier.h @@ -0,0 +1,112 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Frderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + + +#pragma once + +#include "CommonLib/CommonDef.h" +#include + +namespace vvenc { + +struct SPS; // Forward declaration. + +struct LevelTierFeatures +{ + Level::Name level; + uint32_t maxLumaPs; + uint32_t maxCpb[Level::NUMBER_OF_TIERS]; // in units of CpbVclFactor or CpbNalFactor bits + uint32_t maxSlicesPerAu; + uint32_t maxTilesPerAu; + uint32_t maxTileCols; + uint64_t maxLumaSr; + uint32_t maxBr[Level::NUMBER_OF_TIERS]; // in units of BrVclFactor or BrNalFactor bits/s + uint32_t minCrBase[Level::NUMBER_OF_TIERS]; + uint32_t getMaxPicWidthInLumaSamples() const; + uint32_t getMaxPicHeightInLumaSamples() const; +}; + + +struct ProfileFeatures +{ + Profile::Name profile; + const char *pNameString; + uint32_t maxBitDepth; + ChromaFormat maxChromaFormat; + + bool canUseLevel15p5; + uint32_t cpbVclFactor; + uint32_t cpbNalFactor; + uint32_t formatCapabilityFactorx1000; + uint32_t minCrScaleFactorx100; + const LevelTierFeatures *pLevelTiersListInfo; + bool onePictureOnlyFlagMustBe1; + + static const ProfileFeatures *getProfileFeatures(const Profile::Name p); +}; + + +class ProfileLevelTierFeatures +{ + private: + const ProfileFeatures *m_pProfile; + const LevelTierFeatures *m_pLevelTier; + Level::Tier m_tier; + public: + ProfileLevelTierFeatures() : m_pProfile(nullptr), m_pLevelTier(nullptr), m_tier(Level::MAIN) {} + + void extractPTLInformation(const SPS &sps); + + const ProfileFeatures *getProfileFeatures() const { return m_pProfile; } + const LevelTierFeatures *getLevelTierFeatures() const { return m_pLevelTier; } + Level::Tier getTier() const { return m_tier; } + uint64_t getCpbSizeInBits() const; + double getMinCr() const; + uint32_t getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const; +}; + + +} // namespace diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp index fe136b5ab..b1f0e84a3 100644 --- a/source/Lib/CommonLib/Quant.cpp +++ b/source/Lib/CommonLib/Quant.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Quant.cpp @@ -129,10 +133,46 @@ QpParam::QpParam(const TransformUnit& tu, const ComponentID &compID, const bool // ==================================================================================================================== // Quant class member functions // ==================================================================================================================== +static void DeQuantCore(const int maxX,const int maxY,const int scale,const TCoeff*const piQCoef,const size_t piQCfStride,TCoeff *const piCoef,const int rightShift,const int inputMaximum,const TCoeff transformMaximum) +{ + const int inputMinimum = -(inputMaximum+1); + const TCoeff transformMinimum = -(transformMaximum+1); + if (rightShift>0) + { + const Intermediate_Int iAdd = (Intermediate_Int) 1 << (rightShift - 1); + for( int y = 0, n = 0; y <= maxY; y++) + { + for( int x = 0; x <= maxX; x++, n++ ) + { + const TCoeff clipQCoef = TCoeff(Clip3(inputMinimum, inputMaximum, piQCoef[x + y * piQCfStride])); + Intermediate_Int iCoeffQ = (Intermediate_Int(clipQCoef) * scale + iAdd) >> rightShift; + piCoef[n] = TCoeff(Clip3(transformMinimum,transformMaximum,iCoeffQ)); + } + } + } + else // rightshift <0 + { + int leftShift = -rightShift; + for( int y = 0, n = 0; y <= maxY; y++) + { + for( int x = 0; x <= maxX; x++, n++ ) + { + const TCoeff clipQCoef = TCoeff(Clip3(inputMinimum, inputMaximum, piQCoef[x + y * piQCfStride])); + const Intermediate_Int iCoeffQ = (Intermediate_Int(clipQCoef) * scale) << leftShift; + piCoef[n] = TCoeff(Clip3(transformMinimum,transformMaximum,iCoeffQ)); + } + } + } +} Quant::Quant( const Quant* other ) : m_RDOQ( 0 ), m_useRDOQTS( false ), m_useSelectiveRDOQ( false ), m_dLambda( 0.0 ) { xInitScalingList( other ); + DeQuant=DeQuantCore; +#if defined( TARGET_SIMD_X86 ) && ENABLE_SIMD_OPT_QUANT + initQuantX86(); +#endif + } Quant::~Quant() @@ -153,8 +193,7 @@ void invResDPCM( const TransformUnit& tu, const ComponentID compID, CoeffBuf& ds const TCoeff* coef = &coeffs.buf[0]; TCoeff* dst = &dstBuf.buf[0]; - - if( tu.cu->bdpcmMode == 1 ) + if ( tu.cu->bdpcmM[toChannelType(compID)] == 1) { for( int y = 0; y < hgt; y++ ) { @@ -193,8 +232,7 @@ void fwdResDPCM( TransformUnit& tu, const ComponentID compID ) CoeffBuf coeffs = tu.getCoeffs(compID); TCoeff* coef = &coeffs.buf[0]; - - if( tu.cu->bdpcmMode == 1 ) + if (tu.cu->bdpcmM[toChannelType(compID)] == 1) { for( int y = 0; y < hgt; y++ ) { @@ -359,30 +397,33 @@ void Quant::dequant(const TransformUnit& tu, const ComponentID compID, const QpParam& cQP) { - const SPS *sps = tu.cs->sps; - const CompArea &area = tu.blocks[compID]; - const uint32_t uiWidth = area.width; - const uint32_t uiHeight = area.height; - TCoeff *const piCoef = dstCoeff.buf; - const uint32_t numSamplesInBlock = uiWidth * uiHeight; - const int maxLog2TrDynamicRange = sps->getMaxLog2TrDynamicRange(toChannelType(compID)); - const TCoeff transformMinimum = -(1 << maxLog2TrDynamicRange); - const TCoeff transformMaximum = (1 << maxLog2TrDynamicRange) - 1; - const bool isTransformSkip = tu.mtsIdx[compID]==MTS_SKIP && isLuma(compID); - const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied); - const int scalingListType = getScalingListType(tu.cu->predMode, compID); - const int channelBitDepth = sps->bitDepths[toChannelType(compID)]; + const SPS *sps = tu.cs->sps; + const CompArea &area = tu.blocks[compID]; + const uint32_t uiWidth = area.width; + const uint32_t uiHeight = area.height; + TCoeff *const piCoef = dstCoeff.buf; + size_t piStride; + const uint32_t numSamplesInBlock = uiWidth * uiHeight; + const int maxLog2TrDynamicRange = sps->getMaxLog2TrDynamicRange(toChannelType(compID)); + const TCoeff transformMinimum = -(1 << maxLog2TrDynamicRange); + const TCoeff transformMaximum = (1 << maxLog2TrDynamicRange) - 1; + const bool isTransformSkip = tu.mtsIdx[compID] == MTS_SKIP; + const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (CU::isSepTree(*tu.cu) ? true : isLuma(compID)); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied); + const int scalingListType = getScalingListType(tu.cu->predMode, compID); + const int channelBitDepth = sps->bitDepths[toChannelType(compID)]; const TCoeff *coef; - if( tu.cu->bdpcmMode && isLuma(compID) ) + if (tu.cu->bdpcmM[toChannelType(compID)]) { invResDPCM( tu, compID, dstCoeff ); coef = piCoef; + piStride=dstCoeff.stride; } else { coef = tu.getCoeffs(compID).buf; + piStride=tu.getCoeffs(compID).stride; } const TCoeff *const piQCoef = coef; CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); @@ -396,7 +437,7 @@ void Quant::dequant(const TransformUnit& tu, const int QP_per = cQP.per(isTransformSkip); const int QP_rem = cQP.rem(isTransformSkip); - const int rightShift = (IQUANT_SHIFT - (iTransformShift + QP_per)) + (enableScalingLists ? LOG2_SCALING_LIST_NEUTRAL_VALUE : 0); + const int rightShift = (IQUANT_SHIFT - ((isTransformSkip ? 0 : iTransformShift) + QP_per)) + (enableScalingLists ? LOG2_SCALING_LIST_NEUTRAL_VALUE : 0); if(enableScalingLists) { @@ -416,24 +457,20 @@ void Quant::dequant(const TransformUnit& tu, if(rightShift > 0) { const Intermediate_Int iAdd = (Intermediate_Int) 1 << (rightShift - 1); - for( int n = 0; n < numSamplesInBlock; n++ ) { const TCoeff clipQCoef = TCoeff(Clip3(inputMinimum, inputMaximum, piQCoef[n])); const Intermediate_Int iCoeffQ = ((Intermediate_Int(clipQCoef) * piDequantCoef[n]) + iAdd ) >> rightShift; - piCoef[n] = TCoeff(Clip3(transformMinimum,transformMaximum,iCoeffQ)); } } else { const int leftShift = -rightShift; - for( int n = 0; n < numSamplesInBlock; n++ ) { const TCoeff clipQCoef = TCoeff(Clip3(inputMinimum, inputMaximum, piQCoef[n])); const Intermediate_Int iCoeffQ = (Intermediate_Int(clipQCoef) * piDequantCoef[n]) << leftShift; - piCoef[n] = TCoeff(Clip3(transformMinimum,transformMaximum,iCoeffQ)); } } @@ -442,38 +479,12 @@ void Quant::dequant(const TransformUnit& tu, { const int scale = g_invQuantScales[needSqrtAdjustment?1:0][QP_rem]; const int scaleBits = ( IQUANT_SHIFT + 1 ); - //from the dequantisation equation: //iCoeffQ = Intermediate_Int((int64_t(clipQCoef) * scale + iAdd) >> rightShift); //(sizeof(Intermediate_Int) * 8) = inputBitDepth + scaleBits - rightShift const uint32_t targetInputBitDepth = std::min((maxLog2TrDynamicRange + 1), (((sizeof(Intermediate_Int) * 8) + rightShift) - scaleBits)); - const Intermediate_Int inputMinimum = -(1 << (targetInputBitDepth - 1)); const Intermediate_Int inputMaximum = (1 << (targetInputBitDepth - 1)) - 1; - - if (rightShift > 0) - { - const Intermediate_Int iAdd = (Intermediate_Int) 1 << (rightShift - 1); - - for( int n = 0; n < numSamplesInBlock; n++ ) - { - const TCoeff clipQCoef = TCoeff(Clip3(inputMinimum, inputMaximum, piQCoef[n])); - const Intermediate_Int iCoeffQ = (Intermediate_Int(clipQCoef) * scale + iAdd) >> rightShift; - - piCoef[n] = TCoeff(Clip3(transformMinimum,transformMaximum,iCoeffQ)); - } - } - else - { - const int leftShift = -rightShift; - - for( int n = 0; n < numSamplesInBlock; n++ ) - { - const TCoeff clipQCoef = TCoeff(Clip3(inputMinimum, inputMaximum, piQCoef[n])); - const Intermediate_Int iCoeffQ = (Intermediate_Int(clipQCoef) * scale) << leftShift; - - piCoef[n] = TCoeff(Clip3(transformMinimum,transformMaximum,iCoeffQ)); - } - } + DeQuant(uiWidth-1,uiHeight-1,scale,piQCoef,piStride,piCoef,rightShift,inputMaximum,transformMaximum); } } @@ -607,7 +618,7 @@ void Quant::quant(TransformUnit& tu, const ComponentID compID, const CCoeffBuf& const CCoeffBuf& piCoef = pSrc; CoeffBuf piQCoef = tu.getCoeffs(compID); - const bool useTransformSkip = tu.mtsIdx[compID]==MTS_SKIP && isLuma(compID); + const bool useTransformSkip = tu.mtsIdx[compID] == MTS_SKIP; const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID)); { @@ -623,7 +634,7 @@ void Quant::quant(TransformUnit& tu, const ComponentID compID, const CCoeffBuf& const uint32_t uiLog2TrHeight = Log2(uiHeight); int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight); - const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); + const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (CU::isSepTree(*tu.cu) ? true : isLuma(compID)); const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip, isLfnstApplied); // for blocks that where width*height != 4^N, the effective scaling applied during transformation cannot be @@ -638,8 +649,7 @@ void Quant::quant(TransformUnit& tu, const ComponentID compID, const CCoeffBuf& iTransformShift = std::max(0, iTransformShift); } - - const int iQBits = QUANT_SHIFT + cQP.per(useTransformSkip) + iTransformShift; + const int iQBits = QUANT_SHIFT + cQP.per(useTransformSkip) + (useTransformSkip ? 0 : iTransformShift); // QBits will be OK for any internal bit depth as the reduction in transform shift is balanced by an increase in Qp_per due to QpBDOffset const int64_t iAdd = int64_t(tu.cs->slice->isIRAP() ? 171 : 85) << int64_t(iQBits - 9); @@ -663,8 +673,7 @@ void Quant::quant(TransformUnit& tu, const ComponentID compID, const CCoeffBuf& piQCoef.buf[uiBlockPos] = Clip3( entropyCodingMinimum, entropyCodingMaximum, quantisedCoefficient ); } // for n - - if( tu.cu->bdpcmMode && isLuma(compID) ) + if (tu.cu->bdpcmM[toChannelType(compID)]) { fwdResDPCM( tu, compID ); } @@ -699,7 +708,7 @@ bool Quant::xNeedRDOQ(TransformUnit& tu, const ComponentID compID, const CCoeffB const CCoeffBuf piCoef = pSrc; - const bool useTransformSkip = tu.mtsIdx[compID] == MTS_SKIP && isLuma(compID); + const bool useTransformSkip = tu.mtsIdx[compID] == MTS_SKIP; const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID)); int scalingListType = getScalingListType(tu.cu->predMode, compID); @@ -709,7 +718,7 @@ bool Quant::xNeedRDOQ(TransformUnit& tu, const ComponentID compID, const CCoeffB const uint32_t uiLog2TrHeight = Log2(uiHeight); int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight); - const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); + const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (CU::isSepTree(*tu.cu) ? true : isLuma(compID)); const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0), isLfnstApplied); /* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be diff --git a/source/Lib/CommonLib/Quant.h b/source/Lib/CommonLib/Quant.h index 884474742..8539d68e2 100644 --- a/source/Lib/CommonLib/Quant.h +++ b/source/Lib/CommonLib/Quant.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Quant.h \brief base quantization class (header) */ @@ -136,6 +140,13 @@ class Quant void xDestroyScalingList (); void xSetFlatScalingList ( uint32_t list, uint32_t sizeX, uint32_t sizeY, int qp ); void xSignBitHidingHDQ ( TCoeff* pQCoef, const TCoeff* pCoef, TCoeff* deltaU, const CoeffCodingContext& cctx, const int maxLog2TrDynamicRange); + void ( *DeQuant) (const int maxX,const int maxY,const int scale,const TCoeff*const piQCoef,const size_t piQCfStride,TCoeff *const piCoef,const int rightShift,const int inputMaximum,const TCoeff transformMaximum); + +#ifdef TARGET_SIMD_X86 + void initQuantX86(); + template + void _initQuantX86(); +#endif protected: int m_RDOQ; diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index 155baeb21..99b8d7f62 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file QuantRDOQ.cpp @@ -506,7 +510,7 @@ void QuantRDOQ::quant(TransformUnit& tu, const ComponentID compID, const CCoeffB { if( useTransformSkip ) { - if((isLuma(compID) && useTransformSkip) || (isChroma(compID) && tu.cu->bdpcmModeChroma)) + if(tu.cu->bdpcmM[toChannelType(compID)]) { forwardRDPCM( tu, compID, pSrc, uiAbsSum, cQP, ctx ); } @@ -599,7 +603,7 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit& tu, const ComponentID compID, c const bool isTransformSkip = tu.mtsIdx[compID]==MTS_SKIP; const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem(isTransformSkip)); const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem(isTransformSkip), uiLog2BlockWidth, uiLog2BlockHeight); - const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); + const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (CU::isSepTree(*tu.cu) ? true : isLuma(compID)); const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied); const int defaultQuantisationCoefficient = g_quantScales[ needSqrtAdjustment ?1:0][cQP.rem(isTransformSkip)]; const double defaultErrorScale = xGetErrScaleCoeffNoScalingList(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem(isTransformSkip)); @@ -1390,7 +1394,7 @@ void QuantRDOQ::forwardRDPCM( TransformUnit& tu, const ComponentID compID, const const bool extendedPrecision = sps.spsRExt.extendedPrecisionProcessing; const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(chType); - const int dirMode = isLuma(compID) ? tu.cu->bdpcmMode : tu.cu->bdpcmModeChroma; + const int dirMode = tu.cu->bdpcmM[toChannelType(compID)]; int transformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange); diff --git a/source/Lib/CommonLib/QuantRDOQ.h b/source/Lib/CommonLib/QuantRDOQ.h index b2d8ad583..1e4fe6669 100644 --- a/source/Lib/CommonLib/QuantRDOQ.h +++ b/source/Lib/CommonLib/QuantRDOQ.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file QuantRDOQ.h \brief RDOQ class (header) */ diff --git a/source/Lib/CommonLib/QuantRDOQ2.cpp b/source/Lib/CommonLib/QuantRDOQ2.cpp index 36c37a5f9..ea41e2dd7 100644 --- a/source/Lib/CommonLib/QuantRDOQ2.cpp +++ b/source/Lib/CommonLib/QuantRDOQ2.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file QuantRDOQ2.cpp @@ -314,7 +318,7 @@ void QuantRDOQ2::quant( TransformUnit &tu, const ComponentID compID, const CCoef { if( useTransformSkip ) { - if((isLuma(compID) && useTransformSkip) || (isChroma(compID) && tu.cu->bdpcmModeChroma)) + if(tu.cu->bdpcmM[toChannelType(compID)]) { forwardRDPCM( tu, compID, pSrc, uiAbsSum, cQP, ctx ); } @@ -581,7 +585,7 @@ int QuantRDOQ2::xRateDistOptQuantFast( TransformUnit &tu, const ComponentID &com const uint32_t uiLog2BlockWidth = Log2(uiWidth); const uint32_t uiLog2BlockHeight = Log2(uiHeight); - const uint32_t uiMaxNumCoeff = rect.area(); + const uint32_t uiMaxNumCoeff = uiWidth * uiHeight; const uint32_t log2CGSize = cctx.log2CGSize(); int scalingListType = getScalingListType( tu.cu->predMode, compID ); @@ -616,7 +620,7 @@ int QuantRDOQ2::xRateDistOptQuantFast( TransformUnit &tu, const ComponentID &com cost_t bestTotalCost = std::numeric_limits::max() / 2; int ctxBinSampleRatio = MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT; - int remRegBins = (uiWidth * uiHeight * ctxBinSampleRatio) >> 4; + int remRegBins = ( tu.getTbAreaAfterCoefZeroOut( compID ) * ctxBinSampleRatio ) >> 4; uint32_t goRiceParam = 0; #if ENABLE_TRACING @@ -644,7 +648,6 @@ int QuantRDOQ2::xRateDistOptQuantFast( TransformUnit &tu, const ComponentID &com uint32_t uiBlkPos = cctx.blockPos( iScanPos ); if( plSrcCoeff[uiBlkPos] ) break; - piDstCoeff[uiBlkPos] = 0; } ////////////////////////////////////////////////////////////////////////// @@ -683,7 +686,6 @@ int QuantRDOQ2::xRateDistOptQuantFast( TransformUnit &tu, const ComponentID &com lastSubSetId = subSetId; break; } - piDstCoeff[uiBlkPos] = 0; #if ENABLE_TRACING if( bFirstNZSeen ) { @@ -753,7 +755,6 @@ int QuantRDOQ2::xRateDistOptQuantFast( TransformUnit &tu, const ComponentID &com { // ----------------- ABS LEVEL 0 ---------------- const BinFracBits fracBitsSig = fracBits.getFracBitsArray( ctxIdSig ); - piDstCoeff [uiBlkPos] = 0; piCostSig [iScanPosinCG] = xiGetCostSigCoef( fracBitsSig, 0 ); piCostCoeff[iScanPosinCG] = piCostCoeff0[iScanPosinCG] + piCostSig[iScanPosinCG]; @@ -1242,7 +1243,7 @@ int QuantRDOQ2::xRateDistOptQuantFast( TransformUnit &tu, const ComponentID &com } #if ENABLE_TRACING - for ( int scanPos = iCGNum * iCGSize; scanPos >= 0; scanPos-- ) + for ( int scanPos = iCGNum * iCGSize-1; scanPos >= 0; scanPos-- ) { if(( scanPos & iCGSizeM1) == iCGSizeM1 ) { diff --git a/source/Lib/CommonLib/QuantRDOQ2.h b/source/Lib/CommonLib/QuantRDOQ2.h index 6777e78de..910c61227 100644 --- a/source/Lib/CommonLib/QuantRDOQ2.h +++ b/source/Lib/CommonLib/QuantRDOQ2.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file QuantRDOQ2.h \brief RDOQ class (header) */ diff --git a/source/Lib/CommonLib/RdCost.cpp b/source/Lib/CommonLib/RdCost.cpp index a2136b7a8..f4da2eb35 100644 --- a/source/Lib/CommonLib/RdCost.cpp +++ b/source/Lib/CommonLib/RdCost.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file RdCost.cpp @@ -239,8 +243,15 @@ Distortion RdCost::getDistPart( const CPelBuf& org, const CPelBuf& cur, int bitD } else { - const int base = (bitDepth > 10) ? 1 : 0; - dist = m_afpDistortFunc[base][eDFunc + Log2(org.width)]( dp ); + if( ( org.width == 1 ) ) + { + dist = xGetSSE( dp ); + } + else + { + const int base = (bitDepth > 10) ? 1 : 0; + dist = m_afpDistortFunc[base][eDFunc + Log2(org.width)](dp); + } } if (isChroma(compId)) { diff --git a/source/Lib/CommonLib/RdCost.h b/source/Lib/CommonLib/RdCost.h index b7d7ed80d..b7ca249db 100644 --- a/source/Lib/CommonLib/RdCost.h +++ b/source/Lib/CommonLib/RdCost.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file RdCost.h \brief RD cost computation classes (header) */ diff --git a/source/Lib/CommonLib/Reshape.cpp b/source/Lib/CommonLib/Reshape.cpp index db35d87cf..57ccffa42 100644 --- a/source/Lib/CommonLib/Reshape.cpp +++ b/source/Lib/CommonLib/Reshape.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Reshape.cpp diff --git a/source/Lib/CommonLib/Reshape.h b/source/Lib/CommonLib/Reshape.h index ff5fbb79c..be2e08e64 100644 --- a/source/Lib/CommonLib/Reshape.h +++ b/source/Lib/CommonLib/Reshape.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Reshape.h \brief reshaping header and class (header) */ diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 4e5b37eec..7355fb6b9 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Rom.cpp @@ -77,7 +81,7 @@ StatCounters::StatCounter2DSet g_cuCounters1D( std::vector StatCounters::StatCounter2DSet g_cuCounters2D( std::vector { g_cuCounterIdNames, std::end( g_cuCounterIdNames ) }, MAX_CU_SIZE_IDX, MAX_CU_SIZE_IDX ); #endif -MsgFnc g_msgFnc = nullptr; +std::function g_msgFnc = nullptr; // ==================================================================================================================== // LFNST Tables @@ -574,47 +578,6 @@ class ScanGenerator } break; - case SCAN_TRAV_HOR: - if (m_line % 2 == 0) - { - if (m_column == (m_blockWidth - 1)) - { - m_line++; - m_column = m_blockWidth - 1; - } - else m_column++; - } - else - { - if (m_column == 0) - { - m_line++; - m_column = 0; - } - else m_column--; - } - break; - - case SCAN_TRAV_VER: - if (m_column % 2 == 0) - { - if (m_line == (m_blockHeight - 1)) - { - m_column++; - m_line = m_blockHeight - 1; - } - else m_line++; - } - else - { - if (m_line == 0) - { - m_column++; - m_line = 0; - } - else m_line--; - } - break; //------------------------------------------------ default: @@ -627,24 +590,23 @@ class ScanGenerator } }; -uint32_t const g_log2SbbSize[MAX_CU_SIZE_IDX][MAX_CU_SIZE_IDX][2] = +uint32_t const g_log2SbbSize[MAX_TU_SIZE_IDX][MAX_TU_SIZE_IDX][2] = //===== luma/chroma ===== { - { { 0,0 },{ 0,1 },{ 0,2 },{ 0,3 },{ 0,4 },{ 0,4 },{ 0,4 },{ 0,4 } }, - { { 1,0 },{ 1,1 },{ 1,1 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 } }, - { { 2,0 },{ 1,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, - { { 3,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, - { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, - { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, - { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, - { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } } + { { 0,0 },{ 0,1 },{ 0,2 },{ 0,3 },{ 0,4 },{ 0,4 },{ 0,4 } }, + { { 1,0 },{ 1,1 },{ 1,1 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 } }, + { { 2,0 },{ 1,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 3,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } } }; // --------------------------------------------------------------------------------------------------------------------- void ScanOrderRom::initScanOrderRom() { - const uint32_t maxSizeIdx = MAX_CU_SIZE_IDX; + const uint32_t maxSizeIdx = MAX_TU_SIZE_IDX; // initialize scan orders for (uint32_t blockHeightIdx = 0; blockHeightIdx < maxSizeIdx; blockHeightIdx++) { @@ -754,8 +716,8 @@ void ScanOrderRom::initScanOrderRom() void ScanOrderRom::destroyScanOrderRom() { - unsigned numWidths = MAX_CU_SIZE_IDX; - unsigned numHeights = MAX_CU_SIZE_IDX; + unsigned numWidths = MAX_TU_SIZE_IDX; + unsigned numHeights = MAX_TU_SIZE_IDX; for (uint32_t groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++) { @@ -1014,8 +976,6 @@ const char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = "INTER64X64_CHROMAU_FROM16x16_CHROMAU", "INTER64X64_CHROMAV_FROM16x16_CHROMAV" }, - { - }, }; const char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = @@ -1052,8 +1012,6 @@ const char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = "INTER64X64_CHROMAU_DC_FROM16x16_CHROMAU", "INTER64X64_CHROMAV_DC_FROM16x16_CHROMAV" }, - { - }, }; const int g_quantTSDefault4x4[4 * 4] = @@ -1088,8 +1046,8 @@ const int g_quantInterDefault8x8[8 * 8] = 16,16,16,16,16,16,16,16 }; -const uint32_t g_scalingListSize [SCALING_LIST_SIZE_NUM] = { 1, 4, 16, 64, 256, 1024, 4096, 16384 }; -const uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM] = { 1, 2, 4, 8, 16, 32, 64, 128 }; +const uint32_t g_scalingListSize [SCALING_LIST_SIZE_NUM] = { 1, 4, 16, 64, 256, 1024, 4096 }; +const uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM] = { 1, 2, 4, 8, 16, 32, 64 }; const uint8_t g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize] = { diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index 6288f28ce..72d52e8fd 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Rom.h \brief global variables & functions (header) */ @@ -104,7 +108,7 @@ class ScanOrderRom extern ScanOrderRom g_scanOrderRom; -extern const uint32_t g_log2SbbSize[MAX_CU_DEPTH + 1][MAX_CU_DEPTH + 1][2]; +extern const uint32_t g_log2SbbSize[MAX_TU_SIZE_IDX][MAX_TU_SIZE_IDX][2]; extern ScanElement g_coefTopLeftDiagScan8x8[MAX_CU_SIZE / 2 + 1][64]; extern const int g_quantScales [2/*0=4^n blocks, 1=2*4^n blocks*/][SCALING_LIST_REM_NUM]; // Q(QP%6) diff --git a/source/Lib/CommonLib/RomTr.cpp b/source/Lib/CommonLib/RomTr.cpp index 3d810e4b5..151c9ac30 100644 --- a/source/Lib/CommonLib/RomTr.cpp +++ b/source/Lib/CommonLib/RomTr.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file RomNSST.cpp diff --git a/source/Lib/CommonLib/SEI.cpp b/source/Lib/CommonLib/SEI.cpp index eb6b413f1..552754f91 100644 --- a/source/Lib/CommonLib/SEI.cpp +++ b/source/Lib/CommonLib/SEI.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -3. LIMITED PATENT LICENSE +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -4. DISCLAIMER -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file SEI.cpp @@ -66,11 +70,11 @@ void xTraceSEIMessageType( SEI::PayloadType payloadType ) } #endif -SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType) +SEIMessages getSeisByType(const SEIMessages &seiList, SEI::PayloadType seiType) { SEIMessages result; - for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++) + for (SEIMessages::const_iterator it=seiList.begin(); it!=seiList.end(); it++) { if ((*it)->payloadType() == seiType) { @@ -110,37 +114,6 @@ void deleteSEIs (SEIMessages &seiList) seiList.clear(); } -void SEIBufferingPeriod::copyTo (SEIBufferingPeriod& target) -{ - target.m_bpSeqParameterSetId = m_bpSeqParameterSetId; - target.m_rapCpbParamsPresent = m_rapCpbParamsPresent; - target.m_cpbDelayOffset = m_cpbDelayOffset; - target.m_dpbDelayOffset = m_dpbDelayOffset; - target.m_concatenationFlag = m_concatenationFlag; - target.m_auCpbRemovalDelayDelta = m_auCpbRemovalDelayDelta; - ::memcpy(target.m_initialCpbRemovalDelay, m_initialCpbRemovalDelay, sizeof(m_initialCpbRemovalDelay)); - ::memcpy(target.m_initialCpbRemovalDelayOffset, m_initialCpbRemovalDelayOffset, sizeof(m_initialCpbRemovalDelayOffset)); - ::memcpy(target.m_initialAltCpbRemovalDelay, m_initialAltCpbRemovalDelay, sizeof(m_initialAltCpbRemovalDelay)); - ::memcpy(target.m_initialAltCpbRemovalDelayOffset, m_initialAltCpbRemovalDelayOffset, sizeof(m_initialAltCpbRemovalDelayOffset)); -} - -void SEIPictureTiming::copyTo (SEIPictureTiming& target) -{ - target.m_picStruct = m_picStruct; - target.m_sourceScanType = m_sourceScanType; - target.m_duplicateFlag = m_duplicateFlag; - - target.m_auCpbRemovalDelay = m_auCpbRemovalDelay; - target.m_picDpbOutputDelay = m_picDpbOutputDelay; - target.m_picDpbOutputDuDelay = m_picDpbOutputDuDelay; - target.m_numDecodingUnitsMinus1 = m_numDecodingUnitsMinus1; - target.m_duCommonCpbRemovalDelayFlag = m_duCommonCpbRemovalDelayFlag; - target.m_duCommonCpbRemovalDelayMinus1 = m_duCommonCpbRemovalDelayMinus1; - - target.m_numNalusInDuMinus1 = m_numNalusInDuMinus1; - target.m_duCpbRemovalDelayMinus1 = m_duCpbRemovalDelayMinus1; -} - // Static member const char *SEI::getSEIMessageString(SEI::PayloadType payloadType) { @@ -148,37 +121,28 @@ const char *SEI::getSEIMessageString(SEI::PayloadType payloadType) { case SEI::BUFFERING_PERIOD: return "Buffering period"; case SEI::PICTURE_TIMING: return "Picture timing"; - case SEI::PAN_SCAN_RECT: return "Pan-scan rectangle"; // not currently decoded case SEI::FILLER_PAYLOAD: return "Filler payload"; // not currently decoded case SEI::USER_DATA_REGISTERED_ITU_T_T35: return "User data registered"; // not currently decoded case SEI::USER_DATA_UNREGISTERED: return "User data unregistered"; - case SEI::RECOVERY_POINT: return "Recovery point"; - case SEI::SCENE_INFO: return "Scene information"; // not currently decoded - case SEI::FULL_FRAME_SNAPSHOT: return "Picture snapshot"; // not currently decoded - case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START: return "Progressive refinement segment start"; // not currently decoded - case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END: return "Progressive refinement segment end"; // not currently decoded case SEI::FILM_GRAIN_CHARACTERISTICS: return "Film grain characteristics"; // not currently decoded - case SEI::POST_FILTER_HINT: return "Post filter hint"; // not currently decoded - case SEI::TONE_MAPPING_INFO: return "Tone mapping information"; - case SEI::KNEE_FUNCTION_INFO: return "Knee function information"; case SEI::FRAME_PACKING: return "Frame packing arrangement"; - case SEI::DISPLAY_ORIENTATION: return "Display orientation"; - case SEI::GREEN_METADATA: return "Green metadata information"; - case SEI::SOP_DESCRIPTION: return "Structure of pictures information"; - case SEI::ACTIVE_PARAMETER_SETS: return "Active parameter sets"; + case SEI::PARAMETER_SETS_INCLUSION_INDICATION: return "Parameter sets inclusion indication"; case SEI::DECODING_UNIT_INFO: return "Decoding unit information"; - case SEI::TEMPORAL_LEVEL0_INDEX: return "Temporal sub-layer zero index"; - case SEI::DECODED_PICTURE_HASH: return "Decoded picture hash"; case SEI::SCALABLE_NESTING: return "Scalable nesting"; - case SEI::REGION_REFRESH_INFO: return "Region refresh information"; - case SEI::NO_DISPLAY: return "No display"; - case SEI::TIME_CODE: return "Time code"; + case SEI::DECODED_PICTURE_HASH: return "Decoded picture hash"; + case SEI::DEPENDENT_RAP_INDICATION: return "Dependent RAP indication"; case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: return "Mastering display colour volume"; - case SEI::SEGM_RECT_FRAME_PACKING: return "Segmented rectangular frame packing arrangement"; - case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: return "Temporal motion constrained tile sets"; - case SEI::CHROMA_RESAMPLING_FILTER_HINT: return "Chroma sampling filter hint"; - case SEI::COLOUR_REMAPPING_INFO: return "Colour remapping info"; case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: return "Alternative transfer characteristics"; + case SEI::CONTENT_LIGHT_LEVEL_INFO: return "Content light level information"; + case SEI::AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment"; + case SEI::CONTENT_COLOUR_VOLUME: return "Content colour volume"; + case SEI::EQUIRECTANGULAR_PROJECTION: return "Equirectangular projection"; + case SEI::SPHERE_ROTATION: return "Sphere rotation"; + case SEI::REGION_WISE_PACKING: return "Region wise packing information"; + case SEI::OMNI_VIEWPORT: return "Omni viewport"; + case SEI::GENERALIZED_CUBEMAP_PROJECTION: return "Generalized cubemap projection"; + case SEI::SAMPLE_ASPECT_RATIO_INFO: return "Sample aspect ratio information"; + case SEI::SUBPICTURE_LEVEL_INFO: return "Subpicture level information"; default: return "Unknown"; } } diff --git a/source/Lib/CommonLib/SEI.h b/source/Lib/CommonLib/SEI.h index ffae76743..bd425cb37 100644 --- a/source/Lib/CommonLib/SEI.h +++ b/source/Lib/CommonLib/SEI.h @@ -1,48 +1,51 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include "CommonDef.h" -#include "libmd5/MD5.h" #include #include @@ -63,37 +66,29 @@ class SEI { BUFFERING_PERIOD = 0, PICTURE_TIMING = 1, - PAN_SCAN_RECT = 2, FILLER_PAYLOAD = 3, USER_DATA_REGISTERED_ITU_T_T35 = 4, USER_DATA_UNREGISTERED = 5, - RECOVERY_POINT = 6, - SCENE_INFO = 9, - FULL_FRAME_SNAPSHOT = 15, - PROGRESSIVE_REFINEMENT_SEGMENT_START = 16, - PROGRESSIVE_REFINEMENT_SEGMENT_END = 17, FILM_GRAIN_CHARACTERISTICS = 19, - POST_FILTER_HINT = 22, - TONE_MAPPING_INFO = 23, FRAME_PACKING = 45, - DISPLAY_ORIENTATION = 47, - GREEN_METADATA = 56, - SOP_DESCRIPTION = 128, - ACTIVE_PARAMETER_SETS = 129, + PARAMETER_SETS_INCLUSION_INDICATION = 129, DECODING_UNIT_INFO = 130, - TEMPORAL_LEVEL0_INDEX = 131, DECODED_PICTURE_HASH = 132, SCALABLE_NESTING = 133, - REGION_REFRESH_INFO = 134, - NO_DISPLAY = 135, - TIME_CODE = 136, MASTERING_DISPLAY_COLOUR_VOLUME = 137, - SEGM_RECT_FRAME_PACKING = 138, - TEMP_MOTION_CONSTRAINED_TILE_SETS = 139, - CHROMA_RESAMPLING_FILTER_HINT = 140, - KNEE_FUNCTION_INFO = 141, - COLOUR_REMAPPING_INFO = 142, - ALTERNATIVE_TRANSFER_CHARACTERISTICS = 182, + DEPENDENT_RAP_INDICATION = 145, + EQUIRECTANGULAR_PROJECTION = 150, + SPHERE_ROTATION = 154, + REGION_WISE_PACKING = 155, + OMNI_VIEWPORT = 156, + GENERALIZED_CUBEMAP_PROJECTION = 153, + FRAME_FIELD_INFO = 168, + SUBPICTURE_LEVEL_INFO = 203, + SAMPLE_ASPECT_RATIO_INFO = 204, + CONTENT_LIGHT_LEVEL_INFO = 144, + ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147, + AMBIENT_VIEWING_ENVIRONMENT = 148, + CONTENT_COLOUR_VOLUME = 149, }; SEI() {} @@ -104,379 +99,378 @@ class SEI virtual PayloadType payloadType() const = 0; }; -static const uint32_t ISO_IEC_11578_LEN=16; - -class SEIuserDataUnregistered : public SEI +struct SEIMasteringDisplay { -public: - PayloadType payloadType() const { return USER_DATA_UNREGISTERED; } - - SEIuserDataUnregistered() - : userData(0) - {} - - virtual ~SEIuserDataUnregistered() - { - delete userData; - } - - uint8_t uuid_iso_iec_11578[ISO_IEC_11578_LEN]; - uint32_t userDataLength; - uint8_t *userData; + bool colourVolumeSEIEnabled; + uint32_t maxLuminance; + uint32_t minLuminance; + uint16_t primaries[3][2]; + uint16_t whitePoint[2]; }; -class SEIDecodedPictureHash : public SEI + +class SEIEquirectangularProjection : public SEI { public: - PayloadType payloadType() const { return DECODED_PICTURE_HASH; } - - SEIDecodedPictureHash() {} - virtual ~SEIDecodedPictureHash() {} + PayloadType payloadType() const { return EQUIRECTANGULAR_PROJECTION; } - HashType method; + SEIEquirectangularProjection() {} + virtual ~SEIEquirectangularProjection() {} - PictureHash m_pictureHash; + bool erpCancelFlag; + bool erpPersistenceFlag; + bool erpGuardBandFlag; + uint8_t erpGuardBandType; + uint8_t erpLeftGuardBandWidth; + uint8_t erpRightGuardBandWidth; }; -class SEIActiveParameterSets : public SEI +class SEISphereRotation : public SEI { public: - PayloadType payloadType() const { return ACTIVE_PARAMETER_SETS; } + PayloadType payloadType() const { return SPHERE_ROTATION; } - SEIActiveParameterSets() - : m_selfContainedCvsFlag(false) - , m_noParameterSetUpdateFlag (false) - , numSpsIdsMinus1 (0) - {} - virtual ~SEIActiveParameterSets() {} + SEISphereRotation() {} + virtual ~SEISphereRotation() {} - bool m_selfContainedCvsFlag; - bool m_noParameterSetUpdateFlag; - int numSpsIdsMinus1; - std::vector activeSeqParameterSetId; + bool sphereRotationCancelFlag; + bool sphereRotationPersistenceFlag; + int sphereRotationYaw; + int sphereRotationPitch; + int sphereRotationRoll; }; -class SEIBufferingPeriod : public SEI +class SEIOmniViewport : public SEI { public: - PayloadType payloadType() const { return BUFFERING_PERIOD; } - void copyTo (SEIBufferingPeriod& target); + PayloadType payloadType() const { return OMNI_VIEWPORT; } - SEIBufferingPeriod() - : m_bpSeqParameterSetId (0) - , m_rapCpbParamsPresent (false) - , m_cpbDelayOffset (0) - , m_dpbDelayOffset (0) - { - ::memset(m_initialCpbRemovalDelay, 0, sizeof(m_initialCpbRemovalDelay)); - ::memset(m_initialCpbRemovalDelayOffset, 0, sizeof(m_initialCpbRemovalDelayOffset)); - ::memset(m_initialAltCpbRemovalDelay, 0, sizeof(m_initialAltCpbRemovalDelay)); - ::memset(m_initialAltCpbRemovalDelayOffset, 0, sizeof(m_initialAltCpbRemovalDelayOffset)); - } - virtual ~SEIBufferingPeriod() {} - - uint32_t m_bpSeqParameterSetId; - bool m_rapCpbParamsPresent; - uint32_t m_cpbDelayOffset; - uint32_t m_dpbDelayOffset; - uint32_t m_initialCpbRemovalDelay [MAX_CPB_CNT][2]; - uint32_t m_initialCpbRemovalDelayOffset [MAX_CPB_CNT][2]; - uint32_t m_initialAltCpbRemovalDelay [MAX_CPB_CNT][2]; - uint32_t m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2]; - bool m_concatenationFlag; - uint32_t m_auCpbRemovalDelayDelta; -}; -class SEIPictureTiming : public SEI -{ -public: - PayloadType payloadType() const { return PICTURE_TIMING; } - void copyTo (SEIPictureTiming& target); + SEIOmniViewport() {} + virtual ~SEIOmniViewport() {} - SEIPictureTiming() - : m_picStruct (0) - , m_sourceScanType (0) - , m_duplicateFlag (false) - , m_picDpbOutputDuDelay (0) - {} - virtual ~SEIPictureTiming() + struct OmniViewport { - } + int azimuthCentre; + int elevationCentre; + int tiltCentre; + uint32_t horRange; + uint32_t verRange; + }; - uint32_t m_picStruct; - uint32_t m_sourceScanType; - bool m_duplicateFlag; - - uint32_t m_auCpbRemovalDelay; - uint32_t m_picDpbOutputDelay; - uint32_t m_picDpbOutputDuDelay; - uint32_t m_numDecodingUnitsMinus1; - bool m_duCommonCpbRemovalDelayFlag; - uint32_t m_duCommonCpbRemovalDelayMinus1; - std::vector m_numNalusInDuMinus1; - std::vector m_duCpbRemovalDelayMinus1; + uint32_t omniViewportId; + bool omniViewportCancelFlag; + bool omniViewportPersistenceFlag; + uint8_t omniViewportCntMinus1; + std::vector omniViewportRegions; }; -class SEIDecodingUnitInfo : public SEI +class SEIRegionWisePacking : public SEI { public: - PayloadType payloadType() const { return DECODING_UNIT_INFO; } - - SEIDecodingUnitInfo() - : m_decodingUnitIdx(0) - , m_duSptCpbRemovalDelay(0) - , m_dpbOutputDuDelayPresent(false) - , m_picSptDpbOutputDuDelay(0) - {} - virtual ~SEIDecodingUnitInfo() {} - int m_decodingUnitIdx; - int m_duSptCpbRemovalDelay; - bool m_dpbOutputDuDelayPresent; - int m_picSptDpbOutputDuDelay; + PayloadType payloadType() const { return REGION_WISE_PACKING; } + SEIRegionWisePacking() {} + virtual ~SEIRegionWisePacking() {} + bool rwpCancelFlag; + bool rwpPersistenceFlag; + bool constituentPictureMatchingFlag; + int numPackedRegions; + int projPictureWidth; + int projPictureHeight; + int packedPictureWidth; + int packedPictureHeight; + std::vector rwpTransformType; + std::vector rwpGuardBandFlag; + std::vector projRegionWidth; + std::vector projRegionHeight; + std::vector rwpProjRegionTop; + std::vector projRegionLeft; + std::vector packedRegionWidth; + std::vector packedRegionHeight; + std::vector packedRegionTop; + std::vector packedRegionLeft; + std::vector rwpLeftGuardBandWidth; + std::vector rwpRightGuardBandWidth; + std::vector rwpTopGuardBandHeight; + std::vector rwpBottomGuardBandHeight; + std::vector rwpGuardBandNotUsedForPredFlag; + std::vector rwpGuardBandType; }; -class SEIRecoveryPoint : public SEI +class SEIGeneralizedCubemapProjection : public SEI { public: - PayloadType payloadType() const { return RECOVERY_POINT; } - - SEIRecoveryPoint() {} - virtual ~SEIRecoveryPoint() {} - - int m_recoveryPocCnt; - bool m_exactMatchingFlag; - bool m_brokenLinkFlag; + PayloadType payloadType() const { return GENERALIZED_CUBEMAP_PROJECTION; } + + SEIGeneralizedCubemapProjection() {} + virtual ~SEIGeneralizedCubemapProjection() {} + + bool gcmpCancelFlag; + bool gcmpPersistenceFlag; + uint8_t gcmpPackingType; + uint8_t gcmpMappingFunctionType; + std::vector gcmpFaceIndex; + std::vector gcmpFaceRotation; + std::vector gcmpFunctionCoeffU; + std::vector gcmpFunctionUAffectedByVFlag; + std::vector gcmpFunctionCoeffV; + std::vector gcmpFunctionVAffectedByUFlag; + bool gcmpGuardBandFlag; + uint8_t gcmpGuardBandType; + bool gcmpGuardBandBoundaryExteriorFlag; + uint8_t gcmpGuardBandSamplesMinus1; }; -class SEIFramePacking : public SEI +class SEISampleAspectRatioInfo : public SEI { public: - PayloadType payloadType() const { return FRAME_PACKING; } - - SEIFramePacking() {} - virtual ~SEIFramePacking() {} - - int m_arrangementId; - bool m_arrangementCancelFlag; - int m_arrangementType; - bool m_quincunxSamplingFlag; - int m_contentInterpretationType; - bool m_spatialFlippingFlag; - bool m_frame0FlippedFlag; - bool m_fieldViewsFlag; - bool m_currentFrameIsFrame0Flag; - bool m_frame0SelfContainedFlag; - bool m_frame1SelfContainedFlag; - int m_frame0GridPositionX; - int m_frame0GridPositionY; - int m_frame1GridPositionX; - int m_frame1GridPositionY; - int m_arrangementReservedByte; - bool m_arrangementPersistenceFlag; - bool m_upsampledAspectRatio; + PayloadType payloadType() const { return SAMPLE_ASPECT_RATIO_INFO; } + SEISampleAspectRatioInfo() {} + virtual ~SEISampleAspectRatioInfo() {} + bool sariCancelFlag; + bool sariPersistenceFlag; + int sariAspectRatioIdc; + int sariSarWidth; + int sariSarHeight; }; -class SEISegmentedRectFramePacking : public SEI -{ -public: - PayloadType payloadType() const { return SEGM_RECT_FRAME_PACKING; } - - SEISegmentedRectFramePacking() {} - virtual ~SEISegmentedRectFramePacking() {} - - bool m_arrangementCancelFlag; - int m_contentInterpretationType; - bool m_arrangementPersistenceFlag; -}; +static const uint32_t ISO_IEC_11578_LEN=16; -class SEIDisplayOrientation : public SEI +class SEIuserDataUnregistered : public SEI { public: - PayloadType payloadType() const { return DISPLAY_ORIENTATION; } + PayloadType payloadType() const { return USER_DATA_UNREGISTERED; } - SEIDisplayOrientation() - : cancelFlag(true) - , persistenceFlag(0) - , extensionFlag(false) + SEIuserDataUnregistered() + : userData(0) {} - virtual ~SEIDisplayOrientation() {} - bool cancelFlag; - bool horFlip; - bool verFlip; + virtual ~SEIuserDataUnregistered() + { + delete userData; + } - uint32_t anticlockwiseRotation; - bool persistenceFlag; - bool extensionFlag; + uint8_t uuid_iso_iec_11578[ISO_IEC_11578_LEN]; + uint32_t userDataLength; + uint8_t* userData; }; -class SEITemporalLevel0Index : public SEI +class SEIDecodedPictureHash : public SEI { public: - PayloadType payloadType() const { return TEMPORAL_LEVEL0_INDEX; } + PayloadType payloadType() const { return DECODED_PICTURE_HASH; } - SEITemporalLevel0Index() - : tl0Idx(0) - , rapIdx(0) - {} - virtual ~SEITemporalLevel0Index() {} + SEIDecodedPictureHash() {} + virtual ~SEIDecodedPictureHash() {} - uint32_t tl0Idx; - uint32_t rapIdx; + HashType method; + bool singleCompFlag; + PictureHash pictureHash; }; -class SEIGradualDecodingRefreshInfo : public SEI +class SEIDependentRAPIndication : public SEI { public: - PayloadType payloadType() const { return REGION_REFRESH_INFO; } - - SEIGradualDecodingRefreshInfo() - : m_gdrForegroundFlag(0) - {} - virtual ~SEIGradualDecodingRefreshInfo() {} + PayloadType payloadType() const { return DEPENDENT_RAP_INDICATION; } + SEIDependentRAPIndication() { } - bool m_gdrForegroundFlag; + virtual ~SEIDependentRAPIndication() { } }; -class SEINoDisplay : public SEI + +class SEIBufferingPeriod : public SEI { public: - PayloadType payloadType() const { return NO_DISPLAY; } + PayloadType payloadType() const { return BUFFERING_PERIOD; } - SEINoDisplay() - : m_noDisplay(false) - {} - virtual ~SEINoDisplay() {} + SEIBufferingPeriod() + : bpNalCpbParamsPresent (false) + , bpVclCpbParamsPresent (false) + , initialCpbRemovalDelayLength (0) + , cpbRemovalDelayLength (0) + , dpbOutputDelayLength (0) + , bpCpbCnt(0) + , duCpbRemovalDelayIncrementLength (0) + , dpbOutputDelayDuLength (0) + , cpbRemovalDelayDeltasPresent (false) + , numCpbRemovalDelayDeltas (0) + , bpMaxSubLayers (0) + , bpDecodingUnitHrdParamsPresent (false) + , decodingUnitCpbParamsInPicTimingSeiFlag (false) + , decodingUnitDpbDuParamsInPicTimingSeiFlag(false) + , sublayerInitialCpbRemovalDelayPresent(false) + , additionalConcatenationInfoPresent (false) + , maxInitialRemovalDelayForConcatenation (0) + , sublayerDpbOutputOffsetsPresent (false) + , altCpbParamsPresent (false) + , useAltCpbParamsFlag (false) + { + ::memset( initialCpbRemovalDelay, 0, sizeof(initialCpbRemovalDelay)); + ::memset( initialCpbRemovalOffset, 0, sizeof(initialCpbRemovalOffset)); + ::memset( cpbRemovalDelayDelta, 0, sizeof(cpbRemovalDelayDelta)); + ::memset( dpbOutputTidOffset, 0, sizeof(dpbOutputTidOffset)); + } + virtual ~SEIBufferingPeriod() {} - bool m_noDisplay; + bool bpNalCpbParamsPresent; + bool bpVclCpbParamsPresent; + uint32_t initialCpbRemovalDelayLength; + uint32_t cpbRemovalDelayLength; + uint32_t dpbOutputDelayLength; + int bpCpbCnt; + uint32_t duCpbRemovalDelayIncrementLength; + uint32_t dpbOutputDelayDuLength; + uint32_t initialCpbRemovalDelay [MAX_TLAYER][MAX_CPB_CNT][2]; + uint32_t initialCpbRemovalOffset [MAX_TLAYER][MAX_CPB_CNT][2]; + bool concatenationFlag; + uint32_t auCpbRemovalDelayDelta; + bool cpbRemovalDelayDeltasPresent; + int numCpbRemovalDelayDeltas; + int bpMaxSubLayers; + uint32_t cpbRemovalDelayDelta [15]; + bool bpDecodingUnitHrdParamsPresent; + bool decodingUnitCpbParamsInPicTimingSeiFlag; + bool decodingUnitDpbDuParamsInPicTimingSeiFlag; + bool sublayerInitialCpbRemovalDelayPresent; + bool additionalConcatenationInfoPresent; + uint32_t maxInitialRemovalDelayForConcatenation; + bool sublayerDpbOutputOffsetsPresent; + uint32_t dpbOutputTidOffset [MAX_TLAYER]; + bool altCpbParamsPresent; + bool useAltCpbParamsFlag; }; -class SEISOPDescription : public SEI +class SEIPictureTiming : public SEI { public: - PayloadType payloadType() const { return SOP_DESCRIPTION; } - - SEISOPDescription() {} - virtual ~SEISOPDescription() {} - - uint32_t m_sopSeqParameterSetId; - uint32_t m_numPicsInSopMinus1; + PayloadType payloadType() const { return PICTURE_TIMING; } - uint32_t m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP]; - uint32_t m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP]; - uint32_t m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP]; - int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP]; + SEIPictureTiming() + : picDpbOutputDelay (0) + , picDpbOutputDuDelay (0) + , numDecodingUnitsMinus1 (0) + , duCommonCpbRemovalDelayFlag (false) + , cpbAltTimingInfoPresent (false) + , ptDisplayElementalPeriodsMinus1(0) + , delayForConcatenationEnsureFlag(false) + { + ::memset(ptSubLayerDelaysPresent, 0, sizeof(ptSubLayerDelaysPresent)); + ::memset(duCommonCpbRemovalDelayMinus1, 0, sizeof(duCommonCpbRemovalDelayMinus1)); + ::memset(cpbRemovalDelayDeltaEnabledFlag, 0, sizeof(cpbRemovalDelayDeltaEnabledFlag)); + ::memset(cpbRemovalDelayDeltaIdx, 0, sizeof(cpbRemovalDelayDeltaIdx)); + ::memset(auCpbRemovalDelay, 0, sizeof(auCpbRemovalDelay)); + } + virtual ~SEIPictureTiming() {} + + bool ptSubLayerDelaysPresent[MAX_TLAYER]; + bool cpbRemovalDelayDeltaEnabledFlag[MAX_TLAYER]; + uint32_t cpbRemovalDelayDeltaIdx[MAX_TLAYER]; + uint32_t auCpbRemovalDelay[MAX_TLAYER]; + uint32_t picDpbOutputDelay; + uint32_t picDpbOutputDuDelay; + uint32_t numDecodingUnitsMinus1; + bool duCommonCpbRemovalDelayFlag; + uint32_t duCommonCpbRemovalDelayMinus1[MAX_TLAYER]; + std::vector numNalusInDuMinus1; + std::vector duCpbRemovalDelayMinus1; + bool cpbAltTimingInfoPresent; + std::vector> nalCpbAltInitialRemovalDelayDelta; + std::vector> nalCpbAltInitialRemovalOffsetDelta; + std::vector nalCpbDelayOffset; + std::vector nalDpbDelayOffset; + std::vector> vclCpbAltInitialRemovalDelayDelta; + std::vector> vclCpbAltInitialRemovalOffsetDelta; + std::vector vclCpbDelayOffset; + std::vector vclDpbDelayOffset; + int ptDisplayElementalPeriodsMinus1; + bool delayForConcatenationEnsureFlag; }; -class SEIToneMappingInfo : public SEI +class SEIDecodingUnitInfo : public SEI { public: - PayloadType payloadType() const { return TONE_MAPPING_INFO; } - SEIToneMappingInfo() {} - virtual ~SEIToneMappingInfo() {} - - int m_toneMapId; - bool m_toneMapCancelFlag; - bool m_toneMapPersistenceFlag; - int m_codedDataBitDepth; - int m_targetBitDepth; - int m_modelId; - int m_minValue; - int m_maxValue; - int m_sigmoidMidpoint; - int m_sigmoidWidth; - std::vector m_startOfCodedInterval; - int m_numPivots; - std::vector m_codedPivotValue; - std::vector m_targetPivotValue; - int m_cameraIsoSpeedIdc; - int m_cameraIsoSpeedValue; - int m_exposureIndexIdc; - int m_exposureIndexValue; - bool m_exposureCompensationValueSignFlag; - int m_exposureCompensationValueNumerator; - int m_exposureCompensationValueDenomIdc; - int m_refScreenLuminanceWhite; - int m_extendedRangeWhiteLevel; - int m_nominalBlackLevelLumaCodeValue; - int m_nominalWhiteLevelLumaCodeValue; - int m_extendedWhiteLevelLumaCodeValue; + PayloadType payloadType() const { return DECODING_UNIT_INFO; } + + SEIDecodingUnitInfo() + : decodingUnitIdx(0) + , dpbOutputDuDelayPresent(false) + , picSptDpbOutputDuDelay(0) + {} + virtual ~SEIDecodingUnitInfo() {} + + int decodingUnitIdx; + int duSptCpbRemovalDelayIncrement[MAX_TLAYER]; + bool duiSubLayerDelaysPresent[MAX_TLAYER]; + bool dpbOutputDuDelayPresent; + int picSptDpbOutputDuDelay; }; -class SEIKneeFunctionInfo : public SEI + +class SEIFrameFieldInfo : public SEI { public: - PayloadType payloadType() const { return KNEE_FUNCTION_INFO; } - SEIKneeFunctionInfo() {} - virtual ~SEIKneeFunctionInfo() {} - - int m_kneeId; - bool m_kneeCancelFlag; - bool m_kneePersistenceFlag; - int m_kneeInputDrange; - int m_kneeInputDispLuminance; - int m_kneeOutputDrange; - int m_kneeOutputDispLuminance; - int m_kneeNumKneePointsMinus1; - std::vector m_kneeInputKneePoint; - std::vector m_kneeOutputKneePoint; + PayloadType payloadType() const { return FRAME_FIELD_INFO; } + + SEIFrameFieldInfo() + : fieldPicFlag(false) + , bottomFieldFlag (false) + , pairingIndicatedFlag (false) + , pairedWithNextFieldFlag(false) + , displayFieldsFromFrameFlag(false) + , topFieldFirstFlag(false) + , duplicateFlag(false) + , displayElementalPeriodsMinus1(0) + , sourceScanType(0) + {} + virtual ~SEIFrameFieldInfo() {} + + bool fieldPicFlag; + bool bottomFieldFlag; + bool pairingIndicatedFlag; + bool pairedWithNextFieldFlag; + bool displayFieldsFromFrameFlag; + bool topFieldFirstFlag; + bool duplicateFlag; + int displayElementalPeriodsMinus1; + int sourceScanType; }; -class SEIColourRemappingInfo : public SEI + +class SEIFramePacking : public SEI { public: + PayloadType payloadType() const { return FRAME_PACKING; } - struct CRIlut - { - int codedValue; - int targetValue; - bool operator < (const CRIlut& a) const - { - return codedValue < a.codedValue; - } - }; - - PayloadType payloadType() const { return COLOUR_REMAPPING_INFO; } - SEIColourRemappingInfo() {} - ~SEIColourRemappingInfo() {} - - void copyFrom( const SEIColourRemappingInfo &seiCriInput) - { - (*this) = seiCriInput; - } + SEIFramePacking() {} + virtual ~SEIFramePacking() {} - uint32_t m_colourRemapId; - bool m_colourRemapCancelFlag; - bool m_colourRemapPersistenceFlag; - bool m_colourRemapVideoSignalInfoPresent; - bool m_colourRemapFullRangeFlag; - int m_colourRemapPrimaries; - int m_colourRemapTransferFunction; - int m_colourRemapMatrixCoefficients; - int m_colourRemapInputBitDepth; - int m_colourRemapBitDepth; - int m_preLutNumValMinus1[3]; - std::vector m_preLut[3]; - bool m_colourRemapMatrixPresent; - int m_log2MatrixDenom; - int m_colourRemapCoeffs[3][3]; - int m_postLutNumValMinus1[3]; - std::vector m_postLut[3]; + bool arrangementCancelFlag; + bool quincunxSamplingFlag; + bool spatialFlippingFlag; + bool frame0FlippedFlag; + bool fieldViewsFlag; + bool currentFrameIsFrame0Flag; + bool frame0SelfContainedFlag; + bool frame1SelfContainedFlag; + bool arrangementPersistenceFlag; + bool upsampledAspectRatio; + int arrangementId; + int arrangementType; + int contentInterpretationType; + int frame0GridPositionX; + int frame0GridPositionY; + int frame1GridPositionX; + int frame1GridPositionY; + int arrangementReservedByte; }; -class SEIChromaResamplingFilterHint : public SEI +class SEIParameterSetsInclusionIndication : public SEI { public: - PayloadType payloadType() const {return CHROMA_RESAMPLING_FILTER_HINT;} - SEIChromaResamplingFilterHint() {} - virtual ~SEIChromaResamplingFilterHint() {} - - int m_verChromaFilterIdc; - int m_horChromaFilterIdc; - bool m_verFilteringFieldProcessingFlag; - int m_targetFormatIdc; - bool m_perfectReconstructionFlag; - std::vector > m_verFilterCoeff; - std::vector > m_horFilterCoeff; + PayloadType payloadType() const { return PARAMETER_SETS_INCLUSION_INDICATION; } + SEIParameterSetsInclusionIndication() {} + virtual ~SEIParameterSetsInclusionIndication() {} + + int selfContainedClvsFlag; }; class SEIMasteringDisplayColourVolume : public SEI @@ -486,13 +480,13 @@ class SEIMasteringDisplayColourVolume : public SEI SEIMasteringDisplayColourVolume() {} virtual ~SEIMasteringDisplayColourVolume(){} -// SEIMasteringDisplay values; + SEIMasteringDisplay values; }; typedef std::list SEIMessages; /// output a selection of SEI messages by payload type. Ownership stays in original message list. -SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType); +SEIMessages getSeisByType(const SEIMessages &seiList, SEI::PayloadType seiType); /// remove a selection of SEI messages by payload type from the original list and return them in a new list. SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType); @@ -505,126 +499,172 @@ class SEIScalableNesting : public SEI public: PayloadType payloadType() const { return SCALABLE_NESTING; } - SEIScalableNesting() {} + SEIScalableNesting() + : snOlsFlag (false) + , snSubpicFlag (false) + , snNumOlssMinus1 (0) + , snAllLayersFlag (false) + , snNumLayersMinus1 (0) + , snNumSubpics (1) + , snSubpicIdLen (0) + , snNumSEIs(0) + {} virtual ~SEIScalableNesting() { - deleteSEIs(m_nestedSEIs); + deleteSEIs(nestedSEIs); } - bool m_bitStreamSubsetFlag; - bool m_nestingOpFlag; - bool m_defaultOpFlag; //value valid if m_nestingOpFlag != 0 - uint32_t m_nestingNumOpsMinus1; // -"- - uint32_t m_nestingMaxTemporalIdPlus1[MAX_TLAYER]; // -"- - uint32_t m_nestingOpIdx[MAX_NESTING_NUM_OPS]; // -"- + bool snOlsFlag; + bool snSubpicFlag; + uint32_t snNumOlssMinus1; + uint32_t snOlsIdxDeltaMinus1[MAX_NESTING_NUM_LAYER]; + uint32_t snOlsIdx[MAX_NESTING_NUM_LAYER]; + bool snAllLayersFlag; //value valid if m_nestingOlsFlag == 0 + uint32_t snNumLayersMinus1; //value valid if m_nestingOlsFlag == 0 and m_nestingAllLayersFlag == 0 + uint8_t snLayerId[MAX_NESTING_NUM_LAYER]; //value valid if m_nestingOlsFlag == 0 and m_nestingAllLayersFlag == 0. This can e.g. be a static array of 64 uint8_t values + uint32_t snNumSubpics; + uint8_t snSubpicIdLen; + std::vector snSubpicId; + uint32_t snNumSEIs; + + SEIMessages nestedSEIs; +}; + +class SEIAlternativeTransferCharacteristics : public SEI +{ +public: + PayloadType payloadType() const { return ALTERNATIVE_TRANSFER_CHARACTERISTICS; } + + SEIAlternativeTransferCharacteristics() : preferredTransferCharacteristics(18) + { } - bool m_allLayersFlag; //value valid if m_nestingOpFlag == 0 - uint32_t m_nestingNoOpMaxTemporalIdPlus1; //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0 - uint32_t m_nestingNumLayersMinus1; //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0 - uint8_t m_nestingLayerId[MAX_NESTING_NUM_LAYER]; //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0. This can e.g. be a static array of 64 uint8_t values + virtual ~SEIAlternativeTransferCharacteristics() {} - SEIMessages m_nestedSEIs; + uint32_t preferredTransferCharacteristics; }; -class SEITimeCode : public SEI +class SEIUserDataRegistered : public SEI { public: - PayloadType payloadType() const { return TIME_CODE; } - SEITimeCode() {} - virtual ~SEITimeCode(){} + PayloadType payloadType() const { return USER_DATA_REGISTERED_ITU_T_T35; } + + SEIUserDataRegistered() {} + virtual ~SEIUserDataRegistered() {} - uint32_t numClockTs; + uint16_t ituCountryCode; + std::vector userData; }; -//definition according to P1005_v1; -class SEITempMotionConstrainedTileSets: public SEI +class SEIFilmGrainCharacteristics : public SEI { - struct TileSetData +public: + PayloadType payloadType() const { return FILM_GRAIN_CHARACTERISTICS; } + + SEIFilmGrainCharacteristics() {} + virtual ~SEIFilmGrainCharacteristics() {} + + bool filmGrainCharacteristicsCancelFlag; + uint8_t filmGrainModelId; + bool separateColourDescriptionPresent; + uint8_t filmGrainBitDepthLumaMinus8; + uint8_t filmGrainBitDepthChromaMinus8; + bool filmGrainFullRangeFlag; + uint8_t filmGrainColourPrimaries; + uint8_t filmGrainTransferCharacteristics; + uint8_t filmGrainMatrixCoeffs; + uint8_t blendingModeId; + uint8_t log2ScaleFactor; + + struct CompModelIntensityValues { - protected: - std::vector m_top_left_tile_index; //[tileSetIdx][tileIdx]; - std::vector m_bottom_right_tile_index; - - public: - int m_mcts_id; - bool m_display_tile_set_flag; - bool m_exact_sample_value_match_flag; - bool m_mcts_tier_level_idc_present_flag; - bool m_mcts_tier_flag; - int m_mcts_level_idc; - - void setNumberOfTileRects(const int number) - { - m_top_left_tile_index .resize(number); - m_bottom_right_tile_index.resize(number); - } - - int getNumberOfTileRects() const - { - CHECK(m_top_left_tile_index.size() != m_bottom_right_tile_index.size(), "Inconsistent tile arrangement"); - return int(m_top_left_tile_index.size()); - } - - int& topLeftTileIndex (const int tileRectIndex) { return m_top_left_tile_index [tileRectIndex]; } - int& bottomRightTileIndex(const int tileRectIndex) { return m_bottom_right_tile_index[tileRectIndex]; } - const int& topLeftTileIndex (const int tileRectIndex) const { return m_top_left_tile_index [tileRectIndex]; } - const int& bottomRightTileIndex(const int tileRectIndex) const { return m_bottom_right_tile_index[tileRectIndex]; } + uint8_t intensityIntervalLowerBound; + uint8_t intensityIntervalUpperBound; + std::vector compModelValue; }; -protected: - std::vector m_tile_set_data; - -public: - - bool m_mc_all_tiles_exact_sample_value_match_flag; - bool m_each_tile_one_tile_set_flag; - bool m_limited_tile_set_display_flag; - bool m_max_mcs_tier_level_idc_present_flag; - bool m_max_mcts_tier_flag; - int m_max_mcts_level_idc; + struct CompModel + { + bool presentFlag; + uint8_t numModelValues; + std::vector intensityValues; + }; - PayloadType payloadType() const { return TEMP_MOTION_CONSTRAINED_TILE_SETS; } + CompModel compModel[MAX_NUM_COMP]; + bool filmGrainCharacteristicsPersistenceFlag; +}; - void setNumberOfTileSets(const int number) { m_tile_set_data.resize(number); } - int getNumberOfTileSets() const { return int(m_tile_set_data.size()); } +class SEIContentLightLevelInfo : public SEI +{ +public: + PayloadType payloadType() const { return CONTENT_LIGHT_LEVEL_INFO; } + SEIContentLightLevelInfo() { } - TileSetData &tileSetData (const int index) { return m_tile_set_data[index]; } - const TileSetData &tileSetData (const int index) const { return m_tile_set_data[index]; } + virtual ~SEIContentLightLevelInfo() { } + uint32_t maxContentLightLevel; + uint32_t maxPicAverageLightLevel; }; -#if ENABLE_TRACING -void xTraceSEIHeader(); -void xTraceSEIMessageType( SEI::PayloadType payloadType ); -#endif - -class SEIAlternativeTransferCharacteristics : public SEI +class SEIAmbientViewingEnvironment : public SEI { public: - PayloadType payloadType() const { return ALTERNATIVE_TRANSFER_CHARACTERISTICS; } + PayloadType payloadType() const { return AMBIENT_VIEWING_ENVIRONMENT; } + SEIAmbientViewingEnvironment() { } - SEIAlternativeTransferCharacteristics() : m_preferredTransferCharacteristics(18) - { } - - virtual ~SEIAlternativeTransferCharacteristics() {} + virtual ~SEIAmbientViewingEnvironment() { } - uint32_t m_preferredTransferCharacteristics; + uint32_t ambientIlluminance; + uint16_t ambientLightX; + uint16_t ambientLightY; }; -class SEIGreenMetadataInfo : public SEI +class SEIContentColourVolume : public SEI { public: - PayloadType payloadType() const { return GREEN_METADATA; } - SEIGreenMetadataInfo() {} - - virtual ~SEIGreenMetadataInfo() {} + PayloadType payloadType() const { return CONTENT_COLOUR_VOLUME; } + SEIContentColourVolume() {} + virtual ~SEIContentColourVolume() {} + + bool ccvCancelFlag; + bool ccvPersistenceFlag; + bool ccvPrimariesPresent; + bool ccvMinLuminanceValuePresent; + bool ccvMaxLuminanceValuePresent; + bool ccvAvgLuminanceValuePresent; + int ccvPrimariesX[MAX_NUM_COMP]; + int ccvPrimariesY[MAX_NUM_COMP]; + uint32_t ccvMinLuminanceValue; + uint32_t ccvMaxLuminanceValue; + uint32_t ccvAvgLuminanceValue; +}; - uint32_t m_greenMetadataType; - uint32_t m_xsdMetricType; - uint32_t m_xsdMetricValue; +class SEISubpicureLevelInfo : public SEI +{ +public: + PayloadType payloadType() const { return SUBPICTURE_LEVEL_INFO; } + SEISubpicureLevelInfo() + : numRefLevels(0) + , explicitFractionPresent (false) + , cbrConstraintFlag (false) + , numSubpics(0) + , sliMaxSublayers(1) + , sliSublayerInfoPresent(false) + {} + virtual ~SEISubpicureLevelInfo() {} + + int numRefLevels; + bool explicitFractionPresent; + bool cbrConstraintFlag; + int numSubpics; + int sliMaxSublayers; + bool sliSublayerInfoPresent; + std::vector> nonSubpicLayersFraction; + std::vector> refLevelIdc; + std::vector>> refLevelFraction; }; + } // namespace vvenc //! \} diff --git a/source/Lib/CommonLib/SampleAdaptiveOffset.cpp b/source/Lib/CommonLib/SampleAdaptiveOffset.cpp index 479a1c0d8..6373cf131 100644 --- a/source/Lib/CommonLib/SampleAdaptiveOffset.cpp +++ b/source/Lib/CommonLib/SampleAdaptiveOffset.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file SampleAdaptiveOffset.cpp diff --git a/source/Lib/CommonLib/SampleAdaptiveOffset.h b/source/Lib/CommonLib/SampleAdaptiveOffset.h index 4e7271242..9d260a2aa 100644 --- a/source/Lib/CommonLib/SampleAdaptiveOffset.h +++ b/source/Lib/CommonLib/SampleAdaptiveOffset.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file SampleAdaptiveOffset.h \brief sample adaptive offset class (header) */ diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 9a763f3fb..dcbeff492 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Slice.cpp @@ -51,7 +55,6 @@ vvc@hhi.fraunhofer.de #include "Picture.h" #include "UnitTools.h" #include "dtrace_next.h" -//#include "VVEnc/EncCfg.h" //! \ingroup CommonLib //! \{ @@ -1499,7 +1502,8 @@ SPS::SPS() , numHorVirtualBoundaries ( 0 ) , virtualBoundariesPosX { 0, 0, 0 } , virtualBoundariesPosY { 0, 0, 0 } -, hrdParametersPresent ( 0 ) +, hrdParametersPresent ( false ) +, subLayerParametersPresent ( false ) , fieldSeqFlag ( false ) , vuiParametersPresent ( false ) , vuiParameters () @@ -1558,9 +1562,6 @@ SPS::SPS() ::memset(ltRefPicPocLsbSps, 0, sizeof(ltRefPicPocLsbSps)); ::memset(usedByCurrPicLtSPS, 0, sizeof(usedByCurrPicLtSPS)); - ::memset(ppsValidFlag, 0, sizeof(ppsValidFlag)); - ::memset(scalingWindowSizeInPPS, 0, sizeof(scalingWindowSizeInPPS)); - for( int i = 0; i < MAX_NUM_SUB_PICS; i++ ) { @@ -1851,7 +1852,7 @@ uint32_t PPS::getSubPicIdxFromSubPicId( uint32_t subPicId ) const } -SubPic PPS::getSubPicFromPos(const Position& pos) const +const SubPic& PPS::getSubPicFromPos(const Position& pos) const { for (int i = 0; i< numSubPics; i++) { @@ -1864,7 +1865,7 @@ SubPic PPS::getSubPicFromPos(const Position& pos) const } -SubPic PPS::getSubPicFromCU(const CodingUnit& cu) const +const SubPic& PPS::getSubPicFromCU(const CodingUnit& cu) const { const Position lumaPos = cu.Y().valid() ? cu.Y().pos() : recalcPosition(cu.chromaFormat, cu.chType, CH_L, cu.blocks[cu.chType].pos()); return getSubPicFromPos(lumaPos); diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index d50a92bbc..1db2b651f 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Slice.h \brief slice header and SPS class (header) */ @@ -50,6 +54,7 @@ vvc@hhi.fraunhofer.de #include "AlfParameters.h" #include "Common.h" #include "MotionInfo.h" +#include "HRD.h" #include #include @@ -112,7 +117,7 @@ typedef std::vector RPLList; struct ConstraintInfo { - bool gciPresentFlag; + bool gciPresent; bool noRprConstraintFlag; bool noResChangeInClvsConstraintFlag; bool oneTilePerPicConstraintFlag; @@ -183,7 +188,7 @@ struct ConstraintInfo ConstraintInfo() - : gciPresentFlag ( false ) + : gciPresent ( false ) , noRprConstraintFlag ( false ) , noResChangeInClvsConstraintFlag ( false ) , oneTilePerPicConstraintFlag ( false ) @@ -441,10 +446,9 @@ struct SubPic struct DCI { uint32_t dciId; - uint32_t maxSubLayersMinus1; std::vector profileTierLevel; - DCI() : dciId(0), maxSubLayersMinus1 (0) {}; + DCI() : dciId(0) {} }; struct VPS @@ -453,12 +457,13 @@ struct VPS uint32_t maxLayers; uint32_t maxSubLayers; uint32_t layerId[MAX_VPS_LAYERS]; + bool defaultPtlDpbHrdMaxTidFlag; bool allLayersSameNumSubLayers; bool allIndependentLayers; uint32_t vpsCfgPredDirection[MAX_VPS_SUBLAYERS]; bool independentLayer[MAX_VPS_LAYERS]; bool directRefLayer[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; - uint8_t maxTidIlRefPicsPlus1[MAX_VPS_LAYERS]; + uint8_t maxTidIlRefPicsPlus1[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; bool eachLayerIsAnOls; uint32_t olsModeIdc; uint32_t numOutputLayerSets; @@ -475,11 +480,17 @@ struct VPS uint32_t interLayerRefIdx[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; bool extension; - bool generalHrdParamsPresentFlag; - + bool generalHrdParamsPresent; + bool sublayerCpbParamsPresent; + uint32_t numOlsHrdParamsMinus1; + uint32_t hrdMaxTid[MAX_NUM_OLSS]; + uint32_t olsHrdIdx[MAX_NUM_OLSS]; + GeneralHrdParams generalHrdParams; + OlsHrdParams olsHrdParams[MAX_TLAYER]; std::vector olsDpbPicSize; std::vector olsDpbParamsIdx; std::vector> outputLayerIdInOls; + std::vector> numSubLayersInLayerInOLS; std::vector olsDpbChromaFormatIdc; std::vector olsDpbBitDepthMinus8; @@ -502,6 +513,7 @@ struct VPS : vpsId ( 0 ) , maxLayers ( 0 ) , maxSubLayers ( 0 ) + , defaultPtlDpbHrdMaxTidFlag ( false ) , allLayersSameNumSubLayers ( false ) , allIndependentLayers ( false ) , eachLayerIsAnOls ( false ) @@ -751,8 +763,9 @@ struct SPS bool hrdParametersPresent; -// GeneralHrdParams m_generalHrdParams; -// OlsHrdParams m_olsHrdParams[MAX_TLAYER]; + bool subLayerParametersPresent; + GeneralHrdParams generalHrdParams; + OlsHrdParams olsHrdParams[MAX_TLAYER]; bool fieldSeqFlag; bool vuiParametersPresent; VUI vuiParameters; @@ -797,8 +810,6 @@ struct SPS bool interLayerPresent; uint32_t log2ParallelMergeLevelMinus2; // th fix this - bool ppsValidFlag[64]; - Size scalingWindowSizeInPPS[64]; uint32_t maxNumMergeCand; uint32_t maxNumAffineMergeCand; uint32_t maxNumIBCMergeCand; @@ -949,8 +960,8 @@ struct PPS uint32_t getTileIdx( const Position& pos ) const { return 0; } //tbd - SubPic getSubPicFromPos(const Position& pos) const; - SubPic getSubPicFromCU (const CodingUnit& cu) const; + const SubPic& getSubPicFromPos(const Position& pos) const; + const SubPic& getSubPicFromCU (const CodingUnit& cu) const; void resetTileSliceInfo(); void initTiles(); @@ -968,8 +979,8 @@ struct APS LmcsParam lmcsParam; CcAlfFilterParam ccAlfParam; bool hasPrefixNalUnitType; - bool chromaPresentFlag; - APS() : apsId(0), temporalId( 0 ), layerId( 0 ), apsType(0), hasPrefixNalUnitType(false), chromaPresentFlag( false ) + bool chromaPresent; + APS() : apsId(0), temporalId( 0 ), layerId( 0 ), apsType(0), hasPrefixNalUnitType(false), chromaPresent( false ) { } }; @@ -1122,7 +1133,7 @@ struct PicHeader deblockingFilterBetaOffsetDiv2[COMP_Cr] = 0; deblockingFilterTcOffsetDiv2[COMP_Cr] = 0; lmcsEnabled = 0; - lmcsApsId = -1; + lmcsApsId = 0; lmcsAps = nullptr; lmcsChromaResidualScale = 0; explicitScalingListEnabled = 0; @@ -1334,12 +1345,7 @@ template class ParameterSetMap ~ParameterSetMap() { - for (typename std::map >::iterator i = m_paramsetMap.begin(); i!= m_paramsetMap.end(); i++) - { - delete (*i).second.pNaluData; - delete (*i).second.parameterSet; - } - delete m_lastActiveParameterSet; m_lastActiveParameterSet = NULL; + clearMap(); } T *allocatePS( const int psId ) @@ -1357,7 +1363,14 @@ template class ParameterSetMap void clearMap() { + for( typename std::map >::iterator i = m_paramsetMap.begin(); i != m_paramsetMap.end(); i++ ) + { + delete (*i).second.pNaluData; + delete (*i).second.parameterSet; + } + delete m_lastActiveParameterSet; m_lastActiveParameterSet = nullptr; m_paramsetMap.clear(); + m_activePsId.clear(); } void storePS( int psId, T *ps ) @@ -1494,6 +1507,7 @@ class ParameterSetManager bool getAPSChangedFlag(int apsId, int apsType) const { return m_apsMap.getChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); } void clearAPSChangedFlag(int apsId, int apsType) { m_apsMap.clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); } bool activateAPS(int apsId, int apsType); + const VPS* getActiveVPS()const { return m_vpsMap.getPS(m_activeVPSId); }; const SPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); }; const DCI* getActiveDCI()const { return m_dciMap.getPS(m_activeDCIId); }; diff --git a/source/Lib/CommonLib/StatCounter.cpp b/source/Lib/CommonLib/StatCounter.cpp index 9dd842c6b..7c554fd51 100644 --- a/source/Lib/CommonLib/StatCounter.cpp +++ b/source/Lib/CommonLib/StatCounter.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "CommonDef.h" diff --git a/source/Lib/CommonLib/StatCounter.h b/source/Lib/CommonLib/StatCounter.h index c9866ef84..c59cd1eb0 100644 --- a/source/Lib/CommonLib/StatCounter.h +++ b/source/Lib/CommonLib/StatCounter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once diff --git a/source/Lib/CommonLib/TimeProfiler.h b/source/Lib/CommonLib/TimeProfiler.h index 1d41a5d0d..06551c5c1 100644 --- a/source/Lib/CommonLib/TimeProfiler.h +++ b/source/Lib/CommonLib/TimeProfiler.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file TimeProfiler.h \brief profiling of run-time behavior (header) */ diff --git a/source/Lib/CommonLib/TrQuant.cpp b/source/Lib/CommonLib/TrQuant.cpp index f7a51215a..e33f3d7a6 100644 --- a/source/Lib/CommonLib/TrQuant.cpp +++ b/source/Lib/CommonLib/TrQuant.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file TrQuant.cpp @@ -272,7 +276,14 @@ void TrQuant::invTransformNxN( TransformUnit& tu, const ComponentID compID, PelB { xInvLfnst(tu, compID); } - xIT( tu, compID, tempCoeff, pResi ); + if (tu.mtsIdx[compID] == MTS_SKIP) + { + xITransformSkip(tempCoeff, pResi, tu, compID); + } + else + { + xIT(tu, compID, tempCoeff, pResi); + } } //DTRACE_BLOCK_COEFF(tu.getCoeffs(compID), tu, tu.cu->predMode, compID); @@ -367,7 +378,16 @@ std::vector TrQuant::selectICTCandidates( const TransformUnit& tu, CompStor // ------------------------------------------------------------------------------------------------ void TrQuant::xSetTrTypes( const TransformUnit& tu, const ComponentID compID, const int width, const int height, int &trTypeHor, int &trTypeVer ) { - if( tu.cs->sps->getUseImplicitMTS() && CU::isIntra(*tu.cu) && isLuma(compID) && tu.cu->lfnstIdx == 0 && tu.cu->mipFlag == 0 ) + const bool isISP = CU::isIntra(*tu.cu) && tu.cu->ispMode && isLuma(compID); + if (isISP && tu.cu->lfnstIdx) + { + return; + } + if (!tu.cs->sps->MTS) + { + return; + } + if (CU::isIntra(*tu.cu) && isLuma(compID) && ((tu.cs->sps->getUseImplicitMTS() && tu.cu->lfnstIdx == 0 && tu.cu->mipFlag == 0) || tu.cu->ispMode)) { if (width >= 4 && width <= 16) trTypeHor = DST7; @@ -486,8 +506,22 @@ void TrQuant::xT( const TransformUnit& tu, const ComponentID compID, const CPelB CHECK( shift_1st < 0, "Negative shift" ); CHECK( shift_2nd < 0, "Negative shift" ); - fastFwdTrans[trTypeHor][transformWidthIndex ](block, tmp, shift_1st, height, 0, skipWidth); - fastFwdTrans[trTypeVer][transformHeightIndex](tmp, dstCoeff.buf, shift_2nd, width, skipWidth, skipHeight); + if (width > 1 && height > 1) + { + fastFwdTrans[trTypeHor][transformWidthIndex](block, tmp, shift_1st, height, 0, skipWidth); + fastFwdTrans[trTypeVer][transformHeightIndex](tmp, dstCoeff.buf, shift_2nd, width, skipWidth, skipHeight); + } + else if (height == 1) // 1-D horizontal transform + { + fastFwdTrans[trTypeHor][transformWidthIndex](block, dstCoeff.buf, shift_1st, 1, 0, skipWidth); + } + else // if (iWidth == 1) //1-D vertical transform + { + int shift = ((floorLog2(height)) + bitDepth + TRANSFORM_MATRIX_SHIFT) - maxLog2TrDynamicRange + COM16_C806_TRANS_PREC; + CHECK(shift < 0, "Negative shift"); + CHECKD((transformHeightIndex < 0), "There is a problem with the height."); + fastFwdTrans[trTypeVer][transformHeightIndex](block, dstCoeff.buf, shift, 1, 0, skipHeight); + } } @@ -514,15 +548,46 @@ void TrQuant::xIT( const TransformUnit& tu, const ComponentID compID, const CCoe int skipWidth = ( trTypeHor != DCT2 && width == 32 ) ? 16 : width > JVET_C0024_ZERO_OUT_TH ? width - JVET_C0024_ZERO_OUT_TH : 0; int skipHeight = ( trTypeVer != DCT2 && height == 32 ) ? 16 : height > JVET_C0024_ZERO_OUT_TH ? height - JVET_C0024_ZERO_OUT_TH : 0; + if (tu.cs->sps->LFNST && tu.cu->lfnstIdx) + { + if ((width == 4 && height > 4) || (width > 4 && height == 4)) + { + skipWidth = width - 4; + skipHeight = height - 4; + } + else if ((width >= 8 && height >= 8)) + { + skipWidth = width - 8; + skipHeight = height - 8; + } + } + const int shift_1st = TRANSFORM_MATRIX_SHIFT + 1 + COM16_C806_TRANS_PREC; // 1 has been added to shift_1st at the expense of shift_2nd const int shift_2nd = ( TRANSFORM_MATRIX_SHIFT + maxLog2TrDynamicRange - 1 ) - bitDepth + COM16_C806_TRANS_PREC; CHECK( shift_1st < 0, "Negative shift" ); CHECK( shift_2nd < 0, "Negative shift" ); TCoeff *block = m_blk; TCoeff *tmp = m_tmp; - fastInvTrans[trTypeVer][transformHeightIndex](pCoeff.buf, tmp, shift_1st, width, skipWidth, skipHeight, clipMinimum, clipMaximum); - fastInvTrans[trTypeHor][transformWidthIndex] (tmp, block, shift_2nd, height, 0, skipWidth, clipMinimum, clipMaximum); - + if (width > 1 && height > 1) // 2-D transform + { + fastInvTrans[trTypeVer][transformHeightIndex](pCoeff.buf, tmp, shift_1st, width, skipWidth, skipHeight, clipMinimum, clipMaximum); + fastInvTrans[trTypeHor][transformWidthIndex](tmp, block, shift_2nd, height, 0, skipWidth, clipMinimum, clipMaximum); + } + else if (width == 1) // 1-D vertical transform + { + int shift = (TRANSFORM_MATRIX_SHIFT + maxLog2TrDynamicRange - 1) - bitDepth + COM16_C806_TRANS_PREC; + CHECK(shift < 0, "Negative shift"); + CHECK((transformHeightIndex < 0), "There is a problem with the height."); + fastInvTrans[trTypeVer][transformHeightIndex](pCoeff.buf, block, shift + 1, 1, 0, skipHeight, clipMinimum, clipMaximum); + } + else // if(iHeight == 1) //1-D horizontal transform + { + const int shift = (TRANSFORM_MATRIX_SHIFT + maxLog2TrDynamicRange - 1) - bitDepth + COM16_C806_TRANS_PREC; + CHECK(shift < 0, "Negative shift"); + CHECK((transformWidthIndex < 0), "There is a problem with the width."); + fastInvTrans[trTypeHor][transformWidthIndex](pCoeff.buf, block, shift + 1, 1, 0, skipWidth, clipMinimum, clipMaximum); + } + #if ENABLE_SIMD_TRAFO if( width & 3 ) #endif //ENABLE_SIMD_TRAFO @@ -552,6 +617,25 @@ void TrQuant::xIT( const TransformUnit& tu, const ComponentID compID, const CCoe #endif //ENABLE_SIMD_TRAFO } +/** Wrapper function between HM interface and core NxN transform skipping + */ +void TrQuant::xITransformSkip(const CCoeffBuf& pCoeff, + PelBuf& pResidual, + const TransformUnit& tu, + const ComponentID compID) +{ + const CompArea& area = tu.blocks[compID]; + const int width = area.width; + const int height = area.height; + + for (uint32_t y = 0; y < height; y++) + { + for (uint32_t x = 0; x < width; x++) + { + pResidual.at(x, y) = Pel(pCoeff.at(x, y)); + } + } +} void TrQuant::xQuant(TransformUnit& tu, const ComponentID compID, const CCoeffBuf& pSrc, TCoeff &uiAbsSum, const QpParam& cQP, const Ctx& ctx) { @@ -575,8 +659,7 @@ void TrQuant::transformNxN(TransformUnit &tu, const ComponentID compID, const Qp TU::setCbfAtDepth( tu, compID, tu.depth, uiAbsSum > 0 ); return; } - - if( tu.cu->bdpcmMode && isLuma(compID) ) + if (tu.cu->bdpcmM[toChannelType(compID)]) { tu.mtsIdx[compID] = MTS_SKIP; } @@ -588,7 +671,14 @@ void TrQuant::transformNxN(TransformUnit &tu, const ComponentID compID, const Qp if (!loadTr) { DTRACE_PEL_BUF( D_RESIDUALS, resiBuf, tu, tu.cu->predMode, compID ); - xT( tu, compID, resiBuf, tempCoeff, uiWidth, uiHeight ); + if (tu.mtsIdx[compID] == MTS_SKIP) + { + xTransformSkip(tu, compID, resiBuf, tempCoeff.buf); + } + else + { + xT(tu, compID, resiBuf, tempCoeff, uiWidth, uiHeight); + } } if (cs.sps->LFNST) { @@ -604,11 +694,10 @@ void TrQuant::transformNxN(TransformUnit &tu, const ComponentID compID, const Qp TU::setCbfAtDepth (tu, compID, tu.depth, uiAbsSum > 0); } - -void TrQuant::checktransformsNxN( TransformUnit &tu, std::vector *trModes, const int maxCand) +void TrQuant::checktransformsNxN( TransformUnit &tu, std::vector *trModes, const int maxCand, const ComponentID compID) { CodingStructure &cs = *tu.cs; - const CompArea & rect = tu.blocks[COMP_Y]; + const CompArea& rect = tu.blocks[compID]; const uint32_t width = rect.width; const uint32_t height = rect.height; @@ -621,8 +710,8 @@ void TrQuant::checktransformsNxN( TransformUnit &tu, std::vector *trMode const double facBB[] = { 1.2, 1.3, 1.3, 1.4, 1.5 }; while (it != trModes->end()) { - tu.mtsIdx[COMP_Y] = it->first; - CoeffBuf tempCoeff(m_mtsCoeffs[tu.mtsIdx[COMP_Y]], rect); + tu.mtsIdx[compID] = it->first; + CoeffBuf tempCoeff(m_mtsCoeffs[tu.mtsIdx[compID]], rect); if (tu.noResidual) { int sumAbs = 0; @@ -630,8 +719,14 @@ void TrQuant::checktransformsNxN( TransformUnit &tu, std::vector *trMode it++; continue; } - - xT(tu, COMP_Y, resiBuf, tempCoeff, width, height); + if (tu.mtsIdx[compID] == MTS_SKIP) + { + xTransformSkip(tu, compID, resiBuf, tempCoeff.buf); + } + else + { + xT(tu, compID, resiBuf, tempCoeff, width, height); + } int sumAbs = 0; for (int pos = 0; pos < width * height; pos++) @@ -640,12 +735,16 @@ void TrQuant::checktransformsNxN( TransformUnit &tu, std::vector *trMode } double scaleSAD = 1.0; - if (tu.mtsIdx[COMP_Y] == MTS_SKIP && ((floorLog2(width) + floorLog2(height)) & 1) == 1) + if (tu.mtsIdx[compID] == MTS_SKIP && ((floorLog2(width) + floorLog2(height)) & 1) == 1) { scaleSAD = 1.0 / 1.414213562; // compensate for not scaling transform skip coefficients by 1/sqrt(2) } - - trCosts.push_back(TrCost(int(sumAbs * scaleSAD), pos++)); + if (tu.mtsIdx[compID] == MTS_SKIP) + { + int trShift = getTransformShift(tu.cu->slice->sps->bitDepths[CH_L], rect.size(), tu.cu->slice->sps->getMaxLog2TrDynamicRange(toChannelType(compID))); + scaleSAD *= pow(2, trShift); + } + trCosts.push_back(TrCost(int(std::min(sumAbs * scaleSAD, std::numeric_limits::max())), pos++)); it++; } @@ -755,21 +854,21 @@ void TrQuant::xInvLfnst(const TransformUnit &tu, const ComponentID compID) const uint32_t width = area.width; const uint32_t height = area.height; const uint32_t lfnstIdx = tu.cu->lfnstIdx; - if (lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && (tu.cu->isSepTree() ? true : isLuma(compID))) + if (lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && (CU::isSepTree(*tu.cu) ? true : isLuma(compID))) { - const PredictionUnit* pu = tu.cs->getPU(area.pos(), toChannelType(compID)); + const CodingUnit& cu = *tu.cs->getCU(area.pos(), toChannelType(compID), TREE_D); const bool whge3 = width >= 8 && height >= 8; const ScanElement *scan = whge3 ? g_coefTopLeftDiagScan8x8[Log2(width)] : g_scanOrderRom.getScanOrder(SCAN_GROUPED_4x4, SCAN_DIAG, Log2(area.width), Log2(area.height)); - uint32_t intraMode = PU::getFinalIntraMode(*pu, toChannelType(compID)); + uint32_t intraMode = CU::getFinalIntraMode(cu, toChannelType(compID)); - if (PU::isLMCMode( pu->intraDir[toChannelType(compID)])) + if (CU::isLMCMode( cu.intraDir[toChannelType(compID)])) { - intraMode = PU::getCoLocatedIntraLumaMode(*pu); + intraMode = CU::getCoLocatedIntraLumaMode(cu); } - if (PU::isMIP(*pu, toChannelType(compID))) + if (CU::isMIP(cu, toChannelType(compID))) { intraMode = PLANAR_IDX; } @@ -777,7 +876,12 @@ void TrQuant::xInvLfnst(const TransformUnit &tu, const ComponentID compID) if (lfnstIdx < 3) { - intraMode = xGetLFNSTIntraMode(tu.blocks[compID], intraMode); + if (tu.cu->ispMode && isLuma(compID)) + { + intraMode = xGetLFNSTIntraMode(tu.cu->blocks[compID], intraMode); + } + else + intraMode = xGetLFNSTIntraMode(tu.blocks[compID], intraMode); bool transposeFlag = xGetTransposeFlag(intraMode); const int sbSize = whge3 ? 8 : 4; bool tu4x4Flag = (width == 4 && height == 4); @@ -855,9 +959,9 @@ void TrQuant::xFwdLfnst(const TransformUnit &tu, const ComponentID compID, const const uint32_t width = area.width; const uint32_t height = area.height; const uint32_t lfnstIdx = tu.cu->lfnstIdx; - if (lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && (tu.cu->isSepTree() ? true : isLuma(compID))) + if (lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && (CU::isSepTree(*tu.cu) ? true : isLuma(compID))) { - const PredictionUnit* pu = tu.cs->getPU(area.pos(), toChannelType(compID)); + const CodingUnit& cu = *tu.cs->getCU(area.pos(), toChannelType(compID), TREE_D); const bool whge3 = width >= 8 && height >= 8; const ScanElement *scan = whge3 @@ -865,13 +969,13 @@ void TrQuant::xFwdLfnst(const TransformUnit &tu, const ComponentID compID, const : g_scanOrderRom.getScanOrder( SCAN_GROUPED_4x4, SCAN_DIAG, Log2(area.width), Log2(area.height)); - uint32_t intraMode = PU::getFinalIntraMode(*pu, toChannelType(compID)); + uint32_t intraMode = CU::getFinalIntraMode(cu, toChannelType(compID)); - if (PU::isLMCMode(pu->intraDir[toChannelType(compID)])) + if (CU::isLMCMode(cu.intraDir[toChannelType(compID)])) { - intraMode = PU::getCoLocatedIntraLumaMode(*pu); + intraMode = CU::getCoLocatedIntraLumaMode(cu); } - if (PU::isMIP(*pu, toChannelType(compID))) + if (CU::isMIP(cu, toChannelType(compID))) { intraMode = PLANAR_IDX; } @@ -879,8 +983,14 @@ void TrQuant::xFwdLfnst(const TransformUnit &tu, const ComponentID compID, const if (lfnstIdx < 3) { - intraMode = xGetLFNSTIntraMode(tu.blocks[compID], intraMode); - + if (tu.cu->ispMode && isLuma(compID)) + { + intraMode = xGetLFNSTIntraMode(tu.cu->blocks[compID], intraMode); + } + else + { + intraMode = xGetLFNSTIntraMode(tu.blocks[compID], intraMode); + } bool transposeFlag = xGetTransposeFlag(intraMode); const int sbSize = whge3 ? 8 : 4; bool tu4x4Flag = (width == 4 && height == 4); @@ -954,6 +1064,20 @@ void TrQuant::xFwdLfnst(const TransformUnit &tu, const ComponentID compID, const } } +void TrQuant::xTransformSkip(const TransformUnit& tu, const ComponentID& compID, const CPelBuf& resi, TCoeff* psCoeff) +{ + const CompArea& rect = tu.blocks[compID]; + const uint32_t width = rect.width; + const uint32_t height = rect.height; + + for (uint32_t y = 0, coefficientIndex = 0; y < height; y++) + { + for (uint32_t x = 0; x < width; x++, coefficientIndex++) + { + psCoeff[coefficientIndex] = TCoeff(resi.at(x, y)); + } + } +} } // namespace vvenc //! \} diff --git a/source/Lib/CommonLib/TrQuant.h b/source/Lib/CommonLib/TrQuant.h index 48f7a4f9d..e45188423 100644 --- a/source/Lib/CommonLib/TrQuant.h +++ b/source/Lib/CommonLib/TrQuant.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file TrQuant.h \brief transform and quantization class (header) */ @@ -88,7 +92,7 @@ class TrQuant public: void invTransformNxN ( TransformUnit& tu, const ComponentID compID, PelBuf& pResi, const QpParam& cQPs); void transformNxN ( TransformUnit& tu, const ComponentID compID, const QpParam& cQP, TCoeff &uiAbsSum, const Ctx& ctx, const bool loadTr = false); - void checktransformsNxN ( TransformUnit& tu, std::vector *trModes, const int maxCand); + void checktransformsNxN ( TransformUnit& tu, std::vector *trModes, const int maxCand, const ComponentID compID = COMP_Y); void invTransformICT ( const TransformUnit& tu, PelBuf& resCb, PelBuf& resCr ); std::pair fwdTransformICT ( const TransformUnit& tu, const PelBuf& resCb, const PelBuf& resCr, PelBuf& resC1, PelBuf& resC2, int jointCbCr = -1 ); @@ -141,7 +145,10 @@ class TrQuant // inverse transform void xIT ( const TransformUnit& tu, const ComponentID compID, const CCoeffBuf& pCoeff, PelBuf& pResidual ); - + // skipping Transform + void xTransformSkip(const TransformUnit& tu, const ComponentID& compID, const CPelBuf& resi, TCoeff* psCoeff); + // inverse skipping transform + void xITransformSkip(const CCoeffBuf& plCoef, PelBuf& pResidual, const TransformUnit& tu, const ComponentID component); void xGetCoeffEnergy( TransformUnit &tu, const ComponentID &compID, diff --git a/source/Lib/CommonLib/TrQuant_EMT.cpp b/source/Lib/CommonLib/TrQuant_EMT.cpp index c90a46a0b..e3f21ca4a 100644 --- a/source/Lib/CommonLib/TrQuant_EMT.cpp +++ b/source/Lib/CommonLib/TrQuant_EMT.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file TrQuant_EMT.cpp diff --git a/source/Lib/CommonLib/TrQuant_EMT.h b/source/Lib/CommonLib/TrQuant_EMT.h index 5c5bf846e..1440351c6 100644 --- a/source/Lib/CommonLib/TrQuant_EMT.h +++ b/source/Lib/CommonLib/TrQuant_EMT.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file TrQuant_EMT.h \brief transform and quantization class (header) */ diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 7c494992d..93f190f52 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file TypeDef.h \brief Define macros, basic types, new types and enumerations */ @@ -65,7 +69,8 @@ namespace vvenc { #define JVET_M0497_MATRIX_MULT 1 // 0: Fast method; 1: Matrix multiplication #define FIX_FOR_TEMPORARY_COMPILER_ISSUES_ENABLED 1 // Some compilers fail on particular code fragments, remove this when the compiler is fixed (or new version is used) - // ==================================================================================================================== + +// ==================================================================================================================== // General settings // ==================================================================================================================== @@ -74,9 +79,9 @@ namespace vvenc { #endif #if ENABLE_VALGRIND_CODE -#define VALGRIND_MEMCLEAR( ref ) memset(ref,0,sizeof(ref)) +#define VALGRIND_MEMCLEAR(_ref,_size) memset(_ref,0,(_size)) #else -#define VALGRIND_MEMCLEAR( ref ) +#define VALGRIND_MEMCLEAR(_ref,_size) #endif #ifndef ENABLE_TRACING @@ -409,8 +414,6 @@ enum MESearchMethod enum CoeffScanType { SCAN_DIAG = 0, ///< up-right diagonal scan - SCAN_TRAV_HOR = 1, - SCAN_TRAV_VER = 2, SCAN_NUMBER_OF_TYPES }; @@ -430,7 +433,6 @@ enum ScalingListSize SCALING_LIST_16x16, SCALING_LIST_32x32, SCALING_LIST_64x64, - SCALING_LIST_128x128, SCALING_LIST_SIZE_NUM, //for user define matrix SCALING_LIST_FIRST_CODED = SCALING_LIST_2x2, @@ -875,13 +877,11 @@ class dynamic_cache }; typedef dynamic_cache CUCache; -typedef dynamic_cache PUCache; typedef dynamic_cache TUCache; struct XUCache { CUCache cuCache; - PUCache puCache; TUCache tuCache; }; diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index 94082d10c..1e4e34e54 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file Unit.cpp @@ -248,8 +252,8 @@ const UnitArea UnitArea::singleChan(const ChannelType chType) const // coding unit method definitions // --------------------------------------------------------------------------- -CodingUnit::CodingUnit(const UnitArea& unit) : UnitArea(unit), cs(nullptr), slice(nullptr), chType( CH_L ), next(nullptr), pu(nullptr), firstTU(nullptr), lastTU(nullptr) { initData(); } -CodingUnit::CodingUnit(const ChromaFormat _chromaFormat, const Area& _area) : UnitArea(_chromaFormat, _area), cs(nullptr), slice(nullptr), chType( CH_L ), next(nullptr), pu(nullptr), firstTU(nullptr), lastTU(nullptr) { initData(); } +CodingUnit::CodingUnit(const UnitArea& unit) : UnitArea(unit), cs(nullptr), slice(nullptr), chType( CH_L ), next(nullptr), firstTU(nullptr), lastTU(nullptr) { initData(); initPuData(); } +CodingUnit::CodingUnit(const ChromaFormat _chromaFormat, const Area& _area) : UnitArea(_chromaFormat, _area), cs(nullptr), slice(nullptr), chType( CH_L ), next(nullptr), firstTU(nullptr), lastTU(nullptr) { initData(); initPuData(); } CodingUnit& CodingUnit::operator=( const CodingUnit& other ) { @@ -267,8 +271,8 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) colorTransform = other.colorTransform; geo = other.geo; geo = other.geo; - bdpcmMode = other.bdpcmMode; - bdpcmModeChroma = other.bdpcmModeChroma; + bdpcmM[CH_L] = other.bdpcmM[CH_L]; + bdpcmM[CH_C] = other.bdpcmM[CH_C]; qp = other.qp; chromaQpAdj = other.chromaQpAdj; rootCbf = other.rootCbf; @@ -279,8 +283,6 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) imv = other.imv; imvNumCand = other.imvNumCand; BcwIdx = other.BcwIdx; - refIdxBi[0] = other.refIdxBi[0]; - refIdxBi[1] = other.refIdxBi[1]; smvdMode = other.smvdMode; ispMode = other.ispMode; @@ -289,6 +291,12 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) treeType = other.treeType; modeType = other.modeType; modeTypeSeries = other.modeTypeSeries; + + const IntraPredictionData& ipd = other; + *this = ipd; + + const InterPredictionData& tpd = other; + *this = tpd; return *this; } @@ -306,8 +314,8 @@ void CodingUnit::initData() affineType = 0; colorTransform = false; geo = false; - bdpcmMode = 0; - bdpcmModeChroma = 0; + bdpcmM[CH_L] = 0; + bdpcmM[CH_C] = 0; qp = 0; chromaQpAdj = 0; rootCbf = true; @@ -318,8 +326,6 @@ void CodingUnit::initData() imv = 0; imvNumCand = 0; BcwIdx = BCW_DEFAULT; - refIdxBi[0] = -1; - refIdxBi[1] = -1; smvdMode = 0; ispMode = 0; mipFlag = false; @@ -330,151 +336,44 @@ void CodingUnit::initData() } -bool CodingUnit::isSepTree() const -{ - return treeType != TREE_D || CS::isDualITree( *cs ); -} - -bool CodingUnit::isLocalSepTree() const -{ - return treeType != TREE_D && !CS::isDualITree(*cs); -} - -bool CodingUnit::checkCCLMAllowed() const -{ - bool allowCCLM = false; - - if( !CS::isDualITree( *cs ) ) //single tree I slice or non-I slice (Note: judging chType is no longer equivalent to checking dual-tree I slice since the local dual-tree is introduced) - { - allowCCLM = true; - } - else if( slice->sps->CTUSize <= 32 ) //dual tree, CTUsize < 64 - { - allowCCLM = true; - } - else //dual tree, CTU size 64 or 128 - { - int depthFor64x64Node = slice->sps->CTUSize == 128 ? 1 : 0; - const PartSplit cuSplitTypeDepth1 = CU::getSplitAtDepth( *this, depthFor64x64Node ); - const PartSplit cuSplitTypeDepth2 = CU::getSplitAtDepth( *this, depthFor64x64Node + 1 ); - - //allow CCLM if 64x64 chroma tree node uses QT split or HBT+VBT split combination - if( cuSplitTypeDepth1 == CU_QUAD_SPLIT || (cuSplitTypeDepth1 == CU_HORZ_SPLIT && cuSplitTypeDepth2 == CU_VERT_SPLIT) ) - { - if( chromaFormat == CHROMA_420 ) - { - CHECK( !(blocks[COMP_Cb].width <= 16 && blocks[COMP_Cb].height <= 16), "chroma cu size shall be <= 16x16 for YUV420 format" ); - } - allowCCLM = true; - } - //allow CCLM if 64x64 chroma tree node uses NS (No Split) and becomes a chroma CU containing 32x32 chroma blocks - else if( cuSplitTypeDepth1 == CU_DONT_SPLIT ) - { - if( chromaFormat == CHROMA_420 ) - { - CHECK( !(blocks[COMP_Cb].width == 32 && blocks[COMP_Cb].height == 32), "chroma cu size shall be 32x32 for YUV420 format" ); - } - allowCCLM = true; - } - //allow CCLM if 64x32 chroma tree node uses NS and becomes a chroma CU containing 32x16 chroma blocks - else if( cuSplitTypeDepth1 == CU_HORZ_SPLIT && cuSplitTypeDepth2 == CU_DONT_SPLIT ) - { - if( chromaFormat == CHROMA_420 ) - { - CHECK( !(blocks[COMP_Cb].width == 32 && blocks[COMP_Cb].height == 16), "chroma cu size shall be 32x16 for YUV420 format" ); - } - allowCCLM = true; - } - - //further check luma conditions - if( allowCCLM ) - { - //disallow CCLM if luma 64x64 block uses BT or TT or NS with ISP - const Position lumaRefPos( chromaPos().x << getComponentScaleX( COMP_Cb, chromaFormat ), chromaPos().y << getComponentScaleY( COMP_Cb, chromaFormat ) ); - const CodingUnit* colLumaCu = cs->refCS->getCU( lumaRefPos, CH_L, TREE_D ); - - if( colLumaCu->lwidth() < 64 || colLumaCu->lheight() < 64 ) //further split at 64x64 luma node - { - const PartSplit cuSplitTypeDepth1Luma = CU::getSplitAtDepth( *colLumaCu, depthFor64x64Node ); - CHECK( !(cuSplitTypeDepth1Luma >= CU_QUAD_SPLIT && cuSplitTypeDepth1Luma <= CU_TRIV_SPLIT), "split mode shall be BT, TT or QT" ); - if( cuSplitTypeDepth1Luma != CU_QUAD_SPLIT ) - { - allowCCLM = false; - } - } - else if( colLumaCu->lwidth() == 64 && colLumaCu->lheight() == 64 && colLumaCu->ispMode ) //not split at 64x64 luma node and use ISP mode - { - allowCCLM = false; - } - } - } - - return allowCCLM; -} - -uint8_t CodingUnit::checkAllowedSbt() const -{ - if( !slice->sps->SBT || predMode != MODE_INTER || pu->ciip) - { - return 0; - } - - const int cuWidth = lwidth(); - const int cuHeight = lheight(); - - //parameter - const int maxSbtCUSize = cs->sps->getMaxTbSize(); - - //check on size - if( cuWidth > maxSbtCUSize || cuHeight > maxSbtCUSize ) - { - return 0; - } - - const int minSbtCUSize = 1 << ( MIN_CU_LOG2 + 1 ); - const int minQuadCUSize = 1 << ( MIN_CU_LOG2 + 2 ); - - uint8_t sbtAllowed = 0; - if( cuWidth >= minSbtCUSize ) sbtAllowed += 1 << SBT_VER_HALF; - if( cuHeight >= minSbtCUSize ) sbtAllowed += 1 << SBT_HOR_HALF; - if( cuWidth >= minQuadCUSize ) sbtAllowed += 1 << SBT_VER_QUAD; - if( cuHeight >= minQuadCUSize ) sbtAllowed += 1 << SBT_HOR_QUAD; - - return sbtAllowed; -} // --------------------------------------------------------------------------- // prediction unit method definitions // --------------------------------------------------------------------------- -PredictionUnit::PredictionUnit(const UnitArea& unit) : UnitArea(unit) , cu(nullptr), cs(nullptr), chType( CH_L ) { initData(); } -PredictionUnit::PredictionUnit(const ChromaFormat _chromaFormat, const Area& _area) : UnitArea(_chromaFormat, _area), cu(nullptr), cs(nullptr), chType( CH_L ) { initData(); } - -void PredictionUnit::initData() +void CodingUnit::initPuData() { // intra data - need this default initialization for PCM intraDir[0] = DC_IDX; intraDir[1] = PLANAR_IDX; - mipTransposedFlag = false; multiRefIdx = 0; + mipTransposedFlag = false; // inter data mergeFlag = false; regularMergeFlag = false; + ciip = false; + mvRefine = false; + mmvdMergeFlag = false; mergeIdx = MAX_UCHAR; geoSplitDir = MAX_UCHAR; geoMergeIdx0 = MAX_UCHAR; geoMergeIdx1 = MAX_UCHAR; - mmvdMergeFlag = false; - mmvdMergeIdx = MAX_UINT; + + mcControl = 0; + interDir = MAX_UCHAR; + mmvdMergeIdx = MAX_UINT; mergeType = MRG_TYPE_DEFAULT_N; - mvRefine = false; - for (uint32_t i = 0; i < MAX_NUM_SUBCU_DMVR; i++) + if( mvdL0SubPu ) { - mvdL0SubPu[i].setZero(); + int maxDmvrMvds = std::max( 1, lwidth() >> DMVR_SUBCU_SIZE_LOG2 ) * std::max( 1, lheight() >> DMVR_SUBCU_SIZE_LOG2 ); + for (uint32_t i = 0; i < maxDmvrMvds; i++) + { + mvdL0SubPu[i].setZero(); + } } for (uint32_t i = 0; i < NUM_REF_PIC_LIST_01; i++) @@ -482,8 +381,8 @@ void PredictionUnit::initData() mvpIdx[i] = MAX_UCHAR; mvpNum[i] = MAX_UCHAR; refIdx[i] = -1; - mv[i] .setZero(); mvd[i] .setZero(); + mv[i] .setZero(); for( uint32_t j = 0; j < 3; j++ ) { mvdAffi[i][j].setZero(); @@ -493,12 +392,9 @@ void PredictionUnit::initData() mvAffi[i][j].setZero(); } } - - mcControl = 0; - ciip = false; } -PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) +CodingUnit& CodingUnit::operator=( const IntraPredictionData& other ) { for( uint32_t i = 0; i < MAX_NUM_CH; i++ ) { @@ -506,6 +402,11 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) } mipTransposedFlag = other.mipTransposedFlag; multiRefIdx = other.multiRefIdx; + return *this; +} + +CodingUnit& CodingUnit::operator=( const InterPredictionData& other ) +{ mergeFlag = other.mergeFlag; regularMergeFlag = other.regularMergeFlag; mergeIdx = other.mergeIdx; @@ -518,12 +419,11 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) mergeType = other.mergeType; mvRefine = other.mvRefine; - if( other.mergeFlag ) + if( other.mergeFlag && mvdL0SubPu ) { - for (uint32_t i = 0; i < MAX_NUM_SUBCU_DMVR; i++) - { - mvdL0SubPu[i] = other.mvdL0SubPu[i]; - } + const int maxDmvrMvds = std::max( 1, lwidth() >> DMVR_SUBCU_SIZE_LOG2 ) * std::max( 1, lheight() >> DMVR_SUBCU_SIZE_LOG2 ); + + memcpy( mvdL0SubPu, other.mvdL0SubPu, sizeof( Mv ) * maxDmvrMvds ); } for (uint32_t i = 0; i < NUM_REF_PIC_LIST_01; i++) @@ -546,7 +446,7 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) return *this; } -PredictionUnit& PredictionUnit::operator=( const MotionInfo& mi ) +CodingUnit& CodingUnit::operator=( const MotionInfo& mi ) { interDir = mi.interDir; @@ -559,23 +459,23 @@ PredictionUnit& PredictionUnit::operator=( const MotionInfo& mi ) return *this; } -const MotionInfo& PredictionUnit::getMotionInfo() const +const MotionInfo& CodingUnit::getMotionInfo() const { return cs->getMotionInfo( lumaPos() ); } -const MotionInfo& PredictionUnit::getMotionInfo( const Position& pos ) const +const MotionInfo& CodingUnit::getMotionInfo( const Position& pos ) const { CHECKD( !Y().contains( pos ), "Trying to access motion info outsied of PU" ); return cs->getMotionInfo( pos ); } -MotionBuf PredictionUnit::getMotionBuf() +MotionBuf CodingUnit::getMotionBuf() { return cs->getMotionBuf( *this ); } -CMotionBuf PredictionUnit::getMotionBuf() const +CMotionBuf CodingUnit::getMotionBuf() const { return cs->getMotionBuf( *this ); } @@ -619,7 +519,7 @@ void TransformUnit::initData() chromaAdj = 0; } -void TransformUnit::init(TCoeff** coeffs, Pel** pcmbuf, bool** runType) +void TransformUnit::init(TCoeff** coeffs) { uint32_t numBlocks = getNumberValidTBlocks(*cs->pcv); diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index 533d076f2..fbe303c28 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Unit.h * \brief defines unit as a set of blocks and basic unit types (coding, prediction, transform) */ @@ -284,74 +288,8 @@ struct UnitAreaRelative : public UnitArea namespace vvenc { struct TransformUnit; -struct PredictionUnit; class CodingStructure; -struct CodingUnit : public UnitArea -{ - CodingStructure* cs; - Slice* slice; - ChannelType chType; - - PredMode predMode; - - uint8_t depth; // number of all splits, applied with generalized splits - uint8_t qtDepth; // number of applied quad-splits, before switching to the multi-type-tree (mtt) - // a triple split would increase the mtDepth by 1, but the qtDepth by 2 in the first and last part and by 1 in the middle part (because of the 1-2-1 split proportions) - uint8_t btDepth; // number of applied binary splits, after switching to the mtt (or it's equivalent) - uint8_t mtDepth; // the actual number of splits after switching to mtt (equals btDepth if only binary splits are allowed) - int8_t chromaQpAdj; - int8_t qp; - SplitSeries splitSeries; - TreeType treeType; - ModeType modeType; - ModeTypeSeries modeTypeSeries; - bool skip; - bool mmvdSkip; - bool affine; - int affineType; - bool colorTransform; - bool geo; - int bdpcmMode; - int bdpcmModeChroma; - uint8_t imv; - bool rootCbf; - uint8_t sbtInfo; - uint32_t tileIdx; - uint8_t mtsFlag; - uint32_t lfnstIdx; - uint8_t BcwIdx; - int refIdxBi[2]; - bool mipFlag; - - // needed for fast imv mode decisions - int8_t imvNumCand; - uint8_t smvdMode; - uint8_t ispMode; - - CodingUnit() : chType( CH_L ) { } - CodingUnit(const UnitArea& unit); - CodingUnit(const ChromaFormat _chromaFormat, const Area& area); - - CodingUnit& operator=( const CodingUnit& other ); - - void initData(); - - unsigned idx; - CodingUnit *next; - - PredictionUnit *pu; - - TransformUnit *firstTU; - TransformUnit *lastTU; - - uint8_t checkAllowedSbt() const; - bool checkCCLMAllowed() const; - bool isSepTree() const; - bool isLocalSepTree() const; - bool isConsInter() const { return modeType == MODE_TYPE_INTER; } - bool isConsIntra() const { return modeType == MODE_TYPE_INTRA; } -}; // --------------------------------------------------------------------------- // prediction unit @@ -359,57 +297,92 @@ struct CodingUnit : public UnitArea struct IntraPredictionData { - uint32_t intraDir[MAX_NUM_CH]; - int multiRefIdx; - bool mipTransposedFlag; + uint8_t intraDir[MAX_NUM_CH]; + uint8_t multiRefIdx; + bool mipTransposedFlag; }; struct InterPredictionData { - InterPredictionData() : mvdL0SubPu(mvdL0SubPuBuffer) {} + InterPredictionData() : mvdL0SubPu(nullptr) {} + bool mergeFlag; bool regularMergeFlag; bool ciip; bool mvRefine; + bool mmvdMergeFlag; uint8_t mergeIdx; uint8_t geoSplitDir; uint8_t geoMergeIdx0; uint8_t geoMergeIdx1; - uint32_t mmvdMergeIdx; - bool mmvdMergeFlag; uint8_t interDir; uint8_t mcControl; // mmvd(bio), luma/chroma + uint32_t mmvdMergeIdx; + MergeType mergeType; + Mv* mvdL0SubPu; uint8_t mvpIdx [NUM_REF_PIC_LIST_01]; uint8_t mvpNum [NUM_REF_PIC_LIST_01]; Mv mvd [NUM_REF_PIC_LIST_01]; Mv mv [NUM_REF_PIC_LIST_01]; int16_t refIdx [NUM_REF_PIC_LIST_01]; - MergeType mergeType; - Mv* mvdL0SubPu; Mv mvdAffi [NUM_REF_PIC_LIST_01][3]; Mv mvAffi [NUM_REF_PIC_LIST_01][3]; - Mv mvdL0SubPuBuffer[MAX_NUM_SUBCU_DMVR]; }; -struct PredictionUnit : public UnitArea, public IntraPredictionData, public InterPredictionData + + +struct CodingUnit : public UnitArea, public IntraPredictionData, public InterPredictionData { - CodingUnit* cu; - CodingStructure* cs; - ChannelType chType; + CodingStructure* cs; + Slice* slice; + ChannelType chType; + + PredMode predMode; - unsigned idx; + uint8_t depth; // number of all splits, applied with generalized splits + uint8_t qtDepth; // number of applied quad-splits, before switching to the multi-type-tree (mtt) + // a triple split would increase the mtDepth by 1, but the qtDepth by 2 in the first and last part and by 1 in the middle part (because of the 1-2-1 split proportions) + uint8_t btDepth; // number of applied binary splits, after switching to the mtt (or it's equivalent) + uint8_t mtDepth; // the actual number of splits after switching to mtt (equals btDepth if only binary splits are allowed) + int8_t chromaQpAdj; + int8_t qp; + SplitSeries splitSeries; + TreeType treeType; + ModeType modeType; + ModeTypeSeries modeTypeSeries; + bool skip; + bool mmvdSkip; + bool colorTransform; + bool geo; + bool rootCbf; + bool mipFlag; + bool affine; + uint8_t affineType; + uint8_t imv; + uint8_t sbtInfo; + uint8_t mtsFlag; + uint8_t lfnstIdx; + uint8_t BcwIdx; + int8_t imvNumCand; + uint8_t smvdMode; + uint8_t ispMode; + uint8_t bdpcmM[MAX_NUM_CH]; + uint32_t tileIdx; - // constructors - PredictionUnit (): chType( CH_L ) { } - PredictionUnit ( const UnitArea& unit); - PredictionUnit ( const ChromaFormat _chromaFormat, const Area& area); + // needed for fast imv mode decisions - void initData (); + CodingUnit() : chType( CH_L ) {} + CodingUnit(const UnitArea& unit); + CodingUnit(const ChromaFormat _chromaFormat, const Area& area); - PredictionUnit& operator= ( const PredictionUnit& other); - PredictionUnit& operator= ( const MotionInfo& mi); + void initData(); + void initPuData(); + CodingUnit& operator= ( const CodingUnit& other ); + CodingUnit& operator= ( const InterPredictionData& other); + CodingUnit& operator= ( const IntraPredictionData& other); + CodingUnit& operator= ( const MotionInfo& mi); // for accessing motion information, which can have higher resolution than PUs (should always be used, when accessing neighboring motion information) const MotionInfo& getMotionInfo () const; @@ -417,6 +390,12 @@ struct PredictionUnit : public UnitArea, public IntraPredictionData, public Inte MotionBuf getMotionBuf (); CMotionBuf getMotionBuf () const; + + unsigned idx; + CodingUnit* next; + + TransformUnit* firstTU; + TransformUnit* lastTU; }; // --------------------------------------------------------------------------- @@ -445,7 +424,7 @@ struct TransformUnit : public UnitArea TransformUnit ( const UnitArea& unit); TransformUnit ( const ChromaFormat _chromaFormat, const Area& area); void initData (); - void init ( TCoeff **coeffs, Pel** pcmbuf, bool** runType); + void init ( TCoeff **coeffs); TransformUnit& operator= ( const TransformUnit& other); void copyComponentFrom ( const TransformUnit& other, const ComponentID compID); @@ -456,7 +435,7 @@ struct TransformUnit : public UnitArea const CCoeffBuf getCoeffs ( ComponentID id) const { return CCoeffBuf(m_coeffs[id], blocks[id]); } private: - TCoeff *m_coeffs[ MAX_NUM_TBLOCKS ]; + TCoeff* m_coeffs[ MAX_NUM_TBLOCKS ]; }; // --------------------------------------------------------------------------- diff --git a/source/Lib/CommonLib/UnitPartitioner.cpp b/source/Lib/CommonLib/UnitPartitioner.cpp index d025caaa7..b143e3b1e 100644 --- a/source/Lib/CommonLib/UnitPartitioner.cpp +++ b/source/Lib/CommonLib/UnitPartitioner.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file UnitPartitioner.h @@ -292,7 +296,10 @@ void Partitioner::initCtu( const UnitArea& ctuArea, const ChannelType _chType, c void Partitioner::splitCurrArea( const PartSplit split, const CodingStructure& cs ) { - CHECKD( !canSplit( split, cs ), "Trying to apply a prohibited split!" ); + if ((split != TU_1D_HORZ_SPLIT) && (split != TU_1D_VERT_SPLIT)) + { + CHECKD(!canSplit(split, cs), "Trying to apply a prohibited split!"); + } bool isImplicit = isSplitImplicit( split, cs ); bool canQtSplit = canSplit( CU_QUAD_SPLIT, cs ); @@ -334,6 +341,12 @@ void Partitioner::splitCurrArea( const PartSplit split, const CodingStructure& c case SBT_HOR_QUAD_POS1_SPLIT: PartitionerImpl::getSbtTuTiling( back.parts, area, cs, split ); break; + case TU_1D_HORZ_SPLIT: + case TU_1D_VERT_SPLIT: + { + PartitionerImpl::getTUIntraSubPartitions(back.parts, area, cs, split, TREE_D); + break; + } default: THROW( "Unknown split mode" ); break; @@ -345,7 +358,7 @@ void Partitioner::splitCurrArea( const PartSplit split, const CodingStructure& c m_currArea = m_partStack.back().parts.front(); #endif - if( split == TU_MAX_TR_SPLIT ) + if ((split == TU_MAX_TR_SPLIT) || (split == TU_1D_HORZ_SPLIT) || (split == TU_1D_VERT_SPLIT)) { currTrDepth++; } @@ -529,6 +542,30 @@ bool Partitioner::canSplit( const PartSplit split, const CodingStructure &cs ) return true; } +bool Partitioner::canSplitISP(const PartSplit split, const CodingStructure& cs, CodingUnit& cu) +{ + // const PartSplit implicitSplit = getImplicitSplit(cs); + const UnitArea& area = currArea(); + + switch (split) + { + case TU_1D_HORZ_SPLIT: + { + return area.lheight() == cu.lheight(); + } + case TU_1D_VERT_SPLIT: + { + return area.lwidth() == cu.lwidth(); + } + case TU_MAX_TR_SPLIT: + { + // this split is performed implicitly with the other splits + return false; + } + default: THROW("Unknown 1-D split mode"); break; + } +} + bool Partitioner::isSplitImplicit( const PartSplit split, const CodingStructure &cs ) { return split == getImplicitSplit( cs ); @@ -630,6 +667,11 @@ void Partitioner::exitCurrSplit() CHECK( currTrDepth == 0, "TR depth is '0', although a TU split was performed" ); currTrDepth--; } + else if ((currSplit == TU_1D_HORZ_SPLIT) || (currSplit == TU_1D_VERT_SPLIT)) + { + CHECK(currTrDepth == 0, "TR depth is '0', although a TU split was performed"); + currTrDepth--; + } else { CHECK( currTrDepth > 0, "RQT found with QTBT partitioner" ); diff --git a/source/Lib/CommonLib/UnitPartitioner.h b/source/Lib/CommonLib/UnitPartitioner.h index 4548af7bf..cca19d6a6 100644 --- a/source/Lib/CommonLib/UnitPartitioner.h +++ b/source/Lib/CommonLib/UnitPartitioner.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file UnitPartitioner.h * \brief Provides a class for partitioning management */ @@ -168,6 +172,7 @@ class Partitioner public: void canSplit ( const CodingStructure &cs, bool& canNo, bool& canQt, bool& canBh, bool& canBv, bool& canTh, bool& canTv ); bool canSplit ( const PartSplit split, const CodingStructure &cs ); + bool canSplitISP ( const PartSplit split, const CodingStructure& cs, CodingUnit& cu ); bool isSplitImplicit ( const PartSplit split, const CodingStructure &cs ); PartSplit getImplicitSplit ( const CodingStructure &cs ); bool isSepTree ( const CodingStructure &cs ); diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index f029c9e22..435d05069 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file UnitTool.cpp @@ -61,7 +65,7 @@ namespace vvenc { // CS tools -void clipColPos(int& posX, int& posY, const PredictionUnit& pu); +void clipColPos(int& posX, int& posY, const CodingUnit& cu); bool CS::isDualITree( const CodingStructure &cs ) @@ -79,28 +83,28 @@ void CS::setRefinedMotionField(CodingStructure &cs) MotionBuf mb = cs.getMotionBuf(); MotionInfo* orgPtr = mb.buf; - for( CodingUnit *cu : cs.cus ) + for( CodingUnit *ptrCU : cs.cus ) { - PredictionUnit &pu = *cu->pu; + CodingUnit& cu = *ptrCU; - if( isLuma( pu.chType ) && PU::checkDMVRCondition( pu ) ) + if( isLuma( cu.chType ) && CU::checkDMVRCondition( cu ) ) { - const int dy = std::min( pu.lumaSize().height, DMVR_SUBCU_SIZE ); - const int dx = std::min( pu.lumaSize().width, DMVR_SUBCU_SIZE ); + const int dy = std::min( cu.lumaSize().height, DMVR_SUBCU_SIZE ); + const int dx = std::min( cu.lumaSize().width, DMVR_SUBCU_SIZE ); static const unsigned scale = 4 * std::max(1, 4 * AMVP_DECIMATION_FACTOR / 4); static const unsigned mask = scale - 1; - const Position puPos = pu.lumaPos(); - const Mv mv0 = pu.mv[0]; - const Mv mv1 = pu.mv[1]; + const Position puPos = cu.lumaPos(); + const Mv mv0 = cu.mv[0]; + const Mv mv1 = cu.mv[1]; - for( int y = puPos.y, num = 0; y < ( puPos.y + pu.lumaSize().height ); y = y + dy ) + for( int y = puPos.y, num = 0; y < ( puPos.y + cu.lumaSize().height ); y = y + dy ) { - for( int x = puPos.x; x < ( puPos.x + pu.lumaSize().width ); x = x + dx, num++ ) + for( int x = puPos.x; x < ( puPos.x + cu.lumaSize().width ); x = x + dx, num++ ) { - const Mv subPuMv0 = mv0 + pu.mvdL0SubPu[num]; - const Mv subPuMv1 = mv1 - pu.mvdL0SubPu[num]; + const Mv subPuMv0 = mv0 + cu.mvdL0SubPu[num]; + const Mv subPuMv1 = mv1 - cu.mvdL0SubPu[num]; int y2 = ( ( y - 1 ) & ~mask ) + scale; @@ -126,6 +130,110 @@ void CS::setRefinedMotionField(CodingStructure &cs) } // CU tools +bool CU::checkCCLMAllowed(const CodingUnit& cu) +{ + bool allowCCLM = false; + + if( !CS::isDualITree( *cu.cs ) ) //single tree I slice or non-I slice (Note: judging chType is no longer equivalent to checking dual-tree I slice since the local dual-tree is introduced) + { + allowCCLM = true; + } + else if( cu.slice->sps->CTUSize <= 32 ) //dual tree, CTUsize < 64 + { + allowCCLM = true; + } + else //dual tree, CTU size 64 or 128 + { + int depthFor64x64Node = cu.slice->sps->CTUSize == 128 ? 1 : 0; + const PartSplit cuSplitTypeDepth1 = CU::getSplitAtDepth( cu, depthFor64x64Node ); + const PartSplit cuSplitTypeDepth2 = CU::getSplitAtDepth( cu, depthFor64x64Node + 1 ); + + //allow CCLM if 64x64 chroma tree node uses QT split or HBT+VBT split combination + if( cuSplitTypeDepth1 == CU_QUAD_SPLIT || (cuSplitTypeDepth1 == CU_HORZ_SPLIT && cuSplitTypeDepth2 == CU_VERT_SPLIT) ) + { + if( cu.chromaFormat == CHROMA_420 ) + { + CHECK( !(cu.blocks[COMP_Cb].width <= 16 && cu.blocks[COMP_Cb].height <= 16), "chroma cu size shall be <= 16x16 for YUV420 format" ); + } + allowCCLM = true; + } + //allow CCLM if 64x64 chroma tree node uses NS (No Split) and becomes a chroma CU containing 32x32 chroma blocks + else if( cuSplitTypeDepth1 == CU_DONT_SPLIT ) + { + if( cu.chromaFormat == CHROMA_420 ) + { + CHECK( !(cu.blocks[COMP_Cb].width == 32 && cu.blocks[COMP_Cb].height == 32), "chroma cu size shall be 32x32 for YUV420 format" ); + } + allowCCLM = true; + } + //allow CCLM if 64x32 chroma tree node uses NS and becomes a chroma CU containing 32x16 chroma blocks + else if( cuSplitTypeDepth1 == CU_HORZ_SPLIT && cuSplitTypeDepth2 == CU_DONT_SPLIT ) + { + if( cu.chromaFormat == CHROMA_420 ) + { + CHECK( !(cu.blocks[COMP_Cb].width == 32 && cu.blocks[COMP_Cb].height == 16), "chroma cu size shall be 32x16 for YUV420 format" ); + } + allowCCLM = true; + } + + //further check luma conditions + if( allowCCLM ) + { + //disallow CCLM if luma 64x64 block uses BT or TT or NS with ISP + const Position lumaRefPos( cu.chromaPos().x << getComponentScaleX( COMP_Cb, cu.chromaFormat ), cu.chromaPos().y << getComponentScaleY( COMP_Cb, cu.chromaFormat ) ); + const CodingUnit* colLumaCu = cu.cs->refCS->getCU( lumaRefPos, CH_L, TREE_D ); + + if( colLumaCu->lwidth() < 64 || colLumaCu->lheight() < 64 ) //further split at 64x64 luma node + { + const PartSplit cuSplitTypeDepth1Luma = CU::getSplitAtDepth( *colLumaCu, depthFor64x64Node ); + CHECK( !(cuSplitTypeDepth1Luma >= CU_QUAD_SPLIT && cuSplitTypeDepth1Luma <= CU_TRIV_SPLIT), "split mode shall be BT, TT or QT" ); + if( cuSplitTypeDepth1Luma != CU_QUAD_SPLIT ) + { + allowCCLM = false; + } + } + else if( colLumaCu->lwidth() == 64 && colLumaCu->lheight() == 64 && colLumaCu->ispMode ) //not split at 64x64 luma node and use ISP mode + { + allowCCLM = false; + } + } + } + + return allowCCLM; +} + +uint8_t CU::checkAllowedSbt(const CodingUnit& cu) +{ + if( !cu.slice->sps->SBT || cu.predMode != MODE_INTER || cu.ciip) + { + return 0; + } + + const int cuWidth = cu.lwidth(); + const int cuHeight = cu.lheight(); + + //parameter + const int maxSbtCUSize = cu.cs->sps->getMaxTbSize(); + + //check on size + if( cuWidth > maxSbtCUSize || cuHeight > maxSbtCUSize ) + { + return 0; + } + + const int minSbtCUSize = 1 << ( MIN_CU_LOG2 + 1 ); + const int minQuadCUSize = 1 << ( MIN_CU_LOG2 + 2 ); + + uint8_t sbtAllowed = 0; + if( cuWidth >= minSbtCUSize ) sbtAllowed += 1 << SBT_VER_HALF; + if( cuHeight >= minSbtCUSize ) sbtAllowed += 1 << SBT_HOR_HALF; + if( cuWidth >= minQuadCUSize ) sbtAllowed += 1 << SBT_VER_QUAD; + if( cuHeight >= minQuadCUSize ) sbtAllowed += 1 << SBT_HOR_QUAD; + + return sbtAllowed; +} + + bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, Picture* refPic, int& xScale, int& yScale ) { const Window& curScalingWindow = curPPS->scalingWindow; @@ -168,7 +276,7 @@ bool CU::isSameCtu(const CodingUnit& cu, const CodingUnit& cu2) bool CU::isLastSubCUOfCtu( const CodingUnit &cu ) { - const Area cuAreaY = cu.isSepTree() ? Area( recalcPosition( cu.chromaFormat, cu.chType, CH_L, cu.blocks[cu.chType].pos() ), recalcSize( cu.chromaFormat, cu.chType, CH_L, cu.blocks[cu.chType].size() ) ) : (const Area&)cu.Y(); + const Area cuAreaY = CU::isSepTree(cu) ? Area( recalcPosition( cu.chromaFormat, cu.chType, CH_L, cu.blocks[cu.chType].pos() ), recalcSize( cu.chromaFormat, cu.chType, CH_L, cu.blocks[cu.chType].size() ) ) : (const Area&)cu.Y(); return ( ( ( ( cuAreaY.x + cuAreaY.width ) & cu.cs->pcv->maxCUSizeMask ) == 0 || cuAreaY.x + cuAreaY.width == cu.cs->pcv->lumaWidth ) && ( ( ( cuAreaY.y + cuAreaY.height ) & cu.cs->pcv->maxCUSizeMask ) == 0 || cuAreaY.y + cuAreaY.height == cu.cs->pcv->lumaHeight ) ); @@ -203,24 +311,17 @@ int CU::predictQP( const CodingUnit& cu, const int prevQP ) } -void CU::addPUs( CodingUnit& cu ) -{ - cu.cs->addPU( CS::getArea( *cu.cs, cu, cu.chType, cu.treeType ), cu.chType, &cu ); -} - void CU::saveMotionInHMVP( const CodingUnit& cu, const bool isToBeDone ) { - const PredictionUnit& pu = *cu.pu; - if (!cu.geo && !cu.affine && !isToBeDone) { - MotionInfo puMi = pu.getMotionInfo(); + MotionInfo puMi = cu.getMotionInfo(); HPMVInfo mi ( puMi, ( puMi.interDir == 3 ) ? cu.BcwIdx : BCW_DEFAULT, cu.imv == IMV_HPEL ); - const unsigned log2ParallelMergeLevel = (pu.cs->sps->log2ParallelMergeLevelMinus2 + 2); - const unsigned xBr = pu.cu->Y().width + pu.cu->Y().x; - const unsigned yBr = pu.cu->Y().height + pu.cu->Y().y; - bool enableHmvp = ((xBr >> log2ParallelMergeLevel) > (pu.cu->Y().x >> log2ParallelMergeLevel)) && ((yBr >> log2ParallelMergeLevel) > (pu.cu->Y().y >> log2ParallelMergeLevel)); + const unsigned log2ParallelMergeLevel = (cu.cs->sps->log2ParallelMergeLevelMinus2 + 2); + const unsigned xBr = cu.Y().width + cu.Y().x; + const unsigned yBr = cu.Y().height + cu.Y().y; + bool enableHmvp = ((xBr >> log2ParallelMergeLevel) > (cu.Y().x >> log2ParallelMergeLevel)) && ((yBr >> log2ParallelMergeLevel) > (cu.Y().y >> log2ParallelMergeLevel)); bool enableInsertion = CU::isIBC(cu) || enableHmvp; if (enableInsertion) cu.cs->addMiToLut( /*CU::isIBC(cu) ? cu.cs->motionLut.lutIbc :*/ cu.cs->motionLut.lut, mi); @@ -402,29 +503,29 @@ const CodingUnit* CU::getAbove(const CodingUnit& curr) // PU tools -int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm ) +int CU::getIntraMPMs( const CodingUnit& cu, unsigned* mpm ) { const int numMPMs = NUM_MOST_PROBABLE_MODES; { int numCand = -1; int leftIntraDir = PLANAR_IDX, aboveIntraDir = PLANAR_IDX; - const CompArea& area = pu.Y(); + const CompArea& area = cu.Y(); const Position posRT = area.topRight(); const Position posLB = area.bottomLeft(); // Get intra direction of left PU - const PredictionUnit *puLeft = pu.cs->getPURestricted(posLB.offset(-1, 0), pu, CH_L); - if (puLeft && CU::isIntra(*puLeft->cu)) + const CodingUnit* puLeft = (posLB.x & cu.cs->pcv->maxCUSizeMask) ? cu.cs->getCU(posLB.offset(-1, 0), CH_L, cu.treeType) : cu.cs->picture->cs->getCURestricted(posLB.offset(-1, 0), cu, CH_L); + if (puLeft && CU::isIntra(*puLeft) && !CU::isMIP(*puLeft)) { - leftIntraDir = PU::getIntraDirLuma( *puLeft ); + leftIntraDir = puLeft->intraDir[CH_L]; } - // Get intra direction of above PU - const PredictionUnit *puAbove = pu.cs->getPURestricted(posRT.offset(0, -1), pu, CH_L); - if (puAbove && CU::isIntra(*puAbove->cu) && CU::isSameCtu(*pu.cu, *puAbove->cu)) + // Get intra direction of above PU, but only from the same CU + const CodingUnit* puAbove = (posRT.y & cu.cs->pcv->maxCUSizeMask) ? cu.cs->getCU(posRT.offset(0, -1), CH_L, cu.treeType) : nullptr; + if (puAbove && CU::isIntra(*puAbove) && !CU::isMIP(*puAbove)) { - aboveIntraDir = PU::getIntraDirLuma( *puAbove ); + aboveIntraDir = puAbove->intraDir[CH_L]; } CHECK(2 >= numMPMs, "Invalid number of most probable modes"); @@ -511,31 +612,31 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm ) } } -bool PU::isMIP(const PredictionUnit &pu, const ChannelType chType) +bool CU::isMIP(const CodingUnit& cu, const ChannelType chType) { - return chType == CH_L ? pu.cu->mipFlag : ((pu.intraDir[CH_C] == DM_CHROMA_IDX) && isDMChromaMIP(pu)); + return chType == CH_L ? cu.mipFlag : ((cu.intraDir[CH_C] == DM_CHROMA_IDX) && isDMChromaMIP(cu)); } -bool PU::isDMChromaMIP(const PredictionUnit &pu) +bool CU::isDMChromaMIP(const CodingUnit& cu) { - return !pu.cu->isSepTree() && (pu.chromaFormat == CHROMA_444) && getCoLocatedLumaPU(pu).cu->mipFlag; + return !CU::isSepTree(cu) && (cu.chromaFormat == CHROMA_444) && getCoLocatedLumaPU(cu).mipFlag; } -uint32_t PU::getIntraDirLuma( const PredictionUnit &pu ) +uint32_t CU::getIntraDirLuma(const CodingUnit& cu) { - if (isMIP(pu)) + if (isMIP(cu)) { return PLANAR_IDX; } else { - return pu.intraDir[CH_L]; + return cu.intraDir[CH_L]; } } -void PU::getIntraChromaCandModes( const PredictionUnit &pu, unsigned modeList[NUM_CHROMA_MODE] ) +void CU::getIntraChromaCandModes( const CodingUnit& cu, unsigned modeList[NUM_CHROMA_MODE] ) { { modeList[0] = PLANAR_IDX; @@ -548,12 +649,12 @@ void PU::getIntraChromaCandModes( const PredictionUnit &pu, unsigned modeList[NU modeList[7] = DM_CHROMA_IDX; // If Direct Mode is MIP, mode cannot be already in the list. - if (isDMChromaMIP(pu)) + if (isDMChromaMIP(cu)) { return; } - const uint32_t lumaMode = getCoLocatedIntraLumaMode(pu); + const uint32_t lumaMode = getCoLocatedIntraLumaMode(cu); for( int i = 0; i < 4; i++ ) { if( lumaMode == modeList[i] ) @@ -565,17 +666,17 @@ void PU::getIntraChromaCandModes( const PredictionUnit &pu, unsigned modeList[NU } } -bool PU::isLMCMode(unsigned mode) +bool CU::isLMCMode(unsigned mode) { return (mode >= LM_CHROMA_IDX && mode <= MDLM_T_IDX); } -bool PU::isLMCModeEnabled(const PredictionUnit &pu, unsigned mode) +bool CU::isLMCModeEnabled(const CodingUnit& cu, unsigned mode) { - return ( pu.cs->sps->LMChroma && pu.cu->checkCCLMAllowed() ); + return ( cu.cs->sps->LMChroma && CU::checkCCLMAllowed(cu) ); } -int PU::getLMSymbolList(const PredictionUnit &pu, int *modeList) +int CU::getLMSymbolList(const CodingUnit& cu, int *modeList) { int idx = 0; @@ -585,43 +686,38 @@ int PU::getLMSymbolList(const PredictionUnit &pu, int *modeList) return idx; } -bool PU::isChromaIntraModeCrossCheckMode( const PredictionUnit &pu ) -{ - return !pu.cu->bdpcmModeChroma && pu.intraDir[CH_C] == DM_CHROMA_IDX; -} - -uint32_t PU::getFinalIntraMode( const PredictionUnit &pu, const ChannelType chType ) +uint32_t CU::getFinalIntraMode( const CodingUnit& cu, const ChannelType chType ) { - uint32_t uiIntraMode = pu.intraDir[chType]; + uint32_t uiIntraMode = cu.intraDir[chType]; if( uiIntraMode == DM_CHROMA_IDX && !isLuma( chType ) ) { - uiIntraMode = getCoLocatedIntraLumaMode(pu); + uiIntraMode = getCoLocatedIntraLumaMode(cu); } - if( pu.chromaFormat == CHROMA_422 && !isLuma( chType ) && uiIntraMode < NUM_LUMA_MODE ) // map directional, planar and dc + if( cu.chromaFormat == CHROMA_422 && !isLuma( chType ) && uiIntraMode < NUM_LUMA_MODE ) // map directional, planar and dc { uiIntraMode = g_chroma422IntraAngleMappingTable[uiIntraMode]; } return uiIntraMode; } -const PredictionUnit &PU::getCoLocatedLumaPU(const PredictionUnit &pu) +const CodingUnit& CU::getCoLocatedLumaPU(const CodingUnit& cu) { - Position topLeftPos = pu.blocks[pu.chType].lumaPos(); - Position refPos = topLeftPos.offset(pu.blocks[pu.chType].lumaSize().width >> 1, - pu.blocks[pu.chType].lumaSize().height >> 1); - const PredictionUnit &lumaPU = pu.cu->isSepTree() ? *pu.cs->refCS->getPU(refPos, CH_L) - : *pu.cs->getPU(topLeftPos, CH_L); + Position topLeftPos = cu.blocks[cu.chType].lumaPos(); + Position refPos = topLeftPos.offset(cu.blocks[cu.chType].lumaSize().width >> 1, + cu.blocks[cu.chType].lumaSize().height >> 1); + const CodingUnit& lumaCU = CU::isSepTree(cu) ? *cu.cs->refCS->getCU(refPos, CH_L, TREE_D) + : *cu.cs->getCU(topLeftPos, CH_L, TREE_D); - return lumaPU; + return lumaCU; } -uint32_t PU::getCoLocatedIntraLumaMode(const PredictionUnit &pu) +uint32_t CU::getCoLocatedIntraLumaMode(const CodingUnit& cu) { - return PU::getIntraDirLuma(PU::getCoLocatedLumaPU(pu)); + return CU::getIntraDirLuma(CU::getCoLocatedLumaPU(cu)); } -bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const bool isAvailableA1, const MotionInfo& miLeft, const bool isAvailableB1, const MotionInfo& miAbove, const bool ibcFlag, const bool isGt4x4) +bool CU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const bool isAvailableA1, const MotionInfo& miLeft, const bool isAvailableB1, const MotionInfo& miAbove, const bool ibcFlag, const bool isGt4x4) { const Slice& slice = *cs.slice; HPMVInfo miNeighbor; @@ -668,11 +764,11 @@ bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, const int } -void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, int mmvdList, const int mrgCandIdx ) +void CU::getInterMergeCandidates( const CodingUnit& cu, MergeCtx& mrgCtx, int mmvdList, const int mrgCandIdx ) { - const unsigned plevel = pu.cs->sps->log2ParallelMergeLevelMinus2 + 2; - const CodingStructure &cs = *pu.cs; - const Slice &slice = *pu.cs->slice; + const unsigned plevel = cu.cs->sps->log2ParallelMergeLevelMinus2 + 2; + const CodingStructure &cs = *cu.cs; + const Slice &slice = *cu.cs->slice; const uint32_t maxNumMergeCand = slice.sps->maxNumMergeCand; for (uint32_t ui = 0; ui < maxNumMergeCand; ++ui) @@ -690,15 +786,15 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in int cnt = 0; - const Position posLT = pu.Y().topLeft(); - const Position posRT = pu.Y().topRight(); - const Position posLB = pu.Y().bottomLeft(); + const Position posLT = cu.Y().topLeft(); + const Position posRT = cu.Y().topRight(); + const Position posLB = cu.Y().bottomLeft(); MotionInfo miAbove, miLeft, miAboveLeft, miAboveRight, miBelowLeft; // above - const PredictionUnit *puAbove = cs.getPURestricted(posRT.offset(0, -1), pu, pu.chType); + const CodingUnit* puAbove = cs.getCURestricted(posRT.offset(0, -1), cu, cu.chType); - bool isAvailableB1 = puAbove && isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) && pu.cu != puAbove->cu && CU::isInter(*puAbove->cu); + bool isAvailableB1 = puAbove && isDiffMER(cu.lumaPos(), posRT.offset(0, -1), plevel) && &cu != puAbove && CU::isInter(*puAbove); if (isAvailableB1) { @@ -706,9 +802,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in // get Inter Dir mrgCtx.interDirNeighbours[cnt] = miAbove.interDir; - mrgCtx.useAltHpelIf[cnt] = puAbove->cu->imv == IMV_HPEL; + mrgCtx.useAltHpelIf[cnt] = puAbove->imv == IMV_HPEL; // get Mv from Above - mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puAbove->cu->BcwIdx : BCW_DEFAULT; + mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puAbove->BcwIdx : BCW_DEFAULT; mrgCtx.mvFieldNeighbours[cnt << 1].setMvField(miAbove.mv[0], miAbove.refIdx[0]); if (slice.isInterB()) @@ -730,9 +826,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in } //left - const PredictionUnit* puLeft = cs.getPURestricted(posLB.offset(-1, 0), pu, pu.chType); + const CodingUnit* puLeft = cs.getCURestricted(posLB.offset(-1, 0), cu, cu.chType); - const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) && pu.cu != puLeft->cu && CU::isInter(*puLeft->cu); + const bool isAvailableA1 = puLeft && isDiffMER(cu.lumaPos(), posLB.offset(-1, 0), plevel) && &cu != puLeft && CU::isInter(*puLeft); if (isAvailableA1) { @@ -742,8 +838,8 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in { // get Inter Dir mrgCtx.interDirNeighbours[cnt] = miLeft.interDir; - mrgCtx.useAltHpelIf[cnt] = puLeft->cu->imv == IMV_HPEL; - mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puLeft->cu->BcwIdx : BCW_DEFAULT; + mrgCtx.useAltHpelIf[cnt] = puLeft->imv == IMV_HPEL; + mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puLeft->BcwIdx : BCW_DEFAULT; // get Mv from Left mrgCtx.mvFieldNeighbours[cnt << 1].setMvField(miLeft.mv[0], miLeft.refIdx[0]); @@ -767,9 +863,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in } // above right - const PredictionUnit *puAboveRight = cs.getPURestricted( posRT.offset( 1, -1 ), pu, pu.chType ); + const CodingUnit* puAboveRight = cs.getCURestricted( posRT.offset( 1, -1 ), cu, cu.chType ); - bool isAvailableB0 = puAboveRight && isDiffMER( pu.lumaPos(), posRT.offset(1, -1), plevel) && CU::isInter( *puAboveRight->cu ); + bool isAvailableB0 = puAboveRight && isDiffMER( cu.lumaPos(), posRT.offset(1, -1), plevel) && CU::isInter( *puAboveRight ); if( isAvailableB0 ) { @@ -779,9 +875,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in { // get Inter Dir mrgCtx.interDirNeighbours[cnt] = miAboveRight.interDir; - mrgCtx.useAltHpelIf[cnt] = puAboveRight->cu->imv == IMV_HPEL; + mrgCtx.useAltHpelIf[cnt] = puAboveRight->imv == IMV_HPEL; // get Mv from Above-right - mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puAboveRight->cu->BcwIdx : BCW_DEFAULT; + mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puAboveRight->BcwIdx : BCW_DEFAULT; mrgCtx.mvFieldNeighbours[cnt << 1].setMvField( miAboveRight.mv[0], miAboveRight.refIdx[0] ); if( slice.isInterB() ) @@ -804,9 +900,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in } //left bottom - const PredictionUnit *puLeftBottom = cs.getPURestricted( posLB.offset( -1, 1 ), pu, pu.chType ); + const CodingUnit* puLeftBottom = cs.getCURestricted( posLB.offset( -1, 1 ), cu, cu.chType ); - bool isAvailableA0 = puLeftBottom && isDiffMER( pu.lumaPos(), posLB.offset(-1, 1), plevel) && CU::isInter( *puLeftBottom->cu ); + bool isAvailableA0 = puLeftBottom && isDiffMER( cu.lumaPos(), posLB.offset(-1, 1), plevel) && CU::isInter( *puLeftBottom ); if( isAvailableA0 ) { @@ -816,8 +912,8 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in { // get Inter Dir mrgCtx.interDirNeighbours[cnt] = miBelowLeft.interDir; - mrgCtx.useAltHpelIf[cnt] = puLeftBottom->cu->imv == IMV_HPEL; - mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puLeftBottom->cu->BcwIdx : BCW_DEFAULT; + mrgCtx.useAltHpelIf[cnt] = puLeftBottom->imv == IMV_HPEL; + mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puLeftBottom->BcwIdx : BCW_DEFAULT; // get Mv from Bottom-Left mrgCtx.mvFieldNeighbours[cnt << 1].setMvField( miBelowLeft.mv[0], miBelowLeft.refIdx[0] ); @@ -844,9 +940,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in // above left if ( cnt < 4 ) { - const PredictionUnit *puAboveLeft = cs.getPURestricted( posLT.offset( -1, -1 ), pu, pu.chType ); + const CodingUnit* puAboveLeft = cs.getCURestricted( posLT.offset( -1, -1 ), cu, cu.chType ); - bool isAvailableB2 = puAboveLeft && isDiffMER( pu.lumaPos(), posLT.offset(-1, -1), plevel ) && CU::isInter( *puAboveLeft->cu ); + bool isAvailableB2 = puAboveLeft && isDiffMER( cu.lumaPos(), posLT.offset(-1, -1), plevel ) && CU::isInter( *puAboveLeft ); if( isAvailableB2 ) { @@ -856,8 +952,8 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in { // get Inter Dir mrgCtx.interDirNeighbours[cnt] = miAboveLeft.interDir; - mrgCtx.useAltHpelIf[cnt] = puAboveLeft->cu->imv == IMV_HPEL; - mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puAboveLeft->cu->BcwIdx : BCW_DEFAULT; + mrgCtx.useAltHpelIf[cnt] = puAboveLeft->imv == IMV_HPEL; + mrgCtx.BcwIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? puAboveLeft->BcwIdx : BCW_DEFAULT; // get Mv from Above-Left mrgCtx.mvFieldNeighbours[cnt << 1].setMvField( miAboveLeft.mv[0], miAboveLeft.refIdx[0] ); @@ -881,18 +977,18 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in return; } - if (slice.picHeader->enableTMVP && (pu.lumaSize().width + pu.lumaSize().height > 12)) + if (slice.picHeader->enableTMVP && (cu.lumaSize().width + cu.lumaSize().height > 12)) { //>> MTK colocated-RightBottom // offset the pos to be sure to "point" to the same position the uiAbsPartIdx would've pointed to - Position posRB = pu.Y().bottomRight().offset( -3, -3 ); + Position posRB = cu.Y().bottomRight().offset( -3, -3 ); const PreCalcValues& pcv = *cs.pcv; Position posC0; - Position posC1 = pu.Y().center(); + Position posC1 = cu.Y().center(); bool C0Avail = false; bool boundaryCond = ((posRB.x + pcv.minCUSize) < pcv.lumaWidth) && ((posRB.y + pcv.minCUSize) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->pps->getSubPicFromPos(pu.lumaPos()); + const SubPic& curSubPic = cu.cs->slice->pps->getSubPicFromPos(cu.lumaPos()); if (curSubPic.treatedAsPic ) { boundaryCond = ((posRB.x + pcv.minCUSize) <= curSubPic.subPicRight && @@ -912,8 +1008,8 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in int iRefIdx = 0; int dir = 0; unsigned uiArrayAddr = cnt; - bool bExistMV = ( C0Avail && getColocatedMVP(pu, REF_PIC_LIST_0, posC0, cColMv, iRefIdx ) ) - || getColocatedMVP( pu, REF_PIC_LIST_0, posC1, cColMv, iRefIdx ); + bool bExistMV = ( C0Avail && getColocatedMVP(cu, REF_PIC_LIST_0, posC0, cColMv, iRefIdx ) ) + || getColocatedMVP( cu, REF_PIC_LIST_0, posC1, cColMv, iRefIdx ); if (bExistMV) { dir |= 1; @@ -922,8 +1018,8 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in if (slice.isInterB()) { - bExistMV = ( C0Avail && getColocatedMVP(pu, REF_PIC_LIST_1, posC0, cColMv, iRefIdx ) ) - || getColocatedMVP( pu, REF_PIC_LIST_1, posC1, cColMv, iRefIdx ); + bExistMV = ( C0Avail && getColocatedMVP(cu, REF_PIC_LIST_1, posC0, cColMv, iRefIdx ) ) + || getColocatedMVP( cu, REF_PIC_LIST_1, posC1, cColMv, iRefIdx ); if (bExistMV) { dir |= 2; @@ -959,7 +1055,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in if (cnt != maxNumMergeCandMin1) { bool isGt4x4 = true; - bool bFound = addMergeHMVPCand(cs, mrgCtx, mrgCandIdx, maxNumMergeCandMin1, cnt, isAvailableA1, miLeft, isAvailableB1, miAbove, CU::isIBC(*pu.cu), isGt4x4); + bool bFound = addMergeHMVPCand(cs, mrgCtx, mrgCandIdx, maxNumMergeCandMin1, cnt, isAvailableA1, miLeft, isAvailableB1, miAbove, CU::isIBC(cu), isGt4x4); if (bFound) { return; @@ -1048,7 +1144,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in mrgCtx.mvFieldNeighbours [(uiArrayAddr << 1) + 1].setMvField(Mv(0, 0), r); } - if ( mrgCtx.interDirNeighbours[uiArrayAddr] == 1 && pu.cs->slice->getRefPic(REF_PIC_LIST_0, mrgCtx.mvFieldNeighbours[uiArrayAddr << 1].refIdx)->getPOC() == pu.cs->slice->poc) + if ( mrgCtx.interDirNeighbours[uiArrayAddr] == 1 && cu.cs->slice->getRefPic(REF_PIC_LIST_0, mrgCtx.mvFieldNeighbours[uiArrayAddr << 1].refIdx)->getPOC() == cu.cs->slice->poc) { THROW("no IBC support"); } @@ -1068,24 +1164,24 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, in mrgCtx.numValidMergeCand = uiArrayAddr; } -bool PU::checkDMVRCondition(const PredictionUnit& pu) +bool CU::checkDMVRCondition(const CodingUnit& cu) { - if (!pu.cs->sps->DMVR || pu.cs->slice->picHeader->disDmvrFlag) + if (!cu.cs->sps->DMVR || cu.cs->slice->picHeader->disDmvrFlag) { return false; } - return pu.mergeFlag - && pu.mergeType == MRG_TYPE_DEFAULT_N - && !pu.ciip - && !pu.cu->affine - && !pu.mmvdMergeFlag - && !pu.cu->mmvdSkip - && PU::isBiPredFromDifferentDirEqDistPoc(pu) - && (pu.lheight() >= 8) - && (pu.lwidth() >= 8) - && ((pu.lheight() * pu.lwidth()) >= 128) - && (pu.cu->BcwIdx == BCW_DEFAULT); + return cu.mergeFlag + && cu.mergeType == MRG_TYPE_DEFAULT_N + && !cu.ciip + && !cu.affine + && !cu.mmvdMergeFlag + && !cu.mmvdSkip + && CU::isBiPredFromDifferentDirEqDistPoc(cu) + && (cu.lheight() >= 8) + && (cu.lwidth() >= 8) + && ((cu.lheight() * cu.lwidth()) >= 128) + && (cu.BcwIdx == BCW_DEFAULT); } int convertMvFixedToFloat(int32_t val) @@ -1123,7 +1219,7 @@ int roundMvComp(int x) return convertMvFloatToFixed(convertMvFixedToFloat(x)); } -int PU::getDistScaleFactor(const int currPOC, const int currRefPOC, const int colPOC, const int colRefPOC) +int CU::getDistScaleFactor(const int currPOC, const int currRefPOC, const int colPOC, const int colRefPOC) { int iDiffPocD = colPOC - colRefPOC; int iDiffPocB = currPOC - currRefPOC; @@ -1142,7 +1238,7 @@ int PU::getDistScaleFactor(const int currPOC, const int currRefPOC, const int co } } -void PU::getInterMMVDMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx) +void CU::getInterMMVDMergeCandidates(const CodingUnit& cu, MergeCtx& mrgCtx, const int& mrgCandIdx) { int refIdxList0, refIdxList1; int k; @@ -1181,7 +1277,7 @@ void PU::getInterMMVDMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, } } -bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList refPicList, const Position& _pos, Mv& rcMv, const int refIdx, bool sbFlag ) +bool CU::getColocatedMVP(const CodingUnit& cu, const RefPicList refPicList, const Position& _pos, Mv& rcMv, const int refIdx, bool sbFlag ) { // don't perform MV compression when generally disabled or SbTMVP is used const unsigned scale = 4 * std::max(1, 4 * AMVP_DECIMATION_FACTOR / 4); @@ -1189,7 +1285,7 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList refPicList, const Position pos = Position{ PosType( _pos.x & mask ), PosType( _pos.y & mask ) }; - const Slice &slice = *pu.cs->slice; + const Slice &slice = *cu.cs->slice; // use coldir. const Picture* const pColPic = slice.getRefPic(RefPicList(slice.isInterB() ? 1 - slice.colFromL0Flag : 0), slice.colRefIdx); @@ -1200,7 +1296,7 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList refPicList, } // Check the position of colocated block is within a subpicture - SubPic curSubPic = pu.cs->slice->pps->getSubPicFromPos(pu.lumaPos()); + const SubPic& curSubPic = cu.cs->slice->pps->getSubPicFromPos(cu.lumaPos()); if (curSubPic.treatedAsPic) { if (!curSubPic.isContainingPos(pos)) @@ -1215,7 +1311,7 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList refPicList, { return false; } - if (CU::isIBC(*pu.cu)) + if (CU::isIBC(cu)) { return false; } @@ -1298,7 +1394,7 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList refPicList, return true; } -bool PU::isDiffMER(const Position &pos1, const Position &pos2, const unsigned plevel) +bool CU::isDiffMER(const Position &pos1, const Position &pos2, const unsigned plevel) { const unsigned xN = pos1.x; const unsigned yN = pos1.y; @@ -1326,9 +1422,9 @@ bool PU::isDiffMER(const Position &pos1, const Position &pos2, const unsigned pl * \param iRefIdx * \param pInfo */ -void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int refIdx, AMVPInfo &amvpInfo) +void CU::fillMvpCand(CodingUnit& cu, const RefPicList refPicList, const int refIdx, AMVPInfo &amvpInfo) { - CodingStructure &cs = *pu.cs; + CodingStructure &cs = *cu.cs; AMVPInfo *pInfo = &amvpInfo; @@ -1340,31 +1436,31 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int } //-- Get Spatial MV - Position posLT = pu.Y().topLeft(); - Position posRT = pu.Y().topRight(); - Position posLB = pu.Y().bottomLeft(); + Position posLT = cu.Y().topLeft(); + Position posRT = cu.Y().topRight(); + Position posLB = cu.Y().bottomLeft(); { - bool bAdded = addMVPCandUnscaled( pu, refPicList, refIdx, posLB, MD_BELOW_LEFT, *pInfo ); + bool bAdded = addMVPCandUnscaled( cu, refPicList, refIdx, posLB, MD_BELOW_LEFT, *pInfo ); if( !bAdded ) { - bAdded = addMVPCandUnscaled( pu, refPicList, refIdx, posLB, MD_LEFT, *pInfo ); + bAdded = addMVPCandUnscaled( cu, refPicList, refIdx, posLB, MD_LEFT, *pInfo ); } } // Above predictor search { - bool bAdded = addMVPCandUnscaled( pu, refPicList, refIdx, posRT, MD_ABOVE_RIGHT, *pInfo ); + bool bAdded = addMVPCandUnscaled( cu, refPicList, refIdx, posRT, MD_ABOVE_RIGHT, *pInfo ); if( !bAdded ) { - bAdded = addMVPCandUnscaled( pu, refPicList, refIdx, posRT, MD_ABOVE, *pInfo ); + bAdded = addMVPCandUnscaled( cu, refPicList, refIdx, posRT, MD_ABOVE, *pInfo ); if( !bAdded ) { - addMVPCandUnscaled( pu, refPicList, refIdx, posLT, MD_ABOVE_LEFT, *pInfo ); + addMVPCandUnscaled( cu, refPicList, refIdx, posLT, MD_ABOVE_LEFT, *pInfo ); } } } @@ -1372,7 +1468,7 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int for( int i = 0; i < pInfo->numCand; i++ ) { - pInfo->mvCand[i].roundTransPrecInternal2Amvr(pu.cu->imv); + pInfo->mvCand[i].roundTransPrecInternal2Amvr(cu.imv); } if( pInfo->numCand == 2 ) @@ -1383,22 +1479,22 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int } } - if (cs.picHeader->enableTMVP && pInfo->numCand < AMVP_MAX_NUM_CANDS && (pu.lumaSize().width + pu.lumaSize().height > 12)) + if (cs.picHeader->enableTMVP && pInfo->numCand < AMVP_MAX_NUM_CANDS && (cu.lumaSize().width + cu.lumaSize().height > 12)) { // Get Temporal Motion Predictor const int refIdx_Col = refIdx; - Position posRB = pu.Y().bottomRight().offset(-3, -3); + Position posRB = cu.Y().bottomRight().offset(-3, -3); const PreCalcValues& pcv = *cs.pcv; Position posC0; bool C0Avail = false; - Position posC1 = pu.Y().center(); + Position posC1 = cu.Y().center(); Mv cColMv; bool boundaryCond = ((posRB.x + pcv.minCUSize) < pcv.lumaWidth) && ((posRB.y + pcv.minCUSize) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->pps->getSubPicFromPos(pu.lumaPos()); + const SubPic& curSubPic = cu.cs->slice->pps->getSubPicFromPos(cu.lumaPos()); if (curSubPic.treatedAsPic) { boundaryCond = ((posRB.x + pcv.minCUSize) <= curSubPic.subPicRight && @@ -1413,9 +1509,9 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int C0Avail = true; } } - if ( ( C0Avail && getColocatedMVP( pu, refPicList, posC0, cColMv, refIdx_Col ) ) || getColocatedMVP( pu, refPicList, posC1, cColMv, refIdx_Col ) ) + if ( ( C0Avail && getColocatedMVP( cu, refPicList, posC0, cColMv, refIdx_Col ) ) || getColocatedMVP( cu, refPicList, posC1, cColMv, refIdx_Col ) ) { - cColMv.roundTransPrecInternal2Amvr(pu.cu->imv); + cColMv.roundTransPrecInternal2Amvr(cu.imv); pInfo->mvCand[pInfo->numCand++] = cColMv; } } @@ -1423,7 +1519,7 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int if (pInfo->numCand < AMVP_MAX_NUM_CANDS) { const int currRefPOC = cs.slice->getRefPic(refPicList, refIdx)->getPOC(); - addAMVPHMVPCand(pu, refPicList, currRefPOC, *pInfo); + addAMVPHMVPCand(cu, refPicList, currRefPOC, *pInfo); } if (pInfo->numCand > AMVP_MAX_NUM_CANDS) @@ -1439,14 +1535,14 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int for (Mv &mv : pInfo->mvCand) { - mv.roundTransPrecInternal2Amvr(pu.cu->imv); + mv.roundTransPrecInternal2Amvr(cu.imv); } } -bool PU::addAffineMVPCandUnscaled(const PredictionUnit &pu, const RefPicList refPicList, const int refIdx, const Position& pos, const MvpDir dir, AffineAMVPInfo &affiAMVPInfo) +bool CU::addAffineMVPCandUnscaled(const CodingUnit& cu, const RefPicList refPicList, const int refIdx, const Position& pos, const MvpDir dir, AffineAMVPInfo &affiAMVPInfo) { - CodingStructure &cs = *pu.cs; - const PredictionUnit *neibPU = NULL; + CodingStructure &cs = *cu.cs; + const CodingUnit* neibPU = NULL; Position neibPos; switch (dir) @@ -1470,9 +1566,9 @@ bool PU::addAffineMVPCandUnscaled(const PredictionUnit &pu, const RefPicList ref break; } - neibPU = cs.getPURestricted(neibPos, pu, pu.chType); + neibPU = cs.getCURestricted(neibPos, cu, cu.chType); - if (neibPU == NULL || !CU::isInter(*neibPU->cu) || !neibPU->cu->affine + if (neibPU == NULL || !CU::isInter(*neibPU) || !neibPU->affine || neibPU->mergeType != MRG_TYPE_DEFAULT_N ) { @@ -1490,19 +1586,19 @@ bool PU::addAffineMVPCandUnscaled(const PredictionUnit &pu, const RefPicList ref const RefPicList refPicListIndex = (predictorSource == 0) ? refPicList : refPicList2nd; const int neibRefIdx = neibMi.refIdx[refPicListIndex]; - if (((neibPU->interDir & (refPicListIndex + 1)) == 0) || pu.cu->slice->getRefPOC(refPicListIndex, neibRefIdx) != currRefPOC) + if (((neibPU->interDir & (refPicListIndex + 1)) == 0) || cu.slice->getRefPOC(refPicListIndex, neibRefIdx) != currRefPOC) { continue; } - xInheritedAffineMv(pu, neibPU, refPicListIndex, outputAffineMv); - outputAffineMv[0].roundAffinePrecInternal2Amvr(pu.cu->imv); - outputAffineMv[1].roundAffinePrecInternal2Amvr(pu.cu->imv); + xInheritedAffineMv(cu, neibPU, refPicListIndex, outputAffineMv); + outputAffineMv[0].roundAffinePrecInternal2Amvr(cu.imv); + outputAffineMv[1].roundAffinePrecInternal2Amvr(cu.imv); affiAMVPInfo.mvCandLT[affiAMVPInfo.numCand] = outputAffineMv[0]; affiAMVPInfo.mvCandRT[affiAMVPInfo.numCand] = outputAffineMv[1]; - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { - outputAffineMv[2].roundAffinePrecInternal2Amvr(pu.cu->imv); + outputAffineMv[2].roundAffinePrecInternal2Amvr(cu.imv); affiAMVPInfo.mvCandLB[affiAMVPInfo.numCand] = outputAffineMv[2]; } affiAMVPInfo.numCand++; @@ -1512,31 +1608,31 @@ bool PU::addAffineMVPCandUnscaled(const PredictionUnit &pu, const RefPicList ref return false; } -void PU::xInheritedAffineMv(const PredictionUnit &pu, const PredictionUnit* puNeighbour, RefPicList refPicList, Mv rcMv[3]) +void CU::xInheritedAffineMv(const CodingUnit& cu, const CodingUnit* cuNeighbour, RefPicList refPicList, Mv rcMv[3]) { - int posNeiX = puNeighbour->Y().pos().x; - int posNeiY = puNeighbour->Y().pos().y; - int posCurX = pu.Y().pos().x; - int posCurY = pu.Y().pos().y; + int posNeiX = cuNeighbour->Y().pos().x; + int posNeiY = cuNeighbour->Y().pos().y; + int posCurX = cu.Y().pos().x; + int posCurY = cu.Y().pos().y; - int neiW = puNeighbour->Y().width; - int curW = pu.Y().width; - int neiH = puNeighbour->Y().height; - int curH = pu.Y().height; + int neiW = cuNeighbour->Y().width; + int curW = cu.Y().width; + int neiH = cuNeighbour->Y().height; + int curH = cu.Y().height; Mv mvLT, mvRT, mvLB; - mvLT = puNeighbour->mvAffi[refPicList][0]; - mvRT = puNeighbour->mvAffi[refPicList][1]; - mvLB = puNeighbour->mvAffi[refPicList][2]; + mvLT = cuNeighbour->mvAffi[refPicList][0]; + mvRT = cuNeighbour->mvAffi[refPicList][1]; + mvLB = cuNeighbour->mvAffi[refPicList][2]; bool isTopCtuBoundary = false; - if ((posNeiY + neiH) % pu.cs->sps->CTUSize == 0 && (posNeiY + neiH) == posCurY) + if ((posNeiY + neiH) % cu.cs->sps->CTUSize == 0 && (posNeiY + neiH) == posCurY) { // use bottom-left and bottom-right sub-block MVs for inheritance - const Position posRB = puNeighbour->Y().bottomRight(); - const Position posLB = puNeighbour->Y().bottomLeft(); - mvLT = puNeighbour->getMotionInfo(posLB).mv[refPicList]; - mvRT = puNeighbour->getMotionInfo(posRB).mv[refPicList]; + const Position posRB = cuNeighbour->Y().bottomRight(); + const Position posLB = cuNeighbour->Y().bottomLeft(); + mvLT = cuNeighbour->getMotionInfo(posLB).mv[refPicList]; + mvRT = cuNeighbour->getMotionInfo(posRB).mv[refPicList]; posNeiY += neiH; isTopCtuBoundary = true; } @@ -1546,7 +1642,7 @@ void PU::xInheritedAffineMv(const PredictionUnit &pu, const PredictionUnit* puNe iDMvHorX = (mvRT - mvLT).hor << (shift - Log2(neiW)); iDMvHorY = (mvRT - mvLT).ver << (shift - Log2(neiW)); - if (puNeighbour->cu->affineType == AFFINEMODEL_6PARAM && !isTopCtuBoundary) + if (cuNeighbour->affineType == AFFINEMODEL_6PARAM && !isTopCtuBoundary) { iDMvVerX = (mvLB - mvLT).hor << (shift - Log2(neiH)); iDMvVerY = (mvLB - mvLT).ver << (shift - Log2(neiH)); @@ -1578,7 +1674,7 @@ void PU::xInheritedAffineMv(const PredictionUnit &pu, const PredictionUnit* puNe rcMv[1].clipToStorageBitDepth(); // v2 - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { horTmp = iMvScaleHor + iDMvHorX * (posCurX - posNeiX) + iDMvVerX * (posCurY + curH - posNeiY); verTmp = iMvScaleVer + iDMvHorY * (posCurX - posNeiX) + iDMvVerY * (posCurY + curH - posNeiY); @@ -1589,7 +1685,7 @@ void PU::xInheritedAffineMv(const PredictionUnit &pu, const PredictionUnit* puNe } } -void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, const int refIdx, AffineAMVPInfo &affiAMVPInfo) +void CU::fillAffineMvpCand(CodingUnit& cu, const RefPicList refPicList, const int refIdx, AffineAMVPInfo &affiAMVPInfo) { affiAMVPInfo.numCand = 0; @@ -1600,22 +1696,22 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons // insert inherited affine candidates Mv outputAffineMv[3]; - Position posLT = pu.Y().topLeft(); - Position posRT = pu.Y().topRight(); - Position posLB = pu.Y().bottomLeft(); + Position posLT = cu.Y().topLeft(); + Position posRT = cu.Y().topRight(); + Position posLB = cu.Y().bottomLeft(); // check left neighbor - if (!addAffineMVPCandUnscaled(pu, refPicList, refIdx, posLB, MD_BELOW_LEFT, affiAMVPInfo)) + if (!addAffineMVPCandUnscaled(cu, refPicList, refIdx, posLB, MD_BELOW_LEFT, affiAMVPInfo)) { - addAffineMVPCandUnscaled(pu, refPicList, refIdx, posLB, MD_LEFT, affiAMVPInfo); + addAffineMVPCandUnscaled(cu, refPicList, refIdx, posLB, MD_LEFT, affiAMVPInfo); } // check above neighbor - if (!addAffineMVPCandUnscaled(pu, refPicList, refIdx, posRT, MD_ABOVE_RIGHT, affiAMVPInfo)) + if (!addAffineMVPCandUnscaled(cu, refPicList, refIdx, posRT, MD_ABOVE_RIGHT, affiAMVPInfo)) { - if (!addAffineMVPCandUnscaled(pu, refPicList, refIdx, posRT, MD_ABOVE, affiAMVPInfo)) + if (!addAffineMVPCandUnscaled(cu, refPicList, refIdx, posRT, MD_ABOVE, affiAMVPInfo)) { - addAffineMVPCandUnscaled(pu, refPicList, refIdx, posLT, MD_ABOVE_LEFT, affiAMVPInfo); + addAffineMVPCandUnscaled(cu, refPicList, refIdx, posLT, MD_ABOVE_LEFT, affiAMVPInfo); } } @@ -1623,9 +1719,9 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons { for (int i = 0; i < affiAMVPInfo.numCand; i++) { - affiAMVPInfo.mvCandLT[i].roundAffinePrecInternal2Amvr(pu.cu->imv); - affiAMVPInfo.mvCandRT[i].roundAffinePrecInternal2Amvr(pu.cu->imv); - affiAMVPInfo.mvCandLB[i].roundAffinePrecInternal2Amvr(pu.cu->imv); + affiAMVPInfo.mvCandLT[i].roundAffinePrecInternal2Amvr(cu.imv); + affiAMVPInfo.mvCandRT[i].roundAffinePrecInternal2Amvr(cu.imv); + affiAMVPInfo.mvCandLB[i].roundAffinePrecInternal2Amvr(cu.imv); } return; } @@ -1638,14 +1734,14 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons amvpInfo0.numCand = 0; // A->C: Above Left, Above, Left - addMVPCandUnscaled(pu, refPicList, refIdx, posLT, MD_ABOVE_LEFT, amvpInfo0); + addMVPCandUnscaled(cu, refPicList, refIdx, posLT, MD_ABOVE_LEFT, amvpInfo0); if (amvpInfo0.numCand < 1) { - addMVPCandUnscaled(pu, refPicList, refIdx, posLT, MD_ABOVE, amvpInfo0); + addMVPCandUnscaled(cu, refPicList, refIdx, posLT, MD_ABOVE, amvpInfo0); } if (amvpInfo0.numCand < 1) { - addMVPCandUnscaled(pu, refPicList, refIdx, posLT, MD_LEFT, amvpInfo0); + addMVPCandUnscaled(cu, refPicList, refIdx, posLT, MD_LEFT, amvpInfo0); } cornerMVPattern = cornerMVPattern | amvpInfo0.numCand; @@ -1654,10 +1750,10 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons amvpInfo1.numCand = 0; // D->E: Above, Above Right - addMVPCandUnscaled(pu, refPicList, refIdx, posRT, MD_ABOVE, amvpInfo1); + addMVPCandUnscaled(cu, refPicList, refIdx, posRT, MD_ABOVE, amvpInfo1); if (amvpInfo1.numCand < 1) { - addMVPCandUnscaled(pu, refPicList, refIdx, posRT, MD_ABOVE_RIGHT, amvpInfo1); + addMVPCandUnscaled(cu, refPicList, refIdx, posRT, MD_ABOVE_RIGHT, amvpInfo1); } cornerMVPattern = cornerMVPattern | (amvpInfo1.numCand << 1); @@ -1666,10 +1762,10 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons amvpInfo2.numCand = 0; // F->G: Left, Below Left - addMVPCandUnscaled(pu, refPicList, refIdx, posLB, MD_LEFT, amvpInfo2); + addMVPCandUnscaled(cu, refPicList, refIdx, posLB, MD_LEFT, amvpInfo2); if (amvpInfo2.numCand < 1) { - addMVPCandUnscaled(pu, refPicList, refIdx, posLB, MD_BELOW_LEFT, amvpInfo2); + addMVPCandUnscaled(cu, refPicList, refIdx, posLB, MD_BELOW_LEFT, amvpInfo2); } cornerMVPattern = cornerMVPattern | (amvpInfo2.numCand << 2); @@ -1677,11 +1773,11 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons outputAffineMv[1] = amvpInfo1.mvCand[0]; outputAffineMv[2] = amvpInfo2.mvCand[0]; - outputAffineMv[0].roundAffinePrecInternal2Amvr(pu.cu->imv); - outputAffineMv[1].roundAffinePrecInternal2Amvr(pu.cu->imv); - outputAffineMv[2].roundAffinePrecInternal2Amvr(pu.cu->imv); + outputAffineMv[0].roundAffinePrecInternal2Amvr(cu.imv); + outputAffineMv[1].roundAffinePrecInternal2Amvr(cu.imv); + outputAffineMv[2].roundAffinePrecInternal2Amvr(cu.imv); - if (cornerMVPattern == 7 || (cornerMVPattern == 3 && pu.cu->affineType == AFFINEMODEL_4PARAM)) + if (cornerMVPattern == 7 || (cornerMVPattern == 3 && cu.affineType == AFFINEMODEL_4PARAM)) { affiAMVPInfo.mvCandLT[affiAMVPInfo.numCand] = outputAffineMv[0]; affiAMVPInfo.mvCandRT[affiAMVPInfo.numCand] = outputAffineMv[1]; @@ -1704,20 +1800,20 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons } // Get Temporal Motion Predictor - if (affiAMVPInfo.numCand < 2 && pu.cs->picHeader->enableTMVP) + if (affiAMVPInfo.numCand < 2 && cu.cs->picHeader->enableTMVP) { const int refIdxCol = refIdx; - Position posRB = pu.Y().bottomRight().offset(-3, -3); + Position posRB = cu.Y().bottomRight().offset(-3, -3); - const PreCalcValues& pcv = *pu.cs->pcv; + const PreCalcValues& pcv = *cu.cs->pcv; Position posC0; bool C0Avail = false; - Position posC1 = pu.Y().center(); + Position posC1 = cu.Y().center(); Mv cColMv; bool boundaryCond = ((posRB.x + pcv.minCUSize) < pcv.lumaWidth) && ((posRB.y + pcv.minCUSize) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->pps->getSubPicFromPos(pu.lumaPos()); + const SubPic& curSubPic = cu.cs->slice->pps->getSubPicFromPos(cu.lumaPos()); if (curSubPic.treatedAsPic) { boundaryCond = ((posRB.x + pcv.minCUSize) <= curSubPic.subPicRight && @@ -1732,9 +1828,9 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons C0Avail = true; } } - if ((C0Avail && getColocatedMVP(pu, refPicList, posC0, cColMv, refIdxCol)) || getColocatedMVP(pu, refPicList, posC1, cColMv, refIdxCol)) + if ((C0Avail && getColocatedMVP(cu, refPicList, posC0, cColMv, refIdxCol)) || getColocatedMVP(cu, refPicList, posC1, cColMv, refIdxCol)) { - cColMv.roundAffinePrecInternal2Amvr(pu.cu->imv); + cColMv.roundAffinePrecInternal2Amvr(cu.imv); affiAMVPInfo.mvCandLT[affiAMVPInfo.numCand] = cColMv; affiAMVPInfo.mvCandRT[affiAMVPInfo.numCand] = cColMv; affiAMVPInfo.mvCandLB[affiAMVPInfo.numCand] = cColMv; @@ -1757,16 +1853,16 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList refPicList, cons for (int i = 0; i < affiAMVPInfo.numCand; i++) { - affiAMVPInfo.mvCandLT[i].roundAffinePrecInternal2Amvr(pu.cu->imv); - affiAMVPInfo.mvCandRT[i].roundAffinePrecInternal2Amvr(pu.cu->imv); - affiAMVPInfo.mvCandLB[i].roundAffinePrecInternal2Amvr(pu.cu->imv); + affiAMVPInfo.mvCandLT[i].roundAffinePrecInternal2Amvr(cu.imv); + affiAMVPInfo.mvCandRT[i].roundAffinePrecInternal2Amvr(cu.imv); + affiAMVPInfo.mvCandLB[i].roundAffinePrecInternal2Amvr(cu.imv); } } -bool PU::addMVPCandUnscaled( const PredictionUnit &pu, const RefPicList refPicList, const int iRefIdx, const Position& pos, const MvpDir dir, AMVPInfo &info ) +bool CU::addMVPCandUnscaled( const CodingUnit& cu, const RefPicList refPicList, const int iRefIdx, const Position& pos, const MvpDir dir, AMVPInfo &info ) { - CodingStructure &cs = *pu.cs; - const PredictionUnit *neibPU = NULL; + CodingStructure &cs = *cu.cs; + const CodingUnit* neibPU = NULL; Position neibPos; switch (dir) @@ -1790,9 +1886,9 @@ bool PU::addMVPCandUnscaled( const PredictionUnit &pu, const RefPicList refPicLi break; } - neibPU = cs.getPURestricted( neibPos, pu, pu.chType ); + neibPU = cs.getCURestricted( neibPos, cu, cu.chType ); - if( neibPU == NULL || !CU::isInter( *neibPU->cu ) ) + if( neibPU == NULL || !CU::isInter( *neibPU ) ) { return false; } @@ -1818,11 +1914,11 @@ bool PU::addMVPCandUnscaled( const PredictionUnit &pu, const RefPicList refPicLi } -void PU::addAMVPHMVPCand(const PredictionUnit &pu, const RefPicList refPicList, const int currRefPOC, AMVPInfo &info) +void CU::addAMVPHMVPCand(const CodingUnit& cu, const RefPicList refPicList, const int currRefPOC, AMVPInfo &info) { - const Slice &slice = *(*pu.cs).slice; + const Slice &slice = *(*cu.cs).slice; - auto &lut = /*CU::isIBC(*pu.cu) ? pu.cs->motionLut.lutIbc :*/ pu.cs->motionLut.lut; + auto &lut = /*CU::isIBC(cu) ? cu.cs->motionLut.lutIbc :*/ cu.cs->motionLut.lut; int num_avai_candInLUT = (int) lut.size(); int num_allowedCand = std::min(MAX_NUM_HMVP_AVMPCANDS, num_avai_candInLUT); const RefPicList refPicList2nd = (refPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; @@ -1840,10 +1936,10 @@ void PU::addAMVPHMVPCand(const PredictionUnit &pu, const RefPicList refPicList, const RefPicList refPicListIndex = (predictorSource == 0) ? refPicList : refPicList2nd; const int neibRefIdx = neibMi.refIdx[refPicListIndex]; - if (neibRefIdx >= 0 && (CU::isIBC(*pu.cu) || (currRefPOC == slice.getRefPOC(refPicListIndex, neibRefIdx)))) + if (neibRefIdx >= 0 && (CU::isIBC(cu) || (currRefPOC == slice.getRefPOC(refPicListIndex, neibRefIdx)))) { Mv pmv = neibMi.mv[refPicListIndex]; - pmv.roundTransPrecInternal2Amvr(pu.cu->imv); + pmv.roundTransPrecInternal2Amvr(cu.imv); info.mvCand[info.numCand++] = pmv; if (info.numCand >= AMVP_MAX_NUM_CANDS) @@ -1855,24 +1951,24 @@ void PU::addAMVPHMVPCand(const PredictionUnit &pu, const RefPicList refPicList, } } -bool PU::isBipredRestriction(const PredictionUnit &pu) +bool CU::isBipredRestriction(const CodingUnit& cu) { - if(pu.cu->lumaSize().width == 4 && pu.cu->lumaSize().height ==4 ) + if(cu.lumaSize().width == 4 && cu.lumaSize().height ==4 ) { return true; } /* disable bi-prediction for 4x8/8x4 */ - if ( pu.cu->lumaSize().width + pu.cu->lumaSize().height == 12 ) + if ( cu.lumaSize().width + cu.lumaSize().height == 12 ) { return true; } return false; } -void PU::getAffineControlPointCand(const PredictionUnit &pu, MotionInfo mi[4], bool isAvailable[4], int verIdx[4], int8_t BcwIdx, int modelIdx, int verNum, AffineMergeCtx& affMrgType) +void CU::getAffineControlPointCand(const CodingUnit& cu, MotionInfo mi[4], bool isAvailable[4], int verIdx[4], int8_t BcwIdx, int modelIdx, int verNum, AffineMergeCtx& affMrgType) { - int cuW = pu.Y().width; - int cuH = pu.Y().height; + int cuW = cu.Y().width; + int cuH = cu.Y().height; int vx, vy; int shift = MAX_CU_DEPTH; int shiftHtoW = shift + Log2(cuW) - Log2(cuH); @@ -2009,9 +2105,9 @@ void PU::getAffineControlPointCand(const PredictionUnit &pu, MotionInfo mi[4], b } -bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, bool& LICFlag, const int count, int mmvdList) +bool CU::getInterMergeSbTMVPCand(const CodingUnit& cu, MergeCtx& mrgCtx, bool& LICFlag, const int count, int mmvdList) { - const Slice &slice = *pu.cs->slice; + const Slice &slice = *cu.cs->slice; const unsigned scale = 4 * std::max(1, 4 * AMVP_DECIMATION_FACTOR / 4); const unsigned mask = ~(scale - 1); @@ -2037,8 +2133,8 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo bool tempLICFlag = false; // compute the location of the current PU - Position puPos = pu.lumaPos(); - Size puSize = pu.lumaSize(); + Position puPos = cu.lumaPos(); + Size puSize = cu.lumaSize(); int numPartLine = std::max(puSize.width >> ATMVP_SUB_BLOCK_SIZE, 1u); int numPartCol = std::max(puSize.height >> ATMVP_SUB_BLOCK_SIZE, 1u); int puHeight = numPartCol == 1 ? puSize.height : 1 << ATMVP_SUB_BLOCK_SIZE; @@ -2061,7 +2157,7 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo centerPos.x = puPos.x + (puSize.width >> 1) + tempX; centerPos.y = puPos.y + (puSize.height >> 1) + tempY; - clipColPos(centerPos.x, centerPos.y, pu); + clipColPos(centerPos.x, centerPos.y, cu); centerPos = Position{ PosType(centerPos.x & mask), PosType(centerPos.y & mask) }; @@ -2076,7 +2172,7 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo { RefPicList currRefPicList = RefPicList(currRefListId); - if (getColocatedMVP(pu, currRefPicList, centerPos, cColMv, refIdx, true)) + if (getColocatedMVP(cu, currRefPicList, centerPos, cColMv, refIdx, true)) { // set as default, for further motion vector field spanning mrgCtx.mvFieldNeighbours[(count << 1) + currRefListId].setMvField(cColMv, 0); @@ -2104,7 +2200,7 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo MotionBuf& mb = mrgCtx.subPuMvpMiBuf; - const bool isBiPred = isBipredRestriction(pu); + const bool isBiPred = isBipredRestriction(cu); for (int y = puPos.y; y < puPos.y + puSize.height; y += puHeight) { @@ -2112,7 +2208,7 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo { Position colPos{ x + xOff, y + yOff }; - clipColPos(colPos.x, colPos.y, pu); + clipColPos(colPos.x, colPos.y, cu); colPos = Position{ PosType(colPos.x & mask), PosType(colPos.y & mask) }; @@ -2128,7 +2224,7 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo for (unsigned currRefListId = 0; currRefListId < (bBSlice ? 2 : 1); currRefListId++) { RefPicList currRefPicList = RefPicList(currRefListId); - if (getColocatedMVP(pu, currRefPicList, colPos, cColMv, refIdx, true)) + if (getColocatedMVP(cu, currRefPicList, colPos, cColMv, refIdx, true)) { mi.refIdx[currRefListId] = 0; mi.mv[currRefListId] = cColMv; @@ -2153,7 +2249,7 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo mi.refIdx[1] = NOT_VALID; } - mb.subBuf(g_miScaling.scale(Position{ x, y } -pu.lumaPos()), g_miScaling.scale(Size(puWidth, puHeight))).fill(mi); + mb.subBuf(g_miScaling.scale(Position{ x, y } -cu.lumaPos()), g_miScaling.scale(Size(puWidth, puHeight))).fill(mi); } } } @@ -2161,26 +2257,26 @@ bool PU::getInterMergeSbTMVPCand(const PredictionUnit &pu, MergeCtx& mrgCtx, boo } -const int getAvailableAffineNeighboursForLeftPredictor(const PredictionUnit &pu, const PredictionUnit* npu[]) +const int getAvailableAffineNeighboursForLeftPredictor(const CodingUnit& cu, const CodingUnit* npu[]) { - const Position posLB = pu.Y().bottomLeft(); + const Position posLB = cu.Y().bottomLeft(); int num = 0; - const unsigned plevel = pu.cs->sps->log2ParallelMergeLevelMinus2 + 2; + const unsigned plevel = cu.cs->sps->log2ParallelMergeLevelMinus2 + 2; - const PredictionUnit *puLeftBottom = pu.cs->getPURestricted(posLB.offset(-1, 1), pu, pu.chType); - if (puLeftBottom && puLeftBottom->cu->affine + const CodingUnit* puLeftBottom = cu.cs->getCURestricted(posLB.offset(-1, 1), cu, cu.chType); + if (puLeftBottom && puLeftBottom->affine && puLeftBottom->mergeType == MRG_TYPE_DEFAULT_N - && PU::isDiffMER(pu.lumaPos(), posLB.offset(-1, 1), plevel) + && CU::isDiffMER(cu.lumaPos(), posLB.offset(-1, 1), plevel) ) { npu[num++] = puLeftBottom; return num; } - const PredictionUnit* puLeft = pu.cs->getPURestricted(posLB.offset(-1, 0), pu, pu.chType); - if (puLeft && puLeft->cu->affine + const CodingUnit* puLeft = cu.cs->getCURestricted(posLB.offset(-1, 0), cu, cu.chType); + if (puLeft && puLeft->affine && puLeft->mergeType == MRG_TYPE_DEFAULT_N - && PU::isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) + && CU::isDiffMER(cu.lumaPos(), posLB.offset(-1, 0), plevel) ) { npu[num++] = puLeft; @@ -2190,37 +2286,37 @@ const int getAvailableAffineNeighboursForLeftPredictor(const PredictionUnit &pu, return num; } -const int getAvailableAffineNeighboursForAbovePredictor(const PredictionUnit &pu, const PredictionUnit* npu[], int numAffNeighLeft) +const int getAvailableAffineNeighboursForAbovePredictor(const CodingUnit& cu, const CodingUnit* npu[], int numAffNeighLeft) { - const Position posLT = pu.Y().topLeft(); - const Position posRT = pu.Y().topRight(); - const unsigned plevel = pu.cs->sps->log2ParallelMergeLevelMinus2 + 2; + const Position posLT = cu.Y().topLeft(); + const Position posRT = cu.Y().topRight(); + const unsigned plevel = cu.cs->sps->log2ParallelMergeLevelMinus2 + 2; int num = numAffNeighLeft; - const PredictionUnit* puAboveRight = pu.cs->getPURestricted(posRT.offset(1, -1), pu, pu.chType); - if (puAboveRight && puAboveRight->cu->affine + const CodingUnit* puAboveRight = cu.cs->getCURestricted(posRT.offset(1, -1), cu, cu.chType); + if (puAboveRight && puAboveRight->affine && puAboveRight->mergeType == MRG_TYPE_DEFAULT_N - && PU::isDiffMER(pu.lumaPos(), posRT.offset(1, -1), plevel) + && CU::isDiffMER(cu.lumaPos(), posRT.offset(1, -1), plevel) ) { npu[num++] = puAboveRight; return num; } - const PredictionUnit* puAbove = pu.cs->getPURestricted(posRT.offset(0, -1), pu, pu.chType); - if (puAbove && puAbove->cu->affine + const CodingUnit* puAbove = cu.cs->getCURestricted(posRT.offset(0, -1), cu, cu.chType); + if (puAbove && puAbove->affine && puAbove->mergeType == MRG_TYPE_DEFAULT_N - && PU::isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) + && CU::isDiffMER(cu.lumaPos(), posRT.offset(0, -1), plevel) ) { npu[num++] = puAbove; return num; } - const PredictionUnit *puAboveLeft = pu.cs->getPURestricted(posLT.offset(-1, -1), pu, pu.chType); - if (puAboveLeft && puAboveLeft->cu->affine + const CodingUnit* puAboveLeft = cu.cs->getCURestricted(posLT.offset(-1, -1), cu, cu.chType); + if (puAboveLeft && puAboveLeft->affine && puAboveLeft->mergeType == MRG_TYPE_DEFAULT_N - && PU::isDiffMER(pu.lumaPos(), posLT.offset(-1, -1), plevel) + && CU::isDiffMER(cu.lumaPos(), posLT.offset(-1, -1), plevel) ) { npu[num++] = puAboveLeft; @@ -2230,12 +2326,12 @@ const int getAvailableAffineNeighboursForAbovePredictor(const PredictionUnit &pu return num; } -void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, const int mrgCandIdx) +void CU::getAffineMergeCand( CodingUnit& cu, AffineMergeCtx& affMrgCtx, const int mrgCandIdx) { - const CodingStructure &cs = *pu.cs; - const Slice &slice = *pu.cs->slice; + const CodingStructure &cs = *cu.cs; + const Slice &slice = *cu.cs->slice; const uint32_t maxNumAffineMergeCand = slice.picHeader->maxNumAffineMergeCand; - const unsigned plevel = pu.cs->sps->log2ParallelMergeLevelMinus2 + 2; + const unsigned plevel = cu.cs->sps->log2ParallelMergeLevelMinus2 + 2; for (int i = 0; i < maxNumAffineMergeCand; i++) { @@ -2264,12 +2360,12 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, int pos = 0; // Get spatial MV - const Position posCurLB = pu.Y().bottomLeft(); + const Position posCurLB = cu.Y().bottomLeft(); MotionInfo miLeft; //left - const PredictionUnit* puLeft = cs.getPURestricted(posCurLB.offset(-1, 0), pu, pu.chType); - const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posCurLB.offset(-1, 0), plevel) && pu.cu != puLeft->cu && CU::isInter(*puLeft->cu); + const CodingUnit* puLeft = cs.getCURestricted(posCurLB.offset(-1, 0), cu, cu.chType); + const bool isAvailableA1 = puLeft && isDiffMER(cu.lumaPos(), posCurLB.offset(-1, 0), plevel) && &cu != puLeft && CU::isInter(*puLeft); if (isAvailableA1) { miLeft = puLeft->getMotionInfo(posCurLB.offset(-1, 0)); @@ -2287,7 +2383,7 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, } mrgCtx.numValidMergeCand = pos; - isAvailableSubPu = getInterMergeSbTMVPCand(pu, mrgCtx, tmpLICFlag, pos, 0); + isAvailableSubPu = getInterMergeSbTMVPCand(cu, mrgCtx, tmpLICFlag, pos, 0); if (isAvailableSubPu) { for (int mvNum = 0; mvNum < 3; mvNum++) @@ -2317,35 +2413,35 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, if (slice.sps->Affine) { ///> Start: inherited affine candidates - const PredictionUnit* npu[5]; - int numAffNeighLeft = getAvailableAffineNeighboursForLeftPredictor(pu, npu); - int numAffNeigh = getAvailableAffineNeighboursForAbovePredictor(pu, npu, numAffNeighLeft); + const CodingUnit* npu[5]; + int numAffNeighLeft = getAvailableAffineNeighboursForLeftPredictor(cu, npu); + int numAffNeigh = getAvailableAffineNeighboursForAbovePredictor(cu, npu, numAffNeighLeft); for (int idx = 0; idx < numAffNeigh; idx++) { // derive Mv from Neigh affine PU Mv cMv[2][3]; - const PredictionUnit* puNeigh = npu[idx]; - pu.cu->affineType = puNeigh->cu->affineType; - if (puNeigh->interDir != 2) + const CodingUnit* cuNeigh = npu[idx]; + cu.affineType = cuNeigh->affineType; + if (cuNeigh->interDir != 2) { - xInheritedAffineMv(pu, puNeigh, REF_PIC_LIST_0, cMv[0]); + xInheritedAffineMv(cu, cuNeigh, REF_PIC_LIST_0, cMv[0]); } if (slice.isInterB()) { - if (puNeigh->interDir != 1) + if (cuNeigh->interDir != 1) { - xInheritedAffineMv(pu, puNeigh, REF_PIC_LIST_1, cMv[1]); + xInheritedAffineMv(cu, cuNeigh, REF_PIC_LIST_1, cMv[1]); } } for (int mvNum = 0; mvNum < 3; mvNum++) { - affMrgCtx.mvFieldNeighbours[(affMrgCtx.numValidMergeCand << 1) + 0][mvNum].setMvField(cMv[0][mvNum], puNeigh->refIdx[0]); - affMrgCtx.mvFieldNeighbours[(affMrgCtx.numValidMergeCand << 1) + 1][mvNum].setMvField(cMv[1][mvNum], puNeigh->refIdx[1]); + affMrgCtx.mvFieldNeighbours[(affMrgCtx.numValidMergeCand << 1) + 0][mvNum].setMvField(cMv[0][mvNum], cuNeigh->refIdx[0]); + affMrgCtx.mvFieldNeighbours[(affMrgCtx.numValidMergeCand << 1) + 1][mvNum].setMvField(cMv[1][mvNum], cuNeigh->refIdx[1]); } - affMrgCtx.interDirNeighbours[affMrgCtx.numValidMergeCand] = puNeigh->interDir; - affMrgCtx.affineType[affMrgCtx.numValidMergeCand] = (EAffineModel)(puNeigh->cu->affineType); - affMrgCtx.BcwIdx[affMrgCtx.numValidMergeCand] = puNeigh->cu->BcwIdx; + affMrgCtx.interDirNeighbours[affMrgCtx.numValidMergeCand] = cuNeigh->interDir; + affMrgCtx.affineType[affMrgCtx.numValidMergeCand] = (EAffineModel)(cuNeigh->affineType); + affMrgCtx.BcwIdx[affMrgCtx.numValidMergeCand] = cuNeigh->BcwIdx; if (affMrgCtx.numValidMergeCand == mrgCandIdx) { @@ -2368,56 +2464,48 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, int8_t neighBcw[2] = { BCW_DEFAULT, BCW_DEFAULT }; // control point: LT B2->B3->A2 - const Position posLT[3] = { pu.Y().topLeft().offset(-1, -1), pu.Y().topLeft().offset(0, -1), pu.Y().topLeft().offset(-1, 0) }; + const Position posLT[3] = { cu.Y().topLeft().offset(-1, -1), cu.Y().topLeft().offset(0, -1), cu.Y().topLeft().offset(-1, 0) }; for (int i = 0; i < 3; i++) { const Position pos = posLT[i]; - const PredictionUnit* puNeigh = cs.getPURestricted(pos, pu, pu.chType); + const CodingUnit* cuNeigh = cs.getCURestricted(pos, cu, cu.chType); - if (puNeigh && CU::isInter(*puNeigh->cu) - && PU::isDiffMER(pu.lumaPos(), pos, plevel) - ) + if (cuNeigh && CU::isInter(*cuNeigh) && CU::isDiffMER(cu.lumaPos(), pos, plevel)) { isAvailable[0] = true; - mi[0] = puNeigh->getMotionInfo(pos); - neighBcw[0] = puNeigh->cu->BcwIdx; + mi[0] = cuNeigh->getMotionInfo(pos); + neighBcw[0] = cuNeigh->BcwIdx; break; } } // control point: RT B1->B0 - const Position posRT[2] = { pu.Y().topRight().offset(0, -1), pu.Y().topRight().offset(1, -1) }; + const Position posRT[2] = { cu.Y().topRight().offset(0, -1), cu.Y().topRight().offset(1, -1) }; for (int i = 0; i < 2; i++) { const Position pos = posRT[i]; - const PredictionUnit* puNeigh = cs.getPURestricted(pos, pu, pu.chType); - + const CodingUnit* cuNeigh = cs.getCURestricted(pos, cu, cu.chType); - if (puNeigh && CU::isInter(*puNeigh->cu) - && PU::isDiffMER(pu.lumaPos(), pos, plevel) - ) + if (cuNeigh && CU::isInter(*cuNeigh) && CU::isDiffMER(cu.lumaPos(), pos, plevel)) { isAvailable[1] = true; - mi[1] = puNeigh->getMotionInfo(pos); - neighBcw[1] = puNeigh->cu->BcwIdx; + mi[1] = cuNeigh->getMotionInfo(pos); + neighBcw[1] = cuNeigh->BcwIdx; break; } } // control point: LB A1->A0 - const Position posLB[2] = { pu.Y().bottomLeft().offset(-1, 0), pu.Y().bottomLeft().offset(-1, 1) }; + const Position posLB[2] = { cu.Y().bottomLeft().offset(-1, 0), cu.Y().bottomLeft().offset(-1, 1) }; for (int i = 0; i < 2; i++) { const Position pos = posLB[i]; - const PredictionUnit* puNeigh = cs.getPURestricted(pos, pu, pu.chType); + const CodingUnit* cuNeigh = cs.getCURestricted(pos, cu, cu.chType); - - if (puNeigh && CU::isInter(*puNeigh->cu) - && PU::isDiffMER(pu.lumaPos(), pos, plevel) - ) + if (cuNeigh && CU::isInter(*cuNeigh) && CU::isDiffMER(cu.lumaPos(), pos, plevel)) { isAvailable[2] = true; - mi[2] = puNeigh->getMotionInfo(pos); + mi[2] = cuNeigh->getMotionInfo(pos); break; } } @@ -2427,14 +2515,14 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, { //>> MTK colocated-RightBottom // offset the pos to be sure to "point" to the same position the uiAbsPartIdx would've pointed to - Position posRB = pu.Y().bottomRight().offset(-3, -3); + Position posRB = cu.Y().bottomRight().offset(-3, -3); const PreCalcValues& pcv = *cs.pcv; Position posC0; bool C0Avail = false; bool boundaryCond = ((posRB.x + pcv.minCUSize) < pcv.lumaWidth) && ((posRB.y + pcv.minCUSize) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->pps->getSubPicFromPos(pu.lumaPos()); + const SubPic& curSubPic = cu.cs->slice->pps->getSubPicFromPos(cu.lumaPos()); if (curSubPic.treatedAsPic) { boundaryCond = ((posRB.x + pcv.minCUSize) <= curSubPic.subPicRight && @@ -2452,7 +2540,7 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, Mv cColMv; int refIdx = 0; - bool bExistMV = C0Avail && getColocatedMVP(pu, REF_PIC_LIST_0, posC0, cColMv, refIdx); + bool bExistMV = C0Avail && getColocatedMVP(cu, REF_PIC_LIST_0, posC0, cColMv, refIdx); if (bExistMV) { mi[3].mv[0] = cColMv; @@ -2463,7 +2551,7 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, if (slice.isInterB()) { - bExistMV = C0Avail && getColocatedMVP(pu, REF_PIC_LIST_1, posC0, cColMv, refIdx); + bExistMV = C0Avail && getColocatedMVP(cu, REF_PIC_LIST_1, posC0, cColMv, refIdx); if (bExistMV) { mi[3].mv[1] = cColMv; @@ -2487,11 +2575,11 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, }; int verNum[6] = { 3, 3, 3, 3, 2, 2 }; - int startIdx = pu.cs->sps->AffineType ? 0 : 4; + int startIdx = cu.cs->sps->AffineType ? 0 : 4; for (int idx = startIdx; idx < modelNum; idx++) { int modelIdx = order[idx]; - getAffineControlPointCand(pu, mi, isAvailable, model[modelIdx], ((modelIdx == 3) ? neighBcw[1] : neighBcw[0]), modelIdx, verNum[modelIdx], affMrgCtx); + getAffineControlPointCand(cu, mi, isAvailable, model[modelIdx], ((modelIdx == 3) ? neighBcw[1] : neighBcw[0]), modelIdx, verNum[modelIdx], affMrgCtx); if (affMrgCtx.numValidMergeCand != 0 && affMrgCtx.numValidMergeCand - 1 == mrgCandIdx) { return; @@ -2536,7 +2624,7 @@ void PU::getAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, } } -void PU::setAllAffineMvField(PredictionUnit &pu, MvField *mvField, RefPicList eRefList) +void CU::setAllAffineMvField(CodingUnit& cu, MvField *mvField, RefPicList eRefList) { // Set Mv Mv mv[3]; @@ -2544,16 +2632,16 @@ void PU::setAllAffineMvField(PredictionUnit &pu, MvField *mvField, RefPicList eR { mv[i] = mvField[i].mv; } - setAllAffineMv(pu, mv[0], mv[1], mv[2], eRefList); + setAllAffineMv(cu, mv[0], mv[1], mv[2], eRefList); // Set RefIdx CHECK(mvField[0].refIdx != mvField[1].refIdx || mvField[0].refIdx != mvField[2].refIdx, "Affine mv corners don't have the same refIdx."); - pu.refIdx[eRefList] = mvField[0].refIdx; + cu.refIdx[eRefList] = mvField[0].refIdx; } -void PU::setAllAffineMv(PredictionUnit& pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList, bool clipCPMVs) +void CU::setAllAffineMv(CodingUnit& cu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList, bool clipCPMVs) { - int width = pu.Y().width; + int width = cu.Y().width; int shift = MAX_CU_DEPTH; bool SameMV = false; if (affLT == affRT) @@ -2567,7 +2655,7 @@ void PU::setAllAffineMv(PredictionUnit& pu, Mv affLT, Mv affRT, Mv affLB, RefPic { affLT.mvCliptoStorageBitDepth(); affRT.mvCliptoStorageBitDepth(); - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { affLB.mvCliptoStorageBitDepth(); } @@ -2581,8 +2669,8 @@ void PU::setAllAffineMv(PredictionUnit& pu, Mv affLT, Mv affRT, Mv affLB, RefPic { deltaMvHorX = (affRT - affLT).hor << (shift - Log2(width)); deltaMvHorY = (affRT - affLT).ver << (shift - Log2(width)); - int height = pu.Y().height; - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + int height = cu.Y().height; + if (cu.affineType == AFFINEMODEL_6PARAM) { deltaMvVerX = (affLB - affLT).hor << (shift - Log2(height)); deltaMvVerY = (affLB - affLT).ver << (shift - Log2(height)); @@ -2600,12 +2688,12 @@ void PU::setAllAffineMv(PredictionUnit& pu, Mv affLT, Mv affRT, Mv affLB, RefPic int blockHeight = AFFINE_MIN_BLOCK_SIZE; const int halfBW = blockWidth >> 1; const int halfBH = blockHeight >> 1; - MotionBuf mb = pu.getMotionBuf(); + MotionBuf mb = cu.getMotionBuf(); int mvScaleTmpHor, mvScaleTmpVer; - const bool subblkMVSpreadOverLimit = InterPredInterpolation::isSubblockVectorSpreadOverLimit(deltaMvHorX, deltaMvHorY, deltaMvVerX, deltaMvVerY, pu.interDir); + const bool subblkMVSpreadOverLimit = InterPredInterpolation::isSubblockVectorSpreadOverLimit(deltaMvHorX, deltaMvHorY, deltaMvVerX, deltaMvVerY, cu.interDir); - int h = pu.Y().height / blockHeight; - int w = pu.Y().width / blockWidth; + int h = cu.Y().height / blockHeight; + int w = cu.Y().width / blockWidth; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) @@ -2625,8 +2713,8 @@ void PU::setAllAffineMv(PredictionUnit& pu, Mv affLT, Mv affRT, Mv affLB, RefPic } else { - mvScaleTmpHor = mvScaleHor + deltaMvHorX * (pu.Y().width >> 1) + deltaMvVerX * (pu.Y().height >> 1); - mvScaleTmpVer = mvScaleVer + deltaMvHorY * (pu.Y().width >> 1) + deltaMvVerY * (pu.Y().height >> 1); + mvScaleTmpHor = mvScaleHor + deltaMvHorX * (cu.Y().width >> 1) + deltaMvVerX * (cu.Y().height >> 1); + mvScaleTmpVer = mvScaleVer + deltaMvHorY * (cu.Y().width >> 1) + deltaMvVerY * (cu.Y().height >> 1); } } roundAffineMv(mvScaleTmpHor, mvScaleTmpVer, shift); @@ -2637,29 +2725,29 @@ void PU::setAllAffineMv(PredictionUnit& pu, Mv affLT, Mv affRT, Mv affLB, RefPic } } - pu.mvAffi[eRefList][0] = affLT; - pu.mvAffi[eRefList][1] = affRT; - pu.mvAffi[eRefList][2] = affLB; + cu.mvAffi[eRefList][0] = affLT; + cu.mvAffi[eRefList][1] = affRT; + cu.mvAffi[eRefList][2] = affLB; } -void clipColPos(int& posX, int& posY, const PredictionUnit& pu) +void clipColPos(int& posX, int& posY, const CodingUnit& cu) { - Position puPos = pu.lumaPos(); - int log2CtuSize = pu.cs->pcv->maxCUSizeLog2; + Position puPos = cu.lumaPos(); + int log2CtuSize = cu.cs->pcv->maxCUSizeLog2; int ctuX = ((puPos.x >> log2CtuSize) << log2CtuSize); int ctuY = ((puPos.y >> log2CtuSize) << log2CtuSize); int horMax; - SubPic curSubPic = pu.cu->slice->pps->getSubPicFromPos(puPos); + const SubPic& curSubPic = cu.slice->pps->getSubPicFromPos(puPos); if (curSubPic.treatedAsPic) { - horMax = std::min((int)curSubPic.subPicRight, ctuX + (int)pu.cs->sps->CTUSize + 3); + horMax = std::min((int)curSubPic.subPicRight, ctuX + (int)cu.cs->sps->CTUSize + 3); } else { - horMax = std::min((int)pu.cs->pps->picWidthInLumaSamples - 1, ctuX + (int)pu.cs->sps->CTUSize + 3); + horMax = std::min((int)cu.cs->pps->picWidthInLumaSamples - 1, ctuX + (int)cu.cs->sps->CTUSize + 3); } int horMin = std::max((int)0, ctuX); - int verMax = std::min((int)pu.cs->pps->picHeightInLumaSamples - 1, ctuY + (int)pu.cs->sps->CTUSize - 1); + int verMax = std::min((int)cu.cs->pps->picHeightInLumaSamples - 1, ctuY + (int)cu.cs->sps->CTUSize - 1); int verMin = std::max((int)0, ctuY); posX = std::min(horMax, std::max(horMin, posX)); @@ -2667,26 +2755,26 @@ void clipColPos(int& posX, int& posY, const PredictionUnit& pu) } -void PU::spanMotionInfo( PredictionUnit &pu, const MergeCtx &mrgCtx ) +void CU::spanMotionInfo( CodingUnit& cu, const MergeCtx &mrgCtx ) { - MotionBuf mb = pu.getMotionBuf(); - if (!pu.mergeFlag || pu.mergeType == MRG_TYPE_DEFAULT_N) + MotionBuf mb = cu.getMotionBuf(); + if (!cu.mergeFlag || cu.mergeType == MRG_TYPE_DEFAULT_N) { MotionInfo mi; - mi.isInter = CU::isInter(*pu.cu); - mi.sliceIdx = pu.cu->slice->independentSliceIdx; + mi.isInter = CU::isInter(cu); + mi.sliceIdx = cu.slice->independentSliceIdx; if( mi.isInter ) { - mi.interDir = pu.interDir; + mi.interDir = cu.interDir; for( int i = 0; i < NUM_REF_PIC_LIST_01; i++ ) { - mi.mv[i] = pu.mv[i]; - mi.refIdx[i] = pu.refIdx[i]; + mi.mv[i] = cu.mv[i]; + mi.refIdx[i] = cu.refIdx[i]; } - if (pu.cu->affine) + if (cu.affine) { for (int y = 0; y < mb.height; y++) { @@ -2712,25 +2800,25 @@ void PU::spanMotionInfo( PredictionUnit &pu, const MergeCtx &mrgCtx ) mb.fill( mi ); } - else if (pu.mergeType == MRG_TYPE_SUBPU_ATMVP) + else if (cu.mergeType == MRG_TYPE_SUBPU_ATMVP) { CHECK(mrgCtx.subPuMvpMiBuf.area() == 0 || !mrgCtx.subPuMvpMiBuf.buf, "Buffer not initialized"); mb.copyFrom(mrgCtx.subPuMvpMiBuf); } } -bool PU::isBiPredFromDifferentDirEqDistPoc(const PredictionUnit& pu) +bool CU::isBiPredFromDifferentDirEqDistPoc(const CodingUnit& cu) { - if (pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0) + if (cu.refIdx[0] >= 0 && cu.refIdx[1] >= 0) { - if (pu.cu->slice->getRefPic(REF_PIC_LIST_0, pu.refIdx[0])->isLongTerm - || pu.cu->slice->getRefPic(REF_PIC_LIST_1, pu.refIdx[1])->isLongTerm) + if (cu.slice->getRefPic(REF_PIC_LIST_0, cu.refIdx[0])->isLongTerm + || cu.slice->getRefPic(REF_PIC_LIST_1, cu.refIdx[1])->isLongTerm) { return false; } - const int poc0 = pu.cu->slice->getRefPOC(REF_PIC_LIST_0, pu.refIdx[0]); - const int poc1 = pu.cu->slice->getRefPOC(REF_PIC_LIST_1, pu.refIdx[1]); - const int poc = pu.cu->slice->poc; + const int poc0 = cu.slice->getRefPOC(REF_PIC_LIST_0, cu.refIdx[0]); + const int poc1 = cu.slice->getRefPOC(REF_PIC_LIST_1, cu.refIdx[1]); + const int poc = cu.slice->poc; if ((poc - poc0)*(poc - poc1) < 0) { if (abs(poc - poc0) == abs(poc - poc1)) @@ -2742,25 +2830,25 @@ bool PU::isBiPredFromDifferentDirEqDistPoc(const PredictionUnit& pu) return false; } -void PU::restrictBiPredMergeCandsOne(PredictionUnit &pu) +void CU::restrictBiPredMergeCandsOne(CodingUnit& cu) { - if (PU::isBipredRestriction(pu)) + if (CU::isBipredRestriction(cu)) { - if (pu.interDir == 3) + if (cu.interDir == 3) { - pu.interDir = 1; - pu.refIdx[1] = -1; - pu.mv[1] = Mv(0, 0); - pu.cu->BcwIdx = BCW_DEFAULT; + cu.interDir = 1; + cu.refIdx[1] = -1; + cu.mv[1] = Mv(0, 0); + cu.BcwIdx = BCW_DEFAULT; } } } -void PU::getGeoMergeCandidates(const PredictionUnit &pu, MergeCtx &geoMrgCtx) +void CU::getGeoMergeCandidates(const CodingUnit& cu, MergeCtx &geoMrgCtx) { MergeCtx tmpMergeCtx; - const Slice & slice = *pu.cs->slice; + const Slice & slice = *cu.cs->slice; const uint32_t maxNumMergeCand = slice.sps->maxNumMergeCand; geoMrgCtx.numValidMergeCand = 0; @@ -2777,7 +2865,7 @@ void PU::getGeoMergeCandidates(const PredictionUnit &pu, MergeCtx &geoMrgCtx) geoMrgCtx.useAltHpelIf[i] = false; } - PU::getInterMergeCandidates(pu, tmpMergeCtx, 0); + CU::getInterMergeCandidates(cu, tmpMergeCtx, 0); for (int32_t i = 0; i < maxNumMergeCand; i++) { @@ -2819,17 +2907,17 @@ void PU::getGeoMergeCandidates(const PredictionUnit &pu, MergeCtx &geoMrgCtx) } } -void PU::spanGeoMotionInfo(PredictionUnit &pu, MergeCtx &geoMrgCtx, const uint8_t splitDir, const uint8_t candIdx0, +void CU::spanGeoMotionInfo(CodingUnit& cu, MergeCtx &geoMrgCtx, const uint8_t splitDir, const uint8_t candIdx0, const uint8_t candIdx1) { - pu.geoSplitDir = splitDir; - pu.geoMergeIdx0 = candIdx0; - pu.geoMergeIdx1 = candIdx1; - MotionBuf mb = pu.getMotionBuf(); + cu.geoSplitDir = splitDir; + cu.geoMergeIdx0 = candIdx0; + cu.geoMergeIdx1 = candIdx1; + MotionBuf mb = cu.getMotionBuf(); MotionInfo biMv; biMv.isInter = true; - biMv.sliceIdx = pu.cs->slice->independentSliceIdx; + biMv.sliceIdx = cu.cs->slice->independentSliceIdx; if (geoMrgCtx.interDirNeighbours[candIdx0] == 1 && geoMrgCtx.interDirNeighbours[candIdx1] == 2) { @@ -2871,14 +2959,14 @@ void PU::spanGeoMotionInfo(PredictionUnit &pu, MergeCtx &geoMrgCtx, const uint8_ int distanceIdx = g_GeoParams[splitDir][1]; int distanceX = angle; int distanceY = (distanceX + (GEO_NUM_ANGLES >> 2)) % GEO_NUM_ANGLES; - int offsetX = (-(int) pu.lwidth()) >> 1; - int offsetY = (-(int) pu.lheight()) >> 1; + int offsetX = (-(int) cu.lwidth()) >> 1; + int offsetY = (-(int) cu.lheight()) >> 1; if (distanceIdx > 0) { - if (angle % 16 == 8 || (angle % 16 != 0 && pu.lheight() >= pu.lwidth())) - offsetY += angle < 16 ? ((distanceIdx * pu.lheight()) >> 3) : -(int) ((distanceIdx * pu.lheight()) >> 3); + if (angle % 16 == 8 || (angle % 16 != 0 && cu.lheight() >= cu.lwidth())) + offsetY += angle < 16 ? ((distanceIdx * cu.lheight()) >> 3) : -(int) ((distanceIdx * cu.lheight()) >> 3); else - offsetX += angle < 16 ? ((distanceIdx * pu.lwidth()) >> 3) : -(int) ((distanceIdx * pu.lwidth()) >> 3); + offsetX += angle < 16 ? ((distanceIdx * cu.lwidth()) >> 3) : -(int) ((distanceIdx * cu.lwidth()) >> 3); } for (int y = 0; y < mb.height; y++) { @@ -2923,81 +3011,75 @@ void PU::spanGeoMotionInfo(PredictionUnit &pu, MergeCtx &geoMrgCtx, const uint8_ void CU::resetMVDandMV2Int( CodingUnit& cu ) { - PredictionUnit &pu = *cu.pu; + MergeCtx mrgCtx; + + if( !cu.mergeFlag ) { - MergeCtx mrgCtx; + if( cu.interDir != 2 /* PRED_L1 */ ) + { + Mv mv = cu.mv[0]; + Mv mvPred; + AMVPInfo amvpInfo; + CU::fillMvpCand(cu, REF_PIC_LIST_0, cu.refIdx[0], amvpInfo); + cu.mvpNum[0] = amvpInfo.numCand; - if( !pu.mergeFlag ) + mvPred = amvpInfo.mvCand[cu.mvpIdx[0]]; + mv.roundTransPrecInternal2Amvr(cu.imv); + cu.mv[0] = mv; + Mv mvDiff = mv - mvPred; + cu.mvd[0] = mvDiff; + } + if( cu.interDir != 1 /* PRED_L0 */ ) { - if( pu.interDir != 2 /* PRED_L1 */ ) - { - Mv mv = pu.mv[0]; - Mv mvPred; - AMVPInfo amvpInfo; - PU::fillMvpCand(pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo); - pu.mvpNum[0] = amvpInfo.numCand; + Mv mv = cu.mv[1]; + Mv mvPred; + AMVPInfo amvpInfo; + CU::fillMvpCand(cu, REF_PIC_LIST_1, cu.refIdx[1], amvpInfo); + cu.mvpNum[1] = amvpInfo.numCand; + + mvPred = amvpInfo.mvCand[cu.mvpIdx[1]]; + mv.roundTransPrecInternal2Amvr(cu.imv); + Mv mvDiff = mv - mvPred; - mvPred = amvpInfo.mvCand[pu.mvpIdx[0]]; - mv.roundTransPrecInternal2Amvr(cu.imv); - pu.mv[0] = mv; - Mv mvDiff = mv - mvPred; - pu.mvd[0] = mvDiff; + if( cu.cs->slice->picHeader->mvdL1Zero && cu.interDir == 3 /* PRED_BI */ ) + { + cu.mvd[1] = Mv(); + mv = mvPred; } - if( pu.interDir != 1 /* PRED_L0 */ ) + else { - Mv mv = pu.mv[1]; - Mv mvPred; - AMVPInfo amvpInfo; - PU::fillMvpCand(pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo); - pu.mvpNum[1] = amvpInfo.numCand; - - mvPred = amvpInfo.mvCand[pu.mvpIdx[1]]; - mv.roundTransPrecInternal2Amvr(cu.imv); - Mv mvDiff = mv - mvPred; - - if( pu.cu->cs->slice->picHeader->mvdL1Zero && pu.interDir == 3 /* PRED_BI */ ) - { - pu.mvd[1] = Mv(); - mv = mvPred; - } - else - { - pu.mvd[1] = mvDiff; - } - pu.mv[1] = mv; + cu.mvd[1] = mvDiff; } - - } - else - { - PU::getInterMergeCandidates ( pu, mrgCtx, 0 ); - mrgCtx.setMergeInfo( pu, pu.mergeIdx ); + cu.mv[1] = mv; } - PU::spanMotionInfo( pu, mrgCtx ); } + else + { + CU::getInterMergeCandidates ( cu, mrgCtx, 0 ); + mrgCtx.setMergeInfo( cu, cu.mergeIdx ); + } + + CU::spanMotionInfo( cu, mrgCtx ); } bool CU::hasSubCUNonZeroMVd( const CodingUnit& cu ) { bool bNonZeroMvd = false; - const auto &pu = *cu.pu; + if( ( !cu.mergeFlag ) && ( !cu.skip ) ) { - if( ( !pu.mergeFlag ) && ( !cu.skip ) ) + if( cu.interDir != 2 /* PRED_L1 */ ) + { + bNonZeroMvd |= cu.mvd[REF_PIC_LIST_0].hor != 0; + bNonZeroMvd |= cu.mvd[REF_PIC_LIST_0].ver != 0; + } + if( cu.interDir != 1 /* PRED_L0 */ ) { - if( pu.interDir != 2 /* PRED_L1 */ ) + if( !cu.cs->slice->picHeader->mvdL1Zero || cu.interDir != 3 /* PRED_BI */ ) { - bNonZeroMvd |= pu.mvd[REF_PIC_LIST_0].hor != 0; - bNonZeroMvd |= pu.mvd[REF_PIC_LIST_0].ver != 0; - } - if( pu.interDir != 1 /* PRED_L0 */ ) - { - if( !pu.cu->cs->slice->picHeader->mvdL1Zero || pu.interDir != 3 /* PRED_BI */ ) - { - bNonZeroMvd |= pu.mvd[REF_PIC_LIST_1].hor != 0; - bNonZeroMvd |= pu.mvd[REF_PIC_LIST_1].ver != 0; - } + bNonZeroMvd |= cu.mvd[REF_PIC_LIST_1].hor != 0; + bNonZeroMvd |= cu.mvd[REF_PIC_LIST_1].ver != 0; } } } @@ -3009,33 +3091,30 @@ bool CU::hasSubCUNonZeroAffineMVd( const CodingUnit& cu ) { bool nonZeroAffineMvd = false; - if ( !cu.affine || cu.pu->mergeFlag ) + if ( !cu.affine || cu.mergeFlag ) { return false; } - const auto &pu = *cu.pu; + if ( ( !cu.mergeFlag ) && ( !cu.skip ) ) { - if ( ( !pu.mergeFlag ) && ( !cu.skip ) ) + if ( cu.interDir != 2 /* PRED_L1 */ ) { - if ( pu.interDir != 2 /* PRED_L1 */ ) + for ( int i = 0; i < ( cu.affineType == AFFINEMODEL_6PARAM ? 3 : 2 ); i++ ) { - for ( int i = 0; i < ( cu.affineType == AFFINEMODEL_6PARAM ? 3 : 2 ); i++ ) - { - nonZeroAffineMvd |= pu.mvdAffi[REF_PIC_LIST_0][i].hor != 0; - nonZeroAffineMvd |= pu.mvdAffi[REF_PIC_LIST_0][i].ver != 0; - } + nonZeroAffineMvd |= cu.mvdAffi[REF_PIC_LIST_0][i].hor != 0; + nonZeroAffineMvd |= cu.mvdAffi[REF_PIC_LIST_0][i].ver != 0; } + } - if ( pu.interDir != 1 /* PRED_L0 */ ) + if ( cu.interDir != 1 /* PRED_L0 */ ) + { + if ( !cu.cs->slice->picHeader->mvdL1Zero || cu.interDir != 3 /* PRED_BI */ ) { - if ( !pu.cu->cs->slice->picHeader->mvdL1Zero || pu.interDir != 3 /* PRED_BI */ ) + for ( int i = 0; i < ( cu.affineType == AFFINEMODEL_6PARAM ? 3 : 2 ); i++ ) { - for ( int i = 0; i < ( cu.affineType == AFFINEMODEL_6PARAM ? 3 : 2 ); i++ ) - { - nonZeroAffineMvd |= pu.mvdAffi[REF_PIC_LIST_1][i].hor != 0; - nonZeroAffineMvd |= pu.mvdAffi[REF_PIC_LIST_1][i].ver != 0; - } + nonZeroAffineMvd |= cu.mvdAffi[REF_PIC_LIST_1][i].hor != 0; + nonZeroAffineMvd |= cu.mvdAffi[REF_PIC_LIST_1][i].ver != 0; } } } @@ -3089,21 +3168,16 @@ PartSplit CU::getSbtTuSplit( const uint8_t sbtInfo ) return PartSplit(sbtTuSplitType); } -bool CU::isPredRegDiffFromTB(const CodingUnit &cu, const ComponentID compID) -{ - return (compID == COMP_Y) - && (cu.ispMode == VER_INTRA_SUBPARTITIONS && - CU::isMinWidthPredEnabledForBlkSize(cu.blocks[compID].width, cu.blocks[compID].height) - ); -} -bool CU::isMinWidthPredEnabledForBlkSize(const int w, const int h) +bool CU::isPredRegDiffFromTB(const CodingUnit &cu) { - return ((w == 8 && h > 4) || w == 4); + return (cu.ispMode == VER_INTRA_SUBPARTITIONS && ((cu.blocks[0].width == 4 )|| ((cu.blocks[0].width == 8) && (cu.blocks[0].height > 4)))); } -bool CU::isFirstTBInPredReg(const CodingUnit& cu, const ComponentID compID, const CompArea& area) + +bool CU::isFirstTBInPredReg(const CodingUnit& cu, const CompArea& area) { - return (compID == COMP_Y) && cu.ispMode && ((area.topLeft().x - cu.Y().topLeft().x) % PRED_REG_MIN_WIDTH == 0); + return ((area.topLeft().x - cu.Y().topLeft().x) % PRED_REG_MIN_WIDTH == 0); } + void CU::adjustPredArea(CompArea& area) { area.width = std::max(PRED_REG_MIN_WIDTH, area.width); @@ -3132,14 +3206,14 @@ bool CU::isBcwIdxCoded( const CodingUnit &cu ) return false; } - if( !cu.pu->mergeFlag ) + if( !cu.mergeFlag ) { - if( cu.pu->interDir == 3 ) + if( cu.interDir == 3 ) { WPScalingParam *wp0; WPScalingParam *wp1; - int refIdx0 = cu.pu->refIdx[REF_PIC_LIST_0]; - int refIdx1 = cu.pu->refIdx[REF_PIC_LIST_1]; + int refIdx0 = cu.refIdx[REF_PIC_LIST_0]; + int refIdx1 = cu.refIdx[REF_PIC_LIST_1]; cu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0); cu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1); @@ -3157,11 +3231,11 @@ bool CU::isBcwIdxCoded( const CodingUnit &cu ) uint8_t CU::getValidBcwIdx( const CodingUnit &cu ) { - if( cu.pu->interDir == 3 && !cu.pu->mergeFlag ) + if( cu.interDir == 3 && !cu.mergeFlag ) { return cu.BcwIdx; } - else if( cu.pu->interDir == 3 && cu.pu->mergeFlag && cu.pu->mergeType == MRG_TYPE_DEFAULT_N ) + else if( cu.interDir == 3 && cu.mergeFlag && cu.mergeType == MRG_TYPE_DEFAULT_N ) { // This is intended to do nothing here. } @@ -3177,12 +3251,12 @@ void CU::setBcwIdx( CodingUnit &cu, uint8_t uh ) { int8_t uhCnt = 0; - if( cu.pu->interDir == 3 && !cu.pu->mergeFlag ) + if( cu.interDir == 3 && !cu.mergeFlag ) { cu.BcwIdx = uh; ++uhCnt; } - else if( cu.pu->interDir == 3 && cu.pu->mergeFlag && cu.pu->mergeType == MRG_TYPE_DEFAULT_N ) + else if( cu.interDir == 3 && cu.mergeFlag && cu.mergeType == MRG_TYPE_DEFAULT_N ) { // This is intended to do nothing here. } @@ -3217,7 +3291,7 @@ bool CU::isMTSAllowed(const CodingUnit &cu, const ComponentID compID) mtsAllowed &= cuWidth <= maxSize && cuHeight <= maxSize; mtsAllowed &= !cu.ispMode; mtsAllowed &= !cu.sbtInfo; - mtsAllowed &= !(cu.bdpcmMode && cuWidth <= tsMaxSize && cuHeight <= tsMaxSize); + mtsAllowed &= !(cu.bdpcmM[CH_L] && cuWidth <= tsMaxSize && cuHeight <= tsMaxSize); return mtsAllowed; } @@ -3256,15 +3330,13 @@ bool TU::isTSAllowed(const TransformUnit &tu, const ComponentID compID) bool tsAllowed = tu.cs->sps->transformSkip; tsAllowed &= ( !tu.cu->ispMode || !isLuma(compID) ); SizeType transformSkipMaxSize = 1 << maxSize; - tsAllowed &= !(tu.cu->bdpcmMode && isLuma(compID)); - tsAllowed &= !(tu.cu->bdpcmModeChroma && isChroma(compID)); + tsAllowed &= !(tu.cu->bdpcmM[toChannelType(compID)]); tsAllowed &= tu.blocks[compID].width <= transformSkipMaxSize && tu.blocks[compID].height <= transformSkipMaxSize; tsAllowed &= !tu.cu->sbtInfo; return tsAllowed; } - int TU::getICTMode( const TransformUnit& tu, int jointCbCr ) { if( jointCbCr < 0 ) @@ -3277,7 +3349,7 @@ int TU::getICTMode( const TransformUnit& tu, int jointCbCr ) bool TU::needsSqrt2Scale( const TransformUnit& tu, const ComponentID compID ) { const Size& size=tu.blocks[compID]; - const bool isTransformSkip = tu.mtsIdx[compID]==MTS_SKIP && isLuma(compID); + const bool isTransformSkip = tu.mtsIdx[compID] == MTS_SKIP; return (!isTransformSkip) && (((Log2(size.width * size.height)) & 1) == 1); } diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index 331160cc1..474147726 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file UnitTool.h * \brief defines operations for basic units */ @@ -58,39 +62,44 @@ namespace vvenc { // CS tools namespace CS { - UnitArea getArea (const CodingStructure &cs, const UnitArea& area, const ChannelType chType, const TreeType treeType); - bool isDualITree (const CodingStructure &cs); - void setRefinedMotionField ( CodingStructure &cs); + UnitArea getArea (const CodingStructure &cs, const UnitArea& area, const ChannelType chType, const TreeType treeType); + bool isDualITree (const CodingStructure &cs); + void setRefinedMotionField ( CodingStructure &cs); } // CU tools namespace CU { - inline bool isIntra (const CodingUnit &cu) { return cu.predMode == MODE_INTRA; } - inline bool isInter (const CodingUnit &cu) { return cu.predMode == MODE_INTER; } - inline bool isIBC (const CodingUnit &cu) { return cu.predMode == MODE_IBC; } - inline bool isPLT (const CodingUnit &cu) { return cu.predMode == MODE_PLT; } - inline bool isRDPCMEnabled (const CodingUnit& cu) { return cu.predMode == MODE_INTRA ? cu.cs->sps->spsRExt.implicitRdpcmEnabled : cu.cs->sps->spsRExt.explicitRdpcmEnabled;} - inline bool isSameSlice (const CodingUnit& cu, const CodingUnit& cu2) { return cu.slice->independentSliceIdx == cu2.slice->independentSliceIdx; } - inline bool isSameTile (const CodingUnit& cu, const CodingUnit& cu2) { return cu.tileIdx == cu2.tileIdx; } - inline bool isSameSliceAndTile (const CodingUnit& cu, const CodingUnit& cu2) { return ( cu.slice->independentSliceIdx == cu2.slice->independentSliceIdx ) && ( cu.tileIdx == cu2.tileIdx ); } - + inline bool isSepTree (const CodingUnit &cu) { return cu.treeType != TREE_D || CS::isDualITree( *cu.cs ); } + inline bool isLocalSepTree (const CodingUnit &cu) { return cu.treeType != TREE_D && !CS::isDualITree(*cu.cs); } + inline bool isConsInter (const CodingUnit &cu) { return cu.modeType == MODE_TYPE_INTER; } + inline bool isConsIntra (const CodingUnit &cu) { return cu.modeType == MODE_TYPE_INTRA; } + + inline bool isIntra (const CodingUnit &cu) { return cu.predMode == MODE_INTRA; } + inline bool isInter (const CodingUnit &cu) { return cu.predMode == MODE_INTER; } + inline bool isIBC (const CodingUnit &cu) { return cu.predMode == MODE_IBC; } + inline bool isPLT (const CodingUnit &cu) { return cu.predMode == MODE_PLT; } + inline bool isRDPCMEnabled (const CodingUnit& cu) { return cu.predMode == MODE_INTRA ? cu.cs->sps->spsRExt.implicitRdpcmEnabled : cu.cs->sps->spsRExt.explicitRdpcmEnabled;} + inline bool isSameSlice (const CodingUnit& cu, const CodingUnit& cu2) { return cu.slice->independentSliceIdx == cu2.slice->independentSliceIdx; } + inline bool isSameTile (const CodingUnit& cu, const CodingUnit& cu2) { return cu.tileIdx == cu2.tileIdx; } + inline bool isSameSliceAndTile (const CodingUnit& cu, const CodingUnit& cu2) { return ( cu.slice->independentSliceIdx == cu2.slice->independentSliceIdx ) && ( cu.tileIdx == cu2.tileIdx ); } + + uint8_t checkAllowedSbt (const CodingUnit &cu); + bool checkCCLMAllowed (const CodingUnit &cu); bool isSameCtu (const CodingUnit &cu, const CodingUnit &cu2); bool isSameSubPic (const CodingUnit &cu, const CodingUnit &cu2); bool isLastSubCUOfCtu (const CodingUnit &cu); uint32_t getCtuAddr (const CodingUnit &cu); int predictQP (const CodingUnit& cu, const int prevQP); - void addPUs ( CodingUnit& cu); - void saveMotionInHMVP (const CodingUnit& cu, const bool isToBeDone ); + void saveMotionInHMVP (const CodingUnit& cu, const bool isToBeDone ); PartSplit getSplitAtDepth (const CodingUnit& cu, const unsigned depth); ModeType getModeTypeAtDepth (const CodingUnit& cu, const unsigned depth); - bool isPredRegDiffFromTB (const CodingUnit& cu, const ComponentID compID); - bool isFirstTBInPredReg (const CodingUnit& cu, const ComponentID compID, const CompArea& area); - bool isMinWidthPredEnabledForBlkSize(const int w, const int h); + bool isPredRegDiffFromTB (const CodingUnit& cu); + bool isFirstTBInPredReg (const CodingUnit& cu, const CompArea& area); void adjustPredArea (CompArea& area); bool isBcwIdxCoded (const CodingUnit& cu); uint8_t getValidBcwIdx (const CodingUnit& cu); @@ -105,8 +114,8 @@ namespace CU bool isISPFirst (const CodingUnit &cu, const CompArea& tuArea, const ComponentID compID); bool canUseISP (const CodingUnit &cu, const ComponentID compID); bool canUseISP (const int width, const int height, const int maxTrSize = MAX_TB_SIZEY ); - bool canUseLfnstWithISP ( const CompArea& cuArea, const ISPType ispSplitType ); - bool canUseLfnstWithISP ( const CodingUnit& cu, const ChannelType chType ); + bool canUseLfnstWithISP (const CompArea& cuArea, const ISPType ispSplitType ); + bool canUseLfnstWithISP (const CodingUnit& cu, const ChannelType chType ); uint32_t getISPSplitDim (const int width, const int height, const PartSplit ispType); bool allLumaCBFsAreZero (const CodingUnit& cu); @@ -133,68 +142,65 @@ namespace CU const CodingUnit* getLeft (const CodingUnit& curr); const CodingUnit* getAbove (const CodingUnit& curr); -} -// PU tools -namespace PU -{ - int getLMSymbolList (const PredictionUnit &pu, int *modeList); - bool isMIP (const PredictionUnit &pu, const ChannelType channelType = CH_L); - int getIntraMPMs (const PredictionUnit &pu, unsigned *mpm ); - bool isDMChromaMIP (const PredictionUnit &pu); - uint32_t getIntraDirLuma (const PredictionUnit &pu); - void getIntraChromaCandModes (const PredictionUnit &pu, unsigned modeList[NUM_CHROMA_MODE]); - const PredictionUnit &getCoLocatedLumaPU(const PredictionUnit &pu); - uint32_t getFinalIntraMode (const PredictionUnit &pu, const ChannelType chType); - uint32_t getCoLocatedIntraLumaMode (const PredictionUnit &pu); - void getInterMergeCandidates (const PredictionUnit &pu, MergeCtx& mrgCtx, int mmvdList, const int mrgCandIdx = -1 ); - void getInterMMVDMergeCandidates (const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx = -1); - int getDistScaleFactor (const int currPOC, const int currRefPOC, const int colPOC, const int colRefPOC); - bool isDiffMER (const Position &pos1, const Position &pos2, const unsigned plevel); - bool getColocatedMVP (const PredictionUnit &pu, const RefPicList refPicList, const Position& pos, Mv& rcMv, const int refIdx, bool sbFlag = false); - void fillMvpCand ( PredictionUnit &pu, const RefPicList refPicList, const int refIdx, AMVPInfo &amvpInfo ); - bool addMVPCandUnscaled (const PredictionUnit &pu, const RefPicList refPicList, const int iRefIdx, const Position& pos, const MvpDir dir, AMVPInfo &amvpInfo); - bool addMergeHMVPCand (const CodingStructure &cs, MergeCtx& mrgCtx, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const bool isAvailableA1, const MotionInfo &miLeft, const bool isAvailableB1, const MotionInfo &miAbove, const bool ibcFlag, const bool isGt4x4); - void addAMVPHMVPCand (const PredictionUnit &pu, const RefPicList refPicList, const int currRefPOC, AMVPInfo &info); - bool isBipredRestriction (const PredictionUnit &pu); - void spanMotionInfo ( PredictionUnit &pu, const MergeCtx &mrgCtx = MergeCtx() ); - void restrictBiPredMergeCandsOne ( PredictionUnit &pu); - - bool isLMCMode ( unsigned mode); - bool isLMCModeEnabled (const PredictionUnit &pu, unsigned mode); - bool isChromaIntraModeCrossCheckMode(const PredictionUnit &pu); - void getGeoMergeCandidates (const PredictionUnit &pu, MergeCtx &GeoMrgCtx); - void spanGeoMotionInfo (PredictionUnit &pu, MergeCtx &GeoMrgCtx, const uint8_t splitDir, const uint8_t candIdx0, const uint8_t candIdx1); - bool isBiPredFromDifferentDirEqDistPoc(const PredictionUnit &pu); - bool checkDMVRCondition (const PredictionUnit &pu); - void getAffineControlPointCand (const PredictionUnit &pu, MotionInfo mi[4], bool isAvailable[4], int verIdx[4], int8_t BcwIdx, int modelIdx, int verNum, AffineMergeCtx& affMrgCtx); - void getAffineMergeCand (const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, const int mrgCandIdx = -1); - void setAllAffineMvField ( PredictionUnit &pu, MvField *mvField, RefPicList eRefList); - void setAllAffineMv ( PredictionUnit &pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList, bool clipCPMVs = false); - void xInheritedAffineMv (const PredictionUnit &pu, const PredictionUnit* puNeighbour, RefPicList refPicList, Mv rcMv[3]); - void fillAffineMvpCand ( PredictionUnit &pu, const RefPicList refPicList, const int refIdx, AffineAMVPInfo &affiAMVPInfo); - bool addAffineMVPCandUnscaled (const PredictionUnit &pu, const RefPicList refPicList, const int refIdx, const Position& pos, const MvpDir dir, AffineAMVPInfo &affiAmvpInfo); - bool getInterMergeSbTMVPCand (const PredictionUnit &pu, MergeCtx &mrgCtx, bool& LICFlag, const int count, int mmvdList); + + + int getLMSymbolList (const CodingUnit& cu, int *modeList); + bool isMIP (const CodingUnit& cu, const ChannelType channelType = CH_L); + int getIntraMPMs (const CodingUnit& cu, unsigned *mpm ); + bool isDMChromaMIP (const CodingUnit& cu); + uint32_t getIntraDirLuma (const CodingUnit& cu); + void getIntraChromaCandModes (const CodingUnit& cu, unsigned modeList[NUM_CHROMA_MODE]); + const CodingUnit &getCoLocatedLumaPU (const CodingUnit& cu); + uint32_t getFinalIntraMode (const CodingUnit& cu, const ChannelType chType); + uint32_t getCoLocatedIntraLumaMode (const CodingUnit& cu); + void getInterMergeCandidates (const CodingUnit& cu, MergeCtx& mrgCtx, int mmvdList, const int mrgCandIdx = -1 ); + void getInterMMVDMergeCandidates (const CodingUnit& cu, MergeCtx& mrgCtx, const int& mrgCandIdx = -1); + int getDistScaleFactor (const int currPOC, const int currRefPOC, const int colPOC, const int colRefPOC); + bool isDiffMER (const Position &pos1, const Position &pos2, const unsigned plevel); + bool getColocatedMVP (const CodingUnit& cu, const RefPicList refPicList, const Position& pos, Mv& rcMv, const int refIdx, bool sbFlag = false); + void fillMvpCand ( CodingUnit& cu, const RefPicList refPicList, const int refIdx, AMVPInfo &amvpInfo ); + bool addMVPCandUnscaled (const CodingUnit& cu, const RefPicList refPicList, const int iRefIdx, const Position& pos, const MvpDir dir, AMVPInfo &amvpInfo); + bool addMergeHMVPCand (const CodingStructure &cs, MergeCtx& mrgCtx, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const bool isAvailableA1, const MotionInfo &miLeft, const bool isAvailableB1, const MotionInfo &miAbove, const bool ibcFlag, const bool isGt4x4); + void addAMVPHMVPCand (const CodingUnit& cu, const RefPicList refPicList, const int currRefPOC, AMVPInfo &info); + bool isBipredRestriction (const CodingUnit& cu); + void spanMotionInfo ( CodingUnit& cu, const MergeCtx &mrgCtx = MergeCtx() ); + void restrictBiPredMergeCandsOne ( CodingUnit& cu); + + bool isLMCMode ( unsigned mode); + bool isLMCModeEnabled (const CodingUnit& cu, unsigned mode); + void getGeoMergeCandidates (const CodingUnit& cu, MergeCtx &GeoMrgCtx); + void spanGeoMotionInfo (CodingUnit& cu, MergeCtx &GeoMrgCtx, const uint8_t splitDir, const uint8_t candIdx0, const uint8_t candIdx1); + bool isBiPredFromDifferentDirEqDistPoc(const CodingUnit& cu); + bool checkDMVRCondition (const CodingUnit& cu); + void getAffineControlPointCand (const CodingUnit& cu, MotionInfo mi[4], bool isAvailable[4], int verIdx[4], int8_t BcwIdx, int modelIdx, int verNum, AffineMergeCtx& affMrgCtx); + void getAffineMergeCand ( CodingUnit& cu, AffineMergeCtx& affMrgCtx, const int mrgCandIdx = -1); + void setAllAffineMvField ( CodingUnit& cu, MvField *mvField, RefPicList eRefList); + void setAllAffineMv ( CodingUnit& cu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList, bool clipCPMVs = false); + void xInheritedAffineMv (const CodingUnit& cu, const CodingUnit* cuNeighbour, RefPicList refPicList, Mv rcMv[3]); + void fillAffineMvpCand ( CodingUnit& cu, const RefPicList refPicList, const int refIdx, AffineAMVPInfo &affiAMVPInfo); + bool addAffineMVPCandUnscaled (const CodingUnit& cu, const RefPicList refPicList, const int refIdx, const Position& pos, const MvpDir dir, AffineAMVPInfo &affiAmvpInfo); + bool getInterMergeSbTMVPCand (const CodingUnit& cu, MergeCtx &mrgCtx, bool& LICFlag, const int count, int mmvdList); } // TU tools namespace TU { - bool isNonTransformedResidualRotated(const TransformUnit& tu, const ComponentID compID); - bool getCbf (const TransformUnit& tu, const ComponentID compID); - bool getCbfAtDepth (const TransformUnit& tu, const ComponentID compID, const unsigned depth); - void setCbfAtDepth ( TransformUnit& tu, const ComponentID compID, const unsigned depth, const bool cbf); - bool isTSAllowed (const TransformUnit& tu, const ComponentID compID); - - bool needsSqrt2Scale (const TransformUnit& tu, const ComponentID compID); - TransformUnit* getPrevTU (const TransformUnit& tu, const ComponentID compID); - bool getPrevTuCbfAtDepth (const TransformUnit& tu, const ComponentID compID, const int trDepth ); - int getICTMode (const TransformUnit& tu, int jointCbCr = -1); + bool isNonTransformedResidualRotated (const TransformUnit& tu, const ComponentID compID); + bool getCbf (const TransformUnit& tu, const ComponentID compID); + bool getCbfAtDepth (const TransformUnit& tu, const ComponentID compID, const unsigned depth); + void setCbfAtDepth ( TransformUnit& tu, const ComponentID compID, const unsigned depth, const bool cbf); + bool isTSAllowed (const TransformUnit& tu, const ComponentID compID); + + bool needsSqrt2Scale (const TransformUnit& tu, const ComponentID compID); + TransformUnit* getPrevTU (const TransformUnit& tu, const ComponentID compID); + bool getPrevTuCbfAtDepth (const TransformUnit& tu, const ComponentID compID, const int trDepth ); + int getICTMode (const TransformUnit& tu, int jointCbCr = -1); } -uint32_t getCtuAddr (const Position& pos, const PreCalcValues &pcv); -int getNumModesMip (const Size& block); -int getMipSizeId (const Size& block); -bool allowLfnstWithMip (const Size& block); +uint32_t getCtuAddr (const Position& pos, const PreCalcValues &pcv); +int getNumModesMip (const Size& block); +int getMipSizeId (const Size& block); +bool allowLfnstWithMip (const Size& block); template uint32_t updateCandList(T uiMode, double uiCost, static_vector& candModeList, static_vector& candCostList diff --git a/source/Lib/CommonLib/dtrace.cpp b/source/Lib/CommonLib/dtrace.cpp index 0bc674dde..e166f83dc 100644 --- a/source/Lib/CommonLib/dtrace.cpp +++ b/source/Lib/CommonLib/dtrace.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file dtrace.cpp diff --git a/source/Lib/CommonLib/dtrace.h b/source/Lib/CommonLib/dtrace.h index 2617ff51f..5913c38ba 100644 --- a/source/Lib/CommonLib/dtrace.h +++ b/source/Lib/CommonLib/dtrace.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file dtrace.h * \brief Implementation of trace messages support for debugging */ diff --git a/source/Lib/CommonLib/dtrace_buffer.h b/source/Lib/CommonLib/dtrace_buffer.h index 1aebabb13..8c2f86274 100644 --- a/source/Lib/CommonLib/dtrace_buffer.h +++ b/source/Lib/CommonLib/dtrace_buffer.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file dtrace_buffer.h * \brief Easy to use dtrace calls concerning buffers */ @@ -175,16 +179,16 @@ inline void dtraceCCRC( CDTrace *trace_ctx, DTRACE_CHANNEL channel, const Coding calcCheckSum( pelBuf, cs.sps->bitDepths[ toChannelType(compId) ])); } -inline void dtraceMotField( CDTrace *trace_ctx, const PredictionUnit& pu ) +inline void dtraceMotField( CDTrace *trace_ctx, const CodingUnit& cu ) { - DTRACE( trace_ctx, D_MOT_FIELD, "PU %d,%d @ %d,%d\n", pu.lwidth(), pu.lheight(), pu.lx(), pu.ly() ); - const CMotionBuf mb = pu.getMotionBuf(); + DTRACE( trace_ctx, D_MOT_FIELD, "CU %d,%d @ %d,%d\n", cu.lwidth(), cu.lheight(), cu.lx(), cu.ly() ); + const CMotionBuf mb = cu.getMotionBuf(); for( uint32_t listIdx = 0; listIdx < 2; listIdx++ ) { RefPicList eListIdx = RefPicList( listIdx ); - for( int y = 0, i = 0; y < pu.lheight(); y += 4 ) + for( int y = 0, i = 0; y < cu.lheight(); y += 4 ) { - for( int x = 0; x < pu.lwidth(); x += 4, i++ ) + for( int x = 0; x < cu.lwidth(); x += 4, i++ ) { const MotionInfo &mi = mb.at( x >> 2, y >> 2 ); DTRACE( trace_ctx, D_MOT_FIELD, "%d,%d:%d ", mi.mv[eListIdx].hor, mi.mv[eListIdx].ver, mi.refIdx[eListIdx] ); diff --git a/source/Lib/CommonLib/dtrace_codingstruct.h b/source/Lib/CommonLib/dtrace_codingstruct.h index 30b41397a..b5558f2c6 100644 --- a/source/Lib/CommonLib/dtrace_codingstruct.h +++ b/source/Lib/CommonLib/dtrace_codingstruct.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file dtrace_codingstruct.h * \brief Easy to use dtrace calls concerning coding structures */ @@ -102,8 +106,8 @@ inline void dtraceModeCost(CodingStructure &cs, double lambda) } bool isIntra = CU::isIntra( *cs.cus.front() ); - int intraModeL = isIntra ? cs.pus.front()->intraDir[0] : 0; - int intraModeC = isIntra ? cs.pus.front()->intraDir[1] : 0; + int intraModeL = isIntra ? cs.cus.front()->intraDir[0] : 0; + int intraModeC = isIntra ? cs.cus.front()->intraDir[1] : 0; if (isIntra && intraModeC == DM_CHROMA_IDX) intraModeC = 68; int imvVal = 0; @@ -117,7 +121,7 @@ inline void dtraceModeCost(CodingStructure &cs, double lambda) cs.cus[0]->qp, cs.cus[0]->predMode, cs.cus[0]->skip, - cs.pus[0]->mergeFlag, + cs.cus[0]->mergeFlag, 0, 0, imvVal, 0, 0, @@ -157,8 +161,8 @@ inline void dtraceBestMode(CodingStructure *&tempCS, CodingStructure *&bestCS, d } bool isIntra = CU::isIntra( *tempCS->cus[0] ); - int intraModeL = isIntra ? tempCS->pus[0]->intraDir[0] : 0; - int intraModeC = isIntra ? tempCS->pus[0]->intraDir[1] : 0; + int intraModeL = isIntra ? tempCS->cus[0]->intraDir[0] : 0; + int intraModeC = isIntra ? tempCS->cus[0]->intraDir[1] : 0; if(!bSplitCS) { @@ -170,7 +174,7 @@ inline void dtraceBestMode(CodingStructure *&tempCS, CodingStructure *&bestCS, d tempCS->cus[0]->qtDepth, tempCS->cus[0]->qp, tempCS->cus[0]->predMode, - tempCS->pus[0]->mergeFlag, + tempCS->cus[0]->mergeFlag, intraModeL, intraModeC, tempCost, tempBits, tempDist, bestCost, bestBits, bestCS->dist, diff --git a/source/Lib/CommonLib/dtrace_next.h b/source/Lib/CommonLib/dtrace_next.h index 49ca2b29f..4c6d1b596 100644 --- a/source/Lib/CommonLib/dtrace_next.h +++ b/source/Lib/CommonLib/dtrace_next.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file dtrace_next.h * \brief DTrace support for next software */ diff --git a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h index f65cfdae0..9ee04113a 100644 --- a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h +++ b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "CommonDefX86.h" #include "../AdaptiveLoopFilter.h" diff --git a/source/Lib/CommonLib/x86/AffineGradientSearchX86.h b/source/Lib/CommonLib/x86/AffineGradientSearchX86.h index b2286df23..abbec0785 100644 --- a/source/Lib/CommonLib/x86/AffineGradientSearchX86.h +++ b/source/Lib/CommonLib/x86/AffineGradientSearchX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** * \file * \brief Implementation of AffineGradientSearch class diff --git a/source/Lib/CommonLib/x86/BufferX86.h b/source/Lib/CommonLib/x86/BufferX86.h index bafd8d8f2..cd722cd7b 100644 --- a/source/Lib/CommonLib/x86/BufferX86.h +++ b/source/Lib/CommonLib/x86/BufferX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file YuvX86.cpp \brief SIMD averaging. */ @@ -1534,213 +1538,6 @@ void transposeNxN_SSE( const Pel* src, int srcStride, Pel* dst, int dstStride ) #endif } -template< X86_VEXT vext > -void applyPROF_SSE(Pel* dstPel, int dstStride, const Pel* srcPel, int srcStride, int width, int height, const Pel* gradX, const Pel* gradY, int gradStride, const int* dMvX, const int* dMvY, int dMvStride, const bool& bi, int shiftNum, Pel offset, const ClpRng& clpRng) -{ - CHECKD( width != 4 || height != 4, "block width error!"); - - const int dILimit = 1 << std::max(clpRng.bd + 1, 13); - -#if USE_AVX2 - __m256i mm_dmvx, mm_dmvy, mm_gradx, mm_grady, mm_dI, mm_dI0, mm_src; - __m256i mm_offset = _mm256_set1_epi16( offset ); - __m256i vibdimin = _mm256_set1_epi16( clpRng.min ); - __m256i vibdimax = _mm256_set1_epi16( clpRng.max ); - __m256i mm_dimin = _mm256_set1_epi32( -dILimit ); - __m256i mm_dimax = _mm256_set1_epi32( dILimit - 1 ); - - const int *vX0 = dMvX, *vY0 = dMvY; - const Pel *gX0 = gradX, *gY0 = gradY; - - // first two rows - mm_dmvx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vX0 ) ), _mm_loadu_si128( ( const __m128i * )( vX0 + dMvStride ) ), 1 ); - mm_dmvy = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vY0 ) ), _mm_loadu_si128( ( const __m128i * )( vY0 + dMvStride ) ), 1 ); - - mm_dmvx = _mm256_packs_epi32( mm_dmvx, _mm256_setzero_si256() ); - mm_dmvy = _mm256_packs_epi32( mm_dmvy, _mm256_setzero_si256() ); - - mm_gradx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gX0 ) ), _mm_loadl_epi64( ( __m128i* )( gX0 + gradStride ) ), 1 ); - mm_grady = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gY0 ) ), _mm_loadl_epi64( ( __m128i* )( gY0 + gradStride ) ), 1 ); - - mm_dI0 = _mm256_madd_epi16( _mm256_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm256_unpacklo_epi16( mm_gradx, mm_grady ) ); - mm_dI0 = _mm256_min_epi32( mm_dimax, _mm256_max_epi32( mm_dimin, mm_dI0 ) ); - - // next two rows - vX0 += ( dMvStride << 1 ); vY0 += ( dMvStride << 1 ); gX0 += ( gradStride << 1 ); gY0 += ( gradStride << 1 ); - - mm_dmvx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vX0 ) ), _mm_loadu_si128( ( const __m128i * )( vX0 + dMvStride ) ), 1 ); - mm_dmvy = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vY0 ) ), _mm_loadu_si128( ( const __m128i * )( vY0 + dMvStride ) ), 1 ); - - mm_dmvx = _mm256_packs_epi32( mm_dmvx, _mm256_setzero_si256() ); - mm_dmvy = _mm256_packs_epi32( mm_dmvy, _mm256_setzero_si256() ); - - mm_gradx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gX0 ) ), _mm_loadl_epi64( ( __m128i* )( gX0 + gradStride ) ), 1 ); - mm_grady = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gY0 ) ), _mm_loadl_epi64( ( __m128i* )( gY0 + gradStride ) ), 1 ); - - mm_dI = _mm256_madd_epi16( _mm256_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm256_unpacklo_epi16( mm_gradx, mm_grady ) ); - mm_dI = _mm256_min_epi32( mm_dimax, _mm256_max_epi32( mm_dimin, mm_dI ) ); - - // combine four rows - mm_dI = _mm256_packs_epi32( mm_dI0, mm_dI ); - const Pel* src0 = srcPel + srcStride; - mm_src = _mm256_inserti128_si256( - _mm256_castsi128_si256(_mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i *)srcPel), _mm_loadl_epi64((const __m128i *)(srcPel + (srcStride << 1))))), - _mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i *)src0), _mm_loadl_epi64((const __m128i *)(src0 + (srcStride << 1)))), - 1 - ); - mm_dI = _mm256_add_epi16(mm_dI, mm_src); - if (!bi) - { - mm_dI = _mm256_srai_epi16(_mm256_adds_epi16(mm_dI, mm_offset), shiftNum); - mm_dI = _mm256_min_epi16(vibdimax, _mm256_max_epi16(vibdimin, mm_dI)); - } - - // store final results - __m128i dITmp = _mm256_extractf128_si256(mm_dI, 1); - Pel* dst0 = dstPel; - _mm_storel_epi64((__m128i *)dst0, _mm256_castsi256_si128(mm_dI)); - dst0 += dstStride; _mm_storel_epi64((__m128i *)dst0, dITmp); - dst0 += dstStride; _mm_storel_epi64((__m128i *)dst0, _mm_unpackhi_epi64(_mm256_castsi256_si128(mm_dI), _mm256_castsi256_si128(mm_dI))); - dst0 += dstStride; _mm_storel_epi64((__m128i *)dst0, _mm_unpackhi_epi64(dITmp, dITmp)); -#else - __m128i mm_dmvx, mm_dmvy, mm_gradx, mm_grady, mm_dI, mm_dI0; - __m128i mm_offset = _mm_set1_epi16( offset ); - __m128i vibdimin = _mm_set1_epi16( clpRng.min ); - __m128i vibdimax = _mm_set1_epi16( clpRng.max ); - __m128i mm_dimin = _mm_set1_epi32( -dILimit ); - __m128i mm_dimax = _mm_set1_epi32( dILimit - 1 ); - - for( int h = 0; h < height; h += 2 ) - { - const int* vX = dMvX; - const int* vY = dMvY; - const Pel* gX = gradX; - const Pel* gY = gradY; - const Pel* src = srcPel; - Pel* dst = dstPel; - - // first row - mm_dmvx = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) vX ), _mm_setzero_si128() ); - mm_dmvy = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) vY ), _mm_setzero_si128() ); - mm_gradx = _mm_loadl_epi64( ( __m128i* ) gX ); - mm_grady = _mm_loadl_epi64( ( __m128i* ) gY ); - mm_dI0 = _mm_madd_epi16 ( _mm_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm_unpacklo_epi16( mm_gradx, mm_grady ) ); - mm_dI0 = _mm_min_epi32 ( mm_dimax, _mm_max_epi32( mm_dimin, mm_dI0 ) ); - - // second row - mm_dmvx = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) ( vX + dMvStride ) ), _mm_setzero_si128() ); - mm_dmvy = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) ( vY + dMvStride ) ), _mm_setzero_si128() ); - mm_gradx = _mm_loadl_epi64( ( __m128i* ) ( gX + gradStride ) ); - mm_grady = _mm_loadl_epi64( ( __m128i* ) ( gY + gradStride ) ); - mm_dI = _mm_madd_epi16 ( _mm_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm_unpacklo_epi16( mm_gradx, mm_grady ) ); - mm_dI = _mm_min_epi32 ( mm_dimax, _mm_max_epi32( mm_dimin, mm_dI ) ); - - // combine both rows - mm_dI = _mm_packs_epi32( mm_dI0, mm_dI ); - mm_dI = _mm_add_epi16 ( _mm_unpacklo_epi64( _mm_loadl_epi64( ( const __m128i * )src ), _mm_loadl_epi64( ( const __m128i * )( src + srcStride ) ) ), mm_dI ); - if (!bi) - { - mm_dI = _mm_srai_epi16(_mm_adds_epi16(mm_dI, mm_offset), shiftNum); - mm_dI = _mm_min_epi16(vibdimax, _mm_max_epi16(vibdimin, mm_dI)); - } - - _mm_storel_epi64( ( __m128i * ) dst, mm_dI ); - _mm_storel_epi64( ( __m128i * )( dst + dstStride ), _mm_unpackhi_epi64( mm_dI, mm_dI ) ); - - dMvX += (dMvStride << 1); - dMvY += (dMvStride << 1); - gradX += (gradStride << 1); - gradY += (gradStride << 1); - srcPel += (srcStride << 1); - dstPel += (dstStride << 1); - } -#endif -} - -template< X86_VEXT vext, bool PAD = true> -void gradFilter_SSE(const Pel* src, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth) //exist in InterPredX86 -{ - const Pel* srcTmp = src + srcStride + 1; - Pel* gradXTmp = gradX + gradStride + 1; - Pel* gradYTmp = gradY + gradStride + 1; - - int widthInside = width - 2 * BDOF_EXTEND_SIZE; - int heightInside = height - 2 * BDOF_EXTEND_SIZE; - int shift1 = std::max(6, bitDepth - 6); - __m128i mmShift1 = _mm_cvtsi32_si128(shift1); - assert((widthInside & 3) == 0); - - if ((widthInside & 7) == 0) - { - for (int y = 0; y < heightInside; y++) - { - int x = 0; - for (; x < widthInside; x += 8) - { - __m128i mmPixTop = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x - srcStride)), mmShift1); - __m128i mmPixBottom = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x + srcStride)), mmShift1); - __m128i mmPixLeft = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x - 1)), mmShift1); - __m128i mmPixRight = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x + 1)), mmShift1); - - __m128i mmGradVer = _mm_sub_epi16(mmPixBottom, mmPixTop); - __m128i mmGradHor = _mm_sub_epi16(mmPixRight, mmPixLeft); - - _mm_storeu_si128((__m128i *) (gradYTmp + x), mmGradVer); - _mm_storeu_si128((__m128i *) (gradXTmp + x), mmGradHor); - } - gradXTmp += gradStride; - gradYTmp += gradStride; - srcTmp += srcStride; - } - } - else - { - __m128i mmPixTop = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp - srcStride)), _mm_loadl_epi64((__m128i*) (srcTmp))), mmShift1); - for (int y = 0; y < heightInside; y += 2) - { - __m128i mmPixBottom = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp + srcStride)), _mm_loadl_epi64((__m128i*) (srcTmp + (srcStride << 1)))), mmShift1); - __m128i mmPixLeft = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp - 1)), _mm_loadl_epi64((__m128i*) (srcTmp - 1 + srcStride))), mmShift1); - __m128i mmPixRight = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp + 1)), _mm_loadl_epi64((__m128i*) (srcTmp + 1 + srcStride))), mmShift1); - - __m128i mmGradVer = _mm_sub_epi16(mmPixBottom, mmPixTop); - __m128i mmGradHor = _mm_sub_epi16(mmPixRight, mmPixLeft); - - _mm_storel_epi64((__m128i *) gradYTmp, mmGradVer); - _mm_storel_epi64((__m128i *) (gradYTmp + gradStride), _mm_unpackhi_epi64(mmGradVer, mmGradHor)); - _mm_storel_epi64((__m128i *) gradXTmp, mmGradHor); - _mm_storel_epi64((__m128i *) (gradXTmp + gradStride), _mm_unpackhi_epi64(mmGradHor, mmGradVer)); - - mmPixTop = mmPixBottom; - gradXTmp += gradStride << 1; - gradYTmp += gradStride << 1; - srcTmp += srcStride << 1; - } - } - - if (PAD) - { - gradXTmp = gradX + gradStride + 1; - gradYTmp = gradY + gradStride + 1; - for (int y = 0; y < heightInside; y++) - { - gradXTmp[-1] = gradXTmp[0]; - gradXTmp[widthInside] = gradXTmp[widthInside - 1]; - gradXTmp += gradStride; - - gradYTmp[-1] = gradYTmp[0]; - gradYTmp[widthInside] = gradYTmp[widthInside - 1]; - gradYTmp += gradStride; - } - - gradXTmp = gradX + gradStride; - gradYTmp = gradY + gradStride; - ::memcpy(gradXTmp - gradStride, gradXTmp, sizeof(Pel)*(width)); - ::memcpy(gradXTmp + heightInside*gradStride, gradXTmp + (heightInside - 1)*gradStride, sizeof(Pel)*(width)); - ::memcpy(gradYTmp - gradStride, gradYTmp, sizeof(Pel)*(width)); - ::memcpy(gradYTmp + heightInside*gradStride, gradYTmp + (heightInside - 1)*gradStride, sizeof(Pel)*(width)); - } -} - template void applyLut_SIMD( const Pel* src, const ptrdiff_t srcStride, Pel* dst, const ptrdiff_t dstStride, int width, int height, const Pel* lut ) { @@ -1885,8 +1682,6 @@ void PelBufferOps::_initPelBufOpsX86() transpose4x4 = transposeNxN_SSE; transpose8x8 = transposeNxN_SSE; - profGradFilter = gradFilter_SSE; - applyPROF = applyPROF_SSE; roundIntVector = roundIntVector_SIMD; mipMatrixMul_4_4 = mipMatrixMul_SSE; diff --git a/source/Lib/CommonLib/x86/CommonDefX86.cpp b/source/Lib/CommonLib/x86/CommonDefX86.cpp index 72e642c62..ec514b410 100644 --- a/source/Lib/CommonLib/x86/CommonDefX86.cpp +++ b/source/Lib/CommonLib/x86/CommonDefX86.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /* diff --git a/source/Lib/CommonLib/x86/CommonDefX86.h b/source/Lib/CommonLib/x86/CommonDefX86.h index 58e16c767..c75f81cf6 100644 --- a/source/Lib/CommonLib/x86/CommonDefX86.h +++ b/source/Lib/CommonLib/x86/CommonDefX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file CommonDefX86.h */ diff --git a/source/Lib/CommonLib/x86/InitX86.cpp b/source/Lib/CommonLib/x86/InitX86.cpp index 335ce522c..9b6a74880 100644 --- a/source/Lib/CommonLib/x86/InitX86.cpp +++ b/source/Lib/CommonLib/x86/InitX86.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /* @@ -346,8 +350,29 @@ void QuantRDOQ2::initQuantX86() default: break; } +} +void Quant::initQuantX86() +{ + auto vext = read_x86_extension_flags(); + switch (vext){ + case AVX512: + case AVX2: + _initQuantX86(); + break; + case AVX: + _initQuantX86(); + break; + case SSE42: + case SSE41: + _initQuantX86(); + break; + default: + break; + } } + + #endif } // namespace vvenc diff --git a/source/Lib/CommonLib/x86/InterPredX86.h b/source/Lib/CommonLib/x86/InterPredX86.h index 71a707792..bf706915a 100644 --- a/source/Lib/CommonLib/x86/InterPredX86.h +++ b/source/Lib/CommonLib/x86/InterPredX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file InterPredX86.h \brief SIMD for InterPrediction */ @@ -59,55 +63,28 @@ vvc@hhi.fraunhofer.de namespace vvenc { -#define _mm_storeu_si32(p, a) (void)(*(int*)(p) = _mm_cvtsi128_si32((a))) - -template< X86_VEXT vext > -void addBDOFAvg4_SSE(const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel*gradY1, int gradStride, int width, int height, int tmpx, int tmpy, unsigned shift, int offset, const ClpRng& clpRng) -{ -#if USE_AVX2 - if( vext >= AVX2 ) +#if _MSC_VER <= 1900 && !defined( _mm256_extract_epi32 ) + inline uint32_t _mm256_extract_epi32( __m256i vec, const int i ) { - __m256i mm_tmpx = _mm256_set1_epi32( ( tmpx & 0xffff ) | ( tmpy << 16 ) ); - __m256i mm_offset = _mm256_set1_epi32( offset ); - __m256i vibdimin = _mm256_set1_epi16( clpRng.min ); - __m256i vibdimax = _mm256_set1_epi16( clpRng.max ); - __m256i mm_a, mm_b, mm_c; - __m256i mm_sum; - - for( int y = 0; y < 4; y += 2, dst += 2 * dstStride, src0 += 2 * src0Stride, src1 += 2 * src0Stride, gradX0 += 2 * gradStride, gradX1 += 2 * gradStride, gradY0 += 2 * gradStride, gradY1 += 2 * gradStride ) - { - mm_a = _mm256_castsi128_si256 ( _mm_loadl_epi64( (const __m128i *) gradX0 ) ); - mm_a = _mm256_inserti128_si256( mm_a, _mm_loadl_epi64( (const __m128i *) ( gradX0 + gradStride ) ), 1 ); - mm_b = _mm256_castsi128_si256 ( _mm_loadl_epi64( (const __m128i *) gradY0 ) ); - mm_b = _mm256_inserti128_si256( mm_b, _mm_loadl_epi64( (const __m128i *) ( gradY0 + gradStride ) ), 1 ); - - mm_a = _mm256_unpacklo_epi16 ( mm_a, mm_b ); - - mm_c = _mm256_castsi128_si256 ( _mm_loadl_epi64( (const __m128i *) gradX1 ) ); - mm_c = _mm256_inserti128_si256( mm_c, _mm_loadl_epi64( (const __m128i *) ( gradX1 + gradStride ) ), 1 ); - mm_b = _mm256_castsi128_si256 ( _mm_loadl_epi64( (const __m128i *) gradY1 ) ); - mm_b = _mm256_inserti128_si256( mm_b, _mm_loadl_epi64( (const __m128i *) ( gradY1 + gradStride ) ), 1 ); - - mm_b = _mm256_unpacklo_epi16 ( mm_c, mm_b ); - - mm_a = _mm256_sub_epi16 ( mm_a, mm_b ); - mm_sum = _mm256_madd_epi16 ( mm_a, mm_tmpx ); - mm_a = _mm256_cvtepi16_epi32 ( _mm_loadl_epi64( (const __m128i *) ( src0 ) ) ); - mm_a = _mm256_inserti128_si256( mm_a, _mm_cvtepi16_epi32( _mm_loadl_epi64( (const __m128i *) ( src0 + src0Stride ) ) ), 1 ); - mm_b = _mm256_cvtepi16_epi32 ( _mm_loadl_epi64( (const __m128i *) ( src1 ) ) ); - mm_b = _mm256_inserti128_si256( mm_b, _mm_cvtepi16_epi32( _mm_loadl_epi64( (const __m128i *) ( src1 + src1Stride ) ) ), 1 ); - mm_sum = _mm256_add_epi32 ( _mm256_add_epi32( mm_sum, mm_a ), _mm256_add_epi32( mm_b, mm_offset ) ); - mm_sum = _mm256_packs_epi32 ( _mm256_srai_epi32( mm_sum, shift ), mm_a ); - mm_sum = _mm256_min_epi16 ( vibdimax, _mm256_max_epi16( vibdimin, mm_sum ) ); - - _mm_storel_epi64 ( (__m128i *) dst, _mm256_castsi256_si128 ( mm_sum ) ); - _mm_storel_epi64 ( (__m128i *) ( dst + dstStride ), _mm256_extracti128_si256( mm_sum, 1 ) ); - } - + __m128i indx = _mm_cvtsi32_si128( i ); + __m256i val = _mm256_permutevar8x32_epi32( vec, _mm256_castsi128_si256( indx ) ); + return _mm_cvtsi128_si32( _mm256_castsi256_si128( val ) ); } - else - { #endif + +static inline int rightShiftMSB(int numer, int denom) +{ + int shiftIdx = _bit_scan_reverse(denom); + return (numer >> shiftIdx); +} + +template +static inline void addBIOAvg4_SSE(const int16_t* src0, const int16_t* src1, int16_t* dst, ptrdiff_t dstStride, const int16_t* gradX0, const int16_t* gradX1, const int16_t* gradY0, const int16_t* gradY1, ptrdiff_t widthG, int tmpx, int tmpy, int shift, int offset, const ClpRng& clpRng) +{ + const ptrdiff_t src0Stride = widthG + 2; + const ptrdiff_t src1Stride = widthG + 2; + const ptrdiff_t gradStride = widthG; + __m128i mm_tmpx = _mm_set1_epi32( ( tmpx & 0xffff ) | ( tmpy << 16 ) ); __m128i mm_offset = _mm_set1_epi32( offset ); __m128i vibdimin = _mm_set1_epi16( clpRng.min ); @@ -124,69 +101,336 @@ void addBDOFAvg4_SSE(const Pel* src0, int src0Stride, const Pel* src1, int src1S mm_sum = _mm_madd_epi16 ( mm_a, mm_tmpx ); mm_a = _mm_cvtepi16_epi32 ( _mm_loadl_epi64( (const __m128i *) ( src0 ) ) ); mm_b = _mm_cvtepi16_epi32 ( _mm_loadl_epi64( (const __m128i *) ( src1 ) ) ); - //mm_sum = _mm_srai_epi32 ( _mm_add_epi32( mm_sum, mm_boffset ), 1 ); mm_sum = _mm_add_epi32 ( _mm_add_epi32( mm_sum, mm_a ), _mm_add_epi32( mm_b, mm_offset ) ); mm_sum = _mm_packs_epi32 ( _mm_srai_epi32( mm_sum, shift ), mm_a ); mm_sum = _mm_min_epi16 ( vibdimax, _mm_max_epi16( vibdimin, mm_sum ) ); _mm_storel_epi64 ( (__m128i *) dst, mm_sum ); } +} + #if USE_AVX2 +static inline void addBIOAvg4_2x_AVX2(const int16_t* src0, const int16_t* src1, int16_t* dst, ptrdiff_t dstStride, const int16_t* gradX0, const int16_t* gradX1, const int16_t* gradY0, const int16_t* gradY1, ptrdiff_t widthG, int tmpx0, int tmpx1, int tmpy0, int tmpy1, int shift, int offset, const ClpRng& clpRng) +{ + const ptrdiff_t src0Stride = widthG + 2; + const ptrdiff_t src1Stride = widthG + 2; + const ptrdiff_t gradStride = widthG; + + __m256i mm_tmpx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_set1_epi32( ( tmpx0 & 0xffff ) | ( tmpy0 << 16 ) ) ), _mm_set1_epi32( ( tmpx1 & 0xffff ) | ( tmpy1 << 16 ) ), 1 ); + __m256i mm_offset = _mm256_set1_epi32( offset ); + __m256i vibdimin = _mm256_set1_epi32( clpRng.min ); + __m256i vibdimax = _mm256_set1_epi32( clpRng.max ); + __m256i mm_a; + __m256i mm_b; + __m256i mm_sum; + __m128i xsrc0, xsrc1; + + for( int y = 0; y < 4; y++, dst += dstStride, src0 += src0Stride, src1 += src1Stride, gradX0 += gradStride, gradX1 += gradStride, gradY0 += gradStride, gradY1 += gradStride ) + { + xsrc0 = _mm_loadu_si128 ( ( const __m128i * ) gradX0 ); + xsrc1 = _mm_loadu_si128 ( ( const __m128i * ) gradY0 ); + mm_a = _mm256_castsi128_si256( _mm_unpacklo_epi16( xsrc0, xsrc1 ) ); + mm_a = _mm256_inserti128_si256( mm_a, _mm_unpackhi_epi16( xsrc0, xsrc1 ), 1 ); + xsrc0 = _mm_loadu_si128 ( ( const __m128i * ) gradX1 ); + xsrc1 = _mm_loadu_si128 ( ( const __m128i * ) gradY1 ); + mm_b = _mm256_castsi128_si256( _mm_unpacklo_epi16( xsrc0, xsrc1 ) ); + mm_b = _mm256_inserti128_si256( mm_b, _mm_unpackhi_epi16( xsrc0, xsrc1 ), 1 ); + mm_a = _mm256_sub_epi16 ( mm_a, mm_b ); + mm_sum = _mm256_madd_epi16 ( mm_a, mm_tmpx ); + mm_a = _mm256_cvtepi16_epi32 ( _mm_loadu_si128( (const __m128i *) ( src0 ) ) ); + mm_b = _mm256_cvtepi16_epi32 ( _mm_loadu_si128( (const __m128i *) ( src1 ) ) ); + mm_sum = _mm256_add_epi32 ( _mm256_add_epi32( mm_sum, mm_a ), _mm256_add_epi32( mm_b, mm_offset ) ); + mm_sum = _mm256_srai_epi32 ( mm_sum, shift ); + mm_sum = _mm256_min_epi32 ( vibdimax, _mm256_max_epi32( vibdimin, mm_sum ) ); + _mm_storeu_si128 ( (__m128i *) dst, _mm256_cvtepi32_epi16x( mm_sum ) ); } -#endif } +#endif template< X86_VEXT vext > -void calcBDOFSums_SSE(const Pel* srcY0Tmp, const Pel* srcY1Tmp, Pel* gradX0, Pel* gradX1, Pel* gradY0, Pel* gradY1, int xu, int yu, const int src0Stride, const int src1Stride, const int widthG, const int bitDepth, int* sumAbsGX, int* sumAbsGY, int* sumDIX, int* sumDIY, int* sumSignGY_GX) - +static inline void calcBIOSums_SSE(const Pel* srcY0Tmp, const Pel* srcY1Tmp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, const int widthG, const int bitDepth, int limit, int &tmpx, int &tmpy) { - int shift4 = 4; - int shift5 = 1; - - __m128i sumAbsGXTmp = _mm_setzero_si128(); - __m128i sumDIXTmp = _mm_setzero_si128(); - __m128i sumAbsGYTmp = _mm_setzero_si128(); - __m128i sumDIYTmp = _mm_setzero_si128(); + static constexpr int shift4 = 4; + static constexpr int shift5 = 1; + const int srcStride = widthG + 2; + + __m128i sumAbsGXTmp = _mm_setzero_si128(); + __m128i sumDIXTmp = _mm_setzero_si128(); + __m128i sumAbsGYTmp = _mm_setzero_si128(); + __m128i sumDIYTmp = _mm_setzero_si128(); __m128i sumSignGyGxTmp = _mm_setzero_si128(); - Pel tmpStore[8]; + for (int y = 0; y < 6; y++) { __m128i shiftSrcY0Tmp = _mm_srai_epi16(_mm_loadu_si128((__m128i*)(srcY0Tmp)), shift4); __m128i shiftSrcY1Tmp = _mm_srai_epi16(_mm_loadu_si128((__m128i*)(srcY1Tmp)), shift4); - __m128i loadGradX0 = _mm_loadu_si128((__m128i*)(gradX0)); - __m128i loadGradX1 = _mm_loadu_si128((__m128i*)(gradX1)); - __m128i loadGradY0 = _mm_loadu_si128((__m128i*)(gradY0)); - __m128i loadGradY1 = _mm_loadu_si128((__m128i*)(gradY1)); - __m128i subTemp1 = _mm_sub_epi16(shiftSrcY1Tmp, shiftSrcY0Tmp); - __m128i packTempX = _mm_srai_epi16(_mm_add_epi16(loadGradX0, loadGradX1), shift5); - __m128i packTempY = _mm_srai_epi16(_mm_add_epi16(loadGradY0, loadGradY1), shift5); - __m128i gX = _mm_abs_epi16(packTempX); - __m128i gY = _mm_abs_epi16(packTempY); - __m128i dIX = _mm_sign_epi16(subTemp1, packTempX ); - __m128i dIY = _mm_sign_epi16(subTemp1, packTempY ); - __m128i signGY_GX = _mm_sign_epi16(packTempX, packTempY ); - - sumAbsGXTmp = _mm_add_epi16(sumAbsGXTmp, gX); - sumDIXTmp = _mm_add_epi16(sumDIXTmp, dIX); - sumAbsGYTmp = _mm_add_epi16(sumAbsGYTmp, gY); - sumDIYTmp = _mm_add_epi16(sumDIYTmp, dIY); - sumSignGyGxTmp = _mm_add_epi16(sumSignGyGxTmp, signGY_GX); - srcY0Tmp += src0Stride; - srcY1Tmp += src1Stride; + __m128i loadGradX0 = _mm_loadu_si128((__m128i*)(gradX0)); + __m128i loadGradX1 = _mm_loadu_si128((__m128i*)(gradX1)); + __m128i loadGradY0 = _mm_loadu_si128((__m128i*)(gradY0)); + __m128i loadGradY1 = _mm_loadu_si128((__m128i*)(gradY1)); + __m128i subTemp1 = _mm_sub_epi16(shiftSrcY1Tmp, shiftSrcY0Tmp); + __m128i packTempX = _mm_srai_epi16(_mm_add_epi16(loadGradX0, loadGradX1), shift5); + __m128i packTempY = _mm_srai_epi16(_mm_add_epi16(loadGradY0, loadGradY1), shift5); + __m128i gX = _mm_abs_epi16(packTempX); + __m128i gY = _mm_abs_epi16(packTempY); + __m128i dIX = _mm_sign_epi16(subTemp1, packTempX); + __m128i dIY = _mm_sign_epi16(subTemp1, packTempY); + __m128i signGY_GX = _mm_sign_epi16(packTempX, packTempY); + + sumAbsGXTmp = _mm_add_epi16(sumAbsGXTmp, gX); + sumDIXTmp = _mm_add_epi16(sumDIXTmp, dIX); + sumAbsGYTmp = _mm_add_epi16(sumAbsGYTmp, gY); + sumDIYTmp = _mm_add_epi16(sumDIYTmp, dIY); + sumSignGyGxTmp = _mm_add_epi16(sumSignGyGxTmp, signGY_GX); + + srcY0Tmp += srcStride; + srcY1Tmp += srcStride; gradX0 += widthG; gradX1 += widthG; gradY0 += widthG; gradY1 += widthG; } - _mm_storeu_si128((__m128i *)tmpStore, sumAbsGXTmp); - *sumAbsGX = tmpStore[0] + tmpStore[1] + tmpStore[2] + tmpStore[3] + tmpStore[4] + tmpStore[5]; - _mm_storeu_si128((__m128i *)tmpStore, sumAbsGYTmp); - *sumAbsGY = tmpStore[0] + tmpStore[1] + tmpStore[2] + tmpStore[3] + tmpStore[4] + tmpStore[5]; - _mm_storeu_si128((__m128i *)tmpStore, sumDIXTmp); - *sumDIX = tmpStore[0] + tmpStore[1] + tmpStore[2] + tmpStore[3] + tmpStore[4] + tmpStore[5]; - _mm_storeu_si128((__m128i *)tmpStore, sumDIYTmp); - *sumDIY = tmpStore[0] + tmpStore[1] + tmpStore[2] + tmpStore[3] + tmpStore[4] + tmpStore[5]; - _mm_storeu_si128((__m128i *)tmpStore, sumSignGyGxTmp); - *sumSignGY_GX = tmpStore[0] + tmpStore[1] + tmpStore[2] + tmpStore[3] + tmpStore[4] + tmpStore[5]; + + sumAbsGXTmp = _mm_madd_epi16(sumAbsGXTmp, _mm_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0)); + sumDIXTmp = _mm_madd_epi16(sumDIXTmp, _mm_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0)); + sumAbsGYTmp = _mm_madd_epi16(sumAbsGYTmp, _mm_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0)); + sumDIYTmp = _mm_madd_epi16(sumDIYTmp, _mm_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0)); + sumSignGyGxTmp = _mm_madd_epi16(sumSignGyGxTmp, _mm_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0)); + + __m128i a12 = _mm_unpacklo_epi32(sumAbsGXTmp, sumAbsGYTmp); + __m128i a3 = _mm_unpackhi_epi32(sumAbsGXTmp, sumAbsGYTmp); + __m128i b12 = _mm_unpacklo_epi32(sumDIXTmp, sumDIYTmp); + __m128i b3 = _mm_unpackhi_epi32(sumDIXTmp, sumDIYTmp); + __m128i c1 = _mm_unpacklo_epi64(a12, b12); + __m128i c2 = _mm_unpackhi_epi64(a12, b12); + __m128i c3 = _mm_unpacklo_epi64(a3, b3); + + c1 = _mm_add_epi32(c1, c2); + c1 = _mm_add_epi32(c1, c3); + + int sumAbsGX = _mm_cvtsi128_si32(c1); + int sumAbsGY = _mm_cvtsi128_si32(_mm_shuffle_epi32(c1, 0x55)); + int sumDIX = _mm_cvtsi128_si32(_mm_shuffle_epi32(c1, 0xaa)); + int sumDIY = _mm_cvtsi128_si32(_mm_shuffle_epi32(c1, 0xff)); + + sumSignGyGxTmp = _mm_add_epi32(sumSignGyGxTmp, _mm_shuffle_epi32(sumSignGyGxTmp, 0x4e)); // 01001110 + sumSignGyGxTmp = _mm_add_epi32(sumSignGyGxTmp, _mm_shuffle_epi32(sumSignGyGxTmp, 0xb1)); // 10110001 + int sumSignGY_GX = _mm_cvtsi128_si32(sumSignGyGxTmp); + + tmpx = sumAbsGX == 0 ? 0 : rightShiftMSB( sumDIX << 2, sumAbsGX ); + tmpx = Clip3( -limit, limit, tmpx ); + + int mainsGxGy = sumSignGY_GX >> 12; + int secsGxGy = sumSignGY_GX & ( ( 1 << 12 ) - 1 ); + int tmpData = tmpx * mainsGxGy; + tmpData = ( ( tmpData << 12 ) + tmpx * secsGxGy ) >> 1; + tmpy = sumAbsGY == 0 ? 0 : rightShiftMSB( ( ( sumDIY << 2 ) - tmpData ), sumAbsGY ); + tmpy = Clip3( -limit, limit, tmpy ); +} + +#if USE_AVX2 +static inline void calcBIOSums2x_AVX2(const Pel* srcY0Tmp, const Pel* srcY1Tmp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, const int widthG, const int bitDepth, int limit, int &tmpx0, int &tmpx1, int &tmpy0, int &tmpy1 ) +{ + static constexpr int shift4 = 4; + static constexpr int shift5 = 1; + const int srcStride = widthG + 2; + + __m256i sumAbsGXTmp = _mm256_setzero_si256(); + __m256i sumDIXTmp = _mm256_setzero_si256(); + __m256i sumAbsGYTmp = _mm256_setzero_si256(); + __m256i sumDIYTmp = _mm256_setzero_si256(); + __m256i sumSignGyGxTmp = _mm256_setzero_si256(); + +#define _mm256_load2_si128_offset4(addr) _mm256_inserti128_si256( _mm256_castsi128_si256(_mm_loadu_si128((const __m128i*) &addr[0])), _mm_loadu_si128((const __m128i*) &addr[4]), 1 ) + + for (int y = 0; y < 6; y++) + { + __m256i shiftSrcY0Tmp = _mm256_srai_epi16(_mm256_load2_si128_offset4(srcY0Tmp), shift4); + __m256i shiftSrcY1Tmp = _mm256_srai_epi16(_mm256_load2_si128_offset4(srcY1Tmp), shift4); + __m256i loadGradX0 = _mm256_load2_si128_offset4(gradX0); + __m256i loadGradX1 = _mm256_load2_si128_offset4(gradX1); + __m256i loadGradY0 = _mm256_load2_si128_offset4(gradY0); + __m256i loadGradY1 = _mm256_load2_si128_offset4(gradY1); + __m256i subTemp1 = _mm256_sub_epi16(shiftSrcY1Tmp, shiftSrcY0Tmp); + __m256i packTempX = _mm256_srai_epi16(_mm256_add_epi16(loadGradX0, loadGradX1), shift5); + __m256i packTempY = _mm256_srai_epi16(_mm256_add_epi16(loadGradY0, loadGradY1), shift5); + __m256i gX = _mm256_abs_epi16(packTempX); + __m256i gY = _mm256_abs_epi16(packTempY); + __m256i dIX = _mm256_sign_epi16(subTemp1, packTempX ); + __m256i dIY = _mm256_sign_epi16(subTemp1, packTempY ); + __m256i signGY_GX = _mm256_sign_epi16(packTempX, packTempY ); + + sumAbsGXTmp = _mm256_add_epi16(sumAbsGXTmp, gX); + sumDIXTmp = _mm256_add_epi16(sumDIXTmp, dIX); + sumAbsGYTmp = _mm256_add_epi16(sumAbsGYTmp, gY); + sumDIYTmp = _mm256_add_epi16(sumDIYTmp, dIY); + sumSignGyGxTmp = _mm256_add_epi16(sumSignGyGxTmp, signGY_GX); + + srcY0Tmp += srcStride; + srcY1Tmp += srcStride; + gradX0 += widthG; + gradX1 += widthG; + gradY0 += widthG; + gradY1 += widthG; + } + +#undef _mm256_load2_si128_offset4 + + sumAbsGXTmp = _mm256_madd_epi16(sumAbsGXTmp, _mm256_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0)); + sumDIXTmp = _mm256_madd_epi16(sumDIXTmp, _mm256_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0)); + sumAbsGYTmp = _mm256_madd_epi16(sumAbsGYTmp, _mm256_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0)); + sumDIYTmp = _mm256_madd_epi16(sumDIYTmp, _mm256_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0)); + sumSignGyGxTmp = _mm256_madd_epi16(sumSignGyGxTmp, _mm256_setr_epi16(1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0)); + + __m256i a12 = _mm256_unpacklo_epi32(sumAbsGXTmp, sumAbsGYTmp); + __m256i a3 = _mm256_unpackhi_epi32(sumAbsGXTmp, sumAbsGYTmp); + __m256i b12 = _mm256_unpacklo_epi32(sumDIXTmp, sumDIYTmp); + __m256i b3 = _mm256_unpackhi_epi32(sumDIXTmp, sumDIYTmp); + __m256i c1 = _mm256_unpacklo_epi64(a12, b12); + __m256i c2 = _mm256_unpackhi_epi64(a12, b12); + __m256i c3 = _mm256_unpacklo_epi64(a3, b3); + + c1 = _mm256_add_epi32(c1, c2); + c1 = _mm256_add_epi32(c1, c3); + + int tmpData[8]; + + _mm256_storeu_si256( ( __m256i* ) &tmpData[0], c1 ); + + #define sumAbsGX0 tmpData[0] + #define sumAbsGX1 tmpData[4] + + #define sumAbsGY0 tmpData[1] + #define sumAbsGY1 tmpData[5] + + #define sumDIX0 tmpData[2] + #define sumDIX1 tmpData[6] + + #define sumDIY0 tmpData[3] + #define sumDIY1 tmpData[7] + + sumSignGyGxTmp = _mm256_add_epi32(sumSignGyGxTmp, _mm256_shuffle_epi32(sumSignGyGxTmp, 0x4e)); // 01001110 + sumSignGyGxTmp = _mm256_add_epi32(sumSignGyGxTmp, _mm256_shuffle_epi32(sumSignGyGxTmp, 0xb1)); // 10110001 + + int sumSignGY_GX0 = _mm256_extract_epi32( sumSignGyGxTmp, 0 ); + int sumSignGY_GX1 = _mm256_extract_epi32( sumSignGyGxTmp, 4 ); + +#if 0 + tmpx0 = sumAbsGX0 == 0 ? 0 : Clip3( -limit, limit, rightShiftMSB( sumDIX0 << 2, sumAbsGX0 ) ); + tmpx1 = sumAbsGX1 == 0 ? 0 : Clip3( -limit, limit, rightShiftMSB( sumDIX1 << 2, sumAbsGX1 ) ); + __m128i vtmpx = _mm_setr_epi32 ( tmpx0, tmpx1, 0, 0 ); + __m128i vsumSignGY_GX = _mm_setr_epi32 ( sumSignGY_GX0, sumSignGY_GX1, 0, 0 ); + __m128i vmainsGxGy = _mm_srai_epi32 ( vsumSignGY_GX, 12 ); + __m128i vsecsGxGy = _mm_and_si128 ( vsumSignGY_GX, _mm_set1_epi32( ( 1 << 12 ) - 1 ) ); + __m128i vtmpData = _mm_mullo_epi32( vtmpx, vmainsGxGy ); + vtmpData = _mm_slli_epi32 ( vtmpData, 12 ); + vtmpData = _mm_add_epi32 ( vtmpData, _mm_mullo_epi32( vtmpx, vsecsGxGy ) ); + vtmpData = _mm_srai_epi32 ( vtmpData, 1 ); + __m128i vtmpyIn = _mm_slli_epi32 ( _mm_setr_epi32( sumDIY0, sumDIY1, 0, 0 ), 2 ); + vtmpyIn = _mm_sub_epi32 ( vtmpyIn, vtmpData ); + + tmpy0 = sumAbsGY0 == 0 ? 0 : Clip3( -limit, limit, rightShiftMSB( _mm_extract_epi32( vtmpyIn, 0 ), sumAbsGY0 ) ); + tmpy1 = sumAbsGY1 == 0 ? 0 : Clip3( -limit, limit, rightShiftMSB( _mm_extract_epi32( vtmpyIn, 1 ), sumAbsGY1 ) ); +#else + tmpx0 = sumAbsGX0 == 0 ? 0 : rightShiftMSB( sumDIX0 << 2, sumAbsGX0 ); + tmpx0 = Clip3( -limit, limit, tmpx0 ); + + int mainsGxGy0 = sumSignGY_GX0 >> 12; + int secsGxGy0 = sumSignGY_GX0 & ( ( 1 << 12 ) - 1 ); + int tmpData0 = tmpx0 * mainsGxGy0; + tmpData0 = ( ( tmpData0 << 12 ) + tmpx0 * secsGxGy0 ) >> 1; + tmpy0 = sumAbsGY0 == 0 ? 0 : rightShiftMSB( ( ( sumDIY0 << 2 ) - tmpData0 ), sumAbsGY0 ); + tmpy0 = Clip3( -limit, limit, tmpy0 ); + + + tmpx1 = sumAbsGX1 == 0 ? 0 : rightShiftMSB( sumDIX1 << 2, sumAbsGX1 ); + tmpx1 = Clip3( -limit, limit, tmpx1 ); + + int mainsGxGy1 = sumSignGY_GX1 >> 12; + int secsGxGy1 = sumSignGY_GX1 & ( ( 1 << 12 ) - 1 ); + int tmpData1 = tmpx1 * mainsGxGy1; + tmpData1 = ( ( tmpData1 << 12 ) + tmpx1 * secsGxGy1 ) >> 1; + tmpy1 = sumAbsGY1 == 0 ? 0 : rightShiftMSB( ( ( sumDIY1 << 2 ) - tmpData1 ), sumAbsGY1 ); + tmpy1 = Clip3( -limit, limit, tmpy1 ); +#endif + +#undef sumAbsGX0 +#undef sumAbsGX1 +#undef sumAbsGY0 +#undef sumAbsGY1 +#undef sumDIX0 +#undef sumDIX1 +#undef sumDIY0 +#undef sumDIY1 +} +#endif + +template< X86_VEXT vext> +void BiOptFlowCoreSIMD( const Pel* srcY0, + const Pel* srcY1, + const Pel* gradX0, + const Pel* gradX1, + const Pel* gradY0, + const Pel* gradY1, + const int width, + const int height, + Pel* dstY, + const ptrdiff_t dstStride, + const int shiftNum, + const int offset, + const int limit, + const ClpRng& clpRng, + const int bitDepth ) +{ + const int widthG = width + 2 * BDOF_EXTEND_SIZE; + const int stridePredMC = widthG + 2; + int offsetPos = widthG * BDOF_EXTEND_SIZE + BDOF_EXTEND_SIZE; + const int xUnit = ( width >> 2 ); + const int yUnit = ( height >> 2 ); + + const Pel* srcY0Temp; + const Pel* srcY1Temp; + Pel *dstY0; + + int OffPos; + int OffPad = 0; + + for( int yu = 0; yu < yUnit; yu++, srcY0 += ( stridePredMC << 2 ), srcY1 += ( stridePredMC << 2 ), dstY += ( dstStride << 2 ), offsetPos += ( widthG << 2 ) ) + { + srcY0Temp = srcY0; + srcY1Temp = srcY1; + dstY0 = dstY; + + OffPos = offsetPos; + OffPad = ( ( yu * widthG ) << 2 ); + +#if USE_AVX2 + for( int xu = 0; xu < xUnit; xu += 2, srcY0Temp += 8, srcY1Temp += 8, dstY0 += 8, OffPos += 8, OffPad += 8 ) + { + int tmpx0, tmpy0, tmpx1, tmpy1; + + //calcBIOSums_SSE( srcY0Temp + 0, srcY1Temp + 0, gradX0 + OffPad + 0, gradX1 + OffPad + 0, gradY0 + OffPad + 0, gradY1 + OffPad + 0, stridePredMC, bitDepth, limit, tmpx, tmpy ); + //calcBIOSums_SSE( srcY0Temp + 0, srcY1Temp + 0, gradX0 + OffPad + 0, gradX1 + OffPad + 0, gradY0 + OffPad + 0, gradY1 + OffPad + 0, stridePredMC, bitDepth, limit, tmpx, tmpy ); + calcBIOSums2x_AVX2( srcY0Temp, srcY1Temp, gradX0 + OffPad, gradX1 + OffPad, gradY0 + OffPad, gradY1 + OffPad, widthG, bitDepth, limit, tmpx0, tmpx1, tmpy0, tmpy1 ); + + //addBIOAvg4_SSE( srcY0Temp + stridePredMC + 1 + 0, srcY1Temp + stridePredMC + 1 + 0, dstY0 + 0, dstStride, gradX0 + OffPos + 0, gradX1 + OffPos + 0, gradY0 + OffPos + 0, gradY1 + OffPos + 0, widthG, tmpx0, tmpy0, shiftNum, offset, clpRng ); + //addBIOAvg4_SSE( srcY0Temp + stridePredMC + 1 + 4, srcY1Temp + stridePredMC + 1 + 4, dstY0 + 4, dstStride, gradX0 + OffPos + 4, gradX1 + OffPos + 4, gradY0 + OffPos + 4, gradY1 + OffPos + 4, widthG, tmpx1, tmpy1, shiftNum, offset, clpRng ); + addBIOAvg4_2x_AVX2( srcY0Temp + stridePredMC + 1, srcY1Temp + stridePredMC + 1, dstY0, dstStride, gradX0 + OffPos, gradX1 + OffPos, gradY0 + OffPos, gradY1 + OffPos, widthG, tmpx0, tmpx1, tmpy0, tmpy1, shiftNum, offset, clpRng ); + } // xu +#else + for( int xu = 0; xu < xUnit; xu++, srcY0Temp += 4, srcY1Temp += 4, dstY0 += 4, OffPos += 4, OffPad += 4 ) + { + int tmpx, tmpy; + + calcBIOSums_SSE( srcY0Temp, srcY1Temp, gradX0 + OffPad, gradX1 + OffPad, gradY0 + OffPad, gradY1 + OffPad, widthG, bitDepth, limit, tmpx, tmpy ); + + addBIOAvg4_SSE ( srcY0Temp + stridePredMC + 1, srcY1Temp + stridePredMC + 1, dstY0, dstStride, gradX0 + OffPos, gradX1 + OffPos, gradY0 + OffPos, gradY1 + OffPos, widthG, tmpx, tmpy, shiftNum, offset, clpRng ); + } // xu +#endif + } // yu +#if USE_AVX2 + + _mm256_zeroupper(); +#endif } template< X86_VEXT vext, bool PAD = true> @@ -199,26 +443,26 @@ void gradFilter_SSE(const Pel* src, int srcStride, int width, int height, int gr int widthInside = width - 2 * BDOF_EXTEND_SIZE; int heightInside = height - 2 * BDOF_EXTEND_SIZE; int shift1 = 6; - __m128i mmShift1 = _mm_cvtsi32_si128( shift1 ); + __m128i mmShift1 = _mm_cvtsi32_si128(shift1); assert((widthInside & 3) == 0); - if ( ( widthInside & 7 ) == 0 ) + if ((widthInside & 7) == 0) { for (int y = 0; y < heightInside; y++) { int x = 0; - for ( ; x < widthInside; x += 8 ) + for (; x < widthInside; x += 8) { - __m128i mmPixTop = _mm_sra_epi16( _mm_loadu_si128( ( __m128i* ) ( srcTmp + x - srcStride ) ), mmShift1 ); - __m128i mmPixBottom = _mm_sra_epi16( _mm_loadu_si128( ( __m128i* ) ( srcTmp + x + srcStride ) ), mmShift1 ); - __m128i mmPixLeft = _mm_sra_epi16( _mm_loadu_si128( ( __m128i* ) ( srcTmp + x - 1 ) ), mmShift1 ); - __m128i mmPixRight = _mm_sra_epi16( _mm_loadu_si128( ( __m128i* ) ( srcTmp + x + 1 ) ), mmShift1 ); + __m128i mmPixTop = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x - srcStride)), mmShift1); + __m128i mmPixBottom = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x + srcStride)), mmShift1); + __m128i mmPixLeft = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x - 1)), mmShift1); + __m128i mmPixRight = _mm_sra_epi16(_mm_loadu_si128((__m128i*) (srcTmp + x + 1)), mmShift1); - __m128i mmGradVer = _mm_sub_epi16( mmPixBottom, mmPixTop ); - __m128i mmGradHor = _mm_sub_epi16( mmPixRight, mmPixLeft ); + __m128i mmGradVer = _mm_sub_epi16(mmPixBottom, mmPixTop); + __m128i mmGradHor = _mm_sub_epi16(mmPixRight, mmPixLeft); - _mm_storeu_si128( ( __m128i * ) ( gradYTmp + x ), mmGradVer ); - _mm_storeu_si128( ( __m128i * ) ( gradXTmp + x ), mmGradHor ); + _mm_storeu_si128((__m128i*) (gradYTmp + x), mmGradVer); + _mm_storeu_si128((__m128i*) (gradXTmp + x), mmGradHor); } gradXTmp += gradStride; @@ -228,25 +472,25 @@ void gradFilter_SSE(const Pel* src, int srcStride, int width, int height, int gr } else { - __m128i mmPixTop = _mm_sra_epi16( _mm_unpacklo_epi64( _mm_loadl_epi64( (__m128i*) ( srcTmp - srcStride ) ), _mm_loadl_epi64( (__m128i*) ( srcTmp ) ) ), mmShift1 ); - for ( int y = 0; y < heightInside; y += 2 ) + __m128i mmPixTop = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp - srcStride)), _mm_loadl_epi64((__m128i*) (srcTmp))), mmShift1); + for (int y = 0; y < heightInside; y += 2) { - __m128i mmPixBottom = _mm_sra_epi16( _mm_unpacklo_epi64( _mm_loadl_epi64( (__m128i*) ( srcTmp + srcStride ) ), _mm_loadl_epi64( (__m128i*) ( srcTmp + ( srcStride << 1 ) ) ) ), mmShift1 ); - __m128i mmPixLeft = _mm_sra_epi16( _mm_unpacklo_epi64( _mm_loadl_epi64( (__m128i*) ( srcTmp - 1 ) ), _mm_loadl_epi64( (__m128i*) ( srcTmp - 1 + srcStride ) ) ), mmShift1 ); - __m128i mmPixRight = _mm_sra_epi16( _mm_unpacklo_epi64( _mm_loadl_epi64( (__m128i*) ( srcTmp + 1 ) ), _mm_loadl_epi64( (__m128i*) ( srcTmp + 1 + srcStride ) ) ), mmShift1 ); + __m128i mmPixBottom = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp + srcStride)), _mm_loadl_epi64((__m128i*) (srcTmp + (srcStride << 1)))), mmShift1); + __m128i mmPixLeft = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp - 1)), _mm_loadl_epi64((__m128i*) (srcTmp - 1 + srcStride))), mmShift1); + __m128i mmPixRight = _mm_sra_epi16(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*) (srcTmp + 1)), _mm_loadl_epi64((__m128i*) (srcTmp + 1 + srcStride))), mmShift1); - __m128i mmGradVer = _mm_sub_epi16( mmPixBottom, mmPixTop ); - __m128i mmGradHor = _mm_sub_epi16( mmPixRight, mmPixLeft ); + __m128i mmGradVer = _mm_sub_epi16(mmPixBottom, mmPixTop); + __m128i mmGradHor = _mm_sub_epi16(mmPixRight, mmPixLeft); - _mm_storel_epi64( (__m128i *) gradYTmp, mmGradVer ); - _mm_storel_epi64( (__m128i *) ( gradYTmp + gradStride ), _mm_unpackhi_epi64( mmGradVer, mmGradHor ) ); - _mm_storel_epi64( (__m128i *) gradXTmp, mmGradHor ); - _mm_storel_epi64( (__m128i *) ( gradXTmp + gradStride ), _mm_unpackhi_epi64( mmGradHor, mmGradVer ) ); + _mm_storel_epi64((__m128i*) gradYTmp, mmGradVer); + _mm_storel_epi64((__m128i*) (gradYTmp + gradStride), _mm_unpackhi_epi64(mmGradVer, mmGradHor)); + _mm_storel_epi64((__m128i*) gradXTmp, mmGradHor); + _mm_storel_epi64((__m128i*) (gradXTmp + gradStride), _mm_unpackhi_epi64(mmGradHor, mmGradVer)); mmPixTop = mmPixBottom; gradXTmp += gradStride << 1; gradYTmp += gradStride << 1; - srcTmp += srcStride << 1; + srcTmp += srcStride << 1; } } @@ -267,19 +511,143 @@ void gradFilter_SSE(const Pel* src, int srcStride, int width, int height, int gr gradXTmp = gradX + gradStride; gradYTmp = gradY + gradStride; - ::memcpy(gradXTmp - gradStride, gradXTmp, sizeof(Pel)*(width)); - ::memcpy(gradXTmp + heightInside*gradStride, gradXTmp + (heightInside - 1)*gradStride, sizeof(Pel)*(width)); - ::memcpy(gradYTmp - gradStride, gradYTmp, sizeof(Pel)*(width)); - ::memcpy(gradYTmp + heightInside*gradStride, gradYTmp + (heightInside - 1)*gradStride, sizeof(Pel)*(width)); + ::memcpy(gradXTmp - gradStride, gradXTmp, sizeof(Pel) * (width)); + ::memcpy(gradXTmp + heightInside * gradStride, gradXTmp + (heightInside - 1) * gradStride, sizeof(Pel) * (width)); + ::memcpy(gradYTmp - gradStride, gradYTmp, sizeof(Pel) * (width)); + ::memcpy(gradYTmp + heightInside * gradStride, gradYTmp + (heightInside - 1) * gradStride, sizeof(Pel) * (width)); + } +} + +template< X86_VEXT vext > +void applyPROF_SSE(Pel* dstPel, int dstStride, const Pel* srcPel, int srcStride, int width, int height, const Pel* gradX, const Pel* gradY, int gradStride, const int* dMvX, const int* dMvY, int dMvStride, const bool& bi, int shiftNum, Pel offset, const ClpRng& clpRng) +{ + CHECKD( width != 4 || height != 4, "block width error!"); + + const int dILimit = 1 << std::max(clpRng.bd + 1, 13); + +#if USE_AVX2 + __m256i mm_dmvx, mm_dmvy, mm_gradx, mm_grady, mm_dI, mm_dI0, mm_src; + __m256i mm_offset = _mm256_set1_epi16( offset ); + __m256i vibdimin = _mm256_set1_epi16( clpRng.min ); + __m256i vibdimax = _mm256_set1_epi16( clpRng.max ); + __m256i mm_dimin = _mm256_set1_epi32( -dILimit ); + __m256i mm_dimax = _mm256_set1_epi32( dILimit - 1 ); + + const int *vX0 = dMvX, *vY0 = dMvY; + const Pel *gX0 = gradX, *gY0 = gradY; + + // first two rows + mm_dmvx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vX0 ) ), _mm_loadu_si128( ( const __m128i * )( vX0 + dMvStride ) ), 1 ); + mm_dmvy = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vY0 ) ), _mm_loadu_si128( ( const __m128i * )( vY0 + dMvStride ) ), 1 ); + + mm_dmvx = _mm256_packs_epi32( mm_dmvx, _mm256_setzero_si256() ); + mm_dmvy = _mm256_packs_epi32( mm_dmvy, _mm256_setzero_si256() ); + + mm_gradx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gX0 ) ), _mm_loadl_epi64( ( __m128i* )( gX0 + gradStride ) ), 1 ); + mm_grady = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gY0 ) ), _mm_loadl_epi64( ( __m128i* )( gY0 + gradStride ) ), 1 ); + + mm_dI0 = _mm256_madd_epi16( _mm256_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm256_unpacklo_epi16( mm_gradx, mm_grady ) ); + mm_dI0 = _mm256_min_epi32( mm_dimax, _mm256_max_epi32( mm_dimin, mm_dI0 ) ); + + // next two rows + vX0 += ( dMvStride << 1 ); vY0 += ( dMvStride << 1 ); gX0 += ( gradStride << 1 ); gY0 += ( gradStride << 1 ); + + mm_dmvx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vX0 ) ), _mm_loadu_si128( ( const __m128i * )( vX0 + dMvStride ) ), 1 ); + mm_dmvy = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) vY0 ) ), _mm_loadu_si128( ( const __m128i * )( vY0 + dMvStride ) ), 1 ); + + mm_dmvx = _mm256_packs_epi32( mm_dmvx, _mm256_setzero_si256() ); + mm_dmvy = _mm256_packs_epi32( mm_dmvy, _mm256_setzero_si256() ); + + mm_gradx = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gX0 ) ), _mm_loadl_epi64( ( __m128i* )( gX0 + gradStride ) ), 1 ); + mm_grady = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_loadl_epi64( ( __m128i* )gY0 ) ), _mm_loadl_epi64( ( __m128i* )( gY0 + gradStride ) ), 1 ); + + mm_dI = _mm256_madd_epi16( _mm256_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm256_unpacklo_epi16( mm_gradx, mm_grady ) ); + mm_dI = _mm256_min_epi32( mm_dimax, _mm256_max_epi32( mm_dimin, mm_dI ) ); + + // combine four rows + mm_dI = _mm256_packs_epi32( mm_dI0, mm_dI ); + const Pel* src0 = srcPel + srcStride; + mm_src = _mm256_inserti128_si256( + _mm256_castsi128_si256(_mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i *)srcPel), _mm_loadl_epi64((const __m128i *)(srcPel + (srcStride << 1))))), + _mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i *)src0), _mm_loadl_epi64((const __m128i *)(src0 + (srcStride << 1)))), + 1 + ); + mm_dI = _mm256_add_epi16(mm_dI, mm_src); + if (!bi) + { + mm_dI = _mm256_srai_epi16(_mm256_adds_epi16(mm_dI, mm_offset), shiftNum); + mm_dI = _mm256_min_epi16(vibdimax, _mm256_max_epi16(vibdimin, mm_dI)); } + + // store final results + __m128i dITmp = _mm256_extractf128_si256(mm_dI, 1); + Pel* dst0 = dstPel; + _mm_storel_epi64((__m128i *)dst0, _mm256_castsi256_si128(mm_dI)); + dst0 += dstStride; _mm_storel_epi64((__m128i *)dst0, dITmp); + dst0 += dstStride; _mm_storel_epi64((__m128i *)dst0, _mm_unpackhi_epi64(_mm256_castsi256_si128(mm_dI), _mm256_castsi256_si128(mm_dI))); + dst0 += dstStride; _mm_storel_epi64((__m128i *)dst0, _mm_unpackhi_epi64(dITmp, dITmp)); +#else + __m128i mm_dmvx, mm_dmvy, mm_gradx, mm_grady, mm_dI, mm_dI0; + __m128i mm_offset = _mm_set1_epi16( offset ); + __m128i vibdimin = _mm_set1_epi16( clpRng.min ); + __m128i vibdimax = _mm_set1_epi16( clpRng.max ); + __m128i mm_dimin = _mm_set1_epi32( -dILimit ); + __m128i mm_dimax = _mm_set1_epi32( dILimit - 1 ); + + for( int h = 0; h < height; h += 2 ) + { + const int* vX = dMvX; + const int* vY = dMvY; + const Pel* gX = gradX; + const Pel* gY = gradY; + const Pel* src = srcPel; + Pel* dst = dstPel; + + // first row + mm_dmvx = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) vX ), _mm_setzero_si128() ); + mm_dmvy = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) vY ), _mm_setzero_si128() ); + mm_gradx = _mm_loadl_epi64( ( __m128i* ) gX ); + mm_grady = _mm_loadl_epi64( ( __m128i* ) gY ); + mm_dI0 = _mm_madd_epi16 ( _mm_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm_unpacklo_epi16( mm_gradx, mm_grady ) ); + mm_dI0 = _mm_min_epi32 ( mm_dimax, _mm_max_epi32( mm_dimin, mm_dI0 ) ); + + // second row + mm_dmvx = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) ( vX + dMvStride ) ), _mm_setzero_si128() ); + mm_dmvy = _mm_packs_epi32( _mm_loadu_si128( ( const __m128i * ) ( vY + dMvStride ) ), _mm_setzero_si128() ); + mm_gradx = _mm_loadl_epi64( ( __m128i* ) ( gX + gradStride ) ); + mm_grady = _mm_loadl_epi64( ( __m128i* ) ( gY + gradStride ) ); + mm_dI = _mm_madd_epi16 ( _mm_unpacklo_epi16( mm_dmvx, mm_dmvy ), _mm_unpacklo_epi16( mm_gradx, mm_grady ) ); + mm_dI = _mm_min_epi32 ( mm_dimax, _mm_max_epi32( mm_dimin, mm_dI ) ); + + // combine both rows + mm_dI = _mm_packs_epi32( mm_dI0, mm_dI ); + mm_dI = _mm_add_epi16 ( _mm_unpacklo_epi64( _mm_loadl_epi64( ( const __m128i * )src ), _mm_loadl_epi64( ( const __m128i * )( src + srcStride ) ) ), mm_dI ); + if (!bi) + { + mm_dI = _mm_srai_epi16(_mm_adds_epi16(mm_dI, mm_offset), shiftNum); + mm_dI = _mm_min_epi16(vibdimax, _mm_max_epi16(vibdimin, mm_dI)); + } + + _mm_storel_epi64( ( __m128i * ) dst, mm_dI ); + _mm_storel_epi64( ( __m128i * )( dst + dstStride ), _mm_unpackhi_epi64( mm_dI, mm_dI ) ); + + dMvX += (dMvStride << 1); + dMvY += (dMvStride << 1); + gradX += (gradStride << 1); + gradY += (gradStride << 1); + srcPel += (srcStride << 1); + dstPel += (dstStride << 1); + } +#endif } template void InterPredInterpolation::_initInterPredictionX86() { - xFpAddBDOFAvg4 = addBDOFAvg4_SSE; + xFpBiDirOptFlow = BiOptFlowCoreSIMD; xFpBDOFGradFilter = gradFilter_SSE; - xFpCalcBDOFSums = calcBDOFSums_SSE; + xFpProfGradFilter = gradFilter_SSE; + xFpApplyPROF = applyPROF_SSE; } template void InterPredInterpolation::_initInterPredictionX86(); diff --git a/source/Lib/CommonLib/x86/InterpolationFilterX86.h b/source/Lib/CommonLib/x86/InterpolationFilterX86.h index fd395be7d..3d769eeb4 100644 --- a/source/Lib/CommonLib/x86/InterpolationFilterX86.h +++ b/source/Lib/CommonLib/x86/InterpolationFilterX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** * \file * \brief Implementation of InterpolationFilter class @@ -73,7 +77,7 @@ namespace vvenc { #define cond_mm_prefetch(a,b) _mm_prefetch(a,b) //#define cond_mm_prefetch(a,b) -// because of sub pu atmvp and tripple split +// because of sub cu atmvp and tripple split #define JEM_UNALIGNED_DST 1 // =========================== @@ -452,6 +456,60 @@ static void simdInterpolateHorM8( const int16_t* src, int srcStride, int16_t *ds } + +// SIMD interpolation horizontal, block width modulo 8 +template +static void simdInterpolateHorM8_singleCol(const int16_t* src, int srcStride, int16_t* dst, int dstStride, int width, int height, int shift, int offset, const ClpRng& clpRng, int16_t const* coeff) +{ + CHECKD( width != 1 || ( height & 3 ), "Windth needs to be '1'!" ); + + cond_mm_prefetch((const char*)src, _MM_HINT_T0); + cond_mm_prefetch((const char*)src + srcStride, _MM_HINT_T0); + + __m128i vcoeffh = _mm_loadu_si128((__m128i const*)coeff); + __m128i voffset = _mm_set1_epi32(offset); + __m128i vibdimin = _mm_set1_epi16(clpRng.min); + __m128i vibdimax = _mm_set1_epi16(clpRng.max); + + for (int row = 0; row < height; row += 4) + { + cond_mm_prefetch((const char*)src + 2 * srcStride, _MM_HINT_T0); + + __m128i + vsrc0 = _mm_loadu_si128((__m128i const*) src); src += srcStride; + vsrc0 = _mm_madd_epi16 (vsrc0, vcoeffh); + + __m128i + vsrc1 = _mm_loadu_si128((__m128i const*) src); src += srcStride; + vsrc1 = _mm_madd_epi16 (vsrc1, vcoeffh); + + __m128i + vsrc2 = _mm_loadu_si128((__m128i const*) src); src += srcStride; + vsrc2 = _mm_madd_epi16 (vsrc2, vcoeffh); + + __m128i + vsrc3 = _mm_loadu_si128((__m128i const*) src); src += srcStride; + vsrc3 = _mm_madd_epi16 (vsrc3, vcoeffh); + + vsrc0 = _mm_hadd_epi32(vsrc0, vsrc1); + vsrc2 = _mm_hadd_epi32(vsrc2, vsrc3); + vsrc0 = _mm_hadd_epi32(vsrc0, vsrc2); + + vsrc0 = _mm_add_epi32 (vsrc0, voffset); + vsrc0 = _mm_srai_epi32(vsrc0, shift); + + if (shiftBack) { //clip + vsrc0 = _mm_min_epi16(vibdimax, _mm_max_epi16(vibdimin, vsrc0)); + } + + *dst = _mm_cvtsi128_si32(vsrc0); dst += dstStride; + *dst = _mm_extract_epi32(vsrc0, 1); dst += dstStride; + *dst = _mm_extract_epi32(vsrc0, 2); dst += dstStride; + *dst = _mm_extract_epi32(vsrc0, 3); dst += dstStride; + } +} + + template static void simdInterpolateHorM8_AVX2( const int16_t* src, int srcStride, int16_t *dst, int dstStride, int width, int height, int shift, int offset, const ClpRng& clpRng, int16_t const *coeff ) { @@ -1388,6 +1446,11 @@ static void simdFilter( const ClpRng& clpRng, Pel const *src, int srcStride, Pel simdInterpolateN2_M4( src, srcStride, dst, dstStride, cStride, width, height, shift, offset, clpRng, c ); return; } + else if( N == 8 && width == 1 && ( height & 3 ) == 0 && !isVertical ) + { + simdInterpolateHorM8_singleCol( src, srcStride, dst, dstStride, width, height, shift, offset, clpRng, c ); + return; + } } for( row = 0; row < height; row++ ) @@ -2094,7 +2157,7 @@ void simdFilter16xX_N8( const ClpRng& clpRng, Pel const *src, int srcStride, Pel #endif { Pel* tmp = ( Pel* ) alloca( 16 * extHeight * sizeof( Pel ) ); - VALGRIND_MEMCLEAR( tmp ); + VALGRIND_MEMCLEAR( tmp, 16 * extHeight * sizeof( Pel ) ); simdInterpolateHorM8( src, srcStride, tmp, 16, 16, extHeight, shift1st, offset1st, clpRng, coeffH ); simdInterpolateVerM8( tmp, 16, dst, dstStride, 16, height, shift2nd, offset2nd, clpRng, coeffV ); @@ -2132,7 +2195,7 @@ void simdFilter16xX_N4( const ClpRng& clpRng, Pel const *src, int srcStride, Pel const int extHeight = height + 3; Pel* tmp = ( Pel* ) alloca( 16 * extHeight * sizeof( Pel ) ); - VALGRIND_MEMCLEAR( tmp ); + VALGRIND_MEMCLEAR( tmp, 16 * extHeight * sizeof( Pel ) ); #if USE_AVX2 if( vext >= AVX2 ) @@ -2278,7 +2341,7 @@ void simdFilter8xX_N8( const ClpRng& clpRng, Pel const *src, int srcStride, Pel* #endif { Pel* tmp = ( Pel* ) alloca( 8 * extHeight * sizeof( Pel ) ); - VALGRIND_MEMCLEAR( tmp ); + VALGRIND_MEMCLEAR( tmp, 8 * extHeight * sizeof( Pel ) ); simdInterpolateHorM8( src, srcStride, tmp, 8, 8, extHeight, shift1st, offset1st, clpRng, coeffH ); simdInterpolateVerM8( tmp, 8, dst, dstStride, 8, height, shift2nd, offset2nd, clpRng, coeffV ); @@ -2414,7 +2477,7 @@ void simdFilter8xX_N4( const ClpRng& clpRng, Pel const *src, int srcStride, Pel* #endif { Pel* tmp = ( Pel* ) alloca( 8 * extHeight * sizeof( Pel ) ); - VALGRIND_MEMCLEAR( tmp ); + VALGRIND_MEMCLEAR( tmp, 8 * extHeight * sizeof( Pel ) ); simdInterpolateHorM8( src, srcStride, tmp, 8, 8, extHeight, shift1st, offset1st, clpRng, coeffH ); simdInterpolateVerM8( tmp, 8, dst, dstStride, 8, height, shift2nd, offset2nd, clpRng, coeffV ); @@ -2427,7 +2490,7 @@ void simdFilter8xX_N4( const ClpRng& clpRng, Pel const *src, int srcStride, Pel* #endif template -void xWeightedGeoBlk_SSE(const ClpRngs &clpRng, const PredictionUnit &pu, const uint32_t width, const uint32_t height, +void xWeightedGeoBlk_SSE(const ClpRngs &clpRng, const CodingUnit& cu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf &predDst, PelUnitBuf &predSrc0, PelUnitBuf &predSrc1) { @@ -2442,8 +2505,8 @@ void xWeightedGeoBlk_SSE(const ClpRngs &clpRng, const PredictionUnit &pu, const const int32_t shiftWeighted = std::max(2, (IF_INTERNAL_PREC - clpRng.comp[compIdx].bd)) + log2WeightBase; const int32_t offsetWeighted = (1 << (shiftWeighted - 1)) + (IF_INTERNAL_OFFS << log2WeightBase); - int16_t wIdx = floorLog2(pu.lwidth()) - GEO_MIN_CU_LOG2; - int16_t hIdx = floorLog2(pu.lheight()) - GEO_MIN_CU_LOG2; + int16_t wIdx = floorLog2(cu.lwidth()) - GEO_MIN_CU_LOG2; + int16_t hIdx = floorLog2(cu.lheight()) - GEO_MIN_CU_LOG2; int16_t angle = g_GeoParams[splitDir][0]; int16_t stepY = 0; int16_t *weight = nullptr; @@ -2475,7 +2538,7 @@ void xWeightedGeoBlk_SSE(const ClpRngs &clpRng, const PredictionUnit &pu, const const __m128i mmMin = _mm_set1_epi16(clpRng.comp[compIdx].min); const __m128i mmMax = _mm_set1_epi16(clpRng.comp[compIdx].max); - if (compIdx != COMP_Y && pu.chromaFormat == CHROMA_420) + if (compIdx != COMP_Y && cu.chromaFormat == CHROMA_420) stepY <<= 1; if (width == 4) { @@ -2525,7 +2588,7 @@ void xWeightedGeoBlk_SSE(const ClpRngs &clpRng, const PredictionUnit &pu, const __m256i s1 = _mm256_lddqu_si256((__m256i *) (src1 + x)); __m256i w0 = _mm256_lddqu_si256((__m256i *) (weight + x)); - if (compIdx != COMP_Y && pu.chromaFormat != CHROMA_444) + if (compIdx != COMP_Y && cu.chromaFormat != CHROMA_444) { const __m256i mask = _mm256_set_epi16(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); __m256i w0p0, w0p1; @@ -2598,7 +2661,7 @@ void xWeightedGeoBlk_SSE(const ClpRngs &clpRng, const PredictionUnit &pu, const __m128i s0 = _mm_lddqu_si128((__m128i *) (src0 + x)); __m128i s1 = _mm_lddqu_si128((__m128i *) (src1 + x)); __m128i w0; - if (compIdx != COMP_Y && pu.chromaFormat != CHROMA_444) + if (compIdx != COMP_Y && cu.chromaFormat != CHROMA_444) { const __m128i mask = _mm_set_epi16(0, 1, 0, 1, 0, 1, 0, 1); __m128i w0p0, w0p1; diff --git a/source/Lib/CommonLib/x86/IntraPredX86.h b/source/Lib/CommonLib/x86/IntraPredX86.h index 6ec9b9149..e0f338798 100644 --- a/source/Lib/CommonLib/x86/IntraPredX86.h +++ b/source/Lib/CommonLib/x86/IntraPredX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file IntraPredX86.h \brief SIMD for IntraPrediction */ @@ -816,8 +820,8 @@ void xPredIntraPlanar_SIMD( PelBuf& pDst, const CPelBuf& pSrc) const uint32_t width = pDst.width; const uint32_t height = pDst.height; - const uint32_t log2W = floorLog2( width < 2 ? 2 : width ); - const uint32_t log2H = floorLog2( height < 2 ? 2 : height ); + const uint32_t log2W = floorLog2(width); + const uint32_t log2H = floorLog2(height); const uint32_t offset = 1 << (log2W + log2H); const ptrdiff_t stride = pDst.stride; Pel* pred = pDst.buf; @@ -1123,7 +1127,7 @@ void IntraAnglePDPC_SIMD(Pel* pDsty,const int dstStride,Pel* refSide,const int w { #ifdef USE_AVX2 ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE,short ref[16]); - VALGRIND_MEMCLEAR( ref ); + VALGRIND_MEMCLEAR( ref, sizeof( ref ) ); // Pel dummy[16]; // Pel* pdum=&dummy[0]; @@ -1192,7 +1196,7 @@ void IntraAnglePDPC_SIMD(Pel* pDsty,const int dstStride,Pel* refSide,const int w else { ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE,short ref[8]); - VALGRIND_MEMCLEAR( ref ); + VALGRIND_MEMCLEAR( ref, sizeof( ref ) ); __m128i wl16; if (scale==0) diff --git a/source/Lib/CommonLib/x86/LoopFilterX86.h b/source/Lib/CommonLib/x86/LoopFilterX86.h index 719566509..6b4ef8347 100644 --- a/source/Lib/CommonLib/x86/LoopFilterX86.h +++ b/source/Lib/CommonLib/x86/LoopFilterX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file LoopFilterX86.h \brief deblocking filter simd code */ diff --git a/source/Lib/CommonLib/x86/MCTFX86.h b/source/Lib/CommonLib/x86/MCTFX86.h index e09a8907a..93559ab87 100644 --- a/source/Lib/CommonLib/x86/MCTFX86.h +++ b/source/Lib/CommonLib/x86/MCTFX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** * \file * \brief Implementation of AffineGradientSearch class @@ -177,101 +181,101 @@ template int motionErrorLumaFrac_SIMD( const Pel* origOrigin, const ptrdiff_t origStride, const Pel* buffOrigin, const ptrdiff_t buffStride, const int bs, const int x, const int y, const int dx, const int dy, const int16_t* xFilter, const int16_t* yFilter, const int bitDepth, const int besterror ) { int error = 0; - int tempArray[64 + 8][64]; - int base; + const int base = x + ( dx >> 4 ) - 3; CHECK( bs & 7, "SIMD blockSize needs to be a multiple of 8" ); - __m128i xfilt1 = _mm_loadu_si128( ( const __m128i * ) xFilter ); + const Pel maxSampleValue = ( 1 << bitDepth ) - 1; - for( int y1 = 1; y1 < bs + 7; y1++ ) - { - const int yOffset = y + y1 + ( dy >> 4 ) - 3; - const Pel* sourceRow = buffOrigin + ( yOffset ) *buffStride + 0; +#if USE_AVX2 + __m256i vfilt12 = _mm256_unpacklo_epi16( _mm256_set1_epi16( yFilter[1] ), _mm256_set1_epi16( yFilter[2] ) ); + __m256i vfilt34 = _mm256_unpacklo_epi16( _mm256_set1_epi16( yFilter[3] ), _mm256_set1_epi16( yFilter[4] ) ); + __m256i vfilt56 = _mm256_unpacklo_epi16( _mm256_set1_epi16( yFilter[5] ), _mm256_set1_epi16( yFilter[6] ) ); + + __m256i vfilt1 = _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) xFilter ) ); + vfilt1 = _mm256_inserti128_si256( vfilt1, _mm256_castsi256_si128( vfilt1 ), 1 ); + __m256i vmax = _mm256_set1_epi32( maxSampleValue ); + __m256i vmin = _mm256_setzero_si256(); + + const int yOffset = y + 1 + ( dy >> 4 ) - 3; + const Pel* sourceCol = buffOrigin + base + yOffset * buffStride; + const Pel* origCol = origOrigin + y * origStride + x; - for( int x1 = 0; x1 < bs; x1 += 4 ) - { - base = x + x1 + ( dx >> 4 ) - 3; - const Pel* rowStart = sourceRow + base; + for( int x1 = 0; x1 < bs; x1 += 8, sourceCol += 8, origCol += 8 ) + { + const Pel* origRow = origCol; + const Pel* rowStart = sourceCol; - __m128i vsrc0 = _mm_loadu_si128( ( const __m128i * ) &rowStart[0] ); - __m128i vsrc1 = _mm_loadu_si128( ( const __m128i * ) &rowStart[1] ); - __m128i vsrc2 = _mm_loadu_si128( ( const __m128i * ) &rowStart[2] ); - __m128i vsrc3 = _mm_loadu_si128( ( const __m128i * ) &rowStart[3] ); + __m128i xsrc[6]; - vsrc0 = _mm_madd_epi16( vsrc0, xfilt1 ); - vsrc1 = _mm_madd_epi16( vsrc1, xfilt1 ); - vsrc2 = _mm_madd_epi16( vsrc2, xfilt1 ); - vsrc3 = _mm_madd_epi16( vsrc3, xfilt1 ); + for( int y1 = 1; y1 < bs + 6; y1++, rowStart += buffStride ) + { + __m256i vsrc0 = _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) &rowStart[0] ) ); + __m256i vsrc1 = _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) &rowStart[1] ) ); + __m256i vsrc2 = _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) &rowStart[2] ) ); + __m256i vsrc3 = _mm256_castsi128_si256( _mm_loadu_si128( ( const __m128i * ) &rowStart[3] ) ); - vsrc0 = _mm_hadd_epi32( vsrc0, vsrc1 ); - vsrc2 = _mm_hadd_epi32( vsrc2, vsrc3 ); + vsrc0 = _mm256_inserti128_si256( vsrc0, _mm_loadu_si128( ( const __m128i * ) &rowStart[4] ), 1 ); + vsrc1 = _mm256_inserti128_si256( vsrc1, _mm_loadu_si128( ( const __m128i * ) &rowStart[5] ), 1 ); + vsrc2 = _mm256_inserti128_si256( vsrc2, _mm_loadu_si128( ( const __m128i * ) &rowStart[6] ), 1 ); + vsrc3 = _mm256_inserti128_si256( vsrc3, _mm_loadu_si128( ( const __m128i * ) &rowStart[7] ), 1 ); - vsrc0 = _mm_hadd_epi32( vsrc0, vsrc2 ); + vsrc0 = _mm256_madd_epi16( vsrc0, vfilt1 ); + vsrc1 = _mm256_madd_epi16( vsrc1, vfilt1 ); + vsrc2 = _mm256_madd_epi16( vsrc2, vfilt1 ); + vsrc3 = _mm256_madd_epi16( vsrc3, vfilt1 ); - _mm_storeu_si128( ( __m128i * ) &tempArray[y1][x1], vsrc0 ); - - //sum = 0; - //sum += xFilter[1] * rowStart[1]; - //sum += xFilter[2] * rowStart[2]; - //sum += xFilter[3] * rowStart[3]; - //sum += xFilter[4] * rowStart[4]; - //sum += xFilter[5] * rowStart[5]; - //sum += xFilter[6] * rowStart[6]; - // - //tempArray[y1][x1] = sum; - } - } + vsrc0 = _mm256_hadd_epi32( vsrc0, vsrc1 ); + vsrc2 = _mm256_hadd_epi32( vsrc2, vsrc3 ); - const Pel maxSampleValue = ( 1 << bitDepth ) - 1; + vsrc0 = _mm256_hadd_epi32( vsrc0, vsrc2 ); -#if USE_AVX2 - if( ( bs & 7 ) == 0 && vext >= AVX2 ) - { - __m256i vfilt1 = _mm256_set1_epi32( yFilter[1] ); - __m256i vfilt2 = _mm256_set1_epi32( yFilter[2] ); - __m256i vfilt3 = _mm256_set1_epi32( yFilter[3] ); - __m256i vfilt4 = _mm256_set1_epi32( yFilter[4] ); - __m256i vfilt5 = _mm256_set1_epi32( yFilter[5] ); - __m256i vfilt6 = _mm256_set1_epi32( yFilter[6] ); + __m256i + vsum = _mm256_add_epi32 ( vsrc0, _mm256_set1_epi32( 1 << 5 ) ); + vsum = _mm256_srai_epi32 ( vsum, 6 ); + vsum = _mm256_min_epi32 ( vmax, _mm256_max_epi32( vmin, vsum ) ); - __m256i vmax = _mm256_set1_epi32( maxSampleValue ); - __m256i vmin = _mm256_setzero_si256(); + __m128i + xsum = _mm256_cvtepi32_epi16x( vsum ); - for( int y1 = 0; y1 < bs; y1++ ) - { - const Pel* origRow = origOrigin + ( y + y1 )*origStride + 0; - for( int x1 = 0; x1 < bs; x1 += 8 ) + if( y1 >= 6 ) { - __m256i vsum = _mm256_set1_epi32( 1 << 11 ); - - vsum = _mm256_add_epi32( vsum, _mm256_mullo_epi32( vfilt1, _mm256_loadu_si256( ( const __m256i * ) &tempArray[y1 + 1][x1] ) ) ); - vsum = _mm256_add_epi32( vsum, _mm256_mullo_epi32( vfilt2, _mm256_loadu_si256( ( const __m256i * ) &tempArray[y1 + 2][x1] ) ) ); - vsum = _mm256_add_epi32( vsum, _mm256_mullo_epi32( vfilt3, _mm256_loadu_si256( ( const __m256i * ) &tempArray[y1 + 3][x1] ) ) ); - vsum = _mm256_add_epi32( vsum, _mm256_mullo_epi32( vfilt4, _mm256_loadu_si256( ( const __m256i * ) &tempArray[y1 + 4][x1] ) ) ); - vsum = _mm256_add_epi32( vsum, _mm256_mullo_epi32( vfilt5, _mm256_loadu_si256( ( const __m256i * ) &tempArray[y1 + 5][x1] ) ) ); - vsum = _mm256_add_epi32( vsum, _mm256_mullo_epi32( vfilt6, _mm256_loadu_si256( ( const __m256i * ) &tempArray[y1 + 6][x1] ) ) ); - - vsum = _mm256_srai_epi32( vsum, 12 ); - - vsum = _mm256_min_epi32( vmax, _mm256_max_epi32( vmin, vsum ) ); - + xsrc[0] = xsrc[1]; + xsrc[1] = xsrc[2]; + xsrc[2] = xsrc[3]; + xsrc[3] = xsrc[4]; + xsrc[4] = xsrc[5]; + xsrc[5] = xsum; + + __m256i vsrc12 = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_unpacklo_epi16( xsrc[0], xsrc[1] ) ), + _mm_unpackhi_epi16( xsrc[0], xsrc[1] ), 1 ); + __m256i vsrc34 = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_unpacklo_epi16( xsrc[2], xsrc[3] ) ), + _mm_unpackhi_epi16( xsrc[2], xsrc[3] ), 1 ); + __m256i vsrc56 = _mm256_inserti128_si256( _mm256_castsi128_si256( _mm_unpacklo_epi16( xsrc[4], xsrc[5] ) ), + _mm_unpackhi_epi16( xsrc[4], xsrc[5] ), 1 ); + __m256i - vorg = _mm256_cvtepi16_epi32( _mm_loadu_si128( ( const __m128i * ) &origRow[x + x1] ) ); + vsum = _mm256_set1_epi32( 1 << 5 ); + vsum = _mm256_add_epi32( vsum, _mm256_madd_epi16( vfilt12, vsrc12 ) ); + vsum = _mm256_add_epi32( vsum, _mm256_madd_epi16( vfilt34, vsrc34 ) ); + vsum = _mm256_add_epi32( vsum, _mm256_madd_epi16( vfilt56, vsrc56 ) ); + + vsum = _mm256_srai_epi32 ( vsum, 6 ); + vsum = _mm256_min_epi32 ( vmax, _mm256_max_epi32( vmin, vsum ) ); - vsum = _mm256_sub_epi32( vsum, vorg ); - vsum = _mm256_mullo_epi32( vsum, vsum ); + __m128i + xorg = _mm_loadu_si128( ( const __m128i * ) origRow ); + origRow += origStride; + + xsum = _mm256_cvtepi32_epi16x( vsum ); - vsum = _mm256_hadd_epi32( vsum, vsum ); + xsum = _mm_sub_epi16 ( xsum, xorg ); + xsum = _mm_madd_epi16( xsum, xsum ); - __m128i - xsum = _mm256_extractf128_si256( vsum, 1 ); + xsum = _mm_hadd_epi32( xsum, xsum ); - error += _mm256_extract_epi32( vsum, 0 ); - error += _mm256_extract_epi32( vsum, 1 ); - - error += _mm_extract_epi32 ( xsum, 0 ); - error += _mm_extract_epi32 ( xsum, 1 ); + error += _mm_extract_epi32( xsum, 0 ); + error += _mm_extract_epi32( xsum, 1 ); //sum = 0; //sum += yFilter[1] * tempArray[y1 + 1][x1]; @@ -281,79 +285,145 @@ int motionErrorLumaFrac_SIMD( const Pel* origOrigin, const ptrdiff_t origStride, //sum += yFilter[5] * tempArray[y1 + 5][x1]; //sum += yFilter[6] * tempArray[y1 + 6][x1]; // - //sum = ( sum + ( 1 << 11 ) ) >> 12; + //sum = ( sum + ( 1 << 5 ) ) >> 6; //sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); // //error += ( sum - origRow[x + x1] ) * ( sum - origRow[x + x1] ); + + if( error > besterror ) + { + return error; + } } - if( error > besterror ) + else { - return error; + xsrc[y1] = xsum; + + //sum = 0; + //sum += xFilter[1] * rowStart[1]; + //sum += xFilter[2] * rowStart[2]; + //sum += xFilter[3] * rowStart[3]; + //sum += xFilter[4] * rowStart[4]; + //sum += xFilter[5] * rowStart[5]; + //sum += xFilter[6] * rowStart[6]; + // + //sum = ( sum + ( 1 << 5 ) ) >> 6; + //sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); + // + //tempArray[y1][x1] = sum; } } - - return error; } -#endif - - xfilt1 = _mm_set1_epi32( yFilter[1] ); - __m128i xfilt2 = _mm_set1_epi32( yFilter[2] ); - __m128i xfilt3 = _mm_set1_epi32( yFilter[3] ); - __m128i xfilt4 = _mm_set1_epi32( yFilter[4] ); - __m128i xfilt5 = _mm_set1_epi32( yFilter[5] ); - __m128i xfilt6 = _mm_set1_epi32( yFilter[6] ); - +#else + __m128i xfilt12 = _mm_unpacklo_epi16( _mm_set1_epi16( yFilter[1] ), _mm_set1_epi16( yFilter[2] ) ); + __m128i xfilt34 = _mm_unpacklo_epi16( _mm_set1_epi16( yFilter[3] ), _mm_set1_epi16( yFilter[4] ) ); + __m128i xfilt56 = _mm_unpacklo_epi16( _mm_set1_epi16( yFilter[5] ), _mm_set1_epi16( yFilter[6] ) ); + + __m128i xfilt1 = _mm_loadu_si128( ( const __m128i * ) xFilter ); __m128i xmax = _mm_set1_epi32( maxSampleValue ); __m128i xmin = _mm_setzero_si128(); + + const int yOffset = y + 1 + ( dy >> 4 ) - 3; + const Pel* sourceCol = buffOrigin + base + yOffset * buffStride; + const Pel* origCol = origOrigin + y * origStride + x; - for( int y1 = 0; y1 < bs; y1++ ) + for( int x1 = 0; x1 < bs; x1 += 4, sourceCol += 4, origCol += 4 ) { - const Pel* origRow = origOrigin + ( y + y1 )*origStride + 0; - for( int x1 = 0; x1 < bs; x1 += 4 ) + const Pel* origRow = origCol; + const Pel* rowStart = sourceCol; + + __m128i xsrc[6]; + + for( int y1 = 1; y1 < bs + 6; y1++, rowStart += buffStride ) { - __m128i xsum = _mm_set1_epi32( 1 << 11 ); + __m128i xsrc0 = _mm_loadu_si128( ( const __m128i * ) &rowStart[0] ); + __m128i xsrc1 = _mm_loadu_si128( ( const __m128i * ) &rowStart[1] ); + __m128i xsrc2 = _mm_loadu_si128( ( const __m128i * ) &rowStart[2] ); + __m128i xsrc3 = _mm_loadu_si128( ( const __m128i * ) &rowStart[3] ); - xsum = _mm_add_epi32( xsum, _mm_mullo_epi32( xfilt1, _mm_loadu_si128( ( const __m128i * ) &tempArray[y1 + 1][x1] ) ) ); - xsum = _mm_add_epi32( xsum, _mm_mullo_epi32( xfilt2, _mm_loadu_si128( ( const __m128i * ) &tempArray[y1 + 2][x1] ) ) ); - xsum = _mm_add_epi32( xsum, _mm_mullo_epi32( xfilt3, _mm_loadu_si128( ( const __m128i * ) &tempArray[y1 + 3][x1] ) ) ); - xsum = _mm_add_epi32( xsum, _mm_mullo_epi32( xfilt4, _mm_loadu_si128( ( const __m128i * ) &tempArray[y1 + 4][x1] ) ) ); - xsum = _mm_add_epi32( xsum, _mm_mullo_epi32( xfilt5, _mm_loadu_si128( ( const __m128i * ) &tempArray[y1 + 5][x1] ) ) ); - xsum = _mm_add_epi32( xsum, _mm_mullo_epi32( xfilt6, _mm_loadu_si128( ( const __m128i * ) &tempArray[y1 + 6][x1] ) ) ); + xsrc0 = _mm_madd_epi16( xsrc0, xfilt1 ); + xsrc1 = _mm_madd_epi16( xsrc1, xfilt1 ); + xsrc2 = _mm_madd_epi16( xsrc2, xfilt1 ); + xsrc3 = _mm_madd_epi16( xsrc3, xfilt1 ); - xsum = _mm_srai_epi32( xsum, 12 ); + xsrc0 = _mm_hadd_epi32( xsrc0, xsrc1 ); + xsrc2 = _mm_hadd_epi32( xsrc2, xsrc3 ); - xsum = _mm_min_epi32( xmax, _mm_max_epi32( xmin, xsum ) ); + xsrc0 = _mm_hadd_epi32( xsrc0, xsrc2 ); __m128i - xorg = _mm_loadl_epi64( ( const __m128i * ) &origRow[x + x1] ); - xorg = _mm_cvtepi16_epi32( xorg ); - - xsum = _mm_sub_epi32( xsum, xorg ); - xsum = _mm_mullo_epi32( xsum, xsum ); - - xsum = _mm_hadd_epi32( xsum, xsum ); - - error += _mm_extract_epi32( xsum, 0 ); - error += _mm_extract_epi32( xsum, 1 ); - - //sum = 0; - //sum += yFilter[1] * tempArray[y1 + 1][x1]; - //sum += yFilter[2] * tempArray[y1 + 2][x1]; - //sum += yFilter[3] * tempArray[y1 + 3][x1]; - //sum += yFilter[4] * tempArray[y1 + 4][x1]; - //sum += yFilter[5] * tempArray[y1 + 5][x1]; - //sum += yFilter[6] * tempArray[y1 + 6][x1]; - // - //sum = ( sum + ( 1 << 11 ) ) >> 12; - //sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); - // - //error += ( sum - origRow[x + x1] ) * ( sum - origRow[x + x1] ); - } - if( error > besterror ) - { - return error; + xsum = _mm_add_epi32 ( xsrc0, _mm_set1_epi32( 1 << 5 ) ); + xsum = _mm_srai_epi32 ( xsum, 6 ); + xsum = _mm_min_epi32 ( xmax, _mm_max_epi32( xmin, xsum ) ); + xsum = _mm_packs_epi32( xsum, _mm_setzero_si128() ); + + if( y1 >= 6 ) + { + xsrc[0] = xsrc[1]; + xsrc[1] = xsrc[2]; + xsrc[2] = xsrc[3]; + xsrc[3] = xsrc[4]; + xsrc[4] = xsrc[5]; + xsrc[5] = xsum; + + xsum = _mm_set1_epi32( 1 << 5 ); + + xsum = _mm_add_epi32( xsum, _mm_madd_epi16( xfilt12, _mm_unpacklo_epi16( xsrc[0], xsrc[1] ) ) ); + xsum = _mm_add_epi32( xsum, _mm_madd_epi16( xfilt34, _mm_unpacklo_epi16( xsrc[2], xsrc[3] ) ) ); + xsum = _mm_add_epi32( xsum, _mm_madd_epi16( xfilt56, _mm_unpacklo_epi16( xsrc[4], xsrc[5] ) ) ); + + xsum = _mm_srai_epi32 ( xsum, 6 ); + xsum = _mm_min_epi32 ( xmax, _mm_max_epi32( xmin, xsum ) ); + xsum = _mm_packs_epi32( xsum, _mm_setzero_si128() ); + + __m128i + xorg = _mm_loadl_epi64( ( const __m128i * ) origRow ); + origRow += origStride; + + xsum = _mm_sub_epi16 ( xsum, xorg ); + xsum = _mm_madd_epi16( xsum, xsum ); + + error += _mm_extract_epi32( xsum, 0 ); + error += _mm_extract_epi32( xsum, 1 ); + + //sum = 0; + //sum += yFilter[1] * tempArray[y1 + 1][x1]; + //sum += yFilter[2] * tempArray[y1 + 2][x1]; + //sum += yFilter[3] * tempArray[y1 + 3][x1]; + //sum += yFilter[4] * tempArray[y1 + 4][x1]; + //sum += yFilter[5] * tempArray[y1 + 5][x1]; + //sum += yFilter[6] * tempArray[y1 + 6][x1]; + // + //sum = ( sum + ( 1 << 5 ) ) >> 6; + //sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); + // + //error += ( sum - origRow[x + x1] ) * ( sum - origRow[x + x1] ); + + if( error > besterror ) + { + return error; + } + } + else + { + xsrc[y1] = xsum; + + //sum = 0; + //sum += xFilter[1] * rowStart[1]; + //sum += xFilter[2] * rowStart[2]; + //sum += xFilter[3] * rowStart[3]; + //sum += xFilter[4] * rowStart[4]; + //sum += xFilter[5] * rowStart[5]; + //sum += xFilter[6] * rowStart[6]; + // + //sum = ( sum + ( 1 << 5 ) ) >> 6; + //sum = sum < 0 ? 0 : ( sum > maxSampleValue ? maxSampleValue : sum ); + // + //tempArray[y1][x1] = sum; + } } } +#endif return error; } diff --git a/source/Lib/CommonLib/x86/QuantX86.h b/source/Lib/CommonLib/x86/QuantX86.h index a74fabe9e..793b4b7d8 100644 --- a/source/Lib/CommonLib/x86/QuantX86.h +++ b/source/Lib/CommonLib/x86/QuantX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** * \file * \brief Implementation of quantization functions @@ -170,6 +174,156 @@ int xQuantCGWise_SSE( short* piQCoef, short* piCbf, const short* piCoef, const i return (0xffff & _mm_cvtsi128_si32( AbsSum )); } +static constexpr unsigned short levmask[16] = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0,0,0,0,0,0,0,0}; +template +static void DeQuantCoreSIMD(const int maxX,const int maxY,const int scale,const TCoeff *const piQCoef,const size_t piQCfStride,TCoeff *const piCoef,const int rightShift,const int inputMaximum,const TCoeff transformMaximum) +{ + const int inputMinimum = -(inputMaximum+1); + const TCoeff transformMinimum = -(transformMaximum+1); + const int width = maxX+1; + + __m128i vlevmask; + if (maxX<7) + vlevmask = _mm_loadu_si128( ( __m128i const * )&levmask[7-maxX] ); + else + vlevmask = _mm_set_epi64x(0xffffffffffffffff,0xffffffffffffffff); + + if (rightShift>0) + { + const Intermediate_Int iAdd = (Intermediate_Int) 1 << (rightShift - 1); + + __m128i v_max = _mm_set1_epi16 ((short)inputMaximum); + __m128i v_min = _mm_set1_epi16 ((short)inputMinimum); + __m128i v_Tmax = _mm_set1_epi32 ((short)transformMaximum); + __m128i v_Tmin = _mm_set1_epi32 ((short)transformMinimum); + __m128i v_scale = _mm_set1_epi16 ((short)scale); + __m128i v_add = _mm_set1_epi32 (iAdd); + __m128i v_rshift = _mm_set1_epi64x (rightShift); + + if (maxX<4) + { + for( int y = 0; y <= maxY; y++) + { + __m128i v_level = _mm_loadu_si128( ( __m128i const * )&piQCoef[y * piQCfStride] ); + v_level = _mm_packs_epi32 (v_level,v_level); + v_level = _mm_and_si128(v_level,vlevmask); + v_level = _mm_max_epi16 (v_level, v_min); + v_level = _mm_min_epi16 (v_level, v_max); + __m128i v_low = _mm_mullo_epi16(v_level,v_scale); + __m128i v_high = _mm_mulhi_epi16(v_level,v_scale); + + v_level = _mm_unpacklo_epi16(v_low,v_high); + v_level = _mm_add_epi32(v_level,v_add); + v_level = _mm_sra_epi32(v_level,v_rshift); + + v_level = _mm_max_epi32 (v_level, v_Tmin); + v_level = _mm_min_epi32 (v_level, v_Tmax); + _mm_storeu_si128(( __m128i * )(piCoef+y*width ), v_level ); + } + } + else + { + for( int y = 0; y <= maxY; y++) + { + for( int x = 0; x <= maxX; x+=8) + { + __m128i v_levell = _mm_loadu_si128( ( __m128i const * )&piQCoef[x+ y * piQCfStride] ); + __m128i v_levelh = _mm_loadu_si128( ( __m128i const * )&piQCoef[x+4 + y * piQCfStride] ); + __m128i v_level = _mm_packs_epi32 (v_levell,v_levelh); + v_level = _mm_and_si128(v_level,vlevmask); + v_level = _mm_max_epi16 (v_level, v_min); + v_level = _mm_min_epi16 (v_level, v_max); + __m128i v_low = _mm_mullo_epi16(v_level,v_scale); + __m128i v_high = _mm_mulhi_epi16(v_level,v_scale); + + v_level = _mm_unpacklo_epi16(v_low,v_high); + v_level = _mm_add_epi32(v_level,v_add); + v_level = _mm_sra_epi32(v_level,v_rshift); + + v_level = _mm_max_epi32 (v_level, v_Tmin); + v_level = _mm_min_epi32 (v_level, v_Tmax); + _mm_storeu_si128(( __m128i * )(piCoef+x+y*width ), v_level ); + + v_level = _mm_unpackhi_epi16(v_low,v_high); + v_level = _mm_add_epi32(v_level,v_add); + v_level = _mm_sra_epi32(v_level,v_rshift); + + v_level = _mm_max_epi32 (v_level, v_Tmin); + v_level = _mm_min_epi32 (v_level, v_Tmax); + _mm_storeu_si128(( __m128i * )(piCoef+4+x+y*width ), v_level ); + } + } + } + } + else // rightshift <0 + { + __m128i v_max = _mm_set1_epi16 ((short)inputMaximum); + __m128i v_min = _mm_set1_epi16 ((short)inputMinimum); + __m128i v_Tmax = _mm_set1_epi32 ((short)transformMaximum); + __m128i v_Tmin = _mm_set1_epi32 ((short)transformMinimum); + __m128i v_scale = _mm_set1_epi16 ((short)scale); + __m128i v_lshift = _mm_set1_epi64x (-rightShift); + + if (maxX<4) + { + for( int y = 0; y <= maxY; y++) + { + __m128i v_level = maxX == 1 ? _mm_loadl_epi64( (__m128i const*) & piQCoef[y * piQCfStride] ) : _mm_loadu_si128( ( __m128i const * )&piQCoef[y * piQCfStride] ); + v_level = _mm_packs_epi32 (v_level,v_level); + v_level = _mm_and_si128(v_level,vlevmask); + + v_level = _mm_max_epi16 (v_level, v_min); + v_level = _mm_min_epi16 (v_level, v_max); + __m128i v_low = _mm_mullo_epi16(v_level,v_scale); + __m128i v_high = _mm_mulhi_epi16(v_level,v_scale); + + v_level = _mm_unpacklo_epi16(v_low,v_high); + v_level = _mm_sll_epi32(v_level,v_lshift); + + v_level = _mm_max_epi32 (v_level, v_Tmin); + v_level = _mm_min_epi32 (v_level, v_Tmax); + if( maxX == 1 ) + { + _mm_storel_epi64( (__m128i*)(piCoef + y * width), v_level ); + } + else + _mm_storeu_si128(( __m128i * )(piCoef+y*width ), v_level ); + } + } + else + { + for( int y = 0; y <= maxY; y++) + { + for( int x = 0; x <= maxX; x+=8) + { + __m128i v_levell = _mm_loadu_si128( ( __m128i const * )&piQCoef[x+ y * piQCfStride] ); + __m128i v_levelh = _mm_loadu_si128( ( __m128i const * )&piQCoef[x+4 + y * piQCfStride] ); + __m128i v_level = _mm_packs_epi32 (v_levell,v_levelh); + v_level = _mm_and_si128(v_level,vlevmask); + v_level = _mm_max_epi16 (v_level, v_min); + v_level = _mm_min_epi16 (v_level, v_max); + __m128i v_low = _mm_mullo_epi16(v_level,v_scale); + __m128i v_high = _mm_mulhi_epi16(v_level,v_scale); + + v_level = _mm_unpacklo_epi16(v_low,v_high); + v_level = _mm_sll_epi32(v_level,v_lshift); + + v_level = _mm_max_epi32 (v_level, v_Tmin); + v_level = _mm_min_epi32 (v_level, v_Tmax); + _mm_storeu_si128(( __m128i * )(piCoef+x+y*width ), v_level ); + + v_level = _mm_unpackhi_epi16(v_low,v_high); + v_level = _mm_sll_epi32(v_level,v_lshift); + + v_level = _mm_max_epi32 (v_level, v_Tmin); + v_level = _mm_min_epi32 (v_level, v_Tmax); + _mm_storeu_si128(( __m128i * )(piCoef+4+x+y*width ), v_level ); + } + } + } + } +} + template void QuantRDOQ2::_initQuantX86() @@ -182,6 +336,14 @@ void QuantRDOQ2::_initQuantX86() template void QuantRDOQ2::_initQuantX86(); +template +void Quant::_initQuantX86() +{ + DeQuant = DeQuantCoreSIMD; +} +template void Quant::_initQuantX86(); + + } // namespace vvenc //! \} diff --git a/source/Lib/CommonLib/x86/RdCostX86.h b/source/Lib/CommonLib/x86/RdCostX86.h index f1889ec39..2e649d742 100644 --- a/source/Lib/CommonLib/x86/RdCostX86.h +++ b/source/Lib/CommonLib/x86/RdCostX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file RdCostX86.cpp \brief RD cost computation class, SIMD version */ @@ -372,20 +376,27 @@ Distortion RdCost::xGetSAD_NxN_SIMD( const DistParam &rcDtParam ) // Do for width that multiple of 16 __m256i vone = _mm256_set1_epi16( 1 ); __m256i vsum32 = _mm256_setzero_si256(); + for( int iY = 0; iY < iRows; iY+=iSubStep ) { - __m256i vsum16 = _mm256_setzero_si256(); - for( int iX = 0; iX < iWidth; iX+=16 ) + __m256i vsrc1 = _mm256_loadu_si256( ( __m256i* )( pSrc1 ) ); + __m256i vsrc2 = _mm256_loadu_si256( ( __m256i* )( pSrc2 ) ); + __m256i vsum16 = _mm256_abs_epi16( _mm256_sub_epi16( vsrc1, vsrc2 ) ); + + for( int iX = 16; iX < iWidth; iX+=16 ) { - __m256i vsrc1 = _mm256_loadu_si256( ( __m256i* )( &pSrc1[iX] ) ); - __m256i vsrc2 = _mm256_loadu_si256( ( __m256i* )( &pSrc2[iX] ) ); + vsrc1 = _mm256_loadu_si256( ( __m256i* )( &pSrc1[iX] ) ); + vsrc2 = _mm256_loadu_si256( ( __m256i* )( &pSrc2[iX] ) ); vsum16 = _mm256_add_epi16( vsum16, _mm256_abs_epi16( _mm256_sub_epi16( vsrc1, vsrc2 ) ) ); } + __m256i vsumtemp = _mm256_madd_epi16( vsum16, vone ); vsum32 = _mm256_add_epi32( vsum32, vsumtemp ); + pSrc1 += iStrideSrc1; pSrc2 += iStrideSrc2; } + vsum32 = _mm256_hadd_epi32( vsum32, vone ); vsum32 = _mm256_hadd_epi32( vsum32, vone ); uiSum = _mm_cvtsi128_si32( _mm256_castsi256_si128( vsum32 ) ) + _mm_cvtsi128_si32( _mm256_extracti128_si256( vsum32, 1 ) ); @@ -394,19 +405,36 @@ Distortion RdCost::xGetSAD_NxN_SIMD( const DistParam &rcDtParam ) #endif { // For width that multiple of 8 - __m128i vone = _mm_set1_epi16( 1 ); + __m128i vone = _mm_set1_epi16( 1 ); __m128i vsum32 = _mm_setzero_si128(); + for( int iY = 0; iY < iRows; iY+=iSubStep ) { - __m128i vsum16 = _mm_setzero_si128(); - for( int iX = 0; iX < iWidth; iX+=8 ) + __m128i vsrc1 = _mm_loadu_si128( ( const __m128i* )( pSrc1 ) ); + __m128i vsrc2 = _mm_loadu_si128( ( const __m128i* )( pSrc2 ) ); + __m128i vsum16 = _mm_abs_epi16( _mm_sub_epi16( vsrc1, vsrc2 ) ); + + if( iWidth >= 16 ) { - __m128i vsrc1 = _mm_loadu_si128( ( const __m128i* )( &pSrc1[iX] ) ); - __m128i vsrc2 = _mm_lddqu_si128( ( const __m128i* )( &pSrc2[iX] ) ); + vsrc1 = _mm_loadu_si128( ( const __m128i* )( &pSrc1[8] ) ); + vsrc2 = _mm_loadu_si128( ( const __m128i* )( &pSrc2[8] ) ); vsum16 = _mm_add_epi16( vsum16, _mm_abs_epi16( _mm_sub_epi16( vsrc1, vsrc2 ) ) ); + + for( int iX = 16; iX < iWidth; iX += 16 ) + { + vsrc1 = _mm_loadu_si128( ( const __m128i* )( &pSrc1[iX] ) ); + vsrc2 = _mm_loadu_si128( ( const __m128i* )( &pSrc2[iX] ) ); + vsum16 = _mm_add_epi16( vsum16, _mm_abs_epi16( _mm_sub_epi16( vsrc1, vsrc2 ) ) ); + + vsrc1 = _mm_loadu_si128( ( const __m128i* )( &pSrc1[iX + 8] ) ); + vsrc2 = _mm_loadu_si128( ( const __m128i* )( &pSrc2[iX + 8] ) ); + vsum16 = _mm_add_epi16( vsum16, _mm_abs_epi16( _mm_sub_epi16( vsrc1, vsrc2 ) ) ); + } } + __m128i vsumtemp = _mm_madd_epi16( vsum16, vone ); vsum32 = _mm_add_epi32( vsum32, vsumtemp ); + pSrc1 += iStrideSrc1; pSrc2 += iStrideSrc2; } @@ -509,122 +537,189 @@ static uint32_t xCalcHAD4x4_SSE( const Torg *piOrg, const Tcur *piCur, const int //working up to 12-bit static uint32_t xCalcHAD8x8_SSE( const Torg *piOrg, const Tcur *piCur, const int iStrideOrg, const int iStrideCur, const int iBitDepth ) { - __m128i m1[8][2], m2[8][2]; + __m128i m1[2][8], m2[2][8]; + + CHECK( iBitDepth > 10, "Only bit-depths of up to 10 bits supported!" ); for( int k = 0; k < 8; k++ ) { __m128i r0 = ( sizeof( Torg ) > 1 ) ? ( _mm_loadu_si128( ( __m128i* )piOrg ) ) : ( _mm_unpacklo_epi8( _mm_loadl_epi64( ( const __m128i* )piOrg ), _mm_setzero_si128() ) ); __m128i r1 = ( sizeof( Tcur ) > 1 ) ? ( _mm_lddqu_si128( ( __m128i* )piCur ) ) : ( _mm_unpacklo_epi8( _mm_loadl_epi64( ( const __m128i* )piCur ), _mm_setzero_si128() ) ); // th _mm_loadu_si128( (__m128i*)piCur ) - m2[k][0] = _mm_sub_epi16( r0, r1 ); - m2[k][1] = _mm_cvtepi16_epi32( _mm_srli_si128( m2[k][0], 8 ) ); - m2[k][0] = _mm_cvtepi16_epi32( m2[k][0] ); + m2[0][k] = _mm_sub_epi16( r0, r1 ); // 11bit + //m2[1][k] = _mm_cvtepi16_epi32( _mm_srli_si128( m2[0][k], 8 ) ); + //m2[0][k] = _mm_cvtepi16_epi32( m2[0][k] ); piCur += iStrideCur; piOrg += iStrideOrg; } +#if 0 for( int i = 0; i < 2; i++ ) { //horizontal - m1[0][i] = _mm_add_epi32( m2[0][i], m2[4][i] ); - m1[1][i] = _mm_add_epi32( m2[1][i], m2[5][i] ); - m1[2][i] = _mm_add_epi32( m2[2][i], m2[6][i] ); - m1[3][i] = _mm_add_epi32( m2[3][i], m2[7][i] ); - m1[4][i] = _mm_sub_epi32( m2[0][i], m2[4][i] ); - m1[5][i] = _mm_sub_epi32( m2[1][i], m2[5][i] ); - m1[6][i] = _mm_sub_epi32( m2[2][i], m2[6][i] ); - m1[7][i] = _mm_sub_epi32( m2[3][i], m2[7][i] ); - - m2[0][i] = _mm_add_epi32( m1[0][i], m1[2][i] ); - m2[1][i] = _mm_add_epi32( m1[1][i], m1[3][i] ); - m2[2][i] = _mm_sub_epi32( m1[0][i], m1[2][i] ); - m2[3][i] = _mm_sub_epi32( m1[1][i], m1[3][i] ); - m2[4][i] = _mm_add_epi32( m1[4][i], m1[6][i] ); - m2[5][i] = _mm_add_epi32( m1[5][i], m1[7][i] ); - m2[6][i] = _mm_sub_epi32( m1[4][i], m1[6][i] ); - m2[7][i] = _mm_sub_epi32( m1[5][i], m1[7][i] ); - - m1[0][i] = _mm_add_epi32( m2[0][i], m2[1][i] ); - m1[1][i] = _mm_sub_epi32( m2[0][i], m2[1][i] ); - m1[2][i] = _mm_add_epi32( m2[2][i], m2[3][i] ); - m1[3][i] = _mm_sub_epi32( m2[2][i], m2[3][i] ); - m1[4][i] = _mm_add_epi32( m2[4][i], m2[5][i] ); - m1[5][i] = _mm_sub_epi32( m2[4][i], m2[5][i] ); - m1[6][i] = _mm_add_epi32( m2[6][i], m2[7][i] ); - m1[7][i] = _mm_sub_epi32( m2[6][i], m2[7][i] ); - - m2[0][i] = _mm_unpacklo_epi32( m1[0][i], m1[1][i] ); - m2[1][i] = _mm_unpacklo_epi32( m1[2][i], m1[3][i] ); - m2[2][i] = _mm_unpackhi_epi32( m1[0][i], m1[1][i] ); - m2[3][i] = _mm_unpackhi_epi32( m1[2][i], m1[3][i] ); - m2[4][i] = _mm_unpacklo_epi32( m1[4][i], m1[5][i] ); - m2[5][i] = _mm_unpacklo_epi32( m1[6][i], m1[7][i] ); - m2[6][i] = _mm_unpackhi_epi32( m1[4][i], m1[5][i] ); - m2[7][i] = _mm_unpackhi_epi32( m1[6][i], m1[7][i] ); - - m1[0][i] = _mm_unpacklo_epi64( m2[0][i], m2[1][i] ); - m1[1][i] = _mm_unpackhi_epi64( m2[0][i], m2[1][i] ); - m1[2][i] = _mm_unpacklo_epi64( m2[2][i], m2[3][i] ); - m1[3][i] = _mm_unpackhi_epi64( m2[2][i], m2[3][i] ); - m1[4][i] = _mm_unpacklo_epi64( m2[4][i], m2[5][i] ); - m1[5][i] = _mm_unpackhi_epi64( m2[4][i], m2[5][i] ); - m1[6][i] = _mm_unpacklo_epi64( m2[6][i], m2[7][i] ); - m1[7][i] = _mm_unpackhi_epi64( m2[6][i], m2[7][i] ); + m1[i][0] = _mm_add_epi32( m2[i][0], m2[i][4] ); + m1[i][1] = _mm_add_epi32( m2[i][1], m2[i][5] ); + m1[i][2] = _mm_add_epi32( m2[i][2], m2[i][6] ); + m1[i][3] = _mm_add_epi32( m2[i][3], m2[i][7] ); + m1[i][4] = _mm_sub_epi32( m2[i][0], m2[i][4] ); + m1[i][5] = _mm_sub_epi32( m2[i][1], m2[i][5] ); + m1[i][6] = _mm_sub_epi32( m2[i][2], m2[i][6] ); + m1[i][7] = _mm_sub_epi32( m2[i][3], m2[i][7] ); + + m2[i][0] = _mm_add_epi32( m1[i][0], m1[i][2] ); + m2[i][1] = _mm_add_epi32( m1[i][1], m1[i][3] ); + m2[i][2] = _mm_sub_epi32( m1[i][0], m1[i][2] ); + m2[i][3] = _mm_sub_epi32( m1[i][1], m1[i][3] ); + m2[i][4] = _mm_add_epi32( m1[i][4], m1[i][6] ); + m2[i][5] = _mm_add_epi32( m1[i][5], m1[i][7] ); + m2[i][6] = _mm_sub_epi32( m1[i][4], m1[i][6] ); + m2[i][7] = _mm_sub_epi32( m1[i][5], m1[i][7] ); + + m1[i][0] = _mm_add_epi32( m2[i][0], m2[i][1] ); + m1[i][1] = _mm_sub_epi32( m2[i][0], m2[i][1] ); + m1[i][2] = _mm_add_epi32( m2[i][2], m2[i][3] ); + m1[i][3] = _mm_sub_epi32( m2[i][2], m2[i][3] ); + m1[i][4] = _mm_add_epi32( m2[i][4], m2[i][5] ); + m1[i][5] = _mm_sub_epi32( m2[i][4], m2[i][5] ); + m1[i][6] = _mm_add_epi32( m2[i][6], m2[i][7] ); + m1[i][7] = _mm_sub_epi32( m2[i][6], m2[i][7] ); + + m2[i][0] = _mm_unpacklo_epi32( m1[i][0], m1[i][1] ); + m2[i][1] = _mm_unpacklo_epi32( m1[i][2], m1[i][3] ); + m2[i][2] = _mm_unpackhi_epi32( m1[i][0], m1[i][1] ); + m2[i][3] = _mm_unpackhi_epi32( m1[i][2], m1[i][3] ); + m2[i][4] = _mm_unpacklo_epi32( m1[i][4], m1[i][5] ); + m2[i][5] = _mm_unpacklo_epi32( m1[i][6], m1[i][7] ); + m2[i][6] = _mm_unpackhi_epi32( m1[i][4], m1[i][5] ); + m2[i][7] = _mm_unpackhi_epi32( m1[i][6], m1[i][7] ); + + m1[i][0] = _mm_unpacklo_epi64( m2[i][0], m2[i][1] ); + m1[i][1] = _mm_unpackhi_epi64( m2[i][0], m2[i][1] ); + m1[i][2] = _mm_unpacklo_epi64( m2[i][2], m2[i][3] ); + m1[i][3] = _mm_unpackhi_epi64( m2[i][2], m2[i][3] ); + m1[i][4] = _mm_unpacklo_epi64( m2[i][4], m2[i][5] ); + m1[i][5] = _mm_unpackhi_epi64( m2[i][4], m2[i][5] ); + m1[i][6] = _mm_unpacklo_epi64( m2[i][6], m2[i][7] ); + m1[i][7] = _mm_unpackhi_epi64( m2[i][6], m2[i][7] ); } +#else + //horizontal + m1[0][0] = _mm_add_epi16( m2[0][0], m2[0][4] ); + m1[0][1] = _mm_add_epi16( m2[0][1], m2[0][5] ); + m1[0][2] = _mm_add_epi16( m2[0][2], m2[0][6] ); + m1[0][3] = _mm_add_epi16( m2[0][3], m2[0][7] ); + m1[0][4] = _mm_sub_epi16( m2[0][0], m2[0][4] ); + m1[0][5] = _mm_sub_epi16( m2[0][1], m2[0][5] ); + m1[0][6] = _mm_sub_epi16( m2[0][2], m2[0][6] ); + m1[0][7] = _mm_sub_epi16( m2[0][3], m2[0][7] ); // 12 bit + + m2[0][0] = _mm_add_epi16( m1[0][0], m1[0][2] ); + m2[0][1] = _mm_add_epi16( m1[0][1], m1[0][3] ); + m2[0][2] = _mm_sub_epi16( m1[0][0], m1[0][2] ); + m2[0][3] = _mm_sub_epi16( m1[0][1], m1[0][3] ); + m2[0][4] = _mm_add_epi16( m1[0][4], m1[0][6] ); + m2[0][5] = _mm_add_epi16( m1[0][5], m1[0][7] ); + m2[0][6] = _mm_sub_epi16( m1[0][4], m1[0][6] ); + m2[0][7] = _mm_sub_epi16( m1[0][5], m1[0][7] ); // 13 bit + + m1[0][0] = _mm_add_epi16( m2[0][0], m2[0][1] ); + m1[0][1] = _mm_sub_epi16( m2[0][0], m2[0][1] ); + m1[0][2] = _mm_add_epi16( m2[0][2], m2[0][3] ); + m1[0][3] = _mm_sub_epi16( m2[0][2], m2[0][3] ); + m1[0][4] = _mm_add_epi16( m2[0][4], m2[0][5] ); + m1[0][5] = _mm_sub_epi16( m2[0][4], m2[0][5] ); + m1[0][6] = _mm_add_epi16( m2[0][6], m2[0][7] ); + m1[0][7] = _mm_sub_epi16( m2[0][6], m2[0][7] ); // 14 bit + + m2[0][0] = _mm_unpacklo_epi16( m1[0][0], m1[0][1] ); + m2[0][1] = _mm_unpacklo_epi16( m1[0][2], m1[0][3] ); + m2[0][2] = _mm_unpackhi_epi16( m1[0][0], m1[0][1] ); + m2[0][3] = _mm_unpackhi_epi16( m1[0][2], m1[0][3] ); + m2[0][4] = _mm_unpacklo_epi16( m1[0][4], m1[0][5] ); + m2[0][5] = _mm_unpacklo_epi16( m1[0][6], m1[0][7] ); + m2[0][6] = _mm_unpackhi_epi16( m1[0][4], m1[0][5] ); + m2[0][7] = _mm_unpackhi_epi16( m1[0][6], m1[0][7] ); + + m1[0][0] = _mm_unpacklo_epi32( m2[0][0], m2[0][1] ); + m1[0][1] = _mm_unpackhi_epi32( m2[0][0], m2[0][1] ); + m1[0][2] = _mm_unpacklo_epi32( m2[0][2], m2[0][3] ); + m1[0][3] = _mm_unpackhi_epi32( m2[0][2], m2[0][3] ); + m1[0][4] = _mm_unpacklo_epi32( m2[0][4], m2[0][5] ); + m1[0][5] = _mm_unpackhi_epi32( m2[0][4], m2[0][5] ); + m1[0][6] = _mm_unpacklo_epi32( m2[0][6], m2[0][7] ); + m1[0][7] = _mm_unpackhi_epi32( m2[0][6], m2[0][7] ); + + m1[1][0] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][0], 8 ) ); + m1[0][0] = _mm_cvtepi16_epi32( m1[0][0] ); + m1[1][1] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][1], 8 ) ); + m1[0][1] = _mm_cvtepi16_epi32( m1[0][1] ); + m1[1][2] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][2], 8 ) ); + m1[0][2] = _mm_cvtepi16_epi32( m1[0][2] ); + m1[1][3] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][3], 8 ) ); + m1[0][3] = _mm_cvtepi16_epi32( m1[0][3] ); + m1[1][4] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][4], 8 ) ); + m1[0][4] = _mm_cvtepi16_epi32( m1[0][4] ); + m1[1][5] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][5], 8 ) ); + m1[0][5] = _mm_cvtepi16_epi32( m1[0][5] ); + m1[1][6] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][6], 8 ) ); + m1[0][6] = _mm_cvtepi16_epi32( m1[0][6] ); + m1[1][7] = _mm_cvtepi16_epi32( _mm_srli_si128( m1[0][7], 8 ) ); + m1[0][7] = _mm_cvtepi16_epi32( m1[0][7] ); +#endif - __m128i n1[8][2]; - __m128i n2[8][2]; + __m128i n1[2][8]; + __m128i n2[2][8]; for( int i = 0; i < 8; i++ ) { int ii = i % 4; int ij = i >> 2; - n2[i][0] = m1[ii ][ij]; - n2[i][1] = m1[ii + 4][ij]; + n2[0][i] = m1[ij][ii ]; + n2[1][i] = m1[ij][ii + 4]; } for( int i = 0; i < 2; i++ ) { - n1[0][i] = _mm_add_epi32( n2[0][i], n2[4][i] ); - n1[1][i] = _mm_add_epi32( n2[1][i], n2[5][i] ); - n1[2][i] = _mm_add_epi32( n2[2][i], n2[6][i] ); - n1[3][i] = _mm_add_epi32( n2[3][i], n2[7][i] ); - n1[4][i] = _mm_sub_epi32( n2[0][i], n2[4][i] ); - n1[5][i] = _mm_sub_epi32( n2[1][i], n2[5][i] ); - n1[6][i] = _mm_sub_epi32( n2[2][i], n2[6][i] ); - n1[7][i] = _mm_sub_epi32( n2[3][i], n2[7][i] ); - - n2[0][i] = _mm_add_epi32( n1[0][i], n1[2][i] ); - n2[1][i] = _mm_add_epi32( n1[1][i], n1[3][i] ); - n2[2][i] = _mm_sub_epi32( n1[0][i], n1[2][i] ); - n2[3][i] = _mm_sub_epi32( n1[1][i], n1[3][i] ); - n2[4][i] = _mm_add_epi32( n1[4][i], n1[6][i] ); - n2[5][i] = _mm_add_epi32( n1[5][i], n1[7][i] ); - n2[6][i] = _mm_sub_epi32( n1[4][i], n1[6][i] ); - n2[7][i] = _mm_sub_epi32( n1[5][i], n1[7][i] ); - - n1[0][i] = _mm_abs_epi32( _mm_add_epi32( n2[0][i], n2[1][i] ) ); - n1[1][i] = _mm_abs_epi32( _mm_sub_epi32( n2[0][i], n2[1][i] ) ); - n1[2][i] = _mm_abs_epi32( _mm_add_epi32( n2[2][i], n2[3][i] ) ); - n1[3][i] = _mm_abs_epi32( _mm_sub_epi32( n2[2][i], n2[3][i] ) ); - n1[4][i] = _mm_abs_epi32( _mm_add_epi32( n2[4][i], n2[5][i] ) ); - n1[5][i] = _mm_abs_epi32( _mm_sub_epi32( n2[4][i], n2[5][i] ) ); - n1[6][i] = _mm_abs_epi32( _mm_add_epi32( n2[6][i], n2[7][i] ) ); - n1[7][i] = _mm_abs_epi32( _mm_sub_epi32( n2[6][i], n2[7][i] ) ); + n1[i][0] = _mm_add_epi32( n2[i][0], n2[i][4] ); + n1[i][1] = _mm_add_epi32( n2[i][1], n2[i][5] ); + n1[i][2] = _mm_add_epi32( n2[i][2], n2[i][6] ); + n1[i][3] = _mm_add_epi32( n2[i][3], n2[i][7] ); + n1[i][4] = _mm_sub_epi32( n2[i][0], n2[i][4] ); + n1[i][5] = _mm_sub_epi32( n2[i][1], n2[i][5] ); + n1[i][6] = _mm_sub_epi32( n2[i][2], n2[i][6] ); + n1[i][7] = _mm_sub_epi32( n2[i][3], n2[i][7] ); + + n2[i][0] = _mm_add_epi32( n1[i][0], n1[i][2] ); + n2[i][1] = _mm_add_epi32( n1[i][1], n1[i][3] ); + n2[i][2] = _mm_sub_epi32( n1[i][0], n1[i][2] ); + n2[i][3] = _mm_sub_epi32( n1[i][1], n1[i][3] ); + n2[i][4] = _mm_add_epi32( n1[i][4], n1[i][6] ); + n2[i][5] = _mm_add_epi32( n1[i][5], n1[i][7] ); + n2[i][6] = _mm_sub_epi32( n1[i][4], n1[i][6] ); + n2[i][7] = _mm_sub_epi32( n1[i][5], n1[i][7] ); + + n1[i][0] = _mm_abs_epi32( _mm_add_epi32( n2[i][0], n2[i][1] ) ); + n1[i][1] = _mm_abs_epi32( _mm_sub_epi32( n2[i][0], n2[i][1] ) ); + n1[i][2] = _mm_abs_epi32( _mm_add_epi32( n2[i][2], n2[i][3] ) ); + n1[i][3] = _mm_abs_epi32( _mm_sub_epi32( n2[i][2], n2[i][3] ) ); + n1[i][4] = _mm_abs_epi32( _mm_add_epi32( n2[i][4], n2[i][5] ) ); + n1[i][5] = _mm_abs_epi32( _mm_sub_epi32( n2[i][4], n2[i][5] ) ); + n1[i][6] = _mm_abs_epi32( _mm_add_epi32( n2[i][6], n2[i][7] ) ); + n1[i][7] = _mm_abs_epi32( _mm_sub_epi32( n2[i][6], n2[i][7] ) ); } for( int i = 0; i < 8; i++ ) { - m1[i][0] = _mm_add_epi32( n1[i][0], n1[i][1] ); + m1[0][i] = _mm_add_epi32( n1[0][i], n1[1][i] ); } - m1[0][0] = _mm_add_epi32( m1[0][0], m1[1][0] ); - m1[2][0] = _mm_add_epi32( m1[2][0], m1[3][0] ); - m1[4][0] = _mm_add_epi32( m1[4][0], m1[5][0] ); - m1[6][0] = _mm_add_epi32( m1[6][0], m1[7][0] ); + m1[0][0] = _mm_add_epi32( m1[0][0], m1[0][1] ); + m1[0][2] = _mm_add_epi32( m1[0][2], m1[0][3] ); + m1[0][4] = _mm_add_epi32( m1[0][4], m1[0][5] ); + m1[0][6] = _mm_add_epi32( m1[0][6], m1[0][7] ); - m1[0][0] = _mm_add_epi32( m1[0][0], m1[2][0] ); - m1[4][0] = _mm_add_epi32( m1[4][0], m1[6][0] ); - __m128i iSum = _mm_add_epi32( m1[0][0], m1[4][0] ); + m1[0][0] = _mm_add_epi32( m1[0][0], m1[0][2] ); + m1[0][4] = _mm_add_epi32( m1[0][4], m1[0][6] ); + __m128i iSum = _mm_add_epi32( m1[0][0], m1[0][4] ); iSum = _mm_hadd_epi32( iSum, iSum ); iSum = _mm_hadd_epi32( iSum, iSum ); @@ -1325,21 +1420,22 @@ static uint32_t xCalcHAD16x16_AVX2( const Torg *piOrg, const Tcur *piCur, const const int iLoops = 2; __m256i m1[2][8], m2[2][8]; + CHECK( iBitDepth > 10, "Only bitdepths up to 10 supported!" ); + for( int l = 0; l < iLoops; l++ ) { + for( int k = 0; k < 8; k++ ) { - for( int k = 0; k < 8; k++ ) - { - __m256i r0 = _mm256_lddqu_si256( ( __m256i* ) piOrg ); - __m256i r1 = _mm256_lddqu_si256( ( __m256i* ) piCur ); - m2[0][k] = _mm256_sub_epi16( r0, r1 ); - m2[1][k] = _mm256_cvtepi16_epi32( _mm256_extracti128_si256( m2[0][k], 1 ) ); - m2[0][k] = _mm256_cvtepi16_epi32( _mm256_castsi256_si128( m2[0][k] ) ); - piCur += iStrideCur; - piOrg += iStrideOrg; - } + __m256i r0 = _mm256_loadu_si256( ( __m256i* ) piOrg ); + __m256i r1 = _mm256_loadu_si256( ( __m256i* ) piCur ); + m2[0][k] = _mm256_sub_epi16( r0, r1 ); // 11 bit + //m2[1][k] = _mm256_cvtepi16_epi32( _mm256_extracti128_si256( m2[0][k], 1 ) ); + //m2[0][k] = _mm256_cvtepi16_epi32( _mm256_castsi256_si128( m2[0][k] ) ); + piCur += iStrideCur; + piOrg += iStrideOrg; } +#if 0 constexpr int perm_unpacklo_epi128 = ( 0 << 0 ) + ( 2 << 4 ); constexpr int perm_unpackhi_epi128 = ( 1 << 0 ) + ( 3 << 4 ); @@ -1419,6 +1515,82 @@ static uint32_t xCalcHAD16x16_AVX2( const Torg *piOrg, const Tcur *piCur, const m1[1][5] = _mm256_permute2x128_si256( m2[0][5], m2[1][5], perm_unpackhi_epi128 ); m1[1][6] = _mm256_permute2x128_si256( m2[0][6], m2[1][6], perm_unpackhi_epi128 ); m1[1][7] = _mm256_permute2x128_si256( m2[0][7], m2[1][7], perm_unpackhi_epi128 ); +#else + m1[0][0] = _mm256_add_epi16( m2[0][0], m2[0][4] ); + m1[0][1] = _mm256_add_epi16( m2[0][1], m2[0][5] ); + m1[0][2] = _mm256_add_epi16( m2[0][2], m2[0][6] ); + m1[0][3] = _mm256_add_epi16( m2[0][3], m2[0][7] ); + m1[0][4] = _mm256_sub_epi16( m2[0][0], m2[0][4] ); + m1[0][5] = _mm256_sub_epi16( m2[0][1], m2[0][5] ); + m1[0][6] = _mm256_sub_epi16( m2[0][2], m2[0][6] ); + m1[0][7] = _mm256_sub_epi16( m2[0][3], m2[0][7] ); // 12 bit + + m2[0][0] = _mm256_add_epi16( m1[0][0], m1[0][2] ); + m2[0][1] = _mm256_add_epi16( m1[0][1], m1[0][3] ); + m2[0][2] = _mm256_sub_epi16( m1[0][0], m1[0][2] ); + m2[0][3] = _mm256_sub_epi16( m1[0][1], m1[0][3] ); + m2[0][4] = _mm256_add_epi16( m1[0][4], m1[0][6] ); + m2[0][5] = _mm256_add_epi16( m1[0][5], m1[0][7] ); + m2[0][6] = _mm256_sub_epi16( m1[0][4], m1[0][6] ); + m2[0][7] = _mm256_sub_epi16( m1[0][5], m1[0][7] ); // 13 bit + + m1[0][0] = _mm256_add_epi16( m2[0][0], m2[0][1] ); + m1[0][1] = _mm256_sub_epi16( m2[0][0], m2[0][1] ); + m1[0][2] = _mm256_add_epi16( m2[0][2], m2[0][3] ); + m1[0][3] = _mm256_sub_epi16( m2[0][2], m2[0][3] ); + m1[0][4] = _mm256_add_epi16( m2[0][4], m2[0][5] ); + m1[0][5] = _mm256_sub_epi16( m2[0][4], m2[0][5] ); + m1[0][6] = _mm256_add_epi16( m2[0][6], m2[0][7] ); + m1[0][7] = _mm256_sub_epi16( m2[0][6], m2[0][7] ); // 14 bit + + // transpose + // 8x8 + m2[0][0] = _mm256_unpacklo_epi16( m1[0][0], m1[0][1] ); + m2[0][1] = _mm256_unpacklo_epi16( m1[0][2], m1[0][3] ); + m2[0][2] = _mm256_unpacklo_epi16( m1[0][4], m1[0][5] ); + m2[0][3] = _mm256_unpacklo_epi16( m1[0][6], m1[0][7] ); + m2[0][4] = _mm256_unpackhi_epi16( m1[0][0], m1[0][1] ); + m2[0][5] = _mm256_unpackhi_epi16( m1[0][2], m1[0][3] ); + m2[0][6] = _mm256_unpackhi_epi16( m1[0][4], m1[0][5] ); + m2[0][7] = _mm256_unpackhi_epi16( m1[0][6], m1[0][7] ); + + m1[0][0] = _mm256_unpacklo_epi32( m2[0][0], m2[0][1] ); + m1[0][1] = _mm256_unpackhi_epi32( m2[0][0], m2[0][1] ); + m1[0][2] = _mm256_unpacklo_epi32( m2[0][2], m2[0][3] ); + m1[0][3] = _mm256_unpackhi_epi32( m2[0][2], m2[0][3] ); + m1[0][4] = _mm256_unpacklo_epi32( m2[0][4], m2[0][5] ); + m1[0][5] = _mm256_unpackhi_epi32( m2[0][4], m2[0][5] ); + m1[0][6] = _mm256_unpacklo_epi32( m2[0][6], m2[0][7] ); + m1[0][7] = _mm256_unpackhi_epi32( m2[0][6], m2[0][7] ); + + m2[0][0] = _mm256_unpacklo_epi64( m1[0][0], m1[0][2] ); + m2[0][1] = _mm256_unpackhi_epi64( m1[0][0], m1[0][2] ); + m2[0][2] = _mm256_unpacklo_epi64( m1[0][1], m1[0][3] ); + m2[0][3] = _mm256_unpackhi_epi64( m1[0][1], m1[0][3] ); + m2[0][4] = _mm256_unpacklo_epi64( m1[0][4], m1[0][6] ); + m2[0][5] = _mm256_unpackhi_epi64( m1[0][4], m1[0][6] ); + m2[0][6] = _mm256_unpacklo_epi64( m1[0][5], m1[0][7] ); + m2[0][7] = _mm256_unpackhi_epi64( m1[0][5], m1[0][7] ); + + __m256i vzero = _mm256_setzero_si256(); + __m256i vtmp; + +#define UNPACKX(x) \ + vtmp = _mm256_cmpgt_epi16( vzero, m2[0][x] ); \ + m1[0][x] = _mm256_unpacklo_epi16( m2[0][x], vtmp ); \ + m1[1][x] = _mm256_unpackhi_epi16( m2[0][x], vtmp ); + + UNPACKX( 0 ); + UNPACKX( 1 ); + UNPACKX( 2 ); + UNPACKX( 3 ); + UNPACKX( 4 ); + UNPACKX( 5 ); + UNPACKX( 6 ); + UNPACKX( 7 ); + +#undef UNPACKX +#endif for( int i = 0; i < 2; i++ ) { @@ -1498,21 +1670,22 @@ static uint32_t xCalcHAD16x8_AVX2( const Torg *piOrg, const Tcur *piCur, const i #ifdef USE_AVX2 __m256i m1[16], m2[16]; + CHECK( iBitDepth > 10, "Only bitdepths up to 10 supported!" ); + { + for( int k = 0; k < 8; k++ ) { - for( int k = 0; k < 8; k++ ) - { - __m256i r0 = _mm256_lddqu_si256( (__m256i*)piOrg ); - __m256i r1 = _mm256_lddqu_si256( (__m256i*)piCur ); - m1[k] = _mm256_sub_epi16( r0, r1 ); - m1[k+8] = _mm256_cvtepi16_epi32( _mm256_extracti128_si256( m1[k], 1 ) ); - m1[k] = _mm256_cvtepi16_epi32( _mm256_castsi256_si128 ( m1[k] ) ); - piCur += iStrideCur; - piOrg += iStrideOrg; - } + __m256i r0 = _mm256_lddqu_si256( (__m256i*)piOrg ); + __m256i r1 = _mm256_lddqu_si256( (__m256i*)piCur ); + m1[k] = _mm256_sub_epi16( r0, r1 ); // 11 bit + //m1[k+8] = _mm256_cvtepi16_epi32( _mm256_extracti128_si256( m1[k], 1 ) ); + //m1[k] = _mm256_cvtepi16_epi32( _mm256_castsi256_si128 ( m1[k] ) ); + piCur += iStrideCur; + piOrg += iStrideOrg; } // vertical, first 8x8 +#if 0 m2[0] = _mm256_add_epi32( m1[0], m1[4] ); m2[1] = _mm256_add_epi32( m1[1], m1[5] ); m2[2] = _mm256_add_epi32( m1[2], m1[6] ); @@ -1625,6 +1798,67 @@ static uint32_t xCalcHAD16x8_AVX2( const Torg *piOrg, const Tcur *piCur, const i m1[8+5] = _mm256_permute2x128_si256( m2[8+4], m2[8+6], perm_unpackhi_epi128 ); m1[8+6] = _mm256_permute2x128_si256( m2[8+5], m2[8+7], perm_unpacklo_epi128 ); m1[8+7] = _mm256_permute2x128_si256( m2[8+5], m2[8+7], perm_unpackhi_epi128 ); +#else + m2[0] = _mm256_add_epi16( m1[0], m1[4] ); + m2[1] = _mm256_add_epi16( m1[1], m1[5] ); + m2[2] = _mm256_add_epi16( m1[2], m1[6] ); + m2[3] = _mm256_add_epi16( m1[3], m1[7] ); + m2[4] = _mm256_sub_epi16( m1[0], m1[4] ); + m2[5] = _mm256_sub_epi16( m1[1], m1[5] ); + m2[6] = _mm256_sub_epi16( m1[2], m1[6] ); + m2[7] = _mm256_sub_epi16( m1[3], m1[7] ); // 12 bit + + m1[0] = _mm256_add_epi16( m2[0], m2[2] ); + m1[1] = _mm256_add_epi16( m2[1], m2[3] ); + m1[2] = _mm256_sub_epi16( m2[0], m2[2] ); + m1[3] = _mm256_sub_epi16( m2[1], m2[3] ); + m1[4] = _mm256_add_epi16( m2[4], m2[6] ); + m1[5] = _mm256_add_epi16( m2[5], m2[7] ); + m1[6] = _mm256_sub_epi16( m2[4], m2[6] ); + m1[7] = _mm256_sub_epi16( m2[5], m2[7] ); // 13 bit + + m2[0] = _mm256_add_epi16( m1[0], m1[1] ); + m2[1] = _mm256_sub_epi16( m1[0], m1[1] ); + m2[2] = _mm256_add_epi16( m1[2], m1[3] ); + m2[3] = _mm256_sub_epi16( m1[2], m1[3] ); + m2[4] = _mm256_add_epi16( m1[4], m1[5] ); + m2[5] = _mm256_sub_epi16( m1[4], m1[5] ); + m2[6] = _mm256_add_epi16( m1[6], m1[7] ); + m2[7] = _mm256_sub_epi16( m1[6], m1[7] ); // 14 bit + + m1[0] = _mm256_unpacklo_epi16( m2[0], m2[1] ); + m1[1] = _mm256_unpacklo_epi16( m2[2], m2[3] ); + m1[2] = _mm256_unpacklo_epi16( m2[4], m2[5] ); + m1[3] = _mm256_unpacklo_epi16( m2[6], m2[7] ); + m1[4] = _mm256_unpackhi_epi16( m2[0], m2[1] ); + m1[5] = _mm256_unpackhi_epi16( m2[2], m2[3] ); + m1[6] = _mm256_unpackhi_epi16( m2[4], m2[5] ); + m1[7] = _mm256_unpackhi_epi16( m2[6], m2[7] ); + + m2[0] = _mm256_unpacklo_epi32( m1[0], m1[1] ); + m2[1] = _mm256_unpackhi_epi32( m1[0], m1[1] ); + m2[2] = _mm256_unpacklo_epi32( m1[2], m1[3] ); + m2[3] = _mm256_unpackhi_epi32( m1[2], m1[3] ); + m2[4] = _mm256_unpacklo_epi32( m1[4], m1[5] ); + m2[5] = _mm256_unpackhi_epi32( m1[4], m1[5] ); + m2[6] = _mm256_unpacklo_epi32( m1[6], m1[7] ); + m2[7] = _mm256_unpackhi_epi32( m1[6], m1[7] ); + + m1[0] = _mm256_unpacklo_epi64( m2[0], m2[2] ); + m1[1] = _mm256_unpackhi_epi64( m2[0], m2[2] ); + m1[2] = _mm256_unpacklo_epi64( m2[1], m2[3] ); + m1[3] = _mm256_unpackhi_epi64( m2[1], m2[3] ); + m1[4] = _mm256_unpacklo_epi64( m2[4], m2[6] ); + m1[5] = _mm256_unpackhi_epi64( m2[4], m2[6] ); + m1[6] = _mm256_unpacklo_epi64( m2[5], m2[7] ); + m1[7] = _mm256_unpackhi_epi64( m2[5], m2[7] ); + + for( int k = 0; k < 8; k++ ) + { + m1[k+8] = _mm256_cvtepi16_epi32( _mm256_extracti128_si256( m1[k], 1 ) ); + m1[k] = _mm256_cvtepi16_epi32( _mm256_castsi256_si128 ( m1[k] ) ); + } +#endif // horizontal { diff --git a/source/Lib/CommonLib/x86/SampleAdaptiveOffsetX86.h b/source/Lib/CommonLib/x86/SampleAdaptiveOffsetX86.h index 5def8f6ab..a5f3403de 100644 --- a/source/Lib/CommonLib/x86/SampleAdaptiveOffsetX86.h +++ b/source/Lib/CommonLib/x86/SampleAdaptiveOffsetX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file SampleAdaptiveOffsetX86.h \brief SAO filter class */ diff --git a/source/Lib/CommonLib/x86/TrafoX86.h b/source/Lib/CommonLib/x86/TrafoX86.h index 60f764323..ba952e644 100644 --- a/source/Lib/CommonLib/x86/TrafoX86.h +++ b/source/Lib/CommonLib/x86/TrafoX86.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file TrafoX86.h \brief SIMD averaging. */ @@ -344,6 +348,25 @@ void fastFwd_SSE( const TMatrixCoeff* tc, const TCoeff* src, TCoeff* dst, unsign { TCoeff* dstPtr = dst + i; const TMatrixCoeff* itPtr = tc; + + __m256i vsrcarr[2][4]; + + for( int k = 0; k < trSize; k += 16 ) + { + __m256i vsrc0 = _mm256_load_si256( ( const __m256i* ) &src[k + 0] ); + __m256i vsrc1 = _mm256_load_si256( ( const __m256i* ) &src[k + 8] ); + __m256i vsrc = _mm256_packs_epi32( vsrc0, vsrc1 ); + vsrc = _mm256_permute4x64_epi64( vsrc, ( 0 << 0 ) + ( 2 << 2 ) + ( 1 << 4 ) + ( 3 << 6 ) ); + + vsrcarr[0][k >> 4] = vsrc; + + vsrc0 = _mm256_load_si256( ( const __m256i* ) &src[k + 0 + trSize] ); + vsrc1 = _mm256_load_si256( ( const __m256i* ) &src[k + 8 + trSize] ); + vsrc = _mm256_packs_epi32( vsrc0, vsrc1 ); + vsrc = _mm256_permute4x64_epi64( vsrc, ( 0 << 0 ) + ( 2 << 2 ) + ( 1 << 4 ) + ( 3 << 6 ) ); + + vsrcarr[1][k >> 4] = vsrc; + } for( int j = 0; j < cutoff; j += 4 ) { @@ -363,28 +386,25 @@ void fastFwd_SSE( const TMatrixCoeff* tc, const TCoeff* src, TCoeff* dst, unsign #if 0 #if defined( _MSC_VER ) && _MSC_VER > 1900 - __m256i vit0 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 0 + 0 * trSize] ); - __m256i vit1 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 0 + 1 * trSize] ); - __m256i vit2 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 0 + 2 * trSize] ); - __m256i vit3 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 0 + 3 * trSize] ); + __m256i vit0 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 0 * trSize] ); + __m256i vit1 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 1 * trSize] ); + __m256i vit2 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 2 * trSize] ); + __m256i vit3 = _mm256_stream_load_si256( ( const __m256i* ) &itPtr[k + 3 * trSize] ); #else - __m256i vit0 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 0 + 0 * trSize] ); - __m256i vit1 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 0 + 1 * trSize] ); - __m256i vit2 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 0 + 2 * trSize] ); - __m256i vit3 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 0 + 3 * trSize] ); + __m256i vit0 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 0 * trSize] ); + __m256i vit1 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 1 * trSize] ); + __m256i vit2 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 2 * trSize] ); + __m256i vit3 = _mm256_stream_load_si256( ( __m256i* ) &itPtr[k + 3 * trSize] ); #endif #else - __m256i vit0 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 0 + 0 * trSize] ); - __m256i vit1 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 0 + 1 * trSize] ); - __m256i vit2 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 0 + 2 * trSize] ); - __m256i vit3 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 0 + 3 * trSize] ); + __m256i vit0 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 0 * trSize] ); + __m256i vit1 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 1 * trSize] ); + __m256i vit2 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 2 * trSize] ); + __m256i vit3 = _mm256_load_si256( ( const __m256i* ) &itPtr[k + 3 * trSize] ); #endif - // first source line - __m256i vsrc0 = _mm256_load_si256( ( const __m256i* ) &src [k + 0] ); - __m256i vsrc1 = _mm256_load_si256( ( const __m256i* ) &src [k + 8] ); - __m256i vsrc = _mm256_packs_epi32( vsrc0, vsrc1 ); - vsrc = _mm256_permute4x64_epi64( vsrc, ( 0 << 0 ) + ( 2 << 2 ) + ( 1 << 4 ) + ( 3 << 6 ) ); + // first source line + __m256i vsrc = vsrcarr[0][k >> 4]; __m256i vtmp = _mm256_madd_epi16( vit0, vsrc ); @@ -398,13 +418,8 @@ void fastFwd_SSE( const TMatrixCoeff* tc, const TCoeff* src, TCoeff* dst, unsign vtmp = _mm256_madd_epi16( vit3, vsrc ); vsum03 = _mm256_add_epi32 ( vsum03, vtmp ); - - // second source line - vsrc0 = _mm256_load_si256( ( const __m256i* ) &src[k + 0 + trSize] ); - vsrc1 = _mm256_load_si256( ( const __m256i* ) &src[k + 8 + trSize] ); - - vsrc = _mm256_packs_epi32( vsrc0, vsrc1 ); - vsrc = _mm256_permute4x64_epi64( vsrc, ( 0 << 0 ) + ( 2 << 2 ) + ( 1 << 4 ) + ( 3 << 6 ) ); + + vsrc = vsrcarr[1][k >> 4]; vtmp = _mm256_madd_epi16( vit0, vsrc ); vsum10 = _mm256_add_epi32 ( vsum10, vtmp ); @@ -470,6 +485,27 @@ void fastFwd_SSE( const TMatrixCoeff* tc, const TCoeff* src, TCoeff* dst, unsign { TCoeff* dstPtr = dst + i; const TMatrixCoeff* itPtr = tc; + +#if USE_AVX2 + __m128i vsrcarr[2][1]; +#else + __m128i vsrcarr[2][8]; +#endif + + for( int k = 0; k < trSize; k += 8 ) + { + __m128i vsrc0 = _mm_load_si128( ( const __m128i* ) &src[k + 0] ); + __m128i vsrc1 = _mm_load_si128( ( const __m128i* ) &src[k + 4] ); + __m128i vsrc = _mm_packs_epi32( vsrc0, vsrc1 ); + + vsrcarr[0][k >> 3] = vsrc; + + vsrc0 = _mm_load_si128( ( const __m128i* ) &src[k + 0 + trSize] ); + vsrc1 = _mm_load_si128( ( const __m128i* ) &src[k + 4 + trSize] ); + vsrc = _mm_packs_epi32( vsrc0, vsrc1 ); + + vsrcarr[1][k >> 3] = vsrc; + } for( int j = 0; j < cutoff; j += 4 ) { @@ -489,27 +525,25 @@ void fastFwd_SSE( const TMatrixCoeff* tc, const TCoeff* src, TCoeff* dst, unsign #if 0 #if defined( _MSC_VER ) && _MSC_VER > 1900 - __m128i vit0 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 0 + 0 * trSize] ); - __m128i vit1 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 0 + 1 * trSize] ); - __m128i vit2 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 0 + 2 * trSize] ); - __m128i vit3 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 0 + 3 * trSize] ); + __m128i vit0 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 0 * trSize] ); + __m128i vit1 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 1 * trSize] ); + __m128i vit2 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 2 * trSize] ); + __m128i vit3 = _mm_stream_load_si128( ( const __m128i* ) &itPtr[k + 3 * trSize] ); #else - __m128i vit0 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 0 + 0 * trSize] ); - __m128i vit1 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 0 + 1 * trSize] ); - __m128i vit2 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 0 + 2 * trSize] ); - __m128i vit3 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 0 + 3 * trSize] ); + __m128i vit0 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 0 * trSize] ); + __m128i vit1 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 1 * trSize] ); + __m128i vit2 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 2 * trSize] ); + __m128i vit3 = _mm_stream_load_si128( ( __m128i* ) &itPtr[k + 3 * trSize] ); #endif #else - __m128i vit0 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 0 + 0 * trSize] ); - __m128i vit1 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 0 + 1 * trSize] ); - __m128i vit2 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 0 + 2 * trSize] ); - __m128i vit3 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 0 + 3 * trSize] ); + __m128i vit0 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 0 * trSize] ); + __m128i vit1 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 1 * trSize] ); + __m128i vit2 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 2 * trSize] ); + __m128i vit3 = _mm_load_si128( ( const __m128i* ) &itPtr[k + 3 * trSize] ); #endif - // first source line - __m128i vsrc0 = _mm_load_si128( ( const __m128i* ) &src [k + 0] ); - __m128i vsrc1 = _mm_load_si128( ( const __m128i* ) &src [k + 4] ); - - __m128i vsrc = _mm_packs_epi32( vsrc0, vsrc1 ); + + // fist source line + __m128i vsrc = vsrcarr[0][k >> 3]; __m128i vtmp = _mm_madd_epi16( vit0, vsrc ); @@ -525,10 +559,7 @@ void fastFwd_SSE( const TMatrixCoeff* tc, const TCoeff* src, TCoeff* dst, unsign vsum03 = _mm_add_epi32 ( vsum03, vtmp ); // second source line - vsrc0 = _mm_load_si128( ( const __m128i* ) &src[k + 0 + trSize] ); - vsrc1 = _mm_load_si128( ( const __m128i* ) &src[k + 4 + trSize] ); - - vsrc = _mm_packs_epi32( vsrc0, vsrc1 ); + vsrc = vsrcarr[1][k >> 3]; vtmp = _mm_madd_epi16( vit0, vsrc ); vsum10 = _mm_add_epi32 ( vsum10, vtmp ); diff --git a/source/Lib/CommonLib/x86/avx/AdaptiveLoopFilter_avx.cpp b/source/Lib/CommonLib/x86/avx/AdaptiveLoopFilter_avx.cpp index d99e3b87a..44fe4c46d 100644 --- a/source/Lib/CommonLib/x86/avx/AdaptiveLoopFilter_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/AdaptiveLoopFilter_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../AdaptiveLoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/avx/AffineGradientSearch_avx.cpp b/source/Lib/CommonLib/x86/avx/AffineGradientSearch_avx.cpp index 62a5c21ff..ee3c79e77 100644 --- a/source/Lib/CommonLib/x86/avx/AffineGradientSearch_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/AffineGradientSearch_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../AffineGradientSearchX86.h" diff --git a/source/Lib/CommonLib/x86/avx/Buffer_avx.cpp b/source/Lib/CommonLib/x86/avx/Buffer_avx.cpp index a4686bf05..ef84e68b2 100644 --- a/source/Lib/CommonLib/x86/avx/Buffer_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/Buffer_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../BufferX86.h" diff --git a/source/Lib/CommonLib/x86/avx/InterPred_avx.cpp b/source/Lib/CommonLib/x86/avx/InterPred_avx.cpp index a0af6225d..0b4537b54 100644 --- a/source/Lib/CommonLib/x86/avx/InterPred_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/InterPred_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterPredX86.h" diff --git a/source/Lib/CommonLib/x86/avx/InterpolationFilter_avx.cpp b/source/Lib/CommonLib/x86/avx/InterpolationFilter_avx.cpp index 62eba59c9..692906598 100644 --- a/source/Lib/CommonLib/x86/avx/InterpolationFilter_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/InterpolationFilter_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterpolationFilterX86.h" diff --git a/source/Lib/CommonLib/x86/avx/IntraPred_avx.cpp b/source/Lib/CommonLib/x86/avx/IntraPred_avx.cpp index b1861e73d..3c996aee4 100644 --- a/source/Lib/CommonLib/x86/avx/IntraPred_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/IntraPred_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../IntraPredX86.h" diff --git a/source/Lib/CommonLib/x86/avx/LoopFilter_avx.cpp b/source/Lib/CommonLib/x86/avx/LoopFilter_avx.cpp index e100f3586..9461f2b7d 100644 --- a/source/Lib/CommonLib/x86/avx/LoopFilter_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/LoopFilter_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../LoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/avx/MCTF_avx.cpp b/source/Lib/CommonLib/x86/avx/MCTF_avx.cpp index ae59f80f6..49f3ca528 100644 --- a/source/Lib/CommonLib/x86/avx/MCTF_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/MCTF_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../MCTFX86.h" diff --git a/source/Lib/CommonLib/x86/avx/Quant_avx.cpp b/source/Lib/CommonLib/x86/avx/Quant_avx.cpp index 4607d484e..e5a2c4cde 100644 --- a/source/Lib/CommonLib/x86/avx/Quant_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/Quant_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../QuantX86.h" diff --git a/source/Lib/CommonLib/x86/avx/RdCost_avx.cpp b/source/Lib/CommonLib/x86/avx/RdCost_avx.cpp index 8b47b8b33..457197f36 100644 --- a/source/Lib/CommonLib/x86/avx/RdCost_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/RdCost_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../RdCostX86.h" diff --git a/source/Lib/CommonLib/x86/avx/SampleAdaptiveOffset_avx.cpp b/source/Lib/CommonLib/x86/avx/SampleAdaptiveOffset_avx.cpp index 7e0fb670e..a4cfb7af1 100644 --- a/source/Lib/CommonLib/x86/avx/SampleAdaptiveOffset_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/SampleAdaptiveOffset_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../SampleAdaptiveOffsetX86.h" diff --git a/source/Lib/CommonLib/x86/avx/Trafo_avx.cpp b/source/Lib/CommonLib/x86/avx/Trafo_avx.cpp index 57411c015..3c8d0129a 100644 --- a/source/Lib/CommonLib/x86/avx/Trafo_avx.cpp +++ b/source/Lib/CommonLib/x86/avx/Trafo_avx.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../TrafoX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/AdaptiveLoopFilter_avx2.cpp b/source/Lib/CommonLib/x86/avx2/AdaptiveLoopFilter_avx2.cpp index d99e3b87a..44fe4c46d 100644 --- a/source/Lib/CommonLib/x86/avx2/AdaptiveLoopFilter_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/AdaptiveLoopFilter_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../AdaptiveLoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/AffineGradientSearch_avx2.cpp b/source/Lib/CommonLib/x86/avx2/AffineGradientSearch_avx2.cpp index 62a5c21ff..ee3c79e77 100644 --- a/source/Lib/CommonLib/x86/avx2/AffineGradientSearch_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/AffineGradientSearch_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../AffineGradientSearchX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/Buffer_avx2.cpp b/source/Lib/CommonLib/x86/avx2/Buffer_avx2.cpp index a4686bf05..ef84e68b2 100644 --- a/source/Lib/CommonLib/x86/avx2/Buffer_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/Buffer_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../BufferX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/InterPred_avx2.cpp b/source/Lib/CommonLib/x86/avx2/InterPred_avx2.cpp index a0af6225d..0b4537b54 100644 --- a/source/Lib/CommonLib/x86/avx2/InterPred_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/InterPred_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterPredX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/InterpolationFilter_avx2.cpp b/source/Lib/CommonLib/x86/avx2/InterpolationFilter_avx2.cpp index 62eba59c9..692906598 100644 --- a/source/Lib/CommonLib/x86/avx2/InterpolationFilter_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/InterpolationFilter_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterpolationFilterX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/IntraPred_avx2.cpp b/source/Lib/CommonLib/x86/avx2/IntraPred_avx2.cpp index b1861e73d..3c996aee4 100644 --- a/source/Lib/CommonLib/x86/avx2/IntraPred_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/IntraPred_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../IntraPredX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/LoopFilter_avx2.cpp b/source/Lib/CommonLib/x86/avx2/LoopFilter_avx2.cpp index e100f3586..9461f2b7d 100644 --- a/source/Lib/CommonLib/x86/avx2/LoopFilter_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/LoopFilter_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../LoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/MCTF_avx2.cpp b/source/Lib/CommonLib/x86/avx2/MCTF_avx2.cpp index ae59f80f6..49f3ca528 100644 --- a/source/Lib/CommonLib/x86/avx2/MCTF_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/MCTF_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../MCTFX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/Quant_avx2.cpp b/source/Lib/CommonLib/x86/avx2/Quant_avx2.cpp index 4607d484e..e5a2c4cde 100644 --- a/source/Lib/CommonLib/x86/avx2/Quant_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/Quant_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../QuantX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/RdCost_avx2.cpp b/source/Lib/CommonLib/x86/avx2/RdCost_avx2.cpp index 8b47b8b33..457197f36 100644 --- a/source/Lib/CommonLib/x86/avx2/RdCost_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/RdCost_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../RdCostX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/SampleAdaptiveOffset_avx2.cpp b/source/Lib/CommonLib/x86/avx2/SampleAdaptiveOffset_avx2.cpp index 7e0fb670e..a4cfb7af1 100644 --- a/source/Lib/CommonLib/x86/avx2/SampleAdaptiveOffset_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/SampleAdaptiveOffset_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../SampleAdaptiveOffsetX86.h" diff --git a/source/Lib/CommonLib/x86/avx2/Trafo_avx2.cpp b/source/Lib/CommonLib/x86/avx2/Trafo_avx2.cpp index 57411c015..3c8d0129a 100644 --- a/source/Lib/CommonLib/x86/avx2/Trafo_avx2.cpp +++ b/source/Lib/CommonLib/x86/avx2/Trafo_avx2.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../TrafoX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/AdaptiveLoopFilter_sse41.cpp b/source/Lib/CommonLib/x86/sse41/AdaptiveLoopFilter_sse41.cpp index d99e3b87a..44fe4c46d 100644 --- a/source/Lib/CommonLib/x86/sse41/AdaptiveLoopFilter_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/AdaptiveLoopFilter_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../AdaptiveLoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/AffineGradientSearch_sse41.cpp b/source/Lib/CommonLib/x86/sse41/AffineGradientSearch_sse41.cpp index 62a5c21ff..ee3c79e77 100644 --- a/source/Lib/CommonLib/x86/sse41/AffineGradientSearch_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/AffineGradientSearch_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../AffineGradientSearchX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/Buffer_sse41.cpp b/source/Lib/CommonLib/x86/sse41/Buffer_sse41.cpp index a4686bf05..ef84e68b2 100644 --- a/source/Lib/CommonLib/x86/sse41/Buffer_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/Buffer_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../BufferX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/InterPred_sse41.cpp b/source/Lib/CommonLib/x86/sse41/InterPred_sse41.cpp index a0af6225d..0b4537b54 100644 --- a/source/Lib/CommonLib/x86/sse41/InterPred_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/InterPred_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterPredX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/InterpolationFilter_sse41.cpp b/source/Lib/CommonLib/x86/sse41/InterpolationFilter_sse41.cpp index 62eba59c9..692906598 100644 --- a/source/Lib/CommonLib/x86/sse41/InterpolationFilter_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/InterpolationFilter_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterpolationFilterX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/IntraPred_sse41.cpp b/source/Lib/CommonLib/x86/sse41/IntraPred_sse41.cpp index b1861e73d..3c996aee4 100644 --- a/source/Lib/CommonLib/x86/sse41/IntraPred_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/IntraPred_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../IntraPredX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/LoopFilter_sse41.cpp b/source/Lib/CommonLib/x86/sse41/LoopFilter_sse41.cpp index e100f3586..9461f2b7d 100644 --- a/source/Lib/CommonLib/x86/sse41/LoopFilter_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/LoopFilter_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../LoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/MCTF_avx41.cpp b/source/Lib/CommonLib/x86/sse41/MCTF_avx41.cpp index ae59f80f6..49f3ca528 100644 --- a/source/Lib/CommonLib/x86/sse41/MCTF_avx41.cpp +++ b/source/Lib/CommonLib/x86/sse41/MCTF_avx41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../MCTFX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/Quant_sse41.cpp b/source/Lib/CommonLib/x86/sse41/Quant_sse41.cpp index 4607d484e..e5a2c4cde 100644 --- a/source/Lib/CommonLib/x86/sse41/Quant_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/Quant_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../QuantX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/RdCost_sse41.cpp b/source/Lib/CommonLib/x86/sse41/RdCost_sse41.cpp index 8b47b8b33..457197f36 100644 --- a/source/Lib/CommonLib/x86/sse41/RdCost_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/RdCost_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../RdCostX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/SampleAdaptiveOffset_sse41.cpp b/source/Lib/CommonLib/x86/sse41/SampleAdaptiveOffset_sse41.cpp index 7e0fb670e..a4cfb7af1 100644 --- a/source/Lib/CommonLib/x86/sse41/SampleAdaptiveOffset_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/SampleAdaptiveOffset_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../SampleAdaptiveOffsetX86.h" diff --git a/source/Lib/CommonLib/x86/sse41/Trafo_sse41.cpp b/source/Lib/CommonLib/x86/sse41/Trafo_sse41.cpp index 57411c015..3c8d0129a 100644 --- a/source/Lib/CommonLib/x86/sse41/Trafo_sse41.cpp +++ b/source/Lib/CommonLib/x86/sse41/Trafo_sse41.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../TrafoX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/Buffer_sse42.cpp b/source/Lib/CommonLib/x86/sse42/Buffer_sse42.cpp index a4686bf05..ef84e68b2 100644 --- a/source/Lib/CommonLib/x86/sse42/Buffer_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/Buffer_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../BufferX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/InterPred_sse42.cpp b/source/Lib/CommonLib/x86/sse42/InterPred_sse42.cpp index a0af6225d..0b4537b54 100644 --- a/source/Lib/CommonLib/x86/sse42/InterPred_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/InterPred_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterPredX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/InterpolationFilter_sse42.cpp b/source/Lib/CommonLib/x86/sse42/InterpolationFilter_sse42.cpp index 62eba59c9..692906598 100644 --- a/source/Lib/CommonLib/x86/sse42/InterpolationFilter_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/InterpolationFilter_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../InterpolationFilterX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/IntraPred_sse42.cpp b/source/Lib/CommonLib/x86/sse42/IntraPred_sse42.cpp index b1861e73d..3c996aee4 100644 --- a/source/Lib/CommonLib/x86/sse42/IntraPred_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/IntraPred_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../IntraPredX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/LoopFilter_sse42.cpp b/source/Lib/CommonLib/x86/sse42/LoopFilter_sse42.cpp index e100f3586..9461f2b7d 100644 --- a/source/Lib/CommonLib/x86/sse42/LoopFilter_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/LoopFilter_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../LoopFilterX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/MCTF_avx42.cpp b/source/Lib/CommonLib/x86/sse42/MCTF_avx42.cpp index ae59f80f6..49f3ca528 100644 --- a/source/Lib/CommonLib/x86/sse42/MCTF_avx42.cpp +++ b/source/Lib/CommonLib/x86/sse42/MCTF_avx42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../MCTFX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/Quant_sse42.cpp b/source/Lib/CommonLib/x86/sse42/Quant_sse42.cpp index 4607d484e..e5a2c4cde 100644 --- a/source/Lib/CommonLib/x86/sse42/Quant_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/Quant_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../QuantX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/RdCost_sse42.cpp b/source/Lib/CommonLib/x86/sse42/RdCost_sse42.cpp index 8b47b8b33..457197f36 100644 --- a/source/Lib/CommonLib/x86/sse42/RdCost_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/RdCost_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../RdCostX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/SampleAdaptiveOffset_sse42.cpp b/source/Lib/CommonLib/x86/sse42/SampleAdaptiveOffset_sse42.cpp index 7e0fb670e..a4cfb7af1 100644 --- a/source/Lib/CommonLib/x86/sse42/SampleAdaptiveOffset_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/SampleAdaptiveOffset_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../SampleAdaptiveOffsetX86.h" diff --git a/source/Lib/CommonLib/x86/sse42/Trafo_sse42.cpp b/source/Lib/CommonLib/x86/sse42/Trafo_sse42.cpp index 57411c015..3c8d0129a 100644 --- a/source/Lib/CommonLib/x86/sse42/Trafo_sse42.cpp +++ b/source/Lib/CommonLib/x86/sse42/Trafo_sse42.cpp @@ -1,43 +1,47 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #include "../TrafoX86.h" diff --git a/source/Lib/DecoderLib/AnnexBread.cpp b/source/Lib/DecoderLib/AnnexBread.cpp index d62ad50d2..bc6fb7eb6 100644 --- a/source/Lib/DecoderLib/AnnexBread.cpp +++ b/source/Lib/DecoderLib/AnnexBread.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** diff --git a/source/Lib/DecoderLib/AnnexBread.h b/source/Lib/DecoderLib/AnnexBread.h index 2929f5c91..5d0a4cc0b 100644 --- a/source/Lib/DecoderLib/AnnexBread.h +++ b/source/Lib/DecoderLib/AnnexBread.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file AnnexBread.h \brief reading functions for Annex B byte streams diff --git a/source/Lib/DecoderLib/BinDecoder.cpp b/source/Lib/DecoderLib/BinDecoder.cpp index 789f530ec..bf42f1857 100644 --- a/source/Lib/DecoderLib/BinDecoder.cpp +++ b/source/Lib/DecoderLib/BinDecoder.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file BinDecoder.cpp diff --git a/source/Lib/DecoderLib/BinDecoder.h b/source/Lib/DecoderLib/BinDecoder.h index 7bd36960f..cb2e1ac60 100644 --- a/source/Lib/DecoderLib/BinDecoder.h +++ b/source/Lib/DecoderLib/BinDecoder.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file BinDecoder.h * \brief Low level binary symbol writer */ diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 15f4d771f..95394bb17 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file CABACReader.cpp @@ -760,7 +764,7 @@ PartSplit CABACReader::split_cu_mode( CodingStructure& cs, Partitioner &partitio // void cu_pred_data ( pus ) // void cu_lic_flag ( cu ) // void intra_luma_pred_modes ( pus ) -// void intra_chroma_pred_mode ( pu ) +// void intra_chroma_pred_mode ( cu ) // void cu_residual ( cu, partitioner, cuCtx ) // void rqt_root_cbf ( cu ) // bool end_of_ctu ( cu, cuCtx ) @@ -771,7 +775,8 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& CodingStructure& cs = *cu.cs; CHECK( cu.treeType != partitioner.treeType || cu.modeType != partitioner.modeType, "treeType or modeType mismatch" ); DTRACE( g_trace_ctx, D_SYNTAX, "coding_unit() treeType=%d modeType=%d\n", cu.treeType, cu.modeType ); - PredictionUnit& pu = cs.addPU(cu, partitioner.chType, &cu); + cu.initPuData(); + // skip flag if ((!cs.slice->isIntra() || cs.slice->sps->IBC) && cu.Y().valid()) { @@ -784,7 +789,7 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& cu.colorTransform = false; cs.addEmptyTUs( partitioner, &cu ); MergeCtx mrgCtx; - prediction_unit ( pu, mrgCtx ); + prediction_unit ( cu, mrgCtx ); end_of_ctu( cu, cuCtx ); return; } @@ -800,7 +805,6 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& THROW("no support"); return; } - // --> create PUs // prediction data ( intra prediction modes / reference indexes + motion vectors ) cu_pred_data( cu ); @@ -814,7 +818,7 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& void CABACReader::cu_skip_flag( CodingUnit& cu ) { - if ((cu.slice->isIntra() || cu.isConsIntra()) && cu.cs->slice->sps->IBC) + if ((cu.slice->isIntra() || CU::isConsIntra(cu)) && cu.cs->slice->sps->IBC) { cu.skip = false; cu.rootCbf = false; @@ -839,7 +843,7 @@ void CABACReader::cu_skip_flag( CodingUnit& cu ) { return; } - if( !cu.cs->slice->sps->IBC && cu.isConsIntra() ) + if( !cu.cs->slice->sps->IBC && CU::isConsIntra(cu) ) { return; } @@ -850,7 +854,7 @@ void CABACReader::cu_skip_flag( CodingUnit& cu ) if (skip && cu.cs->slice->sps->IBC) { - if (cu.lwidth() < 128 && cu.lheight() < 128 && !cu.isConsInter()) // disable IBC mode larger than 64x64 and disable IBC when only allowing inter mode + if (cu.lwidth() < 128 && cu.lheight() < 128 && !CU::isConsInter(cu)) // disable IBC mode larger than 64x64 and disable IBC when only allowing inter mode { if ( cu.lwidth() == 4 && cu.lheight() == 4 ) { @@ -867,7 +871,7 @@ void CABACReader::cu_skip_flag( CodingUnit& cu ) cu.rootCbf = false; cu.predMode = MODE_IBC; cu.mmvdSkip = false; - cu.pu->regularMergeFlag = false; + cu.regularMergeFlag = false; } else { @@ -974,13 +978,13 @@ void CABACReader::pred_mode( CodingUnit& cu ) { if (cu.cs->slice->sps->IBC && cu.chType != CH_C) { - if( cu.isConsInter() ) + if( CU::isConsInter(cu) ) { cu.predMode = MODE_INTER; return; } - if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || cu.isConsIntra() ) + if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || CU::isConsIntra(cu) ) { cu.predMode = MODE_INTRA; if (cu.lwidth() < 128 && cu.lheight() < 128) // disable IBC mode larger than 64x64 @@ -1028,16 +1032,16 @@ void CABACReader::pred_mode( CodingUnit& cu ) } else { - if( cu.isConsInter() ) + if( CU::isConsInter(cu) ) { cu.predMode = MODE_INTER; return; } - if ( cu.cs->slice->isIntra() || (cu.lwidth() == 4 && cu.lheight() == 4) || cu.isConsIntra() ) + if ( cu.cs->slice->isIntra() || (cu.lwidth() == 4 && cu.lheight() == 4) || CU::isConsIntra(cu) ) { cu.predMode = MODE_INTRA; - if (cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64 && (((isLuma(cu.chType) && cu.lwidth() * cu.lheight() > 16) || (!isLuma(cu.chType) && cu.chromaSize().area() > 16))) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) + if (cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64 && (((isLuma(cu.chType) && cu.lwidth() * cu.lheight() > 16) || (!isLuma(cu.chType) && cu.chromaSize().area() > 16))) && (!CU::isLocalSepTree(cu) || isLuma(cu.chType) ) ) { if (m_BinDecoder.decodeBin(Ctx::PLTFlag(0))) { @@ -1048,7 +1052,7 @@ void CABACReader::pred_mode( CodingUnit& cu ) else { cu.predMode = m_BinDecoder.decodeBin(Ctx::PredMode(DeriveCtx::CtxPredModeFlag())) ? MODE_INTRA : MODE_INTER; - if (cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64 && (((isLuma(cu.chType) && cu.lwidth() * cu.lheight() > 16) || (!isLuma(cu.chType) && cu.chromaSize().area() > 16)))&& (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) + if (cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64 && (((isLuma(cu.chType) && cu.lwidth() * cu.lheight() > 16) || (!isLuma(cu.chType) && cu.chromaSize().area() > 16)))&& (!CU::isLocalSepTree(cu) || isLuma(cu.chType) ) ) { if (m_BinDecoder.decodeBin(Ctx::PLTFlag(0))) { @@ -1065,41 +1069,35 @@ void CABACReader::bdpcm_mode( CodingUnit& cu, const ComponentID compID ) { if (isLuma(compID)) { - cu.bdpcmMode = 0; + cu.bdpcmM[CH_L] = 0; if (!CS::isDualITree(*cu.cs)) { - cu.bdpcmModeChroma = 0; + cu.bdpcmM[CH_C] = 0; } } else { - cu.bdpcmModeChroma = 0; + cu.bdpcmM[CH_C] = 0; } return; } - int bdpcmMode; unsigned ctxId = isLuma( compID ) ? 0 : 2; - bdpcmMode = m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId) ); + int bdpcmMode = m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId) ); if (bdpcmMode) { bdpcmMode += m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId+1) ); } + + cu.bdpcmM[toChannelType(compID)] = bdpcmMode; + if (isLuma(compID)) { - cu.bdpcmMode = bdpcmMode; - } - else - { - cu.bdpcmModeChroma = bdpcmMode; - } - if (isLuma(compID)) - { - DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_L, cu.lumaPos().x, cu.lumaPos().y, cu.lwidth(), cu.lheight(), cu.bdpcmMode); + DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_L, cu.lumaPos().x, cu.lumaPos().y, cu.lwidth(), cu.lheight(), cu.bdpcmM[CH_L]); } else { - DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_C, cu.chromaPos().x, cu.chromaPos().y, cu.chromaSize().width, cu.chromaSize().height, cu.bdpcmModeChroma); + DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_C, cu.chromaPos().x, cu.chromaPos().y, cu.chromaSize().width, cu.chromaSize().height, cu.bdpcmM[CH_C]); } } @@ -1112,7 +1110,7 @@ void CABACReader::cu_pred_data( CodingUnit &cu ) bdpcm_mode(cu, COMP_Y ); } intra_luma_pred_modes( cu ); - if( ( !cu.Y().valid() || (!cu.isSepTree() && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) ) + if( ( !cu.Y().valid() || (!CU::isSepTree(cu) && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) ) { bdpcm_mode(cu, ComponentID(CH_C)); } @@ -1126,10 +1124,7 @@ void CABACReader::cu_pred_data( CodingUnit &cu ) } MergeCtx mrgCtx; - PredictionUnit &pu = *cu.pu; - { - prediction_unit( pu, mrgCtx ); - } + prediction_unit( cu, mrgCtx ); imv_mode ( cu, mrgCtx ); affine_amvr_mode( cu, mrgCtx ); @@ -1209,18 +1204,16 @@ void CABACReader::xReadTruncBinCode(uint32_t& symbol, uint32_t maxSymbol) void CABACReader::extend_ref_line(CodingUnit& cu) { - if( !cu.cs->sps->MRL || !cu.Y().valid() || cu.predMode != MODE_INTRA || !isLuma(cu.chType) || cu.bdpcmMode ) + if( !cu.cs->sps->MRL || !cu.Y().valid() || cu.predMode != MODE_INTRA || !isLuma(cu.chType) || cu.bdpcmM[CH_L] ) { - cu.pu->multiRefIdx = 0; + cu.multiRefIdx = 0; return; } - PredictionUnit* pu = cu.pu; - bool isFirstLineOfCtu = (((cu.block(COMP_Y).y)&((cu.cs->sps)->CTUSize - 1)) == 0); if (isFirstLineOfCtu) { - pu->multiRefIdx = 0; + cu.multiRefIdx = 0; } else { @@ -1235,8 +1228,8 @@ void CABACReader::extend_ref_line(CodingUnit& cu) } } - pu->multiRefIdx = multiRefIdx; -// DTRACE( g_trace_ctx, D_SYNTAX, "extend_ref_line() idx=%d pos=(%d,%d) mode=%d\n", 0, pu->lumaPos().x, pu->lumaPos().y, multiRefIdx ); + cu.multiRefIdx = multiRefIdx; +// DTRACE( g_trace_ctx, D_SYNTAX, "extend_ref_line() idx=%d pos=(%d,%d) mode=%d\n", 0, cu.lumaPos().x, cu.lumaPos().y, multiRefIdx ); } } @@ -1247,9 +1240,9 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) return; } - if( cu.bdpcmMode ) + if( cu.bdpcmM[CH_L] ) { - cu.pu->intraDir[0] = cu.bdpcmMode == 2? VER_IDX : HOR_IDX; + cu.intraDir[0] = cu.bdpcmM[CH_L] == 2? VER_IDX : HOR_IDX; return; } @@ -1264,7 +1257,7 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) // prev_intra_luma_pred_flag int mpmFlag; - if ( cu.pu->multiRefIdx ) + if ( cu.multiRefIdx ) { mpmFlag = true; } @@ -1273,18 +1266,16 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) mpmFlag = m_BinDecoder.decodeBin(Ctx::IntraLumaMpmFlag()); } - PredictionUnit *pu = cu.pu; - unsigned mpm_pred[NUM_MOST_PROBABLE_MODES]; // mpm_idx / rem_intra_luma_pred_mode { - PU::getIntraMPMs( *pu, mpm_pred ); + CU::getIntraMPMs( cu, mpm_pred ); if( mpmFlag ) { uint32_t ipred_idx = 0; { - unsigned ctx = (pu->cu->ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0); - if (pu->multiRefIdx == 0) + unsigned ctx = (cu.ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0); + if (cu.multiRefIdx == 0) { ipred_idx = m_BinDecoder.decodeBin(Ctx::IntraLumaPlanarFlag(ctx)); } @@ -1309,7 +1300,7 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) ipred_idx += m_BinDecoder.decodeBinEP(); } } - pu->intraDir[0] = mpm_pred[ipred_idx]; + cu.intraDir[0] = mpm_pred[ipred_idx]; } else { @@ -1323,96 +1314,91 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) ipred_mode += (ipred_mode >= mpm_pred[i]); } - pu->intraDir[0] = ipred_mode; + cu.intraDir[0] = ipred_mode; } - DTRACE( g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", 0, pu->lumaPos().x, pu->lumaPos().y, pu->intraDir[0] ); + DTRACE( g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", 0, cu.lumaPos().x, cu.lumaPos().y, cu.intraDir[0] ); } } void CABACReader::intra_chroma_pred_modes( CodingUnit& cu ) { - if( cu.chromaFormat == CHROMA_400 || ( cu.isSepTree() && cu.chType == CH_L ) ) + if( cu.chromaFormat == CHROMA_400 || ( CU::isSepTree(cu) && cu.chType == CH_L ) ) { return; } - if( cu.bdpcmModeChroma ) + if( cu.bdpcmM[CH_C] ) { - cu.pu->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX; + cu.intraDir[1] = cu.bdpcmM[CH_C] == 2 ? VER_IDX : HOR_IDX; return; } - PredictionUnit *pu = cu.pu; - - { - CHECK( pu->cu != &cu, "Inkonsistent PU-CU mapping" ); - intra_chroma_pred_mode( *pu ); - } + intra_chroma_pred_mode( cu ); } -bool CABACReader::intra_chroma_lmc_mode(PredictionUnit& pu) + +bool CABACReader::intra_chroma_lmc_mode(CodingUnit& cu) { int lmModeList[10]; - PU::getLMSymbolList(pu, lmModeList); + CU::getLMSymbolList(cu, lmModeList); int symbol = m_BinDecoder.decodeBin(Ctx::CclmModeIdx(0)); if (symbol == 0) { - pu.intraDir[1] = lmModeList[symbol]; - CHECK(pu.intraDir[1] != LM_CHROMA_IDX, "should be LM_CHROMA"); + cu.intraDir[1] = lmModeList[symbol]; + CHECK(cu.intraDir[1] != LM_CHROMA_IDX, "should be LM_CHROMA"); } else { symbol += m_BinDecoder.decodeBinEP(); - pu.intraDir[1] = lmModeList[symbol]; + cu.intraDir[1] = lmModeList[symbol]; } return true; //it will only enter this function for LMC modes, so always return true ; } -void CABACReader::intra_chroma_pred_mode(PredictionUnit& pu) +void CABACReader::intra_chroma_pred_mode(CodingUnit& cu) { - if (pu.cu->colorTransform) + if (cu.colorTransform) { - pu.intraDir[CH_C] = DM_CHROMA_IDX; + cu.intraDir[CH_C] = DM_CHROMA_IDX; return; } // LM chroma mode - if (pu.cs->sps->LMChroma && pu.cu->checkCCLMAllowed()) + if (cu.cs->sps->LMChroma && CU::checkCCLMAllowed(cu)) { bool isLMCMode = m_BinDecoder.decodeBin(Ctx::CclmModeFlag(0)) ? true : false; if (isLMCMode) { - intra_chroma_lmc_mode(pu); + intra_chroma_lmc_mode(cu); return; } } if (m_BinDecoder.decodeBin(Ctx::IntraChromaPredMode(0)) == 0) { - pu.intraDir[1] = DM_CHROMA_IDX; + cu.intraDir[1] = DM_CHROMA_IDX; return; } unsigned candId = m_BinDecoder.decodeBinsEP(2); unsigned chromaCandModes[NUM_CHROMA_MODE]; - PU::getIntraChromaCandModes(pu, chromaCandModes); + CU::getIntraChromaCandModes(cu, chromaCandModes); CHECK(candId >= NUM_CHROMA_MODE, "Chroma prediction mode index out of bounds"); - CHECK(PU::isLMCMode(chromaCandModes[candId]), "The intra dir cannot be LM_CHROMA for this path"); + CHECK(CU::isLMCMode(chromaCandModes[candId]), "The intra dir cannot be LM_CHROMA for this path"); CHECK(chromaCandModes[candId] == DM_CHROMA_IDX, "The intra dir cannot be DM_CHROMA for this path"); - pu.intraDir[1] = chromaCandModes[candId]; + cu.intraDir[1] = chromaCandModes[candId]; } void CABACReader::cu_residual( CodingUnit& cu, Partitioner &partitioner, CUCtx& cuCtx ) { if (!CU::isIntra(cu)) { - PredictionUnit& pu = *cu.pu; - if( !pu.mergeFlag ) + if( !cu.mergeFlag ) { rqt_root_cbf( cu ); } @@ -1447,11 +1433,12 @@ void CABACReader::cu_residual( CodingUnit& cu, Partitioner &partitioner, CUCtx& ChromaCbfs chromaCbfs; if( cu.ispMode && isLuma( partitioner.chType ) ) { - transform_tree( *cu.cs, partitioner, cuCtx, CU::getISPType(cu, getFirstComponentOfChannel(partitioner.chType)), 0 ); + Partitioner subTuPartitioner = partitioner; + transform_tree(*cu.cs, subTuPartitioner, cuCtx, cu, CU::getISPType(cu, getFirstComponentOfChannel(partitioner.chType)), 0); } else { - transform_tree( *cu.cs, partitioner, cuCtx ); + transform_tree(*cu.cs, partitioner, cuCtx, cu); } residual_lfnst_mode( cu, cuCtx ); mts_idx ( cu, cuCtx ); @@ -1471,7 +1458,7 @@ void CABACReader::adaptive_color_transform(CodingUnit& cu) return; } - if (cu.isSepTree()) + if (CU::isSepTree(cu)) { return; } @@ -1484,7 +1471,7 @@ void CABACReader::adaptive_color_transform(CodingUnit& cu) void CABACReader::sbt_mode( CodingUnit& cu ) { - const uint8_t sbtAllowed = cu.checkAllowedSbt(); + const uint8_t sbtAllowed = CU::checkAllowedSbt(cu); if( !sbtAllowed ) { return; @@ -1546,7 +1533,7 @@ void CABACReader::end_of_ctu( CodingUnit& cu, CUCtx& cuCtx ) if ( ( ( rbPos.x & cu.cs->pcv->maxCUSizeMask ) == 0 || rbPos.x == cu.cs->pcv->lumaWidth ) && ( ( rbPos.y & cu.cs->pcv->maxCUSizeMask ) == 0 || rbPos.y == cu.cs->pcv->lumaHeight ) - && ( !cu.isSepTree() || cu.chromaFormat == CHROMA_400 || isChroma( cu.chType ) ) + && ( !CU::isSepTree(cu) || cu.chromaFormat == CHROMA_400 || isChroma( cu.chType ) ) ) { cuCtx.isDQPCoded = ( cu.cs->pps->useDQP && !cuCtx.isDQPCoded ); @@ -1562,133 +1549,133 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ //================================================================================ // clause 7.3.8.6 //-------------------------------------------------------------------------------- -// void prediction_unit ( pu, mrgCtx ); -// void merge_flag ( pu ); -// void merge_data ( pu, mrgCtx ); -// void merge_idx ( pu ); -// void inter_pred_idc ( pu ); -// void ref_idx ( pu, refList ); -// void mvp_flag ( pu, refList ); +// void prediction_unit ( cu, mrgCtx ); +// void merge_flag ( cu ); +// void merge_data ( cu, mrgCtx ); +// void merge_idx ( cu ); +// void inter_pred_idc ( cu ); +// void ref_idx ( cu, refList ); +// void mvp_flag ( cu, refList ); //================================================================================ -void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx ) +void CABACReader::prediction_unit( CodingUnit& cu, MergeCtx& mrgCtx ) { - if( pu.cu->skip ) + if( cu.skip ) { - pu.mergeFlag = true; + cu.mergeFlag = true; } else { - merge_flag( pu ); + merge_flag( cu ); } - if( pu.mergeFlag ) + if( cu.mergeFlag ) { - merge_data(pu); + merge_data(cu); } - else if (CU::isIBC(*pu.cu)) + else if (CU::isIBC(cu)) { - pu.interDir = 1; - pu.cu->affine = false; - pu.refIdx[REF_PIC_LIST_0] = MAX_NUM_REF; - mvd_coding(pu.mvd[REF_PIC_LIST_0]); - if ( pu.cs->sps->maxNumIBCMergeCand == 1 ) + cu.interDir = 1; + cu.affine = false; + cu.refIdx[REF_PIC_LIST_0] = MAX_NUM_REF; + mvd_coding(cu.mvd[REF_PIC_LIST_0]); + if ( cu.cs->sps->maxNumIBCMergeCand == 1 ) { - pu.mvpIdx[REF_PIC_LIST_0] = 0; + cu.mvpIdx[REF_PIC_LIST_0] = 0; } else { - mvp_flag(pu, REF_PIC_LIST_0); + mvp_flag(cu, REF_PIC_LIST_0); } } else { - inter_pred_idc( pu ); - affine_flag ( *pu.cu ); - smvd_mode( pu ); + inter_pred_idc( cu ); + affine_flag ( cu ); + smvd_mode( cu ); - if( pu.interDir != 2 /* PRED_L1 */ ) + if( cu.interDir != 2 /* PRED_L1 */ ) { - ref_idx ( pu, REF_PIC_LIST_0 ); - if( pu.cu->affine ) + ref_idx ( cu, REF_PIC_LIST_0 ); + if( cu.affine ) { - mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][0] ); - mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][1] ); - if ( pu.cu->affineType == AFFINEMODEL_6PARAM ) + mvd_coding( cu.mvdAffi[REF_PIC_LIST_0][0] ); + mvd_coding( cu.mvdAffi[REF_PIC_LIST_0][1] ); + if ( cu.affineType == AFFINEMODEL_6PARAM ) { - mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][2] ); + mvd_coding( cu.mvdAffi[REF_PIC_LIST_0][2] ); } } else { - mvd_coding( pu.mvd[REF_PIC_LIST_0] ); + mvd_coding( cu.mvd[REF_PIC_LIST_0] ); } - mvp_flag ( pu, REF_PIC_LIST_0 ); + mvp_flag ( cu, REF_PIC_LIST_0 ); } - if( pu.interDir != 1 /* PRED_L0 */ ) + if( cu.interDir != 1 /* PRED_L0 */ ) { - if ( pu.cu->smvdMode != 1 ) + if ( cu.smvdMode != 1 ) { - ref_idx ( pu, REF_PIC_LIST_1 ); - if( pu.cu->cs->slice->picHeader->mvdL1Zero && pu.interDir == 3 /* PRED_BI */ ) + ref_idx ( cu, REF_PIC_LIST_1 ); + if( cu.cs->slice->picHeader->mvdL1Zero && cu.interDir == 3 /* PRED_BI */ ) { - pu.mvd[ REF_PIC_LIST_1 ] = Mv(); - pu.mvdAffi[REF_PIC_LIST_1][0] = Mv(); - pu.mvdAffi[REF_PIC_LIST_1][1] = Mv(); - pu.mvdAffi[REF_PIC_LIST_1][2] = Mv(); + cu.mvd[ REF_PIC_LIST_1 ] = Mv(); + cu.mvdAffi[REF_PIC_LIST_1][0] = Mv(); + cu.mvdAffi[REF_PIC_LIST_1][1] = Mv(); + cu.mvdAffi[REF_PIC_LIST_1][2] = Mv(); } - else if( pu.cu->affine ) + else if( cu.affine ) { - mvd_coding( pu.mvdAffi[REF_PIC_LIST_1][0] ); - mvd_coding( pu.mvdAffi[REF_PIC_LIST_1][1] ); - if ( pu.cu->affineType == AFFINEMODEL_6PARAM ) + mvd_coding( cu.mvdAffi[REF_PIC_LIST_1][0] ); + mvd_coding( cu.mvdAffi[REF_PIC_LIST_1][1] ); + if ( cu.affineType == AFFINEMODEL_6PARAM ) { - mvd_coding( pu.mvdAffi[REF_PIC_LIST_1][2] ); + mvd_coding( cu.mvdAffi[REF_PIC_LIST_1][2] ); } } else { - mvd_coding( pu.mvd[REF_PIC_LIST_1] ); + mvd_coding( cu.mvd[REF_PIC_LIST_1] ); } } - mvp_flag ( pu, REF_PIC_LIST_1 ); + mvp_flag ( cu, REF_PIC_LIST_1 ); } } - if( pu.interDir == 3 /* PRED_BI */ && PU::isBipredRestriction(pu) ) + if( cu.interDir == 3 /* PRED_BI */ && CU::isBipredRestriction(cu) ) { - pu.mv [REF_PIC_LIST_1] = Mv(0, 0); - pu.refIdx[REF_PIC_LIST_1] = -1; - pu.interDir = 1; - pu.cu->BcwIdx = BCW_DEFAULT; + cu.mv [REF_PIC_LIST_1] = Mv(0, 0); + cu.refIdx[REF_PIC_LIST_1] = -1; + cu.interDir = 1; + cu.BcwIdx = BCW_DEFAULT; } - if ( pu.cu->smvdMode ) + if ( cu.smvdMode ) { - RefPicList eCurRefList = (RefPicList)(pu.cu->smvdMode - 1); - pu.mvd[1 - eCurRefList].set( -pu.mvd[eCurRefList].hor, -pu.mvd[eCurRefList].ver ); - CHECK(!((pu.mvd[1 - eCurRefList].hor >= MVD_MIN) && (pu.mvd[1 - eCurRefList].hor <= MVD_MAX)) || !((pu.mvd[1 - eCurRefList].ver >= MVD_MIN) && (pu.mvd[1 - eCurRefList].ver <= MVD_MAX)), "Illegal MVD value"); - pu.refIdx[1 - eCurRefList] = pu.cs->slice->symRefIdx[ 1 - eCurRefList ]; + RefPicList eCurRefList = (RefPicList)(cu.smvdMode - 1); + cu.mvd[1 - eCurRefList].set( -cu.mvd[eCurRefList].hor, -cu.mvd[eCurRefList].ver ); + CHECK(!((cu.mvd[1 - eCurRefList].hor >= MVD_MIN) && (cu.mvd[1 - eCurRefList].hor <= MVD_MAX)) || !((cu.mvd[1 - eCurRefList].ver >= MVD_MIN) && (cu.mvd[1 - eCurRefList].ver <= MVD_MAX)), "Illegal MVD value"); + cu.refIdx[1 - eCurRefList] = cu.cs->slice->symRefIdx[ 1 - eCurRefList ]; } - PU::spanMotionInfo( pu, mrgCtx ); + CU::spanMotionInfo( cu, mrgCtx ); } -void CABACReader::smvd_mode( PredictionUnit& pu ) +void CABACReader::smvd_mode( CodingUnit& cu ) { - pu.cu->smvdMode = 0; - if ( pu.interDir != 3 || pu.cu->affine ) + cu.smvdMode = 0; + if ( cu.interDir != 3 || cu.affine ) { return; } - if ( pu.cs->slice->biDirPred == false ) + if ( cu.cs->slice->biDirPred == false ) { return; } - pu.cu->smvdMode = m_BinDecoder.decodeBin( Ctx::SmvdFlag() ) ? 1 : 0; + cu.smvdMode = m_BinDecoder.decodeBin( Ctx::SmvdFlag() ) ? 1 : 0; - DTRACE( g_trace_ctx, D_SYNTAX, "symmvd_flag() symmvd=%d pos=(%d,%d) size=%dx%d\n", pu.cu->smvdMode ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height ); + DTRACE( g_trace_ctx, D_SYNTAX, "symmvd_flag() symmvd=%d pos=(%d,%d) size=%dx%d\n", cu.smvdMode ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height ); } void CABACReader::subblock_merge_flag( CodingUnit& cu ) @@ -1724,118 +1711,117 @@ void CABACReader::affine_flag( CodingUnit& cu ) } } -void CABACReader::merge_flag( PredictionUnit& pu ) +void CABACReader::merge_flag( CodingUnit& cu ) { - pu.mergeFlag = ( m_BinDecoder.decodeBin( Ctx::MergeFlag() ) ); + cu.mergeFlag = ( m_BinDecoder.decodeBin( Ctx::MergeFlag() ) ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_flag() merge=%d pos=(%d,%d) size=%dx%d\n", pu.mergeFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height ); + DTRACE( g_trace_ctx, D_SYNTAX, "merge_flag() merge=%d pos=(%d,%d) size=%dx%d\n", cu.mergeFlag ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height ); - if (pu.mergeFlag && CU::isIBC(*pu.cu)) + if (cu.mergeFlag && CU::isIBC(cu)) { - pu.mmvdMergeFlag = false; - pu.regularMergeFlag = false; + cu.mmvdMergeFlag = false; + cu.regularMergeFlag = false; return; } } -void CABACReader::merge_data( PredictionUnit& pu ) +void CABACReader::merge_data( CodingUnit& cu ) { - if (CU::isIBC(*pu.cu)) + if (CU::isIBC(cu)) { - merge_idx(pu); + merge_idx(cu); return; } else { - CodingUnit cu = *pu.cu; - subblock_merge_flag(*pu.cu); - if (pu.cu->affine) + subblock_merge_flag(cu); + if (cu.affine) { - merge_idx(pu); - cu.pu->regularMergeFlag = false; + merge_idx(cu); + cu.regularMergeFlag = false; return; } - const bool ciipAvailable = pu.cs->sps->CIIP && !pu.cu->skip && pu.cu->lwidth() < MAX_CU_SIZE && pu.cu->lheight() < MAX_CU_SIZE && pu.cu->lwidth() * pu.cu->lheight() >= 64; - const bool geoAvailable = pu.cu->cs->slice->sps->GEO && pu.cu->cs->slice->isInterB() && pu.cs->sps->maxNumGeoCand > 1 - && pu.cu->lwidth() >= GEO_MIN_CU_SIZE && pu.cu->lheight() >= GEO_MIN_CU_SIZE - && pu.cu->lwidth() <= GEO_MAX_CU_SIZE && pu.cu->lheight() <= GEO_MAX_CU_SIZE - && pu.cu->lwidth() < 8 * pu.cu->lheight() && pu.cu->lheight() < 8 * pu.cu->lwidth(); + const bool ciipAvailable = cu.cs->sps->CIIP && !cu.skip && cu.lwidth() < MAX_CU_SIZE && cu.lheight() < MAX_CU_SIZE && cu.lwidth() * cu.lheight() >= 64; + const bool geoAvailable = cu.cs->slice->sps->GEO && cu.cs->slice->isInterB() && cu.cs->sps->maxNumGeoCand > 1 + && cu.lwidth() >= GEO_MIN_CU_SIZE && cu.lheight() >= GEO_MIN_CU_SIZE + && cu.lwidth() <= GEO_MAX_CU_SIZE && cu.lheight() <= GEO_MAX_CU_SIZE + && cu.lwidth() < 8 * cu.lheight() && cu.lheight() < 8 * cu.lwidth(); if (geoAvailable || ciipAvailable) { - cu.pu->regularMergeFlag = m_BinDecoder.decodeBin(Ctx::RegularMergeFlag(cu.skip ? 0 : 1)); + cu.regularMergeFlag = m_BinDecoder.decodeBin(Ctx::RegularMergeFlag(cu.skip ? 0 : 1)); } else { - cu.pu->regularMergeFlag = true; + cu.regularMergeFlag = true; } - if (cu.pu->regularMergeFlag) + if (cu.regularMergeFlag) { if (cu.cs->slice->sps->MMVD) { - cu.pu->mmvdMergeFlag = m_BinDecoder.decodeBin(Ctx::MmvdFlag(0)); - DTRACE( g_trace_ctx, D_SYNTAX, "mmvd_merge_flag() mmvd_merge=%d pos=(%d,%d) size=%dx%d\n", pu.mmvdMergeFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height ); + cu.mmvdMergeFlag = m_BinDecoder.decodeBin(Ctx::MmvdFlag(0)); + DTRACE( g_trace_ctx, D_SYNTAX, "mmvd_merge_flag() mmvd_merge=%d pos=(%d,%d) size=%dx%d\n", cu.mmvdMergeFlag ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height ); } else { - cu.pu->mmvdMergeFlag = false; + cu.mmvdMergeFlag = false; } if (cu.skip) { - cu.mmvdSkip = cu.pu->mmvdMergeFlag; + cu.mmvdSkip = cu.mmvdMergeFlag; } } else { - pu.mmvdMergeFlag = false; - pu.cu->mmvdSkip = false; + cu.mmvdMergeFlag = false; + cu.mmvdSkip = false; if (geoAvailable && ciipAvailable) { - Ciip_flag(pu); + Ciip_flag(cu); } else if (ciipAvailable) { - pu.ciip = true; + cu.ciip = true; } else { - pu.ciip = false; + cu.ciip = false; } - if (pu.ciip) + if (cu.ciip) { - pu.intraDir[0] = PLANAR_IDX; - pu.intraDir[1] = DM_CHROMA_IDX; + cu.intraDir[0] = PLANAR_IDX; + cu.intraDir[1] = DM_CHROMA_IDX; } else { - pu.cu->geo = true; + cu.geo = true; } } } - if (pu.mmvdMergeFlag || pu.cu->mmvdSkip) + if (cu.mmvdMergeFlag || cu.mmvdSkip) { - mmvd_merge_idx(pu); + mmvd_merge_idx(cu); } else { - merge_idx(pu); + merge_idx(cu); } } -void CABACReader::merge_idx( PredictionUnit& pu ) +void CABACReader::merge_idx( CodingUnit& cu ) { - if ( pu.cu->affine ) + if ( cu.affine ) { - int numCandminus1 = int( pu.cs->picHeader->maxNumAffineMergeCand ) - 1; - pu.mergeIdx = 0; + int numCandminus1 = int( cu.cs->picHeader->maxNumAffineMergeCand ) - 1; + cu.mergeIdx = 0; if ( numCandminus1 > 0 ) { if ( m_BinDecoder.decodeBin( Ctx::AffMergeIdx() ) ) { - pu.mergeIdx++; - for ( ; pu.mergeIdx < numCandminus1; pu.mergeIdx++ ) + cu.mergeIdx++; + for ( ; cu.mergeIdx < numCandminus1; cu.mergeIdx++ ) { if ( !m_BinDecoder.decodeBinEP() ) { @@ -1844,23 +1830,23 @@ void CABACReader::merge_idx( PredictionUnit& pu ) } } } - DTRACE( g_trace_ctx, D_SYNTAX, "aff_merge_idx() aff_merge_idx=%d\n", pu.mergeIdx ); + DTRACE( g_trace_ctx, D_SYNTAX, "aff_merge_idx() aff_merge_idx=%d\n", cu.mergeIdx ); } else { - int numCandminus1 = int( pu.cs->sps->maxNumMergeCand ) - 1; - pu.mergeIdx = 0; + int numCandminus1 = int( cu.cs->sps->maxNumMergeCand ) - 1; + cu.mergeIdx = 0; - if( pu.cu->geo ) + if( cu.geo ) { uint32_t splitDir = 0; xReadTruncBinCode(splitDir, GEO_NUM_PARTITION_MODE); - pu.geoSplitDir = splitDir; - const int maxNumGeoCand = pu.cs->sps->maxNumGeoCand; + cu.geoSplitDir = splitDir; + const int maxNumGeoCand = cu.cs->sps->maxNumGeoCand; CHECK(maxNumGeoCand < 2, "Incorrect max number of geo candidates"); - CHECK(pu.cu->lheight() > 64 || pu.cu->lwidth() > 64, "Incorrect block size of geo flag"); + CHECK(cu.lheight() > 64 || cu.lwidth() > 64, "Incorrect block size of geo flag"); int numCandminus2 = maxNumGeoCand - 2; - pu.mergeIdx = 0; + cu.mergeIdx = 0; int mergeCand0 = 0; int mergeCand1 = 0; if( m_BinDecoder.decodeBin( Ctx::MergeIdx() ) ) @@ -1875,24 +1861,24 @@ void CABACReader::merge_idx( PredictionUnit& pu ) } } mergeCand1 += mergeCand1 >= mergeCand0 ? 1 : 0; - pu.geoMergeIdx0 = mergeCand0; - pu.geoMergeIdx1 = mergeCand1; + cu.geoMergeIdx0 = mergeCand0; + cu.geoMergeIdx1 = mergeCand1; DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_split_dir=%d\n", splitDir ); DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_idx0=%d\n", mergeCand0 ); DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_idx1=%d\n", mergeCand1 ); return; } - if (pu.cu->predMode == MODE_IBC) + if (cu.predMode == MODE_IBC) { - numCandminus1 = int(pu.cs->sps->maxNumIBCMergeCand) - 1; + numCandminus1 = int(cu.cs->sps->maxNumIBCMergeCand) - 1; } if( numCandminus1 > 0 ) { if( m_BinDecoder.decodeBin( Ctx::MergeIdx() ) ) { - pu.mergeIdx++; - for( ; pu.mergeIdx < numCandminus1; pu.mergeIdx++ ) + cu.mergeIdx++; + for( ; cu.mergeIdx < numCandminus1; cu.mergeIdx++ ) { if( !m_BinDecoder.decodeBinEP() ) { @@ -1901,14 +1887,14 @@ void CABACReader::merge_idx( PredictionUnit& pu ) } } } - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() merge_idx=%d\n", pu.mergeIdx ); + DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() merge_idx=%d\n", cu.mergeIdx ); } } -void CABACReader::mmvd_merge_idx(PredictionUnit& pu) +void CABACReader::mmvd_merge_idx(CodingUnit& cu) { int var0 = 0; - if (pu.cs->sps->maxNumMergeCand > 1) + if (cu.cs->sps->maxNumMergeCand > 1) { static_assert(MMVD_BASE_MV_NUM == 2, ""); var0 = m_BinDecoder.decodeBin(Ctx::MmvdMergeIdx()); @@ -1947,98 +1933,98 @@ void CABACReader::mmvd_merge_idx(PredictionUnit& pu) } DTRACE(g_trace_ctx, D_SYNTAX, "pos() pos=%d\n", var2); int mvpIdx = (var0 * MMVD_MAX_REFINE_NUM + var1 * 4 + var2); - pu.mmvdMergeIdx = mvpIdx; - DTRACE(g_trace_ctx, D_SYNTAX, "mmvd_merge_idx() mmvd_merge_idx=%d\n", pu.mmvdMergeIdx); + cu.mmvdMergeIdx = mvpIdx; + DTRACE(g_trace_ctx, D_SYNTAX, "mmvd_merge_idx() mmvd_merge_idx=%d\n", cu.mmvdMergeIdx); } -void CABACReader::inter_pred_idc( PredictionUnit& pu ) +void CABACReader::inter_pred_idc( CodingUnit& cu ) { - if( pu.cs->slice->isInterP() ) + if( cu.cs->slice->isInterP() ) { - pu.interDir = 1; + cu.interDir = 1; return; } - if( !(PU::isBipredRestriction(pu)) ) + if( !(CU::isBipredRestriction(cu)) ) { - unsigned ctxId = DeriveCtx::CtxInterDir(pu); + unsigned ctxId = DeriveCtx::CtxInterDir(cu); if( m_BinDecoder.decodeBin( Ctx::InterDir(ctxId) ) ) { - DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=%d value=%d pos=(%d,%d)\n", ctxId, 3, pu.lumaPos().x, pu.lumaPos().y ); - pu.interDir = 3; + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=%d value=%d pos=(%d,%d)\n", ctxId, 3, cu.lumaPos().x, cu.lumaPos().y ); + cu.interDir = 3; return; } } if( m_BinDecoder.decodeBin( Ctx::InterDir(5) ) ) { - DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 2, pu.lumaPos().x, pu.lumaPos().y ); - pu.interDir = 2; + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 2, cu.lumaPos().x, cu.lumaPos().y ); + cu.interDir = 2; return; } - DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 1, pu.lumaPos().x, pu.lumaPos().y ); - pu.interDir = 1; + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 1, cu.lumaPos().x, cu.lumaPos().y ); + cu.interDir = 1; return; } -void CABACReader::ref_idx( PredictionUnit &pu, RefPicList eRefList ) +void CABACReader::ref_idx( CodingUnit& cu, RefPicList eRefList ) { - if ( pu.cu->smvdMode ) + if ( cu.smvdMode ) { - pu.refIdx[eRefList] = pu.cs->slice->symRefIdx[ eRefList ]; + cu.refIdx[eRefList] = cu.cs->slice->symRefIdx[ eRefList ]; return; } - int numRef = pu.cs->slice->numRefIdx[eRefList]; + int numRef = cu.cs->slice->numRefIdx[eRefList]; if( numRef <= 1 || !m_BinDecoder.decodeBin( Ctx::RefPic() ) ) { if( numRef > 1 ) { - DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", 0, pu.lumaPos().x, pu.lumaPos().y ); + DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", 0, cu.lumaPos().x, cu.lumaPos().y ); } - pu.refIdx[eRefList] = 0; + cu.refIdx[eRefList] = 0; return; } if( numRef <= 2 || !m_BinDecoder.decodeBin( Ctx::RefPic(1) ) ) { - DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", 1, pu.lumaPos().x, pu.lumaPos().y ); - pu.refIdx[eRefList] = 1; + DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", 1, cu.lumaPos().x, cu.lumaPos().y ); + cu.refIdx[eRefList] = 1; return; } for( int idx = 3; ; idx++ ) { if( numRef <= idx || !m_BinDecoder.decodeBinEP() ) { - pu.refIdx[eRefList] = (signed char)( idx - 1 ); - DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", idx-1, pu.lumaPos().x, pu.lumaPos().y ); + cu.refIdx[eRefList] = (signed char)( idx - 1 ); + DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", idx-1, cu.lumaPos().x, cu.lumaPos().y ); return; } } } -void CABACReader::mvp_flag( PredictionUnit& pu, RefPicList eRefList ) +void CABACReader::mvp_flag( CodingUnit& cu, RefPicList eRefList ) { unsigned mvp_idx = m_BinDecoder.decodeBin( Ctx::MVPIdx() ); - DTRACE( g_trace_ctx, D_SYNTAX, "mvp_flag() value=%d pos=(%d,%d)\n", mvp_idx, pu.lumaPos().x, pu.lumaPos().y ); - pu.mvpIdx [eRefList] = mvp_idx; + DTRACE( g_trace_ctx, D_SYNTAX, "mvp_flag() value=%d pos=(%d,%d)\n", mvp_idx, cu.lumaPos().x, cu.lumaPos().y ); + cu.mvpIdx [eRefList] = mvp_idx; DTRACE( g_trace_ctx, D_SYNTAX, "mvpIdx(refList:%d)=%d\n", eRefList, mvp_idx ); } -void CABACReader::Ciip_flag(PredictionUnit& pu) +void CABACReader::Ciip_flag(CodingUnit& cu) { - if (!pu.cs->sps->CIIP) + if (!cu.cs->sps->CIIP) { - pu.ciip = false; + cu.ciip = false; return; } - if (pu.cu->skip) + if (cu.skip) { - pu.ciip = false; + cu.ciip = false; return; } - pu.ciip = (m_BinDecoder.decodeBin(Ctx::CiipFlag())); - DTRACE(g_trace_ctx, D_SYNTAX, "Ciip_flag() Ciip=%d pos=(%d,%d) size=%dx%d\n", pu.ciip ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height); + cu.ciip = (m_BinDecoder.decodeBin(Ctx::CiipFlag())); + DTRACE(g_trace_ctx, D_SYNTAX, "Ciip_flag() Ciip=%d pos=(%d,%d) size=%dx%d\n", cu.ciip ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height); } @@ -2049,8 +2035,7 @@ void CABACReader::Ciip_flag(PredictionUnit& pu) // bool split_transform_flag( depth ) // bool cbf_comp ( area, depth ) //================================================================================ - -void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner, CUCtx& cuCtx, const PartSplit ispType, const int subTuIdx ) +void CABACReader::transform_tree(CodingStructure& cs, Partitioner& partitioner, CUCtx& cuCtx, CodingUnit& cuTop, const PartSplit ispType, const int subTuIdx) { const UnitArea& area = partitioner.currArea(); CodingUnit& cu = *cs.getCU(area.blocks[partitioner.chType], partitioner.chType, partitioner.treeType ); @@ -2067,7 +2052,7 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner, if( !split && cu.ispMode ) { - split = partitioner.canSplit( ispType, cs ); + split = partitioner.canSplitISP(ispType, cs, cuTop); } if( split ) @@ -2096,7 +2081,7 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner, do { - transform_tree( cs, partitioner, cuCtx, ispType, subTuCounter ); + transform_tree(cs, partitioner, cuCtx, cuTop, ispType, subTuCounter); subTuCounter += subTuCounter != -1 ? 1 : 0; } while( partitioner.nextPart( cs ) ); @@ -2121,16 +2106,16 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner, transform_unit(tu, cuCtx, partitioner, subTuCounter); } } - -bool CABACReader::cbf_comp( CodingStructure& cs, const CompArea& area, unsigned depth, const bool prevCbf, const bool useISP ) +bool CABACReader::cbf_comp(CodingUnit& cu, const CompArea& area, unsigned depth, const bool prevCbf, const bool useISP) { - const unsigned ctxId = DeriveCtx::CtxQtCbf( area.compID, prevCbf, useISP && isLuma( area.compID ) ); - const CtxSet& ctxSet = Ctx::QtCbf[ area.compID ]; + unsigned ctxId = DeriveCtx::CtxQtCbf(area.compID, prevCbf, useISP && isLuma(area.compID)); + const CtxSet& ctxSet = Ctx::QtCbf[area.compID]; unsigned cbf = 0; - if( area.compID == COMP_Y && cs.getCU( area.pos(), ChannelType( area.compID ), TREE_L )->bdpcmMode ) + if (cu.bdpcmM[toChannelType(area.compID)]) { - cbf = m_BinDecoder.decodeBin( ctxSet( 1 ) ); + ctxId = (area.compID != COMP_Cr) ? 1 : 2; + cbf = m_BinDecoder.decodeBin(ctxSet(ctxId)); } else { @@ -2144,7 +2129,7 @@ bool CABACReader::cbf_comp( CodingStructure& cs, const CompArea& area, unsigned //================================================================================ // clause 7.3.8.9 //-------------------------------------------------------------------------------- -// void mvd_coding( pu, refList ) +// void mvd_coding( cu, refList ) //================================================================================ void CABACReader::mvd_coding( Mv &rMvd ) @@ -2203,8 +2188,6 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& { const UnitArea& area = partitioner.currArea(); const unsigned trDepth = partitioner.currTrDepth; - - CodingStructure& cs = *tu.cs; CodingUnit& cu = *tu.cu; ChromaCbfs chromaCbfs; chromaCbfs.Cb = chromaCbfs.Cr = false; @@ -2212,20 +2195,20 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& const bool chromaCbfISP = area.blocks[COMP_Cb].valid() && cu.ispMode; // cbf_cb & cbf_cr - if (area.chromaFormat != CHROMA_400 && area.blocks[COMP_Cb].valid() && (!cu.isSepTree() || partitioner.chType == CH_C) && (!cu.ispMode || chromaCbfISP)) + if (area.chromaFormat != CHROMA_400 && area.blocks[COMP_Cb].valid() && (!CU::isSepTree(cu) || partitioner.chType == CH_C) && (!cu.ispMode || chromaCbfISP)) { const int cbfDepth = chromaCbfISP ? trDepth - 1 : trDepth; if (!(cu.sbtInfo && tu.noResidual)) { - chromaCbfs.Cb = cbf_comp(cs, area.blocks[COMP_Cb], cbfDepth); + chromaCbfs.Cb = cbf_comp(cu, area.blocks[COMP_Cb], cbfDepth); } if (!(cu.sbtInfo && tu.noResidual)) { - chromaCbfs.Cr = cbf_comp(cs, area.blocks[COMP_Cr], cbfDepth, chromaCbfs.Cb); + chromaCbfs.Cr = cbf_comp(cu, area.blocks[COMP_Cr], cbfDepth, chromaCbfs.Cb); } } - else if (cu.isSepTree()) + else if (CU::isSepTree(cu)) { chromaCbfs = ChromaCbfs(false); } @@ -2272,7 +2255,7 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& previousCbf = TU::getPrevTuCbfAtDepth(tu, COMP_Y, trDepth); } } - bool cbfY = lastCbfIsInferred ? true : cbf_comp(cs, tu.Y(), trDepth, previousCbf, cu.ispMode); + bool cbfY = lastCbfIsInferred ? true : cbf_comp(cu, tu.Y(), trDepth, previousCbf, cu.ispMode); TU::setCbfAtDepth(tu, COMP_Y, trDepth, (cbfY ? 1 : 0)); } } @@ -2286,7 +2269,7 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& bool cbfChroma = ( lumaOnly ? false : ( chromaCbfs.Cb || chromaCbfs.Cr ) ); if( ( cu.lwidth() > 64 || cu.lheight() > 64 || cbfLuma || cbfChroma ) && - (!tu.cu->isSepTree() || isLuma(tu.chType)) ) + (!CU::isSepTree(*tu.cu) || isLuma(tu.chType)) ) { if( cu.cs->pps->useDQP && !cuCtx.isDQPCoded ) { @@ -2295,10 +2278,10 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& cuCtx.isDQPCoded = true; } } - if (!cu.isSepTree() || isChroma(tu.chType)) // !DUAL_TREE_LUMA + if (!CU::isSepTree(cu) || isChroma(tu.chType)) // !DUAL_TREE_LUMA { - SizeType channelWidth = !cu.isSepTree() ? cu.lwidth() : cu.chromaSize().width; - SizeType channelHeight = !cu.isSepTree() ? cu.lheight() : cu.chromaSize().height; + SizeType channelWidth = !CU::isSepTree(cu) ? cu.lwidth() : cu.chromaSize().width; + SizeType channelHeight = !CU::isSepTree(cu) ? cu.lheight() : cu.chromaSize().height; if (cu.cs->slice->chromaQpAdjEnabled && (channelWidth > 64 || channelHeight > 64 || cbfChroma) && !cuCtx.isChromaQpAdjCoded) { @@ -2403,7 +2386,7 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& // parse transform skip ts_flag ( tu, compID ); - if( isLuma( compID ) && ( tu.mtsIdx[compID] == MTS_SKIP ) ) + if ( tu.mtsIdx[compID] == MTS_SKIP) { residual_codingTS( tu, compID ); return; @@ -2461,7 +2444,7 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& void CABACReader::ts_flag( TransformUnit& tu, ComponentID compID ) { - int tsFlag = ( (tu.cu->bdpcmMode && isLuma(compID)) || (tu.cu->bdpcmModeChroma && isChroma(compID)) ) ? 1 : tu.mtsIdx[compID] == MTS_SKIP ? 1 : 0; + int tsFlag = (tu.cu->bdpcmM[toChannelType(compID)] || tu.mtsIdx[compID] == MTS_SKIP) ? 1 : 0; int ctxIdx = isLuma(compID) ? 0 : 1; if( TU::isTSAllowed ( tu, compID ) ) @@ -2509,7 +2492,7 @@ void CABACReader::mts_idx( CodingUnit& cu, CUCtx& cuCtx ) void CABACReader::isp_mode( CodingUnit& cu ) { - if( !CU::isIntra( cu ) || !isLuma( cu.chType ) || cu.pu->multiRefIdx || !cu.cs->sps->ISP || cu.bdpcmMode || !CU::canUseISP( cu, getFirstComponentOfChannel( cu.chType ) ) || cu.colorTransform ) + if( !CU::isIntra( cu ) || !isLuma( cu.chType ) || cu.multiRefIdx || !cu.cs->sps->ISP || cu.bdpcmM[CH_L] || !CU::canUseISP( cu, getFirstComponentOfChannel( cu.chType ) ) || cu.colorTransform ) { cu.ispMode = NOT_INTRA_SUBPARTITIONS; return; @@ -2528,8 +2511,8 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) { int chIdx = CS::isDualITree( *cu.cs ) && cu.chType == CH_C ? 1 : 0; if ( (cu.ispMode && !CU::canUseLfnstWithISP( cu, cu.chType ) ) || - (cu.cs->sps->LFNST && CU::isIntra(cu) && cu.mipFlag && !allowLfnstWithMip(cu.pu->lumaSize())) || - ( cu.isSepTree() && cu.chType == CH_C && std::min( cu.blocks[ 1 ].width, cu.blocks[ 1 ].height ) < 4 ) + (cu.cs->sps->LFNST && CU::isIntra(cu) && cu.mipFlag && !allowLfnstWithMip(cu.lumaSize())) || + ( CU::isSepTree(cu) && cu.chType == CH_C && std::min( cu.blocks[ 1 ].width, cu.blocks[ 1 ].height ) < 4 ) || ( cu.blocks[ chIdx ].lumaSize().width > cu.cs->sps->getMaxTbSize() || cu.blocks[ chIdx ].lumaSize().height > cu.cs->sps->getMaxTbSize() ) ) { @@ -2538,8 +2521,8 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) if( cu.cs->sps->LFNST && CU::isIntra( cu ) ) { - const bool lumaFlag = cu.isSepTree() ? ( isLuma( cu.chType ) ? true : false ) : true; - const bool chromaFlag = cu.isSepTree() ? ( isChroma( cu.chType ) ? true : false ) : true; + const bool lumaFlag = CU::isSepTree(cu) ? ( isLuma( cu.chType ) ? true : false ) : true; + const bool chromaFlag = CU::isSepTree(cu) ? ( isChroma( cu.chType ) ? true : false ) : true; bool nonZeroCoeffNonTsCorner8x8 = ( lumaFlag && cuCtx.violatesLfnstConstrained[CH_L] ) || (chromaFlag && cuCtx.violatesLfnstConstrained[CH_C] ); bool isTrSkip = false; for (auto &currTU : CU::traverseTUs(cu)) @@ -2567,7 +2550,7 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) } unsigned cctx = 0; - if ( cu.isSepTree() ) cctx++; + if ( CU::isSepTree(cu) ) cctx++; uint32_t idxLFNST = m_BinDecoder.decodeBin( Ctx::LFNSTIdx( cctx ) ); if( idxLFNST ) @@ -2788,7 +2771,7 @@ void CABACReader::residual_codingTS( TransformUnit& tu, ComponentID compID ) DTRACE( g_trace_ctx, D_SYNTAX, "residual_codingTS() etype=%d pos=(%d,%d) size=%dx%d\n", tu.blocks[compID].compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.blocks[compID].width, tu.blocks[compID].height ); // init coeff coding context - CoeffCodingContext cctx ( tu, compID, false, isLuma(compID) ? tu.cu->bdpcmMode : tu.cu->bdpcmModeChroma); + CoeffCodingContext cctx ( tu, compID, false, tu.cu->bdpcmM[toChannelType(compID)]); TCoeff* coeff = tu.getCoeffs( compID ).buf; int maxCtxBins = (cctx.maxNumCoeff() * 7) >> 2; @@ -3019,20 +3002,20 @@ void CABACReader::mip_pred_modes( CodingUnit &cu ) return; } - mip_pred_mode( *cu.pu ); + mip_pred_mode( cu ); } -void CABACReader::mip_pred_mode( PredictionUnit &pu ) +void CABACReader::mip_pred_mode( CodingUnit& cu ) { - pu.mipTransposedFlag = bool(m_BinDecoder.decodeBinEP()); + cu.mipTransposedFlag = bool(m_BinDecoder.decodeBinEP()); uint32_t mipMode; - const int numModes = getNumModesMip( pu.Y() ); + const int numModes = getNumModesMip( cu.Y() ); xReadTruncBinCode( mipMode, numModes ); - pu.intraDir[CH_L] = mipMode; - CHECKD( pu.intraDir[CH_L] < 0 || pu.intraDir[CH_L] >= numModes, "Invalid MIP mode" ); + cu.intraDir[CH_L] = mipMode; + CHECKD( cu.intraDir[CH_L] < 0 || cu.intraDir[CH_L] >= numModes, "Invalid MIP mode" ); - DTRACE( g_trace_ctx, D_SYNTAX, "mip_pred_mode() pos=(%d,%d) mode=%d transposed=%d\n", pu.lumaPos().x, pu.lumaPos().y, pu.intraDir[CH_L], pu.mipTransposedFlag ? 1 : 0 ); + DTRACE( g_trace_ctx, D_SYNTAX, "mip_pred_mode() pos=(%d,%d) mode=%d transposed=%d\n", cu.lumaPos().x, cu.lumaPos().y, cu.intraDir[CH_L], cu.mipTransposedFlag ? 1 : 0 ); } } // namespace vvenc diff --git a/source/Lib/DecoderLib/CABACReader.h b/source/Lib/DecoderLib/CABACReader.h index 9b2efbf81..ca4291c7e 100644 --- a/source/Lib/DecoderLib/CABACReader.h +++ b/source/Lib/DecoderLib/CABACReader.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file CABACReader.h * \brief Reader for low level syntax */ @@ -97,8 +101,8 @@ class CABACReader : public DeriveCtx void extend_ref_line ( CodingUnit& cu); void intra_luma_pred_modes ( CodingUnit& cu ); void intra_chroma_pred_modes ( CodingUnit& cu ); - bool intra_chroma_lmc_mode ( PredictionUnit& pu ); - void intra_chroma_pred_mode ( PredictionUnit& pu ); + bool intra_chroma_lmc_mode ( CodingUnit& cu ); + void intra_chroma_pred_mode ( CodingUnit& cu ); void cu_residual ( CodingUnit& cu, Partitioner& pm, CUCtx& cuCtx ); void rqt_root_cbf ( CodingUnit& cu ); void adaptive_color_transform ( CodingUnit& cu); @@ -106,29 +110,29 @@ class CABACReader : public DeriveCtx void end_of_ctu ( CodingUnit& cu, CUCtx& cuCtx ); void mip_flag ( CodingUnit& cu ); void mip_pred_modes ( CodingUnit& cu ); - void mip_pred_mode ( PredictionUnit& pu ); + void mip_pred_mode ( CodingUnit& cu ); void cu_palette_info ( CodingUnit& cu, ComponentID compBegin, uint32_t numComp, CUCtx& cuCtx ); void cuPaletteSubblockInfo ( CodingUnit& cu, ComponentID compBegin, uint32_t numComp, int subSetId, uint32_t& prevRunPos, unsigned& prevRunType ); // prediction unit (clause 7.3.8.6) - void prediction_unit ( PredictionUnit& pu, MergeCtx& mrgCtx ); - void merge_flag ( PredictionUnit& pu ); - void merge_data ( PredictionUnit& pu ); + void prediction_unit ( CodingUnit& cu, MergeCtx& mrgCtx ); + void merge_flag ( CodingUnit& cu ); + void merge_data ( CodingUnit& cu ); void affine_flag ( CodingUnit& cu ); void subblock_merge_flag ( CodingUnit& cu ); - void merge_idx ( PredictionUnit& pu ); - void mmvd_merge_idx ( PredictionUnit& pu); + void merge_idx ( CodingUnit& cu ); + void mmvd_merge_idx ( CodingUnit& cu); void imv_mode ( CodingUnit& cu, MergeCtx& mrgCtx ); void affine_amvr_mode ( CodingUnit& cu, MergeCtx& mrgCtx ); - void inter_pred_idc ( PredictionUnit& pu ); - void ref_idx ( PredictionUnit& pu, RefPicList eRefList ); - void mvp_flag ( PredictionUnit& pu, RefPicList eRefList ); - void Ciip_flag ( PredictionUnit& pu ); - void smvd_mode ( PredictionUnit& pu ); + void inter_pred_idc ( CodingUnit& cu ); + void ref_idx ( CodingUnit& cu, RefPicList eRefList ); + void mvp_flag ( CodingUnit& cu, RefPicList eRefList ); + void Ciip_flag ( CodingUnit& cu ); + void smvd_mode ( CodingUnit& cu ); // transform tree (clause 7.3.8.8) - void transform_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 ); - bool cbf_comp ( CodingStructure& cs, const CompArea& area, unsigned depth, const bool prevCbf = false, const bool useISP = false ); + void transform_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, CodingUnit& cu, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 ); + bool cbf_comp ( CodingUnit& cu, const CompArea& area, unsigned depth, const bool prevCbf = false, const bool useISP = false ); // mvd coding (clause 7.3.8.9) void mvd_coding ( Mv &rMvd ); diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index c1985e277..ced66a41e 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file DecCu.cpp @@ -139,36 +143,50 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) return; } - CodingStructure &cs = *tu.cs; - const CompArea& area = tu.blocks[compID]; - - const ChannelType chType = toChannelType( compID ); - - PelBuf piPred = m_PredBuffer.getCompactBuf( area ); - - const PredictionUnit &pu = *tu.cs->getPU( area.pos(), chType ); - const uint32_t uiChFinalMode = PU::getFinalIntraMode( pu, chType ); - PelBuf pReco = cs.getRecoBuf(area); + CodingStructure &cs = *tu.cs; + const CompArea& area = tu.blocks[compID]; + const ChannelType chType = toChannelType( compID ); + PelBuf piPred = tu.cu->ispMode && isLuma( compID ) ? cs.getPredBuf( area ) : m_PredBuffer.getCompactBuf( area ); + const CodingUnit& cu = *tu.cu; + const uint32_t uiChFinalMode = CU::getFinalIntraMode( cu, chType ); + PelBuf pReco = cs.getRecoBuf( area ); //===== init availability pattern ===== - bool predRegDiffFromTB = CU::isPredRegDiffFromTB(*tu.cu, compID); - bool firstTBInPredReg = CU::isFirstTBInPredReg(*tu.cu, compID, area); CompArea areaPredReg(COMP_Y, tu.chromaFormat, area); + bool predRegDiffFromTB = isLuma( compID ) && CU::isPredRegDiffFromTB( *tu.cu ); + bool firstTBInPredReg = isLuma( compID ) && CU::isFirstTBInPredReg ( *tu.cu, area ); + + if( tu.cu->ispMode && isLuma( compID ) ) { - m_pcIntraPred->initIntraPatternChType(*tu.cu, area); + if( predRegDiffFromTB ) + { + if( firstTBInPredReg ) + { + CU::adjustPredArea( areaPredReg ); + m_pcIntraPred->initIntraPatternChTypeISP( *tu.cu, areaPredReg, pReco ); + } + } + else + { + m_pcIntraPred->initIntraPatternChTypeISP( *tu.cu, area, pReco ); + } + } + else + { + m_pcIntraPred->initIntraPatternChType( *tu.cu, area ); } //===== get prediction signal ===== - if( compID != COMP_Y && PU::isLMCMode( uiChFinalMode ) ) + if( compID != COMP_Y && CU::isLMCMode( uiChFinalMode ) ) { - const PredictionUnit& pu = *tu.cu->pu; - m_pcIntraPred->loadLMLumaRecPels( pu, area ); - m_pcIntraPred->predIntraChromaLM( compID, piPred, pu, area, uiChFinalMode ); + const CodingUnit& cu = *tu.cu; + m_pcIntraPred->loadLMLumaRecPels( cu, area ); + m_pcIntraPred->predIntraChromaLM( compID, piPred, cu, area, uiChFinalMode ); } - else if( PU::isMIP( pu, chType ) ) + else if( CU::isMIP( cu, chType ) ) { - m_pcIntraPred->initIntraMip( pu ); - m_pcIntraPred->predIntraMip( piPred, pu ); + m_pcIntraPred->initIntraMip( cu ); + m_pcIntraPred->predIntraMip( piPred, cu ); } else { @@ -177,12 +195,12 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) if (firstTBInPredReg) { PelBuf piPredReg = cs.getPredBuf(areaPredReg); - m_pcIntraPred->predIntraAng(compID, piPredReg, pu); + m_pcIntraPred->predIntraAng(compID, piPredReg, cu); } } else { - m_pcIntraPred->predIntraAng(compID, piPred, pu); + m_pcIntraPred->predIntraAng(compID, piPred, cu); } } //===== inverse transform ===== @@ -234,15 +252,6 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) piResi.scaleSignal(tu.chromaAdj, 0, tu.cu->cs->slice->clpRngs[compID]); } - if( !tu.cu->ispMode || !isLuma( compID ) ) - { - cs.setDecomp( area ); - } - else if( tu.cu->ispMode && isLuma( compID ) && CU::isISPFirst( *tu.cu, tu.blocks[compID], compID ) ) - { - cs.setDecomp( tu.cu->blocks[compID] ); - } - piPred.reconstruct( piPred, piResi, tu.cu->cs->slice->clpRngs[ compID ] ); pReco.copyFrom( piPred ); @@ -301,13 +310,12 @@ void DecCu::xReconInter(CodingUnit &cu) CodingStructure &cs = *cu.cs; // inter prediction - PredictionUnit &pu = *cu.pu; - PelUnitBuf predBuf = m_PredBuffer.getCompactBuf( pu ); + PelUnitBuf predBuf = m_PredBuffer.getCompactBuf( cu ); const ReshapeData& reshapeData = cs.picture->reshapeData; if (cu.geo) { - m_pcInterPred->motionCompensationGeo(pu, predBuf, m_geoMrgCtx); - PU::spanGeoMotionInfo(*cu.pu, m_geoMrgCtx, cu.pu->geoSplitDir, cu.pu->geoMergeIdx0, cu.pu->geoMergeIdx1); + m_pcInterPred->motionCompensationGeo(cu, predBuf, m_geoMrgCtx); + CU::spanGeoMotionInfo(cu, m_geoMrgCtx, cu.geoSplitDir, cu.geoMergeIdx0, cu.geoMergeIdx1); } else if( cu.predMode == MODE_IBC ) { @@ -315,47 +323,46 @@ void DecCu::xReconInter(CodingUnit &cu) } else { - cu.pu->mvRefine = true; - m_pcInterPred->motionCompensation( pu, predBuf ); - cu.pu->mvRefine = false; + cu.mvRefine = true; + m_pcInterPred->motionCompensation( cu, predBuf ); + cu.mvRefine = false; if (!cu.affine && !cu.geo ) { - const MotionInfo &mi = pu.getMotionInfo(); + const MotionInfo &mi = cu.getMotionInfo(); HPMVInfo hMi( mi, (mi.interDir == 3) ? cu.BcwIdx : BCW_DEFAULT, cu.imv == IMV_HPEL ); cs.addMiToLut( cu.cs->motionLut.lut, hMi ); } - if (cu.pu->ciip) + if (cu.ciip) { - const PredictionUnit& pu = *cu.pu; - PelBuf ciipBuf = m_TmpBuffer.getCompactBuf( pu.Y() ); + PelBuf ciipBuf = m_TmpBuffer.getCompactBuf( cu.Y() ); - m_pcIntraPred->initIntraPatternChType(cu, pu.Y()); - m_pcIntraPred->predIntraAng(COMP_Y, ciipBuf, pu); + m_pcIntraPred->initIntraPatternChType(cu, cu.Y()); + m_pcIntraPred->predIntraAng(COMP_Y, ciipBuf, cu); if( cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() ) { predBuf.Y().rspSignal( reshapeData.getFwdLUT()); } - const int numCiipIntra = m_pcIntraPred->getNumIntraCiip( pu ); + const int numCiipIntra = m_pcIntraPred->getNumIntraCiip( cu ); predBuf.Y().weightCiip( ciipBuf, numCiipIntra); - if (isChromaEnabled(pu.chromaFormat) && pu.chromaSize().width > 2) + if (isChromaEnabled(cu.chromaFormat) && cu.chromaSize().width > 2) { - PelBuf ciipBufC = m_TmpBuffer.getCompactBuf( pu.Cb() ); - m_pcIntraPred->initIntraPatternChType(cu, pu.Cb()); - m_pcIntraPred->predIntraAng(COMP_Cb, ciipBufC, pu); + PelBuf ciipBufC = m_TmpBuffer.getCompactBuf( cu.Cb() ); + m_pcIntraPred->initIntraPatternChType(cu, cu.Cb()); + m_pcIntraPred->predIntraAng(COMP_Cb, ciipBufC, cu); predBuf.Cb().weightCiip( ciipBufC, numCiipIntra); - m_pcIntraPred->initIntraPatternChType(cu, pu.Cr()); - m_pcIntraPred->predIntraAng(COMP_Cr, ciipBufC, pu); + m_pcIntraPred->initIntraPatternChType(cu, cu.Cr()); + m_pcIntraPred->predIntraAng(COMP_Cr, ciipBufC, cu); predBuf.Cr().weightCiip( ciipBufC, numCiipIntra); } } } - if (cs.slice->lmcsEnabled && reshapeData.getCTUFlag() && !cu.pu->ciip && !CU::isIBC(cu) ) + if (cs.slice->lmcsEnabled && reshapeData.getCTUFlag() && !cu.ciip && !CU::isIBC(cu) ) { predBuf.Y().rspSignal(reshapeData.getFwdLUT()); } @@ -372,8 +379,6 @@ void DecCu::xReconInter(CodingUnit &cu) { cs.getRecoBuf(cu).copyClip( predBuf, cs.slice->clpRngs); } - - cs.setDecomp(cu); } void DecCu::xDecodeInterTU( TransformUnit& currTU, const ComponentID compID ) @@ -453,142 +458,139 @@ void DecCu::xDecodeInterTexture(CodingUnit &cu) void DecCu::xDeriveCUMV( CodingUnit &cu ) { - PredictionUnit &pu = *cu.pu; - { - MergeCtx mrgCtx; + MergeCtx mrgCtx; - if( pu.mergeFlag ) + if( cu.mergeFlag ) + { + if (cu.mmvdMergeFlag || cu.mmvdSkip) { - if (pu.mmvdMergeFlag || pu.cu->mmvdSkip) + CHECK(cu.ciip == true, "invalid MHIntra"); + if (cu.cs->sps->SbtMvp) { - CHECK(pu.ciip == true, "invalid MHIntra"); - if (pu.cs->sps->SbtMvp) - { - Size bufSize = g_miScaling.scale(pu.lumaSize()); - mrgCtx.subPuMvpMiBuf = MotionBuf(m_subPuMiBuf, bufSize); - } - int fPosBaseIdx = pu.mmvdMergeIdx / MMVD_MAX_REFINE_NUM; - PU::getInterMergeCandidates(pu, mrgCtx, 1, fPosBaseIdx + 1); - PU::getInterMMVDMergeCandidates(pu, mrgCtx, pu.mmvdMergeIdx); - mrgCtx.setMmvdMergeCandiInfo(pu, pu.mmvdMergeIdx); - PU::spanMotionInfo(pu, mrgCtx); + Size bufSize = g_miScaling.scale(cu.lumaSize()); + mrgCtx.subPuMvpMiBuf = MotionBuf(m_subPuMiBuf, bufSize); + } + int fPosBaseIdx = cu.mmvdMergeIdx / MMVD_MAX_REFINE_NUM; + CU::getInterMergeCandidates(cu, mrgCtx, 1, fPosBaseIdx + 1); + CU::getInterMMVDMergeCandidates(cu, mrgCtx, cu.mmvdMergeIdx); + mrgCtx.setMmvdMergeCandiInfo(cu, cu.mmvdMergeIdx); + CU::spanMotionInfo(cu, mrgCtx); + } + else + { + if (cu.geo) + { + CU::getGeoMergeCandidates(cu, m_geoMrgCtx); } else { - if (pu.cu->geo) - { - PU::getGeoMergeCandidates(pu, m_geoMrgCtx); - } - else + if (cu.affine) { - if (pu.cu->affine) + AffineMergeCtx affineMergeCtx; + if (cu.cs->sps->SbtMvp) { - AffineMergeCtx affineMergeCtx; - if (pu.cs->sps->SbtMvp) - { - Size bufSize = g_miScaling.scale(pu.lumaSize()); - mrgCtx.subPuMvpMiBuf = MotionBuf(m_subPuMiBuf, bufSize); - affineMergeCtx.mrgCtx = &mrgCtx; - } - PU::getAffineMergeCand(pu, affineMergeCtx, pu.mergeIdx); - pu.interDir = affineMergeCtx.interDirNeighbours[pu.mergeIdx]; - pu.cu->affineType = affineMergeCtx.affineType[pu.mergeIdx]; - pu.cu->BcwIdx = affineMergeCtx.BcwIdx[pu.mergeIdx]; - pu.mergeType = affineMergeCtx.mergeType[pu.mergeIdx]; + Size bufSize = g_miScaling.scale(cu.lumaSize()); + mrgCtx.subPuMvpMiBuf = MotionBuf(m_subPuMiBuf, bufSize); + affineMergeCtx.mrgCtx = &mrgCtx; + } + CU::getAffineMergeCand(cu, affineMergeCtx, cu.mergeIdx); + cu.interDir = affineMergeCtx.interDirNeighbours[cu.mergeIdx]; + cu.affineType = affineMergeCtx.affineType[cu.mergeIdx]; + cu.BcwIdx = affineMergeCtx.BcwIdx[cu.mergeIdx]; + cu.mergeType = affineMergeCtx.mergeType[cu.mergeIdx]; - if (pu.mergeType == MRG_TYPE_SUBPU_ATMVP) - { - pu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(pu.mergeIdx << 1) + 0][0].refIdx; - pu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(pu.mergeIdx << 1) + 1][0].refIdx; - } - else + if (cu.mergeType == MRG_TYPE_SUBPU_ATMVP) + { + cu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(cu.mergeIdx << 1) + 0][0].refIdx; + cu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(cu.mergeIdx << 1) + 1][0].refIdx; + } + else + { + for (int i = 0; i < 2; ++i) { - for (int i = 0; i < 2; ++i) + if (cu.cs->slice->numRefIdx[RefPicList(i)] > 0) { - if (pu.cs->slice->numRefIdx[RefPicList(i)] > 0) - { - MvField *mvField = affineMergeCtx.mvFieldNeighbours[(pu.mergeIdx << 1) + i]; - pu.mvpIdx[i] = 0; - pu.mvpNum[i] = 0; - pu.mvd[i] = Mv(); - PU::setAllAffineMvField(pu, mvField, RefPicList(i)); - } + MvField *mvField = affineMergeCtx.mvFieldNeighbours[(cu.mergeIdx << 1) + i]; + cu.mvpIdx[i] = 0; + cu.mvpNum[i] = 0; + cu.mvd[i] = Mv(); + CU::setAllAffineMvField(cu, mvField, RefPicList(i)); } } } - else - { - PU::getInterMergeCandidates(pu, mrgCtx, 0, pu.mergeIdx); - mrgCtx.setMergeInfo(pu, pu.mergeIdx); - } - - PU::spanMotionInfo(pu, mrgCtx); } + else + { + CU::getInterMergeCandidates(cu, mrgCtx, 0, cu.mergeIdx); + mrgCtx.setMergeInfo(cu, cu.mergeIdx); + } + + CU::spanMotionInfo(cu, mrgCtx); } - } - else + } + } + else + { + if (cu.affine) { - if (pu.cu->affine) + for (uint32_t uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++) { - for (uint32_t uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++) + RefPicList eRefList = RefPicList(uiRefListIdx); + if (cu.cs->slice->numRefIdx[eRefList] > 0 && (cu.interDir & (1 << uiRefListIdx))) { - RefPicList eRefList = RefPicList(uiRefListIdx); - if (pu.cs->slice->numRefIdx[eRefList] > 0 && (pu.interDir & (1 << uiRefListIdx))) - { - AffineAMVPInfo affineAMVPInfo; - PU::fillAffineMvpCand(pu, eRefList, pu.refIdx[eRefList], affineAMVPInfo); + AffineAMVPInfo affineAMVPInfo; + CU::fillAffineMvpCand(cu, eRefList, cu.refIdx[eRefList], affineAMVPInfo); - const unsigned mvp_idx = pu.mvpIdx[eRefList]; + const unsigned mvp_idx = cu.mvpIdx[eRefList]; - pu.mvpNum[eRefList] = affineAMVPInfo.numCand; + cu.mvpNum[eRefList] = affineAMVPInfo.numCand; - // Mv mv[3]; - CHECK(pu.refIdx[eRefList] < 0, "Unexpected negative refIdx."); - if (!cu.cs->pcv->isEncoder) + // Mv mv[3]; + CHECK(cu.refIdx[eRefList] < 0, "Unexpected negative refIdx."); + if (!cu.cs->pcv->isEncoder) + { + cu.mvdAffi[eRefList][0].changeAffinePrecAmvr2Internal(cu.imv); + cu.mvdAffi[eRefList][1].changeAffinePrecAmvr2Internal(cu.imv); + if (cu.affineType == AFFINEMODEL_6PARAM) { - pu.mvdAffi[eRefList][0].changeAffinePrecAmvr2Internal(pu.cu->imv); - pu.mvdAffi[eRefList][1].changeAffinePrecAmvr2Internal(pu.cu->imv); - if (cu.affineType == AFFINEMODEL_6PARAM) - { - pu.mvdAffi[eRefList][2].changeAffinePrecAmvr2Internal(pu.cu->imv); - } + cu.mvdAffi[eRefList][2].changeAffinePrecAmvr2Internal(cu.imv); } + } - Mv mvLT = affineAMVPInfo.mvCandLT[mvp_idx] + pu.mvdAffi[eRefList][0]; - Mv mvRT = affineAMVPInfo.mvCandRT[mvp_idx] + pu.mvdAffi[eRefList][1]; - mvRT += pu.mvdAffi[eRefList][0]; + Mv mvLT = affineAMVPInfo.mvCandLT[mvp_idx] + cu.mvdAffi[eRefList][0]; + Mv mvRT = affineAMVPInfo.mvCandRT[mvp_idx] + cu.mvdAffi[eRefList][1]; + mvRT += cu.mvdAffi[eRefList][0]; - Mv mvLB; - if (cu.affineType == AFFINEMODEL_6PARAM) - { - mvLB = affineAMVPInfo.mvCandLB[mvp_idx] + pu.mvdAffi[eRefList][2]; - mvLB += pu.mvdAffi[eRefList][0]; - } - PU::setAllAffineMv(pu, mvLT, mvRT, mvLB, eRefList, true); + Mv mvLB; + if (cu.affineType == AFFINEMODEL_6PARAM) + { + mvLB = affineAMVPInfo.mvCandLB[mvp_idx] + cu.mvdAffi[eRefList][2]; + mvLB += cu.mvdAffi[eRefList][0]; } + CU::setAllAffineMv(cu, mvLT, mvRT, mvLB, eRefList, true); } } - else + } + else + { + for ( uint32_t uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) { - for ( uint32_t uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) + RefPicList eRefList = RefPicList( uiRefListIdx ); + if ((cu.cs->slice->numRefIdx[eRefList] > 0 || (eRefList == REF_PIC_LIST_0 && CU::isIBC(cu))) && (cu.interDir & (1 << uiRefListIdx))) { - RefPicList eRefList = RefPicList( uiRefListIdx ); - if ((pu.cs->slice->numRefIdx[eRefList] > 0 || (eRefList == REF_PIC_LIST_0 && CU::isIBC(*pu.cu))) && (pu.interDir & (1 << uiRefListIdx))) + AMVPInfo amvpInfo; + CU::fillMvpCand(cu, eRefList, cu.refIdx[eRefList], amvpInfo); + cu.mvpNum [eRefList] = amvpInfo.numCand; + if (!cu.cs->pcv->isEncoder) { - AMVPInfo amvpInfo; - PU::fillMvpCand(pu, eRefList, pu.refIdx[eRefList], amvpInfo); - pu.mvpNum [eRefList] = amvpInfo.numCand; - if (!cu.cs->pcv->isEncoder) - { - pu.mvd[eRefList].changeTransPrecAmvr2Internal(pu.cu->imv); - } - pu.mv[eRefList] = amvpInfo.mvCand[pu.mvpIdx[eRefList]] + pu.mvd[eRefList]; - pu.mv[eRefList].mvCliptoStorageBitDepth(); + cu.mvd[eRefList].changeTransPrecAmvr2Internal(cu.imv); } + cu.mv[eRefList] = amvpInfo.mvCand[cu.mvpIdx[eRefList]] + cu.mvd[eRefList]; + cu.mv[eRefList].mvCliptoStorageBitDepth(); } } - PU::spanMotionInfo( pu, mrgCtx ); } + CU::spanMotionInfo( cu, mrgCtx ); } } diff --git a/source/Lib/DecoderLib/DecCu.h b/source/Lib/DecoderLib/DecCu.h index 004483c4d..bfefeb114 100644 --- a/source/Lib/DecoderLib/DecCu.h +++ b/source/Lib/DecoderLib/DecCu.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file DecCu.h \brief CU decoder class (header) */ diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 62017be2f..de5d2b55e 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file DecLib.cpp @@ -71,7 +75,7 @@ vvc@hhi.fraunhofer.de namespace vvenc { -bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::string& bitstreamFileName, FFwdDecoder& ffwdDecoder, ParameterSetMap& apsMap, bool bDecodeUntilPocFound /* = false */, int debugPOC /* = -1*/ ) +bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::string& bitstreamFileName, FFwdDecoder& ffwdDecoder, ParameterSetMap* apsMap, bool bDecodeUntilPocFound /* = false */, int debugPOC /* = -1*/, bool copyToEnc /* = true */ ) { PicList* pcListPic = NULL; bool bRet = false; @@ -93,7 +97,7 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri ffwdDecoder.pcDecLib->setDebugPOC ( debugPOC ); ffwdDecoder.pcDecLib->setDecodedPictureHashSEIEnabled( true ); - ffwdDecoder.pcDecLib->setAPSMapEnc ( &apsMap ); + if(apsMap) ffwdDecoder.pcDecLib->setAPSMapEnc ( apsMap ); msg( INFO, "start to decode %s \n", bitstreamFileName.c_str() ); } @@ -148,87 +152,90 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri { for( auto & pic : *pcListPic ) { - if( pic->poc == poc && (!bDecodeUntilPocFound || expectedPoc == poc ) ) + if( copyToEnc ) { - CHECK( pcEncPic->slices.size() == 0, "at least one slice should be available" ); + if( pic->poc == poc && (!bDecodeUntilPocFound || expectedPoc == poc ) ) + { + CHECK( pcEncPic->slices.size() == 0, "at least one slice should be available" ); - CHECK( expectedPoc != poc, "mismatch in POC - check encoder configuration" ); + CHECK( expectedPoc != poc, "mismatch in POC - check encoder configuration" ); - if( poc != debugPOC ) - { - for( int i = 0; i < pic->slices.size(); i++ ) + if( poc != debugPOC ) { - if( pcEncPic->slices.size() <= i ) + for( int i = 0; i < pic->slices.size(); i++ ) { - pcEncPic->slices.push_back( new Slice ); - pcEncPic->slices.back()->pps = pcEncPic->slices[0]->pps; - pcEncPic->slices.back()->sps = pcEncPic->slices[0]->sps; - pcEncPic->slices.back()->vps = pcEncPic->slices[0]->vps; - pcEncPic->slices.back()->pic = pcEncPic->slices[0]->pic; + if( pcEncPic->slices.size() <= i ) + { + pcEncPic->slices.push_back( new Slice ); + pcEncPic->slices.back()->pps = pcEncPic->slices[0]->pps; + pcEncPic->slices.back()->sps = pcEncPic->slices[0]->sps; + pcEncPic->slices.back()->vps = pcEncPic->slices[0]->vps; + pcEncPic->slices.back()->pic = pcEncPic->slices[0]->pic; + } + pcEncPic->slices[i]->copySliceInfo( pic->slices[i], false ); } - pcEncPic->slices[i]->copySliceInfo( pic->slices[i], false ); } - } - pcEncPic->cs->slice = pcEncPic->slices.back(); - - { - if ( pic->cs->sps->saoEnabled ) - { - pcEncPic->copySAO( *pic, 0 ); - } + pcEncPic->cs->slice = pcEncPic->slices.back(); - if( pic->cs->sps->alfEnabled ) { - std::copy(pic->getAlfCtbFilterIndexVec().begin(), pic->getAlfCtbFilterIndexVec().end(), pcEncPic->getAlfCtbFilterIndexVec().begin()); - for( int compIdx = 0; compIdx < MAX_NUM_COMP; compIdx++ ) + if ( pic->cs->sps->saoEnabled ) { - std::copy( pic->getAlfCtuEnabled()[compIdx].begin(), pic->getAlfCtuEnabled()[compIdx].end(), pcEncPic->getAlfCtuEnabled()[compIdx].begin() ); + pcEncPic->copySAO( *pic, 0 ); } - pcEncPic->resizeAlfCtbFilterIndex(pic->cs->pcv->sizeInCtus); - memcpy( pcEncPic->getAlfCtbFilterIndex(), pic->getAlfCtbFilterIndex(), sizeof(short)*pic->cs->pcv->sizeInCtus ); - std::copy( pic->getAlfCtuAlternative(COMP_Cb).begin(), pic->getAlfCtuAlternative(COMP_Cb).end(), pcEncPic->getAlfCtuAlternative(COMP_Cb).begin() ); - std::copy( pic->getAlfCtuAlternative(COMP_Cr).begin(), pic->getAlfCtuAlternative(COMP_Cr).end(), pcEncPic->getAlfCtuAlternative(COMP_Cr).begin() ); + if( pic->cs->sps->alfEnabled ) + { + std::copy(pic->getAlfCtbFilterIndexVec().begin(), pic->getAlfCtbFilterIndexVec().end(), pcEncPic->getAlfCtbFilterIndexVec().begin()); + for( int compIdx = 0; compIdx < MAX_NUM_COMP; compIdx++ ) + { + std::copy( pic->getAlfCtuEnabled()[compIdx].begin(), pic->getAlfCtuEnabled()[compIdx].end(), pcEncPic->getAlfCtuEnabled()[compIdx].begin() ); + } + pcEncPic->resizeAlfCtbFilterIndex(pic->cs->pcv->sizeInCtus); + memcpy( pcEncPic->getAlfCtbFilterIndex(), pic->getAlfCtbFilterIndex(), sizeof(short)*pic->cs->pcv->sizeInCtus ); + + std::copy( pic->getAlfCtuAlternative(COMP_Cb).begin(), pic->getAlfCtuAlternative(COMP_Cb).end(), pcEncPic->getAlfCtuAlternative(COMP_Cb).begin() ); + std::copy( pic->getAlfCtuAlternative(COMP_Cr).begin(), pic->getAlfCtuAlternative(COMP_Cr).end(), pcEncPic->getAlfCtuAlternative(COMP_Cr).begin() ); + + for( int i = 0; i < pic->slices.size(); i++ ) + { + pcEncPic->slices[i]->tileGroupNumAps = (pic->slices[i]->tileGroupNumAps); + pcEncPic->slices[i]->setAlfAPSs(pic->slices[i]->alfAps); + pcEncPic->slices[i]-> tileGroupChromaApsId = pic->slices[i]->tileGroupChromaApsId; + pcEncPic->slices[i]->tileGroupAlfEnabled[COMP_Y] = pic->slices[i]->tileGroupAlfEnabled[COMP_Y]; + pcEncPic->slices[i]->tileGroupAlfEnabled[COMP_Cb] = pic->slices[i]->tileGroupAlfEnabled[COMP_Cb]; + pcEncPic->slices[i]->tileGroupAlfEnabled[COMP_Cr] = pic->slices[i]->tileGroupAlfEnabled[COMP_Cr]; + pcEncPic->slices[i]->tileGroupCcAlfCbApsId = pic->slices[i]->tileGroupCcAlfCbApsId; + pcEncPic->slices[i]->tileGroupCcAlfCbEnabled = pic->slices[i]->tileGroupCcAlfCbEnabled; + pcEncPic->slices[i]->tileGroupCcAlfCrApsId = pic->slices[i]->tileGroupCcAlfCrApsId; + pcEncPic->slices[i]->tileGroupCcAlfCrEnabled = pic->slices[i]->tileGroupCcAlfCrEnabled; + } + } - for( int i = 0; i < pic->slices.size(); i++ ) + pcDecLib->executeLoopFilters(); + if ( pic->cs->sps->saoEnabled ) { - pcEncPic->slices[i]->tileGroupNumAps = (pic->slices[i]->tileGroupNumAps); - pcEncPic->slices[i]->setAlfAPSs(pic->slices[i]->alfAps); - pcEncPic->slices[i]-> tileGroupChromaApsId = pic->slices[i]->tileGroupChromaApsId; - pcEncPic->slices[i]->tileGroupAlfEnabled[COMP_Y] = pic->slices[i]->tileGroupAlfEnabled[COMP_Y]; - pcEncPic->slices[i]->tileGroupAlfEnabled[COMP_Cb] = pic->slices[i]->tileGroupAlfEnabled[COMP_Cb]; - pcEncPic->slices[i]->tileGroupAlfEnabled[COMP_Cr] = pic->slices[i]->tileGroupAlfEnabled[COMP_Cr]; - pcEncPic->slices[i]->tileGroupCcAlfCbApsId = pic->slices[i]->tileGroupCcAlfCbApsId; - pcEncPic->slices[i]->tileGroupCcAlfCbEnabled = pic->slices[i]->tileGroupCcAlfCbEnabled; - pcEncPic->slices[i]->tileGroupCcAlfCrApsId = pic->slices[i]->tileGroupCcAlfCrApsId; - pcEncPic->slices[i]->tileGroupCcAlfCrEnabled = pic->slices[i]->tileGroupCcAlfCrEnabled; + pcEncPic->copySAO( *pic, 1 ); } - } - pcDecLib->executeLoopFilters(); - if ( pic->cs->sps->saoEnabled ) - { - pcEncPic->copySAO( *pic, 1 ); - } + pcEncPic->cs->copyStructure( *pic->cs, CH_L, TREE_D, true, true ); - pcEncPic->cs->copyStructure( *pic->cs, CH_L, TREE_D, true, true ); + if( CS::isDualITree( *pcEncPic->cs ) ) + { + pcEncPic->cs->copyStructure( *pic->cs, CH_C, TREE_D, true, true ); + } + } - if( CS::isDualITree( *pcEncPic->cs ) ) + pcEncPic->cs->slice = pcEncPic->slices[ 0 ]; + pcEncPic->cs->picHeader->copyPicInfo( pic->cs->picHeader, false ); + for( auto& cu: pcEncPic->cs->cus) { - pcEncPic->cs->copyStructure( *pic->cs, CH_C, TREE_D, true, true ); + cu->slice = pcEncPic->cs->slice; } + goOn = false; // exit the loop return + bRet = true; + break; } - - pcEncPic->cs->slice = pcEncPic->slices[ 0 ]; - pcEncPic->cs->picHeader->copyPicInfo( pic->cs->picHeader, false ); - for( auto& cu: pcEncPic->cs->cus) - { - cu->slice = pcEncPic->cs->slice; - } - goOn = false; // exit the loop return - bRet = true; - break; } } } @@ -238,7 +245,7 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri pcDecLib->executeLoopFilters(); } - pcDecLib->finishPicture( poc, pcListPic, DETAILS ); + pcDecLib->finishPicture( poc, pcListPic, copyToEnc ? DETAILS : INFO ); // write output if( ! pcListPic->empty()) @@ -967,7 +974,7 @@ void DecLib::xActivateParameterSets( const int layerId) } APS* lmcsAPS = NULL; - if (m_picHeader.lmcsApsId != -1) + if (m_picHeader.lmcsEnabled) { lmcsAPS = m_parameterSetManager.getAPS(m_picHeader.lmcsApsId, LMCS_APS); CHECK(lmcsAPS == 0, "No LMCS APS present"); @@ -996,7 +1003,7 @@ void DecLib::xActivateParameterSets( const int layerId) m_apcSlicePilot->pps = pps; m_apcSlicePilot->picHeader = &m_picHeader; m_apcSlicePilot->applyReferencePictureListBasedMarking(m_cListPic, m_apcSlicePilot->rpl[0], m_apcSlicePilot->rpl[1], layerId, *pps); - m_pic->finalInit(*vps, *sps, *pps, m_picHeader, m_unitCache, nullptr, apss, lmcsAPS); + m_pic->finalInit(*vps, *sps, *pps, &m_picHeader, m_unitCache, nullptr, apss, lmcsAPS); m_pic->createTempBuffers( m_pic->cs->pps->pcv->maxCUSize ); m_pic->cs->createCoeffs(); @@ -1243,7 +1250,7 @@ void DecLib::xParsePrefixSEImessages() while (!m_prefixSEINALUs.empty()) { InputNALUnit &nalu=*m_prefixSEINALUs.front(); - m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, nalu.m_temporalId, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); + m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_HRD, m_pDecodedSEIOutputStream ); delete m_prefixSEINALUs.front(); m_prefixSEINALUs.pop_front(); } @@ -1675,7 +1682,7 @@ bool DecLib::decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay, i case NAL_UNIT_SUFFIX_SEI: if (m_pic) { - m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pic->SEIs, nalu.m_nalUnitType, nalu.m_temporalId, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); + m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pic->SEIs, nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_HRD, m_pDecodedSEIOutputStream ); } else { diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index 75df50a16..c5b801cf3 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file DecLib.h \brief decoder class (header) */ @@ -69,7 +73,7 @@ namespace vvenc { class InputNALUnit; struct FFwdDecoder; -bool tryDecodePicture( Picture* pic, const int expectedPoc, const std::string& bitstreamFileName, FFwdDecoder& ffwdDecoder, ParameterSetMap& apsMap, bool bDecodeUntilPocFound = false, int debugPOC = -1 ); +bool tryDecodePicture( Picture* pic, const int expectedPoc, const std::string& bitstreamFileName, FFwdDecoder& ffwdDecoder, ParameterSetMap* apsMap, bool bDecodeUntilPocFound = false, int debugPOC = -1, bool copyToEnc = true ); // Class definition // ==================================================================================================================== @@ -106,6 +110,7 @@ class DecLib LoopFilter m_cLoopFilter; SampleAdaptiveOffset m_cSAO; Reshape m_cReshaper; + HRD m_HRD; AdaptiveLoopFilter m_cALF; RdCost m_cRdCost; ///< RD cost computation class XUCache m_unitCache; diff --git a/source/Lib/DecoderLib/DecSlice.cpp b/source/Lib/DecoderLib/DecSlice.cpp index 5e9ff5c22..048d81102 100644 --- a/source/Lib/DecoderLib/DecSlice.cpp +++ b/source/Lib/DecoderLib/DecSlice.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file DecSlice.cpp @@ -143,7 +147,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream ) const unsigned maxCUSize = sps->CTUSize; Position pos( ctuXPosInCtus*maxCUSize, ctuYPosInCtus*maxCUSize) ; UnitArea ctuArea(cs.area.chromaFormat, Area( pos.x, pos.y, maxCUSize, maxCUSize ) ); - SubPic curSubPic = slice->pps->getSubPicFromPos(pos); + const SubPic& curSubPic = slice->pps->getSubPicFromPos(pos); // padding/restore at slice level if (slice->pps->numSubPics>=2 && curSubPic.treatedAsPic && ctuIdx==0) { diff --git a/source/Lib/DecoderLib/DecSlice.h b/source/Lib/DecoderLib/DecSlice.h index 08131162e..f88b8023b 100644 --- a/source/Lib/DecoderLib/DecSlice.h +++ b/source/Lib/DecoderLib/DecSlice.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file DecSlice.h \brief slice decoder class (header) */ diff --git a/source/Lib/DecoderLib/NALread.cpp b/source/Lib/DecoderLib/NALread.cpp index 7ed90d9fd..03a00def0 100644 --- a/source/Lib/DecoderLib/NALread.cpp +++ b/source/Lib/DecoderLib/NALread.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** @@ -54,7 +58,7 @@ vvc@hhi.fraunhofer.de #include #include #include -#include "../../../include/vvenc/Nal.h" +#include "vvenc/Nal.h" //! \ingroup DecoderLib //! \{ diff --git a/source/Lib/DecoderLib/NALread.h b/source/Lib/DecoderLib/NALread.h index 7fb9891df..e97aae4d0 100644 --- a/source/Lib/DecoderLib/NALread.h +++ b/source/Lib/DecoderLib/NALread.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file NALread.h \brief reading functionality for NAL units @@ -46,7 +50,7 @@ vvc@hhi.fraunhofer.de #pragma once -#include "../../../include/vvenc/Nal.h" +#include "vvenc/Nal.h" #include "CommonLib/CommonDef.h" #include "CommonLib/BitStream.h" diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp index 9d6a4a3e5..05cb9b3ed 100644 --- a/source/Lib/DecoderLib/SEIread.cpp +++ b/source/Lib/DecoderLib/SEIread.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** @@ -61,6 +65,14 @@ vvc@hhi.fraunhofer.de //! \{ namespace vvenc { +void SEIReader::sei_read_scode(std::ostream *pOS, uint32_t length, int& code, const char *pSymbolName) +{ + READ_SCODE(length, code, pSymbolName); + if (pOS) + { + (*pOS) << " " << std::setw(55) << pSymbolName << ": " << code << "\n"; + } +} void SEIReader::sei_read_code(std::ostream *pOS, uint32_t uiLength, uint32_t& ruiCode, const char *pSymbolName) { @@ -108,6 +120,7 @@ static inline void output_sei_message_header(SEI &sei, std::ostream *pDecodedMes } #undef READ_CODE +#undef READ_SCODE #undef READ_SVLC #undef READ_UVLC #undef READ_FLAG @@ -116,29 +129,33 @@ static inline void output_sei_message_header(SEI &sei, std::ostream *pDecodedMes /** * unmarshal a single SEI message from bitstream bs */ -void SEIReader::parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t temporalId, const SPS *sps, std::ostream *pDecodedMessageOutputStream) + // note: for independent parsing no parameter set should not be required here +void SEIReader::parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream) { + SEIMessages seiListInCurNalu; setBitstream(bs); - CHECK(m_pcBitstream->getNumBitsUntilByteAligned(), "Bitstream not aligned"); + do { - xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); - + xReadSEImessage(seis, nalUnitType, nuh_layer_id, temporalId, vps, sps, hrd, pDecodedMessageOutputStream); + seiListInCurNalu.push_back(seis.back()); /* SEI messages are an integer number of bytes, something has failed * in the parsing if bitstream not byte-aligned */ CHECK(m_pcBitstream->getNumBitsUntilByteAligned(), "Bitstream not aligned"); } while (m_pcBitstream->getNumBitsLeft() > 8); + SEIMessages fillerData = getSeisByType(seiListInCurNalu, SEI::FILLER_PAYLOAD); + CHECK(fillerData.size() > 0 && fillerData.size() != seiListInCurNalu.size(), "When an SEI NAL unit contains an SEI message with payloadType equal to filler payload, the SEI NAL unit shall not contain any other SEI message with payloadType not equal to filler payload"); + xReadRbspTrailingBits(); } -void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const SPS *sps, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream) { -#if ENABLE_TRACING - xTraceSEIHeader(); -#endif + DTRACE( g_trace_ctx, D_HEADER, "=========== SEI message ===========\n" ); + int payloadType = 0; uint32_t val = 0; @@ -155,9 +172,7 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType payloadSize += val; } while (val==0xFF); -#if ENABLE_TRACING - xTraceSEIMessageType((SEI::PayloadType)payloadType); -#endif + DTRACE( g_trace_ctx, D_HEADER, "=========== %s SEI message ===========\n", SEI::getSEIMessageString( (SEI::PayloadType)payloadType ) ); /* extract the payload for this single SEI message. * This allows greater safety in erroneous parsing of an SEI message @@ -169,6 +184,8 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType setBitstream(bs->extractSubstream(payloadSize * 8)); SEI *sei = NULL; + const SEIBufferingPeriod *bp = NULL; + const SEIPictureTiming *pt = NULL; if(nalUnitType == NAL_UNIT_PREFIX_SEI) { @@ -178,111 +195,114 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType sei = new SEIuserDataUnregistered; xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::ACTIVE_PARAMETER_SETS: - sei = new SEIActiveParameterSets; - xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); - break; case SEI::DECODING_UNIT_INFO: - if (!sps) + bp = &hrd.bufferingPeriodSEI; + if (!bp) { - msg( WARNING, "Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); + msg( WARNING, "Warning: Found Decoding unit information SEI message, but no active buffering period is available. Ignoring."); } else { sei = new SEIDecodingUnitInfo; - xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); + xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, *bp, temporalId, pDecodedMessageOutputStream); } break; case SEI::BUFFERING_PERIOD: - if (!sps) - { - msg( WARNING, "Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); - } - else - { sei = new SEIBufferingPeriod; - xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream); - } + xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, pDecodedMessageOutputStream); + hrd.bufferingPeriodSEI = *((SEIBufferingPeriod*) sei); break; case SEI::PICTURE_TIMING: - if (!sps) - { - msg( WARNING, "Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); - } - else { - sei = new SEIPictureTiming; - xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream); + bp = &hrd.bufferingPeriodSEI; + if (!bp) + { + msg( WARNING, "Warning: Found Picture timing SEI message, but no active buffering period is available. Ignoring."); + } + else + { + sei = new SEIPictureTiming; + xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, temporalId, *bp, pDecodedMessageOutputStream); + hrd.pictureTimingSEI = *( (SEIPictureTiming*) sei ); + } } break; - case SEI::RECOVERY_POINT: - sei = new SEIRecoveryPoint; - xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::SCALABLE_NESTING: + sei = new SEIScalableNesting; + xParseSEIScalableNesting((SEIScalableNesting&)*sei, nalUnitType, nuh_layer_id, payloadSize, vps, sps, pDecodedMessageOutputStream); + break; + case SEI::FRAME_FIELD_INFO: + sei = new SEIFrameFieldInfo; + pt = &hrd.pictureTimingSEI; + xParseSEIFrameFieldinfo((SEIFrameFieldInfo&) *sei, *pt, payloadSize, pDecodedMessageOutputStream); + break; + case SEI::DEPENDENT_RAP_INDICATION: + sei = new SEIDependentRAPIndication; + xParseSEIDependentRAPIndication((SEIDependentRAPIndication&) *sei, payloadSize, pDecodedMessageOutputStream); break; case SEI::FRAME_PACKING: sei = new SEIFramePacking; xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::SEGM_RECT_FRAME_PACKING: - sei = new SEISegmentedRectFramePacking; - xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::PARAMETER_SETS_INCLUSION_INDICATION: + sei = new SEIParameterSetsInclusionIndication; + xParseSEIParameterSetsInclusionIndication((SEIParameterSetsInclusionIndication&)*sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::DISPLAY_ORIENTATION: - sei = new SEIDisplayOrientation; - xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: + sei = new SEIMasteringDisplayColourVolume; + xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::TEMPORAL_LEVEL0_INDEX: - sei = new SEITemporalLevel0Index; - xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: + sei = new SEIAlternativeTransferCharacteristics; + xParseSEIAlternativeTransferCharacteristics((SEIAlternativeTransferCharacteristics&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::REGION_REFRESH_INFO: - sei = new SEIGradualDecodingRefreshInfo; - xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::EQUIRECTANGULAR_PROJECTION: + sei = new SEIEquirectangularProjection; + xParseSEIEquirectangularProjection((SEIEquirectangularProjection&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::NO_DISPLAY: - sei = new SEINoDisplay; - xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::SPHERE_ROTATION: + sei = new SEISphereRotation; + xParseSEISphereRotation((SEISphereRotation&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::TONE_MAPPING_INFO: - sei = new SEIToneMappingInfo; - xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::OMNI_VIEWPORT: + sei = new SEIOmniViewport; + xParseSEIOmniViewport((SEIOmniViewport&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::SOP_DESCRIPTION: - sei = new SEISOPDescription; - xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::REGION_WISE_PACKING: + sei = new SEIRegionWisePacking; + xParseSEIRegionWisePacking((SEIRegionWisePacking&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::SCALABLE_NESTING: - sei = new SEIScalableNesting; - xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); + case SEI::GENERALIZED_CUBEMAP_PROJECTION: + sei = new SEIGeneralizedCubemapProjection; + xParseSEIGeneralizedCubemapProjection((SEIGeneralizedCubemapProjection&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: - sei = new SEITempMotionConstrainedTileSets; - xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::SUBPICTURE_LEVEL_INFO: + sei = new SEISubpicureLevelInfo; + xParseSEISubpictureLevelInfo((SEISubpicureLevelInfo&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::TIME_CODE: - sei = new SEITimeCode; - xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::SAMPLE_ASPECT_RATIO_INFO: + sei = new SEISampleAspectRatioInfo; + xParseSEISampleAspectRatioInfo((SEISampleAspectRatioInfo&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::CHROMA_RESAMPLING_FILTER_HINT: - sei = new SEIChromaResamplingFilterHint; - xParseSEIChromaResamplingFilterHint((SEIChromaResamplingFilterHint&) *sei, payloadSize, pDecodedMessageOutputStream); - //} + case SEI::USER_DATA_REGISTERED_ITU_T_T35: + sei = new SEIUserDataRegistered; + xParseSEIUserDataRegistered((SEIUserDataRegistered&)*sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::KNEE_FUNCTION_INFO: - sei = new SEIKneeFunctionInfo; - xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::FILM_GRAIN_CHARACTERISTICS: + sei = new SEIFilmGrainCharacteristics; + xParseSEIFilmGrainCharacteristics((SEIFilmGrainCharacteristics&)*sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::COLOUR_REMAPPING_INFO: - sei = new SEIColourRemappingInfo; - xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::CONTENT_LIGHT_LEVEL_INFO: + sei = new SEIContentLightLevelInfo; + xParseSEIContentLightLevelInfo((SEIContentLightLevelInfo&)*sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: - sei = new SEIMasteringDisplayColourVolume; - xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::AMBIENT_VIEWING_ENVIRONMENT: + sei = new SEIAmbientViewingEnvironment; + xParseSEIAmbientViewingEnvironment((SEIAmbientViewingEnvironment&)*sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: - sei = new SEIAlternativeTransferCharacteristics; - xParseSEIAlternativeTransferCharacteristics((SEIAlternativeTransferCharacteristics&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::CONTENT_COLOUR_VOLUME: + sei = new SEIContentColourVolume; + xParseSEIContentColourVolume((SEIContentColourVolume&)*sei, payloadSize, pDecodedMessageOutputStream); break; default: for (uint32_t i = 0; i < payloadSize; i++) @@ -310,9 +330,9 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType sei = new SEIDecodedPictureHash; xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); break; - case SEI::GREEN_METADATA: - sei = new SEIGreenMetadataInfo; - xParseSEIGreenMetadataInfo((SEIGreenMetadataInfo&) *sei, payloadSize, pDecodedMessageOutputStream); + case SEI::SCALABLE_NESTING: + sei = new SEIScalableNesting; + xParseSEIScalableNesting((SEIScalableNesting&)*sei, nalUnitType, nuh_layer_id, payloadSize, vps, sps, pDecodedMessageOutputStream); break; default: for (uint32_t i = 0; i < payloadSize; i++) @@ -424,8 +444,15 @@ void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, uint32_t output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); uint32_t val; - sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); + sei_read_code( pDecodedMessageOutputStream, 8, val, "dpb_sei_hash_type"); sei.method = static_cast(val); bytesRead++; + sei_read_code( pDecodedMessageOutputStream, 1, val, "dph_sei_single_component_flag"); + sei.singleCompFlag = val; + sei_read_code( pDecodedMessageOutputStream, 7, val, "dph_sei_reserved_zero_7bits"); + bytesRead++; + uint32_t expectedSize = ( sei.singleCompFlag ? 1 : 3 ) * (sei.method == 0 ? 16 : (sei.method == 1 ? 2 : 4)); + CHECK ((payloadSize - bytesRead) != expectedSize, "The size of the decoded picture hash does not match the expected size."); + const char *traceString="\0"; switch (sei.method) { @@ -440,11 +467,11 @@ void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, uint32_t (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); } - sei.m_pictureHash.hash.clear(); + sei.pictureHash.hash.clear(); for(;bytesRead < payloadSize; bytesRead++) { sei_read_code( NULL, 8, val, traceString); - sei.m_pictureHash.hash.push_back((uint8_t)val); + sei.pictureHash.hash.push_back((uint8_t)val); if (pDecodedMessageOutputStream) { (*pDecodedMessageOutputStream) << std::setw(2) << val; @@ -457,545 +484,1051 @@ void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, uint32_t } } -void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuhLayerId, uint32_t payloadSize, const VPS *vps, const SPS *sps, std::ostream *decodedMessageOutputStream) { - uint32_t val; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - - sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); - sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); - sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; + uint32_t symbol; + SEIMessages seis; + output_sei_message_header(sei, decodedMessageOutputStream, payloadSize); - sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); - for (int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) + sei_read_flag(decodedMessageOutputStream, symbol, "sn_ols_flag"); sei.snOlsFlag = symbol; + sei_read_flag(decodedMessageOutputStream, symbol, "sn_subpic_flag"); sei.snSubpicFlag = symbol; + if (sei.snOlsFlag) { - sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; + sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_olss_minus1"); sei.snNumOlssMinus1 = symbol; + for (uint32_t i = 0; i <= sei.snNumOlssMinus1; i++) + { + sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_ols_idx_delta_minus1[i]"); sei.snOlsIdxDeltaMinus1[i] = symbol; + } + for (uint32_t i = 0; i <= sei.snNumOlssMinus1; i++) + { + if (i == 0) + { + sei.snOlsIdx[i] = sei.snOlsIdxDeltaMinus1[i]; + } + else + { + sei.snOlsIdx[i] = sei.snOlsIdxDeltaMinus1[i] + sei.snOlsIdxDeltaMinus1[i - 1] + 1; + } + } + if (vps && vps->vpsId != 0) + { + uint32_t lowestLayerId = MAX_UINT; + for (uint32_t olsIdxForSEI = 0; olsIdxForSEI <= sei.snNumOlssMinus1; olsIdxForSEI++) + { + int olsIdx = sei.snOlsIdx[olsIdxForSEI]; + for (int layerIdx = 0; layerIdx < vps->numLayersInOls[olsIdx]; layerIdx++) + { + if (lowestLayerId > vps->layerIdInOls[olsIdx][layerIdx]) + { + lowestLayerId = vps->layerIdInOls[olsIdx][layerIdx]; + } + } + } + CHECK(lowestLayerId!= nuhLayerId, "nuh_layer_id is not equal to the lowest layer among Olss that the scalable SEI applies"); + } + } + else + { + sei_read_flag(decodedMessageOutputStream, symbol, "sn_all_layers_flag"); sei.snAllLayersFlag = symbol; + if (!sei.snAllLayersFlag) + { + sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_layers_minus1"); sei.snNumLayersMinus1 = symbol; + sei.snLayerId[0] = nuhLayerId; + for (uint32_t i = 1; i <= sei.snNumLayersMinus1; i++) + { + sei_read_code(decodedMessageOutputStream, 6, symbol, "sn_layer_id[i]"); sei.snLayerId[i] = symbol; + } + } + } + if (sei.snSubpicFlag) + { + sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_subpics_minus1"); sei.snNumSubpics = symbol + 1; + sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_subpic_id_len_minus1"); sei.snSubpicIdLen = symbol + 1; + sei.snSubpicId.resize(sei.snNumSubpics); + for (uint32_t i = 0; i < sei.snNumSubpics; i++) + { + sei_read_code(decodedMessageOutputStream, sei.snSubpicIdLen, symbol, "sn_subpic_id[i]"); sei.snSubpicId[i] = symbol; + } } -} -void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream) -{ - THROW("no support"); -} + sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_seis_minus1"); sei.snNumSEIs = symbol + 1; + CHECK (sei.snNumSEIs > 64, "The value of sn_num_seis_minus1 shall be in the range of 0 to 63"); -void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream) -{ - THROW("no support"); -} + // byte alignment + while (m_pcBitstream->getNumBitsRead() % 8 != 0) + { + sei_read_flag(decodedMessageOutputStream, symbol, "sn_zero_bit"); + } -void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream) -{ - THROW("no support"); -} + // read nested SEI messages + for (int32_t i=0; ipayloadType() == SEI::BUFFERING_PERIOD) + { + SEIBufferingPeriod *bp = (SEIBufferingPeriod*) tmpSEIs.front(); + m_nestedHrd.bufferingPeriodSEI = *bp; + } + sei.nestedSEIs.push_back(tmpSEIs.front()); + tmpSEIs.clear(); + } -void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -{ - int iCode; - uint32_t uiCode; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + xCheckScalableNestingConstraints(sei, nalUnitType, vps); - sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; - sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; - sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; + if (decodedMessageOutputStream) + { + (*decodedMessageOutputStream) << "End of scalable nesting SEI message\n"; + } } -void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sei, const NalUnitType nalUnitType, const VPS* vps) { - uint32_t val; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + const std::vector vclAssociatedSeiList { 3, 19, 45, 129, 137, 144, 145, 147, 148, 149, 150, 153, 154, 155, 156, 168, 204 }; - sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; - sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; + bool containBPorPTorDUIorSLI = false; + bool containNoBPorPTorDUIorSLI = false; - if( !sei.m_arrangementCancelFlag ) + for (auto nestedsei : sei.nestedSEIs) { - sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; - CHECK( ( sei.m_arrangementType <= 2 ) || ( sei.m_arrangementType >= 6 ), "Invalid arrangement type" ); + CHECK(nestedsei->payloadType() == SEI::FILLER_PAYLOAD || nestedsei->payloadType() == SEI::SCALABLE_NESTING, "An SEI message that has payloadType equal to filler payload or scalable nesting shall not be contained in a scalable nesting SEI message"); + + CHECK(nestedsei->payloadType() != SEI::FILLER_PAYLOAD && nestedsei->payloadType() != SEI::DECODED_PICTURE_HASH && nalUnitType != NAL_UNIT_PREFIX_SEI, "When a scalable nesting SEI message contains an SEI message that has payloadType not equal to filler payload or decoded picture hash, the SEI NAL unit containing the scalable nesting SEI message shall have nal_unit_type equal to PREFIX_SEI_NUT"); + + CHECK(nestedsei->payloadType() == SEI::DECODED_PICTURE_HASH && nalUnitType != NAL_UNIT_SUFFIX_SEI, "When a scalable nesting SEI message contains an SEI message that has payloadType equal to decoded picture hash, the SEI NAL unit containing the scalable nesting SEI message shall have nal_unit_type equal to SUFFIX_SEI_NUT"); - sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; + CHECK(nestedsei->payloadType() == SEI::DECODED_PICTURE_HASH && !sei.snSubpicFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to decoded picture hash, the value of sn_subpic_flag shall be equal to 1"); - sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; - sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; - sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; - sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; - sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; - sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; - sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; + CHECK(nestedsei->payloadType() == SEI::SUBPICTURE_LEVEL_INFO && sei.snSubpicFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to SLI, the value of sn_subpic_flag shall be equal to 0"); - if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) + CHECK(vps->generalHrdParams.generalSamePicTimingInAllOlsFlag && nestedsei->payloadType() == SEI::PICTURE_TIMING, "When general_same_pic_timing_in_all_ols_flag is equal to 1, there shall be no SEI NAL unit that contain a scalable-nested SEI message with payloadType equal to PT"); + + for (int i = 0; i < vclAssociatedSeiList.size(); i++) { - sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; - sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; - sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; - sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; + CHECK(nestedsei->payloadType() == vclAssociatedSeiList[i] && sei.snOlsFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to a value in vclAssociatedSeiList, the value of sn_ols_flag shall be equal to 0"); } - sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; - sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); + if (nestedsei->payloadType() == SEI::BUFFERING_PERIOD || nestedsei->payloadType() == SEI::PICTURE_TIMING || nestedsei->payloadType() == SEI::DECODING_UNIT_INFO || nestedsei->payloadType() == SEI::SUBPICTURE_LEVEL_INFO) + { + containBPorPTorDUIorSLI = true; + CHECK(!sei.snOlsFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to BP, PT, or DUI, or SLI, the value of sn_ols_flag shall be equal to 1"); + } + if (!(nestedsei->payloadType() == SEI::BUFFERING_PERIOD || nestedsei->payloadType() == SEI::PICTURE_TIMING || nestedsei->payloadType() == SEI::DECODING_UNIT_INFO || nestedsei->payloadType() == SEI::SUBPICTURE_LEVEL_INFO)) + { + containNoBPorPTorDUIorSLI = true; + } } - sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; + CHECK(containBPorPTorDUIorSLI && containNoBPorPTorDUIorSLI, "When a scalable nesting SEI message contains a BP, PT, DUI, or SLI SEI message, the scalable nesting SEI message shall not contain any other SEI message with payloadType not equal to BP, PT, DUI, or SLI"); } -void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, uint32_t payloadSize, const SEIBufferingPeriod& bp, const uint32_t temporalId, std::ostream *pDecodedMessageOutputStream) { uint32_t val; output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; - if( !sei.m_arrangementCancelFlag ) + sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); + sei.decodingUnitIdx = val; + + if(!bp.decodingUnitCpbParamsInPicTimingSeiFlag) + { + for (int i = temporalId; i <= bp.bpMaxSubLayers - 1; i++) + { + if (i < (bp.bpMaxSubLayers - 1)) + { + sei_read_flag( pDecodedMessageOutputStream, val, "dui_sub_layer_delays_present_flag[i]" ); + sei.duiSubLayerDelaysPresent[i] = val; + } + else + { + sei.duiSubLayerDelaysPresent[i] = 1; + } + if( sei.duiSubLayerDelaysPresent[i] ) + { + sei_read_code( pDecodedMessageOutputStream, bp.duCpbRemovalDelayIncrementLength, val, "du_spt_cpb_removal_delay_increment[i]"); + sei.duSptCpbRemovalDelayIncrement[i] = val; + } + else + { + sei.duSptCpbRemovalDelayIncrement[i] = 0; + } + } + } + else + { + for( int i = temporalId; i < bp.bpMaxSubLayers - 1; i ++ ) + { + sei.duSptCpbRemovalDelayIncrement[i] = 0; + } + } + if (bp.decodingUnitDpbDuParamsInPicTimingSeiFlag) + { + sei_read_flag(pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.dpbOutputDuDelayPresent = (val != 0); + } + else { - sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; - sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; + sei.dpbOutputDuDelayPresent = false; + } + if(sei.dpbOutputDuDelayPresent) + { + sei_read_code( pDecodedMessageOutputStream, bp.dpbOutputDelayDuLength, val, "pic_spt_dpb_output_du_delay"); + sei.picSptDpbOutputDuDelay = val; } } -void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) { - uint32_t val; + int i, nalOrVcl; + uint32_t code; + + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; - if( !sei.cancelFlag ) + + sei_read_flag( pDecodedMessageOutputStream, code, "bp_nal_hrd_parameters_present_flag" ); sei.bpNalCpbParamsPresent = code; + sei_read_flag( pDecodedMessageOutputStream, code, "bp_vcl_hrd_parameters_present_flag" ); sei.bpVclCpbParamsPresent = code; + + sei_read_code( pDecodedMessageOutputStream, 5, code, "initial_cpb_removal_delay_length_minus1" ); sei.initialCpbRemovalDelayLength = code + 1; + sei_read_code( pDecodedMessageOutputStream, 5, code, "cpb_removal_delay_length_minus1" ); sei.cpbRemovalDelayLength = code + 1; + sei_read_code( pDecodedMessageOutputStream, 5, code, "dpb_output_delay_length_minus1" ); sei.dpbOutputDelayLength = code + 1; + sei_read_flag( pDecodedMessageOutputStream, code, "bp_decoding_unit_hrd_params_present_flag" ); sei.bpDecodingUnitHrdParamsPresent = code; + if( sei.bpDecodingUnitHrdParamsPresent ) { - sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; - sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; - sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; - sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; + sei_read_code( pDecodedMessageOutputStream, 5, code, "du_cpb_removal_delay_increment_length_minus1" ); sei.duCpbRemovalDelayIncrementLength = code + 1; + sei_read_code( pDecodedMessageOutputStream, 5, code, "dpb_output_delay_du_length_minus1" ); sei.dpbOutputDelayDuLength = code + 1; + sei_read_flag( pDecodedMessageOutputStream, code, "decoding_unit_cpb_params_in_pic_timing_sei_flag" ); sei.decodingUnitCpbParamsInPicTimingSeiFlag = code; + sei_read_flag(pDecodedMessageOutputStream, code, "decoding_unit_dpb_du_params_in_pic_timing_sei_flag"); sei.decodingUnitDpbDuParamsInPicTimingSeiFlag = code; + } + else + { + sei.duCpbRemovalDelayIncrementLength = 24; + sei.dpbOutputDelayDuLength = 24; + sei.decodingUnitDpbDuParamsInPicTimingSeiFlag = false; } -} -void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -{ - uint32_t val; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; - sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; -} + CHECK(sei.altCpbParamsPresent && sei.bpDecodingUnitHrdParamsPresent,"When bp_alt_cpb_params_present_flag is equal to 1, the value of bp_du_hrd_params_present_flag shall be equal to 0"); -void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -{ - uint32_t val; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; -} + sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); + sei.concatenationFlag = code; + sei_read_flag ( pDecodedMessageOutputStream, code, "additional_concatenation_info_present_flag"); + sei.additionalConcatenationInfoPresent = code; + if (sei.additionalConcatenationInfoPresent) + { + sei_read_code( pDecodedMessageOutputStream, sei.initialCpbRemovalDelayLength, code, "max_initial_removal_delay_for_concatenation" ); + sei.maxInitialRemovalDelayForConcatenation = code; + } + + sei_read_code( pDecodedMessageOutputStream, ( sei.cpbRemovalDelayLength ), code, "au_cpb_removal_delay_delta_minus1" ); + sei.auCpbRemovalDelayDelta = code + 1; + sei_read_code(pDecodedMessageOutputStream, 3, code, "bp_max_sub_layers_minus1"); + sei.bpMaxSubLayers = code + 1; + if (sei.bpMaxSubLayers - 1 > 0) + { + sei_read_flag(pDecodedMessageOutputStream, code, "cpb_removal_delay_deltas_present_flag"); + sei.cpbRemovalDelayDeltasPresent = code; + } + else + { + sei.cpbRemovalDelayDeltasPresent = false; + } + if (sei.cpbRemovalDelayDeltasPresent) + { + sei_read_uvlc( pDecodedMessageOutputStream, code, "num_cpb_removal_delay_deltas_minus1" ); + sei.numCpbRemovalDelayDeltas = code + 1; + for( i = 0; i < sei.numCpbRemovalDelayDeltas; i ++ ) + { + sei_read_code( pDecodedMessageOutputStream, ( sei.cpbRemovalDelayLength ), code, "cpb_removal_delay_delta[i]" ); + sei.cpbRemovalDelayDelta[ i ] = code; + } + } + + sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_cpb_cnt_minus1"); + sei.bpCpbCnt = code + 1; + + if (sei.bpMaxSubLayers - 1 > 0) + { + sei_read_flag(pDecodedMessageOutputStream, code, "bp_sublayer_initial_cpb_removal_delay_present_flag"); + sei.sublayerInitialCpbRemovalDelayPresent = code; + } + else + { + sei.sublayerInitialCpbRemovalDelayPresent = false; + } + for (i = (sei.sublayerInitialCpbRemovalDelayPresent ? 0 : sei.bpMaxSubLayers - 1); i < sei.bpMaxSubLayers; i++) + { + for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) + { + if( ( ( nalOrVcl == 0 ) && ( sei.bpNalCpbParamsPresent ) ) || + ( ( nalOrVcl == 1 ) && ( sei.bpVclCpbParamsPresent ) ) ) + { + for( int j = 0; j < ( sei.bpCpbCnt ); j ++ ) + { + sei_read_code( pDecodedMessageOutputStream, sei.initialCpbRemovalDelayLength, code, nalOrVcl ? "vcl_initial_cpb_removal_delay[i][j]" : "nal_initial_cpb_removal_delay[i][j]" ); + sei.initialCpbRemovalDelay[i][j][nalOrVcl] = code; + sei_read_code( pDecodedMessageOutputStream, sei.initialCpbRemovalDelayLength, code, nalOrVcl ? "vcl_initial_cpb_removal_offset[i][j]" : "nal_initial_cpb_removal_offset[i][j]" ); + sei.initialCpbRemovalDelay[i][j][nalOrVcl] = code; + } + } + } + } + if (sei.bpMaxSubLayers-1 > 0) + { + sei_read_flag(pDecodedMessageOutputStream, code, "bp_sublayer_dpb_output_offsets_present_flag"); + sei.sublayerDpbOutputOffsetsPresent = code; + } + else + { + sei.sublayerDpbOutputOffsetsPresent = false; + } + if(sei.sublayerDpbOutputOffsetsPresent) + { + for(int i = 0; i < sei.bpMaxSubLayers - 1; i++) + { + sei_read_uvlc( pDecodedMessageOutputStream, code, "dpb_output_tid_offset[i]" ); + sei.dpbOutputTidOffset[i] = code; + } + sei.dpbOutputTidOffset[sei.bpMaxSubLayers-1] = 0; + } + sei_read_flag(pDecodedMessageOutputStream, code, "bp_alt_cpb_params_present_flag"); + sei.altCpbParamsPresent = code; + if (sei.altCpbParamsPresent) + { + sei_read_flag(pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); sei.useAltCpbParamsFlag = code; + } -void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -{ - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei.m_noDisplay = true; } -void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSize, const uint32_t temporalId, const SEIBufferingPeriod& bp, std::ostream *pDecodedMessageOutputStream) { - int i; - uint32_t val; + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; - sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; - if ( !sei.m_toneMapCancelFlag ) + uint32_t symbol; + sei_read_code( pDecodedMessageOutputStream, bp.cpbRemovalDelayLength, symbol, "pt_cpb_removal_delay_minus1[bp_max_sub_layers_minus1]" ); + sei.auCpbRemovalDelay[bp.bpMaxSubLayers - 1] = symbol + 1; + if (bp.bpMaxSubLayers == 1) { - sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; - sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; - sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; - sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; - switch(sei.m_modelId) + sei.ptSubLayerDelaysPresent[0] = true; + } + for (int i = temporalId; i < bp.bpMaxSubLayers - 1; i++) + { + sei_read_flag(pDecodedMessageOutputStream, symbol, "pt_sub_layer_delays_present_flag[i]"); + sei.ptSubLayerDelaysPresent[i] = (symbol == 1); + if (sei.ptSubLayerDelaysPresent[i]) { - case 0: + if (bp.cpbRemovalDelayDeltasPresent) { - sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; - break; + sei_read_flag(pDecodedMessageOutputStream, symbol, "pt_cpb_removal_delay_delta_enabled_flag[i]"); + sei.cpbRemovalDelayDeltaEnabledFlag[i] = (symbol == 1); } - case 1: + else { - sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; - break; + sei.cpbRemovalDelayDeltaEnabledFlag[i] = false; } - case 2: + if (sei.cpbRemovalDelayDeltaEnabledFlag[i]) { - uint32_t num = 1u << sei.m_targetBitDepth; - sei.m_startOfCodedInterval.resize(num+1); - for(i = 0; i < num; i++) + if ((bp.numCpbRemovalDelayDeltas - 1) > 0) { - sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); - sei.m_startOfCodedInterval[i] = val; + sei_read_code(pDecodedMessageOutputStream, ceilLog2(bp.numCpbRemovalDelayDeltas), symbol, "pt_cpb_removal_delay_delta_idx[i]"); + sei.cpbRemovalDelayDeltaIdx[i] = symbol; } - sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; - break; - } - case 3: - { - sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; - sei.m_codedPivotValue.resize(sei.m_numPivots); - sei.m_targetPivotValue.resize(sei.m_numPivots); - for(i = 0; i < sei.m_numPivots; i++ ) + else { - sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); - sei.m_codedPivotValue[i] = val; - sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); - sei.m_targetPivotValue[i] = val; + sei.cpbRemovalDelayDeltaIdx[i] = 0; } - break; } - case 4: + else + { + sei_read_code(pDecodedMessageOutputStream, bp.cpbRemovalDelayLength, symbol, "pt_cpb_removal_delay_minus1[i]"); + sei.auCpbRemovalDelay[i] = symbol + 1; + } + } + } + sei_read_code(pDecodedMessageOutputStream, bp.dpbOutputDelayLength, symbol, "pt_dpb_output_delay"); + sei.picDpbOutputDelay = symbol; + + if( bp.altCpbParamsPresent ) + { + sei_read_flag( pDecodedMessageOutputStream, symbol, "cpb_alt_timing_info_present_flag" ); sei.cpbAltTimingInfoPresent = symbol; + if( sei.cpbAltTimingInfoPresent ) + { + if (bp.bpNalCpbParamsPresent) { - sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; - if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO + sei.nalCpbAltInitialRemovalDelayDelta.resize(bp.bpMaxSubLayers); + sei.nalCpbAltInitialRemovalOffsetDelta.resize(bp.bpMaxSubLayers); + for (int i = 0; i <= bp.bpMaxSubLayers - 1; ++i) { - sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; + sei.nalCpbAltInitialRemovalDelayDelta[i].resize(bp.bpCpbCnt, 0); + sei.nalCpbAltInitialRemovalOffsetDelta[i].resize(bp.bpCpbCnt, 0); } - sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; - if( sei.m_exposureIndexIdc == 255) //Extended_ISO + sei.nalCpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + sei.nalDpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + for (int i = (bp.sublayerInitialCpbRemovalDelayPresent ? 0 : bp.bpMaxSubLayers - 1); + i <= bp.bpMaxSubLayers - 1; ++i) { - sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; + for (int j = 0; j < bp.bpCpbCnt; j++) + { + sei_read_code(pDecodedMessageOutputStream, bp.initialCpbRemovalDelayLength, symbol, + "nal_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + sei.nalCpbAltInitialRemovalDelayDelta[i][j] = symbol; + sei_read_code(pDecodedMessageOutputStream, bp.initialCpbRemovalDelayLength, symbol, + "nal_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + sei.nalCpbAltInitialRemovalOffsetDelta[i][j] = symbol; + } + sei_read_code(pDecodedMessageOutputStream, bp.cpbRemovalDelayLength, sei.nalCpbDelayOffset[i], + "nal_cpb_delay_offset[ i ]"); + sei_read_code(pDecodedMessageOutputStream, bp.dpbOutputDelayLength, sei.nalDpbDelayOffset[i], + "nal_dpb_delay_offset[ i ]"); } - sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; - sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; - sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; - sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; - sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; - sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; - break; } - default: + + if (bp.bpVclCpbParamsPresent) { - THROW("Undefined SEIToneMapModelId"); - break; + sei.vclCpbAltInitialRemovalDelayDelta.resize(bp.bpMaxSubLayers); + sei.vclCpbAltInitialRemovalOffsetDelta.resize(bp.bpMaxSubLayers); + for (int i = 0; i <= bp.bpMaxSubLayers - 1; ++i) + { + sei.vclCpbAltInitialRemovalDelayDelta[i].resize(bp.bpCpbCnt, 0); + sei.vclCpbAltInitialRemovalOffsetDelta[i].resize(bp.bpCpbCnt, 0); + } + sei.vclCpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + sei.vclDpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + for (int i = (bp.sublayerInitialCpbRemovalDelayPresent ? 0 : bp.bpMaxSubLayers - 1); + i <= bp.bpMaxSubLayers - 1; ++i) + { + for (int j = 0; j < bp.bpCpbCnt; j++) + { + sei_read_code(pDecodedMessageOutputStream, bp.initialCpbRemovalDelayLength, symbol, + "vcl_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + sei.vclCpbAltInitialRemovalDelayDelta[i][j] = symbol; + sei_read_code(pDecodedMessageOutputStream, bp.initialCpbRemovalDelayLength, symbol, + "vcl_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + sei.vclCpbAltInitialRemovalOffsetDelta[i][j] = symbol; + } + sei_read_code(pDecodedMessageOutputStream, bp.cpbRemovalDelayLength, sei.vclCpbDelayOffset[i], + "vcl_cpb_delay_offset[ i ]"); + sei_read_code(pDecodedMessageOutputStream, bp.dpbOutputDelayLength, sei.vclDpbDelayOffset[i], + "vcl_dpb_delay_offset[ i ]"); + } } - }//switch model id - }// if(!sei.m_toneMapCancelFlag) -} + } + } + else + { + sei.cpbAltTimingInfoPresent = false; + sei.nalCpbAltInitialRemovalDelayDelta.resize(bp.bpMaxSubLayers); + sei.nalCpbAltInitialRemovalOffsetDelta.resize(bp.bpMaxSubLayers); + sei.nalCpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + sei.nalDpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + for (int i = (bp.sublayerInitialCpbRemovalDelayPresent ? 0 : bp.bpMaxSubLayers - 1); + i <= bp.bpMaxSubLayers - 1; ++i) + { + sei.nalCpbAltInitialRemovalDelayDelta[i].resize(bp.bpCpbCnt, 0); + sei.nalCpbAltInitialRemovalOffsetDelta[i].resize(bp.bpCpbCnt, 0); + } -void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -{ - int iCode; - uint32_t uiCode; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + sei.vclCpbAltInitialRemovalDelayDelta.resize(bp.bpMaxSubLayers); + sei.vclCpbAltInitialRemovalOffsetDelta.resize(bp.bpMaxSubLayers); + sei.vclCpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + sei.vclDpbDelayOffset.resize(bp.bpMaxSubLayers, 0); + for (int i = (bp.sublayerInitialCpbRemovalDelayPresent ? 0 : bp.bpMaxSubLayers - 1); + i <= bp.bpMaxSubLayers - 1; ++i) + { + sei.vclCpbAltInitialRemovalDelayDelta[i].resize(bp.bpCpbCnt, 0); + sei.vclCpbAltInitialRemovalOffsetDelta[i].resize(bp.bpCpbCnt, 0); + } + } - sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; - sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; - for (uint32_t i = 0; i <= sei.m_numPicsInSopMinus1; i++) + if ( bp.bpDecodingUnitHrdParamsPresent && bp.decodingUnitDpbDuParamsInPicTimingSeiFlag ) { - sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; - sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; - if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) + sei_read_code( pDecodedMessageOutputStream, bp.dpbOutputDelayDuLength, symbol, "pic_dpb_output_du_delay" ); + sei.picDpbOutputDuDelay = symbol; + } + if( bp.bpDecodingUnitHrdParamsPresent && bp.decodingUnitCpbParamsInPicTimingSeiFlag ) + { + sei_read_uvlc( pDecodedMessageOutputStream, symbol, "num_decoding_units_minus1" ); + sei.numDecodingUnitsMinus1 = symbol; + sei.numNalusInDuMinus1.resize(sei.numDecodingUnitsMinus1 + 1 ); + sei.duCpbRemovalDelayMinus1.resize( (sei.numDecodingUnitsMinus1 + 1) * bp.bpMaxSubLayers ); + + if (sei.numDecodingUnitsMinus1 > 0) { - sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; + sei_read_flag( pDecodedMessageOutputStream, symbol, "du_common_cpb_removal_delay_flag" ); + sei.duCommonCpbRemovalDelayFlag = symbol; + if( sei.duCommonCpbRemovalDelayFlag ) + { + for( int i = temporalId; i < bp.bpMaxSubLayers - 1; i ++ ) + { + if( sei.ptSubLayerDelaysPresent[i] ) + { + sei_read_code( pDecodedMessageOutputStream, bp.duCpbRemovalDelayIncrementLength, symbol, "du_common_cpb_removal_delay_increment_minus1[i]" ); + sei.duCommonCpbRemovalDelayMinus1[i] = symbol; + } + } + } + for( int i = 0; i <= sei.numDecodingUnitsMinus1; i ++ ) + { + sei_read_uvlc( pDecodedMessageOutputStream, symbol, "num_nalus_in_du_minus1[i]" ); + sei.numNalusInDuMinus1[i] = symbol; + if( !sei.duCommonCpbRemovalDelayFlag && i < sei.numDecodingUnitsMinus1 ) + { + for( int j = temporalId; j < bp.bpMaxSubLayers - 1; j ++ ) + { + if( sei.ptSubLayerDelaysPresent[j] ) + { + sei_read_code( pDecodedMessageOutputStream, bp.duCpbRemovalDelayIncrementLength, symbol, "du_cpb_removal_delay_increment_minus1[i][j]" ); + sei.duCpbRemovalDelayMinus1[i * bp.bpMaxSubLayers + j] = symbol; + } + } + } + } } - if (i > 0) + else { - sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; + sei.duCommonCpbRemovalDelayFlag = 0; } } + + if (bp.additionalConcatenationInfoPresent) + { + sei_read_flag( pDecodedMessageOutputStream, symbol, "pt_delay_for_concatenation_ensured_flag" ); + sei.delayForConcatenationEnsureFlag = symbol; + } + sei_read_code( pDecodedMessageOutputStream, 8, symbol, "pt_display_elemental_periods_minus1" ); + sei.ptDisplayElementalPeriodsMinus1 = symbol; } -void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIFrameFieldinfo(SEIFrameFieldInfo& sei, const SEIPictureTiming& pt, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) { - uint32_t uiCode; - SEIMessages seis; output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; - sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; - if (sei.m_nestingOpFlag) + uint32_t symbol; + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_field_pic_flag" ); + sei.fieldPicFlag= symbol; + if (sei.fieldPicFlag) { - sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; - sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; - for (uint32_t i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_bottom_field_flag" ); + sei.bottomFieldFlag = symbol; + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_pairing_indicated_flag" ); + sei.pairingIndicatedFlag = symbol; + if (sei.pairingIndicatedFlag) { - sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; - sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_paired_with_next_field_flag" ); + sei.pairedWithNextFieldFlag = symbol; } } else { - sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; - if (!sei.m_allLayersFlag) + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_display_fields_from_frame_flag" ); + sei.displayFieldsFromFrameFlag = symbol; + if (sei.displayFieldsFromFrameFlag) { - sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; - sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; - for (uint32_t i = 0; i <= sei.m_nestingNumLayersMinus1; i++) - { - sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; - } + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_display_fields_from_frame_flag" ); + sei.topFieldFirstFlag = symbol; } + sei_read_code( pDecodedMessageOutputStream, 8, symbol, "ffi_display_elemental_periods_minus1" ); + sei.displayElementalPeriodsMinus1 = symbol; } + sei_read_code( pDecodedMessageOutputStream, 2, symbol, "ffi_source_scan_type" ); + sei.sourceScanType = symbol; + sei_read_flag( pDecodedMessageOutputStream, symbol, "ffi_duplicate_flag" ); + sei.duplicateFlag = symbol; +} - // byte alignment - while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) +void SEIReader::xParseSEIDependentRAPIndication( SEIDependentRAPIndication& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream ) +{ + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); +} + + +void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +{ + uint32_t val; + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + + sei_read_uvlc( pDecodedMessageOutputStream, val, "fp_arrangement_id" ); sei.arrangementId = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_arrangement_cancel_flag" ); sei.arrangementCancelFlag = val; + + if( !sei.arrangementCancelFlag ) { - uint32_t code; - sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); + sei_read_code( pDecodedMessageOutputStream, 7, val, "fp_arrangement_type" ); sei.arrangementType = val; + CHECK( ( sei.arrangementType <= 2 ) || ( sei.arrangementType >= 6 ), "Invalid arrangement type" ); + + sei_read_flag( pDecodedMessageOutputStream, val, "fp_quincunx_sampling_flag" ); sei.quincunxSamplingFlag = val; + + sei_read_code( pDecodedMessageOutputStream, 6, val, "fp_content_interpretation_type" ); sei.contentInterpretationType = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_spatial_flipping_flag" ); sei.spatialFlippingFlag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_frame0_flipped_flag" ); sei.frame0FlippedFlag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_field_views_flag" ); sei.fieldViewsFlag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_current_frame_is_frame0_flag" ); sei.currentFrameIsFrame0Flag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_frame0_self_contained_flag" ); sei.frame0SelfContainedFlag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_frame1_self_contained_flag" ); sei.frame1SelfContainedFlag = val; + + if ( sei.quincunxSamplingFlag == 0 && sei.arrangementType != 5) + { + sei_read_code( pDecodedMessageOutputStream, 4, val, "fp_frame0_grid_position_x" ); sei.frame0GridPositionX = val; + sei_read_code( pDecodedMessageOutputStream, 4, val, "fp_frame0_grid_position_y" ); sei.frame0GridPositionY = val; + sei_read_code( pDecodedMessageOutputStream, 4, val, "fp_frame1_grid_position_x" ); sei.frame1GridPositionX = val; + sei_read_code( pDecodedMessageOutputStream, 4, val, "fp_frame1_grid_position_y" ); sei.frame1GridPositionY = val; + } + + sei_read_code( pDecodedMessageOutputStream, 8, val, "fp_frame_packing_arrangement_reserved_byte" ); sei.arrangementReservedByte = val; + sei_read_flag( pDecodedMessageOutputStream, val, "fp_frame_packing_arrangement_persistence_flag" ); sei.arrangementPersistenceFlag = (val != 0); } + sei_read_flag( pDecodedMessageOutputStream, val, "fp_upsampled_aspect_ratio_flag" ); sei.upsampledAspectRatio = val; +} - // read nested SEI messages - do - { - xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); - } while (m_pcBitstream->getNumBitsLeft() > 8); +void SEIReader::xParseSEIParameterSetsInclusionIndication(SEIParameterSetsInclusionIndication& sei, uint32_t payloadSize, std::ostream* pDecodedMessageOutputStream) +{ + uint32_t val; + output_sei_message_header( sei, pDecodedMessageOutputStream, payloadSize ); + + sei_read_flag( pDecodedMessageOutputStream, val, "psii_self_contained_clvs_flag" ); + sei.selfContainedClvsFlag = val; +} + +void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +{ + uint32_t code; + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_display_primaries_x[0]" ); sei.values.primaries[0][0] = code; + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_display_primaries_y[0]" ); sei.values.primaries[0][1] = code; + + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_display_primaries_x[1]" ); sei.values.primaries[1][0] = code; + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_display_primaries_y[1]" ); sei.values.primaries[1][1] = code; + + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_display_primaries_x[2]" ); sei.values.primaries[2][0] = code; + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_display_primaries_y[2]" ); sei.values.primaries[2][1] = code; + + + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_white_point_x" ); sei.values.whitePoint[0] = code; + sei_read_code( pDecodedMessageOutputStream, 16, code, "mdcv_white_point_y" ); sei.values.whitePoint[1] = code; + + sei_read_code( pDecodedMessageOutputStream, 32, code, "mdcv_max_display_mastering_luminance" ); sei.values.maxLuminance = code; + sei_read_code( pDecodedMessageOutputStream, 32, code, "mdcv_min_display_mastering_luminance" ); sei.values.minLuminance = code; +} + +void SEIReader::xParseSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics& sei, uint32_t payloadSize, std::ostream* pDecodedMessageOutputStream) +{ + uint32_t code; + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + + sei_read_code(pDecodedMessageOutputStream, 8, code, "preferred_transfer_characteristics"); sei.preferredTransferCharacteristics = code; +} + +void SEIReader::xParseSEIUserDataRegistered(SEIUserDataRegistered& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +{ + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + uint32_t code; + assert(payloadSize>0); + sei_read_code(pDecodedMessageOutputStream, 8, code, "itu_t_t35_country_code"); payloadSize--; + if (code == 255) + { + assert(payloadSize>0); + sei_read_code(pDecodedMessageOutputStream, 8, code, "itu_t_t35_country_code_extension_byte"); payloadSize--; + code += 255; + } + sei.ituCountryCode = code; + sei.userData.resize(payloadSize); + for (uint32_t i = 0; i < sei.userData.size(); i++) + { + sei_read_code(NULL, 8, code, "itu_t_t35_payload_byte"); + sei.userData[i] = code; + } if (pDecodedMessageOutputStream) { - (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; + (*pDecodedMessageOutputStream) << " itu_t_t35 payload size: " << sei.userData.size() << "\n"; } } -void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIFilmGrainCharacteristics(SEIFilmGrainCharacteristics& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) { uint32_t code; output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag"); sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0); - sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); - if(!sei.m_each_tile_one_tile_set_flag) + sei_read_flag(pDecodedMessageOutputStream, code, "fg_characteristics_cancel_flag"); sei.filmGrainCharacteristicsCancelFlag = code != 0; + if (!sei.filmGrainCharacteristicsCancelFlag) { - sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); - sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); - - if(sei.getNumberOfTileSets() != 0) + sei_read_code(pDecodedMessageOutputStream, 2, code, "fg_model_id"); sei.filmGrainModelId = code; + sei_read_flag(pDecodedMessageOutputStream, code, "separate_colour_description_present_flag"); sei.separateColourDescriptionPresent = code != 0; + if (sei.separateColourDescriptionPresent) + { + sei_read_code(pDecodedMessageOutputStream, 3, code, "fg_bit_depth_luma_minus8"); sei.filmGrainBitDepthLumaMinus8 = code; + sei_read_code(pDecodedMessageOutputStream, 3, code, "fg_bit_depth_chroma_minus8"); sei.filmGrainBitDepthChromaMinus8 = code; + sei_read_flag(pDecodedMessageOutputStream, code, "fg_full_range_flag"); sei.filmGrainFullRangeFlag = code != 0; + sei_read_code(pDecodedMessageOutputStream, 8, code, "fg_colour_primaries"); sei.filmGrainColourPrimaries = code; + sei_read_code(pDecodedMessageOutputStream, 8, code, "fg_transfer_characteristics"); sei.filmGrainTransferCharacteristics = code; + sei_read_code(pDecodedMessageOutputStream, 8, code, "fg_matrix_coeffs"); sei.filmGrainMatrixCoeffs = code; + } + sei_read_code(pDecodedMessageOutputStream, 2, code, "fg_blending_mode_id"); sei.blendingModeId = code; + sei_read_code(pDecodedMessageOutputStream, 4, code, "fg_log2_scale_factor"); sei.log2ScaleFactor = code; + for (int c = 0; c<3; c++) + { + sei_read_flag(pDecodedMessageOutputStream, code, "fg_comp_model_present_flag[c]"); sei.compModel[c].presentFlag = code != 0; + } + for (int c = 0; c<3; c++) { - for(int i = 0; i < sei.getNumberOfTileSets(); i++) + SEIFilmGrainCharacteristics::CompModel &cm = sei.compModel[c]; + if (cm.presentFlag) { - sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; - - if(sei.m_limited_tile_set_display_flag) + uint32_t numIntensityIntervals; + sei_read_code(pDecodedMessageOutputStream, 8, code, "fg_num_intensity_intervals_minus1[c]"); numIntensityIntervals = code + 1; + sei_read_code(pDecodedMessageOutputStream, 3, code, "fg_num_model_values_minus1[c]"); cm.numModelValues = code + 1; + cm.intensityValues.resize(numIntensityIntervals); + for (uint32_t interval = 0; interval 0) - { - for(int i = 0; i < numVerticalFilters; i++) - { - uint32_t verTapLengthMinus1; - sei_read_uvlc( pDecodedMessageOutputStream, verTapLengthMinus1, "ver_tap_length_minus_1"); sei.m_verFilterCoeff[i].resize(verTapLengthMinus1+1); - for(int j = 0; j < (verTapLengthMinus1 + 1); j++) - { - sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); - } - } - } + SEIOmniViewport::OmniViewport &viewport = sei.omniViewportRegions[region]; + sei_read_scode( pDecodedMessageOutputStream, 32, scode, "omni_viewport_azimuth_centre" ); viewport.azimuthCentre = scode; + sei_read_scode( pDecodedMessageOutputStream, 32, scode, "omni_viewport_elevation_centre" ); viewport.elevationCentre = scode; + sei_read_scode( pDecodedMessageOutputStream, 32, scode, "omni_viewport_tilt_centre" ); viewport.tiltCentre = code; + sei_read_code( pDecodedMessageOutputStream, 32, code, "omni_viewport_hor_range" ); viewport.horRange = code; + sei_read_code( pDecodedMessageOutputStream, 32, code, "omni_viewport_ver_range" ); viewport.verRange = code; } - if(sei.m_horChromaFilterIdc == 1) + } + else + { + sei.omniViewportRegions.clear(); + sei.omniViewportPersistenceFlag=false; + } +} + +void SEIReader::xParseSEIRegionWisePacking(SEIRegionWisePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +{ + output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + uint32_t val; + + sei_read_flag( pDecodedMessageOutputStream, val, "rwp_cancel_flag" ); sei.rwpCancelFlag = val; + if (!sei.rwpCancelFlag) + { + sei_read_flag( pDecodedMessageOutputStream, val, "rwp_persistence_flag" ); sei.rwpPersistenceFlag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "rwp_constituent_picture_matching_flag" ); sei.constituentPictureMatchingFlag = val; + sei_read_code( pDecodedMessageOutputStream, 5, val, "rwp_reserved_zero_5bits" ); + sei_read_code( pDecodedMessageOutputStream, 8, val, "rwp_num_packed_regions" ); sei.numPackedRegions = val; + sei_read_code( pDecodedMessageOutputStream, 32, val, "rwp_proj_picture_width" ); sei.projPictureWidth = val; + sei_read_code( pDecodedMessageOutputStream, 32, val, "rwp_proj_picture_height" ); sei.projPictureHeight = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "rwp_packed_picture_width" ); sei.packedPictureWidth = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "rwp_packed_picture_height" ); sei.packedPictureHeight = val; + + sei.rwpTransformType.resize(sei.numPackedRegions); + sei.rwpGuardBandFlag.resize(sei.numPackedRegions); + sei.projRegionWidth.resize(sei.numPackedRegions); + sei.projRegionHeight.resize(sei.numPackedRegions); + sei.rwpProjRegionTop.resize(sei.numPackedRegions); + sei.projRegionLeft.resize(sei.numPackedRegions); + sei.packedRegionWidth.resize(sei.numPackedRegions); + sei.packedRegionHeight.resize(sei.numPackedRegions); + sei.packedRegionTop.resize(sei.numPackedRegions); + sei.packedRegionLeft.resize(sei.numPackedRegions); + sei.rwpLeftGuardBandWidth.resize(sei.numPackedRegions); + sei.rwpRightGuardBandWidth.resize(sei.numPackedRegions); + sei.rwpTopGuardBandHeight.resize(sei.numPackedRegions); + sei.rwpBottomGuardBandHeight.resize(sei.numPackedRegions); + sei.rwpGuardBandNotUsedForPredFlag.resize(sei.numPackedRegions); + sei.rwpGuardBandType.resize(4*sei.numPackedRegions); + + for( int i=0; i < sei.numPackedRegions; i++ ) { - uint32_t numHorizontalFilters; - sei_read_uvlc( pDecodedMessageOutputStream, numHorizontalFilters, "num_horizontal_filters"); sei.m_horFilterCoeff.resize(numHorizontalFilters); - if(numHorizontalFilters > 0) + sei_read_code( pDecodedMessageOutputStream, 4, val, "rwp_reserved_zero_4bits" ); + sei_read_code( pDecodedMessageOutputStream, 3, val, "rwp_tTransform_type" ); sei.rwpTransformType[i] = val; + sei_read_flag( pDecodedMessageOutputStream, val, "rwp_guard_band_flag" ); sei.rwpGuardBandFlag[i] = val; + sei_read_code( pDecodedMessageOutputStream, 32, val, "rwp_proj_region_width" ); sei.projRegionWidth[i] = val; + sei_read_code( pDecodedMessageOutputStream, 32, val, "rwp_proj_region_height" ); sei.projRegionHeight[i] = val; + sei_read_code( pDecodedMessageOutputStream, 32, val, "rwp_proj_region_top" ); sei.rwpProjRegionTop[i] = val; + sei_read_code( pDecodedMessageOutputStream, 32, val, "rwp_proj_region_left" ); sei.projRegionLeft[i] = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "rwp_packed_region_width" ); sei.packedRegionWidth[i] = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "rwp_packed_region_height" ); sei.packedRegionHeight[i] = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "rwp_packed_region_top" ); sei.packedRegionTop[i] = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "rwp_packed_region_left" ); sei.packedRegionLeft[i] = val; + if( sei.rwpGuardBandFlag[i] ) { - for(int i = 0; i < numHorizontalFilters; i++) + sei_read_code( pDecodedMessageOutputStream, 8, val, "rwp_left_guard_band_width" ); sei.rwpLeftGuardBandWidth[i] = val; + sei_read_code( pDecodedMessageOutputStream, 8, val, "rwp_right_guard_band_width" ); sei.rwpRightGuardBandWidth[i] = val; + sei_read_code( pDecodedMessageOutputStream, 8, val, "rwp_top_guard_band_height" ); sei.rwpTopGuardBandHeight[i] = val; + sei_read_code( pDecodedMessageOutputStream, 8, val, "rwp_bottom_guard_band_height" ); sei.rwpBottomGuardBandHeight[i] = val; + sei_read_flag( pDecodedMessageOutputStream, val, "rwp_guard_band_not_used_forPred_flag" ); sei.rwpGuardBandNotUsedForPredFlag[i] = val; + for( int j=0; j < 4; j++ ) { - uint32_t horTapLengthMinus1; - sei_read_uvlc( pDecodedMessageOutputStream, horTapLengthMinus1, "hor_tap_length_minus_1"); sei.m_horFilterCoeff[i].resize(horTapLengthMinus1+1); - for(int j = 0; j < (horTapLengthMinus1 + 1); j++) - { - sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); - } + sei_read_code( pDecodedMessageOutputStream, 3, val, "rwp_guard_band_type" ); sei.rwpGuardBandType[i*4 + j] = val; } + sei_read_code( pDecodedMessageOutputStream, 3, val, "rwp_guard_band_reserved_zero_3bits" ); } } } } -void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEIGeneralizedCubemapProjection(SEIGeneralizedCubemapProjection& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) { - int i; uint32_t val; output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; - sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; - if ( !sei.m_kneeCancelFlag ) + sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_cancel_flag" ); sei.gcmpCancelFlag = val; + if (!sei.gcmpCancelFlag) { - sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; - sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; - sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; - CHECK( sei.m_kneeNumKneePointsMinus1 <= 0, "Invali state" ); - sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); - sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); - for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) + sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_persistence_flag" ); sei.gcmpPersistenceFlag = val; + sei_read_code( pDecodedMessageOutputStream, 3, val, "gcmp_packing_type" ); sei.gcmpPackingType = val; + sei_read_code( pDecodedMessageOutputStream, 2, val, "gcmp_mapping_function_type" ); sei.gcmpMappingFunctionType = val; + + int numFace = sei.gcmpPackingType == 4 || sei.gcmpPackingType == 5 ? 5 : 6; + sei.gcmpFaceIndex.resize(numFace); + sei.gcmpFaceRotation.resize(numFace); + if (sei.gcmpMappingFunctionType == 2) + { + sei.gcmpFunctionCoeffU.resize(numFace); + sei.gcmpFunctionUAffectedByVFlag.resize(numFace); + sei.gcmpFunctionCoeffV.resize(numFace); + sei.gcmpFunctionVAffectedByUFlag.resize(numFace); + } + + for (int i = 0; i < numFace; i++) + { + sei_read_code( pDecodedMessageOutputStream, 3, val, "gcmp_face_index" ); sei.gcmpFaceIndex[i] = val; + sei_read_code( pDecodedMessageOutputStream, 2, val, "gcmp_face_rotation" ); sei.gcmpFaceRotation[i] = val; + if (sei.gcmpMappingFunctionType == 2) + { + sei_read_code( pDecodedMessageOutputStream, 7, val, "gcmp_function_coeff_u" ); sei.gcmpFunctionCoeffU[i] = val; + sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_function_u_affected_by_v_flag" ); sei.gcmpFunctionUAffectedByVFlag[i] = val; + sei_read_code( pDecodedMessageOutputStream, 7, val, "gcmp_function_coeff_v" ); sei.gcmpFunctionCoeffV[i] = val; + sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_function_v_affected_by_u_flag" ); sei.gcmpFunctionVAffectedByUFlag[i] = val; + } + } + sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_guard_band_flag" ); sei.gcmpGuardBandFlag = val; + if (sei.gcmpGuardBandFlag) { - sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; - sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; + sei_read_code( pDecodedMessageOutputStream, 3, val, "gcmp_guard_band_type" ); sei.gcmpGuardBandType = val; + sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_guard_band_boundary_exterior_flag" ); sei.gcmpGuardBandBoundaryExteriorFlag = val; + sei_read_code( pDecodedMessageOutputStream, 4, val, "gcmp_guard_band_samples_minus1" ); sei.gcmpGuardBandSamplesMinus1 = val; } } } -void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) +void SEIReader::xParseSEISubpictureLevelInfo(SEISubpicureLevelInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) { - uint32_t uiVal; - int iVal; output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - - sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; - sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; - if( !sei.m_colourRemapCancelFlag ) + uint32_t val; + sei_read_code( pDecodedMessageOutputStream, 3, val, "sli_num_ref_levels_minus1" ); sei.numRefLevels = val + 1; + sei_read_flag( pDecodedMessageOutputStream, val, "sli_cbr_constraint_flag" ); sei.cbrConstraintFlag = val; + sei_read_flag( pDecodedMessageOutputStream, val, "sli_explicit_fraction_present_flag" ); sei.explicitFractionPresent = val; + if (sei.explicitFractionPresent) { - sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; - sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresent = uiVal; - if ( sei.m_colourRemapVideoSignalInfoPresent ) + sei_read_uvlc(pDecodedMessageOutputStream, val, "sli_num_subpics_minus1"); sei.numSubpics = val + 1; + sei_read_code(pDecodedMessageOutputStream, 3, val, "sli_max_sublayers_minus1" ); sei.sliMaxSublayers = val + 1; + sei_read_flag(pDecodedMessageOutputStream, val, "sli_sublayer_info_present_flag"); sei.sliSublayerInfoPresent = val; + while (!isByteAligned()) { - sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; + sei_read_flag( pDecodedMessageOutputStream, val, "sli_alignment_zero_bit" ); CHECK (val != 0, "sli_alignment_zero_bit not equal to zero" ); } - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; + } - for( int c=0 ; c<3 ; c++ ) - { - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; - sei.m_preLut[c].resize(sei.m_preLutNumValMinus1[c]+1); - if( uiVal> 0 ) - { - for ( int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) - { - sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLut[c][i].codedValue = uiVal; - sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLut[c][i].targetValue = uiVal; - } - } - else // pre_lut_num_val_minus1[c] == 0 + sei.refLevelIdc.resize(sei.numRefLevels); + sei.nonSubpicLayersFraction.resize(sei.numRefLevels); + // sei parameters initialization + for (int i = 0; i < sei.numRefLevels; i++) + { + sei.nonSubpicLayersFraction[i].resize(sei.sliMaxSublayers); + sei.refLevelIdc[i].resize(sei.sliMaxSublayers); + for (int k = 0; k < sei.sliMaxSublayers; k++) { - sei.m_preLut[c][0].codedValue = 0; - sei.m_preLut[c][0].targetValue = 0; - sei.m_preLut[c][1].codedValue = (1 << sei.m_colourRemapInputBitDepth) - 1 ; - sei.m_preLut[c][1].targetValue = (1 << sei.m_colourRemapBitDepth) - 1 ; - } + sei.refLevelIdc[i][k] = Level::LEVEL15_5; } - - sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresent = uiVal; - if( sei.m_colourRemapMatrixPresent ) + } + if (sei.explicitFractionPresent) + { + sei.refLevelFraction.resize(sei.numRefLevels); + for (int i = 0; i < sei.numRefLevels; i++) { - sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; - for ( int c=0 ; c<3 ; c++ ) - { - for ( int i=0 ; i<3 ; i++ ) + sei.refLevelFraction[i].resize(sei.numSubpics); + for (int j = 0; j < sei.numSubpics; j++) + { + sei.refLevelFraction[i][j].resize(sei.sliMaxSublayers); + for (int k = 0; k < sei.sliMaxSublayers; k++) { - sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; + sei.refLevelFraction[i][j][k] = 0; } } } - else // setting default matrix (I3) + } + + // parsing + for (int k = sei.sliSublayerInfoPresent ? 0 : sei.sliMaxSublayers - 1; k < sei.sliMaxSublayers; k++) + { + for (int i = 0; i < sei.numRefLevels; i++) { - sei.m_log2MatrixDenom = 10; - for ( int c=0 ; c<3 ; c++ ) + sei_read_code(pDecodedMessageOutputStream, 8, val, "sli_non_subpic_layers_fraction[i][k]"); sei.nonSubpicLayersFraction[i][k] = (Level::Name) val; + sei_read_code(pDecodedMessageOutputStream, 8, val, "sli_ref_level_idc[i][k]"); sei.refLevelIdc[i][k] = (Level::Name) val; + + if (sei.explicitFractionPresent) { - for ( int i=0 ; i<3 ; i++ ) + for (int j = 0; j < sei.numSubpics; j++) { - sei.m_colourRemapCoeffs[c][i] = (c==i) << sei.m_log2MatrixDenom; + sei_read_code(pDecodedMessageOutputStream, 8, val, "sli_ref_level_fraction_minus1[i][j][k]"); sei.refLevelFraction[i][j][k] = val; } } } - for( int c=0 ; c<3 ; c++ ) + } + + // update the inference of m_refLevelIdc[][] and m_refLevelFraction[][][] + if (!sei.sliSublayerInfoPresent) + { + for (int k = sei.sliMaxSublayers - 2; k >= 0; k--) { - sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; - sei.m_postLut[c].resize(sei.m_postLutNumValMinus1[c]+1); - if( uiVal > 0 ) + for (int i = 0; i < sei.numRefLevels; i++) { - for ( int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) + sei.nonSubpicLayersFraction[i][k] = sei.nonSubpicLayersFraction[i][sei.sliMaxSublayers - 1]; + sei.refLevelIdc[i][k] = sei.refLevelIdc[i][sei.sliMaxSublayers - 1]; + if (sei.explicitFractionPresent) { - sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLut[c][i].codedValue = uiVal; - sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLut[c][i].targetValue = uiVal; + for (int j = 0; j < sei.numSubpics; j++) + { + sei.refLevelFraction[i][j][k] = sei.refLevelFraction[i][j][sei.sliMaxSublayers - 1]; + } } } - else - { - sei.m_postLut[c][0].codedValue = 0; - sei.m_postLut[c][0].targetValue = 0; - sei.m_postLut[c][1].targetValue = (1 << sei.m_colourRemapBitDepth) - 1; - sei.m_postLut[c][1].codedValue = (1 << sei.m_colourRemapBitDepth) - 1; - } } } } -void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -{ - THROW("na SEIMasteringDisplay"); -} - -void SEIReader::xParseSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics& sei, uint32_t payloadSize, std::ostream* pDecodedMessageOutputStream) +void SEIReader::xParseSEISampleAspectRatioInfo(SEISampleAspectRatioInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) { - uint32_t code; output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); + uint32_t val; - sei_read_code(pDecodedMessageOutputStream, 8, code, "preferred_transfer_characteristics"); sei.m_preferredTransferCharacteristics = code; + sei_read_flag( pDecodedMessageOutputStream, val, "sari_cancel_flag" ); sei.sariCancelFlag = val; + if (!sei.sariCancelFlag) + { + sei_read_flag( pDecodedMessageOutputStream, val, "sari_persistence_flag" ); sei.sariPersistenceFlag = val; + sei_read_code( pDecodedMessageOutputStream, 8, val, "sari_aspect_ratio_idc" ); sei.sariAspectRatioIdc = val; + if (sei.sariAspectRatioIdc == 255) + { + sei_read_code( pDecodedMessageOutputStream, 16, val, "sari_sar_width" ); sei.sariSarWidth = val; + sei_read_code( pDecodedMessageOutputStream, 16, val, "sari_sar_height" ); sei.sariSarHeight = val; + } + } } -void SEIReader::xParseSEIGreenMetadataInfo(SEIGreenMetadataInfo& sei, uint32_t payloadSize, std::ostream* pDecodedMessageOutputStream) -{ - uint32_t code; - output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); - - sei_read_code(pDecodedMessageOutputStream, 8, code, "green_metadata_type"); - sei.m_greenMetadataType = code; - - sei_read_code(pDecodedMessageOutputStream, 8, code, "xsd_metric_type"); - sei.m_xsdMetricType = code; - - sei_read_code(pDecodedMessageOutputStream, 16, code, "xsd_metric_value"); - sei.m_xsdMetricValue = code; -} -} // namespace vvenc +}// namespace //! \} diff --git a/source/Lib/DecoderLib/SEIread.h b/source/Lib/DecoderLib/SEIread.h index d09b752c8..11acd2e18 100644 --- a/source/Lib/DecoderLib/SEIread.h +++ b/source/Lib/DecoderLib/SEIread.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file SEIread.h \brief reading funtionality for SEI messages @@ -47,6 +51,7 @@ vvc@hhi.fraunhofer.de #pragma once #include "CommonLib/SEI.h" +#include "CommonLib/HRD.h" //! \ingroup DecoderLib //! \{ @@ -61,39 +66,44 @@ class SEIReader: public VLCReader public: SEIReader() {}; virtual ~SEIReader() {}; - void parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t temporalId, const SPS *sps, std::ostream *pDecodedMessageOutputStream); + void parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId,const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream); protected: - void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, const SPS *sps, std::ostream *pDecodedMessageOutputStream); + void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream); void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIActiveParameterSets (SEIActiveParameterSets &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream); + void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, uint32_t payloadSize, const SEIBufferingPeriod& bp, const uint32_t temporalId, std::ostream *pDecodedMessageOutputStream); void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream); - void xParseSEIPictureTiming (SEIPictureTiming& sei, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream); - void xParseSEIRecoveryPoint (SEIRecoveryPoint& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIPictureTiming (SEIPictureTiming& sei, uint32_t payloadSize, const uint32_t temporalId, const SEIBufferingPeriod& bp, std::ostream *pDecodedMessageOutputStream); + void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuhLayerId, uint32_t payloadSize, const VPS *vps, const SPS *sps, std::ostream *decodedMessageOutputStream); + void xCheckScalableNestingConstraints (const SEIScalableNesting& sei, const NalUnitType nalUnitType, const VPS* vps); + void xParseSEIFrameFieldinfo (SEIFrameFieldInfo& sei, const SEIPictureTiming& pt, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIDependentRAPIndication (SEIDependentRAPIndication& sei, uint32_t payLoadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIFramePacking (SEIFramePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEISegmentedRectFramePacking (SEISegmentedRectFramePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIDisplayOrientation (SEIDisplayOrientation &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEITemporalLevel0Index (SEITemporalLevel0Index &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIRegionRefreshInfo (SEIGradualDecodingRefreshInfo &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEINoDisplay (SEINoDisplay &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIToneMappingInfo (SEIToneMappingInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEISOPDescription (SEISOPDescription &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream); - void xParseSEITempMotionConstraintsTileSets (SEITempMotionConstrainedTileSets& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEITimeCode (SEITimeCode& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIChromaResamplingFilterHint (SEIChromaResamplingFilterHint& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIParameterSetsInclusionIndication(SEIParameterSetsInclusionIndication& sei, uint32_t payloadSize, std::ostream* pDecodedMessageOutputStream); void xParseSEIMasteringDisplayColourVolume (SEIMasteringDisplayColourVolume& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics& sei, uint32_t payLoadSize, std::ostream *pDecodedMessageOutputStream); - void xParseSEIGreenMetadataInfo (SEIGreenMetadataInfo& sei, uint32_t payLoadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIEquirectangularProjection (SEIEquirectangularProjection &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEISphereRotation (SEISphereRotation &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIOmniViewport (SEIOmniViewport& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIRegionWisePacking (SEIRegionWisePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIGeneralizedCubemapProjection (SEIGeneralizedCubemapProjection &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEISubpictureLevelInfo (SEISubpicureLevelInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEISampleAspectRatioInfo (SEISampleAspectRatioInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIUserDataRegistered (SEIUserDataRegistered& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIFilmGrainCharacteristics (SEIFilmGrainCharacteristics& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIContentLightLevelInfo (SEIContentLightLevelInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIAmbientViewingEnvironment (SEIAmbientViewingEnvironment& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + void xParseSEIContentColourVolume (SEIContentColourVolume& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); + + void sei_read_scode (std::ostream *pOS, uint32_t length, int& code, const char *pSymbolName); + void sei_read_code (std::ostream *pOS, uint32_t uiLength, uint32_t& ruiCode, const char *pSymbolName); + void sei_read_uvlc (std::ostream *pOS, uint32_t& ruiCode, const char *pSymbolName); + void sei_read_svlc (std::ostream *pOS, int& ruiCode, const char *pSymbolName); + void sei_read_flag (std::ostream *pOS, uint32_t& ruiCode, const char *pSymbolName); - void sei_read_code(std::ostream *pOS, uint32_t uiLength, uint32_t& ruiCode, const char *pSymbolName); - void sei_read_uvlc(std::ostream *pOS, uint32_t& ruiCode, const char *pSymbolName); - void sei_read_svlc(std::ostream *pOS, int& ruiCode, const char *pSymbolName); - void sei_read_flag(std::ostream *pOS, uint32_t& ruiCode, const char *pSymbolName); +protected: + HRD m_nestedHrd; }; } // namespace vvenc diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 0b29bae15..2a140fcf6 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file VLCWReader.cpp @@ -378,10 +382,10 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana READ_CODE( 4, uiCode, "pps_seq_parameter_set_id"); pcPPS->spsId = (uiCode); - READ_FLAG( pcPPS->mixedNaluTypesInPic, "mixed_nalu_types_in_pic_flag" ); + READ_FLAG( pcPPS->mixedNaluTypesInPic, "pps_mixed_nalu_types_in_pic_flag" ); - READ_UVLC( pcPPS->picWidthInLumaSamples, "pic_width_in_luma_samples" ); - READ_UVLC( pcPPS->picHeightInLumaSamples, "pic_height_in_luma_samples" ); + READ_UVLC( pcPPS->picWidthInLumaSamples, "pps_pic_width_in_luma_samples" ); + READ_UVLC( pcPPS->picHeightInLumaSamples, "pps_pic_height_in_luma_samples" ); READ_FLAG( uiCode, "pps_conformance_window_flag" ); @@ -390,23 +394,29 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana { //th assume that the sps is there and its the final one Window &conf = pcPPS->conformanceWindow; - READ_UVLC( uiCode, "conf_win_left_offset" ); conf.winLeftOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); - READ_UVLC( uiCode, "conf_win_right_offset" ); conf.winRightOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); - READ_UVLC( uiCode, "conf_win_top_offset" ); conf.winTopOffset = ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); - READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.winBottomOffset= ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "pps_conf_win_left_offset" ); conf.winLeftOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "pps_conf_win_right_offset" ); conf.winRightOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "pps_conf_win_top_offset" ); conf.winTopOffset = ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "pps_conf_win_bottom_offset" ); conf.winBottomOffset= ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); conf.enabledFlag = true; } - READ_FLAG( uiCode, "scaling_window_flag" ); + if( pcPPS->picWidthInLumaSamples == pcSPS->maxPicWidthInLumaSamples && pcPPS->picHeightInLumaSamples == pcSPS->maxPicHeightInLumaSamples ) + { + CHECK( pcPPS->conformanceWindow.enabledFlag, "When pic_width_in_luma_samples is equal to pic_width_max_in_luma_samples and pic_height_in_luma_samples is equal to pic_height_max_in_luma_samples, the value of pps_conformance_window_flag shall be equal to 0"); + pcPPS->conformanceWindow = pcSPS->conformanceWindow; + } + + READ_FLAG( uiCode, "spps_caling_window_flag" ); if( uiCode != 0 ) { //th assume that the sps is there and its the final one Window &conf = pcPPS->scalingWindow; int iCode; - READ_SVLC( iCode, "scaling_win_left_offset" ); conf.winLeftOffset = ( iCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); - READ_SVLC( iCode, "scaling_win_right_offset" ); conf.winRightOffset = ( iCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); - READ_SVLC( iCode, "scaling_win_top_offset" ); conf.winTopOffset = ( iCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); - READ_SVLC( iCode, "scaling_win_bottom_offset" ); conf.winBottomOffset= ( iCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); + READ_SVLC( iCode, "pps_scaling_win_left_offset" ); conf.winLeftOffset = ( iCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); + READ_SVLC( iCode, "pps_scaling_win_right_offset" ); conf.winRightOffset = ( iCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); + READ_SVLC( iCode, "pps_scaling_win_top_offset" ); conf.winTopOffset = ( iCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); + READ_SVLC( iCode, "pps_scaling_win_bottom_offset" ); conf.winBottomOffset= ( iCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); conf.enabledFlag = true; } else @@ -414,10 +424,10 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana pcPPS->scalingWindow = pcPPS->conformanceWindow; } - READ_FLAG( pcPPS->outputFlagPresent, "output_flag_present_flag" ); + READ_FLAG( pcPPS->outputFlagPresent, "pps_output_flag_present_flag" ); READ_FLAG( pcPPS->noPicPartition, "pps_no_pic_partition_flag"); - READ_FLAG( pcPPS->subPicIdMappingInPps, "subpic_id_mapping_in_pps_flag" ); + READ_FLAG( pcPPS->subPicIdMappingInPps, "pps_subpic_id_mapping_in_pps_flag" ); if( pcPPS->subPicIdMappingInPps ) { if( !pcPPS->noPicPartition ) @@ -452,19 +462,19 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana THROW("no support"); } - READ_FLAG( pcPPS->cabacInitPresent, "cabac_init_present_flag" ); + READ_FLAG( pcPPS->cabacInitPresent, "pps_cabac_init_present_flag" ); - READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); + READ_UVLC(uiCode, "pps_num_ref_idx_l0_default_active_minus1"); CHECK(uiCode > 14, "Invalid code read"); pcPPS->numRefIdxL0DefaultActive = (uiCode+1); - READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); + READ_UVLC(uiCode, "pps_num_ref_idx_l1_default_active_minus1"); CHECK(uiCode > 14, "Invalid code read"); pcPPS->numRefIdxL1DefaultActive = (uiCode+1); - READ_FLAG(pcPPS->rpl1IdxPresent, "rpl1_idx_present_flag"); - READ_FLAG( pcPPS->weightPred, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) - READ_FLAG( pcPPS->weightedBiPred, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) + READ_FLAG(pcPPS->rpl1IdxPresent, "pps_rpl1_idx_present_flag"); + READ_FLAG( pcPPS->weightPred, "pps_weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) + READ_FLAG( pcPPS->weightedBiPred, "pps_weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) READ_FLAG(pcPPS->wrapAroundEnabled, "pps_ref_wraparound_enabled_flag"); if (pcPPS->wrapAroundEnabled) { @@ -472,9 +482,9 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana pcPPS->wrapAroundOffset = (uiCode); } - READ_SVLC(pcPPS->picInitQPMinus26, "init_qp_minus26" ); + READ_SVLC(pcPPS->picInitQPMinus26, "pps_init_qp_minus26" ); - READ_FLAG( pcPPS->useDQP, "cu_qp_delta_enabled_flag" ); + READ_FLAG( pcPPS->useDQP, "pps_cu_qp_delta_enabled_flag" ); READ_FLAG(pcPPS->usePPSChromaTool, "pps_chroma_tool_offsets_present_flag"); if (pcPPS->usePPSChromaTool) { @@ -510,7 +520,7 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana if (uiCode != 0) { uint32_t tableSizeMinus1 = 0; - READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); + READ_UVLC(tableSizeMinus1, "pps_chroma_qp_offset_list_len_minus1"); CHECK(tableSizeMinus1 >= MAX_QP_OFFSET_LIST_SIZE, "Table size exceeds maximum"); for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) @@ -518,13 +528,13 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana int cbOffset; int crOffset; int jointCbCrOffset = 0; - READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); + READ_SVLC(cbOffset, "pps_cb_qp_offset_list[i]"); CHECK(cbOffset < -12 || cbOffset > 12, "Invalid chroma QP offset"); - READ_SVLC(crOffset, "cr_qp_offset_list[i]"); + READ_SVLC(crOffset, "pps_cr_qp_offset_list[i]"); CHECK(crOffset < -12 || crOffset > 12, "Invalid chroma QP offset"); if (pcPPS->jointCbCrQpOffsetPresent ) { - READ_SVLC(jointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); + READ_SVLC(jointCbCrOffset, "pps_joint_cbcr_qp_offset_list[i]"); } CHECK(jointCbCrOffset < -12 || jointCbCrOffset > 12, "Invalid chroma QP offset"); // table uses +1 for index (see comment inside the function) @@ -533,7 +543,7 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana CHECK(pcPPS->chromaQpOffsetListLen != tableSizeMinus1 + 1, "Invalid chroma QP offset list length"); } } - READ_FLAG( pcPPS->deblockingFilterControlPresent, "deblocking_filter_control_present_flag" ); + READ_FLAG( pcPPS->deblockingFilterControlPresent, "pps_deblocking_filter_control_present_flag" ); if(pcPPS->deblockingFilterControlPresent) { READ_FLAG( pcPPS->deblockingFilterOverrideEnabled, "deblocking_filter_override_enabled_flag" ); @@ -580,19 +590,19 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana } if (!pcPPS->noPicPartition) { - READ_FLAG(pcPPS->rplInfoInPh, "rpl_info_in_ph_flag"); - READ_FLAG(pcPPS->saoInfoInPh, "sao_info_in_ph_flag"); - READ_FLAG(pcPPS->alfInfoInPh, "alf_info_in_ph_flag"); + READ_FLAG(pcPPS->rplInfoInPh, "pps_rpl_info_in_ph_flag"); + READ_FLAG(pcPPS->saoInfoInPh, "pps_sao_info_in_ph_flag"); + READ_FLAG(pcPPS->alfInfoInPh, "pps_alf_info_in_ph_flag"); if ((pcPPS->weightPred || pcPPS->weightedBiPred) && pcPPS->rplInfoInPh) { - READ_FLAG(pcPPS->wpInfoInPh, "wp_info_in_ph_flag"); + READ_FLAG(pcPPS->wpInfoInPh, "pps_wp_info_in_ph_flag"); } - READ_FLAG(pcPPS->qpDeltaInfoInPh, "qp_delta_info_in_ph_flag"); + READ_FLAG(pcPPS->qpDeltaInfoInPh, "pps_qp_delta_info_in_ph_flag"); } - READ_FLAG( pcPPS->pictureHeaderExtensionPresent, "picture_header_extension_present_flag"); + READ_FLAG( pcPPS->pictureHeaderExtensionPresent, "pps_picture_header_extension_present_flag"); - READ_FLAG( pcPPS->sliceHeaderExtensionPresent, "slice_header_extension_present_flag"); + READ_FLAG( pcPPS->sliceHeaderExtensionPresent, "pps_slice_header_extension_present_flag"); READ_FLAG( uiCode, "pps_extension_present_flag"); if (uiCode) @@ -615,9 +625,9 @@ void HLSyntaxReader::parseAPS( APS* aps ) READ_CODE(5, aps->apsId, "adaptation_parameter_set_id"); - uint32_t codeApsChromaPresentFlag; - READ_FLAG(codeApsChromaPresentFlag, "aps_chroma_present_flag"); - aps->chromaPresentFlag = codeApsChromaPresentFlag; + uint32_t codeApsChromaPresent; + READ_FLAG(codeApsChromaPresent, "aps_chroma_present_flag"); + aps->chromaPresent = codeApsChromaPresent; if (aps->apsType == ALF_APS) @@ -648,7 +658,7 @@ void HLSyntaxReader::parseAlfAps( APS* aps ) READ_FLAG(code, "alf_luma_new_filter"); alfp.newFilterFlag[CH_L] = code; CcAlfFilterParam& ccAlfParam = aps->ccAlfParam; - if (aps->chromaPresentFlag) + if (aps->chromaPresent) { READ_FLAG(code, "alf_chroma_new_filter"); alfp.newFilterFlag[CH_C] = code; @@ -775,11 +785,11 @@ void HLSyntaxReader::parseLmcsAps( APS* aps ) info.reshaperModelBinCWDelta[i] = (1 - 2 * signCW) * absCW; } - if (aps->chromaPresentFlag) + if (aps->chromaPresent) { READ_CODE(3, code, "lmcs_delta_abs_crs"); } - int absCW = aps->chromaPresentFlag ? code : 0; + int absCW = aps->chromaPresent ? code : 0; if (absCW > 0) { READ_CODE(1, code, "lmcs_delta_sign_crs_flag"); @@ -794,18 +804,18 @@ void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) #if ENABLE_TRACING DTRACE( g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n"); #endif - READ_FLAG(pcVUI->progressiveSourceFlag, "vui_general_progressive_source_flag" ); - READ_FLAG(pcVUI->interlacedSourceFlag, "vui_general_interlaced_source_flag" ); + READ_FLAG(pcVUI->progressiveSourceFlag, "vui_progressive_source_flag" ); + READ_FLAG(pcVUI->interlacedSourceFlag, "vui_interlaced_source_flag" ); READ_FLAG(pcVUI->nonPackedFlag, "vui_non_packed_constraint_flag"); READ_FLAG(pcVUI->nonProjectedFlag, "vui_non_projected_constraint_flag"); - READ_FLAG( pcVUI->aspectRatioInfoPresent, "aspect_ratio_info_present_flag"); + READ_FLAG( pcVUI->aspectRatioInfoPresent, "vui_aspect_ratio_info_present_flag"); if (pcVUI->aspectRatioInfoPresent) { - READ_CODE(8, pcVUI->aspectRatioIdc, "aspect_ratio_idc"); + READ_CODE(8, pcVUI->aspectRatioIdc, "vui_aspect_ratio_idc"); if (pcVUI->aspectRatioIdc == 255) { - READ_CODE(16, pcVUI->sarWidth, "sar_width"); - READ_CODE(16, pcVUI->sarHeight, "sar_height"); + READ_CODE(16, pcVUI->sarWidth, "vui_sar_width"); + READ_CODE(16, pcVUI->sarHeight, "vui_sar_height"); } } @@ -814,39 +824,136 @@ void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) { READ_FLAG(pcVUI->overscanAppropriateFlag, "vui_overscan_appropriate_flag"); } - READ_FLAG(pcVUI->colourDescriptionPresent, "colour_description_present_flag"); + READ_FLAG(pcVUI->colourDescriptionPresent, "vui_colour_description_present_flag"); if (pcVUI->colourDescriptionPresent) { - READ_CODE(8, pcVUI->colourPrimaries, "colour_primaries"); - READ_CODE(8, pcVUI->transferCharacteristics, "transfer_characteristics"); - READ_CODE(8, pcVUI->matrixCoefficients, "matrix_coeffs"); + READ_CODE(8, pcVUI->colourPrimaries, "vui_colour_primaries"); + READ_CODE(8, pcVUI->transferCharacteristics, "vui_transfer_characteristics"); + READ_CODE(8, pcVUI->matrixCoefficients, "vui_matrix_coeffs"); READ_FLAG( pcVUI->videoFullRangeFlag, "vui_full_range_flag"); } - READ_FLAG( pcVUI->chromaLocInfoPresent, "chroma_loc_info_present_flag"); + READ_FLAG( pcVUI->chromaLocInfoPresent, "vui_chroma_loc_info_present_flag"); if (pcVUI->chromaLocInfoPresent) { if(pcVUI->progressiveSourceFlag && !pcVUI->interlacedSourceFlag) { - READ_UVLC( pcVUI->chromaSampleLocType, "chroma_sample_loc_type" ); + READ_UVLC( pcVUI->chromaSampleLocType, "vui_chroma_sample_loc_type" ); } else { - READ_UVLC( pcVUI->chromaSampleLocTypeTopField, "chroma_sample_loc_type_top_field" ); - READ_UVLC( pcVUI->chromaSampleLocTypeBottomField, "chroma_sample_loc_type_bottom_field" ); + READ_UVLC( pcVUI->chromaSampleLocTypeTopField, "vui_chroma_sample_loc_type_top_field" ); + READ_UVLC( pcVUI->chromaSampleLocTypeBottomField, "vui_chroma_sample_loc_type_bottom_field" ); } } } +void HLSyntaxReader::parseGeneralHrdParameters(GeneralHrdParams *hrd) +{ + uint32_t symbol; + READ_CODE( 32, symbol, "num_units_in_tick"); hrd->numUnitsInTick = symbol; + READ_CODE( 32, symbol, "time_scale"); hrd->timeScale = symbol; + READ_FLAG( symbol, "general_nal_hrd_parameters_present_flag"); hrd->generalNalHrdParamsPresent = (symbol == 1); + READ_FLAG( symbol, "general_vcl_hrd_parameters_present_flag"); hrd->generalVclHrdParamsPresent = (symbol == 1); + if( hrd->generalNalHrdParamsPresent || hrd->generalVclHrdParamsPresent ) + { + READ_FLAG( symbol, "general_same_pic_timing_in_all_ols_flag"); hrd->generalSamePicTimingInAllOlsFlag = (symbol == 1); + READ_FLAG( symbol, "general_decoding_unit_hrd_params_present_flag"); hrd->generalDecodingUnitHrdParamsPresent = (symbol == 1); + if (hrd->generalDecodingUnitHrdParamsPresent) + { + READ_CODE( 8, symbol, "tick_divisor_minus2"); hrd->tickDivisorMinus2 = symbol; + } + READ_CODE( 4, symbol, "bit_rate_scale"); hrd->bitRateScale = symbol; + READ_CODE( 4, symbol, "cpb_size_scale"); hrd->cpbSizeScale = symbol; + if (hrd->generalDecodingUnitHrdParamsPresent) + { + READ_CODE( 4, symbol, "cpb_size_du_scale"); hrd->cpbSizeDuScale = symbol; + } + READ_UVLC( symbol, "hrd_cpb_cnt_minus1"); hrd->hrdCpbCntMinus1 = symbol; + CHECK(symbol > 31,"The value of hrd_cpb_cnt_minus1 shall be in the range of 0 to 31, inclusive"); +} +} +void HLSyntaxReader::parseOlsHrdParameters(GeneralHrdParams * generalHrd, OlsHrdParams *olsHrd, uint32_t firstSubLayer, uint32_t maxNumSubLayersMinus1) +{ + uint32_t symbol; + + for( int i = firstSubLayer; i <= maxNumSubLayersMinus1; i ++ ) + { + OlsHrdParams *hrd = &(olsHrd[i]); + READ_FLAG( symbol, "fixed_pic_rate_general_flag"); hrd->fixedPicRateGeneralFlag = (symbol == 1); + if (!hrd->fixedPicRateGeneralFlag) + { + READ_FLAG( symbol, "fixed_pic_rate_within_cvs_flag"); hrd->fixedPicRateWithinCvsFlag = (symbol == 1); + } + else + { + hrd->fixedPicRateWithinCvsFlag = (true); + } + + hrd->lowDelayHrdFlag = (false); // Inferred to be 0 when not present + + if (hrd->fixedPicRateWithinCvsFlag) + { + READ_UVLC( symbol, "elemental_duration_in_tc_minus1"); hrd->elementDurationInTcMinus1 = symbol; + } + else if((generalHrd->generalNalHrdParamsPresent || generalHrd->generalVclHrdParamsPresent) &&generalHrd->hrdCpbCntMinus1 == 0) + { + READ_FLAG( symbol, "low_delay_hrd_flag"); hrd->lowDelayHrdFlag = (symbol == 1); + } + + for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) + { + if (((nalOrVcl == 0) && (generalHrd->generalNalHrdParamsPresent)) || ((nalOrVcl == 1) && (generalHrd->generalVclHrdParamsPresent))) + { + for (int j = 0; j <= (generalHrd->hrdCpbCntMinus1); j++) + { + READ_UVLC( symbol, "bit_rate_value_minus1"); hrd->bitRateValueMinus1[j][nalOrVcl] = symbol; + READ_UVLC( symbol, "cpb_size_value_minus1"); hrd->cpbSizeValueMinus1[j][nalOrVcl] = symbol; + if (generalHrd->generalDecodingUnitHrdParamsPresent) + { + READ_UVLC( symbol, "cpb_size_du_value_minus1"); hrd->duCpbSizeValueMinus1[j][nalOrVcl] = symbol; + READ_UVLC( symbol, "bit_rate_du_value_minus1"); hrd->duBitRateValueMinus1[j][nalOrVcl] = symbol; + } + READ_FLAG( symbol, "cbr_flag"); hrd->cbrFlag[j][nalOrVcl] = (symbol == 1); + } + } + } + } + for (int i = 0; i < firstSubLayer; i++) + { + OlsHrdParams* hrdHighestTLayer = &(olsHrd[maxNumSubLayersMinus1]); + OlsHrdParams* hrdTemp = &(olsHrd[i]); + hrdTemp->fixedPicRateGeneralFlag = hrdHighestTLayer->fixedPicRateGeneralFlag; + hrdTemp->fixedPicRateWithinCvsFlag = hrdHighestTLayer->fixedPicRateWithinCvsFlag; + hrdTemp->elementDurationInTcMinus1 = hrdHighestTLayer->elementDurationInTcMinus1; + for (int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl++) + { + if (((nalOrVcl == 0) && (generalHrd->generalNalHrdParamsPresent)) || ((nalOrVcl == 1) && (generalHrd->generalVclHrdParamsPresent))) + { + for (int j = 0; j <= (generalHrd->hrdCpbCntMinus1); j++) + { + hrdTemp->bitRateValueMinus1[j][nalOrVcl] = hrdHighestTLayer->bitRateValueMinus1[j][nalOrVcl]; + hrdTemp->cpbSizeValueMinus1[j][nalOrVcl] = hrdHighestTLayer->cpbSizeValueMinus1[j][nalOrVcl]; + if (generalHrd->generalDecodingUnitHrdParamsPresent) + { + hrdTemp->duBitRateValueMinus1[j][nalOrVcl] = hrdHighestTLayer->duBitRateValueMinus1[j][nalOrVcl]; + hrdTemp->duCpbSizeValueMinus1[j][nalOrVcl] = hrdHighestTLayer->duCpbSizeValueMinus1[j][nalOrVcl]; + } + hrdTemp->cbrFlag[j][nalOrVcl] = hrdHighestTLayer->cbrFlag[j][nalOrVcl]; + } + } + } + } +} void HLSyntaxReader::dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, SPS *pcSPS) { uint32_t code; for (int i = (subLayerInfoFlag ? 0 : maxSubLayersMinus1); i <= maxSubLayersMinus1; i++) { - READ_UVLC(pcSPS->maxDecPicBuffering[i], "max_dec_pic_buffering_minus1[i]"); - READ_UVLC(code, "max_num_reorder_pics[i]"); pcSPS->numReorderPics[i] = code; - READ_UVLC(pcSPS->maxLatencyIncreasePlus1[i], "max_latency_increase_plus1[i]"); + READ_UVLC(pcSPS->maxDecPicBuffering[i], "dpb_max_dec_pic_buffering_minus1[i]"); + READ_UVLC(code, "dpb_max_num_reorder_pics[i]"); pcSPS->numReorderPics[i] = code; + READ_UVLC(pcSPS->maxLatencyIncreasePlus1[i], "dpb_max_latency_increase_plus1[i]"); } } @@ -858,7 +965,7 @@ void HLSyntaxReader::parseExtraPHBitsStruct( SPS *sps, int numBytes ) for (int i=0; i < 8*numBytes; i++) { - READ_FLAG(symbol, "extra_ph_bit_present_flag[ i ]"); + READ_FLAG(symbol, "sps_extra_ph_bit_present_flag[ i ]"); presentFlags[i] = symbol; } } @@ -871,7 +978,7 @@ void HLSyntaxReader::parseExtraSHBitsStruct( SPS *sps, int numBytes ) for (int i=0; i < 8*numBytes; i++) { - READ_FLAG(symbol, "extra_sh_bit_present_flag[ i ]"); + READ_FLAG(symbol, "sps_extra_sh_bit_present_flag[ i ]"); presentFlags[i] = symbol; } } @@ -885,7 +992,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_CODE( 4, uiCode, "sps_video_parameter_set_id" ); pcSPS->vpsId = ( uiCode ); READ_CODE(3, uiCode, "sps_max_sub_layers_minus1"); pcSPS->maxTLayers = (uiCode + 1); CHECK(uiCode > 6, "Invalid maximum number of T-layer signalled"); - READ_CODE(2, uiCode, "chroma_format_idc" ); pcSPS->chromaFormatIdc = ( ChromaFormat(uiCode) ); + READ_CODE(2, uiCode, "sps_chroma_format_idc" ); pcSPS->chromaFormatIdc = ( ChromaFormat(uiCode) ); READ_CODE(2, uiCode, "sps_log2_ctu_size_minus5"); pcSPS->CTUSize = (1 << (uiCode + 5)); CHECK(uiCode > 2, "sps_log2_ctu_size_minus5 must be less than or equal to 2"); unsigned ctbLog2SizeY = uiCode + 5; @@ -904,10 +1011,10 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } READ_FLAG(pcSPS->GDR, "gdr_enabled_flag"); - READ_FLAG(pcSPS->rprEnabled, "ref_pic_resampling_enabled_flag"); + READ_FLAG(pcSPS->rprEnabled, "sps_ref_pic_resampling_enabled_flag"); if (pcSPS->rprEnabled) { - READ_FLAG(pcSPS->resChangeInClvsEnabled, "res_change_in_clvs_allowed_flag"); + READ_FLAG(pcSPS->resChangeInClvsEnabled, "sps_res_change_in_clvs_allowed_flag"); } if (pcSPS->profileTierLevel.constraintInfo.noResChangeInClvsConstraintFlag) @@ -915,21 +1022,21 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) CHECK(uiCode != 0, "When no_res_change_in_clvs_constraint_flag is equal to 1, res_change_in_clvs_allowed_flag shall be equal to 0"); } - READ_UVLC ( uiCode, "pic_width_max_in_luma_samples" ); pcSPS->maxPicWidthInLumaSamples = ( uiCode ); - READ_UVLC ( uiCode, "pic_height_max_in_luma_samples" ); pcSPS->maxPicHeightInLumaSamples = ( uiCode ); + READ_UVLC ( uiCode, "sps_pic_width_max_in_luma_samples" ); pcSPS->maxPicWidthInLumaSamples = ( uiCode ); + READ_UVLC ( uiCode, "sps_pic_height_max_in_luma_samples" ); pcSPS->maxPicHeightInLumaSamples = ( uiCode ); READ_FLAG(uiCode, "sps_conformance_window_flag"); if (uiCode != 0) { Window &conf = pcSPS->conformanceWindow; - READ_UVLC( uiCode, "conf_win_left_offset" ); conf.winLeftOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); - READ_UVLC( uiCode, "conf_win_right_offset" ); conf.winRightOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); - READ_UVLC( uiCode, "conf_win_top_offset" ); conf.winTopOffset = ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); - READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.winBottomOffset= ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "sps_conf_win_left_offset" ); conf.winLeftOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "sps_conf_win_right_offset" ); conf.winRightOffset = ( uiCode * SPS::getWinUnitX( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "sps_conf_win_top_offset" ); conf.winTopOffset = ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); + READ_UVLC( uiCode, "sps_conf_win_bottom_offset" ); conf.winBottomOffset= ( uiCode * SPS::getWinUnitY( pcSPS->chromaFormatIdc ) ); conf.enabledFlag = true; } - READ_FLAG( pcSPS->subPicInfoPresent, "subpic_info_present_flag" ); + READ_FLAG( pcSPS->subPicInfoPresent, "sps_subpic_info_present_flag" ); if (pcSPS->subPicInfoPresent) { @@ -947,21 +1054,21 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( pcSPS->entryPointsPresent, "sps_entry_point_offsets_present_flag"); - READ_CODE( 4, uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->bitsForPOC = ( 4 + uiCode ); + READ_CODE( 4, uiCode, "sps_log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->bitsForPOC = ( 4 + uiCode ); CHECK(uiCode > 12, "Invalid code"); READ_FLAG(pcSPS->pocMsbFlag, "sps_poc_msb_flag"); if( pcSPS->pocMsbFlag) { - READ_UVLC(uiCode, "poc_msb_len_minus1"); pcSPS->pocMsbLen = (1 + uiCode); + READ_UVLC(uiCode, "sps_poc_msb_len_minus1"); pcSPS->pocMsbLen = (1 + uiCode); CHECK(uiCode > (32 - ( pcSPS->bitsForPOC - 4 )- 5), "The value of poc_msb_len_minus1 shall be in the range of 0 to 32 - log2_max_pic_order_cnt_lsb_minus4 - 5, inclusive"); } // extra bits are for future extensions, we will read, but ignore them, // unless a meaning is specified in the spec - READ_CODE(2, uiCode, "num_extra_ph_bits_bytes"); pcSPS->numExtraPHBitsBytes = (uiCode); + READ_CODE(2, uiCode, "sps_num_extra_ph_bits_bytes"); pcSPS->numExtraPHBitsBytes = (uiCode); parseExtraPHBitsStruct( pcSPS, uiCode ); - READ_CODE(2, uiCode, "num_extra_sh_bits_bytes"); pcSPS->numExtraSHBitsBytes = (uiCode); + READ_CODE(2, uiCode, "sps_num_extra_sh_bits_bytes"); pcSPS->numExtraSHBitsBytes = (uiCode); parseExtraSHBitsStruct( pcSPS, uiCode ); if (pcSPS->ptlDpbHrdParamsPresent) @@ -973,7 +1080,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) dpb_parameters(pcSPS->maxTLayers - 1, pcSPS->subLayerDpbParams, pcSPS); } - READ_UVLC(uiCode, "log2_min_luma_coding_block_size_minus2"); + READ_UVLC(uiCode, "sps_log2_min_luma_coding_block_size_minus2"); int log2MinCUSize = uiCode + 2; pcSPS->log2MinCodingBlockSize = (log2MinCUSize); @@ -983,7 +1090,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) CHECK( ( pcSPS->maxPicWidthInLumaSamples % ( std::max( 8, minCuSize ) ) ) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)" ); CHECK( ( pcSPS->maxPicHeightInLumaSamples % ( std::max( 8, minCuSize ) ) ) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)" ); - READ_FLAG(pcSPS->partitionOverrideEnabled, "partition_constraints_override_enabled_flag"); + READ_FLAG(pcSPS->partitionOverrideEnabled, "sps_partition_constraints_override_enabled_flag"); READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_slice_luma"); unsigned minQtLog2SizeIntraY = uiCode + log2MinCUSize; pcSPS->minQTSize[0] = 1 << minQtLog2SizeIntraY; @@ -1001,7 +1108,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } if( pcSPS->chromaFormatIdc != CHROMA_400 ) { - READ_FLAG(pcSPS->dualITree, "qtbtt_dual_tree_intra_flag"); + READ_FLAG(pcSPS->dualITree, "sps_qtbtt_dual_tree_intra_flag"); } if (pcSPS->dualITree) { @@ -1037,7 +1144,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG(pcSPS->transformSkip, "sps_transform_skip_enabled_flag"); if (pcSPS->transformSkip) { - READ_UVLC(uiCode, "log2_transform_skip_max_size_minus2"); + READ_UVLC(uiCode, "sps_log2_transform_skip_max_size_minus2"); pcSPS->log2MaxTransformSkipBlockSize = (uiCode + 2); READ_FLAG( pcSPS->BDPCM, "sps_bdpcm_enabled_flag"); @@ -1055,7 +1162,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { READ_FLAG(pcSPS->jointCbCr, "sps_joint_cbcr_enabled_flag"); ChromaQpMappingTableParams chromaQpMappingTableParams; - READ_FLAG(chromaQpMappingTableParams.m_sameCQPTableForAllChromaFlag, "same_qp_table_for_chroma"); + READ_FLAG(chromaQpMappingTableParams.m_sameCQPTableForAllChromaFlag, "sps_same_qp_table_for_chroma"); int numQpTables = chromaQpMappingTableParams.m_sameCQPTableForAllChromaFlag ? 1 : (pcSPS->jointCbCr ? 3 : 2); chromaQpMappingTableParams.m_numQpTables = numQpTables; for (int i = 0; i < numQpTables; i++) @@ -1097,7 +1204,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG(pcSPS->rpl1CopyFromRpl0, "rpl1_copy_from_rpl0_flag"); //Read candidate for List0 - READ_UVLC(uiCode, "num_ref_pic_lists_in_sps[0]"); + READ_UVLC(uiCode, "sps_num_ref_pic_lists_in_sps[0]"); uint32_t numberOfRPL = uiCode; pcSPS->rplList[0].resize(numberOfRPL+1); for (uint32_t ii = 0; ii < numberOfRPL; ii++) @@ -1108,7 +1215,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) //Read candidate for List1 if (!pcSPS->rpl1CopyFromRpl0) { - READ_UVLC(uiCode, "num_ref_pic_lists_in_sps[1]"); + READ_UVLC(uiCode, "sps_num_ref_pic_lists_in_sps[1]"); numberOfRPL = uiCode; pcSPS->rplList[1].resize(numberOfRPL+1); for (uint32_t ii = 0; ii < numberOfRPL; ii++) @@ -1153,14 +1260,14 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { READ_FLAG(pcSPS->fpelMmvd, "sps_mmvd_fullpel_only_flag"); } - READ_UVLC(uiCode, "six_minus_max_num_merge_cand"); + READ_UVLC(uiCode, "sps_six_minus_max_num_merge_cand"); CHECK(MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of merge candidates!"); pcSPS->maxNumMergeCand = (MRG_MAX_NUM_CANDS - uiCode); READ_FLAG(pcSPS->SBT, "sps_sbt_enabled_flag"); - READ_FLAG( pcSPS->Affine, "sps_affine_enabled_flag" ); + READ_FLAG( pcSPS->Affine, "sps_affine_enabled_flag" ); if ( pcSPS->Affine ) { - READ_UVLC(uiCode, "five_minus_max_num_subblock_merge_cand"); + READ_UVLC(uiCode, "sps_five_minus_max_num_subblock_merge_cand"); pcSPS->maxNumAffineMergeCand = (AFFINE_MRG_MAX_NUM_CANDS - uiCode); READ_FLAG( pcSPS->AffineType, "sps_affine_type_flag" ); if( pcSPS->AMVR) @@ -1183,7 +1290,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { if( pcSPS->maxNumMergeCand >= 3) { - READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_gpm_cand"); + READ_UVLC(uiCode, "sps_max_num_merge_cand_minus_max_num_gpm_cand"); CHECK(pcSPS->maxNumMergeCand < uiCode, "Incorrrect max number of GEO candidates!"); pcSPS->maxNumGeoCand = ((uint32_t)(pcSPS->maxNumMergeCand - uiCode)); } @@ -1193,7 +1300,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } } } - READ_UVLC(uiCode, "log2_parallel_merge_level_minus2"); + READ_UVLC(uiCode, "sps_log2_parallel_merge_level_minus2"); CHECK(uiCode + 2 > ctbLog2SizeY, "The value of log2_parallel_merge_level_minus2 shall be in the range of 0 to ctbLog2SizeY - 2"); pcSPS->log2ParallelMergeLevelMinus2 = (uiCode); @@ -1224,7 +1331,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG(pcSPS->IBC, "sps_ibc_enabled_flag"); if (pcSPS->IBC) { - READ_UVLC(uiCode, "six_minus_max_num_ibc_merge_cand"); + READ_UVLC(uiCode, "sps_six_minus_max_num_ibc_merge_cand"); CHECK(IBC_MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of IBC merge candidates!"); pcSPS->maxNumIBCMergeCand = (IBC_MRG_MAX_NUM_CANDS - uiCode); } @@ -1238,7 +1345,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) if (pcSPS->LFNST && pcSPS->scalingListEnabled) { - READ_FLAG(pcSPS->disableScalingMatrixForLfnstBlks, "scaling_matrix_for_lfnst_disabled_flag"); + READ_FLAG(pcSPS->disableScalingMatrixForLfnstBlks, "sps_scaling_matrix_for_lfnst_disabled_flag"); } if (pcSPS->useColorTrans && pcSPS->scalingListEnabled) @@ -1277,13 +1384,24 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( pcSPS->hrdParametersPresent, "sps_general_hrd_params_present_flag"); if( pcSPS->hrdParametersPresent ) { - THROW("no support"); + parseGeneralHrdParameters(&pcSPS->generalHrdParams); + if ((pcSPS->maxTLayers-1) > 0) + { + READ_FLAG(uiCode, "sps_sublayer_cpb_params_present_flag"); pcSPS->subLayerParametersPresent = uiCode; + } + else if((pcSPS->maxTLayers-1) == 0) + { + pcSPS->subLayerParametersPresent = 0; + } + + uint32_t firstSubLayer = pcSPS->subLayerParametersPresent ? 0 : (pcSPS->maxTLayers - 1); + parseOlsHrdParameters(&pcSPS->generalHrdParams, pcSPS->olsHrdParams, firstSubLayer, pcSPS->maxTLayers - 1); } } - READ_FLAG( pcSPS->fieldSeqFlag, "field_seq_flag"); + READ_FLAG( pcSPS->fieldSeqFlag, "sps_field_seq_flag"); - READ_FLAG( pcSPS->vuiParametersPresent, "vui_parameters_present_flag" ); + READ_FLAG( pcSPS->vuiParametersPresent, "sps_vui_parameters_present_flag" ); if (pcSPS->vuiParametersPresent) { @@ -1404,11 +1522,11 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) READ_CODE(3, uiCode, "vps_max_sublayers_minus1"); pcVPS->maxSubLayers = (uiCode + 1); CHECK(uiCode + 1 > MAX_VPS_SUBLAYERS, "Invalid code"); if( pcVPS->maxLayers > 1 && pcVPS->maxSubLayers > 1) { - READ_FLAG(pcVPS->allLayersSameNumSubLayers, "vps_all_layers_same_num_sublayers_flag"); + READ_FLAG(pcVPS->defaultPtlDpbHrdMaxTidFlag, "vps_default_ptl_dpb_hrd_max_tid_flag"); } else { - pcVPS->allLayersSameNumSubLayers = true; + pcVPS->defaultPtlDpbHrdMaxTidFlag = true; } if( pcVPS->maxLayers > 1 ) { @@ -1429,29 +1547,29 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) READ_FLAG(uiCode, "vps_independent_layer_flag"); pcVPS->independentLayer[i] = uiCode; if (!pcVPS->independentLayer[i]) { + READ_FLAG(uiCode, "max_tid_ref_present_flag[ i ]"); + bool presentFlag = uiCode; uint16_t sumUiCode = 0; for (int j = 0, k = 0; j < i; j++) { - READ_FLAG(uiCode, "vps_direct_dependency_flag"); pcVPS->directRefLayer[i][j] = uiCode; - if( uiCode ) + READ_FLAG(uiCode, "vps_direct_ref_layer_flag"); pcVPS->directRefLayer[i][j] = uiCode; + if (uiCode) { - pcVPS->interLayerRefIdx[i][j] = k; pcVPS->directRefLayerIdx[i][k++] = j; sumUiCode++; } + if (presentFlag && pcVPS->directRefLayer[i][j]) + { + READ_CODE(3, uiCode, "max_tid_il_ref_pics_plus1[ i ][ j ]"); + pcVPS->maxTidIlRefPicsPlus1[i][j] = uiCode; + } + else + { + pcVPS->maxTidIlRefPicsPlus1[i][j]= 7; + } } CHECK(sumUiCode == 0, "There has to be at least one value of j such that the value of vps_direct_dependency_flag[ i ][ j ] is equal to 1,when vps_independent_layer_flag[ i ] is equal to 0 "); - READ_FLAG(uiCode, "max_tid_ref_present_flag[ i ]"); - if (uiCode) - { - READ_CODE(3, uiCode, "max_tid_il_ref_pics_plus1[ i ]"); - pcVPS->maxTidIlRefPicsPlus1[i]= uiCode; - } - else - { - pcVPS->maxTidIlRefPicsPlus1[i] = 7; - } } } } @@ -1474,12 +1592,12 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) } if (pcVPS->olsModeIdc == 2) { - READ_CODE(8, uiCode, "num_output_layer_sets_minus2"); pcVPS->numOutputLayerSets = (uiCode + 2); + READ_CODE(8, uiCode, "vps_num_output_layer_sets_minus2"); pcVPS->numOutputLayerSets = (uiCode + 2); for (uint32_t i = 1; i <= pcVPS->numOutputLayerSets - 1; i++) { for (uint32_t j = 0; j < pcVPS->maxLayers; j++) { - READ_FLAG(pcVPS->olsOutputLayer[i][j], "ols_output_layer_flag"); + READ_FLAG(pcVPS->olsOutputLayer[i][j], "vps_ols_output_layer_flag"); } } } @@ -1492,13 +1610,13 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { if(i > 0) { - READ_FLAG(pcVPS->ptPresent[i], "pt_present_flag"); + READ_FLAG(pcVPS->ptPresent[i], "vps_pt_present_flag"); } else pcVPS->ptPresent[0] = true; - if(!pcVPS->allIndependentLayers) + if(!pcVPS->defaultPtlDpbHrdMaxTidFlag) { - READ_CODE(3, uiCode, "ptl_max_temporal_id"); + READ_CODE(3, uiCode, "vps_ptl_max_temporal_id"); pcVPS->ptlMaxTemporalId[i] = uiCode; } else if(pcVPS->maxSubLayers > 1) @@ -1551,7 +1669,7 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { if (!pcVPS->allLayersSameNumSubLayers) { - READ_CODE(3, uiCode, "dpb_max_temporal_id[i]"); + READ_CODE(3, uiCode, "vps_dpb_max_temporal_id[i]"); pcVPS->dpbMaxTemporalId.push_back(uiCode); } else @@ -1561,9 +1679,9 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) for( int j = ( pcVPS->sublayerDpbParamsPresent ? 0 : pcVPS->dpbMaxTemporalId[i] ); j <= pcVPS->dpbMaxTemporalId[i]; j++ ) { - READ_UVLC( uiCode, "max_dec_pic_buffering_minus1[i]" ); pcVPS->dpbParameters[i].maxDecPicBuffering[j] = uiCode+1; - READ_UVLC( uiCode, "max_num_reorder_pics[i]" ); pcVPS->dpbParameters[i].numReorderPics[j] = uiCode; - READ_UVLC( uiCode, "max_latency_increase_plus1[i]" ); pcVPS->dpbParameters[i].maxLatencyIncreasePlus1[j] = uiCode; + READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->dpbParameters[i].maxDecPicBuffering[j] = uiCode+1; + READ_UVLC( uiCode, "vps_max_num_reorder_pics[i]" ); pcVPS->dpbParameters[i].numReorderPics[j] = uiCode; + READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->dpbParameters[i].maxLatencyIncreasePlus1[j] = uiCode; } for( int j = ( pcVPS->sublayerDpbParamsPresent ? pcVPS->dpbMaxTemporalId[i] : 0 ); j < pcVPS->dpbMaxTemporalId[i]; j++ ) @@ -1583,13 +1701,13 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { if( pcVPS->numLayersInOls[i] > 1 ) { - READ_UVLC( uiCode, "ols_dpb_pic_width[i]" ); pcVPS->olsDpbPicSize[i].width = uiCode; - READ_UVLC( uiCode, "ols_dpb_pic_height[i]" ); pcVPS->olsDpbPicSize[i].height = uiCode; - READ_CODE( 2, uiCode, "ols_dpb_chroma_format[i]"); pcVPS->olsDpbChromaFormatIdc[i] = uiCode; - READ_UVLC( uiCode, "ols_dpb_bitdepth_minus8[i]"); pcVPS->olsDpbBitDepthMinus8[i] = uiCode; + READ_UVLC( uiCode, "vps_ols_dpb_pic_width[i]" ); pcVPS->olsDpbPicSize[i].width = uiCode; + READ_UVLC( uiCode, "vps_ols_dpb_pic_height[i]" ); pcVPS->olsDpbPicSize[i].height = uiCode; + READ_CODE( 2, uiCode, "vps_ols_dpb_chroma_format[i]"); pcVPS->olsDpbChromaFormatIdc[i] = uiCode; + READ_UVLC( uiCode, "vps_ols_dpb_bitdepth_minus8[i]"); pcVPS->olsDpbBitDepthMinus8[i] = uiCode; if ((pcVPS->numDpbParams > 1) && (pcVPS->numDpbParams != pcVPS->numMultiLayeredOlss)) { - READ_UVLC( uiCode, "ols_dpb_params_idx[i]" ); pcVPS->olsDpbParamsIdx[i] = uiCode; + READ_UVLC( uiCode, "vps_ols_dpb_params_idx[i]" ); pcVPS->olsDpbParamsIdx[i] = uiCode; } else if (pcVPS->numDpbParams == 1) { @@ -1623,11 +1741,11 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag DTRACE( g_trace_ctx, D_HEADER, "=========== Picture Header ===========\n" ); - READ_FLAG(picHeader->gdrOrIrapPic, "gdr_or_irap_pic_flag"); + READ_FLAG(picHeader->gdrOrIrapPic, "ph_gdr_or_irap_pic_flag"); READ_FLAG(picHeader->nonRefPic, "ph_non_ref_pic_flag"); if (picHeader->gdrOrIrapPic) { - READ_FLAG(picHeader->gdrPic, "gdr_pic_flag"); + READ_FLAG(picHeader->gdrPic, "ph_gdr_pic_flag"); } READ_FLAG(picHeader->picInterSliceAllowed, "ph_inter_slice_allowed_flag"); if (picHeader->picInterSliceAllowed) @@ -1653,7 +1771,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if( picHeader->gdrPic ) { - READ_UVLC(picHeader->recoveryPocCnt, "recovery_poc_cnt"); + READ_UVLC(picHeader->recoveryPocCnt, "ph_recovery_poc_cnt"); } std::vector phExtraBitsPresent = sps->extraPHBitPresent; @@ -1671,7 +1789,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag READ_FLAG(picHeader->pocMsbPresent, "ph_poc_msb_present_flag"); if (picHeader->pocMsbPresent) { - READ_CODE(sps->pocMsbLen, uiCode, "poc_msb_val"); + READ_CODE(sps->pocMsbLen, uiCode, "ph_poc_msb_val"); picHeader->pocMsbVal = (uiCode); } } @@ -1682,20 +1800,20 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { if (pps->alfInfoInPh) { - READ_FLAG(picHeader->alfEnabled[COMP_Y], "pic_alf_enabled_flag"); + READ_FLAG(picHeader->alfEnabled[COMP_Y], "ph_alf_enabled_flag"); bool alfCbEnabledFlag = false; bool alfCrEnabledFlag = false; if (uiCode) { - READ_CODE(3, uiCode, "pic_num_alf_aps_ids_luma"); + READ_CODE(3, uiCode, "ph_num_alf_aps_ids_luma"); int numAps = uiCode; picHeader->numAlfAps = (numAps); picHeader->alfApsId.resize( numAps ); for (int i = 0; i < numAps; i++) { - READ_CODE(3, uiCode, "pic_alf_aps_id_luma"); + READ_CODE(3, uiCode, "ph_alf_aps_id_luma"); picHeader->alfApsId[i] = uiCode; } @@ -1707,7 +1825,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (alfCbEnabledFlag || alfCrEnabledFlag) { - READ_CODE(3, uiCode, "pic_alf_aps_id_chroma"); + READ_CODE(3, uiCode, "ph_alf_aps_id_chroma"); picHeader->alfChromaApsId = uiCode; } if (sps->ccalfEnabled ) @@ -1842,7 +1960,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag // picture output flag if( pps->outputFlagPresent && !picHeader->nonRefPic) { - READ_FLAG( picHeader->picOutputFlag, "pic_output_flag" ); + READ_FLAG( picHeader->picOutputFlag, "ph_pic_output_flag" ); } // reference picture lists @@ -1856,7 +1974,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (sps->getNumRPL(listIdx) > 0 && (listIdx == 0 || (listIdx == 1 && pps->rpl1IdxPresent))) { - READ_FLAG(uiCode, "pic_rpl_sps_flag[i]"); + READ_FLAG(uiCode, "rpl_sps_flag[i]"); } else if (sps->getNumRPL(listIdx) == 0) { @@ -1887,7 +2005,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag (listIdx == 0 || (listIdx == 1 && pps->rpl1IdxPresent))) { int numBits = ceilLog2(sps->getNumRPL(listIdx)); - READ_CODE(numBits, uiCode, "pic_rpl_idx[i]"); + READ_CODE(numBits, uiCode, "rpl_idx[i]"); picHeader->rplIdx[listIdx] = uiCode; picHeader->pRPL[listIdx] = &sps->rplList[listIdx][uiCode]; } @@ -1918,17 +2036,16 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { if (picHeader->pRPL[listIdx]->ltrpInSliceHeader) { - READ_CODE(sps->bitsForPOC, uiCode, "pic_poc_lsb_lt[i][j]"); + READ_CODE(sps->bitsForPOC, uiCode, "poc_lsb_lt[i][j]"); picHeader->localRPL[listIdx].setRefPicIdentifier( i, uiCode, true, false, 0 ); } READ_FLAG(picHeader->localRPL[listIdx].deltaPocMSBPresent[i], "pic_delta_poc_msb_present_flag[i][j]"); if (picHeader->localRPL[listIdx].deltaPocMSBPresent[i]) { - READ_UVLC(uiCode, "pic_delta_poc_msb_cycle_lt[i][j]"); + READ_UVLC(uiCode, "delta_poc_msb_cycle_lt[i][j]"); picHeader->localRPL[listIdx].deltaPocMSBCycleLT[i] = uiCode; } } - //th check else part } } } @@ -2104,7 +2221,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if( (pps->weightPred || pps->weightedBiPred) && pps->wpInfoInPh ) { - parsePredWeightTable(picHeader, sps); + parsePredWeightTable(picHeader, pps, sps); } } // inherit constraint values from SPS @@ -2118,7 +2235,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (pps->qpDeltaInfoInPh) { - READ_SVLC(picHeader->qpDelta, "slice_qp_delta"); + READ_SVLC(picHeader->qpDelta, "ph_qp_delta"); } // joint Cb/Cr sign flag @@ -2370,7 +2487,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } if (!picHeader->picIntraSliceAllowed) { - CHECK(pcSlice->sliceType == I_SLICE, "when pic_intra_slice_allowed_flag = 0, no I_Slice is allowed"); + CHECK(pcSlice->sliceType == I_SLICE, "when ph_intra_slice_allowed_flag = 0, no I_Slice is allowed"); } // set default values in case slice overrides are disabled @@ -2414,24 +2531,24 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (pcSlice->nalUnitType == NAL_UNIT_CODED_SLICE_CRA || pcSlice->nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcSlice->nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->nalUnitType == NAL_UNIT_CODED_SLICE_GDR) { - READ_FLAG(picHeader->noOutputOfPriorPics, "no_output_of_prior_pics_flag"); + READ_FLAG(picHeader->noOutputOfPriorPics, "sh_no_output_of_prior_pics_flag"); } if (sps->alfEnabled && !pps->alfInfoInPh) { - READ_FLAG(uiCode, "slice_alf_enabled_flag"); + READ_FLAG(uiCode, "sh_alf_enabled_flag"); pcSlice->tileGroupAlfEnabled[COMP_Y] = uiCode; bool alfCbEnabledFlag = false; bool alfCrEnabledFlag = false; if (uiCode) { - READ_CODE(3, uiCode, "slice_num_alf_aps_ids_luma"); + READ_CODE(3, uiCode, "sh_num_alf_aps_ids_luma"); int numAps = uiCode; pcSlice->tileGroupNumAps = (numAps); std::vector apsId(numAps, -1); for (int i = 0; i < numAps; i++) { - READ_CODE(3, uiCode, "slice_alf_aps_id_luma"); + READ_CODE(3, uiCode, "sh_alf_aps_id_luma"); apsId[i] = uiCode; APS* APStoCheckLuma = parameterSetManager->getAPS(apsId[i], ALF_APS); CHECK(APStoCheckLuma == nullptr, "referenced APS not found"); @@ -2442,12 +2559,12 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setAlfApsIds(apsId); if (bChroma) { - READ_FLAG( alfCbEnabledFlag, "slice_alf_cb_enabled_flag"); - READ_FLAG( alfCrEnabledFlag, "slice_alf_cr_enabled_flag"); + READ_FLAG( alfCbEnabledFlag, "sh_alf_cb_enabled_flag"); + READ_FLAG( alfCrEnabledFlag, "sh_alf_cr_enabled_flag"); } if (alfCbEnabledFlag || alfCrEnabledFlag) { - READ_CODE(3, uiCode, "slice_alf_aps_id_chroma"); + READ_CODE(3, uiCode, "sh_alf_aps_id_chroma"); pcSlice->tileGroupChromaApsId = uiCode; APS* APStoCheckChroma = parameterSetManager->getAPS(uiCode, ALF_APS); CHECK(APStoCheckChroma->alfParam.newFilterFlag[CH_C] != 1, "bitstream conformance error, alf_chroma_filter_signal_flag shall be equal to 1"); @@ -2463,21 +2580,21 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (sps->ccalfEnabled && pcSlice->tileGroupAlfEnabled[COMP_Y]) { - READ_FLAG(pcSlice->tileGroupCcAlfCbEnabled, "slice_cc_alf_cb_enabled_flag"); + READ_FLAG(pcSlice->tileGroupCcAlfCbEnabled, "sh_cc_alf_cb_enabled_flag"); if (pcSlice->tileGroupCcAlfCbEnabled) { // parse APS ID - READ_CODE(3, uiCode, "slice_cc_alf_cb_aps_id"); + READ_CODE(3, uiCode, "sh_cc_alf_cb_aps_id"); pcSlice->tileGroupCcAlfCbApsId = (uiCode); pcSlice->ccAlfFilterParam = parameterSetManager->getAPS( uiCode, ALF_APS )->ccAlfParam; } // Cr - READ_FLAG(pcSlice->tileGroupCcAlfCrEnabled, "slice_cc_alf_cr_enabled_flag"); + READ_FLAG(pcSlice->tileGroupCcAlfCrEnabled, "sh_cc_alf_cr_enabled_flag"); if (pcSlice->tileGroupCcAlfCrEnabled) { // parse APS ID - READ_CODE(3, uiCode, "slice_cc_alf_cr_aps_id"); + READ_CODE(3, uiCode, "sh_cc_alf_cr_aps_id"); pcSlice->tileGroupCcAlfCrApsId = (uiCode); pcSlice->ccAlfFilterParam = parameterSetManager->getAPS( uiCode, ALF_APS )->ccAlfParam; } @@ -2486,7 +2603,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (picHeader->lmcsEnabled && !pcSlice->pictureHeaderInSliceHeader) { - READ_FLAG(pcSlice->lmcsEnabled, "slice_lmcs_enabled_flag"); + READ_FLAG(pcSlice->lmcsEnabled, "sh_lmcs_enabled_flag"); } else { @@ -2494,7 +2611,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } if (picHeader->explicitScalingListEnabled && !pcSlice->pictureHeaderInSliceHeader) { - READ_FLAG(pcSlice->explicitScalingListUsed, "slice_explicit_scaling_list_used_flag"); + READ_FLAG(pcSlice->explicitScalingListUsed, "sh_explicit_scaling_list_used_flag"); } else { @@ -2662,12 +2779,12 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if ((!pcSlice->isIntra() && pcSlice->rpl[0]->getNumRefEntries() > 1) || (pcSlice->isInterB() && pcSlice->rpl[1]->getNumRefEntries() > 1) ) { - READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); + READ_FLAG( uiCode, "sh_num_ref_idx_active_override_flag"); if (uiCode) { if(slice->rpl[0]->getNumRefEntries() > 1) { - READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); + READ_UVLC (uiCode, "sh_num_ref_idx_l0_active_minus1" ); } else { @@ -2678,7 +2795,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { if(slice->rpl[1]->getNumRefEntries() > 1) { - READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); + READ_UVLC (uiCode, "sh_num_ref_idx_l1_active_minus1" ); } else { @@ -2736,7 +2853,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par slice->cabacInitFlag = false; // default if(pps->cabacInitPresent && !slice->isIntra()) { - READ_FLAG(slice->cabacInitFlag, "cabac_init_flag"); + READ_FLAG(slice->cabacInitFlag, "sh_cabac_init_flag"); slice->encCABACTableIdx = ( slice->sliceType == B_SLICE ? ( slice->cabacInitFlag ? P_SLICE : B_SLICE ) : ( slice->cabacInitFlag ? B_SLICE : P_SLICE ) ); } @@ -2748,7 +2865,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } else if( !pps->rplInfoInPh && pcSlice->sliceType == B_SLICE ) { - READ_FLAG( pcSlice->colFromL0Flag, "collocated_from_l0_flag" ); + READ_FLAG( pcSlice->colFromL0Flag, "sh_collocated_from_l0_flag" ); } else { @@ -2789,7 +2906,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } else { - READ_SVLC(iCode, "slice_qp_delta"); + READ_SVLC(iCode, "sh_slice_qp_delta"); qpDelta = iCode; } pcSlice->sliceQp = (26 + pps->picInitQPMinus26 + qpDelta); @@ -2801,7 +2918,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { if (numValidComp>COMP_Cb) { - READ_SVLC( iCode, "slice_cb_qp_offset" ); + READ_SVLC( iCode, "sh_cb_qp_offset" ); slice->sliceChromaQpDelta[COMP_Cb] = iCode; CHECK( slice->sliceChromaQpDelta[COMP_Cb] < -12, "Invalid chroma QP offset" ); CHECK( slice->sliceChromaQpDelta[COMP_Cb] > 12, "Invalid chroma QP offset" ); @@ -2811,7 +2928,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (numValidComp>COMP_Cr) { - READ_SVLC( iCode, "slice_cr_qp_offset" ); + READ_SVLC( iCode, "sh_cr_qp_offset" ); slice->sliceChromaQpDelta[COMP_Cr] = iCode; CHECK( slice->sliceChromaQpDelta[COMP_Cr] < -12, "Invalid chroma QP offset" ); CHECK( slice->sliceChromaQpDelta[COMP_Cr] > 12, "Invalid chroma QP offset" ); @@ -2819,7 +2936,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par CHECK( (pps->chromaQpOffset[COMP_Cr] + slice->sliceChromaQpDelta[COMP_Cr]) > 12, "Invalid chroma QP offset" ); if (sps->jointCbCr) { - READ_SVLC(iCode, "slice_joint_cbcr_qp_offset" ); + READ_SVLC(iCode, "sh_joint_cbcr_qp_offset" ); slice->sliceChromaQpDelta[COMP_JOINT_CbCr] = iCode; CHECK( slice->sliceChromaQpDelta[COMP_JOINT_CbCr] < -12, "Invalid chroma QP offset"); CHECK( slice->sliceChromaQpDelta[COMP_JOINT_CbCr] > 12, "Invalid chroma QP offset"); @@ -2831,7 +2948,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (pps->chromaQpOffsetListLen>0) { - READ_FLAG(slice->chromaQpAdjEnabled, "cu_chroma_qp_offset_enabled_flag"); + READ_FLAG(slice->chromaQpAdjEnabled, "sh_cu_chroma_qp_offset_enabled_flag"); } else { @@ -2841,10 +2958,10 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if(sps->saoEnabled ) { - READ_FLAG(slice->saoEnabled[CH_L], "slice_sao_luma_flag"); + READ_FLAG(slice->saoEnabled[CH_L], "sh_slice_sao_luma_flag"); if (bChroma) { - READ_FLAG(slice->saoEnabled[CH_C], "slice_sao_chroma_flag"); + READ_FLAG(slice->saoEnabled[CH_C], "sh_slice_sao_chroma_flag"); } } @@ -2852,33 +2969,36 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { if(pps->deblockingFilterOverrideEnabled&& !pps->dbfInfoInPh) { - READ_FLAG ( slice->deblockingFilterOverrideFlag, "deblocking_filter_override_flag" ); + READ_FLAG ( slice->deblockingFilterOverrideFlag, "sh_deblocking_filter_params_present_flag" ); } if(slice->deblockingFilterOverrideFlag) { - READ_FLAG ( slice->deblockingFilterDisable, "slice_deblocking_filter_disabled_flag" ); + if (!pps->deblockingFilterDisabled ) + { + READ_FLAG ( slice->deblockingFilterDisable, "sh_deblocking_filter_disabled_flag" ); + } if(!slice->deblockingFilterDisable) { - READ_SVLC( slice->deblockingFilterBetaOffsetDiv2[COMP_Y], "slice_beta_offset_div2" ); + READ_SVLC( slice->deblockingFilterBetaOffsetDiv2[COMP_Y], "sh_beta_offset_div2" ); CHECK( slice->deblockingFilterBetaOffsetDiv2[COMP_Y] < -12 && slice->deblockingFilterBetaOffsetDiv2[COMP_Y] > 12, "Invalid deblocking filter configuration"); - READ_SVLC( slice->deblockingFilterTcOffsetDiv2[COMP_Y], "slice_tc_offset_div2" ); + READ_SVLC( slice->deblockingFilterTcOffsetDiv2[COMP_Y], "sh_tc_offset_div2" ); CHECK (slice->deblockingFilterTcOffsetDiv2[COMP_Y] < -12 && slice->deblockingFilterTcOffsetDiv2[COMP_Y] > 12, "Invalid deblocking filter configuration"); if( pps->usePPSChromaTool ) { - READ_SVLC( iCode, "slice_cb_beta_offset_div2" ); pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cb] = ( iCode ); + READ_SVLC( iCode, "sh_cb_beta_offset_div2" ); pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cb] = ( iCode ); CHECK( pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cb] < -12 || pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cb] > 12, "Invalid deblocking filter configuration"); - READ_SVLC( iCode, "slice_cb_tc_offset_div2" ); pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cb] = ( iCode ); + READ_SVLC( iCode, "sh_cb_tc_offset_div2" ); pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cb] = ( iCode ); CHECK( pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cb] < -12 || pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cb] > 12, "Invalid deblocking filter configuration"); - READ_SVLC( iCode, "slice_cr_beta_offset_div2" ); pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cr] = ( iCode ); + READ_SVLC( iCode, "sh_cr_beta_offset_div2" ); pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cr] = ( iCode ); CHECK( pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cr] < -12 || pcSlice->deblockingFilterBetaOffsetDiv2[COMP_Cr] > 12, "Invalid deblocking filter configuration"); - READ_SVLC( iCode, "slice_cr_tc_offset_div2" ); pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cr] = ( iCode ); + READ_SVLC( iCode, "sh_cr_tc_offset_div2" ); pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cr] = ( iCode ); CHECK( pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cr] < -12 || pcSlice->deblockingFilterTcOffsetDiv2[COMP_Cr] > 12, "Invalid deblocking filter configuration"); } @@ -2905,30 +3025,30 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par // dependent quantization if( sps->depQuantEnabled ) { - READ_FLAG(pcSlice->depQuantEnabled, "slice_dep_quant_enabled_flag"); + READ_FLAG(pcSlice->depQuantEnabled, "sh_dep_quant_enabled_flag"); } // sign data hiding if( sps->signDataHidingEnabled && !pcSlice->depQuantEnabled ) { - READ_FLAG( pcSlice->signDataHidingEnabled, "slice_sign_data_hiding_enabled_flag" ); + READ_FLAG( pcSlice->signDataHidingEnabled, "sh_sign_data_hiding_enabled_flag" ); } // signal TS residual coding disabled flag if (sps->transformSkip && !pcSlice->depQuantEnabled && !pcSlice->signDataHidingEnabled) { - READ_FLAG(pcSlice->tsResidualCodingDisabled, "slice_ts_residual_coding_disabled_flag"); + READ_FLAG(pcSlice->tsResidualCodingDisabled, "sh_ts_residual_coding_disabled_flag"); } pcSlice->setDefaultClpRng( *sps ); if(pps->sliceHeaderExtensionPresent) { - READ_UVLC(uiCode,"slice_segment_header_extension_length"); + READ_UVLC(uiCode,"sh_slice_header_extension_length"); for(int i=0; i 0 ) { uint32_t offsetLenMinus1; - READ_UVLC( offsetLenMinus1, "offset_len_minus1" ); + READ_UVLC( offsetLenMinus1, "sh_entry_offset_len_minus1" ); entryPointOffset.resize( numEntryPoints ); for( int idx = 0; idx < numEntryPoints; idx++ ) { - READ_CODE( offsetLenMinus1 + 1, uiCode, "entry_point_offset_minus1" ); + READ_CODE( offsetLenMinus1 + 1, uiCode, "sh_entry_point_offset_minus1" ); entryPointOffset[idx] = uiCode + 1; } } @@ -3002,24 +3122,24 @@ void HLSyntaxReader::getSlicePoc(Slice* pcSlice, PicHeader* picHeader, Parameter //!KS: need to add error handling code here, if SPS is not available CHECK(sps==0, "Invalid SPS"); - READ_FLAG(uiCode, "picture_header_in_slice_header_flag"); + READ_FLAG(uiCode, "sh_picture_header_in_slice_header_flag"); if (uiCode == 0) { pocLsb = picHeader->pocLsb; } else { - READ_FLAG(uiCode, "gdr_or_irap_pic_flag"); + READ_FLAG(uiCode, "ph_gdr_or_irap_pic_flag"); if (uiCode) { - READ_FLAG(uiCode, "gdr_pic_flag"); + READ_FLAG(uiCode, "ph_gdr_pic_flag"); } READ_FLAG(uiCode, "ph_inter_slice_allowed_flag"); if (uiCode) { READ_FLAG(uiCode, "ph_intra_slice_allowed_flag"); } - READ_FLAG(uiCode, "non_reference_picture_flag"); + READ_FLAG(uiCode, "ph_non_reference_picture_flag"); // parameter sets READ_UVLC(uiCode, "ph_pic_parameter_set_id"); // picture order count @@ -3069,8 +3189,8 @@ void HLSyntaxReader::getSlicePoc(Slice* pcSlice, PicHeader* picHeader, Parameter void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo) { uint32_t symbol; - READ_FLAG(cinfo->gciPresentFlag, "gci_present_flag"); - if (cinfo->gciPresentFlag) + READ_FLAG(cinfo->gciPresent, "gci_present_flag"); + if (cinfo->gciPresent) { READ_FLAG(cinfo->intraOnlyConstraintFlag, "gci_intra_only_constraint_flag"); READ_FLAG(cinfo->allLayersIndependentConstraintFlag, "gci_all_layers_independent_constraint_flag"); @@ -3171,11 +3291,11 @@ void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo) } -void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1) +void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, bool profileTierPresent, int maxNumSubLayersMinus1) { bool flag; uint32_t symbol; - if(profileTierPresentFlag) + if(profileTierPresent) { READ_CODE(7 , symbol, "general_profile_idc" ); ptl->profileIdc = Profile::Name(symbol); @@ -3189,7 +3309,7 @@ void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, bool profileTi READ_FLAG( ptl->frameOnlyConstraintFlag, "ptl_frame_only_constraint_flag" ); READ_FLAG( ptl->multiLayerEnabledFlag, "ptl_multilayer_enabled_flag" ); - if(profileTierPresentFlag) + if(profileTierPresent) { parseConstraintInfo( &ptl->constraintInfo ); } @@ -3213,7 +3333,7 @@ void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, bool profileTi } } - if (profileTierPresentFlag) + if (profileTierPresent) { READ_CODE(8, symbol, "ptl_num_sub_profiles"); ptl->numSubProfile = symbol; @@ -3384,7 +3504,7 @@ void HLSyntaxReader::parsePredWeightTable( Slice* slice, const SPS *sps ) CHECK(uiTotalSignalledWeightFlags>24, "Too many weight flag signalled"); } -void HLSyntaxReader::parsePredWeightTable( PicHeader* picHeader, const SPS *sps ) +void HLSyntaxReader::parsePredWeightTable( PicHeader* picHeader, const PPS *pps, const SPS *sps ) { WPScalingParam *wp; const ChromaFormat chFmt = sps->chromaFormatIdc; @@ -3515,7 +3635,7 @@ void HLSyntaxReader::parsePredWeightTable( PicHeader* picHeader, const SPS *sps if (numRef == 0) { - if (picHeader->pRPL[1]->getNumRefEntries() > 0) + if (pps->weightedBiPred && picHeader->pRPL[1]->getNumRefEntries() > 0) { READ_UVLC(numLxWeights, "num_l1_weights"); } diff --git a/source/Lib/DecoderLib/VLCReader.h b/source/Lib/DecoderLib/VLCReader.h index decc2fd83..c67f6323a 100644 --- a/source/Lib/DecoderLib/VLCReader.h +++ b/source/Lib/DecoderLib/VLCReader.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file VLCWReader.h * \brief Reader for high level syntax */ @@ -147,14 +151,16 @@ class HLSyntaxReader : public VLCReader void parseVUI ( VUI* pcVUI, SPS* pcSPS ); void parseConstraintInfo ( ConstraintInfo *cinfo); - void parseProfileTierLevel ( ProfileTierLevel *ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1); + void parseProfileTierLevel ( ProfileTierLevel *ptl, bool profileTierPresent, int maxNumSubLayersMinus1); + void parseOlsHrdParameters ( GeneralHrdParams* generalHrd, OlsHrdParams *olsHrd, uint32_t firstSubLayer, uint32_t tempLevelHigh); + void parseGeneralHrdParameters ( GeneralHrdParams *generalHrd); void parsePictureHeader ( PicHeader* picHeader, ParameterSetManager *parameterSetManager, bool readRbspTrailingBits ); void parseSliceHeader ( Slice* slice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC ); void parseTerminatingBit ( uint32_t& ruiBit ); void parseRemainingBytes ( bool noTrailingBytesExpected ); void parsePredWeightTable ( Slice* pcSlice, const SPS *sps ); - void parsePredWeightTable ( PicHeader* picHeader, const SPS *sps ); + void parsePredWeightTable ( PicHeader* picHeader, const PPS *pps, const SPS *sps ); void parseExtraPHBitsStruct( SPS *sps, int numBytes ); void parseExtraSHBitsStruct( SPS *sps, int numBytes ); diff --git a/source/Lib/EncoderLib/Analyze.h b/source/Lib/EncoderLib/Analyze.h index d7467f08f..a7539b54a 100644 --- a/source/Lib/EncoderLib/Analyze.h +++ b/source/Lib/EncoderLib/Analyze.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file Analyze.h \brief encoder analyzer class (header) */ diff --git a/source/Lib/EncoderLib/BinEncoder.cpp b/source/Lib/EncoderLib/BinEncoder.cpp index 1f752fd5b..b53053570 100644 --- a/source/Lib/EncoderLib/BinEncoder.cpp +++ b/source/Lib/EncoderLib/BinEncoder.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ diff --git a/source/Lib/EncoderLib/BinEncoder.h b/source/Lib/EncoderLib/BinEncoder.h index 8f7d48b29..9e68c5d44 100644 --- a/source/Lib/EncoderLib/BinEncoder.h +++ b/source/Lib/EncoderLib/BinEncoder.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include "CommonLib/Contexts.h" diff --git a/source/Lib/EncoderLib/BitAllocation.cpp b/source/Lib/EncoderLib/BitAllocation.cpp index aa489ab60..13628ebc5 100644 --- a/source/Lib/EncoderLib/BitAllocation.cpp +++ b/source/Lib/EncoderLib/BitAllocation.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file BitAllocation.cpp @@ -335,8 +339,8 @@ int BitAllocation::applyQPAdaptationChroma (const Slice* slice, const EncCfg* en if (pic == nullptr || encCfg == nullptr || optChromaQPOffset == nullptr || encCfg->m_usePerceptQPA > 4) return -1; - const bool isXPSNRBasedQPA = (encCfg->m_usePerceptQPA & 1) == 0; - const bool isHighResolution = (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && isXPSNRBasedQPA; + const bool isXPSNRBasedQPA = (encCfg->m_usePerceptQPA & 1) == 0 && encCfg->m_RCNumPasses != 2; + const bool isHighResolution = (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && ( encCfg->m_usePerceptQPA & 1 ) == 0; const int bitDepth = slice->sps->bitDepths[CH_L]; optChromaQPOffset[0] = optChromaQPOffset[1] = 0; @@ -359,7 +363,7 @@ int BitAllocation::applyQPAdaptationChroma (const Slice* slice, const EncCfg* en { int averageAdaptedLumaQP = ((encCfg->m_RCRateControlMode > 0) && (encCfg->m_RCRateControlMode < 3) ? Clip3 (0, MAX_QP, sliceQP) : Clip3 (0, MAX_QP, sliceQP + apprI3Log2 (hpEner[0] / getAveragePictureActivity (encCfg->m_SourceWidth, encCfg->m_SourceHeight, - ctuPumpRedQP.back(), + encCfg->m_RCNumPasses == 2 ? 0 : ctuPumpRedQP.back(), (encCfg->m_usePerceptQPATempFiltISlice || !slice->isIntra()) && isXPSNRBasedQPA, bitDepth)))); if (isChromaEnabled (pic->chromaFormat) && (averageAdaptedLumaQP < MAX_QP)) { @@ -378,7 +382,9 @@ int BitAllocation::applyQPAdaptationChroma (const Slice* slice, const EncCfg* en savedLumaQP = averageAdaptedLumaQP; } // savedLumaQP < 0 + GCC_WARNING_DISABLE_maybe_uninitialized // probably spurious warning, when building with -fsanitize=undefined: "error: ‘encCfg.33’ may be used uninitialized in this function" const int lumaChromaMappingDQP = (savedLumaQP - slice->sps->chromaQpMappingTable.getMappedChromaQpValue (compID, savedLumaQP)) >> (encCfg->m_QP >= MAX_QP_PERCEPT_QPA ? 1 : 0); + GCC_WARNING_RESET optChromaQPOffset[comp-1] = std::min (3 + lumaChromaMappingDQP, adaptChromaQPOffset + lumaChromaMappingDQP); } // isChroma (compID) @@ -397,8 +403,8 @@ int BitAllocation::applyQPAdaptationLuma (const Slice* slice, const EncCfg* encC if (pic == nullptr || pic->cs == nullptr || encCfg == nullptr || ctuStartAddr >= ctuBoundingAddr) return -1; - const bool isXPSNRBasedQPA = (encCfg->m_usePerceptQPA & 1) == 0; - const bool isHighResolution = (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && isXPSNRBasedQPA; + const bool isXPSNRBasedQPA = (encCfg->m_usePerceptQPA & 1) == 0 && encCfg->m_RCNumPasses != 2; + const bool isHighResolution = (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && ( encCfg->m_usePerceptQPA & 1 ) == 0; const bool useFrameWiseQPA = (encCfg->m_QP > MAX_QP_PERCEPT_QPA); const int bitDepth = slice->sps->bitDepths[CH_L]; const int sliceQP = (savedQP < 0 ? slice->sliceQp : savedQP); @@ -436,7 +442,7 @@ int BitAllocation::applyQPAdaptationLuma (const Slice* slice, const EncCfg* encC } else { - hpEnerPic = 1.0 / getAveragePictureActivity (encCfg->m_SourceWidth, encCfg->m_SourceHeight, ctuPumpRedQP.back(), + hpEnerPic = 1.0 / getAveragePictureActivity (encCfg->m_SourceWidth, encCfg->m_SourceHeight, encCfg->m_RCNumPasses == 2 ? 0 : ctuPumpRedQP.back(), (encCfg->m_usePerceptQPATempFiltISlice || !slice->isIntra()) && isXPSNRBasedQPA, bitDepth); } @@ -582,8 +588,8 @@ int BitAllocation::applyQPAdaptationSubCtu (const Slice* slice, const EncCfg* en if (pic == nullptr || encCfg == nullptr) return -1; - const bool isXPSNRBasedQPA = (encCfg->m_usePerceptQPA & 1) == 0; - const bool isHighResolution = (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && isXPSNRBasedQPA; + const bool isXPSNRBasedQPA = (encCfg->m_usePerceptQPA & 1) == 0 && encCfg->m_RCNumPasses != 2; + const bool isHighResolution = (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && ( encCfg->m_usePerceptQPA & 1 ) == 0; const int bitDepth = slice->sps->bitDepths[CH_L]; const PosType guardSize = (isHighResolution ? 2 : 1); const Position pos = lumaArea.pos(); @@ -658,14 +664,15 @@ double BitAllocation::getPicVisualActivity (const Slice* slice, const EncCfg* en if (pic == nullptr || encCfg == nullptr) return 0.0; - const bool isXPSNRQPA = (encCfg->m_usePerceptQPA & 1) == 0; + const bool isXPSNRQPA = (encCfg->m_usePerceptQPA & 1) == 0 && encCfg->m_RCNumPasses != 2; + const bool isHighRes = ( encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280 ) && ( encCfg->m_usePerceptQPA & 1 ) == 0; const CPelBuf picOrig = (origBuf != nullptr ? *origBuf : pic->getOrigBuf (COMP_Y)); const CPelBuf picPrv1 = (isXPSNRQPA ? pic->getOrigBufPrev (COMP_Y, false) : picOrig); const CPelBuf picPrv2 = pic->getOrigBufPrev (COMP_Y, true ); return filterAndCalculateAverageActivity (picOrig.buf, picOrig.stride, picOrig.height, picOrig.width, picPrv1.buf, picPrv1.stride, (isXPSNRQPA ? picPrv2.buf : nullptr), picPrv2.stride, encCfg->m_FrameRate, - slice->sps->bitDepths[CH_L], (encCfg->m_SourceWidth > 2048 || encCfg->m_SourceHeight > 1280) && isXPSNRQPA); + slice->sps->bitDepths[CH_L], isHighRes); } } // namespace vvenc diff --git a/source/Lib/EncoderLib/BitAllocation.h b/source/Lib/EncoderLib/BitAllocation.h index c44e5dd3d..e382230b3 100644 --- a/source/Lib/EncoderLib/BitAllocation.h +++ b/source/Lib/EncoderLib/BitAllocation.h @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file BitAllocation.h \brief Bit allocation class for QP adaptation and, possibly, rate control (header) */ #pragma once -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CommonLib/Slice.h" #include "CommonLib/Unit.h" diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 35096d363..830751ce1 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file CABACWriter.cpp @@ -636,7 +640,7 @@ void CABACWriter::split_cu_mode( const PartSplit split, const CodingStructure& c // void cu_pred_data ( pus ) // void cu_lic_flag ( cu ) // void intra_luma_pred_modes ( pus ) -// void intra_chroma_pred_mode ( pu ) +// void intra_chroma_pred_mode ( cu ) // void cu_residual ( cu, partitioner, cuCtx ) // void rqt_root_cbf ( cu ) // void end_of_ctu ( cu, cuCtx ) @@ -659,8 +663,8 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C // skip data if( cu.skip ) { - CHECK( !cu.pu->mergeFlag, "Merge flag has to be on!" ); - prediction_unit ( *cu.pu ); + CHECK( !cu.mergeFlag, "Merge flag has to be on!" ); + prediction_unit ( cu ); CHECK(cu.colorTransform, "ACT should not be enabled for skip mode"); end_of_ctu ( cu, cuCtx ); return; @@ -677,8 +681,6 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C THROW("no support"); return; } - if (!CS::isDualITree(cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat)) - bdpcm_mode(cu, ComponentID(CH_C)); // prediction data ( intra prediction modes / reference indexes + motion vectors ) cu_pred_data( cu ); @@ -695,7 +697,7 @@ void CABACWriter::cu_skip_flag( const CodingUnit& cu ) { unsigned ctxId = DeriveCtx::CtxSkipFlag(); - if ((cu.slice->isIntra() || cu.isConsIntra()) && cu.cs->slice->sps->IBC) + if ((cu.slice->isIntra() || CU::isConsIntra(cu)) && cu.cs->slice->sps->IBC) { if (cu.lwidth() < 128 && cu.lheight() < 128) // disable IBC mode larger than 64x64 { @@ -708,7 +710,7 @@ void CABACWriter::cu_skip_flag( const CodingUnit& cu ) { return; } - if( !cu.cs->slice->sps->IBC && cu.isConsIntra() ) + if( !cu.cs->slice->sps->IBC && CU::isConsIntra(cu) ) { return; } @@ -717,7 +719,7 @@ void CABACWriter::cu_skip_flag( const CodingUnit& cu ) DTRACE( g_trace_ctx, D_SYNTAX, "cu_skip_flag() ctx=%d skip=%d\n", ctxId, cu.skip ? 1 : 0 ); if (cu.skip && cu.cs->slice->sps->IBC) { - if (cu.lwidth() < 128 && cu.lheight() < 128 && !cu.isConsInter()) // disable IBC mode larger than 64x64 and disable IBC when only allowing inter mode + if (cu.lwidth() < 128 && cu.lheight() < 128 && !CU::isConsInter(cu)) // disable IBC mode larger than 64x64 and disable IBC when only allowing inter mode { if ( cu.lwidth() == 4 && cu.lheight() == 4 ) { @@ -735,13 +737,13 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) { if (cu.cs->slice->sps->IBC && cu.chType != CH_C) { - if( cu.isConsInter() ) + if( CU::isConsInter(cu) ) { assert( CU::isInter( cu ) ); return; } - if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || cu.isConsIntra() ) + if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || CU::isConsIntra(cu) ) { if (cu.lwidth() < 128 && cu.lheight() < 128) // disable IBC mode larger than 64x64 { @@ -755,7 +757,7 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) } else { - if( cu.isConsInter() ) + if( CU::isConsInter(cu) ) { return; } @@ -779,22 +781,22 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) } else { - if( cu.isConsInter() ) + if( CU::isConsInter(cu) ) { assert( CU::isInter( cu ) ); return; } - if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || cu.isConsIntra() ) + if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || CU::isConsIntra(cu) ) { - if (cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) + if (cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!CU::isLocalSepTree(cu) || isLuma(cu.chType) ) ) { m_BinEncoder.encodeBin((CU::isPLT(cu)), Ctx::PLTFlag(0)); } return; } m_BinEncoder.encodeBin((CU::isIntra(cu) || CU::isPLT(cu)), Ctx::PredMode(DeriveCtx::CtxPredModeFlag())); - if ((CU::isIntra(cu) || CU::isPLT(cu)) && cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64&& ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) + if ((CU::isIntra(cu) || CU::isPLT(cu)) && cu.cs->slice->sps->PLT && cu.lwidth() <= 64 && cu.lheight() <= 64&& ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!CU::isLocalSepTree(cu) || isLuma(cu.chType) ) ) { m_BinEncoder.encodeBin((CU::isPLT(cu)), Ctx::PLTFlag(0)); } @@ -807,7 +809,7 @@ void CABACWriter::bdpcm_mode( const CodingUnit& cu, const ComponentID compID ) if( !cu.cs->sps->BDPCM) return; if( !CU::bdpcmAllowed( cu, compID ) ) return; - int bdpcmMode = isLuma(compID) ? cu.bdpcmMode : cu.bdpcmModeChroma; + int bdpcmMode = cu.bdpcmM[toChannelType(compID)]; unsigned ctxId = isLuma(compID) ? 0 : 2; m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(ctxId)); @@ -817,11 +819,11 @@ void CABACWriter::bdpcm_mode( const CodingUnit& cu, const ComponentID compID ) } if (isLuma(compID)) { - DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_L, cu.lumaPos().x, cu.lumaPos().y, cu.lwidth(), cu.lheight(), cu.bdpcmMode); + DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_L, cu.lumaPos().x, cu.lumaPos().y, cu.lwidth(), cu.lheight(), cu.bdpcmM[CH_L]); } else { - DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_C, cu.chromaPos().x, cu.chromaPos().y, cu.chromaSize().width, cu.chromaSize().height, cu.bdpcmModeChroma); + DTRACE(g_trace_ctx, D_SYNTAX, "bdpcm_mode(%d) x=%d, y=%d, w=%d, h=%d, bdpcm=%d\n", CH_C, cu.chromaPos().x, cu.chromaPos().y, cu.chromaSize().width, cu.chromaSize().height, cu.bdpcmM[CH_C]); } } @@ -835,7 +837,7 @@ void CABACWriter::cu_pred_data( const CodingUnit& cu ) bdpcm_mode( cu, COMP_Y ); } intra_luma_pred_modes ( cu ); - if( ( !cu.Y().valid() || ( !cu.isSepTree() && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) ) + if( ( !cu.Y().valid() || ( !CU::isSepTree(cu) && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) ) { bdpcm_mode( cu, ComponentID(CH_C) ); } @@ -847,7 +849,7 @@ void CABACWriter::cu_pred_data( const CodingUnit& cu ) return; } - prediction_unit ( *cu.pu ); + prediction_unit ( cu ); imv_mode ( cu ); affine_amvr_mode( cu ); cu_bcw_flag ( cu ); @@ -932,37 +934,9 @@ void CABACWriter::xWriteTruncBinCode(uint32_t symbol, uint32_t maxSymbol) } -void CABACWriter::extend_ref_line(const PredictionUnit& pu) -{ - const CodingUnit& cu = *pu.cu; - if( !cu.Y().valid() || cu.predMode != MODE_INTRA || !isLuma( cu.chType ) || cu.bdpcmMode ) - { - return; - } if( !cu.cs->sps->MRL ) - { - return; - } - - bool isFirstLineOfCtu = (((cu.block(COMP_Y).y)&((cu.cs->sps)->CTUSize - 1)) == 0); - if (isFirstLineOfCtu) - { - return; - } - int multiRefIdx = pu.multiRefIdx; - if (MRL_NUM_REF_LINES > 1) - { - m_BinEncoder.encodeBin(multiRefIdx != MULTI_REF_LINE_IDX[0], Ctx::MultiRefLineIdx(0)); - if (MRL_NUM_REF_LINES > 2 && multiRefIdx != MULTI_REF_LINE_IDX[0]) - { - m_BinEncoder.encodeBin(multiRefIdx != MULTI_REF_LINE_IDX[1], Ctx::MultiRefLineIdx(1)); - } - } -} - - void CABACWriter::extend_ref_line(const CodingUnit& cu) { - if ( !cu.Y().valid() || cu.predMode != MODE_INTRA || !isLuma(cu.chType) || cu.bdpcmMode ) + if ( !cu.Y().valid() || cu.predMode != MODE_INTRA || !isLuma(cu.chType) || cu.bdpcmM[CH_L] ) { return; } @@ -976,7 +950,7 @@ void CABACWriter::extend_ref_line(const CodingUnit& cu) { return; } - int multiRefIdx = cu.pu->multiRefIdx; + int multiRefIdx = cu.multiRefIdx; if (MRL_NUM_REF_LINES > 1) { m_BinEncoder.encodeBin(multiRefIdx != MULTI_REF_LINE_IDX[0], Ctx::MultiRefLineIdx(0)); @@ -984,24 +958,17 @@ void CABACWriter::extend_ref_line(const CodingUnit& cu) { m_BinEncoder.encodeBin(multiRefIdx != MULTI_REF_LINE_IDX[1], Ctx::MultiRefLineIdx(1)); } - } } void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) { - if( !cu.Y().valid() ) + if( !cu.Y().valid() || cu.bdpcmM[CH_L] ) { return; } - if( cu.bdpcmMode ) - { - cu.pu->intraDir[0] = cu.bdpcmMode == 2? VER_IDX : HOR_IDX; - return; - } - mip_flag(cu); if (cu.mipFlag) { @@ -1017,13 +984,11 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) unsigned mpm_idx; unsigned ipred_mode ; - const PredictionUnit* pu = cu.pu; - // prev_intra_luma_pred_flag { - PU::getIntraMPMs( *pu, mpm_pred ); + CU::getIntraMPMs( cu, mpm_pred ); - ipred_mode = pu->intraDir[0]; + ipred_mode = cu.intraDir[0]; mpm_idx = numMPMs; for( unsigned idx = 0; idx < numMPMs; idx++ ) { @@ -1033,7 +998,7 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) break; } } - if ( pu->multiRefIdx ) + if ( cu.multiRefIdx ) { CHECK(mpm_idx >= numMPMs, "use of non-MPM"); } @@ -1048,8 +1013,8 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) if( mpm_idx < numMPMs ) { { - unsigned ctx = (pu->cu->ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0); - if (pu->multiRefIdx == 0) + unsigned ctx = (cu.ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0); + if (cu.multiRefIdx == 0) m_BinEncoder.encodeBin(mpm_idx > 0, Ctx::IntraLumaPlanarFlag(ctx)); if( mpm_idx ) { @@ -1087,43 +1052,52 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) } } - DTRACE( g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", 0, pu->lumaPos().x, pu->lumaPos().y, pu->intraDir[0] ); + DTRACE( g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", 0, cu.lumaPos().x, cu.lumaPos().y, cu.intraDir[0] ); } } -void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu ) +void CABACWriter::intra_luma_pred_mode( const CodingUnit& cu, const unsigned *mpmLst ) { + if( cu.bdpcmM[CH_L] ) + { + return; + } - if( pu.cu->bdpcmMode ) return; - mip_flag(*pu.cu); - if (pu.cu->mipFlag) + mip_flag(cu); + if (cu.mipFlag) { - mip_pred_mode(pu); + mip_pred_mode(cu); return; } - extend_ref_line( pu ); + extend_ref_line( cu ); - isp_mode( *pu.cu ); + isp_mode( cu ); // prev_intra_luma_pred_flag - const int numMPMs = NUM_MOST_PROBABLE_MODES; + unsigned ipred_mode = cu.intraDir[0]; + static constexpr int numMPMs = NUM_MOST_PROBABLE_MODES; + unsigned mpm_idx = numMPMs; unsigned mpm_pred[numMPMs]; - PU::getIntraMPMs( pu, mpm_pred ); - - unsigned ipred_mode = pu.intraDir[0]; - unsigned mpm_idx = numMPMs; + if (mpmLst) + { + memcpy(mpm_pred, mpmLst, sizeof(unsigned) * numMPMs); + } + else + { + CU::getIntraMPMs(cu, mpm_pred); + } - for( int idx = 0; idx < numMPMs; idx++ ) + for (int idx = 0; idx < numMPMs; idx++) { - if( ipred_mode == mpm_pred[idx] ) + if (ipred_mode == mpm_pred[idx]) { mpm_idx = idx; break; } } - if ( pu.multiRefIdx ) + if (cu.multiRefIdx) { CHECK(mpm_idx >= numMPMs, "use of non-MPM"); } @@ -1135,66 +1109,60 @@ void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu ) // mpm_idx / rem_intra_luma_pred_mode if( mpm_idx < numMPMs ) { + unsigned ctx = (cu.ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0); + if (cu.multiRefIdx == 0) + m_BinEncoder.encodeBin( mpm_idx > 0, Ctx::IntraLumaPlanarFlag(ctx) ); + if( mpm_idx ) { - unsigned ctx = (pu.cu->ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0); - if (pu.multiRefIdx == 0) - m_BinEncoder.encodeBin( mpm_idx > 0, Ctx::IntraLumaPlanarFlag(ctx) ); - if( mpm_idx ) - { - m_BinEncoder.encodeBinEP( mpm_idx > 1 ); - } - if (mpm_idx > 1) - { - m_BinEncoder.encodeBinEP(mpm_idx > 2); - } - if (mpm_idx > 2) - { - m_BinEncoder.encodeBinEP(mpm_idx > 3); - } - if (mpm_idx > 3) - { - m_BinEncoder.encodeBinEP(mpm_idx > 4); - } + m_BinEncoder.encodeBinEP( mpm_idx > 1 ); + } + if (mpm_idx > 1) + { + m_BinEncoder.encodeBinEP(mpm_idx > 2); + } + if (mpm_idx > 2) + { + m_BinEncoder.encodeBinEP(mpm_idx > 3); + } + if (mpm_idx > 3) + { + m_BinEncoder.encodeBinEP(mpm_idx > 4); } } else { - std::sort( mpm_pred, mpm_pred + numMPMs ); + // mpm_pred[0] is always 0, i.e. PLANAR, so its always first in the list + std::sort( mpm_pred + 1, mpm_pred + numMPMs ); + + for (int idx = numMPMs - 1; idx >= 0; idx--) { - for (int idx = numMPMs - 1; idx >= 0; idx--) + if (ipred_mode > mpm_pred[idx]) { - if (ipred_mode > mpm_pred[idx]) - { - ipred_mode--; - } + ipred_mode--; } - xWriteTruncBinCode(ipred_mode, NUM_LUMA_MODE - NUM_MOST_PROBABLE_MODES); // Remaining mode is truncated binary coded } + + xWriteTruncBinCode(ipred_mode, NUM_LUMA_MODE - NUM_MOST_PROBABLE_MODES); // Remaining mode is truncated binary coded } } void CABACWriter::intra_chroma_pred_modes( const CodingUnit& cu ) { - if( cu.chromaFormat == CHROMA_400 || ( cu.isSepTree() && cu.chType == CH_L ) ) + if( cu.chromaFormat == CHROMA_400 || ( CU::isSepTree(cu) && cu.chType == CH_L ) || cu.bdpcmM[CH_C] ) { return; } - if( cu.bdpcmModeChroma ) - { - cu.pu->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX; - return; - } - intra_chroma_pred_mode( *cu.pu ); + intra_chroma_pred_mode( cu ); } -void CABACWriter::intra_chroma_lmc_mode(const PredictionUnit& pu) +void CABACWriter::intra_chroma_lmc_mode(const CodingUnit& cu) { - const unsigned intraDir = pu.intraDir[1]; + const unsigned intraDir = cu.intraDir[1]; int lmModeList[10]; - PU::getLMSymbolList(pu, lmModeList); + CU::getLMSymbolList(cu, lmModeList); int symbol = -1; for (int k = 0; k < LM_SYMBOL_NUM; k++) { @@ -1217,21 +1185,21 @@ void CABACWriter::intra_chroma_lmc_mode(const PredictionUnit& pu) } -void CABACWriter::intra_chroma_pred_mode(const PredictionUnit& pu) +void CABACWriter::intra_chroma_pred_mode(const CodingUnit& cu) { - if (pu.cu->colorTransform) + if (cu.colorTransform) { - CHECK(pu.intraDir[CH_C] != DM_CHROMA_IDX, "chroma should use DM for adaptive color transform"); + CHECK(cu.intraDir[CH_C] != DM_CHROMA_IDX, "chroma should use DM for adaptive color transform"); return; } - const unsigned intraDir = pu.intraDir[1]; - if (pu.cs->sps->LMChroma && pu.cu->checkCCLMAllowed()) + const unsigned intraDir = cu.intraDir[1]; + if (cu.cs->sps->LMChroma && CU::checkCCLMAllowed(cu)) { - m_BinEncoder.encodeBin(PU::isLMCMode(intraDir) ? 1 : 0, Ctx::CclmModeFlag(0)); - if (PU::isLMCMode(intraDir)) + m_BinEncoder.encodeBin(CU::isLMCMode(intraDir) ? 1 : 0, Ctx::CclmModeFlag(0)); + if (CU::isLMCMode(intraDir)) { - intra_chroma_lmc_mode(pu); + intra_chroma_lmc_mode(cu); return; } } @@ -1245,7 +1213,7 @@ void CABACWriter::intra_chroma_pred_mode(const PredictionUnit& pu) // chroma candidate index unsigned chromaCandModes[NUM_CHROMA_MODE]; - PU::getIntraChromaCandModes(pu, chromaCandModes); + CU::getIntraChromaCandModes(cu, chromaCandModes); int candId = 0; for (; candId < NUM_CHROMA_MODE; candId++) @@ -1268,8 +1236,7 @@ void CABACWriter::cu_residual( const CodingUnit& cu, Partitioner& partitioner, C { if (!CU::isIntra(cu)) { - PredictionUnit& pu = *cu.pu; - if( !pu.mergeFlag ) + if( !cu.mergeFlag ) { rqt_root_cbf( cu ); } @@ -1325,7 +1292,7 @@ void CABACWriter::adaptive_color_transform(const CodingUnit& cu) return; } - if (cu.isSepTree()) + if (CU::isSepTree(cu)) { CHECK(cu.colorTransform, "adaptive color transform should be disabled when dualtree and localtree are enabled"); return; @@ -1340,7 +1307,7 @@ void CABACWriter::adaptive_color_transform(const CodingUnit& cu) void CABACWriter::sbt_mode( const CodingUnit& cu ) { - uint8_t sbtAllowed = cu.checkAllowedSbt(); + uint8_t sbtAllowed = CU::checkAllowedSbt(cu); if( !sbtAllowed ) { return; @@ -1401,7 +1368,7 @@ void CABACWriter::end_of_ctu( const CodingUnit& cu, CUCtx& cuCtx ) const bool isLastSubCUOfCtu = CU::isLastSubCUOfCtu( cu ); if ( isLastSubCUOfCtu - && ( !cu.isSepTree() || cu.chromaFormat == CHROMA_400 || isChroma( cu.chType ) ) + && ( !CU::isSepTree(cu) || cu.chromaFormat == CHROMA_400 || isChroma( cu.chType ) ) ) { cuCtx.isDQPCoded = ( cu.cs->pps->useDQP && !cuCtx.isDQPCoded ); @@ -1419,124 +1386,124 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u //================================================================================ // clause 7.3.8.6 //-------------------------------------------------------------------------------- -// void prediction_unit ( pu ); -// void merge_flag ( pu ); -// void merge_idx ( pu ); -// void inter_pred_idc ( pu ); -// void ref_idx ( pu, refList ); -// void mvp_flag ( pu, refList ); +// void prediction_unit ( cu ); +// void merge_flag ( cu ); +// void merge_idx ( cu ); +// void inter_pred_idc ( cu ); +// void ref_idx ( cu, refList ); +// void mvp_flag ( cu, refList ); //================================================================================ -void CABACWriter::prediction_unit( const PredictionUnit& pu ) +void CABACWriter::prediction_unit( const CodingUnit& cu ) { - CHECK( pu.cu->treeType == TREE_C, "cannot be chroma CU" ); - if( pu.cu->skip ) + CHECK( cu.treeType == TREE_C, "cannot be chroma CU" ); + if( cu.skip ) { - CHECK( !pu.mergeFlag, "merge_flag must be true for skipped CUs" ); + CHECK( !cu.mergeFlag, "merge_flag must be true for skipped CUs" ); } else { - merge_flag( pu ); + merge_flag( cu ); } - if( pu.mergeFlag ) + if( cu.mergeFlag ) { - merge_data(pu); + merge_data(cu); } - else if (CU::isIBC(*pu.cu)) + else if (CU::isIBC(cu)) { - ref_idx(pu, REF_PIC_LIST_0); - Mv mvd = pu.mvd[REF_PIC_LIST_0]; - mvd.changeIbcPrecInternal2Amvr(pu.cu->imv); + ref_idx(cu, REF_PIC_LIST_0); + Mv mvd = cu.mvd[REF_PIC_LIST_0]; + mvd.changeIbcPrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision - if ( pu.cu->slice->sps->maxNumIBCMergeCand == 1 ) + if ( cu.slice->sps->maxNumIBCMergeCand == 1 ) { - CHECK( pu.mvpIdx[REF_PIC_LIST_0], "mvpIdx for IBC mode should be 0" ); + CHECK( cu.mvpIdx[REF_PIC_LIST_0], "mvpIdx for IBC mode should be 0" ); } else - mvp_flag(pu, REF_PIC_LIST_0); + mvp_flag(cu, REF_PIC_LIST_0); } else { - inter_pred_idc( pu ); - affine_flag ( *pu.cu ); - smvd_mode( pu ); - if( pu.interDir != 2 /* PRED_L1 */ ) + inter_pred_idc( cu ); + affine_flag ( cu ); + smvd_mode( cu ); + if( cu.interDir != 2 /* PRED_L1 */ ) { - ref_idx ( pu, REF_PIC_LIST_0 ); - if ( pu.cu->affine ) + ref_idx ( cu, REF_PIC_LIST_0 ); + if ( cu.affine ) { - Mv mvd = pu.mvdAffi[REF_PIC_LIST_0][0]; - mvd.changeAffinePrecInternal2Amvr(pu.cu->imv); + Mv mvd = cu.mvdAffi[REF_PIC_LIST_0][0]; + mvd.changeAffinePrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision - mvd = pu.mvdAffi[REF_PIC_LIST_0][1]; - mvd.changeAffinePrecInternal2Amvr(pu.cu->imv); + mvd = cu.mvdAffi[REF_PIC_LIST_0][1]; + mvd.changeAffinePrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision - if ( pu.cu->affineType == AFFINEMODEL_6PARAM ) + if ( cu.affineType == AFFINEMODEL_6PARAM ) { - mvd = pu.mvdAffi[REF_PIC_LIST_0][2]; - mvd.changeAffinePrecInternal2Amvr(pu.cu->imv); + mvd = cu.mvdAffi[REF_PIC_LIST_0][2]; + mvd.changeAffinePrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision } } else { - Mv mvd = pu.mvd[REF_PIC_LIST_0]; - mvd.changeTransPrecInternal2Amvr(pu.cu->imv); + Mv mvd = cu.mvd[REF_PIC_LIST_0]; + mvd.changeTransPrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision } - mvp_flag ( pu, REF_PIC_LIST_0 ); + mvp_flag ( cu, REF_PIC_LIST_0 ); } - if( pu.interDir != 1 /* PRED_L0 */ ) + if( cu.interDir != 1 /* PRED_L0 */ ) { - if ( pu.cu->smvdMode != 1 ) + if ( cu.smvdMode != 1 ) { - ref_idx ( pu, REF_PIC_LIST_1 ); - if( !pu.cs->picHeader->mvdL1Zero || pu.interDir != 3 /* PRED_BI */ ) + ref_idx ( cu, REF_PIC_LIST_1 ); + if( !cu.cs->picHeader->mvdL1Zero || cu.interDir != 3 /* PRED_BI */ ) { - if ( pu.cu->affine ) + if ( cu.affine ) { - Mv mvd = pu.mvdAffi[REF_PIC_LIST_1][0]; - mvd.changeAffinePrecInternal2Amvr(pu.cu->imv); + Mv mvd = cu.mvdAffi[REF_PIC_LIST_1][0]; + mvd.changeAffinePrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision - mvd = pu.mvdAffi[REF_PIC_LIST_1][1]; - mvd.changeAffinePrecInternal2Amvr(pu.cu->imv); + mvd = cu.mvdAffi[REF_PIC_LIST_1][1]; + mvd.changeAffinePrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision - if ( pu.cu->affineType == AFFINEMODEL_6PARAM ) + if ( cu.affineType == AFFINEMODEL_6PARAM ) { - mvd = pu.mvdAffi[REF_PIC_LIST_1][2]; - mvd.changeAffinePrecInternal2Amvr(pu.cu->imv); + mvd = cu.mvdAffi[REF_PIC_LIST_1][2]; + mvd.changeAffinePrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision } } else { - Mv mvd = pu.mvd[REF_PIC_LIST_1]; - mvd.changeTransPrecInternal2Amvr(pu.cu->imv); + Mv mvd = cu.mvd[REF_PIC_LIST_1]; + mvd.changeTransPrecInternal2Amvr(cu.imv); mvd_coding(mvd, 0); // already changed to signaling precision } } } - mvp_flag ( pu, REF_PIC_LIST_1 ); + mvp_flag ( cu, REF_PIC_LIST_1 ); } } } -void CABACWriter::smvd_mode( const PredictionUnit& pu ) +void CABACWriter::smvd_mode( const CodingUnit& cu ) { - if ( pu.interDir != 3 || pu.cu->affine ) + if ( cu.interDir != 3 || cu.affine ) { return; } - if ( pu.cs->slice->biDirPred == false ) + if ( cu.cs->slice->biDirPred == false ) { return; } - m_BinEncoder.encodeBin( pu.cu->smvdMode ? 1 : 0, Ctx::SmvdFlag() ); + m_BinEncoder.encodeBin( cu.smvdMode ? 1 : 0, Ctx::SmvdFlag() ); - DTRACE( g_trace_ctx, D_SYNTAX, "symmvd_flag() symmvd=%d pos=(%d,%d) size=%dx%d\n", pu.cu->smvdMode ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height ); + DTRACE( g_trace_ctx, D_SYNTAX, "symmvd_flag() symmvd=%d pos=(%d,%d) size=%dx%d\n", cu.smvdMode ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height ); } @@ -1570,60 +1537,60 @@ void CABACWriter::affine_flag( const CodingUnit& cu ) } -void CABACWriter::merge_flag( const PredictionUnit& pu ) +void CABACWriter::merge_flag( const CodingUnit& cu ) { - m_BinEncoder.encodeBin( pu.mergeFlag, Ctx::MergeFlag() ); + m_BinEncoder.encodeBin( cu.mergeFlag, Ctx::MergeFlag() ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_flag() merge=%d pos=(%d,%d) size=%dx%d\n", pu.mergeFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height ); + DTRACE( g_trace_ctx, D_SYNTAX, "merge_flag() merge=%d pos=(%d,%d) size=%dx%d\n", cu.mergeFlag ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height ); } -void CABACWriter::merge_data(const PredictionUnit& pu) +void CABACWriter::merge_data(const CodingUnit& cu) { - if (CU::isIBC(*pu.cu)) + if (CU::isIBC(cu)) { - merge_idx(pu); + merge_idx(cu); return; } - subblock_merge_flag(*pu.cu); - if (pu.cu->affine) + subblock_merge_flag(cu); + if (cu.affine) { - merge_idx(pu); + merge_idx(cu); return; } - const bool ciipAvailable = pu.cs->sps->CIIP && !pu.cu->skip && pu.cu->lwidth() < MAX_CU_SIZE && pu.cu->lheight() < MAX_CU_SIZE && pu.cu->lwidth() * pu.cu->lheight() >= 64; - const bool geoAvailable = pu.cu->cs->slice->sps->GEO && pu.cu->cs->slice->isInterB() && pu.cu->cs->sps->maxNumGeoCand > 1 - && pu.cu->lwidth() >= GEO_MIN_CU_SIZE && pu.cu->lheight() >= GEO_MIN_CU_SIZE - && pu.cu->lwidth() <= GEO_MAX_CU_SIZE && pu.cu->lheight() <= GEO_MAX_CU_SIZE - && pu.cu->lwidth() < 8 * pu.cu->lheight() && pu.cu->lheight() < 8 * pu.cu->lwidth(); + const bool ciipAvailable = cu.cs->sps->CIIP && !cu.skip && cu.lwidth() < MAX_CU_SIZE && cu.lheight() < MAX_CU_SIZE && cu.lwidth() * cu.lheight() >= 64; + const bool geoAvailable = cu.cs->slice->sps->GEO && cu.cs->slice->isInterB() && cu.cs->sps->maxNumGeoCand > 1 + && cu.lwidth() >= GEO_MIN_CU_SIZE && cu.lheight() >= GEO_MIN_CU_SIZE + && cu.lwidth() <= GEO_MAX_CU_SIZE && cu.lheight() <= GEO_MAX_CU_SIZE + && cu.lwidth() < 8 * cu.lheight() && cu.lheight() < 8 * cu.lwidth(); if (geoAvailable || ciipAvailable) { - m_BinEncoder.encodeBin(pu.regularMergeFlag, Ctx::RegularMergeFlag(pu.cu->skip ? 0 : 1)); + m_BinEncoder.encodeBin(cu.regularMergeFlag, Ctx::RegularMergeFlag(cu.skip ? 0 : 1)); } - if (pu.regularMergeFlag) + if (cu.regularMergeFlag) { - if (pu.cs->sps->MMVD) + if (cu.cs->sps->MMVD) { - m_BinEncoder.encodeBin(pu.mmvdMergeFlag, Ctx::MmvdFlag(0)); - DTRACE(g_trace_ctx, D_SYNTAX, "mmvd_merge_flag() mmvd_merge=%d pos=(%d,%d) size=%dx%d\n", pu.mmvdMergeFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height); + m_BinEncoder.encodeBin(cu.mmvdMergeFlag, Ctx::MmvdFlag(0)); + DTRACE(g_trace_ctx, D_SYNTAX, "mmvd_merge_flag() mmvd_merge=%d pos=(%d,%d) size=%dx%d\n", cu.mmvdMergeFlag ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height); } - if (pu.mmvdMergeFlag || pu.cu->mmvdSkip) + if (cu.mmvdMergeFlag || cu.mmvdSkip) { - mmvd_merge_idx(pu); + mmvd_merge_idx(cu); } else { - merge_idx(pu); + merge_idx(cu); } } else { if (geoAvailable && ciipAvailable) { - ciip_flag(pu); + ciip_flag(cu); } - merge_idx(pu); + merge_idx(cu); } } @@ -1695,17 +1662,17 @@ void CABACWriter::affine_amvr_mode( const CodingUnit& cu ) } -void CABACWriter::merge_idx( const PredictionUnit& pu ) +void CABACWriter::merge_idx( const CodingUnit& cu ) { - if ( pu.cu->affine ) + if ( cu.affine ) { - int numCandminus1 = int( pu.cs->picHeader->maxNumAffineMergeCand ) - 1; + int numCandminus1 = int( cu.cs->picHeader->maxNumAffineMergeCand ) - 1; if ( numCandminus1 > 0 ) { - if ( pu.mergeIdx == 0 ) + if ( cu.mergeIdx == 0 ) { m_BinEncoder.encodeBin( 0, Ctx::AffMergeIdx() ); - DTRACE( g_trace_ctx, D_SYNTAX, "aff_merge_idx() aff_merge_idx=%d\n", pu.mergeIdx ); + DTRACE( g_trace_ctx, D_SYNTAX, "aff_merge_idx() aff_merge_idx=%d\n", cu.mergeIdx ); return; } else @@ -1713,29 +1680,29 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) m_BinEncoder.encodeBin( 1, Ctx::AffMergeIdx() ); for ( unsigned idx = 1; idx < numCandminus1; idx++ ) { - m_BinEncoder.encodeBinEP( pu.mergeIdx == idx ? 0 : 1 ); - if ( pu.mergeIdx == idx ) + m_BinEncoder.encodeBinEP( cu.mergeIdx == idx ? 0 : 1 ); + if ( cu.mergeIdx == idx ) { break; } } } } - DTRACE( g_trace_ctx, D_SYNTAX, "aff_merge_idx() aff_merge_idx=%d\n", pu.mergeIdx ); + DTRACE( g_trace_ctx, D_SYNTAX, "aff_merge_idx() aff_merge_idx=%d\n", cu.mergeIdx ); } else { - if( pu.cu->geo ) + if( cu.geo ) { - uint8_t splitDir = pu.geoSplitDir; - uint8_t candIdx0 = pu.geoMergeIdx0; - uint8_t candIdx1 = pu.geoMergeIdx1; + uint8_t splitDir = cu.geoSplitDir; + uint8_t candIdx0 = cu.geoMergeIdx0; + uint8_t candIdx1 = cu.geoMergeIdx1; DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_split_dir=%d\n", splitDir ); DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_idx0=%d\n", candIdx0 ); DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_idx1=%d\n", candIdx1 ); xWriteTruncBinCode(splitDir, GEO_NUM_PARTITION_MODE); candIdx1 -= candIdx1 < candIdx0 ? 0 : 1; - const int maxNumGeoCand = pu.cs->sps->maxNumGeoCand; + const int maxNumGeoCand = cu.cs->sps->maxNumGeoCand; CHECK(maxNumGeoCand < 2, "Incorrect max number of geo candidates"); CHECK(candIdx0 >= maxNumGeoCand, "Incorrect candIdx0"); CHECK(candIdx1 >= maxNumGeoCand, "Incorrect candIdx1"); @@ -1755,13 +1722,13 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) } return; } - int numCandminus1 = (pu.cu->predMode == MODE_IBC) ? (int(pu.cs->sps->maxNumIBCMergeCand) - 1) : (int(pu.cs->sps->maxNumMergeCand) - 1); + int numCandminus1 = (cu.predMode == MODE_IBC) ? (int(cu.cs->sps->maxNumIBCMergeCand) - 1) : (int(cu.cs->sps->maxNumMergeCand) - 1); if( numCandminus1 > 0 ) { - if( pu.mergeIdx == 0 ) + if( cu.mergeIdx == 0 ) { m_BinEncoder.encodeBin( 0, Ctx::MergeIdx() ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() merge_idx=%d\n", pu.mergeIdx ); + DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() merge_idx=%d\n", cu.mergeIdx ); return; } else @@ -1769,28 +1736,28 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) m_BinEncoder.encodeBin( 1, Ctx::MergeIdx() ); for( unsigned idx = 1; idx < numCandminus1; idx++ ) { - m_BinEncoder.encodeBinEP( pu.mergeIdx == idx ? 0 : 1 ); - if( pu.mergeIdx == idx ) + m_BinEncoder.encodeBinEP( cu.mergeIdx == idx ? 0 : 1 ); + if( cu.mergeIdx == idx ) { break; } } } } - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() merge_idx=%d\n", pu.mergeIdx ); + DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() merge_idx=%d\n", cu.mergeIdx ); } } -void CABACWriter::mmvd_merge_idx(const PredictionUnit& pu) +void CABACWriter::mmvd_merge_idx(const CodingUnit& cu) { int var0, var1, var2; - int mvpIdx = pu.mmvdMergeIdx; + int mvpIdx = cu.mmvdMergeIdx; var0 = mvpIdx / MMVD_MAX_REFINE_NUM; var1 = (mvpIdx - (var0 * MMVD_MAX_REFINE_NUM)) / 4; var2 = mvpIdx - (var0 * MMVD_MAX_REFINE_NUM) - var1 * 4; - if (pu.cs->sps->maxNumMergeCand > 1) + if (cu.cs->sps->maxNumMergeCand > 1) { static_assert(MMVD_BASE_MV_NUM == 2, ""); assert(var0 < 2); @@ -1823,23 +1790,23 @@ void CABACWriter::mmvd_merge_idx(const PredictionUnit& pu) m_BinEncoder.encodeBinsEP(var2, 2); DTRACE(g_trace_ctx, D_SYNTAX, "pos() pos=%d\n", var2); - DTRACE(g_trace_ctx, D_SYNTAX, "mmvd_merge_idx() mmvd_merge_idx=%d\n", pu.mmvdMergeIdx); + DTRACE(g_trace_ctx, D_SYNTAX, "mmvd_merge_idx() mmvd_merge_idx=%d\n", cu.mmvdMergeIdx); } -void CABACWriter::inter_pred_idc( const PredictionUnit& pu ) +void CABACWriter::inter_pred_idc( const CodingUnit& cu ) { - if( !pu.cs->slice->isInterB() ) + if( !cu.cs->slice->isInterB() ) { return; } - if( !(PU::isBipredRestriction(pu)) ) + if( !(CU::isBipredRestriction(cu)) ) { - unsigned ctxId = DeriveCtx::CtxInterDir(pu); - if( pu.interDir == 3 ) + unsigned ctxId = DeriveCtx::CtxInterDir(cu); + if( cu.interDir == 3 ) { m_BinEncoder.encodeBin( 1, Ctx::InterDir(ctxId) ); - DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=%d value=%d pos=(%d,%d)\n", ctxId, pu.interDir, pu.lumaPos().x, pu.lumaPos().y ); + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=%d value=%d pos=(%d,%d)\n", ctxId, cu.interDir, cu.lumaPos().x, cu.lumaPos().y ); return; } else @@ -1847,24 +1814,24 @@ void CABACWriter::inter_pred_idc( const PredictionUnit& pu ) m_BinEncoder.encodeBin( 0, Ctx::InterDir(ctxId) ); } } - m_BinEncoder.encodeBin( ( pu.interDir == 2 ), Ctx::InterDir( 5 ) ); - DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", pu.interDir, pu.lumaPos().x, pu.lumaPos().y ); + m_BinEncoder.encodeBin( ( cu.interDir == 2 ), Ctx::InterDir( 5 ) ); + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", cu.interDir, cu.lumaPos().x, cu.lumaPos().y ); } -void CABACWriter::ref_idx( const PredictionUnit& pu, RefPicList eRefList ) +void CABACWriter::ref_idx( const CodingUnit& cu, RefPicList eRefList ) { - if ( pu.cu->smvdMode ) + if ( cu.smvdMode ) { - CHECK( pu.refIdx[eRefList] != pu.cs->slice->symRefIdx[ eRefList ], "Invalid reference index!\n" ); + CHECK( cu.refIdx[eRefList] != cu.cs->slice->symRefIdx[ eRefList ], "Invalid reference index!\n" ); return; } - int numRef = pu.cs->slice->numRefIdx[eRefList]; + int numRef = cu.cs->slice->numRefIdx[eRefList]; - if (eRefList == REF_PIC_LIST_0 && pu.cs->sps->IBC) + if (eRefList == REF_PIC_LIST_0 && cu.cs->sps->IBC) { - if (CU::isIBC(*pu.cu)) + if (CU::isIBC(cu)) return; } @@ -1872,17 +1839,17 @@ void CABACWriter::ref_idx( const PredictionUnit& pu, RefPicList eRefList ) { return; } - int refIdx = pu.refIdx[eRefList]; + int refIdx = cu.refIdx[eRefList]; m_BinEncoder.encodeBin( (refIdx > 0), Ctx::RefPic() ); if( numRef <= 2 || refIdx == 0 ) { - DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", refIdx, pu.lumaPos().x, pu.lumaPos().y ); + DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", refIdx, cu.lumaPos().x, cu.lumaPos().y ); return; } m_BinEncoder.encodeBin( (refIdx > 1), Ctx::RefPic(1) ); if( numRef <= 3 || refIdx == 1 ) { - DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", refIdx, pu.lumaPos().x, pu.lumaPos().y ); + DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", refIdx, cu.lumaPos().x, cu.lumaPos().y ); return; } for( int idx = 3; idx < numRef; idx++ ) @@ -1897,32 +1864,32 @@ void CABACWriter::ref_idx( const PredictionUnit& pu, RefPicList eRefList ) break; } } - DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", refIdx, pu.lumaPos().x, pu.lumaPos().y ); + DTRACE( g_trace_ctx, D_SYNTAX, "ref_idx() value=%d pos=(%d,%d)\n", refIdx, cu.lumaPos().x, cu.lumaPos().y ); } -void CABACWriter::mvp_flag( const PredictionUnit& pu, RefPicList eRefList ) +void CABACWriter::mvp_flag( const CodingUnit& cu, RefPicList eRefList ) { - m_BinEncoder.encodeBin( pu.mvpIdx[eRefList], Ctx::MVPIdx() ); - DTRACE( g_trace_ctx, D_SYNTAX, "mvp_flag() value=%d pos=(%d,%d)\n", pu.mvpIdx[eRefList], pu.lumaPos().x, pu.lumaPos().y ); - DTRACE( g_trace_ctx, D_SYNTAX, "mvpIdx(refList:%d)=%d\n", eRefList, pu.mvpIdx[eRefList] ); + m_BinEncoder.encodeBin( cu.mvpIdx[eRefList], Ctx::MVPIdx() ); + DTRACE( g_trace_ctx, D_SYNTAX, "mvp_flag() value=%d pos=(%d,%d)\n", cu.mvpIdx[eRefList], cu.lumaPos().x, cu.lumaPos().y ); + DTRACE( g_trace_ctx, D_SYNTAX, "mvpIdx(refList:%d)=%d\n", eRefList, cu.mvpIdx[eRefList] ); } -void CABACWriter::ciip_flag(const PredictionUnit& pu) +void CABACWriter::ciip_flag(const CodingUnit& cu) { - if (!pu.cs->sps->CIIP) + if (!cu.cs->sps->CIIP) { - CHECK(pu.ciip == true, "invalid Ciip SPS"); + CHECK(cu.ciip == true, "invalid Ciip SPS"); return; } - if (pu.cu->skip) + if (cu.skip) { - CHECK(pu.ciip == true, "invalid Ciip and skip"); + CHECK(cu.ciip == true, "invalid Ciip and skip"); return; } - m_BinEncoder.encodeBin(pu.ciip, Ctx::CiipFlag()); - DTRACE(g_trace_ctx, D_SYNTAX, "Ciip_flag() Ciip=%d pos=(%d,%d) size=%dx%d\n", pu.ciip ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height); + m_BinEncoder.encodeBin(cu.ciip, Ctx::CiipFlag()); + DTRACE(g_trace_ctx, D_SYNTAX, "Ciip_flag() Ciip=%d pos=(%d,%d) size=%dx%d\n", cu.ciip ? 1 : 0, cu.lumaPos().x, cu.lumaPos().y, cu.lumaSize().width, cu.lumaSize().height); } @@ -1990,7 +1957,7 @@ void CABACWriter::cbf_comp( const CodingUnit& cu, bool cbf, const CompArea& area { const CtxSet& ctxSet = Ctx::QtCbf[ area.compID ]; unsigned ctxId; - if( ( area.compID == COMP_Y && cu.bdpcmMode ) || ( area.compID != COMP_Y && cu.bdpcmModeChroma ) ) + if( cu.bdpcmM[toChannelType(area.compID)] ) { ctxId = (area.compID != COMP_Cr) ? 1 : 2; m_BinEncoder.encodeBin(cbf, ctxSet(ctxId)); @@ -2008,7 +1975,7 @@ void CABACWriter::cbf_comp( const CodingUnit& cu, bool cbf, const CompArea& area //================================================================================ // clause 7.3.8.9 //-------------------------------------------------------------------------------- -// void mvd_coding( pu, refList ) +// void mvd_coding( cu, refList ) //================================================================================ void CABACWriter::mvd_coding( const Mv &rMvd, int8_t imv ) { @@ -2087,7 +2054,7 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partiti if (area.chromaFormat != CHROMA_400) { const bool chromaCbfISP = area.blocks[COMP_Cb].valid() && cu.ispMode; - if (area.blocks[COMP_Cb].valid() && (!cu.isSepTree() || partitioner.chType == CH_C) && (!cu.ispMode || chromaCbfISP)) + if (area.blocks[COMP_Cb].valid() && (!CU::isSepTree(cu) || partitioner.chType == CH_C) && (!cu.ispMode || chromaCbfISP)) { { unsigned cbfDepth = chromaCbfISP ? trDepth - 1 : trDepth; @@ -2106,12 +2073,12 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partiti } } } - else if (cu.isSepTree()) + else if (CU::isSepTree(cu)) { chromaCbfs = ChromaCbfs(false); } } - else if (cu.isSepTree()) + else if (CU::isSepTree(cu)) { chromaCbfs = ChromaCbfs(false); } @@ -2181,7 +2148,7 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partiti } if( ( cu.lwidth() > 64 || cu.lheight() > 64 || cbfLuma || cbfChroma ) && - (!tu.cu->isSepTree() || isLuma(tu.chType)) ) + (!CU::isSepTree(*tu.cu) || isLuma(tu.chType)) ) { if( cu.cs->pps->useDQP && !cuCtx.isDQPCoded ) { @@ -2430,7 +2397,7 @@ void CABACWriter::mts_idx( const CodingUnit& cu, CUCtx* cuCtx ) void CABACWriter::isp_mode( const CodingUnit& cu ) { - if( !CU::isIntra( cu ) || !isLuma( cu.chType ) || cu.pu->multiRefIdx || !cu.cs->sps->ISP || cu.bdpcmMode || !CU::canUseISP( cu, getFirstComponentOfChannel( cu.chType ) ) || cu.colorTransform) + if( !CU::isIntra( cu ) || !isLuma( cu.chType ) || cu.multiRefIdx || !cu.cs->sps->ISP || cu.bdpcmM[CH_L] || !CU::canUseISP( cu, getFirstComponentOfChannel( cu.chType ) ) || cu.colorTransform) { CHECK( cu.ispMode != NOT_INTRA_SUBPARTITIONS, "cu.ispMode != 0" ); return; @@ -2452,8 +2419,8 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) { int chIdx = CS::isDualITree( *cu.cs ) && cu.chType == CH_C ? 1 : 0; if( ( cu.ispMode && !CU::canUseLfnstWithISP( cu, cu.chType ) ) || - (cu.cs->sps->LFNST && CU::isIntra(cu) && cu.mipFlag && !allowLfnstWithMip(cu.pu->lumaSize())) || - ( cu.isSepTree() && cu.chType == CH_C && std::min( cu.blocks[ 1 ].width, cu.blocks[ 1 ].height ) < 4 ) + (cu.cs->sps->LFNST && CU::isIntra(cu) && cu.mipFlag && !allowLfnstWithMip(cu.lumaSize())) || + ( CU::isSepTree(cu) && cu.chType == CH_C && std::min( cu.blocks[ 1 ].width, cu.blocks[ 1 ].height ) < 4 ) || ( cu.blocks[ chIdx ].lumaSize().width > cu.cs->sps->getMaxTbSize() || cu.blocks[ chIdx ].lumaSize().height > cu.cs->sps->getMaxTbSize() ) ) { @@ -2462,8 +2429,8 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) if( cu.cs->sps->LFNST && CU::isIntra( cu ) ) { - const bool lumaFlag = cu.isSepTree() ? ( isLuma( cu.chType ) ? true : false ) : true; - const bool chromaFlag = cu.isSepTree() ? ( isChroma( cu.chType ) ? true : false ) : true; + const bool lumaFlag = CU::isSepTree(cu) ? ( isLuma( cu.chType ) ? true : false ) : true; + const bool chromaFlag = CU::isSepTree(cu) ? ( isChroma( cu.chType ) ? true : false ) : true; bool nonZeroCoeffNonTsCorner8x8 = ( lumaFlag && cuCtx.violatesLfnstConstrained[CH_L] ) || (chromaFlag && cuCtx.violatesLfnstConstrained[CH_C] ); bool isTrSkip = false; @@ -2495,7 +2462,7 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) } unsigned cctx = 0; - if ( cu.isSepTree() ) cctx++; + if ( CU::isSepTree(cu) ) cctx++; const uint32_t idxLFNST = cu.lfnstIdx; assert( idxLFNST < 3 ); @@ -2708,7 +2675,7 @@ void CABACWriter::residual_codingTS( const TransformUnit& tu, ComponentID compID DTRACE( g_trace_ctx, D_SYNTAX, "residual_codingTS() etype=%d pos=(%d,%d) size=%dx%d\n", tu.blocks[compID].compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.blocks[compID].width, tu.blocks[compID].height ); // init coeff coding context - CoeffCodingContext cctx ( tu, compID, false, isLuma(compID) ? tu.cu->bdpcmMode : tu.cu->bdpcmModeChroma); + CoeffCodingContext cctx ( tu, compID, false, tu.cu->bdpcmM[toChannelType(compID)]); const TCoeff* coeff = tu.getCoeffs( compID ).buf; int maxCtxBins = (cctx.maxNumCoeff() * 7) >> 2; cctx.setNumCtxBins(maxCtxBins); @@ -3041,19 +3008,19 @@ void CABACWriter::mip_pred_modes( const CodingUnit& cu ) return; } - mip_pred_mode( *cu.pu ); + mip_pred_mode( cu ); } -void CABACWriter::mip_pred_mode( const PredictionUnit& pu ) +void CABACWriter::mip_pred_mode( const CodingUnit& cu ) { - m_BinEncoder.encodeBinEP( (pu.mipTransposedFlag ? 1 : 0) ); + m_BinEncoder.encodeBinEP( (cu.mipTransposedFlag ? 1 : 0) ); - const int numModes = getNumModesMip( pu.Y() ); - CHECKD( pu.intraDir[CH_L] < 0 || pu.intraDir[CH_L] >= numModes, "Invalid MIP mode" ); - xWriteTruncBinCode( pu.intraDir[CH_L], numModes ); + const int numModes = getNumModesMip( cu.Y() ); + CHECKD( cu.intraDir[CH_L] < 0 || cu.intraDir[CH_L] >= numModes, "Invalid MIP mode" ); + xWriteTruncBinCode( cu.intraDir[CH_L], numModes ); - DTRACE( g_trace_ctx, D_SYNTAX, "mip_pred_mode() pos=(%d,%d) mode=%d transposed=%d\n", pu.lumaPos().x, pu.lumaPos().y, pu.intraDir[CH_L], pu.mipTransposedFlag ? 1 : 0 ); + DTRACE( g_trace_ctx, D_SYNTAX, "mip_pred_mode() pos=(%d,%d) mode=%d transposed=%d\n", cu.lumaPos().x, cu.lumaPos().y, cu.intraDir[CH_L], cu.mipTransposedFlag ? 1 : 0 ); } diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index 3bae9f393..951d8d37e 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file CABACWriter.h * \brief Writer for low level syntax */ @@ -100,13 +104,12 @@ class CABACWriter : public DeriveCtx void cu_pred_data ( const CodingUnit& cu ); void cu_bcw_flag ( const CodingUnit& cu ); - void extend_ref_line ( const PredictionUnit& pu ); void extend_ref_line ( const CodingUnit& cu ); void intra_luma_pred_modes ( const CodingUnit& cu ); - void intra_luma_pred_mode ( const PredictionUnit& pu ); + void intra_luma_pred_mode ( const CodingUnit& cu, const unsigned *mpmLst = nullptr ); void intra_chroma_pred_modes ( const CodingUnit& cu ); - void intra_chroma_lmc_mode ( const PredictionUnit& pu ); - void intra_chroma_pred_mode ( const PredictionUnit& pu ); + void intra_chroma_lmc_mode ( const CodingUnit& cu ); + void intra_chroma_pred_mode ( const CodingUnit& cu ); void cu_residual ( const CodingUnit& cu, Partitioner& pm, CUCtx& cuCtx ); void rqt_root_cbf ( const CodingUnit& cu ); void adaptive_color_transform ( const CodingUnit& cu); @@ -114,25 +117,25 @@ class CABACWriter : public DeriveCtx void end_of_ctu ( const CodingUnit& cu, CUCtx& cuCtx ); void mip_flag ( const CodingUnit& cu ); void mip_pred_modes ( const CodingUnit& cu ); - void mip_pred_mode ( const PredictionUnit& pu ); + void mip_pred_mode ( const CodingUnit& cu ); void cu_palette_info ( const CodingUnit& cu, ComponentID compBegin, uint32_t numComp, CUCtx& cuCtx); void cuPaletteSubblockInfo ( const CodingUnit& cu, ComponentID compBegin, uint32_t numComp, int subSetId, uint32_t& prevRunPos, unsigned& prevRunType ); // prediction unit (clause 7.3.8.6) - void prediction_unit ( const PredictionUnit& pu ); - void merge_flag ( const PredictionUnit& pu ); - void merge_data ( const PredictionUnit& pu ); + void prediction_unit ( const CodingUnit& cu ); + void merge_flag ( const CodingUnit& cu ); + void merge_data ( const CodingUnit& cu ); void affine_flag ( const CodingUnit& cu ); void subblock_merge_flag ( const CodingUnit& cu ); - void merge_idx ( const PredictionUnit& pu ); - void mmvd_merge_idx ( const PredictionUnit& pu); + void merge_idx ( const CodingUnit& cu ); + void mmvd_merge_idx ( const CodingUnit& cu); void imv_mode ( const CodingUnit& cu ); void affine_amvr_mode ( const CodingUnit& cu ); - void inter_pred_idc ( const PredictionUnit& pu ); - void ref_idx ( const PredictionUnit& pu, RefPicList eRefList ); - void mvp_flag ( const PredictionUnit& pu, RefPicList eRefList ); + void inter_pred_idc ( const CodingUnit& cu ); + void ref_idx ( const CodingUnit& cu, RefPicList eRefList ); + void mvp_flag ( const CodingUnit& cu, RefPicList eRefList ); - void ciip_flag ( const PredictionUnit& pu ); - void smvd_mode ( const PredictionUnit& pu ); + void ciip_flag ( const CodingUnit& cu ); + void smvd_mode ( const CodingUnit& cu ); // transform tree (clause 7.3.8.8) void transform_tree ( const CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 ); diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp index 62744c64e..5f6829ef8 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncAdaptiveLoopFilter.cpp @@ -52,7 +56,7 @@ vvc@hhi.fraunhofer.de #include "CommonLib/TimeProfiler.h" #include -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "Utilities/NoMallocThreadPool.h" @@ -539,12 +543,13 @@ int AlfCovariance::gnsSolveByChol( TE LHS, double* rhs, double *x, int numEq ) c ////////////////////////////////////////////////////////////////////////////////////////// EncAdaptiveLoopFilter::EncAdaptiveLoopFilter() - : m_encCfg ( nullptr ) - , m_apsMap ( nullptr ) - , m_CABACEstimator( nullptr ) - , m_CtxCache ( nullptr ) - , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) - , m_threadpool ( nullptr ) + : m_encCfg ( nullptr ) + , m_apsMap ( nullptr ) + , m_CABACEstimator ( nullptr ) + , m_CtxCache ( nullptr ) + , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) + , m_bestFilterCount( 0 ) + , m_threadpool ( nullptr ) { for( int i = 0; i < MAX_NUM_COMP; i++ ) { @@ -1294,83 +1299,36 @@ void EncAdaptiveLoopFilter::reconstructCTU_MT( Picture& pic, CodingStructure& cs const int nCtuX = ctuRsAddr % cs.pcv->widthInCtus; const int nCtuY = ctuRsAddr / cs.pcv->widthInCtus; - CHECK( nCtuY >= cs.pcv->heightInCtus, "Wrong CTU index" ); - - UnitArea curCtuArea = UnitArea( cs.area.chromaFormat, cs.pcv->getCtuArea( nCtuX, nCtuY ) ); - - PelUnitBuf curCtuBuf = m_tempBuf.getBuf( curCtuArea ); - const int extMargin = ( MAX_ALF_FILTER_LENGTH + 1 ) >> 1; //MAX_ALF_FILTER_LENGTH >> 1; - if( nCtuY == 0 ) + // copy unfiltered reco (including padded / extented area) + const ChromaFormat chromaFormat = cs.area.chromaFormat; + UnitArea ctuArea = UnitArea( chromaFormat, cs.pcv->getCtuArea( nCtuX, nCtuY ) ); + const int extMargin = ( MAX_ALF_FILTER_LENGTH + 1 ) >> 1; + for( int i = 0; i < getNumberValidComponents( chromaFormat ); i++ ) { - if( nCtuX == 0 ) { - // First CTU in line - curCtuBuf.copyFrom( pic.getRecoBuf( curCtuArea ) ); - curCtuBuf.extendBorderPelLft( 0, curCtuArea.lheight(), extMargin ); - if( nCtuY == 0 ) - { - // First CTU line, extend top border - curCtuBuf.extendBorderPelTop( -extMargin, curCtuArea.lwidth() + extMargin, extMargin ); - } - } - - if( nCtuX + 1 < cs.pcv->widthInCtus ){ - UnitArea nextCtuArea = UnitArea( cs.area.chromaFormat, cs.pcv->getCtuArea( nCtuX + 1, nCtuY ) ); - PelUnitBuf nextCtuBuf = m_tempBuf.getBuf( nextCtuArea ); - nextCtuBuf.copyFrom( pic.getRecoBuf( nextCtuArea ) ); - if( nCtuY == 0 ) - { - // First CTU line, extend top border - nextCtuBuf.extendBorderPelTop( 0, nextCtuArea.lwidth(), extMargin ); - } - } - else{ - // Last CTU in line - curCtuBuf.extendBorderPelRgt( 0, curCtuArea.lheight(), MAX_ALF_FILTER_LENGTH >> 1 ); - if( nCtuY == 0 && nCtuX > 0 ) - { - // First CTU line, extend top border - curCtuBuf.extendBorderPelTop( curCtuArea.lwidth(), extMargin, extMargin ); - } - } - } - - if( nCtuY + 1 < cs.pcv->heightInCtus ) - { - if( nCtuX == 0 ) + const int extX = extMargin >> getComponentScaleX( ComponentID( i ), chromaFormat ); + const int extY = extMargin >> getComponentScaleY( ComponentID( i ), chromaFormat ); + CompArea cpyArea = ctuArea.blocks[ i ]; + cpyArea.x += extX; + cpyArea.y += extY; + if ( nCtuX == 0 ) { - // Copy below CTU - UnitArea nextCtuArea = UnitArea(cs.area.chromaFormat, cs.pcv->getCtuArea(nCtuX, nCtuY + 1)); - PelUnitBuf nextCtuBuf = m_tempBuf.getBuf( nextCtuArea); - nextCtuBuf.copyFrom( pic.getRecoBuf( nextCtuArea ) ); - nextCtuBuf.extendBorderPelLft( 0, nextCtuArea.lheight(), extMargin ); - } - - // Copy CTU below-right - if( nCtuX + 1 < cs.pcv->widthInCtus ){ - UnitArea nextCtuArea = UnitArea( cs.area.chromaFormat, cs.pcv->getCtuArea( nCtuX + 1, nCtuY + 1 ) ); - PelUnitBuf nextCtuBuf = m_tempBuf.getBuf( nextCtuArea ); - nextCtuBuf.copyFrom( pic.getRecoBuf( nextCtuArea ) ); + cpyArea.x -= 2 * extX; + cpyArea.width += 2 * extX; } - else{ - // Last CTU in line - UnitArea nextCtuArea = UnitArea(cs.area.chromaFormat, cs.pcv->getCtuArea(nCtuX, nCtuY + 1)); - PelUnitBuf nextCtuBuf = m_tempBuf.getBuf( nextCtuArea ); - nextCtuBuf.extendBorderPelRgt( 0, nextCtuArea.lheight(), MAX_ALF_FILTER_LENGTH >> 1 ); + if ( nCtuY == 0 ) + { + cpyArea.y -= 2 * extY; + cpyArea.height += 2 * extY; } - } - else - { - // Last CTU line, extend bottom border only - int botBoundaryStart = nCtuX == 0 ? -extMargin: curCtuArea.lwidth(); - int botBoundarySize = curCtuArea.lwidth() + ( ( nCtuX + 1 < cs.pcv->widthInCtus ) ? curCtuArea.lwidth(): extMargin ); - if( nCtuX == 0 ) - botBoundarySize += extMargin; - curCtuBuf.extendBorderPelBot( botBoundaryStart, botBoundarySize, extMargin ); + PelBuf dstBuf = m_tempBuf.getBuf( cpyArea ); + PelBuf srcBuf = pic.getRecoBuf( cpyArea ); + dstBuf.copyFrom( srcBuf ); } // Perform filtering - reconstructCTU( pic, cs, curCtuBuf, ctuRsAddr ); + PelUnitBuf ctuBuf = m_tempBuf.getBuf( ctuArea ); + reconstructCTU( pic, cs, ctuBuf, ctuRsAddr ); } #if ENABLE_TRACING diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h index 83b8c629d..37a2d8d5a 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncAdaptiveLoopFilter.h \brief estimation part of adaptive loop filter class (header) */ #pragma once -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CABACWriter.h" #include "CommonLib/AdaptiveLoopFilter.h" diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 6a88a5b8b..f9e63a5a6 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncCu.cpp @@ -349,12 +353,8 @@ void EncCu::encodeCtu( Picture* pic, int (&prevQP)[MAX_NUM_CH], uint32_t ctuXPos if( m_pcEncCfg->m_ensureWppBitEqual && ctuXPosInCtus == 0 ) { - if( m_pcEncCfg->m_ensureWppBitEqual - && m_pcEncCfg->m_numWppThreads < 1 - && ctuYPosInCtus > 0 ) + if( ctuYPosInCtus > 0 ) { - m_cInterSearch.m_AffineProfList->resetAffineMVList (); - m_cInterSearch.m_BlkUniMvInfoBuffer->resetUniMvList(); m_CABACEstimator->initCtxModels( *slice ); } @@ -499,7 +499,7 @@ bool EncCu::xCheckBestMode( CodingStructure *&tempCS, CodingStructure *&bestCS, if( tempCS->cus.size() == 1 ) { const CodingUnit& cu = *tempCS->cus.front(); - CHECK( cu.skip && !cu.pu->mergeFlag, "Skip flag without a merge flag is not allowed!" ); + CHECK( cu.skip && !cu.mergeFlag, "Skip flag without a merge flag is not allowed!" ); } DTRACE_BEST_MODE( tempCS, bestCS, m_cRdCost.getLambda(true), useEDO ); @@ -601,11 +601,6 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } m_modeCtrl.initCULevel( partitioner, *tempCS ); - if( partitioner.currQtDepth == 0 && partitioner.currMtDepth == 0 && !tempCS->slice->isIntra() && ( sps.SBT || sps.MTSInter ) ) - { - int maxSLSize = sps.SBT ? (1 << tempCS->slice->sps->log2MaxTbSize) : MTS_INTER_MAX_CU_SIZE; - m_modeCtrl.resetSaveloadSbt( maxSLSize ); - } m_sbtCostSave[0] = m_sbtCostSave[1] = MAX_DOUBLE; m_CurrCtx->start = m_CABACEstimator->getCtx(); @@ -872,12 +867,11 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par && bestCS->area.Y() == (*bestCS->cus.back()).Y() ) { - const CodingUnit& cu = *bestCS->cus.front(); - const PredictionUnit& pu = *cu.pu; + const CodingUnit& cu = *bestCS->cus.front(); if (!cu.affine && !cu.geo) { - const MotionInfo &mi = pu.getMotionInfo(); + const MotionInfo &mi = cu.getMotionInfo(); HPMVInfo hMi( mi, (mi.interDir == 3) ? cu.BcwIdx : BCW_DEFAULT, cu.imv == IMV_HPEL ); cu.cs->addMiToLut( /*CU::isIBC(cu) ? cu.cs->motionLut.lutIbc :*/ cu.cs->motionLut.lut, hMi ); } @@ -1318,11 +1312,10 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; cu.ispMode = NOT_INTRA_SUBPARTITIONS; - - CU::addPUs( cu ); + cu.initPuData(); tempCS->interHad = m_modeCtrl.comprCUCtx->interHad; - + double maxCostAllowedForChroma = MAX_DOUBLE; if( isLuma( partitioner.chType ) ) { if (!tempCS->slice->isIntra() && bestCS) @@ -1342,18 +1335,30 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC { // JEM assumes only perfect reconstructions can from now on beat the inter mode m_modeCtrl.comprCUCtx->interHad = 0; - return;// th new continue; + return; } } - if( tempCS->area.chromaFormat != CHROMA_400 && ( partitioner.chType == CH_C || !cu.isSepTree() ) ) + if( tempCS->area.chromaFormat != CHROMA_400 && ( partitioner.chType == CH_C || !CU::isSepTree(cu) ) ) { - m_cIntraSearch.estIntraPredChromaQT( cu, partitioner ); + bool useIntraSubPartitions = cu.ispMode != NOT_INTRA_SUBPARTITIONS; + Partitioner subTuPartitioner = partitioner; + if ((m_pcEncCfg->m_ISP >= 3) && (!partitioner.isSepTree(*tempCS) && useIntraSubPartitions)) + { + maxCostAllowedForChroma = bestCS->cost < MAX_DOUBLE ? bestCS->cost - tempCS->lumaCost : MAX_DOUBLE; + } + m_cIntraSearch.estIntraPredChromaQT( + cu, (!useIntraSubPartitions || (CU::isSepTree(cu) && !isLuma(CH_C))) ? partitioner : subTuPartitioner, + maxCostAllowedForChroma); + if ((m_pcEncCfg->m_ISP >= 3) && useIntraSubPartitions && !cu.ispMode) + { + return; + } } cu.rootCbf = false; - for( uint32_t t = 0; t < getNumberValidTBlocks( *cu.cs->pcv ); t++ ) + for (uint32_t t = 0; t < getNumberValidTBlocks(*cu.cs->pcv); t++) { cu.rootCbf |= cu.firstTU->cbf[t] != 0; } @@ -1361,34 +1366,33 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC // Get total bits for current mode: encode CU m_CABACEstimator->resetBits(); - if( (!cu.cs->slice->isIntra() || cu.cs->slice->sps->IBC) && cu.Y().valid()) + if ((!cu.cs->slice->isIntra() || cu.cs->slice->sps->IBC) && cu.Y().valid()) { - m_CABACEstimator->cu_skip_flag ( cu ); + m_CABACEstimator->cu_skip_flag(cu); } - m_CABACEstimator->pred_mode ( cu ); - m_CABACEstimator->cu_pred_data ( cu ); - m_CABACEstimator->bdpcm_mode ( cu, ComponentID(partitioner.chType) ); + m_CABACEstimator->pred_mode(cu); + m_CABACEstimator->cu_pred_data(cu); // Encode Coefficients CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; - m_CABACEstimator->cu_residual( cu, partitioner, cuCtx ); + m_CABACEstimator->cu_residual(cu, partitioner, cuCtx); tempCS->fracBits = m_CABACEstimator->getEstFracBits(); - tempCS->cost = m_cRdCost.calcRdCost(tempCS->fracBits, tempCS->dist); + tempCS->cost = m_cRdCost.calcRdCost(tempCS->fracBits, tempCS->dist); - xEncodeDontSplit( *tempCS, partitioner ); + xEncodeDontSplit(*tempCS, partitioner); - xCheckDQP( *tempCS, partitioner ); + xCheckDQP(*tempCS, partitioner); - if( m_pcEncCfg->m_EDO ) + if (m_pcEncCfg->m_EDO) { - xCalDebCost( *tempCS, partitioner ); + xCalDebCost(*tempCS, partitioner); } - DTRACE_MODE_COST( *tempCS, m_cRdCost.getLambda(true) ); - xCheckBestMode( tempCS, bestCS, partitioner, encTestMode, m_pcEncCfg->m_EDO ); + DTRACE_MODE_COST(*tempCS, m_cRdCost.getLambda(true)); + xCheckBestMode(tempCS, bestCS, partitioner, encTestMode, m_pcEncCfg->m_EDO); STAT_COUNT_CU_MODES( partitioner.chType == CH_L, g_cuCounters1D[CU_MODES_TESTED][0][!tempCS->slice->isIntra() + tempCS->slice->depth] ); STAT_COUNT_CU_MODES( partitioner.chType == CH_L && !tempCS->slice->isIntra(), g_cuCounters2D[CU_MODES_TESTED][Log2( tempCS->area.lheight() )][Log2( tempCS->area.lwidth() )] ); @@ -1591,7 +1595,6 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); mergeCtx.subPuMvpMiBuf = MotionBuf(m_subPuMiBuf, bufSize); } - Mv refinedMvdL0[MRG_MAX_NUM_CANDS][MAX_NUM_SUBCU_DMVR]; m_mergeBestSATDCost = MAX_DOUBLE; @@ -1608,13 +1611,10 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC cu.slice = tempCS->slice; cu.tileIdx = 0; - PredictionUnit pu( tempCS->area ); - pu.cu = &cu; - pu.cs = tempCS; - PU::getInterMergeCandidates(pu, mergeCtx, 0 ); - PU::getInterMMVDMergeCandidates(pu, mergeCtx); + CU::getInterMergeCandidates(cu, mergeCtx, 0 ); + CU::getInterMMVDMergeCandidates(cu, mergeCtx); - pu.regularMergeFlag = true; + cu.regularMergeFlag = true; } bool candHasNoResidual[MRG_MAX_NUM_CANDS + MMVD_ADD_NUM] = { false }; @@ -1693,12 +1693,12 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC cu.qp = encTestMode.qp; //cu.emtFlag is set below - PredictionUnit &pu = tempCS->addPU( cu, partitioner.chType, &cu ); + cu.initPuData(); const DFunc dfunc = encTestMode.lossless || tempCS->slice->disableSATDForRd ? DF_SAD : DF_HAD; DistParam distParam = m_cRdCost.setDistParam(tempCS->getOrgBuf(COMP_Y), m_SortedPelUnitBufs.getTestBuf(COMP_Y), sps.bitDepths[ CH_L ], dfunc); - bool sameMV[ MRG_MAX_NUM_CANDS ] = { false }; + bool sameMV[ MRG_MAX_NUM_CANDS ] = { false, }; if (m_pcEncCfg->m_useFastMrg == 2) { for (int m = 0; m < mergeCtx.numValidMergeCand - 1; m++) @@ -1717,42 +1717,30 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC } } + Mv* cu_mvdL0SubPuBackup = cu.mvdL0SubPu; //we have to restore this later for( uint32_t uiMergeCand = 0; uiMergeCand < mergeCtx.numValidMergeCand; uiMergeCand++ ) { if (sameMV[uiMergeCand]) { continue; } - mergeCtx.setMergeInfo( pu, uiMergeCand ); + mergeCtx.setMergeInfo( cu, uiMergeCand ); - PU::spanMotionInfo( pu, mergeCtx ); - pu.mvRefine = true; - bool BioOrDmvr = m_cInterSearch.motionCompensation(pu, m_SortedPelUnitBufs.getTestBuf(), REF_PIC_LIST_X); - pu.mvRefine = false; + CU::spanMotionInfo( cu, mergeCtx ); + cu.mvRefine = true; + cu.mvdL0SubPu = m_refinedMvdL0[uiMergeCand]; // set an alternative storage for sub mvs + bool BioOrDmvr = m_cInterSearch.motionCompensation(cu, m_SortedPelUnitBufs.getTestBuf(), REF_PIC_LIST_X); + cu.mvRefine = false; if( mergeCtx.interDirNeighbours[uiMergeCand] == 3 && mergeCtx.mrgTypeNeighbours[uiMergeCand] == MRG_TYPE_DEFAULT_N ) { - mergeCtx.mvFieldNeighbours[2*uiMergeCand].mv = pu.mv[0]; - mergeCtx.mvFieldNeighbours[2*uiMergeCand+1].mv = pu.mv[1]; - { - if (PU::checkDMVRCondition(pu)) - { - int num = 0; - for (int i = 0; i < (pu.lumaSize().height); i += DMVR_SUBCU_SIZE) - { - for (int j = 0; j < (pu.lumaSize().width); j += DMVR_SUBCU_SIZE) - { - refinedMvdL0[uiMergeCand][num] = pu.mvdL0SubPu[num]; - num++; - } - } - } - } + mergeCtx.mvFieldNeighbours[2*uiMergeCand].mv = cu.mv[0]; + mergeCtx.mvFieldNeighbours[2*uiMergeCand+1].mv = cu.mv[1]; } distParam.cur.buf = m_SortedPelUnitBufs.getTestBuf().Y().buf; Distortion uiSad = distParam.distFunc(distParam); - uint64_t fracBits = xCalcPuMeBits(pu); + uint64_t fracBits = xCalcPuMeBits(cu); //restore ctx m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::MergeFlag(), merge_ctx_size), ctxStartIntraCtx); @@ -1767,7 +1755,7 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC } } - + cu.mvdL0SubPu = cu_mvdL0SubPuBackup; // restore original stoarge if (testCIIP) { unsigned numCiipInitialCand = std::min(NUM_MRG_SATD_CAND-1+numCiiPExtraTests, (const int)RdModeList.size()); @@ -1789,12 +1777,12 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC if( numCiipTests ) { - pu.ciip = true; + cu.ciip = true; // generate intrainter Y prediction - pu.intraDir[0] = PLANAR_IDX; - m_cIntraSearch.initIntraPatternChType(*pu.cu, pu.Y()); - m_cIntraSearch.predIntraAng(COMP_Y, ciipBuf.Y(), pu); - numCiipIntra = m_cIntraSearch.getNumIntraCiip( pu ); + cu.intraDir[0] = PLANAR_IDX; + m_cIntraSearch.initIntraPatternChType(cu, cu.Y()); + m_cIntraSearch.predIntraAng(COMP_Y, ciipBuf.Y(), cu); + numCiipIntra = m_cIntraSearch.getNumIntraCiip( cu ); // save the to-be-tested merge candidates for (uint32_t mergeCounter = 0; mergeCounter < numCiipTests; mergeCounter++) @@ -1802,15 +1790,15 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC uint32_t mergeCand = sortedMergeCand[mergeCounter]; // estimate merge bits - mergeCtx.setMergeInfo(pu, mergeCand); + mergeCtx.setMergeInfo(cu, mergeCand); PelUnitBuf testBuf = m_SortedPelUnitBufs.getTestBuf(); if( BioOrDmvr[mergeCounter] ) // recalc { - pu.mvRefine = false; - pu.mcControl = 0; - m_cInterSearch.motionCompensation(pu, testBuf); + cu.mvRefine = false; + cu.mcControl = 0; + m_cInterSearch.motionCompensation(cu, testBuf); } else { @@ -1826,7 +1814,7 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC // calculate cost if( slice.lmcsEnabled && reshapeData.getCTUFlag() ) { - PelBuf tmpLmcs = m_aTmpStorageLCU[0].getCompactBuf( pu.Y() ); + PelBuf tmpLmcs = m_aTmpStorageLCU[0].getCompactBuf( cu.Y() ); tmpLmcs.rspSignal( testBuf.Y(), reshapeData.getInvLUT()); distParam.cur = tmpLmcs; } @@ -1838,8 +1826,8 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC Distortion sadValue = distParam.distFunc(distParam); m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::MergeFlag(), merge_ctx_size), ctxStartIntraCtx); - pu.regularMergeFlag = false; - uint64_t fracBits = xCalcPuMeBits(pu); + cu.regularMergeFlag = false; + uint64_t fracBits = xCalcPuMeBits(cu); if (uiSadBestForQPA > sadValue) { uiSadBestForQPA = sadValue; } double cost = (double)sadValue + (double)fracBits * sqrtLambdaForFirstPassIntra; int insertPos = -1; @@ -1855,7 +1843,7 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC break; } } - pu.ciip = false; + cu.ciip = false; } } @@ -1865,10 +1853,10 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC uiNumMrgSATDCand = (unsigned)RdModeList.size(); testMMVD = (RdModeList.size() > 1); } - if (pu.cs->sps->MMVD && testMMVD) + if (cu.cs->sps->MMVD && testMMVD) { cu.mmvdSkip = true; - pu.regularMergeFlag = true; + cu.regularMergeFlag = true; int tempNum = (mergeCtx.numValidMergeCand > 1) ? MMVD_ADD_NUM : MMVD_ADD_NUM >> 1; int bestDir = 0; @@ -1917,21 +1905,21 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC { continue; } - mergeCtx.setMmvdMergeCandiInfo(pu, mmvdMergeCand); + mergeCtx.setMmvdMergeCandiInfo(cu, mmvdMergeCand); - PU::spanMotionInfo(pu, mergeCtx); - pu.mvRefine = true; - pu.mcControl = (refineStep > 2) || (m_pcEncCfg->m_MMVD > 1) ? 3 : 0; - CHECK(!pu.mmvdMergeFlag, "MMVD merge should be set"); + CU::spanMotionInfo(cu, mergeCtx); + cu.mvRefine = true; + cu.mcControl = (refineStep > 2) || (m_pcEncCfg->m_MMVD > 1) ? 3 : 0; + CHECK(!cu.mmvdMergeFlag, "MMVD merge should be set"); // Don't do chroma MC here - m_cInterSearch.motionCompensation(pu, m_SortedPelUnitBufs.getTestBuf(), REF_PIC_LIST_X); - pu.mcControl = 0; - pu.mvRefine = false; + m_cInterSearch.motionCompensation(cu, m_SortedPelUnitBufs.getTestBuf(), REF_PIC_LIST_X); + cu.mcControl = 0; + cu.mvRefine = false; distParam.cur.buf = m_SortedPelUnitBufs.getTestBuf().Y().buf; Distortion uiSad = distParam.distFunc(distParam); m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::MergeFlag(), merge_ctx_size), ctxStartIntraCtx); - uint64_t fracBits = xCalcPuMeBits(pu); + uint64_t fracBits = xCalcPuMeBits(cu); if (uiSadBestForQPA > uiSad) { uiSadBestForQPA = uiSad; } double cost = (double)uiSad + (double)fracBits * sqrtLambdaForFirstPassIntra; if (m_pcEncCfg->m_MMVD > 1 && bestCostOffset > cost) @@ -1961,23 +1949,23 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC } } m_mergeBestSATDCost = candCostList[0]; - if (testCIIP && isChromaEnabled(pu.cs->pcv->chrFormat) && pu.chromaSize().width != 2 ) + if (testCIIP && isChromaEnabled(cu.cs->pcv->chrFormat) && cu.chromaSize().width != 2 ) { for (uint32_t mergeCnt = 0; mergeCnt < uiNumMrgSATDCand; mergeCnt++) { if (RdModeList[mergeCnt].isCIIP) { - pu.intraDir[0] = PLANAR_IDX; - pu.intraDir[1] = DM_CHROMA_IDX; - pu.ciip = true; + cu.intraDir[0] = PLANAR_IDX; + cu.intraDir[1] = DM_CHROMA_IDX; + cu.ciip = true; - m_cIntraSearch.initIntraPatternChType(*pu.cu, pu.Cb()); - m_cIntraSearch.predIntraAng(COMP_Cb, ciipBuf.Cb(), pu); + m_cIntraSearch.initIntraPatternChType(cu, cu.Cb()); + m_cIntraSearch.predIntraAng(COMP_Cb, ciipBuf.Cb(), cu); - m_cIntraSearch.initIntraPatternChType(*pu.cu, pu.Cr()); - m_cIntraSearch.predIntraAng(COMP_Cr, ciipBuf.Cr(), pu); + m_cIntraSearch.initIntraPatternChType(cu, cu.Cr()); + m_cIntraSearch.predIntraAng(COMP_Cr, ciipBuf.Cr(), cu); - pu.ciip = false; + cu.ciip = false; break; } } @@ -2018,6 +2006,7 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC } } } + uiNumMrgSATDCand = std::min(int(uiNumMrgSATDCand), int(RdModeList.size())); uint32_t iteration = (encTestMode.lossless) ? 1 : 2; @@ -2056,35 +2045,35 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; - PredictionUnit &pu = tempCS->addPU( cu, partitioner.chType, &cu ); + cu.initPuData(); if (uiNoResidualPass == 0 && RdModeList[uiMrgHADIdx].isCIIP) { cu.mmvdSkip = false; - mergeCtx.setMergeInfo(pu, uiMergeCand); - pu.ciip = true; - pu.regularMergeFlag = false; - pu.intraDir[0] = PLANAR_IDX; - pu.intraDir[1] = DM_CHROMA_IDX; + mergeCtx.setMergeInfo(cu, uiMergeCand); + cu.ciip = true; + cu.regularMergeFlag = false; + cu.intraDir[0] = PLANAR_IDX; + cu.intraDir[1] = DM_CHROMA_IDX; } else if (RdModeList[uiMrgHADIdx].isMMVD) { cu.mmvdSkip = true; - pu.regularMergeFlag = true; - pu.ciip = false; - mergeCtx.setMmvdMergeCandiInfo(pu, uiMergeCand); + cu.regularMergeFlag = true; + cu.ciip = false; + mergeCtx.setMmvdMergeCandiInfo(cu, uiMergeCand); } else { cu.mmvdSkip = false; - pu.regularMergeFlag = true; - pu.ciip = false; - mergeCtx.setMergeInfo(pu, uiMergeCand); + cu.regularMergeFlag = true; + cu.ciip = false; + mergeCtx.setMergeInfo(cu, uiMergeCand); } - PU::spanMotionInfo( pu, mergeCtx ); + CU::spanMotionInfo( cu, mergeCtx ); { - if (!pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && (pu.lwidth() + pu.lheight() == 12)) + if (!cu.affine && cu.refIdx[0] >= 0 && cu.refIdx[1] >= 0 && (cu.lwidth() + cu.lheight() == 12)) { tempCS->initStructData(encTestMode.qp); continue; @@ -2092,24 +2081,24 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC if( mrgTempBufSet ) { - if( PU::checkDMVRCondition( pu ) ) + if( CU::checkDMVRCondition( cu ) ) { int num = 0; - for( int i = 0; i < ( pu.lumaSize().height ); i += DMVR_SUBCU_SIZE ) + for( int i = 0; i < ( cu.lheight() ); i += DMVR_SUBCU_SIZE ) { - for( int j = 0; j < ( pu.lumaSize().width ); j += DMVR_SUBCU_SIZE ) + for( int j = 0; j < ( cu.lwidth() ); j += DMVR_SUBCU_SIZE ) { - pu.mvdL0SubPu[num] = refinedMvdL0[uiMergeCand][num]; + cu.mvdL0SubPu[num] = m_refinedMvdL0[uiMergeCand][num]; num++; } } } - if (pu.ciip) + if (cu.ciip) { PelUnitBuf predBuf = tempCS->getPredBuf(); predBuf.copyFrom( *m_SortedPelUnitBufs.getBufFromSortedList( uiMrgHADIdx )); - if (isChromaEnabled(pu.chromaFormat) && pu.chromaSize().width > 2 ) + if (isChromaEnabled(cu.chromaFormat) && cu.chromaSize().width > 2 ) { predBuf.Cb().weightCiip( ciipBuf.Cb(), numCiipIntra); predBuf.Cr().weightCiip( ciipBuf.Cr(), numCiipIntra); @@ -2119,17 +2108,17 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC { if (RdModeList[uiMrgHADIdx].isMMVD) { - pu.mcControl = 0; - m_cInterSearch.motionCompensation(pu, tempCS->getPredBuf() ); + cu.mcControl = 0; + m_cInterSearch.motionCompensation(cu, tempCS->getPredBuf() ); } else if( RdModeList[uiMrgHADIdx].isCIIP ) { if( mmvdCandInserted ) { - pu.mcControl = 0; - pu.mvRefine = true; - m_cInterSearch.motionCompensation(pu, tempCS->getPredBuf() ); - pu.mvRefine = false; + cu.mcControl = 0; + cu.mvRefine = true; + m_cInterSearch.motionCompensation(cu, tempCS->getPredBuf() ); + cu.mvRefine = false; } else { @@ -2146,12 +2135,12 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC } else { - pu.mvRefine = true; - m_cInterSearch.motionCompensation( pu, tempCS->getPredBuf() ); - pu.mvRefine = false; + cu.mvRefine = true; + m_cInterSearch.motionCompensation( cu, tempCS->getPredBuf() ); + cu.mvRefine = false; } } - if (!cu.mmvdSkip && !pu.ciip && uiNoResidualPass != 0) + if (!cu.mmvdSkip && !cu.ciip && uiNoResidualPass != 0) { CHECK(uiMergeCand >= mergeCtx.numValidMergeCand, "out of normal merge"); isTestSkipMerge[uiMergeCand] = true; @@ -2161,12 +2150,12 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC if (m_pcEncCfg->m_useFastMrg == 2) { - if( pu.ciip && bestCS->cost == MAX_DOUBLE && uiMrgHADIdx+1 == uiNumMrgSATDCand ) + if( cu.ciip && bestCS->cost == MAX_DOUBLE && uiMrgHADIdx+1 == uiNumMrgSATDCand ) { uiNumMrgSATDCand = (unsigned)RdModeList.size(); } - if (uiMrgHADIdx > 0 && tempCS->cost >= bestEndCost && !pu.ciip) + if (uiMrgHADIdx > 0 && tempCS->cost >= bestEndCost && !cu.ciip) { uiMrgHADIdx = uiNumMrgSATDCand; tempCS->initStructData(encTestMode.qp); @@ -2178,7 +2167,7 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC } } - if( m_pcEncCfg->m_useFastDecisionForMerge && !bestIsSkip && !pu.ciip) + if( m_pcEncCfg->m_useFastDecisionForMerge && !bestIsSkip && !cu.ciip) { bestIsSkip = !bestCS->cus.empty() && bestCS->getCU( partitioner.chType, partitioner.treeType )->rootCbf == 0; } @@ -2188,11 +2177,10 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC if( uiNoResidualPass == 0 && m_pcEncCfg->m_useEarlySkipDetection ) { const CodingUnit &bestCU = *bestCS->getCU( partitioner.chType, partitioner.treeType ); - const PredictionUnit &bestPU = *bestCS->getPU( partitioner.chType ); if( bestCU.rootCbf == 0 ) { - if( bestPU.mergeFlag ) + if( bestCU.mergeFlag ) { m_modeCtrl.comprCUCtx->earlySkip = true; } @@ -2204,7 +2192,7 @@ void EncCu::xCheckRDCostMerge( CodingStructure *&tempCS, CodingStructure *&bestC { if( slice.numRefIdx[ uiRefListIdx ] > 0 ) { - absolute_MV += bestPU.mvd[uiRefListIdx].getAbsHor() + bestPU.mvd[uiRefListIdx].getAbsVer(); + absolute_MV += bestCU.mvd[uiRefListIdx].getAbsHor() + bestCU.mvd[uiRefListIdx].getAbsVer(); } } @@ -2255,12 +2243,12 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes cu.mmvdSkip = false; cu.skip = false; cu.mipFlag = false; - cu.bdpcmMode = 0; + cu.bdpcmM[CH_L] = 0; - PredictionUnit &pu = tempCS->addPU(cu, pm.chType, &cu); - pu.mergeFlag = true; - pu.regularMergeFlag = false; - PU::getGeoMergeCandidates(pu, mergeCtx); + cu.initPuData(); + cu.mergeFlag = true; + cu.regularMergeFlag = false; + CU::getGeoMergeCandidates(cu, mergeCtx); GeoComboCostList comboList; int bitsCandTB = floorLog2(GEO_NUM_PARTITION_MODE); @@ -2323,7 +2311,7 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes return; } - bool sameMV[MRG_MAX_NUM_CANDS] = { false }; + bool sameMV[MRG_MAX_NUM_CANDS] = { false, }; if (m_pcEncCfg->m_Geo > 1) { for (int m = 0; m < maxNumMergeCandidates; m++) @@ -2346,7 +2334,7 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes PelBuf sadBuf[MAX_TMP_BUFS]; for( int i = 0; i < maxNumMergeCandidates; i++) { - mcBuf[i] = m_aTmpStorageLCU[i].getCompactBuf( pu ); + mcBuf[i] = m_aTmpStorageLCU[i].getCompactBuf( cu ); sadBuf[i] = m_SortedPelUnitBufs.getBufFromSortedList(i)->Y(); } @@ -2362,9 +2350,9 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes continue; } - mergeCtx.setMergeInfo(pu, mergeCand); - PU::spanMotionInfo(pu, mergeCtx); - m_cInterSearch.motionCompensation(pu, mcBuf[mergeCand], REF_PIC_LIST_X); //new + mergeCtx.setMergeInfo(cu, mergeCand); + CU::spanMotionInfo(cu, mergeCtx); + m_cInterSearch.motionCompensation(cu, mcBuf[mergeCand], REF_PIC_LIST_X); //new g_pelBufOP.roundGeo( mcBuf[mergeCand].Y().buf, sadBuf[mergeCand].buf, numSamples, rshift, offset, lclpRng); @@ -2505,7 +2493,7 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes DistParam distParamSAD2 = m_cRdCost.setDistParam( tempCS->getOrgBuf(COMP_Y), m_SortedPelUnitBufs.getTestBuf(COMP_Y), sps.bitDepths[CH_L], dfunc); int geoNumMrgSATDCand = std::min(GEO_MAX_TRY_WEIGHTED_SATD, geoNumCobo); - const ClpRngs &clpRngs = pu.cu->slice->clpRngs; + const ClpRngs &clpRngs = cu.slice->clpRngs; const int EndGeo = std::min(geoNumCobo, ((m_pcEncCfg->m_Geo > 1) ? 10 : GEO_MAX_TRY_WEIGHTED_SAD)); for (uint8_t candidateIdx = 0; candidateIdx < EndGeo; candidateIdx++) @@ -2515,7 +2503,7 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes int mergeCand1 = comboList.list[candidateIdx].mergeIdx1; geoCombinations[candidateIdx] = m_SortedPelUnitBufs.getTestBuf(); - m_cInterSearch.weightedGeoBlk(clpRngs, pu, splitDir, CH_L, geoCombinations[candidateIdx], mcBuf[mergeCand0], mcBuf[mergeCand1]); + m_cInterSearch.weightedGeoBlk(clpRngs, cu, splitDir, CH_L, geoCombinations[candidateIdx], mcBuf[mergeCand0], mcBuf[mergeCand1]); distParamSAD2.cur = geoCombinations[candidateIdx].Y(); Distortion sad = distParamSAD2.distFunc(distParamSAD2); int mvBits = 2; @@ -2551,11 +2539,11 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes geoNumMrgSATDCand = geoNumMrgSATDCand > 2 ? 2 : geoNumMrgSATDCand; } - for (uint8_t i = 0; i < geoNumMrgSATDCand && isChromaEnabled(pu.chromaFormat); i++) + for (uint8_t i = 0; i < geoNumMrgSATDCand && isChromaEnabled(cu.chromaFormat); i++) { const uint8_t candidateIdx = geoRdModeList[i]; const GeoMergeCombo& ge = comboList.list[candidateIdx]; - m_cInterSearch.weightedGeoBlk(clpRngs, pu, ge.splitDir, CH_C, geoCombinations[candidateIdx], mcBuf[ge.mergeIdx0], mcBuf[ge.mergeIdx1]); + m_cInterSearch.weightedGeoBlk(clpRngs, cu, ge.splitDir, CH_C, geoCombinations[candidateIdx], mcBuf[ge.mergeIdx0], mcBuf[ge.mergeIdx1]); } tempCS->initStructData(encTestMode.qp); uint8_t iteration; @@ -2589,17 +2577,17 @@ void EncCu::xCheckRDCostMergeGeo(CodingStructure *&tempCS, CodingStructure *&bes cu.mmvdSkip = false; cu.skip = false; cu.mipFlag = false; - cu.bdpcmMode = 0; - PredictionUnit &pu = tempCS->addPU(cu, pm.chType, &cu); - pu.mergeFlag = true; - pu.regularMergeFlag = false; - pu.geoSplitDir = comboList.list[candidateIdx].splitDir; - pu.geoMergeIdx0 = comboList.list[candidateIdx].mergeIdx0; - pu.geoMergeIdx1 = comboList.list[candidateIdx].mergeIdx1; - pu.mmvdMergeFlag = false; - pu.mmvdMergeIdx = MAX_UINT; - - PU::spanGeoMotionInfo(pu, mergeCtx, pu.geoSplitDir, pu.geoMergeIdx0, pu.geoMergeIdx1); + cu.bdpcmM[CH_L] = 0; + cu.initPuData(); + cu.mergeFlag = true; + cu.regularMergeFlag = false; + cu.geoSplitDir = comboList.list[candidateIdx].splitDir; + cu.geoMergeIdx0 = comboList.list[candidateIdx].mergeIdx0; + cu.geoMergeIdx1 = comboList.list[candidateIdx].mergeIdx1; + cu.mmvdMergeFlag = false; + cu.mmvdMergeIdx = MAX_UINT; + + CU::spanGeoMotionInfo(cu, mergeCtx, cu.geoSplitDir, cu.geoMergeIdx0, cu.geoMergeIdx1); tempCS->getPredBuf().copyFrom(geoCombinations[candidateIdx]); xEncodeInterResidual(tempCS, bestCS, pm, encTestMode, noResidualPass, @@ -2629,7 +2617,7 @@ void EncCu::xCheckRDCostInter( CodingStructure *&tempCS, CodingStructure *&bestC cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; - CU::addPUs( cu ); + cu.initPuData(); m_cInterSearch.predInterSearch( cu, partitioner ); @@ -2648,7 +2636,7 @@ void EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes { Test_AMVR = false; } - else if (m_pcEncCfg->m_AMVRspeed > 4 && bestCS->getCU(partitioner.chType, partitioner.treeType)->pu->mergeFlag) + else if (m_pcEncCfg->m_AMVRspeed > 4 && bestCS->getCU(partitioner.chType, partitioner.treeType)->mergeFlag && !bestCS->getCU(partitioner.chType, partitioner.treeType)->ciip) { Test_AMVR = false; } @@ -2733,7 +2721,8 @@ void EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; - CU::addPUs(cu); + + cu.initPuData(); cu.imv = i; @@ -2753,9 +2742,9 @@ void EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes { continue; } - cu.pu->mvRefine = true; - m_cInterSearch.motionCompensation(*cu.pu, tempCS->getPredBuf() ); - cu.pu->mvRefine = false; + cu.mvRefine = true; + m_cInterSearch.motionCompensation(cu, tempCS->getPredBuf() ); + cu.mvRefine = false; } if( Do_OnceRes ) @@ -2766,7 +2755,6 @@ void EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes bestCostIMV = costCur; tempCSbest->getPredBuf().copyFrom(tempCS->getPredBuf()); tempCSbest->clearCUs(); - tempCSbest->clearPUs(); tempCSbest->clearTUs(); tempCSbest->copyStructure(*tempCS, partitioner.chType, TREE_D); } @@ -2830,8 +2818,8 @@ void EncCu::xCalDebCost( CodingStructure &cs, Partitioner &partitioner ) return; } - ComponentID compStr = ( cu->isSepTree() && !isLuma( partitioner.chType ) ) ? COMP_Cb : COMP_Y; - ComponentID compEnd = ( cu->isSepTree() && isLuma( partitioner.chType ) ) ? COMP_Y : COMP_Cr; + ComponentID compStr = ( CU::isSepTree(*cu) && !isLuma( partitioner.chType ) ) ? COMP_Cb : COMP_Y; + ComponentID compEnd = ( CU::isSepTree(*cu) && isLuma( partitioner.chType ) ) ? COMP_Y : COMP_Cr; const UnitArea currCsArea = clipArea( CS::getArea( cs, cs.area, partitioner.chType, partitioner.treeType ), *cs.picture ); PelStorage& picDbBuf = m_dbBuffer; //th we could reduce the buffer size and do some relocate @@ -2870,7 +2858,7 @@ void EncCu::xCalDebCost( CodingStructure &cs, Partitioner &partitioner ) PelBuf dbReco = picDbBuf.getBuf( compArea ); if (cs.slice->lmcsEnabled && isLuma(compId) ) { - if ((!cs.sps->LFNST)&& (!cs.sps->MTS) && reshapeData.getCTUFlag()) + if ((!cs.sps->LFNST) && (!cs.sps->MTS) && (!cs.sps->ISP)&& reshapeData.getCTUFlag()) { PelBuf rspReco = cs.getRspRecoBuf(); dbReco.copyFrom( rspReco ); @@ -2916,9 +2904,9 @@ void EncCu::xCalDebCost( CodingStructure &cs, Partitioner &partitioner ) } } - ChannelType dbChType = cu->isSepTree() ? partitioner.chType : MAX_NUM_CH; + ChannelType dbChType = CU::isSepTree(*cu) ? partitioner.chType : MAX_NUM_CH; - CHECK( cu->isSepTree() && !cu->Y().valid() && partitioner.chType == CH_L, "xxx" ); + CHECK( CU::isSepTree(*cu) && !cu->Y().valid() && partitioner.chType == CH_L, "xxx" ); //deblock if( leftEdgeAvai ) @@ -3027,10 +3015,8 @@ Distortion EncCu::xGetDistortionDb(CodingStructure &cs, CPelBuf& org, CPelBuf& r return dist; } -bool checkValidMvs(CodingUnit* cu) +bool checkValidMvs( const CodingUnit& cu) { - PredictionUnit& pu = *cu->pu; - // clang-format off const int affineShiftTab[3] = { @@ -3052,21 +3038,21 @@ bool checkValidMvs(CodingUnit* cu) for (int refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) { - if (pu.refIdx[refList] >= 0) + if (cu.refIdx[refList] >= 0) { - if (!cu->affine) + if (!cu.affine) { - mvShift = normalShiftTab[cu->imv]; - Mv signaledmvd(pu.mvd[refList].hor >> mvShift, pu.mvd[refList].ver >> mvShift); + mvShift = normalShiftTab[cu.imv]; + Mv signaledmvd(cu.mvd[refList].hor >> mvShift, cu.mvd[refList].ver >> mvShift); if (!((signaledmvd.hor >= MVD_MIN) && (signaledmvd.hor <= MVD_MAX)) || !((signaledmvd.ver >= MVD_MIN) && (signaledmvd.ver <= MVD_MAX))) return false; } else { - for (int ctrlP = 1 + (cu->affineType == AFFINEMODEL_6PARAM); ctrlP >= 0; ctrlP--) + for (int ctrlP = 1 + (cu.affineType == AFFINEMODEL_6PARAM); ctrlP >= 0; ctrlP--) { - mvShift = affineShiftTab[cu->imv]; - Mv signaledmvd(pu.mvdAffi[refList][ctrlP].hor >> mvShift, pu.mvdAffi[refList][ctrlP].ver >> mvShift); + mvShift = affineShiftTab[cu.imv]; + Mv signaledmvd(cu.mvdAffi[refList][ctrlP].hor >> mvShift, cu.mvdAffi[refList][ctrlP].ver >> mvShift); if (!((signaledmvd.hor >= MVD_MIN) && (signaledmvd.hor <= MVD_MAX)) || !((signaledmvd.ver >= MVD_MIN) && (signaledmvd.ver <= MVD_MAX))) return false;; } @@ -3075,23 +3061,23 @@ bool checkValidMvs(CodingUnit* cu) } // avoid MV exceeding 18-bit dynamic range const int maxMv = 1 << 17; - if (!cu->affine && !pu.mergeFlag) + if (!cu.affine && !cu.mergeFlag) { - if ((pu.refIdx[0] >= 0 && (pu.mv[0].getAbsHor() >= maxMv || pu.mv[0].getAbsVer() >= maxMv)) - || (pu.refIdx[1] >= 0 && (pu.mv[1].getAbsHor() >= maxMv || pu.mv[1].getAbsVer() >= maxMv))) + if ((cu.refIdx[0] >= 0 && (cu.mv[0].getAbsHor() >= maxMv || cu.mv[0].getAbsVer() >= maxMv)) + || (cu.refIdx[1] >= 0 && (cu.mv[1].getAbsHor() >= maxMv || cu.mv[1].getAbsVer() >= maxMv))) { return false; } } - if (cu->affine && !pu.mergeFlag) + if (cu.affine && !cu.mergeFlag) { for (int refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) { - if (pu.refIdx[refList] >= 0) + if (cu.refIdx[refList] >= 0) { - for (int ctrlP = 1 + (cu->affineType == AFFINEMODEL_6PARAM); ctrlP >= 0; ctrlP--) + for (int ctrlP = 1 + (cu.affineType == AFFINEMODEL_6PARAM); ctrlP >= 0; ctrlP--) { - if (pu.mvAffi[refList][ctrlP].getAbsHor() >= maxMv || pu.mvAffi[refList][ctrlP].getAbsVer() >= maxMv) + if (cu.mvAffi[refList][ctrlP].getAbsHor() >= maxMv || cu.mvAffi[refList][ctrlP].getAbsVer() >= maxMv) { return false; } @@ -3113,7 +3099,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&be CodingUnit* cu = tempCS->getCU( partitioner.chType, partitioner.treeType ); double bestCostInternal = MAX_DOUBLE; - if( ! checkValidMvs(cu)) + if( ! checkValidMvs(*cu)) return; double currBestCost = MAX_DOUBLE; @@ -3133,7 +3119,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&be bool doPreAnalyzeResi = false; const bool mtsAllowed = tempCS->sps->MTSInter && partitioner.currArea().lwidth() <= MTS_INTER_MAX_CU_SIZE && partitioner.currArea().lheight() <= MTS_INTER_MAX_CU_SIZE; - uint8_t sbtAllowed = cu->checkAllowedSbt(); + uint8_t sbtAllowed = CU::checkAllowedSbt(*cu); if( tempCS->pps->picWidthInLumaSamples < (uint32_t)SBT_FAST64_WIDTH_THRESHOLD || m_pcEncCfg->m_SBT>1) { sbtAllowed = ((cu->lwidth() > 32 || cu->lheight() > 32)) ? 0 : sbtAllowed; @@ -3159,13 +3145,13 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&be if( NULL != bestHasNonResi && (bestCostInternal > tempCS->cost) ) { bestCostInternal = tempCS->cost; - if (!(tempCS->getPU(partitioner.chType)->ciip)) + if (!(cu->ciip)) *bestHasNonResi = !cu->rootCbf; } if (cu->rootCbf == false) { - if (tempCS->getPU(partitioner.chType)->ciip) + if (cu->ciip) { tempCS->cost = MAX_DOUBLE; tempCS->costDbOffset = 0; @@ -3304,7 +3290,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&be if( NULL != bestHasNonResi && ( bestCostInternal > tempCS->cost ) ) { bestCostInternal = tempCS->cost; - if( !( tempCS->getPU( partitioner.chType )->ciip ) ) + if( !( cu->ciip ) ) *bestHasNonResi = !cu->rootCbf; } @@ -3428,11 +3414,9 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& cu.tileIdx = 0; cu.mmvdSkip = false; - PredictionUnit pu(tempCS->area); - pu.cu = &cu; - pu.cs = tempCS; - pu.regularMergeFlag = false; - PU::getAffineMergeCand(pu, affineMergeCtx); + cu.regularMergeFlag = false; + CU::getAffineMergeCand(cu, affineMergeCtx); + cu.regularMergeFlag = true; if (affineMergeCtx.numValidMergeCand <= 0) { @@ -3481,12 +3465,12 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; - PredictionUnit &pu = tempCS->addPU(cu, partitioner.chType, &cu); + cu.initPuData(); const DFunc dfunc = encTestMode.lossless || tempCS->slice->disableSATDForRd ? DF_SAD : DF_HAD; DistParam distParam = m_cRdCost.setDistParam(tempCS->getOrgBuf(COMP_Y), m_SortedPelUnitBufs.getTestBuf(COMP_Y), sps.bitDepths[CH_L], dfunc); - bool sameMV[5] = { false }; + bool sameMV[MRG_MAX_NUM_CANDS+1] = { false, }; if (m_pcEncCfg->m_Affine > 1) { for (int m = 0; m < affineMergeCtx.numValidMergeCand; m++) @@ -3495,17 +3479,14 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& { sameMV[m] = m!=0; } - else + else if (sameMV[m + 1] == false) { - if (sameMV[m + 1] == false) + for (int n = m + 1; n < affineMergeCtx.numValidMergeCand; n++) { - for (int n = m + 1; n < affineMergeCtx.numValidMergeCand; n++) + if( (affineMergeCtx.mvFieldNeighbours[(m << 1) + 0]->mv == affineMergeCtx.mvFieldNeighbours[(n << 1) + 0]->mv) + && (affineMergeCtx.mvFieldNeighbours[(m << 1) + 1]->mv == affineMergeCtx.mvFieldNeighbours[(n << 1) + 1]->mv)) { - if( (affineMergeCtx.mvFieldNeighbours[(m << 1) + 0]->mv == affineMergeCtx.mvFieldNeighbours[(n << 1) + 0]->mv) - && (affineMergeCtx.mvFieldNeighbours[(m << 1) + 1]->mv == affineMergeCtx.mvFieldNeighbours[(n << 1) + 1]->mv)) - { - sameMV[n] = true; - } + sameMV[n] = true; } } } @@ -3520,31 +3501,31 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& } // set merge information - pu.interDir = affineMergeCtx.interDirNeighbours[uiMergeCand]; - pu.mergeFlag = true; - pu.regularMergeFlag = false; - pu.mergeIdx = uiMergeCand; + cu.interDir = affineMergeCtx.interDirNeighbours[uiMergeCand]; + cu.mergeFlag = true; + cu.regularMergeFlag = false; + cu.mergeIdx = uiMergeCand; cu.affineType = affineMergeCtx.affineType[uiMergeCand]; cu.BcwIdx = affineMergeCtx.BcwIdx[uiMergeCand]; - pu.mergeType = affineMergeCtx.mergeType[uiMergeCand]; - if (pu.mergeType == MRG_TYPE_SUBPU_ATMVP) + cu.mergeType = affineMergeCtx.mergeType[uiMergeCand]; + if (cu.mergeType == MRG_TYPE_SUBPU_ATMVP) { - pu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0][0].refIdx; - pu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1][0].refIdx; - PU::spanMotionInfo(pu, mrgCtx); + cu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0][0].refIdx; + cu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1][0].refIdx; + CU::spanMotionInfo(cu, mrgCtx); } else { - PU::setAllAffineMvField(pu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0], REF_PIC_LIST_0); - PU::setAllAffineMvField(pu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1], REF_PIC_LIST_1); - PU::spanMotionInfo(pu); + CU::setAllAffineMvField(cu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0], REF_PIC_LIST_0); + CU::setAllAffineMvField(cu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1], REF_PIC_LIST_1); + CU::spanMotionInfo(cu); } distParam.cur.buf = m_SortedPelUnitBufs.getTestBuf().Y().buf; - pu.mcControl = 2; - m_cInterSearch.motionCompensation(pu, m_SortedPelUnitBufs.getTestBuf(), REF_PIC_LIST_X); - pu.mcControl = 0; + cu.mcControl = 2; + m_cInterSearch.motionCompensation(cu, m_SortedPelUnitBufs.getTestBuf(), REF_PIC_LIST_X); + cu.mcControl = 0; Distortion uiSad = distParam.distFunc(distParam); uint32_t uiBitsCand = uiMergeCand + 1; @@ -3618,46 +3599,46 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; - PredictionUnit &pu = tempCS->addPU(cu, partitioner.chType, &cu); + cu.initPuData(); // set merge information - pu.mergeFlag = true; - pu.mergeIdx = uiMergeCand; - pu.interDir = affineMergeCtx.interDirNeighbours[uiMergeCand]; + cu.mergeFlag = true; + cu.mergeIdx = uiMergeCand; + cu.interDir = affineMergeCtx.interDirNeighbours[uiMergeCand]; cu.affineType = affineMergeCtx.affineType[uiMergeCand]; cu.BcwIdx = affineMergeCtx.BcwIdx[uiMergeCand]; - pu.mergeType = affineMergeCtx.mergeType[uiMergeCand]; - if (pu.mergeType == MRG_TYPE_SUBPU_ATMVP) + cu.mergeType = affineMergeCtx.mergeType[uiMergeCand]; + if (cu.mergeType == MRG_TYPE_SUBPU_ATMVP) { - pu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0][0].refIdx; - pu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1][0].refIdx; - PU::spanMotionInfo(pu, mrgCtx); + cu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0][0].refIdx; + cu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1][0].refIdx; + CU::spanMotionInfo(cu, mrgCtx); } else { - PU::setAllAffineMvField(pu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0], REF_PIC_LIST_0); - PU::setAllAffineMvField(pu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1], REF_PIC_LIST_1); + CU::setAllAffineMvField(cu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0], REF_PIC_LIST_0); + CU::setAllAffineMvField(cu, affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1], REF_PIC_LIST_1); - PU::spanMotionInfo(pu); + CU::spanMotionInfo(cu); } PelUnitBuf* sortedListBuf = m_SortedPelUnitBufs.getBufFromSortedList(uiMrgHADIdx); if (sortedListBuf) { - tempCS->getPredBuf().copyFrom(*sortedListBuf, true, false); // Copy Luma Only - pu.mcControl = 4; - m_cInterSearch.motionCompensation(pu, tempCS->getPredBuf(), REF_PIC_LIST_X); + tempCS->getPredBuf().Y().copyFrom( sortedListBuf->Y() ); // Copy Luma Only + cu.mcControl = 4; + m_cInterSearch.motionCompensation(cu, tempCS->getPredBuf(), REF_PIC_LIST_X); } else { - m_cInterSearch.motionCompensation(pu, tempCS->getPredBuf()); + m_cInterSearch.motionCompensation(cu, tempCS->getPredBuf()); } xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, uiNoResidualPass, (uiNoResidualPass == 0 ? &candHasNoResidual[uiMergeCand] : NULL)); - if (m_pcEncCfg->m_useFastDecisionForMerge && !bestIsSkip) + if (m_pcEncCfg->m_useFastDecisionForMerge && !bestIsSkip && !bestCS->cus.empty()) { bestIsSkip = bestCS->getCU(partitioner.chType, partitioner.treeType)->rootCbf == 0; } @@ -3667,11 +3648,10 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& if (uiNoResidualPass == 0 && m_pcEncCfg->m_useEarlySkipDetection) { const CodingUnit &bestCU = *bestCS->getCU(partitioner.chType, partitioner.treeType); - const PredictionUnit &bestPU = *bestCS->getPU(partitioner.chType); - if (bestCU.rootCbf == 0) + if( bestCU.rootCbf == 0) { - if (bestPU.mergeFlag) + if(bestCU.mergeFlag) { m_modeCtrl.comprCUCtx->earlySkip = true; } @@ -3683,7 +3663,7 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& { if (slice.numRefIdx[uiRefListIdx] > 0) { - absolute_MV += bestPU.mvd[uiRefListIdx].getAbsHor() + bestPU.mvd[uiRefListIdx].getAbsVer(); + absolute_MV += bestCU.mvd[uiRefListIdx].getAbsHor() + bestCU.mvd[uiRefListIdx].getAbsVer(); } } @@ -3699,15 +3679,15 @@ void EncCu::xCheckRDCostAffineMerge(CodingStructure *&tempCS, CodingStructure *& STAT_COUNT_CU_MODES( partitioner.chType == CH_L && !tempCS->slice->isIntra(), g_cuCounters2D[CU_MODES_TESTED][Log2( tempCS->area.lheight() )][Log2( tempCS->area.lwidth() )] ); } -uint64_t EncCu::xCalcPuMeBits(const PredictionUnit& pu) +uint64_t EncCu::xCalcPuMeBits(const CodingUnit& cu) { - assert(pu.mergeFlag); - assert(!CU::isIBC(*pu.cu)); + assert(cu.mergeFlag); + assert(!CU::isIBC(cu)); m_CABACEstimator->resetBits(); - m_CABACEstimator->merge_flag(pu); - if (pu.mergeFlag) + m_CABACEstimator->merge_flag(cu); + if (cu.mergeFlag) { - m_CABACEstimator->merge_data(pu); + m_CABACEstimator->merge_data(cu); } return m_CABACEstimator->getEstFracBits(); } @@ -3717,13 +3697,14 @@ double EncCu::xCalcDistortion(CodingStructure *&cur_CS, ChannelType chType, int const auto currDist1 = m_cRdCost.getDistPart(cur_CS->getOrgBuf( COMP_Y ), cur_CS->getPredBuf( COMP_Y ), BitDepth, COMP_Y, DF_HAD); unsigned int uiMvBits = 0; unsigned imvShift = imv == IMV_HPEL ? 1 : (imv << 1); - if (cur_CS->getPU(chType)->interDir != 2) + const CodingUnit& cu = *cur_CS->getCU( chType, TREE_D); + if (cu.interDir != 2) { - uiMvBits += m_cRdCost.getBitsOfVectorWithPredictor(cur_CS->getPU(chType)->mvd[0].hor, cur_CS->getPU(chType)->mvd[0].ver, imvShift + MV_FRACTIONAL_BITS_DIFF); + uiMvBits += m_cRdCost.getBitsOfVectorWithPredictor(cu.mvd[0].hor, cu.mvd[0].ver, imvShift + MV_FRACTIONAL_BITS_DIFF); } - if (cur_CS->getPU(chType)->interDir != 1) + if (cu.interDir != 1) { - uiMvBits += m_cRdCost.getBitsOfVectorWithPredictor(cur_CS->getPU(chType)->mvd[1].hor, cur_CS->getPU(chType)->mvd[1].ver, imvShift + MV_FRACTIONAL_BITS_DIFF); + uiMvBits += m_cRdCost.getBitsOfVectorWithPredictor(cu.mvd[1].hor, cu.mvd[1].ver, imvShift + MV_FRACTIONAL_BITS_DIFF); } return (double(currDist1) + (double)m_cRdCost.getCost(uiMvBits)); } diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index e32034d4e..31f885698 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncCu.h \brief Coding Unit (CU) encoder class (header) */ #pragma once -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CABACWriter.h" #include "IntraSearch.h" #include "InterSearch.h" @@ -192,6 +196,8 @@ class EncCu double m_mergeBestSATDCost; MotionInfo m_subPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; + + Mv m_refinedMvdL0[MRG_MAX_NUM_CANDS][MAX_NUM_SUBCU_DMVR]; double m_sbtCostSave[2]; // thread stuff @@ -243,7 +249,7 @@ class EncCu void xEncodeInterResidual ( CodingStructure*& tempCS, CodingStructure*& bestCS, Partitioner& pm, const EncTestMode& encTestMode, int residualPass = 0, bool* bestHasNonResi = NULL, double* equBcwCost = NULL ); - uint64_t xCalcPuMeBits ( const PredictionUnit& pu); + uint64_t xCalcPuMeBits ( const CodingUnit& cu); double xCalcDistortion ( CodingStructure *&cur_CS, ChannelType chType, int BitDepth, int imv); int xCheckMMVDCand ( uint32_t& mmvdMergeCand, int& bestDir, int tempNum, double& bestCostOffset, double& bestCostMerge, double bestCostList ); }; diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 75677f372..8508c7d6b 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncGOP.cpp @@ -51,9 +55,10 @@ vvc@hhi.fraunhofer.de #include "CommonLib/UnitTools.h" #include "CommonLib/dtrace_codingstruct.h" #include "CommonLib/dtrace_buffer.h" +#include "CommonLib/MD5.h" #include "DecoderLib/DecLib.h" #include "BitAllocation.h" -#include "libmd5/MD5.h" +#include "EncHRD.h" #include @@ -131,7 +136,7 @@ void trySkipOrDecodePicture( bool& decPic, bool& encPic, const EncCfg& cfg, Pict { if( cfg.m_forceDecodeBitstream1 ) { - if( 0 != ( ffwdDecoder.bDecode1stPart = tryDecodePicture( pic, pic->getPOC(), cfg.m_decodeBitstreams[ 0 ], ffwdDecoder, apsMap, false ) ) ) + if( 0 != ( ffwdDecoder.bDecode1stPart = tryDecodePicture( pic, pic->getPOC(), cfg.m_decodeBitstreams[ 0 ], ffwdDecoder, &apsMap, false ) ) ) { decPic = ffwdDecoder.bDecode1stPart; } @@ -139,7 +144,7 @@ void trySkipOrDecodePicture( bool& decPic, bool& encPic, const EncCfg& cfg, Pict else { // update decode decision - if( (0 != ( ffwdDecoder.bDecode1stPart = ( cfg.m_switchPOC != pic->getPOC() ) )) && ( 0 != ( ffwdDecoder.bDecode1stPart = tryDecodePicture( pic, pic->getPOC(), cfg.m_decodeBitstreams[ 0 ], ffwdDecoder, apsMap, false, cfg.m_switchPOC ) ) ) ) + if( (0 != ( ffwdDecoder.bDecode1stPart = ( cfg.m_switchPOC != pic->getPOC() ) )) && ( 0 != ( ffwdDecoder.bDecode1stPart = tryDecodePicture( pic, pic->getPOC(), cfg.m_decodeBitstreams[ 0 ], ffwdDecoder, &apsMap, false, cfg.m_switchPOC ) ) ) ) { decPic = ffwdDecoder.bDecode1stPart; return; @@ -147,7 +152,7 @@ void trySkipOrDecodePicture( bool& decPic, bool& encPic, const EncCfg& cfg, Pict else if( pic->getPOC() ) { // reset decoder if used and not required any further - tryDecodePicture( NULL, 0, std::string( "" ), ffwdDecoder, apsMap ); + tryDecodePicture( NULL, 0, std::string( "" ), ffwdDecoder, &apsMap ); } } } @@ -172,7 +177,7 @@ void trySkipOrDecodePicture( bool& decPic, bool& encPic, const EncCfg& cfg, Pict expectedPoc = pic->getPOC() - iRestartIntraPOC; slice0.copySliceInfo( pic->slices[ 0 ], false ); } - if( bDecode2ndPart && (0 != (bDecode2ndPart = tryDecodePicture( pic, expectedPoc, cfg.m_decodeBitstreams[ 1 ], ffwdDecoder, apsMap, true )) )) + if( bDecode2ndPart && (0 != (bDecode2ndPart = tryDecodePicture( pic, expectedPoc, cfg.m_decodeBitstreams[ 1 ], ffwdDecoder, &apsMap, true )) )) { decPic = bDecode2ndPart; if ( cfg.m_bs2ModPOCAndType ) @@ -239,6 +244,8 @@ EncGOP::EncGOP() , m_associatedIRAPPOC ( 0 ) , m_associatedIRAPType ( NAL_UNIT_CODED_SLICE_IDR_N_LP ) , m_pcEncCfg ( nullptr ) + , m_pcRateCtrl ( nullptr ) + , m_pcEncHRD ( nullptr ) , m_gopApsMap ( MAX_NUM_APS * MAX_NUM_APS_TYPE ) , m_numPicEncoder ( 0 ) , m_gopThreadPool ( nullptr ) @@ -252,10 +259,10 @@ EncGOP::EncGOP() EncGOP::~EncGOP() { - if( ! m_pcEncCfg->m_decodeBitstreams[ 0 ].empty() || ! m_pcEncCfg->m_decodeBitstreams[ 1 ].empty() ) + if( m_pcEncCfg && (! m_pcEncCfg->m_decodeBitstreams[ 0 ].empty() || ! m_pcEncCfg->m_decodeBitstreams[ 1 ].empty()) ) { // reset potential decoder resources - tryDecodePicture( NULL, 0, std::string(""), m_ffwdDecoder, m_gopApsMap ); + tryDecodePicture( NULL, 0, std::string(""), m_ffwdDecoder, &m_gopApsMap ); } for ( auto& picEncoder : m_picEncoderList ) @@ -275,12 +282,14 @@ EncGOP::~EncGOP() } -void EncGOP::init( const EncCfg& encCfg, const SPS& sps, const PPS& pps, RateCtrl& rateCtrl, NoMallocThreadPool* threadPool ) +void EncGOP::init( const EncCfg& encCfg, const SPS& sps, const PPS& pps, RateCtrl& rateCtrl, EncHRD& encHrd, NoMallocThreadPool* threadPool ) { m_pcEncCfg = &encCfg; m_pcRateCtrl = &rateCtrl; + m_pcEncHRD = &encHrd; + - m_seiEncoder.init( encCfg ); + m_seiEncoder.init( encCfg, encHrd ); m_Reshaper.init ( encCfg ); const int maxEncoder = ( encCfg.m_frameParallel && encCfg.m_numFppThreads > 1 ) ? encCfg.m_numFppThreads : 1; @@ -428,6 +437,7 @@ void EncGOP::encodePicture( std::vector encList, PicList& picList, Acc if ( pic->writePic ) { xWritePicture( *pic, au, isEncodeLtRef ); + xSyncAlfAps( *pic, m_gopApsMap, pic->picApsMap ); } xUpdateAfterPicRC( pic ); @@ -1200,6 +1210,7 @@ void EncGOP::xWritePicture( Picture& pic, AccessUnit& au, bool isEncodeLtRef ) } m_actualTotalBits += xWriteParameterSets( pic, au, m_HLSWriter ); + xWriteLeadingSEIs( pic, au ); m_actualTotalBits += xWritePictureSlices( pic, au, m_HLSWriter ); pic.encTime.stopTimer(); @@ -1207,7 +1218,6 @@ void EncGOP::xWritePicture( Picture& pic, AccessUnit& au, bool isEncodeLtRef ) std::string digestStr; xWriteTrailingSEIs( pic, au, digestStr ); xPrintPictureInfo ( pic, au, digestStr, m_pcEncCfg->m_printFrameMSE, isEncodeLtRef ); - xSyncAlfAps( pic, m_gopApsMap, pic.picApsMap ); } @@ -1231,7 +1241,7 @@ int EncGOP::xWriteParameterSets( Picture& pic, AccessUnit& accessUnit, HLSWriter } bool IrapOrGdrAu = slice->picHeader->gdrPic || (slice->isIRAP() && !slice->pps->mixedNaluTypesInPic); - if ((( slice->vps->maxLayers > 1 && IrapOrGdrAu) || m_pcEncCfg->m_AccessUnitDelimiter) && slice->nuhLayerId ) + if ((( slice->vps->maxLayers > 1 && IrapOrGdrAu) || m_pcEncCfg->m_AccessUnitDelimiter) && !slice->nuhLayerId ) { xWriteAccessUnitDelimiter( accessUnit, slice, IrapOrGdrAu, hlsWriter ); } @@ -1248,7 +1258,7 @@ int EncGOP::xWriteParameterSets( Picture& pic, AccessUnit& accessUnit, HLSWriter const bool doAPS = aps && apsMap.getChangedFlag( apsMapIdx ); if ( doAPS ) { - aps->chromaPresentFlag = slice->sps->chromaFormatIdc != CHROMA_400; + aps->chromaPresent = slice->sps->chromaFormatIdc != CHROMA_400; aps->temporalId = slice->TLayer; actualTotalBits += xWriteAPS( accessUnit, aps, hlsWriter, NAL_UNIT_PREFIX_APS ); apsMap.clearChangedFlag( apsMapIdx ); @@ -1284,7 +1294,7 @@ int EncGOP::xWriteParameterSets( Picture& pic, AccessUnit& accessUnit, HLSWriter if ( writeAps ) { - aps->chromaPresentFlag = slice->sps->chromaFormatIdc != CHROMA_400; + aps->chromaPresent = slice->sps->chromaFormatIdc != CHROMA_400; aps->temporalId = slice->TLayer; actualTotalBits += xWriteAPS( accessUnit, aps, hlsWriter, NAL_UNIT_PREFIX_APS ); apsMap.clearChangedFlag( apsMapIdx ); @@ -1331,6 +1341,47 @@ int EncGOP::xWritePictureSlices( Picture& pic, AccessUnit& accessUnit, HLSWriter return numBytes * 8; } +void EncGOP::xWriteLeadingSEIs( const Picture& pic, AccessUnit& accessUnit ) +{ + const Slice* slice = pic.slices[ 0 ]; + SEIMessages leadingSeiMessages; + + bool bpPresentInAU = false; + + if((m_pcEncCfg->m_bufferingPeriodSEIEnabled) && (slice->isIRAP() || slice->nalUnitType == NAL_UNIT_CODED_SLICE_GDR) && + slice->nuhLayerId==slice->vps->layerId[0] && (slice->sps->hrdParametersPresent)) + { + SEIBufferingPeriod *bufferingPeriodSEI = new SEIBufferingPeriod(); + bool noLeadingPictures = ( (slice->nalUnitType!= NAL_UNIT_CODED_SLICE_IDR_W_RADL) && (slice->nalUnitType!= NAL_UNIT_CODED_SLICE_CRA) ); + m_seiEncoder.initBufferingPeriodSEI(*bufferingPeriodSEI, noLeadingPictures); + m_pcEncHRD->bufferingPeriodSEI = *bufferingPeriodSEI; + m_pcEncHRD->bufferingPeriodInitialized = true; + + leadingSeiMessages.push_back(bufferingPeriodSEI); + bpPresentInAU = true; + } + +// if (m_pcEncCfg->m_dependentRAPIndicationSEIEnabled && slice->isDRAP ) +// { +// SEIDependentRAPIndication *dependentRAPIndicationSEI = new SEIDependentRAPIndication(); +// m_seiEncoder.initDrapSEI( dependentRAPIndicationSEI ); +// leadingSeiMessages.push_back(dependentRAPIndicationSEI); +// } + + if( m_pcEncCfg->m_pictureTimingSEIEnabled && m_pcEncCfg->m_bufferingPeriodSEIEnabled ) + { + SEIMessages nestedSeiMessages; + SEIMessages duInfoSeiMessages; + uint32_t numDU = 1; + m_seiEncoder.initPictureTimingSEI( leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, slice, numDU, bpPresentInAU ); + } + + // Note: using accessUnit.end() works only as long as this function is called after slice coding and before EOS/EOB NAL units + AccessUnit::iterator pos = accessUnit.end(); + xWriteSEISeparately( NAL_UNIT_PREFIX_SEI, leadingSeiMessages, accessUnit, pos, slice->TLayer, slice->sps ); + + deleteSEIs( leadingSeiMessages ); +} void EncGOP::xWriteTrailingSEIs( const Picture& pic, AccessUnit& accessUnit, std::string& digestStr ) { @@ -1341,7 +1392,7 @@ void EncGOP::xWriteTrailingSEIs( const Picture& pic, AccessUnit& accessUnit, std { SEIDecodedPictureHash *decodedPictureHashSei = new SEIDecodedPictureHash(); const CPelUnitBuf recoBuf = pic.cs->getRecoBuf(); - m_seiEncoder.initDecodedPictureHashSEI( decodedPictureHashSei, recoBuf, digestStr, slice->sps->bitDepths ); + m_seiEncoder.initDecodedPictureHashSEI( *decodedPictureHashSei, recoBuf, digestStr, slice->sps->bitDepths ); trailingSeiMessages.push_back( decodedPictureHashSei ); } @@ -1424,7 +1475,7 @@ void EncGOP::xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUn return; } OutputNALUnit nalu(naluType, temporalId); - m_seiWriter.writeSEImessages(nalu.m_Bitstream, seiMessages, sps, false); + m_seiWriter.writeSEImessages(nalu.m_Bitstream, seiMessages, *m_pcEncHRD, false, temporalId); auPos = accessUnit.insert(auPos, new NALUnitEBSP(nalu)); auPos++; } @@ -1441,7 +1492,7 @@ void EncGOP::xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages SEIMessages tmpMessages; tmpMessages.push_back(*sei); OutputNALUnit nalu(naluType, temporalId); - m_seiWriter.writeSEImessages(nalu.m_Bitstream, tmpMessages, sps, false); + m_seiWriter.writeSEImessages(nalu.m_Bitstream, tmpMessages, *m_pcEncHRD, false, temporalId); auPos = accessUnit.insert(auPos, new NALUnitEBSP(nalu)); auPos++; } @@ -1544,8 +1595,16 @@ void EncGOP::picInitRateControl( int gopId, Picture& pic, Slice* slice ) { bits = 200; } - m_pcRateCtrl->encRCPic->targetBits = bits; - m_pcRateCtrl->encRCPic->bitsLeft = bits; + + if ( m_pcEncCfg->m_RCNumPasses == 2 ) + { + m_pcRateCtrl->encRCPic->bitsLeft = m_pcRateCtrl->encRCPic->targetBits; + } + else + { + m_pcRateCtrl->encRCPic->targetBits = bits; + m_pcRateCtrl->encRCPic->bitsLeft = bits; + } } std::list listPreviousPicture = m_pcRateCtrl->getPicList(); @@ -1664,6 +1723,8 @@ void EncGOP::xCalculateAddPSNR( const Picture* pic, CPelUnitBuf cPicD, AccessUni } } + m_pcRateCtrl->addRCPassStats( slice->poc, slice->sliceQp, numRBSPBytes * 8, dPSNR[COMP_Y], dPSNR[COMP_Cb], dPSNR[COMP_Cr], slice->isIntra(), slice->TLayer ); + const uint32_t uibits = numRBSPBytes * 8; //===== add PSNR ===== @@ -1700,63 +1761,77 @@ void EncGOP::xCalculateAddPSNR( const Picture* pic, CPelUnitBuf cPicD, AccessUni if( m_pcEncCfg->m_verbosity >= NOTICE ) { - std::string cInfo = print("POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits", - slice->poc, - slice->TLayer, - c, - slice->sliceQp, - uibits ); + if( ! m_pcRateCtrl->rcIsFinalPass ) + { + std::string cInfo = print("RC pass %d/%d, analyze poc %d", + m_pcRateCtrl->rcPass + 1, + m_pcRateCtrl->rcMaxPass + 1, + slice->poc ); - std::string cPSNR = print(" [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", dPSNR[COMP_Y], dPSNR[COMP_Cb], dPSNR[COMP_Cr] ); + accessUnit.m_cInfo.append( cInfo ); - accessUnit.m_cInfo.append( cInfo ); - accessUnit.m_cInfo.append( cPSNR ); + msg( NOTICE, cInfo.c_str() ); + } + else + { + std::string cInfo = print("POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits", + slice->poc, + slice->TLayer, + c, + slice->sliceQp, + uibits ); - msg( NOTICE, cInfo.c_str() ); - msg( NOTICE, cPSNR.c_str() ); + std::string cPSNR = print(" [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", dPSNR[COMP_Y], dPSNR[COMP_Cb], dPSNR[COMP_Cr] ); + accessUnit.m_cInfo.append( cInfo ); + accessUnit.m_cInfo.append( cPSNR ); - if ( m_pcEncCfg->m_printHexPsnr ) - { - uint64_t xPsnr[MAX_NUM_COMP]; - for (int i = 0; i < MAX_NUM_COMP; i++) + msg( NOTICE, cInfo.c_str() ); + msg( NOTICE, cPSNR.c_str() ); + + + if ( m_pcEncCfg->m_printHexPsnr ) { - std::copy(reinterpret_cast(&dPSNR[i]), - reinterpret_cast(&dPSNR[i]) + sizeof(dPSNR[i]), - reinterpret_cast(&xPsnr[i])); - } + uint64_t xPsnr[MAX_NUM_COMP]; + for (int i = 0; i < MAX_NUM_COMP; i++) + { + std::copy(reinterpret_cast(&dPSNR[i]), + reinterpret_cast(&dPSNR[i]) + sizeof(dPSNR[i]), + reinterpret_cast(&xPsnr[i])); + } - std::string cPSNRHex = print(" [xY %16" PRIx64 " xU %16" PRIx64 " xV %16" PRIx64 "]", xPsnr[COMP_Y], xPsnr[COMP_Cb], xPsnr[COMP_Cr]); + std::string cPSNRHex = print(" [xY %16" PRIx64 " xU %16" PRIx64 " xV %16" PRIx64 "]", xPsnr[COMP_Y], xPsnr[COMP_Cb], xPsnr[COMP_Cr]); - accessUnit.m_cInfo.append( cPSNRHex ); - msg(NOTICE, cPSNRHex.c_str() ); - } + accessUnit.m_cInfo.append( cPSNRHex ); + msg(NOTICE, cPSNRHex.c_str() ); + } - if( printFrameMSE ) - { - std::string cFrameMSE = print( " [Y MSE %6.4lf U MSE %6.4lf V MSE %6.4lf]", MSEyuvframe[COMP_Y], MSEyuvframe[COMP_Cb], MSEyuvframe[COMP_Cr]); - accessUnit.m_cInfo.append( cFrameMSE ); - msg(NOTICE, cFrameMSE.c_str() ); - } + if( printFrameMSE ) + { + std::string cFrameMSE = print( " [Y MSE %6.4lf U MSE %6.4lf V MSE %6.4lf]", MSEyuvframe[COMP_Y], MSEyuvframe[COMP_Cb], MSEyuvframe[COMP_Cr]); + accessUnit.m_cInfo.append( cFrameMSE ); + msg(NOTICE, cFrameMSE.c_str() ); + } - std::string cEncTime = print(" [ET %5d ]", pic->encTime.getTimerInSec() ); - accessUnit.m_cInfo.append( cEncTime ); - msg(NOTICE, cEncTime.c_str() ); + std::string cEncTime = print(" [ET %5d ]", pic->encTime.getTimerInSec() ); + accessUnit.m_cInfo.append( cEncTime ); + msg(NOTICE, cEncTime.c_str() ); - std::string cRefPics; - for( int iRefList = 0; iRefList < 2; iRefList++ ) - { - std::string tmp = print(" [L%d ", iRefList); - cRefPics.append( tmp ); - for( int iRefIndex = 0; iRefIndex < slice->numRefIdx[ iRefList ]; iRefIndex++ ) + std::string cRefPics; + for( int iRefList = 0; iRefList < 2; iRefList++ ) { - tmp = print("%d ", slice->getRefPOC( RefPicList( iRefList ), iRefIndex)); + std::string tmp = print(" [L%d ", iRefList); cRefPics.append( tmp ); + for( int iRefIndex = 0; iRefIndex < slice->numRefIdx[ iRefList ]; iRefIndex++ ) + { + tmp = print("%d ", slice->getRefPOC( RefPicList( iRefList ), iRefIndex)); + cRefPics.append( tmp ); + } + cRefPics.append( "]" ); } - cRefPics.append( "]" ); + accessUnit.m_cInfo.append( cRefPics ); + msg(NOTICE, cRefPics.c_str() ); } - accessUnit.m_cInfo.append( cRefPics ); - msg(NOTICE, cRefPics.c_str() ); } } @@ -1808,31 +1883,34 @@ void EncGOP::xPrintPictureInfo( const Picture& pic, AccessUnit& accessUnit, cons double PSNR_Y; xCalculateAddPSNR( &pic, pic.getRecoBuf(), accessUnit, printFrameMSE, &PSNR_Y, isEncodeLtRef ); - std::string modeName; - switch ( m_pcEncCfg->m_decodedPictureHashSEIType ) - { - case HASHTYPE_MD5: - modeName = "MD5"; - break; - case HASHTYPE_CRC: - modeName = "CRC"; - break; - case HASHTYPE_CHECKSUM: - modeName = "Checksum"; - break; - default: - break; - } - - if ( modeName.length() ) + if( m_pcRateCtrl->rcIsFinalPass ) { - if ( digestStr.empty() ) + std::string modeName; + switch ( m_pcEncCfg->m_decodedPictureHashSEIType ) { - msg( NOTICE, " [%s:%s]", modeName.c_str(), "?" ); + case HASHTYPE_MD5: + modeName = "MD5"; + break; + case HASHTYPE_CRC: + modeName = "CRC"; + break; + case HASHTYPE_CHECKSUM: + modeName = "Checksum"; + break; + default: + break; } - else + + if ( modeName.length() ) { - msg( NOTICE, " [%s:%s]", modeName.c_str(), digestStr.c_str() ); + if ( digestStr.empty() ) + { + msg( NOTICE, " [%s:%s]", modeName.c_str(), "?" ); + } + else + { + msg( NOTICE, " [%s:%s]", modeName.c_str(), digestStr.c_str() ); + } } } diff --git a/source/Lib/EncoderLib/EncGOP.h b/source/Lib/EncoderLib/EncGOP.h index e69576748..b2251bd38 100644 --- a/source/Lib/EncoderLib/EncGOP.h +++ b/source/Lib/EncoderLib/EncGOP.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncGOP.h \brief GOP encoder class (header) */ @@ -60,7 +64,7 @@ vvc@hhi.fraunhofer.de #include #include #include -#include "../../../include/vvenc/Nal.h" +#include "vvenc/Nal.h" #include "Utilities/NoMallocThreadPool.h" #include @@ -75,6 +79,7 @@ namespace vvenc { class InputByteStream; class DecLib; +class EncHRD; struct FFwdDecoder { @@ -123,8 +128,9 @@ class EncGOP EncReshape m_Reshaper; BlkStat m_BlkStat; FFwdDecoder m_ffwdDecoder; - ParameterSetMap m_gopApsMap; RateCtrl* m_pcRateCtrl; + EncHRD* m_pcEncHRD; + ParameterSetMap m_gopApsMap; std::vector m_picEncoderList; std::list m_encodePics; @@ -143,7 +149,7 @@ class EncGOP EncGOP(); virtual ~EncGOP(); - void init ( const EncCfg& encCfg, const SPS& sps, const PPS& pps, RateCtrl& rateCtrl, NoMallocThreadPool* threadPool ); + void init ( const EncCfg& encCfg, const SPS& sps, const PPS& pps, RateCtrl& rateCtrl, EncHRD& encHrd, NoMallocThreadPool* threadPool ); void encodePicture ( std::vector encList, PicList& picList, AccessUnit& au, bool isEncodeLtRef ); void finishEncPicture ( EncPicture* picEncoder, Picture& pic ); void printOutSummary ( int numAllPicCoded, const bool printMSEBasedSNR, const bool printSequenceMSE, const bool printHexPsnr, const BitDepths &bitDepths ); @@ -173,6 +179,7 @@ class EncGOP void xWritePicture ( Picture& pic, AccessUnit& au, bool isEncodeLtRef ); int xWriteParameterSets ( Picture& pic, AccessUnit& accessUnit, HLSWriter& hlsWriter ); int xWritePictureSlices ( Picture& pic, AccessUnit& accessUnit, HLSWriter& hlsWriter ); + void xWriteLeadingSEIs ( const Picture& pic, AccessUnit& accessUnit ); void xWriteTrailingSEIs ( const Picture& pic, AccessUnit& accessUnit, std::string& digestStr ); int xWriteVPS ( AccessUnit &accessUnit, const VPS *vps, HLSWriter& hlsWriter ); int xWriteDCI ( AccessUnit &accessUnit, const DCI *dci, HLSWriter& hlsWriter ); diff --git a/source/Lib/EncoderLib/EncHRD.cpp b/source/Lib/EncoderLib/EncHRD.cpp new file mode 100644 index 000000000..e858ba237 --- /dev/null +++ b/source/Lib/EncoderLib/EncHRD.cpp @@ -0,0 +1,197 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Frderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +#include "EncHRD.h" +#include "CommonLib/ProfileLevelTier.h" + +namespace vvenc { + +// calculate scale value of bitrate and initial delay +int EncHRD::xCalcScale(int x) +{ + if (x==0) + { + return 0; + } + uint32_t mask = 0xffffffff; + int scaleValue = 32; + + while ((x&mask) != 0) + { + scaleValue--; + mask = (mask >> 1); + } + + return scaleValue; +} + +void EncHRD::initHRDParameters(const EncCfg& encCfg, const SPS& sps) +{ +// if (!encCfg.m_hrdParametersPresent && !encCfg.getCpbSaturationEnabled()) +// { +// return; +// } + ProfileLevelTierFeatures profileLevelTierFeatures; + profileLevelTierFeatures.extractPTLInformation( sps ); + + bool useSubCpbParams = false; //encCfg.getNoPicPartitionFlag() == false; + int bitRate = encCfg.m_RCTargetBitrate; + int cpbSize = profileLevelTierFeatures.getCpbSizeInBits(); + + CHECK(!(cpbSize != 0), "Unspecified error"); // CPB size may not be equal to zero. ToDo: have a better default and check for level constraints + + switch (encCfg.m_FrameRate) + { + case 24: + generalHrdParams.numUnitsInTick = 1125000; generalHrdParams.timeScale = 27000000; + break; + case 25: + generalHrdParams.numUnitsInTick = 1080000; generalHrdParams.timeScale = 27000000; + break; + case 30: + generalHrdParams.numUnitsInTick = 900900; generalHrdParams.timeScale = 27000000; + break; + case 50: + generalHrdParams.numUnitsInTick = 540000; generalHrdParams.timeScale = 27000000; + break; + case 60: + generalHrdParams.numUnitsInTick = 450450; generalHrdParams.timeScale = 27000000; + break; + default: + generalHrdParams.numUnitsInTick = 1001; generalHrdParams.timeScale = 60000; + break; + } + + if (encCfg.m_temporalSubsampleRatio > 1) + { + uint32_t temporalSubsampleRatio = encCfg.m_temporalSubsampleRatio; + if (double(generalHrdParams.numUnitsInTick) * temporalSubsampleRatio > std::numeric_limits::max()) + { + generalHrdParams.timeScale = generalHrdParams.timeScale / temporalSubsampleRatio; + } + else + { + generalHrdParams.numUnitsInTick = generalHrdParams.numUnitsInTick * temporalSubsampleRatio; + } + } + bool rateCnt = (bitRate > 0); + + generalHrdParams.generalNalHrdParamsPresent = rateCnt; + generalHrdParams.generalVclHrdParamsPresent = rateCnt; + + generalHrdParams.generalSamePicTimingInAllOlsFlag = true; + useSubCpbParams &= (generalHrdParams.generalNalHrdParamsPresent || generalHrdParams.generalVclHrdParamsPresent); + generalHrdParams.generalDecodingUnitHrdParamsPresent = useSubCpbParams; + + if (generalHrdParams.generalDecodingUnitHrdParamsPresent) + { + generalHrdParams.tickDivisorMinus2 = (100 - 2); + } + + if (xCalcScale(bitRate) <= 6) + { + generalHrdParams.bitRateScale = 0; + } + else + { + generalHrdParams.bitRateScale = xCalcScale(bitRate) - 6; + } + + if (xCalcScale(cpbSize) <= 4) + { + generalHrdParams.cpbSizeScale = 0; + } + else + { + generalHrdParams.cpbSizeScale = xCalcScale(cpbSize) - 4; + } + + generalHrdParams.cpbSizeDuScale = 6; // in units of 2^( 4 + 6 ) = 1,024 bit + generalHrdParams.hrdCpbCntMinus1 = 0; + + + // Note: parameters for all temporal layers are initialized with the same values + int i, j; + uint32_t bitrateValue, cpbSizeValue; + uint32_t duCpbSizeValue; + uint32_t duBitRateValue = 0; + + for (i = 0; i < MAX_TLAYER; i++) + { + olsHrdParams[i].fixedPicRateGeneralFlag = true; + olsHrdParams[i].fixedPicRateWithinCvsFlag = true; + olsHrdParams[i].elementDurationInTcMinus1 = 0; + olsHrdParams[i].lowDelayHrdFlag = false; + + //! \todo check for possible PTL violations + // BitRate[ i ] = ( bit_rate_value_minus1[ i ] + 1 ) * 2^( 6 + bit_rate_scale ) + bitrateValue = bitRate / (1 << (6 + generalHrdParams.bitRateScale)); // bitRate is in bits, so it needs to be scaled down + // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) + cpbSizeValue = cpbSize / (1 << (4 + generalHrdParams.cpbSizeScale)); // using bitRate results in 1 second CPB size + + // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know + // in how many DUs the slice segment settings will result + duCpbSizeValue = bitrateValue; + duBitRateValue = cpbSizeValue; + + for (j = 0; j < (generalHrdParams.hrdCpbCntMinus1 + 1); j++) + { + olsHrdParams[i].bitRateValueMinus1[j][0] = bitrateValue - 1; + olsHrdParams[i].cpbSizeValueMinus1[j][0] = cpbSizeValue - 1; + olsHrdParams[i].duCpbSizeValueMinus1[j][0] = duCpbSizeValue - 1; + olsHrdParams[i].duBitRateValueMinus1[j][0] = duBitRateValue - 1; + olsHrdParams[i].cbrFlag[j][0] = false; + + olsHrdParams[i].bitRateValueMinus1[j][1] = bitrateValue - 1; + olsHrdParams[i].cpbSizeValueMinus1[j][1] = cpbSizeValue - 1; + olsHrdParams[i].duCpbSizeValueMinus1[j][1] = duCpbSizeValue - 1; + olsHrdParams[i].duBitRateValueMinus1[j][1] = duBitRateValue - 1; + olsHrdParams[i].cbrFlag[j][1] = false; + } + } +} + +} //namespace \ No newline at end of file diff --git a/source/Lib/EncoderLib/EncHRD.h b/source/Lib/EncoderLib/EncHRD.h index eeca3526c..36c360050 100644 --- a/source/Lib/EncoderLib/EncHRD.h +++ b/source/Lib/EncoderLib/EncHRD.h @@ -1,58 +1,62 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ -#ifndef __ENCHRD__ -#define __ENCHRD__ +#pragma once -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CommonLib/Common.h" #include "CommonLib/HRD.h" #include "CommonLib/Slice.h" namespace vvenc { + class EncHRD :public HRD { public: - void initHRDParameters( EncCfg* encCfg ); + void initHRDParameters( const EncCfg& encCfg, const SPS& sps ); protected: // calculate scale value of bitrate and initial delay @@ -61,4 +65,3 @@ namespace vvenc { }; } -#endif // __ENCHRD__ diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index fb69498ec..6a7d2152f 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncLib.cpp @@ -47,7 +51,7 @@ vvc@hhi.fraunhofer.de #include "EncLib.h" -#include "../../../include/vvenc/EncoderIf.h" +#include "vvenc/EncoderIf.h" #include "CommonLib/Picture.h" #include "CommonLib/CommonDef.h" #include "CommonLib/TimeProfiler.h" @@ -65,31 +69,41 @@ namespace vvenc { // ==================================================================================================================== EncLib::EncLib() - : m_numPicsRcvd ( 0 ) - , m_numPicsInQueue( 0 ) - , m_numPicsCoded ( 0 ) - , m_pocEncode ( -1 ) - , m_pocRecOut ( 0 ) + : m_cGOPEncoder ( nullptr ) , m_yuvWriterIf ( nullptr ) - , m_threadPool ( nullptr ) + , m_threadPool ( nullptr ) , m_spsMap ( MAX_NUM_SPS ) , m_ppsMap ( MAX_NUM_PPS ) - , m_GOPSizeLog2 ( -1 ) - , m_TicksPerFrameMul4 ( 0 ) { + xResetLib(); } EncLib::~EncLib() { } -void EncLib::init( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ) +void EncLib::xResetLib() +{ + m_numPicsRcvd = 0; + m_numPicsInQueue = 0; + m_numPicsCoded = 0; + m_pocEncode = -1; + m_pocRecOut = 0; + m_GOPSizeLog2 = -1; + m_TicksPerFrameMul4 = 0; +} + +void EncLib::initEncoderLib( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ) { // copy config parameter const_cast(m_cEncCfg).setCfgParameter( encCfg ); + m_cBckCfg.setCfgParameter( encCfg ); m_yuvWriterIf = yuvWriterIf; + // initialize first pass + initPass( 0 ); + #if ENABLE_TRACING g_trace_ctx = tracing_init( m_cEncCfg.m_traceFile, m_cEncCfg.m_traceRule ); if( g_trace_ctx && m_cEncCfg.m_listTracingChannels ) @@ -100,73 +114,6 @@ void EncLib::init( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ) } #endif - // setup parameter sets - const int dciId = m_cEncCfg.m_decodingParameterSetEnabled ? 1 : 0; - SPS& sps0 = *( m_spsMap.allocatePS(0) ); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. - PPS& pps0 = *( m_ppsMap.allocatePS(0) ); - - xInitSPS( sps0 ); - sps0.dciId = m_cDCI.dciId; - xInitVPS( m_cVPS ); - xInitDCI( m_cDCI, sps0, dciId ); - xInitPPS( pps0, sps0 ); - xInitRPL( sps0 ); - - if ( encCfg.m_numWppThreads > 0 ) - { - const int maxCntEnc = ( encCfg.m_numWppThreads > 0 ) ? std::min( (int)pps0.pcv->heightInCtus, encCfg.m_numWppThreads) : 1; - m_threadPool = new NoMallocThreadPool( maxCntEnc, "EncSliceThreadPool" ); - } - - m_MCTF.init( m_cEncCfg.m_internalBitDepth, m_cEncCfg.m_SourceWidth, m_cEncCfg.m_SourceHeight, sps0.CTUSize, - m_cEncCfg.m_internChromaFormat, m_cEncCfg.m_QP, m_cEncCfg.m_MCTFFrames, m_cEncCfg.m_MCTFStrengths, - m_cEncCfg.m_MCTFFutureReference, m_cEncCfg.m_MCTF, - m_cEncCfg.m_MCTFNumLeadFrames, m_cEncCfg.m_MCTFNumTrailFrames, m_cEncCfg.m_framesToBeEncoded, m_threadPool ); - - m_cGOPEncoder.init( m_cEncCfg, sps0, pps0, m_cRateCtrl, m_threadPool ); - - m_pocToGopId.resize( m_cEncCfg.m_GOPSize, -1 ); - m_nextPocOffset.resize( m_cEncCfg.m_GOPSize, 0 ); - for ( int i = 0; i < m_cEncCfg.m_GOPSize; i++ ) - { - const int poc = m_cEncCfg.m_GOPList[ i ].m_POC % m_cEncCfg.m_GOPSize; - CHECK( m_cEncCfg.m_GOPList[ i ].m_POC > m_cEncCfg.m_GOPSize, "error: poc greater than gop size" ); - CHECK( m_pocToGopId[ poc ] != -1, "error: multiple entries in gop list map to same poc modulo gop size" ); - m_pocToGopId[ poc ] = i; - const int nextGopNum = ( i + 1 ) / m_cEncCfg.m_GOPSize; - const int nextGopId = ( i + 1 ) % m_cEncCfg.m_GOPSize; - const int nextPoc = nextGopNum * m_cEncCfg.m_GOPSize + m_cEncCfg.m_GOPList[ nextGopId ].m_POC; - m_nextPocOffset[ poc ] = nextPoc - m_cEncCfg.m_GOPList[ i ].m_POC; - } - for ( int i = 0; i < m_cEncCfg.m_GOPSize; i++ ) - { - CHECK( m_pocToGopId [ i ] < 0 || m_nextPocOffset[ i ] == 0, "error: poc not found in gop list" ); - } - - if ( encCfg.m_RCRateControlMode ) - { - m_cRateCtrl.init( encCfg.m_RCRateControlMode, encCfg.m_framesToBeEncoded, encCfg.m_RCTargetBitrate, (int)( (double)encCfg.m_FrameRate / encCfg.m_temporalSubsampleRatio + 0.5 ), encCfg.m_IntraPeriod, encCfg.m_GOPSize, encCfg.m_SourceWidth, encCfg.m_SourceHeight, - encCfg.m_CTUSize, encCfg.m_CTUSize, encCfg.m_internalBitDepth[ CH_L ], encCfg.m_RCKeepHierarchicalBit, encCfg.m_RCUseLCUSeparateModel, encCfg.m_GOPList ); - } - - int iOffset = -1; - while((1<<(++iOffset)) < m_cEncCfg.m_GOPSize); - m_GOPSizeLog2 = iOffset; - - if( m_cEncCfg.m_FrameRate ) - { - int iTempRate = m_cEncCfg.m_FrameRate; - int iTempScale = 1; - switch( m_cEncCfg.m_FrameRate ) - { - case 23: iTempRate = 24000; iTempScale = 1001; break; - case 29: iTempRate = 30000; iTempScale = 1001; break; - case 59: iTempRate = 60000; iTempScale = 1001; break; - default: break; - } - m_TicksPerFrameMul4 = (int)((int64_t)4 *(int64_t)m_cEncCfg.m_TicksPerSecond * (int64_t)iTempScale/(int64_t)iTempRate); - } - #if ENABLE_TIME_PROFILING if( g_timeProfiler == nullptr ) { @@ -188,10 +135,16 @@ void EncLib::init( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ) #endif } -void EncLib::destroy() +void EncLib::uninitEncoderLib() { - m_MCTF.uninit(); - m_cRateCtrl.destroy(); + xUninitLib(); + +#if ENABLE_TRACING + if ( g_trace_ctx ) + { + tracing_uninit( g_trace_ctx ); + } +#endif #if ENABLE_CU_MODE_COUNTERS std::cout << std::endl; @@ -262,23 +215,160 @@ void EncLib::destroy() g_timeProfiler = nullptr; } #endif +} + +void EncLib::initPass( int pass ) +{ + xUninitLib(); - if ( m_threadPool ) + // set rate control pass + m_cRateCtrl.setRCPass( pass, m_cEncCfg.m_RCNumPasses - 1 ); + + // modify encoder config based on rate control pass + if( m_cEncCfg.m_RCNumPasses > 1 ) + { + xSetRCEncCfg( pass ); + } + + // setup parameter sets + const int dciId = m_cEncCfg.m_decodingParameterSetEnabled ? 1 : 0; + SPS& sps0 = *( m_spsMap.allocatePS( 0 ) ); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. + PPS& pps0 = *( m_ppsMap.allocatePS( 0 ) ); + + xInitSPS( sps0 ); + sps0.dciId = m_cDCI.dciId; + xInitVPS( m_cVPS ); + xInitDCI( m_cDCI, sps0, dciId ); + xInitPPS( pps0, sps0 ); + xInitRPL( sps0 ); + xInitHrdParameters( sps0 ); + + // thread pool + if( m_cEncCfg.m_numWppThreads > 0 ) + { + const int maxCntEnc = ( m_cEncCfg.m_numWppThreads > 0 ) ? std::min( (int)pps0.pcv->heightInCtus, m_cEncCfg.m_numWppThreads) : 1; + m_threadPool = new NoMallocThreadPool( maxCntEnc, "EncSliceThreadPool" ); + } + + m_MCTF.init( m_cEncCfg.m_internalBitDepth, m_cEncCfg.m_SourceWidth, m_cEncCfg.m_SourceHeight, sps0.CTUSize, + m_cEncCfg.m_internChromaFormat, m_cEncCfg.m_QP, m_cEncCfg.m_MCTFFrames, m_cEncCfg.m_MCTFStrengths, + m_cEncCfg.m_MCTFFutureReference, m_cEncCfg.m_MCTF, + m_cEncCfg.m_MCTFNumLeadFrames, m_cEncCfg.m_MCTFNumTrailFrames, m_cEncCfg.m_framesToBeEncoded, m_threadPool ); + + CHECK( m_cGOPEncoder != nullptr, "encoder library already initialised" ); + m_cGOPEncoder = new EncGOP; + m_cGOPEncoder->init( m_cEncCfg, sps0, pps0, m_cRateCtrl, m_cEncHRD, m_threadPool ); + + m_pocToGopId.resize( m_cEncCfg.m_GOPSize, -1 ); + m_nextPocOffset.resize( m_cEncCfg.m_GOPSize, 0 ); + for ( int i = 0; i < m_cEncCfg.m_GOPSize; i++ ) + { + const int poc = m_cEncCfg.m_GOPList[ i ].m_POC % m_cEncCfg.m_GOPSize; + CHECK( m_cEncCfg.m_GOPList[ i ].m_POC > m_cEncCfg.m_GOPSize, "error: poc greater than gop size" ); + CHECK( m_pocToGopId[ poc ] != -1, "error: multiple entries in gop list map to same poc modulo gop size" ); + m_pocToGopId[ poc ] = i; + const int nextGopNum = ( i + 1 ) / m_cEncCfg.m_GOPSize; + const int nextGopId = ( i + 1 ) % m_cEncCfg.m_GOPSize; + const int nextPoc = nextGopNum * m_cEncCfg.m_GOPSize + m_cEncCfg.m_GOPList[ nextGopId ].m_POC; + m_nextPocOffset[ poc ] = nextPoc - m_cEncCfg.m_GOPList[ i ].m_POC; + } + for ( int i = 0; i < m_cEncCfg.m_GOPSize; i++ ) + { + CHECK( m_pocToGopId [ i ] < 0 || m_nextPocOffset[ i ] == 0, "error: poc not found in gop list" ); + } + + if ( m_cEncCfg.m_RCRateControlMode ) + { + m_cRateCtrl.init( m_cEncCfg.m_RCRateControlMode, m_cEncCfg.m_framesToBeEncoded, m_cEncCfg.m_RCTargetBitrate, (int)( (double)m_cEncCfg.m_FrameRate / m_cEncCfg.m_temporalSubsampleRatio + 0.5 ), m_cEncCfg.m_IntraPeriod, m_cEncCfg.m_GOPSize, m_cEncCfg.m_SourceWidth, m_cEncCfg.m_SourceHeight, + m_cEncCfg.m_CTUSize, m_cEncCfg.m_CTUSize, m_cEncCfg.m_internalBitDepth[ CH_L ], m_cEncCfg.m_RCKeepHierarchicalBit, m_cEncCfg.m_RCUseLCUSeparateModel, m_cEncCfg.m_GOPList ); + + if ( pass == 1 ) + { + m_cRateCtrl.processFirstPassData(); + // update first pass data + m_cRateCtrl.encRCSeq->firstPassData = m_cRateCtrl.getFirstPassStats(); + } + } + + int iOffset = -1; + while((1<<(++iOffset)) < m_cEncCfg.m_GOPSize); + m_GOPSizeLog2 = iOffset; + + if( m_cEncCfg.m_FrameRate ) + { + int iTempRate = m_cEncCfg.m_FrameRate; + int iTempScale = 1; + switch( m_cEncCfg.m_FrameRate ) + { + case 23: iTempRate = 24000; iTempScale = 1001; break; + case 29: iTempRate = 30000; iTempScale = 1001; break; + case 59: iTempRate = 60000; iTempScale = 1001; break; + default: break; + } + m_TicksPerFrameMul4 = (int)((int64_t)4 *(int64_t)m_cEncCfg.m_TicksPerSecond * (int64_t)iTempScale/(int64_t)iTempRate); + } +} + +void EncLib::xUninitLib() +{ + + // internal picture buffer + xDeletePicBuffer(); + + // sub modules + m_cRateCtrl.destroy(); + m_nextPocOffset.clear(); + m_pocToGopId.clear(); + if( m_cGOPEncoder ) + { + delete m_cGOPEncoder; + m_cGOPEncoder = nullptr; + } + m_MCTF.uninit(); + + // thread pool + if( m_threadPool ) { m_threadPool->shutdown( true ); delete m_threadPool; m_threadPool = nullptr; } - // internal picture buffer - xDeletePicBuffer(); + // cleanup parameter sets + m_spsMap.clearMap(); + m_ppsMap.clearMap(); -#if ENABLE_TRACING - if ( g_trace_ctx ) + // reset internal data + xResetLib(); +} + +void EncLib::xSetRCEncCfg( int pass ) +{ + // restore encoder configuration for second rate control passes + const_cast(m_cEncCfg).setCfgParameter( m_cBckCfg ); + + // set encoder config for rate control first pass + if( ! m_cRateCtrl.rcIsFinalPass ) { - tracing_uninit( g_trace_ctx ); + // preserve MCTF settings + const int mctf = m_cBckCfg.m_MCTF; + + m_cBckCfg.initPreset( PresetMode::FIRSTPASS ); + + // use fixQP encoding in first pass + m_cBckCfg.m_RCRateControlMode = 0; + m_cBckCfg.m_QP = 32; + + // restore MCTF + m_cBckCfg.m_MCTF = mctf; + + // configure QPA in the first pass + m_cBckCfg.m_usePerceptQPA = 0; // disable QPA in the first pass + m_cBckCfg.m_sliceChromaQpOffsetPeriodicity = 0; + m_cBckCfg.m_usePerceptQPATempFiltISlice = 0; + + std::swap( const_cast(m_cEncCfg), m_cBckCfg ); } -#endif } // ==================================================================================================================== @@ -290,11 +380,7 @@ void EncLib::encodePicture( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& a PROFILER_ACCUM_AND_START_NEW_SET( 1, g_timeProfiler, P_PIC_LEVEL ); // clear output access unit - au.m_bCtsValid = false; - au.m_bDtsValid = false; - au.m_bRAP = false; - au.m_cInfo = ""; - au.m_iStatus = 0; + au.clearAu(); // setup picture and store original yuv Picture* pic = nullptr; @@ -329,6 +415,7 @@ void EncLib::encodePicture( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& a xInitPicture( *pic, m_numPicsRcvd, pps, sps, m_cVPS, m_cDCI ); + xDetectScreenC(*pic, yuvOrgBuf, m_cEncCfg.m_TS ); m_numPicsRcvd += 1; m_numPicsInQueue += 1; } @@ -377,17 +464,12 @@ void EncLib::encodePicture( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& a au.m_uiCts = encList[0]->cts; au.m_bCtsValid = encList[0]->ctsValid; - au.m_uiDts = ((iDiffFrames - m_GOPSizeLog2) * m_TicksPerFrameMul4)/4 + au.m_uiCts; + au.m_uiDts = ((iDiffFrames - m_GOPSizeLog2) * m_TicksPerFrameMul4)/4 + au.m_uiCts; au.m_bDtsValid = true; - //assert( (int64_t)au.m_uiDts < 0 || au.m_uiCts >= au.m_uiDts ); - } - else - { - assert(0); } // encode picture with current poc - m_cGOPEncoder.encodePicture( encList, m_cListPic, au, false ); + m_cGOPEncoder->encodePicture( encList, m_cListPic, au, false ); m_numPicsInQueue -= 1; m_numPicsCoded += 1; // output reconstructed yuv @@ -396,15 +478,21 @@ void EncLib::encodePicture( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& a isQueueEmpty = ( m_numPicsInQueue <= 0 ); - if ( m_cEncCfg.m_RCRateControlMode && isQueueEmpty ) + if( m_cEncCfg.m_RCRateControlMode && isQueueEmpty ) { m_cRateCtrl.destroyRCGOP(); } + + // reset output access unit, if not final pass + if( !m_cRateCtrl.rcIsFinalPass ) + { + au.clearAu(); + } } void EncLib::printSummary() { - m_cGOPEncoder.printOutSummary( m_numPicsCoded, m_cEncCfg.m_printMSEBasedSequencePSNR, m_cEncCfg.m_printSequenceMSE, m_cEncCfg.m_printHexPsnr, m_spsMap.getFirstPS()->bitDepths ); + m_cGOPEncoder->printOutSummary( m_numPicsCoded, m_cEncCfg.m_printMSEBasedSequencePSNR, m_cEncCfg.m_printSequenceMSE, m_cEncCfg.m_printHexPsnr, m_spsMap.getFirstPS()->bitDepths ); } // ==================================================================================================================== @@ -477,7 +565,7 @@ Picture* EncLib::xGetNewPicBuffer( const PPS& pps, const SPS& sps ) m_cListPic.push_back( pic ); } - pic->isMctfFiltered = false; + pic->isMctfProcessed = false; pic->isInitDone = false; pic->isReconstructed = false; pic->isBorderExtended = false; @@ -510,7 +598,7 @@ void EncLib::xInitPicture( Picture& pic, int picNum, const PPS& pps, const SPS& pic.cs->picHeader = nullptr; } - pic.finalInit( vps, sps, pps, *picHeader, m_shrdUnitCache, mutex, nullptr, nullptr ); + pic.finalInit( vps, sps, pps, picHeader, m_shrdUnitCache, mutex, nullptr, nullptr ); pic.vps = &vps; pic.dci = &dci; @@ -560,6 +648,8 @@ void EncLib::xDeletePicBuffer() delete pic; pic = nullptr; } + + m_cListPic.clear(); } Picture* EncLib::xGetPictureBuffer( int poc ) @@ -584,7 +674,7 @@ void EncLib::xCreateCodingOrder( int start, int max, int numInQueue, bool flush, while ( poc < max ) { Picture* pic = xGetPictureBuffer( poc ); - if ( m_cEncCfg.m_MCTF && ! pic->isMctfFiltered ) + if ( m_cEncCfg.m_MCTF && ! pic->isMctfProcessed ) { break; } @@ -649,7 +739,6 @@ void EncLib::xInitDCI(DCI &dci, const SPS &sps, const int dciId) const // The SPS must have already been set up. // set the DPS profile information. dci.dciId = dciId; - dci.maxSubLayersMinus1 = sps.maxTLayers - 1; dci.profileTierLevel.resize(1); // copy profile level tier info @@ -714,8 +803,8 @@ void EncLib::xInitConstraintInfo(ConstraintInfo &ci) const ci.noCiipConstraintFlag = m_cEncCfg.m_CIIP == 0; ci.noGeoConstraintFlag = m_cEncCfg.m_Geo == 0; ci.noLadfConstraintFlag = true; - ci.noTransformSkipConstraintFlag = true; - ci.noBDPCMConstraintFlag = true; + ci.noTransformSkipConstraintFlag = m_cEncCfg.m_TS == 0; + ci.noBDPCMConstraintFlag = m_cEncCfg.m_useBDPCM==0; ci.noJointCbCrConstraintFlag = ! m_cEncCfg.m_JointCbCrMode; ci.noMrlConstraintFlag = ! m_cEncCfg.m_MRL; ci.noIspConstraintFlag = true; @@ -755,6 +844,7 @@ void EncLib::xInitSPS(SPS &sps) const sps.maxPicWidthInLumaSamples = m_cEncCfg.m_SourceWidth; sps.maxPicHeightInLumaSamples = m_cEncCfg.m_SourceHeight; + sps.conformanceWindow.setWindow( m_cEncCfg.m_confWinLeft, m_cEncCfg.m_confWinRight, m_cEncCfg.m_confWinTop, m_cEncCfg.m_confWinBottom ); sps.chromaFormatIdc = m_cEncCfg.m_internChromaFormat; sps.CTUSize = m_cEncCfg.m_CTUSize; sps.maxMTTDepth[0] = m_cEncCfg.m_maxMTTDepthI; @@ -806,6 +896,10 @@ void EncLib::xInitSPS(SPS &sps) const sps.depQuantEnabled = m_cEncCfg.m_DepQuantEnabled; sps.signDataHidingEnabled = m_cEncCfg.m_SignDataHidingEnabled; sps.MTSIntra = m_cEncCfg.m_MTS ; + sps.ISP = m_cEncCfg.m_ISP; + sps.transformSkip = m_cEncCfg.m_TS; + sps.log2MaxTransformSkipBlockSize = m_cEncCfg.m_TSsize; + sps.BDPCM = m_cEncCfg.m_useBDPCM; for (uint32_t chType = 0; chType < MAX_NUM_CH; chType++) { @@ -828,7 +922,7 @@ void EncLib::xInitSPS(SPS &sps) const for (int i = 0; i < std::min(sps.maxTLayers, (uint32_t) MAX_TLAYER); i++ ) { sps.maxDecPicBuffering[i] = m_cEncCfg.m_maxDecPicBuffering[i]; - sps.numReorderPics[i] = m_cEncCfg.m_numReorderPics[i]; + sps.numReorderPics[i] = m_cEncCfg.m_maxNumReorderPics[i]; } sps.vuiParametersPresent = m_cEncCfg.m_vuiParametersPresent; @@ -853,6 +947,8 @@ void EncLib::xInitSPS(SPS &sps) const vui.videoFullRangeFlag = m_cEncCfg.m_videoFullRangeFlag; } + sps.hrdParametersPresent = m_cEncCfg.m_hrdParametersPresent; + sps.numLongTermRefPicSPS = NUM_LONG_TERM_REF_PIC_SPS; CHECK(!(NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS), "Unspecified error"); for (int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++) @@ -876,13 +972,19 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) const bUseDQP = false; } - // pps ID already initialised. pps.spsId = sps.spsId; pps.jointCbCrQpOffsetPresent = m_cEncCfg.m_JointCbCrMode; pps.picWidthInLumaSamples = m_cEncCfg.m_SourceWidth; pps.picHeightInLumaSamples = m_cEncCfg.m_SourceHeight; - pps.conformanceWindow.setWindow( m_cEncCfg.m_confWinLeft, m_cEncCfg.m_confWinRight, m_cEncCfg.m_confWinTop, m_cEncCfg.m_confWinBottom ); + if( pps.picWidthInLumaSamples == sps.maxPicWidthInLumaSamples && pps.picHeightInLumaSamples == sps.maxPicHeightInLumaSamples ) + { + pps.conformanceWindow = sps.conformanceWindow; + } + else + { + pps.conformanceWindow.setWindow( m_cEncCfg.m_confWinLeft, m_cEncCfg.m_confWinRight, m_cEncCfg.m_confWinTop, m_cEncCfg.m_confWinBottom ); + } pps.picWidthInCtu = (pps.picWidthInLumaSamples + (sps.CTUSize-1)) / sps.CTUSize; pps.picHeightInCtu = (pps.picHeightInLumaSamples + (sps.CTUSize-1)) / sps.CTUSize; @@ -982,9 +1084,9 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) const if( chromaArrayType != CHROMA_400 ) { bool chromaQPOffsetNotZero = ( pps.chromaQpOffset[COMP_Cb] != 0 || pps.chromaQpOffset[COMP_Cr] != 0 || pps.jointCbCrQpOffsetPresent || pps.sliceChromaQpFlag || pps.chromaQpOffsetListLen ); - bool chromaDbfOffsetNotAsLuma = ( pps.deblockingFilterBetaOffsetDiv2[COMP_Cb] != pps.deblockingFilterBetaOffsetDiv2[COMP_Y] + bool chromaDbfOffsetNotAsLuma = ( pps.deblockingFilterBetaOffsetDiv2[COMP_Cb] != pps.deblockingFilterBetaOffsetDiv2[COMP_Y] || pps.deblockingFilterBetaOffsetDiv2[COMP_Cr] != pps.deblockingFilterBetaOffsetDiv2[COMP_Y] - || pps.deblockingFilterTcOffsetDiv2[COMP_Cb] != pps.deblockingFilterTcOffsetDiv2[COMP_Y] + || pps.deblockingFilterTcOffsetDiv2[COMP_Cb] != pps.deblockingFilterTcOffsetDiv2[COMP_Y] || pps.deblockingFilterTcOffsetDiv2[COMP_Cr] != pps.deblockingFilterTcOffsetDiv2[COMP_Y]); pps.usePPSChromaTool = chromaQPOffsetNotZero || chromaDbfOffsetNotAsLuma; } @@ -1079,7 +1181,7 @@ void EncLib::xInitRPL(SPS &sps) const } } } - + sps.allRplEntriesHasSameSign = isAllEntriesinRPLHasSameSignFlag; bool isRpl1CopiedFromRpl0 = true; @@ -1116,17 +1218,17 @@ void EncLib::xOutputRecYuv() { Slice::sortPicList( m_cListPic ); - for ( const auto& picItr : m_cListPic ) + for( const auto& picItr : m_cListPic ) { - if ( picItr->poc < m_pocRecOut ) + if( picItr->poc < m_pocRecOut ) continue; - if ( ! picItr->isReconstructed || picItr->poc != m_pocRecOut ) + if( ! picItr->isReconstructed || picItr->poc != m_pocRecOut ) return; - const PPS& pps = *(picItr->cs->pps); - YUVBuffer yuvBuffer; - setupYuvBuffer( picItr->getRecoBuf(), yuvBuffer, &pps.conformanceWindow ); - if ( m_yuvWriterIf ) + if( m_cRateCtrl.rcIsFinalPass && m_yuvWriterIf ) { + const PPS& pps = *(picItr->cs->pps); + YUVBuffer yuvBuffer; + setupYuvBuffer( picItr->getRecoBuf(), yuvBuffer, &pps.conformanceWindow ); m_yuvWriterIf->outputYuv( yuvBuffer ); } m_pocRecOut = picItr->poc + 1; @@ -1134,6 +1236,90 @@ void EncLib::xOutputRecYuv() } } +void EncLib::xInitHrdParameters(SPS &sps) +{ + m_cEncHRD.initHRDParameters( m_cEncCfg, sps ); + + sps.generalHrdParams = m_cEncHRD.generalHrdParams; + + for(int i = 0; i < MAX_TLAYER; i++) + { + sps.olsHrdParams[i] = m_cEncHRD.olsHrdParams[i]; + } +} + +void EncLib::xDetectScreenC(Picture& pic, PelUnitBuf yuvOrgBuf, int useTS) +{ + if (useTS < 2) + { + pic.useSC = useTS; + } + else + { + int K_SC = 5; + int SIZE_BL = 4; + int TH_SC = 6; + const Pel* piSrc = yuvOrgBuf.Y().buf; + uint32_t uiStride = yuvOrgBuf.Y().stride; + uint32_t uiWidth = yuvOrgBuf.Y().width; + uint32_t uiHeight = yuvOrgBuf.Y().height; + unsigned i, j; + int size = SIZE_BL; + std::vector Vall; + for (j = 0; j < uiHeight;) + { + for (i = 0; i < uiWidth;) + { + int sum = 0; + int Mit = 0; + int V = 0; + int h = i; + int w = j; + for (h = j; (h < j + size) && (h < uiHeight); h++) + { + for (w = i; (w < i + size) && (w < uiWidth); w++) + { + sum += int(piSrc[h * uiStride + w]); + } + } + int sizeEnd = ((h - j) * (w - i)); + Mit = sum / sizeEnd; + for (h = j; (h < j + size) && (h < uiHeight); h++) + { + for (w = i; (w < i + size) && (w < uiWidth); w++) + { + V += abs(Mit - int(piSrc[h * uiStride + w])); + } + } + // Variance in Block (SIZE_BL*SIZE_BL) + V = V / sizeEnd; + Vall.push_back(V); + i += size; + } + j += size; + } + int s = 0; + for (auto it = Vall.begin(); it != Vall.end(); ++it) + { + if (*it < TH_SC) + { + s++; + } + } + if (s > (Vall.size() / K_SC)) + { + pic.useSC = true; + // printf(" s= %d all= %d SSC\n", s, int(Vall.size() / K_SC)); + } + else + { + pic.useSC = false; + // printf(" s= %d all= %d NC\n", s, int(Vall.size() / K_SC)); + } + Vall.clear(); + } +} + } // namespace vvenc //! \} diff --git a/source/Lib/EncoderLib/EncLib.h b/source/Lib/EncoderLib/EncLib.h index 86530948b..0dc5b44b8 100644 --- a/source/Lib/EncoderLib/EncLib.h +++ b/source/Lib/EncoderLib/EncLib.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncLib.h \brief encoder class (header) */ @@ -46,10 +50,11 @@ vvc@hhi.fraunhofer.de #pragma once #include "EncGOP.h" +#include "EncHRD.h" #include "CommonLib/MCTF.h" +#include "vvenc/EncCfg.h" +#include "vvenc/Nal.h" #include -#include "../../../include/vvenc/EncCfg.h" -#include "../../../include/vvenc/Nal.h" //! \ingroup EncoderLib //! \{ @@ -72,9 +77,13 @@ class EncLib int m_numPicsCoded; int m_pocEncode; int m_pocRecOut; + int m_GOPSizeLog2; + int m_TicksPerFrameMul4; const EncCfg m_cEncCfg; - EncGOP m_cGOPEncoder; + EncCfg m_cBckCfg; + EncGOP* m_cGOPEncoder; + EncHRD m_cEncHRD; MCTF m_MCTF; PicList m_cListPic; YUVWriterIf* m_yuvWriterIf; @@ -92,19 +101,21 @@ class EncLib std::vector m_pocToGopId; std::vector m_nextPocOffset; - int m_GOPSizeLog2; - int m_TicksPerFrameMul4; - public: EncLib(); virtual ~EncLib(); - void init ( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ); - void destroy (); + void initEncoderLib ( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ); + void initPass ( int pass ); void encodePicture ( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& au, bool& isQueueEmpty ); + void uninitEncoderLib (); void printSummary (); private: + void xUninitLib (); + void xResetLib (); + void xSetRCEncCfg ( int pass ); + int xGetGopIdFromPoc ( int poc ) const { return m_pocToGopId[ poc % m_cEncCfg.m_GOPSize ]; } int xGetNextPocICO ( int poc, bool flush, int max ) const; void xCreateCodingOrder ( int start, int max, int numInQueue, bool flush, std::vector& encList ); @@ -120,7 +131,9 @@ class EncLib void xInitPPS ( PPS &pps, const SPS &sps ) const; ///< initialize PPS from encoder options void xInitPPSforTiles ( PPS &pps ) const; void xInitRPL ( SPS &sps ) const; + void xInitHrdParameters ( SPS &sps ); void xOutputRecYuv (); + void xDetectScreenC ( Picture& pic , PelUnitBuf yuvOrgBuf, int useTS); }; } // namespace vvenc diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index 70340189f..ab0b180ca 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncModeCtrl.cpp @@ -230,9 +234,7 @@ void SaveLoadEncInfoSbt::resetSaveloadSbt( int maxSbtSize ) } } -static bool isTheSameNbHood( const CodingUnit &cu, const CodingStructure& cs, const Partitioner &partitioner - , const PredictionUnit &pu, int picW, int picH - ) +static bool isTheSameNbHood( const CodingUnit &cu, const CodingStructure& cs, const Partitioner &partitioner, int picW, int picH ) { if( cu.chType != partitioner.chType ) { @@ -274,6 +276,11 @@ void BestEncInfoCache::create( const ChromaFormat chFmt ) { for( int hIdx = 0; hIdx < maxSizeIdx; hIdx++ ) { + int dmvrSize = 0; + if( hIdx >= 1 && wIdx >= 1 && (wIdx+hIdx) >= 3 ) + { + dmvrSize = (1 << std::max(0,(wIdx + MIN_CU_LOG2 - DMVR_SUBCU_SIZE_LOG2))) * (1 << std::max(0,(hIdx + MIN_CU_LOG2 - DMVR_SUBCU_SIZE_LOG2))); + } for( unsigned x = 0; x < numPos; x++ ) { for( unsigned y = 0; y < numPos; y++ ) @@ -281,13 +288,16 @@ void BestEncInfoCache::create( const ChromaFormat chFmt ) if(( x + (1<<(wIdx) ) <= ( MAX_CU_SIZE >> MIN_CU_LOG2 ) ) &&( y + (1<<(hIdx) ) <= ( MAX_CU_SIZE >> MIN_CU_LOG2 ) )) { - m_bestEncInfo[wIdx][hIdx][x][y] = new BestEncodingInfo; + m_bestEncInfo[wIdx][hIdx][x][y] = new BestEncodingInfo(dmvrSize); const UnitArea area( chFmt, Area( 0, 0, 1<<(wIdx+2), 1<<(hIdx+2) ) ); - new ( &m_bestEncInfo[wIdx][hIdx][x][y]->cu ) CodingUnit ( area ); - new ( &m_bestEncInfo[wIdx][hIdx][x][y]->pu ) PredictionUnit( area ); + new ( &m_bestEncInfo[wIdx][hIdx][x][y]->cu ) CodingUnit ( area ); new ( &m_bestEncInfo[wIdx][hIdx][x][y]->tu ) TransformUnit( area ); + if( dmvrSize ) + { + m_bestEncInfo[wIdx][hIdx][x][y]->cu.mvdL0SubPu = &m_bestEncInfo[wIdx][hIdx][x][y]->dmvrMvdBuffer[0]; + } m_bestEncInfo[wIdx][hIdx][x][y]->poc = -1; m_bestEncInfo[wIdx][hIdx][x][y]->testMode = EncTestMode(); @@ -328,15 +338,6 @@ void BestEncInfoCache::destroy() delete[] m_pCoeff; m_pCoeff = nullptr; - delete[] m_pPcmBuf; - m_pPcmBuf = nullptr; - - if (m_runType != nullptr) - { - delete[] m_runType; - m_runType = nullptr; - } - m_pcv = nullptr; } @@ -373,12 +374,8 @@ void BestEncInfoCache::init( const Slice &slice ) } m_pCoeff = new TCoeff[numCoeff]; - m_pPcmBuf = new Pel [numCoeff]; - m_runType = new bool[numCoeff]; TCoeff *coeffPtr = m_pCoeff; - Pel *pcmPtr = m_pPcmBuf; - bool *runTypePtr = m_runType; m_dummyCS.pcv = m_pcv; @@ -393,20 +390,16 @@ void BestEncInfoCache::init( const Slice &slice ) if( m_bestEncInfo[wIdx][hIdx][x][y] ) { TCoeff *coeff[MAX_NUM_TBLOCKS] = { 0, }; - Pel *pcmbf[MAX_NUM_TBLOCKS] = { 0, }; - bool *runType[MAX_NUM_TBLOCKS] = { 0, }; const UnitArea& area = m_bestEncInfo[wIdx][hIdx][x][y]->tu; for( int i = 0; i < area.blocks.size(); i++ ) { coeff[i] = coeffPtr; coeffPtr += area.blocks[i].area(); - pcmbf[i] = pcmPtr; pcmPtr += area.blocks[i].area(); - runType[i] = runTypePtr; runTypePtr += area.blocks[i].area(); } m_bestEncInfo[wIdx][hIdx][x][y]->tu.cs = &m_dummyCS; - m_bestEncInfo[wIdx][hIdx][x][y]->tu.init(coeff, pcmbf, runType); + m_bestEncInfo[wIdx][hIdx][x][y]->tu.init(coeff); } } } @@ -416,7 +409,7 @@ void BestEncInfoCache::init( const Slice &slice ) bool BestEncInfoCache::setFromCs( const CodingStructure& cs, const Partitioner& partitioner ) { - if( cs.cus.size() != 1 || cs.tus.size() != 1 || cs.pus.size() != 1 ) + if( cs.cus.size() != 1 || cs.tus.size() != 1 || partitioner.maxBTD <= 1 ) { return false; } @@ -428,10 +421,8 @@ bool BestEncInfoCache::setFromCs( const CodingStructure& cs, const Partitioner& encInfo.poc = cs.picture->poc; encInfo.cu.repositionTo( *cs.cus.front() ); - encInfo.pu.repositionTo( *cs.pus.front() ); encInfo.tu.repositionTo( *cs.tus.front() ); encInfo.cu = *cs.cus.front(); - encInfo.pu = *cs.pus.front(); for( auto &blk : cs.tus.front()->blocks ) { if( blk.valid() ) encInfo.tu.copyComponentFrom( *cs.tus.front(), blk.compID ); @@ -445,10 +436,11 @@ bool BestEncInfoCache::setFromCs( const CodingStructure& cs, const Partitioner& bool BestEncInfoCache::isReusingCuValid( const CodingStructure& cs, const Partitioner& partitioner, int qp ) { - if( partitioner.treeType == TREE_C ) + if( partitioner.treeType == TREE_C || partitioner.maxBTD <= 1 ) { return false; //if save & load is allowed for chroma CUs, we should check whether luma info (pred, recon, etc) is the same, which is quite complex } + unsigned idx1, idx2, idx3, idx4; getAreaIdxNew( cs.area.Y(), *m_pcv, idx1, idx2, idx3, idx4 ); @@ -460,9 +452,9 @@ bool BestEncInfoCache::isReusingCuValid( const CodingStructure& cs, const Partit } if( encInfo.cu.qp != qp ) return false; - if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType, partitioner.treeType ) != CS::getArea( cs, encInfo.cu, partitioner.chType, partitioner.treeType ) || !isTheSameNbHood( encInfo.cu, cs, partitioner - , encInfo.pu, (cs.picture->Y().width), (cs.picture->Y().height) -) + if( cs.picture->poc != encInfo.poc + || CS::getArea( cs, cs.area, partitioner.chType, partitioner.treeType ) != CS::getArea( cs, encInfo.cu, partitioner.chType, partitioner.treeType ) + || !isTheSameNbHood( encInfo.cu, cs, partitioner, (cs.picture->Y().width), (cs.picture->Y().height)) || CU::isIBC(encInfo.cu) || partitioner.currQgEnable() || cs.currQP[partitioner.chType] != encInfo.cu.qp ) @@ -482,9 +474,9 @@ bool BestEncInfoCache::setCsFrom( CodingStructure& cs, EncTestMode& testMode, co BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4]; - if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType, partitioner.treeType ) != CS::getArea( cs, encInfo.cu, partitioner.chType, partitioner.treeType ) || !isTheSameNbHood( encInfo.cu, cs, partitioner - , encInfo.pu, (cs.picture->Y().width), (cs.picture->Y().height) - ) + if( cs.picture->poc != encInfo.poc + || CS::getArea( cs, cs.area, partitioner.chType, partitioner.treeType ) != CS::getArea( cs, encInfo.cu, partitioner.chType, partitioner.treeType ) + || !isTheSameNbHood( encInfo.cu, cs, partitioner, (cs.picture->Y().width), (cs.picture->Y().height)) || partitioner.currQgEnable() || cs.currQP[partitioner.chType] != encInfo.cu.qp ) { @@ -495,15 +487,15 @@ bool BestEncInfoCache::setCsFrom( CodingStructure& cs, EncTestMode& testMode, co CodingUnit &cu = cs.addCU( ua, partitioner.chType ); cu.treeType = partitioner.treeType; cu.modeType = partitioner.modeType; - PredictionUnit &pu = cs.addPU( ua, partitioner.chType, &cu ); + cu.initPuData(); TransformUnit &tu = cs.addTU( ua, partitioner.chType, &cu ); cu .repositionTo( encInfo.cu ); - pu .repositionTo( encInfo.pu ); + cu .repositionTo( encInfo.cu ); tu .repositionTo( encInfo.tu ); cu = encInfo.cu; - pu = encInfo.pu; + cu = encInfo.cu; for( auto &blk : tu.blocks ) { if( blk.valid() ) tu.copyComponentFrom( encInfo.tu, blk.compID ); @@ -562,6 +554,12 @@ void EncModeCtrl::initCTUEncoding( const Slice &slice ) { m_skipThresholdE0023FastEnc = SKIP_DEPTH; } + if( ! slice.isIntra() && ( slice.sps->SBT || slice.sps->MTSInter ) ) + { + int maxSLSize = slice.sps->SBT ? (1 << slice.sps->log2MaxTbSize) : MTS_INTER_MAX_CU_SIZE; + resetSaveloadSbt( maxSLSize ); + } + } void EncModeCtrl::initCULevel( Partitioner &partitioner, const CodingStructure& cs ) @@ -595,6 +593,44 @@ void EncModeCtrl::initCULevel( Partitioner &partitioner, const CodingStructure& cuECtx.isReusingCu = isReusingCuValid( cs, partitioner, cs.baseQP ); cuECtx.didHorzSplit = partitioner.canSplit( CU_HORZ_SPLIT, cs ); cuECtx.didVertSplit = partitioner.canSplit( CU_VERT_SPLIT, cs ); + + + if( m_pcEncCfg->m_contentBasedFastQtbt ) + { + const CompArea& currArea = partitioner.currArea().Y(); + int cuHeight = currArea.height; + int cuWidth = currArea.width; + + const bool condIntraInter = m_pcEncCfg->m_IntraPeriod == 1 ? ( partitioner.currBtDepth == 0 ) : ( cuHeight > 32 && cuWidth > 32 ); + + if( cuWidth == cuHeight && condIntraInter ) + { + const CPelBuf bufCurrArea = cs.getOrgBuf( partitioner.currArea().block( COMP_Y ) ); + + Intermediate_Int horVal = 0; + Intermediate_Int verVal = 0; + Intermediate_Int dupVal = 0; + Intermediate_Int dowVal = 0; + + unsigned j, k; + + for( k = 0; k < cuHeight - 1; k++ ) + { + for( j = 0; j < cuWidth - 1; j++ ) + { + horVal += abs( bufCurrArea.at( j + 1, k ) - bufCurrArea.at( j, k ) ); + verVal += abs( bufCurrArea.at( j , k + 1 ) - bufCurrArea.at( j, k ) ); + dowVal += abs( bufCurrArea.at( j + 1, k ) - bufCurrArea.at( j, k + 1 ) ); + dupVal += abs( bufCurrArea.at( j + 1, k + 1 ) - bufCurrArea.at( j, k ) ); + } + } + + cuECtx.grad_horVal = (double)horVal; + cuECtx.grad_verVal = (double)verVal; + cuECtx.grad_dowVal = (double)dowVal; + cuECtx.grad_dupVal = (double)dupVal; + } + } } void EncModeCtrl::finishCULevel( Partitioner &partitioner ) @@ -680,32 +716,14 @@ bool EncModeCtrl::trySplit( const EncTestMode& encTestmode, const CodingStructur if( cuWidth == cuHeight && condIntraInter && split != CU_QUAD_SPLIT ) { - const CPelBuf bufCurrArea = cs.getOrgBuf( partitioner.currArea().block( COMP_Y ) ); - - double horVal = 0; - double verVal = 0; - double dupVal = 0; - double dowVal = 0; - - const double th = m_pcEncCfg->m_IntraPeriod == 1 ? 1.2 : 1.0; - - unsigned j, k; + const double th1 = m_pcEncCfg->m_IntraPeriod == 1 ? 1.2 : 1.0; + const double th2 = m_pcEncCfg->m_IntraPeriod == 1 ? (1.2 / sqrt( 2 )) : (1.0 / sqrt( 2 )); - for( j = 0; j < cuWidth - 1; j++ ) - { - for( k = 0; k < cuHeight - 1; k++ ) - { - horVal += abs( bufCurrArea.at( j + 1, k ) - bufCurrArea.at( j, k ) ); - verVal += abs( bufCurrArea.at( j , k + 1 ) - bufCurrArea.at( j, k ) ); - dowVal += abs( bufCurrArea.at( j + 1, k ) - bufCurrArea.at( j, k + 1 ) ); - dupVal += abs( bufCurrArea.at( j + 1, k + 1 ) - bufCurrArea.at( j, k ) ); - } - } - if( horVal > th * verVal && sqrt( 2 ) * horVal > th * dowVal && sqrt( 2 ) * horVal > th * dupVal && ( split == CU_HORZ_SPLIT || split == CU_TRIH_SPLIT ) ) + if( cuECtx.grad_horVal > th1 * cuECtx.grad_verVal && cuECtx.grad_horVal > th2 * cuECtx.grad_dowVal && cuECtx.grad_horVal > th2 * cuECtx.grad_dupVal && ( split == CU_HORZ_SPLIT || split == CU_TRIH_SPLIT ) ) { return false; } - if( th * dupVal < sqrt( 2 ) * verVal && th * dowVal < sqrt( 2 ) * verVal && th * horVal < verVal && ( split == CU_VERT_SPLIT || split == CU_TRIV_SPLIT ) ) + if( th2 * cuECtx.grad_dupVal < cuECtx.grad_verVal && th2 * cuECtx.grad_dowVal < cuECtx.grad_verVal && th1 * cuECtx.grad_horVal < cuECtx.grad_verVal && ( split == CU_VERT_SPLIT || split == CU_TRIV_SPLIT ) ) { return false; } @@ -870,7 +888,9 @@ bool EncModeCtrl::tryMode( const EncTestMode& encTestmode, const CodingStructure if( encTestmode.type == ETM_INTRA ) { - if( lumaArea.width > 64 || lumaArea.height > 64) + // if this is removed, the IntraSearch::xIntraCodingLumaQT needs to be adapted to support Intra TU split + // also isXXAvailable in IntraPrediction.cpp need to be fixed to check availability within the same CU without isDecomp + if( lumaArea.width > cs.sps->getMaxTbSize() || lumaArea.height > cs.sps->getMaxTbSize() ) { return false; } @@ -892,7 +912,7 @@ bool EncModeCtrl::tryMode( const EncTestMode& encTestmode, const CodingStructure } else if( !( slice.isIRAP() || /*bestModeType == ETM_INTRA || */!cuECtx.bestTU || - ((!m_pcEncCfg->m_bDisableIntraPUsInInterSlices) && (!relatedCU.isInter || !relatedCU.isIBC) && ( + ((!m_pcEncCfg->m_bDisableIntraCUsInInterSlices) && (!relatedCU.isInter || !relatedCU.isIBC) && ( ( cuECtx.bestTU->cbf[0] != 0 ) || ( ( numComp > COMP_Cb ) && cuECtx.bestTU->cbf[1] != 0 ) || ( ( numComp > COMP_Cr ) && cuECtx.bestTU->cbf[2] != 0 ) // avoid very complex intra if it is unlikely diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index 6519dc724..19dd1f4e6 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncModeCtrl.h \brief Encoder controller for trying out specific modes */ @@ -191,6 +195,10 @@ struct ComprCUCtx , bestCostTriHorzSplit (MAX_DOUBLE) , bestCostImv (MAX_DOUBLE *.5) , bestCostNoImv (MAX_DOUBLE *.5) + , grad_horVal (0) + , grad_verVal (0) + , grad_dupVal (0) + , grad_dowVal (0) , interHad (MAX_DISTORTION) , maxQtSubDepth (0) , earlySkip (false) @@ -218,6 +226,10 @@ struct ComprCUCtx double bestCostTriHorzSplit; double bestCostImv; double bestCostNoImv; + double grad_horVal; + double grad_verVal; + double grad_dupVal; + double grad_dowVal; Distortion interHad; int maxQtSubDepth; bool earlySkip; @@ -298,14 +310,15 @@ class CacheBlkInfoCtrl }; struct BestEncodingInfo -{ - CodingUnit cu; - PredictionUnit pu; - TransformUnit tu; - EncTestMode testMode; - int poc; - Distortion dist; - double costEDO; +{ + BestEncodingInfo( int dmvrSize ) { dmvrMvdBuffer.resize(dmvrSize); } + CodingUnit cu; + TransformUnit tu; + EncTestMode testMode; + int poc; + Distortion dist; + double costEDO; + std::vector dmvrMvdBuffer; }; class BestEncInfoCache @@ -314,8 +327,6 @@ class BestEncInfoCache const PreCalcValues* m_pcv; BestEncodingInfo* m_bestEncInfo[6][6][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2]; TCoeff* m_pCoeff; - Pel* m_pPcmBuf; - bool* m_runType; CodingStructure m_dummyCS; XUCache m_dummyCache; @@ -324,7 +335,7 @@ class BestEncInfoCache void create ( const ChromaFormat chFmt ); void destroy (); public: - BestEncInfoCache() : m_pcv( nullptr ), m_pCoeff( nullptr ), m_pPcmBuf( nullptr ), m_runType( nullptr ), m_dummyCS( m_dummyCache, nullptr ) {} + BestEncInfoCache() : m_pcv( nullptr ), m_pCoeff( nullptr ), m_dummyCS( m_dummyCache, nullptr ) {} virtual ~BestEncInfoCache() {} void init ( const Slice &slice ); diff --git a/source/Lib/EncoderLib/EncPicture.cpp b/source/Lib/EncoderLib/EncPicture.cpp index 59484e58a..9ff166ace 100644 --- a/source/Lib/EncoderLib/EncPicture.cpp +++ b/source/Lib/EncoderLib/EncPicture.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncPicture.cpp diff --git a/source/Lib/EncoderLib/EncPicture.h b/source/Lib/EncoderLib/EncPicture.h index 4c531d283..1a24c7bec 100644 --- a/source/Lib/EncoderLib/EncPicture.h +++ b/source/Lib/EncoderLib/EncPicture.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncPicture.h \brief encode picture (header) */ diff --git a/source/Lib/EncoderLib/EncReshape.cpp b/source/Lib/EncoderLib/EncReshape.cpp index 4468cbecf..57cca831f 100644 --- a/source/Lib/EncoderLib/EncReshape.cpp +++ b/source/Lib/EncoderLib/EncReshape.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncReshape.cpp @@ -224,7 +228,7 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) { for (bx = x1; bx <= x2; bx++) { - tempSq = pWinY[bx] * pWinY[bx]; + tempSq = (int64_t)pWinY[bx] * (int64_t)pWinY[bx]; leftSum += pWinY[bx]; leftSumSq += tempSq; leftColSum[bx] += pWinY[bx]; @@ -251,7 +255,7 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) for (bx = x1; bx <= x2; bx++) { topRowSum[y + winLens] += pWinY[bx]; - topRowSumSq[y + winLens] += pWinY[bx] * pWinY[bx]; + topRowSumSq[y + winLens] += (int64_t)pWinY[bx] * (int64_t)pWinY[bx]; } topSum += topRowSum[y + winLens]; topSumSq += topRowSumSq[y + winLens]; @@ -270,7 +274,7 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) for (bx = x1; bx <= x2; bx++) { leftColSum[bx] += pWinY[bx]; - leftColSumSq[bx] += pWinY[bx] * pWinY[bx]; + leftColSumSq[bx] += (int64_t)pWinY[bx] * (int64_t)pWinY[bx]; } pWinY += stride; } @@ -291,7 +295,7 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) for (by = y1; by <= y2; by++) { leftColSum[x + winLens] += pWinY[x + winLens]; - leftColSumSq[x + winLens] += pWinY[x + winLens] * pWinY[x + winLens]; + leftColSumSq[x + winLens] += (int64_t)pWinY[x + winLens] * (int64_t)pWinY[x + winLens]; pWinY += stride; } } @@ -304,14 +308,14 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) pWinY = &picY.buf[0]; pWinY += winLens * stride; leftColSum[x + winLens] += pWinY[x + winLens]; - leftColSumSq[x + winLens] += pWinY[x + winLens] * pWinY[x + winLens]; + leftColSumSq[x + winLens] += (int64_t)pWinY[x + winLens] * (int64_t)pWinY[x + winLens]; } if (y > winLens) { pWinY = &picY.buf[0]; pWinY -= (winLens + 1) * stride; leftColSum[x + winLens] -= pWinY[x + winLens]; - leftColSumSq[x + winLens] -= pWinY[x + winLens] * pWinY[x + winLens]; + leftColSumSq[x + winLens] -= (int64_t)pWinY[x + winLens] * (int64_t)pWinY[x + winLens]; } } topColSum[x + winLens] = leftColSum[x + winLens]; @@ -391,7 +395,7 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) for (int x = 0; x < width; x++) { avgY += picY.buf[x]; - varY += picY.buf[x] * picY.buf[x]; + varY += (double)picY.buf[x] * (double)picY.buf[x]; } picY.buf += stride; } @@ -401,8 +405,8 @@ void EncReshape::calcSeqStats(Picture& pic, SeqInfo &stats) { avgU += picU.buf[x]; avgV += picV.buf[x]; - varU += picU.buf[x] * picU.buf[x]; - varV += picV.buf[x] * picV.buf[x]; + varU += (int64_t)picU.buf[x] * (int64_t)picU.buf[x]; + varV += (int64_t)picV.buf[x] * (int64_t)picV.buf[x]; } picU.buf += strideC; picV.buf += strideC; diff --git a/source/Lib/EncoderLib/EncReshape.h b/source/Lib/EncoderLib/EncReshape.h index 575ed4a9e..e515f75a3 100644 --- a/source/Lib/EncoderLib/EncReshape.h +++ b/source/Lib/EncoderLib/EncReshape.h @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncReshape.h \brief encoder reshaping header and class (header) */ #pragma once -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CommonLib/Reshape.h" //! \ingroup EncoderLib diff --git a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp index a14842786..fcd040685 100644 --- a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp +++ b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** @@ -54,7 +58,7 @@ vvc@hhi.fraunhofer.de #include #include #include -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" //! \ingroup EncoderLib //! \{ diff --git a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.h b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.h index 0e21b6cb6..81067ea61 100644 --- a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.h +++ b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncSampleAdaptiveOffset.h \brief estimation part of sample adaptive offset class (header) diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index 5c19ebc4e..ac2ff03af 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncSlice.cpp @@ -56,7 +60,7 @@ vvc@hhi.fraunhofer.de #include "Utilities/NoMallocThreadPool.h" #include -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" //! \ingroup EncoderLib //! \{ @@ -825,7 +829,7 @@ bool EncSlice::xProcessCtuTask( int taskIdx, CtuEncParam* ctuEncParam ) encCu.encodeCtu( pic, lineEncRsrc->m_prevQp, ctuPosX, ctuPosY ); // cleanup line memory when last ctu in line done to reduce overall memory consumption - if( encSlice->m_pcEncCfg->m_numWppThreads > 0 && ctuPosX == pcv.widthInCtus - 1 ) + if( encSlice->m_pcEncCfg->m_ensureWppBitEqual && ctuPosX == pcv.widthInCtus - 1 ) { lineEncRsrc->m_AffineProfList.resetAffineMVList(); lineEncRsrc->m_BlkUniMvInfoBuffer.resetUniMvList(); @@ -955,24 +959,14 @@ bool EncSlice::xProcessCtuTask( int taskIdx, CtuEncParam* ctuEncParam ) // we have to do some kind of position aware boundary padding // it's done here because the conditions are readable PelUnitBuf recoBuf = cs.picture->getRecoBuf(); - const int fltSize = MAX_ALF_FILTER_LENGTH >> 1; + const int fltSize = ( MAX_ALF_FILTER_LENGTH + 1 ) >> 1; + const int xL = ( ctuPosX == 0 ) ? ( x-fltSize ) : ( x ); + const int xR = ( ctuPosX+1 == pcv.widthInCtus ) ? ( x+width+fltSize ) : ( x+width ); if( ctuPosX == 0 ) recoBuf.extendBorderPelLft( y, height, fltSize ); if( ctuPosX+1 == pcv.widthInCtus ) recoBuf.extendBorderPelRgt( y, height, fltSize ); - - if( ctuPosY == 0 ) - { - recoBuf.extendBorderPelTop( x, width, fltSize ); - if( ctuPosX == 0 ) recoBuf.extendBorderPelTop( x-(2*fltSize), (2*fltSize), fltSize ); - if( ctuPosX+1 == pcv.widthInCtus ) recoBuf.extendBorderPelTop( x+width, (2*fltSize), (2*fltSize) ); - } - - if( ctuPosY+1 == pcv.heightInCtus ) - { - recoBuf.extendBorderPelBot( x, width, fltSize ); - if( ctuPosX == 0 ) recoBuf.extendBorderPelBot( x-(2*fltSize), (2*fltSize), (2*fltSize) ); - if( ctuPosX+1 == pcv.widthInCtus ) recoBuf.extendBorderPelBot( x+width, (2*fltSize), (2*fltSize) ); - } + if( ctuPosY == 0 ) recoBuf.extendBorderPelTop( xL, xR-xL, fltSize ); + if( ctuPosY+1 == pcv.heightInCtus ) recoBuf.extendBorderPelBot( xL, xR-xL, fltSize ); } ITT_TASKEND( itt_domain_encode, itt_handle_sao ); diff --git a/source/Lib/EncoderLib/EncSlice.h b/source/Lib/EncoderLib/EncSlice.h index e225648bd..aa2199ecf 100644 --- a/source/Lib/EncoderLib/EncSlice.h +++ b/source/Lib/EncoderLib/EncSlice.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file EncSlice.h \brief slice encoder class (header) */ diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index fc21cc56c..df325ff28 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncSearch.cpp @@ -1029,37 +1033,24 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) MergeCtx mergeCtx; // Loop over Prediction Units - CHECK(!cu.pu, "CU does not contain any PUs"); - uint32_t puIdx = 0; - auto &pu = *cu.pu; - uint32_t uiLastModeTemp = 0; + uint32_t puIdx = 0; + uint32_t uiLastModeTemp = 0; Distortion uiAffineCost = MAX_DISTORTION; Distortion uiHevcCost = MAX_DISTORTION; - bool checkAffine = (pu.cu->imv == 0); /*|| pu.cu->slice->getSPS()->getAffineAmvrEnabledFlag()) && pu.cu->imv != IMV_HPEL;*/ - - bool checkNonAffine = pu.cu->imv == 0 || pu.cu->imv == IMV_HPEL || (pu.cu->slice->sps->AMVR && - pu.cu->imv <= (pu.cu->slice->sps->AMVR ? IMV_4PEL : 0)); - CodingUnit *bestCU = m_modeCtrl->comprCUCtx->bestCS != nullptr ? m_modeCtrl->comprCUCtx->bestCU : nullptr; - bool trySmvd = (bestCU != nullptr && pu.cu->imv == 2 && checkAffine) ? (!bestCU->pu->mergeFlag && !bestCU->affine) : true; - if (pu.cu->imv && bestCU != nullptr && checkAffine) - { - checkAffine = !(bestCU->pu->mergeFlag || !bestCU->affine); - } - - if (pu.cu->cs->bestParent != nullptr && pu.cu->cs->bestParent->getCU(CH_L,TREE_D) != nullptr && pu.cu->cs->bestParent->getCU(CH_L,TREE_D)->affine == false) + bool checkAffine = (cu.imv == 0); + if (cu.cs->bestParent != nullptr && cu.cs->bestParent->getCU(CH_L,TREE_D) != nullptr && cu.cs->bestParent->getCU(CH_L,TREE_D)->affine == false) { m_skipPROF = true; } m_encOnly = true; { - CHECK(pu.cu != &cu, "PU is contained in another CU"); if (cu.cs->sps->SbtMvp) { - Size bufSize = g_miScaling.scale(pu.lumaSize()); + Size bufSize = g_miScaling.scale(cu.lumaSize()); mergeCtx.subPuMvpMiBuf = MotionBuf(m_subPuMiBuf, bufSize); } - PU::spanMotionInfo( pu ); + CU::spanMotionInfo( cu ); Distortion uiCost[2] = { MAX_DISTORTION, MAX_DISTORTION }; Distortion uiCostBi = MAX_DISTORTION; Distortion uiCostTemp; @@ -1080,15 +1071,14 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) uint32_t bitsValidList1 = MAX_UINT; Distortion costValidList1 = MAX_DISTORTION; - CPelUnitBuf origBuf = pu.cs->getOrgBuf( pu ); + CPelUnitBuf origBuf = cu.cs->getOrgBuf( cu ); xGetBlkBits( cs.slice->isInterP(), puIdx, uiLastMode, uiMbBits ); m_pcRdCost->selectMotionLambda(); - unsigned imvShift = pu.cu->imv == IMV_HPEL ? 1 : (pu.cu->imv << 1); - if ( checkNonAffine ) - { + unsigned imvShift = cu.imv == IMV_HPEL ? 1 : (cu.imv << 1); + // Uni-directional prediction for ( int iRefList = 0; iRefList < iNumPredDir; iRefList++ ) { @@ -1104,10 +1094,10 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) uiBitsTemp--; } } - xEstimateMvPredAMVP( pu, origBuf, refPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], amvp[refPicList], biPDistTemp); + xEstimateMvPredAMVP( cu, origBuf, refPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], amvp[refPicList], biPDistTemp); - aaiMvpIdx[iRefList][iRefIdxTemp] = pu.mvpIdx[refPicList]; - aaiMvpNum[iRefList][iRefIdxTemp] = pu.mvpNum[refPicList]; + aaiMvpIdx[iRefList][iRefIdxTemp] = cu.mvpIdx[refPicList]; + aaiMvpNum[iRefList][iRefIdxTemp] = cu.mvpNum[refPicList]; if(cs.picHeader->mvdL1Zero && iRefList==1 && biPDistTemp < bestBiPDist) { @@ -1134,15 +1124,15 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } else { - xMotionEstimation( pu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, amvp[refPicList] ); + xMotionEstimation( cu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, amvp[refPicList] ); } } else { - xMotionEstimation( pu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, amvp[refPicList] ); + xMotionEstimation( cu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, amvp[refPicList] ); } xCopyAMVPInfo( &amvp[refPicList], &aacAMVPInfo[iRefList][iRefIdxTemp]); // must always be done ( also when AMVP_MODE = AM_NONE ) - xCheckBestMVP( refPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], amvp[refPicList], uiBitsTemp, uiCostTemp, pu.cu->imv ); + xCheckBestMVP( refPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], amvp[refPicList], uiBitsTemp, uiCostTemp, cu.imv ); if ( iRefList == 0 ) { @@ -1174,7 +1164,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) ::memcpy(cMvHevcTemp, cMvTemp, sizeof(cMvTemp)); if (cu.imv == 0 && (!cu.slice->sps->BCW || BcwIdx == BCW_DEFAULT)) { - m_BlkUniMvInfoBuffer->insertUniMvCands(pu.Y(), &cMvTemp[0][0]); + m_BlkUniMvInfoBuffer->insertUniMvCands(cu.Y(), &cMvTemp[0][0]); unsigned idx1, idx2, idx3, idx4; getAreaIdxNew(cu.Y(), *cs.pcv, idx1, idx2, idx3, idx4); @@ -1187,7 +1177,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } // Bi-predictive Motion estimation - if( cs.slice->isInterB() && !PU::isBipredRestriction( pu ) && (cu.slice->checkLDC || BcwIdx == BCW_DEFAULT) ) + if( cs.slice->isInterB() && !CU::isBipredRestriction( cu ) && (cu.slice->checkLDC || BcwIdx == BCW_DEFAULT) ) { bool doBiPred = true; cMvBi[0] = cMv[0]; @@ -1208,12 +1198,12 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) cMvBi [1] = cMvPredBi[1][bestBiPRefIdxL1]; iRefIdxBi[1] = bestBiPRefIdxL1; - pu.mv [REF_PIC_LIST_1] = cMvBi[1]; - pu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; - pu.mvpIdx[REF_PIC_LIST_1] = bestBiPMvpL1; + cu.mv [REF_PIC_LIST_1] = cMvBi[1]; + cu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; + cu.mvpIdx[REF_PIC_LIST_1] = bestBiPMvpL1; - PelUnitBuf predBufTmp = m_tmpPredStorage[REF_PIC_LIST_1].getCompactBuf( pu ); - motionCompensation( pu, predBufTmp, REF_PIC_LIST_1 ); + PelUnitBuf predBufTmp = m_tmpPredStorage[REF_PIC_LIST_1].getCompactBuf( cu ); + motionCompensation( cu, predBufTmp, REF_PIC_LIST_1 ); uiMotBits[0] = uiBits[0] - uiMbBits[0]; uiMotBits[1] = uiMbBits[1]; @@ -1272,11 +1262,11 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } if ( iIter == 0 && !cs.picHeader->mvdL1Zero) { - pu.mv [1 - iRefList] = cMv [1 - iRefList]; - pu.refIdx[1 - iRefList] = iRefIdx[1 - iRefList]; + cu.mv [1 - iRefList] = cMv [1 - iRefList]; + cu.refIdx[1 - iRefList] = iRefIdx[1 - iRefList]; - PelUnitBuf predBufTmp = m_tmpPredStorage[1 - iRefList].getCompactBuf( pu ); - motionCompensation( pu, predBufTmp, RefPicList(1 - iRefList) ); + PelUnitBuf predBufTmp = m_tmpPredStorage[1 - iRefList].getCompactBuf( cu ); + motionCompensation( cu, predBufTmp, RefPicList(1 - iRefList) ); } RefPicList refPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); @@ -1309,8 +1299,8 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } // call ME xCopyAMVPInfo(&aacAMVPInfo[iRefList][iRefIdxTemp], &amvp[refPicList] ); - xMotionEstimation ( pu, origBuf, refPicList, cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, amvp[refPicList], true ); - xCheckBestMVP( refPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], amvp[refPicList], uiBitsTemp, uiCostTemp, pu.cu->imv); + xMotionEstimation ( cu, origBuf, refPicList, cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, amvp[refPicList], true ); + xCheckBestMVP( refPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], amvp[refPicList], uiBitsTemp, uiCostTemp, cu.imv); if ( uiCostTemp < uiCostBi ) { bChanged = true; @@ -1325,11 +1315,11 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) if(iNumIter!=1) { // Set motion - pu.mv [refPicList] = cMvBi [iRefList]; - pu.refIdx[refPicList] = iRefIdxBi[iRefList]; + cu.mv [refPicList] = cMvBi [iRefList]; + cu.refIdx[refPicList] = iRefIdxBi[iRefList]; - PelUnitBuf predBufTmp = m_tmpPredStorage[iRefList].getCompactBuf( pu ); - motionCompensation( pu, predBufTmp, refPicList ); + PelUnitBuf predBufTmp = m_tmpPredStorage[iRefList].getCompactBuf( cu ); + motionCompensation( cu, predBufTmp, refPicList ); } } } // for loop-iRefIdxTemp @@ -1339,22 +1329,20 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) if ((uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1]) || enforceBcwPred) { xCopyAMVPInfo(&aacAMVPInfo[0][iRefIdxBi[0]], &amvp[REF_PIC_LIST_0]); - xCheckBestMVP( REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], amvp[REF_PIC_LIST_0], uiBits[2], uiCostBi, pu.cu->imv); + xCheckBestMVP( REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], amvp[REF_PIC_LIST_0], uiBits[2], uiCostBi, cu.imv); if(!cs.picHeader->mvdL1Zero) { xCopyAMVPInfo(&aacAMVPInfo[1][iRefIdxBi[1]], &amvp[REF_PIC_LIST_1]); - xCheckBestMVP( REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], amvp[REF_PIC_LIST_1], uiBits[2], uiCostBi, pu.cu->imv); + xCheckBestMVP( REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], amvp[REF_PIC_LIST_1], uiBits[2], uiCostBi, cu.imv); } } break; } } // for loop-iter } - cu.refIdxBi[0] = iRefIdxBi[0]; - cu.refIdxBi[1] = iRefIdxBi[1]; // SMVD - if( cs.slice->biDirPred && trySmvd ) + if( cs.slice->biDirPred ) { double th1 = 1.02; bool testSME = true; @@ -1383,9 +1371,11 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) { for ( int j = 0; j < aacAMVPInfo[tarRefList][refIdxTar].numCand; j++ ) { + GCC_WARNING_DISABLE_array_bounds // probably a bug in gcc-10 static analyzer: It thinks the indices are -1 and therefore triggers -Werror=array-bounds cCurMvField.setMvField( aacAMVPInfo[curRefList][refIdxCur].mvCand[i], refIdxCur ); cTarMvField.setMvField( aacAMVPInfo[tarRefList][refIdxTar].mvCand[j], refIdxTar ); - Distortion cost = xGetSymCost( pu, origBuf, eCurRefList, cCurMvField, cTarMvField, BcwIdx ); + GCC_WARNING_RESET + Distortion cost = xGetSymCost( cu, origBuf, eCurRefList, cCurMvField, cTarMvField, BcwIdx ); if ( cost < costStart ) { costStart = cost; @@ -1401,10 +1391,10 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) m_pcRdCost->setCostScale(0); Mv pred = cMvPredSym[curRefList]; - pred.changeTransPrecInternal2Amvr(pu.cu->imv); + pred.changeTransPrecInternal2Amvr(cu.imv); m_pcRdCost->setPredictor(pred); Mv mv = cCurMvField.mv; - mv.changeTransPrecInternal2Amvr(pu.cu->imv); + mv.changeTransPrecInternal2Amvr(cu.imv); uint32_t bits = m_pcRdCost->getBitsOfVectorWithPredictor(mv.hor, mv.ver, 0); bits += m_auiMVPIdxCost[mvpIdxSym[curRefList]][AMVP_MAX_NUM_CANDS]; bits += m_auiMVPIdxCost[mvpIdxSym[tarRefList]][AMVP_MAX_NUM_CANDS]; @@ -1413,9 +1403,9 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) std::vector symmvdCands; auto smmvdCandsGen = [&](Mv mvCand, bool mvPrecAdj) { - if (mvPrecAdj && pu.cu->imv) + if (mvPrecAdj && cu.imv) { - mvCand.roundTransPrecInternal2Amvr(pu.cu->imv); + mvCand.roundTransPrecInternal2Amvr(cu.imv); } bool toAddMvCand = true; @@ -1463,7 +1453,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } Distortion bestCost = costStart; - xSymMvdCheckBestMvp(pu, origBuf, mvStart, (RefPicList)curRefList, aacAMVPInfo, BcwIdx, cMvPredSym, mvpIdxSym, costStart, false); + xSymMvdCheckBestMvp(cu, origBuf, mvStart, (RefPicList)curRefList, aacAMVPInfo, BcwIdx, cMvPredSym, mvpIdxSym, costStart, false); if (costStart < bestCost) { cCurMvField.setMvField(mvStart, refIdxCur); @@ -1479,14 +1469,14 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) testSME = m_pcEncCfg->m_SMVD <= 2 || ( symCost < uiCostBi * th1 && uiCostBi < uiCost[ 0 ] && uiCostBi < uiCost[ 1 ] ); if( testSME ) { - xSymMotionEstimation( pu, origBuf, cMvPredSym[ curRefList ], cMvPredSym[ tarRefList ], eCurRefList, cCurMvField, cTarMvField, symCost, BcwIdx ); + xSymMotionEstimation( cu, origBuf, cMvPredSym[ curRefList ], cMvPredSym[ tarRefList ], eCurRefList, cCurMvField, cTarMvField, symCost, BcwIdx ); } symCost += mvpCost; if (startPtMv != cCurMvField.mv) { // if ME change MV, run a final check for best MVP. - xSymMvdCheckBestMvp(pu, origBuf, cCurMvField.mv, (RefPicList)curRefList, aacAMVPInfo, BcwIdx, cMvPredSym, mvpIdxSym, symCost, true); + xSymMvdCheckBestMvp(cu, origBuf, cCurMvField.mv, (RefPicList)curRefList, aacAMVPInfo, BcwIdx, cMvPredSym, mvpIdxSym, symCost, true); } bits = uiMbBits[2]; @@ -1514,16 +1504,16 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } // if (B_SLICE) // Clear Motion Field - pu.mv [REF_PIC_LIST_0] = Mv(); - pu.mv [REF_PIC_LIST_1] = Mv(); - pu.mvd [REF_PIC_LIST_0] = cMvZero; - pu.mvd [REF_PIC_LIST_1] = cMvZero; - pu.refIdx[REF_PIC_LIST_0] = NOT_VALID; - pu.refIdx[REF_PIC_LIST_1] = NOT_VALID; - pu.mvpIdx[REF_PIC_LIST_0] = NOT_VALID; - pu.mvpIdx[REF_PIC_LIST_1] = NOT_VALID; - pu.mvpNum[REF_PIC_LIST_0] = NOT_VALID; - pu.mvpNum[REF_PIC_LIST_1] = NOT_VALID; + cu.mv [REF_PIC_LIST_0] = Mv(); + cu.mv [REF_PIC_LIST_1] = Mv(); + cu.mvd [REF_PIC_LIST_0] = cMvZero; + cu.mvd [REF_PIC_LIST_1] = cMvZero; + cu.refIdx[REF_PIC_LIST_0] = NOT_VALID; + cu.refIdx[REF_PIC_LIST_1] = NOT_VALID; + cu.mvpIdx[REF_PIC_LIST_0] = NOT_VALID; + cu.mvpIdx[REF_PIC_LIST_1] = NOT_VALID; + cu.mvpNum[REF_PIC_LIST_0] = NOT_VALID; + cu.mvpNum[REF_PIC_LIST_1] = NOT_VALID; // Set Motion Field cMv [1] = mvValidList1; @@ -1539,39 +1529,39 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1]) { uiLastMode = 2; - pu.mv [REF_PIC_LIST_0] = cMvBi[0]; - pu.mv [REF_PIC_LIST_1] = cMvBi[1]; - pu.mvd [REF_PIC_LIST_0] = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]]; - pu.mvd [REF_PIC_LIST_1] = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]]; - pu.refIdx[REF_PIC_LIST_0] = iRefIdxBi[0]; - pu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; - pu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdxBi[0][iRefIdxBi[0]]; - pu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdxBi[1][iRefIdxBi[1]]; - pu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdxBi[0]]; - pu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdxBi[1]]; - pu.interDir = 3; - - pu.cu->smvdMode = symMode; + cu.mv [REF_PIC_LIST_0] = cMvBi[0]; + cu.mv [REF_PIC_LIST_1] = cMvBi[1]; + cu.mvd [REF_PIC_LIST_0] = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]]; + cu.mvd [REF_PIC_LIST_1] = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]]; + cu.refIdx[REF_PIC_LIST_0] = iRefIdxBi[0]; + cu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; + cu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdxBi[0][iRefIdxBi[0]]; + cu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdxBi[1][iRefIdxBi[1]]; + cu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdxBi[0]]; + cu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdxBi[1]]; + cu.interDir = 3; + + cu.smvdMode = symMode; } else if ( uiCost[0] <= uiCost[1] ) { uiLastMode = 0; - pu.mv [REF_PIC_LIST_0] = cMv[0]; - pu.mvd [REF_PIC_LIST_0] = cMv[0] - cMvPred[0][iRefIdx[0]]; - pu.refIdx[REF_PIC_LIST_0] = iRefIdx[0]; - pu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdx[0][iRefIdx[0]]; - pu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdx[0]]; - pu.interDir = 1; + cu.mv [REF_PIC_LIST_0] = cMv[0]; + cu.mvd [REF_PIC_LIST_0] = cMv[0] - cMvPred[0][iRefIdx[0]]; + cu.refIdx[REF_PIC_LIST_0] = iRefIdx[0]; + cu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdx[0][iRefIdx[0]]; + cu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdx[0]]; + cu.interDir = 1; } else { uiLastMode = 1; - pu.mv [REF_PIC_LIST_1] = cMv[1]; - pu.mvd [REF_PIC_LIST_1] = cMv[1] - cMvPred[1][iRefIdx[1]]; - pu.refIdx[REF_PIC_LIST_1] = iRefIdx[1]; - pu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdx[1][iRefIdx[1]]; - pu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdx[1]]; - pu.interDir = 2; + cu.mv [REF_PIC_LIST_1] = cMv[1]; + cu.mvd [REF_PIC_LIST_1] = cMv[1] - cMvPred[1][iRefIdx[1]]; + cu.refIdx[REF_PIC_LIST_1] = iRefIdx[1]; + cu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdx[1][iRefIdx[1]]; + cu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdx[1]]; + cu.interDir = 2; } if( BcwIdx != BCW_DEFAULT ) @@ -1579,8 +1569,8 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) cu.BcwIdx = BCW_DEFAULT; // Reset to default for the Non-NormalMC modes. } uiHevcCost = (uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1]) ? uiCostBi : ((uiCost[0] <= uiCost[1]) ? uiCost[0] : uiCost[1]); - } - if( cu.pu->interDir == 3 && !cu.pu->mergeFlag ) + + if( cu.interDir == 3 && !cu.mergeFlag ) { if (BcwIdx != BCW_DEFAULT) { @@ -1590,8 +1580,8 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) if (m_pcEncCfg->m_Affine > 1) { - checkAffine &= bestCU->affine; - if (bestCU->slice->TLayer > 3) + checkAffine &= m_modeCtrl->comprCUCtx->bestCU->affine; + if (cu.slice->TLayer > 3) { checkAffine = false; } @@ -1601,34 +1591,34 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) PROFILER_SCOPE_AND_STAGE_EXT( 1, g_timeProfiler, P_INTER_MVD_SEARCH_AFFINE, &cs, partitioner.chType ); m_hevcCost = uiHevcCost; // save normal hevc result - uint32_t uiMRGIndex = pu.mergeIdx; - bool bMergeFlag = pu.mergeFlag; - uint32_t uiInterDir = pu.interDir; + uint32_t uiMRGIndex = cu.mergeIdx; + bool bMergeFlag = cu.mergeFlag; + uint32_t uiInterDir = cu.interDir; int iSymMode = cu.smvdMode; Mv cMvd[2]; uint32_t uiMvpIdx[2], uiMvpNum[2]; - uiMvpIdx[0] = pu.mvpIdx[REF_PIC_LIST_0]; - uiMvpIdx[1] = pu.mvpIdx[REF_PIC_LIST_1]; - uiMvpNum[0] = pu.mvpNum[REF_PIC_LIST_0]; - uiMvpNum[1] = pu.mvpNum[REF_PIC_LIST_1]; - cMvd[0] = pu.mvd[REF_PIC_LIST_0]; - cMvd[1] = pu.mvd[REF_PIC_LIST_1]; + uiMvpIdx[0] = cu.mvpIdx[REF_PIC_LIST_0]; + uiMvpIdx[1] = cu.mvpIdx[REF_PIC_LIST_1]; + uiMvpNum[0] = cu.mvpNum[REF_PIC_LIST_0]; + uiMvpNum[1] = cu.mvpNum[REF_PIC_LIST_1]; + cMvd[0] = cu.mvd[REF_PIC_LIST_0]; + cMvd[1] = cu.mvd[REF_PIC_LIST_1]; MvField cHevcMvField[2]; - cHevcMvField[0].setMvField(pu.mv[REF_PIC_LIST_0], pu.refIdx[REF_PIC_LIST_0]); - cHevcMvField[1].setMvField(pu.mv[REF_PIC_LIST_1], pu.refIdx[REF_PIC_LIST_1]); + cHevcMvField[0].setMvField(cu.mv[REF_PIC_LIST_0], cu.refIdx[REF_PIC_LIST_0]); + cHevcMvField[1].setMvField(cu.mv[REF_PIC_LIST_1], cu.refIdx[REF_PIC_LIST_1]); // do affine ME & Merge cu.affineType = AFFINEMODEL_4PARAM; Mv acMvAffine4Para[2][MAX_REF_PICS][3]; int refIdx4Para[2] = { -1, -1 }; - xPredAffineInterSearch(pu, origBuf, puIdx, uiLastModeTemp, uiAffineCost, cMvHevcTemp, acMvAffine4Para, refIdx4Para, BcwIdx, enforceBcwPred); + xPredAffineInterSearch(cu, origBuf, puIdx, uiLastModeTemp, uiAffineCost, cMvHevcTemp, acMvAffine4Para, refIdx4Para, BcwIdx, enforceBcwPred); - if (pu.cu->imv == 0) + if (cu.imv == 0) { - storeAffineMotion(pu.mvAffi, pu.refIdx, AFFINEMODEL_4PARAM, BcwIdx); + storeAffineMotion(cu.mvAffi, cu.refIdx, AFFINEMODEL_4PARAM, BcwIdx); } if (cu.slice->sps->AffineType) { @@ -1639,22 +1629,22 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) int bestMvpIdx[2], bestMvpNum[2], bestRefIdx[2]; uint8_t bestInterDir; - bestInterDir = pu.interDir; - bestRefIdx[0] = pu.refIdx[0]; - bestRefIdx[1] = pu.refIdx[1]; - bestMvpIdx[0] = pu.mvpIdx[0]; - bestMvpIdx[1] = pu.mvpIdx[1]; - bestMvpNum[0] = pu.mvpNum[0]; - bestMvpNum[1] = pu.mvpNum[1]; + bestInterDir = cu.interDir; + bestRefIdx[0] = cu.refIdx[0]; + bestRefIdx[1] = cu.refIdx[1]; + bestMvpIdx[0] = cu.mvpIdx[0]; + bestMvpIdx[1] = cu.mvpIdx[1]; + bestMvpNum[0] = cu.mvpNum[0]; + bestMvpNum[1] = cu.mvpNum[1]; for (int refList = 0; refList < 2; refList++) { - bestMv[refList][0] = pu.mvAffi[refList][0]; - bestMv[refList][1] = pu.mvAffi[refList][1]; - bestMv[refList][2] = pu.mvAffi[refList][2]; - bestMvd[refList][0] = pu.mvdAffi[refList][0]; - bestMvd[refList][1] = pu.mvdAffi[refList][1]; - bestMvd[refList][2] = pu.mvdAffi[refList][2]; + bestMv[refList][0] = cu.mvAffi[refList][0]; + bestMv[refList][1] = cu.mvAffi[refList][1]; + bestMv[refList][2] = cu.mvAffi[refList][2]; + bestMvd[refList][0] = cu.mvdAffi[refList][0]; + bestMvd[refList][1] = cu.mvdAffi[refList][1]; + bestMvd[refList][2] = cu.mvdAffi[refList][2]; } refIdx4Para[0] = bestRefIdx[0]; @@ -1662,33 +1652,33 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) Distortion uiAffine6Cost = MAX_DISTORTION; cu.affineType = AFFINEMODEL_6PARAM; - xPredAffineInterSearch(pu, origBuf, puIdx, uiLastModeTemp, uiAffine6Cost, cMvHevcTemp, acMvAffine4Para, refIdx4Para, BcwIdx, enforceBcwPred); + xPredAffineInterSearch(cu, origBuf, puIdx, uiLastModeTemp, uiAffine6Cost, cMvHevcTemp, acMvAffine4Para, refIdx4Para, BcwIdx, enforceBcwPred); - if (pu.cu->imv == 0) + if (cu.imv == 0) { - storeAffineMotion(pu.mvAffi, pu.refIdx, AFFINEMODEL_6PARAM, BcwIdx); + storeAffineMotion(cu.mvAffi, cu.refIdx, AFFINEMODEL_6PARAM, BcwIdx); } // reset to 4 parameter affine inter mode if (uiAffineCost <= uiAffine6Cost) { cu.affineType = AFFINEMODEL_4PARAM; - pu.interDir = bestInterDir; - pu.refIdx[0] = bestRefIdx[0]; - pu.refIdx[1] = bestRefIdx[1]; - pu.mvpIdx[0] = bestMvpIdx[0]; - pu.mvpIdx[1] = bestMvpIdx[1]; - pu.mvpNum[0] = bestMvpNum[0]; - pu.mvpNum[1] = bestMvpNum[1]; + cu.interDir = bestInterDir; + cu.refIdx[0] = bestRefIdx[0]; + cu.refIdx[1] = bestRefIdx[1]; + cu.mvpIdx[0] = bestMvpIdx[0]; + cu.mvpIdx[1] = bestMvpIdx[1]; + cu.mvpNum[0] = bestMvpNum[0]; + cu.mvpNum[1] = bestMvpNum[1]; for (int verIdx = 0; verIdx < 3; verIdx++) { - pu.mvdAffi[REF_PIC_LIST_0][verIdx] = bestMvd[0][verIdx]; - pu.mvdAffi[REF_PIC_LIST_1][verIdx] = bestMvd[1][verIdx]; + cu.mvdAffi[REF_PIC_LIST_0][verIdx] = bestMvd[0][verIdx]; + cu.mvdAffi[REF_PIC_LIST_1][verIdx] = bestMvd[1][verIdx]; } - PU::setAllAffineMv(pu, bestMv[0][0], bestMv[0][1], bestMv[0][2], REF_PIC_LIST_0); - PU::setAllAffineMv(pu, bestMv[1][0], bestMv[1][1], bestMv[1][2], REF_PIC_LIST_1); + CU::setAllAffineMv(cu, bestMv[0][0], bestMv[0][1], bestMv[0][2], REF_PIC_LIST_0); + CU::setAllAffineMv(cu, bestMv[1][0], bestMv[1][1], bestMv[1][2], REF_PIC_LIST_1); } else { @@ -1703,21 +1693,21 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) { // set hevc me result cu.affine = false; - pu.mergeFlag = bMergeFlag; - pu.regularMergeFlag = false; - pu.mergeIdx = uiMRGIndex; - pu.interDir = uiInterDir; + cu.mergeFlag = bMergeFlag; + cu.regularMergeFlag = false; + cu.mergeIdx = uiMRGIndex; + cu.interDir = uiInterDir; cu.smvdMode = iSymMode; - pu.mv[REF_PIC_LIST_0] = cHevcMvField[0].mv; - pu.refIdx[REF_PIC_LIST_0] = cHevcMvField[0].refIdx; - pu.mv[REF_PIC_LIST_1] = cHevcMvField[1].mv; - pu.refIdx[REF_PIC_LIST_1] = cHevcMvField[1].refIdx; - pu.mvpIdx[REF_PIC_LIST_0] = uiMvpIdx[0]; - pu.mvpIdx[REF_PIC_LIST_1] = uiMvpIdx[1]; - pu.mvpNum[REF_PIC_LIST_0] = uiMvpNum[0]; - pu.mvpNum[REF_PIC_LIST_1] = uiMvpNum[1]; - pu.mvd[REF_PIC_LIST_0] = cMvd[0]; - pu.mvd[REF_PIC_LIST_1] = cMvd[1]; + cu.mv[REF_PIC_LIST_0] = cHevcMvField[0].mv; + cu.refIdx[REF_PIC_LIST_0] = cHevcMvField[0].refIdx; + cu.mv[REF_PIC_LIST_1] = cHevcMvField[1].mv; + cu.refIdx[REF_PIC_LIST_1] = cHevcMvField[1].refIdx; + cu.mvpIdx[REF_PIC_LIST_0] = uiMvpIdx[0]; + cu.mvpIdx[REF_PIC_LIST_1] = uiMvpIdx[1]; + cu.mvpNum[REF_PIC_LIST_0] = uiMvpNum[0]; + cu.mvpNum[REF_PIC_LIST_1] = uiMvpNum[1]; + cu.mvd[REF_PIC_LIST_0] = cMvd[0]; + cu.mvd[REF_PIC_LIST_1] = cMvd[1]; } else { @@ -1728,23 +1718,19 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) } - PU::spanMotionInfo( pu, mergeCtx ); + CU::spanMotionInfo( cu, mergeCtx ); m_skipPROF = false; m_encOnly = false; - if (BcwIdx == BCW_DEFAULT || !m_affineMotion.affine4ParaAvail || !m_affineMotion.affine6ParaAvail) - { - m_affineMotion.hevcCost[pu.cu->imv] = uiHevcCost; - } // MC - PelUnitBuf predBuf = pu.cs->getPredBuf(pu); - motionCompensation( pu, predBuf, REF_PIC_LIST_X ); + PelUnitBuf predBuf = cu.cs->getPredBuf(cu); + motionCompensation( cu, predBuf, REF_PIC_LIST_X ); puIdx++; } } // AMVP -void InterSearch::xEstimateMvPredAMVP( PredictionUnit& pu, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv& rcMvPred, AMVPInfo& rAMVPInfo, Distortion& distBiP ) +void InterSearch::xEstimateMvPredAMVP( CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv& rcMvPred, AMVPInfo& rAMVPInfo, Distortion& distBiP ) { Mv cBestMv; int iBestIdx = 0; @@ -1754,18 +1740,18 @@ void InterSearch::xEstimateMvPredAMVP( PredictionUnit& pu, CPelUnitBuf& origBuf, AMVPInfo* pcAMVPInfo = &rAMVPInfo; // Fill the MV Candidates - PU::fillMvpCand( pu, refPicList, iRefIdx, *pcAMVPInfo ); + CU::fillMvpCand( cu, refPicList, iRefIdx, *pcAMVPInfo ); // initialize Mvp index & Mvp iBestIdx = 0; cBestMv = pcAMVPInfo->mvCand[0]; - PelUnitBuf predBuf = m_tmpStorageLCU.getCompactBuf( pu ); + PelUnitBuf predBuf = m_tmpStorageLCU.getCompactBuf( cu ); //-- Check Minimum Cost. for( i = 0 ; i < pcAMVPInfo->numCand; i++) { - Distortion uiTmpCost = xGetTemplateCost( pu, origBuf, predBuf, pcAMVPInfo->mvCand[i], i, AMVP_MAX_NUM_CANDS, refPicList, iRefIdx ); + Distortion uiTmpCost = xGetTemplateCost( cu, origBuf, predBuf, pcAMVPInfo->mvCand[i], i, AMVP_MAX_NUM_CANDS, refPicList, iRefIdx ); if( uiBestCost > uiTmpCost ) { uiBestCost = uiTmpCost; @@ -1777,8 +1763,8 @@ void InterSearch::xEstimateMvPredAMVP( PredictionUnit& pu, CPelUnitBuf& origBuf, // Setting Best MVP rcMvPred = cBestMv; - pu.mvpIdx[refPicList] = iBestIdx; - pu.mvpNum[refPicList] = pcAMVPInfo->numCand; + cu.mvpIdx[refPicList] = iBestIdx; + cu.mvpNum[refPicList] = pcAMVPInfo->numCand; return; } @@ -1888,7 +1874,7 @@ void InterSearch::xCheckBestMVP ( RefPicList refPicList, const Mv& cMv, Mv& rcMv } -Distortion InterSearch::xGetTemplateCost( const PredictionUnit& pu, +Distortion InterSearch::xGetTemplateCost( const CodingUnit& cu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv cMvCand, @@ -1900,21 +1886,21 @@ Distortion InterSearch::xGetTemplateCost( const PredictionUnit& pu, { Distortion uiCost = MAX_DISTORTION; - const Picture* picRef = pu.cu->slice->getRefPic( refPicList, iRefIdx ); - clipMv( cMvCand, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv ); + const Picture* picRef = cu.slice->getRefPic( refPicList, iRefIdx ); + clipMv( cMvCand, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); // prediction pattern - xPredInterBlk( COMP_Y, pu, picRef, cMvCand, predBuf, false, pu.cu->slice->clpRngs[ COMP_Y ], false, false); + xPredInterBlk( COMP_Y, cu, picRef, cMvCand, predBuf, false, cu.slice->clpRngs[ COMP_Y ], false, false); // calc distortion - uiCost = m_pcRdCost->getDistPart(origBuf.Y(), predBuf.Y(), pu.cs->sps->bitDepths[ CH_L ], COMP_Y, DF_SAD); + uiCost = m_pcRdCost->getDistPart(origBuf.Y(), predBuf.Y(), cu.cs->sps->bitDepths[ CH_L ], COMP_Y, DF_SAD); uiCost += m_pcRdCost->getCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum] ); return uiCost; } -void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, RefPicList refPicList, Mv& rcMvPred, int iRefIdxPred, Mv& rcMv, int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost, const AMVPInfo& amvpInfo, bool bBi) +void InterSearch::xMotionEstimation(CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, Mv& rcMvPred, int iRefIdxPred, Mv& rcMv, int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost, const AMVPInfo& amvpInfo, bool bBi) { Mv cMvHalf, cMvQter; @@ -1929,36 +1915,36 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re if(bBi) // Bi-predictive ME { - PelUnitBuf origBufTmp = m_tmpStorageLCU.getCompactBuf( pu ); + PelUnitBuf origBufTmp = m_tmpStorageLCU.getCompactBuf( cu ); // NOTE: Other buf contains predicted signal from another direction - PelUnitBuf otherBuf = m_tmpPredStorage[1 - (int)refPicList].getCompactBuf( pu ); + PelUnitBuf otherBuf = m_tmpPredStorage[1 - (int)refPicList].getCompactBuf( cu ); origBufTmp.copyFrom(origBuf); - origBufTmp.removeHighFreq( otherBuf, m_pcEncCfg->m_bClipForBiPredMeEnabled, pu.cu->slice->clpRngs ); + origBufTmp.removeHighFreq( otherBuf, m_pcEncCfg->m_bClipForBiPredMeEnabled, cu.slice->clpRngs ); - origBufTmpCnst = m_tmpStorageLCU.getCompactBuf( pu ); + origBufTmpCnst = m_tmpStorageLCU.getCompactBuf( cu ); pBuf = &origBufTmpCnst; - fWeight = xGetMEDistortionWeight( pu.cu->BcwIdx, refPicList ); + fWeight = xGetMEDistortionWeight( cu.BcwIdx, refPicList ); } // Search key pattern initialization CPelBuf tmpPattern = pBuf->Y(); CPelBuf* pcPatternKey = &tmpPattern; - m_lumaClpRng = pu.cs->slice->clpRngs[ COMP_Y ]; + m_lumaClpRng = cu.cs->slice->clpRngs[ COMP_Y ]; - const Picture* refPic = pu.cu->slice->getRefPic(refPicList, iRefIdxPred); - CPelBuf buf = pu.cs->sps->wrapAroundEnabled ? refPic->getRecoWrapBuf(pu.blocks[COMP_Y]) : refPic->getRecoBuf(pu.blocks[COMP_Y]); + const Picture* refPic = cu.slice->getRefPic(refPicList, iRefIdxPred); + CPelBuf buf = cu.cs->sps->wrapAroundEnabled ? refPic->getRecoWrapBuf(cu.blocks[COMP_Y]) : refPic->getRecoBuf(cu.blocks[COMP_Y]); TZSearchStruct cStruct; cStruct.pcPatternKey = pcPatternKey; cStruct.iRefStride = buf.stride; cStruct.piRefY = buf.buf; - cStruct.imvShift = pu.cu->imv == IMV_HPEL ? 1 : (pu.cu->imv << 1); - cStruct.useAltHpelIf = pu.cu->imv == IMV_HPEL; + cStruct.imvShift = cu.imv == IMV_HPEL ? 1 : (cu.imv << 1); + cStruct.useAltHpelIf = cu.imv == IMV_HPEL; cStruct.inCtuSearch = false; cStruct.zeroMV = false; - CodedCUInfo &relatedCU = m_modeCtrl->getBlkInfo( pu ); + CodedCUInfo &relatedCU = m_modeCtrl->getBlkInfo( cu ); bool bQTBTMV = false; bool bQTBTMV2 = false; @@ -1986,7 +1972,7 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re Mv bestInitMv = (bBi ? rcMv : rcMvPred); Mv cTmpMv = bestInitMv; - clipMv(cTmpMv, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + clipMv(cTmpMv, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); cTmpMv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); m_cDistParam.cur.buf = cStruct.piRefY + (cTmpMv.ver * cStruct.iRefStride) + cTmpMv.hor; Distortion uiBestSad = m_cDistParam.distFunc(m_cDistParam); @@ -2009,7 +1995,7 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re continue; cTmpMv = curMvInfo->uniMvs[refPicList][iRefIdxPred]; - clipMv(cTmpMv, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + clipMv(cTmpMv, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); cTmpMv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); m_cDistParam.cur.buf = cStruct.piRefY + (cTmpMv.ver * cStruct.iRefStride) + cTmpMv.hor; @@ -2025,7 +2011,7 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re if( !bQTBTMV ) { - xSetSearchRange(pu, bestInitMv, iSrchRng, cStruct.searchRange ); + xSetSearchRange(cu, bestInitMv, iSrchRng, cStruct.searchRange ); } xPatternSearch( cStruct, rcMv, ruiCost); } @@ -2034,7 +2020,7 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re rcMv = cIntMv; cStruct.subShiftMode = ( !m_pcEncCfg->m_bRestrictMESampling && m_pcEncCfg->m_motionEstimationSearchMethod == MESEARCH_SELECTIVE ) ? 1 : ( m_pcEncCfg->m_fastInterSearchMode == FASTINTERSEARCH_MODE1 || m_pcEncCfg->m_fastInterSearchMode == FASTINTERSEARCH_MODE3 ) ? 2 : 0; - xTZSearch(pu, refPicList, iRefIdxPred, cStruct, rcMv, ruiCost, NULL, false, true); + xTZSearch(cu, refPicList, iRefIdxPred, cStruct, rcMv, ruiCost, NULL, false, true); } else { @@ -2042,15 +2028,15 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re ( m_pcEncCfg->m_fastInterSearchMode == FASTINTERSEARCH_MODE1 || m_pcEncCfg->m_fastInterSearchMode == FASTINTERSEARCH_MODE3 ) ? 2 : 0; rcMv = rcMvPred; const Mv *pIntegerMv2Nx2NPred = nullptr; - xPatternSearchFast(pu, refPicList, iRefIdxPred, cStruct, rcMv, ruiCost, pIntegerMv2Nx2NPred); + xPatternSearchFast(cu, refPicList, iRefIdxPred, cStruct, rcMv, ruiCost, pIntegerMv2Nx2NPred); relatedCU.setMv( refPicList, iRefIdxPred, rcMv ); } - DTRACE( g_trace_ctx, D_ME, "%d %d %d :MECostFPel: %d,%d,%dx%d, %d", DTRACE_GET_COUNTER( g_trace_ctx, D_ME ), pu.cu->slice->poc, 0, ( int ) refPicList, ( int ) bBi, pu.Y().x, pu.Y().y, pu.Y().width, pu.Y().height, ruiCost ); + DTRACE( g_trace_ctx, D_ME, "%d %d %d :MECostFPel: %d,%d,%dx%d, %d", DTRACE_GET_COUNTER( g_trace_ctx, D_ME ), cu.slice->poc, 0, ( int ) refPicList, ( int ) bBi, cu.Y().x, cu.Y().y, cu.Y().width, cu.Y().height, ruiCost ); // sub-pel refinement for sub-pel resolution - if ( pu.cu->imv == 0 || pu.cu->imv == IMV_HPEL ) + if ( cu.imv == 0 || cu.imv == IMV_HPEL ) { - xPatternSearchFracDIF(pu, refPicList, iRefIdxPred, cStruct, rcMv, cMvHalf, cMvQter, ruiCost); + xPatternSearchFracDIF(cu, refPicList, iRefIdxPred, cStruct, rcMv, cMvHalf, cMvQter, ruiCost); m_pcRdCost->setCostScale( 0 ); rcMv <<= 2; rcMv += ( cMvHalf <<= 1 ); @@ -2063,34 +2049,34 @@ void InterSearch::xMotionEstimation(PredictionUnit& pu, CPelUnitBuf& origBuf, Re else // integer refinement for integer-pel and 4-pel resolution { rcMv.changePrecision(MV_PRECISION_INT, MV_PRECISION_INTERNAL); - xPatternSearchIntRefine( pu, cStruct, rcMv, rcMvPred, riMVPIdx, ruiBits, ruiCost, amvpInfo, fWeight); + xPatternSearchIntRefine( cu, cStruct, rcMv, rcMvPred, riMVPIdx, ruiBits, ruiCost, amvpInfo, fWeight); } DTRACE(g_trace_ctx, D_ME, " MECost: %6d (%d) MV:%d,%d\n", (int)refPicList, (int)bBi, ruiCost, ruiBits, rcMv.hor << 2, rcMv.ver << 2); } -void InterSearch::xSetSearchRange ( const PredictionUnit& pu, +void InterSearch::xSetSearchRange ( const CodingUnit& cu, const Mv& cMvPred, const int iSrchRng, SearchRange& sr ) { - const PreCalcValues& pcv = *pu.cs->pcv; + const PreCalcValues& pcv = *cu.cs->pcv; const int iMvShift = MV_FRACTIONAL_BITS_INTERNAL; Mv cFPMvPred = cMvPred; - clipMv( cFPMvPred, pu.cu->lumaPos(), pu.cu->lumaSize(), pcv ); + clipMv( cFPMvPred, cu.lumaPos(), cu.lumaSize(), pcv ); Mv mvTL(cFPMvPred.hor - (iSrchRng << iMvShift), cFPMvPred.ver - (iSrchRng << iMvShift)); Mv mvBR(cFPMvPred.hor + (iSrchRng << iMvShift), cFPMvPred.ver + (iSrchRng << iMvShift)); if( pcv.wrapArround ) { - wrapClipMv( mvTL, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs); - wrapClipMv( mvBR, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs); + wrapClipMv( mvTL, cu.lumaPos(), cu.lumaSize(), *cu.cs); + wrapClipMv( mvBR, cu.lumaPos(), cu.lumaSize(), *cu.cs); } else { - clipMv( mvTL, pu.cu->lumaPos(), pu.cu->lumaSize(), pcv); - clipMv( mvBR, pu.cu->lumaPos(), pu.cu->lumaSize(), pcv); + clipMv( mvTL, cu.lumaPos(), cu.lumaSize(), pcv); + clipMv( mvBR, cu.lumaPos(), cu.lumaSize(), pcv); } mvTL.divideByPowerOf2( iMvShift ); @@ -2148,7 +2134,7 @@ void InterSearch::xPatternSearch( TZSearchStruct& cStruct, } -void InterSearch::xPatternSearchFast( const PredictionUnit& pu, +void InterSearch::xPatternSearchFast( const CodingUnit& cu, RefPicList refPicList, int iRefIdxPred, TZSearchStruct& cStruct, @@ -2159,18 +2145,18 @@ void InterSearch::xPatternSearchFast( const PredictionUnit& pu, switch ( m_motionEstimationSearchMethod ) { case MESEARCH_DIAMOND_FAST: - xTZSearch ( pu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false, true ); + xTZSearch ( cu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false, true ); break; case MESEARCH_DIAMOND: - xTZSearch ( pu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false ); + xTZSearch ( cu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false ); break; case MESEARCH_SELECTIVE: - xTZSearchSelective( pu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred ); + xTZSearchSelective( cu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred ); break; case MESEARCH_DIAMOND_ENHANCED: - xTZSearch ( pu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred, true ); + xTZSearch ( cu, refPicList, iRefIdxPred, cStruct, rcMv, ruiSAD, pIntegerMv2Nx2NPred, true ); break; case MESEARCH_FULL: // shouldn't get here. @@ -2180,7 +2166,7 @@ void InterSearch::xPatternSearchFast( const PredictionUnit& pu, } -void InterSearch::xTZSearch( const PredictionUnit& pu, +void InterSearch::xTZSearch( const CodingUnit& cu, RefPicList refPicList, int iRefIdxPred, TZSearchStruct& cStruct, @@ -2215,7 +2201,7 @@ void InterSearch::xTZSearch( const PredictionUnit& pu, int iSearchRange = m_iSearchRange; { - clipMv( rcMv, pu.cu->lumaPos(), pu.cu->lumaSize(),*pu.cs->pcv ); + clipMv( rcMv, cu.lumaPos(), cu.lumaSize(),*cu.cs->pcv ); } rcMv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_QUARTER); rcMv.divideByPowerOf2(2); @@ -2251,7 +2237,7 @@ void InterSearch::xTZSearch( const PredictionUnit& pu, Mv integerMv2Nx2NPred = *pIntegerMv2Nx2NPred; integerMv2Nx2NPred.changePrecision(MV_PRECISION_INT, MV_PRECISION_INTERNAL); { - clipMv( integerMv2Nx2NPred, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv ); + clipMv( integerMv2Nx2NPred, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); } integerMv2Nx2NPred.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_QUARTER); integerMv2Nx2NPred.divideByPowerOf2(2); @@ -2279,7 +2265,7 @@ void InterSearch::xTZSearch( const PredictionUnit& pu, } Mv cTmpMv = curMvInfo->uniMvs[refPicList][iRefIdxPred]; - clipMv(cTmpMv, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + clipMv(cTmpMv, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); cTmpMv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); m_cDistParam.cur.buf = cStruct.piRefY + (cTmpMv.ver * cStruct.iRefStride) + cTmpMv.hor; @@ -2298,7 +2284,7 @@ void InterSearch::xTZSearch( const PredictionUnit& pu, // set search range Mv currBestMv(cStruct.iBestX, cStruct.iBestY ); currBestMv <<= MV_FRACTIONAL_BITS_INTERNAL; - xSetSearchRange(pu, currBestMv, m_iSearchRange >> (bFastSettings ? 1 : 0), sr ); + xSetSearchRange(cu, currBestMv, m_iSearchRange >> (bFastSettings ? 1 : 0), sr ); } // start search @@ -2487,7 +2473,7 @@ void InterSearch::xTZSearch( const PredictionUnit& pu, } -void InterSearch::xTZSearchSelective( const PredictionUnit& pu, +void InterSearch::xTZSearchSelective( const CodingUnit& cu, RefPicList refPicList, int iRefIdxPred, TZSearchStruct& cStruct, @@ -2510,7 +2496,7 @@ void InterSearch::xTZSearchSelective( const PredictionUnit& pu, int iStartX = 0; int iStartY = 0; int iDist = 0; - clipMv( rcMv, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv ); + clipMv( rcMv, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); rcMv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_QUARTER); rcMv.divideByPowerOf2(2); @@ -2538,7 +2524,7 @@ void InterSearch::xTZSearchSelective( const PredictionUnit& pu, { Mv integerMv2Nx2NPred = *pIntegerMv2Nx2NPred; integerMv2Nx2NPred.changePrecision(MV_PRECISION_INT, MV_PRECISION_INTERNAL); - clipMv( integerMv2Nx2NPred, pu.cu->lumaPos(), pu.cu->lumaSize(),*pu.cs->pcv ); + clipMv( integerMv2Nx2NPred, cu.lumaPos(), cu.lumaSize(),*cu.cs->pcv ); integerMv2Nx2NPred.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_QUARTER); integerMv2Nx2NPred.divideByPowerOf2(2); @@ -2563,7 +2549,7 @@ void InterSearch::xTZSearchSelective( const PredictionUnit& pu, continue; Mv cTmpMv = curMvInfo->uniMvs[refPicList][iRefIdxPred]; - clipMv(cTmpMv, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + clipMv(cTmpMv, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); cTmpMv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); m_cDistParam.cur.buf = cStruct.piRefY + (cTmpMv.ver * cStruct.iRefStride) + cTmpMv.hor; @@ -2582,7 +2568,7 @@ void InterSearch::xTZSearchSelective( const PredictionUnit& pu, // set search range Mv currBestMv(cStruct.iBestX, cStruct.iBestY ); currBestMv <<= 2; - xSetSearchRange( pu, currBestMv, m_iSearchRange, sr ); + xSetSearchRange( cu, currBestMv, m_iSearchRange, sr ); } // Initial search @@ -2659,13 +2645,13 @@ void InterSearch::xTZSearchSelective( const PredictionUnit& pu, ruiSAD = cStruct.uiBestSad - m_pcRdCost->getCostOfVectorWithPredictor( cStruct.iBestX, cStruct.iBestY, cStruct.imvShift ); } -void InterSearch::xPatternSearchIntRefine(PredictionUnit& pu, TZSearchStruct& cStruct, Mv& rcMv, Mv& rcMvPred, int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost, const AMVPInfo& amvpInfo, double fWeight) +void InterSearch::xPatternSearchIntRefine(CodingUnit& cu, TZSearchStruct& cStruct, Mv& rcMv, Mv& rcMvPred, int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost, const AMVPInfo& amvpInfo, double fWeight) { - CHECK( pu.cu->imv == 0 || pu.cu->imv == IMV_HPEL , "xPatternSearchIntRefine(): Sub-pel MV used."); + CHECK( cu.imv == 0 || cu.imv == IMV_HPEL , "xPatternSearchIntRefine(): Sub-pel MV used."); CHECK( amvpInfo.mvCand[riMVPIdx] != rcMvPred, "xPatternSearchIntRefine(): MvPred issue."); - m_pcRdCost->setDistParam(m_cDistParam, *cStruct.pcPatternKey, cStruct.piRefY, cStruct.iRefStride, m_lumaClpRng.bd, COMP_Y, 0, m_pcEncCfg->m_bUseHADME && !pu.cs->slice->disableSATDForRd); + m_pcRdCost->setDistParam(m_cDistParam, *cStruct.pcPatternKey, cStruct.piRefY, cStruct.iRefStride, m_lumaClpRng.bd, COMP_Y, 0, m_pcEncCfg->m_bUseHADME && !cu.cs->slice->disableSATDForRd); // -> set MV scale for cost calculation to QPEL (0) m_pcRdCost->setCostScale ( 0 ); @@ -2687,8 +2673,8 @@ void InterSearch::xPatternSearchIntRefine(PredictionUnit& pu, TZSearchStruct& c CHECK( (cBaseMvd[0].hor & 0x03) != 0 || (cBaseMvd[0].ver & 0x03) != 0 , "xPatternSearchIntRefine(): AMVP cand 0 Mvd issue."); CHECK( (cBaseMvd[1].hor & 0x03) != 0 || (cBaseMvd[1].ver & 0x03) != 0 , "xPatternSearchIntRefine(): AMVP cand 1 Mvd issue."); - cBaseMvd[0].roundTransPrecInternal2Amvr(pu.cu->imv); - cBaseMvd[1].roundTransPrecInternal2Amvr(pu.cu->imv); + cBaseMvd[0].roundTransPrecInternal2Amvr(cu.imv); + cBaseMvd[1].roundTransPrecInternal2Amvr(cu.imv); // test best integer position and all 8 neighboring positions for (int pos = 0; pos < 9; pos ++) @@ -2698,7 +2684,7 @@ void InterSearch::xPatternSearchIntRefine(PredictionUnit& pu, TZSearchStruct& c for (int iMVPIdx = 0; iMVPIdx < amvpInfo.numCand; iMVPIdx++) { cTestMv[iMVPIdx] = testPos[pos]; - cTestMv[iMVPIdx].changeTransPrecAmvr2Internal(pu.cu->imv); + cTestMv[iMVPIdx].changeTransPrecAmvr2Internal(cu.imv); cTestMv[iMVPIdx] += cBaseMvd[iMVPIdx]; cTestMv[iMVPIdx] += amvpInfo.mvCand[iMVPIdx]; @@ -2706,7 +2692,7 @@ void InterSearch::xPatternSearchIntRefine(PredictionUnit& pu, TZSearchStruct& c { Mv cTempMV = cTestMv[iMVPIdx]; { - clipMv(cTempMV, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cu->cs->pcv); + clipMv(cTempMV, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); } m_cDistParam.cur.buf = cStruct.piRefY + cStruct.iRefStride * (cTempMV.ver >> MV_FRACTIONAL_BITS_INTERNAL) + (cTempMV.hor >> MV_FRACTIONAL_BITS_INTERNAL); uiDist = uiSATD = (Distortion) (m_cDistParam.distFunc( m_cDistParam ) * fWeight); @@ -2718,10 +2704,10 @@ void InterSearch::xPatternSearchIntRefine(PredictionUnit& pu, TZSearchStruct& c int iMvBits = m_auiMVPIdxCost[iMVPIdx][AMVP_MAX_NUM_CANDS]; Mv pred = amvpInfo.mvCand[iMVPIdx]; - pred.changeTransPrecInternal2Amvr(pu.cu->imv); + pred.changeTransPrecInternal2Amvr(cu.imv); m_pcRdCost->setPredictor( pred ); Mv mv = cTestMv[iMVPIdx]; - mv.changeTransPrecInternal2Amvr(pu.cu->imv); + mv.changeTransPrecInternal2Amvr(cu.imv); iMvBits += m_pcRdCost->getBitsOfVectorWithPredictor( mv.hor, mv.ver, 0 ); uiDist += m_pcRdCost->getCost(iMvBits); @@ -2758,7 +2744,7 @@ void InterSearch::xPatternSearchIntRefine(PredictionUnit& pu, TZSearchStruct& c } void InterSearch::xPatternSearchFracDIF( - const PredictionUnit& pu, + const CodingUnit& cu, RefPicList refPicList, int iRefIdx, TZSearchStruct& cStruct, @@ -2785,7 +2771,7 @@ void InterSearch::xPatternSearchFracDIF( Mv baseRefMv(0, 0); Distortion uiDistBest = MAX_DISTORTION; int patternId = 41; - ruiCost = xPatternRefinement( cStruct.pcPatternKey, baseRefMv, 2, rcMvHalf, ( !pu.cs->slice->disableSATDForRd ), uiDistBest, patternId, &cPatternRoi, cStruct.useAltHpelIf ); + ruiCost = xPatternRefinement( cStruct.pcPatternKey, baseRefMv, 2, rcMvHalf, ( !cu.cs->slice->disableSATDForRd ), uiDistBest, patternId, &cPatternRoi, cStruct.useAltHpelIf ); patternId -= ( m_pcEncCfg->m_fastSubPel ? 41 : 0 ); @@ -2800,43 +2786,43 @@ void InterSearch::xPatternSearchFracDIF( rcMvQter = rcMvInt; rcMvQter <<= 1; // for mv-cost rcMvQter += rcMvHalf; rcMvQter <<= 1; - ruiCost = xPatternRefinement( cStruct.pcPatternKey, baseRefMv, 1, rcMvQter, ( !pu.cs->slice->disableSATDForRd ), uiDistBest, patternId, &cPatternRoi, cStruct.useAltHpelIf ); + ruiCost = xPatternRefinement( cStruct.pcPatternKey, baseRefMv, 1, rcMvQter, ( !cu.cs->slice->disableSATDForRd ), uiDistBest, patternId, &cPatternRoi, cStruct.useAltHpelIf ); } } -Distortion InterSearch::xGetSymCost( const PredictionUnit& pu, CPelUnitBuf& origBuf, RefPicList eCurRefPicList, const MvField& cCurMvField, MvField& cTarMvField, int BcwIdx ) +Distortion InterSearch::xGetSymCost( const CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList eCurRefPicList, const MvField& cCurMvField, MvField& cTarMvField, int BcwIdx ) { Distortion cost = MAX_DISTORTION; RefPicList eTarRefPicList = (RefPicList)(1 - (int)eCurRefPicList); // get prediction of eCurRefPicList - PelUnitBuf predBufA = m_tmpPredStorage[eCurRefPicList].getCompactBuf( pu ); - const Picture* picRefA = pu.cu->slice->getRefPic( eCurRefPicList, cCurMvField.refIdx ); + PelUnitBuf predBufA = m_tmpPredStorage[eCurRefPicList].getCompactBuf( cu ); + const Picture* picRefA = cu.slice->getRefPic( eCurRefPicList, cCurMvField.refIdx ); Mv mvA = cCurMvField.mv; - clipMv( mvA, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cu->cs->pcv ); - xPredInterBlk( COMP_Y, pu, picRefA, mvA, predBufA, false, pu.cu->slice->clpRngs[ COMP_Y ], false, false ); + clipMv( mvA, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); + xPredInterBlk( COMP_Y, cu, picRefA, mvA, predBufA, false, cu.slice->clpRngs[ COMP_Y ], false, false ); // get prediction of eTarRefPicList - PelUnitBuf predBufB = m_tmpPredStorage[eTarRefPicList].getCompactBuf( pu ); - const Picture* picRefB = pu.cu->slice->getRefPic( eTarRefPicList, cTarMvField.refIdx ); + PelUnitBuf predBufB = m_tmpPredStorage[eTarRefPicList].getCompactBuf( cu ); + const Picture* picRefB = cu.slice->getRefPic( eTarRefPicList, cTarMvField.refIdx ); Mv mvB = cTarMvField.mv; - clipMv( mvB, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cu->cs->pcv ); - xPredInterBlk( COMP_Y, pu, picRefB, mvB, predBufB, false, pu.cu->slice->clpRngs[ COMP_Y ], false, false ); + clipMv( mvB, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); + xPredInterBlk( COMP_Y, cu, picRefB, mvB, predBufB, false, cu.slice->clpRngs[ COMP_Y ], false, false ); - PelUnitBuf bufTmp = m_tmpStorageLCU.getCompactBuf( UnitAreaRelative( *pu.cu, pu ) ); + PelUnitBuf bufTmp = m_tmpStorageLCU.getCompactBuf( UnitAreaRelative( cu, cu ) ); bufTmp.copyFrom( origBuf ); - bufTmp.removeHighFreq( predBufA, m_pcEncCfg->m_bClipForBiPredMeEnabled, pu.cu->slice->clpRngs/*, getBcwWeight( pu.cu->BcwIdx, eTarRefPicList )*/ ); - double fWeight = xGetMEDistortionWeight( pu.cu->BcwIdx, eTarRefPicList ); + bufTmp.removeHighFreq( predBufA, m_pcEncCfg->m_bClipForBiPredMeEnabled, cu.slice->clpRngs/*, getBcwWeight( cu.BcwIdx, eTarRefPicList )*/ ); + double fWeight = xGetMEDistortionWeight( cu.BcwIdx, eTarRefPicList ); // calc distortion - DFunc distFunc = ( !pu.cu->slice->disableSATDForRd ) ? DF_HAD : DF_SAD; - cost = ( Distortion ) floor( fWeight * ( double ) m_pcRdCost->getDistPart( bufTmp.Y(), predBufB.Y(), pu.cs->sps->bitDepths[ CH_L ], COMP_Y, distFunc ) ); + DFunc distFunc = ( !cu.slice->disableSATDForRd ) ? DF_HAD : DF_SAD; + cost = ( Distortion ) floor( fWeight * ( double ) m_pcRdCost->getDistPart( bufTmp.Y(), predBufB.Y(), cu.cs->sps->bitDepths[ CH_L ], COMP_Y, distFunc ) ); return(cost); } -Distortion InterSearch::xSymRefineMvSearch( PredictionUnit &pu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, +Distortion InterSearch::xSymRefineMvSearch( CodingUnit& cu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion uiMinCost, int SearchPattern, int nSearchStepShift, uint32_t uiMaxSearchRounds, int BcwIdx ) { const Mv mvSearchOffsetCross[4] = { Mv( 0 , 1 ) , Mv( 1 , 0 ) , Mv( 0 , -1 ) , Mv( -1 , 0 ) }; @@ -2915,18 +2901,18 @@ Distortion InterSearch::xSymRefineMvSearch( PredictionUnit &pu, CPelUnitBuf& ori // get MVD cost Mv pred = rcMvCurPred; - pred.changeTransPrecInternal2Amvr(pu.cu->imv); + pred.changeTransPrecInternal2Amvr(cu.imv); m_pcRdCost->setPredictor( pred ); m_pcRdCost->setCostScale( 0 ); Mv mv = mvCand.mv; - mv.changeTransPrecInternal2Amvr(pu.cu->imv); + mv.changeTransPrecInternal2Amvr(cu.imv); uint32_t uiMvBits = m_pcRdCost->getBitsOfVectorWithPredictor( mv.hor, mv.ver, 0 ); Distortion uiCost = m_pcRdCost->getCost( uiMvBits ); // get MVD pair and set target MV mvPair.refIdx = rTarMvField.refIdx; mvPair.mv.set( rcMvTarPred.hor - (mvCand.mv.hor - rcMvCurPred.hor), rcMvTarPred.ver - (mvCand.mv.ver - rcMvCurPred.ver) ); - uiCost += xGetSymCost( pu, origBuf, refPicList, mvCand, mvPair, BcwIdx ); + uiCost += xGetSymCost( cu, origBuf, refPicList, mvCand, mvPair, BcwIdx ); if ( uiCost < uiMinCost ) { uiMinCost = uiCost; @@ -2958,20 +2944,20 @@ Distortion InterSearch::xSymRefineMvSearch( PredictionUnit &pu, CPelUnitBuf& ori } -void InterSearch::xSymMotionEstimation( PredictionUnit& pu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion& ruiCost, int BcwIdx ) +void InterSearch::xSymMotionEstimation( CodingUnit& cu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion& ruiCost, int BcwIdx ) { // Refine Search int nSearchStepShift = MV_FRACTIONAL_BITS_DIFF; int nDiamondRound = 8; int nCrossRound = 1; - nSearchStepShift += pu.cu->imv == IMV_HPEL ? 1 : (pu.cu->imv << 1); - nDiamondRound >>= pu.cu->imv; + nSearchStepShift += cu.imv == IMV_HPEL ? 1 : (cu.imv << 1); + nDiamondRound >>= cu.imv; - ruiCost = xSymRefineMvSearch( pu, origBuf, rcMvCurPred, rcMvTarPred, refPicList, rCurMvField, rTarMvField, ruiCost, 2, nSearchStepShift, nDiamondRound, BcwIdx ); + ruiCost = xSymRefineMvSearch( cu, origBuf, rcMvCurPred, rcMvTarPred, refPicList, rCurMvField, rTarMvField, ruiCost, 2, nSearchStepShift, nDiamondRound, BcwIdx ); if( m_pcEncCfg->m_SMVD < 3 ) { - ruiCost = xSymRefineMvSearch( pu, origBuf, rcMvCurPred, rcMvTarPred, refPicList, rCurMvField, rTarMvField, ruiCost, 0, nSearchStepShift, nCrossRound, BcwIdx ); + ruiCost = xSymRefineMvSearch( cu, origBuf, rcMvCurPred, rcMvTarPred, refPicList, rCurMvField, rTarMvField, ruiCost, 0, nSearchStepShift, nCrossRound, BcwIdx ); } } @@ -3268,7 +3254,7 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti CHECK(CU::isIntra(cu), "Inter search provided with intra CU"); if( cu.chromaFormat != CHROMA_400 - && (!cu.isSepTree() || isChroma(partitioner.chType)) + && (!CU::isSepTree(cu) || isChroma(partitioner.chType)) ) { { @@ -3663,124 +3649,198 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par continue; } - const bool isFirstMode = true; - - // copy the original residual into the residual buffer - csFull->getResiBuf(compArea).copyFrom(orgResiBuf.get(compID)); - - - m_CABACEstimator->getCtx() = ctxStart; - m_CABACEstimator->resetBits(); - - const QpParam cQP(tu, compID); // note: uses tu.transformSkip[compID] - m_pcTrQuant->selectLambda(compID); - - const Slice& slice = *tu.cu->slice; - if (slice.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && isChroma(compID) && slice.picHeader->lmcsChromaResidualScale ) + bool tsAllowed = TU::isTSAllowed(tu, compID) && (isLuma(compID) || (isChroma(compID) && m_pcEncCfg->m_useChromaTS)); + if (isChroma(compID) && tsAllowed && (tu.mtsIdx[COMP_Y] != MTS_SKIP)) { - double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.chromaAdj); - m_pcTrQuant->scaleLambda( 1.0/(cRescale*cRescale) ); + tsAllowed = false; } + tsAllowed &= cs.picture->useSC; + uint8_t nNumTransformCands = 1 + (tsAllowed ? 1 : 0); // DCT + TS = 2 tests + std::vector trModes; - if ( sps.jointCbCr && isChroma( compID ) && ( tu.cu->cs->slice->sliceQp > 18 ) ) + if (nNumTransformCands > 1) { - m_pcTrQuant->scaleLambda( 1.05 ); + trModes.push_back(TrMode(0, true)); //DCT2 + //for a SBT-no-residual TU, the RDO process should be called once, in order to get the RD cost + if ( !tu.noResidual ) + { + trModes.push_back(TrMode(1, true)); + } + else + { + nNumTransformCands--; + } } - TCoeff currAbsSum = 0; - uint64_t currCompFracBits = 0; - Distortion currCompDist = 0; - double currCompCost = 0; - uint64_t nonCoeffFracBits = 0; - Distortion nonCoeffDist = 0; - double nonCoeffCost = 0; - - if (slice.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && isChroma(compID) && slice.picHeader->lmcsChromaResidualScale && tu.blocks[compID].width*tu.blocks[compID].height > 4 ) + bool isLast = true; + for (int transformMode = 0; transformMode < nNumTransformCands; transformMode++) { - PelBuf resiBuf = csFull->getResiBuf(compArea); - resiBuf.scaleSignal(tu.chromaAdj, 1, slice.clpRngs[compID]); - } + const bool isFirstMode = transformMode == 0; - m_pcTrQuant->transformNxN( tu, compID, cQP, currAbsSum, m_CABACEstimator->getCtx() ); + // copy the original residual into the residual buffer + csFull->getResiBuf(compArea).copyFrom(orgResiBuf.get(compID)); - const CPelBuf zeroBuf(m_pTempPel, compArea); - const CPelBuf& orgResi = orgResiBuf.get(compID); - nonCoeffDist = m_pcRdCost->getDistPart( zeroBuf, orgResi, channelBitDepth, compID, DF_SSE ); // initialized with zero residual distortion + m_CABACEstimator->getCtx() = ctxStart; + m_CABACEstimator->resetBits(); - if( !tu.noResidual ) - { - const bool prevCbf = ( compID == COMP_Cr ? tu.cbf[COMP_Cb] : false ); - m_CABACEstimator->cbf_comp( *tu.cu, false, compArea, currDepth, prevCbf ); - } + if (bestTU.mtsIdx[compID] == MTS_SKIP && m_pcEncCfg->m_TS) + { + continue; + } + tu.mtsIdx[compID] = transformMode ? trModes[transformMode].first : 0; - nonCoeffFracBits = m_CABACEstimator->getEstFracBits(); - nonCoeffCost = m_pcRdCost->calcRdCost(nonCoeffFracBits, nonCoeffDist, !m_pcEncCfg->m_lumaLevelToDeltaQPEnabled); + const QpParam cQP(tu, compID); // note: uses tu.transformSkip[compID] + m_pcTrQuant->selectLambda(compID); - if ((puiZeroDist != NULL) && isFirstMode) - { - *puiZeroDist += nonCoeffDist; // initialized with zero residual distortion - } + const Slice& slice = *tu.cu->slice; + if (slice.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && isChroma(compID) && slice.picHeader->lmcsChromaResidualScale ) + { + double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.chromaAdj); + m_pcTrQuant->scaleLambda( 1.0/(cRescale*cRescale) ); + } - if (currAbsSum > 0) //if non-zero coefficients are present, a residual needs to be derived for further prediction - { - m_CABACEstimator->getCtx() = ctxStart; - m_CABACEstimator->resetBits(); + if ( sps.jointCbCr && isChroma( compID ) && ( tu.cu->cs->slice->sliceQp > 18 ) ) + { + m_pcTrQuant->scaleLambda( 1.05 ); + } + TCoeff currAbsSum = 0; + uint64_t currCompFracBits = 0; + Distortion currCompDist = 0; + double currCompCost = 0; + uint64_t nonCoeffFracBits = 0; + Distortion nonCoeffDist = 0; + double nonCoeffCost = 0; - const bool prevCbf = ( compID == COMP_Cr ? tu.cbf[COMP_Cb] : false ); - m_CABACEstimator->cbf_comp( *tu.cu, true, compArea, currDepth, prevCbf ); - if( compID == COMP_Cr ) + if (slice.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && isChroma(compID) && slice.picHeader->lmcsChromaResidualScale && tu.blocks[compID].width*tu.blocks[compID].height > 4 ) + { + PelBuf resiBuf = csFull->getResiBuf(compArea); + resiBuf.scaleSignal(tu.chromaAdj, 1, slice.clpRngs[compID]); + } + + if (nNumTransformCands > 1) + { + if (transformMode == 0) + { + m_pcTrQuant->checktransformsNxN(tu, &trModes, 2, compID); + tu.mtsIdx[compID] = trModes[0].first; + if (!trModes[transformMode + 1].second) + { + nNumTransformCands = 1; + } + } + m_pcTrQuant->transformNxN(tu, compID, cQP, currAbsSum, m_CABACEstimator->getCtx(), true); + } + else { - const int cbfMask = ( tu.cbf[COMP_Cb] ? 2 : 0 ) + 1; - m_CABACEstimator->joint_cb_cr( tu, cbfMask ); + m_pcTrQuant->transformNxN(tu, compID, cQP, currAbsSum, m_CABACEstimator->getCtx()); } + if (isFirstMode || (currAbsSum == 0)) + { + const CPelBuf zeroBuf(m_pTempPel, compArea); + const CPelBuf& orgResi = orgResiBuf.get(compID); - m_CABACEstimator->residual_coding( tu, compID ); + nonCoeffDist = m_pcRdCost->getDistPart(zeroBuf, orgResi, channelBitDepth, compID, DF_SSE); // initialized with zero residual distortion - currCompFracBits = m_CABACEstimator->getEstFracBits(); + if (!tu.noResidual) + { + const bool prevCbf = (compID == COMP_Cr ? tu.cbf[COMP_Cb] : false); + m_CABACEstimator->cbf_comp(*tu.cu, false, compArea, currDepth, prevCbf); + } - PelBuf resiBuf = csFull->getResiBuf(compArea); - CPelBuf orgResi = orgResiBuf.get(compID); + nonCoeffFracBits = m_CABACEstimator->getEstFracBits(); + nonCoeffCost = m_pcRdCost->calcRdCost(nonCoeffFracBits, nonCoeffDist, !m_pcEncCfg->m_lumaLevelToDeltaQPEnabled); + } - m_pcTrQuant->invTransformNxN(tu, compID, resiBuf, cQP); - if (slice.picHeader->lmcsEnabled && isChroma(compID) && slice.picHeader->lmcsChromaResidualScale && tu.blocks[compID].width*tu.blocks[compID].height > 4) + if ((puiZeroDist != NULL) && isFirstMode) { - resiBuf.scaleSignal(tu.chromaAdj, 0, slice.clpRngs[compID]); + *puiZeroDist += nonCoeffDist; // initialized with zero residual distortion } - currCompDist = m_pcRdCost->getDistPart(orgResi, resiBuf, channelBitDepth, compID, DF_SSE); - currCompCost = m_pcRdCost->calcRdCost(currCompFracBits, currCompDist, false); - } - else - { - currCompFracBits = nonCoeffFracBits; - currCompDist = nonCoeffDist; - currCompCost = nonCoeffCost; + if (currAbsSum > 0) //if non-zero coefficients are present, a residual needs to be derived for further prediction + { + if (isFirstMode) + { + m_CABACEstimator->getCtx() = ctxStart; + m_CABACEstimator->resetBits(); + } - tu.cbf[compID] = 0; - } + const bool prevCbf = ( compID == COMP_Cr ? tu.cbf[COMP_Cb] : false ); + m_CABACEstimator->cbf_comp( *tu.cu, true, compArea, currDepth, prevCbf ); + if( compID == COMP_Cr ) + { + const int cbfMask = ( tu.cbf[COMP_Cb] ? 2 : 0 ) + 1; + m_CABACEstimator->joint_cb_cr( tu, cbfMask ); + } + CUCtx cuCtx; + cuCtx.isDQPCoded = true; + cuCtx.isChromaQpAdjCoded = true; + m_CABACEstimator->residual_coding(tu, compID, &cuCtx); + m_CABACEstimator->mts_idx(cu, &cuCtx); - // evaluate - if( ( currCompCost < minCost[compID] ) ) - { - // copy component - if (isFirstMode && ((nonCoeffCost < currCompCost) || (currAbsSum == 0))) // check for forced null - { - tu.getCoeffs( compID ).fill( 0 ); - csFull->getResiBuf( compArea ).fill( 0 ); - tu.cbf[compID] = 0; + currCompFracBits = m_CABACEstimator->getEstFracBits(); - currAbsSum = 0; + PelBuf resiBuf = csFull->getResiBuf(compArea); + CPelBuf orgResi = orgResiBuf.get(compID); + + m_pcTrQuant->invTransformNxN(tu, compID, resiBuf, cQP); + if (slice.picHeader->lmcsEnabled && isChroma(compID) && slice.picHeader->lmcsChromaResidualScale && tu.blocks[compID].width*tu.blocks[compID].height > 4) + { + resiBuf.scaleSignal(tu.chromaAdj, 0, slice.clpRngs[compID]); + } + + currCompDist = m_pcRdCost->getDistPart(orgResi, resiBuf, channelBitDepth, compID, DF_SSE); + currCompCost = m_pcRdCost->calcRdCost(currCompFracBits, currCompDist, false); + } + else if (transformMode > 0) + { + currCompCost = MAX_DOUBLE; + } + else + { currCompFracBits = nonCoeffFracBits; currCompDist = nonCoeffDist; currCompCost = nonCoeffCost; + + tu.cbf[compID] = 0; } - uiSingleDistComp[compID] = currCompDist; - minCost[compID] = currCompCost; + // evaluate + if ((currCompCost < minCost[compID]) || (transformMode == 1 && currCompCost == minCost[compID])) + { + // copy component + if (isFirstMode && ((nonCoeffCost < currCompCost) || (currAbsSum == 0))) // check for forced null + { + tu.getCoeffs( compID ).fill( 0 ); + csFull->getResiBuf( compArea ).fill( 0 ); + tu.cbf[compID] = 0; + + currAbsSum = 0; + currCompFracBits = nonCoeffFracBits; + currCompDist = nonCoeffDist; + currCompCost = nonCoeffCost; + } + + uiSingleDistComp[compID] = currCompDist; + minCost[compID] = currCompCost; + if (transformMode != (nNumTransformCands - 1)) + { + bestTU.copyComponentFrom(tu, compID); + saveCS.getResiBuf(compArea).copyFrom(csFull->getResiBuf(compArea)); + } + else + { + isLast = false; + } + } + if( tu.noResidual ) + { + CHECK( currCompFracBits > 0 || currAbsSum, "currCompFracBits > 0 when tu noResidual" ); + } } - if( tu.noResidual ) + if (isLast) { - CHECK( currCompFracBits > 0 || currAbsSum, "currCompFracBits > 0 when tu noResidual" ); + tu.copyComponentFrom(bestTU, compID); + csFull->getResiBuf(compArea).copyFrom(saveCS.getResiBuf(compArea)); } } // component loop @@ -3796,6 +3856,13 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par double minCostCbCr = minCost[COMP_Cb] + minCost[COMP_Cr]; bool isLastBest = false; + bool checkDCTOnly = m_pcEncCfg->m_useChromaTS && ((TU::getCbf(tu, COMP_Cb) && tu.mtsIdx[COMP_Cb] == MTS_DCT2_DCT2 && !TU::getCbf(tu, COMP_Cr)) || + (TU::getCbf(tu, COMP_Cr) && tu.mtsIdx[COMP_Cr] == MTS_DCT2_DCT2 && !TU::getCbf(tu, COMP_Cb)) || + (TU::getCbf(tu, COMP_Cb) && tu.mtsIdx[COMP_Cb] == MTS_DCT2_DCT2 && TU::getCbf(tu, COMP_Cr) && tu.mtsIdx[COMP_Cr] == MTS_DCT2_DCT2)); + bool checkTSOnly = m_pcEncCfg->m_useChromaTS && ((TU::getCbf(tu, COMP_Cb) && tu.mtsIdx[COMP_Cb] == MTS_SKIP && !TU::getCbf(tu, COMP_Cr)) || + (TU::getCbf(tu, COMP_Cr) && tu.mtsIdx[COMP_Cr] == MTS_SKIP && !TU::getCbf(tu, COMP_Cb)) || + (TU::getCbf(tu, COMP_Cb) && tu.mtsIdx[COMP_Cb] == MTS_SKIP && TU::getCbf(tu, COMP_Cr) && tu.mtsIdx[COMP_Cr] == MTS_SKIP)); + CompStorage orgResiCb[4], orgResiCr[4]; // 0:std, 1-3:jointCbCr std::vector jointCbfMasksToTest; if ( checkJointCbCr ) @@ -3820,110 +3887,161 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par for (int cbfMask: jointCbfMasksToTest) { - TCoeff currAbsSum = 0; - uint64_t currCompFracBits = 0; - Distortion currCompDistCb = 0; - Distortion currCompDistCr = 0; - double currCompCost = 0; - - tu.jointCbCr = (uint8_t) cbfMask; - - const QpParam cQP(tu, COMP_Cb); // note: uses tu.transformSkip[compID] - m_pcTrQuant->selectLambda(COMP_Cb); + ComponentID codeCompId = (cbfMask >> 1 ? COMP_Cb : COMP_Cr); + ComponentID otherCompId = (codeCompId == COMP_Cr ? COMP_Cb : COMP_Cr); - // Lambda is loosened for the joint mode with respect to single modes as the same residual is used for both chroma blocks - const int absIct = abs( TU::getICTMode(tu) ); - const double lfact = ( absIct == 1 || absIct == 3 ? 0.8 : 0.5 ); - m_pcTrQuant->scaleLambda( lfact ); - if ( checkJointCbCr && (tu.cu->cs->slice->sliceQp > 18)) + bool tsAllowed = TU::isTSAllowed(tu, codeCompId) && (m_pcEncCfg->m_useChromaTS); + if (tsAllowed && (tu.mtsIdx[COMP_Y] != MTS_SKIP)) { - m_pcTrQuant->scaleLambda( 1.05 ); + tsAllowed = false; } - - m_CABACEstimator->getCtx() = ctxStart; - m_CABACEstimator->resetBits(); - - PelBuf cbResi = csFull->getResiBuf(cbArea); - PelBuf crResi = csFull->getResiBuf(crArea); - cbResi.copyFrom(orgResiCb[cbfMask]); - crResi.copyFrom(orgResiCr[cbfMask]); - - if ( reshape ) + tsAllowed &= cs.picture->useSC; + if (!tsAllowed) { - double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.chromaAdj); - m_pcTrQuant->scaleLambda( 1.0/(cRescale*cRescale) ); + checkTSOnly = false; } - - int codedCbfMask = 0; - ComponentID codeCompId = (tu.jointCbCr >> 1 ? COMP_Cb : COMP_Cr); - ComponentID otherCompId = (codeCompId == COMP_Cr ? COMP_Cb : COMP_Cr); - const QpParam qpCbCr(tu, codeCompId); - - tu.getCoeffs(otherCompId).fill(0); // do we need that? - TU::setCbfAtDepth(tu, otherCompId, tu.depth, false); - - PelBuf& codeResi = (codeCompId == COMP_Cr ? crResi : cbResi); - TCoeff compAbsSum = 0; - m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, compAbsSum, m_CABACEstimator->getCtx()); - if (compAbsSum > 0) + uint8_t numTransformCands = 1 + (tsAllowed && (!(checkDCTOnly || checkTSOnly)) ? 1 : 0); // DCT + TS = 2 tests + std::vector trModes; + if (numTransformCands > 1) { - m_pcTrQuant->invTransformNxN(tu, codeCompId, codeResi, qpCbCr); - codedCbfMask += (codeCompId == COMP_Cb ? 2 : 1); + trModes.push_back(TrMode(0, true)); // DCT2 + trModes.push_back(TrMode(1, true));//TS } else { - codeResi.fill(0); + tu.mtsIdx[codeCompId] = checkTSOnly ? 1 : 0; } - - if (tu.jointCbCr == 3 && codedCbfMask == 2) - { - codedCbfMask = 3; - TU::setCbfAtDepth(tu, COMP_Cr, tu.depth, true); - } - if (codedCbfMask && tu.jointCbCr != codedCbfMask) + for (int modeId = 0; modeId < numTransformCands; modeId++) { - codedCbfMask = 0; - } - currAbsSum = codedCbfMask; + TCoeff currAbsSum = 0; + uint64_t currCompFracBits = 0; + Distortion currCompDistCb = 0; + Distortion currCompDistCr = 0; + double currCompCost = 0; + + tu.jointCbCr = (uint8_t)cbfMask; + if (numTransformCands > 1) + { + tu.mtsIdx[codeCompId] = trModes[modeId].first; + } + tu.mtsIdx[otherCompId] = MTS_DCT2_DCT2; + const QpParam cQP(tu, COMP_Cb); // note: uses tu.transformSkip[compID] + m_pcTrQuant->selectLambda(COMP_Cb); + + // Lambda is loosened for the joint mode with respect to single modes as the same residual is used for both chroma blocks + const int absIct = abs(TU::getICTMode(tu)); + const double lfact = (absIct == 1 || absIct == 3 ? 0.8 : 0.5); + m_pcTrQuant->scaleLambda(lfact); + if (checkJointCbCr && (tu.cu->cs->slice->sliceQp > 18)) + { + m_pcTrQuant->scaleLambda(1.05); + } - if (currAbsSum > 0) - { - m_CABACEstimator->cbf_comp(*tu.cu, codedCbfMask >> 1, cbArea, currDepth, false); - m_CABACEstimator->cbf_comp(*tu.cu, codedCbfMask & 1, crArea, currDepth, codedCbfMask >> 1); - m_CABACEstimator->joint_cb_cr(tu, codedCbfMask); - if (codedCbfMask >> 1) - m_CABACEstimator->residual_coding(tu, COMP_Cb); - if (codedCbfMask & 1) - m_CABACEstimator->residual_coding(tu, COMP_Cr); - currCompFracBits = m_CABACEstimator->getEstFracBits(); + m_CABACEstimator->getCtx() = ctxStart; + m_CABACEstimator->resetBits(); + + PelBuf cbResi = csFull->getResiBuf(cbArea); + PelBuf crResi = csFull->getResiBuf(crArea); + cbResi.copyFrom(orgResiCb[cbfMask]); + crResi.copyFrom(orgResiCr[cbfMask]); - m_pcTrQuant->invTransformICT(tu, cbResi, crResi); if (reshape) { - cbResi.scaleSignal(tu.chromaAdj, 0, slice.clpRngs[COMP_Cb]); - crResi.scaleSignal(tu.chromaAdj, 0, slice.clpRngs[COMP_Cr]); + double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.chromaAdj); + m_pcTrQuant->scaleLambda(1.0 / (cRescale * cRescale)); } - currCompDistCb = m_pcRdCost->getDistPart(orgResiBuf.Cb(), cbResi, channelBitDepth, COMP_Cb, DF_SSE); - currCompDistCr = m_pcRdCost->getDistPart(orgResiBuf.Cr(), crResi, channelBitDepth, COMP_Cr, DF_SSE); - currCompCost = m_pcRdCost->calcRdCost(currCompFracBits, currCompDistCr + currCompDistCb, false); - } - else - currCompCost = MAX_DOUBLE; + int codedCbfMask = 0; + ComponentID codeCompId = (tu.jointCbCr >> 1 ? COMP_Cb : COMP_Cr); + ComponentID otherCompId = (codeCompId == COMP_Cr ? COMP_Cb : COMP_Cr); + const QpParam qpCbCr(tu, codeCompId); - // evaluate - if( currCompCost < minCostCbCr ) - { - uiSingleDistComp[COMP_Cb] = currCompDistCb; - uiSingleDistComp[COMP_Cr] = currCompDistCr; - minCostCbCr = currCompCost; - isLastBest = (cbfMask == jointCbfMasksToTest.back()); - if (!isLastBest) + tu.getCoeffs(otherCompId).fill(0); // do we need that? + TU::setCbfAtDepth(tu, otherCompId, tu.depth, false); + + PelBuf& codeResi = (codeCompId == COMP_Cr ? crResi : cbResi); + TCoeff compAbsSum = 0; + if (numTransformCands > 1) + { + if (modeId == 0) + { + m_pcTrQuant->checktransformsNxN(tu, &trModes, 2, codeCompId); + tu.mtsIdx[codeCompId] = trModes[modeId].first; + tu.mtsIdx[otherCompId] = MTS_DCT2_DCT2; + if (!trModes[modeId + 1].second) + { + numTransformCands = 1; + } + } + m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, compAbsSum, m_CABACEstimator->getCtx(), true); + } + else + { + m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, compAbsSum, m_CABACEstimator->getCtx()); + } + if (compAbsSum > 0) + { + m_pcTrQuant->invTransformNxN(tu, codeCompId, codeResi, qpCbCr); + codedCbfMask += (codeCompId == COMP_Cb ? 2 : 1); + } + else + { + codeResi.fill(0); + } + + if (tu.jointCbCr == 3 && codedCbfMask == 2) + { + codedCbfMask = 3; + TU::setCbfAtDepth(tu, COMP_Cr, tu.depth, true); + } + if (codedCbfMask && tu.jointCbCr != codedCbfMask) + { + codedCbfMask = 0; + } + currAbsSum = codedCbfMask; + if (!tu.mtsIdx[codeCompId]) + { + numTransformCands = (currAbsSum <= 0) ? 1 : numTransformCands; + } + if (currAbsSum > 0) { - bestTU.copyComponentFrom(tu, COMP_Cb); - bestTU.copyComponentFrom(tu, COMP_Cr); - saveCS.getResiBuf(cbArea).copyFrom(csFull->getResiBuf(cbArea)); - saveCS.getResiBuf(crArea).copyFrom(csFull->getResiBuf(crArea)); + m_CABACEstimator->cbf_comp(*tu.cu, codedCbfMask >> 1, cbArea, currDepth, false); + m_CABACEstimator->cbf_comp(*tu.cu, codedCbfMask & 1, crArea, currDepth, codedCbfMask >> 1); + m_CABACEstimator->joint_cb_cr(tu, codedCbfMask); + if (codedCbfMask >> 1) + m_CABACEstimator->residual_coding(tu, COMP_Cb); + if (codedCbfMask & 1) + m_CABACEstimator->residual_coding(tu, COMP_Cr); + currCompFracBits = m_CABACEstimator->getEstFracBits(); + + m_pcTrQuant->invTransformICT(tu, cbResi, crResi); + if (reshape) + { + cbResi.scaleSignal(tu.chromaAdj, 0, slice.clpRngs[COMP_Cb]); + crResi.scaleSignal(tu.chromaAdj, 0, slice.clpRngs[COMP_Cr]); + } + + currCompDistCb = m_pcRdCost->getDistPart(orgResiBuf.Cb(), cbResi, channelBitDepth, COMP_Cb, DF_SSE); + currCompDistCr = m_pcRdCost->getDistPart(orgResiBuf.Cr(), crResi, channelBitDepth, COMP_Cr, DF_SSE); + currCompCost = m_pcRdCost->calcRdCost(currCompFracBits, currCompDistCr + currCompDistCb, false); + } + else + currCompCost = MAX_DOUBLE; + + // evaluate + if (currCompCost < minCostCbCr) + { + uiSingleDistComp[COMP_Cb] = currCompDistCb; + uiSingleDistComp[COMP_Cr] = currCompDistCr; + minCostCbCr = currCompCost; + isLastBest = (cbfMask == jointCbfMasksToTest.back()) && (modeId == (numTransformCands - 1)); + if (!isLastBest) + { + bestTU.copyComponentFrom(tu, COMP_Cb); + bestTU.copyComponentFrom(tu, COMP_Cr); + saveCS.getResiBuf(cbArea).copyFrom(csFull->getResiBuf(cbArea)); + saveCS.getResiBuf(crArea).copyFrom(csFull->getResiBuf(crArea)); + } } } @@ -4073,7 +4191,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa { CodingUnit &cu = *cs.getCU( partitioner.chType, partitioner.treeType ); if( cu.predMode == MODE_INTER ) - CHECK( cu.isSepTree(), "CU with Inter mode must be in single tree" ); + CHECK( CU::isSepTree(cu), "CU with Inter mode must be in single tree" ); const ChromaFormat format = cs.area.chromaFormat;; const int numValidComponents = getNumberValidComponents(format); @@ -4087,7 +4205,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa CHECK( cu.sbtInfo != 0, "sbtInfo shall be 0 if CU has no residual" ); cs.getResiBuf().fill(0); cs.getRecoBuf().copyFrom(cs.getPredBuf() ); - if( cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && !cu.pu->ciip && !CU::isIBC(cu)) + if( cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && !cu.ciip && !CU::isIBC(cu)) { cs.getRecoBuf().Y().rspSignal( reshapeData.getFwdLUT()); } @@ -4120,10 +4238,10 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa } } - PredictionUnit &pu = *cs.getPU(partitioner.chType); + CodingUnit& cu = *cs.getCU(partitioner.chType, TREE_D); m_CABACEstimator->resetBits(); m_CABACEstimator->cu_skip_flag ( cu ); - m_CABACEstimator->merge_data(pu); + m_CABACEstimator->merge_data(cu); cs.fracBits = m_CABACEstimator->getEstFracBits(); cs.dist = distortion; cs.cost = m_pcRdCost->calcRdCost(cs.fracBits, cs.dist); @@ -4134,7 +4252,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa // Residual coding. if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag()) { - if (!cu.pu->ciip && !CU::isIBC(cu)) + if (!cu.ciip && !CU::isIBC(cu)) { const CompArea& areaY = cu.Y(); PelBuf tmpPred = m_tmpStorageLCU.getCompactBuf(areaY); @@ -4200,7 +4318,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa if (cu.rootCbf && cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag()) { - if (!cu.pu->ciip && !CU::isIBC(cu)) + if (!cu.ciip && !CU::isIBC(cu)) { PelBuf tmpPred = m_tmpStorageLCU.getCompactBuf(cu.Y()); tmpPred.rspSignal(cs.getPredBuf(COMP_Y), reshapeData.getFwdLUT()); @@ -4214,7 +4332,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa else { cs.getRecoBuf().bufs[0].reconstruct(cs.getPredBuf().bufs[0], cs.getResiBuf().bufs[0], cs.slice->clpRngs[COMP_Y]); - if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && !cu.pu->ciip && !CU::isIBC(cu)) + if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() && !cu.ciip && !CU::isIBC(cu)) { cs.getRecoBuf().bufs[0].rspSignal(reshapeData.getFwdLUT()); } @@ -4266,14 +4384,14 @@ uint64_t InterSearch::xGetSymbolFracBitsInter(CodingStructure &cs, Partitioner & m_CABACEstimator->resetBits(); - if( cu.pu->mergeFlag && !cu.rootCbf ) + if( cu.mergeFlag && !cu.rootCbf ) { cu.skip = true; m_CABACEstimator->cu_skip_flag ( cu ); - if (!cu.pu->ciip) + if (!cu.ciip) { - m_CABACEstimator->merge_data(*cu.pu); + m_CABACEstimator->merge_data(cu); } fracBits += m_CABACEstimator->getEstFracBits(); } @@ -4301,7 +4419,7 @@ double InterSearch::xGetMEDistortionWeight(uint8_t BcwIdx, RefPicList refPicList } void InterSearch::xSymMvdCheckBestMvp( - PredictionUnit& pu, + CodingUnit& cu, CPelUnitBuf& origBuf, Mv curMv, RefPicList curRefList, @@ -4314,8 +4432,8 @@ void InterSearch::xSymMvdCheckBestMvp( ) { RefPicList tarRefList = (RefPicList)(1 - curRefList); - int32_t refIdxCur = pu.cu->slice->symRefIdx[curRefList]; - int32_t refIdxTar = pu.cu->slice->symRefIdx[tarRefList]; + int32_t refIdxCur = cu.slice->symRefIdx[curRefList]; + int32_t refIdxTar = cu.slice->symRefIdx[tarRefList]; MvField cCurMvField, cTarMvField; cCurMvField.setMvField(curMv, refIdxCur); @@ -4327,16 +4445,16 @@ void InterSearch::xSymMvdCheckBestMvp( PelUnitBuf bufTmp; // get prediction of eCurRefPicList - PelUnitBuf predBufA = m_tmpPredStorage[curRefList].getCompactBuf( pu ); - const Picture* picRefA = pu.cu->slice->getRefPic(curRefList, cCurMvField.refIdx); + PelUnitBuf predBufA = m_tmpPredStorage[curRefList].getCompactBuf( cu ); + const Picture* picRefA = cu.slice->getRefPic(curRefList, cCurMvField.refIdx); Mv mvA = cCurMvField.mv; - clipMv( mvA, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv ); - xPredInterBlk( COMP_Y, pu, picRefA, mvA, predBufA, false, pu.cu->slice->clpRngs[ COMP_Y ], false, false ); + clipMv( mvA, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); + xPredInterBlk( COMP_Y, cu, picRefA, mvA, predBufA, false, cu.slice->clpRngs[ COMP_Y ], false, false ); - bufTmp = m_tmpStorageLCU.getBuf( UnitAreaRelative( *pu.cu, pu ) ); + bufTmp = m_tmpStorageLCU.getBuf( UnitAreaRelative( cu, cu ) ); bufTmp.copyFrom( origBuf ); - bufTmp.removeHighFreq( predBufA, m_pcEncCfg->m_bClipForBiPredMeEnabled, pu.cu->slice->clpRngs/*, getBcwWeight( pu.cu->BcwIdx, tarRefList )*/ ); - fWeight = xGetMEDistortionWeight( pu.cu->BcwIdx, tarRefList ); + bufTmp.removeHighFreq( predBufA, m_pcEncCfg->m_bClipForBiPredMeEnabled, cu.slice->clpRngs/*, getBcwWeight( cu.BcwIdx, tarRefList )*/ ); + fWeight = xGetMEDistortionWeight( cu.BcwIdx, tarRefList ); int32_t skipMvpIdx[2]; skipMvpIdx[0] = skip ? mvpIdxSym[0] : -1; @@ -4353,21 +4471,21 @@ void InterSearch::xSymMvdCheckBestMvp( cTarMvField.setMvField(curMv.getSymmvdMv(amvpCur.mvCand[i], amvpTar.mvCand[j]), refIdxTar); // get prediction of eTarRefPicList - PelUnitBuf predBufB = m_tmpPredStorage[tarRefList].getCompactBuf( pu ); - const Picture* picRefB = pu.cu->slice->getRefPic(tarRefList, cTarMvField.refIdx); + PelUnitBuf predBufB = m_tmpPredStorage[tarRefList].getCompactBuf( cu ); + const Picture* picRefB = cu.slice->getRefPic(tarRefList, cTarMvField.refIdx); Mv mvB = cTarMvField.mv; - clipMv( mvB, pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv ); - xPredInterBlk( COMP_Y, pu, picRefB, mvB, predBufB, false, pu.cu->slice->clpRngs[ COMP_Y ], false, false ); + clipMv( mvB, cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv ); + xPredInterBlk( COMP_Y, cu, picRefB, mvB, predBufB, false, cu.slice->clpRngs[ COMP_Y ], false, false ); // calc distortion - DFunc distFunc = ( !pu.cu->slice->disableSATDForRd ) ? DF_HAD : DF_SAD; - cost = ( Distortion ) floor( fWeight * ( double ) m_pcRdCost->getDistPart( bufTmp.Y(), predBufB.Y(), pu.cs->sps->bitDepths[ CH_L ], COMP_Y, distFunc ) ); + DFunc distFunc = ( !cu.slice->disableSATDForRd ) ? DF_HAD : DF_SAD; + cost = ( Distortion ) floor( fWeight * ( double ) m_pcRdCost->getDistPart( bufTmp.Y(), predBufB.Y(), cu.cs->sps->bitDepths[ CH_L ], COMP_Y, distFunc ) ); Mv pred = amvpCur.mvCand[i]; - pred.changeTransPrecInternal2Amvr(pu.cu->imv); + pred.changeTransPrecInternal2Amvr(cu.imv); m_pcRdCost->setPredictor(pred); Mv mv = curMv; - mv.changeTransPrecInternal2Amvr(pu.cu->imv); + mv.changeTransPrecInternal2Amvr(cu.imv); uint32_t bits = m_pcRdCost->getBitsOfVectorWithPredictor(mv.hor, mv.ver, 0); bits += m_auiMVPIdxCost[i][AMVP_MAX_NUM_CANDS]; bits += m_auiMVPIdxCost[j][AMVP_MAX_NUM_CANDS]; @@ -4398,10 +4516,6 @@ void InterSearch::resetSavedAffineMotion() m_affineMotion.affine4ParaRefIdx[i] = -1; m_affineMotion.affine6ParaRefIdx[i] = -1; } - for (int i = 0; i < 3; i++) - { - m_affineMotion.hevcCost[i] = MAX_DISTORTION; - } m_affineMotion.affine4ParaAvail = false; m_affineMotion.affine6ParaAvail = false; } @@ -4435,7 +4549,7 @@ void InterSearch::storeAffineMotion(Mv acAffineMv[2][3], int16_t affineRefIdx[2] } } -void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, +void InterSearch::xPredAffineInterSearch( CodingUnit& cu, CPelUnitBuf& origBuf, int puIdx, uint32_t& lastMode, @@ -4447,7 +4561,7 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, bool enforceBcwPred, uint32_t BcwIdxBits ) { - const Slice &slice = *pu.cu->slice; + const Slice &slice = *cu.slice; affineCost = MAX_DISTORTION; @@ -4459,7 +4573,7 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, int iNumPredDir = slice.isInterP() ? 1 : 2; int mvNum = 2; - mvNum = pu.cu->affineType ? 3 : 2; + mvNum = cu.affineType ? 3 : 2; // Mvp Mv cMvPred[2][MAX_REF_PICS][3]; @@ -4503,19 +4617,19 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, xGetBlkBits(slice.isInterP(), puIdx, lastMode, uiMbBits); - pu.cu->affine = true; - pu.mergeFlag = false; - pu.regularMergeFlag = false; + cu.affine = true; + cu.mergeFlag = false; + cu.regularMergeFlag = false; if (BcwIdx != BCW_DEFAULT) { - pu.cu->BcwIdx = BcwIdx; + cu.BcwIdx = BcwIdx; } // Uni-directional prediction for (int iRefList = 0; iRefList < iNumPredDir; iRefList++) { RefPicList refPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); - pu.interDir = (iRefList ? 2 : 1); + cu.interDir = (iRefList ? 2 : 1); for (int iRefIdxTemp = 0; iRefIdxTemp < slice.numRefIdx[refPicList]; iRefIdxTemp++) { // Get RefIdx bits @@ -4530,14 +4644,14 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, } // Do Affine AMVP - xEstimateAffineAMVP(pu, affiAMVPInfoTemp[refPicList], origBuf, refPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], biPDistTemp); + xEstimateAffineAMVP(cu, affiAMVPInfoTemp[refPicList], origBuf, refPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], biPDistTemp); if (affineAmvrEnabled) { - biPDistTemp += m_pcRdCost->getCost(xCalcAffineMVBits(pu, cMvPred[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp])); + biPDistTemp += m_pcRdCost->getCost(xCalcAffineMVBits(cu, cMvPred[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp])); } - aaiMvpIdx[iRefList][iRefIdxTemp] = pu.mvpIdx[refPicList]; - aaiMvpNum[iRefList][iRefIdxTemp] = pu.mvpNum[refPicList];; - if (pu.cu->affineType == AFFINEMODEL_6PARAM && refIdx4Para[iRefList] != iRefIdxTemp) + aaiMvpIdx[iRefList][iRefIdxTemp] = cu.mvpIdx[refPicList]; + aaiMvpNum[iRefList][iRefIdxTemp] = cu.mvpNum[refPicList];; + if (cu.affineType == AFFINEMODEL_6PARAM && refIdx4Para[iRefList] != iRefIdxTemp) { xCopyAffineAMVPInfo(affiAMVPInfoTemp[refPicList], aacAffineAMVPInfo[iRefList][iRefIdxTemp]); continue; @@ -4547,21 +4661,21 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, for (int i = 0; i<3; i++) { mvHevc[i] = hevcMv[iRefList][iRefIdxTemp]; - mvHevc[i].roundAffinePrecInternal2Amvr(pu.cu->imv); + mvHevc[i].roundAffinePrecInternal2Amvr(cu.imv); } - PelUnitBuf predBuf = m_tmpStorageLCU.getCompactBuf(pu); + PelUnitBuf predBuf = m_tmpStorageLCU.getCompactBuf(cu); - Distortion uiCandCost = xGetAffineTemplateCost(pu, origBuf, predBuf, mvHevc, aaiMvpIdx[iRefList][iRefIdxTemp], + Distortion uiCandCost = xGetAffineTemplateCost(cu, origBuf, predBuf, mvHevc, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); if (affineAmvrEnabled) { - uiCandCost += m_pcRdCost->getCost(xCalcAffineMVBits(pu, mvHevc, cMvPred[iRefList][iRefIdxTemp])); + uiCandCost += m_pcRdCost->getCost(xCalcAffineMVBits(cu, mvHevc, cMvPred[iRefList][iRefIdxTemp])); } //check stored affine motion - bool affine4Para = pu.cu->affineType == AFFINEMODEL_4PARAM; - bool savedParaAvail = pu.cu->imv && ((m_affineMotion.affine4ParaRefIdx[iRefList] == iRefIdxTemp && affine4Para && m_affineMotion.affine4ParaAvail) || + bool affine4Para = cu.affineType == AFFINEMODEL_4PARAM; + bool savedParaAvail = cu.imv && ((m_affineMotion.affine4ParaRefIdx[iRefList] == iRefIdxTemp && affine4Para && m_affineMotion.affine4ParaAvail) || (m_affineMotion.affine6ParaRefIdx[iRefList] == iRefIdxTemp && !affine4Para && m_affineMotion.affine6ParaAvail)); if (savedParaAvail) @@ -4570,11 +4684,11 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, for (int i = 0; i < mvNum; i++) { mvFour[i] = affine4Para ? m_affineMotion.acMvAffine4Para[iRefList][i] : m_affineMotion.acMvAffine6Para[iRefList][i]; - mvFour[i].roundAffinePrecInternal2Amvr(pu.cu->imv); + mvFour[i].roundAffinePrecInternal2Amvr(cu.imv); } - Distortion candCostInherit = xGetAffineTemplateCost(pu, origBuf, predBuf, mvFour, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); - candCostInherit += m_pcRdCost->getCost(xCalcAffineMVBits(pu, mvFour, cMvPred[iRefList][iRefIdxTemp])); + Distortion candCostInherit = xGetAffineTemplateCost(cu, origBuf, predBuf, mvFour, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); + candCostInherit += m_pcRdCost->getCost(xCalcAffineMVBits(cu, mvFour, cMvPred[iRefList][iRefIdxTemp])); if (candCostInherit < uiCandCost) { @@ -4583,7 +4697,7 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, } } - if (pu.cu->affineType == AFFINEMODEL_4PARAM && m_AffineProfList->m_affMVListSize) + if (cu.affineType == AFFINEMODEL_4PARAM && m_AffineProfList->m_affMVListSize) { int shift = MAX_CU_DEPTH; for (int i = 0; i < m_AffineProfList->m_affMVListSize; i++) @@ -4616,25 +4730,25 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, dMvHorY = dMv.ver << (shift - Log2(mvInfo->w)); dMvVerX = -dMvHorY; dMvVerY = dMvHorX; - vx = mvScaleHor + dMvHorX * (pu.Y().x - mvInfo->x) + dMvVerX * (pu.Y().y - mvInfo->y); - vy = mvScaleVer + dMvHorY * (pu.Y().x - mvInfo->x) + dMvVerY * (pu.Y().y - mvInfo->y); + vx = mvScaleHor + dMvHorX * (cu.Y().x - mvInfo->x) + dMvVerX * (cu.Y().y - mvInfo->y); + vy = mvScaleVer + dMvHorY * (cu.Y().x - mvInfo->x) + dMvVerY * (cu.Y().y - mvInfo->y); roundAffineMv(vx, vy, shift); mvTmp[0] = Mv(vx, vy); mvTmp[0].clipToStorageBitDepth(); - clipMv(mvTmp[0], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); - mvTmp[0].roundAffinePrecInternal2Amvr(pu.cu->imv); - vx = mvScaleHor + dMvHorX * (pu.Y().x + pu.Y().width - mvInfo->x) + dMvVerX * (pu.Y().y - mvInfo->y); - vy = mvScaleVer + dMvHorY * (pu.Y().x + pu.Y().width - mvInfo->x) + dMvVerY * (pu.Y().y - mvInfo->y); + clipMv(mvTmp[0], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + mvTmp[0].roundAffinePrecInternal2Amvr(cu.imv); + vx = mvScaleHor + dMvHorX * (cu.Y().x + cu.Y().width - mvInfo->x) + dMvVerX * (cu.Y().y - mvInfo->y); + vy = mvScaleVer + dMvHorY * (cu.Y().x + cu.Y().width - mvInfo->x) + dMvVerY * (cu.Y().y - mvInfo->y); roundAffineMv(vx, vy, shift); mvTmp[1] = Mv(vx, vy); mvTmp[1].clipToStorageBitDepth(); - clipMv(mvTmp[1], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); - mvTmp[0].roundAffinePrecInternal2Amvr(pu.cu->imv); - mvTmp[1].roundAffinePrecInternal2Amvr(pu.cu->imv); - Distortion tmpCost = xGetAffineTemplateCost(pu, origBuf, predBuf, mvTmp, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); + clipMv(mvTmp[1], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + mvTmp[0].roundAffinePrecInternal2Amvr(cu.imv); + mvTmp[1].roundAffinePrecInternal2Amvr(cu.imv); + Distortion tmpCost = xGetAffineTemplateCost(cu, origBuf, predBuf, mvTmp, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); if (affineAmvrEnabled) { - tmpCost += m_pcRdCost->getCost(xCalcAffineMVBits(pu, mvTmp, cMvPred[iRefList][iRefIdxTemp])); + tmpCost += m_pcRdCost->getCost(xCalcAffineMVBits(cu, mvTmp, cMvPred[iRefList][iRefIdxTemp])); } if (tmpCost < uiCandCost) { @@ -4643,30 +4757,30 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, } } } - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { Mv mvFour[3]; mvFour[0] = mvAffine4Para[iRefList][iRefIdxTemp][0]; mvFour[1] = mvAffine4Para[iRefList][iRefIdxTemp][1]; - mvAffine4Para[iRefList][iRefIdxTemp][0].roundAffinePrecInternal2Amvr(pu.cu->imv); - mvAffine4Para[iRefList][iRefIdxTemp][1].roundAffinePrecInternal2Amvr(pu.cu->imv); + mvAffine4Para[iRefList][iRefIdxTemp][0].roundAffinePrecInternal2Amvr(cu.imv); + mvAffine4Para[iRefList][iRefIdxTemp][1].roundAffinePrecInternal2Amvr(cu.imv); int shift = MAX_CU_DEPTH; - int vx2 = (mvFour[0].hor << shift) - ((mvFour[1].ver - mvFour[0].ver) << (shift + Log2(pu.lheight()) - Log2(pu.lwidth()))); - int vy2 = (mvFour[0].ver << shift) + ((mvFour[1].hor - mvFour[0].hor) << (shift + Log2(pu.lheight()) - Log2(pu.lwidth()))); + int vx2 = (mvFour[0].hor << shift) - ((mvFour[1].ver - mvFour[0].ver) << (shift + Log2(cu.lheight()) - Log2(cu.lwidth()))); + int vy2 = (mvFour[0].ver << shift) + ((mvFour[1].hor - mvFour[0].hor) << (shift + Log2(cu.lheight()) - Log2(cu.lwidth()))); int offset = (1 << (shift - 1)); vx2 = (vx2 + offset - (vx2 >= 0)) >> shift; vy2 = (vy2 + offset - (vy2 >= 0)) >> shift; mvFour[2].hor = vx2; mvFour[2].ver = vy2; mvFour[2].clipToStorageBitDepth(); - mvFour[0].roundAffinePrecInternal2Amvr(pu.cu->imv); - mvFour[1].roundAffinePrecInternal2Amvr(pu.cu->imv); - mvFour[2].roundAffinePrecInternal2Amvr(pu.cu->imv); - Distortion uiCandCostInherit = xGetAffineTemplateCost(pu, origBuf, predBuf, mvFour, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); + mvFour[0].roundAffinePrecInternal2Amvr(cu.imv); + mvFour[1].roundAffinePrecInternal2Amvr(cu.imv); + mvFour[2].roundAffinePrecInternal2Amvr(cu.imv); + Distortion uiCandCostInherit = xGetAffineTemplateCost(cu, origBuf, predBuf, mvFour, aaiMvpIdx[iRefList][iRefIdxTemp], AMVP_MAX_NUM_CANDS, refPicList, iRefIdxTemp); if (affineAmvrEnabled) { - uiCandCostInherit += m_pcRdCost->getCost(xCalcAffineMVBits(pu, mvFour, cMvPred[iRefList][iRefIdxTemp])); + uiCandCostInherit += m_pcRdCost->getCost(xCalcAffineMVBits(cu, mvFour, cMvPred[iRefList][iRefIdxTemp])); } if (uiCandCostInherit < uiCandCost) { @@ -4700,33 +4814,33 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, if (m_pcEncCfg->m_bFastMEForGenBLowDelayEnabled && iRefList == 1) // list 1 { - if (slice.list1IdxToList0Idx[iRefIdxTemp] >= 0 && (pu.cu->affineType != AFFINEMODEL_6PARAM || slice.list1IdxToList0Idx[iRefIdxTemp] == refIdx4Para[0])) + if (slice.list1IdxToList0Idx[iRefIdxTemp] >= 0 && (cu.affineType != AFFINEMODEL_6PARAM || slice.list1IdxToList0Idx[iRefIdxTemp] == refIdx4Para[0])) { int iList1ToList0Idx = slice.list1IdxToList0Idx[iRefIdxTemp]; ::memcpy(tmp.affMVs[1][iRefIdxTemp], tmp.affMVs[0][iList1ToList0Idx], sizeof(Mv) * 3); uiCostTemp = uiCostTempL0[iList1ToList0Idx]; uiCostTemp -= m_pcRdCost->getCost(uiBitsTempL0[iList1ToList0Idx]); - uiBitsTemp += xCalcAffineMVBits(pu, tmp.affMVs[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp]); + uiBitsTemp += xCalcAffineMVBits(cu, tmp.affMVs[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp]); /*calculate the correct cost*/ uiCostTemp += m_pcRdCost->getCost(uiBitsTemp); DTRACE(g_trace_ctx, D_COMMON, " (%d) uiCostTemp=%d\n", DTRACE_GET_COUNTER(g_trace_ctx, D_COMMON), uiCostTemp); } else { - xAffineMotionEstimation(pu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, tmp.affMVs[iRefList][iRefIdxTemp], + xAffineMotionEstimation(cu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, tmp.affMVs[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, aaiMvpIdx[iRefList][iRefIdxTemp], affiAMVPInfoTemp[refPicList]); } } else { - xAffineMotionEstimation(pu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, tmp.affMVs[iRefList][iRefIdxTemp], + xAffineMotionEstimation(cu, origBuf, refPicList, cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, tmp.affMVs[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, aaiMvpIdx[iRefList][iRefIdxTemp], affiAMVPInfoTemp[refPicList]); } // Set best AMVP Index xCopyAffineAMVPInfo(affiAMVPInfoTemp[refPicList], aacAffineAMVPInfo[iRefList][iRefIdxTemp]); - if (pu.cu->imv != 2)//|| !m_pcEncCfg->getUseAffineAmvrEncOpt()) - xCheckBestAffineMVP(pu, affiAMVPInfoTemp[refPicList], refPicList, tmp.affMVs[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); + if (cu.imv != 2)//|| !m_pcEncCfg->getUseAffineAmvrEncOpt()) + xCheckBestAffineMVP(cu, affiAMVPInfoTemp[refPicList], refPicList, tmp.affMVs[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); if (iRefList == 0) { @@ -4756,19 +4870,19 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, } // End refIdx loop } // end Uni-prediction - if (pu.cu->affineType == AFFINEMODEL_4PARAM) + if (cu.affineType == AFFINEMODEL_4PARAM) { ::memcpy(mvAffine4Para, tmp.affMVs, sizeof(tmp.affMVs)); - if (pu.cu->imv == 0) + if (cu.imv == 0) { - m_AffineProfList->insert( tmp, pu.Y()); + m_AffineProfList->insert( tmp, cu.Y()); } } // Bi-directional prediction - if (slice.isInterB() && !PU::isBipredRestriction(pu)) + if (slice.isInterB() && !CU::isBipredRestriction(cu)) { - pu.interDir = 3; + cu.interDir = 3; m_isBi = true; // Set as best list0 and list1 @@ -4785,7 +4899,7 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, if (slice.picHeader->mvdL1Zero) // GPB, list 1 only use Mvp { xCopyAffineAMVPInfo(aacAffineAMVPInfo[1][bestBiPRefIdxL1], affiAMVPInfoTemp[REF_PIC_LIST_1]); - pu.mvpIdx[REF_PIC_LIST_1] = bestBiPMvpL1; + cu.mvpIdx[REF_PIC_LIST_1] = bestBiPMvpL1; aaiMvpIdxBi[1][bestBiPRefIdxL1] = bestBiPMvpL1; // Set Mv for list1 @@ -4798,11 +4912,11 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, iRefIdxBi[1] = bestBiPRefIdxL1; // Get list1 prediction block - PU::setAllAffineMv(pu, cMvBi[1][0], cMvBi[1][1], cMvBi[1][2], REF_PIC_LIST_1); - pu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; + CU::setAllAffineMv(cu, cMvBi[1][0], cMvBi[1][1], cMvBi[1][2], REF_PIC_LIST_1); + cu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; - PelUnitBuf predBufTmp = m_tmpPredStorage[REF_PIC_LIST_1].getCompactBuf( pu ); - motionCompensation(pu, predBufTmp, REF_PIC_LIST_1); + PelUnitBuf predBufTmp = m_tmpPredStorage[REF_PIC_LIST_1].getCompactBuf( cu ); + motionCompensation(cu, predBufTmp, REF_PIC_LIST_1); // Update bits uiMotBits[0] = uiBits[0] - uiMbBits[0]; @@ -4859,11 +4973,11 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, // First iterate, get prediction block of opposite direction if (iIter == 0 && !slice.picHeader->mvdL1Zero) { - PU::setAllAffineMv(pu, aacMv[1 - iRefList][0], aacMv[1 - iRefList][1], aacMv[1 - iRefList][2], RefPicList(1 - iRefList)); - pu.refIdx[1 - iRefList] = iRefIdx[1 - iRefList]; + CU::setAllAffineMv(cu, aacMv[1 - iRefList][0], aacMv[1 - iRefList][1], aacMv[1 - iRefList][2], RefPicList(1 - iRefList)); + cu.refIdx[1 - iRefList] = iRefIdx[1 - iRefList]; - PelUnitBuf predBufTmp = m_tmpPredStorage[1 - iRefList].getCompactBuf( pu ); - motionCompensation(pu, predBufTmp, RefPicList(1 - iRefList)); + PelUnitBuf predBufTmp = m_tmpPredStorage[1 - iRefList].getCompactBuf( cu ); + motionCompensation(cu, predBufTmp, RefPicList(1 - iRefList)); } RefPicList refPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); @@ -4880,13 +4994,13 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, iRefEnd = slice.numRefIdx[refPicList] - 1; for (int iRefIdxTemp = iRefStart; iRefIdxTemp <= iRefEnd; iRefIdxTemp++) { - if (pu.cu->affineType == AFFINEMODEL_6PARAM && refIdx4Para[iRefList] != iRefIdxTemp) + if (cu.affineType == AFFINEMODEL_6PARAM && refIdx4Para[iRefList] != iRefIdxTemp) { continue; } // update bits uiBitsTemp = uiMbBits[2] + uiMotBits[1 - iRefList]; - // uiBitsTemp += ((pu.cu->slice->getSPS()->BCW == true) ? BcwIdxBits : 0); + // uiBitsTemp += ((cu.slice->getSPS()->BCW == true) ? BcwIdxBits : 0); if (slice.numRefIdx[refPicList] > 1) { uiBitsTemp += iRefIdxTemp + 1; @@ -4898,12 +5012,12 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; // call Affine ME - xAffineMotionEstimation(pu, origBuf, refPicList, cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, tmp.affMVs[iRefList][iRefIdxTemp], + xAffineMotionEstimation(cu, origBuf, refPicList, cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, tmp.affMVs[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp, aaiMvpIdxBi[iRefList][iRefIdxTemp], aacAffineAMVPInfo[iRefList][iRefIdxTemp], true); xCopyAffineAMVPInfo(aacAffineAMVPInfo[iRefList][iRefIdxTemp], affiAMVPInfoTemp[refPicList]); - if (pu.cu->imv != 2) + if (cu.imv != 2) { - xCheckBestAffineMVP(pu, affiAMVPInfoTemp[refPicList], refPicList, tmp.affMVs[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); + xCheckBestAffineMVP(cu, affiAMVPInfoTemp[refPicList], refPicList, tmp.affMVs[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); } if (uiCostTemp < uiCostBi) @@ -4919,10 +5033,10 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, if (iNumIter != 1) // MC for next iter { // Set motion - PU::setAllAffineMv(pu, cMvBi[iRefList][0], cMvBi[iRefList][1], cMvBi[iRefList][2], refPicList); - pu.refIdx[refPicList] = iRefIdxBi[refPicList]; - PelUnitBuf predBufTmp = m_tmpPredStorage[iRefList].getCompactBuf( pu ); - motionCompensation(pu, predBufTmp, refPicList); + CU::setAllAffineMv(cu, cMvBi[iRefList][0], cMvBi[iRefList][1], cMvBi[iRefList][2], refPicList); + cu.refIdx[refPicList] = iRefIdxBi[refPicList]; + PelUnitBuf predBufTmp = m_tmpPredStorage[iRefList].getCompactBuf( cu ); + motionCompensation(cu, predBufTmp, refPicList); } } } // for loop-iRefIdxTemp @@ -4932,12 +5046,12 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, if ((uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1]) || enforceBcwPred) { xCopyAffineAMVPInfo(aacAffineAMVPInfo[0][iRefIdxBi[0]], affiAMVPInfoTemp[REF_PIC_LIST_0]); - xCheckBestAffineMVP(pu, affiAMVPInfoTemp[REF_PIC_LIST_0], REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], uiBits[2], uiCostBi); + xCheckBestAffineMVP(cu, affiAMVPInfoTemp[REF_PIC_LIST_0], REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], uiBits[2], uiCostBi); if (!slice.picHeader->mvdL1Zero) { xCopyAffineAMVPInfo(aacAffineAMVPInfo[1][iRefIdxBi[1]], affiAMVPInfoTemp[REF_PIC_LIST_1]); - xCheckBestAffineMVP(pu, affiAMVPInfoTemp[REF_PIC_LIST_1], REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], uiBits[2], uiCostBi); + xCheckBestAffineMVP(cu, affiAMVPInfoTemp[REF_PIC_LIST_1], REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], uiBits[2], uiCostBi); } } break; @@ -4947,21 +5061,21 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, m_isBi = false; } // if (B_SLICE) - pu.mv[REF_PIC_LIST_0] = Mv(); - pu.mv[REF_PIC_LIST_1] = Mv(); - pu.mvd[REF_PIC_LIST_0] = cMvZero; - pu.mvd[REF_PIC_LIST_1] = cMvZero; - pu.refIdx[REF_PIC_LIST_0] = NOT_VALID; - pu.refIdx[REF_PIC_LIST_1] = NOT_VALID; - pu.mvpIdx[REF_PIC_LIST_0] = NOT_VALID; - pu.mvpIdx[REF_PIC_LIST_1] = NOT_VALID; - pu.mvpNum[REF_PIC_LIST_0] = NOT_VALID; - pu.mvpNum[REF_PIC_LIST_1] = NOT_VALID; + cu.mv[REF_PIC_LIST_0] = Mv(); + cu.mv[REF_PIC_LIST_1] = Mv(); + cu.mvd[REF_PIC_LIST_0] = cMvZero; + cu.mvd[REF_PIC_LIST_1] = cMvZero; + cu.refIdx[REF_PIC_LIST_0] = NOT_VALID; + cu.refIdx[REF_PIC_LIST_1] = NOT_VALID; + cu.mvpIdx[REF_PIC_LIST_0] = NOT_VALID; + cu.mvpIdx[REF_PIC_LIST_1] = NOT_VALID; + cu.mvpNum[REF_PIC_LIST_0] = NOT_VALID; + cu.mvpNum[REF_PIC_LIST_1] = NOT_VALID; for (int verIdx = 0; verIdx < 3; verIdx++) { - pu.mvdAffi[REF_PIC_LIST_0][verIdx] = cMvZero; - pu.mvdAffi[REF_PIC_LIST_1][verIdx] = cMvZero; + cu.mvdAffi[REF_PIC_LIST_0][verIdx] = cMvZero; + cu.mvdAffi[REF_PIC_LIST_1][verIdx] = cMvZero; } // Set Motion Field @@ -4980,89 +5094,89 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, { lastMode = 2; affineCost = uiCostBi; - pu.interDir = 3; - PU::setAllAffineMv(pu, cMvBi[0][0], cMvBi[0][1], cMvBi[0][2], REF_PIC_LIST_0); - PU::setAllAffineMv(pu, cMvBi[1][0], cMvBi[1][1], cMvBi[1][2], REF_PIC_LIST_1); - pu.refIdx[REF_PIC_LIST_0] = iRefIdxBi[0]; - pu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; + cu.interDir = 3; + CU::setAllAffineMv(cu, cMvBi[0][0], cMvBi[0][1], cMvBi[0][2], REF_PIC_LIST_0); + CU::setAllAffineMv(cu, cMvBi[1][0], cMvBi[1][1], cMvBi[1][2], REF_PIC_LIST_1); + cu.refIdx[REF_PIC_LIST_0] = iRefIdxBi[0]; + cu.refIdx[REF_PIC_LIST_1] = iRefIdxBi[1]; for (int verIdx = 0; verIdx < mvNum; verIdx++) { - pu.mvdAffi[REF_PIC_LIST_0][verIdx] = cMvBi[0][verIdx] - cMvPredBi[0][iRefIdxBi[0]][verIdx]; - pu.mvdAffi[REF_PIC_LIST_1][verIdx] = cMvBi[1][verIdx] - cMvPredBi[1][iRefIdxBi[1]][verIdx]; + cu.mvdAffi[REF_PIC_LIST_0][verIdx] = cMvBi[0][verIdx] - cMvPredBi[0][iRefIdxBi[0]][verIdx]; + cu.mvdAffi[REF_PIC_LIST_1][verIdx] = cMvBi[1][verIdx] - cMvPredBi[1][iRefIdxBi[1]][verIdx]; if (verIdx != 0) { - pu.mvdAffi[0][verIdx] = pu.mvdAffi[0][verIdx] - pu.mvdAffi[0][0]; - pu.mvdAffi[1][verIdx] = pu.mvdAffi[1][verIdx] - pu.mvdAffi[1][0]; + cu.mvdAffi[0][verIdx] = cu.mvdAffi[0][verIdx] - cu.mvdAffi[0][0]; + cu.mvdAffi[1][verIdx] = cu.mvdAffi[1][verIdx] - cu.mvdAffi[1][0]; } } - pu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdxBi[0][iRefIdxBi[0]]; - pu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdxBi[0]]; - pu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdxBi[1][iRefIdxBi[1]]; - pu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdxBi[1]]; + cu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdxBi[0][iRefIdxBi[0]]; + cu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdxBi[0]]; + cu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdxBi[1][iRefIdxBi[1]]; + cu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdxBi[1]]; } else if (uiCost[0] <= uiCost[1]) // List 0 { lastMode = 0; affineCost = uiCost[0]; - pu.interDir = 1; - PU::setAllAffineMv(pu, aacMv[0][0], aacMv[0][1], aacMv[0][2], REF_PIC_LIST_0); - pu.refIdx[REF_PIC_LIST_0] = iRefIdx[0]; + cu.interDir = 1; + CU::setAllAffineMv(cu, aacMv[0][0], aacMv[0][1], aacMv[0][2], REF_PIC_LIST_0); + cu.refIdx[REF_PIC_LIST_0] = iRefIdx[0]; for (int verIdx = 0; verIdx < mvNum; verIdx++) { - pu.mvdAffi[REF_PIC_LIST_0][verIdx] = aacMv[0][verIdx] - cMvPred[0][iRefIdx[0]][verIdx]; + cu.mvdAffi[REF_PIC_LIST_0][verIdx] = aacMv[0][verIdx] - cMvPred[0][iRefIdx[0]][verIdx]; if (verIdx != 0) { - pu.mvdAffi[0][verIdx] = pu.mvdAffi[0][verIdx] - pu.mvdAffi[0][0]; + cu.mvdAffi[0][verIdx] = cu.mvdAffi[0][verIdx] - cu.mvdAffi[0][0]; } } - pu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdx[0][iRefIdx[0]]; - pu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdx[0]]; + cu.mvpIdx[REF_PIC_LIST_0] = aaiMvpIdx[0][iRefIdx[0]]; + cu.mvpNum[REF_PIC_LIST_0] = aaiMvpNum[0][iRefIdx[0]]; } else { lastMode = 1; affineCost = uiCost[1]; - pu.interDir = 2; - PU::setAllAffineMv(pu, aacMv[1][0], aacMv[1][1], aacMv[1][2], REF_PIC_LIST_1); - pu.refIdx[REF_PIC_LIST_1] = iRefIdx[1]; + cu.interDir = 2; + CU::setAllAffineMv(cu, aacMv[1][0], aacMv[1][1], aacMv[1][2], REF_PIC_LIST_1); + cu.refIdx[REF_PIC_LIST_1] = iRefIdx[1]; for (int verIdx = 0; verIdx < mvNum; verIdx++) { - pu.mvdAffi[REF_PIC_LIST_1][verIdx] = aacMv[1][verIdx] - cMvPred[1][iRefIdx[1]][verIdx]; + cu.mvdAffi[REF_PIC_LIST_1][verIdx] = aacMv[1][verIdx] - cMvPred[1][iRefIdx[1]][verIdx]; if (verIdx != 0) { - pu.mvdAffi[1][verIdx] = pu.mvdAffi[1][verIdx] - pu.mvdAffi[1][0]; + cu.mvdAffi[1][verIdx] = cu.mvdAffi[1][verIdx] - cu.mvdAffi[1][0]; } } - pu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdx[1][iRefIdx[1]]; - pu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdx[1]]; + cu.mvpIdx[REF_PIC_LIST_1] = aaiMvpIdx[1][iRefIdx[1]]; + cu.mvpNum[REF_PIC_LIST_1] = aaiMvpNum[1][iRefIdx[1]]; } if (BcwIdx != BCW_DEFAULT) { - pu.cu->BcwIdx = BCW_DEFAULT; + cu.BcwIdx = BCW_DEFAULT; } } -Distortion InterSearch::xGetAffineTemplateCost(PredictionUnit& pu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv acMvCand[3], int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx) +Distortion InterSearch::xGetAffineTemplateCost(CodingUnit& cu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv acMvCand[3], int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx) { Distortion uiCost = MAX_DISTORTION; - const Picture* picRef = pu.cu->slice->getRefPic(refPicList, iRefIdx); + const Picture* picRef = cu.slice->getRefPic(refPicList, iRefIdx); // prediction pattern Mv mv[3]; memcpy(mv, acMvCand, sizeof(mv)); - xPredAffineBlk(COMP_Y, pu, picRef, mv, predBuf, false, pu.cu->slice->clpRngs[COMP_Y], refPicList); + xPredAffineBlk(COMP_Y, cu, picRef, mv, predBuf, false, cu.slice->clpRngs[COMP_Y], refPicList); // calc distortion - enum DFunc distFunc = (pu.cs->slice->disableSATDForRd) ? DF_SAD : DF_HAD; - uiCost = m_pcRdCost->getDistPart(origBuf.Y(), predBuf.Y(), pu.cs->sps->bitDepths[CH_L], COMP_Y + enum DFunc distFunc = (cu.cs->slice->disableSATDForRd) ? DF_SAD : DF_HAD; + uiCost = m_pcRdCost->getDistPart(origBuf.Y(), predBuf.Y(), cu.cs->sps->bitDepths[CH_L], COMP_Y , distFunc ); uiCost += m_pcRdCost->getCost(m_auiMVPIdxCost[iMVPIdx][iMVPNum]); @@ -5142,14 +5256,14 @@ void solveEqual(double** dEqualCoeff, int iOrder, double* dAffinePara) } } -void InterSearch::xCheckBestAffineMVP(PredictionUnit &pu, AffineAMVPInfo &affineAMVPInfo, RefPicList refPicList, Mv acMv[3], Mv acMvPred[3], int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost) +void InterSearch::xCheckBestAffineMVP(CodingUnit& cu, AffineAMVPInfo &affineAMVPInfo, RefPicList refPicList, Mv acMv[3], Mv acMvPred[3], int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost) { if (affineAMVPInfo.numCand < 2) { return; } - int mvNum = pu.cu->affineType ? 3 : 2; + int mvNum = cu.affineType ? 3 : 2; m_pcRdCost->selectMotionLambda(); m_pcRdCost->setCostScale(0); @@ -5158,7 +5272,7 @@ void InterSearch::xCheckBestAffineMVP(PredictionUnit &pu, AffineAMVPInfo &affine // Get origin MV bits Mv tmpPredMv[3]; - int iOrgMvBits = xCalcAffineMVBits(pu, acMv, acMvPred); + int iOrgMvBits = xCalcAffineMVBits(cu, acMv, acMvPred); iOrgMvBits += m_auiMVPIdxCost[riMVPIdx][AMVP_MAX_NUM_CANDS]; int iBestMvBits = iOrgMvBits; @@ -5174,7 +5288,7 @@ void InterSearch::xCheckBestAffineMVP(PredictionUnit &pu, AffineAMVPInfo &affine { tmpPredMv[2] = affineAMVPInfo.mvCandLB[iMVPIdx]; } - int iMvBits = xCalcAffineMVBits(pu, acMv, tmpPredMv); + int iMvBits = xCalcAffineMVBits(cu, acMv, tmpPredMv); iMvBits += m_auiMVPIdxCost[iMVPIdx][AMVP_MAX_NUM_CANDS]; if (iMvBits < iBestMvBits) @@ -5196,7 +5310,7 @@ void InterSearch::xCheckBestAffineMVP(PredictionUnit &pu, AffineAMVPInfo &affine } } -void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, +void InterSearch::xAffineMotionEstimation(CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, Mv acMvPred[3], @@ -5209,43 +5323,43 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, bool bBi) { int bestMvpIdx = mvpIdx; - const int width = pu.Y().width; - const int height = pu.Y().height; + const int width = cu.Y().width; + const int height = cu.Y().height; - const Picture* refPic = pu.cu->slice->getRefPic(refPicList, iRefIdxPred); + const Picture* refPic = cu.slice->getRefPic(refPicList, iRefIdxPred); // Set Origin YUV: pcYuv CPelUnitBuf* pBuf = &origBuf; double fWeight = 1.0; CPelUnitBuf origBufTmpCnst; - enum DFunc distFunc = (pu.cs->slice->disableSATDForRd) ? DF_SAD : DF_HAD; + enum DFunc distFunc = (cu.cs->slice->disableSATDForRd) ? DF_SAD : DF_HAD; // if Bi, set to ( 2 * Org - ListX ) if (bBi) { - PelUnitBuf origBufTmp = m_tmpStorageLCU.getCompactBuf(pu); + PelUnitBuf origBufTmp = m_tmpStorageLCU.getCompactBuf(cu); // NOTE: Other buf contains predicted signal from another direction - PelUnitBuf otherBuf = m_tmpPredStorage[1 - (int)refPicList].getCompactBuf( pu ); + PelUnitBuf otherBuf = m_tmpPredStorage[1 - (int)refPicList].getCompactBuf( cu ); origBufTmp.copyFrom(origBuf); - origBufTmp.removeHighFreq(otherBuf, m_pcEncCfg->m_bClipForBiPredMeEnabled, pu.cu->slice->clpRngs); + origBufTmp.removeHighFreq(otherBuf, m_pcEncCfg->m_bClipForBiPredMeEnabled, cu.slice->clpRngs); - origBufTmpCnst = m_tmpStorageLCU.getCompactBuf(pu); + origBufTmpCnst = m_tmpStorageLCU.getCompactBuf(cu); pBuf = &origBufTmpCnst; - fWeight = xGetMEDistortionWeight(pu.cu->BcwIdx, refPicList); + fWeight = xGetMEDistortionWeight(cu.BcwIdx, refPicList); } // pred YUV - PelUnitBuf predBuf = m_tmpAffiStorage.getCompactBuf(pu); + PelUnitBuf predBuf = m_tmpAffiStorage.getCompactBuf(cu); // Set start Mv position, use input mv as started search mv Mv acMvTemp[3]; ::memcpy(acMvTemp, acMv, sizeof(Mv) * 3); // Set delta mv // malloc buffer - int iParaNum = pu.cu->affineType ? 7 : 5; + int iParaNum = cu.affineType ? 7 : 5; int affineParaNum = iParaNum - 1; - int mvNum = pu.cu->affineType ? 3 : 2; + int mvNum = cu.affineType ? 3 : 2; double **pdEqualCoeff; pdEqualCoeff = new double *[iParaNum]; for (int i = 0; i < iParaNum; i++) @@ -5264,29 +5378,29 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, // do motion compensation with origin mv - clipMv(acMvTemp[0], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); - clipMv(acMvTemp[1], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + clipMv(acMvTemp[0], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + clipMv(acMvTemp[1], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + if (cu.affineType == AFFINEMODEL_6PARAM) { - clipMv(acMvTemp[2], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + clipMv(acMvTemp[2], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); } - acMvTemp[0].roundAffinePrecInternal2Amvr(pu.cu->imv); - acMvTemp[1].roundAffinePrecInternal2Amvr(pu.cu->imv); - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + acMvTemp[0].roundAffinePrecInternal2Amvr(cu.imv); + acMvTemp[1].roundAffinePrecInternal2Amvr(cu.imv); + if (cu.affineType == AFFINEMODEL_6PARAM) { - acMvTemp[2].roundAffinePrecInternal2Amvr(pu.cu->imv); + acMvTemp[2].roundAffinePrecInternal2Amvr(cu.imv); } - xPredAffineBlk(COMP_Y, pu, refPic, acMvTemp, predBuf, false, pu.cs->slice->clpRngs[COMP_Y], refPicList); + xPredAffineBlk(COMP_Y, cu, refPic, acMvTemp, predBuf, false, cu.cs->slice->clpRngs[COMP_Y], refPicList); // get error - uiCostBest = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), pu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); + uiCostBest = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), cu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); // get cost with mv m_pcRdCost->setCostScale(0); uiBitsBest = ruiBits; DTRACE(g_trace_ctx, D_COMMON, " (%d) xx uiBitsBest=%d\n", DTRACE_GET_COUNTER(g_trace_ctx, D_COMMON), uiBitsBest); - uiBitsBest += xCalcAffineMVBits(pu, acMvTemp, acMvPred); + uiBitsBest += xCalcAffineMVBits(cu, acMvTemp, acMvPred); DTRACE(g_trace_ctx, D_COMMON, " (%d) yy uiBitsBest=%d\n", DTRACE_GET_COUNTER(g_trace_ctx, D_COMMON), uiBitsBest); uiCostBest = (Distortion)(floor(fWeight * (double)uiCostBest) + (double)m_pcRdCost->getCost(uiBitsBest)); @@ -5298,7 +5412,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, const int predBufStride = predBuf.Y().stride; Mv prevIterMv[7][3]; int iIterTime; - if (pu.cu->affineType == AFFINEMODEL_6PARAM) + if (cu.affineType == AFFINEMODEL_6PARAM) { iIterTime = bBi ? 3 : 4; } @@ -5307,7 +5421,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, iIterTime = bBi ? 3 : 5; } - if (!pu.cu->cs->sps->AffineType)// getUseAffineType()) + if (!cu.cs->sps->AffineType)// getUseAffineType()) { iIterTime = bBi ? 5 : 7; } @@ -5351,7 +5465,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, } m_EqualCoeffComputer(piError, width, pdDerivate, width, i64EqualCoeff, width, height - , (pu.cu->affineType == AFFINEMODEL_6PARAM) + , (cu.affineType == AFFINEMODEL_6PARAM) ); for (int row = 0; row < iParaNum; row++) @@ -5371,7 +5485,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, // convert to delta mv dDeltaMv[0] = dAffinePara[0]; dDeltaMv[2] = dAffinePara[2]; - const bool extParams = pu.cu->affineType == AFFINEMODEL_6PARAM; + const bool extParams = cu.affineType == AFFINEMODEL_6PARAM; if (extParams) { dDeltaMv[1] = dAffinePara[1] * width + dAffinePara[0]; @@ -5387,8 +5501,8 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, const int normShiftTab[3] = { MV_PRECISION_QUARTER - MV_PRECISION_INT, MV_PRECISION_SIXTEENTH - MV_PRECISION_INT, MV_PRECISION_QUARTER - MV_PRECISION_INT }; const int stepShiftTab[3] = { MV_PRECISION_INTERNAL - MV_PRECISION_QUARTER, MV_PRECISION_INTERNAL - MV_PRECISION_SIXTEENTH, MV_PRECISION_INTERNAL - MV_PRECISION_QUARTER }; - const int multiShift = 1 << normShiftTab[pu.cu->imv]; - const int mvShift = stepShiftTab[pu.cu->imv]; + const int multiShift = 1 << normShiftTab[cu.imv]; + const int mvShift = stepShiftTab[cu.imv]; acDeltaMv[0] = Mv((int)(dDeltaMv[0] * multiShift + SIGN(dDeltaMv[0]) * 0.5) << mvShift, (int)(dDeltaMv[2] * multiShift + SIGN(dDeltaMv[2]) * 0.5) << mvShift); acDeltaMv[1] = Mv((int)(dDeltaMv[1] * multiShift + SIGN(dDeltaMv[1]) * 0.5) << mvShift, (int)(dDeltaMv[3] * multiShift + SIGN(dDeltaMv[3]) * 0.5) << mvShift); @@ -5400,7 +5514,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, for (int i = 0; i < mvNum; i++) { Mv deltaMv = acDeltaMv[i]; - if (pu.cu->imv == 2) + if (cu.imv == 2) { deltaMv.roundToPrecision(MV_PRECISION_INTERNAL, MV_PRECISION_HALF); } @@ -5421,21 +5535,21 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, acMvTemp[i] += acDeltaMv[i]; acMvTemp[i].hor = Clip3(MV_MIN, MV_MAX, acMvTemp[i].hor); acMvTemp[i].ver = Clip3(MV_MIN, MV_MAX, acMvTemp[i].ver); - acMvTemp[i].roundAffinePrecInternal2Amvr(pu.cu->imv); + acMvTemp[i].roundAffinePrecInternal2Amvr(cu.imv); - clipMv(acMvTemp[i], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); + clipMv(acMvTemp[i], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); } - xPredAffineBlk(COMP_Y, pu, refPic, acMvTemp, predBuf, false, pu.cu->slice->clpRngs[COMP_Y], refPicList); + xPredAffineBlk(COMP_Y, cu, refPic, acMvTemp, predBuf, false, cu.slice->clpRngs[COMP_Y], refPicList); // get error - Distortion uiCostTemp = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), pu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); + Distortion uiCostTemp = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), cu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); DTRACE(g_trace_ctx, D_COMMON, " (%d) uiCostTemp=%d\n", DTRACE_GET_COUNTER(g_trace_ctx, D_COMMON), uiCostTemp); // get cost with mv m_pcRdCost->setCostScale(0); uint32_t uiBitsTemp = ruiBits; - uiBitsTemp += xCalcAffineMVBits(pu, acMvTemp, acMvPred); + uiBitsTemp += xCalcAffineMVBits(cu, acMvTemp, acMvPred); uiCostTemp = (Distortion)(floor(fWeight * (double)uiCostTemp) + (double)m_pcRdCost->getCost(uiBitsTemp)); // store best cost and mv @@ -5454,13 +5568,13 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, auto checkCPMVRdCost = [&](Mv ctrlPtMv[3]) { - xPredAffineBlk(COMP_Y, pu, refPic, ctrlPtMv, predBuf, false, pu.cu->slice->clpRngs[COMP_Y], refPicList); + xPredAffineBlk(COMP_Y, cu, refPic, ctrlPtMv, predBuf, false, cu.slice->clpRngs[COMP_Y], refPicList); // get error - Distortion costTemp = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), pu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); + Distortion costTemp = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), cu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); // get cost with mv m_pcRdCost->setCostScale(0); uint32_t bitsTemp = ruiBits; - bitsTemp += xCalcAffineMVBits(pu, ctrlPtMv, acMvPred); + bitsTemp += xCalcAffineMVBits(cu, ctrlPtMv, acMvPred); costTemp = (Distortion)(floor(fWeight * (double)costTemp) + (double)m_pcRdCost->getCost(bitsTemp)); // store best cost and mv if (costTemp < uiCostBest) @@ -5472,7 +5586,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, }; const uint32_t mvShiftTable[3] = { MV_PRECISION_INTERNAL - MV_PRECISION_QUARTER, MV_PRECISION_INTERNAL - MV_PRECISION_INTERNAL, MV_PRECISION_INTERNAL - MV_PRECISION_INT }; - const uint32_t mvShift = mvShiftTable[pu.cu->imv]; + const uint32_t mvShift = mvShiftTable[cu.imv]; if (uiCostBest <= AFFINE_ME_LIST_MVP_TH*m_hevcCost) { Mv mvPredTmp[3] = { acMvPred[0], acMvPred[1], acMvPred[2] }; @@ -5508,7 +5622,7 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, } //keep the translation; - if (pu.cu->affineType == AFFINEMODEL_6PARAM && mvME[1] != (mvPredTmp[1] + dMv) && mvME[2] != (mvPredTmp[2] + dMv)) + if (cu.affineType == AFFINEMODEL_6PARAM && mvME[1] != (mvPredTmp[1] + dMv) && mvME[2] != (mvPredTmp[2] + dMv)) { ::memcpy(acMvTemp, mvME, sizeof(Mv) * 3); @@ -5542,12 +5656,12 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, for (int i = ((iter == 0) ? 0 : 4); i < ((iter == 0) ? 4 : 8); i++) { acMvTemp[j].set(centerMv[j].hor + (testPos[i][0] << mvShift), centerMv[j].ver + (testPos[i][1] << mvShift)); - clipMv(acMvTemp[j], pu.cu->lumaPos(), pu.cu->lumaSize(), *pu.cs->pcv); - xPredAffineBlk(COMP_Y, pu, refPic, acMvTemp, predBuf, false, pu.cu->slice->clpRngs[COMP_Y], refPicList); + clipMv(acMvTemp[j], cu.lumaPos(), cu.lumaSize(), *cu.cs->pcv); + xPredAffineBlk(COMP_Y, cu, refPic, acMvTemp, predBuf, false, cu.slice->clpRngs[COMP_Y], refPicList); - Distortion costTemp = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), pu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); + Distortion costTemp = m_pcRdCost->getDistPart(predBuf.Y(), pBuf->Y(), cu.cs->sps->bitDepths[CH_L], COMP_Y, distFunc); uint32_t bitsTemp = ruiBits; - bitsTemp += xCalcAffineMVBits(pu, acMvTemp, acMvPred); + bitsTemp += xCalcAffineMVBits(cu, acMvTemp, acMvPred); costTemp = (Distortion)(floor(fWeight * (double)costTemp) + (double)m_pcRdCost->getCost(bitsTemp)); if (costTemp < uiCostBest) @@ -5582,17 +5696,17 @@ void InterSearch::xAffineMotionEstimation(PredictionUnit& pu, DTRACE(g_trace_ctx, D_COMMON, " (%d) uiBitsBest=%d, uiCostBest=%d\n", DTRACE_GET_COUNTER(g_trace_ctx, D_COMMON), uiBitsBest, uiCostBest); } -void InterSearch::xEstimateAffineAMVP(PredictionUnit& pu, AffineAMVPInfo& affineAMVPInfo, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv acMvPred[3], Distortion& distBiP) +void InterSearch::xEstimateAffineAMVP(CodingUnit& cu, AffineAMVPInfo& affineAMVPInfo, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv acMvPred[3], Distortion& distBiP) { Mv bestMvLT, bestMvRT, bestMvLB; int iBestIdx = 0; Distortion uiBestCost = MAX_DISTORTION; // Fill the MV Candidates - PU::fillAffineMvpCand(pu, refPicList, iRefIdx, affineAMVPInfo); + CU::fillAffineMvpCand(cu, refPicList, iRefIdx, affineAMVPInfo); CHECK(affineAMVPInfo.numCand == 0, "Assertion failed."); - PelUnitBuf predBuf = m_tmpStorageLCU.getCompactBuf( pu ); + PelUnitBuf predBuf = m_tmpStorageLCU.getCompactBuf( cu ); bool stop_check = false; if (affineAMVPInfo.mvCandLT[0] == affineAMVPInfo.mvCandLT[1]) @@ -5613,7 +5727,7 @@ void InterSearch::xEstimateAffineAMVP(PredictionUnit& pu, AffineAMVPInfo& affine } Mv mv[3] = { affineAMVPInfo.mvCandLT[i], affineAMVPInfo.mvCandRT[i], affineAMVPInfo.mvCandLB[i] }; - Distortion uiTmpCost = xGetAffineTemplateCost(pu, origBuf, predBuf, mv, i, AMVP_MAX_NUM_CANDS, refPicList, iRefIdx); + Distortion uiTmpCost = xGetAffineTemplateCost(cu, origBuf, predBuf, mv, i, AMVP_MAX_NUM_CANDS, refPicList, iRefIdx); if (uiBestCost > uiTmpCost) { @@ -5631,8 +5745,8 @@ void InterSearch::xEstimateAffineAMVP(PredictionUnit& pu, AffineAMVPInfo& affine acMvPred[1] = bestMvRT; acMvPred[2] = bestMvLB; - pu.mvpIdx[refPicList] = iBestIdx; - pu.mvpNum[refPicList] = affineAMVPInfo.numCand; + cu.mvpIdx[refPicList] = iBestIdx; + cu.mvpNum[refPicList] = affineAMVPInfo.numCand; DTRACE(g_trace_ctx, D_COMMON, "#estAffi=%d \n", affineAMVPInfo.numCand); } @@ -5645,19 +5759,19 @@ void InterSearch::xCopyAffineAMVPInfo(AffineAMVPInfo& src, AffineAMVPInfo& dst) ::memcpy(dst.mvCandLB, src.mvCandLB, sizeof(Mv)*src.numCand); } -uint32_t InterSearch::xCalcAffineMVBits(PredictionUnit& pu, Mv acMvTemp[3], Mv acMvPred[3]) +uint32_t InterSearch::xCalcAffineMVBits(CodingUnit& cu, Mv acMvTemp[3], Mv acMvPred[3]) { - int mvNum = pu.cu->affineType ? 3 : 2; + int mvNum = cu.affineType ? 3 : 2; m_pcRdCost->setCostScale(0); uint32_t bitsTemp = 0; for (int verIdx = 0; verIdx < mvNum; verIdx++) { Mv pred = verIdx == 0 ? acMvPred[verIdx] : acMvPred[verIdx] + acMvTemp[0] - acMvPred[0]; - pred.changeAffinePrecInternal2Amvr(pu.cu->imv); + pred.changeAffinePrecInternal2Amvr(cu.imv); m_pcRdCost->setPredictor(pred); Mv mv = acMvTemp[verIdx]; - mv.changeAffinePrecInternal2Amvr(pu.cu->imv); + mv.changeAffinePrecInternal2Amvr(cu.imv); bitsTemp += m_pcRdCost->getBitsOfVectorWithPredictor(mv.hor, mv.ver, 0); } diff --git a/source/Lib/EncoderLib/InterSearch.h b/source/Lib/EncoderLib/InterSearch.h index 41a2f220d..639e27a19 100644 --- a/source/Lib/EncoderLib/InterSearch.h +++ b/source/Lib/EncoderLib/InterSearch.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file InterSearch.h \brief inter search class (header) */ @@ -203,8 +207,6 @@ typedef struct Mv acMvAffine6Para[2][3]; int16_t affine4ParaRefIdx[2]; int16_t affine6ParaRefIdx[2]; - Distortion hevcCost[3]; - Distortion affineCost[3]; bool affine4ParaAvail; bool affine6ParaAvail; } EncAffineMotion; @@ -446,9 +448,9 @@ class InterSearch : public InterPrediction, AffineGradientSearch // Inter search (AMP) // ------------------------------------------------------------------------------------------------------------------- - void xEstimateMvPredAMVP ( PredictionUnit& pu, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv& rcMvPred, AMVPInfo& amvpInfo, Distortion& distBiP ); + void xEstimateMvPredAMVP ( CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv& rcMvPred, AMVPInfo& amvpInfo, Distortion& distBiP ); void xCheckBestMVP ( RefPicList refPicList, const Mv& cMv, Mv& rcMvPred, int& riMVPIdx, AMVPInfo& amvpInfo, uint32_t& ruiBits, Distortion& ruiCost, const uint8_t imv); - Distortion xGetTemplateCost ( const PredictionUnit& pu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv cMvCand, int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx ); + Distortion xGetTemplateCost ( const CodingUnit& cu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv cMvCand, int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx ); void xCopyAMVPInfo ( AMVPInfo* pSrc, AMVPInfo* pDst ); uint32_t xGetMvpIdxBits ( int iIdx, int iNum ); @@ -459,7 +461,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch // motion estimation // ------------------------------------------------------------------------------------------------------------------- - void xMotionEstimation ( PredictionUnit& pu, + void xMotionEstimation ( CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, Mv& rcMvPred, @@ -472,7 +474,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch bool bBi = false ); - void xTZSearch ( const PredictionUnit& pu, + void xTZSearch ( const CodingUnit& cu, RefPicList refPicList, int iRefIdxPred, TZSearchStruct& cStruct, @@ -483,7 +485,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch const bool bFastSettings = false ); - void xTZSearchSelective ( const PredictionUnit& pu, + void xTZSearchSelective ( const CodingUnit& cu, RefPicList refPicList, int iRefIdxPred, TZSearchStruct& cStruct, @@ -492,13 +494,13 @@ class InterSearch : public InterPrediction, AffineGradientSearch const Mv* const pIntegerMv2Nx2NPred ); - void xSetSearchRange ( const PredictionUnit& pu, + void xSetSearchRange ( const CodingUnit& cu, const Mv& cMvPred, const int iSrchRng, SearchRange& sr ); - void xPatternSearchFast ( const PredictionUnit& pu, + void xPatternSearchFast ( const CodingUnit& cu, RefPicList refPicList, int iRefIdxPred, TZSearchStruct& cStruct, @@ -512,7 +514,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch Distortion& ruiSAD ); - void xPatternSearchIntRefine ( PredictionUnit& pu, + void xPatternSearchIntRefine ( CodingUnit& cu, TZSearchStruct& cStruct, Mv& rcMv, Mv& rcMvPred, @@ -523,7 +525,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch double fWeight ); - void xPatternSearchFracDIF ( const PredictionUnit& pu, + void xPatternSearchFracDIF ( const CodingUnit& cu, RefPicList refPicList, int iRefIdx, TZSearchStruct& cStruct, @@ -533,7 +535,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch Distortion& ruiCost ); - void xPredAffineInterSearch ( PredictionUnit& pu, + void xPredAffineInterSearch ( CodingUnit& cu, CPelUnitBuf& origBuf, int puIdx, uint32_t& lastMode, @@ -546,7 +548,7 @@ class InterSearch : public InterPrediction, AffineGradientSearch uint32_t BcwIdxBits = 0 ); - void xAffineMotionEstimation ( PredictionUnit& pu, + void xAffineMotionEstimation ( CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, Mv acMvPred[3], @@ -559,20 +561,20 @@ class InterSearch : public InterPrediction, AffineGradientSearch bool bBi = false ); - void xEstimateAffineAMVP ( PredictionUnit& pu, AffineAMVPInfo& affineAMVPInfo, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv acMvPred[3], Distortion& distBiP); + void xEstimateAffineAMVP ( CodingUnit& cu, AffineAMVPInfo& affineAMVPInfo, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv acMvPred[3], Distortion& distBiP); - Distortion xGetAffineTemplateCost ( PredictionUnit& pu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv acMvCand[3], int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx); + Distortion xGetAffineTemplateCost ( CodingUnit& cu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv acMvCand[3], int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx); void xCopyAffineAMVPInfo ( AffineAMVPInfo& src, AffineAMVPInfo& dst ); - void xCheckBestAffineMVP ( PredictionUnit &pu, AffineAMVPInfo &affineAMVPInfo, RefPicList refPicList, Mv acMv[3], Mv acMvPred[3], int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost ); - uint32_t xCalcAffineMVBits ( PredictionUnit& pu, Mv mvCand[3], Mv mvPred[3]); + void xCheckBestAffineMVP ( CodingUnit& cu, AffineAMVPInfo &affineAMVPInfo, RefPicList refPicList, Mv acMv[3], Mv acMvPred[3], int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost ); + uint32_t xCalcAffineMVBits ( CodingUnit& cu, Mv mvCand[3], Mv mvPred[3]); - Distortion xGetSymCost ( const PredictionUnit& pu, CPelUnitBuf& origBuf, RefPicList eCurRefPicList, const MvField& cCurMvField, MvField& cTarMvField , int BcwIdx ); - Distortion xSymRefineMvSearch ( PredictionUnit& pu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, + Distortion xGetSymCost ( const CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList eCurRefPicList, const MvField& cCurMvField, MvField& cTarMvField , int BcwIdx ); + Distortion xSymRefineMvSearch ( CodingUnit& cu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion uiMinCost, int searchPattern, int nSearchStepShift, uint32_t uiMaxSearchRounds, int BcwIdx ); - void xSymMotionEstimation ( PredictionUnit& pu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion& ruiCost, int BcwIdx ); + void xSymMotionEstimation ( CodingUnit& cu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion& ruiCost, int BcwIdx ); double xGetMEDistortionWeight ( uint8_t BcwIdx, RefPicList refPicList); - void xSymMvdCheckBestMvp ( PredictionUnit& pu, CPelUnitBuf& origBuf, Mv curMv, RefPicList curRefList, AMVPInfo amvpInfo[2][MAX_REF_PICS], + void xSymMvdCheckBestMvp ( CodingUnit& cu, CPelUnitBuf& origBuf, Mv curMv, RefPicList curRefList, AMVPInfo amvpInfo[2][MAX_REF_PICS], int32_t BcwIdx, Mv cMvPredSym[2], int32_t mvpIdxSym[2], Distortion& bestCost, bool skip ); void xExtDIFUpSamplingH ( CPelBuf* pcPattern, bool useAltHpelIf); diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 0110fba55..1445ca45b 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncSearch.cpp @@ -55,7 +59,7 @@ vvc@hhi.fraunhofer.de #include "CommonLib/dtrace_buffer.h" #include "CommonLib/Reshape.h" #include -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" //! \ingroup EncoderLib //! \{ @@ -176,7 +180,7 @@ static constexpr double COST_UNKNOWN = -65536.0; double IntraSearch::xFindInterCUCost( CodingUnit &cu ) { - if( cu.isConsIntra() && !cu.slice->isIntra() ) + if( CU::isConsIntra(cu) && !cu.slice->isIntra() ) { //search corresponding inter CU cost for( int i = 0; i < m_numCuInSCIPU; i++ ) @@ -204,19 +208,18 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, CHECK(numModesForFullRD >= numModesAvailable, "Too many modes for full RD search"); - PredictionUnit &pu = *cu.pu; const SPS& sps = *cu.cs->sps; const bool fastMip = sps.MIP && m_pcEncCfg->m_useFastMIP; // this should always be true - CHECK( !pu.Y().valid(), "PU is not valid" ); + CHECK( !cu.Y().valid(), "CU is not valid" ); - const CompArea& area = pu.Y(); + const CompArea& area = cu.Y(); const UnitArea localUnitArea(area.chromaFormat, Area(0, 0, area.width, area.height)); if( testMip) { - numModesForFullRD += fastMip? std::max(numModesForFullRD, floorLog2(std::min(pu.lwidth(), pu.lheight())) - m_pcEncCfg->m_useFastMIP) : numModesForFullRD; + numModesForFullRD += fastMip? std::max(numModesForFullRD, floorLog2(std::min(cu.lwidth(), cu.lheight())) - m_pcEncCfg->m_useFastMIP) : numModesForFullRD; m_SortedPelUnitBufs->prepare( localUnitArea, numModesForFullRD + 1 ); } else @@ -238,13 +241,16 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, //*** Derive (regular) candidates using Hadamard cu.mipFlag = false; - pu.multiRefIdx = 0; + cu.multiRefIdx = 0; //===== init pattern for luma prediction ===== - initIntraPatternChType(cu, pu.Y(), true); + initIntraPatternChType(cu, cu.Y(), true); bool satdChecked[NUM_INTRA_MODE] = { false }; + unsigned mpmLst[NUM_MOST_PROBABLE_MODES]; + CU::getIntraMPMs(cu, mpmLst); + for( unsigned mode = 0; mode < numModesAvailable; mode++ ) { // Skip checking extended Angular modes in the first round of SATD @@ -253,17 +259,17 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, continue; } - pu.intraDir[0] = mode; + cu.intraDir[0] = mode; - initPredIntraParams(pu, pu.Y(), sps); + initPredIntraParams(cu, cu.Y(), sps); distParam.cur.buf = piPred.buf = m_SortedPelUnitBufs->getTestBuf().Y().buf; - predIntraAng( COMP_Y, piPred, pu); + predIntraAng( COMP_Y, piPred, cu); // Use the min between SAD and HAD as the cost criterion // SAD is scaled by 2 to align with the scaling of HAD Distortion minSadHad = distParam.distFunc(distParam); - uint64_t fracModeBits = xFracModeBitsIntraLuma( pu ); + uint64_t fracModeBits = xFracModeBitsIntraLuma( cu, mpmLst ); //restore ctx m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::IntraLumaMpmFlag(), intra_ctx_size), ctxStartIntraCtx); @@ -293,17 +299,17 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, if( ! satdChecked[mode]) { - pu.intraDir[0] = mode; + cu.intraDir[0] = mode; - initPredIntraParams(pu, pu.Y(), sps); + initPredIntraParams(cu, cu.Y(), sps); distParam.cur.buf = piPred.buf = m_SortedPelUnitBufs->getTestBuf().Y().buf; - predIntraAng(COMP_Y, piPred, pu ); + predIntraAng(COMP_Y, piPred, cu ); // Use the min between SAD and SATD as the cost criterion // SAD is scaled by 2 to align with the scaling of HAD Distortion minSadHad = distParam.distFunc(distParam); - uint64_t fracModeBits = xFracModeBitsIntraLuma( pu ); + uint64_t fracModeBits = xFracModeBitsIntraLuma( cu, mpmLst ); //restore ctx m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::IntraLumaMpmFlag(), intra_ctx_size), ctxStartIntraCtx); @@ -321,76 +327,76 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, } } - const bool isFirstLineOfCtu = (((pu.block(COMP_Y).y)&((pu.cs->sps)->CTUSize - 1)) == 0); + const bool isFirstLineOfCtu = (((cu.block(COMP_Y).y)&((cu.cs->sps)->CTUSize - 1)) == 0); if( m_pcEncCfg->m_MRL && ! isFirstLineOfCtu ) { - pu.multiRefIdx = 1; + cu.multiRefIdx = 1; unsigned multiRefMPM [NUM_MOST_PROBABLE_MODES]; - PU::getIntraMPMs(pu, multiRefMPM); + CU::getIntraMPMs(cu, multiRefMPM); for (int mRefNum = 1; mRefNum < MRL_NUM_REF_LINES; mRefNum++) { int multiRefIdx = MULTI_REF_LINE_IDX[mRefNum]; - pu.multiRefIdx = multiRefIdx; - initIntraPatternChType(cu, pu.Y(), true); + cu.multiRefIdx = multiRefIdx; + initIntraPatternChType(cu, cu.Y(), true); for (int x = 1; x < NUM_MOST_PROBABLE_MODES; x++) { - pu.intraDir[0] = multiRefMPM[x]; - initPredIntraParams(pu, pu.Y(), sps); + cu.intraDir[0] = multiRefMPM[x]; + initPredIntraParams(cu, cu.Y(), sps); distParam.cur.buf = piPred.buf = m_SortedPelUnitBufs->getTestBuf().Y().buf; - predIntraAng(COMP_Y, piPred, pu); + predIntraAng(COMP_Y, piPred, cu); // Use the min between SAD and SATD as the cost criterion // SAD is scaled by 2 to align with the scaling of HAD Distortion minSadHad = distParam.distFunc(distParam); // NB xFracModeBitsIntra will not affect the mode for chroma that may have already been pre-estimated. - uint64_t fracModeBits = xFracModeBitsIntraLuma( pu ); + uint64_t fracModeBits = xFracModeBitsIntraLuma( cu, mpmLst ); //restore ctx m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::IntraLumaMpmFlag(), intra_ctx_size), ctxStartIntraCtx); double cost = (double) minSadHad + (double) fracModeBits * sqrtLambdaForFirstPass; -// DTRACE(g_trace_ctx, D_INTRA_COST, "IntraMRL: %u, %llu, %f (%d)\n", minSadHad, fracModeBits, cost, pu.intraDir[0]); +// DTRACE(g_trace_ctx, D_INTRA_COST, "IntraMRL: %u, %llu, %f (%d)\n", minSadHad, fracModeBits, cost, cu.intraDir[0]); int insertPos = -1; - updateCandList( ModeInfo( false, false, multiRefIdx, NOT_INTRA_SUBPARTITIONS, pu.intraDir[0] ), cost, RdModeList, CandCostList, numModesForFullRD, &insertPos ); - updateCandList( ModeInfo( false, false, multiRefIdx, NOT_INTRA_SUBPARTITIONS, pu.intraDir[0] ), (double)minSadHad, HadModeList, CandHadList, numHadCand ); + updateCandList( ModeInfo( false, false, multiRefIdx, NOT_INTRA_SUBPARTITIONS, cu.intraDir[0] ), cost, RdModeList, CandCostList, numModesForFullRD, &insertPos ); + updateCandList( ModeInfo( false, false, multiRefIdx, NOT_INTRA_SUBPARTITIONS, cu.intraDir[0] ), (double)minSadHad, HadModeList, CandHadList, numHadCand ); m_SortedPelUnitBufs->insert(insertPos, (int)RdModeList.size()); } } - pu.multiRefIdx = 0; + cu.multiRefIdx = 0; } if (testMip) { cu.mipFlag = true; - pu.multiRefIdx = 0; + cu.multiRefIdx = 0; double mipHadCost[MAX_NUM_MIP_MODE] = { MAX_DOUBLE }; - initIntraPatternChType(cu, pu.Y()); - initIntraMip( pu ); + initIntraPatternChType(cu, cu.Y()); + initIntraMip( cu ); - const int transpOff = getNumModesMip( pu.Y() ); + const int transpOff = getNumModesMip( cu.Y() ); const int numModesFull = (transpOff << 1); for( uint32_t uiModeFull = 0; uiModeFull < numModesFull; uiModeFull++ ) { const bool isTransposed = (uiModeFull >= transpOff ? true : false); const uint32_t uiMode = (isTransposed ? uiModeFull - transpOff : uiModeFull); - pu.mipTransposedFlag = isTransposed; - pu.intraDir[CH_L] = uiMode; + cu.mipTransposedFlag = isTransposed; + cu.intraDir[CH_L] = uiMode; distParam.cur.buf = piPred.buf = m_SortedPelUnitBufs->getTestBuf().Y().buf; - predIntraMip(piPred, pu); + predIntraMip(piPred, cu); // Use the min between SAD and HAD as the cost criterion // SAD is scaled by 2 to align with the scaling of HAD Distortion minSadHad = distParam.distFunc(distParam); - uint64_t fracModeBits = xFracModeBitsIntraLuma( pu ); + uint64_t fracModeBits = xFracModeBitsIntraLuma( cu, mpmLst ); //restore ctx m_CABACEstimator->getCtx() = SubCtx(CtxSet(Ctx::IntraLumaMpmFlag(), intra_ctx_size), ctxStartIntraCtx); @@ -400,13 +406,13 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, DTRACE(g_trace_ctx, D_INTRA_COST, "IntraMIP: %u, %llu, %f (%d)\n", minSadHad, fracModeBits, cost, uiModeFull); int insertPos = -1; - updateCandList( ModeInfo( true, isTransposed, 0, NOT_INTRA_SUBPARTITIONS, pu.intraDir[0] ), cost, RdModeList, CandCostList, numModesForFullRD+1, &insertPos ); - updateCandList( ModeInfo( true, isTransposed, 0, NOT_INTRA_SUBPARTITIONS, pu.intraDir[0] ), 0.8*(double)minSadHad, HadModeList, CandHadList, numHadCand ); + updateCandList( ModeInfo( true, isTransposed, 0, NOT_INTRA_SUBPARTITIONS, cu.intraDir[0] ), cost, RdModeList, CandCostList, numModesForFullRD+1, &insertPos ); + updateCandList( ModeInfo( true, isTransposed, 0, NOT_INTRA_SUBPARTITIONS, cu.intraDir[0] ), 0.8*(double)minSadHad, HadModeList, CandHadList, numHadCand ); m_SortedPelUnitBufs->insert(insertPos, (int)RdModeList.size()); } - const double thresholdHadCost = 1.0 + 1.4 / sqrt((double)(pu.lwidth()*pu.lheight())); - xReduceHadCandList(RdModeList, CandCostList, *m_SortedPelUnitBufs, numModesForFullRD, thresholdHadCost, mipHadCost, pu, fastMip); + const double thresholdHadCost = 1.0 + 1.4 / sqrt((double)(cu.lwidth()*cu.lheight())); + xReduceHadCandList(RdModeList, CandCostList, *m_SortedPelUnitBufs, numModesForFullRD, thresholdHadCost, mipHadCost, cu, fastMip); } if( m_pcEncCfg->m_bFastUDIUseMPMEnabled ) @@ -414,9 +420,9 @@ void IntraSearch::xEstimateLumaRdModeList(int& numModesForFullRD, const int numMPMs = NUM_MOST_PROBABLE_MODES; unsigned intraMpms[numMPMs]; - pu.multiRefIdx = 0; + cu.multiRefIdx = 0; - const int numCand = PU::getIntraMPMs( pu, intraMpms ); + const int numCand = CU::getIntraMPMs( cu, intraMpms ); ModeInfo mostProbableMode(false, false, 0, NOT_INTRA_SUBPARTITIONS, 0); for( int j = 0; j < numCand; j++ ) @@ -447,16 +453,12 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, d //===== loop over partitions ===== const TempCtx ctxStart ( m_CtxCache, m_CABACEstimator->getCtx() ); - CHECK( !cu.pu, "CU has no PUs" ); // variables for saving fast intra modes scan results across multiple LFNST passes double costInterCU = xFindInterCUCost( cu ); - auto &pu = *cu.pu; bool validReturn = false; - CHECK(pu.cu != &cu, "PU is not contained in the CU"); - //===== determine set of modes to be tested (using prediction signal only) ===== int numModesAvailable = NUM_LUMA_MODE; // total number of Intra modes static_vector RdModeList; @@ -470,9 +472,29 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, d numModesForFullRD = numModesAvailable; #endif const SPS& sps = *cu.cs->sps; - const bool mipAllowed = sps.MIP && pu.lwidth() <= sps.getMaxTbSize() && pu.lheight() <= sps.getMaxTbSize() && ((cu.lfnstIdx == 0) || allowLfnstWithMip(cu.pu->lumaSize())); + const bool mipAllowed = sps.MIP && cu.lwidth() <= sps.getMaxTbSize() && cu.lheight() <= sps.getMaxTbSize() && ((cu.lfnstIdx == 0) || allowLfnstWithMip(cu.lumaSize())); const int SizeThr = 8>>std::max(0,m_pcEncCfg->m_useFastMIP-2); const bool testMip = mipAllowed && (cu.lwidth() <= (SizeThr * cu.lheight()) && cu.lheight() <= (SizeThr * cu.lwidth())) && (cu.lwidth() <= MIP_MAX_WIDTH && cu.lheight() <= MIP_MAX_HEIGHT); + bool testISP = sps.ISP && CU::canUseISP(width, height, cu.cs->sps->getMaxTbSize()); + if (testISP) + { + int numTotalPartsHor = (int)width >> floorLog2(CU::getISPSplitDim(width, height, TU_1D_VERT_SPLIT)); + int numTotalPartsVer = (int)height >> floorLog2(CU::getISPSplitDim(width, height, TU_1D_HORZ_SPLIT)); + m_ispTestedModes[0].init(numTotalPartsHor, numTotalPartsVer); + // the total number of subpartitions is modified to take into account the cases where LFNST cannot be combined with + // ISP due to size restrictions + numTotalPartsHor = sps.LFNST && CU::canUseLfnstWithISP(cu.Y(), HOR_INTRA_SUBPARTITIONS) ? numTotalPartsHor : 0; + numTotalPartsVer = sps.LFNST && CU::canUseLfnstWithISP(cu.Y(), VER_INTRA_SUBPARTITIONS) ? numTotalPartsVer : 0; + for (int j = 1; j < NUM_LFNST_NUM_PER_SET; j++) + { + m_ispTestedModes[j].init(numTotalPartsHor, numTotalPartsVer); + } + testISP = m_ispTestedModes[0].numTotalParts[0]; + } + else + { + m_ispTestedModes[0].init(0, 0); + } xEstimateLumaRdModeList(numModesForFullRD, RdModeList, HadModeList, CandCostList, CandHadList, cu, testMip); @@ -520,7 +542,7 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, d } //===== check modes (using r-d costs) ===== - ModeInfo uiBestPUMode; + ModeInfo bestPUMode; CodingStructure *csTemp = m_pTempCS[Log2(cu.lwidth())][Log2(cu.lheight())]; CodingStructure *csBest = m_pBestCS[Log2(cu.lwidth())][Log2(cu.lheight())]; @@ -530,84 +552,152 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, d csTemp->initStructData(); csBest->initStructData(); - int bestLfnstIdx = 0; + int bestLfnstIdx = 0; + int NumBDPCMCand = (cs.picture->useSC && sps.BDPCM && CU::bdpcmAllowed(cu, ComponentID(partitioner.chType))) ? 2 : 0; + int bestbdpcmMode = 0; + int bestISP = 0; + int bestMrl = 0; + bool bestMip = 0; + int EndMode = (int)RdModeList.size(); + bool useISPlfnst = testISP && sps.LFNST; + bool noLFNST_ts = false; + double bestCostIsp[2] = { MAX_DOUBLE, MAX_DOUBLE }; - for (int mode = 0; mode < (int)RdModeList.size(); mode++) + for (int mode_cur = 0; mode_cur < EndMode + NumBDPCMCand; mode_cur++) { + int mode = mode_cur; + if (mode_cur >= EndMode) + { + mode = mode_cur - EndMode ? -1 : -2; + testISP = false; + } // set CU/PU to luma prediction mode ModeInfo testMode; + int noISP = 0; + int endISP = testISP ? 2 : 0; + bool noLFNST = false || noLFNST_ts; + if (mode && useISPlfnst) { - testMode = RdModeList[mode]; - cu.bdpcmMode = 0; - cu.ispMode = testMode.ispMod; - cu.mipFlag = testMode.mipFlg; - pu.mipTransposedFlag = testMode.mipTrFlg; - pu.multiRefIdx = testMode.mRefId; - pu.intraDir[CH_L] = testMode.modeId; - - CHECK(cu.mipFlag && pu.multiRefIdx, "Error: combination of MIP and MRL not supported"); - CHECK(pu.multiRefIdx && (pu.intraDir[0] == PLANAR_IDX), "Error: combination of MRL and Planar mode not supported"); - CHECK(cu.ispMode && cu.mipFlag, "Error: combination of ISP and MIP not supported"); - CHECK(cu.ispMode && pu.multiRefIdx, "Error: combination of ISP and MRL not supported"); + noLFNST |= (bestCostIsp[0] > (bestCostIsp[1] * 1.4)); + if (mode > 2) + { + endISP = 0; + testISP = false; + } + } + if (testISP) + { + xSpeedUpISP(1, testISP, mode, noISP, endISP, cu, RdModeList, bestPUMode, bestISP, bestLfnstIdx); } - // determine residual for partition - cs.initSubStructure( *csTemp, partitioner.chType, cs.area, true ); - - xIntraCodingLumaQT(*csTemp, partitioner, m_SortedPelUnitBufs->getBufFromSortedList(mode), bestCost); + for (int ispM = 0; ispM <= endISP; ispM++) + { + if (ispM && (ispM == noISP)) + { + continue; + } - DTRACE(g_trace_ctx, D_INTRA_COST, "IntraCost T [x=%d,y=%d,w=%d,h=%d] %f (%d,%d,%d,%d,%d,%d) \n", cu.blocks[0].x, - cu.blocks[0].y, width, height, csTemp->cost, testMode.modeId, testMode.ispMod, - pu.multiRefIdx, cu.mipFlag, cu.lfnstIdx, cu.mtsFlag); + if (mode < 0) + { + cu.bdpcmM[CH_L] = -mode; + testMode = ModeInfo(false, false, 0, NOT_INTRA_SUBPARTITIONS, cu.bdpcmM[CH_L] == 2 ? VER_IDX : HOR_IDX); + } + else + { + testMode = RdModeList[mode]; + cu.bdpcmM[CH_L] = 0; + } + cu.ispMode = ispM; + cu.mipFlag = testMode.mipFlg; + cu.mipTransposedFlag = testMode.mipTrFlg; + cu.multiRefIdx = testMode.mRefId; + cu.intraDir[CH_L] = testMode.modeId; + if (cu.ispMode && xSpeedUpISP(0, testISP, mode, noISP, endISP, cu, RdModeList, bestPUMode, bestISP, 0) ) + { + continue; + } + CHECK(cu.mipFlag && cu.multiRefIdx, "Error: combination of MIP and MRL not supported"); + CHECK(cu.multiRefIdx && (cu.intraDir[0] == PLANAR_IDX), "Error: combination of MRL and Planar mode not supported"); + CHECK(cu.ispMode && cu.mipFlag, "Error: combination of ISP and MIP not supported"); + CHECK(cu.ispMode && cu.multiRefIdx, "Error: combination of ISP and MRL not supported"); - // check r-d cost - if( csTemp->cost < csBest->cost ) - { - validReturn = true; - std::swap( csTemp, csBest ); - uiBestPUMode = testMode; - bestLfnstIdx = csBest->cus[0]->lfnstIdx; - } + // determine residual for partition + cs.initSubStructure(*csTemp, partitioner.chType, cs.area, true); + int doISP = (((cu.ispMode == 0) && noLFNST) || (useISPlfnst && mode && cu.ispMode && (bestLfnstIdx == 0))) ?-mode :mode; + xIntraCodingLumaQT(*csTemp, partitioner, m_SortedPelUnitBufs->getBufFromSortedList(mode), bestCost, doISP); - // reset context models - m_CABACEstimator->getCtx() = ctxStart; + DTRACE(g_trace_ctx, D_INTRA_COST, "IntraCost T [x=%d,y=%d,w=%d,h=%d] %f (%d,%d,%d,%d,%d,%d) \n", cu.blocks[0].x, + cu.blocks[0].y, width, height, csTemp->cost, testMode.modeId, testMode.ispMod, + cu.multiRefIdx, cu.mipFlag, cu.lfnstIdx, cu.mtsFlag); - csTemp->releaseIntermediateData(); + if (cu.ispMode && !csTemp->cus[0]->firstTU->cbf[COMP_Y]) + { + csTemp->cost = MAX_DOUBLE; + csTemp->costDbOffset = 0; + } + if (useISPlfnst) + { + int n = (cu.ispMode == 0) ? 0 : 1; + bestCostIsp[n] = csTemp->cost < bestCostIsp[n] ? csTemp->cost : bestCostIsp[n]; + } - if( m_pcEncCfg->m_fastLocalDualTreeMode && cu.isConsIntra() && !cu.slice->isIntra() && csBest->cost != MAX_DOUBLE && costInterCU != COST_UNKNOWN && mode >= 0 ) - { - if( m_pcEncCfg->m_fastLocalDualTreeMode == 2 ) + // check r-d cost + if (csTemp->cost < csBest->cost) { - //Note: only try one intra mode, which is especially useful to reduce EncT for LDB case (around 4%) - break; + validReturn = true; + std::swap(csTemp, csBest); + bestPUMode = testMode; + bestLfnstIdx = csBest->cus[0]->lfnstIdx; + bestISP = csBest->cus[0]->ispMode; + bestMip = csBest->cus[0]->mipFlag; + bestMrl = csBest->cus[0]->multiRefIdx; + bestbdpcmMode = cu.bdpcmM[CH_L]; + m_ispTestedModes[bestLfnstIdx].bestSplitSoFar = ISPType(bestISP); + if (csBest->cost < bestCost) + { + bestCost = csBest->cost; + } + if ((csBest->getTU(partitioner.chType)->mtsIdx[COMP_Y] == MTS_SKIP) && ( floorLog2(csBest->getTU(partitioner.chType)->blocks[COMP_Y].area()) >= 6 )) + { + noLFNST_ts = 1; + } } - else + + // reset context models + m_CABACEstimator->getCtx() = ctxStart; + + csTemp->releaseIntermediateData(); + + if (m_pcEncCfg->m_fastLocalDualTreeMode && CU::isConsIntra(cu) && !cu.slice->isIntra() && csBest->cost != MAX_DOUBLE && costInterCU != COST_UNKNOWN && mode >= 0) { - if( csBest->cost > costInterCU * 1.5 ) + if( (m_pcEncCfg->m_fastLocalDualTreeMode == 2) || (csBest->cost > costInterCU * 1.5)) { + //Note: only try one intra mode, which is especially useful to reduce EncT for LDB case (around 4%) + EndMode = 0; break; } } } } // Mode loop - if( validReturn ) + cu.ispMode = bestISP; + if (validReturn) { - cs.useSubStructure( *csBest, partitioner.chType, TREE_D, pu.singleChan( CH_L ), true ); + cs.useSubStructure(*csBest, partitioner.chType, TREE_D, cu.singleChan(CH_L), true); const ReshapeData& reshapeData = cs.picture->reshapeData; - if( cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() ) + if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag()) { - cs.getRspRecoBuf().copyFrom( csBest->getRspRecoBuf()); + cs.getRspRecoBuf().copyFrom(csBest->getRspRecoBuf()); } //=== update PU data ==== cu.lfnstIdx = bestLfnstIdx; - cu.ispMode = uiBestPUMode.ispMod; - cu.mipFlag = uiBestPUMode.mipFlg; - pu.mipTransposedFlag = uiBestPUMode.mipTrFlg; - pu.multiRefIdx = uiBestPUMode.mRefId; - pu.intraDir[ CH_L ] = uiBestPUMode.modeId; + cu.mipTransposedFlag = bestPUMode.mipTrFlg; + cu.intraDir[CH_L] = bestPUMode.modeId; + cu.bdpcmM[CH_L] = bestbdpcmMode; + cu.mipFlag = bestMip; + cu.multiRefIdx = bestMrl; } else { @@ -619,17 +709,15 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, d return validReturn; } -void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner ) +void IntraSearch::estIntraPredChromaQT( CodingUnit& cu, Partitioner& partitioner, const double maxCostAllowed ) { PROFILER_SCOPE_AND_STAGE_EXT( 0, g_timeProfiler, P_INTRA_CHROMA, cu.cs, CH_C ); - const ChromaFormat format = cu.chromaFormat; - const uint32_t numberValidComponents = getNumberValidComponents(format); - CodingStructure &cs = *cu.cs; - const TempCtx ctxStart ( m_CtxCache, m_CABACEstimator->getCtx() ); - - cs.setDecomp( cs.area.Cb(), false ); - - auto &pu = *cu.pu; + const TempCtx ctxStart( m_CtxCache, m_CABACEstimator->getCtx() ); + CodingStructure &cs = *cu.cs; + bool lumaUsesISP = !CU::isSepTree(cu) && cu.ispMode; + PartSplit ispType = lumaUsesISP ? CU::getISPType(cu, COMP_Y) : TU_NO_ISP; + double bestCostSoFar = maxCostAllowed; + const uint32_t numberValidComponents = getNumberValidComponents( cu.chromaFormat ); uint32_t uiBestMode = 0; Distortion uiBestDist = 0; @@ -642,7 +730,7 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner //----- check chroma modes ----- uint32_t chromaCandModes[ NUM_CHROMA_MODE ]; - PU::getIntraChromaCandModes( pu, chromaCandModes ); + CU::getIntraChromaCandModes( cu, chromaCandModes ); // create a temporary CS CodingStructure &saveCS = *m_pSaveCS[0]; @@ -651,13 +739,12 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner saveCS.area.repositionTo( cs.area ); saveCS.clearTUs(); - if( !cu.isSepTree() && cu.ispMode ) - { - saveCS.clearCUs(); - saveCS.clearPUs(); - } + if( !CU::isSepTree(cu) && cu.ispMode ) + { + saveCS.clearCUs(); + } - if( cu.isSepTree() ) + if( CU::isSepTree(cu) ) { if( partitioner.canSplit( TU_MAX_TR_SPLIT, cs ) ) { @@ -674,13 +761,12 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner cs.addTU( CS::getArea( cs, partitioner.currArea(), partitioner.chType, partitioner.treeType ), partitioner.chType, &cu ); } - std::vector orgTUs; - // create a store for the TUs + std::vector orgTUs; for( const auto &ptu : cs.tus ) { // for split TUs in HEVC, add the TUs without Chroma parts for correct setting of Cbfs - if( /*lumaUsesISP ||*/ pu.contains( *ptu, CH_C ) ) + if (lumaUsesISP || cu.contains(*ptu, CH_C)) { saveCS.addTU( *ptu, partitioner.chType, nullptr ); orgTUs.push_back( ptu ); @@ -692,30 +778,30 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner int64_t satdSortedCost[NUM_CHROMA_MODE] = { 0 }; bool modeDisable[NUM_INTRA_MODE + 1] = { false }; // use intra mode idx to check whether enable - CodingStructure& cs = *(pu.cs); - CompArea areaCb = pu.Cb(); - CompArea areaCr = pu.Cr(); + CodingStructure& cs = *(cu.cs); + CompArea areaCb = cu.Cb(); + CompArea areaCr = cu.Cr(); CPelBuf orgCb = cs.getOrgBuf (COMP_Cb); PelBuf predCb = cs.getPredBuf(COMP_Cb); CPelBuf orgCr = cs.getOrgBuf (COMP_Cr); PelBuf predCr = cs.getPredBuf(COMP_Cr); - DistParam distParamSadCb = m_pcRdCost->setDistParam( orgCb, predCb, pu.cs->sps->bitDepths[ CH_C ], DF_SAD); - DistParam distParamSatdCb = m_pcRdCost->setDistParam( orgCb, predCb, pu.cs->sps->bitDepths[ CH_C ], DF_HAD); - DistParam distParamSadCr = m_pcRdCost->setDistParam( orgCr, predCr, pu.cs->sps->bitDepths[ CH_C ], DF_SAD); - DistParam distParamSatdCr = m_pcRdCost->setDistParam( orgCr, predCr, pu.cs->sps->bitDepths[ CH_C ], DF_HAD); + DistParam distParamSadCb = m_pcRdCost->setDistParam( orgCb, predCb, cu.cs->sps->bitDepths[ CH_C ], DF_SAD); + DistParam distParamSatdCb = m_pcRdCost->setDistParam( orgCb, predCb, cu.cs->sps->bitDepths[ CH_C ], DF_HAD); + DistParam distParamSadCr = m_pcRdCost->setDistParam( orgCr, predCr, cu.cs->sps->bitDepths[ CH_C ], DF_SAD); + DistParam distParamSatdCr = m_pcRdCost->setDistParam( orgCr, predCr, cu.cs->sps->bitDepths[ CH_C ], DF_HAD); - pu.intraDir[1] = MDLM_L_IDX; // temporary assigned, just to indicate this is a MDLM mode. for luma down-sampling operation. + cu.intraDir[1] = MDLM_L_IDX; // temporary assigned, just to indicate this is a MDLM mode. for luma down-sampling operation. - initIntraPatternChType(cu, pu.Cb()); - initIntraPatternChType(cu, pu.Cr()); - loadLMLumaRecPels(pu, pu.Cb()); + initIntraPatternChType(cu, cu.Cb()); + initIntraPatternChType(cu, cu.Cr()); + loadLMLumaRecPels(cu, cu.Cb()); for (int idx = uiMinMode; idx < uiMaxMode; idx++) { int mode = chromaCandModes[idx]; satdModeList[idx] = mode; - if (PU::isLMCMode(mode) && !PU::isLMCModeEnabled(pu, mode)) + if (CU::isLMCMode(mode) && !CU::isLMCModeEnabled(cu, mode)) { continue; } @@ -724,17 +810,17 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner continue; } - pu.intraDir[1] = mode; // temporary assigned, for SATD checking. + cu.intraDir[1] = mode; // temporary assigned, for SATD checking. - const bool isLMCMode = PU::isLMCMode(mode); + const bool isLMCMode = CU::isLMCMode(mode); if( isLMCMode ) { - predIntraChromaLM(COMP_Cb, predCb, pu, areaCb, mode); + predIntraChromaLM(COMP_Cb, predCb, cu, areaCb, mode); } else { - initPredIntraParams(pu, pu.Cb(), *cs.sps); - predIntraAng(COMP_Cb, predCb, pu); + initPredIntraParams(cu, cu.Cb(), *cs.sps); + predIntraAng(COMP_Cb, predCb, cu); } int64_t sadCb = distParamSadCb.distFunc(distParamSadCb) * 2; int64_t satdCb = distParamSatdCb.distFunc(distParamSatdCb); @@ -742,12 +828,12 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner if( isLMCMode ) { - predIntraChromaLM(COMP_Cr, predCr, pu, areaCr, mode); + predIntraChromaLM(COMP_Cr, predCr, cu, areaCr, mode); } else { - initPredIntraParams(pu, pu.Cr(), *cs.sps); - predIntraAng(COMP_Cr, predCr, pu); + initPredIntraParams(cu, cu.Cr(), *cs.sps); + predIntraAng(COMP_Cr, predCr, cu); } int64_t sadCr = distParamSadCr.distFunc(distParamSadCr) * 2; int64_t satdCr = distParamSatdCr.distFunc(distParamSatdCr); @@ -777,33 +863,60 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner int bestLfnstIdx = 0; // save the dist Distortion baseDist = cs.dist; + int32_t bestbdpcmMode = 0; + uint32_t numbdpcmModes = (cs.picture->useSC && CU::bdpcmAllowed(cu, COMP_Cb) && + ((partitioner.chType == CH_C) || (cu.ispMode == 0 && cu.lfnstIdx == 0 && cu.firstTU->mtsIdx[COMP_Y] == MTS_SKIP) )) ? 2 : 0; - for (uint32_t uiMode = uiMinMode; uiMode < uiMaxMode; uiMode++) + for (int mode_cur = uiMinMode; mode_cur < (int)(uiMaxMode + numbdpcmModes); mode_cur++) { - const int chromaIntraMode = chromaCandModes[uiMode]; - if( PU::isLMCMode( chromaIntraMode ) && ! PU::isLMCModeEnabled( pu, chromaIntraMode ) ) + int mode = mode_cur; + if (mode_cur >= uiMaxMode) { - continue; + mode = mode_cur > uiMaxMode ? -1 : -2; //set bdpcm mode + if ((mode == -1) && (saveCS.tus[0]->mtsIdx[COMP_Cb] != MTS_SKIP) && (saveCS.tus[0]->mtsIdx[COMP_Cr] != MTS_SKIP)) + { + continue; + } } - if( modeDisable[chromaIntraMode] && PU::isLMCModeEnabled(pu, chromaIntraMode)) // when CCLM is disable, then MDLM is disable. not use satd checking + int chromaIntraMode; + if (mode < 0) { - continue; + cu.bdpcmM[CH_C] = -mode; + chromaIntraMode = cu.bdpcmM[CH_C] == 2 ? chromaCandModes[1] : chromaCandModes[2]; + } + else + { + cu.bdpcmM[CH_C] = 0; + chromaIntraMode = chromaCandModes[mode]; + if (CU::isLMCMode(chromaIntraMode) && !CU::isLMCModeEnabled(cu, chromaIntraMode)) + { + continue; + } + if (modeDisable[chromaIntraMode] && CU::isLMCModeEnabled(cu, chromaIntraMode)) // when CCLM is disable, then MDLM is disable. not use satd checking + { + continue; + } } - cs.setDecomp( pu.Cb(), false ); cs.dist = baseDist; //----- restore context models ----- m_CABACEstimator->getCtx() = ctxStart; //----- chroma coding ----- - pu.intraDir[1] = chromaIntraMode; - + cu.intraDir[1] = chromaIntraMode; + m_ispTestedModes[0].IspType = ispType; + m_ispTestedModes[0].subTuCounter = -1; xIntraChromaCodingQT( cs, partitioner ); + if (lumaUsesISP && cs.dist == MAX_UINT) + { + continue; + } if (cs.sps->transformSkip) { m_CABACEstimator->getCtx() = ctxStart; } - + m_ispTestedModes[0].IspType = ispType; + m_ispTestedModes[0].subTuCounter = -1; uint64_t fracBits = xGetIntraFracBitsQT( cs, partitioner, false ); Distortion uiDist = cs.dist; double dCost = m_pcRdCost->calcRdCost( fracBits, uiDist - baseDist ); @@ -811,9 +924,13 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner //----- compare ----- if( dCost < dBestCost ) { + if (lumaUsesISP && (dCost < bestCostSoFar)) + { + bestCostSoFar = dCost; + } for( uint32_t i = getFirstComponentOfChannel( CH_C ); i < numberValidComponents; i++ ) { - const CompArea& area = pu.blocks[i]; + const CompArea& area = cu.blocks[i]; saveCS.getRecoBuf ( area ).copyFrom( cs.getRecoBuf ( area ) ); cs.picture->getRecoBuf( area ).copyFrom( cs.getRecoBuf ( area ) ); for( uint32_t j = 0; j < saveCS.tus.size(); j++ ) @@ -825,13 +942,16 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner uiBestDist = uiDist; uiBestMode = chromaIntraMode; bestLfnstIdx = cu.lfnstIdx; + bestbdpcmMode = cu.bdpcmM[CH_C]; + } } cu.lfnstIdx = bestLfnstIdx; + cu.bdpcmM[CH_C]= bestbdpcmMode; for( uint32_t i = getFirstComponentOfChannel( CH_C ); i < numberValidComponents; i++ ) { - const CompArea& area = pu.blocks[i]; + const CompArea& area = cu.blocks[i]; cs.getRecoBuf ( area ).copyFrom( saveCS.getRecoBuf( area ) ); cs.picture->getRecoBuf( area ).copyFrom( cs.getRecoBuf ( area ) ); @@ -842,12 +962,15 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner } } } - - pu.intraDir[1] = uiBestMode; + cu.intraDir[1] = uiBestMode; cs.dist = uiBestDist; //----- restore context models ----- m_CABACEstimator->getCtx() = ctxStart; + if (lumaUsesISP && bestCostSoFar >= maxCostAllowed) + { + cu.ispMode = 0; + } } void IntraSearch::saveCuAreaCostInSCIPU( Area area, double cost ) @@ -879,7 +1002,7 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner if (luma) { - bool isFirst = partitioner.currArea().lumaPos() == cs.area.lumaPos(); + bool isFirst = cu.ispMode ? m_ispTestedModes[0].subTuCounter == 0 : partitioner.currArea().lumaPos() == cs.area.lumaPos(); // CU header if( isFirst ) @@ -898,7 +1021,7 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner { m_CABACEstimator->pred_mode( cu ); } - m_CABACEstimator->intra_luma_pred_mode( *cu.pu ); + m_CABACEstimator->intra_luma_pred_mode( cu ); } } else // if (chroma) @@ -907,7 +1030,8 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner if( isFirst ) { - m_CABACEstimator->intra_chroma_pred_mode( *cu.pu ); + m_CABACEstimator->bdpcm_mode(cu, ComponentID(CH_C)); + m_CABACEstimator->intra_chroma_pred_mode( cu ); } } } @@ -915,44 +1039,97 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner void IntraSearch::xEncSubdivCbfQT( CodingStructure &cs, Partitioner &partitioner, const bool luma ) { const UnitArea& currArea = partitioner.currArea(); - TransformUnit &currTU = *cs.getTU( currArea.blocks[partitioner.chType], partitioner.chType ); + int subTuCounter = m_ispTestedModes[0].subTuCounter; + TransformUnit &currTU = *cs.getTU(currArea.blocks[partitioner.chType], partitioner.chType, subTuCounter); CodingUnit &currCU = *currTU.cu; const uint32_t currDepth = partitioner.currTrDepth; + const bool subdiv = currTU.depth > currDepth; + ComponentID compID = partitioner.chType == CH_L ? COMP_Y : COMP_Cb; - - //===== Cbfs ===== - if (luma) + if (!luma) { - bool previousCbf = false; - bool lastCbfIsInferred = false; - if( !lastCbfIsInferred ) + const bool chromaCbfISP = currArea.blocks[COMP_Cb].valid() && currCU.ispMode && !subdiv; + if (!currCU.ispMode || chromaCbfISP) { - m_CABACEstimator->cbf_comp( currCU, TU::getCbfAtDepth( currTU, COMP_Y, currDepth ), currTU.Y(), currTU.depth, previousCbf, currCU.ispMode ); + const uint32_t numberValidComponents = getNumberValidComponents(currArea.chromaFormat); + const uint32_t cbfDepth = (chromaCbfISP ? currDepth - 1 : currDepth); + + for (uint32_t ch = COMP_Cb; ch < numberValidComponents; ch++) + { + const ComponentID compID = ComponentID(ch); + if (currDepth == 0 || TU::getCbfAtDepth(currTU, compID, currDepth - 1) || chromaCbfISP) + { + const bool prevCbf = (compID == COMP_Cr ? TU::getCbfAtDepth(currTU, COMP_Cb, currDepth) : false); + m_CABACEstimator->cbf_comp(currCU, TU::getCbfAtDepth(currTU, compID, currDepth), currArea.blocks[compID], cbfDepth, prevCbf); + } + } } } - else //if( chroma ) + + if (subdiv) { - const uint32_t numberValidComponents = getNumberValidComponents(currArea.chromaFormat); - const uint32_t cbfDepth = currDepth; + if (partitioner.canSplit(TU_MAX_TR_SPLIT, cs)) + { + partitioner.splitCurrArea(TU_MAX_TR_SPLIT, cs); + } + else if (currCU.ispMode && isLuma(compID)) + { + partitioner.splitCurrArea(m_ispTestedModes[0].IspType, cs); + } + else + THROW("Cannot perform an implicit split!"); - for (uint32_t ch = COMP_Cb; ch < numberValidComponents; ch++) + do { - const ComponentID compID = ComponentID(ch); + xEncSubdivCbfQT(cs, partitioner, luma); //? + subTuCounter += subTuCounter != -1 ? 1 : 0; + } while (partitioner.nextPart(cs)); - if( currDepth == 0 || TU::getCbfAtDepth( currTU, compID, currDepth - 1 ) ) + partitioner.exitCurrSplit(); + } + else + { + //===== Cbfs ===== + if (luma) + { + bool previousCbf = false; + bool lastCbfIsInferred = false; + if (m_ispTestedModes[0].IspType != TU_NO_ISP) + { + bool rootCbfSoFar = false; + uint32_t nTus = currCU.ispMode == HOR_INTRA_SUBPARTITIONS ? currCU.lheight() >> floorLog2(currTU.lheight()) + : currCU.lwidth() >> floorLog2(currTU.lwidth()); + if (subTuCounter == nTus - 1) + { + TransformUnit* tuPointer = currCU.firstTU; + for (int tuIdx = 0; tuIdx < nTus - 1; tuIdx++) + { + rootCbfSoFar |= TU::getCbfAtDepth(*tuPointer, COMP_Y, currDepth); + tuPointer = tuPointer->next; + } + if (!rootCbfSoFar) + { + lastCbfIsInferred = true; + } + } + if (!lastCbfIsInferred) + { + previousCbf = TU::getPrevTuCbfAtDepth(currTU, COMP_Y, partitioner.currTrDepth); + } + } + if (!lastCbfIsInferred) { - const bool prevCbf = ( compID == COMP_Cr ? TU::getCbfAtDepth( currTU, COMP_Cb, currDepth ) : false ); - m_CABACEstimator->cbf_comp( currCU, TU::getCbfAtDepth( currTU, compID, currDepth ), currArea.blocks[compID], cbfDepth, prevCbf ); + m_CABACEstimator->cbf_comp(currCU, TU::getCbfAtDepth(currTU, COMP_Y, currDepth), currTU.Y(), currTU.depth, previousCbf, currCU.ispMode); } } } } - -void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, const ComponentID compID, CUCtx *cuCtx ) +void IntraSearch::xEncCoeffQT(CodingStructure& cs, Partitioner& partitioner, const ComponentID compID, CUCtx* cuCtx, const int subTuIdx, const PartSplit ispType) { const UnitArea& currArea = partitioner.currArea(); - TransformUnit& currTU = *cs.getTU( currArea.blocks[partitioner.chType], partitioner.chType ); + int subTuCounter = m_ispTestedModes[0].subTuCounter; + TransformUnit& currTU = *cs.getTU(currArea.blocks[partitioner.chType], partitioner.chType, subTuCounter); uint32_t currDepth = partitioner.currTrDepth; const bool subdiv = currTU.depth > currDepth; @@ -962,12 +1139,17 @@ void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, co { partitioner.splitCurrArea(TU_MAX_TR_SPLIT, cs); } + else if (currTU.cu->ispMode) + { + partitioner.splitCurrArea(m_ispTestedModes[0].IspType, cs); + } else THROW("Implicit TU split not available!"); do { - xEncCoeffQT( cs, partitioner, compID ); + xEncCoeffQT(cs, partitioner, compID, cuCtx, subTuCounter, m_ispTestedModes[0].IspType); + subTuCounter += subTuCounter != -1 ? 1 : 0; } while( partitioner.nextPart( cs ) ); partitioner.exitCurrSplit(); @@ -1006,7 +1188,10 @@ uint64_t IntraSearch::xGetIntraFracBitsQT( CodingStructure &cs, Partitioner &par xEncCoeffQT( cs, partitioner, COMP_Y, cuCtx ); CodingUnit &cu = *cs.cus[0]; - if( cuCtx ) + if (cuCtx /*&& CU::isSepTree(cu)*/ + && (!cu.ispMode || (cu.lfnstIdx && m_ispTestedModes[0].subTuCounter == 0) + || (!cu.lfnstIdx + && m_ispTestedModes[0].subTuCounter == m_ispTestedModes[cu.lfnstIdx].numTotalParts[cu.ispMode - 1] - 1))) { m_CABACEstimator->residual_lfnst_mode( cu, *cuCtx ); } @@ -1075,12 +1260,12 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI const ChannelType chType = toChannelType(compID); const int bitDepth = sps.bitDepths[chType]; - CPelBuf piOrg = cs.getOrgBuf (compID); - PelBuf piPred = cs.getPredBuf (compID); - PelBuf piResi = cs.getResiBuf (compID); - PelBuf piReco = cs.getRecoBuf (compID); + CPelBuf piOrg = cs.getOrgBuf (area); + PelBuf piPred = cs.getPredBuf (area); + PelBuf piResi = cs.getResiBuf (area); + PelBuf piReco = cs.getRecoBuf (area); - const PredictionUnit &pu = *cs.getPU(area.pos(), chType); + const CodingUnit& cu = *tu.cu; //===== init availability pattern ===== CHECK( tu.jointCbCr && compID == COMP_Cr, "wrong combination of compID and jointCbCr" ); @@ -1088,9 +1273,24 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI if ( isLuma(compID) ) { - bool predRegDiffFromTB = CU::isPredRegDiffFromTB(*tu.cu, compID); - bool firstTBInPredReg = CU::isFirstTBInPredReg(*tu.cu, compID, area); + bool predRegDiffFromTB = CU::isPredRegDiffFromTB(*tu.cu ); + bool firstTBInPredReg = false; CompArea areaPredReg(COMP_Y, tu.chromaFormat, area); + if (tu.cu->ispMode ) + { + firstTBInPredReg = CU::isFirstTBInPredReg(*tu.cu, area); + if (predRegDiffFromTB) + { + if (firstTBInPredReg) + { + CU::adjustPredArea(areaPredReg); + initIntraPatternChTypeISP(*tu.cu, areaPredReg, piReco); + } + } + else + initIntraPatternChTypeISP(*tu.cu, area, piReco); + } + else { initIntraPatternChType(*tu.cu, area); } @@ -1101,7 +1301,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI if (firstTBInPredReg) { PelBuf piPredReg = cs.getPredBuf(areaPredReg); - predIntraAng(compID, piPredReg, pu); + predIntraAng(compID, piPredReg, cu); } } else @@ -1110,18 +1310,18 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI { piPred.copyFrom( predBuf->Y() ); } - else if( PU::isMIP( pu, CH_L ) ) + else if( CU::isMIP( cu, CH_L ) ) { - initIntraMip( pu ); - predIntraMip( piPred, pu ); + initIntraMip( cu ); + predIntraMip( piPred, cu ); } else { - predIntraAng(compID, piPred, pu); + predIntraAng(compID, piPred, cu); } } } - DTRACE( g_trace_ctx, D_PRED, "@(%4d,%4d) [%2dx%2d] IMode=%d\n", tu.lx(), tu.ly(), tu.lwidth(), tu.lheight(), PU::getFinalIntraMode(pu, chType) ); + DTRACE( g_trace_ctx, D_PRED, "@(%4d,%4d) [%2dx%2d] IMode=%d\n", tu.lx(), tu.ly(), tu.lwidth(), tu.lheight(), CU::getFinalIntraMode(cu, chType) ); const Slice &slice = *cs.slice; bool flag = cs.picHeader->lmcsEnabled && (slice.isIntra() || (!slice.isIntra() && reshapeData.getCTUFlag())); @@ -1130,7 +1330,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI //===== get residual signal ===== if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag() ) { - piResi.subtract( cs.getRspOrgBuf(), piPred); + piResi.subtract(cs.getRspOrgBuf(area), piPred); } else { @@ -1176,7 +1376,12 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI m_pcTrQuant->transformNxN(tu, compID, cQP, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); DTRACE( g_trace_ctx, D_TU_ABS_SUM, "%d: comp=%d, abssum=%d\n", DTRACE_GET_COUNTER( g_trace_ctx, D_TU_ABS_SUM ), compID, uiAbsSum ); - + if (tu.cu->ispMode && isLuma(compID) && CU::isISPLast(*tu.cu, area, area.compID) && CU::allLumaCBFsAreZero(*tu.cu)) + { + // ISP has to have at least one non-zero CBF + ruiDist = MAX_INT; + return; + } //--- inverse transform --- if (uiAbsSum > 0) { @@ -1254,7 +1459,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI const CPelBuf orgLuma = cs.getOrgBuf( cs.area.blocks[COMP_Y] ); if( compID == COMP_Y && !m_pcEncCfg->m_lumaLevelToDeltaQPEnabled ) { - PelBuf tmpRecLuma = cs.getRspRecoBuf(); + PelBuf tmpRecLuma = cs.getRspRecoBuf(area); tmpRecLuma.rspSignal( piReco, reshapeData.getInvLUT()); ruiDist += m_pcRdCost->getDistPart(piOrg, tmpRecLuma, sps.bitDepths[toChannelType(compID)], compID, DF_SSE_WTD, &orgLuma); } @@ -1277,53 +1482,77 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID compI } } -void IntraSearch::xIntraCodingLumaQT( CodingStructure& cs, Partitioner& partitioner, PelUnitBuf* predBuf, const double bestCostSoFar ) +void IntraSearch::xIntraCodingLumaQT(CodingStructure& cs, Partitioner& partitioner, PelUnitBuf* predBuf, const double bestCostSoFar, int numMode) { PROFILER_SCOPE_AND_STAGE_EXT( 0, g_timeProfiler, P_INTRA_RD_SEARCH_LUMA, &cs, partitioner.chType ); const UnitArea& currArea = partitioner.currArea(); uint32_t currDepth = partitioner.currTrDepth; - - TransformUnit& tu = cs.addTU( CS::getArea( cs, currArea, partitioner.chType, partitioner.treeType ), partitioner.chType, cs.cus[0] ); - tu.depth = currDepth; - - CHECK( !tu.Y().valid(), "Invalid TU" ); - Distortion singleDistLuma = 0; uint32_t numSig = 0; const SPS &sps = *cs.sps; CodingUnit &cu = *cs.cus[0]; - bool mtsAllowed = CU::isMTSAllowed(cu, COMP_Y); - uint64_t singleFracBits = 0; - int endLfnstIdx = (partitioner.isSepTree(cs) && partitioner.chType == CH_C && (currArea.lwidth() < 8 || currArea.lheight() < 8)) - || (currArea.lwidth() > sps.getMaxTbSize() || currArea.lheight() > sps.getMaxTbSize()) || !sps.LFNST ? 0 : 2; - - if (cu.mipFlag && !allowLfnstWithMip(cu.pu->lumaSize())) + bool mtsAllowed = CU::isMTSAllowed(cu, COMP_Y); + uint64_t singleFracBits = 0; + bool splitCbfLumaSum = false; + double bestCostForISP = bestCostSoFar; + double dSingleCost = MAX_DOUBLE; + int endLfnstIdx = (partitioner.isSepTree(cs) && partitioner.chType == CH_C && (currArea.lwidth() < 8 || currArea.lheight() < 8)) + || (currArea.lwidth() > sps.getMaxTbSize() || currArea.lheight() > sps.getMaxTbSize()) || !sps.LFNST || (numMode < 0) ? 0 : 2; + numMode = (numMode < 0) ? -numMode : numMode; + + if (cu.mipFlag && !allowLfnstWithMip(cu.lumaSize())) { endLfnstIdx = 0; } int bestMTS = 0; - int EndMTS = mtsAllowed ? m_pcEncCfg->m_MTSIntraMaxCand +1 : 0; + int EndMTS = mtsAllowed ? m_pcEncCfg->m_MTSIntraMaxCand +1 : 0; + if (cu.ispMode && (EndMTS || endLfnstIdx)) + { + EndMTS = 0; + if ((m_ispTestedModes[1].numTotalParts[cu.ispMode - 1] == 0) + && (m_ispTestedModes[2].numTotalParts[cu.ispMode - 1] == 0)) + { + endLfnstIdx = 0; + } + } + if (cu.bdpcmM[CH_L]) + { + endLfnstIdx = 0; + EndMTS = 0; + } + bool checkTransformSkip = sps.transformSkip; + + SizeType transformSkipMaxSize = 1 << sps.log2MaxTransformSkipBlockSize; + //bool tsAllowed = TU::isTSAllowed(tu, COMP_Y); + bool tsAllowed = cu.cs->sps->transformSkip && (!cu.ispMode) && (!cu.bdpcmM[CH_L]) &&(!cu.sbtInfo); + tsAllowed &= cu.blocks[COMP_Y].width <= transformSkipMaxSize && cu.blocks[COMP_Y].height <= transformSkipMaxSize; + tsAllowed &= cs.picture->useSC; + if (tsAllowed) + { + EndMTS += 1; + } if (endLfnstIdx || EndMTS) { + bool splitCbfLuma = false; + const PartSplit ispType = CU::getISPType(cu, COMP_Y); CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; cs.cost = 0.0; - - double dSingleCost = MAX_DOUBLE; Distortion singleDistTmpLuma = 0; uint64_t singleTmpFracBits = 0; double singleCostTmp = 0; - const TempCtx ctxStart(m_CtxCache, m_CABACEstimator->getCtx()); - TempCtx ctxBest(m_CtxCache); - CodingStructure &saveCS = *m_pSaveCS[0]; - TransformUnit * tmpTU = nullptr; - int bestLfnstIdx = 0; - int startLfnstIdx = 0; + const TempCtx ctxStart (m_CtxCache, m_CABACEstimator->getCtx()); + TempCtx ctxBest (m_CtxCache); + CodingStructure &saveCS = *m_pSaveCS[0]; + TransformUnit * tmpTU = nullptr; + int bestLfnstIdx = 0; + int startLfnstIdx = 0; // speedUps LFNST - bool rapidLFNST = false; - bool rapidDCT = false; - double thresholdDCT = 1; + bool rapidLFNST = false; + bool rapidDCT = false; + double thresholdDCT = 1; + if (m_pcEncCfg->m_MTS == 2) { thresholdDCT += 1.4 / sqrt(cu.lwidth() * cu.lheight()); @@ -1332,37 +1561,68 @@ void IntraSearch::xIntraCodingLumaQT( CodingStructure& cs, Partitioner& partitio if (m_pcEncCfg->m_LFNST > 1) { rapidLFNST = true; + if (m_pcEncCfg->m_LFNST > 2) { - rapidDCT = true; + rapidDCT = true; endLfnstIdx = endLfnstIdx ? 1 : 0; } } - saveCS.pcv = cs.pcv; - saveCS.picture = cs.picture; - saveCS.area.repositionTo(cs.area); + saveCS.pcv = cs.pcv; + saveCS.picture = cs.picture; + saveCS.area.repositionTo( cs.area); saveCS.clearTUs(); - tmpTU = &saveCS.addTU( currArea, partitioner.chType, cs.cus[0] ); - std::vector trModes; - trModes.push_back(TrMode(0, true)); - double dct2Cost = MAX_DOUBLE; - double trGrpStopThreshold = 1.001; + if (cu.ispMode) + { + partitioner.splitCurrArea(ispType, cs); + } + + TransformUnit& tu = cs.addTU(CS::getArea(cs, partitioner.currArea(), partitioner.chType, partitioner.treeType), partitioner.chType, cs.cus[0]); + + if (cu.ispMode) + { + do + { + saveCS.addTU( + CS::getArea(cs, partitioner.currArea(), partitioner.chType, partitioner.treeType), + partitioner.chType, cs.cus[0]); + } while (partitioner.nextPart(cs)); + + partitioner.exitCurrSplit(); + } + else + { + tmpTU = &saveCS.addTU(currArea, partitioner.chType, cs.cus[0]); + } + + + std::vector trModes{ TrMode(0, true) }; + if (tsAllowed) + { + trModes.push_back(TrMode(1, true)); + } + double dct2Cost = MAX_DOUBLE; + double trGrpStopThreshold = 1.001; double trGrpBestCost = MAX_DOUBLE; + if (mtsAllowed) { - if (m_pcEncCfg->m_LFNST ) + if (m_pcEncCfg->m_LFNST) { - uint32_t uiIntraMode = cs.pus[0]->intraDir[partitioner.chType]; - int MTScur = (uiIntraMode < 34) ? MTS_DST7_DCT8 : MTS_DCT8_DST7; - trModes.push_back(TrMode(2, true)); + uint32_t uiIntraMode = cs.cus[0]->intraDir[partitioner.chType]; + int MTScur = (uiIntraMode < 34) ? MTS_DST7_DCT8 : MTS_DCT8_DST7; + + trModes.push_back(TrMode( 2, true)); trModes.push_back(TrMode(MTScur, true)); + MTScur = (uiIntraMode < 34) ? MTS_DCT8_DST7 : MTS_DST7_DCT8; - trModes.push_back(TrMode(MTScur, true)); + + trModes.push_back(TrMode(MTScur, true)); trModes.push_back(TrMode(MTS_DST7_DST7 + 3, true)); } - else + else { for (int i = 2; i < 6; i++) { @@ -1370,595 +1630,955 @@ void IntraSearch::xIntraCodingLumaQT( CodingStructure& cs, Partitioner& partitio } } } - if (EndMTS && !m_pcEncCfg->m_LFNST) + + if ((EndMTS && !m_pcEncCfg->m_LFNST) || (tsAllowed && !mtsAllowed)) { xPreCheckMTS(tu, &trModes, m_pcEncCfg->m_MTSIntraMaxCand, predBuf); + if (!mtsAllowed && !trModes[1].second) + { + EndMTS = 0; + } } + bool NStopMTS = true; - for (int modeId = 0; (modeId <= EndMTS)&&NStopMTS; modeId++) + + for (int modeId = 0; modeId <= EndMTS && NStopMTS; modeId++) { if (modeId > 1) { trGrpBestCost = MAX_DOUBLE; } - for (int lfnstIdx = startLfnstIdx; lfnstIdx <= endLfnstIdx; lfnstIdx++) - { - if (lfnstIdx && modeId) - { - continue; - } - if (mtsAllowed) + for (int lfnstIdx = startLfnstIdx; lfnstIdx <= endLfnstIdx; lfnstIdx++) { - if (!m_pcEncCfg->m_LFNST && !trModes[modeId].second) + if (lfnstIdx && modeId) { continue; } - tu.mtsIdx[COMP_Y] = trModes[modeId].first; - } - cu.lfnstIdx = lfnstIdx; - cuCtx.lfnstLastScanPos = false; - cuCtx.violatesLfnstConstrained[CH_L] = false; - cuCtx.violatesLfnstConstrained[CH_C] = false; + if (mtsAllowed || tsAllowed) + { + if (m_pcEncCfg->m_TS && bestMTS == MTS_SKIP) + { + break; + } + if (!m_pcEncCfg->m_LFNST && !trModes[modeId].second && mtsAllowed) + { + continue; + } - if ((lfnstIdx != startLfnstIdx) || (modeId)) - { - m_CABACEstimator->getCtx() = ctxStart; - } - singleDistTmpLuma = 0; - bool TrLoad = (EndMTS && !m_pcEncCfg->m_LFNST) ? true : false; - xIntraCodingTUBlock(tu, COMP_Y, false, singleDistTmpLuma, &numSig, predBuf, TrLoad); + tu.mtsIdx[COMP_Y] = trModes[modeId].first; + } - cuCtx.mtsLastScanPos = false; - //----- determine rate and r-d cost ----- - singleTmpFracBits = xGetIntraFracBitsQT(cs, partitioner, true, &cuCtx); - if (tu.mtsIdx[COMP_Y] > MTS_SKIP) - { - if (!cuCtx.mtsLastScanPos) + if (cu.ispMode && lfnstIdx) { - singleCostTmp = MAX_DOUBLE; + if (m_ispTestedModes[lfnstIdx].numTotalParts[cu.ispMode - 1] == 0) + { + if (lfnstIdx == 2) + { + endLfnstIdx = 1; + } + continue; + } } - else + + cu.lfnstIdx = lfnstIdx; + cuCtx.lfnstLastScanPos = false; + cuCtx.violatesLfnstConstrained[CH_L] = false; + cuCtx.violatesLfnstConstrained[CH_C] = false; + + if ((lfnstIdx != startLfnstIdx) || (modeId)) { - singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); + m_CABACEstimator->getCtx() = ctxStart; } - } - else - { - singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); - } - if (((EndMTS && (m_pcEncCfg->m_MTS == 2)) || rapidLFNST) && (modeId == 0) && (lfnstIdx == 0)) - { - if (singleCostTmp > bestCostSoFar * thresholdDCT) + + singleDistTmpLuma = 0; + + if (cu.ispMode) { - EndMTS = 0; - if (rapidDCT) + splitCbfLuma = false; + + partitioner.splitCurrArea(ispType, cs); + + singleCostTmp = xTestISP(cs, partitioner, bestCostForISP, ispType, splitCbfLuma, singleTmpFracBits, singleDistTmpLuma, cuCtx); + + partitioner.exitCurrSplit(); + + if (modeId && (singleCostTmp == MAX_DOUBLE)) { - endLfnstIdx = 0; // break the loop but do not cpy best + m_ispTestedModes[lfnstIdx].numTotalParts[cu.ispMode - 1] = 0; + } + + bool storeCost = (numMode == 1) ? true : false; + + if ((m_pcEncCfg->m_ISP >= 2) && (numMode <= 1)) + { + storeCost = true; + } + + if (storeCost) + { + m_ispTestedModes[0].bestCost[cu.ispMode - 1] = singleCostTmp; } } - } - if (lfnstIdx && !cuCtx.lfnstLastScanPos && !cu.ispMode) - { - bool rootCbfL = false; - for( uint32_t t = 0; t < getNumberValidTBlocks(*cu.cs->pcv); t++) - { - rootCbfL |= tu.cbf[t] != 0; - } - if( rapidLFNST && !rootCbfL ) + else { - endLfnstIdx = lfnstIdx; // break the loop - } - bool cbfAtZeroDepth = cu.isSepTree() - ? rootCbfL - : (cs.area.chromaFormat != CHROMA_400 - && std::min(cu.firstTU->blocks[1].width, cu.firstTU->blocks[1].height) < 4) - ? TU::getCbfAtDepth(tu, COMP_Y, currDepth) - : rootCbfL; - if (cbfAtZeroDepth) + bool TrLoad = (EndMTS && !m_pcEncCfg->m_LFNST) || (tsAllowed && !mtsAllowed && (lfnstIdx == 0)) ? true : false; + + xIntraCodingTUBlock(tu, COMP_Y, false, singleDistTmpLuma, &numSig, predBuf, TrLoad); + + cuCtx.mtsLastScanPos = false; + //----- determine rate and r-d cost ----- + if ((sps.LFNST ? (modeId == EndMTS && modeId != 0 && checkTransformSkip) : (trModes[modeId].first != 0)) && !TU::getCbfAtDepth(tu, COMP_Y, currDepth)) { singleCostTmp = MAX_DOUBLE; } - } - if (singleCostTmp < dSingleCost) - { - trGrpBestCost = singleCostTmp; - dSingleCost = singleCostTmp; - singleDistLuma = singleDistTmpLuma; - singleFracBits = singleTmpFracBits; - bestLfnstIdx = lfnstIdx; - bestMTS = modeId; - if ((lfnstIdx == 0) && (modeId == 0) ) + else { - dct2Cost = singleCostTmp; - if (!TU::getCbfAtDepth(tu, COMP_Y, currDepth)) + m_ispTestedModes[0].IspType = TU_NO_ISP; + m_ispTestedModes[0].subTuCounter = -1; + singleTmpFracBits = xGetIntraFracBitsQT(cs, partitioner, true, &cuCtx); + + if (tu.mtsIdx[COMP_Y] > MTS_SKIP) { - if (rapidLFNST) + if (!cuCtx.mtsLastScanPos) + { + singleCostTmp = MAX_DOUBLE; + } + else { - endLfnstIdx = 0; // break the loop but do not cpy best - } - EndMTS = 0; + singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); + } + } + else + { + singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); } } - if ((bestLfnstIdx != endLfnstIdx) || (bestMTS != EndMTS)) - { - saveCS.getPredBuf(tu.Y()).copyFrom(cs.getPredBuf(tu.Y())); - saveCS.getRecoBuf(tu.Y()).copyFrom(cs.getRecoBuf(tu.Y())); + if (((EndMTS && (m_pcEncCfg->m_MTS == 2)) || rapidLFNST) && modeId == 0 && lfnstIdx == 0) + { + if (singleCostTmp > bestCostSoFar * thresholdDCT) + { + EndMTS = 0; + + if (rapidDCT) + { + endLfnstIdx = 0; // break the loop but do not cpy best + } + } + } - tmpTU->copyComponentFrom(tu, COMP_Y); + if (lfnstIdx && !cuCtx.lfnstLastScanPos && !cu.ispMode) + { + bool rootCbfL = false; + + for (uint32_t t = 0; t < getNumberValidTBlocks(*cu.cs->pcv); t++) + { + rootCbfL |= tu.cbf[t] != 0; + } - ctxBest = m_CABACEstimator->getCtx(); + if (rapidLFNST && !rootCbfL) + { + endLfnstIdx = lfnstIdx; // break the loop + } + bool cbfAtZeroDepth = CU::isSepTree(cu) + ? rootCbfL + : (cs.area.chromaFormat != CHROMA_400 && std::min(cu.firstTU->blocks[1].width, cu.firstTU->blocks[1].height) < 4) + ? TU::getCbfAtDepth(tu, COMP_Y, currDepth) + : rootCbfL; + + if (cbfAtZeroDepth) + { + singleCostTmp = MAX_DOUBLE; + } + } } + + if (singleCostTmp < dSingleCost) + { + trGrpBestCost = singleCostTmp; + dSingleCost = singleCostTmp; + singleDistLuma = singleDistTmpLuma; + singleFracBits = singleTmpFracBits; + bestLfnstIdx = lfnstIdx; + bestMTS = modeId; + + if (dSingleCost < bestCostForISP) + { + bestCostForISP = dSingleCost; + } + + splitCbfLumaSum = splitCbfLuma; + + if (lfnstIdx == 0 && modeId == 0 && cu.ispMode == 0) + { + dct2Cost = singleCostTmp; + + if (!TU::getCbfAtDepth(tu, COMP_Y, currDepth)) + { + if (rapidLFNST) + { + endLfnstIdx = 0; // break the loop but do not cpy best + } + + EndMTS = 0; + } + } + + if (bestLfnstIdx != endLfnstIdx || bestMTS != EndMTS) + { + if (cu.ispMode) + { + saveCS.getRecoBuf(currArea.Y()).copyFrom(cs.getRecoBuf(currArea.Y())); + + for (uint32_t j = 0; j < cs.tus.size(); j++) + { + saveCS.tus[j]->copyComponentFrom(*cs.tus[j], COMP_Y); + } + } + else + { + saveCS.getPredBuf(tu.Y()).copyFrom(cs.getPredBuf(tu.Y())); + saveCS.getRecoBuf(tu.Y()).copyFrom(cs.getRecoBuf(tu.Y())); + + tmpTU->copyComponentFrom(tu, COMP_Y); + } + + ctxBest = m_CABACEstimator->getCtx(); + } - } - else - { - if( rapidLFNST ) + } + else { - endLfnstIdx = lfnstIdx; // break the loop + if( rapidLFNST ) + { + endLfnstIdx = lfnstIdx; // break the loop + } } } - } - if (m_pcEncCfg->m_LFNST && ( m_pcEncCfg->m_MTS==2) && modeId && (modeId != EndMTS)) + if (m_pcEncCfg->m_LFNST && m_pcEncCfg->m_MTS == 2 && modeId && modeId != EndMTS) { NStopMTS = false; + if (bestMTS || bestLfnstIdx) { - if ((modeId > 1 && (bestMTS == modeId)) - || (modeId == 1)) + if ((modeId > 1 && bestMTS == modeId) || modeId == 1) { NStopMTS = (dct2Cost / trGrpBestCost) < trGrpStopThreshold; } } } } + cu.lfnstIdx = bestLfnstIdx; - if ((bestLfnstIdx != endLfnstIdx) || (bestMTS != EndMTS)) + if (dSingleCost != MAX_DOUBLE) { - cs.getRecoBuf(tu.Y()).copyFrom(saveCS.getRecoBuf(tu.Y())); + if (bestLfnstIdx != endLfnstIdx || bestMTS != EndMTS) + { + if (cu.ispMode) + { + const UnitArea& currArea = partitioner.currArea(); + cs.getRecoBuf(currArea.Y()).copyFrom(saveCS.getRecoBuf(currArea.Y())); - tu.copyComponentFrom(*tmpTU, COMP_Y); + if (saveCS.tus.size() != cs.tus.size()) + { + partitioner.splitCurrArea(ispType, cs); - m_CABACEstimator->getCtx() = ctxBest; - } + do + { + partitioner.nextPart(cs); + cs.addTU(CS::getArea(cs, partitioner.currArea(), partitioner.chType, partitioner.treeType), + partitioner.chType, cs.cus[0]); + } while (saveCS.tus.size() != cs.tus.size()); + + partitioner.exitCurrSplit(); + } + + for (uint32_t j = 0; j < saveCS.tus.size(); j++) + { + cs.tus[j]->copyComponentFrom(*saveCS.tus[j], COMP_Y); + } + } + else + { + cs.getRecoBuf(tu.Y()).copyFrom(saveCS.getRecoBuf(tu.Y())); + + tu.copyComponentFrom(*tmpTU, COMP_Y); + } + + m_CABACEstimator->getCtx() = ctxBest; + } - // otherwise this would've happened in useSubStructure - cs.picture->getRecoBuf(currArea.Y()).copyFrom(cs.getRecoBuf(currArea.Y())); + // otherwise this would've happened in useSubStructure + cs.picture->getRecoBuf(currArea.Y()).copyFrom(cs.getRecoBuf(currArea.Y())); + } } else { - xIntraCodingTUBlock(tu, COMP_Y, false, singleDistLuma, &numSig, predBuf); + if (cu.ispMode) + { + const PartSplit ispType = CU::getISPType(cu, COMP_Y); + partitioner.splitCurrArea(ispType, cs); - //----- determine rate and r-d cost ----- - singleFracBits = xGetIntraFracBitsQT(cs, partitioner, true); + CUCtx cuCtx; + dSingleCost = xTestISP(cs, partitioner, bestCostForISP, ispType, splitCbfLumaSum, singleFracBits, singleDistLuma, cuCtx); + partitioner.exitCurrSplit(); + bool storeCost = (numMode == 1) ? true : false; + if ((m_pcEncCfg->m_ISP >= 2) && (numMode <= 1)) + { + storeCost = true; + } + if (storeCost) + { + m_ispTestedModes[0].bestCost[cu.ispMode - 1] = dSingleCost; + } + } + else + { + TransformUnit& tu = + cs.addTU(CS::getArea(cs, currArea, partitioner.chType, partitioner.treeType), partitioner.chType, cs.cus[0]); + tu.depth = currDepth; + + CHECK(!tu.Y().valid(), "Invalid TU"); + xIntraCodingTUBlock(tu, COMP_Y, false, singleDistLuma, &numSig, predBuf); + //----- determine rate and r-d cost ----- + m_ispTestedModes[0].IspType = TU_NO_ISP; + m_ispTestedModes[0].subTuCounter = -1; + singleFracBits = xGetIntraFracBitsQT(cs, partitioner, true); + dSingleCost = m_pcRdCost->calcRdCost(singleFracBits, singleDistLuma); + } } + if (cu.ispMode) + { + for (auto& ptu : cs.tus) + { + if (currArea.Y().contains(ptu->Y())) + { + TU::setCbfAtDepth(*ptu, COMP_Y, currDepth, splitCbfLumaSum ? 1 : 0); + } + } + } cs.dist += singleDistLuma; cs.fracBits += singleFracBits; - cs.cost = m_pcRdCost->calcRdCost( cs.fracBits, cs.dist ); + cs.cost = dSingleCost; STAT_COUNT_CU_MODES( partitioner.chType == CH_L, g_cuCounters1D[CU_RD_TESTS][0][!cs.slice->isIntra() + cs.slice->depth] ); STAT_COUNT_CU_MODES( partitioner.chType == CH_L && !cs.slice->isIntra(), g_cuCounters2D[CU_RD_TESTS][Log2( cs.area.lheight() )][Log2( cs.area.lwidth() )] ); } -void IntraSearch::xIntraChromaCodingQT( CodingStructure &cs, Partitioner& partitioner ) +ChromaCbfs IntraSearch::xIntraChromaCodingQT(CodingStructure& cs, Partitioner& partitioner) { UnitArea currArea = partitioner.currArea(); - if( !currArea.Cb().valid() ) return; + if( !currArea.Cb().valid() ) + return ChromaCbfs(false); TransformUnit& currTU = *cs.getTU( currArea.chromaPos(), CH_C ); - const PredictionUnit &pu = *cs.getPU( currArea.chromaPos(), CH_C ); - - CodingStructure &saveCS = *m_pSaveCS[1]; - saveCS.pcv = cs.pcv; - saveCS.picture = cs.picture; - saveCS.area.repositionTo( cs.area ); - - TransformUnit& tmpTU = saveCS.tus.empty() ? saveCS.addTU(currArea, partitioner.chType, nullptr) : *saveCS.tus.front(); - tmpTU.initData(); - tmpTU.UnitArea::operator=( currArea ); - cs.setDecomp(currArea.Cb(), true); // set in advance (required for Cb2/Cr2 in 4:2:2 video) + const CodingUnit& cu = *cs.getCU( currArea.chromaPos(), CH_C, TREE_D ); + ChromaCbfs cbfs(false); + uint32_t currDepth = partitioner.currTrDepth; + if (currDepth == currTU.depth) + { + if (!currArea.Cb().valid() || !currArea.Cr().valid()) + { + return cbfs; + } - const unsigned numTBlocks = getNumberValidTBlocks( *cs.pcv ); + CodingStructure& saveCS = *m_pSaveCS[1]; + saveCS.pcv = cs.pcv; + saveCS.picture = cs.picture; + saveCS.area.repositionTo(cs.area); - CompArea& cbArea = currTU.blocks[COMP_Cb]; - CompArea& crArea = currTU.blocks[COMP_Cr]; - double bestCostCb = MAX_DOUBLE; - double bestCostCr = MAX_DOUBLE; - Distortion bestDistCb = 0; - Distortion bestDistCr = 0; + TransformUnit& tmpTU = saveCS.tus.empty() ? saveCS.addTU(currArea, partitioner.chType, nullptr) : *saveCS.tus.front(); + tmpTU.initData(); + tmpTU.UnitArea::operator=(currArea); - TempCtx ctxStartTU( m_CtxCache ); - TempCtx ctxStart ( m_CtxCache ); - TempCtx ctxBest ( m_CtxCache ); + const unsigned numTBlocks = getNumberValidTBlocks(*cs.pcv); - ctxStartTU = m_CABACEstimator->getCtx(); - currTU.jointCbCr = 0; + CompArea& cbArea = currTU.blocks[COMP_Cb]; + CompArea& crArea = currTU.blocks[COMP_Cr]; + double bestCostCb = MAX_DOUBLE; + double bestCostCr = MAX_DOUBLE; + Distortion bestDistCb = 0; + Distortion bestDistCr = 0; - // Do predictions here to avoid repeating the "default0Save1Load2" stuff - uint32_t predMode = PU::getFinalIntraMode( pu, CH_C ); + TempCtx ctxStartTU(m_CtxCache); + TempCtx ctxStart(m_CtxCache); + TempCtx ctxBest(m_CtxCache); - PelBuf piPredCb = cs.getPredBuf(COMP_Cb); - PelBuf piPredCr = cs.getPredBuf(COMP_Cr); + ctxStartTU = m_CABACEstimator->getCtx(); + ctxStart = m_CABACEstimator->getCtx(); + currTU.jointCbCr = 0; - initIntraPatternChType( *currTU.cu, cbArea); - initIntraPatternChType( *currTU.cu, crArea); + // Do predictions here to avoid repeating the "default0Save1Load2" stuff + int predMode = cu.bdpcmM[CH_C] ? BDPCM_IDX : CU::getFinalIntraMode(cu, CH_C); - if( PU::isLMCMode( predMode ) ) - { - loadLMLumaRecPels( pu, cbArea ); - predIntraChromaLM( COMP_Cb, piPredCb, pu, cbArea, predMode ); - predIntraChromaLM( COMP_Cr, piPredCr, pu, crArea, predMode ); - } - else - { - predIntraAng( COMP_Cb, piPredCb, pu); - predIntraAng( COMP_Cr, piPredCr, pu); - } + PelBuf piPredCb = cs.getPredBuf(COMP_Cb); + PelBuf piPredCr = cs.getPredBuf(COMP_Cr); - // determination of chroma residuals including reshaping and cross-component prediction - //----- get chroma residuals ----- - PelBuf resiCb = cs.getResiBuf(COMP_Cb); - PelBuf resiCr = cs.getResiBuf(COMP_Cr); - resiCb.subtract( cs.getOrgBuf (COMP_Cb), piPredCb ); - resiCr.subtract( cs.getOrgBuf (COMP_Cr), piPredCr ); + initIntraPatternChType(*currTU.cu, cbArea); + initIntraPatternChType(*currTU.cu, crArea); - //----- get reshape parameter ---- - ReshapeData& reshapeData = cs.picture->reshapeData; - bool doReshaping = ( cs.picHeader->lmcsEnabled && cs.picHeader->lmcsChromaResidualScale && (cs.slice->isIntra() || reshapeData.getCTUFlag()) && (cbArea.width * cbArea.height > 4) ); - if( doReshaping ) - { - const Area area = currTU.Y().valid() ? currTU.Y() : Area(recalcPosition(currTU.chromaFormat, currTU.chType, CH_L, currTU.blocks[currTU.chType].pos()), recalcSize(currTU.chromaFormat, currTU.chType, CH_L, currTU.blocks[currTU.chType].size())); - const CompArea& areaY = CompArea(COMP_Y, currTU.chromaFormat, area); - currTU.chromaAdj = reshapeData.calculateChromaAdjVpduNei(currTU, areaY, currTU.cu->treeType); - } + if (CU::isLMCMode(predMode)) + { + loadLMLumaRecPels(cu, cbArea); + predIntraChromaLM(COMP_Cb, piPredCb, cu, cbArea, predMode); + predIntraChromaLM(COMP_Cr, piPredCr, cu, crArea, predMode); + } + else + { + predIntraAng(COMP_Cb, piPredCb, cu); + predIntraAng(COMP_Cr, piPredCr, cu); + } - //===== store original residual signals (std and crossCompPred) ===== - CompStorage orgResiCb[5], orgResiCr[5]; // 0:std, 1-3:jointCbCr (placeholder at this stage), 4:crossComp - for( int k = 0; k < 1; k+=4 ) - { - orgResiCb[k].create( cbArea ); - orgResiCr[k].create( crArea ); - orgResiCb[k].copyFrom( resiCb ); - orgResiCr[k].copyFrom( resiCr ); + // determination of chroma residuals including reshaping and cross-component prediction + //----- get chroma residuals ----- + PelBuf resiCb = cs.getResiBuf(COMP_Cb); + PelBuf resiCr = cs.getResiBuf(COMP_Cr); + resiCb.subtract(cs.getOrgBuf(COMP_Cb), piPredCb); + resiCr.subtract(cs.getOrgBuf(COMP_Cr), piPredCr); - if( doReshaping ) + //----- get reshape parameter ---- + ReshapeData& reshapeData = cs.picture->reshapeData; + bool doReshaping = (cs.picHeader->lmcsEnabled && cs.picHeader->lmcsChromaResidualScale && (cs.slice->isIntra() || reshapeData.getCTUFlag()) && (cbArea.width * cbArea.height > 4)); + if (doReshaping) { - int cResScaleInv = currTU.chromaAdj; - orgResiCb[k].scaleSignal( cResScaleInv, 1, cs.slice->clpRngs[COMP_Cb] ); - orgResiCr[k].scaleSignal( cResScaleInv, 1, cs.slice->clpRngs[COMP_Cr] ); + const Area area = currTU.Y().valid() ? currTU.Y() : Area(recalcPosition(currTU.chromaFormat, currTU.chType, CH_L, currTU.blocks[currTU.chType].pos()), recalcSize(currTU.chromaFormat, currTU.chType, CH_L, currTU.blocks[currTU.chType].size())); + const CompArea& areaY = CompArea(COMP_Y, currTU.chromaFormat, area); + currTU.chromaAdj = reshapeData.calculateChromaAdjVpduNei(currTU, areaY, currTU.cu->treeType); } - } - - CUCtx cuCtx; - cuCtx.isDQPCoded = true; - cuCtx.isChromaQpAdjCoded = true; - cuCtx.lfnstLastScanPos = false; - CodingStructure &saveCScur = *m_pSaveCS[2]; + //===== store original residual signals (std and crossCompPred) ===== + CompStorage orgResiCb[5], orgResiCr[5]; // 0:std, 1-3:jointCbCr (placeholder at this stage), 4:crossComp + for (int k = 0; k < 1; k += 4) + { + orgResiCb[k].create(cbArea); + orgResiCr[k].create(crArea); + orgResiCb[k].copyFrom(resiCb); + orgResiCr[k].copyFrom(resiCr); - saveCScur.pcv = cs.pcv; - saveCScur.picture = cs.picture; - saveCScur.area.repositionTo( cs.area ); + if (doReshaping) + { + int cResScaleInv = currTU.chromaAdj; + orgResiCb[k].scaleSignal(cResScaleInv, 1, cs.slice->clpRngs[COMP_Cb]); + orgResiCr[k].scaleSignal(cResScaleInv, 1, cs.slice->clpRngs[COMP_Cr]); + } + } - TransformUnit& tmpTUcur = saveCScur.tus.empty() ? saveCScur.addTU( currArea, partitioner.chType, nullptr ) : *saveCScur.tus.front(); - tmpTUcur.initData(); - tmpTUcur.UnitArea::operator=( currArea ); + CUCtx cuCtx; + cuCtx.isDQPCoded = true; + cuCtx.isChromaQpAdjCoded = true; + cuCtx.lfnstLastScanPos = false; - TempCtx ctxBestTUL ( m_CtxCache ); + CodingStructure& saveCScur = *m_pSaveCS[2]; - const SPS &sps = *cs.sps; - double bestCostCbcur = MAX_DOUBLE; - double bestCostCrcur = MAX_DOUBLE; - Distortion bestDistCbcur = 0; - Distortion bestDistCrcur = 0; + saveCScur.pcv = cs.pcv; + saveCScur.picture = cs.picture; + saveCScur.area.repositionTo(cs.area); - int endLfnstIdx = ( partitioner.isSepTree( cs ) && partitioner.chType == CH_C && ( partitioner.currArea().lwidth() < 8 || partitioner.currArea().lheight() < 8 ) ) - || ( partitioner.currArea().lwidth() > sps.getMaxTbSize() || partitioner.currArea().lheight() > sps.getMaxTbSize() ) || !sps.LFNST ? 0 : 2; - int startLfnstIdx = 0; - int bestLfnstIdx = 0; - bool NOTONE_LFNST = sps.LFNST ? true : false; + TransformUnit& tmpTUcur = saveCScur.tus.empty() ? saveCScur.addTU(currArea, partitioner.chType, nullptr) : *saveCScur.tus.front(); + tmpTUcur.initData(); + tmpTUcur.UnitArea::operator=(currArea); - // speedUps LFNST - bool rapidLFNST = false; - if (m_pcEncCfg->m_LFNST > 1) - { - rapidLFNST = true; - if (m_pcEncCfg->m_LFNST > 2) - { - endLfnstIdx = endLfnstIdx ? 1 : 0; - } - } + TempCtx ctxBestTUL(m_CtxCache); - if (partitioner.chType != CH_C) - { - startLfnstIdx = currTU.cu->lfnstIdx; - endLfnstIdx = currTU.cu->lfnstIdx; - bestLfnstIdx = currTU.cu->lfnstIdx; - NOTONE_LFNST = false; - rapidLFNST = false; - } + const SPS& sps = *cs.sps; + double bestCostCbcur = MAX_DOUBLE; + double bestCostCrcur = MAX_DOUBLE; + Distortion bestDistCbcur = 0; + Distortion bestDistCrcur = 0; - double dSingleCostAll = MAX_DOUBLE; - double singleCostTmpAll = 0; + int endLfnstIdx = (partitioner.isSepTree(cs) && partitioner.chType == CH_C && (partitioner.currArea().lwidth() < 8 || partitioner.currArea().lheight() < 8)) + || (partitioner.currArea().lwidth() > sps.getMaxTbSize() || partitioner.currArea().lheight() > sps.getMaxTbSize()) || !sps.LFNST ? 0 : 2; + int startLfnstIdx = 0; + int bestLfnstIdx = 0; + bool testLFNST = sps.LFNST; - for (int lfnstIdx = startLfnstIdx; lfnstIdx <= endLfnstIdx; lfnstIdx++) - { - if (rapidLFNST && lfnstIdx) + // speedUps LFNST + bool rapidLFNST = false; + if (m_pcEncCfg->m_LFNST > 1) { - if ((lfnstIdx == 2) && (bestLfnstIdx == 0)) + rapidLFNST = true; + if (m_pcEncCfg->m_LFNST > 2) { - continue; + endLfnstIdx = endLfnstIdx ? 1 : 0; } } - - currTU.cu->lfnstIdx = lfnstIdx; - if (lfnstIdx) + int ts_used = 0; + bool testTS = false; + if (partitioner.chType != CH_C) { - m_CABACEstimator->getCtx() = ctxStartTU; + startLfnstIdx = currTU.cu->lfnstIdx; + endLfnstIdx = currTU.cu->lfnstIdx; + bestLfnstIdx = currTU.cu->lfnstIdx; + testLFNST = false; + rapidLFNST = false; + ts_used = currTU.mtsIdx[COMP_Y]; + } + if (cu.bdpcmM[CH_C]) + { + endLfnstIdx = 0; + testLFNST = false; } - cuCtx.lfnstLastScanPos = false; - cuCtx.violatesLfnstConstrained[CH_L] = false; - cuCtx.violatesLfnstConstrained[CH_C] = false; + double dSingleCostAll = MAX_DOUBLE; + double singleCostTmpAll = 0; - for( uint32_t c = COMP_Cb; c < numTBlocks; c++) + for (int lfnstIdx = startLfnstIdx; lfnstIdx <= endLfnstIdx; lfnstIdx++) { - const ComponentID compID = ComponentID(c); - const CompArea& area = currTU.blocks[compID]; - double dSingleCost = MAX_DOUBLE; - Distortion singleDistCTmp = 0; - double singleCostTmp = 0; - const bool isLastMode = NOTONE_LFNST || cs.sps->jointCbCr ? false : true; + if (rapidLFNST && lfnstIdx) + { + if ((lfnstIdx == 2) && (bestLfnstIdx == 0)) + { + continue; + } + } - if (doReshaping || lfnstIdx) + currTU.cu->lfnstIdx = lfnstIdx; + if (lfnstIdx) { - resiCb.copyFrom( orgResiCb[0] ); - resiCr.copyFrom( orgResiCr[0] ); + m_CABACEstimator->getCtx() = ctxStartTU; } - xIntraCodingTUBlock( currTU, compID, false, singleDistCTmp ); - uint64_t fracBitsTmp = xGetIntraFracBitsQTChroma( currTU, compID, &cuCtx ); - singleCostTmp = m_pcRdCost->calcRdCost( fracBitsTmp, singleDistCTmp ); + cuCtx.lfnstLastScanPos = false; + cuCtx.violatesLfnstConstrained[CH_L] = false; + cuCtx.violatesLfnstConstrained[CH_C] = false; - if( singleCostTmp < dSingleCost ) + for (uint32_t c = COMP_Cb; c < numTBlocks; c++) { - dSingleCost = singleCostTmp; + const ComponentID compID = ComponentID(c); + const CompArea& area = currTU.blocks[compID]; + double dSingleCost = MAX_DOUBLE; + Distortion singleDistCTmp = 0; + double singleCostTmp = 0; + bool tsAllowed = TU::isTSAllowed(currTU, compID) && m_pcEncCfg->m_useChromaTS && !currTU.cu->lfnstIdx && !cu.bdpcmM[CH_C]; + if ((partitioner.chType == CH_L) && (!ts_used)) + { + tsAllowed = false; + } + tsAllowed &= cs.picture->useSC; + uint8_t nNumTransformCands = 1 + (tsAllowed ? 1 : 0); // DCT + TS = 2 tests + std::vector trModes; + if (nNumTransformCands > 1) + { + trModes.push_back(TrMode(0, true)); // DCT2 + trModes.push_back(TrMode(1, true)); // TS + testTS = true; + } + bool cbfDCT2 = true; + const bool isLastMode = testLFNST || cs.sps->jointCbCr || tsAllowed ? false : true; + int bestModeId = 0; + ctxStart = m_CABACEstimator->getCtx(); + for (int modeId = 0; modeId < nNumTransformCands; modeId++) + { + if (doReshaping || lfnstIdx || modeId) + { + resiCb.copyFrom(orgResiCb[0]); + resiCr.copyFrom(orgResiCr[0]); + } + if (modeId == 0) + { + if ( tsAllowed) + { + xPreCheckMTS(currTU, &trModes, m_pcEncCfg->m_MTSIntraMaxCand, 0, compID); + } + } + + currTU.mtsIdx[compID] = currTU.cu->bdpcmM[CH_C] ? MTS_SKIP : modeId; - if ( compID == COMP_Cb ) + if (modeId) + { + if (!cbfDCT2 && trModes[modeId].first == MTS_SKIP) + { + break; + } + m_CABACEstimator->getCtx() = ctxStart; + } + singleDistCTmp = 0; + if (tsAllowed) + { + xIntraCodingTUBlock(currTU, compID, false, singleDistCTmp, 0, 0, true); + if ((modeId == 0) && (!trModes[modeId + 1].second)) + { + nNumTransformCands = 1; + } + } + else + { + xIntraCodingTUBlock(currTU, compID, false, singleDistCTmp); + } + if (((currTU.mtsIdx[compID] == MTS_SKIP && !currTU.cu->bdpcmM[CH_C]) + && !TU::getCbf(currTU, compID))) // In order not to code TS flag when cbf is zero, the case for TS with + // cbf being zero is forbidden. { - bestCostCb = singleCostTmp; - bestDistCb = singleDistCTmp; + singleCostTmp = MAX_DOUBLE; } else { - bestCostCr = singleCostTmp; - bestDistCr = singleDistCTmp; + uint64_t fracBitsTmp = xGetIntraFracBitsQTChroma(currTU, compID, &cuCtx); + singleCostTmp = m_pcRdCost->calcRdCost(fracBitsTmp, singleDistCTmp); } - if( !isLastMode ) + if (singleCostTmp < dSingleCost) + { + dSingleCost = singleCostTmp; + + if (compID == COMP_Cb) + { + bestCostCb = singleCostTmp; + bestDistCb = singleDistCTmp; + } + else + { + bestCostCr = singleCostTmp; + bestDistCr = singleDistCTmp; + } + bestModeId = modeId; + if (currTU.mtsIdx[compID] == MTS_DCT2_DCT2) + { + cbfDCT2 = TU::getCbfAtDepth(currTU, compID, currDepth); + } + if (!isLastMode) + { + saveCS.getRecoBuf(area).copyFrom(cs.getRecoBuf(area)); + tmpTU.copyComponentFrom(currTU, compID); + ctxBest = m_CABACEstimator->getCtx(); + } + } + } + if (testTS && ((c == COMP_Cb && bestModeId < (nNumTransformCands - 1)) )) { - saveCS.getRecoBuf(area).copyFrom(cs.getRecoBuf (area)); - tmpTU.copyComponentFrom(currTU, compID); - ctxBest = m_CABACEstimator->getCtx(); + m_CABACEstimator->getCtx() = ctxBest; + + currTU.copyComponentFrom(tmpTU, COMP_Cb); // Cbf of Cb is needed to estimate cost for Cr Cbf } } - } - singleCostTmpAll = bestCostCb + bestCostCr; + singleCostTmpAll = bestCostCb + bestCostCr; - bool rootCbfL = false; - if (NOTONE_LFNST) - { - for (uint32_t t = 0; t < getNumberValidTBlocks(*cs.pcv); t++) + bool rootCbfL = false; + if (testLFNST) { - rootCbfL |= bool(tmpTU.cbf[t]); - } - if (rapidLFNST && !rootCbfL) - { - endLfnstIdx = lfnstIdx; // end this + for (uint32_t t = 0; t < getNumberValidTBlocks(*cs.pcv); t++) + { + rootCbfL |= bool(tmpTU.cbf[t]); + } + if (rapidLFNST && !rootCbfL) + { + endLfnstIdx = lfnstIdx; // end this + } } - } - if (NOTONE_LFNST && lfnstIdx && !cuCtx.lfnstLastScanPos) - { - bool cbfAtZeroDepth = currTU.cu->isSepTree() - ? rootCbfL : (cs.area.chromaFormat != CHROMA_400 - && std::min(tmpTU.blocks[1].width, tmpTU.blocks[1].height) < 4) - ? TU::getCbfAtDepth(currTU, COMP_Y, currTU.depth) : rootCbfL; - if (cbfAtZeroDepth) + if (testLFNST && lfnstIdx && !cuCtx.lfnstLastScanPos) { - singleCostTmpAll = MAX_DOUBLE; + bool cbfAtZeroDepth = CU::isSepTree(*currTU.cu) + ? rootCbfL : (cs.area.chromaFormat != CHROMA_400 + && std::min(tmpTU.blocks[1].width, tmpTU.blocks[1].height) < 4) + ? TU::getCbfAtDepth(currTU, COMP_Y, currTU.depth) : rootCbfL; + if (cbfAtZeroDepth) + { + singleCostTmpAll = MAX_DOUBLE; + } } - } - - if (NOTONE_LFNST && (singleCostTmpAll < dSingleCostAll)) - { - bestLfnstIdx = lfnstIdx; - if (lfnstIdx != endLfnstIdx) + if ((testLFNST || testTS) && (singleCostTmpAll < dSingleCostAll)) { - dSingleCostAll = singleCostTmpAll; + bestLfnstIdx = lfnstIdx; + if ((lfnstIdx != endLfnstIdx) || testTS) + { + dSingleCostAll = singleCostTmpAll; - bestCostCbcur = bestCostCb; - bestCostCrcur = bestCostCr; - bestDistCbcur = bestDistCb; - bestDistCrcur = bestDistCr; + bestCostCbcur = bestCostCb; + bestCostCrcur = bestCostCr; + bestDistCbcur = bestDistCb; + bestDistCrcur = bestDistCr; - saveCScur.getRecoBuf(cbArea).copyFrom(saveCS.getRecoBuf(cbArea)); - saveCScur.getRecoBuf(crArea).copyFrom(saveCS.getRecoBuf(crArea)); + saveCScur.getRecoBuf(cbArea).copyFrom(saveCS.getRecoBuf(cbArea)); + saveCScur.getRecoBuf(crArea).copyFrom(saveCS.getRecoBuf(crArea)); - tmpTUcur.copyComponentFrom(tmpTU, COMP_Cb); - tmpTUcur.copyComponentFrom(tmpTU, COMP_Cr); + tmpTUcur.copyComponentFrom(tmpTU, COMP_Cb); + tmpTUcur.copyComponentFrom(tmpTU, COMP_Cr); + } + ctxBestTUL = m_CABACEstimator->getCtx(); } - ctxBestTUL = m_CABACEstimator->getCtx(); } - } - if (NOTONE_LFNST && (bestLfnstIdx != endLfnstIdx)) - { - bestCostCb = bestCostCbcur; - bestCostCr = bestCostCrcur; - bestDistCb = bestDistCbcur; - bestDistCr = bestDistCrcur; - currTU.cu->lfnstIdx = bestLfnstIdx; - if (!cs.sps->jointCbCr) + if ((testLFNST && (bestLfnstIdx != endLfnstIdx)) || testTS) { - cs.getRecoBuf(cbArea).copyFrom(saveCScur.getRecoBuf(cbArea)); - cs.getRecoBuf(crArea).copyFrom(saveCScur.getRecoBuf(crArea)); + bestCostCb = bestCostCbcur; + bestCostCr = bestCostCrcur; + bestDistCb = bestDistCbcur; + bestDistCr = bestDistCrcur; + currTU.cu->lfnstIdx = bestLfnstIdx; + if (!cs.sps->jointCbCr) + { + cs.getRecoBuf(cbArea).copyFrom(saveCScur.getRecoBuf(cbArea)); + cs.getRecoBuf(crArea).copyFrom(saveCScur.getRecoBuf(crArea)); - currTU.copyComponentFrom(tmpTUcur, COMP_Cb); - currTU.copyComponentFrom(tmpTUcur, COMP_Cr); + currTU.copyComponentFrom(tmpTUcur, COMP_Cb); + currTU.copyComponentFrom(tmpTUcur, COMP_Cr); - m_CABACEstimator->getCtx() = ctxBestTUL; + m_CABACEstimator->getCtx() = ctxBestTUL; + } } - } - Distortion bestDistCbCr = bestDistCb + bestDistCr; - - if ( cs.sps->jointCbCr ) - { - if (NOTONE_LFNST && (bestLfnstIdx != endLfnstIdx)) - { - saveCS.getRecoBuf(cbArea).copyFrom(saveCScur.getRecoBuf(cbArea)); - saveCS.getRecoBuf(crArea).copyFrom(saveCScur.getRecoBuf(crArea)); + Distortion bestDistCbCr = bestDistCb + bestDistCr; - tmpTU.copyComponentFrom(tmpTUcur, COMP_Cb); - tmpTU.copyComponentFrom(tmpTUcur, COMP_Cr); - m_CABACEstimator->getCtx() = ctxBestTUL; - ctxBest = m_CABACEstimator->getCtx(); - } - // Test using joint chroma residual coding - double bestCostCbCr = bestCostCb + bestCostCr; - int bestJointCbCr = 0; - bool lastIsBest = false; - bool NOLFNST1 = false; - if (rapidLFNST && (startLfnstIdx != endLfnstIdx)) + if (cs.sps->jointCbCr) { - if (bestLfnstIdx == 2) - { - NOLFNST1 = true; - } - else + if ((testLFNST && (bestLfnstIdx != endLfnstIdx)) || testTS) { - endLfnstIdx = 1; - } - } + saveCS.getRecoBuf(cbArea).copyFrom(saveCScur.getRecoBuf(cbArea)); + saveCS.getRecoBuf(crArea).copyFrom(saveCScur.getRecoBuf(crArea)); - for (int lfnstIdxj = startLfnstIdx; lfnstIdxj <= endLfnstIdx; lfnstIdxj++) - { - if (rapidLFNST && NOLFNST1 && (lfnstIdxj == 1)) - { - continue; - } - currTU.cu->lfnstIdx = lfnstIdxj; - std::vector jointCbfMasksToTest; - if (TU::getCbf(tmpTU, COMP_Cb) || TU::getCbf(tmpTU, COMP_Cr)) - { - jointCbfMasksToTest = m_pcTrQuant->selectICTCandidates(currTU, orgResiCb, orgResiCr); + tmpTU.copyComponentFrom(tmpTUcur, COMP_Cb); + tmpTU.copyComponentFrom(tmpTUcur, COMP_Cr); + m_CABACEstimator->getCtx() = ctxBestTUL; + ctxBest = m_CABACEstimator->getCtx(); } - for (int cbfMask: jointCbfMasksToTest) + // Test using joint chroma residual coding + double bestCostCbCr = bestCostCb + bestCostCr; + int bestJointCbCr = 0; + bool checkDCTOnly = m_pcEncCfg->m_useChromaTS && ((TU::getCbf(tmpTU, COMP_Cb) && tmpTU.mtsIdx[COMP_Cb] == MTS_DCT2_DCT2 && !TU::getCbf(tmpTU, COMP_Cr)) || + (TU::getCbf(tmpTU, COMP_Cr) && tmpTU.mtsIdx[COMP_Cr] == MTS_DCT2_DCT2 && !TU::getCbf(tmpTU, COMP_Cb)) || + (TU::getCbf(tmpTU, COMP_Cb) && tmpTU.mtsIdx[COMP_Cb] == MTS_DCT2_DCT2 && TU::getCbf(tmpTU, COMP_Cr) && tmpTU.mtsIdx[COMP_Cr] == MTS_DCT2_DCT2)); + bool checkTSOnly = m_pcEncCfg->m_useChromaTS && ((TU::getCbf(tmpTU, COMP_Cb) && tmpTU.mtsIdx[COMP_Cb] == MTS_SKIP && !TU::getCbf(tmpTU, COMP_Cr)) || + (TU::getCbf(tmpTU, COMP_Cr) && tmpTU.mtsIdx[COMP_Cr] == MTS_SKIP && !TU::getCbf(tmpTU, COMP_Cb)) || + (TU::getCbf(tmpTU, COMP_Cb) && tmpTU.mtsIdx[COMP_Cb] == MTS_SKIP && TU::getCbf(tmpTU, COMP_Cr) && tmpTU.mtsIdx[COMP_Cr] == MTS_SKIP)); + bool lastIsBest = false; + bool noLFNST1 = false; + if (rapidLFNST && (startLfnstIdx != endLfnstIdx)) { - Distortion distTmp = 0; - currTU.jointCbCr = (uint8_t) cbfMask; - - m_CABACEstimator->getCtx() = ctxStartTU; - - resiCb.copyFrom(orgResiCb[cbfMask]); - resiCr.copyFrom(orgResiCr[cbfMask]); - cuCtx.lfnstLastScanPos = false; - cuCtx.violatesLfnstConstrained[CH_L] = false; - cuCtx.violatesLfnstConstrained[CH_C] = false; - - xIntraCodingTUBlock(currTU, COMP_Cb, false, distTmp, 0); - - double costTmp = std::numeric_limits::max(); - if (distTmp < MAX_DISTORTION) + if (bestLfnstIdx == 2) { - uint64_t bits = xGetIntraFracBitsQTChroma(currTU, COMP_Cb, &cuCtx); - costTmp = m_pcRdCost->calcRdCost(bits, distTmp); + noLFNST1 = true; } - bool rootCbfL = false; - for (uint32_t t = 0; t < getNumberValidTBlocks(*cs.pcv); t++) + else { - rootCbfL |= bool(tmpTU.cbf[t]); + endLfnstIdx = 1; } - if (rapidLFNST && !rootCbfL) + } + + for (int lfnstIdxj = startLfnstIdx; lfnstIdxj <= endLfnstIdx; lfnstIdxj++) + { + if (rapidLFNST && noLFNST1 && (lfnstIdxj == 1)) { - endLfnstIdx = lfnstIdxj; + continue; } - if (NOTONE_LFNST && currTU.cu->lfnstIdx && !cuCtx.lfnstLastScanPos) + currTU.cu->lfnstIdx = lfnstIdxj; + std::vector jointCbfMasksToTest; + if (TU::getCbf(tmpTU, COMP_Cb) || TU::getCbf(tmpTU, COMP_Cr)) { - bool cbfAtZeroDepth = currTU.cu->isSepTree() ? rootCbfL - : (cs.area.chromaFormat != CHROMA_400 && std::min(tmpTU.blocks[1].width, tmpTU.blocks[1].height) < 4) - ? TU::getCbfAtDepth(currTU, COMP_Y, currTU.depth) : rootCbfL; - if (cbfAtZeroDepth) - { - costTmp = MAX_DOUBLE; - } + jointCbfMasksToTest = m_pcTrQuant->selectICTCandidates(currTU, orgResiCb, orgResiCr); } - if (costTmp < bestCostCbCr) + for (int cbfMask : jointCbfMasksToTest) { - bestCostCbCr = costTmp; - bestDistCbCr = distTmp; - bestJointCbCr = currTU.jointCbCr; - - // store data - bestLfnstIdx = lfnstIdxj; - if (cbfMask != jointCbfMasksToTest.back() || (lfnstIdxj != endLfnstIdx)) + currTU.jointCbCr = (uint8_t)cbfMask; + ComponentID codeCompId = ((currTU.jointCbCr >> 1) ? COMP_Cb : COMP_Cr); + ComponentID otherCompId = ((codeCompId == COMP_Cb) ? COMP_Cr : COMP_Cb); + bool tsAllowed = TU::isTSAllowed(currTU, codeCompId) && (m_pcEncCfg->m_useChromaTS) && !currTU.cu->lfnstIdx && !cu.bdpcmM[CH_C]; + if ((partitioner.chType == CH_L)&& tsAllowed && (currTU.mtsIdx[COMP_Y] != MTS_SKIP)) { - saveCS.getRecoBuf(cbArea).copyFrom(cs.getRecoBuf(cbArea)); - saveCS.getRecoBuf(crArea).copyFrom(cs.getRecoBuf(crArea)); - - tmpTU.copyComponentFrom(currTU, COMP_Cb); - tmpTU.copyComponentFrom(currTU, COMP_Cr); - - ctxBest = m_CABACEstimator->getCtx(); + tsAllowed = false; + } + tsAllowed &= cs.picture->useSC; + if (!tsAllowed) + { + checkTSOnly = false; + } + uint8_t numTransformCands = 1 + (tsAllowed && !(checkDCTOnly || checkTSOnly)? 1 : 0); // DCT + TS = 2 tests + std::vector trModes; + if (numTransformCands > 1) + { + trModes.push_back(TrMode(0, true)); // DCT2 + trModes.push_back(TrMode(1, true));//TS } else { - lastIsBest = true; - cs.cus[0]->lfnstIdx = bestLfnstIdx; + currTU.mtsIdx[codeCompId] = checkTSOnly || currTU.cu->bdpcmM[CH_C] ? 1 : 0; + } + + for (int modeId = 0; modeId < numTransformCands; modeId++) + { + Distortion distTmp = 0; + currTU.mtsIdx[codeCompId] = currTU.cu->bdpcmM[CH_C] ? MTS_SKIP : MTS_DCT2_DCT2; + if (numTransformCands > 1) + { + currTU.mtsIdx[codeCompId] = currTU.cu->bdpcmM[CH_C] ? MTS_SKIP : trModes[modeId].first; + } + currTU.mtsIdx[otherCompId] = MTS_DCT2_DCT2; + + m_CABACEstimator->getCtx() = ctxStartTU; + + resiCb.copyFrom(orgResiCb[cbfMask]); + resiCr.copyFrom(orgResiCr[cbfMask]); + if ((modeId == 0) && (numTransformCands > 1)) + { + xPreCheckMTS(currTU, &trModes, m_pcEncCfg->m_MTSIntraMaxCand, 0, COMP_Cb); + currTU.mtsIdx[codeCompId] = trModes[modeId].first; + currTU.mtsIdx[(codeCompId == COMP_Cr) ? COMP_Cb : COMP_Cr] = MTS_DCT2_DCT2; + } + cuCtx.lfnstLastScanPos = false; + cuCtx.violatesLfnstConstrained[CH_L] = false; + cuCtx.violatesLfnstConstrained[CH_C] = false; + if (numTransformCands > 1) + { + xIntraCodingTUBlock(currTU, COMP_Cb, false, distTmp, 0, 0, true); + if ((modeId == 0) && !trModes[modeId + 1].second) + { + numTransformCands = 1; + } + } + else + { + xIntraCodingTUBlock(currTU, COMP_Cb, false, distTmp, 0); + } + + double costTmp = std::numeric_limits::max(); + if (distTmp < MAX_DISTORTION) + { + uint64_t bits = xGetIntraFracBitsQTChroma(currTU, COMP_Cb, &cuCtx); + costTmp = m_pcRdCost->calcRdCost(bits, distTmp); + } + else if (!currTU.mtsIdx[codeCompId]) + { + numTransformCands = 1; + } + bool rootCbfL = false; + for (uint32_t t = 0; t < getNumberValidTBlocks(*cs.pcv); t++) + { + rootCbfL |= bool(tmpTU.cbf[t]); + } + if (rapidLFNST && !rootCbfL) + { + endLfnstIdx = lfnstIdxj; + } + if (testLFNST && currTU.cu->lfnstIdx && !cuCtx.lfnstLastScanPos) + { + bool cbfAtZeroDepth = CU::isSepTree(*currTU.cu) ? rootCbfL + : (cs.area.chromaFormat != CHROMA_400 && std::min(tmpTU.blocks[1].width, tmpTU.blocks[1].height) < 4) + ? TU::getCbfAtDepth(currTU, COMP_Y, currTU.depth) : rootCbfL; + if (cbfAtZeroDepth) + { + costTmp = MAX_DOUBLE; + } + } + if (costTmp < bestCostCbCr) + { + bestCostCbCr = costTmp; + bestDistCbCr = distTmp; + bestJointCbCr = currTU.jointCbCr; + + // store data + bestLfnstIdx = lfnstIdxj; + if ((cbfMask != jointCbfMasksToTest.back() || (lfnstIdxj != endLfnstIdx)) || (modeId != (numTransformCands - 1))) + { + saveCS.getRecoBuf(cbArea).copyFrom(cs.getRecoBuf(cbArea)); + saveCS.getRecoBuf(crArea).copyFrom(cs.getRecoBuf(crArea)); + + tmpTU.copyComponentFrom(currTU, COMP_Cb); + tmpTU.copyComponentFrom(currTU, COMP_Cr); + + ctxBest = m_CABACEstimator->getCtx(); + } + else + { + lastIsBest = true; + cs.cus[0]->lfnstIdx = bestLfnstIdx; + } + } } } + + // Retrieve the best CU data (unless it was the very last one tested) } + if (!lastIsBest) + { + cs.getRecoBuf(cbArea).copyFrom(saveCS.getRecoBuf(cbArea)); + cs.getRecoBuf(crArea).copyFrom(saveCS.getRecoBuf(crArea)); - // Retrieve the best CU data (unless it was the very last one tested) + cs.cus[0]->lfnstIdx = bestLfnstIdx; + currTU.copyComponentFrom(tmpTU, COMP_Cb); + currTU.copyComponentFrom(tmpTU, COMP_Cr); + m_CABACEstimator->getCtx() = ctxBest; + } + currTU.jointCbCr = (TU::getCbf(currTU, COMP_Cb) | TU::getCbf(currTU, COMP_Cr)) ? bestJointCbCr : 0; + } // jointCbCr + + cs.dist += bestDistCbCr; + cuCtx.violatesLfnstConstrained[CH_L] = false; + cuCtx.violatesLfnstConstrained[CH_C] = false; + cuCtx.lfnstLastScanPos = false; + cuCtx.violatesMtsCoeffConstraint = false; + cuCtx.mtsLastScanPos = false; + cbfs.cbf(COMP_Cb) = TU::getCbf(currTU, COMP_Cb); + cbfs.cbf(COMP_Cr) = TU::getCbf(currTU, COMP_Cr); + } + else + { + unsigned numValidTBlocks = getNumberValidTBlocks(*cs.pcv); + ChromaCbfs SplitCbfs(false); + + if (partitioner.canSplit(TU_MAX_TR_SPLIT, cs)) + { + partitioner.splitCurrArea(TU_MAX_TR_SPLIT, cs); } - if (!lastIsBest) + else if (currTU.cu->ispMode) { - cs.getRecoBuf (cbArea).copyFrom(saveCS.getRecoBuf (cbArea)); - cs.getRecoBuf (crArea).copyFrom(saveCS.getRecoBuf (crArea)); - - cs.cus[0]->lfnstIdx = bestLfnstIdx; - currTU.copyComponentFrom(tmpTU, COMP_Cb); - currTU.copyComponentFrom(tmpTU, COMP_Cr); - m_CABACEstimator->getCtx() = ctxBest; + partitioner.splitCurrArea(m_ispTestedModes[0].IspType, cs); } - currTU.jointCbCr = TU::getCbf(currTU, COMP_Cb) | TU::getCbf(currTU, COMP_Cr) ? bestJointCbCr : 0; - } // jointCbCr + else + THROW("Implicit TU split not available"); + + do + { + ChromaCbfs subCbfs = xIntraChromaCodingQT(cs, partitioner); + + for (uint32_t ch = COMP_Cb; ch < numValidTBlocks; ch++) + { + const ComponentID compID = ComponentID(ch); + SplitCbfs.cbf(compID) |= subCbfs.cbf(compID); + } + } while (partitioner.nextPart(cs)); - cs.dist += bestDistCbCr; - cuCtx.violatesLfnstConstrained[CH_L] = false; - cuCtx.violatesLfnstConstrained[CH_C] = false; - cuCtx.lfnstLastScanPos = false; - cuCtx.violatesMtsCoeffConstraint = false; - cuCtx.mtsLastScanPos = false; + partitioner.exitCurrSplit(); + + /*if (lumaUsesISP && cs.dist == MAX_UINT) //ahenkel + { + return cbfs; + }*/ + { + cbfs.Cb |= SplitCbfs.Cb; + cbfs.Cr |= SplitCbfs.Cr; + + if (1) //(!lumaUsesISP) + { + for (auto& ptu : cs.tus) + { + if (currArea.Cb().contains(ptu->Cb()) || (!ptu->Cb().valid() && currArea.Y().contains(ptu->Y()))) + { + TU::setCbfAtDepth(*ptu, COMP_Cb, currDepth, SplitCbfs.Cb); + TU::setCbfAtDepth(*ptu, COMP_Cr, currDepth, SplitCbfs.Cr); + } + } + } + } + } + return cbfs; } -uint64_t IntraSearch::xFracModeBitsIntraLuma(const PredictionUnit &pu) +uint64_t IntraSearch::xFracModeBitsIntraLuma(const CodingUnit& cu, const unsigned* mpmLst) { m_CABACEstimator->resetBits(); - if (!pu.ciip) + if (!cu.ciip) { - m_CABACEstimator->intra_luma_pred_mode(pu); + m_CABACEstimator->intra_luma_pred_mode(cu, mpmLst); } return m_CABACEstimator->getEstFracBits(); } template -void IntraSearch::xReduceHadCandList(static_vector& candModeList, static_vector& candCostList, SortedPelUnitBufs& sortedPelBuffer, int& numModesForFullRD, const double thresholdHadCost, const double* mipHadCost, const PredictionUnit &pu, const bool fastMip) +void IntraSearch::xReduceHadCandList(static_vector& candModeList, static_vector& candCostList, SortedPelUnitBufs& sortedPelBuffer, int& numModesForFullRD, const double thresholdHadCost, const double* mipHadCost, const CodingUnit& cu, const bool fastMip) { const int maxCandPerType = numModesForFullRD >> 1; static_vector tempRdModeList; @@ -2010,10 +2630,10 @@ void IntraSearch::xReduceHadCandList(static_vector& candModeList, static_v } sortedPelBuffer.reduceTo( (int)tempRdModeList.size() ); - if ((pu.lwidth() > 8 && pu.lheight() > 8)) + if ((cu.lwidth() > 8 && cu.lheight() > 8)) { // Sort MIP candidates by Hadamard cost - const int transpOff = getNumModesMip(pu.Y()); + const int transpOff = getNumModesMip(cu.Y()); static_vector sortedMipModes(0); static_vector sortedMipCost(0); for (uint8_t mode : { 0, 1, 2 }) @@ -2053,43 +2673,274 @@ void IntraSearch::xReduceHadCandList(static_vector& candModeList, static_v numModesForFullRD = int(candModeList.size()); } -void IntraSearch::xPreCheckMTS(TransformUnit &tu, std::vector *trModes, const int maxCand, PelUnitBuf *predBuf) +void IntraSearch::xPreCheckMTS(TransformUnit &tu, std::vector *trModes, const int maxCand, PelUnitBuf *predBuf, const ComponentID& compID) { CodingStructure& cs = *tu.cs; - const CompArea& area = tu.blocks[COMP_Y]; + const CompArea& area = tu.blocks[compID]; const ReshapeData& reshapeData = cs.picture->reshapeData; + PelBuf piPred = cs.getPredBuf(area); + PelBuf piResi = cs.getResiBuf(area); - PelBuf piPred = cs.getPredBuf(COMP_Y); - PelBuf piResi = cs.getResiBuf(COMP_Y); + const CodingUnit& cu = *cs.getCU(area.pos(), CH_L,TREE_D); + if (compID == COMP_Y) + { + initIntraPatternChType(*tu.cu, area); + if (predBuf) + { + piPred.copyFrom(predBuf->Y()); + } + else if (CU::isMIP(cu, CH_L)) + { + initIntraMip(cu); + predIntraMip(piPred, cu); + } + else + { + predIntraAng(COMP_Y, piPred, cu); + } + } - const PredictionUnit &pu = *cs.getPU(area.pos(), CH_L); - initIntraPatternChType(*tu.cu, area); - if( predBuf ) + //===== get residual signal ===== + if (isLuma(compID)) { - piPred.copyFrom( predBuf->Y() ); + if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag()) + { + piResi.subtract(cs.getRspOrgBuf(), piPred); + } + else + { + CPelBuf piOrg = cs.getOrgBuf(COMP_Y); + piResi.subtract(piOrg, piPred); + } } - else if (PU::isMIP(pu, CH_L)) + + if (isChroma(compID)) { - initIntraMip(pu); - predIntraMip( piPred, pu); + ComponentID codeCompId = (tu.jointCbCr ? (tu.jointCbCr >> 1 ? COMP_Cb : COMP_Cr) : compID); + m_pcTrQuant->checktransformsNxN(tu, trModes, m_pcEncCfg->m_MTSIntraMaxCand, codeCompId); } else + m_pcTrQuant->checktransformsNxN(tu, trModes, m_pcEncCfg->m_MTSIntraMaxCand, compID); +} + +double IntraSearch::xTestISP(CodingStructure& cs, Partitioner& subTuPartitioner, double bestCostForISP, PartSplit ispType, bool& splitcbf, uint64_t& singleFracBits, Distortion& singleDistLuma, CUCtx& cuCtx) +{ + int subTuCounter = 0; + bool earlySkipISP = false; + bool splitCbfLuma = false; + CodingUnit& cu = *cs.cus[0]; + + Distortion singleDistTmpLumaSUM = 0; + uint64_t singleTmpFracBitsSUM = 0; + double singleCostTmpSUM = 0; + cuCtx.isDQPCoded = true; + cuCtx.isChromaQpAdjCoded = true; + + do { - predIntraAng( COMP_Y, piPred, pu); - } + Distortion singleDistTmpLuma = 0; + uint64_t singleTmpFracBits = 0; + double singleCostTmp = 0; + TransformUnit& tmpTUcur = ((cs.tus.size() < (subTuCounter + 1))) + ? cs.addTU(CS::getArea(cs, subTuPartitioner.currArea(), subTuPartitioner.chType, + subTuPartitioner.treeType), + subTuPartitioner.chType, cs.cus[0]) + : *cs.tus[subTuCounter]; + tmpTUcur.depth = subTuPartitioner.currTrDepth; - //===== get residual signal ===== - if (cs.picHeader->lmcsEnabled && reshapeData.getCTUFlag()) + // Encode TU + xIntraCodingTUBlock(tmpTUcur, COMP_Y, false, singleDistTmpLuma, 0); + cuCtx.mtsLastScanPos = false; + + if (singleDistTmpLuma == MAX_INT) // all zero CBF skip + { + earlySkipISP = true; + singleCostTmpSUM = MAX_DOUBLE; + break; + } + + if (m_pcRdCost->calcRdCost(singleTmpFracBitsSUM, singleDistTmpLumaSUM + singleDistTmpLuma) > bestCostForISP) + { + earlySkipISP = true; + } + else + { + m_ispTestedModes[0].IspType = ispType; + m_ispTestedModes[0].subTuCounter = subTuCounter; + singleTmpFracBits = xGetIntraFracBitsQT(cs, subTuPartitioner, true, &cuCtx); + } + singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); + + singleCostTmpSUM += singleCostTmp; + singleDistTmpLumaSUM += singleDistTmpLuma; + singleTmpFracBitsSUM += singleTmpFracBits; + + subTuCounter++; + + splitCbfLuma |= TU::getCbfAtDepth( *cs.getTU(subTuPartitioner.currArea().lumaPos(), subTuPartitioner.chType, subTuCounter - 1), + COMP_Y, subTuPartitioner.currTrDepth); + int nSubPartitions = m_ispTestedModes[cu.lfnstIdx].numTotalParts[cu.ispMode - 1]; + bool doStop = (m_pcEncCfg->m_ISP != 1) || (subTuCounter < nSubPartitions); + if (doStop) + { + if (singleCostTmpSUM > bestCostForISP) + { + earlySkipISP = true; + break; + } + if (subTuCounter < nSubPartitions) + { + double threshold = nSubPartitions == 2 ? 0.95 : subTuCounter == 1 ? 0.83 : 0.91; + if (singleCostTmpSUM > bestCostForISP * threshold) + { + earlySkipISP = true; + break; + } + } + } + } while (subTuPartitioner.nextPart(cs)); + singleDistLuma = singleDistTmpLumaSUM; + singleFracBits = singleTmpFracBitsSUM; + + splitcbf = splitCbfLuma; + return earlySkipISP ? MAX_DOUBLE : singleCostTmpSUM; +} + +int IntraSearch::xSpeedUpISP(int speed, bool& testISP, int mode, int& noISP, int& endISP, CodingUnit& cu, static_vector& RdModeList, const ModeInfo& bestPUMode, int bestISP, int bestLfnstIdx) +{ + if (speed) { - piResi.subtract(cs.getRspOrgBuf(), piPred); + if (mode >= 1) + { + if (m_ispTestedModes[0].splitIsFinished[1] && m_ispTestedModes[0].splitIsFinished[0]) + { + testISP = false; + endISP = 0; + } + else + { + if (m_pcEncCfg->m_ISP >= 2) + { + if (mode == 1) //best Hor||Ver + { + int bestDir = 0; + for (int d = 0; d < 2; d++) + { + int d2 = d ? 0 : 1; + if ((m_ispTestedModes[0].bestCost[d] <= m_ispTestedModes[0].bestCost[d2]) + && (m_ispTestedModes[0].bestCost[d] != MAX_DOUBLE)) + { + bestDir = d + 1; + m_ispTestedModes[0].splitIsFinished[d2] = true; + } + } + m_ispTestedModes[0].bestModeSoFar = bestDir; + if (m_ispTestedModes[0].bestModeSoFar <= 0) + { + m_ispTestedModes[0].splitIsFinished[1] = true; + m_ispTestedModes[0].splitIsFinished[0] = true; + testISP = false; + endISP = 0; + } + } + if (m_ispTestedModes[0].bestModeSoFar == 2) + { + noISP = 1; + } + else + { + endISP = 1; + } + } + } + } + if (testISP) + { + if (mode == 2) + { + for (int d = 0; d < 2; d++) + { + int d2 = d ? 0 : 1; + if (m_ispTestedModes[0].bestCost[d] == MAX_DOUBLE) + { + m_ispTestedModes[0].splitIsFinished[d] = true; + } + if ((m_ispTestedModes[0].bestCost[d2] < 1.3 * m_ispTestedModes[0].bestCost[d]) + && (int(m_ispTestedModes[0].bestSplitSoFar) != (d + 1))) + { + if (d) + { + endISP = 1; + } + else + { + noISP = 1; + } + m_ispTestedModes[0].splitIsFinished[d] = true; + } + } + } + else + { + if (m_ispTestedModes[0].splitIsFinished[0]) + { + noISP = 1; + } + if (m_ispTestedModes[0].splitIsFinished[1]) + { + endISP = 1; + } + } + } + if ((noISP == 1) && (endISP == 1)) + { + endISP = 0; + } } else { - CPelBuf piOrg = cs.getOrgBuf(COMP_Y); - piResi.subtract( piOrg, piPred); + bool stopFound = false; + if (m_pcEncCfg->m_ISP >= 3) + { + if (mode) + { + if ((bestISP == 0) || ((bestPUMode.modeId != RdModeList[mode - 1].modeId) + && (bestPUMode.modeId != RdModeList[mode].modeId))) + { + stopFound = true; + } + } + } + if (cu.mipFlag || cu.multiRefIdx) + { + cu.mipFlag = false; + cu.multiRefIdx = 0; + if (!stopFound) + { + for (int k = 0; k < mode; k++) + { + if (cu.intraDir[CH_L] == RdModeList[k].modeId) + { + stopFound = true; + break; + } + } + } + } + if (stopFound) + { + testISP = false; + endISP = 0; + return 1; + } + if (!stopFound && (m_pcEncCfg->m_ISP >= 2) && (cu.intraDir[CH_L] == DC_IDX)) + { + stopFound = true; + endISP = 0; + return 1; + } } - - m_pcTrQuant->checktransformsNxN(tu, trModes, m_pcEncCfg->m_MTSIntraMaxCand); + return 0; } } // namespace vvenc diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index 4ead2fc52..58961d351 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file IntraSearch.h \brief intra search class (header) */ @@ -79,16 +83,55 @@ class IntraSearch : public IntraPrediction struct ModeInfo { bool mipFlg; // CU::mipFlag - bool mipTrFlg; // PU::mipTransposeFlag - int8_t mRefId; // PU::multiRefIdx + bool mipTrFlg; // CU::mipTransposeFlag + int8_t mRefId; // CU::multiRefIdx uint8_t ispMod; // CU::ispMode - uint8_t modeId; // PU::intraDir[CH_L] + uint8_t modeId; // CU::intraDir[CH_L] ModeInfo() : mipFlg(false), mipTrFlg(false), mRefId(0), ispMod(NOT_INTRA_SUBPARTITIONS), modeId(0) {} ModeInfo(const bool mipf, const bool miptf, const int8_t mrid, const uint8_t ispm, const uint8_t mode) : mipFlg(mipf), mipTrFlg(miptf), mRefId(mrid), ispMod(ispm), modeId(mode) {} bool operator==(const ModeInfo cmp) const { return (0 == ::memcmp(this,&cmp,sizeof(ModeInfo))); } }; + struct ISPTestedModesInfo + { + int numTotalParts[2]; + int bestModeSoFar; + ISPType bestSplitSoFar; + double bestCost[2]; + bool splitIsFinished[2]; + int subTuCounter; + PartSplit IspType; + + // set everything to default values + void clear() + { + for (int splitIdx = 0; splitIdx < NUM_INTRA_SUBPARTITIONS_MODES - 1; splitIdx++) + { + numTotalParts[splitIdx] = 0; + splitIsFinished[splitIdx] = false; + bestCost[splitIdx] = MAX_DOUBLE; + } + bestModeSoFar = -1; + bestSplitSoFar = NOT_INTRA_SUBPARTITIONS; + subTuCounter = -1; + IspType = TU_NO_ISP; + } + void init(const int numTotalPartsHor, const int numTotalPartsVer) + { + clear(); + const int horSplit = HOR_INTRA_SUBPARTITIONS - 1, verSplit = VER_INTRA_SUBPARTITIONS - 1; + numTotalParts[horSplit] = numTotalPartsHor; + numTotalParts[verSplit] = numTotalPartsVer; + splitIsFinished[horSplit] = (numTotalParts[horSplit] == 0); + splitIsFinished[verSplit] = (numTotalParts[verSplit] == 0); + subTuCounter = -1; + IspType = TU_NO_ISP; + } + }; + + ISPTestedModesInfo m_ispTestedModes[NUM_LFNST_NUM_PER_SET]; + protected: // interface to option const EncCfg* m_pcEncCfg; @@ -117,11 +160,11 @@ class IntraSearch : public IntraPrediction void initCuAreaCostInSCIPU (); bool estIntraPredLumaQT ( CodingUnit &cu, Partitioner &pm, double bestCost = MAX_DOUBLE); - void estIntraPredChromaQT ( CodingUnit &cu, Partitioner& pm ); + void estIntraPredChromaQT ( CodingUnit& cu, Partitioner& partitioner, const double maxCostAllowed ); private: double xFindInterCUCost ( CodingUnit &cu ); - void xPreCheckMTS ( TransformUnit &tu, std::vector *trModes, const int maxCand, PelUnitBuf *pPred); + void xPreCheckMTS ( TransformUnit &tu, std::vector *trModes, const int maxCand, PelUnitBuf *pPred, const ComponentID& compID = COMP_Y); void xEstimateLumaRdModeList ( int& numModesForFullRD, static_vector& RdModeList, static_vector& HadModeList, @@ -131,7 +174,7 @@ class IntraSearch : public IntraPrediction // ------------------------------------------------------------------------------------------------------------------- // Intra search // ------------------------------------------------------------------------------------------------------------------- - uint64_t xFracModeBitsIntraLuma ( const PredictionUnit &pu ); + uint64_t xFracModeBitsIntraLuma ( const CodingUnit& cu, const unsigned* mpmLst ); void xEncIntraHeader ( CodingStructure &cs, Partitioner& pm, const bool luma ); void xEncSubdivCbfQT ( CodingStructure &cs, Partitioner& pm, const bool luma ); @@ -139,14 +182,16 @@ class IntraSearch : public IntraPrediction uint64_t xGetIntraFracBitsQTChroma ( const TransformUnit& tu, const ComponentID compID, CUCtx *cuCtx ); - void xEncCoeffQT ( CodingStructure &cs, Partitioner &pm, const ComponentID compID, CUCtx *cuCtx = nullptr ); + void xEncCoeffQT ( CodingStructure& cs, Partitioner& pm, const ComponentID compID, CUCtx* cuCtx = nullptr, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP ); void xIntraCodingTUBlock ( TransformUnit &tu, const ComponentID compID, const bool checkCrossCPrediction, Distortion &ruiDist, uint32_t *numSig = nullptr, PelUnitBuf *pPred = nullptr, const bool loadTr = false); - void xIntraChromaCodingQT ( CodingStructure &cs, Partitioner& pm ); - void xIntraCodingLumaQT ( CodingStructure &cs, Partitioner &pm, PelUnitBuf *pPred, const double bestCostSoFar ); + ChromaCbfs xIntraChromaCodingQT ( CodingStructure& cs, Partitioner& pm ); + void xIntraCodingLumaQT ( CodingStructure& cs, Partitioner& pm, PelUnitBuf* pPred, const double bestCostSoFar, int numMode ); + double xTestISP ( CodingStructure& cs, Partitioner& pm, double bestCostSoFar, PartSplit ispType, bool& splitcbf, uint64_t& singleFracBits, Distortion& singleDistLuma, CUCtx& cuCtx); + int xSpeedUpISP ( int speed, bool& testISP, int mode, int& noISP, int& endISP, CodingUnit& cu, static_vector& RdModeList,const ModeInfo& bestPUMode, int bestISP, int bestLfnstIdx); template - void xReduceHadCandList ( static_vector& candModeList, static_vector& candCostList, SortedPelUnitBufs& sortedPelBuffer, int& numModesForFullRD, const double thresholdHadCost, const double* mipHadCost, const PredictionUnit &pu, const bool fastMip); + void xReduceHadCandList ( static_vector& candModeList, static_vector& candCostList, SortedPelUnitBufs& sortedPelBuffer, int& numModesForFullRD, const double thresholdHadCost, const double* mipHadCost, const CodingUnit& cu, const bool fastMip); };// END CLASS DEFINITION EncSearch diff --git a/source/Lib/EncoderLib/NALwrite.cpp b/source/Lib/EncoderLib/NALwrite.cpp index 7eb13e900..587d4331b 100644 --- a/source/Lib/EncoderLib/NALwrite.cpp +++ b/source/Lib/EncoderLib/NALwrite.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ #include "NALwrite.h" @@ -46,7 +50,7 @@ vvc@hhi.fraunhofer.de #include #include #include -#include "../../../include/vvenc/Nal.h" +#include "vvenc/Nal.h" //! \ingroup EncoderLib //! \{ diff --git a/source/Lib/EncoderLib/NALwrite.h b/source/Lib/EncoderLib/NALwrite.h index 31f2e6faa..4e7321686 100644 --- a/source/Lib/EncoderLib/NALwrite.h +++ b/source/Lib/EncoderLib/NALwrite.h @@ -1,50 +1,54 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include "CommonLib/CommonDef.h" #include "CommonLib/BitStream.h" #include -#include "../../../include/vvenc/Nal.h" +#include "vvenc/Nal.h" //! \ingroup EncoderLib //! \{ diff --git a/source/Lib/EncoderLib/RateCtrl.cpp b/source/Lib/EncoderLib/RateCtrl.cpp index 2198e2bfd..b3369438f 100644 --- a/source/Lib/EncoderLib/RateCtrl.cpp +++ b/source/Lib/EncoderLib/RateCtrl.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -3. LIMITED PATENT LICENSE +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -4. DISCLAIMER -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file RateCtrl.cpp @@ -56,8 +60,10 @@ static const int RC_MAX_PIC_LIST_SIZE = 64; static const int RC_ITERATION_NUM = 20; static const int RC_LCU_SMOOTH_WINDOW_SIZE = 4; static const int RC_LAMBDA_PREC = 1000000; -static const int RC_GOP_ID_QP_OFFSET[ 6 ] = { 0, 0, 0, 3, 1, 1 }; -static const int RC_GOP_ID_QP_OFFSET_GRC[ 6 ] = { 0, 3, 0, 3, 1, 1 }; +static const int RC_GOP_ID_QP_OFFSET[ 6 ] = { 0, 0, 0, 3, 1, 1 }; +static const int RC_GOP_ID_QP_OFFSET_GOP32[ 7 ] = { 0, 0, 0, 0, 3, 1, 1 }; +static const int RC_GOP_ID_QP_OFFSET_GRC[ 6 ] = { 0, 3, 0, 3, 1, 1 }; +static const int RC_GOP_ID_QP_OFFSET_GRC_GOP32[ 7 ] = { 0, 0, 3, 0, 3, 1, 1 }; static const double RC_WEIGHT_PIC_TARGET_BIT_IN_GOP = 0.9; static const double RC_WEIGHT_PIC_TARGET_BIT_IN_BUFFER = 1.0 - RC_WEIGHT_PIC_TARGET_BIT_IN_GOP; static const double RC_WEIGHT_HISTORY_LAMBDA = 0.5; @@ -74,6 +80,7 @@ static const double RC_BETA2 = 1.7860; EncRCSeq::EncRCSeq() { rcMode = 0; + twoPass = false; totalFrames = 0; targetRate = 0; frameRate = 0; @@ -96,12 +103,11 @@ EncRCSeq::EncRCSeq() bitsUsed = 0; framesLeft = 0; bitsLeft = 0; + estimatedBitUsage = 0; useLCUSeparateModel = false; adaptiveBits = 0; + bitUsageRatio = 0.0; lastLambda = 0.0; - seqTargetBpp = 0.0; - alphaUpdate = 0.0; - betaUpdate = 0.0; bitDepth = 0; } @@ -110,10 +116,11 @@ EncRCSeq::~EncRCSeq() destroy(); } -void EncRCSeq::create( int RCMode, int totFrames, int targetBitrate, int frRate, int intraPer, int GOPSize, int pictureWidth, int pictureHeight, int LCUWidth, int LCUHeight, int numOfLevel, bool useLCUSepModel, int adaptiveBit ) +void EncRCSeq::create( int RCMode, bool twoPassRC, int totFrames, int targetBitrate, int frRate, int intraPer, int GOPSize, int pictureWidth, int pictureHeight, int LCUWidth, int LCUHeight, int numOfLevel, bool useLCUSepModel, int adaptiveBit, std::list &firstPassStats ) { destroy(); rcMode = RCMode; + twoPass = twoPassRC; totalFrames = totFrames; targetRate = targetBitrate; frameRate = frRate; @@ -125,35 +132,10 @@ void EncRCSeq::create( int RCMode, int totFrames, int targetBitrate, int frRate, lcuHeight = LCUHeight; numberOfLevel = numOfLevel; useLCUSeparateModel = useLCUSepModel; + firstPassData = firstPassStats; numberOfPixel = picWidth * picHeight; targetBits = (int64_t)totalFrames * (int64_t)targetRate / (int64_t)frameRate; - seqTargetBpp = (double)targetRate / (double)frameRate / (double)numberOfPixel; - if ( seqTargetBpp < 0.03 ) - { - alphaUpdate = 0.01; - betaUpdate = 0.005; - } - else if ( seqTargetBpp < 0.08 ) - { - alphaUpdate = 0.05; - betaUpdate = 0.025; - } - else if ( seqTargetBpp < 0.2 ) - { - alphaUpdate = 0.1; - betaUpdate = 0.05; - } - else if ( seqTargetBpp < 0.5 ) - { - alphaUpdate = 0.2; - betaUpdate = 0.1; - } - else - { - alphaUpdate = 0.4; - betaUpdate = 0.2; - } averageBits = (int)( targetRate / frameRate ); int picWidthInBU = ( picWidth % lcuWidth ) == 0 ? picWidth / lcuWidth : picWidth / lcuWidth + 1; @@ -201,6 +183,8 @@ void EncRCSeq::create( int RCMode, int totFrames, int targetBitrate, int frRate, bitsUsed = 0; framesLeft = totalFrames; bitsLeft = targetBits; + estimatedBitUsage = 0; + bitUsageRatio = 0.0; adaptiveBits = adaptiveBit; lastLambda = 0.0; } @@ -320,6 +304,28 @@ void EncRCSeq::updateAfterPic ( int bits ) framesLeft--; } +void EncRCSeq::getTargetBitsFromFirstPass( int numPicCoded, int &targetBits, double &gopVsBitrateRatio, bool &isNewScene, double alpha[] ) +{ + int picCounter = 0; + int numOfLevels = int( log( gopSize ) / log( 2 ) + 0.5 ) + 2; + + std::list::iterator it; + for ( it = firstPassData.begin(); it != firstPassData.end(); it++, picCounter++ ) + { + if ( numPicCoded == picCounter ) + { + targetBits = it->targetBits; + gopVsBitrateRatio = it->gopBitsVsBitrate; + isNewScene = it->isNewScene; + for ( int i = 0; i < numOfLevels; i++ ) + { + alpha[ i ] = it->estAlpha[ i ]; + } + break; + } + } +} + void EncRCSeq::setAllBitRatio( double basicLambda, double* equaCoeffA, double* equaCoeffB ) { int* bitsRatio = new int[ gopSize ]; @@ -385,123 +391,161 @@ void EncRCGOP::create( EncRCSeq* encRCSeq, int numPic ) double* equaCoeffA = new double[ encRCSeq->gopSize ]; double* equaCoeffB = new double[ encRCSeq->gopSize ]; - if ( encRCSeq->adaptiveBits == 1 ) // for GOP size = 4, low delay case + if ( encRCSeq->adaptiveBits == 1 && encRCSeq->gopSize == 4 ) // for GOP size = 4, low delay case { if ( encRCSeq->lastLambda < 120.0 ) { - lambdaRatio[1] = 0.725 * log( encRCSeq->lastLambda ) + 0.5793; - lambdaRatio[0] = 1.3 * lambdaRatio[1]; - lambdaRatio[2] = 1.3 * lambdaRatio[1]; - lambdaRatio[3] = 1.0; + lambdaRatio[ 1 ] = 0.725 * log( encRCSeq->lastLambda ) + 0.5793; + lambdaRatio[ 0 ] = 1.3 * lambdaRatio[ 1 ]; + lambdaRatio[ 2 ] = 1.3 * lambdaRatio[ 1 ]; + lambdaRatio[ 3 ] = 1.0; } else { - lambdaRatio[0] = 5.0; - lambdaRatio[1] = 4.0; - lambdaRatio[2] = 5.0; - lambdaRatio[3] = 1.0; + lambdaRatio[ 0 ] = 5.0; + lambdaRatio[ 1 ] = 4.0; + lambdaRatio[ 2 ] = 5.0; + lambdaRatio[ 3 ] = 1.0; } } - else if ( encRCSeq->adaptiveBits == 2 ) // for GOP size = 8, random access case + else if ( encRCSeq->adaptiveBits == 2 && encRCSeq->gopSize == 8 ) // for GOP size = 8, random access case { if ( encRCSeq->lastLambda < 90.0 ) { - lambdaRatio[0] = 1.0; - lambdaRatio[1] = 0.725 * log( encRCSeq->lastLambda ) + 0.7963; - lambdaRatio[2] = 1.3 * lambdaRatio[1]; - lambdaRatio[3] = 3.25 * lambdaRatio[1]; - lambdaRatio[4] = 3.25 * lambdaRatio[1]; - lambdaRatio[5] = 1.3 * lambdaRatio[1]; - lambdaRatio[6] = 3.25 * lambdaRatio[1]; - lambdaRatio[7] = 3.25 * lambdaRatio[1]; + lambdaRatio[ 0 ] = 1.0; + lambdaRatio[ 1 ] = 0.725 * log( encRCSeq->lastLambda ) + 0.7963; + lambdaRatio[ 2 ] = 1.3 * lambdaRatio[ 1 ]; + lambdaRatio[ 3 ] = 3.25 * lambdaRatio[ 1 ]; + lambdaRatio[ 4 ] = 3.25 * lambdaRatio[ 1 ]; + lambdaRatio[ 5 ] = 1.3 * lambdaRatio[ 1 ]; + lambdaRatio[ 6 ] = 3.25 * lambdaRatio[ 1 ]; + lambdaRatio[ 7 ] = 3.25 * lambdaRatio[ 1 ]; } else { - lambdaRatio[0] = 1.0; - lambdaRatio[1] = 4.0; - lambdaRatio[2] = 5.0; - lambdaRatio[3] = 12.3; - lambdaRatio[4] = 12.3; - lambdaRatio[5] = 5.0; - lambdaRatio[6] = 12.3; - lambdaRatio[7] = 12.3; + lambdaRatio[ 0 ] = 1.0; + lambdaRatio[ 1 ] = 4.0; + lambdaRatio[ 2 ] = 5.0; + lambdaRatio[ 3 ] = 12.3; + lambdaRatio[ 4 ] = 12.3; + lambdaRatio[ 5 ] = 5.0; + lambdaRatio[ 6 ] = 12.3; + lambdaRatio[ 7 ] = 12.3; } } - else if (encRCSeq->adaptiveBits == 3) // for GOP size = 16, random access case + else if ( encRCSeq->adaptiveBits == 2 && encRCSeq->gopSize == 16 ) // for GOP size = 16, random access case { - { - int bitdepthLumaScale = 2 * ( encRCSeq->bitDepth - 8 - DISTORTION_PRECISION_ADJUSTMENT( encRCSeq->bitDepth ) ); - - double hierarQp = 4.2005 * log(encRCSeq->lastLambda / pow(2.0, bitdepthLumaScale )) + 13.7122; // the qp of POC16 - double qpLev2 = (hierarQp + 0.0) + 0.2016 * (hierarQp + 0.0) - 4.8848; - double qpLev3 = (hierarQp + 3.0) + 0.22286 * (hierarQp + 3.0) - 5.7476; - double qpLev4 = (hierarQp + 4.0) + 0.2333 * (hierarQp + 4.0) - 5.9; - double qpLev5 = (hierarQp + 5.0) + 0.3 * (hierarQp + 5.0) - 7.1444; - - double lambdaLev1 = exp( ( hierarQp - 13.7122 ) / 4.2005 ) * pow( 2.0, bitdepthLumaScale ); - double lambdaLev2 = exp( ( qpLev2 - 13.7122 ) / 4.2005 ) * pow( 2.0, bitdepthLumaScale ); - double lambdaLev3 = exp( ( qpLev3 - 13.7122 ) / 4.2005 ) * pow( 2.0, bitdepthLumaScale ); - double lambdaLev4 = exp( ( qpLev4 - 13.7122 ) / 4.2005 ) * pow( 2.0, bitdepthLumaScale ); - double lambdaLev5 = exp( ( qpLev5 - 13.7122 ) / 4.2005 ) * pow( 2.0, bitdepthLumaScale ); - - lambdaRatio[0] = 1.0; - lambdaRatio[1] = lambdaLev2 / lambdaLev1; - lambdaRatio[2] = lambdaLev3 / lambdaLev1; - lambdaRatio[3] = lambdaLev4 / lambdaLev1; - lambdaRatio[4] = lambdaLev5 / lambdaLev1; - lambdaRatio[5] = lambdaLev5 / lambdaLev1; - lambdaRatio[6] = lambdaLev4 / lambdaLev1; - lambdaRatio[7] = lambdaLev5 / lambdaLev1; - lambdaRatio[8] = lambdaLev5 / lambdaLev1; - lambdaRatio[9] = lambdaLev3 / lambdaLev1; - lambdaRatio[10] = lambdaLev4 / lambdaLev1; - lambdaRatio[11] = lambdaLev5 / lambdaLev1; - lambdaRatio[12] = lambdaLev5 / lambdaLev1; - lambdaRatio[13] = lambdaLev4 / lambdaLev1; - lambdaRatio[14] = lambdaLev5 / lambdaLev1; - lambdaRatio[15] = lambdaLev5 / lambdaLev1; - const double qdfParaLev2A = 0.5847; - const double qdfParaLev2B = -0.0782; - const double qdfParaLev3A = 0.5468; - const double qdfParaLev3B = -0.1364; - const double qdfParaLev4A = 0.6539; - const double qdfParaLev4B = -0.203; - const double qdfParaLev5A = 0.8623; - const double qdfParaLev5B = -0.4676; - double qdfLev1Lev2 = Clip3( 0.12, 0.9, qdfParaLev2A * encRCSeq->picParam[ 2 ].skipRatio + qdfParaLev2B ); - double qdfLev1Lev3 = Clip3( 0.13, 0.9, qdfParaLev3A * encRCSeq->picParam[ 3 ].skipRatio + qdfParaLev3B ); - double qdfLev1Lev4 = Clip3( 0.15, 0.9, qdfParaLev4A * encRCSeq->picParam[ 4 ].skipRatio + qdfParaLev4B ); - double qdfLev1Lev5 = Clip3( 0.20, 0.9, qdfParaLev5A * encRCSeq->picParam[ 5 ].skipRatio + qdfParaLev5B ); - double qdfLev2Lev3 = Clip3(0.09, 0.9, qdfLev1Lev3 * (1 - qdfLev1Lev2)); - double qdfLev2Lev4 = Clip3(0.12, 0.9, qdfLev1Lev4 * (1 - qdfLev1Lev2)); - double qdfLev2Lev5 = Clip3(0.14, 0.9, qdfLev1Lev5 * (1 - qdfLev1Lev2)); - double qdfLev3Lev4 = Clip3(0.06, 0.9, qdfLev1Lev4 * (1 - qdfLev1Lev3)); - double qdfLev3Lev5 = Clip3(0.09, 0.9, qdfLev1Lev5 * (1 - qdfLev1Lev3)); - double qdfLev4Lev5 = Clip3(0.10, 0.9, qdfLev1Lev5 * (1 - qdfLev1Lev4)); - - lambdaLev1 = 1 / (1 + 2 * (qdfLev1Lev2 + 2 * qdfLev1Lev3 + 4 * qdfLev1Lev4 + 8 * qdfLev1Lev5)); - lambdaLev2 = 1 / (1 + (3 * qdfLev2Lev3 + 5 * qdfLev2Lev4 + 8 * qdfLev2Lev5)); - lambdaLev3 = 1 / (1 + 2 * qdfLev3Lev4 + 4 * qdfLev3Lev5); - lambdaLev4 = 1 / (1 + 2 * qdfLev4Lev5); - lambdaLev5 = 1 / (1.0); - - lambdaRatio[0] = 1.0; - lambdaRatio[1] = lambdaLev2 / lambdaLev1; - lambdaRatio[2] = lambdaLev3 / lambdaLev1; - lambdaRatio[3] = lambdaLev4 / lambdaLev1; - lambdaRatio[4] = lambdaLev5 / lambdaLev1; - lambdaRatio[5] = lambdaLev5 / lambdaLev1; - lambdaRatio[6] = lambdaLev4 / lambdaLev1; - lambdaRatio[7] = lambdaLev5 / lambdaLev1; - lambdaRatio[8] = lambdaLev5 / lambdaLev1; - lambdaRatio[9] = lambdaLev3 / lambdaLev1; - lambdaRatio[10] = lambdaLev4 / lambdaLev1; - lambdaRatio[11] = lambdaLev5 / lambdaLev1; - lambdaRatio[12] = lambdaLev5 / lambdaLev1; - lambdaRatio[13] = lambdaLev4 / lambdaLev1; - lambdaRatio[14] = lambdaLev5 / lambdaLev1; - lambdaRatio[15] = lambdaLev5 / lambdaLev1; - } + const double qdfParaLev2A = 0.5847; + const double qdfParaLev2B = -0.0782; + const double qdfParaLev3A = 0.5468; + const double qdfParaLev3B = -0.1364; + const double qdfParaLev4A = 0.6539; + const double qdfParaLev4B = -0.203; + const double qdfParaLev5A = 0.8623; + const double qdfParaLev5B = -0.4676; + double qdfLev1Lev2 = Clip3( 0.12, 0.9, qdfParaLev2A * encRCSeq->picParam[ 2 ].skipRatio + qdfParaLev2B ); + double qdfLev1Lev3 = Clip3( 0.13, 0.9, qdfParaLev3A * encRCSeq->picParam[ 3 ].skipRatio + qdfParaLev3B ); + double qdfLev1Lev4 = Clip3( 0.15, 0.9, qdfParaLev4A * encRCSeq->picParam[ 4 ].skipRatio + qdfParaLev4B ); + double qdfLev1Lev5 = Clip3( 0.20, 0.9, qdfParaLev5A * encRCSeq->picParam[ 5 ].skipRatio + qdfParaLev5B ); + double qdfLev2Lev3 = Clip3( 0.09, 0.9, qdfLev1Lev3 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev2Lev4 = Clip3( 0.12, 0.9, qdfLev1Lev4 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev2Lev5 = Clip3( 0.14, 0.9, qdfLev1Lev5 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev3Lev4 = Clip3( 0.06, 0.9, qdfLev1Lev4 * ( 1 - qdfLev1Lev3 ) ); + double qdfLev3Lev5 = Clip3( 0.09, 0.9, qdfLev1Lev5 * ( 1 - qdfLev1Lev3 ) ); + double qdfLev4Lev5 = Clip3( 0.10, 0.9, qdfLev1Lev5 * ( 1 - qdfLev1Lev4 ) ); + + double lambdaLev1 = 1 / ( 1 + 2 * ( qdfLev1Lev2 + 2 * qdfLev1Lev3 + 4 * qdfLev1Lev4 + 8 * qdfLev1Lev5 ) ); + double lambdaLev2 = 1 / ( 1 + ( 3 * qdfLev2Lev3 + 5 * qdfLev2Lev4 + 8 * qdfLev2Lev5 ) ); + double lambdaLev3 = 1 / ( 1 + 2 * qdfLev3Lev4 + 4 * qdfLev3Lev5 ); + double lambdaLev4 = 1 / ( 1 + 2 * qdfLev4Lev5 ); + double lambdaLev5 = 1 / ( 1.0 ); + + lambdaRatio[ 0 ] = 1.0; + lambdaRatio[ 1 ] = lambdaLev2 / lambdaLev1; + lambdaRatio[ 2 ] = lambdaLev3 / lambdaLev1; + lambdaRatio[ 3 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 4 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 5 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 6 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 7 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 8 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 9 ] = lambdaLev3 / lambdaLev1; + lambdaRatio[ 10 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 11 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 12 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 13 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 14 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 15 ] = lambdaLev5 / lambdaLev1; + } + else if ( encRCSeq->adaptiveBits == 2 && encRCSeq->gopSize == 32 ) // for GOP size = 32, random access case + { + const double qdfParaLev2A = 0.7534; + const double qdfParaLev2B = -0.0303; + const double qdfParaLev3A = 0.7044; + const double qdfParaLev3B = -0.0445; + const double qdfParaLev4A = 0.7084; + const double qdfParaLev4B = -0.1401; + const double qdfParaLev5A = 0.8844; + const double qdfParaLev5B = -0.3676; + const double qdfParaLev6A = 1.2336; + const double qdfParaLev6B = -0.7511; + + double qdfLev1Lev2 = Clip3( 0.12, 0.9, qdfParaLev2A * encRCSeq->picParam[ 2 ].skipRatio + qdfParaLev2B ); + double qdfLev1Lev3 = Clip3( 0.13, 0.9, qdfParaLev3A * encRCSeq->picParam[ 3 ].skipRatio + qdfParaLev3B ); + double qdfLev1Lev4 = Clip3( 0.15, 0.9, qdfParaLev4A * encRCSeq->picParam[ 4 ].skipRatio + qdfParaLev4B ); + double qdfLev1Lev5 = Clip3( 0.20, 0.9, qdfParaLev5A * encRCSeq->picParam[ 5 ].skipRatio + qdfParaLev5B ); + double qdfLev1Lev6 = Clip3( 0.25, 0.9, qdfParaLev6A * encRCSeq->picParam[ 6 ].skipRatio + qdfParaLev6B ); + + double qdfLev2Lev3 = Clip3( 0.09, 0.9, qdfLev1Lev3 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev2Lev4 = Clip3( 0.12, 0.9, qdfLev1Lev4 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev2Lev5 = Clip3( 0.14, 0.9, qdfLev1Lev5 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev2Lev6 = Clip3( 0.16, 0.9, qdfLev1Lev6 * ( 1 - qdfLev1Lev2 ) ); + double qdfLev3Lev4 = Clip3( 0.06, 0.9, qdfLev1Lev4 * ( 1 - qdfLev1Lev3 ) ); + double qdfLev3Lev5 = Clip3( 0.09, 0.9, qdfLev1Lev5 * ( 1 - qdfLev1Lev3 ) ); + double qdfLev3Lev6 = Clip3( 0.10, 0.9, qdfLev1Lev6 * ( 1 - qdfLev1Lev3 ) ); + double qdfLev4Lev5 = Clip3( 0.10, 0.9, qdfLev1Lev5 * ( 1 - qdfLev1Lev4 ) ); + double qdfLev4Lev6 = Clip3( 0.10, 0.9, qdfLev1Lev6 * ( 1 - qdfLev1Lev4 ) ); + double qdfLev5Lev6 = Clip3( 0.12, 0.9, qdfLev1Lev6 * ( 1 - qdfLev1Lev5 ) ); + + double lambdaLev1 = 1 / ( 1 + 2 * qdfLev1Lev2 + 4 * qdfLev1Lev3 + 6 * qdfLev1Lev4 + 8 * qdfLev1Lev5 + 10 * qdfLev1Lev6 ); + double lambdaLev2 = 1 / ( 1 + 3 * qdfLev2Lev3 + 5 * qdfLev2Lev4 + 8 * qdfLev2Lev5 + 9 * qdfLev2Lev6 ); + double lambdaLev3 = 1 / ( 1 + 2 * qdfLev3Lev4 + 4 * qdfLev3Lev5 + 6 * qdfLev3Lev6 ); + double lambdaLev4 = 1 / ( 1 + 2 * qdfLev4Lev5 + 4 * qdfLev4Lev6 ); + double lambdaLev5 = 1 / ( 1 + 2 * qdfLev5Lev6 ); + double lambdaLev6 = 1 / ( 1.0 ); + + lambdaRatio[ 0 ] = 1.0; + lambdaRatio[ 1 ] = lambdaLev2 / lambdaLev1; + lambdaRatio[ 2 ] = lambdaLev3 / lambdaLev1; + lambdaRatio[ 3 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 4 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 5 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 6 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 7 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 8 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 9 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 10 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 11 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 12 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 13 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 14 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 15 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 16 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 17 ] = lambdaLev3 / lambdaLev1; + lambdaRatio[ 18 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 19 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 20 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 21 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 22 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 23 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 24 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 25 ] = lambdaLev4 / lambdaLev1; + lambdaRatio[ 26 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 27 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 28 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 29 ] = lambdaLev5 / lambdaLev1; + lambdaRatio[ 30 ] = lambdaLev6 / lambdaLev1; + lambdaRatio[ 31 ] = lambdaLev6 / lambdaLev1; } xCalEquaCoeff( encRCSeq, lambdaRatio, equaCoeffA, equaCoeffB, encRCSeq->gopSize ); @@ -639,6 +683,7 @@ EncRCPic::EncRCPic() picLambda = 0.0; picMSE = 0.0; validPixelsInPic = 0; + isNewScene = false; } EncRCPic::~EncRCPic() @@ -666,11 +711,44 @@ int EncRCPic::xEstPicTargetBits( EncRCSeq* encRcSeq, EncRCGOP* encRcGOP ) targetBits = 100; // at least allocate 100 bits for one picture } - if ( encRCSeq->framesLeft > 16 || encRCSeq->totalFrames < 1 ) + if ( encRCSeq->framesLeft > encRCSeq->gopSize || encRCSeq->totalFrames < 1 ) { targetBits = int( RC_WEIGHT_PIC_TARGET_BIT_IN_BUFFER * targetBits + RC_WEIGHT_PIC_TARGET_BIT_IN_GOP * encRCGOP->picTargetBitInGOP[ currPicPosition ] ); } + // bit allocation for 2-pass RC + if ( encRcSeq->twoPass ) + { + double gopVsBitrateRatio = 1.0; + int tmpTargetBits = 0; + double alpha[ 7 ] = { 0.0 }; + encRcSeq->getTargetBitsFromFirstPass( encRcSeq->framesCoded, tmpTargetBits, gopVsBitrateRatio, isNewScene, alpha ); + if ( currPicPosition == 0 || encRCSeq->framesLeft < encRcSeq->gopSize ) + { + targetBits = int( ( encRcSeq->estimatedBitUsage - encRcSeq->bitsUsed ) * gopVsBitrateRatio + tmpTargetBits ); // calculate the difference of under/overspent bits and adjust the current target bits based on the gop ratio only for the first frame in the gop + } + else + { + targetBits = tmpTargetBits; + } + + if ( encRcSeq->bitsUsed > 0 ) + { + encRcSeq->bitUsageRatio = double( encRcSeq->estimatedBitUsage ) / encRcSeq->bitsUsed; + } + encRcSeq->estimatedBitUsage += int64_t( tmpTargetBits ); + if ( isNewScene ) + { + int bitdepthLumaScale = 2 * ( encRCSeq->bitDepth - 8 - DISTORTION_PRECISION_ADJUSTMENT( encRCSeq->bitDepth ) ); + int numOfLevels = int( log( encRcSeq->gopSize ) / log( 2 ) + 0.5 ) + 2; + for ( int i = 1; i < numOfLevels; i++ ) + { + encRCSeq->picParam[ i ].alpha = alpha[ i ] * pow( 2.0, bitdepthLumaScale ); + encRcSeq->picParam[ i ].beta = -1.367; + } + } + } + return targetBits; } @@ -812,6 +890,284 @@ double EncRCPic::estimatePicLambda( std::list& listPreviousPictures, estLambda = alpha * pow( bpp, beta ); } + switch ( encRCSeq->rcMode ) + { + case 1: + clipLambdaConventional( listPreviousPictures, estLambda, bitdepthLumaScale ); + break; + case 2: + if ( encRCSeq->twoPass ) + { + clipLambdaTwoPass( listPreviousPictures, estLambda, bitdepthLumaScale ); + } + else + { + clipLambdaFrameRc( listPreviousPictures, estLambda, bitdepthLumaScale ); + } + break; + case 3: + clipLambdaGopRc( listPreviousPictures, estLambda, bitdepthLumaScale ); + break; + default: + clipLambdaConventional( listPreviousPictures, estLambda, bitdepthLumaScale ); + break; + } + + //Avoid different results in different platforms. The problem is caused by the different results of pow() in different platforms. + estLambda = double( int64_t( estLambda * (double)RC_LAMBDA_PREC + 0.5 ) ) / (double)RC_LAMBDA_PREC; + picEstLambda = estLambda; + + double totalWeight = 0.0; + // initial BU bit allocation weight + for ( int i = 0; i < numberOfLCU; i++ ) + { + double alphaLCU, betaLCU; + if ( encRCSeq->useLCUSeparateModel ) + { + alphaLCU = encRCSeq->lcuParam[ frameLevel][ i ].alpha; + betaLCU = encRCSeq->lcuParam[ frameLevel][ i ].beta; + } + else + { + alphaLCU = encRCSeq->picParam[ frameLevel ].alpha; + betaLCU = encRCSeq->picParam[ frameLevel ].beta; + } + + lcu[ i ].bitWeight = lcu[ i ].numberOfPixel * pow( estLambda / alphaLCU, 1.0 / betaLCU ); + + if ( lcu[ i ].bitWeight < 0.01 ) + { + lcu[ i ].bitWeight = 0.01; + } + totalWeight += lcu[ i ].bitWeight; + } + for ( int i = 0; i < numberOfLCU; i++ ) + { + double BUTargetBits = targetBits * lcu[ i ].bitWeight / totalWeight; + lcu[ i ].bitWeight = BUTargetBits; + } + + return estLambda; +} + +void EncRCPic::clipLambdaConventional( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ) +{ + double lastLevelLambda = -1.0; + double lastPicLambda = -1.0; + double lastValidLambda = -1.0; + std::list::iterator it; + for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) + { + if ( ( *it )->frameLevel == frameLevel ) + { + lastLevelLambda = ( *it )->picLambda; + } + lastPicLambda = ( *it )->picLambda; + + if ( lastPicLambda > 0.0 ) + { + lastValidLambda = lastPicLambda; + } + } + + if ( lastLevelLambda > 0.0 ) + { + lastLevelLambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lastLevelLambda ); + lambda = Clip3( lastLevelLambda * pow( 2.0, -3.0 / 3.0 ), lastLevelLambda * pow( 2.0, 3.0 / 3.0 ), lambda ); + } + + if ( lastPicLambda > 0.0 ) + { + lastPicLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastPicLambda ); + lambda = Clip3( lastPicLambda * pow( 2.0, -10.0 / 3.0 ), lastPicLambda * pow( 2.0, 10.0 / 3.0 ), lambda ); + } + else if ( lastValidLambda > 0.0 ) + { + lastValidLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastValidLambda ); + lambda = Clip3( lastValidLambda * pow( 2.0, -10.0 / 3.0 ), lastValidLambda * pow( 2.0, 10.0 / 3.0 ), lambda ); + } + else + { + lambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lambda ); + } + + if ( lambda < encRCGOP->minEstLambda ) + { + lambda = encRCGOP->minEstLambda; + } +} + +void EncRCPic::clipLambdaFrameRc( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ) +{ + bool setLastLevelLambda = false; + double lastPrevTLLambda = -1.0; + double lastLevelLambda = -1.0; + double lastPicLambda = -1.0; + double lastValidLambda = -1.0; + std::list::iterator it; + for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) + { + if ( ( *it )->frameLevel == frameLevel - 1 && ( *it )->picLambda > 0.0 ) + { + lastPrevTLLambda = ( *it )->picLambda; + } + if ( ( *it )->frameLevel == frameLevel && ( *it )->picLambda > 0.0 ) + { + lastLevelLambda = ( *it )->picLambda; + setLastLevelLambda = true; + } + else if ( encRCSeq->framesCoded < encRCSeq->gopSize && ( *it )->frameLevel < frameLevel && ( *it )->picLambda > 0.0 && !setLastLevelLambda ) + { + lastLevelLambda = ( *it )->picLambda; + } + lastPicLambda = ( *it )->picLambda; + + if ( lastPicLambda > 0.0 ) + { + lastValidLambda = lastPicLambda; + } + } + + if ( lastLevelLambda > 0.0 ) + { + lastLevelLambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lastLevelLambda ); + lambda = Clip3( lastLevelLambda * pow( 2.0, -5.0 / 3.0 ), lastLevelLambda * pow( 2.0, 5.0 / 3.0 ), lambda ); + } + + if ( frameLevel > 2 ) + { + int tlQpOffset = encRCSeq->gopSize == 32 ? RC_GOP_ID_QP_OFFSET_GOP32[ frameLevel ] : RC_GOP_ID_QP_OFFSET[ frameLevel ]; + lambda = Clip3( lastPrevTLLambda * pow( 2.0, (double)( tlQpOffset ) / 3.0 ), encRCGOP->maxEstLambda, lambda ); + } + + if ( lastPicLambda > 0.0 ) + { + lastPicLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastPicLambda ); + if ( frameLevel > 1 ) + { + lambda = Clip3( lastPicLambda * pow( 2.0, -10.0 / 3.0 ), lastPicLambda * pow( 2.0, 10.0 / 3.0 ), lambda ); + } + else + { + lambda = Clip3( lastPicLambda * pow( 2.0, -12.0 / 3.0 ), lastPicLambda * pow( 2.0, 12.0 / 3.0 ), lambda ); + } + } + else if ( lastValidLambda > 0.0 ) + { + lastValidLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastValidLambda ); + if ( frameLevel > 1 ) + { + lambda = Clip3( lastValidLambda * pow( 2.0, -10.0 / 3.0 ), lastValidLambda * pow( 2.0, 10.0 / 3.0 ), lambda ); + } + else + { + lambda = Clip3( lastValidLambda * pow( 2.0, -12.0 / 3.0 ), lastValidLambda * pow( 2.0, 12.0 / 3.0 ), lambda ); + } + } + else + { + lambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lambda ); + } + + if ( lambda < encRCGOP->minEstLambda ) + { + lambda = encRCGOP->minEstLambda; + } +} + +void EncRCPic::clipLambdaGopRc( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ) +{ + double lastPrevTLLambda = -1.0; + double lastLevelLambda = -1.0; + double lastPicLambda = -1.0; + double lastValidLambda = -1.0; + std::list::iterator it; + for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) + { + if ( ( *it )->frameLevel == frameLevel - 1 && ( *it )->picLambda > 0.0 ) + { + lastPrevTLLambda = ( *it )->picLambda; + } + if ( ( *it )->frameLevel == frameLevel && ( *it )->picLambda > 0.0 ) + { + lastLevelLambda = ( *it )->picLambda; + } + lastPicLambda = ( *it )->picLambda; + + if ( lastPicLambda > 0.0 ) + { + lastValidLambda = lastPicLambda; + } + } + + if ( lastLevelLambda > 0.0 ) + { + lastLevelLambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lastLevelLambda ); + if ( frameLevel < 1 ) + { + double lowerClippingBoundary = Clip3( -5.0, 5.0, round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 5 ) ); + double upperClippingBoundary = Clip3( -5.0, 5.0, round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 11 ) ); + lambda = Clip3( lastLevelLambda * pow( 2.0, lowerClippingBoundary / 3.0 ), lastLevelLambda * pow( 2.0, upperClippingBoundary / 3.0 ), lambda ); + } + else + { + lambda = Clip3( lastLevelLambda * pow( 2.0, -5.0 / 3.0 ), lastLevelLambda * pow( 2.0, 5.0 / 3.0 ), lambda ); + } + } + + if ( ( encRCSeq->framesCoded < encRCSeq->intraPeriod && frameLevel > 1 ) || ( encRCSeq->framesCoded >= encRCSeq->intraPeriod && frameLevel > 0 ) ) + { + int tlQpOffset = encRCSeq->gopSize == 32 ? RC_GOP_ID_QP_OFFSET_GRC_GOP32[ frameLevel ] : RC_GOP_ID_QP_OFFSET_GRC[ frameLevel ]; + lambda = Clip3( lastPrevTLLambda * pow( 2.0, (double)( tlQpOffset ) / 3.0 ), encRCGOP->maxEstLambda, lambda ); + } + + if ( lastPicLambda > 0.0 ) + { + lastPicLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastPicLambda ); + if ( frameLevel > 1 ) + { + lambda = Clip3( lastPicLambda * pow( 2.0, -10.0 / 3.0 ), lastPicLambda * pow( 2.0, 10.0 / 3.0 ), lambda ); + } + else + { + double limitTH[ 3 ] = { pow( 2.0, bitdepthLumaScale ) * exp( ( 26 - 13.7122 ) / 4.2005 ), pow( 2.0, bitdepthLumaScale ) * exp( ( 30 - 13.7122 ) / 4.2005 ), pow( 2.0, bitdepthLumaScale ) * exp( ( 35 - 13.7122 ) / 4.2005 ) }; + if ( frameLevel == 0 ) + { + double intraLimit = lastPicLambda < limitTH[ 0 ] ? 11.0 : ( lastPicLambda < limitTH[ 1 ] ? 12.0 : ( lastPicLambda < limitTH[ 2 ] ? 13.0 : 14.0 ) ); + lambda = Clip3( lastPicLambda * pow( 2.0, -intraLimit / 3.0 ), lastPicLambda * pow( 2.0, intraLimit / 3.0 ), lambda ); + } + else + { + double intraLimit = lastPicLambda < limitTH[ 0 ] ? 8.0 : ( lastPicLambda < limitTH[ 1 ] ? 9.0 : ( lastPicLambda < limitTH[ 2 ] ? 10.0 : 11.0 ) ); + lambda = Clip3( lastPicLambda * pow( 2.0, -intraLimit / 3.0 ), lastPicLambda * pow( 2.0, intraLimit / 3.0 ), lambda ); + } + } + } + else if ( lastValidLambda > 0.0 ) + { + lastValidLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastValidLambda ); + if ( frameLevel > 1 ) + { + lambda = Clip3( lastValidLambda * pow( 2.0, -10.0 / 3.0 ), lastValidLambda * pow( 2.0, 10.0 / 3.0 ), lambda ); + } + else + { + lambda = Clip3( lastValidLambda * pow( 2.0, -12.0 / 3.0 ), lastValidLambda * pow( 2.0, 12.0 / 3.0 ), lambda ); + } + } + else + { + lambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lambda ); + } + + if ( lambda < encRCGOP->minEstLambda ) + { + lambda = encRCGOP->minEstLambda; + } +} + +void EncRCPic::clipLambdaTwoPass( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ) +{ bool setLastLevelLambda = false; double lastPrevTLLambda = -1.0; double lastLevelLambda = -1.0; @@ -820,16 +1176,18 @@ double EncRCPic::estimatePicLambda( std::list& listPreviousPictures, std::list::iterator it; for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) { - if ( frameLevel - 1 == ( *it )->frameLevel && 0.0 < ( *it )->picLambda ) + // collect lambda from the immediately lower TL + if ( ( *it )->frameLevel == frameLevel - 1 && ( *it )->picLambda > 0.0 ) { lastPrevTLLambda = ( *it )->picLambda; } - if ( ( *it )->frameLevel == frameLevel && 0.0 < ( *it )->picLambda ) + + if ( ( *it )->frameLevel == frameLevel && ( *it )->picLambda > 0.0 ) { lastLevelLambda = ( *it )->picLambda; setLastLevelLambda = true; } - else if ( encRCSeq->rcMode < 3 && encRCSeq->framesCoded < 16 && ( *it )->frameLevel < frameLevel && 0.0 < ( *it )->picLambda && !setLastLevelLambda ) + else if ( encRCSeq->framesCoded < encRCSeq->gopSize && ( *it )->frameLevel < frameLevel && ( *it )->picLambda > 0.0 && !setLastLevelLambda ) // at the beginning, treat frames from the lower TLs as if they are in the same TL { lastLevelLambda = ( *it )->picLambda; } @@ -841,146 +1199,304 @@ double EncRCPic::estimatePicLambda( std::list& listPreviousPictures, } } + // limit lambda among the frames from the same TL if ( lastLevelLambda > 0.0 ) { lastLevelLambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lastLevelLambda ); - if ( encRCSeq->rcMode == 3 && 1 > frameLevel ) + if( isNewScene ) + { + lambda = Clip3( lastLevelLambda * pow( 2.0, -6.0 / 3.0 ), lastLevelLambda * pow( 2.0, 6.0 / 3.0 ), lambda ); + } + else + { + lambda = Clip3( lastLevelLambda * pow( 2.0, -3.0 / 3.0 ), lastLevelLambda * pow( 2.0, 3.0 / 3.0 ), lambda ); + } + } + + // prevent frames from higher TLs to have lower lambda values than frames at lower TLs + if ( frameLevel > 2 ) + { + int tlQpOffset = encRCSeq->gopSize == 32 ? RC_GOP_ID_QP_OFFSET_GOP32[ frameLevel ] : RC_GOP_ID_QP_OFFSET[ frameLevel ]; + if ( encRCSeq->bitUsageRatio > 1.0 ) + { + lambda = Clip3( lastPrevTLLambda * pow( 2.0, (double)( tlQpOffset ) / 3.0 ), lastPrevTLLambda * pow( 2.0, (double)( tlQpOffset ) / 3.0 ), lambda ); + } + else + { + lambda = Clip3( lastPrevTLLambda * pow( 2.0, (double)( tlQpOffset ) / 3.0 ), encRCGOP->maxEstLambda, lambda ); + } + } + + // clip lambda based on the previously encoded picture + if ( lastPicLambda > 0.0 ) + { + lastPicLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastPicLambda ); + if ( frameLevel > 1 ) + { + lambda = Clip3( lastPicLambda * pow( 2.0, -6.0 / 3.0 ), lastPicLambda * pow( 2.0, 6.0 / 3.0 ), lambda ); + } + else // frames at the lowest TLs should have larger clipping interval + { + int lowClipBoundary = Clip3( 12, 15, int( 4.0 * encRCSeq->bitUsageRatio + 8.5 + 0.5 ) ); + lambda = Clip3( lastPicLambda * pow( 2.0, -lowClipBoundary / 3.0 ), lastPicLambda * pow( 2.0, 12.0 / 3.0 ), lambda ); + } + } + else if ( lastValidLambda > 0.0 ) + { + lastValidLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastValidLambda ); + if ( frameLevel > 1 ) + { + lambda = Clip3( lastValidLambda * pow( 2.0, -6.0 / 3.0 ), lastValidLambda * pow( 2.0, 6.0 / 3.0 ), lambda ); + } + else + { + int lowClipBoundary = Clip3( 12, 15, int( 4.0 * encRCSeq->bitUsageRatio + 8.5 + 0.5 ) ); + lambda = Clip3( lastValidLambda * pow( 2.0, -lowClipBoundary / 3.0 ), lastValidLambda * pow( 2.0, 12.0 / 3.0 ), lambda ); + } + } + else + { + lambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, lambda ); + } + + if ( lambda < encRCGOP->minEstLambda ) + { + lambda = encRCGOP->minEstLambda; + } +} + +int EncRCPic::estimatePicQP( double lambda, std::list& listPreviousPictures ) +{ + int bitdepthLumaScale = 2 * ( encRCSeq->bitDepth - 8 - DISTORTION_PRECISION_ADJUSTMENT( encRCSeq->bitDepth ) ); + + int QP = int( 4.2005 * log( lambda / pow( 2.0, bitdepthLumaScale ) ) + 13.7122 + 0.5 ); + + switch ( encRCSeq->rcMode ) + { + case 1: + clipQpConventional( listPreviousPictures, QP ); + break; + case 2: + if ( encRCSeq->twoPass ) + { + clipQpTwoPass( listPreviousPictures, QP ); + } + else + { + clipQpFrameRc( listPreviousPictures, QP ); + } + break; + case 3: + clipQpGopRc( listPreviousPictures, QP ); + break; + default: + clipQpConventional( listPreviousPictures, QP ); + break; + } + + return QP; +} + +void EncRCPic::clipQpConventional( std::list& listPreviousPictures, int & QP ) +{ + int lastLevelQP = RC_INVALID_QP_VALUE; + int lastPicQP = RC_INVALID_QP_VALUE; + int lastValidQP = RC_INVALID_QP_VALUE; + std::list::iterator it; + for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) + { + if ( ( *it )->frameLevel == frameLevel ) + { + lastLevelQP = ( *it )->picQP; + } + lastPicQP = ( *it )->picQP; + if ( lastPicQP > RC_INVALID_QP_VALUE ) + { + lastValidQP = lastPicQP; + } + } + + if ( lastLevelQP > RC_INVALID_QP_VALUE ) + { + QP = Clip3( lastLevelQP - 3, lastLevelQP + 3, QP ); + } + + if ( lastPicQP > RC_INVALID_QP_VALUE ) + { + QP = Clip3( lastPicQP - 10, lastPicQP + 10, QP ); + } + else if ( lastValidQP > RC_INVALID_QP_VALUE ) + { + QP = Clip3( lastValidQP - 10, lastValidQP + 10, QP ); + } +} + +void EncRCPic::clipQpFrameRc( std::list& listPreviousPictures, int &QP ) +{ + bool setLastLevelQP = false; + int lastPrevTLQP = RC_INVALID_QP_VALUE; + int lastLevelQP = RC_INVALID_QP_VALUE; + int lastPicQP = RC_INVALID_QP_VALUE; + int lastValidQP = RC_INVALID_QP_VALUE; + std::list::iterator it; + for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) + { + if ( ( *it )->frameLevel == frameLevel - 1 && ( *it )->picQP > RC_INVALID_QP_VALUE ) + { + lastPrevTLQP = ( *it )->picQP; + } + if ( ( *it )->frameLevel == frameLevel && ( *it )->picQP > RC_INVALID_QP_VALUE ) // use the QP value from the last available frame of that level + { + lastLevelQP = ( *it )->picQP; + setLastLevelQP = true; + } + else if ( encRCSeq->framesCoded < encRCSeq->gopSize && ( *it )->frameLevel < frameLevel && ( *it )->picQP > RC_INVALID_QP_VALUE && !setLastLevelQP ) + { + lastLevelQP = ( *it )->picQP; + } + lastPicQP = ( *it )->picQP; + if ( lastPicQP > RC_INVALID_QP_VALUE ) + { + lastValidQP = lastPicQP; + } + } + + if ( lastLevelQP > RC_INVALID_QP_VALUE ) + { + QP = Clip3( lastLevelQP - 5, lastLevelQP + 5, QP ); + } + + if ( frameLevel > 2 ) + { + int tlQpOffset = encRCSeq->gopSize == 32 ? RC_GOP_ID_QP_OFFSET_GOP32[ frameLevel ] : RC_GOP_ID_QP_OFFSET[ frameLevel ]; + QP = Clip3( lastPrevTLQP + tlQpOffset, MAX_QP, QP ); + } + + if ( lastPicQP > RC_INVALID_QP_VALUE ) + { + if ( frameLevel > 1 ) + { + QP = Clip3( lastPicQP - 10, lastPicQP + 10, QP ); + } + else + { + QP = Clip3( lastPicQP - 12, lastPicQP + 12, QP ); + } + } + else if ( lastValidQP > RC_INVALID_QP_VALUE ) + { + if ( frameLevel > 1 ) + { + QP = Clip3( lastValidQP - 10, lastValidQP + 10, QP ); + } + else + { + QP = Clip3( lastValidQP - 12, lastValidQP + 12, QP ); + } + } +} + +void EncRCPic::clipQpGopRc( std::list& listPreviousPictures, int &QP ) +{ + int lastPrevTLQP = RC_INVALID_QP_VALUE; + int lastLevelQP = RC_INVALID_QP_VALUE; + int lastPicQP = RC_INVALID_QP_VALUE; + int lastValidQP = RC_INVALID_QP_VALUE; + std::list::iterator it; + for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) + { + if ( ( *it )->frameLevel == frameLevel - 1 && ( *it )->picQP > RC_INVALID_QP_VALUE ) + { + lastPrevTLQP = ( *it )->picQP; + } + if ( ( *it )->frameLevel == frameLevel && ( *it )->picQP > RC_INVALID_QP_VALUE ) // use the QP value from the last available frame of that level + { + lastLevelQP = ( *it )->picQP; + } + lastPicQP = ( *it )->picQP; + if ( lastPicQP > RC_INVALID_QP_VALUE ) + { + lastValidQP = lastPicQP; + } + } + + if ( lastLevelQP > RC_INVALID_QP_VALUE ) + { + if ( frameLevel < 1 ) { - double lowerClippingBoundary = Clip3( -5.0, 5.0, round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 5 ) ); - double upperClippingBoundary = Clip3( -5.0, 5.0, round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 11 ) ); - estLambda = Clip3( lastLevelLambda * pow( 2.0, lowerClippingBoundary / 3.0 ), lastLevelLambda * pow( 2.0, upperClippingBoundary / 3.0 ), estLambda ); + int lowerClippingBoundary = Clip3( -5, 5, (int)round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 5 ) ); + int upperClippingBoundary = Clip3( -5, 5, (int)round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 11 ) ); + QP = Clip3( lastLevelQP + lowerClippingBoundary, lastLevelQP + upperClippingBoundary, QP ); } else { - estLambda = Clip3( lastLevelLambda * pow( 2.0, -5.0 / 3.0 ), lastLevelLambda * pow( 2.0, 5.0 / 3.0 ), estLambda ); + QP = Clip3( lastLevelQP - 5, lastLevelQP + 5, QP ); } } - if ( encRCSeq->rcMode == 3 && ( ( encRCSeq->framesCoded < encRCSeq->intraPeriod && 1 < frameLevel ) || ( encRCSeq->framesCoded >= encRCSeq->intraPeriod && 0 < frameLevel ) ) ) - { - estLambda = Clip3( lastPrevTLLambda * pow( 2.0, (double)( RC_GOP_ID_QP_OFFSET_GRC[ frameLevel ] ) / 3.0 ), encRCGOP->maxEstLambda, estLambda ); - } - else if ( encRCSeq->rcMode < 3 && 2 < frameLevel ) + if ( ( encRCSeq->framesCoded < encRCSeq->intraPeriod && frameLevel > 1 ) || ( encRCSeq->framesCoded >= encRCSeq->intraPeriod && frameLevel > 0 ) ) { - estLambda = Clip3( lastPrevTLLambda * pow( 2.0, (double)( RC_GOP_ID_QP_OFFSET[ frameLevel ] ) / 3.0 ), encRCGOP->maxEstLambda, estLambda ); + int tlQpOffset = encRCSeq->gopSize == 32 ? RC_GOP_ID_QP_OFFSET_GRC_GOP32[ frameLevel ] : RC_GOP_ID_QP_OFFSET_GRC[ frameLevel ]; + QP = Clip3( lastPrevTLQP + tlQpOffset, MAX_QP, QP ); } - if ( lastPicLambda > 0.0 ) + if ( lastPicQP > RC_INVALID_QP_VALUE ) { - lastPicLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastPicLambda ); - if ( 1 < frameLevel ) + if ( frameLevel > 1 ) { - estLambda = Clip3( lastPicLambda * pow( 2.0, -10.0 / 3.0 ), lastPicLambda * pow( 2.0, 10.0 / 3.0 ), estLambda ); + QP = Clip3( lastPicQP - 10, lastPicQP + 10, QP ); } else { - if ( encRCSeq->rcMode == 3 ) + if ( frameLevel == 0 ) { - double limitTH[ 3 ] = { pow( 2.0, bitdepthLumaScale ) * exp( ( 26 - 13.7122 ) / 4.2005 ), pow( 2.0, bitdepthLumaScale ) * exp( ( 30 - 13.7122 ) / 4.2005 ), pow( 2.0, bitdepthLumaScale ) * exp( ( 35 - 13.7122 ) / 4.2005 ) }; - if ( 0 == frameLevel ) - { - double intraLimit = lastPicLambda < limitTH[ 0 ] ? 11.0 : ( lastPicLambda < limitTH[ 1 ] ? 12.0 : ( lastPicLambda < limitTH[ 2 ] ? 13.0 : 14.0 ) ); - estLambda = Clip3( lastPicLambda * pow( 2.0, -intraLimit / 3.0 ), lastPicLambda * pow( 2.0, intraLimit / 3.0 ), estLambda ); - } - else - { - double intraLimit = lastPicLambda < limitTH[ 0 ] ? 8.0 : ( lastPicLambda < limitTH[ 1 ] ? 9.0 : ( lastPicLambda < limitTH[ 2 ] ? 10.0 : 11.0 ) ); - estLambda = Clip3( lastPicLambda * pow( 2.0, -intraLimit / 3.0 ), lastPicLambda * pow( 2.0, intraLimit / 3.0 ), estLambda ); - } + int intraLimit = lastPicQP < 26 ? 11 : ( lastPicQP < 30 ? 12 : ( lastPicQP < 35 ? 13 : 14 ) ); + QP = Clip3( lastPicQP - intraLimit, lastPicQP + intraLimit, QP ); } else { - estLambda = Clip3( lastPicLambda * pow( 2.0, -12.0 / 3.0 ), lastPicLambda * pow( 2.0, 12.0 / 3.0 ), estLambda ); + int intraLimit = lastPicQP < 26 ? 8 : ( lastPicQP < 30 ? 9 : ( lastPicQP < 35 ? 10 : 11 ) ); + QP = Clip3( lastPicQP - intraLimit, lastPicQP + intraLimit, QP ); } } } - else if ( lastValidLambda > 0.0 ) - { - lastValidLambda = Clip3( encRCGOP->minEstLambda, 2000.0 * pow( 2.0, bitdepthLumaScale ), lastValidLambda ); - if ( 1 < frameLevel ) - { - estLambda = Clip3( lastValidLambda * pow( 2.0, -10.0 / 3.0 ), lastValidLambda * pow( 2.0, 10.0 / 3.0 ), estLambda ); - } - else - { - estLambda = Clip3( lastValidLambda * pow( 2.0, -12.0 / 3.0 ), lastValidLambda * pow( 2.0, 12.0 / 3.0 ), estLambda ); - } - } - else - { - estLambda = Clip3( encRCGOP->minEstLambda, encRCGOP->maxEstLambda, estLambda ); - } - - if ( estLambda < encRCGOP->minEstLambda ) - { - estLambda = encRCGOP->minEstLambda; - } - - //Avoid different results in different platforms. The problem is caused by the different results of pow() in different platforms. - estLambda = double( int64_t( estLambda * (double)RC_LAMBDA_PREC + 0.5 ) ) / (double)RC_LAMBDA_PREC; - picEstLambda = estLambda; - - double totalWeight = 0.0; - // initial BU bit allocation weight - for ( int i = 0; i < numberOfLCU; i++ ) + else if ( lastValidQP > RC_INVALID_QP_VALUE ) { - double alphaLCU, betaLCU; - if ( encRCSeq->useLCUSeparateModel ) + if ( frameLevel > 1 ) { - alphaLCU = encRCSeq->lcuParam[ frameLevel][ i ].alpha; - betaLCU = encRCSeq->lcuParam[ frameLevel][ i ].beta; + QP = Clip3( lastValidQP - 10, lastValidQP + 10, QP ); } else { - alphaLCU = encRCSeq->picParam[ frameLevel ].alpha; - betaLCU = encRCSeq->picParam[ frameLevel ].beta; - } - - lcu[ i ].bitWeight = lcu[ i ].numberOfPixel * pow( estLambda / alphaLCU, 1.0 / betaLCU ); - - if ( lcu[ i ].bitWeight < 0.01 ) - { - lcu[ i ].bitWeight = 0.01; + QP = Clip3( lastValidQP - 12, lastValidQP + 12, QP ); } - totalWeight += lcu[ i ].bitWeight; } - for ( int i = 0; i < numberOfLCU; i++ ) - { - double BUTargetBits = targetBits * lcu[ i ].bitWeight / totalWeight; - lcu[ i ].bitWeight = BUTargetBits; - } - - return estLambda; } -int EncRCPic::estimatePicQP( double lambda, std::list& listPreviousPictures ) +void EncRCPic::clipQpTwoPass( std::list& listPreviousPictures, int &QP ) { - int bitdepthLumaScale = 2 * ( encRCSeq->bitDepth - 8 - DISTORTION_PRECISION_ADJUSTMENT( encRCSeq->bitDepth ) ); - - int QP = int(4.2005 * log(lambda / pow(2.0, bitdepthLumaScale )) + 13.7122 + 0.5); - bool setLastLevelQP = false; int lastPrevTLQP = RC_INVALID_QP_VALUE; int lastLevelQP = RC_INVALID_QP_VALUE; - int lastPicQP = RC_INVALID_QP_VALUE; + int lastPicQP = RC_INVALID_QP_VALUE; int lastValidQP = RC_INVALID_QP_VALUE; std::list::iterator it; for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) { - if ( frameLevel - 1 == ( *it )->frameLevel && RC_INVALID_QP_VALUE < ( *it )->picQP ) + if ( ( *it )->frameLevel == frameLevel - 1 && ( *it )->picQP > RC_INVALID_QP_VALUE ) { lastPrevTLQP = ( *it )->picQP; } - if ( (*it)->frameLevel == frameLevel && RC_INVALID_QP_VALUE < ( *it )->picQP ) // use the QP value from the last available frame of that level + if ( ( *it )->frameLevel == frameLevel && ( *it )->picQP > RC_INVALID_QP_VALUE ) // use the QP value from the last available frame of that level { - lastLevelQP = (*it)->picQP; + lastLevelQP = ( *it )->picQP; setLastLevelQP = true; } - else if ( encRCSeq->rcMode < 3 && encRCSeq->framesCoded < 16 && ( *it )->frameLevel < frameLevel && RC_INVALID_QP_VALUE < ( *it )->picQP && !setLastLevelQP ) + else if ( encRCSeq->framesCoded < encRCSeq->gopSize && ( *it )->frameLevel < frameLevel && ( *it )->picQP > RC_INVALID_QP_VALUE && !setLastLevelQP ) { lastLevelQP = ( *it )->picQP; } - lastPicQP = (*it)->picQP; + lastPicQP = ( *it )->picQP; if ( lastPicQP > RC_INVALID_QP_VALUE ) { lastValidQP = lastPicQP; @@ -989,67 +1505,53 @@ int EncRCPic::estimatePicQP( double lambda, std::list& listPreviousPi if ( lastLevelQP > RC_INVALID_QP_VALUE ) { - if ( encRCSeq->rcMode == 3 && 1 > frameLevel ) + if ( isNewScene ) { - int lowerClippingBoundary = Clip3( -5, 5, (int)round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 5 ) ); - int upperClippingBoundary = Clip3( -5, 5, (int)round( -10 * ( encRCGOP->targetBits / (double)encRCGOP->idealTargetGOPBits ) + 11 ) ); - QP = Clip3( lastLevelQP + lowerClippingBoundary, lastLevelQP + upperClippingBoundary, QP ); + QP = Clip3( lastLevelQP - 6, lastLevelQP + 6, QP ); } else { - QP = Clip3( lastLevelQP - 5, lastLevelQP + 5, QP ); + QP = Clip3( lastLevelQP - 3, lastLevelQP + 3, QP ); } } - if ( encRCSeq->rcMode == 3 && ( ( encRCSeq->framesCoded < encRCSeq->intraPeriod && 1 < frameLevel ) || ( encRCSeq->framesCoded >= encRCSeq->intraPeriod && 0 < frameLevel ) ) ) + if ( frameLevel > 2 ) // in any case frame level has to be GREATER than 1 { - QP = Clip3( lastPrevTLQP + RC_GOP_ID_QP_OFFSET_GRC[ frameLevel ], MAX_QP, QP ); - } - else if ( encRCSeq->rcMode < 3 && 2 < frameLevel ) - { - QP = Clip3( lastPrevTLQP + RC_GOP_ID_QP_OFFSET[ frameLevel ], MAX_QP, QP ); + int tlQpOffset = encRCSeq->gopSize == 32 ? RC_GOP_ID_QP_OFFSET_GOP32[ frameLevel ] : RC_GOP_ID_QP_OFFSET[ frameLevel ]; + if ( encRCSeq->bitUsageRatio > 1.0 ) + { + QP = Clip3( lastPrevTLQP + tlQpOffset, lastPrevTLQP + tlQpOffset, QP ); + } + else + { + QP = Clip3( lastPrevTLQP + tlQpOffset, MAX_QP, QP ); + } } if ( lastPicQP > RC_INVALID_QP_VALUE ) { - if ( 1 < frameLevel ) + if ( frameLevel > 1 ) { - QP = Clip3( lastPicQP - 10, lastPicQP + 10, QP ); + QP = Clip3( lastPicQP - 6, lastPicQP + 6, QP ); } else { - if ( encRCSeq->rcMode == 3 ) - { - if ( 0 == frameLevel ) - { - int intraLimit = lastPicQP < 26 ? 11 : ( lastPicQP < 30 ? 12 : ( lastPicQP < 35 ? 13 : 14 ) ); - QP = Clip3( lastPicQP - intraLimit, lastPicQP + intraLimit, QP ); - } - else - { - int intraLimit = lastPicQP < 26 ? 8 : ( lastPicQP < 30 ? 9 : ( lastPicQP < 35 ? 10 : 11 ) ); - QP = Clip3( lastPicQP - intraLimit, lastPicQP + intraLimit, QP ); - } - } - else - { - QP = Clip3( lastPicQP - 12, lastPicQP + 12, QP ); - } + int lowClipBoundary = Clip3( 12, 15, int( 4.0 * encRCSeq->bitUsageRatio + 8.5 + 0.5 ) ); + QP = Clip3( lastPicQP - lowClipBoundary, lastPicQP + 12, QP ); } } else if ( lastValidQP > RC_INVALID_QP_VALUE ) { - if ( 1 < frameLevel ) + if ( frameLevel > 1 ) { - QP = Clip3( lastValidQP - 10, lastValidQP + 10, QP ); + QP = Clip3( lastValidQP - 6, lastValidQP + 6, QP ); } else { - QP = Clip3( lastValidQP - 12, lastValidQP + 12, QP ); + int lowClipBoundary = Clip3( 12, 15, int( 4.0 * encRCSeq->bitUsageRatio + 8.5 + 0.5 ) ); + QP = Clip3( lastValidQP - lowClipBoundary, lastValidQP + 12, QP ); } } - - return QP; } double EncRCPic::getLCUTargetBpp(bool isIRAP, const int ctuRsAddr ) @@ -1320,7 +1822,14 @@ void EncRCPic::updateAfterPicture( int actualHeaderBits, int actualTotalBits, do int numOfSkipPixel = 0; for (int LCUIdx = 0; LCUIdx < numberOfLCU; LCUIdx++) { - numOfSkipPixel += int( encRCSeq->lcuParam[ frameLevel ][ LCUIdx ].skipRatio * lcu[ LCUIdx ].numberOfPixel ); + if ( encRCSeq->useLCUSeparateModel ) + { + numOfSkipPixel += int( encRCSeq->lcuParam[ frameLevel ][ LCUIdx ].skipRatio * lcu[ LCUIdx ].numberOfPixel ); + } + else + { + numOfSkipPixel += int( encRCSeq->picParam[ frameLevel ].skipRatio * lcu[ LCUIdx ].numberOfPixel ); + } } skipRatio = (double)numOfSkipPixel / (double)numberOfPixel; @@ -1468,10 +1977,13 @@ double EncRCPic::getLCUEstLambdaAndQP(double bpp, int clipPicQP, int *estQP, con RateCtrl::RateCtrl() { - encRCSeq = NULL; - encRCGOP = NULL; - encRCPic = NULL; - rcQP = 0; + encRCSeq = NULL; + encRCGOP = NULL; + encRCPic = NULL; + rcQP = 0; + rcPass = 0; + rcMaxPass = 0; + rcIsFinalPass = true; } RateCtrl::~RateCtrl() @@ -1499,14 +2011,14 @@ void RateCtrl::destroy() } } -void RateCtrl::init(int RCMode, int totalFrames, int targetBitrate, int frameRate, int intraPeriod, int GOPSize, int picWidth, int picHeight, int LCUWidth, int LCUHeight, int bitDepth, int keepHierBits, bool useLCUSeparateModel, const GOPEntry GOPList[MAX_GOP]) +void RateCtrl::init( int RCMode, int totalFrames, int targetBitrate, int frameRate, int intraPeriod, int GOPSize, int picWidth, int picHeight, int LCUWidth, int LCUHeight, int bitDepth, int keepHierBits, bool useLCUSeparateModel, const GOPEntry GOPList[ MAX_GOP ] ) { destroy(); bool isLowdelay = true; - for ( int i=0; i GOPList[i+1].m_POC ) + if ( GOPList[ i ].m_POC > GOPList[ i + 1 ].m_POC ) { isLowdelay = false; break; @@ -1515,13 +2027,9 @@ void RateCtrl::init(int RCMode, int totalFrames, int targetBitrate, int frameRat int numberOfLevel = 1; int adaptiveBit = 0; - if ( keepHierBits > 0 ) - { - numberOfLevel = int( log((double)GOPSize)/log(2.0) + 0.5 ) + 1; - } - if (!isLowdelay && (GOPSize == 16 || GOPSize == 8)) + if ( keepHierBits > 0 || ( !isLowdelay && ( GOPSize == 32 || GOPSize == 16 || GOPSize == 8 ) ) ) { - numberOfLevel = int( log((double)GOPSize)/log(2.0) + 0.5 ) + 1; + numberOfLevel = int( log( (double)GOPSize ) / log( 2.0 ) + 0.5 ) + 1; } numberOfLevel++; // intra picture numberOfLevel++; // non-reference picture @@ -1629,7 +2137,7 @@ void RateCtrl::init(int RCMode, int totalFrames, int targetBitrate, int frameRat adaptiveBit = 2; } } - else if (GOPSize == 16 && !isLowdelay) + else if ( GOPSize == 16 && !isLowdelay ) { bitsRatio[ 0 ] = (int)( ( -0.5691 * bpp + 0.3577 ) * 1000 + 0.5 ); bitsRatio[ 1 ] = (int)( ( -0.0332 * bpp + 0.1782 ) * 1000 + 0.5 ); @@ -1650,7 +2158,42 @@ void RateCtrl::init(int RCMode, int totalFrames, int targetBitrate, int frameRat if (keepHierBits == 2) { - adaptiveBit = 3; + adaptiveBit = 2; + } + } + else if ( GOPSize == 32 && !isLowdelay ) + { + int bitsRatioInit[ 4 ][ 6 ] = { + { 16, 10, 8, 4, 2, 1 }, + { 16, 10, 8, 4, 2, 1 }, + { 16, 10, 8, 4, 2, 1 }, + { 10, 8, 6, 4, 2, 1 }}; + int cls; + if ( bpp > 0.2 ) + { + cls = 0; + } + else if ( bpp > 0.1 ) + { + cls = 1; + } + else if ( bpp > 0.05 ) + { + cls = 2; + } + else + { + cls = 3; + } + int index[ 32 ] = { 0, 1, 2, 3, 4, 5, 5, 4, 5, 5, 3, 4, 5, 5, 4, 5, 5, 2, 3, 4, 5, 5, 4, 5, 5, 3, 4, 5, 5, 4, 5, 5 }; + + for ( int i = 0; i < 32; i++ ) + { + bitsRatio[ i ] = bitsRatioInit[ cls ][ index[ i ] ]; + } + if ( keepHierBits == 2 ) + { + adaptiveBit = 2; } } else @@ -1740,9 +2283,45 @@ void RateCtrl::init(int RCMode, int totalFrames, int targetBitrate, int frameRat GOPID2Level[14] = 5; GOPID2Level[15] = 5; } + else if ( GOPSize == 32 && !isLowdelay ) + { + GOPID2Level[ 0 ] = 1; + GOPID2Level[ 1 ] = 2; + GOPID2Level[ 2 ] = 3; + GOPID2Level[ 3 ] = 4; + GOPID2Level[ 4 ] = 5; + GOPID2Level[ 5 ] = 6; + GOPID2Level[ 6 ] = 6; + GOPID2Level[ 7 ] = 5; + GOPID2Level[ 8 ] = 6; + GOPID2Level[ 9 ] = 6; + GOPID2Level[ 10 ] = 4; + GOPID2Level[ 11 ] = 5; + GOPID2Level[ 12 ] = 6; + GOPID2Level[ 13 ] = 6; + GOPID2Level[ 14 ] = 5; + GOPID2Level[ 15 ] = 6; + GOPID2Level[ 16 ] = 6; + GOPID2Level[ 17 ] = 3; + GOPID2Level[ 18 ] = 4; + GOPID2Level[ 19 ] = 5; + GOPID2Level[ 20 ] = 6; + GOPID2Level[ 21 ] = 6; + GOPID2Level[ 22 ] = 5; + GOPID2Level[ 23 ] = 6; + GOPID2Level[ 24 ] = 6; + GOPID2Level[ 25 ] = 4; + GOPID2Level[ 26 ] = 5; + GOPID2Level[ 27 ] = 6; + GOPID2Level[ 28 ] = 6; + GOPID2Level[ 29 ] = 5; + GOPID2Level[ 30 ] = 6; + GOPID2Level[ 31 ] = 6; + } + encRCSeq = new EncRCSeq; - encRCSeq->create( RCMode, totalFrames, targetBitrate, frameRate, intraPeriod, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit ); + encRCSeq->create( RCMode, rcMaxPass == 1, totalFrames, targetBitrate, frameRate, intraPeriod, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit, getFirstPassStats() ); encRCSeq->initBitsRatio( bitsRatio ); encRCSeq->initGOPID2Level( GOPID2Level ); encRCSeq->bitDepth = bitDepth; @@ -1774,7 +2353,313 @@ void RateCtrl::destroyRCGOP() encRCGOP = NULL; } +void RateCtrl::setRCPass( int pass, int maxPass ) +{ + rcPass = pass; + rcMaxPass = maxPass; + rcIsFinalPass = ( pass >= maxPass ); +} + +void RateCtrl::processFirstPassData() +{ + CHECK( m_listRCFirstPassStats.size() == 0, "No data available from the first pass!" ); + + int numOfLevels = int( log( encRCSeq->gopSize ) / log( 2 ) + 0.5 ) + 2; + + // run a simple scene change detection + detectNewScene(); + + // process and scale GOP and frame bits using the data from the first pass to account for different target bitrates + processGops(); + + // loop though the first pass data and update alpha parameters when new scenes are detected + std::list::iterator it; + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++ ) + { + if ( it->poc == 0 ) // force a new scene at the beginning + { + it->isNewScene = true; + estimateAlphaFirstPass( numOfLevels, it->poc, encRCSeq->intraPeriod + 1, it->estAlpha ); + } + else if ( it->isNewScene ) // update model parameters at every new scene + { + estimateAlphaFirstPass( numOfLevels, it->poc, encRCSeq->intraPeriod, it->estAlpha ); + } + } +} + +int64_t RateCtrl::getTotalBitsInFirstPass() +{ + int64_t totalBitsFirstPass = 0; + + std::list::iterator it; + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++ ) + { + totalBitsFirstPass += it->numBits; + } + + return totalBitsFirstPass; +} + +void RateCtrl::detectNewScene() +{ + double meanFeatureValueInter = 0.0; + double meanFeatureValueIntra = 0.0; + double newSceneDetectionTH = 0.1; + double newSceneDetectionTHIntra = 0.075; + int pocOfLastSceneChange[ 2 ] = { 0, 0 }; + int counter[ 2 ] = { 0, 0 }; + int pocOfLastCompleteGop = int( floor( ( m_listRCFirstPassStats.size() - 1 ) / encRCSeq->gopSize ) * encRCSeq->gopSize ); + int pocOfLastCompleteIp = int( floor( ( m_listRCFirstPassStats.size() - 1 ) / encRCSeq->intraPeriod ) * encRCSeq->intraPeriod ); + std::vector gopFeature( 2 + pocOfLastCompleteGop / encRCSeq->gopSize ); + std::vector gopFeatureIntra( 1 + pocOfLastCompleteIp / encRCSeq->intraPeriod ); + + // collect the GOP features which will be used to detect scene changes + std::list::iterator it; + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++ ) + { + if ( it->tempLayer == 0 ) + { + if ( !it->isIntra ) + { + gopFeature[ counter[ 0 ] ] = it->yPsnr / log( it->numBits ); + meanFeatureValueInter += gopFeature[ counter[ 0 ] ]; + counter[ 0 ]++; + } + else + { + gopFeatureIntra[ counter[ 1 ] ] = it->yPsnr / log( it->numBits ); + meanFeatureValueIntra += gopFeatureIntra[ counter[ 1 ] ]; + counter[ 1 ]++; + } + } + } + meanFeatureValueInter /= counter[ 0 ]; + meanFeatureValueIntra /= counter[ 1 ]; + + counter[ 0 ] = 0; + counter[ 1 ] = 0; + // iterate through the first pass frame data to detect scene changes + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++ ) + { + if ( it->tempLayer == 0 ) + { + if ( !it->isIntra ) + { + gopFeature[ counter[ 0 ] ] /= meanFeatureValueInter; // normalize GOP feature values + if ( counter[ 0 ] > 0 ) + { + if ( abs( gopFeature[ counter[ 0 ] ] - gopFeature[ counter[ 0 ] - 1 ] ) > newSceneDetectionTH && it->poc - encRCSeq->gopSize > pocOfLastSceneChange[ 1 ] ) // detect scene cut + { + it->isNewScene = true; + pocOfLastSceneChange[ 0 ] = it->poc; + } + } + counter[ 0 ]++; + } + else + { + gopFeatureIntra[ counter[ 1 ] ] /= meanFeatureValueIntra; // normalize GOP feature values + if ( counter[ 1 ] > 0 ) + { + if ( abs( gopFeatureIntra[ counter[ 1 ] ] - gopFeatureIntra[ counter[ 1 ] - 1 ] ) > newSceneDetectionTHIntra && it->poc - encRCSeq->intraPeriod > pocOfLastSceneChange[ 0 ] ) // detect scene cut + { + it->isNewScene = true; + pocOfLastSceneChange[ 1 ] = it->poc; + } + } + counter[ 1 ]++; + } + } + } +} + +void RateCtrl::processGops() +{ + int iterationCounter = 0; + double actualBitrateAfterScaling = -1.0; + int pocOfLastCompleteGop = int( floor( ( m_listRCFirstPassStats.size() - 1 ) / encRCSeq->gopSize ) * encRCSeq->gopSize ); + std::vector gopBits( 2 + pocOfLastCompleteGop / encRCSeq->gopSize ); // +2 for the first I frame (GOP) and a potential last incomplete GOP + std::vector scaledBits( int( m_listRCFirstPassStats.size() ) ); + + // count total bits in every GOP + std::list::iterator it; + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++, iterationCounter++ ) + { + if ( it->poc == 0 ) + { + gopBits[ 0 ] = it->numBits; + } + else + { + gopBits[ 1 + ( it->poc - 1 ) / encRCSeq->gopSize ] += it->numBits; + } + scaledBits[ iterationCounter ] = double( it->numBits ); + } + + // scale GOP and frame bits to account for different target bitrates besed on the first pass data + scaleGops( scaledBits, gopBits, actualBitrateAfterScaling ); + + // calculate frame and GOP ratios; calculate target bits + iterationCounter = 0; + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++, iterationCounter++ ) + { + it->scaledBits = scaledBits[ iterationCounter ]; + if ( it->poc == 0 ) // distinguish between the first frame and the rest of the sequence + { + it->frameInGopRatio = it->scaledBits / gopBits[ 0 ]; + it->gopBitsVsBitrate = double( gopBits[ 0 ] ) / actualBitrateAfterScaling; + } + else + { + it->frameInGopRatio = it->scaledBits / gopBits[ 1 + ( it->poc - 1 ) / encRCSeq->gopSize ]; + it->gopBitsVsBitrate = double( gopBits[ 1 + ( it->poc - 1 ) / encRCSeq->gopSize ] ) / actualBitrateAfterScaling; + } + it->targetBits = int( it->frameInGopRatio * it->gopBitsVsBitrate * encRCSeq->targetRate + 0.5 ); + } +} + +void RateCtrl::scaleGops( std::vector &scaledBits, std::vector &gopBits, double &actualBitrateAfterScaling ) +{ + int64_t totalBitsInFirstPass = getTotalBitsInFirstPass(); + double averageBitrateFirstPass = double( totalBitsInFirstPass ) / m_listRCFirstPassStats.size() * encRCSeq->frameRate; + double scalingParameter = 0.175; // tuning parameter + double gopScalingFactor = 1.0 - scalingParameter * log( encRCSeq->targetRate / averageBitrateFirstPass ) / log( 2 ); + double frameScalingFactor = 1.0; + int pocOfLastCompleteGop = int( floor( ( m_listRCFirstPassStats.size() - 1 ) / encRCSeq->gopSize ) * encRCSeq->gopSize ); + int pocOfLastCompleteIp = int( floor( ( m_listRCFirstPassStats.size() - 1 ) / encRCSeq->intraPeriod ) * encRCSeq->intraPeriod ); + int gopsInIntraPeriod = encRCSeq->intraPeriod / encRCSeq->gopSize; + + // scale the first frame in the sequence + scaledBits[ 0 ] *= gopScalingFactor; + + // scale GOP and frame bits to account for different target rates + for ( int i = 0; i < pocOfLastCompleteIp / encRCSeq->gopSize; i += gopsInIntraPeriod ) + { + double meanGopBits = 0.0; + // iterate through GOPs inside an IP to calculate an average GOP bits within one IP + for ( int j = 0; j < gopsInIntraPeriod; j++ ) + { + meanGopBits += double( gopBits[ 1 + i + j ] ); + } + meanGopBits /= gopsInIntraPeriod; + + // scale GOP bits in an IP + for ( int j = 0; j < gopsInIntraPeriod; j++ ) + { + double tmpGopScaledBits = std::max( 2000.0, ( gopBits[ 1 + i + j ] - meanGopBits ) * gopScalingFactor + meanGopBits ); + frameScalingFactor = tmpGopScaledBits / gopBits[ 1 + i + j ]; + gopBits[ 1 + i + j ] = tmpGopScaledBits; + for ( int k = 0; k < encRCSeq->gopSize; k++ ) // scale frame bits inside the scaled GOP + { + scaledBits[ 1 + ( i + j ) * encRCSeq->gopSize + k ] *= frameScalingFactor; + } + } + } + + // scale the potentially incomplete last IP (but not the last incomplete GOP!) + if ( pocOfLastCompleteGop != pocOfLastCompleteIp ) + { + double meanGopBits = 0.0; + for ( int i = pocOfLastCompleteIp / encRCSeq->gopSize; i < pocOfLastCompleteGop / encRCSeq->gopSize; i++ ) + { + meanGopBits += double( gopBits[ 1 + i ] ); + } + meanGopBits /= ( ( pocOfLastCompleteGop - pocOfLastCompleteIp ) / encRCSeq->gopSize ); + + // scale bits for the last incomplete IP + for ( int i = pocOfLastCompleteIp / encRCSeq->gopSize; i < pocOfLastCompleteGop / encRCSeq->gopSize; i++ ) + { + double tmpGopScaledBits = std::max( 2000.0, ( gopBits[ 1 + i ] - meanGopBits ) * gopScalingFactor + meanGopBits ); + frameScalingFactor = tmpGopScaledBits / gopBits[ 1 + i ]; + gopBits[ 1 + i ] = tmpGopScaledBits; + for ( int j = 0; j < encRCSeq->gopSize; j++ ) //scale frame bits inside the scaled GOP + { + scaledBits[ 1 + i * encRCSeq->gopSize + j ] *= frameScalingFactor; + } + } + } + + // make sure that the total scaled frame bits match the average bitrate + int64_t totalScaledBits = 0; + for ( int i = 0; i < m_listRCFirstPassStats.size(); i++ ) + { + totalScaledBits += int64_t( scaledBits[ i ] ); + } + actualBitrateAfterScaling = double( totalScaledBits ) / m_listRCFirstPassStats.size() * encRCSeq->frameRate; +} + +void RateCtrl::estimateAlphaFirstPass( int numTempLevels, int startPoc, int pocRange, double *alphaEstimate ) +{ + std::vector bitsData( numTempLevels ); + std::vector qpData( numTempLevels ); + std::vector counter( numTempLevels ); + int iterationCounter = 0; + + // collect the first pass TL data for the specified POC range + std::list::iterator it; + for ( it = m_listRCFirstPassStats.begin(); it != m_listRCFirstPassStats.end(); it++ ) + { + if ( it->poc == startPoc ) + { + if ( it->isIntra ) + { + bitsData[ it->tempLayer ] += it->numBits; + qpData[ it->tempLayer ] = it->qp; + counter[ it->tempLayer ]++; + } + else + { + bitsData[ it->tempLayer + 1 ] += it->numBits; + qpData[ it->tempLayer + 1 ] = it->qp; + counter[ it->tempLayer + 1 ]++; + } + iterationCounter++; + } + else if ( iterationCounter > 0 && iterationCounter < pocRange ) + { + if ( it->isIntra ) + { + bitsData[ it->tempLayer ] += it->numBits; + qpData[ it->tempLayer ] = it->qp; + counter[ it->tempLayer ]++; + } + else + { + bitsData[ it->tempLayer + 1 ] += it->numBits; + qpData[ it->tempLayer + 1 ] = it->qp; + counter[ it->tempLayer + 1 ]++; + } + iterationCounter++; + } + else if ( iterationCounter >= pocRange ) + { + break; + } + } + + // calculate alpha parameter based on the collected first pass data + for ( int i = 0; i < numTempLevels; i++ ) + { + if ( counter[ i ] > 0 ) + { + double bpp = ( double( bitsData[ i ] ) / counter[ i ] ) / ( encRCSeq->picWidth * encRCSeq->picHeight ); + alphaEstimate[ i ] = exp( ( qpData[ i ] - 13.7122 ) / 4.2005 ) / pow( bpp, -1.367 ); + } + else + { + alphaEstimate[ i ] = 0.0; + } + } +} +void RateCtrl::addRCPassStats( int poc, int qp, uint32_t numBits, double yPsnr, double uPsnr, double vPsnr, bool isIntra, int tempLayer ) +{ + if( rcPass < rcMaxPass ) + { + m_listRCFirstPassStats.push_back( TRCPassStats( poc, qp, numBits, yPsnr, uPsnr, vPsnr, isIntra, tempLayer ) ); + } +} static int xCalcHADs8x8_ISlice( const Pel *piOrg, const int iStrideOrg ) { @@ -1916,4 +2801,4 @@ void EncRCPic::calCostSliceI( Picture* pic ) // TODO: this only analyses the fir } -} \ No newline at end of file +} diff --git a/source/Lib/EncoderLib/RateCtrl.h b/source/Lib/EncoderLib/RateCtrl.h index 3a606b16a..824049253 100644 --- a/source/Lib/EncoderLib/RateCtrl.h +++ b/source/Lib/EncoderLib/RateCtrl.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file RateCtrl.h \brief Rate control manager class */ @@ -50,7 +54,7 @@ vvc@hhi.fraunhofer.de #include "CommonLib/CommonDef.h" -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include #include @@ -81,13 +85,33 @@ namespace vvenc { int validPix; }; + struct TRCPassStats + { + TRCPassStats( int _poc, int _qp, uint32_t _numBits, double _yPsnr, double _uPsnr, double _vPsnr, bool _isIntra, int _tempLayer ) : poc( _poc ), qp( _qp ), numBits( _numBits ), yPsnr( _yPsnr ), uPsnr( _uPsnr ), vPsnr( _vPsnr ), isIntra( _isIntra ), tempLayer( _tempLayer ), isNewScene( false ), frameInGopRatio( -1.0 ), gopBitsVsBitrate( -1.0 ), scaledBits( double( numBits ) ), targetBits( 0 ), estAlpha() {} + int poc; + int qp; + uint32_t numBits; + double yPsnr; + double uPsnr; + double vPsnr; + bool isIntra; + int tempLayer; + + bool isNewScene; + double frameInGopRatio; + double gopBitsVsBitrate; + double scaledBits; + int targetBits; + double estAlpha[ 7 ]; + }; + class EncRCSeq { public: EncRCSeq(); ~EncRCSeq(); - void create( int RCMode, int totFrames, int targetBitrate, int frameRate, int intraPeriod, int GOPSize, int picWidth, int picHeight, int LCUWidth, int LCUHeight, int numberOfLevel, bool useLCUSeparateModel, int adaptiveBit ); + void create( int RCMode, bool twoPass, int totFrames, int targetBitrate, int frameRate, int intraPeriod, int GOPSize, int picWidth, int picHeight, int LCUWidth, int LCUHeight, int numberOfLevel, bool useLCUSeparateModel, int adaptiveBit, std::list &firstPassData ); void destroy(); void initBitsRatio( int bitsRatio[] ); void initGOPID2Level( int GOPID2Level[] ); @@ -98,9 +122,11 @@ namespace vvenc { void setQpInGOP( int gopId, int gopQp, int &qp ); bool isQpResetRequired( int gopId ); int getLeftAverageBits() { CHECK( !( framesLeft > 0 ), "No frames left" ); return (int)( bitsLeft / framesLeft ); } + void getTargetBitsFromFirstPass( int poc, int &targetBits, double &gopVsBitrateRatio, bool &isNewScene, double alpha[] ); public: int rcMode; + bool twoPass; int totalFrames; int targetRate; int frameRate; @@ -118,20 +144,20 @@ namespace vvenc { int adaptiveBits; int bitDepth; int64_t bitsUsed; + int64_t estimatedBitUsage; + double bitUsageRatio; double lastLambda; bool useLCUSeparateModel; TRCParameter* picParam; TRCParameter** lcuParam; int* bitsRatio; int* gopID2Level; + std::list firstPassData; private: int numberOfLevel; int64_t targetBits; int64_t bitsLeft; - double seqTargetBpp; - double alphaUpdate; - double betaUpdate; }; class EncRCGOP @@ -175,9 +201,17 @@ namespace vvenc { void calCostSliceI( Picture* pic ); int estimatePicQP( double lambda, std::list& listPreviousPictures ); + void clipQpConventional( std::list& listPreviousPictures, int &QP ); + void clipQpFrameRc( std::list& listPreviousPictures, int &QP ); + void clipQpGopRc( std::list& listPreviousPictures, int &QP ); + void clipQpTwoPass( std::list& listPreviousPictures, int &QP ); int getRefineBitsForIntra( int orgBits ); double calculateLambdaIntra( double alpha, double beta, double MADPerPixel, double bitsPerPixel ); double estimatePicLambda( std::list& listPreviousPictures, bool isIRAP ); + void clipLambdaConventional( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ); + void clipLambdaFrameRc( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ); + void clipLambdaGopRc( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ); + void clipLambdaTwoPass( std::list& listPreviousPictures, double &lambda, int bitdepthLumaScale ); void updateAlphaBetaIntra( double *alpha, double *beta ); double getLCUTargetBpp( bool isIRAP, const int ctuRsAddr ); double getLCUEstLambdaAndQP( double bpp, int clipPicQP, int *estQP, const int ctuRsAddr ); @@ -221,6 +255,7 @@ namespace vvenc { double remainingCostIntra; double picLambda; double picMSE; + bool isNewScene; }; class RateCtrl @@ -235,7 +270,17 @@ namespace vvenc { void initRCGOP( int numberOfPictures ); void destroyRCGOP(); + void setRCPass( int pass, int maxPass ); + void addRCPassStats( int poc, int qp, uint32_t numBits, double yPsnr, double uPsnr, double vPsnr, bool isIntra, int tempLayer ); + void processFirstPassData(); + void estimateAlphaFirstPass( int numOfLevels, int startPoc, int pocRange, double *alphaEstimate ); + void processGops(); + void scaleGops( std::vector &scaledBits, std::vector &gopBits, double &actualBitrateAfterScaling ); + int64_t getTotalBitsInFirstPass(); + void detectNewScene(); + std::list& getPicList() { return m_listRCPictures; } + std::list& getFirstPassStats() { return m_listRCFirstPassStats; } public: EncRCSeq* encRCSeq; @@ -243,9 +288,13 @@ namespace vvenc { EncRCPic* encRCPic; std::mutex rcMutex; int rcQP; + int rcPass; + int rcMaxPass; + bool rcIsFinalPass; private: - std::list m_listRCPictures; + std::list m_listRCPictures; + std::list m_listRCFirstPassStats; }; } #endif diff --git a/source/Lib/EncoderLib/SEIEncoder.cpp b/source/Lib/EncoderLib/SEIEncoder.cpp index 8b2fc08ac..2dba8c01f 100644 --- a/source/Lib/EncoderLib/SEIEncoder.cpp +++ b/source/Lib/EncoderLib/SEIEncoder.cpp @@ -1,90 +1,496 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ #include "SEIEncoder.h" -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CommonLib/CommonDef.h" #include "CommonLib/SEI.h" #include "CommonLib/PicYuvMD5.h" +#include "CommonLib/HRD.h" +#include "CommonLib/Slice.h" +#include "EncHRD.h" //! \ingroup EncoderLib //! \{ namespace vvenc { +void SEIEncoder::init( const EncCfg& encCfg, EncHRD& encHRD) +{ + m_pcEncCfg = &encCfg; + m_pcEncHRD = &encHRD; + m_isInitialized = true; + ::memset(m_lastBPSEI, 0, sizeof(m_lastBPSEI)); + ::memset(m_totalCoded, 0, sizeof(m_totalCoded)); +} + +void SEIEncoder::initBufferingPeriodSEI( SEIBufferingPeriod& bpSei, bool noLeadingPictures) +{ + CHECK(!(m_isInitialized), "bufferingPeriodSEI already initialized"); + + uint32_t uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec + bpSei.bpNalCpbParamsPresent = true; + bpSei.bpVclCpbParamsPresent = true; + bpSei.bpMaxSubLayers = m_pcEncCfg->m_maxTempLayer; + bpSei.bpCpbCnt = 1; + for(int i=0; i < bpSei.bpMaxSubLayers; i++) + { + for(int j=0; j < bpSei.bpCpbCnt; j++) + { + bpSei.initialCpbRemovalDelay[j][i][0] = uiInitialCpbRemovalDelay; + bpSei.initialCpbRemovalDelay[j][i][1] = uiInitialCpbRemovalDelay; + bpSei.initialCpbRemovalOffset[j][i][0] = uiInitialCpbRemovalDelay; + bpSei.initialCpbRemovalOffset[j][i][1] = uiInitialCpbRemovalDelay; + } + } + // We don't set concatenation_flag here. max_initial_removal_delay_for_concatenation depends on the usage scenario. + // The parameters could be added to config file, but as long as the initialisation of generic buffering parameters is + // not controllable, it does not seem to make sense to provide settings for these. + bpSei.concatenationFlag = false; + bpSei.maxInitialRemovalDelayForConcatenation = uiInitialCpbRemovalDelay; + bpSei.bpDecodingUnitHrdParamsPresent = false;//m_pcEncCfg->m_noPicPartitionFlag == false; + bpSei.decodingUnitCpbParamsInPicTimingSeiFlag = !m_pcEncCfg->m_decodingUnitInfoSEIEnabled; + bpSei.initialCpbRemovalDelayLength = 16; // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit + // Note: The following parameters require some knowledge about the GOP structure. + // Using getIntraPeriod() should be avoided though, because it assumes certain GOP + // properties, which are only valid in CTC. + // Still copying this setting from HM for consistency, improvements welcome + bool isRandomAccess = m_pcEncCfg->m_IntraPeriod > 0; + if( isRandomAccess && m_pcEncCfg->m_IntraPeriod < 256) + { + bpSei.cpbRemovalDelayLength = // 6 // 32 = 2^5 (plus 1) + bpSei.dpbOutputDelayLength = ceilLog2( m_pcEncCfg->m_IntraPeriod)+1; // 6 // 32 + 3 = 2^6 + } + else + { + bpSei.cpbRemovalDelayLength = 9; // max. 2^10 + bpSei.dpbOutputDelayLength = 9; // max. 2^10 + } + bpSei.duCpbRemovalDelayIncrementLength = 7; // ceil( log2( tick_divisor_minus2 + 2 ) ) + bpSei.dpbOutputDelayDuLength = bpSei.dpbOutputDelayLength + bpSei.duCpbRemovalDelayIncrementLength; + //for the concatenation, it can be set to one during splicing. + bpSei.concatenationFlag = 0; + //since the temporal layer HRDParameters is not ready, we assumed it is fixed + bpSei.auCpbRemovalDelayDelta = 1; + bool bpDeltasGOPStructure = m_pcEncCfg->m_GOPSize == 8 || m_pcEncCfg->m_GOPSize == 16; //assume GOPs specified as in CTC + bpSei.cpbRemovalDelayDeltasPresent = bpDeltasGOPStructure; + if (bpSei.cpbRemovalDelayDeltasPresent) + { + switch (m_pcEncCfg->m_GOPSize) + { + case 8: + { + if (noLeadingPictures) + { + bpSei.numCpbRemovalDelayDeltas = 5; + bpSei.cpbRemovalDelayDelta[0] = 1; + bpSei.cpbRemovalDelayDelta[1] = 2; + bpSei.cpbRemovalDelayDelta[2] = 3; + bpSei.cpbRemovalDelayDelta[3] = 6; + bpSei.cpbRemovalDelayDelta[4] = 7; + } + else + { + bpSei.numCpbRemovalDelayDeltas = 3; + bpSei.cpbRemovalDelayDelta[0] = 1; + bpSei.cpbRemovalDelayDelta[1] = 2; + bpSei.cpbRemovalDelayDelta[2] = 3; + } + } + break; + case 16: + { + if (noLeadingPictures) + { + bpSei.numCpbRemovalDelayDeltas = 9; + bpSei.cpbRemovalDelayDelta[0] = 1; + bpSei.cpbRemovalDelayDelta[1] = 2; + bpSei.cpbRemovalDelayDelta[2] = 3; + bpSei.cpbRemovalDelayDelta[3] = 4; + bpSei.cpbRemovalDelayDelta[4] = 6; + bpSei.cpbRemovalDelayDelta[5] = 7; + bpSei.cpbRemovalDelayDelta[6] = 9; + bpSei.cpbRemovalDelayDelta[7] = 14; + bpSei.cpbRemovalDelayDelta[8] = 15; + } + else + { + bpSei.numCpbRemovalDelayDeltas = 5; + bpSei.cpbRemovalDelayDelta[0] = 1; + bpSei.cpbRemovalDelayDelta[1] = 2; + bpSei.cpbRemovalDelayDelta[2] = 3; + bpSei.cpbRemovalDelayDelta[3] = 6; + bpSei.cpbRemovalDelayDelta[4] = 7; + } + } + break; + default: + { + THROW("m_cpbRemovalDelayDelta not applicable for the GOP size"); + } + break; + } + } + bpSei.sublayerDpbOutputOffsetsPresent = true; + for(int i = 0; i < bpSei.bpMaxSubLayers; i++) + { + bpSei.dpbOutputTidOffset[i] = m_pcEncCfg->m_maxNumReorderPics[i] * (1<<(bpSei.bpMaxSubLayers-1-i)); + if(bpSei.dpbOutputTidOffset[i] >= m_pcEncCfg->m_maxNumReorderPics[bpSei.bpMaxSubLayers-1]) + { + bpSei.dpbOutputTidOffset[i] -= m_pcEncCfg->m_maxNumReorderPics[bpSei.bpMaxSubLayers-1]; + } + else + { + bpSei.dpbOutputTidOffset[i] = 0; + } + } + // A commercial encoder should track the buffer state for all layers and sub-layers + // to ensure CPB conformance. Such tracking is required for calculating alternative + // CPB parameters. + // Unfortunately VTM does not have such tracking. Thus we cannot encode alternative + // CPB parameters here. + bpSei.altCpbParamsPresent = false; + bpSei.useAltCpbParamsFlag = false; +} //! calculate hashes for entire reconstructed picture -void SEIEncoder::initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI , const CPelUnitBuf& pic, std::string &rHashString, const BitDepths &bitDepths) +void SEIEncoder::initDecodedPictureHashSEI( SEIDecodedPictureHash& dphSei, const CPelUnitBuf& pic, std::string &rHashString, const BitDepths &bitDepths) { CHECK(!(m_isInitialized), "Unspecified error"); - CHECK(!(decodedPictureHashSEI!=NULL), "Unspecified error"); - decodedPictureHashSEI->method = m_pcCfg->m_decodedPictureHashSEIType; - switch (m_pcCfg->m_decodedPictureHashSEIType) + dphSei.method = m_pcEncCfg->m_decodedPictureHashSEIType; + dphSei.singleCompFlag = m_pcEncCfg->m_internChromaFormat == 0; + + switch (m_pcEncCfg->m_decodedPictureHashSEIType) { case HASHTYPE_MD5: { - uint32_t numChar=calcMD5(pic, decodedPictureHashSEI->m_pictureHash, bitDepths); - rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); + uint32_t numChar=calcMD5(pic, dphSei.pictureHash, bitDepths); + rHashString = hashToString(dphSei.pictureHash, numChar); } break; case HASHTYPE_CRC: { - uint32_t numChar=calcCRC(pic, decodedPictureHashSEI->m_pictureHash, bitDepths); - rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); + uint32_t numChar=calcCRC(pic, dphSei.pictureHash, bitDepths); + rHashString = hashToString(dphSei.pictureHash, numChar); } break; case HASHTYPE_CHECKSUM: default: { - uint32_t numChar=calcChecksum(pic, decodedPictureHashSEI->m_pictureHash, bitDepths); - rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); + uint32_t numChar=calcChecksum(pic, dphSei.pictureHash, bitDepths); + rHashString = hashToString(dphSei.pictureHash, numChar); } break; } } +void SEIEncoder::initPictureTimingSEI( SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, const Slice *slice, const uint32_t numDU, const bool bpPresentInAU) +{ + // Picture timing depends on buffering period. When either of those is not disabled, + // initialization would fail. Needs more cleanup after DU timing is integrated. + if (!(m_pcEncCfg->m_pictureTimingSEIEnabled && m_pcEncCfg->m_bufferingPeriodSEIEnabled)) + { + return; + } + + const GeneralHrdParams *hrd = &slice->sps->generalHrdParams; + + // update decoding unit parameters + if ((m_pcEncCfg->m_pictureTimingSEIEnabled || m_pcEncCfg->m_bufferingPeriodSEIEnabled) && slice->nuhLayerId == slice->vps->layerId[0]) + { + int picSptDpbOutputDuDelay = 0; + SEIPictureTiming *ptSei = new SEIPictureTiming(); + const uint32_t maxNumSubLayers = slice->sps->maxTLayers; + + // DU parameters + if( hrd->generalDecodingUnitHrdParamsPresent ) + { + ptSei->numDecodingUnitsMinus1 = numDU - 1; + ptSei->duCommonCpbRemovalDelayFlag = false; + ptSei->numNalusInDuMinus1.resize( numDU ); + ptSei->duCpbRemovalDelayMinus1.resize( numDU * maxNumSubLayers ); + } + const uint32_t cpbRemovalDelayLegth = m_pcEncHRD->bufferingPeriodSEI.cpbRemovalDelayLength; + ptSei->auCpbRemovalDelay[maxNumSubLayers-1] = std::min(std::max(1, m_totalCoded[maxNumSubLayers-1] - m_lastBPSEI[maxNumSubLayers-1]), (1< (1<TLayer; + for( int i = temporalId ; i < maxNumSubLayers - 1 ; i ++ ) + { + int indexWithinGOP = (m_totalCoded[maxNumSubLayers - 1] - m_lastBPSEI[maxNumSubLayers - 1]) % m_pcEncCfg->m_GOPSize; + ptSei->ptSubLayerDelaysPresent[i] = true; + if( ((m_rapWithLeading == true) && (indexWithinGOP == 0)) || (m_totalCoded[maxNumSubLayers - 1] == 0) || bpPresentInAU || (slice->poc + m_pcEncCfg->m_GOPSize) > m_pcEncCfg->m_framesToBeEncoded ) + { + ptSei->cpbRemovalDelayDeltaEnabledFlag[i] = false; + } + else + { + ptSei->cpbRemovalDelayDeltaEnabledFlag[i] = m_pcEncHRD->bufferingPeriodSEI.cpbRemovalDelayDeltasPresent; + } + if( ptSei->cpbRemovalDelayDeltaEnabledFlag[i] ) + { + if( m_rapWithLeading == false ) + { + switch (m_pcEncCfg->m_GOPSize) + { + case 8: + { + if((indexWithinGOP == 1 && i == 2)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 0; + } + else if((indexWithinGOP == 2 && i == 2) || (indexWithinGOP == 6 && i == 2)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 1; + } + else if((indexWithinGOP == 1 && i == 1) || (indexWithinGOP == 3 && i == 2)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 2; + } + else if(indexWithinGOP == 2 && i == 1) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 3; + } + else if(indexWithinGOP == 1 && i == 0) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 4; + } + else + { + THROW("m_cpbRemovalDelayDeltaIdx not applicable for the sub-layer and GOP size"); + } + } + break; + case 16: + { + if((indexWithinGOP == 1 && i == 3)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 0; + } + else if((indexWithinGOP == 2 && i == 3) || (indexWithinGOP == 10 && i == 3) || (indexWithinGOP == 14 && i == 3)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 1; + } + else if((indexWithinGOP == 1 && i == 2) || (indexWithinGOP == 3 && i == 3) || (indexWithinGOP == 7 && i == 3) || (indexWithinGOP == 11 && i == 3)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 2; + } + else if(indexWithinGOP == 4 && i == 3) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 3; + } + else if((indexWithinGOP == 2 && i == 2) || (indexWithinGOP == 10 && i == 2)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 4; + } + else if(indexWithinGOP == 1 && i == 1) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 5; + } + else if(indexWithinGOP == 3 && i == 2) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 6; + } + else if(indexWithinGOP == 2 && i == 1) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 7; + } + else if(indexWithinGOP == 1 && i == 0) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 8; + } + else + { + THROW("m_cpbRemovalDelayDeltaIdx not applicable for the sub-layer and GOP size"); + } + } + break; + default: + { + THROW("m_cpbRemovalDelayDeltaIdx not supported for the current GOP size"); + } + break; + } + } + else + { + switch (m_pcEncCfg->m_GOPSize) + { + case 8: + { + if((indexWithinGOP == 1 && i == 2) || (indexWithinGOP == 5 && i == 2)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 0; + } + else if(indexWithinGOP == 2 && i == 2) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 1; + } + else if(indexWithinGOP == 1 && i == 1) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 2; + } + else + { + THROW("m_cpbRemovalDelayDeltaIdx not applicable for the sub-layer and GOP size"); + } + } + break; + case 16: + { + if((indexWithinGOP == 1 && i == 3) || (indexWithinGOP == 9 && i == 3) || (indexWithinGOP == 13 && i == 3)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 0; + } + else if((indexWithinGOP == 2 && i == 3) || (indexWithinGOP == 6 && i == 3) || (indexWithinGOP == 10 && i == 3)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 1; + } + else if((indexWithinGOP == 1 && i == 2) || (indexWithinGOP == 9 && i == 2) || (indexWithinGOP == 3 && i == 3)) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 2; + } + else if(indexWithinGOP == 2 && i == 2) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 3; + } + else if(indexWithinGOP == 1 && i == 1) + { + ptSei->cpbRemovalDelayDeltaIdx[i] = 4; + } + else + { + THROW("m_cpbRemovalDelayDeltaIdx not applicable for the sub-layer and GOP size"); + } + } + break; + default: + { + THROW("m_cpbRemovalDelayDeltaIdx not applicable for the sub-layer and GOP size"); + } + break; + } + } + } + else + { + int scaledDistToBuffPeriod = (m_totalCoded[i] - m_lastBPSEI[i]) * (1<<(maxNumSubLayers - 1 - i)); + ptSei->auCpbRemovalDelay[i] = std::min(std::max(1, scaledDistToBuffPeriod), (1< (1<picDpbOutputDelay = slice->sps->numReorderPics[slice->sps->maxTLayers-1] + slice->poc - m_totalCoded[maxNumSubLayers-1]; +// if(m_pcEncCfg->m_efficientFieldIRAPEnabled && IRAPGOPid > 0 && IRAPGOPid < m_iGopSize) +// { +// // if pictures have been swapped there is likely one more picture delay on their tid. Very rough approximation +// ptSei->picDpbOutputDelay ++; +// } + int factor = hrd->tickDivisorMinus2 + 2; + ptSei->picDpbOutputDuDelay = factor * ptSei->picDpbOutputDelay; + if( m_pcEncCfg->m_decodingUnitInfoSEIEnabled ) + { + picSptDpbOutputDuDelay = factor * ptSei->picDpbOutputDelay; + } + if( bpPresentInAU ) + { + for( int i = temporalId ; i < maxNumSubLayers ; i ++ ) + { + m_lastBPSEI[i] = m_totalCoded[i]; + } + if( (slice->nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL)||(slice->nalUnitType == NAL_UNIT_CODED_SLICE_CRA) ) + { + m_rapWithLeading = true; + } + } + + + if( m_pcEncCfg->m_pictureTimingSEIEnabled ) + { + seiMessages.push_back( ptSei ); + +// if (m_pcEncCfg->m_scalableNestingSEIEnabled && !m_pcEncCfg->m_samePicTimingInAllOLS) +// { +// SEIPictureTiming *pictureTimingSEIcopy = new SEIPictureTiming(); +// *pictureTimingSEIcopy = *pictureTimingSEI; +// nestedSeiMessages.push_back(pictureTimingSEIcopy); +// } + } + + if( m_pcEncCfg->m_decodingUnitInfoSEIEnabled && hrd->generalDecodingUnitHrdParamsPresent ) + { + for( int i = 0; i < ( ptSei->numDecodingUnitsMinus1 + 1 ); i ++ ) + { + SEIDecodingUnitInfo *duInfoSEI = new SEIDecodingUnitInfo(); + duInfoSEI->decodingUnitIdx = i; + for( int j = temporalId; j <= maxNumSubLayers; j++ ) + { + duInfoSEI->duSptCpbRemovalDelayIncrement[j] = ptSei->duCpbRemovalDelayMinus1[i*maxNumSubLayers+j] + 1; + } + duInfoSEI->dpbOutputDuDelayPresent = false; + duInfoSEI->picSptDpbOutputDuDelay = picSptDpbOutputDuDelay; + + duInfoSeiMessages.push_back(duInfoSEI); + } + } + + if( !m_pcEncCfg->m_pictureTimingSEIEnabled && ptSei ) + { + delete ptSei; + } + } + + // not sure if this is the final place + for( int i = slice->TLayer; i < slice->sps->maxTLayers; i ++ ) + { + m_totalCoded[i]++; + } +} + } // namespace vvenc diff --git a/source/Lib/EncoderLib/SEIEncoder.h b/source/Lib/EncoderLib/SEIEncoder.h index 18f308ee4..69bf8a0d1 100644 --- a/source/Lib/EncoderLib/SEIEncoder.h +++ b/source/Lib/EncoderLib/SEIEncoder.h @@ -1,49 +1,54 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ #pragma once #include "CommonLib/SEI.h" #include "CommonLib/Unit.h" +#include //! \ingroup EncoderLib //! \{ @@ -51,27 +56,42 @@ namespace vvenc { // forward declarations class EncCfg; +class EncHRD; + +struct DUData +{ + DUData() : accumBitsDU(0), accumNalsDU(0) {}; + + int accumBitsDU; + int accumNalsDU; +}; //! Initializes different SEI message types based on given encoder configuration parameters class SEIEncoder { public: SEIEncoder() - :m_pcCfg(NULL) - ,m_isInitialized(false) + : m_pcEncCfg ( nullptr ) + , m_pcEncHRD ( nullptr ) + , m_isInitialized ( false ) + , m_rapWithLeading( false ) {}; virtual ~SEIEncoder(){}; - void init(const EncCfg& encCfg) - { - m_pcCfg = &encCfg; - m_isInitialized = true; - }; - void initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI, const CPelUnitBuf& pic, std::string &rHashString, const BitDepths &bitDepths); -private: - const EncCfg* m_pcCfg; + void init( const EncCfg& encCfg, EncHRD& encHRD); + void initDecodedPictureHashSEI ( SEIDecodedPictureHash& dphSei, const CPelUnitBuf& pic, std::string &rHashString, const BitDepths &bitDepths); - bool m_isInitialized; + void initBufferingPeriodSEI ( SEIBufferingPeriod& bpSei, bool noLeadingPictures); + void initPictureTimingSEI ( SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, const Slice *slice, const uint32_t numDU, const bool bpPresentInAU); + void initDrapSEI ( SEIDependentRAPIndication& drapSei) {}; + +private: + const EncCfg* m_pcEncCfg; + EncHRD* m_pcEncHRD; + bool m_isInitialized; + bool m_rapWithLeading; + uint32_t m_lastBPSEI[MAX_TLAYER]; + uint32_t m_totalCoded[MAX_TLAYER]; }; } // namespace vvenc diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp index a2e0d24d9..17ce2be03 100644 --- a/source/Lib/EncoderLib/SEIwrite.cpp +++ b/source/Lib/EncoderLib/SEIwrite.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ #include "SEIwrite.h" @@ -53,81 +57,89 @@ vvc@hhi.fraunhofer.de namespace vvenc { -void SEIWriter::xWriteSEIpayloadData(OutputBitstream& bs, const SEI& sei, const SPS *sps) +void SEIWriter::xWriteSEIpayloadData(OutputBitstream &bs, const SEI& sei, HRD &hrd, const uint32_t temporalId) { + const SEIBufferingPeriod *bp = NULL; switch (sei.payloadType()) { case SEI::USER_DATA_UNREGISTERED: xWriteSEIuserDataUnregistered(*static_cast(&sei)); break; - case SEI::ACTIVE_PARAMETER_SETS: - xWriteSEIActiveParameterSets(*static_cast(& sei)); - break; case SEI::DECODING_UNIT_INFO: - xWriteSEIDecodingUnitInfo(*static_cast(& sei), sps); + bp = &hrd.bufferingPeriodSEI; + CHECK (bp == nullptr, "Buffering Period need to be initialized in HRD to allow writing of Decoding Unit Information SEI"); + xWriteSEIDecodingUnitInfo(*static_cast(& sei), *bp, temporalId); + break; + case SEI::SCALABLE_NESTING: + xWriteSEIScalableNesting(bs, *static_cast(&sei)); break; case SEI::DECODED_PICTURE_HASH: xWriteSEIDecodedPictureHash(*static_cast(&sei)); break; case SEI::BUFFERING_PERIOD: - xWriteSEIBufferingPeriod(*static_cast(&sei), sps); + xWriteSEIBufferingPeriod(*static_cast(&sei)); + hrd.bufferingPeriodSEI = *(static_cast(&sei)); break; case SEI::PICTURE_TIMING: - xWriteSEIPictureTiming(*static_cast(&sei), sps); + { + bp = &hrd.bufferingPeriodSEI; + CHECK (bp == nullptr, "Buffering Period need to be initialized in HRD to allow writing of Picture Timing SEI"); + xWriteSEIPictureTiming(*static_cast(&sei), *bp, temporalId); + } + break; + case SEI::FRAME_FIELD_INFO: + xWriteSEIFrameFieldInfo(*static_cast(&sei)); break; - case SEI::RECOVERY_POINT: - xWriteSEIRecoveryPoint(*static_cast(&sei)); + case SEI::DEPENDENT_RAP_INDICATION: + xWriteSEIDependentRAPIndication(*static_cast(&sei)); break; case SEI::FRAME_PACKING: xWriteSEIFramePacking(*static_cast(&sei)); break; - case SEI::SEGM_RECT_FRAME_PACKING: - xWriteSEISegmentedRectFramePacking(*static_cast(&sei)); + case SEI::PARAMETER_SETS_INCLUSION_INDICATION: + xWriteSEIParameterSetsInclusionIndication(*static_cast(&sei)); break; - case SEI::DISPLAY_ORIENTATION: - xWriteSEIDisplayOrientation(*static_cast(&sei)); - break; - case SEI::TEMPORAL_LEVEL0_INDEX: - xWriteSEITemporalLevel0Index(*static_cast(&sei)); + case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: + xWriteSEIMasteringDisplayColourVolume(*static_cast(&sei)); break; - case SEI::REGION_REFRESH_INFO: - xWriteSEIGradualDecodingRefreshInfo(*static_cast(&sei)); + case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: + xWriteSEIAlternativeTransferCharacteristics(*static_cast(&sei)); break; - case SEI::NO_DISPLAY: - xWriteSEINoDisplay(*static_cast(&sei)); + case SEI::EQUIRECTANGULAR_PROJECTION: + xWriteSEIEquirectangularProjection(*static_cast(&sei)); break; - case SEI::TONE_MAPPING_INFO: - xWriteSEIToneMappingInfo(*static_cast(&sei)); + case SEI::SPHERE_ROTATION: + xWriteSEISphereRotation(*static_cast(&sei)); break; - case SEI::SOP_DESCRIPTION: - xWriteSEISOPDescription(*static_cast(&sei)); + case SEI::OMNI_VIEWPORT: + xWriteSEIOmniViewport(*static_cast(&sei)); break; - case SEI::SCALABLE_NESTING: - xWriteSEIScalableNesting(bs, *static_cast(&sei), sps); + case SEI::REGION_WISE_PACKING: + xWriteSEIRegionWisePacking(*static_cast(&sei)); break; - case SEI::CHROMA_RESAMPLING_FILTER_HINT: - xWriteSEIChromaResamplingFilterHint(*static_cast(&sei)); + case SEI::GENERALIZED_CUBEMAP_PROJECTION: + xWriteSEIGeneralizedCubemapProjection(*static_cast(&sei)); break; - case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: - xWriteSEITempMotionConstrainedTileSets(*static_cast(&sei)); + case SEI::USER_DATA_REGISTERED_ITU_T_T35: + xWriteSEIUserDataRegistered(*static_cast(&sei)); break; - case SEI::TIME_CODE: - xWriteSEITimeCode(*static_cast(&sei)); + case SEI::FILM_GRAIN_CHARACTERISTICS: + xWriteSEIFilmGrainCharacteristics(*static_cast(&sei)); break; - case SEI::KNEE_FUNCTION_INFO: - xWriteSEIKneeFunctionInfo(*static_cast(&sei)); + case SEI::CONTENT_LIGHT_LEVEL_INFO: + xWriteSEIContentLightLevelInfo(*static_cast(&sei)); break; - case SEI::COLOUR_REMAPPING_INFO: - xWriteSEIColourRemappingInfo(*static_cast(&sei)); + case SEI::AMBIENT_VIEWING_ENVIRONMENT: + xWriteSEIAmbientViewingEnvironment(*static_cast(&sei)); break; - case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: - xWriteSEIMasteringDisplayColourVolume(*static_cast(&sei)); + case SEI::CONTENT_COLOUR_VOLUME: + xWriteSEIContentColourVolume(*static_cast(&sei)); break; - case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: - xWriteSEIAlternativeTransferCharacteristics(*static_cast(&sei)); + case SEI::SUBPICTURE_LEVEL_INFO: + xWriteSEISubpictureLevelInfo(*static_cast(&sei)); break; - case SEI::GREEN_METADATA: - xWriteSEIGreenMetadataInfo(*static_cast(&sei)); + case SEI::SAMPLE_ASPECT_RATIO_INFO: + xWriteSEISampleAspectRatioInfo(*static_cast(&sei)); break; default: THROW("Trying to write unhandled SEI message"); @@ -139,13 +151,12 @@ void SEIWriter::xWriteSEIpayloadData(OutputBitstream& bs, const SEI& sei, const /** * marshal all SEI messages in provided list into one bitstream bs */ -void SEIWriter::writeSEImessages(OutputBitstream& bs, const SEIMessages &seiList, const SPS *sps, bool isNested) +void SEIWriter::writeSEImessages(OutputBitstream& bs, const SEIMessages &seiList, HRD &hrd, bool isNested, const uint32_t temporalId) { #if ENABLE_TRACING if (g_HLSTraceEnable) - xTraceSEIHeader(); + DTRACE( g_trace_ctx, D_HEADER, "=========== SEI message ===========\n" ); #endif - OutputBitstream bs_count; for (SEIMessages::const_iterator sei=seiList.begin(); sei!=seiList.end(); sei++) @@ -159,7 +170,7 @@ void SEIWriter::writeSEImessages(OutputBitstream& bs, const SEIMessages &seiList bool traceEnable = g_HLSTraceEnable; g_HLSTraceEnable = false; #endif - xWriteSEIpayloadData(bs_count, **sei, sps); + xWriteSEIpayloadData(bs_count, **sei, hrd, temporalId); #if ENABLE_TRACING g_HLSTraceEnable = traceEnable; #endif @@ -184,10 +195,10 @@ void SEIWriter::writeSEImessages(OutputBitstream& bs, const SEIMessages &seiList /* payloadData */ #if ENABLE_TRACING if (g_HLSTraceEnable) - xTraceSEIMessageType((*sei)->payloadType()); + DTRACE( g_trace_ctx, D_HEADER, "=========== %s SEI message ===========\n", SEI::getSEIMessageString( (SEI::PayloadType)payloadType ) ); #endif - xWriteSEIpayloadData(bs, **sei, sps); + xWriteSEIpayloadData(bs, **sei, hrd, temporalId); } if (!isNested) { @@ -208,7 +219,7 @@ void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei for (uint32_t i = 0; i < sei.userDataLength; i++) { - WRITE_CODE(sei.userData[i], 8 , "user_data"); + WRITE_CODE(sei.userData[i], 8 , "user_data_payload_byte"); } } @@ -229,462 +240,689 @@ void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei) if (traceString != 0) //use of this variable is needed to avoid a compiler error with G++ 4.6.1 { - WRITE_CODE(sei.method, 8, "hash_type"); - for(uint32_t i=0; i 0"); + WRITE_CODE( sei.initialCpbRemovalDelayLength - 1, 5, "initial_cpb_removal_delay_length_minus1" ); + CHECK (sei.cpbRemovalDelayLength < 1, "sei.cpbRemovalDelayLength must be > 0"); + WRITE_CODE( sei.cpbRemovalDelayLength - 1, 5, "cpb_removal_delay_length_minus1" ); + CHECK (sei.dpbOutputDelayLength < 1, "sei.dpbOutputDelayLength must be > 0"); + WRITE_CODE( sei.dpbOutputDelayLength - 1, 5, "dpb_output_delay_length_minus1" ); + WRITE_FLAG( sei.bpDecodingUnitHrdParamsPresent, "bp_decoding_unit_hrd_params_present_flag" ); + if( sei.bpDecodingUnitHrdParamsPresent ) + { + CHECK (sei.duCpbRemovalDelayIncrementLength < 1, "sei.duCpbRemovalDelayIncrementLength must be > 0"); + WRITE_CODE( sei.duCpbRemovalDelayIncrementLength - 1, 5, "du_cpb_removal_delay_increment_length_minus1" ); + CHECK (sei.dpbOutputDelayDuLength < 1, "sei.dpbOutputDelayDuLength must be > 0"); + WRITE_CODE( sei.dpbOutputDelayDuLength - 1, 5, "dpb_output_delay_du_length_minus1" ); + WRITE_FLAG( sei.decodingUnitCpbParamsInPicTimingSeiFlag, "decoding_unit_cpb_params_in_pic_timing_sei_flag" ); + WRITE_FLAG(sei.decodingUnitDpbDuParamsInPicTimingSeiFlag, "decoding_unit_dpb_du_params_in_pic_timing_sei_flag"); + } - if( sei.m_arrangementCancelFlag == 0 ) + WRITE_FLAG( sei.concatenationFlag, "concatenation_flag"); + WRITE_FLAG( sei.additionalConcatenationInfoPresent, "additional_concatenation_info_present_flag"); + if (sei.additionalConcatenationInfoPresent) { - WRITE_CODE( sei.m_arrangementType, 7, "frame_packing_arrangement_type" ); + WRITE_CODE( sei.maxInitialRemovalDelayForConcatenation, sei.initialCpbRemovalDelayLength, "max_initial_removal_delay_for_concatenation" ); + } - WRITE_FLAG( sei.m_quincunxSamplingFlag, "quincunx_sampling_flag" ); - WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" ); - WRITE_FLAG( sei.m_spatialFlippingFlag, "spatial_flipping_flag" ); - WRITE_FLAG( sei.m_frame0FlippedFlag, "frame0_flipped_flag" ); - WRITE_FLAG( sei.m_fieldViewsFlag, "field_views_flag" ); - WRITE_FLAG( sei.m_currentFrameIsFrame0Flag, "current_frame_is_frame0_flag" ); + CHECK (sei.auCpbRemovalDelayDelta < 1, "sei.auCpbRemovalDelayDelta must be > 0"); + WRITE_CODE( sei.auCpbRemovalDelayDelta - 1, sei.cpbRemovalDelayLength, "au_cpb_removal_delay_delta_minus1" ); - WRITE_FLAG( sei.m_frame0SelfContainedFlag, "frame0_self_contained_flag" ); - WRITE_FLAG( sei.m_frame1SelfContainedFlag, "frame1_self_contained_flag" ); + CHECK(sei.bpMaxSubLayers < 1, "bp_max_sub_layers_minus1 must be > 0"); + WRITE_CODE(sei.bpMaxSubLayers - 1, 3, "bp_max_sub_layers_minus1"); + if (sei.bpMaxSubLayers - 1 > 0) + { + WRITE_FLAG(sei.cpbRemovalDelayDeltasPresent, "cpb_removal_delay_deltas_present_flag"); + } - if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) + if (sei.cpbRemovalDelayDeltasPresent) + { + CHECK (sei.numCpbRemovalDelayDeltas < 1, "m_numCpbRemovalDelayDeltas must be > 0"); + WRITE_UVLC( sei.numCpbRemovalDelayDeltas - 1, "num_cpb_removal_delay_deltas_minus1" ); + for( int i = 0; i < sei.numCpbRemovalDelayDeltas; i ++ ) { - WRITE_CODE( sei.m_frame0GridPositionX, 4, "frame0_grid_position_x" ); - WRITE_CODE( sei.m_frame0GridPositionY, 4, "frame0_grid_position_y" ); - WRITE_CODE( sei.m_frame1GridPositionX, 4, "frame1_grid_position_x" ); - WRITE_CODE( sei.m_frame1GridPositionY, 4, "frame1_grid_position_y" ); + WRITE_CODE( sei.cpbRemovalDelayDelta[i], sei.cpbRemovalDelayLength, "cpb_removal_delay_delta[i]" ); } - - WRITE_CODE( sei.m_arrangementReservedByte, 8, "frame_packing_arrangement_reserved_byte" ); - WRITE_FLAG( sei.m_arrangementPersistenceFlag, "frame_packing_arrangement_persistence_flag" ); + } + CHECK (sei.bpCpbCnt < 1, "sei.bpCpbCnt must be > 0"); + WRITE_UVLC( sei.bpCpbCnt - 1, "bp_cpb_cnt_minus1"); + if (sei.bpMaxSubLayers - 1 > 0) + { + WRITE_FLAG(sei.sublayerInitialCpbRemovalDelayPresent, "bp_sublayer_initial_cpb_removal_delay_present_flag"); + } + for (int i = (sei.sublayerInitialCpbRemovalDelayPresent ? 0 : sei.bpMaxSubLayers - 1); i < sei.bpMaxSubLayers; i++) + { + for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) + { + if( ( ( nalOrVcl == 0 ) && ( sei.bpNalCpbParamsPresent ) ) || + ( ( nalOrVcl == 1 ) && ( sei.bpVclCpbParamsPresent ) ) ) + { + for( int j = 0; j < sei.bpCpbCnt; j ++ ) + { + WRITE_CODE( sei.initialCpbRemovalDelay[j][i][nalOrVcl], sei.initialCpbRemovalDelayLength, "initial_cpb_removal_delay[j][i][nalOrVcl]" ); + WRITE_CODE( sei.initialCpbRemovalOffset[j][i][nalOrVcl], sei.initialCpbRemovalDelayLength, "initial_cpb_removal_delay_offset[j][i][nalOrVcl]" ); + } + } + } + } + if (sei.bpMaxSubLayers-1 > 0) + { + WRITE_FLAG(sei.sublayerDpbOutputOffsetsPresent, "bp_sublayer_dpb_output_offsets_present_flag"); } - WRITE_FLAG( sei.m_upsampledAspectRatio, "upsampled_aspect_ratio" ); -} - -void SEIWriter::xWriteSEISegmentedRectFramePacking(const SEISegmentedRectFramePacking& sei) -{ - WRITE_FLAG( sei.m_arrangementCancelFlag, "segmented_rect_frame_packing_arrangement_cancel_flag" ); - if( sei.m_arrangementCancelFlag == 0 ) + if(sei.sublayerDpbOutputOffsetsPresent) + { + for(int i = 0; i < sei.bpMaxSubLayers - 1; i++) + { + WRITE_UVLC( sei.dpbOutputTidOffset[i], "dpb_output_tid_offset[i]" ); + } + } + WRITE_FLAG(sei.altCpbParamsPresent, "bp_alt_cpb_params_present_flag"); + if (sei.altCpbParamsPresent) { - WRITE_CODE( sei.m_contentInterpretationType, 2, "segmented_rect_content_interpretation_type" ); - WRITE_FLAG( sei.m_arrangementPersistenceFlag, "segmented_rect_frame_packing_arrangement_persistence" ); + WRITE_FLAG(sei.useAltCpbParamsFlag, "use_alt_cpb_params_flag"); } + } -void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei) +void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBufferingPeriod &bp, const uint32_t temporalId) { - int i; - WRITE_UVLC( sei.m_toneMapId, "tone_map_id" ); - WRITE_FLAG( sei.m_toneMapCancelFlag, "tone_map_cancel_flag" ); - if( !sei.m_toneMapCancelFlag ) - { - WRITE_FLAG( sei.m_toneMapPersistenceFlag, "tone_map_persistence_flag" ); - WRITE_CODE( sei.m_codedDataBitDepth, 8, "coded_data_bit_depth" ); - WRITE_CODE( sei.m_targetBitDepth, 8, "target_bit_depth" ); - WRITE_UVLC( sei.m_modelId, "model_id" ); - switch(sei.m_modelId) - { - case 0: - { - WRITE_CODE( sei.m_minValue, 32, "min_value" ); - WRITE_CODE( sei.m_maxValue, 32, "max_value" ); - break; - } - case 1: + WRITE_CODE( sei.auCpbRemovalDelay[bp.bpMaxSubLayers - 1] - 1, bp.cpbRemovalDelayLength, "pt_cpb_removal_delay_minus1[bp_max_sub_layers_minus1]" ); + for (int i = temporalId; i < bp.bpMaxSubLayers - 1; i++) + { + WRITE_FLAG(sei.ptSubLayerDelaysPresent[i], "pt_sub_layer_delays_present_flag[i]"); + if (sei.ptSubLayerDelaysPresent[i]) + { + if (bp.cpbRemovalDelayDeltasPresent) { - WRITE_CODE( sei.m_sigmoidMidpoint, 32, "sigmoid_midpoint" ); - WRITE_CODE( sei.m_sigmoidWidth, 32, "sigmoid_width" ); - break; + WRITE_FLAG(sei.cpbRemovalDelayDeltaEnabledFlag[i], "pt_cpb_removal_delay_delta_enabled_flag[i]"); } - case 2: + if (sei.cpbRemovalDelayDeltaEnabledFlag[i]) { - uint32_t num = 1u << sei.m_targetBitDepth; - for(i = 0; i < num; i++) + if ((bp.numCpbRemovalDelayDeltas - 1) > 0) { - WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3, "start_of_coded_interval" ); + WRITE_CODE(sei.cpbRemovalDelayDeltaIdx[i], ceilLog2(bp.numCpbRemovalDelayDeltas), "pt_cpb_removal_delay_delta_idx[i]"); } - break; } - case 3: + else + { + WRITE_CODE(sei.auCpbRemovalDelay[i] - 1, bp.cpbRemovalDelayLength, "pt_cpb_removal_delay_minus1[i]"); + } + } + } + WRITE_CODE(sei.picDpbOutputDelay, bp.dpbOutputDelayLength, "pt_dpb_output_delay"); + if( bp.altCpbParamsPresent ) + { + WRITE_FLAG( sei.cpbAltTimingInfoPresent, "cpb_alt_timing_info_present_flag" ); + if( sei.cpbAltTimingInfoPresent ) + { + if (bp.bpNalCpbParamsPresent) { - WRITE_CODE( sei.m_numPivots, 16, "num_pivots" ); - for(i = 0; i < sei.m_numPivots; i++ ) + for (int i = (bp.sublayerInitialCpbRemovalDelayPresent ? 0 : bp.bpMaxSubLayers - 1); i <= bp.bpMaxSubLayers - 1; ++i) { - WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3, "coded_pivot_value" ); - WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3, "target_pivot_value"); + for (int j = 0; j < bp.bpCpbCnt; j++) + { + WRITE_CODE(sei.nalCpbAltInitialRemovalDelayDelta[i][j], bp.initialCpbRemovalDelayLength, + "nal_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + WRITE_CODE(sei.nalCpbAltInitialRemovalOffsetDelta[i][j], bp.initialCpbRemovalDelayLength, + "nal_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + } + WRITE_CODE(sei.nalCpbDelayOffset[i], bp.cpbRemovalDelayLength, "nal_cpb_delay_offset[ i ]"); + WRITE_CODE(sei.nalDpbDelayOffset[i], bp.dpbOutputDelayLength, "nal_dpb_delay_offset[ i ]"); } - break; } - case 4: + + if (bp.bpVclCpbParamsPresent) { - WRITE_CODE( sei.m_cameraIsoSpeedIdc, 8, "camera_iso_speed_idc" ); - if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO + for (int i = (bp.sublayerInitialCpbRemovalDelayPresent ? 0 : bp.bpMaxSubLayers - 1); i <= bp.bpMaxSubLayers - 1; ++i) { - WRITE_CODE( sei.m_cameraIsoSpeedValue, 32, "camera_iso_speed_value" ); + for (int j = 0; j < bp.bpCpbCnt; j++) + { + WRITE_CODE(sei.vclCpbAltInitialRemovalDelayDelta[i][j], bp.initialCpbRemovalDelayLength, + "vcl_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + WRITE_CODE(sei.vclCpbAltInitialRemovalOffsetDelta[i][j], bp.initialCpbRemovalDelayLength, + "vcl_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + } + WRITE_CODE(sei.vclCpbDelayOffset[i], bp.cpbRemovalDelayLength, "vcl_cpb_delay_offset[ i ]"); + WRITE_CODE(sei.vclDpbDelayOffset[i], bp.dpbOutputDelayLength, "vcl_dpb_delay_offset[ i ]"); } - WRITE_CODE( sei.m_exposureIndexIdc, 8, "exposure_index_idc" ); - if( sei.m_exposureIndexIdc == 255) //Extended_ISO + } + } + } + if (bp.bpDecodingUnitHrdParamsPresent && bp.decodingUnitDpbDuParamsInPicTimingSeiFlag) + { + WRITE_CODE( sei.picDpbOutputDuDelay, bp.dpbOutputDelayDuLength, "pic_dpb_output_du_delay" ); + } + if( bp.bpDecodingUnitHrdParamsPresent && bp.decodingUnitCpbParamsInPicTimingSeiFlag ) + { + WRITE_UVLC( sei.numDecodingUnitsMinus1, "num_decoding_units_minus1" ); + if (sei.numDecodingUnitsMinus1 > 0) + { + WRITE_FLAG( sei.duCommonCpbRemovalDelayFlag, "du_commmon_cpb_removal_delay_flag" ); + if( sei.duCommonCpbRemovalDelayFlag ) + { + for( int i = temporalId; i < bp.bpMaxSubLayers - 1; i ++ ) { - WRITE_CODE( sei.m_exposureIndexValue, 32, "exposure_index_value" ); + if( sei.ptSubLayerDelaysPresent[i] ) + WRITE_CODE( sei.duCommonCpbRemovalDelayMinus1[i], bp.duCpbRemovalDelayIncrementLength, "du_common_cpb_removal_delay_increment_minus1[i]" ); } - WRITE_FLAG( sei.m_exposureCompensationValueSignFlag, "exposure_compensation_value_sign_flag" ); - WRITE_CODE( sei.m_exposureCompensationValueNumerator, 16, "exposure_compensation_value_numerator" ); - WRITE_CODE( sei.m_exposureCompensationValueDenomIdc, 16, "exposure_compensation_value_denom_idc" ); - WRITE_CODE( sei.m_refScreenLuminanceWhite, 32, "ref_screen_luminance_white" ); - WRITE_CODE( sei.m_extendedRangeWhiteLevel, 32, "extended_range_white_level" ); - WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue, 16, "nominal_black_level_luma_code_value" ); - WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue, 16, "nominal_white_level_luma_code_value" ); - WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue, 16, "extended_white_level_luma_code_value" ); - break; } - default: + for( int i = 0; i <= sei.numDecodingUnitsMinus1; i ++ ) { - THROW("Undefined SEIToneMapModelId"); - break; + WRITE_UVLC( sei.numNalusInDuMinus1[i], "num_nalus_in_du_minus1[i]" ); + if( !sei.duCommonCpbRemovalDelayFlag && i < sei.numDecodingUnitsMinus1 ) + { + for( int j = temporalId; j < bp.bpMaxSubLayers - 1; j ++ ) + { + if( sei.ptSubLayerDelaysPresent[j] ) + WRITE_CODE( sei.duCpbRemovalDelayMinus1[i * bp.bpMaxSubLayers + j], bp.duCpbRemovalDelayIncrementLength, "du_cpb_removal_delay_increment_minus1[i][j]" ); + } + } } - }//switch m_modelId - }//if(!sei.m_toneMapCancelFlag) -} + } + } -void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei) -{ - WRITE_FLAG( sei.cancelFlag, "display_orientation_cancel_flag" ); - if( !sei.cancelFlag ) + if (bp.additionalConcatenationInfoPresent) { - WRITE_FLAG( sei.horFlip, "hor_flip" ); - WRITE_FLAG( sei.verFlip, "ver_flip" ); - WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" ); - WRITE_FLAG( sei.persistenceFlag, "display_orientation_persistence_flag" ); + WRITE_FLAG( sei.delayForConcatenationEnsureFlag, "pt_delay_for_concatenation_ensured_flag" ); } + WRITE_CODE( sei.ptDisplayElementalPeriodsMinus1, 8, "pt_display_elemental_periods_minus1" ); } -void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei) -{ - WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" ); - WRITE_CODE( sei.rapIdx, 8 , "rap_idx" ); -} - -void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei) -{ - WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag"); -} - -void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/) -{ -} - -void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei) +void SEIWriter::xWriteSEIFrameFieldInfo(const SEIFrameFieldInfo& sei) { - WRITE_UVLC( sei.m_sopSeqParameterSetId, "sop_seq_parameter_set_id" ); - WRITE_UVLC( sei.m_numPicsInSopMinus1, "num_pics_in_sop_minus1" ); - for (uint32_t i = 0; i <= sei.m_numPicsInSopMinus1; i++) + WRITE_FLAG( sei.fieldPicFlag ? 1 : 0, "ffi_field_pic_flag" ); + if (sei.fieldPicFlag) { - WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" ); - WRITE_CODE( sei.m_sopDescTemporalId[i], 3, "sop_desc_temporal_id" ); - if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) + WRITE_FLAG( sei.bottomFieldFlag ? 1 : 0, "ffi_bottom_field_flag" ); + WRITE_FLAG( sei.pairingIndicatedFlag ? 1 : 0, "ffi_pairing_indicated_flag" ); + if (sei.pairingIndicatedFlag) { - WRITE_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); + WRITE_FLAG( sei.pairedWithNextFieldFlag ? 1 : 0, "ffi_paired_with_next_field_flag" ); } - if (i > 0) + } + else + { + WRITE_FLAG( sei.displayFieldsFromFrameFlag ? 1 : 0, "ffi_display_fields_from_frame_flag" ); + if (sei.displayFieldsFromFrameFlag) { - WRITE_SVLC( sei.m_sopDescPocDelta[i], "sop_desc_poc_delta" ); + WRITE_FLAG( sei.topFieldFirstFlag ? 1 : 0, "ffi_display_fields_from_frame_flag" ); } + WRITE_CODE( sei.displayElementalPeriodsMinus1, 8, "ffi_display_elemental_periods_minus1" ); } + WRITE_CODE( sei.sourceScanType, 2, "ffi_source_scan_type" ); + WRITE_FLAG( sei.duplicateFlag ? 1 : 0, "ffi_duplicate_flag" ); +} + +void SEIWriter::xWriteSEIDependentRAPIndication(const SEIDependentRAPIndication& /*sei*/) +{ + // intentionally empty } -void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sei, const SPS *sps) +void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sei) { - WRITE_FLAG( sei.m_bitStreamSubsetFlag, "bitstream_subset_flag" ); - WRITE_FLAG( sei.m_nestingOpFlag, "nesting_op_flag " ); - if (sei.m_nestingOpFlag) + CHECK (sei.nestedSEIs.size()<1, "There must be at lease one SEI message nested in the scalable nesting SEI.") + + WRITE_FLAG(sei.snOlsFlag, "sn_ols_flag"); + WRITE_FLAG(sei.snSubpicFlag, "sn_subpic_flag"); + if (sei.snOlsFlag) { - WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); - WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops_minus1" ); - for (uint32_t i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) + WRITE_UVLC(sei.snNumOlssMinus1, "sn_num_olss_minus1"); + for (uint32_t i = 0; i <= sei.snNumOlssMinus1; i++) { - WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id_plus1" ); - WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); + WRITE_UVLC(sei.snOlsIdxDeltaMinus1[i], "sn_ols_idx_delta_minus1[i]"); } } else { - WRITE_FLAG( sei.m_allLayersFlag, "all_layers_flag" ); - if (!sei.m_allLayersFlag) + WRITE_FLAG(sei.snAllLayersFlag, "sn_all_layers_flag"); + if (!sei.snAllLayersFlag) { - WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" ); - WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); - for (uint32_t i = 0; i <= sei.m_nestingNumLayersMinus1; i++) + WRITE_UVLC(sei.snNumLayersMinus1, "sn_num_layers"); + for (uint32_t i = 1; i <= sei.snNumLayersMinus1; i++) { - WRITE_CODE( sei.m_nestingLayerId[i], 6, "nesting_layer_id" ); + WRITE_CODE(sei.snLayerId[i], 6, "sn_layer_id"); } } } + if (sei.snSubpicFlag) + { + WRITE_UVLC( sei.snNumSubpics - 1, "sn_num_subpics_minus1"); + CHECK(sei.snSubpicIdLen < 1, "sn_subpic_id_len_minus1 must be >= 0"); + WRITE_UVLC( sei.snSubpicIdLen - 1, "sn_subpic_id_len_minus1"); + for (uint32_t i = 0; i < sei.snNumSubpics; i++) + { + WRITE_CODE(sei.snSubpicId[i], sei.snSubpicIdLen, "sn_subpic_id[i]"); + } + } + + WRITE_UVLC( (uint32_t)sei.nestedSEIs.size() - 1, "sn_num_seis_minus1"); // byte alignment - while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) + while (m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) + { + WRITE_FLAG(0, "sn_zero_bit"); + } + + SEIMessages bufferingPeriod = getSeisByType(sei.nestedSEIs, SEI::BUFFERING_PERIOD); + if (!bufferingPeriod.empty()) { - WRITE_FLAG( 0, "nesting_zero_bit" ); + SEIBufferingPeriod *bp = (SEIBufferingPeriod*)bufferingPeriod.front(); + m_nestingHrd.bufferingPeriodSEI = *(bp); } // write nested SEI messages - writeSEImessages(bs, sei.m_nestedSEIs, sps, true); + writeSEImessages(bs, sei.nestedSEIs, m_nestingHrd, true, 0); } -void SEIWriter::xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei) +void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei) { - //uint32_t code; - WRITE_FLAG(sei.m_mc_all_tiles_exact_sample_value_match_flag, "mc_all_tiles_exact_sample_value_match_flag"); - WRITE_FLAG(sei.m_each_tile_one_tile_set_flag, "each_tile_one_tile_set_flag" ); + WRITE_UVLC( sei.arrangementId, "fp_arrangement_id" ); + WRITE_FLAG( sei.arrangementCancelFlag, "fp_arrangement_cancel_flag" ); - if(!sei.m_each_tile_one_tile_set_flag) + if( sei.arrangementCancelFlag == 0 ) { - WRITE_FLAG(sei.m_limited_tile_set_display_flag, "limited_tile_set_display_flag"); - WRITE_UVLC((sei.getNumberOfTileSets() - 1), "num_sets_in_message_minus1" ); + WRITE_CODE( sei.arrangementType, 7, "fp_arrangement_type" ); + + WRITE_FLAG( sei.quincunxSamplingFlag, "fp_quincunx_sampling_flag" ); + WRITE_CODE( sei.contentInterpretationType, 6, "fp_content_interpretation_type" ); + WRITE_FLAG( sei.spatialFlippingFlag, "fp_spatial_flipping_flag" ); + WRITE_FLAG( sei.frame0FlippedFlag, "fp_frame0_flipped_flag" ); + WRITE_FLAG( sei.fieldViewsFlag, "fp_field_views_flag" ); + WRITE_FLAG( sei.currentFrameIsFrame0Flag, "fp_current_frame_is_frame0_flag" ); + + WRITE_FLAG( sei.frame0SelfContainedFlag, "fp_frame0_self_contained_flag" ); + WRITE_FLAG( sei.frame1SelfContainedFlag, "fp_frame1_self_contained_flag" ); - if(sei.getNumberOfTileSets() > 0) + if(sei.quincunxSamplingFlag == 0 && sei.arrangementType != 5) { - for(int i = 0; i < sei.getNumberOfTileSets(); i++) - { - WRITE_UVLC(sei.tileSetData(i).m_mcts_id, "mcts_id"); + WRITE_CODE( sei.frame0GridPositionX, 4, "fp_frame0_grid_position_x" ); + WRITE_CODE( sei.frame0GridPositionY, 4, "fp_frame0_grid_position_y" ); + WRITE_CODE( sei.frame1GridPositionX, 4, "fp_frame1_grid_position_x" ); + WRITE_CODE( sei.frame1GridPositionY, 4, "fp_frame1_grid_position_y" ); + } - if(sei.m_limited_tile_set_display_flag) - { - WRITE_FLAG(sei.tileSetData(i).m_display_tile_set_flag, "display_tile_set_flag"); - } + WRITE_CODE( sei.arrangementReservedByte, 8, "fp_frame_packing_arrangement_reserved_byte" ); + WRITE_FLAG( sei.arrangementPersistenceFlag, "fp_frame_packing_arrangement_persistence_flag" ); + } - WRITE_UVLC((sei.tileSetData(i).getNumberOfTileRects() - 1), "num_tile_rects_in_set_minus1"); + WRITE_FLAG( sei.upsampledAspectRatio, "fp_upsampled_aspect_ratio" ); +} - for(int j = 0; j < sei.tileSetData(i).getNumberOfTileRects(); j++) - { - WRITE_UVLC(sei.tileSetData(i).topLeftTileIndex (j), "top_left_tile_index"); - WRITE_UVLC(sei.tileSetData(i).bottomRightTileIndex(j), "bottom_right_tile_index"); - } - if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) - { - WRITE_FLAG(sei.tileSetData(i).m_exact_sample_value_match_flag, "exact_sample_value_match_flag"); - } +void SEIWriter::xWriteSEIParameterSetsInclusionIndication(const SEIParameterSetsInclusionIndication& sei) +{ + WRITE_FLAG(sei.selfContainedClvsFlag, "psii_self_contained_clvs_flag"); +} - WRITE_FLAG(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag, "mcts_tier_level_idc_present_flag"); +void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei) +{ + WRITE_CODE( sei.values.primaries[0][0], 16, "mdcv_display_primaries_x[0]" ); + WRITE_CODE( sei.values.primaries[0][1], 16, "mdcv_display_primaries_y[0]" ); - if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) - { - WRITE_FLAG(sei.tileSetData(i).m_mcts_tier_flag, "mcts_tier_flag"); - WRITE_CODE( sei.tileSetData(i).m_mcts_level_idc, 8, "mcts_level_idc"); - } - } + WRITE_CODE( sei.values.primaries[1][0], 16, "mdcv_display_primaries_x[1]" ); + WRITE_CODE( sei.values.primaries[1][1], 16, "mdcv_display_primaries_y[1]" ); + + WRITE_CODE( sei.values.primaries[2][0], 16, "mdcv_display_primaries_x[2]" ); + WRITE_CODE( sei.values.primaries[2][1], 16, "mdcv_display_primaries_y[2]" ); + + WRITE_CODE( sei.values.whitePoint[0], 16, "mdcv_white_point_x" ); + WRITE_CODE( sei.values.whitePoint[1], 16, "mdcv_white_point_y" ); + + WRITE_CODE( sei.values.maxLuminance, 32, "mdcv_max_display_mastering_luminance" ); + WRITE_CODE( sei.values.minLuminance, 32, "mdcv_min_display_mastering_luminance" ); +} + +void SEIWriter::xWriteByteAlign() +{ + if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) + { + WRITE_FLAG( 1, "payload_bit_equal_to_one" ); + while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) + { + WRITE_FLAG( 0, "payload_bit_equal_to_zero" ); } } - else - { - WRITE_FLAG(sei.m_max_mcs_tier_level_idc_present_flag, "max_mcs_tier_level_idc_present_flag"); +} + +void SEIWriter::xWriteSEIAlternativeTransferCharacteristics(const SEIAlternativeTransferCharacteristics& sei) +{ + WRITE_CODE(sei.preferredTransferCharacteristics, 8, "preferred_transfer_characteristics"); +} - if(sei.m_max_mcs_tier_level_idc_present_flag) +void SEIWriter::xWriteSEIEquirectangularProjection(const SEIEquirectangularProjection &sei) +{ + WRITE_FLAG( sei.erpCancelFlag, "erp_cancel_flag" ); + if( !sei.erpCancelFlag ) + { + WRITE_FLAG( sei.erpPersistenceFlag, "erp_persistence_flag" ); + WRITE_FLAG( sei.erpGuardBandFlag, "erp_guard_band_flag" ); + WRITE_CODE( 0, 2, "erp_reserved_zero_2bits" ); + if ( sei.erpGuardBandFlag == 1) { - WRITE_FLAG( sei.m_max_mcts_tier_flag, "max_mcts_tier_flag"); - WRITE_CODE( sei.m_max_mcts_level_idc, 8, "max_mcts_level_idc"); + WRITE_CODE( sei.erpGuardBandType, 3, "erp_guard_band_type" ); + WRITE_CODE( sei.erpLeftGuardBandWidth, 8, "erp_left_guard_band_width" ); + WRITE_CODE( sei.erpRightGuardBandWidth, 8, "erp_right_guard_band_width" ); } } } -void SEIWriter::xWriteSEITimeCode(const SEITimeCode& sei) +void SEIWriter::xWriteSEISphereRotation(const SEISphereRotation &sei) { - THROW("na SEITimeCode"); + WRITE_FLAG( sei.sphereRotationCancelFlag, "sphere_rotation_cancel_flag" ); + if( !sei.sphereRotationCancelFlag ) + { + WRITE_FLAG( sei.sphereRotationPersistenceFlag, "sphere_rotation_persistence_flag" ); + WRITE_CODE( 0, 6, "sphere_rotation_reserved_zero_6bits" ); + WRITE_SCODE(sei.sphereRotationYaw, 32, "sphere_rotation_yaw" ); + WRITE_SCODE(sei.sphereRotationPitch, 32, "sphere_rotation_pitch" ); + WRITE_SCODE(sei.sphereRotationRoll, 32, "sphere_rotation_roll" ); + } } -void SEIWriter::xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint& sei) +void SEIWriter::xWriteSEIOmniViewport(const SEIOmniViewport &sei) { - WRITE_CODE(sei.m_verChromaFilterIdc, 8, "ver_chroma_filter_idc"); - WRITE_CODE(sei.m_horChromaFilterIdc, 8, "hor_chroma_filter_idc"); - WRITE_FLAG(sei.m_verFilteringFieldProcessingFlag, "ver_filtering_field_processing_flag"); - if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) + WRITE_CODE( sei.omniViewportId, 10, "omni_viewport_id" ); + WRITE_FLAG( sei.omniViewportCancelFlag, "omni_viewport_cancel_flag" ); + if ( !sei.omniViewportCancelFlag ) { - WRITE_UVLC(sei.m_targetFormatIdc, "target_format_idc"); - if(sei.m_verChromaFilterIdc == 1) + WRITE_FLAG( sei.omniViewportPersistenceFlag, "omni_viewport_persistence_flag" ); + const uint32_t numRegions = (uint32_t) sei.omniViewportRegions.size(); + WRITE_CODE( numRegions - 1, 4, "omni_viewport_cnt_minus1" ); + for(uint32_t region=0; region 0) - { - for(int i = 0; i < numVerticalFilter; i ++) - { - const int verTapLengthMinus1 = (int) sei.m_verFilterCoeff[i].size() - 1; - WRITE_UVLC(verTapLengthMinus1, "ver_tap_length_minus_1"); - for(int j = 0; j < (verTapLengthMinus1 + 1); j ++) - { - WRITE_SVLC(sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); - } - } - } + const SEIOmniViewport::OmniViewport &viewport=sei.omniViewportRegions[region]; + WRITE_SCODE( viewport.azimuthCentre, 32, "omni_viewport_azimuth_centre" ); + WRITE_SCODE( viewport.elevationCentre, 32, "omni_viewport_elevation_centre" ); + WRITE_SCODE( viewport.tiltCentre, 32, "omni_viewport_tilt_center" ); + WRITE_CODE( viewport.horRange, 32, "omni_viewport_hor_range[i]" ); + WRITE_CODE( viewport.verRange, 32, "omni_viewport_ver_range[i]" ); } - if(sei.m_horChromaFilterIdc == 1) + } +} + +void SEIWriter::xWriteSEIRegionWisePacking(const SEIRegionWisePacking &sei) +{ + WRITE_FLAG( sei.rwpCancelFlag, "rwp_cancel_flag" ); + if(!sei.rwpCancelFlag) + { + WRITE_FLAG( sei.rwpPersistenceFlag, "rwp_persistence_flag" ); + WRITE_FLAG( sei.constituentPictureMatchingFlag, "rwp_constituent_picture_matching_flag" ); + WRITE_CODE( 0, 5, "rwp_reserved_zero_5bits" ); + WRITE_CODE( (uint32_t)sei.numPackedRegions, 8, "rwp_num_packed_regions" ); + WRITE_CODE( (uint32_t)sei.projPictureWidth, 32, "rwp_proj_picture_width" ); + WRITE_CODE( (uint32_t)sei.projPictureHeight, 32, "rwp_proj_picture_height" ); + WRITE_CODE( (uint32_t)sei.packedPictureWidth, 16, "rwp_packed_picture_width" ); + WRITE_CODE( (uint32_t)sei.packedPictureHeight, 16, "rwp_packed_picture_height" ); + for( int i=0; i < sei.numPackedRegions; i++ ) { - const int numHorizontalFilter = (int) sei.m_horFilterCoeff.size(); - WRITE_UVLC(numHorizontalFilter, "num_horizontal_filters"); - if(numHorizontalFilter > 0) + WRITE_CODE( 0, 4, "rwp_reserved_zero_4bits" ); + WRITE_CODE( (uint32_t)sei.rwpTransformType[i], 3, "rwp_tTransform_type" ); + WRITE_FLAG( sei.rwpGuardBandFlag[i], "rwp_guard_band_flag" ); + WRITE_CODE( (uint32_t)sei.projRegionWidth[i], 32, "rwp_proj_region_width" ); + WRITE_CODE( (uint32_t)sei.projRegionHeight[i], 32, "rwp_proj_region_height" ); + WRITE_CODE( (uint32_t)sei.rwpProjRegionTop[i], 32, "rwp_proj_regionTop" ); + WRITE_CODE( (uint32_t)sei.projRegionLeft[i], 32, "rwp_proj_region_left" ); + WRITE_CODE( (uint32_t)sei.packedRegionWidth[i], 16, "rwp_packed_region_width" ); + WRITE_CODE( (uint32_t)sei.packedRegionHeight[i], 16, "rwp_packed_region_height" ); + WRITE_CODE( (uint32_t)sei.packedRegionTop[i], 16, "rwp_packed_region_top" ); + WRITE_CODE( (uint32_t)sei.packedRegionLeft[i], 16, "rwp_packed_region_left" ); + if( sei.rwpGuardBandFlag[i] ) { - for(int i = 0; i < numHorizontalFilter; i ++) + WRITE_CODE( (uint32_t)sei.rwpLeftGuardBandWidth[i], 8, "rwp_left_guard_band_width"); + WRITE_CODE( (uint32_t)sei.rwpRightGuardBandWidth[i], 8, "rwp_right_guard_band_width"); + WRITE_CODE( (uint32_t)sei.rwpTopGuardBandHeight[i], 8, "rwp_top_guard_band_height"); + WRITE_CODE( (uint32_t)sei.rwpBottomGuardBandHeight[i], 8, "rwp_bottom_guard_band_height"); + WRITE_FLAG( sei.rwpGuardBandNotUsedForPredFlag[i], "rwp_guard_band_not_used_forPred_flag" ); + for( int j=0; j < 4; j++ ) { - const int horTapLengthMinus1 = (int) sei.m_horFilterCoeff[i].size() - 1; - WRITE_UVLC(horTapLengthMinus1, "hor_tap_length_minus_1"); - for(int j = 0; j < (horTapLengthMinus1 + 1); j ++) - { - WRITE_SVLC(sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); + WRITE_CODE( (uint32_t)sei.rwpGuardBandType[i*4 + j], 3, "rwp_guard_band_type"); } + WRITE_CODE( 0, 3, "rwp_guard_band_reserved_zero_3bits" ); } } } - } } -void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei) +void SEIWriter::xWriteSEIGeneralizedCubemapProjection(const SEIGeneralizedCubemapProjection &sei) { - WRITE_UVLC( sei.m_kneeId, "knee_function_id" ); - WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" ); - if ( !sei.m_kneeCancelFlag ) + WRITE_FLAG( sei.gcmpCancelFlag, "gcmp_cancel_flag" ); + if (!sei.gcmpCancelFlag) { - WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" ); - WRITE_CODE( (uint32_t)sei.m_kneeInputDrange , 32, "input_d_range" ); - WRITE_CODE( (uint32_t)sei.m_kneeInputDispLuminance, 32, "input_disp_luminance" ); - WRITE_CODE( (uint32_t)sei.m_kneeOutputDrange, 32, "output_d_range" ); - WRITE_CODE( (uint32_t)sei.m_kneeOutputDispLuminance, 32, "output_disp_luminance" ); - WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" ); - for(int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) + WRITE_FLAG( sei.gcmpPersistenceFlag, "gcmp_persistence_flag" ); + WRITE_CODE( sei.gcmpPackingType, 3, "gcmp_packing_type" ); + WRITE_CODE( sei.gcmpMappingFunctionType, 2, "gcmp_mapping_function_type" ); + int numFace = sei.gcmpPackingType == 4 || sei.gcmpPackingType == 5 ? 5 : 6; + for (int i = 0; i < numFace; i++) + { + WRITE_CODE( sei.gcmpFaceIndex[i], 3, "gcmp_face_index" ); + WRITE_CODE( sei.gcmpFaceRotation[i], 2, "gcmp_face_rotation" ); + if (sei.gcmpMappingFunctionType == 2) + { + WRITE_CODE( sei.gcmpFunctionCoeffU[i], 7, "gcmp_function_coeff_u" ); + WRITE_FLAG( sei.gcmpFunctionUAffectedByVFlag[i], "gcmp_function_u_affected_by_v_flag" ); + WRITE_CODE( sei.gcmpFunctionCoeffV[i], 7, "gcmp_function_coeff_v" ); + WRITE_FLAG( sei.gcmpFunctionVAffectedByUFlag[i], "gcmp_function_v_affected_by_u_flag" ); + } + } + WRITE_FLAG( sei.gcmpGuardBandFlag, "gcmp_guard_band_flag" ); + if (sei.gcmpGuardBandFlag) { - WRITE_CODE( (uint32_t)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" ); - WRITE_CODE( (uint32_t)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" ); + WRITE_CODE( sei.gcmpGuardBandType, 3, "gcmp_guard_band_type" ); + WRITE_FLAG( sei.gcmpGuardBandBoundaryExteriorFlag, "gcmp_guard_band_boundary_exterior_flag" ); + WRITE_CODE( sei.gcmpGuardBandSamplesMinus1, 4, "gcmp_guard_band_samples_minus1" ); } } } -void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei) +void SEIWriter::xWriteSEISubpictureLevelInfo(const SEISubpicureLevelInfo &sei) { - WRITE_UVLC( sei.m_colourRemapId, "colour_remap_id" ); - WRITE_FLAG( sei.m_colourRemapCancelFlag, "colour_remap_cancel_flag" ); - if( !sei.m_colourRemapCancelFlag ) + CHECK(sei.numRefLevels < 1, "SEISubpicureLevelInfo: numRefLevels must be greater than zero"); + CHECK(sei.numRefLevels != (int)sei.refLevelIdc.size(), "SEISubpicureLevelInfo: numRefLevels must be equal to the number of levels"); + if (sei.explicitFractionPresent) { - WRITE_FLAG( sei.m_colourRemapPersistenceFlag, "colour_remap_persistence_flag" ); - WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresent, "colour_remap_video_signal_info_present_flag" ); - if ( sei.m_colourRemapVideoSignalInfoPresent ) - { - WRITE_FLAG( sei.m_colourRemapFullRangeFlag, "colour_remap_full_range_flag" ); - WRITE_CODE( sei.m_colourRemapPrimaries, 8, "colour_remap_primaries" ); - WRITE_CODE( sei.m_colourRemapTransferFunction, 8, "colour_remap_transfer_function" ); - WRITE_CODE( sei.m_colourRemapMatrixCoefficients, 8, "colour_remap_matrix_coefficients" ); - } - WRITE_CODE( sei.m_colourRemapInputBitDepth, 8, "colour_remap_input_bit_depth" ); - WRITE_CODE( sei.m_colourRemapBitDepth, 8, "colour_remap_bit_depth" ); - for( int c=0 ; c<3 ; c++ ) + CHECK(sei.numRefLevels != (int)sei.refLevelFraction.size(), "SEISubpicureLevelInfo: numRefLevels must be equal to the number of fractions"); + } + WRITE_CODE( (uint32_t)sei.numRefLevels - 1, 3, "sli_num_ref_levels_minus1"); + WRITE_FLAG( sei.cbrConstraintFlag, "sli_cbr_constraint_flag"); + WRITE_FLAG( sei.explicitFractionPresent, "sli_explicit_fraction_present_flag"); + if (sei.explicitFractionPresent) + { + WRITE_UVLC( sei.numSubpics -1 , "sli_num_subpics_minus1"); + WRITE_CODE( (uint32_t)sei.sliMaxSublayers - 1, 3, "sli_max_sublayers_minus1"); + WRITE_FLAG( sei.sliSublayerInfoPresent, "sli_sublayer_info_present_flag"); + while (!isByteAligned()) { - WRITE_CODE( sei.m_preLutNumValMinus1[c], 8, "pre_lut_num_val_minus1[c]" ); - if( sei.m_preLutNumValMinus1[c]>0 ) - { - for( int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) - { - WRITE_CODE( sei.m_preLut[c][i].codedValue, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" ); - WRITE_CODE( sei.m_preLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" ); - } - } + WRITE_FLAG( 0, "sli_alignment_zero_bit"); } - WRITE_FLAG( sei.m_colourRemapMatrixPresent, "colour_remap_matrix_present_flag" ); - if( sei.m_colourRemapMatrixPresent ) + } + + for (int k = sei.sliSublayerInfoPresent ? 0 : sei.sliMaxSublayers - 1; k < sei.sliMaxSublayers; k++) + { + for (int i = 0; i < sei.numRefLevels; i++) { - WRITE_CODE( sei.m_log2MatrixDenom, 4, "log2_matrix_denom" ); - for( int c=0 ; c<3 ; c++ ) + WRITE_CODE((uint32_t)sei.nonSubpicLayersFraction[i][k], 8, "sli_non_subpic_layers_fraction[i][k]"); + WRITE_CODE((uint32_t)sei.refLevelIdc[i][k], 8, "sli_ref_level_idc[i][k]"); + if (sei.explicitFractionPresent) { - for( int i=0 ; i<3 ; i++ ) + CHECK(sei.numSubpics != (int)sei.refLevelFraction[i].size(), "SEISubpicureLevelInfo: number of fractions differs from number of subpictures"); + for (int j = 0; j < sei.numSubpics; j++) { - WRITE_SVLC( sei.m_colourRemapCoeffs[c][i], "colour_remap_coeffs[c][i]" ); + WRITE_CODE((uint32_t)sei.refLevelFraction[i][j][k], 8, "sli_ref_level_fraction_minus1[i][j][k]"); } } } + } +} - for( int c=0 ; c<3 ; c++ ) +void SEIWriter::xWriteSEISampleAspectRatioInfo(const SEISampleAspectRatioInfo &sei) +{ + WRITE_FLAG( sei.sariCancelFlag, "sari_cancel_flag" ); + if(!sei.sariCancelFlag) + { + WRITE_FLAG( sei.sariPersistenceFlag, "sari_persistence_flag" ); + WRITE_CODE( (uint32_t)sei.sariAspectRatioIdc, 8, "sari_aspect_ratio_idc"); + if (sei.sariAspectRatioIdc == 255) { - WRITE_CODE( sei.m_postLutNumValMinus1[c], 8, "m_postLutNumValMinus1[c]" ); - if( sei.m_postLutNumValMinus1[c]>0 ) - { - for( int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) - { - WRITE_CODE( sei.m_postLut[c][i].codedValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" ); - WRITE_CODE( sei.m_postLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" ); - } - } + WRITE_CODE( (uint32_t)sei.sariSarWidth, 16, "sari_sar_width"); + WRITE_CODE( (uint32_t)sei.sariSarHeight, 16, "sari_sar_height"); } } } -void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei) +void SEIWriter::xWriteSEIUserDataRegistered(const SEIUserDataRegistered &sei) { - THROW("na SEIMasteringDisplay"); + WRITE_CODE((sei.ituCountryCode>255) ? 0xff : sei.ituCountryCode, 8, "itu_t_t35_country_code"); + if (sei.ituCountryCode >= 255) + { + assert(sei.ituCountryCode < 255 + 256); + WRITE_CODE(sei.ituCountryCode - 255, 8, "itu_t_t35_country_code_extension_byte"); + } + for (uint32_t i = 0; igetNumberOfWrittenBits() % 8 != 0) + WRITE_FLAG(sei.filmGrainCharacteristicsCancelFlag, "fg_characteristics_cancel_flag"); + if (!sei.filmGrainCharacteristicsCancelFlag) { - WRITE_FLAG( 1, "payload_bit_equal_to_one" ); - while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) + WRITE_CODE(sei.filmGrainModelId, 2, "fg_model_id"); + WRITE_FLAG(sei.separateColourDescriptionPresent, "separate_colour_description_present_flag"); + if (sei.separateColourDescriptionPresent) { - WRITE_FLAG( 0, "payload_bit_equal_to_zero" ); + WRITE_CODE(sei.filmGrainBitDepthLumaMinus8, 3, "fg_bit_depth_luma_minus8"); + WRITE_CODE(sei.filmGrainBitDepthChromaMinus8, 3, "fg_bit_depth_chroma_minus8"); + WRITE_FLAG(sei.filmGrainFullRangeFlag, "fg_full_range_flag"); + WRITE_CODE(sei.filmGrainColourPrimaries, 8, "fg_colour_primaries"); + WRITE_CODE(sei.filmGrainTransferCharacteristics, 8, "fg_transfer_characteristics"); + WRITE_CODE(sei.filmGrainMatrixCoeffs, 8, "fg_matrix_coeffs"); } - } + WRITE_CODE(sei.blendingModeId, 2, "fg_blending_mode_id"); + WRITE_CODE(sei.log2ScaleFactor, 4, "fg_log2_scale_factor"); + for (int c = 0; c<3; c++) + { + const SEIFilmGrainCharacteristics::CompModel &cm = sei.compModel[c]; + const uint32_t numIntensityIntervals = (uint32_t)cm.intensityValues.size(); + const uint32_t numModelValues = cm.numModelValues; + WRITE_FLAG(sei.compModel[c].presentFlag && numIntensityIntervals>0 && numModelValues>0, "fg_comp_model_present_flag[c]"); + } + for (uint32_t c = 0; c<3; c++) + { + const SEIFilmGrainCharacteristics::CompModel &cm = sei.compModel[c]; + const uint32_t numIntensityIntervals = (uint32_t)cm.intensityValues.size(); + const uint32_t numModelValues = cm.numModelValues; + if (cm.presentFlag && numIntensityIntervals>0 && numModelValues>0) + { + assert(numIntensityIntervals <= 256); + assert(numModelValues <= 256); + WRITE_CODE(numIntensityIntervals - 1, 8, "fg_num_intensity_intervals_minus1[c]"); + WRITE_CODE(numModelValues - 1, 3, "fg_num_model_values_minus1[c]"); + for (uint32_t interval = 0; intervalppsId, 6, "pps_pic_parameter_set_id" ); WRITE_CODE( pcPPS->spsId, 4, "pps_seq_parameter_set_id" ); - WRITE_FLAG( pcPPS->mixedNaluTypesInPic, "mixed_nalu_types_in_pic_flag" ); + WRITE_FLAG( pcPPS->mixedNaluTypesInPic, "pps_mixed_nalu_types_in_pic_flag" ); WRITE_UVLC( pcPPS->picWidthInLumaSamples, "pic_width_in_luma_samples" ); WRITE_UVLC( pcPPS->picHeightInLumaSamples, "pic_height_in_luma_samples" ); - const Window& conf = pcPPS->conformanceWindow; - WRITE_FLAG( conf.enabledFlag, "pps_conformance_window_flag" ); - if (conf.enabledFlag) + if( pcPPS->picWidthInLumaSamples == pcSPS->maxPicWidthInLumaSamples && pcPPS->picHeightInLumaSamples == pcSPS->maxPicHeightInLumaSamples ) { - WRITE_UVLC( conf.winLeftOffset / SPS::getWinUnitX(pcSPS->chromaFormatIdc ), "conf_win_left_offset" ); - WRITE_UVLC( conf.winRightOffset / SPS::getWinUnitX(pcSPS->chromaFormatIdc ), "conf_win_right_offset" ); - WRITE_UVLC( conf.winTopOffset / SPS::getWinUnitY(pcSPS->chromaFormatIdc ), "conf_win_top_offset" ); - WRITE_UVLC( conf.winBottomOffset / SPS::getWinUnitY(pcSPS->chromaFormatIdc ), "conf_win_bottom_offset" ); + WRITE_FLAG( 0, "pps_conformance_window_flag" ); + } + else + { + const Window& conf = pcPPS->conformanceWindow; + WRITE_FLAG( conf.enabledFlag, "pps_conformance_window_flag" ); + if( conf.enabledFlag ) + { + WRITE_UVLC( conf.winLeftOffset / SPS::getWinUnitX(pcSPS->chromaFormatIdc ), "conf_win_left_offset" ); + WRITE_UVLC( conf.winRightOffset / SPS::getWinUnitX(pcSPS->chromaFormatIdc ), "conf_win_right_offset" ); + WRITE_UVLC( conf.winTopOffset / SPS::getWinUnitY(pcSPS->chromaFormatIdc ), "conf_win_top_offset" ); + WRITE_UVLC( conf.winBottomOffset / SPS::getWinUnitY(pcSPS->chromaFormatIdc ), "conf_win_bottom_offset" ); + } } const Window& scWnd = pcPPS->scalingWindow; - - WRITE_FLAG( scWnd.enabledFlag, "scaling_window_flag" ); - if (scWnd.enabledFlag) + WRITE_FLAG( scWnd.enabledFlag, "pps_scaling_window_flag" ); + if( scWnd.enabledFlag ) { WRITE_UVLC( scWnd.winLeftOffset / SPS::getWinUnitX(pcSPS->chromaFormatIdc ), "pps_scaling_win_left_offset" ); WRITE_UVLC( scWnd.winRightOffset / SPS::getWinUnitX(pcSPS->chromaFormatIdc ), "pps_scaling_win_right_offset" ); @@ -283,9 +293,9 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) WRITE_UVLC( scWnd.winBottomOffset / SPS::getWinUnitY(pcSPS->chromaFormatIdc ), "pps_scaling_win_bottom_offset" ); } - WRITE_FLAG( pcPPS->outputFlagPresent, "output_flag_present_flag" ); + WRITE_FLAG( pcPPS->outputFlagPresent, "pps_output_flag_present_flag" ); WRITE_FLAG( pcPPS->noPicPartition, "pps_no_pic_partition_flag" ); - WRITE_FLAG( pcPPS->subPicIdMappingInPps, "subpic_id_mapping_in_pps_flag" ); + WRITE_FLAG( pcPPS->subPicIdMappingInPps, "pps_subpic_id_mapping_in_pps_flag" ); if( pcPPS->subPicIdMappingInPps ) { if( pcPPS->noPicPartition ) @@ -306,21 +316,21 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) THROW("no suppport"); } - WRITE_FLAG( pcPPS->cabacInitPresent, "cabac_init_present_flag" ); - WRITE_UVLC( pcPPS->numRefIdxL0DefaultActive-1, "num_ref_idx_l0_default_active_minus1"); - WRITE_UVLC( pcPPS->numRefIdxL1DefaultActive-1, "num_ref_idx_l1_default_active_minus1"); - WRITE_FLAG( pcPPS->rpl1IdxPresent, "rpl1_idx_present_flag"); + WRITE_FLAG( pcPPS->cabacInitPresent, "pps_cabac_init_present_flag" ); + WRITE_UVLC( pcPPS->numRefIdxL0DefaultActive-1, "pps_num_ref_idx_l0_default_active_minus1"); + WRITE_UVLC( pcPPS->numRefIdxL1DefaultActive-1, "pps_num_ref_idx_l1_default_active_minus1"); + WRITE_FLAG( pcPPS->rpl1IdxPresent, "pps_rpl1_idx_present_flag"); - WRITE_FLAG( pcPPS->weightPred, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) - WRITE_FLAG( pcPPS->weightedBiPred, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) + WRITE_FLAG( pcPPS->weightPred, "pps_weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) + WRITE_FLAG( pcPPS->weightedBiPred, "pps_weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) WRITE_FLAG( pcPPS->wrapAroundEnabled, "pps_ref_wraparound_enabled_flag" ); if( pcPPS->wrapAroundEnabled ) { WRITE_UVLC(pcPPS->picWidthMinusWrapAroundOffset, "pps_pic_width_minus_wraparound_offset"); } - WRITE_SVLC( pcPPS->picInitQPMinus26, "init_qp_minus26"); - WRITE_FLAG( pcPPS->useDQP, "cu_qp_delta_enabled_flag" ); + WRITE_SVLC( pcPPS->picInitQPMinus26, "pps_init_qp_minus26"); + WRITE_FLAG( pcPPS->useDQP, "pps_cu_qp_delta_enabled_flag" ); WRITE_FLAG (pcPPS->usePPSChromaTool, "pps_chroma_tool_offsets_present_flag"); if (pcPPS->usePPSChromaTool) { @@ -338,23 +348,23 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) WRITE_FLAG(cuChromaQpOffsetEnabled, "pps_cu_chroma_qp_offset_list_enabled_flag" ); if( cuChromaQpOffsetEnabled ) { - WRITE_UVLC(pcPPS->chromaQpOffsetListLen - 1, "chroma_qp_offset_list_len_minus1"); + WRITE_UVLC(pcPPS->chromaQpOffsetListLen - 1, "pps_chroma_qp_offset_list_len_minus1"); /* skip zero index */ for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < pcPPS->chromaQpOffsetListLen; cuChromaQpOffsetIdx++) { - WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); - WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); + WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "pps_cb_qp_offset_list[i]"); + WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "pps_cr_qp_offset_list[i]"); if (pcPPS->jointCbCrQpOffsetPresent) { - WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); + WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "pps_joint_cbcr_qp_offset_list[i]"); } } } } - WRITE_FLAG( pcPPS->deblockingFilterControlPresent, "deblocking_filter_control_present_flag"); + WRITE_FLAG( pcPPS->deblockingFilterControlPresent, "debpps_locking_filter_control_present_flag"); if(pcPPS->deblockingFilterControlPresent) { - WRITE_FLAG( pcPPS->deblockingFilterOverrideEnabled, "deblocking_filter_override_enabled_flag" ); + WRITE_FLAG( pcPPS->deblockingFilterOverrideEnabled, "pps_deblocking_filter_override_enabled_flag" ); WRITE_FLAG( pcPPS->deblockingFilterDisabled, "pps_deblocking_filter_disabled_flag" ); if (!pcPPS->noPicPartition && pcPPS->deblockingFilterOverrideEnabled) { @@ -378,29 +388,19 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) { WRITE_FLAG(pcPPS->rplInfoInPh, "pps_rpl_info_in_ph_flag"); WRITE_FLAG(pcPPS->saoInfoInPh, "pps_sao_info_in_ph_flag"); - WRITE_FLAG(pcPPS->alfInfoInPh, "alf_info_in_ph_flag"); + WRITE_FLAG(pcPPS->alfInfoInPh, "pps_alf_info_in_ph_flag"); if( (pcPPS->weightPred || pcPPS->weightedBiPred) && pcPPS->rplInfoInPh) { - WRITE_FLAG(pcPPS->wpInfoInPh, "wp_info_in_ph_flag"); + WRITE_FLAG(pcPPS->wpInfoInPh, "pps_wp_info_in_ph_flag"); } - WRITE_FLAG(pcPPS->qpDeltaInfoInPh, "qp_delta_info_in_ph_flag"); + WRITE_FLAG(pcPPS->qpDeltaInfoInPh, "pps_qp_delta_info_in_ph_flag"); } - - WRITE_FLAG( pcPPS->pictureHeaderExtensionPresent, "picture_header_extension_present_flag"); - WRITE_FLAG( pcPPS->sliceHeaderExtensionPresent, "slice_header_extension_present_flag"); - bool pps_extension_present_flag=false; - bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false}; + WRITE_FLAG( pcPPS->pictureHeaderExtensionPresent, "pps_picture_header_extension_present_flag"); + WRITE_FLAG( pcPPS->sliceHeaderExtensionPresent, "pps_slice_header_extension_present_flag"); - WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" ); + WRITE_FLAG( false, "pps_extension_present_flag" ); - if (pps_extension_present_flag) - { - for(int i=0; iapsType, 3, "aps_params_type"); WRITE_CODE(pcAPS->apsId, 5, "adaptation_parameter_set_id"); - WRITE_FLAG(pcAPS->chromaPresentFlag, "aps_chroma_present_flag"); + WRITE_FLAG(pcAPS->chromaPresent, "aps_chroma_present_flag"); if (pcAPS->apsType == ALF_APS) { @@ -438,7 +438,7 @@ void HLSWriter::codeAlfAps( const APS* pcAPS ) WRITE_FLAG(param.newFilterFlag[CH_L], "alf_luma_new_filter"); const CcAlfFilterParam& paramCcAlf = pcAPS->ccAlfParam; - if (pcAPS->chromaPresentFlag) + if (pcAPS->chromaPresent) { WRITE_FLAG(param.newFilterFlag[CH_C], "alf_chroma_new_filter"); WRITE_FLAG(paramCcAlf.newCcAlfFilter[COMP_Cb - 1], "alf_cc_cb_filter_signal_flag"); @@ -536,10 +536,10 @@ void HLSWriter::codeLmcsAps( const APS* aps ) WRITE_FLAG(signCW, "lmcs_delta_sign_cw_flag[ i ]"); } } - int deltaCRS = aps->chromaPresentFlag ? param.chrResScalingOffset : 0; + int deltaCRS = aps->chromaPresent ? param.chrResScalingOffset : 0; int signCRS = (deltaCRS < 0) ? 1 : 0; int absCRS = (deltaCRS < 0) ? (-deltaCRS) : deltaCRS; - if (aps->chromaPresentFlag) + if (aps->chromaPresent) { WRITE_CODE(absCRS, 3, "lmcs_delta_abs_crs"); } @@ -606,18 +606,77 @@ void HLSWriter::codeVUI( const VUI *pcVUI, const SPS* pcSPS ) } } +void HLSWriter::codeGeneralHrdparameters(const GeneralHrdParams * hrd) +{ + WRITE_CODE(hrd->numUnitsInTick, 32, "num_units_in_tick"); + WRITE_CODE(hrd->timeScale, 32, "time_scale"); + WRITE_FLAG(hrd->generalNalHrdParamsPresent, "general_nal_hrd_parameters_present_flag"); + WRITE_FLAG(hrd->generalVclHrdParamsPresent, "general_vcl_hrd_parameters_present_flag"); + if( hrd->generalNalHrdParamsPresent || hrd->generalVclHrdParamsPresent ) + { + WRITE_FLAG(hrd->generalSamePicTimingInAllOlsFlag, "general_same_pic_timing_in_all_ols_flag"); + WRITE_FLAG(hrd->generalDecodingUnitHrdParamsPresent, "general_decoding_unit_hrd_params_present_flag"); + if (hrd->generalDecodingUnitHrdParamsPresent) + { + WRITE_CODE(hrd->tickDivisorMinus2, 8, "tick_divisor_minus2"); + } + WRITE_CODE(hrd->bitRateScale, 4, "bit_rate_scale"); + WRITE_CODE(hrd->cpbSizeScale, 4, "cpb_size_scale"); + if (hrd->generalDecodingUnitHrdParamsPresent) + { + WRITE_CODE(hrd->cpbSizeDuScale, 4, "cpb_size_du_scale"); + } + WRITE_UVLC(hrd->hrdCpbCntMinus1, "hrd_cpb_cnt_minus1"); + } +} + void HLSWriter::codeOlsHrdParameters(const GeneralHrdParams * generalHrd, const OlsHrdParams *olsHrd, const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1) { - THROW("no support"); + for( int i = firstSubLayer; i <= maxNumSubLayersMinus1; i ++ ) + { + const OlsHrdParams *hrd = &(olsHrd[i]); + WRITE_FLAG(hrd->fixedPicRateGeneralFlag, "fixed_pic_rate_general_flag"); + + if (!hrd->fixedPicRateGeneralFlag) + { + WRITE_FLAG(hrd->fixedPicRateWithinCvsFlag, "fixed_pic_rate_within_cvs_flag"); + } + if (hrd->fixedPicRateWithinCvsFlag) + { + WRITE_UVLC(hrd->elementDurationInTcMinus1, "elemental_duration_in_tc_minus1"); + } + else if ( (generalHrd->generalNalHrdParamsPresent || generalHrd->generalVclHrdParamsPresent) &&generalHrd->hrdCpbCntMinus1 == 0) + { + WRITE_FLAG(hrd->lowDelayHrdFlag, "low_delay_hrd_flag"); + } + + for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) + { + if (((nalOrVcl == 0) && (generalHrd->generalNalHrdParamsPresent)) || ((nalOrVcl == 1) && (generalHrd->generalVclHrdParamsPresent))) + { + for (int j = 0; j <= (generalHrd->hrdCpbCntMinus1); j++) + { + WRITE_UVLC(hrd->bitRateValueMinus1[j][nalOrVcl], "bit_rate_value_minus1"); + WRITE_UVLC(hrd->cpbSizeValueMinus1[j][nalOrVcl], "cpb_size_value_minus1"); + if (generalHrd->generalDecodingUnitHrdParamsPresent) + { + WRITE_UVLC(hrd->duCpbSizeValueMinus1[j][nalOrVcl], "cpb_size_du_value_minus1"); + WRITE_UVLC(hrd->duBitRateValueMinus1[j][nalOrVcl], "bit_rate_du_value_minus1"); + } + WRITE_FLAG(hrd->cbrFlag[j][nalOrVcl], "cbr_flag"); + } + } + } + } } void HLSWriter::dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, const SPS *pcSPS) { for (uint32_t i = (subLayerInfoFlag ? 0 : maxSubLayersMinus1); i <= maxSubLayersMinus1; i++) { - WRITE_UVLC(pcSPS->maxDecPicBuffering[i] - 1, "max_dec_pic_buffering_minus1[i]"); - WRITE_UVLC(pcSPS->numReorderPics[i], "max_num_reorder_pics[i]"); - WRITE_UVLC(pcSPS->maxLatencyIncreasePlus1[i], "max_latency_increase_plus1[i]"); + WRITE_UVLC(pcSPS->maxDecPicBuffering[i] - 1, "dpb_max_dec_pic_buffering_minus1[i]"); + WRITE_UVLC(pcSPS->numReorderPics[i], "dpb_max_num_reorder_pics[i]"); + WRITE_UVLC(pcSPS->maxLatencyIncreasePlus1[i], "dpb_max_latency_increase_plus1[i]"); } } @@ -630,7 +689,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) CHECK(pcSPS->maxTLayers == 0, "Maximum number of temporal sub-layers is '0'"); WRITE_CODE(pcSPS->maxTLayers - 1, 3, "sps_max_sub_layers_minus1"); - WRITE_CODE( int(pcSPS->chromaFormatIdc), 2, "chroma_format_idc" ); + WRITE_CODE( int(pcSPS->chromaFormatIdc), 2, "sps_chroma_format_idc" ); WRITE_CODE(floorLog2(pcSPS->CTUSize) - 5, 2, "sps_log2_ctu_size_minus5"); WRITE_FLAG(pcSPS->ptlDpbHrdParamsPresent, "sps_ptl_dpb_hrd_params_present_flag"); @@ -639,14 +698,14 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) codeProfileTierLevel( &pcSPS->profileTierLevel, true, pcSPS->maxTLayers - 1 ); } - WRITE_FLAG(pcSPS->GDR, "gdr_enabled_flag"); - WRITE_FLAG( pcSPS->rprEnabled, "ref_pic_resampling_enabled_flag" ); + WRITE_FLAG(pcSPS->GDR, "sps_gdr_enabled_flag"); + WRITE_FLAG( pcSPS->rprEnabled, "sps_ref_pic_resampling_enabled_flag" ); if( pcSPS->rprEnabled ) { - WRITE_FLAG(pcSPS->resChangeInClvsEnabled, "res_change_in_clvs_allowed_flag"); + WRITE_FLAG(pcSPS->resChangeInClvsEnabled, "sps_res_change_in_clvs_allowed_flag"); } - WRITE_UVLC( pcSPS->maxPicWidthInLumaSamples, "pic_width_max_in_luma_samples" ); - WRITE_UVLC( pcSPS->maxPicHeightInLumaSamples, "pic_height_max_in_luma_samples" ); + WRITE_UVLC( pcSPS->maxPicWidthInLumaSamples, "sps_pic_width_max_in_luma_samples" ); + WRITE_UVLC( pcSPS->maxPicHeightInLumaSamples, "sps_pic_height_max_in_luma_samples" ); const Window& conf = pcSPS->conformanceWindow; WRITE_FLAG( conf.enabledFlag, "sps_conformance_window_flag" ); @@ -658,7 +717,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC( conf.winBottomOffset / SPS::getWinUnitY(pcSPS->chromaFormatIdc ), "sps_conf_win_bottom_offset" ); } - WRITE_FLAG(pcSPS->subPicInfoPresent, "subpic_info_present_flag"); + WRITE_FLAG(pcSPS->subPicInfoPresent, "sps_subpic_info_present_flag"); if (pcSPS->subPicInfoPresent) { @@ -668,16 +727,16 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC( pcSPS->bitDepths[ CH_L ] - 8, "sps_bitdepth_minus8" ); WRITE_FLAG( pcSPS->entropyCodingSyncEnabled, "sps_entropy_coding_sync_enabled_flag" ); WRITE_FLAG( pcSPS->entryPointsPresent, "sps_entry_point_offsets_present_flag" ); - WRITE_CODE( pcSPS->bitsForPOC-4, 4, "log2_max_pic_order_cnt_lsb_minus4" ); + WRITE_CODE( pcSPS->bitsForPOC-4, 4, "sps_log2_max_pic_order_cnt_lsb_minus4" ); WRITE_FLAG( pcSPS->pocMsbFlag, "sps_poc_msb_flag"); if (pcSPS->pocMsbFlag) { - WRITE_UVLC(pcSPS->pocMsbLen - 1, "poc_msb_len_minus1"); + WRITE_UVLC(pcSPS->pocMsbLen - 1, "sps_poc_msb_len_minus1"); } - WRITE_CODE(0, 2, "num_extra_ph_bits_bytes"); - WRITE_CODE(0, 2, "num_extra_sh_bits_bytes"); + WRITE_CODE(0, 2, "sps_num_extra_ph_bits_bytes"); + WRITE_CODE(0, 2, "sps_num_extra_sh_bits_bytes"); if (pcSPS->ptlDpbHrdParamsPresent) { @@ -689,7 +748,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } WRITE_UVLC(pcSPS->log2MinCodingBlockSize - 2, "log2_min_luma_coding_block_size_minus2"); - WRITE_FLAG(pcSPS->partitionOverrideEnabled, "partition_constraints_override_enabled_flag"); + WRITE_FLAG(pcSPS->partitionOverrideEnabled, "sps_partition_constraints_override_enabled_flag"); WRITE_UVLC(Log2(pcSPS->minQTSize[0]) - pcSPS->log2MinCodingBlockSize, "sps_log2_diff_min_qt_min_cb_intra_slice_luma"); WRITE_UVLC(pcSPS->maxMTTDepth[0], "sps_max_mtt_hierarchy_depth_intra_slice_luma"); if (pcSPS->maxMTTDepth[0] != 0) @@ -697,9 +756,9 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC(Log2(pcSPS->maxBTSize[0]) - Log2(pcSPS->minQTSize[0]), "sps_log2_diff_max_bt_min_qt_intra_slice_luma"); WRITE_UVLC(Log2(pcSPS->maxTTSize[0]) - Log2(pcSPS->minQTSize[0]), "sps_log2_diff_max_tt_min_qt_intra_slice_luma"); } - if( pcSPS->chromaFormatIdc != CHROMA_400 ) + if( pcSPS->chromaFormatIdc != CHROMA_400 ) { - WRITE_FLAG(pcSPS->dualITree, "qtbtt_dual_tree_intra_flag"); + WRITE_FLAG(pcSPS->dualITree, "sps_qtbtt_dual_tree_intra_flag"); } if (pcSPS->dualITree) { @@ -727,7 +786,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG(pcSPS->transformSkip, "sps_transform_skip_enabled_flag"); if (pcSPS->transformSkip) { - WRITE_UVLC(pcSPS->log2MaxTransformSkipBlockSize - 2, "log2_transform_skip_max_size_minus2"); + WRITE_UVLC(pcSPS->log2MaxTransformSkipBlockSize - 2, "sps_log2_transform_skip_max_size_minus2"); WRITE_FLAG(pcSPS->BDPCM, "sps_bdpcm_enabled_flag"); } WRITE_FLAG( pcSPS->MTS, "sps_mts_enabled_flag" ); @@ -768,17 +827,17 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG(pcSPS->lumaReshapeEnable, "sps_lmcs_enable_flag"); WRITE_FLAG( pcSPS->weightPred, "sps_weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) WRITE_FLAG( pcSPS->weightedBiPred, "sps_weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) - WRITE_FLAG( pcSPS->longTermRefsPresent, "long_term_ref_pics_flag" ); + WRITE_FLAG( pcSPS->longTermRefsPresent, "sps_long_term_ref_pics_flag" ); if( pcSPS->vpsId > 0 ) { WRITE_FLAG( pcSPS->interLayerPresent, "sps_inter_layer_ref_pics_present_flag" ); } WRITE_FLAG( pcSPS->idrRefParamList, "sps_idr_rpl_present_flag" ); - WRITE_FLAG( pcSPS->rpl1CopyFromRpl0, "rpl1_copy_from_rpl0_flag"); + WRITE_FLAG( pcSPS->rpl1CopyFromRpl0, "sps_rpl1_copy_from_rpl0_flag"); //Write candidate for List0 uint32_t numberOfRPL = (uint32_t)pcSPS->getNumRPL(0); - WRITE_UVLC(numberOfRPL, "num_ref_pic_lists_in_sps[0]"); + WRITE_UVLC(numberOfRPL, "sps_num_ref_pic_lists_in_sps[0]"); for (int ii = 0; ii < numberOfRPL; ii++) { xCodeRefPicList( &pcSPS->rplList[0][ii], pcSPS->longTermRefsPresent, pcSPS->bitsForPOC, !pcSPS->weightPred && !pcSPS->weightedBiPred, ii ); @@ -788,7 +847,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) if (!pcSPS->rpl1CopyFromRpl0) { numberOfRPL = (uint32_t)pcSPS->getNumRPL(1); - WRITE_UVLC(numberOfRPL, "num_ref_pic_lists_in_sps[1]"); + WRITE_UVLC(numberOfRPL, "sps_num_ref_pic_lists_in_sps[1]"); for (int ii = 0; ii < numberOfRPL; ii++) { xCodeRefPicList( &pcSPS->rplList[1][ii], pcSPS->longTermRefsPresent, pcSPS->bitsForPOC, !pcSPS->weightPred && !pcSPS->weightedBiPred, ii ); @@ -796,7 +855,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } WRITE_FLAG( pcSPS->wrapAroundEnabled, "sps_ref_wraparound_enabled_flag" ); - + WRITE_FLAG( pcSPS->temporalMVPEnabled, "sps_temporal_mvp_enabled_flag" ); if ( pcSPS->temporalMVPEnabled ) @@ -822,7 +881,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) { WRITE_FLAG( pcSPS->fpelMmvd, "sps_fpel_mmvd_enabled_flag" ); } - WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSPS->maxNumMergeCand, "six_minus_max_num_merge_cand"); + WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSPS->maxNumMergeCand, "sps_six_minus_max_num_merge_cand"); WRITE_FLAG( pcSPS->SBT, "sps_sbt_enabled_flag" ); WRITE_FLAG( pcSPS->Affine, "sps_affine_enabled_flag" ); if ( pcSPS->Affine ) @@ -833,7 +892,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) { WRITE_FLAG( pcSPS->AffineAmvr, "sps_affine_amvr_enabled_flag" ); } - + WRITE_FLAG( pcSPS->PROF, "sps_affine_prof_enabled_flag" ); if (pcSPS->PROF) { @@ -850,15 +909,15 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG(pcSPS->GEO, "sps_gpm_enabled_flag"); if (pcSPS->GEO && pcSPS->maxNumMergeCand >= 3) { - WRITE_UVLC(pcSPS->maxNumMergeCand - pcSPS->maxNumGeoCand, "max_num_merge_cand_minus_max_num_gpm_cand"); + WRITE_UVLC(pcSPS->maxNumMergeCand - pcSPS->maxNumGeoCand, "sps_max_num_merge_cand_minus_max_num_gpm_cand"); } } - WRITE_UVLC(pcSPS->log2ParallelMergeLevelMinus2, "log2_parallel_merge_level_minus2"); + WRITE_UVLC(pcSPS->log2ParallelMergeLevelMinus2, "sps_log2_parallel_merge_level_minus2"); WRITE_FLAG( pcSPS->ISP, "sps_isp_enabled_flag"); WRITE_FLAG( pcSPS->MRL, "sps_mrl_enabled_flag"); WRITE_FLAG( pcSPS->MIP, "sps_mip_enabled_flag"); - if( pcSPS->chromaFormatIdc != CHROMA_400) + if( pcSPS->chromaFormatIdc != CHROMA_400) { WRITE_FLAG( pcSPS->LMChroma, "sps_cclm_enabled_flag" ); } @@ -898,7 +957,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( pcSPS->scalingListEnabled, "sps_explicit_scaling_list_enabled_flag" ); if (pcSPS->LFNST && pcSPS->scalingListEnabled ) { - WRITE_FLAG(pcSPS->disableScalingMatrixForLfnstBlks, "scaling_matrix_for_lfnst_disabled_flag"); + WRITE_FLAG(pcSPS->disableScalingMatrixForLfnstBlks, "sps_scaling_matrix_for_lfnst_disabled_flag"); } if (pcSPS->useColorTrans && pcSPS->scalingListEnabled) { @@ -932,13 +991,19 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) if( pcSPS->hrdParametersPresent ) { - THROW("no support"); + codeGeneralHrdparameters(&pcSPS->generalHrdParams); + if ((pcSPS->maxTLayers - 1) > 0) + { + WRITE_FLAG(pcSPS->subLayerParametersPresent, "sps_sublayer_cpb_params_present_flag"); + } + uint32_t firstSubLayer = pcSPS->subLayerParametersPresent ? 0 : (pcSPS->maxTLayers - 1); + codeOlsHrdParameters(&pcSPS->generalHrdParams, pcSPS->olsHrdParams, firstSubLayer, pcSPS->maxTLayers - 1); } } - WRITE_FLAG(pcSPS->fieldSeqFlag, "field_seq_flag"); + WRITE_FLAG(pcSPS->fieldSeqFlag, "sps_field_seq_flag"); - WRITE_FLAG( pcSPS->vuiParametersPresent, "vui_parameters_present_flag" ); + WRITE_FLAG( pcSPS->vuiParametersPresent, "sps_vui_parameters_present_flag" ); if (pcSPS->vuiParametersPresent) { OutputBitstream *bs = m_pcBitIf; // save the original ono @@ -1025,9 +1090,7 @@ void HLSWriter::codeDCI( const DCI* dci ) { DTRACE( g_trace_ctx, D_HEADER, "=========== Decoding Parameter Set ===========\n" ); - WRITE_CODE( dci->dciId, 4, "dci_decoding_parameter_set_id" ); - WRITE_CODE( dci->maxSubLayersMinus1, 3, "dci_max_sub_layers_minus1" ); - WRITE_CODE( 0, 5, "dci_reserved_zero_5bits" ); + WRITE_CODE( 0, 4, "dci_reserved_zero_5bits" ); uint32_t numPTLs = (uint32_t) dci->profileTierLevel.size(); CHECK (numPTLs<1, "At least one PTL must be available in DPS"); @@ -1048,9 +1111,9 @@ void HLSWriter::codeVPS(const VPS* pcVPS) WRITE_CODE(pcVPS->vpsId, 4, "vps_video_parameter_set_id"); WRITE_CODE(pcVPS->maxLayers - 1, 6, "vps_max_layers_minus1"); WRITE_CODE(pcVPS->maxSubLayers - 1, 3, "vps_max_sublayers_minus1"); - if (pcVPS->maxLayers > 1 && pcVPS->maxSubLayers > 1) + if (pcVPS->maxLayers > 1 && pcVPS->maxSubLayers > 1) { - WRITE_FLAG(pcVPS->allLayersSameNumSubLayers, "vps_all_layers_same_num_sublayers_flag"); + WRITE_FLAG(pcVPS->defaultPtlDpbHrdMaxTidFlag, "vps_default_ptl_dpb_hrd_max_tid_flag"); } if (pcVPS->maxLayers > 1) { @@ -1064,28 +1127,32 @@ void HLSWriter::codeVPS(const VPS* pcVPS) WRITE_FLAG(pcVPS->independentLayer[i], "vps_independent_layer_flag"); if (!pcVPS->independentLayer[i]) { + bool presentFlag = false; for (int j = 0; j < i; j++) { - WRITE_FLAG(pcVPS->directRefLayer[i][j], "vps_direct_dependency_flag"); + presentFlag |= ((pcVPS->maxTidIlRefPicsPlus1[i][j] != MAX_TLAYER) && pcVPS->directRefLayer[i][j]); } - bool presentFlag = ( pcVPS->maxTidIlRefPicsPlus1[i] != 7 ); - WRITE_FLAG(presentFlag, "max_tid_ref_present_flag[ i ]"); - if (presentFlag) + WRITE_FLAG(presentFlag, "max_tid_ref_present_flag[ i ]"); + for (int j = 0; j < i; j++) { - WRITE_CODE(pcVPS->maxTidIlRefPicsPlus1[i], 3, "max_tid_il_ref_pics_plus1[ i ]"); + WRITE_FLAG(pcVPS->directRefLayer[i][j], "vps_direct_ref_layer_flag"); + if (presentFlag && pcVPS->directRefLayer[i][j]) + { + WRITE_CODE(pcVPS->maxTidIlRefPicsPlus1[i][j], 3, "max_tid_il_ref_pics_plus1[ i ][ j ]"); + } } } } } if( pcVPS->maxLayers > 1 ) { - if (pcVPS->allIndependentLayers) + if (pcVPS->allIndependentLayers) { WRITE_FLAG(pcVPS->eachLayerIsAnOls, "vps_each_layer_is_an_ols_flag"); } - if (!pcVPS->eachLayerIsAnOls) + if (!pcVPS->eachLayerIsAnOls) { - if (!pcVPS->allIndependentLayers) + if (!pcVPS->allIndependentLayers) { WRITE_CODE(pcVPS->olsModeIdc, 2, "vps_ols_mode_idc"); } @@ -1110,17 +1177,17 @@ void HLSWriter::codeVPS(const VPS* pcVPS) { if(i > 0) { - WRITE_FLAG(pcVPS->ptPresent[i], "pt_present_flag"); + WRITE_FLAG(pcVPS->ptPresent[i], "vps_ptl_present_flag"); } if(!pcVPS->allLayersSameNumSubLayers) { - WRITE_CODE(pcVPS->ptlMaxTemporalId[i] ,3, "ptl_max_temporal_id"); + WRITE_CODE(pcVPS->ptlMaxTemporalId[i] ,3, "vps_ptl_max_temporal_id"); } } int cnt = 0; while (m_pcBitIf->getNumBitsUntilByteAligned()) { - WRITE_FLAG( 0, "vps_plt_reserved_zero_bit"); + WRITE_FLAG( 0, "vps_ptl_reserved_zero_bit"); cnt++; } CHECK(cnt>=8, "More than '8' alignment bytes written"); @@ -1131,7 +1198,7 @@ void HLSWriter::codeVPS(const VPS* pcVPS) for (int i = 0; i < totalNumOlss; i++) { if(pcVPS->numPtls > 1 && pcVPS->numPtls != pcVPS->totalNumOLSs) - WRITE_CODE(pcVPS->olsPtlIdx[i], 8, "ols_ptl_idx"); + WRITE_CODE(pcVPS->olsPtlIdx[i], 8, "vps_ols_ptl_idx"); } if( !pcVPS->allIndependentLayers ) { @@ -1147,7 +1214,7 @@ void HLSWriter::codeVPS(const VPS* pcVPS) { if( !pcVPS->allLayersSameNumSubLayers ) { - WRITE_CODE( pcVPS->dpbMaxTemporalId[i], 3, "dpb_max_temporal_id[i]" ); + WRITE_CODE( pcVPS->dpbMaxTemporalId[i], 3, "vps_dpb_max_temporal_id[i]" ); } if( pcVPS->maxSubLayers == 1 ) { @@ -1155,13 +1222,13 @@ void HLSWriter::codeVPS(const VPS* pcVPS) } else { - if( pcVPS->allLayersSameNumSubLayers ) + if( pcVPS->defaultPtlDpbHrdMaxTidFlag ) { CHECK( pcVPS->dpbMaxTemporalId[i] != pcVPS->maxSubLayers - 1, "When vps_max_sublayers_minus1 is greater than 0 and vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1" ); } else { - WRITE_CODE( pcVPS->dpbMaxTemporalId[i], 3, "dpb_max_temporal_id[i]" ); + WRITE_CODE( pcVPS->dpbMaxTemporalId[i], 3, "vps_dpb_max_temporal_id[i]" ); } } @@ -1177,13 +1244,13 @@ void HLSWriter::codeVPS(const VPS* pcVPS) { if( pcVPS->numLayersInOls[i] > 1 ) { - WRITE_UVLC( pcVPS->olsDpbPicSize[i].width, "ols_dpb_pic_width[i]" ); - WRITE_UVLC( pcVPS->olsDpbPicSize[i].height, "ols_dpb_pic_height[i]" ); - WRITE_CODE( pcVPS->olsDpbChromaFormatIdc[i], 2, "ols_dpb_chroma_format[i]"); - WRITE_UVLC( pcVPS->olsDpbBitDepthMinus8[i], "ols_dpb_bitdepth_minus8[i]"); + WRITE_UVLC( pcVPS->olsDpbPicSize[i].width, "vps_ols_dpb_pic_width[i]" ); + WRITE_UVLC( pcVPS->olsDpbPicSize[i].height, "vps_ols_dpb_pic_height[i]" ); + WRITE_CODE( pcVPS->olsDpbChromaFormatIdc[i], 2, "vps_ols_dpb_chroma_format[i]"); + WRITE_UVLC( pcVPS->olsDpbBitDepthMinus8[i], "vps_ols_dpb_bitdepth_minus8[i]"); if( pcVPS->numDpbParams > 1 && (pcVPS->numDpbParams != pcVPS->numMultiLayeredOlss) ) { - WRITE_UVLC( pcVPS->olsDpbParamsIdx[i], "ols_dpb_params_idx[i]" ); + WRITE_UVLC( pcVPS->olsDpbParamsIdx[i], "vps_ols_dpb_params_idx[i]" ); } } } @@ -1191,11 +1258,32 @@ void HLSWriter::codeVPS(const VPS* pcVPS) if (!pcVPS->eachLayerIsAnOls) { - WRITE_FLAG(pcVPS->generalHrdParamsPresentFlag, "vps_general_hrd_params_present_flag"); + WRITE_FLAG(pcVPS->generalHrdParamsPresent, "vps_general_hrd_params_present_flag"); } - if (pcVPS->generalHrdParamsPresentFlag) + if (pcVPS->generalHrdParamsPresent) { - THROW( "no support"); + codeGeneralHrdparameters(&pcVPS->generalHrdParams); + if ((pcVPS->maxSubLayers-1) > 0) + { + WRITE_FLAG(pcVPS->sublayerCpbParamsPresent, "vps_sublayer_cpb_params_present_flag"); + } + WRITE_UVLC(pcVPS->numOlsHrdParamsMinus1, "vps_num_ols_hrd_params_minus1"); + for (int i = 0; i <= pcVPS->numOlsHrdParamsMinus1; i++) + { + if (!pcVPS->defaultPtlDpbHrdMaxTidFlag) + { + WRITE_CODE(pcVPS->hrdMaxTid[i], 3, "vps_hrd_vps_max_tid[i]"); + } + uint32_t firstSublayer = pcVPS->sublayerCpbParamsPresent ? 0 : pcVPS->hrdMaxTid[i]; + codeOlsHrdParameters(&pcVPS->generalHrdParams, &pcVPS->olsHrdParams[i], firstSublayer, pcVPS->hrdMaxTid[i]); + } + if ((pcVPS->numOlsHrdParamsMinus1 > 0) && ((pcVPS->numOlsHrdParamsMinus1 + 1) != pcVPS->numMultiLayeredOlss)) + { + for (int i = 0; i < pcVPS->numMultiLayeredOlss; i++) + { + WRITE_UVLC(pcVPS->olsHrdIdx[i], "vps_ols_hrd_idx[i]"); + } + } } WRITE_FLAG(0, "vps_extension_flag"); @@ -1211,11 +1299,11 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra DTRACE( g_trace_ctx, D_HEADER, "=========== Picture Header ===========\n" ); CodingStructure& cs = *picHeader->pic->cs; - WRITE_FLAG(picHeader->gdrOrIrapPic, "gdr_or_irap_pic_flag"); + WRITE_FLAG(picHeader->gdrOrIrapPic, "ph_gdr_or_irap_pic_flag"); WRITE_FLAG(picHeader->nonRefPic, "ph_non_ref_pic_flag"); if (picHeader->gdrOrIrapPic) { - WRITE_FLAG(picHeader->gdrPic, "gdr_pic_flag"); + WRITE_FLAG(picHeader->gdrPic, "ph_gdr_pic_flag"); } // Q0781, two-flags WRITE_FLAG(picHeader->picInterSliceAllowed, "ph_inter_slice_allowed_flag"); @@ -1232,22 +1320,22 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra int pocBits = cs.slice->sps->bitsForPOC; int pocMask = (1 << pocBits) - 1; WRITE_CODE(cs.slice->poc & pocMask, pocBits, "ph_pic_order_cnt_lsb"); - if( picHeader->gdrPic ) + if( picHeader->gdrPic ) { - WRITE_UVLC(picHeader->recoveryPocCnt, "recovery_poc_cnt"); + WRITE_UVLC(picHeader->recoveryPocCnt, "ph_recovery_poc_cnt"); } // PH extra bits are not written in the reference encoder // as these bits are reserved for future extensions // for( i = 0; i < NumExtraPhBits; i++ ) // ph_extra_bit[ i ] - + if (sps->pocMsbFlag) { WRITE_FLAG(picHeader->pocMsbPresent, "ph_poc_msb_present_flag"); if (picHeader->pocMsbPresent) { - WRITE_CODE(picHeader->pocMsbVal, sps->pocMsbLen, "poc_msb_val"); + WRITE_CODE(picHeader->pocMsbVal, sps->pocMsbLen, "ph_poc_msb_val"); } } @@ -1256,13 +1344,13 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra { if (pps->alfInfoInPh) { - WRITE_FLAG(picHeader->alfEnabled[COMP_Y], "pic_alf_enabled_flag"); + WRITE_FLAG(picHeader->alfEnabled[COMP_Y], "ph_alf_enabled_flag"); if (picHeader->alfEnabled[COMP_Y]) { - WRITE_CODE(picHeader->numAlfAps, 3, "pic_num_alf_aps_ids_luma"); + WRITE_CODE(picHeader->numAlfAps, 3, "ph_num_alf_aps_ids_luma"); for (int i = 0; i < picHeader->numAlfAps; i++) { - WRITE_CODE(picHeader->alfApsId[i], 3, "pic_alf_aps_id_luma"); + WRITE_CODE(picHeader->alfApsId[i], 3, "ph_alf_aps_id_luma"); } const int alfChromaIdc = picHeader->alfEnabled[COMP_Cb] + picHeader->alfEnabled[COMP_Cr] * 2 ; @@ -1273,7 +1361,7 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra } if (alfChromaIdc) { - WRITE_CODE(picHeader->alfChromaApsId, 3, "pic_alf_aps_id_chroma"); + WRITE_CODE(picHeader->alfChromaApsId, 3, "ph_alf_aps_id_chroma"); } if (sps->ccalfEnabled) { @@ -1309,10 +1397,10 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra // quantization scaling lists if( sps->scalingListEnabled ) { - WRITE_FLAG( picHeader->explicitScalingListEnabled, "pic_scaling_list_present_flag" ); + WRITE_FLAG( picHeader->explicitScalingListEnabled, "ph_scaling_list_present_flag" ); if( picHeader->explicitScalingListEnabled ) { - WRITE_CODE( picHeader->scalingListApsId, 3, "pic_scaling_list_aps_id" ); + WRITE_CODE( picHeader->scalingListApsId, 3, "ph_scaling_list_aps_id" ); } } @@ -1334,19 +1422,19 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra } } } - + // picture output flag if( pps->outputFlagPresent && !picHeader->nonRefPic) { - WRITE_FLAG( picHeader->picOutputFlag, "pic_output_flag" ); + WRITE_FLAG( picHeader->picOutputFlag, "ph_pic_output_flag" ); } // reference picture lists if (pps->rplInfoInPh) { // List0 and List1 - for(int listIdx = 0; listIdx < 2; listIdx++) - { + for(int listIdx = 0; listIdx < 2; listIdx++) + { if(sps->getNumRPL(listIdx) > 0 && (listIdx == 0 || (listIdx == 1 && pps->rpl1IdxPresent))) { @@ -1394,14 +1482,14 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra if (picHeader->pRPL[listIdx]->isLongtermRefPic[i]) { if (picHeader->pRPL[listIdx]->ltrpInSliceHeader) - { + { WRITE_CODE(picHeader->pRPL[listIdx]->refPicIdentifier[i], sps->bitsForPOC, "pic_poc_lsb_lt[listIdx][rplsIdx][j]"); } - WRITE_FLAG(picHeader->localRPL[listIdx].deltaPocMSBPresent[i], "pic_delta_poc_msb_present_flag[i][j]"); - if (picHeader->localRPL[listIdx].deltaPocMSBPresent[i]) + WRITE_FLAG(picHeader->pRPL[listIdx]->deltaPocMSBPresent[i], "pic_delta_poc_msb_present_flag[i][j]"); + if (picHeader->pRPL[listIdx]->deltaPocMSBPresent[i]) { - WRITE_UVLC(picHeader->localRPL[listIdx].deltaPocMSBCycleLT[i], "pic_delta_poc_msb_cycle_lt[i][j]"); + WRITE_UVLC(picHeader->pRPL[listIdx]->deltaPocMSBCycleLT[i], "pic_delta_poc_msb_cycle_lt[i][j]"); } } } @@ -1421,21 +1509,21 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra if (picHeader->splitConsOverride) { WRITE_UVLC(floorLog2(picHeader->minQTSize[0]) - sps->log2MinCodingBlockSize, "pic_log2_diff_min_qt_min_cb_intra_slice_luma"); - WRITE_UVLC(picHeader->maxMTTDepth[0], "pic_max_mtt_hierarchy_depth_intra_slice_luma"); + WRITE_UVLC(picHeader->maxMTTDepth[0], "ph_max_mtt_hierarchy_depth_intra_slice_luma"); if (picHeader->maxMTTDepth[0] != 0) { - WRITE_UVLC(floorLog2(picHeader->maxBTSize[0]) - floorLog2(picHeader->minQTSize[0]), "pic_log2_diff_max_bt_min_qt_intra_slice_luma"); - WRITE_UVLC(floorLog2(picHeader->maxTTSize[0]) - floorLog2(picHeader->minQTSize[0]), "pic_log2_diff_max_tt_min_qt_intra_slice_luma"); + WRITE_UVLC(floorLog2(picHeader->maxBTSize[0]) - floorLog2(picHeader->minQTSize[0]), "ph_log2_diff_max_bt_min_qt_intra_slice_luma"); + WRITE_UVLC(floorLog2(picHeader->maxTTSize[0]) - floorLog2(picHeader->minQTSize[0]), "ph_log2_diff_max_tt_min_qt_intra_slice_luma"); } if (sps->dualITree) { - WRITE_UVLC(floorLog2(picHeader->minQTSize[2]) - sps->log2MinCodingBlockSize, "pic_log2_diff_min_qt_min_cb_intra_slice_chroma"); - WRITE_UVLC(picHeader->maxMTTDepth[2], "pic_max_mtt_hierarchy_depth_intra_slice_chroma"); + WRITE_UVLC(floorLog2(picHeader->minQTSize[2]) - sps->log2MinCodingBlockSize, "ph_log2_diff_min_qt_min_cb_intra_slice_chroma"); + WRITE_UVLC(picHeader->maxMTTDepth[2], "ph_max_mtt_hierarchy_depth_intra_slice_chroma"); if (picHeader->maxMTTDepth[2] != 0) { - WRITE_UVLC(floorLog2(picHeader->maxBTSize[2]) - floorLog2(picHeader->minQTSize[2]), "pic_log2_diff_max_bt_min_qt_intra_slice_chroma"); - WRITE_UVLC(floorLog2(picHeader->maxTTSize[2]) - floorLog2(picHeader->minQTSize[2]), "pic_log2_diff_max_tt_min_qt_intra_slice_chroma"); + WRITE_UVLC(floorLog2(picHeader->maxBTSize[2]) - floorLog2(picHeader->minQTSize[2]), "ph_log2_diff_max_bt_min_qt_intra_slice_chroma"); + WRITE_UVLC(floorLog2(picHeader->maxTTSize[2]) - floorLog2(picHeader->minQTSize[2]), "ph_log2_diff_max_tt_min_qt_intra_slice_chroma"); } } } @@ -1445,11 +1533,11 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra // delta quantization and chrom and chroma offset if (pps->useDQP) { - WRITE_UVLC( picHeader->cuQpDeltaSubdivIntra, "pic_cu_qp_delta_subdiv_intra_slice" ); + WRITE_UVLC( picHeader->cuQpDeltaSubdivIntra, "ph_cu_qp_delta_subdiv_intra_slice" ); } if (pps->chromaQpOffsetListLen ) { - WRITE_UVLC( picHeader->cuChromaQpOffsetSubdivIntra, "pic_cu_chroma_qp_offset_subdiv_intra_slice" ); + WRITE_UVLC( picHeader->cuChromaQpOffsetSubdivIntra, "ph_cu_chroma_qp_offset_subdiv_intra_slice" ); } } @@ -1498,35 +1586,35 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra // full-pel MMVD flag if (sps->fpelMmvd ) { - WRITE_FLAG( picHeader->disFracMMVD, "pic_fpel_mmvd_enabled_flag" ); + WRITE_FLAG( picHeader->disFracMMVD, "ph_fpel_mmvd_enabled_flag" ); } // mvd L1 zero flag if (!pps->rplInfoInPh || picHeader->pRPL[1]->getNumRefEntries() > 0) { WRITE_FLAG(picHeader->mvdL1Zero, "ph_mvd_l1_zero_flag"); } - + // picture level BDOF disable flags if (sps->BdofPresent && (!pps->rplInfoInPh || picHeader->pRPL[1]->getNumRefEntries() > 0)) { - WRITE_FLAG(picHeader->disBdofFlag, "pic_disable_bdof_flag"); + WRITE_FLAG(picHeader->disBdofFlag, "ph_disable_bdof_flag"); } // picture level DMVR disable flags if (sps->DmvrPresent && (!pps->rplInfoInPh || picHeader->pRPL[1]->getNumRefEntries() > 0)) { - WRITE_FLAG(picHeader->disDmvrFlag, "pic_disable_dmvr_flag"); + WRITE_FLAG(picHeader->disDmvrFlag, "ph_disable_dmvr_flag"); } // picture level PROF disable flags if (sps->ProfPresent) { - WRITE_FLAG(picHeader->disProfFlag, "pic_disable_prof_flag"); + WRITE_FLAG(picHeader->disProfFlag, "ph_disable_prof_flag"); } if ((pps->weightPred || pps->weightedBiPred) && pps->wpInfoInPh ) { - xCodePredWeightTable(picHeader, sps); + xCodePredWeightTable(picHeader, pps, sps); } } @@ -1538,14 +1626,14 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra // joint Cb/Cr sign flag if (sps->jointCbCr ) { - WRITE_FLAG( picHeader->jointCbCrSign, "pic_joint_cbcr_sign_flag" ); + WRITE_FLAG( picHeader->jointCbCrSign, "ph_joint_cbcr_sign_flag" ); } // sao enable flags if(sps->saoEnabled) { if (pps->saoInfoInPh) - { + { WRITE_FLAG(picHeader->saoEnabled[CH_L], "ph_sao_luma_enabled_flag"); if (sps->chromaFormatIdc != CHROMA_400) { @@ -1553,15 +1641,15 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra } } } - + // deblocking filter controls if (pps->deblockingFilterControlPresent ) { if(pps->deblockingFilterOverrideEnabled) - { + { if (pps->dbfInfoInPh) { - WRITE_FLAG ( picHeader->deblockingFilterOverride, "pic_deblocking_filter_override_flag" ); + WRITE_FLAG ( picHeader->deblockingFilterOverride, "ph_deblocking_filter_override_flag" ); } } @@ -1586,9 +1674,9 @@ void HLSWriter::codePictureHeader( const PicHeader* picHeader, bool writeRbspTra // picture header extension if(pps->pictureHeaderExtensionPresent) { - WRITE_UVLC(0,"pic_segment_header_extension_length"); + WRITE_UVLC(0,"ph_extension_length"); } - + if ( writeRbspTrailingBits ) { xWriteRbspTrailingBits(); @@ -1600,13 +1688,13 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { DTRACE( g_trace_ctx, D_HEADER, "=========== Slice ===========\n" ); - CodingStructure& cs = *slice->pic->cs; + CodingStructure& cs = *slice->pic->cs; const PicHeader *picHeader = cs.picHeader; - const ChromaFormat format = slice->sps->chromaFormatIdc; + const ChromaFormat format = slice->sps->chromaFormatIdc; const uint32_t numberValidComponents = getNumberValidComponents(format); const bool chromaEnabled = isChromaEnabled(format); - WRITE_FLAG(slice->pictureHeaderInSliceHeader, "picture_header_in_slice_header_flag"); + WRITE_FLAG(slice->pictureHeaderInSliceHeader, "sh_picture_header_in_slice_header_flag"); if(slice->pictureHeaderInSliceHeader) { codePictureHeader(picHeader, false); @@ -1627,7 +1715,7 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { bitsSubPicId = ceilLog2(slice->sps->numSubPics); } - WRITE_CODE(slice->sliceSubPicId, bitsSubPicId, "slice_subpic_id"); + WRITE_CODE(slice->sliceSubPicId, bitsSubPicId, "sh_subpic_id"); } if (!slice->pps->rectSlice) @@ -1639,7 +1727,7 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) // slice address is the index of the slice within the current sub-picture uint32_t currSubPicIdx = slice->pps->getSubPicIdxFromSubPicId( slice->sliceSubPicId ); SubPic currSubPic = slice->pps->subPics[currSubPicIdx]; - if( currSubPic.numSlicesInSubPic > 1 ) + if( currSubPic.numSlicesInSubPic > 1 ) { int numSlicesInPreviousSubPics = 0; for(int sp = 0; sp < currSubPicIdx; sp++) @@ -1647,17 +1735,17 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) numSlicesInPreviousSubPics += slice->pps->subPics[sp].numSlicesInSubPic; } int bitsSliceAddress = ceilLog2(currSubPic.numSlicesInSubPic); - WRITE_CODE( slice->sliceSubPicId - numSlicesInPreviousSubPics, bitsSliceAddress, "slice_address"); + WRITE_CODE( slice->sliceSubPicId - numSlicesInPreviousSubPics, bitsSliceAddress, "sh_slice_address"); } } if (picHeader->picInterSliceAllowed) { - WRITE_UVLC(slice->sliceType, "slice_type"); + WRITE_UVLC(slice->sliceType, "sh_slice_type"); } if (picHeader->gdrOrIrapPic) //th check this { - WRITE_FLAG(picHeader->noOutputOfPriorPics, "no_output_of_prior_pics_flag"); + WRITE_FLAG(picHeader->noOutputOfPriorPics, "sh_no_output_of_prior_pics_flag"); } if (!picHeader->picIntraSliceAllowed ) @@ -1668,41 +1756,41 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) if (slice->sps->alfEnabled && !slice->pps->alfInfoInPh) { const int alfEnabled = slice->tileGroupAlfEnabled[COMP_Y]; - WRITE_FLAG(alfEnabled, "slice_alf_enabled_flag"); + WRITE_FLAG(alfEnabled, "sh_alf_enabled_flag"); if (alfEnabled) { - WRITE_CODE(slice->tileGroupNumAps, 3, "slice_num_alf_aps_ids_luma"); + WRITE_CODE(slice->tileGroupNumAps, 3, "sh_num_alf_aps_ids_luma"); for (int i = 0; i < slice->tileGroupNumAps; i++) { - WRITE_CODE(slice->tileGroupLumaApsId[i], 3, "slice_alf_aps_id_luma"); + WRITE_CODE(slice->tileGroupLumaApsId[i], 3, "sh_alf_aps_id_luma"); } const int alfChromaIdc = slice->tileGroupAlfEnabled[COMP_Cb] + slice->tileGroupAlfEnabled[COMP_Cr] * 2; if (chromaEnabled) { - WRITE_FLAG(slice->tileGroupAlfEnabled[COMP_Cb], "slice_alf_cb_enabled_flag"); - WRITE_FLAG(slice->tileGroupAlfEnabled[COMP_Cr], "slice_alf_cr_enabled_flag"); + WRITE_FLAG(slice->tileGroupAlfEnabled[COMP_Cb], "sh_alf_cb_enabled_flag"); + WRITE_FLAG(slice->tileGroupAlfEnabled[COMP_Cr], "sh_alf_cr_enabled_flag"); } if (alfChromaIdc) { - WRITE_CODE(slice->tileGroupChromaApsId, 3, "slice_alf_aps_id_chroma"); + WRITE_CODE(slice->tileGroupChromaApsId, 3, "sh_alf_aps_id_chroma"); } if (slice->sps->ccalfEnabled) { - WRITE_FLAG(slice->tileGroupCcAlfCbEnabled, "slice_cc_alf_cb_enabled_flag"); + WRITE_FLAG(slice->tileGroupCcAlfCbEnabled, "sh_cc_alf_cb_enabled_flag"); if( slice->tileGroupCcAlfCbEnabled ) { // write CC ALF Cb APS ID - WRITE_CODE(slice->tileGroupCcAlfCbApsId, 3, "slice_cc_alf_cb_aps_id"); + WRITE_CODE(slice->tileGroupCcAlfCbApsId, 3, "sh_cc_alf_cb_aps_id"); } // Cr - WRITE_FLAG(slice->tileGroupCcAlfCrEnabled, "slice_cc_alf_cr_enabled_flag"); + WRITE_FLAG(slice->tileGroupCcAlfCrEnabled, "sh_cc_alf_cr_enabled_flag"); if( slice->tileGroupCcAlfCrEnabled ) { // write CC ALF Cr APS ID - WRITE_CODE(slice->tileGroupCcAlfCrApsId, 3, "slice_cc_alf_cr_aps_id"); + WRITE_CODE(slice->tileGroupCcAlfCrApsId, 3, "sh_cc_alf_cr_aps_id"); } } } @@ -1710,11 +1798,11 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) if (picHeader->lmcsEnabled && !slice->pictureHeaderInSliceHeader) { - WRITE_FLAG( slice->lmcsEnabled, "slice_lmcs_enabled_flag"); + WRITE_FLAG( slice->lmcsEnabled, "sh_lmcs_enabled_flag"); } if (picHeader->explicitScalingListEnabled && !slice->pictureHeaderInSliceHeader) { - WRITE_FLAG(slice->explicitScalingListUsed, "slice_explicit_scaling_list_used_flag"); + WRITE_FLAG(slice->explicitScalingListUsed, "sh_explicit_scaling_list_used_flag"); } if( !slice->pps->rplInfoInPh && (!slice->getIdrPicFlag() || slice->sps->idrRefParamList)) @@ -1752,10 +1840,10 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { WRITE_CODE(slice->rpl[0]->refPicIdentifier[i], slice->sps->bitsForPOC, "slice_poc_lsb_lt[listIdx][rplsIdx][j]"); } - WRITE_FLAG(slice->rplLocal[0].deltaPocMSBPresent[i], "delta_poc_msb_present_flag[i][j]"); - if (slice->rplLocal[0].deltaPocMSBPresent[i]) + WRITE_FLAG(slice->rpl[0]->deltaPocMSBPresent[i], "delta_poc_msb_present_flag[i][j]"); + if (slice->rpl[0]->deltaPocMSBPresent[i]) { - WRITE_UVLC(slice->rplLocal[0].deltaPocMSBCycleLT[i], "delta_poc_msb_cycle_lt[i][j]"); + WRITE_UVLC(slice->rpl[0]->deltaPocMSBCycleLT[i], "delta_poc_msb_cycle_lt[i][j]"); } } } @@ -1813,10 +1901,10 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) WRITE_CODE(slice->rpl[1]->refPicIdentifier[i], slice->sps->bitsForPOC, "slice_poc_lsb_lt[listIdx][rplsIdx][j]"); } - WRITE_FLAG(slice->rplLocal[1].deltaPocMSBPresent[i], "delta_poc_msb_present_flag[i][j]"); - if (slice->rplLocal[1].deltaPocMSBPresent[i]) + WRITE_FLAG(slice->rpl[1]->deltaPocMSBPresent[i], "delta_poc_msb_present_flag[i][j]"); + if (slice->rpl[1]->deltaPocMSBPresent[i]) { - WRITE_UVLC(slice->rplLocal[1].deltaPocMSBCycleLT[i], "delta_poc_msb_cycle_lt[i][j]"); + WRITE_UVLC(slice->rpl[1]->deltaPocMSBCycleLT[i], "delta_poc_msb_cycle_lt[i][j]"); } } } @@ -1852,7 +1940,7 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { const SliceType encCABACTableIdx = slice->encCABACTableIdx; bool encCabacInitFlag = ( slice->sliceType != encCABACTableIdx && encCABACTableIdx != I_SLICE ) ? true : false; - WRITE_FLAG( encCabacInitFlag ? 1 : 0, "cabac_init_flag" ); + WRITE_FLAG( encCabacInitFlag ? 1 : 0, "sh_cabac_init_flag" ); } } @@ -1862,7 +1950,7 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { if (slice->sliceType == B_SLICE) { - WRITE_FLAG(slice->colFromL0Flag, "collocated_from_l0_flag"); + WRITE_FLAG(slice->colFromL0Flag, "sh_collocated_from_l0_flag"); } } @@ -1870,7 +1958,7 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) ( ( slice->colFromL0Flag == 1 && slice->numRefIdx[ REF_PIC_LIST_0 ] > 1 ) || ( slice->colFromL0Flag == 0 && slice->numRefIdx[ REF_PIC_LIST_1 ] > 1 ) ) ) { - WRITE_UVLC( slice->colRefIdx, "collocated_ref_idx" ); + WRITE_UVLC( slice->colRefIdx, "sh_collocated_ref_idx" ); } } @@ -1890,14 +1978,14 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { if (numberValidComponents > COMP_Cb) { - WRITE_SVLC( slice->sliceChromaQpDelta[COMP_Cb], "slice_cb_qp_offset" ); + WRITE_SVLC( slice->sliceChromaQpDelta[COMP_Cb], "sh_cb_qp_offset" ); } if (numberValidComponents > COMP_Cr) { - WRITE_SVLC( slice->sliceChromaQpDelta[COMP_Cr], "slice_cr_qp_offset" ); + WRITE_SVLC( slice->sliceChromaQpDelta[COMP_Cr], "sh_cr_qp_offset" ); if (slice->sps->jointCbCr) { - WRITE_SVLC( slice->sliceChromaQpDelta[COMP_JOINT_CbCr], "slice_joint_cbcr_qp_offset"); + WRITE_SVLC( slice->sliceChromaQpDelta[COMP_JOINT_CbCr], "sh_joint_cbcr_qp_offset"); } } CHECK(numberValidComponents < COMP_Cr+1, "Too many valid components"); @@ -1905,15 +1993,15 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) if (slice->pps->chromaQpOffsetListLen>0) { - WRITE_FLAG(slice->chromaQpAdjEnabled, "cu_chroma_qp_offset_enabled_flag"); + WRITE_FLAG(slice->chromaQpAdjEnabled, "sh_cu_chroma_qp_offset_enabled_flag"); } if( slice->sps->saoEnabled && !slice->pps->saoInfoInPh ) { - WRITE_FLAG( slice->saoEnabled[CH_L], "slice_sao_luma_flag" ); + WRITE_FLAG( slice->saoEnabled[CH_L], "sh_sao_luma_flag" ); if( chromaEnabled ) { - WRITE_FLAG( slice->saoEnabled[CH_C], "slice_sao_chroma_flag" ); + WRITE_FLAG( slice->saoEnabled[CH_C], "sh_sao_chroma_flag" ); } } @@ -1922,13 +2010,13 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) { if (slice->pps->deblockingFilterOverrideEnabled ) { - WRITE_FLAG(slice->deblockingFilterOverrideFlag, "deblocking_filter_override_flag"); + WRITE_FLAG(slice->deblockingFilterOverrideFlag, "sh_deblocking_params_present_flag"); } if (slice->deblockingFilterOverrideFlag) { - if (!slice->pps->deblockingFilterDisabled) + if (!slice->pps->deblockingFilterDisabled) { - WRITE_FLAG(slice->deblockingFilterDisable, "slice_deblocking_filter_disabled_flag"); + WRITE_FLAG(slice->deblockingFilterDisable, "sh_deblocking_filter_disabled_flag"); } if(!slice->deblockingFilterDisable) { @@ -1948,33 +2036,29 @@ void HLSWriter::codeSliceHeader( const Slice* slice ) // dependent quantization if( slice->sps->depQuantEnabled ) { - WRITE_FLAG(slice->depQuantEnabled, "slice_dep_quant_enabled_flag"); + WRITE_FLAG(slice->depQuantEnabled, "sh_dep_quant_used_flag"); } // sign data hiding if( slice->sps->signDataHidingEnabled && !slice->depQuantEnabled ) { - WRITE_FLAG(slice->signDataHidingEnabled, "slice_sign_data_hiding_enabled_flag" ); + WRITE_FLAG(slice->signDataHidingEnabled, "sh_sign_data_hiding_used_flag" ); } if( slice->sps->transformSkip && !slice->depQuantEnabled && !slice->signDataHidingEnabled ) { - WRITE_FLAG(slice->tsResidualCodingDisabled, "slice_ts_residual_coding_disabled_flag"); - } - if (picHeader->explicitScalingListEnabled) - { - WRITE_FLAG(slice->explicitScalingListUsed, "slice_explicit_scaling_list_used_flag"); + WRITE_FLAG(slice->tsResidualCodingDisabled, "sh_ts_residual_coding_disabled_flag"); } if(slice->pps->sliceHeaderExtensionPresent) { - WRITE_UVLC(0,"slice_segment_header_extension_length"); + WRITE_UVLC(0,"slice_header_extension_length"); } } void HLSWriter::codeConstraintInfo ( const ConstraintInfo* cinfo ) { - WRITE_FLAG(cinfo->gciPresentFlag, "gci_present_flag"); - if (cinfo->gciPresentFlag) + WRITE_FLAG(cinfo->gciPresent, "gci_present_flag"); + if (cinfo->gciPresent) { WRITE_FLAG(cinfo->intraOnlyConstraintFlag, "gci_intra_only_constraint_flag"); WRITE_FLAG(cinfo->allLayersIndependentConstraintFlag, "gci_all_layers_independent_constraint_flag"); @@ -2072,9 +2156,9 @@ void HLSWriter::codeConstraintInfo ( const ConstraintInfo* cinfo ) } -void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1 ) +void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, bool profileTierPresent, int maxNumSubLayersMinus1 ) { - if(profileTierPresentFlag) + if(profileTierPresent) { WRITE_CODE( (uint32_t)ptl->profileIdc, 7 , "general_profile_idc" ); WRITE_FLAG( ptl->tierFlag==Level::HIGH, "general_tier_flag" ); @@ -2083,7 +2167,7 @@ void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, bool pro WRITE_CODE( (uint32_t)ptl->levelIdc, 8 , "general_level_idc"); WRITE_FLAG( ptl->frameOnlyConstraintFlag, "ptl_frame_only_constraint_flag" ); WRITE_FLAG( ptl->multiLayerEnabledFlag, "ptl_multilayer_enabled_flag" ); - if(profileTierPresentFlag) + if(profileTierPresent) { codeConstraintInfo( &ptl->constraintInfo ); } @@ -2106,7 +2190,7 @@ void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, bool pro } } - if (profileTierPresentFlag) + if (profileTierPresent) { WRITE_CODE(ptl->numSubProfile, 8, "ptl_num_sub_profiles"); for (int i = 0; i < ptl->numSubProfile; i++) @@ -2150,11 +2234,11 @@ void HLSWriter::codeTilesWPPEntryPoint( Slice* pSlice ) if (pSlice->getNumberOfSubstreamSizes()>0) { - WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); + WRITE_UVLC(offsetLenMinus1, "sh_entry_offset_len_minus1"); for (uint32_t idx=0; idxgetNumberOfSubstreamSizes(); idx++) { - WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1"); + WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "sh_entry_point_offset_minus1"); } } } @@ -2247,7 +2331,7 @@ void HLSWriter::xCodePredWeightTable( const Slice* slice ) } -void HLSWriter::xCodePredWeightTable( const PicHeader *picHeader, const SPS *sps ) +void HLSWriter::xCodePredWeightTable( const PicHeader *picHeader, const PPS *pps, const SPS *sps ) { WPScalingParam *wp; const ChromaFormat format = sps->chromaFormatIdc; @@ -2321,10 +2405,14 @@ void HLSWriter::xCodePredWeightTable( const PicHeader *picHeader, const SPS *sps } } } - if (iNumRef == 0) + if (iNumRef == 0 ) { - numLxWeights = picHeader->numL1Weights; - if (picHeader->pRPL[1]->getNumRefEntries() > 0) + numLxWeights = picHeader->numL1Weights; + if (pps->weightedBiPred == 0) + { + numLxWeights = 0; + } + else if (picHeader->pRPL[1]->getNumRefEntries() > 0) { WRITE_UVLC(numLxWeights, "num_l1_weights"); } diff --git a/source/Lib/EncoderLib/VLCWriter.h b/source/Lib/EncoderLib/VLCWriter.h index 53cdfcb00..72f48a73b 100644 --- a/source/Lib/EncoderLib/VLCWriter.h +++ b/source/Lib/EncoderLib/VLCWriter.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file VLCWriter.h * \brief Writer for high level syntax */ @@ -56,8 +60,8 @@ vvc@hhi.fraunhofer.de namespace vvenc { -class GeneralHrdParams; -class OlsHrdParams; +struct GeneralHrdParams; +struct OlsHrdParams; #if ENABLE_TRACING @@ -124,9 +128,10 @@ class HLSWriter : private VLCWriter void codePictureHeader ( const PicHeader* picHeader, bool writeRbspTrailingBits ); void codeSliceHeader ( const Slice* slice ); void codeConstraintInfo ( const ConstraintInfo* cinfo ); - void codeProfileTierLevel ( const ProfileTierLevel* ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1 ); + void codeProfileTierLevel ( const ProfileTierLevel* ptl, bool profileTierPresent, int maxNumSubLayersMinus1 ); void codeOlsHrdParameters ( const GeneralHrdParams * generalHrd, const OlsHrdParams *olsHrd , const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1); + void codeGeneralHrdparameters ( const GeneralHrdParams *hrd); void codeAUD ( const int audIrapOrGdrAuFlag, const int pictureType ); void codeTilesWPPEntryPoint ( Slice* pSlice ); @@ -135,7 +140,7 @@ class HLSWriter : private VLCWriter private: void dpb_parameters ( int maxSubLayersMinus1, bool subLayerInfoFlag, const SPS *pcSPS); void xCodeRefPicList ( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc, int rplIdx ); - void xCodePredWeightTable ( const PicHeader *picHeader, const SPS *sps ); + void xCodePredWeightTable ( const PicHeader *picHeader, const PPS *pps, const SPS *sps ); void xCodePredWeightTable ( const Slice* slice ); }; diff --git a/source/Lib/Utilities/NoMallocThreadPool.cpp b/source/Lib/Utilities/NoMallocThreadPool.cpp index 76c7f1913..d8293dd7b 100644 --- a/source/Lib/Utilities/NoMallocThreadPool.cpp +++ b/source/Lib/Utilities/NoMallocThreadPool.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file NoMallocThreadPool.cpp diff --git a/source/Lib/Utilities/NoMallocThreadPool.h b/source/Lib/Utilities/NoMallocThreadPool.h index 92a9e22b3..e5a378a5c 100644 --- a/source/Lib/Utilities/NoMallocThreadPool.h +++ b/source/Lib/Utilities/NoMallocThreadPool.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \file NoMallocThreadPool.h \brief thread pool */ diff --git a/source/Lib/libmd5/MD5.h b/source/Lib/libmd5/MD5.h deleted file mode 100644 index 13eaa2638..000000000 --- a/source/Lib/libmd5/MD5.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc - -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ -#pragma once - -#include "libmd5.h" -#include - -//! \ingroup libMD5 -//! \{ - -namespace vvenc { - -static const uint32_t MD5_DIGEST_STRING_LENGTH=16; - -class MD5 -{ -public: - /** - * initialize digest state - */ - MD5() - { - MD5Init(&m_state); - } - - /** - * compute digest over buf of length len. - * multiple calls may extend the digest over more data. - */ - void update(unsigned char *buf, unsigned len) - { - MD5Update(&m_state, buf, len); - } - - /** - * flush any outstanding MD5 data, write the digest into digest. - */ - void finalize(unsigned char digest[MD5_DIGEST_STRING_LENGTH]) - { - MD5Final(digest, &m_state); - } - -private: - context_md5_t m_state; -}; - -} // namespace vvenc - -//! \} - diff --git a/source/Lib/libmd5/libmd5.cpp b/source/Lib/libmd5/libmd5.cpp deleted file mode 100644 index 8ddf76d54..000000000 --- a/source/Lib/libmd5/libmd5.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * This code implements the MD5 message-digest algorithm. The algorithm was - * written by Ron Rivest. This code was written by Colin Plumb in 1993, our - * understanding is that no copyright is claimed and that this code is in the - * public domain. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is functionally equivalent, - * - * To compute the message digest of a chunk of bytes, declare an MD5Context - * structure, pass it to MD5Init, call MD5Update as needed on buffers full of - * bytes, and then call MD5Final, which will fill a supplied 16-byte array with - * the digest. - */ - -#include "libmd5.h" -#include -#include - -//! \ingroup libMD5 -//! \{ - -namespace vvenc { - -static void MD5Transform(uint32_t buf[4], uint32_t const in[16]); - -#ifndef __BIG_ENDIAN__ -# define byteReverse(buf, len) /* Nothing */ -#else -void byteReverse(uint32_t *buf, unsigned len); -/* - * Note: this code is harmless on little-endian machines. - */ -void byteReverse(uint32_t *buf, unsigned len) -{ - uint32_t t; - do { - char* bytes = (char *) buf; - t = ((unsigned) bytes[3] << 8 | bytes[2]) << 16 | - ((unsigned) bytes[1] << 8 | bytes[0]); - *buf = t; - buf++; - } while (--len); -} -#endif - -/* - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void MD5Init(context_md5_t *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; -} - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void MD5Update(context_md5_t *ctx, unsigned char *buf, unsigned len) -{ - uint32_t t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - unsigned char *p = ctx->in.b8 + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in.b32, 16); - MD5Transform(ctx->buf, ctx->in.b32); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memcpy(ctx->in.b8, buf, 64); - byteReverse(ctx->in.b32, 16); - MD5Transform(ctx->buf, ctx->in.b32); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy(ctx->in.b8, buf, len); -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void MD5Final(unsigned char digest[16], context_md5_t *ctx) -{ - unsigned count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in.b8 + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in.b32, 16); - MD5Transform(ctx->buf, ctx->in.b32); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in.b8, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - byteReverse(ctx->in.b32, 14); - - /* Append length in bits and transform */ - ctx->in.b32[14] = ctx->bits[0]; - ctx->in.b32[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, ctx->in.b32); - byteReverse((uint32_t *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - - memset(ctx, 0, sizeof(* ctx)); /* In case it's sensitive */ - /* The original version of this code omitted the asterisk. In - effect, only the first part of ctx was wiped with zeros, not - the whole thing. Bug found by Derek Jones. Original line: */ - // memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ -static void MD5Transform(uint32_t buf[4], uint32_t const in[16]) -{ - register uint32_t a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -} // namespace vvenc - diff --git a/source/Lib/libmd5/libmd5.h b/source/Lib/libmd5/libmd5.h deleted file mode 100644 index ccbb69a0c..000000000 --- a/source/Lib/libmd5/libmd5.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc - -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ -#pragma once - -#include - -//! \ingroup libMD5 -//! \{ - -namespace vvenc { - -typedef struct _context_md5_t { - uint32_t buf[4]; - uint32_t bits[2]; - union { - unsigned char b8[64]; - uint32_t b32[16]; - } in; -} context_md5_t; - -void MD5Init(context_md5_t *ctx); -void MD5Update(context_md5_t *ctx, unsigned char *buf, unsigned len); -void MD5Final(unsigned char digest[16], context_md5_t *ctx); - -} // namespace vvenc - -//! \} - diff --git a/source/Lib/vvenc/CMakeLists.txt b/source/Lib/vvenc/CMakeLists.txt index ec7ce8aa0..6a37055cf 100644 --- a/source/Lib/vvenc/CMakeLists.txt +++ b/source/Lib/vvenc/CMakeLists.txt @@ -4,6 +4,9 @@ set( LIB_NAME vvenc ) # create upper case name string( TOUPPER ${LIB_NAME} LIB_NAME_UC ) +# create file version.h +configure_file( version.h.in "${CMAKE_BINARY_DIR}/${LIB_NAME}/version.h" ) + # get source files file( GLOB BASE_SRC_FILES "*.cpp" "../CommonLib/*.cpp" "../Utilities/*.cpp" "../DecoderLib/*.cpp" "../EncoderLib/*.cpp" ) @@ -28,20 +31,14 @@ file( GLOB SSE41_SRC_FILES "../CommonLib/x86/sse41/*.cpp" ) # get sse4.2 source files file( GLOB SSE42_SRC_FILES "../CommonLib/x86/sse42/*.cpp" ) -# get libmd5 source files -file( GLOB MD5_SRC_FILES "../libmd5/*.cpp" ) - -# get libmd5 include files -file( GLOB MD5_INC_FILES "../libmd5/*.h" ) - # get public/extern include files file( GLOB PUBLIC_INC_FILES "../../../include/${LIB_NAME}/*.h" ) # get all source files -set( SRC_FILES ${BASE_SRC_FILES} ${X86_SRC_FILES} ${SSE41_SRC_FILES} ${SSE42_SRC_FILES} ${AVX_SRC_FILES} ${AVX2_SRC_FILES} ${MD5_SRC_FILES} ) +set( SRC_FILES ${BASE_SRC_FILES} ${X86_SRC_FILES} ${SSE41_SRC_FILES} ${SSE42_SRC_FILES} ${AVX_SRC_FILES} ${AVX2_SRC_FILES} ) # get all include files -file( GLOB PRIVATE_INC_FILES ${BASE_INC_FILES} ${X86_INC_FILES} ${MD5_INC_FILES} ) +file( GLOB PRIVATE_INC_FILES ${BASE_INC_FILES} ${X86_INC_FILES} ) set( INC_FILES ${PRIVATE_INC_FILES} ${PUBLIC_INC_FILES} ) @@ -72,20 +69,25 @@ elseif( UNIX OR MINGW ) set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-mavx2" ) endif() +# set resource file for MSVC compilers +if( MSVC ) + set( RESOURCE_FILE ${LIB_NAME}.rc ) +endif() -add_library( ${LIB_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} ) +add_library( ${LIB_NAME} ${SRC_FILES} ${INC_FILES} ${NATVIS_FILES} ${RESOURCE_FILE} ) target_compile_definitions( ${LIB_NAME} PRIVATE ${LIB_NAME_UC}_SOURCE ) target_compile_definitions( ${LIB_NAME} PUBLIC $<$,$,SHARED_LIBRARY>>:${LIB_NAME_UC}_DYN_LINK> ) -target_compile_options( ${LIB_NAME} PRIVATE $<$,$>:-Wall -Wno-deprecated-register -Wno-unused-const-variable -Wno-unknown-attributes> - $<$:-Wall -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -fdiagnostics-show-option> - $<$:/W4 /wd4100 /wd4127 /wd4244 /wd4245 /wd4389 /wd4456 /wd4457 /wd4458 /wd4459 /wd4505 /wd4701 /wd4702 /wd4703 >) + +target_compile_options( ${LIB_NAME} PRIVATE $<$,$>:-Wall -Werror -Wno-deprecated-register -Wno-unused-const-variable -Wno-unknown-attributes> + $<$:-Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -fdiagnostics-show-option> + $<$:/W4 /WX /wd4100 /wd4127 /wd4244 /wd4245 /wd4251 /wd4310 /wd4389 /wd4456 /wd4457 /wd4458 /wd4459 /wd4505 /wd4701 /wd4702 /wd4703 /wd4996 >) -target_include_directories( ${LIB_NAME} PRIVATE $ - SYSTEM INTERFACE $ ) -target_include_directories( ${LIB_NAME} PRIVATE . .. ../DecoderLib ../EncoderLib ../CommonLib ../CommonLib/x86 ../libmd5 ) +target_include_directories( ${LIB_NAME} PRIVATE $ $ + SYSTEM INTERFACE $ $ ) +target_include_directories( ${LIB_NAME} PRIVATE . .. ../DecoderLib ../EncoderLib ../CommonLib ../CommonLib/x86 ) target_link_libraries( ${LIB_NAME} Threads::Threads ) diff --git a/source/Lib/vvenc/EncCfg.cpp b/source/Lib/vvenc/EncCfg.cpp index 7b8606bf0..9fc919532 100644 --- a/source/Lib/vvenc/EncCfg.cpp +++ b/source/Lib/vvenc/EncCfg.cpp @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncCfg.cpp \brief encoder configuration class */ -#include "../../../include/vvenc/EncCfg.h" +#include "vvenc/EncCfg.h" #include "CommonLib/CommonDef.h" #include "CommonLib/Slice.h" @@ -61,11 +65,20 @@ bool EncCfg::confirmParameter( bool bflag, const char* message ) { if ( ! bflag ) return false; - msg( ERROR, "Error: %s\n", message ); + msg( ERROR, "Parameter Check Error: %s\n", message ); m_confirmFailed = true; return true; } +bool EncCfg::checkExperimental( bool bflag, const char* message ) +{ + if( !bflag ) + return false; + + msg( WARNING, "Warning: Setting experimental: %s\n\n", message ); + return true; +} + bool EncCfg::initCfgParameter() { #define CONFIRM_PARAMETER_OR_RETURN( _f, _m ) { if ( confirmParameter( _f, _m ) ) return true; } @@ -114,25 +127,6 @@ bool EncCfg::initCfgParameter() m_MCTFNumLeadFrames = std::min( m_MCTFNumLeadFrames, MCTF_RANGE ); m_MCTFNumTrailFrames = std::min( m_MCTFNumTrailFrames, MCTF_RANGE ); - - if( !m_tileUniformSpacingFlag && m_numTileColumnsMinus1 > 0 ) - { - CONFIRM_PARAMETER_OR_RETURN( m_tileColumnWidth.size() != m_numTileColumnsMinus1, "Error: The number of columns minus 1 does not match size of tile column array." ); - } - else - { - m_tileColumnWidth.clear(); - } - - if( !m_tileUniformSpacingFlag && m_numTileRowsMinus1 > 0 ) - { - CONFIRM_PARAMETER_OR_RETURN( m_tileRowHeight.size() != m_numTileRowsMinus1, "Error: The number of rows minus 1 does not match size of tile row array." ); - } - else - { - m_tileRowHeight.clear(); - } - /* rules for input, output and internal bitdepths as per help text */ if (m_MSBExtendedBitDepth[CH_L ] == 0) { @@ -219,96 +213,7 @@ bool EncCfg::initCfgParameter() } } - m_topLeftBrickIdx.clear(); - m_bottomRightBrickIdx.clear(); - m_sliceId.clear(); - - bool singleTileInPicFlag = (m_numTileRowsMinus1 == 0 && m_numTileColumnsMinus1 == 0); - - if (!singleTileInPicFlag) - { - //if (!m_singleBrickPerSliceFlag && m_rectSliceFlag) - if (/*m_sliceMode != 0 && m_sliceMode != 4 && */m_rectSliceFlag) - { - int numSlicesInPic = m_numSlicesInPicMinus1 + 1; - - CONFIRM_PARAMETER_OR_RETURN( m_rectSliceBoundary.size() > numSlicesInPic * 2, "Error: The number of slice indices (RectSlicesBoundaryInPic) is greater than the NumSlicesInPicMinus1." ); - CONFIRM_PARAMETER_OR_RETURN( m_rectSliceBoundary.size() < numSlicesInPic * 2, "Error: The number of slice indices (RectSlicesBoundaryInPic) is less than the NumSlicesInPicMinus1." ); - - m_topLeftBrickIdx.resize(numSlicesInPic); - m_bottomRightBrickIdx.resize(numSlicesInPic); - for (uint32_t i = 0; i < numSlicesInPic; ++i) - { - m_topLeftBrickIdx[i] = m_rectSliceBoundary[i * 2]; - m_bottomRightBrickIdx[i] = m_rectSliceBoundary[i * 2 + 1]; - } - //Validating the correctness of rectangular slice structure - int **brickToSlice = (int **)malloc(sizeof(int *) * (m_numTileRowsMinus1 + 1)); - for (int i = 0; i <= m_numTileRowsMinus1; i++) - { - brickToSlice[i] = (int *)malloc(sizeof(int) * (m_numTileColumnsMinus1 + 1)); - memset(brickToSlice[i], -1, sizeof(int) * ((m_numTileColumnsMinus1 + 1))); - } - - //Check overlap case - for (int sliceIdx = 0; sliceIdx < numSlicesInPic; sliceIdx++) - { - int sliceStartRow = m_topLeftBrickIdx[sliceIdx] / (m_numTileColumnsMinus1 + 1); - int sliceEndRow = m_bottomRightBrickIdx[sliceIdx] / (m_numTileColumnsMinus1 + 1); - int sliceStartCol = m_topLeftBrickIdx[sliceIdx] % (m_numTileColumnsMinus1 + 1); - int sliceEndCol = m_bottomRightBrickIdx[sliceIdx] % (m_numTileColumnsMinus1 + 1); - for (int i = 0; i <= m_numTileRowsMinus1; i++) - { - for (int j = 0; j <= m_numTileColumnsMinus1; j++) - { - if (i >= sliceStartRow && i <= sliceEndRow && j >= sliceStartCol && j <= sliceEndCol) - { - CONFIRM_PARAMETER_OR_RETURN( brickToSlice[i][j] != -1, "Error: Values given in RectSlicesBoundaryInPic have conflict! Rectangular slice shall not have overlapped tile(s)" ); - brickToSlice[i][j] = sliceIdx; - } - } - } - } - //Check gap case - for (int i = 0; i <= m_numTileRowsMinus1; i++) - { - for (int j = 0; j <= m_numTileColumnsMinus1; j++) - { - CONFIRM_PARAMETER_OR_RETURN( brickToSlice[i][j] == -1, "Error: Values given in RectSlicesBoundaryInPic have conflict! Rectangular slice shall not have gap" ); - } - } - - for (int i = 0; i <= m_numTileRowsMinus1; i++) - { - free(brickToSlice[i]); - brickToSlice[i] = 0; - } - free(brickToSlice); - brickToSlice = 0; - } // (!m_singleBrickPerSliceFlag && m_rectSliceFlag) - } // !singleTileInPicFlag - - if (m_rectSliceFlag && m_signalledSliceIdFlag) - { - int numSlicesInPic = m_numSlicesInPicMinus1 + 1; - - CONFIRM_PARAMETER_OR_RETURN( m_signalledSliceId.size() > numSlicesInPic, "Error: The number of Slice Ids are greater than the m_signalledTileGroupIdLengthMinus1." ); - CONFIRM_PARAMETER_OR_RETURN( m_signalledSliceId.size() < numSlicesInPic, "Error: The number of Slice Ids are less than the m_signalledTileGroupIdLengthMinus1." ); - m_sliceId.resize(numSlicesInPic); - for (uint32_t i = 0; i < m_signalledSliceId.size(); ++i) - { - m_sliceId[i] = m_signalledSliceId[i]; - } - } - else if (m_rectSliceFlag) - { - int numSlicesInPic = m_numSlicesInPicMinus1 + 1; - m_sliceId.resize(numSlicesInPic); - for (uint32_t i = 0; i < numSlicesInPic; ++i) - { - m_sliceId[i] = i; - } - } + m_sliceId.resize(1,0); for(uint32_t ch=0; ch < MAX_NUM_CH; ch++ ) { @@ -473,6 +378,7 @@ bool EncCfg::initCfgParameter() confirmParameter( m_InputQueueSize < m_GOPSize , "Input queue size must be greater or equal to gop size" ); confirmParameter( m_MCTF && m_InputQueueSize < m_GOPSize + MCTF_ADD_QUEUE_DELAY , "Input queue size must be greater or equal to gop size + N frames for MCTF" ); confirmParameter( m_DecodingRefreshType < 0 || m_DecodingRefreshType > 3, "Decoding Refresh Type must be comprised between 0 and 3 included" ); + confirmParameter( m_DecodingRefreshType !=1, "Decoding Refresh Type CRA currently supported only" ); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! confirmParameter( m_QP < -6 * (m_internalBitDepth[CH_L] - 8) || m_QP > MAX_QP, "QP exceeds supported range (-QpBDOffsety to 63)" ); for( int comp = 0; comp < 3; comp++) { @@ -494,39 +400,66 @@ bool EncCfg::initCfgParameter() confirmParameter( m_ensureWppBitEqual<0 || m_ensureWppBitEqual>1, "WppBitEqual out of range"); confirmParameter( m_numWppThreads && m_ensureWppBitEqual == 0, "NumWppThreads > 0 requires WppBitEqual > 0"); - if (!m_lumaReshapeEnable) - { - m_reshapeSignalType = RESHAPE_SIGNAL_NULL; -// m_intraCMD = 0; - } - if (m_lumaReshapeEnable && m_reshapeSignalType == RESHAPE_SIGNAL_PQ) - { -// m_intraCMD = 1; - } - else if (m_lumaReshapeEnable && (m_reshapeSignalType == RESHAPE_SIGNAL_SDR || m_reshapeSignalType == RESHAPE_SIGNAL_HLG)) - { -// m_intraCMD = 0; - } - else - { - m_lumaReshapeEnable = false; - } if (m_lumaReshapeEnable) { - confirmParameter(m_updateCtrl < 0, "Min. LMCS Update Control is 0"); - confirmParameter(m_updateCtrl > 2, "Max. LMCS Update Control is 2"); - confirmParameter(m_adpOption < 0, "Min. LMCS Adaptation Option is 0"); - confirmParameter(m_adpOption > 4, "Max. LMCS Adaptation Option is 4"); - confirmParameter(m_initialCW < 0, "Min. Initial Total Codeword is 0"); - confirmParameter(m_initialCW > 1023, "Max. Initial Total Codeword is 1023"); + confirmParameter( m_reshapeSignalType < RESHAPE_SIGNAL_SDR || m_reshapeSignalType > RESHAPE_SIGNAL_HLG, "LMCSSignalType out of range" ); + confirmParameter(m_updateCtrl < 0, "Min. LMCS Update Control is 0"); + confirmParameter(m_updateCtrl > 2, "Max. LMCS Update Control is 2"); + confirmParameter(m_adpOption < 0, "Min. LMCS Adaptation Option is 0"); + confirmParameter(m_adpOption > 4, "Max. LMCS Adaptation Option is 4"); + confirmParameter(m_initialCW < 0, "Min. Initial Total Codeword is 0"); + confirmParameter(m_initialCW > 1023, "Max. Initial Total Codeword is 1023"); + confirmParameter(m_LMCSOffset < -7, "Min. LMCS Offset value is -7"); + confirmParameter(m_LMCSOffset > 7, "Max. LMCS Offset value is 7"); if (m_updateCtrl > 0 && m_adpOption > 2) { m_adpOption -= 2; } } - confirmParameter( m_EDO && m_bLoopFilterDisable, "no EDO support with LoopFilter disabled" ); - - confirmParameter( m_chromaCbQpOffset < -12, "Min. Chroma Cb QP Offset is -12" ); - confirmParameter( m_chromaCbQpOffset > 12, "Max. Chroma Cb QP Offset is 12" ); - confirmParameter( m_chromaCrQpOffset < -12, "Min. Chroma Cr QP Offset is -12" ); - confirmParameter( m_chromaCrQpOffset > 12, "Max. Chroma Cr QP Offset is 12" ); + confirmParameter( m_EDO && m_bLoopFilterDisable, "no EDO support with LoopFilter disabled" ); + confirmParameter( m_EDO < 0 || m_EDO > 2, "EDO out of range [0..2]" ); + confirmParameter( m_TMVPModeId < 0 || m_TMVPModeId > 2, "TMVPMode out of range [0..2]" ); + confirmParameter( m_AMVRspeed < 0 || m_AMVRspeed > 7, "AMVR/IMV out of range [0..7]" ); + confirmParameter( m_Affine < 0 || m_Affine > 2, "Affine out of range [0..2]" ); + confirmParameter( m_MMVD < 0 || m_MMVD > 4, "MMVD out of range [0..4]" ); + confirmParameter( m_SMVD < 0 || m_SMVD > 3, "SMVD out of range [0..3]" ); + confirmParameter( m_Geo < 0 || m_Geo > 3, "Geo out of range [0..3]" ); + confirmParameter( m_CIIP < 0 || m_CIIP > 3, "CIIP out of range [0..3]" ); + confirmParameter( m_SBT < 0 || m_SBT > 3, "SBT out of range [0..3]" ); + confirmParameter( m_LFNST< 0 || m_LFNST> 3, "LFNST out of range [0..3]" ); + confirmParameter( m_MCTF < 0 || m_MCTF > 2, "MCTF out of range [0..2]" ); + confirmParameter( m_ISP < 0 || m_ISP > 3, "ISP out of range [0..3]" ); + confirmParameter(m_TS < 0 || m_TS > 2, "TS out of range [0..1]" ); + confirmParameter(m_TSsize < 2 || m_TSsize > 5, "TSsize out of range [0..1]" ); + confirmParameter(m_useBDPCM && m_TS==0, "BDPCM cannot be used when transform skip is disabled" ); + + if( m_alf ) + { + confirmParameter( m_maxNumAlfAlternativesChroma < 1 || m_maxNumAlfAlternativesChroma > MAX_NUM_ALF_ALTERNATIVES_CHROMA, std::string( std::string( "The maximum number of ALF Chroma filter alternatives must be in the range (1-" ) + std::to_string( MAX_NUM_ALF_ALTERNATIVES_CHROMA ) + std::string( ", inclusive)" ) ).c_str() ); + } + + confirmParameter( m_useFastMrg < 0 || m_useFastMrg > 2, "FastMrg out of range [0..2]" ); + confirmParameter( m_useFastMIP < 0 || m_useFastMIP > 4, "FastMIP out of range [0..4]" ); + confirmParameter( m_fastSubPel < 0 || m_fastSubPel > 1, "FastSubPel out of range [0..1]" ); + + + confirmParameter( m_RCRateControlMode != 0 && m_RCRateControlMode != 2, "Invalid rate control mode. Only the frame-level rate control is currently supported" ); + confirmParameter( m_RCRateControlMode == 1 && m_usePerceptQPA > 0, "CTU-level rate control cannot be combined with QPA" ); + confirmParameter( m_RCRateControlMode == 0 && m_RCNumPasses != 1, "Only single pass encoding supported, when rate control is disabled" ); + confirmParameter( m_RCNumPasses == 2 && m_usePerceptQPATempFiltISlice == true, "QPA temporal filtering of I slice not supported with 2-pass rate control" ); + confirmParameter( m_RCNumPasses < 1 || m_RCNumPasses > 2, "Only one pass or two pass encoding supported" ); + confirmParameter( m_verbosity < SILENT || m_verbosity > DETAILS, "verbosity is out of range[0..6]" ); + confirmParameter(!((m_level==Level::LEVEL1) + || (m_level==Level::LEVEL2) || (m_level==Level::LEVEL2_1) + || (m_level==Level::LEVEL3) || (m_level==Level::LEVEL3_1) + || (m_level==Level::LEVEL4) || (m_level==Level::LEVEL4_1) + || (m_level==Level::LEVEL5) || (m_level==Level::LEVEL5_1) || (m_level==Level::LEVEL5_2) + || (m_level==Level::LEVEL6) || (m_level==Level::LEVEL6_1) || (m_level==Level::LEVEL6_2) || (m_level==Level::LEVEL6_3) + || (m_level==Level::LEVEL15_5)), "invalid level selected"); + confirmParameter(!((m_levelTier==Level::Tier::MAIN) || (m_levelTier==Level::Tier::HIGH)), "invalid tier selected"); + + + confirmParameter( m_chromaCbQpOffset < -12, "Min. Chroma Cb QP Offset is -12" ); + confirmParameter( m_chromaCbQpOffset > 12, "Max. Chroma Cb QP Offset is 12" ); + confirmParameter( m_chromaCrQpOffset < -12, "Min. Chroma Cr QP Offset is -12" ); + confirmParameter( m_chromaCrQpOffset > 12, "Max. Chroma Cr QP Offset is 12" ); confirmParameter( m_chromaCbQpOffsetDualTree < -12, "Min. Chroma Cb QP Offset for dual tree is -12" ); confirmParameter( m_chromaCbQpOffsetDualTree > 12, "Max. Chroma Cb QP Offset for dual tree is 12" ); confirmParameter( m_chromaCrQpOffsetDualTree < -12, "Min. Chroma Cr QP Offset for dual tree is -12" ); @@ -563,7 +496,7 @@ bool EncCfg::initCfgParameter() { m_cuQpDeltaSubdiv = 2; } - if ((m_usePerceptQPA == 2 || m_usePerceptQPA == 4) && (m_internChromaFormat != CHROMA_400) && (m_sliceChromaQpOffsetPeriodicity == 0)) + if (m_usePerceptQPA >= 1 && m_internChromaFormat != CHROMA_400 && m_sliceChromaQpOffsetPeriodicity == 0) { m_sliceChromaQpOffsetPeriodicity = 1; } @@ -593,9 +526,6 @@ bool EncCfg::initCfgParameter() confirmParameter( m_log2MaxTbSize > 6, "Log2MaxTbSize must be 6 or smaller." ); confirmParameter( m_log2MaxTbSize < 5, "Log2MaxTbSize must be 5 or greater." ); - bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 ); - confirmParameter( tileFlag && m_entropyCodingSyncEnabled, "Tiles and entropy-coding-sync (Wavefronts) can not be applied together, except in the High Throughput Intra 4:4:4 16 profile"); - confirmParameter( m_SourceWidth % SPS::getWinUnitX(m_internChromaFormat) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); confirmParameter( m_SourceHeight % SPS::getWinUnitY(m_internChromaFormat) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); @@ -614,6 +544,22 @@ bool EncCfg::initCfgParameter() #if ENABLE_TRACING confirmParameter( m_frameParallel && ( m_numFppThreads != 0 && m_numFppThreads != 1 ) && ! m_traceFile.empty(), "Tracing and frame parallel encoding not supported" ); #endif + confirmParameter(((m_SourceWidth) & 7) != 0, "internal picture width must be a multiple of 8 - check cropping options"); + confirmParameter(((m_SourceHeight) & 7) != 0, "internal picture height must be a multiple of 8 - check cropping options"); + + + confirmParameter( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); + confirmParameter( m_maxNumMergeCand > MRG_MAX_NUM_CANDS, "MaxNumMergeCand must be no more than MRG_MAX_NUM_CANDS." ); + confirmParameter( m_maxNumGeoCand > GEO_MAX_NUM_UNI_CANDS, "MaxNumGeoCand must be no more than GEO_MAX_NUM_UNI_CANDS." ); + confirmParameter( m_maxNumGeoCand > m_maxNumMergeCand, "MaxNumGeoCand must be no more than MaxNumMergeCand." ); + confirmParameter( 0 < m_maxNumGeoCand && m_maxNumGeoCand < 2, "MaxNumGeoCand must be no less than 2 unless MaxNumGeoCand is 0." ); + confirmParameter( m_maxNumAffineMergeCand < (m_SbTMVP ? 1 : 0), "MaxNumAffineMergeCand must be greater than 0 when SbTMVP is enabled"); + confirmParameter( m_maxNumAffineMergeCand > AFFINE_MRG_MAX_NUM_CANDS, "MaxNumAffineMergeCand must be no more than AFFINE_MRG_MAX_NUM_CANDS." ); + + + confirmParameter( m_hrdParametersPresent && (0 == m_RCRateControlMode), "HrdParametersPresent requires RateControl enabled"); + confirmParameter( m_bufferingPeriodSEIEnabled && !m_hrdParametersPresent, "BufferingPeriodSEI requires HrdParametersPresent enabled"); + confirmParameter( m_pictureTimingSEIEnabled && !m_hrdParametersPresent, "PictureTimingSEI requires HrdParametersPresent enabled"); // max CU width and height should be power of 2 uint32_t ui = m_CTUSize; @@ -765,16 +711,16 @@ bool EncCfg::initCfgParameter() m_GOPList[i].m_numRefPics[0] = 2; m_GOPList[i].m_numRefPics[1] = 2; } - m_GOPList[0].m_POC = 32; m_GOPList[0].m_temporalId = 0; - m_GOPList[1].m_POC = 16; m_GOPList[1].m_temporalId = 1; - m_GOPList[2].m_POC = 8; m_GOPList[2].m_temporalId = 2; - m_GOPList[3].m_POC = 4; m_GOPList[3].m_temporalId = 3; - m_GOPList[4].m_POC = 2; m_GOPList[4].m_temporalId = 4; - m_GOPList[5].m_POC = 1; m_GOPList[5].m_temporalId = 5; - m_GOPList[6].m_POC = 3; m_GOPList[6].m_temporalId = 5; - m_GOPList[7].m_POC = 6; m_GOPList[7].m_temporalId = 4; - m_GOPList[8].m_POC = 5; m_GOPList[8].m_temporalId = 5; - m_GOPList[9].m_POC = 7; m_GOPList[9].m_temporalId = 5; + m_GOPList[ 0].m_POC = 32; m_GOPList[0].m_temporalId = 0; + m_GOPList[ 1].m_POC = 16; m_GOPList[1].m_temporalId = 1; + m_GOPList[ 2].m_POC = 8; m_GOPList[2].m_temporalId = 2; + m_GOPList[ 3].m_POC = 4; m_GOPList[3].m_temporalId = 3; + m_GOPList[ 4].m_POC = 2; m_GOPList[4].m_temporalId = 4; + m_GOPList[ 5].m_POC = 1; m_GOPList[5].m_temporalId = 5; + m_GOPList[ 6].m_POC = 3; m_GOPList[6].m_temporalId = 5; + m_GOPList[ 7].m_POC = 6; m_GOPList[7].m_temporalId = 4; + m_GOPList[ 8].m_POC = 5; m_GOPList[8].m_temporalId = 5; + m_GOPList[ 9].m_POC = 7; m_GOPList[9].m_temporalId = 5; m_GOPList[10].m_POC = 12; m_GOPList[10].m_temporalId = 3; m_GOPList[11].m_POC = 10; m_GOPList[11].m_temporalId = 4; m_GOPList[12].m_POC = 9; m_GOPList[12].m_temporalId = 5; @@ -782,29 +728,45 @@ bool EncCfg::initCfgParameter() m_GOPList[14].m_POC = 14; m_GOPList[14].m_temporalId = 4; m_GOPList[15].m_POC = 13; m_GOPList[15].m_temporalId = 5; - m_GOPList[16].m_POC = 15; m_GOPList[16].m_temporalId = 5; - m_GOPList[17].m_POC = 24; m_GOPList[17].m_temporalId = 2; - m_GOPList[18].m_POC = 20; m_GOPList[18].m_temporalId = 3; - m_GOPList[19].m_POC = 18; m_GOPList[19].m_temporalId = 4; - m_GOPList[20].m_POC = 17; m_GOPList[20].m_temporalId = 5; - m_GOPList[21].m_POC = 19; m_GOPList[21].m_temporalId = 5; - m_GOPList[22].m_POC = 22; m_GOPList[22].m_temporalId = 4; - m_GOPList[23].m_POC = 21; m_GOPList[23].m_temporalId = 5; - m_GOPList[24].m_POC = 23; m_GOPList[24].m_temporalId = 5; - m_GOPList[25].m_POC = 28; m_GOPList[25].m_temporalId = 3; - m_GOPList[26].m_POC = 26; m_GOPList[26].m_temporalId = 4; - m_GOPList[27].m_POC = 25; m_GOPList[27].m_temporalId = 5; - m_GOPList[28].m_POC = 27; m_GOPList[28].m_temporalId = 5; - m_GOPList[29].m_POC = 30; m_GOPList[29].m_temporalId = 4; - m_GOPList[30].m_POC = 29; m_GOPList[30].m_temporalId = 5; - m_GOPList[31].m_POC = 31; m_GOPList[31].m_temporalId = 5; - - m_GOPList[0].m_numRefPics[0] = 3; - m_GOPList[9].m_numRefPics[0] = 3; + m_GOPList[16].m_POC = 15; m_GOPList[16].m_temporalId = 5; + m_GOPList[17].m_POC = 24; m_GOPList[17].m_temporalId = 2; + m_GOPList[18].m_POC = 20; m_GOPList[18].m_temporalId = 3; + m_GOPList[19].m_POC = 18; m_GOPList[19].m_temporalId = 4; + m_GOPList[20].m_POC = 17; m_GOPList[20].m_temporalId = 5; + m_GOPList[21].m_POC = 19; m_GOPList[21].m_temporalId = 5; + m_GOPList[22].m_POC = 22; m_GOPList[22].m_temporalId = 4; + m_GOPList[23].m_POC = 21; m_GOPList[23].m_temporalId = 5; + m_GOPList[24].m_POC = 23; m_GOPList[24].m_temporalId = 5; + m_GOPList[25].m_POC = 28; m_GOPList[25].m_temporalId = 3; + m_GOPList[26].m_POC = 26; m_GOPList[26].m_temporalId = 4; + m_GOPList[27].m_POC = 25; m_GOPList[27].m_temporalId = 5; + m_GOPList[28].m_POC = 27; m_GOPList[28].m_temporalId = 5; + m_GOPList[29].m_POC = 30; m_GOPList[29].m_temporalId = 4; + m_GOPList[30].m_POC = 29; m_GOPList[30].m_temporalId = 5; + m_GOPList[31].m_POC = 31; m_GOPList[31].m_temporalId = 5; + + m_GOPList[ 0].m_numRefPics[0] = 3; + m_GOPList[ 1].m_numRefPics[0] = 2; + m_GOPList[ 2].m_numRefPics[0] = 2; + m_GOPList[ 3].m_numRefPics[0] = 2; + m_GOPList[ 4].m_numRefPics[0] = 2; + m_GOPList[ 5].m_numRefPics[0] = 2; + m_GOPList[ 6].m_numRefPics[0] = 2; + m_GOPList[ 7].m_numRefPics[0] = 2; + m_GOPList[ 8].m_numRefPics[0] = 2; + m_GOPList[ 9].m_numRefPics[0] = 3; + m_GOPList[10].m_numRefPics[0] = 2; + m_GOPList[11].m_numRefPics[0] = 2; + m_GOPList[12].m_numRefPics[0] = 2; m_GOPList[13].m_numRefPics[0] = 3; m_GOPList[14].m_numRefPics[0] = 3; m_GOPList[15].m_numRefPics[0] = 3; + m_GOPList[16].m_numRefPics[0] = 4; + m_GOPList[17].m_numRefPics[0] = 2; + m_GOPList[18].m_numRefPics[0] = 2; + m_GOPList[19].m_numRefPics[0] = 2; + m_GOPList[20].m_numRefPics[0] = 2; m_GOPList[21].m_numRefPics[0] = 3; m_GOPList[22].m_numRefPics[0] = 3; m_GOPList[23].m_numRefPics[0] = 3; @@ -817,35 +779,35 @@ bool EncCfg::initCfgParameter() m_GOPList[30].m_numRefPics[0] = 3; m_GOPList[31].m_numRefPics[0] = 4; - m_GOPList[0].m_deltaRefPics[0][0] = 32; m_GOPList[0].m_deltaRefPics[0][1] = 48; m_GOPList[0].m_deltaRefPics[0][2] = 64; - m_GOPList[1].m_deltaRefPics[0][0] = 16; m_GOPList[1].m_deltaRefPics[0][1] = 32; - m_GOPList[2].m_deltaRefPics[0][0] = 8; m_GOPList[2].m_deltaRefPics[0][1] = 24; - m_GOPList[3].m_deltaRefPics[0][0] = 4; m_GOPList[3].m_deltaRefPics[0][1] = 20; + m_GOPList[ 0].m_deltaRefPics[0][0] = 32; m_GOPList[ 0].m_deltaRefPics[0][1] = 64; m_GOPList[ 0].m_deltaRefPics[0][2] = 48; //th swapped order of ref-pic 1 and 2 + m_GOPList[ 1].m_deltaRefPics[0][0] = 16; m_GOPList[ 1].m_deltaRefPics[0][1] = 32; + m_GOPList[ 2].m_deltaRefPics[0][0] = 8; m_GOPList[ 2].m_deltaRefPics[0][1] = 24; + m_GOPList[ 3].m_deltaRefPics[0][0] = 4; m_GOPList[ 3].m_deltaRefPics[0][1] = 20; - m_GOPList[4].m_deltaRefPics[0][0] = 2; m_GOPList[4].m_deltaRefPics[0][1] = 18; - m_GOPList[5].m_deltaRefPics[0][0] = 1; m_GOPList[5].m_deltaRefPics[0][1] = -1; - m_GOPList[6].m_deltaRefPics[0][0] = 1; m_GOPList[6].m_deltaRefPics[0][1] = 3; - m_GOPList[7].m_deltaRefPics[0][0] = 2; m_GOPList[7].m_deltaRefPics[0][1] = 6; + m_GOPList[ 4].m_deltaRefPics[0][0] = 2; m_GOPList[ 4].m_deltaRefPics[0][1] = 18; + m_GOPList[ 5].m_deltaRefPics[0][0] = 1; m_GOPList[ 5].m_deltaRefPics[0][1] = -1; + m_GOPList[ 6].m_deltaRefPics[0][0] = 1; m_GOPList[ 6].m_deltaRefPics[0][1] = 3; + m_GOPList[ 7].m_deltaRefPics[0][0] = 2; m_GOPList[ 7].m_deltaRefPics[0][1] = 6; - m_GOPList[8].m_deltaRefPics[0][0] = 1; m_GOPList[8].m_deltaRefPics[0][1] = 5; - m_GOPList[9].m_deltaRefPics[0][0] = 1; m_GOPList[9].m_deltaRefPics[0][1] = 3; m_GOPList[9].m_deltaRefPics[0][2] = 7; + m_GOPList[ 8].m_deltaRefPics[0][0] = 1; m_GOPList[ 8].m_deltaRefPics[0][1] = 5; + m_GOPList[ 9].m_deltaRefPics[0][0] = 1; m_GOPList[ 9].m_deltaRefPics[0][1] = 3; m_GOPList[ 9].m_deltaRefPics[0][2] = 7; m_GOPList[10].m_deltaRefPics[0][0] = 4; m_GOPList[10].m_deltaRefPics[0][1] = 12; m_GOPList[11].m_deltaRefPics[0][0] = 2; m_GOPList[11].m_deltaRefPics[0][1] = 10; - m_GOPList[12].m_deltaRefPics[0][0] = 1; m_GOPList[12].m_deltaRefPics[0][1] = 9; - m_GOPList[13].m_deltaRefPics[0][0] = 1; m_GOPList[13].m_deltaRefPics[0][1] = 3; m_GOPList[13].m_deltaRefPics[0][2] = 11; - m_GOPList[14].m_deltaRefPics[0][0] = 2; m_GOPList[14].m_deltaRefPics[0][1] = 6; m_GOPList[14].m_deltaRefPics[0][2] = 14; - m_GOPList[15].m_deltaRefPics[0][0] = 1; m_GOPList[15].m_deltaRefPics[0][1] = 5; m_GOPList[15].m_deltaRefPics[0][2] = 13; + m_GOPList[12].m_deltaRefPics[0][0] = 1; m_GOPList[12].m_deltaRefPics[0][1] = 9; + m_GOPList[13].m_deltaRefPics[0][0] = 1; m_GOPList[13].m_deltaRefPics[0][1] = 3; m_GOPList[13].m_deltaRefPics[0][2] = 11; + m_GOPList[14].m_deltaRefPics[0][0] = 2; m_GOPList[14].m_deltaRefPics[0][1] = 6; m_GOPList[14].m_deltaRefPics[0][2] = 14; + m_GOPList[15].m_deltaRefPics[0][0] = 1; m_GOPList[15].m_deltaRefPics[0][1] = 5; m_GOPList[15].m_deltaRefPics[0][2] = 13; - m_GOPList[16].m_deltaRefPics[0][0] = 1; m_GOPList[16].m_deltaRefPics[0][1] = 3; m_GOPList[16].m_deltaRefPics[0][2] = 7; m_GOPList[16].m_deltaRefPics[0][3] = 15; + m_GOPList[16].m_deltaRefPics[0][0] = 1; m_GOPList[16].m_deltaRefPics[0][1] = 3; m_GOPList[16].m_deltaRefPics[0][2] = 7; m_GOPList[16].m_deltaRefPics[0][3] = 15; m_GOPList[17].m_deltaRefPics[0][0] = 8; m_GOPList[17].m_deltaRefPics[0][1] = 24; m_GOPList[18].m_deltaRefPics[0][0] = 4; m_GOPList[18].m_deltaRefPics[0][1] = 20; m_GOPList[19].m_deltaRefPics[0][0] = 2; m_GOPList[19].m_deltaRefPics[0][1] = 18; m_GOPList[20].m_deltaRefPics[0][0] = 1; m_GOPList[20].m_deltaRefPics[0][1] = 17; - m_GOPList[21].m_deltaRefPics[0][0] = 1; m_GOPList[21].m_deltaRefPics[0][1] = 3; m_GOPList[21].m_deltaRefPics[0][2] = 19; - m_GOPList[22].m_deltaRefPics[0][0] = 2; m_GOPList[22].m_deltaRefPics[0][1] = 6; m_GOPList[22].m_deltaRefPics[0][2] = 22; - m_GOPList[23].m_deltaRefPics[0][0] = 1; m_GOPList[23].m_deltaRefPics[0][1] = 5; m_GOPList[23].m_deltaRefPics[0][2] = 21; + m_GOPList[21].m_deltaRefPics[0][0] = 1; m_GOPList[21].m_deltaRefPics[0][1] = 3; m_GOPList[21].m_deltaRefPics[0][2] = 19; + m_GOPList[22].m_deltaRefPics[0][0] = 2; m_GOPList[22].m_deltaRefPics[0][1] = 6; m_GOPList[22].m_deltaRefPics[0][2] = 22; + m_GOPList[23].m_deltaRefPics[0][0] = 1; m_GOPList[23].m_deltaRefPics[0][1] = 5; m_GOPList[23].m_deltaRefPics[0][2] = 21; m_GOPList[24].m_deltaRefPics[0][0] = 1; m_GOPList[24].m_deltaRefPics[0][1] = 3; m_GOPList[24].m_deltaRefPics[0][2] = 7; m_GOPList[24].m_deltaRefPics[0][3] = 23; m_GOPList[25].m_deltaRefPics[0][0] = 4; m_GOPList[25].m_deltaRefPics[0][1] = 12; m_GOPList[25].m_deltaRefPics[0][2] = 28; @@ -857,68 +819,79 @@ bool EncCfg::initCfgParameter() m_GOPList[30].m_deltaRefPics[0][0] = 1; m_GOPList[30].m_deltaRefPics[0][1] = 13; m_GOPList[30].m_deltaRefPics[0][2] = 29; m_GOPList[31].m_deltaRefPics[0][0] = 1; m_GOPList[31].m_deltaRefPics[0][1] = 3; m_GOPList[31].m_deltaRefPics[0][2] = 15; m_GOPList[31].m_deltaRefPics[0][3] = 31; - m_GOPList[3].m_numRefPics[1] = 3; - m_GOPList[4].m_numRefPics[1] = 4; - m_GOPList[5].m_numRefPics[1] = 5; - m_GOPList[6].m_numRefPics[1] = 4; - m_GOPList[7].m_numRefPics[1] = 3; - - m_GOPList[8].m_numRefPics[1] = 4; - m_GOPList[9].m_numRefPics[1] = 3; + m_GOPList[ 0].m_numRefPics[1] = 2; + m_GOPList[ 1].m_numRefPics[1] = 2; + m_GOPList[ 2].m_numRefPics[1] = 2; + m_GOPList[ 3].m_numRefPics[1] = 3; + m_GOPList[ 4].m_numRefPics[1] = 4; + m_GOPList[ 5].m_numRefPics[1] = 5; + m_GOPList[ 6].m_numRefPics[1] = 4; + m_GOPList[ 7].m_numRefPics[1] = 3; + m_GOPList[ 8].m_numRefPics[1] = 4; + m_GOPList[ 9].m_numRefPics[1] = 3; m_GOPList[10].m_numRefPics[1] = 2; m_GOPList[11].m_numRefPics[1] = 3; - m_GOPList[12].m_numRefPics[1] = 4; m_GOPList[13].m_numRefPics[1] = 3; + m_GOPList[14].m_numRefPics[1] = 2; m_GOPList[15].m_numRefPics[1] = 3; + m_GOPList[16].m_numRefPics[1] = 2; + m_GOPList[17].m_numRefPics[1] = 2; + m_GOPList[18].m_numRefPics[1] = 2; m_GOPList[19].m_numRefPics[1] = 3; - m_GOPList[20].m_numRefPics[1] = 4; m_GOPList[21].m_numRefPics[1] = 3; + m_GOPList[22].m_numRefPics[1] = 2; m_GOPList[23].m_numRefPics[1] = 3; - + m_GOPList[24].m_numRefPics[1] = 2; + m_GOPList[25].m_numRefPics[1] = 2; + m_GOPList[26].m_numRefPics[1] = 2; m_GOPList[27].m_numRefPics[1] = 3; - - m_GOPList[0].m_deltaRefPics[1][0] = 32; m_GOPList[0].m_deltaRefPics[1][1] = 48; - m_GOPList[1].m_deltaRefPics[1][0] = -16; m_GOPList[1].m_deltaRefPics[1][1] = 16; - m_GOPList[2].m_deltaRefPics[1][0] = -8; m_GOPList[2].m_deltaRefPics[1][1] = -24; - m_GOPList[3].m_deltaRefPics[1][0] = -4; m_GOPList[3].m_deltaRefPics[1][1] = -12; m_GOPList[3].m_deltaRefPics[1][2] = -28; - - m_GOPList[4].m_deltaRefPics[1][0] = -2; m_GOPList[4].m_deltaRefPics[1][1] = -4; m_GOPList[4].m_deltaRefPics[1][2] = -14; m_GOPList[4].m_deltaRefPics[1][3] = -30; - m_GOPList[5].m_deltaRefPics[1][0] = -1; m_GOPList[5].m_deltaRefPics[1][1] = -3; m_GOPList[5].m_deltaRefPics[1][2] = -7; m_GOPList[5].m_deltaRefPics[1][3] = -15; m_GOPList[5].m_deltaRefPics[1][4] = -31; - m_GOPList[6].m_deltaRefPics[1][0] = -1; m_GOPList[6].m_deltaRefPics[1][1] = -5; m_GOPList[6].m_deltaRefPics[1][2] = -13; m_GOPList[6].m_deltaRefPics[1][3] = -29; - m_GOPList[7].m_deltaRefPics[1][0] = -2; m_GOPList[7].m_deltaRefPics[1][1] = -10; m_GOPList[7].m_deltaRefPics[1][2] = -26; - - m_GOPList[8].m_deltaRefPics[1][0] = -1; m_GOPList[8].m_deltaRefPics[1][1] = -3; m_GOPList[8].m_deltaRefPics[1][2] = -11; m_GOPList[8].m_deltaRefPics[1][3] = -27; - m_GOPList[9].m_deltaRefPics[1][0] = -1; m_GOPList[9].m_deltaRefPics[1][1] = -9; m_GOPList[9].m_deltaRefPics[1][2] = -25; - m_GOPList[10].m_deltaRefPics[1][0] = -4; m_GOPList[10].m_deltaRefPics[1][1] = -20; - m_GOPList[11].m_deltaRefPics[1][0] = -2; m_GOPList[11].m_deltaRefPics[1][1] = -6; m_GOPList[11].m_deltaRefPics[1][2] = -22; - - m_GOPList[12].m_deltaRefPics[1][0] = -1; m_GOPList[12].m_deltaRefPics[1][1] = -3; m_GOPList[12].m_deltaRefPics[1][2] = -7; m_GOPList[12].m_deltaRefPics[1][3] = -23; - m_GOPList[13].m_deltaRefPics[1][0] = -1; m_GOPList[13].m_deltaRefPics[1][1] = -5; m_GOPList[13].m_deltaRefPics[1][2] = -21; - m_GOPList[14].m_deltaRefPics[1][0] = -2; m_GOPList[14].m_deltaRefPics[1][1] = -18; - m_GOPList[15].m_deltaRefPics[1][0] = -1; m_GOPList[15].m_deltaRefPics[1][1] = -3; m_GOPList[15].m_deltaRefPics[1][2] = -19; - - m_GOPList[16].m_deltaRefPics[1][0] = -1; m_GOPList[16].m_deltaRefPics[1][1] = -17; - m_GOPList[17].m_deltaRefPics[1][0] = -8; m_GOPList[17].m_deltaRefPics[1][1] = 8; - m_GOPList[18].m_deltaRefPics[1][0] = -4; m_GOPList[18].m_deltaRefPics[1][1] = -12; - m_GOPList[19].m_deltaRefPics[1][0] = -2; m_GOPList[19].m_deltaRefPics[1][1] = -6; m_GOPList[19].m_deltaRefPics[1][2] = -14; - - m_GOPList[20].m_deltaRefPics[1][0] = -1; m_GOPList[20].m_deltaRefPics[1][1] = -3; m_GOPList[20].m_deltaRefPics[1][2] = -7; m_GOPList[20].m_deltaRefPics[1][3] = -15; - m_GOPList[21].m_deltaRefPics[1][0] = -1; m_GOPList[21].m_deltaRefPics[1][1] = -5; m_GOPList[21].m_deltaRefPics[1][2] = -13; - m_GOPList[22].m_deltaRefPics[1][0] = -2; m_GOPList[22].m_deltaRefPics[1][1] = -10; - m_GOPList[23].m_deltaRefPics[1][0] = -1; m_GOPList[23].m_deltaRefPics[1][1] = -3; m_GOPList[23].m_deltaRefPics[1][2] = -11; - - m_GOPList[24].m_deltaRefPics[1][0] = -1; m_GOPList[24].m_deltaRefPics[1][1] = -9; - m_GOPList[25].m_deltaRefPics[1][0] = -4; m_GOPList[25].m_deltaRefPics[1][1] = 4; - m_GOPList[26].m_deltaRefPics[1][0] = -2; m_GOPList[26].m_deltaRefPics[1][1] = -6; - m_GOPList[27].m_deltaRefPics[1][0] = -1; m_GOPList[27].m_deltaRefPics[1][1] = -3; m_GOPList[27].m_deltaRefPics[1][2] = -7; - - m_GOPList[28].m_deltaRefPics[1][0] = -1; m_GOPList[28].m_deltaRefPics[1][1] = -5; - m_GOPList[29].m_deltaRefPics[1][0] = -2; m_GOPList[29].m_deltaRefPics[1][1] = 2; - m_GOPList[30].m_deltaRefPics[1][0] = -1; m_GOPList[30].m_deltaRefPics[1][1] = -3; - m_GOPList[31].m_deltaRefPics[1][0] = -1; m_GOPList[31].m_deltaRefPics[1][1] = 1; + m_GOPList[28].m_numRefPics[1] = 2; + m_GOPList[29].m_numRefPics[1] = 2; + m_GOPList[30].m_numRefPics[1] = 2; + m_GOPList[31].m_numRefPics[1] = 2; + + m_GOPList[ 0].m_deltaRefPics[1][0] = 32; m_GOPList[ 0].m_deltaRefPics[1][1] = 64; //th48 + m_GOPList[ 1].m_deltaRefPics[1][0] = -16; m_GOPList[ 1].m_deltaRefPics[1][1] = 16; + m_GOPList[ 2].m_deltaRefPics[1][0] = -8; m_GOPList[ 2].m_deltaRefPics[1][1] = -24; + m_GOPList[ 3].m_deltaRefPics[1][0] = -4; m_GOPList[ 3].m_deltaRefPics[1][1] = -12; m_GOPList[ 3].m_deltaRefPics[1][2] = -28; + + m_GOPList[ 4].m_deltaRefPics[1][0] = -2; m_GOPList[ 4].m_deltaRefPics[1][1] = -6; m_GOPList[ 4].m_deltaRefPics[1][2] = -14; m_GOPList[ 4].m_deltaRefPics[1][3] = -30; + m_GOPList[ 5].m_deltaRefPics[1][0] = -1; m_GOPList[ 5].m_deltaRefPics[1][1] = -3; m_GOPList[ 5].m_deltaRefPics[1][2] = -7; m_GOPList[ 5].m_deltaRefPics[1][3] = -15; m_GOPList[5].m_deltaRefPics[1][4] = -31; + m_GOPList[ 6].m_deltaRefPics[1][0] = -1; m_GOPList[ 6].m_deltaRefPics[1][1] = -5; m_GOPList[ 6].m_deltaRefPics[1][2] = -13; m_GOPList[ 6].m_deltaRefPics[1][3] = -29; + m_GOPList[ 7].m_deltaRefPics[1][0] = -2; m_GOPList[ 7].m_deltaRefPics[1][1] = -10; m_GOPList[ 7].m_deltaRefPics[1][2] = -26; + + m_GOPList[ 8].m_deltaRefPics[1][0] = -1; m_GOPList[ 8].m_deltaRefPics[1][1] = -3; m_GOPList[ 8].m_deltaRefPics[1][2] = -11; m_GOPList[ 8].m_deltaRefPics[1][3] = -27; + m_GOPList[ 9].m_deltaRefPics[1][0] = -1; m_GOPList[ 9].m_deltaRefPics[1][1] = -9; m_GOPList[ 9].m_deltaRefPics[1][2] = -25; + m_GOPList[10].m_deltaRefPics[1][0] = -4; m_GOPList[10].m_deltaRefPics[1][1] = -20; + m_GOPList[11].m_deltaRefPics[1][0] = -2; m_GOPList[11].m_deltaRefPics[1][1] = -6; m_GOPList[11].m_deltaRefPics[1][2] = -22; + + m_GOPList[12].m_deltaRefPics[1][0] = -1; m_GOPList[12].m_deltaRefPics[1][1] = -3; m_GOPList[12].m_deltaRefPics[1][2] = -7; m_GOPList[12].m_deltaRefPics[1][3] = -23; + m_GOPList[13].m_deltaRefPics[1][0] = -1; m_GOPList[13].m_deltaRefPics[1][1] = -5; m_GOPList[13].m_deltaRefPics[1][2] = -21; + m_GOPList[14].m_deltaRefPics[1][0] = -2; m_GOPList[14].m_deltaRefPics[1][1] = -18; + m_GOPList[15].m_deltaRefPics[1][0] = -1; m_GOPList[15].m_deltaRefPics[1][1] = -3; m_GOPList[15].m_deltaRefPics[1][2] = -19; + + m_GOPList[16].m_deltaRefPics[1][0] = -1; m_GOPList[16].m_deltaRefPics[1][1] = -17; + m_GOPList[17].m_deltaRefPics[1][0] = -8; m_GOPList[17].m_deltaRefPics[1][1] = 8; + m_GOPList[18].m_deltaRefPics[1][0] = -4; m_GOPList[18].m_deltaRefPics[1][1] = -12; + m_GOPList[19].m_deltaRefPics[1][0] = -2; m_GOPList[19].m_deltaRefPics[1][1] = -6; m_GOPList[19].m_deltaRefPics[1][2] = -14; + + m_GOPList[20].m_deltaRefPics[1][0] = -1; m_GOPList[20].m_deltaRefPics[1][1] = -3; m_GOPList[20].m_deltaRefPics[1][2] = -7; m_GOPList[20].m_deltaRefPics[1][3] = -15; + m_GOPList[21].m_deltaRefPics[1][0] = -1; m_GOPList[21].m_deltaRefPics[1][1] = -5; m_GOPList[21].m_deltaRefPics[1][2] = -13; + m_GOPList[22].m_deltaRefPics[1][0] = -2; m_GOPList[22].m_deltaRefPics[1][1] = -10; + m_GOPList[23].m_deltaRefPics[1][0] = -1; m_GOPList[23].m_deltaRefPics[1][1] = -3; m_GOPList[23].m_deltaRefPics[1][2] = -11; + + m_GOPList[24].m_deltaRefPics[1][0] = -1; m_GOPList[24].m_deltaRefPics[1][1] = -9; + m_GOPList[25].m_deltaRefPics[1][0] = -4; m_GOPList[25].m_deltaRefPics[1][1] = 4; + m_GOPList[26].m_deltaRefPics[1][0] = -2; m_GOPList[26].m_deltaRefPics[1][1] = -6; + m_GOPList[27].m_deltaRefPics[1][0] = -1; m_GOPList[27].m_deltaRefPics[1][1] = -3; m_GOPList[27].m_deltaRefPics[1][2] = -7; + + m_GOPList[28].m_deltaRefPics[1][0] = -1; m_GOPList[28].m_deltaRefPics[1][1] = -5; + m_GOPList[29].m_deltaRefPics[1][0] = -2; m_GOPList[29].m_deltaRefPics[1][1] = 2; + m_GOPList[30].m_deltaRefPics[1][0] = -1; m_GOPList[30].m_deltaRefPics[1][1] = -3; + m_GOPList[31].m_deltaRefPics[1][0] = -1; m_GOPList[31].m_deltaRefPics[1][1] = 1; for( int i = 0; i < 32; i++ ) { @@ -932,8 +905,8 @@ bool EncCfg::initCfgParameter() m_GOPList[i].m_QPOffsetModelOffset = -4.9309; m_GOPList[i].m_QPOffsetModelScale = 0.2265; break; - case 2: m_GOPList[i].m_QPOffset = 1; - m_GOPList[i].m_QPOffsetModelOffset = -5.4095; + case 2: m_GOPList[i].m_QPOffset = 0; + m_GOPList[i].m_QPOffsetModelOffset = -4.5000; m_GOPList[i].m_QPOffsetModelScale = 0.2353; break; case 3: m_GOPList[i].m_QPOffset = 3; @@ -1280,7 +1253,7 @@ bool EncCfg::initCfgParameter() } for(int i=0; i m_numReorderPics[m_GOPList[i].m_temporalId]) + if(numReorder > m_maxNumReorderPics[m_GOPList[i].m_temporalId]) { - m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder; + m_maxNumReorderPics[m_GOPList[i].m_temporalId] = numReorder; } } for(int i=0; i m_maxDecPicBuffering[i] - 1) + if(m_maxNumReorderPics[i] > m_maxDecPicBuffering[i] - 1) { - m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1; + m_maxDecPicBuffering[i] = m_maxNumReorderPics[i] + 1; } // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i]) @@ -1342,38 +1315,9 @@ bool EncCfg::initCfgParameter() } // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive - if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1) - { - m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1; - } - - int iWidthInCU = ( m_SourceWidth%m_CTUSize ) ? m_SourceWidth/m_CTUSize + 1 : m_SourceWidth/m_CTUSize; - int iHeightInCU = ( m_SourceHeight%m_CTUSize ) ? m_SourceHeight/m_CTUSize + 1 : m_SourceHeight/m_CTUSize; - uint32_t uiCummulativeColumnWidth = 0; - uint32_t uiCummulativeRowHeight = 0; - - //check the column relative parameters - confirmParameter( m_numTileColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)), "The number of columns is larger than the maximum allowed number of columns." ); - confirmParameter( m_numTileColumnsMinus1 >= iWidthInCU, "The current picture can not have so many columns." ); - if( m_numTileColumnsMinus1 && !m_tileUniformSpacingFlag ) + if(m_maxNumReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1) { - for( int i=0; i= iWidthInCU, "The width of the column is too large." ); - } - - //check the row relative parameters - confirmParameter( m_numTileRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)), "The number of rows is larger than the maximum allowed number of rows." ); - confirmParameter( m_numTileRowsMinus1 >= iHeightInCU, "The current picture can not have so many rows." ); - if( m_numTileRowsMinus1 && !m_tileUniformSpacingFlag ) - { - for(int i=0; i= iHeightInCU, "The height of the row is too large." ); + m_maxDecPicBuffering[MAX_TLAYER-1] = m_maxNumReorderPics[MAX_TLAYER-1] + 1; } confirmParameter( m_MCTF > 2 || m_MCTF < 0, "MCTF out of range" ); @@ -1449,12 +1393,6 @@ bool EncCfg::initCfgParameter() m_numRPLList1++; } - int tilesCount = ( m_numTileRowsMinus1 + 1 ) * ( m_numTileColumnsMinus1 + 1 ); - if ( tilesCount == 1 ) - { - m_bLFCrossTileBoundaryFlag = true; - } - m_PROF &= bool(m_Affine); if (m_Affine > 1) { @@ -1478,6 +1416,9 @@ bool EncCfg::initCfgParameter() } } + /// Experimental settings + checkExperimental( m_RCRateControlMode != 0 && m_RCNumPasses == 2 && m_usePerceptQPA != 0, "2-pass rate control with perceptually optimized QP-adaptation is experimental!" ); + return( m_confirmFailed ); } @@ -1486,6 +1427,577 @@ void EncCfg::setCfgParameter( const EncCfg& encCfg ) *this = encCfg; } +int EncCfg::initPreset( PresetMode preset ) +{ + m_qpInValsCb.clear(); + m_qpInValsCb.push_back( 17 ); + m_qpInValsCb.push_back( 22 ); + m_qpInValsCb.push_back( 34 ); + m_qpInValsCb.push_back( 42 ); + m_qpOutValsCb.clear(); + m_qpOutValsCb.push_back( 17 ); + m_qpOutValsCb.push_back( 23 ); + m_qpOutValsCb.push_back( 35 ); + m_qpOutValsCb.push_back( 39 ); + + // basic settings + m_intraQPOffset = -3; + m_lambdaFromQPEnable = true; + m_MaxCodingDepth = 5; + m_log2DiffMaxMinCodingBlockSize = 5; + m_bUseASR = true; + m_bUseHADME = true; + m_useRDOQTS = true; + m_useSelectiveRDOQ = false; + m_cabacInitPresent = true; + m_fastQtBtEnc = true; + m_fastInterSearchMode = 1; + m_motionEstimationSearchMethod = 4; + m_SearchRange = 384; + m_minSearchWindow = 96; + m_maxNumMergeCand = 6; + m_TSsize = 3; + m_reshapeSignalType = 0; + m_updateCtrl = 0; + m_LMCSOffset = 6; + m_RDOQ = 1; + m_SignDataHidingEnabled = 0; + m_useFastLCTU = 1; + + // partitioning + m_dualITree = 1; + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 8; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 1; + m_maxMTTDepthI = 2; + m_maxMTTDepthIChroma = 2; + + // disable tools + m_Affine = 0; + m_alf = 0; + m_allowDisFracMMVD = 0; + m_useBDPCM = 0; + m_BDOF = 0; + m_ccalf = 0; + m_useChromaTS = 0; + m_CIIP = 0; + m_DepQuantEnabled = 0; + m_DMVR = 0; + m_EDO = 0; + m_Geo = 0; + m_AMVRspeed = 0; + m_ISP = 0; + m_JointCbCrMode = 0; + m_LFNST = 0; + m_LMChroma = 0; + m_lumaReshapeEnable = 0; + m_MCTF = 0; + m_MIP = 0; + m_MMVD = 0; + m_MRL = 0; + m_MTS = 0; + m_MTSImplicit = 0; + m_PROF = 0; + m_bUseSAO = 0; + m_SbTMVP = 0; + m_SBT = 0; + m_SMVD = 0; + m_TMVPModeId = 0; + m_TS = 0; + m_useNonLinearAlfChroma = 0; + m_useNonLinearAlfLuma = 0; + + // enable speedups + m_qtbttSpeedUp = 1; + m_contentBasedFastQtbt = 1; + m_usePbIntraFast = 1; + m_useFastMrg = 2; + m_useAMaxBT = 1; + m_useFastMIP = 4; + m_fastLocalDualTreeMode = 1; + m_fastSubPel = 1; + + switch( preset ) + { + case PresetMode::FIRSTPASS: + // Q44B11 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 32; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 1; + m_maxMTTDepthI = 1; + m_maxMTTDepthIChroma = 1; + + m_RDOQ = 2; + m_SignDataHidingEnabled = 1; + + m_useBDPCM = 1; + m_DMVR = 1; + m_LMChroma = 1; + m_MTSImplicit = 1; + m_bUseSAO = 1; + m_TMVPModeId = 1; + m_TS = 2; + break; + + case PresetMode::FASTER: + // Q44B11 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 32; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 1; + m_maxMTTDepthI = 1; + m_maxMTTDepthIChroma = 1; + + m_RDOQ = 2; + m_SignDataHidingEnabled = 1; + + m_useBDPCM = 1; + m_DMVR = 1; + m_LMChroma = 1; + m_MTSImplicit = 1; + m_bUseSAO = 1; + m_TMVPModeId = 1; + m_TS = 2; + break; + + case PresetMode::FAST: + // Q43B11 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 16; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 1; + m_maxMTTDepthI = 1; + m_maxMTTDepthIChroma = 1; + + m_RDOQ = 2; + m_SignDataHidingEnabled = 1; + + m_alf = 1; + m_ccalf = 1; + m_useBDPCM = 1; + m_DMVR = 1; + m_LMChroma = 1; + m_MCTF = 2; + m_MTSImplicit = 1; + m_bUseSAO = 1; + m_TMVPModeId = 1; + m_TS = 2; + break; + + case PresetMode::MEDIUM: + // Q44B21 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 8; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 1; + m_maxMTTDepthI = 2; + m_maxMTTDepthIChroma = 2; + + m_Affine = 2; + m_alf = 1; + m_allowDisFracMMVD = 1; + m_useBDPCM = 1; + m_BDOF = 1; + m_ccalf = 1; + m_DepQuantEnabled = 1; + m_DMVR = 1; + m_EDO = 2; + m_Geo = 3; + m_AMVRspeed = 5; + m_JointCbCrMode = 1; + m_LFNST = 1; + m_LMChroma = 1; + m_lumaReshapeEnable = 1; + m_MCTF = 2; + m_MIP = 1; + m_MMVD = 3; + m_MRL = 1; + m_MTSImplicit = 1; + m_PROF = 1; + m_bUseSAO = 1; + m_SbTMVP = 1; + m_SMVD = 3; + m_TMVPModeId = 1; + m_TS = 2; + break; + + case PresetMode::SLOW: + // Q44B32 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 8; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 2; + m_maxMTTDepthI = 3; + m_maxMTTDepthIChroma = 3; + + m_Affine = 2; + m_alf = 1; + m_allowDisFracMMVD = 1; + m_useBDPCM = 1; + m_BDOF = 1; + m_ccalf = 1; + m_DepQuantEnabled = 1; + m_CIIP = 1; + m_DMVR = 1; + m_EDO = 2; + m_Geo = 1; + m_AMVRspeed = 1; + m_ISP = 3; + m_JointCbCrMode = 1; + m_LFNST = 1; + m_LMChroma = 1; + m_lumaReshapeEnable = 1; + m_MCTF = 2; + m_MIP = 1; + m_MMVD = 3; + m_MRL = 1; + m_MTSImplicit = 1; + m_PROF = 1; + m_bUseSAO = 1; + m_SbTMVP = 1; + m_SBT = 1; + m_SMVD = 3; + m_TMVPModeId = 1; + m_TS = 2; + + m_contentBasedFastQtbt = 0; + break; + + case PresetMode::SLOWER: + + m_motionEstimationSearchMethod = 1; + + // Q44B33 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 8; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 3; + m_maxMTTDepthI = 3; + m_maxMTTDepthIChroma = 3; + + m_Affine = 1; + m_alf = 1; + m_allowDisFracMMVD = 1; + m_useBDPCM = 1; + m_BDOF = 1; + m_ccalf = 1; + m_DepQuantEnabled = 1; + m_CIIP = 1; + m_DMVR = 1; + m_EDO = 2; + m_Geo = 1; + m_AMVRspeed = 1; + m_ISP = 1; + m_JointCbCrMode = 1; + m_LFNST = 1; + m_LMChroma = 1; + m_lumaReshapeEnable = 1; + m_MCTF = 2; + m_MIP = 1; + m_MMVD = 1; + m_MRL = 1; + m_MTS = 1; + m_MTSImplicit = 0; + m_PROF = 1; + m_bUseSAO = 1; + m_SbTMVP = 1; + m_SBT = 1; + m_SMVD = 1; + m_TMVPModeId = 1; + m_TS = 2; + m_useNonLinearAlfChroma = 1; + m_useNonLinearAlfLuma = 1; + + m_qtbttSpeedUp = 0; + m_contentBasedFastQtbt = 0; + m_useFastMrg = 1; + m_useFastMIP = 0; + m_fastSubPel = 0; + break; + + case PresetMode::TOOLTEST: + // Q44B21 + m_MinQT[ 0 ] = 8; + m_MinQT[ 1 ] = 8; + m_MinQT[ 2 ] = 4; + m_maxMTTDepth = 1; + m_maxMTTDepthI = 2; + m_maxMTTDepthIChroma = 2; + + m_Affine = 2; + m_alf = 1; + m_allowDisFracMMVD = 1; + m_useBDPCM = 1; + m_BDOF = 1; + m_ccalf = 1; + m_DepQuantEnabled = 1; + m_CIIP = 3; + m_DMVR = 1; + m_EDO = 1; + m_Geo = 2; + m_AMVRspeed = 3; + m_ISP = 2; + m_JointCbCrMode = 1; + m_LFNST = 1; + m_LMChroma = 1; + m_lumaReshapeEnable = 1; + m_MCTF = 2; + m_MIP = 1; + m_MMVD = 2; + m_MRL = 1; + m_MTS = 1; + m_PROF = 1; + m_bUseSAO = 1; + m_SbTMVP = 1; + m_SBT = 2; + m_SMVD = 3; + m_TMVPModeId = 1; + m_TS = 1; + m_useNonLinearAlfChroma = 1; + m_useNonLinearAlfLuma = 1; + break; + + default: + return -1; + } + + return 0; +} + +static inline std::string getProfileStr( int profile ) +{ + std::string cT; + switch( profile ) + { + case Profile::NONE : cT = "none"; break; + case Profile::MAIN_10 : cT = "main_10"; break; + case Profile::MAIN_10_STILL_PICTURE : cT = "main_10_still_picture"; break; + case Profile::MAIN_10_444 : cT = "main_10_444"; break; + case Profile::MAIN_10_444_STILL_PICTURE : cT = "main_10_444_still_picture"; break; + case Profile::MULTILAYER_MAIN_10 : cT = "multilayer_main_10"; break; + case Profile::MULTILAYER_MAIN_10_STILL_PICTURE : cT = "multilayer_main_10_still_picture"; break; + case Profile::MULTILAYER_MAIN_10_444 : cT = "multilayer_main_10_444"; break; + case Profile::MULTILAYER_MAIN_10_444_STILL_PICTURE : cT = "multilayer_main_10_444_still_picture"; break; + case Profile::AUTO : cT = "auto"; break; + default : cT = "unknown"; break; + } + return cT; +} + +static inline std::string getLevelStr( int level ) +{ + std::string cT; + switch( level ) + { + case Level::NONE : cT = "none"; break; + case Level::LEVEL1 : cT = "1"; break; + case Level::LEVEL2 : cT = "2"; break; + case Level::LEVEL2_1 : cT = "2.1"; break; + case Level::LEVEL3 : cT = "3"; break; + case Level::LEVEL3_1 : cT = "3.1"; break; + case Level::LEVEL4 : cT = "4"; break; + case Level::LEVEL4_1 : cT = "4.1"; break; + case Level::LEVEL5 : cT = "5"; break; + case Level::LEVEL5_1 : cT = "5.1"; break; + case Level::LEVEL5_2 : cT = "5.2"; break; + case Level::LEVEL6 : cT = "6"; break; + case Level::LEVEL6_1 : cT = "6.1"; break; + case Level::LEVEL6_2 : cT = "6.2"; break; + case Level::LEVEL6_3 : cT = "6.3"; break; + case Level::LEVEL15_5 : cT = "15.5"; break; + default : cT = "unknown"; break; + } + return cT; +} + +static inline std::string getCostFunctionStr( int cost ) +{ + std::string cT; + switch( cost ) + { + case COST_STANDARD_LOSSY : cT = "Lossy coding"; break; + case COST_SEQUENCE_LEVEL_LOSSLESS : cT = "Sequence level lossless coding"; break; + case COST_LOSSLESS_CODING : cT = "Lossless coding"; break; + case COST_MIXED_LOSSLESS_LOSSY_CODING : cT = "Mixed lossless lossy coding"; break; + default : cT = "Unknown"; break; + } + return cT; +} + +void EncCfg::printCfg() const +{ + msg( DETAILS, "Real Format : %dx%d %gHz\n", m_SourceWidth - m_confWinLeft - m_confWinRight, m_SourceHeight - m_confWinTop - m_confWinBottom, (double)m_FrameRate / m_temporalSubsampleRatio ); + msg( DETAILS, "Internal Format : %dx%d %gHz\n", m_SourceWidth, m_SourceHeight, (double)m_FrameRate / m_temporalSubsampleRatio ); + msg( DETAILS, "Sequence PSNR output : %s\n", m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only" ); + msg( DETAILS, "Hexadecimal PSNR output : %s\n", m_printHexPsnr ? "Enabled" : "Disabled" ); + msg( DETAILS, "Sequence MSE output : %s\n", m_printSequenceMSE ? "Enabled" : "Disabled" ); + msg( DETAILS, "Frame MSE output : %s\n", m_printFrameMSE ? "Enabled" : "Disabled" ); + msg( DETAILS, "Cabac-zero-word-padding : %s\n", m_cabacZeroWordPaddingEnabled ? "Enabled" : "Disabled" ); + msg( DETAILS, "Frame/Field : Frame based coding\n" ); + if ( m_framesToBeEncoded > 0 ) + msg( DETAILS, "Frame index : %d frames\n", m_framesToBeEncoded ); + else + msg( DETAILS, "Frame index : all frames\n" ); + msg( DETAILS, "Profile : %s\n", getProfileStr( m_profile ).c_str() ); + msg( DETAILS, "Level : %s\n", getLevelStr( m_level ).c_str() ); + msg( DETAILS, "CU size / total-depth : %d / %d\n", m_CTUSize, m_MaxCodingDepth ); + msg( DETAILS, "Max TB size : %d\n", 1 << m_log2MaxTbSize ); + msg( DETAILS, "Motion search range : %d\n", m_SearchRange ); + msg( DETAILS, "Intra period : %d\n", m_IntraPeriod ); + msg( DETAILS, "Decoding refresh type : %d\n", m_DecodingRefreshType ); + msg( DETAILS, "QP : %d\n", m_QP); + msg( DETAILS, "Percept QPA : %d\n", m_usePerceptQPA ); + msg( DETAILS, "Max dQP signaling subdiv : %d\n", m_cuQpDeltaSubdiv); + msg( DETAILS, "Cb QP Offset (dual tree) : %d (%d)\n", m_chromaCbQpOffset, m_chromaCbQpOffsetDualTree ); + msg( DETAILS, "Cr QP Offset (dual tree) : %d (%d)\n", m_chromaCrQpOffset, m_chromaCrQpOffsetDualTree ); + msg( DETAILS, "GOP size : %d\n", m_GOPSize ); + msg( DETAILS, "Input queue size : %d\n", m_InputQueueSize ); + msg( DETAILS, "Input bit depth : (Y:%d, C:%d)\n", m_inputBitDepth[ CH_L ], m_inputBitDepth[ CH_C ] ); + msg( DETAILS, "MSB-extended bit depth : (Y:%d, C:%d)\n", m_MSBExtendedBitDepth[ CH_L ], m_MSBExtendedBitDepth[ CH_C ] ); + msg( DETAILS, "Internal bit depth : (Y:%d, C:%d)\n", m_internalBitDepth[ CH_L ], m_internalBitDepth[ CH_C ] ); + msg( DETAILS, "cu_chroma_qp_offset_subdiv : %d\n", m_cuChromaQpOffsetSubdiv ); + if (m_bUseSAO) + { + msg( DETAILS, "log2_sao_offset_scale_luma : %d\n", m_log2SaoOffsetScale[ CH_L ] ); + msg( DETAILS, "log2_sao_offset_scale_chroma : %d\n", m_log2SaoOffsetScale[ CH_C ] ); + } + msg( DETAILS, "Cost function: : %s\n", getCostFunctionStr( m_costMode ).c_str() ); + msg( DETAILS, "\n"); + + msg( VERBOSE, "CODING TOOL CFG: "); + msg( VERBOSE, "IBD:%d ", ((m_internalBitDepth[ CH_L ] > m_MSBExtendedBitDepth[ CH_L ]) || (m_internalBitDepth[ CH_C ] > m_MSBExtendedBitDepth[ CH_C ]))); + msg( VERBOSE, "CIP:%d ", m_bUseConstrainedIntraPred ); + msg( VERBOSE, "SAO:%d ", m_bUseSAO ? 1 : 0 ); + msg( VERBOSE, "ALF:%d ", m_alf ? 1 : 0 ); + if( m_alf ) + { + msg( VERBOSE, "(NonLinLuma:%d ", m_useNonLinearAlfLuma ); + msg( VERBOSE, "NonLinChr:%d) ", m_useNonLinearAlfChroma ); + } + msg( VERBOSE, "CCALF:%d ", m_ccalf ? 1 : 0 ); + + const int iWaveFrontSubstreams = m_entropyCodingSyncEnabled ? ( m_SourceHeight + m_CTUSize - 1 ) / m_CTUSize : 1; + msg( VERBOSE, "WPP:%d ", m_entropyCodingSyncEnabled ? 1 : 0 ); + msg( VERBOSE, "WPP-Substreams:%d ", iWaveFrontSubstreams ); + msg( VERBOSE, "TMVP:%d ", m_TMVPModeId ); + + msg( VERBOSE, "DQ:%d ", m_DepQuantEnabled ); + if( m_DepQuantEnabled ) + { + if( m_dqThresholdVal & 1 ) + msg( VERBOSE, "(Thr: %d.5) ", m_dqThresholdVal >> 1 ); + else + msg( VERBOSE, "(Thr: %d) ", m_dqThresholdVal >> 1 ); + } + msg( VERBOSE, "SDH:%d ", m_SignDataHidingEnabled); + msg( VERBOSE, "CST:%d ", m_dualITree ); + msg( VERBOSE, "BDOF:%d ", m_BDOF ); + msg( VERBOSE, "DMVR:%d ", m_DMVR ); + msg( VERBOSE, "MTSImplicit:%d ", m_MTSImplicit ); + msg( VERBOSE, "SBT:%d ", m_SBT ); + msg( VERBOSE, "JCbCr:%d ", m_JointCbCrMode ); + msg( VERBOSE, "CabacInitPresent:%d ", m_cabacInitPresent ); + msg( VERBOSE, "AMVR:%d ", m_AMVRspeed ); + msg( VERBOSE, "SMVD:%d ", m_SMVD ); + + msg( VERBOSE, "LMCS:%d ", m_lumaReshapeEnable ); + if( m_lumaReshapeEnable ) + { + msg( VERBOSE, "(Signal:%s ", m_reshapeSignalType == 0 ? "SDR" : (m_reshapeSignalType == 2 ? "HDR-HLG" : "HDR-PQ") ); + msg( VERBOSE, "Opt:%d", m_adpOption ); + if( m_adpOption > 0 ) + { + msg( VERBOSE, " CW:%d", m_initialCW ); + } + msg( VERBOSE, ") " ); + } + msg( VERBOSE, "CIIP:%d ", m_CIIP ); + msg( VERBOSE, "MIP:%d ", m_MIP ); + msg( VERBOSE, "AFFINE:%d ", m_Affine ); + if( m_Affine ) + { + msg( VERBOSE, "(PROF:%d, ", m_PROF ); + msg( VERBOSE, "Type:%d)", m_AffineType ); + } + msg( VERBOSE, "MMVD:%d ", m_MMVD ); + if( m_MMVD ) + msg( VERBOSE, "DisFracMMVD:%d ", m_allowDisFracMMVD) ; + msg( VERBOSE, "SbTMVP:%d ", m_SbTMVP ); + msg( VERBOSE, "GPM:%d ", m_Geo ); + msg( VERBOSE, "LFNST:%d ", m_LFNST ); + msg( VERBOSE, "MTS:%d ", m_MTS ); + if( m_MTS ) + { + msg( VERBOSE, "(IntraCand:%d)", m_MTSIntraMaxCand ); + } + msg( VERBOSE, "ISP:%d ", m_ISP ); + msg( VERBOSE, "TS:%d ", m_TS ); + if( m_TS ) + { + msg( VERBOSE, "TSLog2MaxSize:%d ", m_TSsize ); + msg( VERBOSE, "useChromaTS:%d ", m_useChromaTS ); + } + msg( VERBOSE, "BDPCM:%d ", m_useBDPCM); + + msg( VERBOSE, "\nENC. ALG. CFG: " ); + msg( VERBOSE, "QPA:%d ", m_usePerceptQPA ); + msg( VERBOSE, "HAD:%d ", m_bUseHADME ); + msg( VERBOSE, "RDQ:%d ", m_RDOQ ); + msg( VERBOSE, "RDQTS:%d ", m_useRDOQTS ); + msg( VERBOSE, "ASR:%d ", m_bUseASR ); + msg( VERBOSE, "MinSearchWindow:%d ", m_minSearchWindow ); + msg( VERBOSE, "RestrictMESampling:%d ", m_bRestrictMESampling ); + msg( VERBOSE, "EDO:%d ", m_EDO ); + msg( VERBOSE, "MCTF:%d ", m_MCTF ); + if( m_MCTF ) + { + msg( VERBOSE, "[L:%d, T:%d] ", m_MCTFNumLeadFrames, m_MCTFNumTrailFrames ); + } + + msg( VERBOSE, "\nFAST TOOL CFG: " ); + msg( VERBOSE, "ECU:%d ", m_bUseEarlyCU ); + msg( VERBOSE, "FEN:%d ", m_fastInterSearchMode ); + msg( VERBOSE, "FDM:%d ", m_useFastDecisionForMerge ); + msg( VERBOSE, "ESD:%d ", m_useEarlySkipDetection ); + msg( VERBOSE, "FastSearch:%d ", m_motionEstimationSearchMethod ); + msg( VERBOSE, "LCTUFast:%d ", m_useFastLCTU ); + msg( VERBOSE, "FastMrg:%d ", m_useFastMrg ); + msg( VERBOSE, "PBIntraFast:%d ", m_usePbIntraFast ); + msg( VERBOSE, "AMaxBT:%d ", m_useAMaxBT ); + msg( VERBOSE, "FastQtBtEnc:%d ", m_fastQtBtEnc ); + msg( VERBOSE, "ContentBasedFastQtbt:%d ", m_contentBasedFastQtbt ); + if( m_MIP ) + { + msg( VERBOSE, "FastMIP:%d ", m_useFastMIP ); + } + msg( VERBOSE, "FastLocalDualTree:%d ", m_fastLocalDualTreeMode ); + msg( VERBOSE, "FastSubPel:%d ", m_fastSubPel ); + msg( VERBOSE, "QtbttExtraFast:%d ", m_qtbttSpeedUp ); + + msg( VERBOSE, "\nRATE CONTROL CFG: " ); + msg( VERBOSE, "RateControl:%d ", m_RCRateControlMode ); + if ( m_RCRateControlMode ) + { + msg( VERBOSE, "Passes:%d ", m_RCNumPasses ); + msg( VERBOSE, "TargetBitrate:%d ", m_RCTargetBitrate ); + msg( VERBOSE, "KeepHierarchicalBit:%d ", m_RCKeepHierarchicalBit ); + msg( VERBOSE, "RCLCUSeparateModel:%d ", m_RCUseLCUSeparateModel ); + msg( VERBOSE, "InitialQP:%d ", m_RCInitialQP ); + msg( VERBOSE, "RCForceIntraQP:%d ", m_RCForceIntraQP ); + } + + msg( VERBOSE, "\nPARALLEL PROCESSING CFG: " ); + msg( VERBOSE, "FPP:%d ", m_frameParallel ); + msg( VERBOSE, "NumFppThreads:%d ", m_numFppThreads ); + msg( VERBOSE, "FppBitEqual:%d ", m_ensureFppBitEqual ); + msg( VERBOSE, "WPP:%d ", m_numWppThreads ); + msg( VERBOSE, "WppBitEqual:%d ", m_ensureWppBitEqual ); + msg( VERBOSE, "WF:%d", m_entropyCodingSyncEnabled ); + msg( VERBOSE, "\n" ); +} + } // namespace vvenc //! \} diff --git a/source/Lib/vvenc/EncoderIf.cpp b/source/Lib/vvenc/EncoderIf.cpp index adea8e3f4..b98a3bd52 100644 --- a/source/Lib/vvenc/EncoderIf.cpp +++ b/source/Lib/vvenc/EncoderIf.cpp @@ -1,51 +1,55 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file EncoderIf.cpp \brief encoder lib interface */ -#include "../../../include/vvenc/EncoderIf.h" +#include "vvenc/EncoderIf.h" #include "EncoderLib/EncLib.h" #include "CommonLib/CommonDef.h" @@ -58,6 +62,8 @@ vvc@hhi.fraunhofer.de namespace vvenc { +bool tryDecodePicture( Picture* pic, const int expectedPoc, const std::string& bitstreamFileName, FFwdDecoder& ffwdDecoder, ParameterSetMap* apsMap, bool bDecodeUntilPocFound = false, int debugPOC = -1, bool copyToEnc = true ); + // ==================================================================================================================== EncoderIf::EncoderIf() @@ -67,26 +73,32 @@ EncoderIf::EncoderIf() EncoderIf::~EncoderIf() { - destroyEncoderLib(); + uninitEncoderLib(); } -void EncoderIf::createEncoderLib( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ) +void EncoderIf::initEncoderLib( const EncCfg& encCfg, YUVWriterIf* yuvWriterIf ) { CHECK( m_pEncLib != nullptr, "encoder library already initialized" ); m_pEncLib = new EncLib; - m_pEncLib->init( encCfg, yuvWriterIf ); + m_pEncLib->initEncoderLib( encCfg, yuvWriterIf ); } -void EncoderIf::destroyEncoderLib() +void EncoderIf::uninitEncoderLib() { if ( m_pEncLib ) { - m_pEncLib->destroy(); + m_pEncLib->uninitEncoderLib(); delete m_pEncLib; m_pEncLib = nullptr; } } +void EncoderIf::initPass( int pass ) +{ + CHECK( m_pEncLib == nullptr, "encoder library not created" ); + m_pEncLib->initPass( pass ); +} + void EncoderIf::encodePicture( bool flush, const YUVBuffer& yuvInBuf, AccessUnit& au, bool& isQueueEmpty ) { CHECK( m_pEncLib == nullptr, "encoder library not initialized" ); @@ -101,7 +113,7 @@ void EncoderIf::printSummary() // ==================================================================================================================== -void setMsgFnc( MsgFnc msgFnc ) +void registerMsgCbf( std::function msgFnc ) { g_msgFnc = msgFnc; } @@ -141,6 +153,18 @@ std::string getCompileInfoString() return compileInfo; } +void decodeBitstream( const std::string& FileName) +{ + FFwdDecoder ffwdDecoder; + Picture cPicture; cPicture.poc=-8000; + + if( tryDecodePicture( &cPicture, -1, FileName, ffwdDecoder, nullptr, false, cPicture.poc, false )) + { + msg( ERROR, "decoding failed"); + THROW("error decoding"); + } +} + } // namespace vvenc //! \} diff --git a/source/Lib/vvenc/FileIO.cpp b/source/Lib/vvenc/FileIO.cpp index ae84a121b..855dcb545 100644 --- a/source/Lib/vvenc/FileIO.cpp +++ b/source/Lib/vvenc/FileIO.cpp @@ -1,58 +1,63 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \file FileIO.cpp \brief file I/O class (header) */ -#include "../../../include/vvenc/FileIO.h" +#include "vvenc/FileIO.h" #include "CommonLib/CommonDef.h" #include "CommonLib/Unit.h" +#include "CommonLib/Slice.h" #include "EncoderLib/NALwrite.h" #include -#include "../../../include/vvenc/EncoderIf.h" +#include "vvenc/EncoderIf.h" //! \ingroup Interface //! \{ @@ -655,7 +660,8 @@ bool YuvIO::writeYuvBuf( const YUVBuffer& yuvOutBuf, const ChromaFormat& internC if ( nonZeroBitDepthShift ) { picScaled.create( internChFmt, Area( Position( 0, 0 ), Size( yuvOutBuf.yuvPlanes[ COMP_Y ].width, yuvOutBuf.yuvPlanes[ COMP_Y ].height ) ) ); - setupYuvBuffer( picScaled, yuvScaled, nullptr ); + Window zeroWindow; + setupYuvBuffer( picScaled, yuvScaled, &zeroWindow ); PelUnitBuf pic; setupPelUnitBuf( yuvOutBuf, pic, internChFmt ); picScaled.copyFrom( pic ); diff --git a/source/Lib/vvenc/resource.h b/source/Lib/vvenc/resource.h new file mode 100644 index 000000000..1b9247f39 --- /dev/null +++ b/source/Lib/vvenc/resource.h @@ -0,0 +1,65 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +/** + \ingroup vvencApp + \file /vvenc/resource.h +*/ + +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by vvenc.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +# ifndef APSTUDIO_READONLY_SYMBOLS +# define _APS_NEXT_RESOURCE_VALUE 101 +# define _APS_NEXT_COMMAND_VALUE 40001 +# define _APS_NEXT_CONTROL_VALUE 1001 +# define _APS_NEXT_SYMED_VALUE 101 +# endif +#endif diff --git a/source/Lib/vvenc/resource_version.h b/source/Lib/vvenc/resource_version.h new file mode 100644 index 000000000..777af304e --- /dev/null +++ b/source/Lib/vvenc/resource_version.h @@ -0,0 +1,56 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +#if !defined( resource_version_h ) +# define resource_version_h + +// pick up top level version information. +# include "vvenc/version.h" + +# define VS_FILE_VERSION VVENC_VS_VERSION +# define VS_FILE_VERSION_STR VVENC_VS_VERSION_STR + +#endif diff --git a/source/Lib/vvenc/version.h.in b/source/Lib/vvenc/version.h.in new file mode 100644 index 000000000..fe81722de --- /dev/null +++ b/source/Lib/vvenc/version.h.in @@ -0,0 +1,61 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +#if !defined( VVENC_VERSION ) + +#define VVENC_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}" + +#define VVENC_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} +#define VVENC_VERSION_MINOR ${PROJECT_VERSION_MINOR} +#define VVENC_VERSION_PATCH ${PROJECT_VERSION_PATCH} +#define VVENC_VERSION_TWEAK ${PROJECT_VERSION_TWEAK} + +#ifdef _WIN32 +#define VVENC_VS_VERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},${PROJECT_VERSION_TWEAK} +#define VVENC_VS_VERSION_STR "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}" +#endif + +#endif diff --git a/source/Lib/vvenc/vvenc.cpp b/source/Lib/vvenc/vvenc.cpp index 01e275549..ee6c1410c 100644 --- a/source/Lib/vvenc/vvenc.cpp +++ b/source/Lib/vvenc/vvenc.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -4. DISCLAIMER +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. -5. CONTACT INFORMATION - -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \ingroup vvencExternalInterfaces @@ -48,13 +52,11 @@ vvc@hhi.fraunhofer.de \date 08/08/2020 */ -#include "../../../include/vvenc/vvenc.h" +#include "vvenc/vvenc.h" #include "vvencimpl.h" namespace vvenc { -//const char *sMsg = "Not initialized"; - VVEnc::VVEnc() { m_pcVVEncImpl = new VVEncImpl; @@ -74,46 +76,37 @@ VVEnc::~VVEnc() } } -int VVEnc::init( const VVEncParameter& rcVVEncParameter ) +int VVEnc::checkConfig( const VVEncParameter& rcVVEncParameter ) { - if( m_pcVVEncImpl->m_bInitialized ) - { - return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_INITIALIZE ); - } + if( rcVVEncParameter.m_iThreadCount > 64 ){ return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_NOT_SUPPORTED ); } - if( rcVVEncParameter.m_iThreadCount > 64 ) - { - return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_NOT_SUPPORTED ); - } + return m_pcVVEncImpl->checkConfig( rcVVEncParameter ); +} - int iRet = m_pcVVEncImpl->init( rcVVEncParameter ); - if( iRet != VVENC_OK ) - { - return iRet; - } +int VVEnc::init( const VVEncParameter& rcVVEncParameter ) +{ + if( m_pcVVEncImpl->m_bInitialized ) { return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_INITIALIZE ); } + if( rcVVEncParameter.m_iThreadCount > 64 ){ return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_NOT_SUPPORTED ); } // Set SIMD extension in case if it hasn't been done before, otherwise it simply reuses the current state std::string simdOpt; vvenc::setSIMDExtension( simdOpt ); - return VVENC_OK; + return m_pcVVEncImpl->init( rcVVEncParameter ); } -int VVEnc::uninit() +int VVEnc::initPass( int pass ) { - if( !m_pcVVEncImpl->m_bInitialized ) - { - return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_INITIALIZE ); - } + if( !m_pcVVEncImpl->m_bInitialized ){ return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_INITIALIZE ); } - if ( 0 != m_pcVVEncImpl->uninit( ) ) - { - return VVENC_ERR_INITIALIZE; - } + return m_pcVVEncImpl->initPass( pass ); +} - m_pcVVEncImpl->m_bInitialized = false; +int VVEnc::uninit() +{ + if( !m_pcVVEncImpl->m_bInitialized ){ return m_pcVVEncImpl->setAndRetErrorMsg( VVENC_ERR_INITIALIZE ); } - return VVENC_OK; + return m_pcVVEncImpl->uninit( ); } bool VVEnc::isInitialized() @@ -123,24 +116,21 @@ bool VVEnc::isInitialized() int VVEnc::encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessUnit ) { - if( !m_pcVVEncImpl->m_bInitialized ) - { return m_pcVVEncImpl->setAndRetErrorMsg(VVENC_ERR_INITIALIZE); } + if( !m_pcVVEncImpl->m_bInitialized ){ return m_pcVVEncImpl->setAndRetErrorMsg(VVENC_ERR_INITIALIZE); } return m_pcVVEncImpl->encode( pcInputPicture, rcVvcAccessUnit ); } int VVEnc::flush( VvcAccessUnit& rcVvcAccessUnit ) { - if( !m_pcVVEncImpl->m_bInitialized ) - { return m_pcVVEncImpl->setAndRetErrorMsg(VVENC_ERR_INITIALIZE); } + if( !m_pcVVEncImpl->m_bInitialized ){ return m_pcVVEncImpl->setAndRetErrorMsg(VVENC_ERR_INITIALIZE); } return m_pcVVEncImpl->setAndRetErrorMsg( m_pcVVEncImpl->flush( rcVvcAccessUnit ) ); } int VVEnc::getPreferredBuffer( PicBuffer &rcPicBuffer ) { - if( !m_pcVVEncImpl->m_bInitialized ) - { return m_pcVVEncImpl->setAndRetErrorMsg(VVENC_ERR_INITIALIZE); } + if( !m_pcVVEncImpl->m_bInitialized ){ return m_pcVVEncImpl->setAndRetErrorMsg(VVENC_ERR_INITIALIZE); } return m_pcVVEncImpl->setAndRetErrorMsg( m_pcVVEncImpl->getPreferredBuffer( rcPicBuffer ) ); } @@ -179,6 +169,16 @@ const char* VVEnc::getLastError() const return m_pcVVEncImpl->m_cErrorString.c_str(); } +int VVEnc::getNumLeadFrames() const +{ + return m_pcVVEncImpl->getNumLeadFrames(); +} + +int VVEnc::getNumTrailFrames() const +{ + return m_pcVVEncImpl->getNumTrailFrames(); +} + const char* VVEnc::getVersionNumber() { return VVEncImpl::getVersionNumber(); @@ -189,7 +189,15 @@ const char* VVEnc::getErrorMsg( int nRet ) return VVEncImpl::getErrorMsg(nRet); } +const char* VVEnc::getPresetParamsAsStr( int iQuality ) +{ + return VVEncImpl::getPresetParamsAsStr(iQuality); +} +void VVEnc::registerMsgCbf( std::function msgFnc ) +{ + vvenc::registerMsgCbf( msgFnc ); +} } // namespace diff --git a/source/Lib/vvenc/vvenc.rc b/source/Lib/vvenc/vvenc.rc new file mode 100644 index 000000000..f7cf22926 --- /dev/null +++ b/source/Lib/vvenc/vvenc.rc @@ -0,0 +1,157 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" +#include "resource_version.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Default) (unknown sub-lang: 0x8) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ZZZ) +LANGUAGE LANG_NEUTRAL, 0x8 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VS_FILE_VERSION + PRODUCTVERSION VS_FILE_VERSION + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "200004b0" + BEGIN + VALUE "CompanyName", "Fraunhofer Heinrich Hertz Institute" + VALUE "FileDescription", "vvenc DLL" + VALUE "FileVersion", VS_FILE_VERSION_STR + VALUE "InternalName", "vvenc.dll" + VALUE "LegalCopyright", "(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V" + VALUE "OriginalFilename", "vvenc.dll" + VALUE "ProductName", "vvenc" + VALUE "ProductVersion", VS_FILE_VERSION_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x2000, 1200 + END +END + +#endif // Neutral (Default) (unknown sub-lang: 0x8) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/source/Lib/vvenc/vvencimpl.cpp b/source/Lib/vvenc/vvencimpl.cpp index 3fd854f2a..6b6102599 100644 --- a/source/Lib/vvenc/vvencimpl.cpp +++ b/source/Lib/vvenc/vvencimpl.cpp @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -4. DISCLAIMER + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. -5. CONTACT INFORMATION -Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department -Einsteinufer 37 -10587 Berlin, Germany -www.hhi.fraunhofer.de/vvc -vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ +------------------------------------------------------------------------------------------- */ /** \ingroup hhivvcdeclibExternalInterfaces @@ -52,15 +56,17 @@ vvc@hhi.fraunhofer.de #include #include +#include -#include "../../../include/vvenc/Nal.h" -#include "../../../include/vvenc/version.h" +#include "vvenc/Nal.h" +#include "vvenc/version.h" +#include "CommonLib/CommonDef.h" namespace vvenc { - + std::string VVEncImpl::m_cTmpErrorString; -int g_LogLevel = LL_ERROR; +std::string VVEncImpl::m_sPresetAsStr; #define ROTPARAMS(x, message) if(x) { rcErrorString = message; return VVENC_ERR_PARAMETER;} @@ -76,6 +82,20 @@ VVEncImpl::~VVEncImpl() } +int VVEncImpl::checkConfig( const vvenc::VVEncParameter& rcVVEncParameter ) +{ + int iRet = xCheckParameter( rcVVEncParameter, m_cErrorString ); + if( 0 != iRet ) { return iRet; } + + vvenc::EncCfg cEncCfg; + if( 0 != xInitLibCfg( rcVVEncParameter, cEncCfg ) ) + { + return VVENC_ERR_INITIALIZE; + } + + return VVENC_OK; +} + int VVEncImpl::init( const vvenc::VVEncParameter& rcVVEncParameter ) { if( m_bInitialized ){ return VVENC_ERR_INITIALIZE; } @@ -83,9 +103,6 @@ int VVEncImpl::init( const vvenc::VVEncParameter& rcVVEncParameter ) int iRet = xCheckParameter( rcVVEncParameter, m_cErrorString ); if( 0 != iRet ) { return iRet; } - g_LogLevel = (int)rcVVEncParameter.m_eLogLevel; - setMsgFnc( &msgFnc ); - std::stringstream cssCap; // cssCap << NVM_ONOS; // @@ -117,15 +134,21 @@ int VVEncImpl::init( const vvenc::VVEncParameter& rcVVEncParameter ) return VVENC_ERR_INITIALIZE; } - if( rcVVEncParameter.m_eLogLevel != LL_DEBUG_PLUS_INTERNAL_LOGS ) - { - setMsgFnc( &msgFncDummy ); - } - - // create the encoder - m_cEncoderIf.createEncoderLib( m_cEncCfg ); + // initialize the encoder + m_cEncoderIf.initEncoderLib( m_cEncCfg ); m_bInitialized = true; + m_bFlushed = false; + return VVENC_OK; +} + +int VVEncImpl::initPass( int pass ) +{ + if( !m_bInitialized ){ return VVENC_ERR_INITIALIZE; } + + m_cEncoderIf.initPass( pass ); + + m_bFlushed = false; return VVENC_OK; } @@ -133,19 +156,20 @@ int VVEncImpl::uninit() { if( !m_bInitialized ){ return VVENC_ERR_INITIALIZE; } - setMsgFnc( &msgFnc ); m_cEncoderIf.printSummary(); - m_cEncoderIf.destroyEncoderLib(); + m_cEncoderIf.uninitEncoderLib(); m_bInitialized = false; + m_bFlushed = false; return VVENC_OK; } int VVEncImpl::encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessUnit ) { - if( !m_bInitialized ) { return VVENC_ERR_INITIALIZE; } + if( !m_bInitialized ) { return VVENC_ERR_INITIALIZE; } if( 0 == rcVvcAccessUnit.m_iBufSize ){ m_cErrorString = "AccessUnit BufferSize is 0"; return VVENC_NOT_ENOUGH_MEM; } + if( m_bFlushed ) { m_cErrorString = "encoder already flushed"; return VVENC_ERR_RESTART_REQUIRED; } int iRet= VVENC_OK; @@ -155,7 +179,37 @@ int VVEncImpl::encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessU return VVENC_ERR_UNSPECIFIED; } - if( pcInputPicture->m_cPicBuffer.m_iBitDepth < 10 ) + if( pcInputPicture->m_cPicBuffer.m_pvY == nullptr || pcInputPicture->m_cPicBuffer.m_pvU == nullptr || pcInputPicture->m_cPicBuffer.m_pvV == nullptr ) + { + m_cErrorString = "InputPicture: invalid input buffers"; + return VVENC_ERR_UNSPECIFIED; + } + + if( pcInputPicture->m_cPicBuffer.m_iWidth != this->m_cVVEncParameter.m_iWidth ) + { + m_cErrorString = "InputPicture: unsuported width"; + return VVENC_ERR_UNSPECIFIED; + } + + if( pcInputPicture->m_cPicBuffer.m_iHeight != this->m_cVVEncParameter.m_iHeight ) + { + m_cErrorString = "InputPicture: unsuported height"; + return VVENC_ERR_UNSPECIFIED; + } + + if( pcInputPicture->m_cPicBuffer.m_iWidth > pcInputPicture->m_cPicBuffer.m_iStride ) + { + m_cErrorString = "InputPicture: unsuported width stride combination"; + return VVENC_ERR_UNSPECIFIED; + } + + if( pcInputPicture->m_cPicBuffer.m_iCStride && pcInputPicture->m_cPicBuffer.m_iWidth/2 > pcInputPicture->m_cPicBuffer.m_iCStride ) + { + m_cErrorString = "InputPicture: unsuported width cstride combination"; + return VVENC_ERR_UNSPECIFIED; + } + + if( pcInputPicture->m_cPicBuffer.m_iBitDepth < 10 || pcInputPicture->m_cPicBuffer.m_iBitDepth > 16 ) { std::stringstream css; css << "InputPicture: unsupported input BitDepth " << pcInputPicture->m_cPicBuffer.m_iBitDepth << ". must be 10 <= BitDepth <= 16"; @@ -163,9 +217,13 @@ int VVEncImpl::encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessU return VVENC_ERR_UNSPECIFIED; } + // we know that the internal buffer requires to be a multiple of 8 in each direction + int internalLumaWidth = ((pcInputPicture->m_cPicBuffer.m_iWidth + 7)/8)*8; + int internalLumaHeight = ((pcInputPicture->m_cPicBuffer.m_iHeight + 7)/8)*8; + int internalLumaStride = (internalLumaWidth > pcInputPicture->m_cPicBuffer.m_iStride) ? internalLumaWidth : pcInputPicture->m_cPicBuffer.m_iStride; - int iChromaInStride = pcInputPicture->m_cPicBuffer.m_iStride >> 1; - if( pcInputPicture->m_cPicBuffer.m_iCStride ) + int iChromaInStride = internalLumaStride >> 1; + if( pcInputPicture->m_cPicBuffer.m_iCStride && pcInputPicture->m_cPicBuffer.m_iCStride > (internalLumaWidth >> 1) ) { iChromaInStride = pcInputPicture->m_cPicBuffer.m_iCStride; } @@ -176,26 +234,27 @@ int VVEncImpl::encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessU YUVPlane& yuvPlane = cYUVBuffer.yuvPlanes[ i ]; if ( i > 0 ) { - yuvPlane.width = pcInputPicture->m_cPicBuffer.m_iWidth >> 1; - yuvPlane.height = pcInputPicture->m_cPicBuffer.m_iHeight >> 1; + yuvPlane.width = internalLumaWidth >> 1; + yuvPlane.height = internalLumaHeight >> 1; yuvPlane.stride = iChromaInStride; } else { - yuvPlane.width = pcInputPicture->m_cPicBuffer.m_iWidth; - yuvPlane.height = pcInputPicture->m_cPicBuffer.m_iHeight; - yuvPlane.stride = pcInputPicture->m_cPicBuffer.m_iStride; + yuvPlane.width = internalLumaWidth; + yuvPlane.height = internalLumaHeight; + yuvPlane.stride = internalLumaStride; } const int size = yuvPlane.stride * yuvPlane.height; yuvPlane.planeBuf = ( size > 0 ) ? new int16_t[ size ] : nullptr; } - xCopyInputPlane( cYUVBuffer.yuvPlanes[0].planeBuf, cYUVBuffer.yuvPlanes[0].stride, cYUVBuffer.yuvPlanes[0].width, cYUVBuffer.yuvPlanes[0].height, - (int16_t*)pcInputPicture->m_cPicBuffer.m_pvY, pcInputPicture->m_cPicBuffer.m_iStride, pcInputPicture->m_cPicBuffer.m_iWidth, pcInputPicture->m_cPicBuffer.m_iHeight, 0 ); - xCopyInputPlane( cYUVBuffer.yuvPlanes[1].planeBuf, iChromaInStride, cYUVBuffer.yuvPlanes[1].width, cYUVBuffer.yuvPlanes[1].height, - (int16_t*)pcInputPicture->m_cPicBuffer.m_pvU, iChromaInStride, pcInputPicture->m_cPicBuffer.m_iWidth>>1, pcInputPicture->m_cPicBuffer.m_iHeight>>1, 0 ); - xCopyInputPlane( cYUVBuffer.yuvPlanes[2].planeBuf, iChromaInStride, cYUVBuffer.yuvPlanes[2].width, cYUVBuffer.yuvPlanes[2].height, - (int16_t*)pcInputPicture->m_cPicBuffer.m_pvV, iChromaInStride, pcInputPicture->m_cPicBuffer.m_iWidth>>1, pcInputPicture->m_cPicBuffer.m_iHeight>>1, 0 ); + xCopyAndPadInputPlane( cYUVBuffer.yuvPlanes[0].planeBuf, cYUVBuffer.yuvPlanes[0].stride, cYUVBuffer.yuvPlanes[0].width, cYUVBuffer.yuvPlanes[0].height, + (int16_t*)pcInputPicture->m_cPicBuffer.m_pvY, pcInputPicture->m_cPicBuffer.m_iStride, pcInputPicture->m_cPicBuffer.m_iWidth, pcInputPicture->m_cPicBuffer.m_iHeight, 0 ); + xCopyAndPadInputPlane( cYUVBuffer.yuvPlanes[1].planeBuf, iChromaInStride, cYUVBuffer.yuvPlanes[1].width, cYUVBuffer.yuvPlanes[1].height, + (int16_t*)pcInputPicture->m_cPicBuffer.m_pvU, iChromaInStride, pcInputPicture->m_cPicBuffer.m_iWidth>>1, pcInputPicture->m_cPicBuffer.m_iHeight>>1, 0 ); + xCopyAndPadInputPlane( cYUVBuffer.yuvPlanes[2].planeBuf, iChromaInStride, cYUVBuffer.yuvPlanes[2].width, cYUVBuffer.yuvPlanes[2].height, + (int16_t*)pcInputPicture->m_cPicBuffer.m_pvV, iChromaInStride, pcInputPicture->m_cPicBuffer.m_iWidth>>1, pcInputPicture->m_cPicBuffer.m_iHeight>>1, 0 ); + cYUVBuffer.sequenceNumber = pcInputPicture->m_cPicBuffer.m_uiSequenceNumber; if( pcInputPicture->m_cPicBuffer.m_bCtsValid ) @@ -229,25 +288,24 @@ int VVEncImpl::encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessU int VVEncImpl::flush( VvcAccessUnit& rcVvcAccessUnit ) { - if( !m_bInitialized ){ return VVENC_ERR_INITIALIZE; } + if( !m_bInitialized ) { return VVENC_ERR_INITIALIZE; } if( 0 == rcVvcAccessUnit.m_iBufSize ){ m_cErrorString = "AccessUnit BufferSize is 0"; return VVENC_NOT_ENOUGH_MEM; } - int iRet= VVENC_OK; - YUVBuffer cYUVBuffer; AccessUnit cAu; - bool encDone = false; - while( !encDone && cAu.empty() ) + /* encode till next output AU done */ + while( !m_bFlushed && cAu.empty() ) { - m_cEncoderIf.encodePicture( true, cYUVBuffer, cAu, encDone ); + m_cEncoderIf.encodePicture( true, cYUVBuffer, cAu, m_bFlushed ); + } - /* copy output AU */ - rcVvcAccessUnit.m_iUsedSize = 0; - if ( !cAu.empty() ) - { - iRet = xCopyAu( rcVvcAccessUnit, cAu ); - } + /* copy next output AU */ + rcVvcAccessUnit.m_iUsedSize = 0; + int iRet = VVENC_OK; + if( !cAu.empty() ) + { + iRet = xCopyAu( rcVvcAccessUnit, cAu ); } return iRet; @@ -283,10 +341,10 @@ int VVEncImpl::getPreferredBuffer( PicBuffer &rcPicBuffer ) if( !m_bInitialized ){ return VVENC_ERR_INITIALIZE; } int iRet= VVENC_OK; - bool bMarginReq = false; + bool bMarginReq = false; int iAddMargin = bMarginReq ? 16: -1; const int iMaxCUSizeLog2 = 7; - const int iBitDepth = 10; + const int iBitDepth = 10; int iMaxCUSizeLog2Buffer = bMarginReq ? iMaxCUSizeLog2 : 0; const BufferDimensions bd( m_cVVEncParameter.m_iWidth, m_cVVEncParameter.m_iHeight, iBitDepth, iMaxCUSizeLog2Buffer, iAddMargin); @@ -294,7 +352,7 @@ int VVEncImpl::getPreferredBuffer( PicBuffer &rcPicBuffer ) rcPicBuffer.m_iWidth = m_cVVEncParameter.m_iWidth; rcPicBuffer.m_iHeight = m_cVVEncParameter.m_iHeight; rcPicBuffer.m_iStride = bd.iStride; - const int iBufSize = bd.iSizeFactor * bd.iLumaSize * 3 / 2 + 3*bd.iAlignmentGuard; + const int iBufSize = bd.iSizeFactor * bd.iLumaSize * 3 / 2 + 3*bd.iAlignmentGuard; rcPicBuffer.m_pucDeletePicBuffer = new (std::nothrow) unsigned char[ iBufSize ]; if( NULL == rcPicBuffer.m_pucDeletePicBuffer ) @@ -311,7 +369,7 @@ int VVEncImpl::getPreferredBuffer( PicBuffer &rcPicBuffer ) rcPicBuffer.m_pvV = (pV + 3*bd.iAlignmentGuard) - (((size_t)pV) & (bd.iAlignmentGuard-1)); rcPicBuffer.m_eColorFormat = VVC_CF_YUV420_PLANAR; - rcPicBuffer.m_uiSequenceNumber = -1; + rcPicBuffer.m_uiSequenceNumber = 0; return iRet; } @@ -366,6 +424,16 @@ int VVEncImpl::setAndRetErrorMsg( int iRet ) return iRet; } +int VVEncImpl::getNumLeadFrames() +{ + return m_cEncCfg.m_MCTFNumLeadFrames; +} + +int VVEncImpl::getNumTrailFrames() +{ + return m_cEncCfg.m_MCTFNumTrailFrames; +} + void VVEncImpl::clockStartTime() { m_cTPStart = std::chrono::steady_clock::now(); @@ -381,6 +449,68 @@ double VVEncImpl::clockGetTimeDiffMs() return (double)(std::chrono::duration_cast((m_cTPEnd)-(m_cTPStart)).count()); } +const char* VVEncImpl::getPresetParamsAsStr( int iQuality ) +{ + m_sPresetAsStr.clear(); + + std::stringstream css; + vvenc::EncCfg cEncCfg; + if( 0 != cEncCfg.initPreset( (PresetMode)iQuality )) + { + css << "undefined preset " << iQuality; + } +// tools + if( cEncCfg.m_RDOQ ) { css << "RDOQ " << cEncCfg.m_RDOQ << " ";} + if( cEncCfg.m_DepQuantEnabled ){ css << "DQ ";} + if( cEncCfg.m_SignDataHidingEnabled ){ css << "SignBitHidingFlag ";} + if( cEncCfg.m_alf ) + { + css << "ALF "; + if( cEncCfg.m_useNonLinearAlfLuma ) css << "NonLinLuma "; + if( cEncCfg.m_useNonLinearAlfChroma ) css << "NonLinChr "; + } + if( cEncCfg.m_ccalf ){ css << "CCALF ";} + +// vvc tools + if( cEncCfg.m_BDOF ) { css << "BIO ";} + if( cEncCfg.m_DMVR ) { css << "DMVR ";} + if( cEncCfg.m_JointCbCrMode ) { css << "JointCbCr ";} + if( cEncCfg.m_AMVRspeed ) { css << "AMVRspeed " << cEncCfg.m_AMVRspeed << " ";} + if( cEncCfg.m_lumaReshapeEnable ){ css << "Reshape ";} + if( cEncCfg.m_EDO ) { css << "EncDbOpt ";} + if( cEncCfg.m_MRL ) { css << "MRL ";} + if( cEncCfg.m_MCTF ) { css << "MCTF "; } + if( cEncCfg.m_SMVD ) { css << "SMVD " << cEncCfg.m_SMVD << " ";} + if( cEncCfg.m_Affine ) + { + css << "Affine " << cEncCfg.m_Affine << " "; + if( cEncCfg.m_PROF ) { css << "(Prof " << cEncCfg.m_PROF << " ";} + if( cEncCfg.m_AffineType ) { css << "Type " << cEncCfg.m_AffineType << ") ";} + } + + if( cEncCfg.m_MMVD ) { css << "MMVD " << cEncCfg.m_MMVD << " ";} + if( cEncCfg.m_allowDisFracMMVD ) { css << "DisFracMMVD ";} + + if( cEncCfg.m_MIP ) { css << "MIP ";} + if( cEncCfg.m_useFastMIP ) { css << "FastMIP " << cEncCfg.m_useFastMIP << " ";} + if( cEncCfg.m_SbTMVP ) { css << "SbTMVP ";} + if( cEncCfg.m_Geo ) { css << "Geo " << cEncCfg.m_Geo << " ";} + if( cEncCfg.m_LFNST ) { css << "LFNST ";} + + if( cEncCfg.m_SBT ) { css << "SBT " ;} + if( cEncCfg.m_CIIP ) { css << "CIIP ";} + if (cEncCfg.m_ISP) { css << "ISP "; } + if (cEncCfg.m_TS) { css << "TS "; } + if (cEncCfg.m_useBDPCM) { css << "BDPCM "; } + + // fast tools + if( cEncCfg.m_contentBasedFastQtbt ) { css << "ContentBasedFastQtbt ";} + + + m_sPresetAsStr = css.str(); + return m_sPresetAsStr.c_str(); +} + /* converting sdk params to internal (wrapper) params*/ int VVEncImpl::xCheckParameter( const vvenc::VVEncParameter& rcSrc, std::string& rcErrorString ) @@ -396,13 +526,19 @@ int VVEncImpl::xCheckParameter( const vvenc::VVEncParameter& rcSrc, std::string& ROTPARAMS( dFPS < 1.0 || dFPS > 120, "fps specified by temporal rate and scale must result in 1Hz < fps < 120Hz" ); ROTPARAMS( rcSrc.m_iTicksPerSecond <= 0 || rcSrc.m_iTicksPerSecond > 27000000, "TicksPerSecond must be in range from 1 to 27000000" ); + ROTPARAMS( (rcSrc.m_iTicksPerSecond < 90000) && (rcSrc.m_iTicksPerSecond*rcSrc.m_iTemporalScale)%rcSrc.m_iTemporalRate, "TicksPerSecond should be a multiple of FrameRate/Framscale" ); + + ROTPARAMS( rcSrc.m_iThreadCount < 0, "ThreadCount must be >= 0" ); - ROTPARAMS( rcSrc.m_iThreadCount <= 0, "ThreadCount must be > 0" ); + ROTPARAMS( rcSrc.m_iIDRPeriod < 0, "IDR period (in frames) must be >= 0" ); + ROTPARAMS( rcSrc.m_iIDRPeriodSec < 0, "IDR period (in seconds) must be > 0" ); + + ROTPARAMS( rcSrc.m_iTemporalRate <= 0, "TemporalRate must be > 0" ); + ROTPARAMS( rcSrc.m_iTemporalScale <= 0, "TemporalScale must be > 0" ); - ROTPARAMS( rcSrc.m_iIDRPeriod < 0, "IDR period must be GEZ" ); ROTPARAMS( rcSrc.m_iGopSize != 1 && rcSrc.m_iGopSize != 16 && rcSrc.m_iGopSize != 32, "GOP size 1, 16, 32 supported" ); - if( 1 != rcSrc.m_iGopSize ) + if( 1 != rcSrc.m_iGopSize && ( rcSrc.m_iIDRPeriod > 0 )) { ROTPARAMS( (rcSrc.m_eDecodingRefreshType == VVC_DRT_IDR || rcSrc.m_eDecodingRefreshType == VVC_DRT_CRA )&& (0 != rcSrc.m_iIDRPeriod % rcSrc.m_iGopSize), "IDR period must be multiple of GOPSize" ); } @@ -411,27 +547,47 @@ int VVEncImpl::xCheckParameter( const vvenc::VVEncParameter& rcSrc, std::string& ROTPARAMS( rcSrc.m_eProfile != VVC_PROFILE_MAIN_10 && rcSrc.m_eProfile != VVC_PROFILE_MAIN_10_STILL_PICTURE && rcSrc.m_eProfile != VVC_PROFILE_AUTO, "unsupported profile, use main_10, main_10_still_picture or auto" ); - ROTPARAMS( rcSrc.m_iQuality < 0 || rcSrc.m_iQuality > 3, "quality must be between 0 - 3 (0: faster, 1: fast, 2: medium, 3: slow)" ); + ROTPARAMS( (rcSrc.m_iQuality < 0 || rcSrc.m_iQuality > 4) && rcSrc.m_iQuality != 255, "quality must be between 0 - 4 (0: faster, 1: fast, 2: medium, 3: slow, 4: slower)" ); ROTPARAMS( rcSrc.m_iTargetBitRate < 0 || rcSrc.m_iTargetBitRate > 100000000, "TargetBitrate must be between 0 - 100000000" ); + ROTPARAMS( rcSrc.m_iTargetBitRate == 0 && rcSrc.m_iNumPasses != 1, "Only single pass encoding supported, when rate control is disabled" ); + ROTPARAMS( rcSrc.m_iNumPasses < 1 || rcSrc.m_iNumPasses > 2, "Only one pass or two pass encoding supported" ); + + ROTPARAMS( rcSrc.m_eLogLevel < 0 || rcSrc.m_eLogLevel > LL_DETAILS, "log message level range 0 - 6" ); + + ROTPARAMS( rcSrc.m_eSegMode != VVC_SEG_OFF && rcSrc.m_iMaxFrames < MCTF_RANGE, "When using segment parallel encoding more then 2 frames have to be encoded" ); + + if( 0 == rcSrc.m_iTargetBitRate ) + { + ROTPARAMS( rcSrc.m_bHrdParametersPresent, "hrdParameters present requires rate control" ); + ROTPARAMS( rcSrc.m_bBufferingPeriodSEIEnabled, "bufferingPeriod SEI enabled requires rate control" ); + ROTPARAMS( rcSrc.m_bPictureTimingSEIEnabled, "pictureTiming SEI enabled requires rate control" ); + } + + ROTPARAMS( rcSrc.m_iInputBitDepth != 8 && rcSrc.m_iInputBitDepth != 10, "Input bitdepth must be 8 or 10 bit" ); + ROTPARAMS( rcSrc.m_iInternalBitDepth != 8 && rcSrc.m_iInternalBitDepth != 10, "Internal bitdepth must be 8 or 10 bit" ); return 0; } int VVEncImpl::xInitLibCfg( const VVEncParameter& rcVVEncParameter, vvenc::EncCfg& rcEncCfg ) { - rcEncCfg.m_verbosity = (int)rcVVEncParameter.m_eLogLevel; + rcEncCfg.m_verbosity = std::min( (int)rcVVEncParameter.m_eLogLevel, (int)vvenc::DETAILS); - rcEncCfg.m_SourceWidth = rcVVEncParameter.m_iWidth; - rcEncCfg.m_SourceHeight = rcVVEncParameter.m_iHeight; - rcEncCfg.m_QP = rcVVEncParameter.m_iQp; + rcEncCfg.m_SourceWidth = rcVVEncParameter.m_iWidth; + rcEncCfg.m_SourceHeight = rcVVEncParameter.m_iHeight; + rcEncCfg.m_QP = rcVVEncParameter.m_iQp; - rcEncCfg.m_usePerceptQPA = rcVVEncParameter.m_iPerceptualQPA; + rcEncCfg.m_usePerceptQPA = rcVVEncParameter.m_iPerceptualQPA; - rcEncCfg.m_AccessUnitDelimiter = true; // enable ACCessUnitDelimiter per default + rcEncCfg.m_AccessUnitDelimiter = rcVVEncParameter.m_bAccessUnitDelimiter; + rcEncCfg.m_hrdParametersPresent = rcVVEncParameter.m_bHrdParametersPresent; + rcEncCfg.m_bufferingPeriodSEIEnabled = rcVVEncParameter.m_bBufferingPeriodSEIEnabled; + rcEncCfg.m_pictureTimingSEIEnabled = rcVVEncParameter.m_bPictureTimingSEIEnabled; if( rcVVEncParameter.m_iTargetBitRate ) { rcEncCfg.m_RCRateControlMode = 2; + rcEncCfg.m_RCNumPasses = rcVVEncParameter.m_iNumPasses; rcEncCfg.m_RCTargetBitrate = rcVVEncParameter.m_iTargetBitRate; rcEncCfg.m_RCKeepHierarchicalBit = 2; rcEncCfg.m_RCUseLCUSeparateModel = 1; @@ -445,27 +601,54 @@ int VVEncImpl::xInitLibCfg( const VVEncParameter& rcVVEncParameter, vvenc::EncCf rcEncCfg.m_RCTargetBitrate = 0; } + rcEncCfg.m_inputBitDepth[0] = rcVVEncParameter.m_iInputBitDepth; + rcEncCfg.m_inputBitDepth[1] = rcVVEncParameter.m_iInputBitDepth; + rcEncCfg.m_internalBitDepth[0] = rcVVEncParameter.m_iInternalBitDepth; + rcEncCfg.m_internalBitDepth[1] = rcVVEncParameter.m_iInternalBitDepth;; - rcEncCfg.m_internalBitDepth[0] = 10; - - if( rcVVEncParameter.m_iThreadCount > 1 ) + rcEncCfg.m_numWppThreads = rcVVEncParameter.m_iThreadCount; + if( rcVVEncParameter.m_iThreadCount > 0 ) { - rcEncCfg.m_numWppThreads = rcVVEncParameter.m_iThreadCount; rcEncCfg.m_ensureWppBitEqual = 1; } - rcEncCfg.m_intraQPOffset = -3; - rcEncCfg.m_lambdaFromQPEnable = true; - rcEncCfg.m_FrameRate = rcVVEncParameter.m_iTemporalRate / rcVVEncParameter.m_iTemporalScale; - - rcEncCfg.m_framesToBeEncoded = 0; + rcEncCfg.m_framesToBeEncoded = rcVVEncParameter.m_iMaxFrames; //======== Coding Structure ============= rcEncCfg.m_GOPSize = rcVVEncParameter.m_iGopSize; - rcEncCfg.m_InputQueueSize = rcVVEncParameter.m_iGopSize; + rcEncCfg.m_InputQueueSize = 0; + + if( rcVVEncParameter.m_iIDRPeriod >= rcVVEncParameter.m_iGopSize ) + { + rcEncCfg.m_IntraPeriod = rcVVEncParameter.m_iIDRPeriod; + } + else // use m_iIDRPeriodSec + { + if ( rcEncCfg.m_FrameRate % rcVVEncParameter.m_iGopSize == 0 ) + { + rcEncCfg.m_IntraPeriod = rcEncCfg.m_FrameRate * rcVVEncParameter.m_iIDRPeriodSec; + } + else + { + int iIDRPeriod = (rcEncCfg.m_FrameRate * rcVVEncParameter.m_iIDRPeriodSec); + if( iIDRPeriod < rcVVEncParameter.m_iGopSize ) + { + iIDRPeriod = rcVVEncParameter.m_iGopSize; + } + + int iDiff = iIDRPeriod % rcVVEncParameter.m_iGopSize; + if( iDiff < rcVVEncParameter.m_iGopSize >> 1 ) + { + rcEncCfg.m_IntraPeriod = iIDRPeriod - iDiff; + } + else + { + rcEncCfg.m_IntraPeriod = iIDRPeriod + rcVVEncParameter.m_iGopSize - iDiff; + } + } + } - rcEncCfg.m_IntraPeriod = rcVVEncParameter.m_iIDRPeriod; if( rcVVEncParameter.m_eDecodingRefreshType == VVC_DRT_IDR ) { rcEncCfg.m_DecodingRefreshType = 2; // Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI @@ -483,429 +666,61 @@ int VVEncImpl::xInitLibCfg( const VVEncParameter& rcVVEncParameter, vvenc::EncCf rcEncCfg.m_DecodingRefreshType = 0; // Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI } - rcEncCfg.m_maxTempLayer = 5; - rcEncCfg.m_numRPLList0 = 20; - rcEncCfg.m_numRPLList1 = 20; - //======== Profile ================ rcEncCfg.m_profile = (vvenc::Profile::Name)rcVVEncParameter.m_eProfile; rcEncCfg.m_levelTier = (vvenc::Level::Tier)rcVVEncParameter.m_eTier; rcEncCfg.m_level = (vvenc::Level::Name)rcVVEncParameter.m_eLevel; rcEncCfg.m_bitDepthConstraintValue = 10; + rcEncCfg.m_rewriteParamSets = true; + rcEncCfg.m_internChromaFormat = vvenc::CHROMA_420; - rcEncCfg.m_rewriteParamSets = true; - - rcEncCfg.m_internChromaFormat = vvenc::CHROMA_420; - -// rcEncCfg.m_sliceArgument = 1500; -// rcEncCfg.m_MaxBTDepth = 2; - - rcEncCfg.m_MaxCodingDepth = 5; - rcEncCfg.m_log2DiffMaxMinCodingBlockSize = 5; - - rcEncCfg.m_bUseASR = true; - rcEncCfg.m_bUseHADME = true; - rcEncCfg.m_RDOQ = 1; - rcEncCfg.m_useRDOQTS = true; - rcEncCfg.m_useSelectiveRDOQ = false; - rcEncCfg.m_JointCbCrMode = true; - rcEncCfg.m_cabacInitPresent = true; - rcEncCfg.m_useFastLCTU = true; - rcEncCfg.m_usePbIntraFast = true; - rcEncCfg.m_useFastMrg = true; - rcEncCfg.m_useAMaxBT = true; - rcEncCfg.m_fastQtBtEnc = true; - rcEncCfg.m_contentBasedFastQtbt = true; - rcEncCfg.m_fastInterSearchMode = 1; - - rcEncCfg.m_MTSImplicit = true; - rcEncCfg.m_SearchRange = 384; - rcEncCfg.m_minSearchWindow = 96; - - rcEncCfg.m_AMVRspeed = 1; - rcEncCfg.m_LMChroma = true; - - rcEncCfg.m_BDOF = true; - rcEncCfg.m_DMVR = true; - rcEncCfg.m_EDO = 1; - rcEncCfg.m_lumaReshapeEnable = true; - - rcEncCfg.m_alf = true; - - // adapt to RA config files - rcEncCfg.m_qpInValsCb.clear(); - rcEncCfg.m_qpInValsCb.push_back(17); - rcEncCfg.m_qpInValsCb.push_back(22); - rcEncCfg.m_qpInValsCb.push_back(34); - rcEncCfg.m_qpInValsCb.push_back(42); - - rcEncCfg.m_qpOutValsCb.clear(); - rcEncCfg.m_qpOutValsCb.push_back(17); - rcEncCfg.m_qpOutValsCb.push_back(23); - rcEncCfg.m_qpOutValsCb.push_back(35); - rcEncCfg.m_qpOutValsCb.push_back(39); - - if( 0 != xInitPreset( rcEncCfg, rcVVEncParameter.m_iQuality ) ) + if( 0 != rcEncCfg.initPreset( (PresetMode)rcVVEncParameter.m_iQuality ) ) { std::stringstream css; - css << "undefined quality preset " << rcVVEncParameter.m_iQuality << " quality must be between 0 - 3."; + css << "undefined quality preset " << rcVVEncParameter.m_iQuality << " quality must be between 0 - 4."; m_cErrorString = css.str(); return VVENC_ERR_PARAMETER; } - if ( rcEncCfg.initCfgParameter() ) + if( rcVVEncParameter.m_eSegMode != VVC_SEG_OFF ) { - m_cErrorString = "cannot init internal config parameter"; - return VVENC_ERR_PARAMETER; - } - - xPrintCfg(); - - return 0; -} - -int VVEncImpl::xInitPreset( vvenc::EncCfg& rcEncCfg, int iQuality ) -{ - - switch( iQuality ) - { - case 0: // faster - rcEncCfg.m_RDOQ = 2; - rcEncCfg.m_DepQuantEnabled = false; - rcEncCfg.m_SignDataHidingEnabled = true; - rcEncCfg.m_BDOF = false; - rcEncCfg.m_alf = false; - rcEncCfg.m_DMVR = false; - rcEncCfg.m_JointCbCrMode = false; - rcEncCfg.m_AMVRspeed = 0; - rcEncCfg.m_lumaReshapeEnable = false; - rcEncCfg.m_EDO = 0; - rcEncCfg.m_motionEstimationSearchMethod = 4; - - rcEncCfg.m_useFastMrg = 2; - rcEncCfg.m_fastLocalDualTreeMode = 1; - rcEncCfg.m_fastSubPel = 1; - rcEncCfg.m_qtbttSpeedUp = 1; - - rcEncCfg.m_LMCSOffset = 6; - rcEncCfg.m_MRL = false; - - rcEncCfg.m_maxMTTDepth = 1; - rcEncCfg.m_maxMTTDepthI = 2; - rcEncCfg.m_maxMTTDepthIChroma = 2; - rcEncCfg.m_maxNumMergeCand = 6; - - rcEncCfg.m_useNonLinearAlfLuma = false; - rcEncCfg.m_useNonLinearAlfChroma = false; - - break; - case 1: - - rcEncCfg.m_InputQueueSize += 5; - - rcEncCfg.m_RDOQ = 2; - rcEncCfg.m_DepQuantEnabled = false; - rcEncCfg.m_SignDataHidingEnabled = true; - rcEncCfg.m_BDOF = true; - rcEncCfg.m_alf = true; - rcEncCfg.m_ccalf = true; - rcEncCfg.m_DMVR = true; - rcEncCfg.m_JointCbCrMode = false; - rcEncCfg.m_AMVRspeed = 0; - rcEncCfg.m_lumaReshapeEnable = false; - rcEncCfg.m_EDO = 0; - rcEncCfg.m_motionEstimationSearchMethod = 4; - - rcEncCfg.m_MCTF = 2; + if( rcEncCfg.m_MCTF ) + { + switch( rcVVEncParameter.m_eSegMode ) + { + case VVC_SEG_FIRST: rcEncCfg.m_MCTFNumLeadFrames = 0; + rcEncCfg.m_MCTFNumTrailFrames = MCTF_RANGE; + break; + case VVC_SEG_MID: + rcEncCfg.m_MCTFNumLeadFrames = MCTF_RANGE; + rcEncCfg.m_MCTFNumTrailFrames = MCTF_RANGE; + break; + case VVC_SEG_LAST: + rcEncCfg.m_MCTFNumLeadFrames = MCTF_RANGE; rcEncCfg.m_MCTFNumTrailFrames = 0; - - rcEncCfg.m_useFastMrg = 2; - rcEncCfg.m_fastLocalDualTreeMode = 1; - rcEncCfg.m_fastSubPel = 1; - rcEncCfg.m_qtbttSpeedUp = 1; - - rcEncCfg.m_LMCSOffset = 6; - rcEncCfg.m_MRL = false; - - rcEncCfg.m_maxMTTDepth = 1; - rcEncCfg.m_maxMTTDepthI = 2; - rcEncCfg.m_maxMTTDepthIChroma = 2; - rcEncCfg.m_maxNumMergeCand = 6; - - rcEncCfg.m_useNonLinearAlfLuma = false; - rcEncCfg.m_useNonLinearAlfChroma = false; - - break; - case 2: // medium ( = ftc ) - - rcEncCfg.m_useNonLinearAlfLuma = false; - rcEncCfg.m_useNonLinearAlfChroma = false; - - rcEncCfg.m_AMVRspeed = 5; - - rcEncCfg.m_SMVD = 3; - - rcEncCfg.m_MCTF = 2; - rcEncCfg.m_MCTFNumLeadFrames = 0; - rcEncCfg.m_MCTFNumTrailFrames = 0; - - rcEncCfg.m_useFastMrg = 2; - rcEncCfg. m_fastLocalDualTreeMode = 1; - rcEncCfg.m_fastSubPel = 1; - - rcEncCfg.m_Affine = 2; - rcEncCfg.m_PROF = 1; - - rcEncCfg.m_MMVD = 3; - rcEncCfg.m_allowDisFracMMVD = 1; - - rcEncCfg.m_motionEstimationSearchMethod = 4; - - rcEncCfg.m_maxMTTDepth = 1; - rcEncCfg.m_maxMTTDepthI = 2; - rcEncCfg.m_maxMTTDepthIChroma = 2; - - rcEncCfg.m_MaxCodingDepth = 5; - - rcEncCfg.m_MIP = 1; - rcEncCfg.m_useFastMIP = 4; - - rcEncCfg.m_ccalf = true; - rcEncCfg.m_qtbttSpeedUp = 1; - rcEncCfg.m_SbTMVP = 1; - rcEncCfg.m_Geo = 3; - rcEncCfg.m_LFNST = 1; - rcEncCfg.m_maxNumMergeCand = 6; - - rcEncCfg.m_LMCSOffset = 6; - - rcEncCfg.m_RCKeepHierarchicalBit = 2; - - break; - - case 3: // slower - - rcEncCfg.m_useNonLinearAlfLuma = true; - rcEncCfg.m_useNonLinearAlfChroma = true; - - rcEncCfg.m_AMVRspeed = 1; - - rcEncCfg.m_SMVD = 3; - - rcEncCfg.m_MCTF = 2; + break; + default: rcEncCfg.m_MCTFNumLeadFrames = 0; rcEncCfg.m_MCTFNumTrailFrames = 0; - - rcEncCfg.m_useFastMrg = 2; - rcEncCfg. m_fastLocalDualTreeMode = 1; - rcEncCfg.m_fastSubPel = 1; - - rcEncCfg.m_Affine = 2; - rcEncCfg.m_PROF = 1; - - rcEncCfg.m_MMVD = 3; - rcEncCfg.m_allowDisFracMMVD = 1; - - rcEncCfg.m_motionEstimationSearchMethod = 4; - - rcEncCfg.m_maxMTTDepth = 2; - rcEncCfg.m_maxMTTDepthI = 3; - rcEncCfg.m_maxMTTDepthIChroma = 3; - - rcEncCfg.m_MaxCodingDepth = 5; - - rcEncCfg.m_MIP = 1; - rcEncCfg.m_useFastMIP = 4; - - rcEncCfg.m_ccalf = true; - rcEncCfg.m_qtbttSpeedUp = 1; - rcEncCfg.m_SbTMVP = 1; - rcEncCfg.m_Geo = 1; - rcEncCfg.m_LFNST = 1; - rcEncCfg.m_maxNumMergeCand = 6; - - rcEncCfg.m_LMCSOffset = 6; - - rcEncCfg.m_RCKeepHierarchicalBit = 2; - - m_cEncCfg.m_SBT = 1; - m_cEncCfg.m_CIIP = 1; - - rcEncCfg.m_contentBasedFastQtbt = false; - - break; - - default: - return -1; - } - - return 0; -} - -void VVEncImpl::xPrintCfg() -{ - //msgFnc( (int)LL_DETAILS, "\n" ); - msgApp( (int)LL_DETAILS, "Real Format : %dx%d %gHz\n", m_cEncCfg.m_SourceWidth - m_cEncCfg.m_confWinLeft - m_cEncCfg.m_confWinRight, m_cEncCfg.m_SourceHeight - m_cEncCfg.m_confWinTop - m_cEncCfg.m_confWinBottom, (double)m_cEncCfg.m_FrameRate / m_cEncCfg.m_temporalSubsampleRatio ); - msgApp( (int)LL_DETAILS, "Internal Format : %dx%d %gHz\n", m_cEncCfg.m_SourceWidth, m_cEncCfg.m_SourceHeight, (double)m_cEncCfg.m_FrameRate / m_cEncCfg.m_temporalSubsampleRatio ); - msgApp( (int)LL_DETAILS, "Sequence PSNR output : %s\n", ( m_cEncCfg.m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only" ) ); - msgApp( (int)LL_DETAILS, "Hexadecimal PSNR output : %s\n", ( m_cEncCfg.m_printHexPsnr ? "Enabled" : "Disabled" ) ); - msgApp( (int)LL_DETAILS, "Sequence MSE output : %s\n", ( m_cEncCfg.m_printSequenceMSE ? "Enabled" : "Disabled" ) ); - msgApp( (int)LL_DETAILS, "Frame MSE output : %s\n", ( m_cEncCfg.m_printFrameMSE ? "Enabled" : "Disabled" ) ); - msgApp( (int)LL_DETAILS, "Cabac-zero-word-padding : %s\n", ( m_cEncCfg.m_cabacZeroWordPaddingEnabled ? "Enabled" : "Disabled" ) ); - msgApp( (int)LL_DETAILS, "Frame/Field : Frame based coding\n" ); - if ( m_cEncCfg.m_framesToBeEncoded > 0 ) - msgApp( (int)LL_DETAILS, "Frame index : %u - %d (%d frames)\n", m_cEncCfg.m_FrameSkip, m_cEncCfg.m_FrameSkip + m_cEncCfg.m_framesToBeEncoded - 1, m_cEncCfg.m_framesToBeEncoded ); - else - msgApp( (int)LL_DETAILS, "Frame index : %u - .. (all frames)\n", m_cEncCfg.m_FrameSkip ); - msgApp( (int)LL_DETAILS, "Profile : %s\n", getProfileStr( m_cEncCfg.m_profile).c_str() ); - msgApp( (int)LL_DETAILS, "Level : %s\n", getLevelStr( m_cEncCfg.m_level).c_str() ); - msgApp( (int)LL_DETAILS, "CU size / total-depth : %d / %d\n", m_cEncCfg.m_CTUSize, m_cEncCfg.m_MaxCodingDepth ); - msgApp( (int)LL_DETAILS, "Max TB size : %d \n", 1 << m_cEncCfg.m_log2MaxTbSize ); - msgApp( (int)LL_DETAILS, "Motion search range : %d\n", m_cEncCfg.m_SearchRange ); - msgApp( (int)LL_DETAILS, "Intra period : %d\n", m_cEncCfg.m_IntraPeriod ); - msgApp( (int)LL_DETAILS, "Decoding refresh type : %d\n", m_cEncCfg.m_DecodingRefreshType ); - msgApp( (int)LL_DETAILS, "QP : %d\n", m_cEncCfg.m_QP); - msgApp( (int)LL_DETAILS, "Percept QPA : %d \n", m_cEncCfg.m_usePerceptQPA ); - msgApp( (int)LL_DETAILS, "Max dQP signaling subdiv : %d\n", m_cEncCfg.m_cuQpDeltaSubdiv); - - msgApp( (int)LL_DETAILS, "Cb QP Offset (dual tree) : %d (%d)\n", m_cEncCfg.m_chromaCbQpOffset, m_cEncCfg.m_chromaCbQpOffsetDualTree); - msgApp( (int)LL_DETAILS, "Cr QP Offset (dual tree) : %d (%d)\n", m_cEncCfg.m_chromaCrQpOffset, m_cEncCfg.m_chromaCrQpOffsetDualTree); - msgApp( (int)LL_DETAILS, "GOP size : %d\n", m_cEncCfg.m_GOPSize ); - msgApp( (int)LL_DETAILS, "Input queue size : %d\n", m_cEncCfg.m_InputQueueSize ); - msgApp( (int)LL_DETAILS, "Input bit depth : (Y:%d, C:%d)\n", m_cEncCfg.m_inputBitDepth[ 0 ], m_cEncCfg.m_inputBitDepth[ 1 ] ); - msgApp( (int)LL_DETAILS, "MSB-extended bit depth : (Y:%d, C:%d)\n", m_cEncCfg.m_MSBExtendedBitDepth[ 0 ], m_cEncCfg.m_MSBExtendedBitDepth[ 1 ] ); - msgApp( (int)LL_DETAILS, "Internal bit depth : (Y:%d, C:%d)\n", m_cEncCfg.m_internalBitDepth[ 0 ], m_cEncCfg.m_internalBitDepth[ 1 ] ); - msgApp( (int)LL_DETAILS, "cu_chroma_qp_offset_subdiv : %d\n", m_cEncCfg.m_cuChromaQpOffsetSubdiv); - if (m_cEncCfg.m_bUseSAO) - { - msgApp( (int)LL_DETAILS, "log2_sao_offset_scale_luma : %d\n", m_cEncCfg.m_log2SaoOffsetScale[ 0 ] ); - msgApp( (int)LL_DETAILS, "log2_sao_offset_scale_chroma : %d\n", m_cEncCfg.m_log2SaoOffsetScale[ 1 ] ); - } - - switch (m_cEncCfg.m_costMode) - { - case vvenc::COST_STANDARD_LOSSY: msgApp( (int)LL_DETAILS, "Cost function: : Lossy coding (default)\n"); break; - case vvenc::COST_SEQUENCE_LEVEL_LOSSLESS: msgApp( (int)LL_DETAILS, "Cost function: : Sequence_level_lossless coding\n"); break; - case vvenc::COST_LOSSLESS_CODING: msgApp( (int)LL_DETAILS, "Cost function: : Lossless coding with fixed QP\n"); break; - case vvenc::COST_MIXED_LOSSLESS_LOSSY_CODING: msgApp( (int)LL_DETAILS, "Cost function: : Mixed_lossless_lossy coding for lossless evaluation\n"); break; - default: msgApp( (int)LL_DETAILS, "Cost function: : Unknown\n"); break; - } - - msgApp( (int)LL_DETAILS, "\n"); - - msgApp( LL_VERBOSE, "TOOL CFG: "); - msgApp( LL_VERBOSE, "IBD:%d ", ((m_cEncCfg.m_internalBitDepth[ 0 ] > m_cEncCfg.m_MSBExtendedBitDepth[ 0 ]) || (m_cEncCfg.m_internalBitDepth[ 1 ] > m_cEncCfg.m_MSBExtendedBitDepth[ 1 ]))); - msgApp( LL_VERBOSE, "HAD:%d ", m_cEncCfg.m_bUseHADME ); - - msgApp( LL_VERBOSE, "RDQ:%d ", m_cEncCfg.m_RDOQ ); - msgApp( LL_VERBOSE, "RDQTS:%d ", m_cEncCfg.m_useRDOQTS ); - msgApp( LL_VERBOSE, "ASR:%d ", m_cEncCfg.m_bUseASR ); - msgApp( LL_VERBOSE, "MinSearchWindow:%d ", m_cEncCfg.m_minSearchWindow ); - msgApp( LL_VERBOSE, "RestrictMESampling:%d ", m_cEncCfg.m_bRestrictMESampling ); - msgApp( LL_VERBOSE, "FEN:%d ", m_cEncCfg.m_fastInterSearchMode ); - msgApp( LL_VERBOSE, "ECU:%d ", m_cEncCfg.m_bUseEarlyCU ); - msgApp( LL_VERBOSE, "FDM:%d ", m_cEncCfg.m_useFastDecisionForMerge ); - msgApp( LL_VERBOSE, "ESD:%d ", m_cEncCfg.m_useEarlySkipDetection ); - msgApp( LL_VERBOSE, "Tiles:%dx%d ", m_cEncCfg.m_numTileColumnsMinus1 + 1, m_cEncCfg.m_numTileRowsMinus1 + 1 ); - msgApp( LL_VERBOSE, "CIP:%d ", m_cEncCfg.m_bUseConstrainedIntraPred); - msgApp( LL_VERBOSE, "SAO:%d ", (m_cEncCfg.m_bUseSAO)?(1):(0)); - msgApp( LL_VERBOSE, "ALF:%d ", m_cEncCfg.m_alf ? 1 : 0 ); - if( m_cEncCfg.m_alf ) - { - msgApp(LL_VERBOSE, "(NonLinLuma:%d ", m_cEncCfg.m_useNonLinearAlfLuma ); - msgApp(LL_VERBOSE, "NonLinChr:%d) ", m_cEncCfg.m_useNonLinearAlfChroma ); - } - msgApp( LL_VERBOSE, "CCALF:%d ", m_cEncCfg.m_ccalf ? 1 : 0 ); - const int iWaveFrontSubstreams = m_cEncCfg.m_entropyCodingSyncEnabled ? (m_cEncCfg.m_SourceHeight + m_cEncCfg.m_CTUSize - 1) / m_cEncCfg.m_CTUSize : 1; - msgApp( LL_VERBOSE, "WaveFrontSynchro:%d WaveFrontSubstreams:%d ", m_cEncCfg.m_entropyCodingSyncEnabled?1:0, iWaveFrontSubstreams); - msgApp( LL_VERBOSE, "TMVPMode:%d ", m_cEncCfg.m_TMVPModeId ); - - msgApp( LL_VERBOSE, "DQ:%d " , m_cEncCfg.m_DepQuantEnabled ); - if( m_cEncCfg.m_DepQuantEnabled ) { if( m_cEncCfg.m_dqThresholdVal & 1 ) msgApp( LL_VERBOSE, "(Thr: %d.5) ", m_cEncCfg.m_dqThresholdVal >> 1 ); else msgApp( LL_VERBOSE, "(Thr: %d) ", m_cEncCfg.m_dqThresholdVal >> 1 ); } - msgApp( LL_VERBOSE, "SignBitHidingFlag:%d ", m_cEncCfg.m_SignDataHidingEnabled ); - msgApp( LL_VERBOSE, "Perceptual QPA:%d " , m_cEncCfg.m_usePerceptQPA ); - - { - msgApp( LL_VERBOSE, "\nNEXT TOOL CFG: " ); - msgApp( LL_VERBOSE, "DualITree:%d ", m_cEncCfg.m_dualITree ); - msgApp( LL_VERBOSE, "BIO:%d ", m_cEncCfg.m_BDOF ); - msgApp( LL_VERBOSE, "DMVR:%d ", m_cEncCfg.m_DMVR ); - msgApp( LL_VERBOSE, "MTSImplicit:%d ", m_cEncCfg.m_MTSImplicit ); - msgApp( LL_VERBOSE, "SBT:%d ", m_cEncCfg.m_SBT ); - msgApp( LL_VERBOSE, "JointCbCr:%d ", m_cEncCfg.m_JointCbCrMode ); - msgApp( LL_VERBOSE, "CabacInitPresent:%d ", m_cEncCfg.m_cabacInitPresent ); - msgApp( LL_VERBOSE, "AMVRspeed:%d ", m_cEncCfg.m_AMVRspeed ); - msgApp( LL_VERBOSE, "SMVD:%d ", m_cEncCfg.m_SMVD ); - - msgApp(LL_VERBOSE, "Reshape:%d ", m_cEncCfg.m_lumaReshapeEnable); - if (m_cEncCfg.m_lumaReshapeEnable) - { - msgApp(LL_VERBOSE, "(Signal:%s ", m_cEncCfg.m_reshapeSignalType == 0 ? "SDR" : (m_cEncCfg.m_reshapeSignalType == 2 ? "HDR-HLG" : "HDR-PQ")); - msgApp(LL_VERBOSE, "Opt:%d", m_cEncCfg.m_adpOption); - if (m_cEncCfg.m_adpOption > 0) { msgApp(LL_VERBOSE, " CW:%d", m_cEncCfg.m_initialCW); } - msgApp(LL_VERBOSE, ") "); - } - msgApp(LL_VERBOSE, "CIIP:%d " , m_cEncCfg.m_CIIP); - msgApp(LL_VERBOSE, "MIP:%d " , m_cEncCfg.m_MIP); - msgApp(LL_VERBOSE, "EncDbOpt:%d ", m_cEncCfg.m_EDO); - msgApp(LL_VERBOSE, "MCTF:%d " , m_cEncCfg.m_MCTF); - if ( m_cEncCfg.m_MCTF ) - { - msgApp(LL_VERBOSE, "[L:%d, T:%d] ", m_cEncCfg.m_MCTFNumLeadFrames, m_cEncCfg.m_MCTFNumTrailFrames); + break; + } } - msgApp( LL_VERBOSE, "Affine:%d ", m_cEncCfg.m_Affine); - msgApp( LL_VERBOSE, "Affine_Prof:%d ", m_cEncCfg.m_PROF); - msgApp( LL_VERBOSE, "Affine_Type:%d ", m_cEncCfg.m_AffineType); - msgApp( LL_VERBOSE, "MMVD:%d ", m_cEncCfg.m_MMVD); - msgApp( LL_VERBOSE, "DisFracMMVD:%d ", m_cEncCfg.m_allowDisFracMMVD); - msgApp( LL_VERBOSE, "FastSearch:%d ", m_cEncCfg.m_motionEstimationSearchMethod); - msgApp( LL_VERBOSE, "SbTMVP:%d ", m_cEncCfg.m_SbTMVP); - msgApp( LL_VERBOSE, "Geo:%d ", m_cEncCfg.m_Geo); - msgApp( LL_VERBOSE, "LFNST:%d ", m_cEncCfg.m_LFNST); - msgApp( LL_VERBOSE, "MTS:%d ", m_cEncCfg.m_MTS); - msgApp( LL_VERBOSE, "MTSIntraCand:%d ", m_cEncCfg.m_MTSIntraMaxCand); } - msgApp( LL_VERBOSE, "\nFAST TOOL CFG: " ); - msgApp( LL_VERBOSE, "LCTUFast:%d ", m_cEncCfg.m_useFastLCTU ); - msgApp( LL_VERBOSE, "FastMrg:%d ", m_cEncCfg.m_useFastMrg ); - msgApp( LL_VERBOSE, "PBIntraFast:%d ", m_cEncCfg.m_usePbIntraFast ); - msgApp( LL_VERBOSE, "AMaxBT:%d ", m_cEncCfg.m_useAMaxBT ); - msgApp( LL_VERBOSE, "FastQtBtEnc:%d ", m_cEncCfg.m_fastQtBtEnc ); - msgApp( LL_VERBOSE, "ContentBasedFastQtbt:%d ", m_cEncCfg.m_contentBasedFastQtbt ); - if(m_cEncCfg. m_MIP ) msgApp(LL_VERBOSE, "FastMIP:%d ", m_cEncCfg.m_useFastMIP); - msgApp( LL_VERBOSE, "FastLocalDualTree:%d ",m_cEncCfg. m_fastLocalDualTreeMode ); - msgApp( LL_VERBOSE, "FastSubPel:%d ", m_cEncCfg.m_fastSubPel ); - msgApp( LL_VERBOSE, "QtbttExtraFast:%d ", m_cEncCfg.m_qtbttSpeedUp ); - msgApp( LL_VERBOSE, "RateControl:%d ", m_cEncCfg.m_RCRateControlMode ); - - if ( m_cEncCfg.m_RCRateControlMode ) + if ( rcEncCfg.initCfgParameter() ) { - msgApp( LL_VERBOSE, "TargetBitrate:%d ", m_cEncCfg.m_RCTargetBitrate ); - msgApp( LL_VERBOSE, "KeepHierarchicalBit:%d ", m_cEncCfg.m_RCKeepHierarchicalBit ); - msgApp( LL_VERBOSE, "RCLCUSeparateModel:%d ", m_cEncCfg.m_RCUseLCUSeparateModel ); - msgApp( LL_VERBOSE, "InitialQP:%d ", m_cEncCfg.m_RCInitialQP ); - msgApp( LL_VERBOSE, "RCForceIntraQP:%d ", m_cEncCfg.m_RCForceIntraQP ); + m_cErrorString = "cannot init internal config parameter"; + return VVENC_ERR_PARAMETER; } - msgApp( LL_VERBOSE, "\nPARALLEL PROCESSING CFG: " ); - msgApp( LL_VERBOSE, "FPP:%d ", m_cEncCfg.m_frameParallel ); - msgApp( LL_VERBOSE, "NumFppThreads:%d ", m_cEncCfg.m_numFppThreads ); - msgApp( LL_VERBOSE, "FppBitEqual:%d ", m_cEncCfg.m_ensureFppBitEqual ); - msgApp( LL_VERBOSE, "WPP:%d ", m_cEncCfg.m_numWppThreads ); - msgApp( LL_VERBOSE, "WppBitEqual:%d ", m_cEncCfg.m_ensureWppBitEqual ); - msgApp( LL_VERBOSE, "WF:%d ", m_cEncCfg.m_entropyCodingSyncEnabled ); + rcEncCfg.printCfg(); - msgApp( LL_VERBOSE, "\n\n"); - - msgApp( LL_NOTICE, "\n"); - - fflush( stdout ); + return 0; } -int VVEncImpl::xCopyInputPlane( int16_t* pDes, const int iDesStride, const int iDesWidth, const int iDesHeight, const int16_t* pSrc, const int iSrcStride, const int iSrcWidth, const int iSrcHeight, const int iMargin ) +int VVEncImpl::xCopyAndPadInputPlane( int16_t* pDes, const int iDesStride, const int iDesWidth, const int iDesHeight, const int16_t* pSrc, const int iSrcStride, const int iSrcWidth, const int iSrcHeight, const int iMargin ) { if( iSrcStride == iDesStride ) { @@ -915,12 +730,28 @@ int VVEncImpl::xCopyInputPlane( int16_t* pDes, const int iDesStride, const int i { for( int y = 0; y < iSrcHeight; y++ ) { - ::memcpy( pDes, pSrc, iSrcStride * sizeof(int16_t) ); - pSrc += iSrcStride; - pDes += iDesStride; + ::memcpy( pDes + y*iDesStride, pSrc + y*iSrcStride, iSrcWidth * sizeof(int16_t) ); + } + } + + if( iSrcWidth < iDesWidth ) + { + for( int y = 0; y < iSrcHeight; y++ ) + { + for( int x = iSrcWidth; x < iDesWidth; x++ ) + { + pDes[ x + y*iDesStride] = pDes[ iSrcWidth - 1 + y*iDesStride]; + } } } + if( iSrcHeight < iDesHeight ) + { + for( int y = iSrcHeight; y < iDesHeight; y++ ) + { + ::memcpy( pDes + y*iDesStride, pDes + (iSrcHeight-1)*iDesStride, iDesWidth * sizeof(int16_t) ); + } + } return 0; } @@ -1024,78 +855,4 @@ int VVEncImpl::xCopyAu( VvcAccessUnit& rcVvcAccessUnit, const vvenc::AccessUnit& return 0; } -void VVEncImpl::msgApp( int level, const char* fmt, ... ) -{ - va_list args; - va_start( args, fmt ); - msgFnc( level, fmt, args ); - va_end( args ); -} - -void VVEncImpl::msgFnc( int level, const char* fmt, va_list args ) -{ - if ( g_LogLevel >= level ) - { - vfprintf( level == 1 ? stderr : stdout, fmt, args ); - } -} - -void VVEncImpl::msgFncDummy( int level, const char* fmt, va_list args ) -{ - // just a dummy to prevent the lib to print stuff to stdout -} - - -std::string VVEncImpl::getProfileStr( int iProfile ) -{ - std::string cT; - - switch( iProfile ) - { - case 0: cT = "none"; break; - case 1: cT = "main_10"; break; - case 2: cT = "main_10_444"; break; - case 3: cT = "main_10_still_picture"; break; - case 4: cT = "main_10_444_still_picture"; break; - case 5: cT = "multilayer_main_10"; break; - case 6: cT = "multilayer_main_10_444"; break; - case 7: cT = "multilayer_main_10_still_picture"; break; - case 8: cT = "multilayer_main_10_444_still_picture"; break; - case 9: cT = "auto"; break; - - default: cT="unknown"; break; - } - - return cT; -} - -std::string VVEncImpl::getLevelStr( int iLevel ) -{ - std::string cT; - - switch( iLevel ) - { - case 0: cT = "none"; break; - case 16: cT = "1"; break; - case 32: cT = "2"; break; - case 35: cT = "2.1"; break; - case 48: cT = "3"; break; - case 51: cT = "3.1"; break; - case 64: cT = "4"; break; - case 67: cT = "4.1"; break; - case 80: cT = "5"; break; - case 83: cT = "5.1"; break; - case 86: cT = "5.2"; break; - case 96: cT = "6"; break; - case 99: cT = "6.1"; break; - case 102: cT = "6.2"; break; - case 255: cT = "15.5"; break; - - default: cT="unknown"; break; - } - - return cT; -} - - } // namespace diff --git a/source/Lib/vvenc/vvencimpl.h b/source/Lib/vvenc/vvencimpl.h index d5c831760..00079df2d 100644 --- a/source/Lib/vvenc/vvencimpl.h +++ b/source/Lib/vvenc/vvencimpl.h @@ -1,44 +1,48 @@ /* ----------------------------------------------------------------------------- -Software Copyright License for the Fraunhofer Software Library VVenc +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. -(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. - -1. INTRODUCTION - -The Fraunhofer Software Library VVenc (“Fraunhofer Versatile Video Encoding Library”) is software that implements (parts of) the Versatile Video Coding Standard - ITU-T H.266 | MPEG-I - Part 3 (ISO/IEC 23090-3) and related technology. -The standard contains Fraunhofer patents as well as third-party patents. Patent licenses from third party standard patent right holders may be required for using the Fraunhofer Versatile Video Encoding Library. It is in your responsibility to obtain those if necessary. - -The Fraunhofer Versatile Video Encoding Library which mean any source code provided by Fraunhofer are made available under this software copyright license. -It is based on the official ITU/ISO/IEC VVC Test Model (VTM) reference software whose copyright holders are indicated in the copyright notices of its source files. The VVC Test Model (VTM) reference software is licensed under the 3-Clause BSD License and therefore not subject of this software copyright license. - -2. COPYRIGHT LICENSE - -Internal use of the Fraunhofer Versatile Video Encoding Library, in source and binary forms, with or without modification, is permitted without payment of copyright license fees for non-commercial purposes of evaluation, testing and academic research. - -No right or license, express or implied, is granted to any part of the Fraunhofer Versatile Video Encoding Library except and solely to the extent as expressly set forth herein. Any commercial use or exploitation of the Fraunhofer Versatile Video Encoding Library and/or any modifications thereto under this license are prohibited. - -For any other use of the Fraunhofer Versatile Video Encoding Library than permitted by this software copyright license You need another license from Fraunhofer. In such case please contact Fraunhofer under the CONTACT INFORMATION below. - -3. LIMITED PATENT LICENSE - -As mentioned under 1. Fraunhofer patents are implemented by the Fraunhofer Versatile Video Encoding Library. If You use the Fraunhofer Versatile Video Encoding Library in Germany, the use of those Fraunhofer patents for purposes of testing, evaluating and research and development is permitted within the statutory limitations of German patent law. However, if You use the Fraunhofer Versatile Video Encoding Library in a country where the use for research and development purposes is not permitted without a license, you must obtain an appropriate license from Fraunhofer. It is Your responsibility to check the legal requirements for any use of applicable patents. - -Fraunhofer provides no warranty of patent non-infringement with respect to the Fraunhofer Versatile Video Encoding Library. - - -4. DISCLAIMER - -The Fraunhofer Versatile Video Encoding Library is provided by Fraunhofer "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties fitness for a particular purpose. IN NO EVENT SHALL FRAUNHOFER BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, including but not limited to procurement of substitute goods or services; loss of use, data, or profits, or business interruption, however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence), arising in any way out of the use of the Fraunhofer Versatile Video Encoding Library, even if advised of the possibility of such damage. - -5. CONTACT INFORMATION +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: Fraunhofer Heinrich Hertz Institute -Attention: Video Coding & Analytics Department Einsteinufer 37 10587 Berlin, Germany www.hhi.fraunhofer.de/vvc vvc@hhi.fraunhofer.de ------------------------------------------------------------------------------ */ + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ /** \ingroup VVEncExternalInterfaces \file hhivvcencimpl.h @@ -50,9 +54,9 @@ vvc@hhi.fraunhofer.de #pragma once #include -#include "../../../include/vvenc/EncCfg.h" -#include "../../../include/vvenc/EncoderIf.h" -#include "../../../include/vvenc/vvenc.h" +#include "vvenc/EncCfg.h" +#include "vvenc/EncoderIf.h" +#include "vvenc/vvenc.h" namespace vvenc { @@ -71,6 +75,7 @@ class VVEncImpl virtual ~VVEncImpl(); int init( const VVEncParameter& rcVVEncParameter ); + int initPass( int pass ); int uninit(); int encode( InputPicture* pcInputPicture, VvcAccessUnit& rcVvcAccessUnit); @@ -78,6 +83,7 @@ class VVEncImpl int getPreferredBuffer( PicBuffer &rcPicBuffer ); int getConfig( VVEncParameter& rcVVEncParameter ); + int checkConfig( const vvenc::VVEncParameter& rcVVEncParameter ); void clockStartTime(); void clockEndTime(); @@ -85,32 +91,29 @@ class VVEncImpl int setAndRetErrorMsg( int Ret ); + int getNumLeadFrames(); + int getNumTrailFrames(); + const char* getEncoderInfo(); static const char* getErrorMsg( int nRet ); static const char* getVersionNumber(); + static const char* getPresetParamsAsStr( int iQuality ); + private: int xCheckParameter ( const VVEncParameter& rcSrc, std::string& rcErrorString ); int xInitLibCfg( const VVEncParameter& rcVVEncParameter, vvenc::EncCfg& rcEncCfg ); - int xInitPreset( vvenc::EncCfg& rcEncCfg, int iQuality ); - void xPrintCfg(); - int xCopyInputPlane( int16_t* pDes, const int iDesStride, const int iDesWidth, const int iDesHeight, + int xCopyAndPadInputPlane( int16_t* pDes, const int iDesStride, const int iDesWidth, const int iDesHeight, const int16_t* pSrc, const int iSrcStride, const int iSrcWidth, const int iSrcHeight, const int iMargin ); int xCopyAu( VvcAccessUnit& rcVvcAccessUnit, const vvenc::AccessUnit& rcAu ); - static void msgApp( int level, const char* fmt, ... ); - static void msgFnc( int level, const char* fmt, va_list args ); - static void msgFncDummy( int level, const char* fmt, va_list args ); - - static std::string getProfileStr( int iProfile ); - static std::string getLevelStr( int iLevel ); - public: bool m_bInitialized = false; + bool m_bFlushed = false; vvenc::EncoderIf m_cEncoderIf; ///< encoder library class @@ -120,7 +123,7 @@ class VVEncImpl std::string m_sEncoderInfo; std::string m_cErrorString; std::string m_sEncoderCapabilities; - + static std::string m_sPresetAsStr; static std::string m_cTmpErrorString; std::chrono::steady_clock::time_point m_cTPStart; diff --git a/source/VisualStudio/common.natvis b/source/VisualStudio/common.natvis index 19a06bdcf..cd3e795fa 100644 --- a/source/VisualStudio/common.natvis +++ b/source/VisualStudio/common.natvis @@ -53,10 +53,5 @@ {{(chroma) TU: x = {((CompArea*) blocks._arr)[1].x}, y = {((CompArea*) blocks._arr)[1].y}, width = {((CompArea*) blocks._arr)[1].width}, height = {((CompArea*) blocks._arr)[1].height}}} {{empty TU}} - - {{PU: x = {((CompArea*) blocks._arr)->x}, y = {((CompArea*) blocks._arr)->y}, width = {((CompArea*) blocks._arr)->width}, height = {((CompArea*) blocks._arr)->height}}} - {{(chroma) PU: x = {((CompArea*) blocks._arr)[1].x}, y = {((CompArea*) blocks._arr)[1].y}, width = {((CompArea*) blocks._arr)[1].width}, height = {((CompArea*) blocks._arr)[1].height}}} - {{empty PU}} - diff --git a/test/data/RTn23.cfg b/test/data/RTn23.cfg new file mode 100644 index 000000000..4419aab9c --- /dev/null +++ b/test/data/RTn23.cfg @@ -0,0 +1,15 @@ +#======== File I/O =============== +InputFile : ../../test/data/RTn23_80x44p15_f15.yuv # Input file +InputBitDepth : 8 # Input bitdepth +InputChromaFormat : 420 # Ratio of luminance to chrominance samples +FrameRate : 60 # Frame Rate per second +FrameSkip : 0 # Number of frames to be skipped in input +SourceWidth : 80 # Input frame width +SourceHeight : 44 # Input frame height +FramesToBeEncoded : 5 # Number of frames to be coded + +Level : 4.1 +PerceptQPA : 2 +NumWppThreads : 4 +WppBitEqual : 1 +IntraPeriod : 32 diff --git a/test/data/RTn23_80x44p15_f15.yuv b/test/data/RTn23_80x44p15_f15.yuv new file mode 100644 index 000000000..219c4143e --- /dev/null +++ b/test/data/RTn23_80x44p15_f15.yuv @@ -0,0 +1 @@ +.;;@LZOEVb}SZa__jjec`kkpjbYk}yvrnic]V3.:CHWT6:T`_heaZfhUNZ[[[cVXYYe~ig}zusmic_W763?HLLEBHT^fwdiVKEPIXR?N[`YTi`_Gb~|wsplf`[5097CDBFD8CKNSd[TaPEBTWDD7KHYXQQ`Vu~zwsoje_36;KJPJ?>:BKAKTPJQVJWTO?>E:0?OIOYS]d~yvrmgb7?7?A9C6.6G=NLLT\@TWdXPFZ[<;899RV;9_~}xtole,-7?J?J215J?VQVSVMDTWI@HW\EbQNNI_WBF}gjdbW_Vou|}{tqjTAQW>D8:70787CR^PJp~yuoGE=::=459LVFTU]B]VNTUOWQPT\UTd>?f``^cYI5;99;B>9\V\ainkPKTOANRKSe[_WXIQW\\MRT;>:{}ztBD;BO4IUB46NP^TNU^lfVaZ]TFM`hdc`5BH:VZXXCQI_]OhaBLz,/9C><@A=@`r{8506:HL`bC9>>@886H==>9;Ta28/5>KLTH^eYNRa[XbbOEHH?DXTGQZE@OTOL[S[YOf{}@@595=M]O<=IVP__T^\^[UK7Hj`Wc[9=G`JAHcobAF<878?6IC6D[[DUK@LACD25GC26765EB=9\@4JF2?@NbTGCLQ><;Vwvc+--015GE851:F?>XY]Y[XL@F:@=?N@23931/40DfO3:9FA>?G<;6HOjtF3.'+10/62/4XDFOXOXVCQP8769=9<<5@511GGWiG/33?FJNXPF57>d[q4+/.2/+/70/7CEK?WPROROC6:4667F;639CWSB<5786?00+/113377?;?K=yms5D<35CE;2*-38=-(=L6=4*/1*00-,/FJ6NHKEWRJJ2E2/5.1/**+2/-0./.@bLKdvkc(511=A9>**-/-8:.*+==T\Ud]OS[W:G75:,-/.-05H7.++1@G87kulzWQ'1309<9(+/1*-933/%BYZX`TD5?F9MD6:<3186>B9:>+--,5OAFvjftS?K(*:*C5<.4/1);@0+0?BTLUYCC56=O7:<@8:5131DGI5355>0EV^rW[]^X0GS{2/==C,I83/.3BN4(-7OXUNAV@/*-:202-4:71,2RV8287I2:a}~sqI;*'-2./,26<>>15=6,.1:5;=;76E]=/3.,.16TVbp[][dgnah}{qtjb_gr=1B:-8oc_~~y{yu{|lpprom|{xxzuywmqppunrmo}zx|||sppqnrqvusr}yy{zvvwtrpsotouzqno~wsvxyy{roppsxmjxjholk|zwxyzytlqvopqqp|whovqv|v|~|xvpurstngotuxysr|wrtvv{}}}ztrtpnqjkrrpwt|vrvpnrr{~}y{rrpjlmqpjltwxvtrmou{{y}~zrlllrpolmrsqrxvuwwtt{zv{~xpjgmrspnqvtrmuzyxwsqz{{zz{wqmkjornlpwstrm|tstnqps{}}{{{|}xotmomnknptvvttyukppswuz||}}|~~~{wyullntppsuuwvwwtonpsww|y}}~~~zytskmqvxvwyyztowyusqyx~}~~~yssloqvxyxqzxttzyxstw|}~~zyuonqvy{xvwzzzxzzzwvy~}}~xs}|}wpqtwxvwuxyzyzz{yyx}|}|}~}}|ru}}|zxututry{{||{z{zzyy|}{|||xvx}|yz{snlsrxz~}{{zz{z|zzz{z|~}xz{||w|zqqsx||||}|{|}}{}zxuwz|z{zxntvx{|zywzzzz{yz{qiojzxu||~~|w{uuuutttutttttttsssrrrsu~}~|}~}}}|}|uqrqqpqqqpqpqpqpqopooop~}~|}}~~~}}|}||wrqsrrqpppppppppponnnnn~~~~|}}~}|~}}{zuty{zwrqqqpqpqpqopnnmn~}~~}|}}}}}~}|{yxz|{|}vpqqqqqqqppponmm}~~~}}}~}}}|~zzx|{{{|yzrrqqqqpqppoomn~~~}~~~~~~~~~|z|{z{}|{~prqqqqpqpponm~}~~~~~~}~~|}{{{~}~{|qqrqqqqpqppnn~~~~~~~~~~}}}~~}}}|~}}|}vuqrqqqqppqppon~}|}}~}}|}|~}}}}|}{}}~}~|zvrqqpqpppppono~~}}|}}~}}}}||~|}}~}~|}{{{yvuuxvqqqqqppo~}}|}|~|||}}}~}|}|~{}{}}}|}}yspqpqoo~~~}}}~~~}|}||}}}|||}}||}}||tpqqpop~~}|~}||}}~}}|~}}}}}~|~|sqrqqpp~~}}~~~}}~~~~~}~}}~}}|}~}ssrrqpp~~}}}}}~~~}}}|~}~|}|~z}xussqqpp~}}~~}}|}~~}}}}}}}~}}}|~utssqqo~~}}~|}}~}~}~~~}}}~yrurrqp~}~~~}~~~~~}}~v|sssr}~}~}}}}~~}}~~~~~~x~sttt~~~~~xvvu}~|}~~}~~}{~}~~|||~}}}}|}|~}}yywv.<;@MZMFWcyQ\a__kiebakkpiaZn}yvrmic]V1/;CHYO6;W`_idaZhfSO[Z\\bVX[Yhgj}zusmic_W754?HKKCAJT_gsdhSKEPIYN?Q\aWVi`]Fh~|wsplfa[3187CD@FB9DMMVeYV`OECWUCC8KIYXPS`Vy~zxsoje^35=KKOI>?9DKBLUPJSUKVSN=>F81BOIPZS]h~ywrmgb9=6?A9C4.8F?NLKUZ@WWeUPG]W;;98:UT:;d~}yuole,-8?HAI127K@XQWSVKEVUI?JW\A=KQ7:@?O@bzhZadg~{wsmh3,=@DJB577@<;BdZ?KSd`R?BVH?AdNPKK^V@LfjdaW_Vqt}ztqjR@ST?C8:61888Za^ZbT^aWgbp{wsmVC7GOH:;85546DEFRNS[XZHXN=>NX]c^XdMBcj_Za[I@DU_OJw~yuo9/-?HE<::<368QRGTW[A_TNURQURNW[UVc;Bg`_^cWG=EQLC@Yx~{wr:>4;79<}ztDD:EL4KT?4?JUB;GYP@SZYQ_kfd_^]X>ABTdabRJZWPNPLDXE7IWo~{v;D<7ASS<7A=8QO^R;HTE\Kcdbd\^YQ`GIMBL[DPonYVF?M]GMPGSsz/.[E8VNVJ4>EN[I?OU`mcX`[]QFNaide\3DF;YZYWCQJa[Pj^APz,/BIGQJC;??A;Aat}75/79<@a\FGJVT\ZV^QTEBNQQbRUoVLGCFNJNVM?>@888I<>=9FYSGTXD@QSNL\R\XPj}A?495@P]K:=KVPa^U_[^[UH6Mi^WdU8>I`G@Kfn`?F;879@=KOOT]S[lWo|x=7:30197;98?IJKR_eUST]O=]`d_eE45>@NE3742@+./FH4:35DJ@E;53:EWS?;5788?.0*/123479@;BJa81.212+//89:HL[U^\RH86:@C;28CE:1*.49<=E*-/02188;@?~sp4$&./F@U,*+*6<4AOZUNHABE68JMhvPh2'120LQJ+''''.3FQFM?;=8CNJ?E>CQK;933////**0+*-0/357Lsdqw~87($@OI:(*-,*607@:B65RDDIUC67E<2013/+,/40*+.0/23..>xopuj}.>,)AI7=1+00,0/.+1HG8OGLEYQIH3D004-1/**+2--/./.DcIO}cy}id)6/1@>9<)+,..:8-),?=X[Ve[OT\T:G579,./.-17G4-++2AG79uuluVT'22/;;7'+/1).:23.%HX[YaSB5BE9OB5;:2286?A8==+--.8OAG~igsQ>P%-7+B59-4.1)>?/+2@CUKXUBA47UV_{91=;13>,/+(.60/.+3GSQBCL<:)'.1./,276>=05=4,.3;4<<;76H]:/3.,/18VSgl[]\ehn`k|{ptia_il:2C8-DJ[H4AZa_kc_[kcPR^X]^`WX]Wo|ep}zusmic_W646AJKLACNTalkffPIGPJ\K@V\bR]g_YFu~|wspkf`Z.379DCAG>:EOK\eUZ]KDFZPC@=KLZWNV`V~zwsoje^44AJMMF;?9GICOUNIWQMVRK=?F32IOJTWV]p~yvrmgb=88B>:D0/PXY<@OJ7=@?P>qugXddk~{wsmh-0=@EL>479@<PUg\M=GTH=IeITFQ]U;X~fid_WaWwr}{uqjO@XKA>8:41888;PeMHIc[WE`VB:DXVff_aF@C`__[`Ta`Yfcu{wrmZ9;LNG7<65467GEGSOVZ[UJZL:DM\^b]WfEEjg][`XDAFZ]MO~yuo3//CHC:9;:369WLLS[UCaQLYOVQUMZZT\]6Jh`_^cTE=FQGD?dw~{wr:<3<6:=C<7A>:@Z[^ZBE^T^diq`OJWIATKMXd^]VWGUT_YIWI=;D}ztDB6JE6MS<3DLT==LYMBWZXQejfc]`[TSZDOMJU~z/2_:?YMXB4AGP]BDPVdo[]^\]MGSejahQ3IB@]ZZSEOMcXTlVBYz./B>@UIGHAHFJKMDNRjoaRZEIAE\md[^B41<5:9GA9CS^ERWA1E}*2EN@2PBABKBCYNOIYiYUGRHDUCaiY^V?R@>?;>SRFKEYUV<27g~22LCG@H_I_DAHNDWL^[PIAGONmL[bML[N`\VD898BRHC@77J[OEZQC@=UWSd_]H4126DASROO\R[XUoyA<395BT[E:?PTReYY_]]YSD7Xg[YgJ8BP\DAQlmV>F8:6;?ALQNV^OchV{v>6;/039:;97CHMKWadOXRbFCb`bab=56A@Q?A[[cU_E6GYQDCTWD[W_KOK\NO^`YWfRC7/;ECHMFWUA@P`SKVOdRF?:=Pn|ytyuod-3,097=NAI7;M:7AXiMKQVMXkPDQ[ZXJCC4:BB?DA=IkdJOPQRJ17@@o}|~x`.1,32=4?V64824@?]XX_WRI<1:K9659?Ma^XbUGZS<4AAd`+)1E.8TTD786.5MF\_m_QJH=OEONF969HA8E\49O:7A?Y_PFEMP:;H9H[Y][ZXDEA<>3/7JHae:038AJHQXKB49J|_Z3(/,4++15.2:GFIGXPQPRK=78384<;JO;88>QR^ZY_L?NK;EA943*.-21397F:IQF<723.0/.*,/(*-0143>P^wv~82&(HLF6&+-+-51<>?@3HLS?6:H72023/+,04.),/0/33,2Dplyj}3;'-IA8;-*2-,0/.+6LA>QFMGZNI?6C-12,3-*+-3,/.//0LaDYza{gg,6-3C9=8'+,/.<4-)0AA]VYfXOU_J7D:+-,.@MBMmxjoN<]$421>74.3.-*C:,,7@GUK]NC@29?I3;<=793134JFD542:92NW`wS_[cL3J_{.5;A:1K/4,06KG,(3=YVUHFW7.*3:/20-7:40,5g~I674AE/El{}pm?@YQnz53=9-8:,0)(1700,-5OQP?GJ97'(/0/.-39<@qLrz*063<2,&&-*)$%)7@K_X98?:17=0..6;6<<;6:NY412,,11>YPsf]]^ejm^s{{otga`na47C4.JyUn~}x{yu~zlpqrom~zxzzuzvmroqtnqlq}yx|}zqopqmqqvtrs}xzzzuwvuqqrqspu{nnp~vswxyz{qnpptvlk||iiokm|zwyyyyslsuopqpq}thpuqv}v}}|xuqtqstkhptuxyrt}ustvw|}~}ysstoopjlsqrxu}usupntr|~}~yzprnjlnrpkmvwxutrmpv|zy~}ypkkmronknsrqsxvuwwtv{{v|~voigmrsnnrvtqmvyyywrr||{zz{vpljlpsmlrwsvpnztsrnqpt|}~|{||}vpsmnmoknpuuustyrlpouwuz|||}}~{xytllpspptuuwvwvrnnpuww|y~}~~~zxtrjnrwxvxyyysoxxursyy~}}~~~xtrmorwxywr{wtuzyxstw~~|~}zzsnnqwy{wvxzyyxzzywvz}}~vu}|}upquwxvwuxzzy{z{yyy}}}|}~~||qw}||yxutvssz{{}|{{{zzyz}}{||{xvy}{y{{qnnssyz~||{z{{z|y{z{z}~|xz{}{x|xpqsy|~~{|}|||}}|}{xuxz}z{zvmuvy|{zxwzzzzzy{{ojnl{vv}{~~{x{uuuutttutttttttsssrrrsu~}~|}~~}}~|}|tqrqqprqqpqqqpqpqopoooq~}~}}}~~~}}}}||vrqsqrppppppppppponnnnn~~~~|}}~}}~|}{zttyzyvrqpqpqpqpqppnnmn~}~~}|~~~|}~}|zyx{|{||upqqqpqqqppponmm}~~}}}~}}~~|~yzy|{{{|zyrrqqqqpqpqoomn~~}}~~~~}~~~~}|z{{y{}|}zprqqqqpqpponm~~}~~~~~~~~|}z{{~|}{zqqrqqqqpqppnn~~}~~~~~~~}}}~~}~|}~}}}|utqrqqqqpqpponn~}|}}~|}|}|~}}}}||{|}~}~|zvrqqoqpppqopoo~~}}|}~~}}}|||~|}|~}}}}||{yvuuxuqqqqqppn~}~|}|~|||}|}~}|}|~{}|}|}}}~yrpqpqpo~~~}|}~~~}||}|}}}|||}}||}}|}sppqppp~~}||||}}~}}}~}}}}|}|~|rqrqqop~~|~~~~}~~~~~}~~}}}}}|}}}~rsrrqpp~}|~}~}~~~}}}}~}~|~|~y{y~tssqqpp~~}~~}}|}~}}}}}}}~}}}|~tssrqqo~~}}~|~}}}~~~~~}}}~xrtrrqp~~~~~}}~~~}~~v{rssr~}~}~}}|}~~~}}~}~~}}x}rttt~}~~~~wvvu~}|~~~}~~||~}}~|}|~}}}}}}}~~}}yzvv6:;FTODQ^zXVa`_fleg_ljrmeYg}yvrnic]V,5ABSU96O]_ce_[akYOW^Z[c\XV[_{ng}}zusmic_W31;CKKD?ETXe}ej\LFNJUVCJ]`_Qjb`OT~{wtplg`[/54B?0@;?;.2D@GLKO^EOZa]QJQa<<7=6L\C7S~}xuole,3M402GAPSTSXMCPYLBEY\K;DT;9B>EKJmb]iey~{wsmh(8?AIG736=>;?ZbDER_eWC=SMG;[ZHPC\XJ>tphfdX[]dyv}ztqkBIY?D9980688;Ne\__Z[c[cak{wrmJ1API?693556=HGNRO\V`JWSG8MO`a`Z]]?SsaY^_QBDP_WJd~yuo-,7GF?9:;547DXDSU`FTYNNWLWNUQ^YTgK6ah_^a^O=BIOADJsz~{wr=5796=A>;9C9;M^YaN=UYX`hlnRLQREJYINe^`YWPKXX]RJU>?8]}zt@::O6@QJ67KSI;EXUEKYYUYjge_^^ZF>DLadeYKVYROPPASR9?ZV{vC<4>JWA<;6\^QB:BC:QLZUWehd]DNN;;BWVROWR\_J;BCE?AEWtk~w263L@=:=?8KQXZA?WFTPXi`e`\aM^NCMFF[JJct\YKAEYPDQHNhz,IQ4PQSQ59EJZT=KS[ljVb]]YGM[jgbe<I^RGWP72j}-:ND8;O=EDO;STNLPdbWNLR?PGPk`Z_CIJ;>=:JXJFGNYWN62E}1=NBD@SWQW?FNHNSQbRNCCLK_`IhTHYPY_WP;8:;MPF??EA?8Vp{7,59;;K?859FENRGL174=LHPj`a[bRcab\SKFGGJLZ^TYM<:>BIUPKWTUZVeyt>774bqzqzuhm1--75:CFHC5GH6H:5>E?N{}xhn1,/16:4OH0470<7YJ2DJ2=BFaVJBJQH9;Elt{*+1/4CM:718CA;UY]\[[N@H;?=>OD22:5205/F;647AVVE:67:8A3.,.215287>;=I>Xqp3K2-.Se-32503>JHZTNFKT@;=7038@99<1.,03725,10/5832,,46>9J-,./30698@>pi&%5+A=R2),+3B5>NWZLP?CD:79F<89=ML=CCN]Sb_STYZ:D<4:.,./-01?3,+*/8I>4[~{~^Qz///7;7*'-.++931/'H=LH;5=11869E;?H/+-.2KDDes|jubH=~*7(?38,3.0'7?0+1<@RNR[BC84;I97:=896131BID<532?2>RZf~lV`[f9>L{z-89B+F71/*3@P5),;M[UQDTD1*.95/4.1972-.C{f>372J96Zvyxq^;IZSy.9:1.?-/,',730.+0@TQFBL@5.'+1//-05;>@=MR4,..0@07N~vzsxlhbi\7^Tay)5387.($*,+%$&/;FT`F4:7D[J.4.+023LUT|^`]ahnh`~xxppdbdyxF0D;/7oeeu~}z|wuvlqrqnn}yx{xu{snsnsrmplx|xz|}xopqpnqrvuqv~x{zyuwtvorpsrru~lot}ttxyy|ypnpowsjmyhjojp{ywyyyyomusoqrps}qirtrww~}{ysrsrssjiqtvyxpu|sstwz}}|xrstopnjmsqsxv}sutonvr}~~~yxpskjlosnkpwxwttpnqy|zz|wnlkoronjosrrtxuvwwsy{yv~}umihpssnnrwspnyyyyvqs~}zzzztokjmprmkuusunsxttpoqpw}}|{|}|sqqmomnkoqvuvsvyomqovvw{|||~~yxyqklrrpptuvuwwvqmoqwvy{y~}~~}zvtojosxwvyxyxrqywtqtxz~~}~}utpmpswyytt|wtwzxwsuw~||yyrnoryyzwvyzyyyzzywv}~}}}ty}||rqruyxvwvyzzy{z{yyz}}}{~~|zp{}}{yuuswrv{{{}{z{{zzy{}|{|}zxvz}zz{ypmosuy{~{|z{z{z{z{z{z}{y{||zx}vortz~}~~{|~|||~|}||xvy{|z{ztnwu{|{zxxzzzzzy{zmlmo|ux~y~yyytutttttuttttttttssrrrsu~}~{}~}}}{}zsqrqqpqqqpqqqpqqqopooop~~}|}}~~~}}}}}zuqqsqqpqppppppppoonnmnn}~~}|}}}}}~|}zysvzzyuqqpqpqpqpqppnnmn~}~~}|~~~}~~||xyx{|{{{rpqqqpqqqpppommm~}~~}}}~}}~~|~yyy|z||{zxqrqqpqpqppoomn~~~}}~~~}~~~~}zz|{y|}{tqrqqqqpqpponm~~}~~~~~~~~|}z{|~}}{uqqrqqqqpqppnn~~}~~~~~~~}~~~~}}}|~}}}{ttqrqqqqpqpponn~}|}}~}~|}|}}}}}|||}~~}}{ytrqqpqpppqopoo~~}||}~~|}}||}~|}|}}}|}{{{xvuvwtqqqqqppn}}~|}}~|}}}|~~|}|}}{}{}|}|}~wrqqqqoo~~}}}~~~|||}}}|}|}|~}||~}|}qpqqppp~~|}~|||}}~|}}~}}}}}}|~|}rqrqqpp~|~~~}~~~~~~}~~}}}}}}}}~|rsrrqqp~}}~~}~}~~}}}}}~}}|}}}xx{{tssrrpp~~~~}~}||}~~|}~}}}}}}}}}|tssrqqp~~}}|~}~}~}~~~~~}~~~vstrrpp~~~~}~~}~~~~~|xyrssq~~~~~}~|~|}~~~}}}~}~{z{rttt~~~~~~~~}|wvvu~}|~~~}~~|}~}}~|}}~~|}}|}}}~}|xyuv87>MREHYdnO^a^akihcfllrhb\s}yvrnic]V.9AFZD3>X^^g`]ZjePR][\^cZW[Yofr}zusmic_W23>GIJ=@LS`mkfhPIGQJ]NBV^cV\ja]Io~{wspkfaZ237?@?E<:DQK\fWY^JEDYRD?=NNXWNWaV~~zwsoje^/@FLKE:?7EJDNTMJXQKVRKDL>459?<OTg\O>FRK>FeKOEKZU>Qijf^V_Zut}{tqj>UJ>@6:5078:;LdIGJa[XE_WC8BYTff`dGCA]b^]bW_cZfdw{wrm57JLE5;54376GEHTOS\ZXJ[M=AL[^a]UhGDek]Z_[HCG[_RO~yuo--AGC:9:946:RMKT[YB_PJWOSQUP[\W\d8Dmd_`cWE>8?X\\[BD]U]ehr^OFWJCSRITe^^VXJRU\[ITH@??v}zt<2IE4FS=2BMT=@L\O@UWWTejfd__[U59ATN;>6DdVK;@ADE?DFopr~w32?I=<7B;=VPaL;NRIZFkcbb]cSW[BIJBQYCSpjVTF>NXEHMITz2Z8>WLZB5@HO`ADOVcpY__]_OGSckbhT5HG=^_`WFPIa^OiWEZ{-CQ>>===VSEIEZVX@24\}1NBH>G]J`IAHOHXJ^ZOIBGOPlJ[aLM\O`[UD899CRJE?FDB9Afz/099<@iOJCGUVZZW\PRBDQPVcJ`jSKHDKRMOWG@9DF;56=KFSMJc266FMBh^fUeYYea_WOFFHFNQcVXWB:<>@HTd\:B768I9>?;?[r4,6AIGSIh_XG\_[]eZHFFEAI\NDZQ@?:VVTd_XK4205BBQTNMYOW][s}<285CMZE8?OSTgXZ^][ZQC5YgZXgK9CQ\CATlnU=B787;BANSRS^PboUzr67-/47:9:7EGKKWadOZQaAEbb`a_?48BCO>@[^dQgG6EXNBLgz|~zuxue|2*185;J?M6=N=7DXjLKRVNZjODR\[VJ@C4;AD>FE>GkeJMOTVD16B=k~~y|_/,/1<1?U53844@>^YX\VO;LcPEXEHM@J;19H745<>Oc[XcWFWTB5ABc]&/C+7OSE877-7LF]^l^OLG?OFPOB:8:GA7G]67N:7A@V^NHEQS>8DUzrc)-026R?943>E:JWZ][\XBF@>?=HO707932240RcA4;;JL978>RS`>/-148\Y^JBPI:G@844B80ED(+++A;7HP^NSCCBB68@C88CF?10/15:/7:+,-0143AJUmwUb&--:OMA'('()13QMML@<>5KJE79H:2036/,-02/),//030,0>}qrrk}3#-J<78),3-+0..+8J??SCKFXKH>5A-.1,8-*+/3++/./.I\DScvmh1+2B5>5(+,./;4,*1BA]TZdYSV]I8F1:3+-..,036,++,2AI67xl~\R/-1;70&)/+)0:03)*TX]^\R=8HCAQ@5:6-574@C7K<*+./BKBJjgwYAN4*374-.0/,+@5+.7=IVK]LB@1K2Ii{|}prJ=SOrx1:4*96,/))2810+.3QOO=II63'(00/0-39=B@=jy;0/.-983?kxp|rnbchDE|sQ{w00470)%%/**"&(8>L^W7:?;299/-.6:8>7<7>N[814,,41AB19PIMWX_^}~yvrmgb2:=8>:./B>CHMN_FL\a^RHN`?:7=9G^F9K~~}xuole/:E:J5.0ABMSQRYMCNYLCBY]L;CR;:C>BVEqf^lfy~{wrmh8=?DH645==<>XcFCS[fWE;PLI9X_GMATUO;lwjheVY]b|u}ztqkIV9LWZhceXD?Gf]a`^Yc__dj{wrm2FNABIs}~{wr34:5;;?:8?89M\Y_P>SXX`hjoPLMUCFYJI__aYWSJSW\UDS?C:K}zt57N89IK64HSI9CUXGHVVUYjge`^^XH=FK_fd\NSVSTRRCQU<>YLt~{v:0D<MGMla\^EEJ9==;DYKDFN[VP82?w}9L@E?NVN\ABMIMSQbROCBML^`GgRHZQY]VP;8;7Rp~,399;NiDMBMSZXU\USIAISO^YJl]NKFGOPMQS=?9K@:57CHKWGM43;JILn\^ZcRbab[QKFGGKK[]U[O;:>=DK]eL6?@A=85AB8B<=Jd,19FFNIUgXPMb]ZbbPDGEACTWHK\G==A\O]cZR<512>F^O?IaofC>=69:@@JNWOXZIu^av42-178<89;JFNN^e[PZWV9Wcc^dO44>EII:M_cYW^;:OTI?>R[\DUZ_Xv{}zz}y.21253DYI;OVMP\^QMJXSGW^bUeYF;05BEDNGO[P=@[h|u{xqf,,829ABGE6HH7AHB[_CQQCNFBH32>E1388DD`&<5-CQN::53/EFR^ehUJM;LHITF<96CD>7[K2BI3=AEbWHCKSK:@PE22;83/6/;bV599DE?:5CJGTVF97?P|bU+0..)*40.5EAL@SRRRONG685576?@LE295LO\U2/-33<@[TND<2Er~o}F)+,5A4?35DO@K]\WAJP?=F:738@VVE886=9C30+.02447:>;AG=U~owS4+/Qf-22317>KH\VKGKQA<>912:B;9<1/,02614,1005839H>PUV~myHZ),3/2-,0/<9FGXU[_UM<6<8B>33?B=4--26=:J-,0.3067;=?ip~%4,>9N-),+1G5@MXYMP?DC;78F;79EC60/1296/>/,-/1237KM\}pKx),-IJL/&''(+1?UJMD==9=MH>CE=PM<:141/1.,*.,)+/0448HcXwx&";JH;((++(627E9E84LGN[Sa^UTYZ;@=27-,./--/52,,*05KD0RyokZc,-886'',-)+841/%>W\Z`WH8BF?LI:6:.0856D<SNTYBB87;F?6;58:6241?G>?63/;4;OV_wTc]eL7Jgz35@)F00+-0AN2(.=QYVPDSD1+.:50331963,.:mdA080L?7[qyzymm>CTSw67,/<,/+'-850-+/BSPC?N@5-'+2-0005=?B=E~Y6.///>18Lxpol`fY:aZiv1.72,&$*,)%#'19EU_G3=@3692,/0:7<97:9ESP070,/41KSLac_bimjazzxqrgbftxF3AB1;ujmqz|zvzonqromw}wy{vwznrootoool|x||}tnprnqqttsp}{x|zwuxstnsnvovwwnozswyyy|tnopqxmiuohnlj~}xyyzxvlquqpsqpy{jkvptz||ywqtqrsnhnsuw{to{yrswv~}{vquqnpkjrrrvvyyrwqpqvx~~{zsqrillqrjluwxvtsmnr}y}~zrmllqpmmkrrrrxwtvvtv{w{xqkhkrspnpuurnszxyxuqy|z|zyqnilornlowsurm}vssnqqr{}}|{|~xpsnomnmmptwutsywloqqwty{||{~|xxvlmmtpqqvuxuxwtnopswv|zz~}~|ytsklqvxuwyyzupvxusrxx|~~~zsuloqvwzwryztsyzxtsw{~}}~zytonqvyzxvwzzyyzzzyvx~~~~yv}}}xprswxvvvwzzzy{zzyx{~}||~}~sv~}|zxtuuurzz||}{z{{zyy|}|{}~{vy|}y{{tmnrrxz|}{|z{zzz{z{zz{~z{|}|x|zqprx{~|||}}||||~{~wx{|{z{xosww|{{yxx{z{yzy}ujokvzu|}{~}w{wtttuttttttttttttssrrrsu~~~}{~~~~}|{}wrqrqqpqqqpqqqpqpqopoooq~~||}}~~}}}}|}xsqrrqqppppppppppponnnnn}}}|~~|}}}|}ywrxzzvtpqpqpqpqpqppnnmn}~~~}|}~~}}}|{yxy||{|wqpqqqqqqqppponmm~}~~|}}~}}~}}{yxz|z|{zytprqqqrpqpqoomn~~~}~~~~~~}~|zz|zz||yoqrqqqqqqpponm~}~~~~~}}||y|}~||~qrqrqqqqpqppnn~~}}~~~~~}}}~~}}}||~}|}vusrrqqqqppppoon}}|}}}|}}}|}|~|}|||}~}|}yxrrqqpqpppqppoo~}}||}~|~~}|}~|}|}}}}||{{yvutvvrqqqqqppo~}}|~}}{}|}}~|}}|~|{||}|}}~|tqqqpqoo~~|~}~~}|}}}}|}}|}|~||}~|{{pqqpppp~||~~|||}}~|}}~|~}~|}}~}xqqrqqpp}}~~~}~~~~~~}~~}}}}|}|~|wrsrrqqp~|~~}}~~~|~}}}}}}}}}{xvwtssqqpp~}}}}||~~~}|~}}}~}}}}|~}yssssqqp~|}~~~~~}~}~}~}~|~~}tttrrpp~~}~~~~~}~x{usssq~~~~~~|}|~~~}}~}~~y}usttu}~}~~~zwvvt~}}~~}||}~~~}}|}~}~|~~|~|~|{xwuu3;HMAEV]oN\`^_iigeemjrkd\n}yvrnhc]V4=AVF1:S][e^\YhgTO]\\ZfZYW\hhp}zusmic_W0;BGH==B=6AMMVfZW_MDCUVCB:OM\XQVbTu~zwsoje_>DGIC7=6ALCKTNKVSIVTM>HL5?B=G>256><6680478>BcIGH_\YCZ[H:>WRdf`hKE=Vg^`bZ`eZdcs{wrm4CLD5763336EDFSMR\XZIZO@=LX]b]VdQ>Wn_X_]KDJVbUNy~yuo+=FC889:458NQHSX\?[QJUQPQSRZ]XYh@;kk]_d[H:@LKA@Yv~{wr0958;=<7<>7;X[Z\F?\S]bioaNEUNBOUGNc\aUZMMTZWLJI>D9^}zt0DG3?L?3;LU>:;ZHIGCDIKIKCKQinbR[GJCDWle[_I5188;:BA9DOaLL]Q6C}L?:=;@GSb`;:A>C777H:=C;>Vs,4@FDPEd_XIXaY^c[HFEE?J[OCXQ@=9RXQd_VI8313C@PRLIVHS_aux073FG[C8=MQTgYY_][ZSD5UgXWgO:CN^CASknW;@77:;EBMSWQ]QSyStl7*/478;87CIKMVbcQZS`ACdaa``?48DDO=?Y_bO`P4BRND=FT[TG[bXa}{{yz}x20042:NV?ETVE]X^KOL]JM]cZ[eN@60;EDHNGYYG@IZXNYD`]SGEI?BggJLMVZI25@=[v}xt{zfm+-0;1;R62844>>\ZW\WOMe[WbWFRZF7?@Zrp,?,5KNE786.6LD^\n^OKF=PEQPA::8HB8E`67J;6AAT`PGEQTB7@I~kuy+/15O?743?D;IVZ_\]WAE@>?>HO9/6;5225/NcC4;GYUQ]HJRC977;;;=89A2.6DD^g>044@HEJYMA3>D`p\W0+1)).3,1;FBLFVQSOOM>68384>6<858NI>YZ]KASH9F?854=GAHkrqK&04mE+3123;EHQ]NJHQI=>>744B?::7/.,1425/.0/2982CCEXNepp|X<-*5-2*0-78?ENZUbXRE6;<=@9/;>B61*059)..2127:==El-03@7HP`NUCCBC69>B87AFA11/15;07<+--1033?NR`~eP+'6JIC=IO=F~rjygK?%423+-./++?4,/7@8410;5GOXe~jYe[g;@Nz0+.*.6LA)(8FZVSJHS5--3;02514640.1KnT7258O2Hfs|xso]9JMrv51(:1,-()391/+.4QOO7IK63'(/0,2/39=A?:^vB2--/582>e~xw{of_dBNvyXu,14-($&,*(#%*5?K_U87?:388-..578;489AIV?06,,22:VGav`d_gmofj~wuqmeek{b77F=3Ue}py|zt}|moqqom|}x{zvyymsnqtnomozy|~|soqqnqputrrzy|zwvwtsosotowxsooxtxyxz{sooptwkjymiokk|wyyzxtlstpqsoq{ximvpu|~{zvqtqrtlhosuyyrp|vrsvt~~ztquooojjsqswvzxrwppsu{~{{qroilmsokmvwyvtrmos|x~}zpmknppmmlsrsryutuwsw{v}voihnrronqvtrmvyxywsq}|y{zwpmimosllqwrupo}tsrorrt}}~|||~vprnnmolnquvuss{tlqprwuz{|||~{xxtkmospprvuwuwwsmopuvv|z{~~~~{xtrkmrwwuxyyytoxwursxy}}~~~ysskprxwzuszxsuzzwtsx}~~yyrnorwyzxuyzyyyzzyxvz}}vy~}}uortxxvwvw{zyy{zzyy|}}}|~}|ry~}{ywutwst{z|||{{{{zyz}}|||~{v{}|y{zrmnrsx{|}{|z{zzz{z{zz{~{||}|x}xpqsy|~|{|}|{|}~|~{~xy|}{z{unuvy|z{xxy{z{yzy}rjpkyyu}z}~|w{utttutttutttttttsssrrrsu~~}}{~~~~}}{}urqrqqprqqpqpqpqpqopoooq~~~}}}}~}}}}}||wrqrrqqppppppppppponnnnn}}}|}~|}}}|}yvsyyzurpqqqpqpqpqopnnmn~~~~}|}~~}}~||zyxz|{{|upqqqqpqpqpppommm~}~}|}~~|~~}}zyy{|z|{zxtprqqqqpqpqoomn}~~}~~~~~~~~~{zz{y{||{orqqqqqpqpponm~}~~~}}~}||y{}~||prqqqqqqpqppnn~~}~~}~~~}}}~~}~}|}~||}uurrrqqqqppppoon}}|}}}}}|}|}}~|}|||~~}||yxqrqqpqpqpqopno~~}|}}~|~}}||~}}}}}}}||{{yvutvuqqqqqqppo~}||}}}|}|}}~|}}}}{|||}|}}~ztqqqpqoo~}|~}~~}|}|}}|||||}~{}}~}|xpqqqppp|}~~}|||}}~|~}~|}}~|}~}~urqrqqpq}~~~~}~~~~~}}~}}}}}}}~|ursrrqqp~|~~~~~~~|~|}}~}}||}zzvvtssrrpq~~}~~}}|}~~}}}}}}~}}}}|~}xssssqqp~~|}~}~}~}~}~}~~~|~~zstsrrpp~~~~~}~~~~~}~v|tsssp~~~~}}|}|~~~}~~~}~y}usutu~~~~}yvvvt}}}}~}~{}}~~~}||}~}}|~~~|~|~~|{yvut4?KH>HXg~[N^]\bleibjjnqf`aw}zvrnid]V:7:8GEDPSMLXMOVQE=?F36NJJUWZ`s~yvrmgb6=79;,.>A@FNI]MF\^cRKHcE:6=9C\N=@x~}xuole6D7I7./=\Iqvk^nku~{wrmhA:@F6359<:=RgI@QVfYI:KMI;OeEP@MQV9\kkd[T]]{t}{tqkR?>9472146<=RYHDO`[REcRA8GXUgdaaFA>ca`]`XbcZcg~{wsm4II>285435:JEJRNXV_OPWJ7GL__`[UhCCgfZ[_WGHN\`PX~yuo/?C>78;635:WHPR_LE_MIZLTLWP_\Uc_4Kqd\`cS@=BODBDjs~{wr1838:?:6A:7E\Y^T?MZVagiqTMHWFBVKIW_^]UYIST\WDP@IB?p}zt2K<6BK72ERM:@RXIDUTVWigfa]^YL]RW~{w19BRC;>3O_QE9AD:MLP]Tbhd`ILT>9?QXTNWRVbU:@BEDC?K|ol~w.A@999A8HTT^F4FITZ>JPYkkUb^]\IJXfi_gI6NABbcbTILEbZRfP=dz>6HTEFG@GIIJFFLZmlWYSFI@Jal^\[=42:5==B>:FW]ET^C3Z}DD;1L;CCO>MUMLQadWQKS>JJIie\_HBK9<<:BUMBHI]TW;39m}I79:?=BJZdQ5>AA?75=E7C>:Fb06CBJIMfYRK__XbbQDIDABSWIG\G==>[OYcZR?6127BDSOIKTIVck}|71=ASP:7DPQ[dU_\_ZYK;?e`U\e?=E[R?G]ogF;?39;>CHPWRV\GinWm1+135987;IHMN]d[P[VX9Tcb]cT55;FHL9J_b[Uc@8KRI@=MV\HQadXp{{{yz{.0052AUN=NVNN[[TMKVVHV]cUcZH;14ADDMIM^S@GLbKVOMa]OB=AV]{~}v|wju,526>EEE8FJ7;Gc]JKZORbdEHV^UV=E<4>H>BFE;Sk\EOO]W@/;??sy~{~tyy_{*.4;0GJ.371:6XP0?I4;CD_WLEKRN=8DVmc--3=J8528CB@OE40;74/6.8_X599CH@DLiV233:BJFPVD76DIujWc~/,+)(10.5CAJBRRRQOOH786475>=JE085KO[X5/-24;?XWLE=3@mmv+'+1A1?25BP@J\[VBGQ?=F:756@SWF387<:C5/,,10349:@:AH?Zmr1)/Jj./2216?JGZWKGJQA<=;539C<8<2.,/3504,10.7866G>QRM{kqO)-//1-*1-<7EEYU\`VM>4=9@=42?A=4.+24=9K/+.-1158::9Z~q/+<9K+(+*-F6?MW[MQ?DC>7:C;7:DE81/0197.?2,-.0136HN[nwX_**IGH)&&'',0?TILD<>9H60244.,.11+*-./11.,3Fssso}$L[Sb^UUWZ==@08-,-.-*/41-,+/0DO4I{nbT,552&%,-(*842.&?5=3665341:G:>42.6:QYUPCSB3+068036/662./3]bD252FI4ZjxzwppM;MRv2).9)-)',740,+.CRQC9OA4/'*2,-305;?@>@rZ9....818GxyqtpacU?fdjt,4/*%")**$#%18EU]F4NVeyvbhYLFOIRVCI[^_OgdcOR~{wspkf`[48=<>>5;FMK^\RaRF@OZGD:HIWZRQ_Z`~zxsoje^A@FE878;I@GSQOOWJUTQ@=A@0546.346><]QHCW^\JPaL<9QT]gbfWC>Hh^a_]\c__bl{wsm8KH7564346CLDOONYS_IVQE7LQ^a^X[c=ImaY\_QGKS`[Ke~yuo4>B;689536DWHTS^AQXLNXLTNUS_YTjP3\p`\b`O<@EL@?Owx~{wr6739Ex~zt6I79GF36IUD9AWTCLVWT\jge^^[WE?FKadc\NTTRUSOBST8D\Q`~{w/HGMez?0QISR68IJ[N@LQ_pcWb\^VFN]idac==P:M`b^LOGJeSZbFBw{:6NKDBF@GGHKCIOcmgP\JHCAPihZ^Q735;6:ITICGQZVR83D}=??QQHCCIC;6Uj27<9UfFKGPVZ[W^PSECLSObRRkWLIDHPONUL;>:G>:57FKOWIP.@IFOf_^`^Sfb`YPGEHEJK`YW[I;:?>FP_cC7@?C:84D?:F;;Nk3:C@QBV^ZLR`\Yd]MDIE>DYREPWC>:J[N`bXO9403<@JSMHOMNZbr}7.D?YE79IRRa]V_]^YTF6Oh\UdX:@H`G@Leo]>=;48^aa_aH36?EMD;T^dQ_^6>PQG>@NXXFYf^\x{}zz{.0354EWGATWFXV^MNJ]OK\`]VfRB8/8EBFOFS[L>JT]IZDW`ZK>@CZbzx{vh}.515E@G<:J@6?NiPKOYLVhVCMY]SQI;CH@=`iPIMQ]Q70==F||~yxxw]*.953O=1751?:ZXV]WR>FaVBVIEPACB14C=2492H@5>CLcPJEOSH:E=CWY^[ZZC@AF>95=IVwq$+2.045.:X@EVVQ[LERG987:<:=87@4/4CDXjD/43=GHITQ>3:ENgUo}--(()2-07F@LDWQRNNMA59474<:GJ=099QO`H0,.36=;743>A:980.-24221,0//993>E@ZKWls4**2-1*-.2<:GJ\SaZTG96=:B918?B83,-45==F)/-01269;:=o|vy)04DLFEOH:7/500/.*+.+(-/116?Lt^n|'CE?1$'*(+60<>XVWdYRVYR7C847+-..++15.,,,03IG3exlw`Y-63-$&/,(.:02,'NW]][R=8I@8OF:5:.4869=8@;-*,02N>A_mhxX@Y011,,---'?5,,6=ETK\PAA3>9F98;5664443?D;:41.9;DJTZrTd_aX5J^{9-1=)-)-3HF*(2DYWTLCV60+184063/642,/9eW=255K=;cl|~xvnoD?K`v/'60*,((070.*,2OOP8CM85*'-1*/317MYtfLU\X]jhcddjiqjbXk}yvrnic]V:>RB06NWVedZ]gdQPY]ZYbXWWYdgi}zusmic_W6:@D=8BO[f{ncgRKEPGXQ?MZ_YSjb^H`~{wtplfaZ59>;?:4/*3B;ELIRYAU[cUNF\X::7<8TWD6^~|xuole<>ASIA@aOLJDRUJ;{oleaSZ\kzz}ztqkJ9;242.437>>aLGF]Z[EZYI:=VQde_hMB<]u~~{wr9468?=49C:BFOdbbXMWRTSQLBXL7K]Oh~{w4=LF;=9;EACQF\S]eg`RDSE7GRF?IGQvz25XC\K2=KM]EDLTepZ]^Z\OFPbjadZ8CN8T_aZGPCQeOa\CMz78OGCBDAEFGICIRjl`RYEI@DWlb[]F53899;B@8BJ_PJ[Q8>}EC-@E9DJL>YJON\fWSIQG=S?ah[]W:<=HNEWM^XMHAGPRjIZ`KKYO_ZUF989BTMG@FFA98Xt58<:_[JIITV[[ZYPPCDPPTbJ^hQKGDKPMPXC?==F<85:KGQRLV/EHA\\e\cXXeb]UNDFGEJPbUWVB:<=?GV`\:9@>D777F:=E9>Vu5J[MDXO@?8TUQb^UI6304??NSLFRHR__}|31F@V=7:LQSdV[^][YQ?6]eXWfJ9BOZABRklR;@859=EANRVP[OK{Wo{z+-236986GGPIYb`MZQa>Ia`^a\?48BCN>?[]cOeQ4FROEE6>J:7BXgJKSRM[jLDSZYVG?B4:@D>DG>DhcHLKSZJ42==Px}~w{zxt^*0;18Q43;24?A]VY[VL:OaLFUCJL>G:17H644;>McZXbUDPZH9>AY]<*3KI>766-8JG^_kZMIAALEPM@98:FA5I[38K88?AS^NIFQQ@:?Dqtvb+25G:635AE;KYZ[ZYT<==HL606932231S`>5;@E<66@Fa|vr$.0.142-FQ?IXSS[DJS@877;::=6;<2.:DGbc8235@IDLVL85=FScUy~+-'(-3,4;FCGKVPPNOK;88483=;LJ537APS^;0-128;NYOHA55\vnz'),B8<64;MG?\Y\FBQF8G<854+/202;FDRXOHHRF=:9735A=9<40-.3504./0.1983DAHXHdlv'-+1-.*/-7:@FPZUbUQA5:<<@60=@@61+/58:D;)/,21368:9E}|q'98L1&*),=?7JR^NPAC@E69A?88CC=01/15:/9:+,-1022>ORspLu%?HG-$&%&)07THJF?:=3KKD2AQ6BRO<99F:2/35/,-02.)--//31,/8kolzm}4B250&(.,+-/-+;K;BPCHKWJI<3A/-.,:1*+.2+*/53/CK>Iu_zcs~28/:+%)*,/62+)4>B]S]aVSVYG7E283-,/-++30-,,.06H=4{xmp^c/32'%(/)(37/0(0WW[_VJ9;H::OB6780777<>:@6-*-.6K=CqoyluT>e6,1+-+0'/@1,.;>KPL]F@=4?9D6;75663453E?;7300:BIKU]uSe]eO8Kh{9%=2***.9K;()7IYTRDKN1.,273190264/,1C`N:247J6Ehl|yvnl?AMkv**7),*()34.-).8SNK4JG57''//+221:\zzron`^=[rpY~s0/*%"%*(&"$,9@M^P5<<8387/--7:<>357ADQ9/4.*.-A_O]|`d`dnmhkysmqfeiu\5N[s\JWZVblddcdijqh_Zn}yvrnid]V8@Q<0;PWVjeZ_h_MQ[Z[[_VVZWh~bk}zusmic_W4;>C;8DO^hyjddPJFOH[L>Q[_UXhbZFl~|wsplga[7;=:>84>IFS^RW^JCCYPDA:HJZXNY^V}~zwsoje^:AB@386BE=KQQLSROYRJ;?H51FLJPZP[d~ywrmgb>86<,)6BSIXVRHHXPH=MWX;>NH7>C9XSX~l^jkl~{wsmh@8E52468::GcO:KQd[N;HRI?9686239OOPS]O?^OJYRVNSL[[T\f9=lg\]cVC=BKF==hv~{wr9479A:3=C9?ZX\Y@IWU^eiqYNFWIAPSGUg`_TYKNR[XEPFC=EI}zt=C6>I<0>NQ<9IVJCTUXTfifb][YR=CETdaaTMWTTRQIEWD8XcMl~{w8=MB9=8EaQI==E>HOH^S_feaMES@7;J]SNSVT^Y=>AED?CGiw~w7>5:7@8BRQcK;ONQXJjbaaZ_PWX>HI@N[DQmjVP@G]m_\Z@52:89cM`G>LLGVN`SNEAJPWgFb[HOWR^YUA988FTKE>FCC7>^}79;=hSJGLVXZ[[TQMBGROY_GgbNHEDKPMPY<@;@C;85=KGTMN`4FHAfXj[dT^eb[TMCFGGISaTWR?8<<@IYbT6;@?B689E8AC7B[5>DCMAa[XI\_V`cSHIE@?PZKF\K?@;YPVc]UD4225@@PRJHTIS``z}06DFR87=NRWdT^\^[YN9=fcVYfA:DWT@DXnjK:B55:?FCPTTQZDXyTvw~+-218878JHPK]d]LYS\:R`b]cV:3:BEMMVNKYXVKJTVJT]aR`]I<22?CCLHIZQ@FMaKQSE`\RCA5BH88F_`HKWNOaeEFVZVV@D?3GIFRH@87>D?5TQ1=K4:ACYYJHFRM=8@Fyqyd*46D5526ED;PY\YYYN;D;>;=LF318621315^Y77:>E@=BB;5:BFh{ut$00-242.QHBNYRVVBNP;977<9;=6>91.?EMhX2338AJENWG59>IU~bU(+''01,6?DGCRTRNONG898474=>KF066GOVW3/-23:;TXMG@4;fvo|&)0F4>53ANBH\[YCEPA:G:846?TUH/56;6A5.,,002358=<=S@^mnx'-5=9<>41@A=5/+16;9I3*/+51478:9M('*),B9;MT\KN>CBC6;B=8=EB8/00068.<3,,-0123AO^zoJ{)DFB'%&%',0>UFJD;;:5LLA@G:ML=;/04-1.,*--(*//148GS~Xw{:C@5'$)*(314B6D;1JK5EUI::;F70024/,-11-*--/02/,0@w~pl|o}:=16-&)1++-.,,@K7JLEFRSIK67@,-/.;.++00*-/821FF;[t_ye|v~7436&&(,-161**:=9@3,)/.>E=H{{rtoqQ>m6+/).+/&6>.-0=>QMPZCA95>64461645J;:42/2AQqv'.4',*'*50-,*/@TOC4NA76%(1-+322:F79i}o|o|{|vwqorrpoqyz}yxxqqrnvqpok~y}|wqpsopqtutpzz{{xvyuuosotpswmryvwyzy}vpoqoypipugmniw{xz{zvnouppqrnv~}njtsry}zyqtsrrphmruwzvpw{stutq~~~wstsmqkkpsqwwxysvuppyu~||urqkklqrkkswxwsunmp}z{{ulllqoomlqsrruytvuvtxz~{qlhlrsqnquvsnrzxyyuqw|{zysnkjoqolovtstl{wrunqqsz~}|}~{qsnomnlnpsvvusyyloqpvuw{|||}~~yyvnlnsqpruuwvwxuomqqxt{{z}~|{tulmqvwvvyyzupuyvsqwx|}}}zttnnruxyxrxyuszyyttuy~}~|zuonquy{xvwzyyyzzzxwv}}zv~|~wpruvyvwuwyzyzz{yzx{}~}}|~ux~~}zyuuuuqy{{|}{z{zzyy|}||||~yy~}z{|tomrryy|}{{|z{y{{|z{zz{||~}x|zrprw{~|~}|}~|||~}}|{~{|~||{yosvx{|zzwyz{z{yz{zknlrzuy|y~}xzxutttttttutttttttsssrrrsu}~}||}~~}}}|ysrqrqqpqqqpqqqpqpqopoooq~~}}}~~}}}|}|}ztqrrrqppqppppppppponnnnn~~}|}~|~}}|zwtu{yxsqpqpqpqpqpqopnnmn~~~~|}~~~|~~||xyx|{{|yqpqqqqqqqqppponmm~~}}|~~}|}~{zxz{{{|z{zsqrqqqqpqppoomn~}~~}}~~~~~~~}yz{zy||z{prqqqqqpqpponm~~~~}~~}~~}||{z}~}|{}prqqqqpqpqppnn}}~~}~~~}}~~}}~|}}}|}xruqrrqqqqpppppnn}}{~}}|~}~|}}}|}|||~}|{wuqqpppqpqpqopno~}||}~}}~}||}|}}}}}}}||{zxutuvtpqqqqqppn~~}}|~||}~|}~~|}|~|||||}|}}xrqqqpqpo~|}~~}}|||}}}}}}||}}{}~~|~spqqqopp~{}||||~~}|~}}}~~|{~}}rrqrqqpq}~~~~}~~~~~}~}}~}}|}~}}sssrrqqp~}}}~~}}}|~}~|}|}}v|wttrsrrpq}~}}|}~~~}|}}}}}~}}}~{~utsssqpo~}|~}~~}}~~~}~~}}~wsssrrpp~~~}~~~~~}~~~wzrsssp~~}}}}}}~~~~~~}y|stutu~}~~}wwvvt~~~~~}}{~}~~||}~~}}}~}}}~~~}{zwuus:EH;?P^qUKXYWflaebfglpg\^q}yvrnic]V8DO70?SVXmcZahZKS]YZ^ZUV[Vnwao|zvsmic_W3;=B98FPakwfd_PIHLKZG?UZ`Q]ebTEz~{wsplga[8<=9>65?JEV[P[[GAH[LEMRRKVPSWRH;@E22JJJTYRXl~ywqmgb@599+*;@=ELFZMEY]aOJOfF:8:8?\K>=u~}xtoleC5F5.0;CBQKWVPFMZMF>QXT8@RA9>?;_Mezi^nhq~{wsmh8<@324788?514-154:=M]NDN^ZSGaRC8IXVge^fF@?[c_\_WadZdc|{wrmEJ@1744378PEIQOUR]NLVI=GM]`_[TjFBaf[]^XHGL]\LV~yuo9?=769425=SLST_GE[ML\OXLTK]YRa_4Gmc\^cS??ELB>?t~{wr:388A82?B7E\Y]T=OVW`fipSMIWFCTNGZda\UXHPT\XEU@HEJK}zt??6>G90BRM:;NTGHTUWWhgea\\YM=EFWda`PNXTSQRFJU?:kcMp~{w:>L>8<6O_OG:>F=MKL]Vbfd_GIR<8JG@TWDXreVK==JQ@HJIPz0AUF`>1FKTV>IN[mlTb[YYGJZfh^gD8KC;[^^QILD]]RhSD_{6>LD?FAGCFJDFK^miTYODFKLKj`Z]HDK9;<<@UMFHHYTX<0?m~8A8BfMbB@OILTT_PMBALO^`GfUGURV]XT=899JSIC>EBC2Cd::9?pLMGPUZ[[]PSHCITM[YJm]MGDELNNRV8C:DA;86AJGVJOk:EIBhYk]cRcdaZSICGFHJZ]TWN=8>E:B?8E]6>BHHF_YVL^]WbaPGIG>BUWHK[G>=A\M[b\S?3128@BSQIJVHPcey{.??RL65AOR\aT^[_ZYI7Gi`U]a;;E]M@E^oeC=B46;ABGRWQRV?ftV|s,-21877;KJMOaeWPVYS;Z_b]cM639[E3CG2;@O?22:4304/>cP398AB?PXz`V))%'1/-7CDICVRRMOLC8:6467;BKB/96MN[M0.-44:?YVLF>3Anuzp~'*4E3>43GL?P[]T@IN=>E:639CVTA.67:7B0/,.012469?;CS@gn{nz),Kc,,02.6>GFYPNCPO@<7453;@;9<1/-14503,1/.6<56H@WNSrzny++0,/),..;:GGZT\\RK;5>8?<15@B:4,,26;:I-+.-6.558<>Vm->>E$())-G6ANYVMI@BE>7OK;9.22-0.,*.,)*/0159G\}Wx{@B=3$%)*)507A8E73PE8HUC9:>C6/133/,.21+*-//12.,2J{ql}q}>524(()0++-.+0EI7NGHFWQHK0<<-.-1;+++1/*.1:03F?>kq`yhzz~:/61$(',,23/),=;UYUeZQTYQ;@>051...,+-6./++02;@6F}tfYp30-#%+/'-802.%GW[Y^O@5E@3FI=49228::@:=A3,*0/B@>OyupqmO=u0--+-*-&=:+-4=@SJVVAA68;BA7=3345152;K:742-4BWGMVaywUc\gD=Mu{-*>(,)+1DF-'.;UXUK?W<0,.75349-762,.4MUD410xqv|n||{uzoorrpotyz}xyypqrovqpnkz}|vqpsoqptuto{z{{xvyutosouptw|mq{uwyzy}tooppynirsfnmhz{xz{yumpupprqox~|lkuqsz}zxqurrsohmsuwzvpx{stwsq}vsusmqjkqrqwvyysvtop}v~||trpjllqrjltxwwstnmqy|ztkllroomlrrqrvxtvuutw{zqkhlrspnquusmszxywuqx{{{yrmkkornlpvttsm}vrunrrsz~}|}zpsnomoloptvvtszxkoqpwux{|||}~yyullnsppruvwvwwtomqrxt|{z}~}{ttkmrwwvwyyyupwyvsqxx|~~}}zttmorvxyxrzyutzyxttvz~}{ytooqvz{xvw{yyyzzzxww~}}yw~}~vpruvyuwuxyzyzz{yzx|}~}||~sz~~|zxutvtrz{{}|{{{{zzz|}||{|yz~}z{|sonsrzy|}|{|z{z{{|zzzz||}~}x}zqqsx{~|~||}~|{|~|}{|{|~{|zxouvy||zzwyz{z{yz{yjnkszty{z}~~x{wututttttuttttttssssrrrsu}}||}~}}|||xrrqrqqpqqqpqpqpqpqopooop~~}}}~~~}}}}|}ytqrrrqpppppppppppponnnnn~}|}~|~}}|zwtv{yxsqpqqqpqpqpqppnnmn~~~{}~~}|~}|{yzy|{{|xppqqqqpqqqppponmm~~}}|~~}|}~{zxz|{{|z|{rqrqqpqpqppoomn~}~~}}~~~~~~~}zz{zy}|zzpqqqqqqpppponm~~}}~~}~}||{{}~}|y|prqqqqpqpqppnn}~~~}~~~}}~~}}~||}}|}xruqrqqqqqpppppon~}|}|}|~}}}}}}|}{}|~}|{vuqqqqpqpppqopno~}||}}}}~}}|~|}|~}}}}|{{zxutuvtpqqqqqppn~~|||}}||}|}~}|}|~{||||}}}}xrqqqpqoo~|}~~~}||||}|}||}|}}{}}}|sppqqopp~|~|}|}|~}||~}}}}~||~}~rrqrqqpq}~~~~}~~~~}~}}~}}}}~}~~sssrrqqp~~}~}~~~}}~|~}~|}|~}u{x~ttrsrrpq~~}}|}~||~~}}~~}}}}z}ussssqqo~||~}~}}}~~}~}}~vsssrrpp~~~}~~~~~}}~}wzrsssq~~}}}}}~}~}~~~~|z{stutu~~~~~~~}wvvwt~~~}||~}~~||}~~~}}}~}|}~~~|{{wvus;FE9ARcmNMYWXhj_ecgfomfWau}yvrnic]V7HK22CTU]k`ZceUKU]XY`WWV[Xrp_t}zusmic_W1=??89IQcptdfZNFKIPWBBW[`Mbc`NI~{wsplfa[8;;9=46?IEYZQ]WEAL[GF8CERYSN]^[~zxsoje^:AA9368F=AOQQKWNWVQD=AB06KHJWUUVu~yvrmgb?2;5)*=>?DKG]GKY`\OGSc?;7:8EZG@GOMTVMDPXJCBSYO8BT;9??>cIqug_ofu~{wsmh5><134878?R`A?MXdVF:ULG8U\ERBURW7W}kheWW]]{u}ztqk;>333-144;=TWMBS[[MK`O?9LT[fbb`D>A`a^][Xa`]`f{wsmGH;264436;PENPOVR`IPSH:658116@SISU\AJZMM_OVKRN\WReW2No`[_bN=BFL?=D{~{wr:378?5/@A6LZX^NVWRNXRX[R8ACG??GUi}~x;:696>6NK[\D>VJ[JYhab]Y\M]K@IF@VRF\taUH<>KO?KFJVz0HNN_94JJVR>JO_mfUaYZUEK^ge^b>:L>A\]\KLGHbYVgOCe{5BID?GAGBGJAHOckfQ[JFD=OfiZ^P823;7;>B<@@Q=SNIQWfYUJMOEAA1Jj9:8EqGOGQTZ[[[ORECLRN_RPmVLEDFMMNUQ7C:F>:68CIJVJPw>CGFhZf__Sec_YRFDGDIL^YTVI;:>;H[L^a\O=413:>DTPJNSHPbkxy,C=VF55FQS`\V^[_ZVE6Pi]UaY8>G_H@Hdn^??@47JLLQbcRTR^K?_]a^bF54?ALF>Q\bUZ`9=RQI@BZd~zt{woh3.3@AB:8H@5=QhQJMUJUiTCMXYTQ=^kQHMNVS<0:=?pvxx}{ob,661L?/960>;ZVY^VQ=E_UCVFDN@BA14D>239;DZ]X]]IE\L@8AA|c-,AHB68511IB[]k_QGH632>I?CXY\XXXB>A;>;CN:24:2304/FeI297BA?=F=86?FLuxtz(2-024-8V?GUWQ\JESG8959::=<7A2/3EFZhC/52=CJGTU>4UY^P?MJ:BB974;HWS;.6898@.0*/02145;?;EQClnyn{*-VX),11/7CFJXNLDSK>:6353=?:::0.-25322,1/.7:39F?VHZtxoz/*0*.(--1;D87CD?10/11821>,,,//316FQnkJ2EE4$%%&'03NNHIA8>5@MG;H;BNG:7/21-/-++/*)+//17:Ed}YzzAA:0#&))+40;=7---18*,+2-*.1:/4C>Ctqayiwz8-7-$((,-21.)-@=YVWeWPUYO9A912/..--+/7..+,24=>7N~ueVs1/*#%,-'.8.1,'PUZZZM<6H:3IH<58138;9@7@>0++01G=>TvunrjM>x+/+++,+(?6*.6=CSIZPA?3<7E?9<4344260?J=531-6IaGMVbztUb[gA=Ovz'19(+)-3G@*'0>WUTHBV7.+/94458.841,/5NQA31.=B:]lp}wpe=CZwv&5*),)&/3--)-/NNN6=M8>.%*2*,415:KiB9,,.,43:Grym~|nkeJDkhPq~t-(%!#(&%#"(9=E]V96=:3685,-0;9C8787KMB-74-,02X^Rlk_a_hlldztkpodeke?7?C4C}f~|o||{u|nprqpovyz}xyyprqovppnlz}}~uqpsoqquutp|zz{xwyutosnvptwznp}uwyzy}toppqynitqgnmi~{xzzytmrvoprroy~{kluqsz|zwpurssnhotuwztpzyrtwvs~}vrurmpjlrrqwvxxrwroqw~|}srpklmrqjlvxwwstnnrz|zsklnroolmrsqrwxtvvuuw|yqkhmrsonqvusmtzxywtqx|{{wqnkkormlqwsurmvrunqqt|}}||yqsmomnloqtvvttzwloqqwux|{||~~}yztllosppsuvwvwxtonqsxt|{z|~|zttknrwwvxyyztoxyvsqxx|}}}xttmprvxywr{xutzyxstvz~}{ytooqwzzxvx{yyy{zzxww}|xx~}~vqruwyvwuxzzy{z{yzx|}~|||~t|~~|zxutvstz{{}}{{{zzyz|}}{{}y{~}y{{rnnsszz|||{}z{z{{|z{zz|}}~}y}xqqsx|~|~||}||||}{}~{|~{|zwouvy|{yywyz{zzyz|xjnjtytzzz}~~w{wutututttutttutttsssrrrsu~~}|}}~}}|||xrrqrqqqrqqpqqqpqpqopooop~~}}}}~}}}}}|}xsqrrrqppqppppppppponnnnn~~||}~|}}}|zwtwzywrqqqpqpqpqpqopnnmn~~}{}~}|~}|{yyy|{{|wpqqqqqpqqpppponnm~~}}|~~~|}~zzx{{|{|z~{rqrqqqqpqppoomn~~~}~~~~~~~|yz|zz||zypqqqqqqpqpponm~~}~~~}~~|||zz~}}{w{prqqqqqqpqppnn}}~~}~}}}~~|~~|}}}||xsuqrqqqqqpqpponn}}|~}}|~}~|}}}|}{}|}}|zvuqqqqpqpppqopoo~}||}~}}~}}|}|}|}}}}}|{{zxutuvupqqqqqppo~~}}|}}|}}}}~}|}|~{||}|}|}|xqqqqpqpo~|}~~~}||||~|}||||}|{}}}|sppqqppp}||}}}}~}|}~}}}~}||~}~rrqrqqpq}}~~~}~~~~}~}}}}|}}~}~sssrrqqp~}~}~}~~~|}}|~}~|}|~|u{x~ttrsrrpq}~~|}|}~~|}~}|}}~}}}~{}ussssqqp~}|~}~~~}}~~~}~~}}wsssrrpp~~~~}~~~~~}~~}wzrsssq~~~|~|}}}~}~~~~|z{stutu~~}~~~~}wwvwt~~~~}||~}~~|}|~~~}}}~}}}~~~|{{wuus;GB9CShjJPYV[ih`dcheplfWcw}yvrnic]U8JG12FUT`j^ZdcTLX\ZXaUXW[[ul_w}zusmic_W2=?=7:JResrceWMELGST@DX\^Ldb^JK~{wsplgaZ8<::<37@HG[WR^SD@OYEE7FDTXSP_][~zwsoje^1<2(,?;ADIJ\BOYaYOGY`<:798HZD:I~}xuoleB3G-//?=ILNTVJCSVJADUYJ8ET7:B>AeHwseamfx~{wrlh5@:124879AV^132-155?>WSLCXY\IO^M=:OS^f`d[B=Daa[_XZc^__k~{wrmIG8354447?NDPNPWS`HSQGFfcY^_RFHR`SKh~yuo:>9558118CPJSVY=PXLN`PVLQQ\XRgQ3Up_[`bL=I}~{wr:398<51@?7QYY^J=VT\`imiNJORDGXGMacbYVQIRY]TJR;HRLN}ztA96@C43GUE8?VNCPPWS]ifc_[[WD?DH^baZLSWROPQBQL8NcOt{v9DI9;<7\XLB9BD@QGWXYeebXCNL9;?XXRLXQZ[O9CCFFZYGWV>6o}J27L;ABQ=WLKQWhWTHOL=UCYk[]Z@KD:<=;FVJHHNVVR50Gy~><8KaQ]@EQDRP\YNK@EOOhPRfNGZPZZXM;872No::6KmENHTT[[[YOQDDOQPaNVlSLEDGNKOWL8C:G=968DEJUIPADFHe\eb]Ufd_XQDEGCILaXTUF;;=>FQ_`@7?>C;87@A9C:;Ia9>AKBM^]QQ_Z[dZLHFFSXYHUc_[xz}zz|w.118AWCFTSFYR]IMJ[LQ^aWVeO>7/9CAFMDSXF;MS[EWEX_ZG<C89J=5?UgNJQTLZkNCPYWTL?D67>DNCNME988F?;B]68J;5?AJ^OHFKPB:9?[nk-4=<632AI=FYZ[XXV???<=:GL714812030OdB2:8D@>>G=86@IRwysz+1-134,?U?IXUR]FGSD896::;>;9?1/7FH`e:;80..2524/,1./892@hk79I3$())5M5IP^MQCCAG9:@C88FD>00/127/4<,,-//417FUslI7DE/$%%&(26QKHI?:>4CMD=J:GMD<4/30..,+,/()-0/27>Gm~Yzy@A7-#'*)-40>:@A2=T9?MR>;8@<4/122--/20*+../21.,4azrl{p}@/50%(,.+*.,+7K?@PEHLXNIB.?4/,-37*,+2,+/2803D=J|qazivy6-7*$()-.31,(0@A\UZdUQUYL8D821/..--+15/.+,15<<8U~udUs1/'"&-*'16-1++UU[[YL:8I62LF;66058<:A7E>/,+05K=?YwunqhM>w(0*,*-(,?3*/8=GSJ\LB=2=7F=:;514327/CG<430,9QfFNVbztTa[gA=Ovz"73(+)-6I;)(2CXUTEGS4-+1;3357.831,/7LL?21/@B>`nq~xpe=D\xv(6'*+)&02--)-2QNM2CJ6@*%+1*,3169I_R68>73684,-2:9E8687OM=-94--.5]\Umh_b`ikke~rkqocej_;8@>4Jz`|o|}{u|nprqpnwy{}xzxprqovppnl{}}~tqpsoqpvusq|z{{xwyusosouptwxop~vwyzy}sopprxmivogoljzyz{ysmrvnprqoz}zimuqtz|zwpurssmhotuxztpzyrtxxs~}vruqmojlsrqxuxwrwroqx|}srojmmrqjmvxwvttmnrz|zrlknronlmrsqrxwuvuuuw}ypjhnrsonqwtrmuzxywtqz|{{wqmklorllqwstqnurunrqs|~|}|xqsmomnlopuvvst{wlpqrwuy||||~}xytllpspptuvwvwxsonqsxu|{z}~~|yusjorwwvxyyytpxyvrqxx}~}|xtsmprwxyvrzxtu{yxstv{}}~zzsnorxzzwvxzyyy{zyxvx}|wx~}~tqruxyvwuxyyy{{{xzx}}~|}|~~u{~~|zwutwstz{{|}{{{zzzz}}}{|}y|~|y{{rnnsszz|||{}{{y{|}z{zz|~}~|y}xprsy|~|~||}|||{}z}||~{|zwnvuz|{yywyz{zzyz|xjnjuxtzzz{~~w{wuttuutttuttttttttssrrrsu~}|}}}}|||wrrqrqqqrqqpqpqpqpqopooop~~}}}~~~}}}}|}ysqrrrqpppppppppppponnnnn~~||}}|}|}|zwtwzywrqqqpqpqpqpqppnnmn~~~|}~~|~}|{yyy|{{|voqqqqqpqpqppponmm~~}}|~~}}}~zzx{|{{|y{sqrqqpqpqppoomn~}~}~~~~~~~}zz|zz|{yzpqqqqqqpqppnnm~~}~~~~~~~}}|z{~~}{v|prqrqqqqpqppnn}~~~~~~~~}}~~|}~|}}}|}wruqrqqqqqpqpponn~}|~|}|~}~|}}}}}{}|}}|zvuqqpqpqpppqopno~}||~}}}~}||~}}|}}}}}|{|ywvtuvuqqqqqpppo~~}}|}}|}}|}~||}|~{|{||}|}}yqqqqqpoo~|}~}}}|||}}|}|}||}||}}}|spqqqppp}|~|}||}}|}}}}}}|{~}~rrqrqqpq}}~~~}~~~~~}~}}~|}|}~}~sssrrqqp~}~}}~~~}}}|~}~|}|~|u{y~ttrsrrpq~~}}|}~|}~}}}~~|}}{}ussssqqp~||~~}}}~}~}~}}wsttrrpp~~~}~~~~~}}~wzrsssq~~}~}}~~}~}~}~~~|z{stutu~~}~~}wvvwt~~~~}||~}~~|}}~~}}}~}}}~~|{{wuutJ\^YPi^]EX~{wsplf`Z9;8;;1;BDL\SU_NDBXUBD7HFXWPRaUf~zwsoje^=@@354>E9GOSOPUP[TM=>F91@KGPZRVZ~yvrmgb83<-(/@:CFFQY@VYeSMIbW::889QUA8V~|xuole9;@+02C;NHRUSIEZRI?JU[@:KN5:C:I_Jpbhlh~{wsmh5@5/3586;G_V:GPc_Q?CVJA?cMQNGVSM9rrlebU^Ylv~}ztqj<<030-447@@]QKF^X\D[XI;?UPef^fPBC\TPNZR]\F;CDB=BId}h~w<579=9=PJgO>ITR]GidbaZ\TX]AFLBG_HOjoZTB>DTIFMGNpz0[E_T0=KMZFBLTjoZ\^X\KITeiaeU6AL8N[[WDQEVcPaaJG|{4HDB?FDGEJFDNYkk\TXDG>E\nb\\D318:8:EB9BI_RLYR8A}K-?I:CGLAYJOR^eTQGREBUDdhZ]U@O?9=<KPFWP`TNGAIPSjG_`KL[Q\ZXE:87?SJG>BAE;7Yx::7X`HMKWV][\SRLDGTMVaIdgOKCDHOKPZA;A>H;96VZb_dW\fe]WMCEHDLRbTUSA9>D888B=:B9=Rn=?@N=W^aLVaV_cUHJFB>O[MD]LA?;XURd`\F6204@=PVPKWLKRZ{yw0H?V98;OSYdU]\^]ZQ:>feXZgD8BTWABTnkN;E=57@E>KSTQXJPvb^n+015956GHPL\e]MWQ^=Raa_e[=46BBQ?FZ]cRfR5IUPEMUOLWWWJKSXKZ^aQ__K<40>BCLIGXS>?P\QJWEa]UA;B5@I89E^aKKVMNbgDHWYUWBE>2:B??CF:HkeHNKQYK54?0C@8OS1?K48@@UZLHENR=::Ankxt14=9425GH=MZ\ZXXN;B<>::=;1/>GMhX2136@IHMYM4866]vxss(+B5>43=NAF[\WGCQB6..+102257==;TMQqqso11i9)-2/3:GCVRNFLTC<:5338?<9=5/.03615,/1.2:81CBI]Knxrq:(0(*)/,9;EGWWY_RM@3@:;>62B@?3/+25:8I4*.+51182<=Kwj>8J'&((*BF;MT\KN?DBG7:D>6UGIE<<;4IMCBG:MN<=014//-++,.(+.0058DI~x]{|?=4'$')*213B6D;3IP5CSJ;=9@820121,-12.*,/./31-.PPO[GA:5<9F;<96062540LA;421->eeFOXd}fX`[f8CQ{%<**)*.>I/(*8MZUQ?SF2-+2:4265492/-1-11E?Fjmsur[=Hav-1%+*'(3..+*->SOD3LB8<%&./+.2189>35680--66?C788>RI6.;0--.ChU]q`bacjlhkmmslbfhT6;@87^pg{n|}zt~lqqqpmyz|}xzwosppvoqmn{}~}spqrnrpvurr~z{{wxxurprpupuxupouxyzz|qopntwljy~lhojkyyzzyqmstnqqqp{~xinupt||zvqurrrkhptvxysq{xsuy{u|usuonnilrqrxuyvrwqnrv{|prmjmnrojmwwwutslntz~ypkkoqnmknrrqsywuvvtvw}~wnjhorsnoqvsrmwzxyvtr{|{|vplkmpqllsvrupp}trsnrqu}~|}}~wqqmolmloqvvwsu|tlppswuz|||||xzrklqrqptuvvwvwrnoqtxu|zz}~}|wuqkoswvvxyzxsqyyurryx~~~~|wtqmpswxyus{wtv{yxstw|}}}zyqnprxzzwuyzyzyzzyxvy~}|wz~}}rqsuyyvwvyzzyzz{yzy}}}}}|u}~~{zvuswrvzz{}|{{{zzz{}}|{|}z}~|z{ypmost{z|{{{}z{z{}|z{zz|}}~{y}wprtz}}|}||~|||{~z}|}~{|zuowu{|{yywzz{zzyz|viniwwt{y{{~~w{vutuuutttutttttttsssrrrsu~~}|}}}}|||vrrqrqqprqqpqqqpqpqopoooq~~}}}}~~}}}}||xsqrrrpqppppppppppponnnnn~~||}~}}~}}|yvtxzyvrqpqqqqqpqpqppnnmn~~~{}~~~}~}|zyyz|{||uoqqqqqpqqqpppommm~}}|~}}}~yzx|{{{{y{rqrqqqqpqpqoomn~}}}~~~~~~~|y{{y{}{zwqrrqqqqpqpponm~~}~~~~~~~|}{{{~}}{vzprqrqqpqpqppnn}}~~}~~~}}}~~|}}|}}}|}vsuqrrqqqqpppppnn}}|~|}|~}}}~}}|}|}}~}}{yuuqqpqpqpppqoono~}||}~}~~}||~|~|~}}}}|{{yvvtuvuqqqqqqppo~~|||}||}}|}~||}}~{||}|}|}}xqqpqpqop~|}~~}|||||}|}}}||}}|}~}|qpqqqpqp|||}|}}~}|}~}}}~}||~}qrqrqqpp}~~~~}~~~~}~}}}|}}}~}}sssrrqqp~}}~}~}~~}}~}}~}}|}|~|vzz~ttrsrrpq~~~|||}~~|}}}}}}~}}}~{~}ussssqqp~||~}~~}}}~~}~}~vtssrrpp~~}}~~~|~|xzrsssq~~|}|}~~}~}~~~~{{zstutu~~}~~~}wvvwt~~~~}|}~}~}|}}~~}}}~}}}~~|{{vuus \ No newline at end of file diff --git a/test/vvenclibtest/CMakeLists.txt b/test/vvenclibtest/CMakeLists.txt new file mode 100644 index 000000000..e019d76d2 --- /dev/null +++ b/test/vvenclibtest/CMakeLists.txt @@ -0,0 +1,34 @@ +# executable +set( EXE_NAME vvenclibtest ) + +# get source files +file( GLOB SRC_FILES "*.cpp" ) + +# get include files +file( GLOB INC_FILES "*.h" ) + +# set resource file for MSVC compilers +if( MSVC ) + set( RESOURCE_FILE ${EXE_NAME}.rc ) +endif() + +# add executable +add_executable( ${EXE_NAME} ${SRC_FILES} ${INC_FILES} ${RESOURCE_FILE} ) +set_target_properties( ${EXE_NAME} PROPERTIES RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}" ) +set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}" ) + +target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall -Werror> + $<$:-Wall -Werror -fdiagnostics-show-option> + $<$:/W4 /WX /wd4244 /wd4251 /wd4996>) + +target_link_libraries( ${EXE_NAME} Threads::Threads vvenc ) + +# example: place header files in different folders +source_group( "Header Files" FILES ${INC_FILES} ) +source_group( "Resource Files" FILES ${RESOURCE_FILE} ) + + +# set the folder where to place the projects +set_target_properties( ${EXE_NAME} PROPERTIES FOLDER app ) diff --git a/test/vvenclibtest/resource.h b/test/vvenclibtest/resource.h new file mode 100644 index 000000000..1929c3948 --- /dev/null +++ b/test/vvenclibtest/resource.h @@ -0,0 +1,65 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +/** + \ingroup vvenclibtest + \file /vvenclibtest/resource.h +*/ + +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by vvenclibtest.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +# ifndef APSTUDIO_READONLY_SYMBOLS +# define _APS_NEXT_RESOURCE_VALUE 101 +# define _APS_NEXT_COMMAND_VALUE 40001 +# define _APS_NEXT_CONTROL_VALUE 1001 +# define _APS_NEXT_SYMED_VALUE 101 +# endif +#endif diff --git a/test/vvenclibtest/resource_version.h b/test/vvenclibtest/resource_version.h new file mode 100644 index 000000000..777af304e --- /dev/null +++ b/test/vvenclibtest/resource_version.h @@ -0,0 +1,56 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +#if !defined( resource_version_h ) +# define resource_version_h + +// pick up top level version information. +# include "vvenc/version.h" + +# define VS_FILE_VERSION VVENC_VS_VERSION +# define VS_FILE_VERSION_STR VVENC_VS_VERSION_STR + +#endif diff --git a/test/vvenclibtest/vvenclibtest.cpp b/test/vvenclibtest/vvenclibtest.cpp new file mode 100644 index 000000000..59b9f0af8 --- /dev/null +++ b/test/vvenclibtest/vvenclibtest.cpp @@ -0,0 +1,642 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +/** + \ingroup vvenclibtest + \file vvenclibtest.cpp + \brief This vvenclibtest.cpp file contains the main entry point of the test application. +*/ + +#include + +#include +#include +#include +#include +#include + +#include "vvenc/version.h" +#include "vvenc/vvenc.h" + +#define TEST(x) { int res = x; g_numTests++; g_numFails += res; if( g_verbose ) if(res) { std::cerr << "\n test failed: In function " << __FUNCTION__ << "\" ln " << __LINE__;} } +#define TESTT(x,w) { int res = x; g_numTests++; g_numFails += res; if( g_verbose ) if(res) { std::cerr << "\n" << w << "\n test failed: In function " << __FUNCTION__ << "\" ln " << __LINE__;} } +#define ERROR(w) { g_numTests++; g_numFails ++; if( g_verbose ) std::cerr << "\n" << w << " test failed: In function " << __FUNCTION__ << "\" ln " << __LINE__; } + +int g_numTests = 0; +int g_numFails = 0; +int g_verbose = 0; + +int testLibCallingOrder(); // check invalid caling order +int testLibParameterRanges(); // single parameter rangewew checks +int testInvalidInputParams(); // input Buffer does not match +int testInvalidOutputParams(); // AUBuffer to small + + +int main( int argc, char* argv[] ) +{ + int testId = -1; + if( argc > 1 ) + { + bool printHelp = false; + if( 0 == strcmp( argv[1] ,"-h") || 0 == strcmp( argv[1], "--help")) + { + printHelp = true; + } + else + { + testId = atoi(argv[1]); + printHelp = ( testId < 1 || testId > 4 ); + } + + if( printHelp ) + { + printf( "venclibtest [1..4]\n"); + return -1; + } + } + + g_numTests = 0; + g_numFails = 0; + g_verbose = 1; + + switch( testId ) + { + case 1: + { + testLibParameterRanges(); + break; + } + case 2: + { + testLibCallingOrder(); + break; + } + case 3: + { + testInvalidInputParams(); + break; + } + case 4: + { + testInvalidOutputParams(); + break; + } + default: + testLibParameterRanges(); + testLibCallingOrder(); + testInvalidInputParams(); + testInvalidOutputParams(); + break; + } + + if( g_numTests == 0 ) + { + std::cerr << "\n\n no test available"; + return -1; + } + + if( g_numFails == 0 ) + { + std::cerr << "\n\n all of " << g_numTests << " tests succeeded"; + } + else + { + std::cerr << "\n\n" << g_numFails << " out of " << g_numTests << " tests failed"; + } + return g_numFails; +} + + +void fillEncoderParameters( vvenc::VVEncParameter& cVVEncParameter ) +{ + cVVEncParameter.m_iQp = 32; // quantization parameter 0-51 + cVVEncParameter.m_iWidth = 176; // luminance width of input picture + cVVEncParameter.m_iHeight = 144; // luminance height of input picture + cVVEncParameter.m_iGopSize = 16; // gop size (1: intra only, 16, 32: hierarchical b frames) + cVVEncParameter.m_eDecodingRefreshType = vvenc::VVC_DRT_CRA; // intra period refresh type + cVVEncParameter.m_iIDRPeriod = 32; // intra period for IDR/CDR intra refresh/RAP flag (should be a factor of m_iGopSize) + cVVEncParameter.m_eLogLevel = vvenc::LL_SILENT; // log level > 4 (VERBOSE) enables psnr/rate output + cVVEncParameter.m_iTemporalRate = 60; // temporal rate (fps) + cVVEncParameter.m_iTemporalScale = 1; // temporal scale (fps) + cVVEncParameter.m_iTicksPerSecond = 90000; // ticks per second e.g. 90000 for dts generation + cVVEncParameter.m_iThreadCount = 0; // number of worker threads (should not exceed the number of physical cpu's) + cVVEncParameter.m_iQuality = 0; // encoding quality (vs speed) 0: faster, 1: fast, 2: medium, 3: slow, 4: slower + cVVEncParameter.m_iPerceptualQPA = 2; // percepual qpa adaption, 0 off, 1 on for sdr(wpsnr), 2 on for sdr(xpsnr), 3 on for hdr(wpsrn), 4 on for hdr(xpsnr), on for hdr(MeanLuma) + cVVEncParameter.m_iInputBitDepth = 8; // 8bit input + cVVEncParameter.m_iInternalBitDepth = 10; // 10bit internal + cVVEncParameter.m_eProfile = vvenc::VVC_PROFILE_MAIN_10; // profile: use main_10 or main_10_still_picture + cVVEncParameter.m_eLevel = vvenc::VVC_LEVEL_4_1; // level + cVVEncParameter.m_eTier = vvenc::VVC_TIER_MAIN; // tier + cVVEncParameter.m_bAccessUnitDelimiter = false; + cVVEncParameter.m_bHrdParametersPresent = false; + cVVEncParameter.m_bBufferingPeriodSEIEnabled = false; + cVVEncParameter.m_bPictureTimingSEIEnabled = false; +} + +void fillInputPic( vvenc::InputPicture& cInputPic ) +{ + cInputPic.m_pcPicAttributes = nullptr; + const short val = 512; + int lumaSize = cInputPic.m_cPicBuffer.m_iHeight * cInputPic.m_cPicBuffer.m_iStride; + int chromaSize = ( cInputPic.m_cPicBuffer.m_iCStride ) ? (cInputPic.m_cPicBuffer.m_iHeight/2 * cInputPic.m_cPicBuffer.m_iCStride) : (lumaSize / 4); + std::fill_n( static_cast (cInputPic.m_cPicBuffer.m_pvY), lumaSize, val ); + std::fill_n( static_cast (cInputPic.m_cPicBuffer.m_pvU), chromaSize, val ); + std::fill_n( static_cast (cInputPic.m_cPicBuffer.m_pvV), chromaSize, val ); +} + +template< typename T, typename V = int> +int testParamList( const std::string& w, T& testParam, vvenc::VVEncParameter& vvencParams, const std::vector& testValues, const bool expectedFail = false ) +{ + vvenc::VVEnc cVVEnc; + const int numFails = g_numFails; + const T savedTestParam = testParam; + + for( auto testVal : testValues ) + { + testParam = (T)testVal; + try + { + // initialize the encoder + TESTT( expectedFail == ( 0 == cVVEnc.checkConfig( vvencParams ) ), "\n" << w << "==" << testVal << " expected " << ( expectedFail ? "failure" : "success" ) ); + } + catch ( ... ) + { + ERROR( "\nCaught Exception " << w << "==" << testVal << " expected " << ( expectedFail ? "failure" : "success" ) ); //fail due to exception + } + } + + //restore original test param + testParam = savedTestParam; + return numFails == g_numFails ? 0 : 1; +} + +int testLibParameterRanges() +{ + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + + testParamList( "DecodingRefreshType", vvencParams.m_eDecodingRefreshType, vvencParams, { 0 } ); + testParamList( "DecodingRefreshType", vvencParams.m_eDecodingRefreshType, vvencParams, { -1,1,2,3,4 }, true ); + + testParamList( "Level", vvencParams.m_eLevel, vvencParams, { 16,32,35,48,51,64,67,80,83,86,96,99,102,255 } ); + testParamList( "Level", vvencParams.m_eLevel, vvencParams, { -1,0,15,31,256, }, true ); + + // testParamList( "LogLevel", vvencParams.m_eLogLevel, vvencParams, { 0,1,2,3,4,5,6} ); + // testParamList( "LogLevel", vvencParams.m_eLogLevel, vvencParams, {-1,7,8}, true ); + + testParamList( "Profile", vvencParams.m_eProfile, vvencParams, { 1,3,9 } ); + testParamList( "Profile", vvencParams.m_eProfile, vvencParams, { -1,0,2,4,5,6,7,8,10 }, true ); + + testParamList( "Tier", vvencParams.m_eTier, vvencParams, { 0,1 } ); + testParamList( "Tier", vvencParams.m_eTier, vvencParams, { -1,2 }, true ); + + testParamList( "GOPSize", vvencParams.m_iGopSize, vvencParams, { 16,32 } ); + testParamList( "GOPSize", vvencParams.m_iGopSize, vvencParams, { 1,8, -1,0,2,3,4,17,33,64,128 }, true ); //th is this intended + + testParamList( "Width", vvencParams.m_iWidth, vvencParams, { 320,1920,3840 } ); + testParamList( "Width", vvencParams.m_iWidth, vvencParams, { -1,0 }, true ); + + testParamList( "Height", vvencParams.m_iHeight, vvencParams, { 16,32,1080,1088 } ); + testParamList( "Height", vvencParams.m_iHeight, vvencParams, { -1,0 }, true ); + + testParamList( "IDRPeriod", vvencParams.m_iIDRPeriod, vvencParams, { 16,32,48, 0 } ); + testParamList( "IDRPeriod", vvencParams.m_iIDRPeriod, vvencParams, { 1,-1,17,24 }, true ); + + testParamList( "PerceptualQPA", vvencParams.m_iPerceptualQPA, vvencParams, { 0,1,2,3,4,5 } ); + testParamList( "PerceptualQPA", vvencParams.m_iPerceptualQPA, vvencParams, { -1,6 }, true ); + + testParamList( "Qp", vvencParams.m_iQp, vvencParams, { 0,1,2,3,4,51 } ); + testParamList( "Qp", vvencParams.m_iQp, vvencParams, { -1,52 }, true ); + + testParamList( "Quality", vvencParams.m_iQuality, vvencParams, { 0,1,2,3,4 } ); + testParamList( "Quality", vvencParams.m_iQuality, vvencParams, { -1,5 }, true ); + + testParamList( "TargetBitRate", vvencParams.m_iTargetBitRate, vvencParams, { 0,1000000,20000000 } ); + testParamList( "TargetBitRate", vvencParams.m_iTargetBitRate, vvencParams, { -1,100000001 }, true ); + + vvencParams.m_iTargetBitRate = 1; + testParamList( "NumPasses", vvencParams.m_iNumPasses, vvencParams, { 1,2 } ); + testParamList( "NumPasses", vvencParams.m_iNumPasses, vvencParams, { -1,0,3 }, true ); + vvencParams.m_iTargetBitRate = 0; + testParamList( "NumPasses", vvencParams.m_iNumPasses, vvencParams, { 1 } ); + testParamList( "NumPasses", vvencParams.m_iNumPasses, vvencParams, { 0,2 }, true ); + + testParamList( "InputBitDepth", vvencParams.m_iInputBitDepth, vvencParams, { 8,10 } ); + testParamList( "InputBitDepth", vvencParams.m_iInputBitDepth, vvencParams, { 0,1,7,9,11 }, true ); + + testParamList( "InternalBitDepth", vvencParams.m_iInternalBitDepth, vvencParams, { 8,10 } ); + testParamList( "InternalBitDepth", vvencParams.m_iInternalBitDepth, vvencParams, { 0,1,7,9,11 }, true ); + + // testParamList( "TemporalScale", vvencParams.m_iTemporalScale, vvencParams, { 1,2,4,1001} ); + // testParamList( "TemporalScale", vvencParams.m_iTemporalScale, vvencParams, { -1,0,3,1000 }, true ); + + vvencParams.m_iTemporalScale = 1; + testParamList( "TemporalRate", vvencParams.m_iTemporalRate, vvencParams, { 1,25,30,50,60,100,120 } ); + testParamList( "TemporalRate", vvencParams.m_iTemporalRate, vvencParams, { -1,0/*,24*/ }, true ); //th is this intended + + vvencParams.m_iTemporalScale = 1001; + testParamList( "TemporalRate", vvencParams.m_iTemporalRate, vvencParams, { 24000,30000,60000 /*,1200000*/ } ); + testParamList( "TemporalRate", vvencParams.m_iTemporalRate, vvencParams, { -1,1,0,24 }, true ); + + fillEncoderParameters( vvencParams ); + + testParamList( "ThreadCount", vvencParams.m_iThreadCount, vvencParams, { 0,1,2,64 } ); + testParamList( "ThreadCount", vvencParams.m_iThreadCount, vvencParams, { -1,65 }, true ); + + testParamList( "TicksPerSecond", vvencParams.m_iTicksPerSecond, vvencParams, { 90000,27000000,60,120 } ); + testParamList( "TicksPerSecond", vvencParams.m_iTicksPerSecond, vvencParams, { -1,0, 50, 27000001 }, true ); + + vvencParams.m_iTargetBitRate = 0; + testParamList( "HrdParametersPresent", vvencParams.m_bHrdParametersPresent, vvencParams, { true }, true ); + testParamList( "BufferingPeriodSEIEnabled", vvencParams.m_bBufferingPeriodSEIEnabled, vvencParams, { true }, true ); + testParamList( "PictureTimingSEIEnabled", vvencParams.m_bPictureTimingSEIEnabled, vvencParams, { true }, true ); + + return 0; +} + +int testfunc( const std::string& w, int (*funcCallingOrder)(void), const bool expectedFail = false ) +{ + const int numFails = g_numFails; + + try + { + // initialize the encoder + TESTT( expectedFail == (0 == funcCallingOrder()), "\n" << w << " expected " << (expectedFail ? "failure" : "success")); + } + catch(...) + { + ERROR("\nCaught Exception " << w << " expected " << (expectedFail ? "failure" : "success")); //fail due to exception + } + + return numFails == g_numFails ? 0 : 1; +} + +int callingOrderInvalidUninit() +{ + vvenc::VVEnc cVVEnc; + if( 0 != cVVEnc.uninit()) + { + return -1; + } + return 0; +} + +int callingOrderInitNoUninit() +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams ) ) + { + return -1; + } + return 0; +} + +int callingOrderInitTwice() +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; // + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams )) + { + return -1; + } + if( 0 != cVVEnc.init( vvencParams )) + { + return -1; + } + return 0; +} + +int callingOrderNoInit() +{ + vvenc::VVEnc cVVEnc; + vvenc::VvcAccessUnit cAU; + vvenc::InputPicture cInputPic; + if( 0 != cVVEnc.encode( &cInputPic, cAU)) + { + return -1; + } + return 0; +} + +int callingOrderRegular() +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams ) ) + { + return -1; + } + vvenc::VvcAccessUnit cAU; + cAU.m_iBufSize = vvencParams.m_iWidth * vvencParams.m_iHeight; cAU.m_pucBuffer = new unsigned char [ cAU.m_iBufSize ]; + + vvenc::InputPicture cInputPic; + if( 0 != cVVEnc.getPreferredBuffer( cInputPic.m_cPicBuffer )) + { + return -1; + } + fillInputPic( cInputPic ); + if( 0 != cVVEnc.encode( &cInputPic, cAU)) + { + return -1; + } + if( 0 != cVVEnc.uninit()) + { + return -1; + } + return 0; +} + +int callingOrderRegularInitPass() +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams ) ) + { + return -1; + } + vvenc::VvcAccessUnit cAU; + cAU.m_iBufSize = vvencParams.m_iWidth * vvencParams.m_iHeight; cAU.m_pucBuffer = new unsigned char [ cAU.m_iBufSize ]; + + vvenc::InputPicture cInputPic; + if( 0 != cVVEnc.getPreferredBuffer( cInputPic.m_cPicBuffer )) + { + return -1; + } + fillInputPic( cInputPic ); + if( 0 != cVVEnc.initPass( 0 ) ) + { + return -1; + } + if( 0 != cVVEnc.encode( &cInputPic, cAU)) + { + return -1; + } + if( 0 != cVVEnc.uninit()) + { + return -1; + } + return 0; +} + +int testLibCallingOrder() +{ + testfunc( "callingOrderInvalidUninit", &callingOrderInvalidUninit, true ); + testfunc( "callingOrderInitNoUninit", &callingOrderInitNoUninit ); // not calling uninit seems to be valid + testfunc( "callingOrderInitTwice", &callingOrderInitTwice, true ); + testfunc( "callingOrderNoInit", &callingOrderNoInit, true ); + testfunc( "callingOrderRegular", &callingOrderRegular, false ); + testfunc( "callingOrderRegularInitPass", &callingOrderRegularInitPass, false ); + return 0; +} + + +int inputBufTest( vvenc::InputPicture& cInputPic ) +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams )) + { + return -1; + } + vvenc::VvcAccessUnit cAU; + cAU.m_iBufSize = vvencParams.m_iWidth * vvencParams.m_iHeight; cAU.m_pucBuffer = new unsigned char [ cAU.m_iBufSize ]; + + if( 0 != cVVEnc.encode( &cInputPic, cAU)) + { + return -1; + } + if( 0 != cVVEnc.uninit()) + { + return -1; + } + return 0; +} + + +int invaildInputUninitialzedInputPic( ) +{ + vvenc::InputPicture cInputPic; + + if( 0 != inputBufTest( cInputPic )) + { + return -1; + } + + return 0; +} + +int invaildInputInvalidPicSize( ) +{ + vvenc::InputPicture cInputPic; + cInputPic.m_cPicBuffer.m_pvY = &cInputPic; + cInputPic.m_cPicBuffer.m_pvU = &cInputPic; + cInputPic.m_cPicBuffer.m_pvV = &cInputPic; + + if( 0 != inputBufTest( cInputPic )) + { + return -1; + } + + return 0; +} + +int invaildInputInvalidLumaStride( ) +{ + vvenc::InputPicture cInputPic; + cInputPic.m_cPicBuffer.m_pvY = &cInputPic; + cInputPic.m_cPicBuffer.m_pvU = &cInputPic; + cInputPic.m_cPicBuffer.m_pvV = &cInputPic; + cInputPic.m_cPicBuffer.m_iWidth = 176; + cInputPic.m_cPicBuffer.m_iHeight = 144; + cInputPic.m_cPicBuffer.m_iStride = 100; + + if( 0 != inputBufTest( cInputPic )) + { + return -1; + } + + return 0; +} + + +int invaildInputInvalidChromaStride( ) +{ + vvenc::InputPicture cInputPic; + cInputPic.m_cPicBuffer.m_pvY = &cInputPic; + cInputPic.m_cPicBuffer.m_pvU = &cInputPic; + cInputPic.m_cPicBuffer.m_pvV = &cInputPic; + cInputPic.m_cPicBuffer.m_iWidth = 176; + cInputPic.m_cPicBuffer.m_iHeight = 144; + cInputPic.m_cPicBuffer.m_iStride = 176; + cInputPic.m_cPicBuffer.m_iCStride = 50; + + if( 0 != inputBufTest( cInputPic )) + { + return -1; + } + + return 0; +} + + +int invaildInputBuf( ) +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams )) + { + return -1; + } + + vvenc::InputPicture cInputPic; + if( 0 != cVVEnc.getPreferredBuffer( cInputPic.m_cPicBuffer )) + { + return -1; + } + fillInputPic( cInputPic ); + + if( 0 != inputBufTest( cInputPic )) + { + return -1; + } + return 0; +} + + +int testInvalidInputParams() +{ + testfunc( "invaildInputUninitialzedInputPic", &invaildInputUninitialzedInputPic, true ); + testfunc( "invaildInputInvalidPicSize", &invaildInputInvalidPicSize, true ); + + testfunc( "invaildInputInvalidPicSize", &invaildInputInvalidPicSize, true ); + testfunc( "invaildInputInvalidLumaStride", &invaildInputInvalidLumaStride, true ); + testfunc( "invaildInputInvalidChromaStride", &invaildInputInvalidChromaStride, true ); + + return 0; +} + +int outputBufSizeTest( vvenc::VvcAccessUnit& cAU, int numPics) +{ + vvenc::VVEnc cVVEnc; + vvenc::VVEncParameter vvencParams; + fillEncoderParameters( vvencParams ); + if( 0 != cVVEnc.init( vvencParams )) + { + return -1; + } + + vvenc::InputPicture cInputPic; + if( 0 != cVVEnc.getPreferredBuffer( cInputPic.m_cPicBuffer )) + { + return -1; + } + fillInputPic( cInputPic ); + for(int i = 0; i < numPics; i++ ) + { + if( 0 != cVVEnc.encode( &cInputPic, cAU)) + { + return -1; + } + } + if( 0 != cVVEnc.uninit()) + { + return -1; + } + return 0; +} + +int outputBufNull() +{ + vvenc::VvcAccessUnit cAU; + cAU.m_pucBuffer = NULL; + + if( 0 != outputBufSizeTest( cAU, 1 )) + { + return -1; + } + return 0; +} + +int outputBufSizeZero() +{ + vvenc::VvcAccessUnit cAU; + cAU.m_pucBuffer = new unsigned char [20000]; + cAU.m_iBufSize = 0; + + if( 0 != outputBufSizeTest( cAU, 1 )) + { + return -1; + } + return 0; +} + +int outputBufSizeToSmall() +{ + vvenc::VvcAccessUnit cAU; + cAU.m_iBufSize = 10; + cAU.m_pucBuffer = new unsigned char [ cAU.m_iBufSize ]; + + if( 0 != outputBufSizeTest( cAU, 17 )) + { + return -1; + } + return 0; +} + +int testInvalidOutputParams() +{ + testfunc( "outputBufNull", &outputBufNull, true ); + testfunc( "outputBufSizeZero", &outputBufSizeZero, true ); + testfunc( "outputBufSizeToSmall", &outputBufSizeToSmall, true ); + return 0; +} diff --git a/test/vvenclibtest/vvenclibtest.rc b/test/vvenclibtest/vvenclibtest.rc new file mode 100644 index 000000000..72f357f50 --- /dev/null +++ b/test/vvenclibtest/vvenclibtest.rc @@ -0,0 +1,157 @@ +/* ----------------------------------------------------------------------------- +The copyright in this software is being made available under the BSD +License, included below. No patent rights, trademark rights and/or +other Intellectual Property Rights other than the copyrights concerning +the Software are granted under this license. + +For any license concerning other Intellectual Property rights than the software, +especially patent licenses, a separate Agreement needs to be closed. +For more information please contact: + +Fraunhofer Heinrich Hertz Institute +Einsteinufer 37 +10587 Berlin, Germany +www.hhi.fraunhofer.de/vvc +vvc@hhi.fraunhofer.de + +Copyright (c) 2019-2020, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Fraunhofer nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------------------- */ + +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" +#include "resource_version.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Default) (unknown sub-lang: 0x8) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ZZZ) +LANGUAGE LANG_NEUTRAL, 0x8 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VS_FILE_VERSION + PRODUCTVERSION VS_FILE_VERSION + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "200004b0" + BEGIN + VALUE "CompanyName", "Fraunhofer Heinrich Hertz Institute" + VALUE "FileDescription", "vvenclibtest Application" + VALUE "FileVersion", VS_FILE_VERSION_STR + VALUE "InternalName", "vvenclibtest.exe" + VALUE "LegalCopyright", "(c) Copyright (2019-2020) Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V" + VALUE "OriginalFilename", "vvenclibtest.exe" + VALUE "ProductName", "vvenclibtest" + VALUE "ProductVersion", VS_FILE_VERSION_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x2000, 1200 + END +END + +#endif // Neutral (Default) (unknown sub-lang: 0x8) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED +