[Bf-blender-cvs] [aa788b759a4] master: deps: FFmpeg vpx/aom-av1 updates

Ray Molenkamp noreply at git.blender.org
Tue Jul 26 13:44:45 CEST 2022


Commit: aa788b759a4119cc93f09c71b5aae270d160c01a
Author: Ray Molenkamp
Date:   Tue Jul 26 13:17:23 2022 +0200
Branches: master
https://developer.blender.org/rBaa788b759a4119cc93f09c71b5aae270d160c01a

deps: FFmpeg vpx/aom-av1 updates

This is a refresh of our current FFmpeg 5.0.0 (unchanged) version with the
following changes:

* libvpx all platforms: enable SSE3/4/AVX/AVX2 instruction sets. libvpx has a
  proper CPUID check in place and will not call the faster kernels unless it is
  sure the CPU supports it. So we can safely enable this, this partially
  resolves T95743 (completely on Linux and macOS).

* libvpx Windows - threading was disabled due to a shared dependency on
  libwinpthreads.dll which we prefer not to distribute. However when configure
  cannot find pthreads it will happily fall back on a win32 threads based
  emulation layer. This also resolves the final part of T95743.

* libaom-av1 - new dependency required for D14920, this is a somewhat odd
  dependency, it's cmake based, but still needs the perl environment setup, so
  we have to setup the env and call cmake our selves for the configure, build
  and install commands. This dep has the same libwinpthreads issue as vpx on
  Windows, however since it's cmake based, it's easier to prevent cmake from
  detecting it.

Differential Revision: https://developer.blender.org/D15399

===================================================================

M	build_files/build_environment/CMakeLists.txt
A	build_files/build_environment/cmake/aom.cmake
M	build_files/build_environment/cmake/download.cmake
M	build_files/build_environment/cmake/ffmpeg.cmake
M	build_files/build_environment/cmake/harvest.cmake
M	build_files/build_environment/cmake/versions.cmake
M	build_files/build_environment/cmake/vpx.cmake
A	build_files/build_environment/patches/vpx_windows.diff
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake

===================================================================

diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index e0350901cd0..856fe7b32ff 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -139,6 +139,7 @@ if(NOT WIN32 OR ENABLE_MINGW64)
     include(cmake/vpx.cmake)
     include(cmake/x264.cmake)
     include(cmake/xvidcore.cmake)
+    include(cmake/aom.cmake)
     include(cmake/ffmpeg.cmake)
     include(cmake/fftw.cmake)
     include(cmake/sndfile.cmake)
