diff --git a/.gitlab-ci-internal.yml b/.gitlab-ci-internal.yml index 6907a2c2..051048d1 100644 --- a/.gitlab-ci-internal.yml +++ b/.gitlab-ci-internal.yml @@ -236,13 +236,19 @@ build_mingw_ubuntu2204: extends: .build_only_template_full image: $CI_REGISTRY/pub/dockerimages/ubuntu_2204_full:latest variables: - toolchainfile: cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2204.cmake + toolchainfile: cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu.cmake build_aarch64_gcc_ubuntu2204: extends: .build_only_template_full image: $CI_REGISTRY/pub/dockerimages/ubuntu_2204_full:latest variables: - toolchainfile: cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2204.cmake + toolchainfile: cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu.cmake + +build_armv7_gcc_ubuntu2204: + extends: .build_only_template_full + image: $CI_REGISTRY/pub/dockerimages/ubuntu_2204_full:latest + variables: + toolchainfile: cmake/toolchains/arm-linux-gnueabihf-gcc-ubuntu.cmake build_ios: extends: .build_only_template_full @@ -297,6 +303,15 @@ test_vc193x_Win32: tags: - vc193x +build_vc193x_arm64: + extends: .build_only_template_full + variables: + MSVC_ARCH: arm64 + tags: + - vc193x + script: + - make msvc-arch=${MSVC_ARCH} all + test_macos_arm64: extends: .build_test_macos_template variables: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff0a6e9..80c9d48c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,59 @@ endif() list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) message( STATUS "CMAKE_MODULE_PATH: updating module path to: ${CMAKE_MODULE_PATH}" ) -set( VVDEC_ARM_SIMD_DEFAULT FALSE ) -if( ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64\|arm" - OR "${CMAKE_CXX_COMPILER}" MATCHES "aarch64\|arm" - OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64\|armv" ) - AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "x86\|x64" ) +# # dump all cmake variables +# get_cmake_property(_variableNames VARIABLES) +# list (SORT _variableNames) +# foreach (_variableName ${_variableNames}) +# message(STATUS "${_variableName}=${${_variableName}}") +# endforeach() + +function( append_cpu_type_guess output_list input_str ) + set( ret ${${output_list}} ) + + string( TOLOWER "${input_str}" input_lower ) + if( ${input_lower} MATCHES "x86\|i386\|x64\|win32\|amd64" ) + list( APPEND ret "X86" ) + elseif( ${input_lower} MATCHES "aarch64\|arm") + list( APPEND ret "ARM" ) + endif() + + set( ${output_list} ${ret} PARENT_SCOPE ) +endfunction() + +# try to detect the actual target architecture +if( ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten" ) + message( DEBUG "Emscripten" ) + # Emscripten doesn't set the CMAKE_SYSTEM_PROCESSOR + list( PREPEND vvdec_target_arch_list "WASM" ) +elseif( NOT CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR ) + message( DEBUG "sys != host ${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR} " ) + # cross compiling: CMAKE_SYSTEM_PROCESSOR was set explicitly, so we use that as first guess + append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_SYSTEM_PROCESSOR}" ) +endif() + +# build list of architectures in order of probability +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_VS_PLATFORM_NAME}" ) +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_OSX_ARCHITECTURES}" ) +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" ) # set by msvc, wen not using msbuild +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_ANDROID_ARCH_ABI}" ) +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_C_LIBRARY_ARCHITECTURE}" ) +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_SYSTEM_PROCESSOR}" ) +append_cpu_type_guess( vvdec_target_arch_list "${CMAKE_HOST_SYSTEM_PROCESSOR}" ) +list( APPEND vvdec_target_arch_list "UNKNOWN" ) # no architecture for which we have specific optimizations +message( DEBUG "vvdec_target_arch_list: ${vvdec_target_arch_list}" ) + +# get most probable architecture +list( POP_FRONT vvdec_target_arch_list VVDEC_TARGET_ARCH ) +message( STATUS "normalized target architecture: ${VVDEC_TARGET_ARCH}" ) +unset( vvdec_target_arch_list ) + +if( VVDEC_TARGET_ARCH STREQUAL "ARM" ) set( VVDEC_ARM_SIMD_DEFAULT TRUE ) + if( MSVC ) + message( STATUS "ARM SIMD intinsics disabling default on MSVC" ) + set( VVDEC_ARM_SIMD_DEFAULT FALSE ) + endif() endif() # we enable x86 intrinsics for all target architectures, because they are implemented through simd-everywhere on non-x86 @@ -61,9 +108,7 @@ if( VVDEC_ENABLE_ARM_SIMD ) add_compile_definitions( TARGET_SIMD_ARM ) endif() -if( ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten" ) - set( VVDEC_TARGET_WASM TRUE ) - +if( VVDEC_TARGET_ARCH STREQUAL "WASM" ) add_compile_options( -pthread ) add_link_options( --bind diff --git a/README.md b/README.md index f9a8a7ce..dc3c8794 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ VVdeC, the Fraunhofer Versatile Video Decoder, is a fast software H.266/VVC deco armv7 - :black_square_button: + :x: armv7 :white_check_mark: diff --git a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1604.cmake b/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu.cmake similarity index 61% rename from cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1604.cmake rename to cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu.cmake index 6e15116d..c86267ee 100644 --- a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1604.cmake +++ b/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu.cmake @@ -27,19 +27,11 @@ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) -set( USE_OPENCV_TOOLCHAIN_FLAGS ON ) -if( USE_OPENCV_TOOLCHAIN_FLAGS ) - # --- - # Snatched from OpenCV 3.4.2-1 - # --- - - set( CMAKE_CXX_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - set( CMAKE_C_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - - set( ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" ) - - set( CMAKE_SHARED_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_MODULE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_EXE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - -endif() +set( ARM_COMPILER_FLAGS "-fdata-sections -Wa,--noexecstack -fsigned-char" ) +set( CMAKE_C_FLAGS_INIT "${ARM_COMPILER_FLAGS}" ) +set( CMAKE_CXX_FLAGS_INIT "${ARM_COMPILER_FLAGS}" ) + +set( ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" ) +set( CMAKE_SHARED_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) +set( CMAKE_MODULE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) +set( CMAKE_EXE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) diff --git a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2004.cmake b/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2004.cmake deleted file mode 100644 index 6e15116d..00000000 --- a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2004.cmake +++ /dev/null @@ -1,45 +0,0 @@ -# name of the target operating system -set( CMAKE_SYSTEM_NAME Linux ) -set( CMAKE_SYSTEM_PROCESSOR aarch64 ) - -set( GNU_MACHINE "aarch64-linux-gnu" ) - -# which compilers to use for C and C++ -set( CMAKE_C_COMPILER ${GNU_MACHINE}-gcc ) -set( CMAKE_CXX_COMPILER ${GNU_MACHINE}-g++ ) - -# here is the target environment located -if( NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE ) - set( ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX} ) -endif() - -list( APPEND CMAKE_FIND_ROOT_PATH ${ARM_LINUX_SYSROOT} ) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) - -# Ubuntu/amd64 + foreign architecture arm64 -set( CMAKE_LIBRARY_PATH /usr/lib/${GNU_MACHINE}-linux-gnu ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH ) -#set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) - -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( USE_OPENCV_TOOLCHAIN_FLAGS ON ) -if( USE_OPENCV_TOOLCHAIN_FLAGS ) - # --- - # Snatched from OpenCV 3.4.2-1 - # --- - - set( CMAKE_CXX_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - set( CMAKE_C_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - - set( ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" ) - - set( CMAKE_SHARED_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_MODULE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_EXE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - -endif() diff --git a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2204.cmake b/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2204.cmake deleted file mode 100644 index 6e15116d..00000000 --- a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu2204.cmake +++ /dev/null @@ -1,45 +0,0 @@ -# name of the target operating system -set( CMAKE_SYSTEM_NAME Linux ) -set( CMAKE_SYSTEM_PROCESSOR aarch64 ) - -set( GNU_MACHINE "aarch64-linux-gnu" ) - -# which compilers to use for C and C++ -set( CMAKE_C_COMPILER ${GNU_MACHINE}-gcc ) -set( CMAKE_CXX_COMPILER ${GNU_MACHINE}-g++ ) - -# here is the target environment located -if( NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE ) - set( ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX} ) -endif() - -list( APPEND CMAKE_FIND_ROOT_PATH ${ARM_LINUX_SYSROOT} ) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) - -# Ubuntu/amd64 + foreign architecture arm64 -set( CMAKE_LIBRARY_PATH /usr/lib/${GNU_MACHINE}-linux-gnu ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH ) -#set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) - -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( USE_OPENCV_TOOLCHAIN_FLAGS ON ) -if( USE_OPENCV_TOOLCHAIN_FLAGS ) - # --- - # Snatched from OpenCV 3.4.2-1 - # --- - - set( CMAKE_CXX_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - set( CMAKE_C_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - - set( ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" ) - - set( CMAKE_SHARED_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_MODULE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_EXE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - -endif() diff --git a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake b/cmake/toolchains/arm-linux-gnueabihf-gcc-ubuntu.cmake similarity index 56% rename from cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake rename to cmake/toolchains/arm-linux-gnueabihf-gcc-ubuntu.cmake index 6e15116d..e9606bb2 100644 --- a/cmake/toolchains/aarch64-linux-gnu-gcc-ubuntu1804.cmake +++ b/cmake/toolchains/arm-linux-gnueabihf-gcc-ubuntu.cmake @@ -1,8 +1,8 @@ # name of the target operating system set( CMAKE_SYSTEM_NAME Linux ) -set( CMAKE_SYSTEM_PROCESSOR aarch64 ) +set( CMAKE_SYSTEM_PROCESSOR arm ) -set( GNU_MACHINE "aarch64-linux-gnu" ) +set( GNU_MACHINE "arm-linux-gnueabihf" ) # which compilers to use for C and C++ set( CMAKE_C_COMPILER ${GNU_MACHINE}-gcc ) @@ -27,19 +27,11 @@ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) -set( USE_OPENCV_TOOLCHAIN_FLAGS ON ) -if( USE_OPENCV_TOOLCHAIN_FLAGS ) - # --- - # Snatched from OpenCV 3.4.2-1 - # --- +set( ARM_COMPILER_FLAGS "-fdata-sections -Wa,--noexecstack -fsigned-char -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv3" ) +set( CMAKE_C_FLAGS_INIT "${ARM_COMPILER_FLAGS}" ) +set( CMAKE_CXX_FLAGS_INIT "${ARM_COMPILER_FLAGS}" ) - set( CMAKE_CXX_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - set( CMAKE_C_FLAGS_INIT "-fdata-sections -Wa,--noexecstack -fsigned-char" ) - - set( ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" ) - - set( CMAKE_SHARED_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_MODULE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - set( CMAKE_EXE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) - -endif() +set( ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" ) +set( CMAKE_SHARED_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) +set( CMAKE_MODULE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) +set( CMAKE_EXE_LINKER_FLAGS_INIT "${ARM_LINKER_FLAGS}" ) diff --git a/cmake/toolchains/i686-w64-mingw32-gcc-posix-ubuntu1604.cmake b/cmake/toolchains/i686-w64-mingw32-gcc-posix-ubuntu.cmake similarity index 79% rename from cmake/toolchains/i686-w64-mingw32-gcc-posix-ubuntu1604.cmake rename to cmake/toolchains/i686-w64-mingw32-gcc-posix-ubuntu.cmake index 0c1af221..003faf92 100644 --- a/cmake/toolchains/i686-w64-mingw32-gcc-posix-ubuntu1604.cmake +++ b/cmake/toolchains/i686-w64-mingw32-gcc-posix-ubuntu.cmake @@ -15,7 +15,7 @@ set( CMAKE_RC_COMPILER i686-w64-mingw32-windres ) # /usr/x86_64-w64-mingw32/include # /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include # /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++.a -set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/i686-w64-mingw32 /usr/lib/gcc/i686-w64-mingw32/5.3-posix ) +set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/i686-w64-mingw32 ) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search @@ -23,8 +23,3 @@ set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/i686-w64-mingw32 /usr/lib/gc set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( bb_MINGW_RUNTIME_FILES - /usr/lib/gcc/i686-w64-mingw32/5.3-posix/libstdc++-6.dll - /usr/lib/gcc/i686-w64-mingw32/5.3-posix/libgcc_s_sjlj-1.dll - /usr/i686-w64-mingw32/lib/libwinpthread-1.dll ) diff --git a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2204.cmake b/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu.cmake similarity index 79% rename from cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2204.cmake rename to cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu.cmake index 3bc07d72..b94ac27b 100644 --- a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2204.cmake +++ b/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu.cmake @@ -15,7 +15,7 @@ set( CMAKE_RC_COMPILER x86_64-w64-mingw32-windres ) # /usr/x86_64-w64-mingw32/include # /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include # /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++.a -set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/x86_64-w64-mingw32 /usr/lib/gcc/x86_64-w64-mingw32/10-posix ) +set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/x86_64-w64-mingw32 ) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search @@ -23,8 +23,3 @@ set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/x86_64-w64-mingw32 /usr/lib/ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( bb_MINGW_RUNTIME_FILES - /usr/lib/gcc/x86_64-w64-mingw32/10-posix/libstdc++-6.dll - /usr/lib/gcc/x86_64-w64-mingw32/10-posix/libgcc_s_seh-1.dll - /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ) diff --git a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu1604.cmake b/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu1604.cmake deleted file mode 100644 index cd57f00e..00000000 --- a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu1604.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# name of the target operating system -set( CMAKE_SYSTEM_NAME Windows ) -set( CMAKE_SYSTEM_PROCESSOR x86_64 ) # or AMD64? - -# which compilers to use for C and C++ -set( CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix ) -set( CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix ) -set( CMAKE_RC_COMPILER x86_64-w64-mingw32-windres ) - -# here is the target environment located -#SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc /home/alex/mingw-install ) -# -# /usr/share/mingw-w64/include -# /usr/x86_64-w64-mingw32/lib -# /usr/x86_64-w64-mingw32/include -# /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include -# /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++.a -set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/x86_64-w64-mingw32 /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix ) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( bb_MINGW_RUNTIME_FILES - /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++-6.dll - /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libgcc_s_seh-1.dll - /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ) - diff --git a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu1804.cmake b/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu1804.cmake deleted file mode 100644 index 9bf5056b..00000000 --- a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu1804.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# name of the target operating system -set( CMAKE_SYSTEM_NAME Windows ) -set( CMAKE_SYSTEM_PROCESSOR x86_64 ) # or AMD64? - -# which compilers to use for C and C++ -set( CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix ) -set( CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix ) -set( CMAKE_RC_COMPILER x86_64-w64-mingw32-windres ) - -# here is the target environment located -#SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc /home/alex/mingw-install ) -# -# /usr/share/mingw-w64/include -# /usr/x86_64-w64-mingw32/lib -# /usr/x86_64-w64-mingw32/include -# /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include -# /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++.a -set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/x86_64-w64-mingw32 /usr/lib/gcc/x86_64-w64-mingw32/7.3-posix ) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( bb_MINGW_RUNTIME_FILES - /usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/libstdc++-6.dll - /usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/libgcc_s_seh-1.dll - /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ) - diff --git a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2004.cmake b/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2004.cmake deleted file mode 100644 index 6e607cc5..00000000 --- a/cmake/toolchains/x86_64-w64-mingw32-gcc-posix-ubuntu2004.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# name of the target operating system -set( CMAKE_SYSTEM_NAME Windows ) -set( CMAKE_SYSTEM_PROCESSOR x86_64 ) # or AMD64? - -# which compilers to use for C and C++ -set( CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix ) -set( CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix ) -set( CMAKE_RC_COMPILER x86_64-w64-mingw32-windres ) - -# here is the target environment located -#SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc /home/alex/mingw-install ) -# -# /usr/share/mingw-w64/include -# /usr/x86_64-w64-mingw32/lib -# /usr/x86_64-w64-mingw32/include -# /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include -# /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++.a -set( CMAKE_FIND_ROOT_PATH /usr/share/mingw-w64 /usr/x86_64-w64-mingw32 /usr/lib/gcc/x86_64-w64-mingw32/9.3-posix ) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - -set( bb_MINGW_RUNTIME_FILES - /usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/libstdc++-6.dll - /usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/libgcc_s_seh-1.dll - /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ) diff --git a/source/Lib/CommonLib/BitStream.h b/source/Lib/CommonLib/BitStream.h index 93d1fa00..47277daa 100644 --- a/source/Lib/CommonLib/BitStream.h +++ b/source/Lib/CommonLib/BitStream.h @@ -50,7 +50,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include "CommonDef.h" -#include "CommonDefX86.h" // needed for simde_bswap64, but don't just include simde-common.h, because it breaks other files + +#ifdef TARGET_SIMD_X86 +# include "CommonDefX86.h" // needed for simde_bswap64, but don't just include simde-common.h, because it breaks other files +#else +# include "simde/simde-common.h" +#endif namespace vvdec { diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index a69399e8..267ea525 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -63,13 +63,9 @@ POSSIBILITY OF SUCH DAMAGE. # define REAL_TARGET_WASM 1 #endif -#if defined( TARGET_SIMD_X86 ) -# ifdef _WIN32 +#ifdef _WIN32 # include -//# elif defined( __GNUC__ ) -//# include -# endif -#endif // TARGET_SIMD_X86 +#endif #if defined( __INTEL_COMPILER ) #pragma warning( disable : 1786 ) @@ -515,18 +511,27 @@ template struct AlignedDeleter #if ENABLE_SIMD_OPT +//necessary to be able to compare with SIMD_EVERYWHERE_EXTENSION_LEVEL in the preprocessor +#define X86_SIMD_UNDEFINED -1 +#define X86_SIMD_SCALAR 0 +#define X86_SIMD_SSE41 1 +#define X86_SIMD_SSE42 2 +#define X86_SIMD_AVX 3 +#define X86_SIMD_AVX2 4 +#define X86_SIMD_AVX512 5 + namespace x86_simd { # ifdef TARGET_SIMD_X86 typedef enum { - UNDEFINED = -1, - SCALAR = 0, - SSE41, - SSE42, - AVX, - AVX2, - AVX512 + UNDEFINED = X86_SIMD_UNDEFINED, + SCALAR = X86_SIMD_SCALAR, + SSE41 = X86_SIMD_SSE41, + SSE42 = X86_SIMD_SSE42, + AVX = X86_SIMD_AVX, + AVX2 = X86_SIMD_AVX2, + AVX512 = X86_SIMD_AVX512, } X86_VEXT; # endif // TARGET_SIMD_X86 } // namespace x86_simd @@ -548,19 +553,13 @@ namespace arm_simd template static inline ValueType rightShift (const ValueType value, const int shift) { return (shift >= 0) ? ( value >> shift) : ( value << -shift); } template static inline ValueType rightShift_round(const ValueType value, const int shift) { return (shift >= 0) ? ((value + (ValueType(1) << (shift - 1))) >> shift) : ( value << -shift); } -#if defined( _WIN32 ) && defined( TARGET_SIMD_X86 ) +#if defined( _WIN32 ) static inline unsigned int bit_scan_reverse( int a ) { unsigned long idx = 0; _BitScanReverse( &idx, a ); return idx; } -// disabled because it requires x86intrin.h which conflicts with simd-everywhere -// #elif defined( __GNUC__ ) && defined( TARGET_SIMD_X86 ) && !defined( REAL_TARGET_WASM ) -// static inline unsigned int bit_scan_reverse( int a ) -// { -// return _bit_scan_reverse( a ); -// } #elif defined( __GNUC__ ) static inline unsigned int bit_scan_reverse( int a ) { diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index aef90f65..7fa105f8 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -163,6 +163,7 @@ namespace vvdec #if defined( TARGET_SIMD_X86 ) && !defined( REAL_TARGET_X86 ) # define SIMD_EVERYWHERE_EXTENSION_LEVEL SSE41 +# define SIMD_EVERYWHERE_EXTENSION_LEVEL_ID X86_SIMD_SSE41 #endif // End of SIMD optimizations @@ -731,6 +732,10 @@ enum ErrHandlingFlags // --------------------------------------------------------------------------- // exception class // --------------------------------------------------------------------------- +#if defined( __MINGW32__ ) && !defined( __MINGW64__ ) +namespace // anonymous namespace to fix linker (bug?) in i686-mingw, which results in duplicate symbols for Exception::operator<<(char[]) +{ +#endif // __MINGW32__ class Exception : public std::exception { @@ -761,6 +766,10 @@ class UnsupportedFeatureException : public Exception CLASS_COPY_MOVE_DEFAULT( UnsupportedFeatureException ) }; +#if defined( __MINGW32__ ) && !defined( __MINGW64__ ) +} // anonymous namespace +#endif // __MINGW32__ + #if !defined( __PRETTY_FUNCTION__ ) && !defined( __GNUC__ ) # define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/source/Lib/CommonLib/x86/CommonDefX86.h b/source/Lib/CommonLib/x86/CommonDefX86.h index cdd76354..f2386485 100644 --- a/source/Lib/CommonLib/x86/CommonDefX86.h +++ b/source/Lib/CommonLib/x86/CommonDefX86.h @@ -49,6 +49,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef TARGET_SIMD_X86 +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +// wingdi.h breaks compilation (why only on arm?). It defines some +// constants like ERROR (included by windows.h, included by simd-everywhere) +# define NOGDI +#endif + # if REAL_TARGET_X86 || REAL_TARGET_WASM # ifdef _WIN32 # include diff --git a/source/Lib/CommonLib/x86/InitX86.cpp b/source/Lib/CommonLib/x86/InitX86.cpp index f8bdf0cb..9dfa4340 100644 --- a/source/Lib/CommonLib/x86/InitX86.cpp +++ b/source/Lib/CommonLib/x86/InitX86.cpp @@ -67,6 +67,13 @@ namespace vvdec #ifdef TARGET_SIMD_X86 +# if defined( REAL_TARGET_X86 ) \ + || ( defined( SIMD_EVERYWHERE_EXTENSION_LEVEL_ID ) && SIMD_EVERYWHERE_EXTENSION_LEVEL_ID >= X86_SIMD_AVX2 ) +# define ENABLE_AVX2_IMPLEMENTATIONS 1 +# else +# define ENABLE_AVX2_IMPLEMENTATIONS 0 +# endif + #if ENABLE_SIMD_OPT_MCIF void InterpolationFilter::initInterpolationFilterX86( /*int iBitDepthY, int iBitDepthC*/ ) @@ -75,10 +82,10 @@ void InterpolationFilter::initInterpolationFilterX86( /*int iBitDepthY, int iBit switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initInterpolationFilterX86(/*iBitDepthY, iBitDepthC*/); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -97,10 +104,10 @@ void PelBufferOps::initPelBufOpsX86() switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initPelBufOpsX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -112,9 +119,6 @@ void PelBufferOps::initPelBufOpsX86() } #endif - - - #if ENABLE_SIMD_OPT_DIST void RdCost::initRdCostX86() { @@ -122,11 +126,12 @@ void RdCost::initRdCostX86() switch (vext){ case AVX512: case AVX2: -#if defined( REAL_TARGET_WASM ) || ( defined( _MSC_VER ) && _MSC_VER >= 1938 && _MSC_VER < 1939 ) -#else +#if ENABLE_AVX2_IMPLEMENTATIONS +#if !(defined(_MSC_VER) && _MSC_VER >= 1938 && _MSC_VER < 1939) // workaround for buggy msvc versions _initRdCostX86(); break; #endif +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -146,10 +151,10 @@ void AdaptiveLoopFilter::initAdaptiveLoopFilterX86() { case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initAdaptiveLoopFilterX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -169,10 +174,10 @@ void LoopFilter::initLoopFilterX86() { case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initLoopFilterX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -193,10 +198,10 @@ void TCoeffOps::initTCoeffOpsX86() { case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initTCoeffOpsX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -215,10 +220,10 @@ void TrQuant::initTrQuantX86() { case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initTrQuantX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -237,10 +242,10 @@ void IntraPrediction::initIntraPredictionX86() switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initIntraPredictionX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -260,10 +265,10 @@ void SampleAdaptiveOffset::initSampleAdaptiveOffsetX86() switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initSampleAdaptiveOffsetX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -284,10 +289,10 @@ void InterPrediction::initInterPredictionX86() switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initInterPredictionX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -307,10 +312,10 @@ void Picture::initPictureX86() switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initPictureX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -330,10 +335,10 @@ void Quant::initQuantX86() switch (vext){ case AVX512: case AVX2: -#ifndef REAL_TARGET_WASM +#if ENABLE_AVX2_IMPLEMENTATIONS _initQuantX86(); break; -#endif // !REAL_TARGET_WASM +#endif // ENABLE_AVX2_IMPLEMENTATIONS case AVX: case SSE42: case SSE41: @@ -347,8 +352,6 @@ void Quant::initQuantX86() #endif +#endif // TARGET_SIMD_X86 - -#endif - -} +} // namespace vvdec diff --git a/source/Lib/vvdec/CMakeLists.txt b/source/Lib/vvdec/CMakeLists.txt index 87581893..e23d958b 100644 --- a/source/Lib/vvdec/CMakeLists.txt +++ b/source/Lib/vvdec/CMakeLists.txt @@ -29,7 +29,7 @@ if( VVDEC_ENABLE_X86_SIMD ) file( GLOB X86_SSE41_SRC_FILES "../CommonLib/x86/sse41/*.cpp" ) #file( GLOB X86_SSE42_SRC_FILES "../CommonLib/x86/sse42/*.cpp" ) #file( GLOB X86_AVX_SRC_FILES "../CommonLib/x86/avx/*.cpp" ) - if( NOT VVDEC_TARGET_WASM ) + if( VVDEC_TARGET_ARCH STREQUAL "X86" ) file( GLOB X86_AVX2_SRC_FILES "../CommonLib/x86/avx2/*.cpp" ) endif() endif() @@ -95,7 +95,7 @@ if( VVDEC_ENABLE_X86_SIMD ) elseif( UNIX OR MINGW ) include( vvdecCompilerSupport ) - if( NOT VVDEC_TARGET_WASM ) + if( NOT VVDEC_TARGET_ARCH STREQUAL "WASM" ) set_if_compiler_supports_flag( FLAG_mxsave -mxsave ) set_property( SOURCE ${X86_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS ${FLAG_mxsave} ) endif()