diff --git a/build_files/build_environment/cmake/aom.cmake b/build_files/build_environment/cmake/aom.cmake
new file mode 100644
index 00000000000..9f64439771f
--- /dev/null
+++ b/build_files/build_environment/cmake/aom.cmake
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+if(WIN32)
+  # The default generator on windows is msbuild, which we do not
+  # want to use for this dep, as needs to build with mingw
+  set(AOM_GENERATOR "Ninja")
+  # The default flags are full of MSVC options given this will be
+  # building with mingw, it'll have an unhappy time with that and
+  # we need to clear them out.
+  set(AOM_CMAKE_FLAGS )
+  # CMake will correctly identify phreads being available, however
+  # we do not want to use them, as that gains a dependency on
+  # libpthreadswin.dll which we do not want. when pthreads is not
+  # available oam will use a pthreads emulation layer using win32 threads
+  set(AOM_EXTRA_ARGS_WIN32 -DCMAKE_HAVE_PTHREAD_H=OFF)
+else()
+  set(AOM_GENERATOR "Unix Makefiles")
+  set(AOM_CMAKE_FLAGS ${DEFAULT_CMAKE_FLAGS})
+endif()
+
+set(AOM_EXTRA_ARGS
+  -DENABLE_TESTDATA=OFF
+  -DENABLE_TESTS=OFF
+  -DENABLE_TOOLS=OFF
+  -DENABLE_EXAMPLES=OFF
+  ${AOM_EXTRA_ARGS_WIN32}
+)
+
+# This is slightly different from all other deps in the way that
+# aom uses cmake as a build system, but still needs the environment setup
+# to include perl so we manually setup the environment and call
+# cmake directly for the configure, build and install commands.
+
+ExternalProject_Add(external_aom
+  URL file://${PACKAGE_DIR}/${AOM_FILE}
+  DOWNLOAD_DIR ${DOWNLOAD_DIR}
+  URL_HASH ${AOM_HASH_TYPE}=${AOM_HASH}
+  PREFIX ${BUILD_DIR}/aom
+  CONFIGURE_COMMAND ${CONFIGURE_ENV} &&
+    cd ${BUILD_DIR}/aom/src/external_aom-build/ &&
+    ${CMAKE_COMMAND} -G "${AOM_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${LIBDIR}/aom ${AOM_CMAKE_FLAGS} ${AOM_EXTRA_ARGS} ${BUILD_DIR}/aom/src/external_aom/
+  BUILD_COMMAND ${CMAKE_COMMAND} --build .
+  INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install
+  INSTALL_DIR ${LIBDIR}/aom
+)
diff --git a/build_files/build_environment/cmake/download.cmake b/build_files/build_environment/cmake/download.cmake
index b7150525a65..547bf77f8dd 100644
--- a/build_files/build_environment/cmake/download.cmake
+++ b/build_files/build_environment/cmake/download.cmake
@@ -116,3 +116,4 @@ download_source(IGC_SPIRV_TOOLS)
 download_source(IGC_SPIRV_TRANSLATOR)
 download_source(GMMLIB)
 download_source(OCLOC)
+download_source(AOM)
diff --git a/build_files/build_environment/cmake/ffmpeg.cmake b/build_files/build_environment/cmake/ffmpeg.cmake
index 4cf96ee2fcb..7730607c514 100644
--- a/build_files/build_environment/cmake/ffmpeg.cmake
+++ b/build_files/build_environment/cmake/ffmpeg.cmake
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-set(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/opus/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/zlib/include")
-set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/opus/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/zlib/lib")
+set(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/opus/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/zlib/include -I${mingw_LIBDIR}/aom/include")
+set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/opus/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/zlib/lib -L${mingw_LIBDIR}/aom/lib")
 set(FFMPEG_EXTRA_FLAGS --pkg-config-flags=--static --extra-cflags=${FFMPEG_CFLAGS} --extra-ldflags=${FFMPEG_LDFLAGS})
-set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}:${mingw_LIBDIR}/vpx/lib/pkgconfig:${mingw_LIBDIR}/theora/lib/pkgconfig:${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:)
+set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}:${mingw_LIBDIR}/vpx/lib/pkgconfig:${mingw_LIBDIR}/theora/lib/pkgconfig:${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:${mingw_LIBDIR}/aom/lib/pkgconfig:)
 
 if(WIN32)
   set(FFMPEG_ENV set ${FFMPEG_ENV} &&)
@@ -79,6 +79,7 @@ ExternalProject_Add(external_ffmpeg
     --disable-librtmp
     --enable-libx264
     --enable-libxvid
+    --enable-libaom
     --disable-libopencore-amrnb
     --disable-libopencore-amrwb
     --disable-libdc1394
@@ -125,6 +126,7 @@ add_dependencies(
   external_vorbis
   external_ogg
   external_lame
+  external_aom
 )
 if(WIN32)
   add_dependencies(
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
index 2865a5304d7..1572feb9220 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -177,6 +177,7 @@ harvest(opus/lib ffmpeg/lib "*.a")
 harvest(vpx/lib ffmpeg/lib "*.a")
 harvest(x264/lib ffmpeg/lib "*.a")
 harvest(xvidcore/lib ffmpeg/lib "*.a")
+harvest(aom/lib ffmpeg/lib "*.a")
 harvest(webp/lib webp/lib "*.a")
 harvest(webp/include webp/include "*.h")
 harvest(usd/include usd/include "*.h")
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index 42c82b68654..3a37a4372af 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -633,3 +633,9 @@ set(OCLOC_URI https://github.com/intel/compute-runtime/archive/refs/tags/${OCLOC
 set(OCLOC_HASH ab22b8bf2560a57fdd3def0e35a62ca75991406f959c0263abb00cd6cd9ae998)
 set(OCLOC_HASH_TYPE SHA256)
 set(OCLOC_FILE ocloc-${OCLOC_VERSION}.tar.gz)
+
+set(AOM_VERSION 3.4.0)
+set(AOM_URI https://storage.googleapis.com/aom-releases/libaom-${AOM_VERSION}.tar.gz)
+set(AOM_HASH bd754b58c3fa69f3ffd29da77de591bd9c26970e3b18537951336d6c0252e354)
+set(AOM_HASH_TYPE SHA256)
+set(AOM_FILE libaom-${AOM_VERSION}.tar.gz)
diff --git a/build_files/build_environment/cmake/vpx.cmake b/build_files/build_environment/cmake/vpx.cmake
index ba17acad80f..111e93e79e1 100644
--- a/build_files/build_environment/cmake/vpx.cmake
+++ b/build_files/build_environment/cmake/vpx.cmake
@@ -1,11 +1,13 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 if(WIN32)
-  if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
-    set(VPX_EXTRA_FLAGS --target=x86_64-win64-gcc --disable-multithread)
-  else()
-    set(VPX_EXTRA_FLAGS --target=x86-win32-gcc --disable-multithread)
-  endif()
+  # VPX is determined to use pthreads which it will tell ffmpeg to dynamically
+  # link, which is not something we're super into distribution wise. However
+  # if it cannot find pthread.h it'll happily provide a pthread emulation
+  # layer using win32 threads. So all this patch does is make it not find
+  # pthead.h
+  set(VPX_PATCH ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/vpx/src/external_vpx < ${PATCH_DIR}/vpx_windows.diff)
+  set(VPX_EXTRA_FLAGS --target=x86_64-win64-gcc )
 else()
   if(APPLE)
     if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
@@ -18,6 +20,16 @@ else()
   endif()
 endif()
 
+if(NOT BLENDER_PLATFORM_ARM)
+  list(APPEND VPX_EXTRA_FLAGS
+    --enable-sse4_1
+    --enable-sse3
+    --enable-ssse3
+    --enable-avx
+    --enable-avx2
+  )
+endif()
+
 ExternalProject_Add(external_vpx
   URL file://${PACKAGE_DIR}/${VPX_FILE}
   DOWNLOAD_DIR ${DOWNLOAD_DIR}
@@ -30,11 +42,6 @@ ExternalProject_Add(external_vpx
       --enable-static
       --disable-install-bins
       --disable-install-srcs
-      --disable-sse4_1
-      --disable-sse3
-      --disable-ssse3
-      --disable-avx
-      --disable-avx2
       --disable-unit-tests
       --disable-examples
       --enable-vp8
@@ -42,6 +49,7 @@ ExternalProject_Add(external_vpx
       ${VPX_EXTRA_FLAGS}
   BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make -j${MAKE_THREADS}
   INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make install
+  PATCH_COMMAND ${VPX_PATCH}
   INSTALL_DIR ${LIBDIR}/vpx
 )
 
diff --git a/build_files/build_environment/patches/vpx_windows.diff b/build_files/build_environment/patches/vpx_windows.diff
new file mode 100644
index 00000000000..13e3b06d95d
--- /dev/null
+++ b/build_files/build_environment/patches/vpx_windows.diff
@@ -0,0 +1,11 @@
+diff -Naur orig/configure external_vpx/configure
+--- orig/configure	2022-07-06 09:22:04 -0600
++++ external_vpx/configure	2022-07-06 09:24:12 -0600
+@@ -270,7 +270,6 @@
+ HAVE_LIST="
+     ${ARCH_EXT_LIST}
+     vpx_ports
+-    pthread_h
+     unistd_h
+ "
+ EXPERIMENT_LIST="
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 32b10625590..3c77a28d55f 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -162,6 +162,9 @@ if(WITH_CODEC_FFMPEG)
  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list