[x265] [PATCH] cmake: plumb in build support for Main12

Steve Borho steve at borho.org
Thu Jul 2 17:56:31 CEST 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1435777105 18000
#      Wed Jul 01 13:58:25 2015 -0500
# Node ID c2ee1d9a69d7b1ed401d52c1695a89869965cac6
# Parent  76a314f91799c2dce6878c389503d2fe9007dbe8
cmake: plumb in build support for Main12

Obviously a lot of work is necessary before Main12 will actually work, but this
lays the ground-work for the third bit-depth build option. To build Main12 you
specify -DHIGH_BIT_DEPTH=ON -DMAIN12=ON to cmake

diff -r 76a314f91799 -r c2ee1d9a69d7 build/linux/multilib.sh
--- a/build/linux/multilib.sh	Wed Jul 01 17:05:52 2015 -0700
+++ b/build/linux/multilib.sh	Wed Jul 01 13:58:25 2015 -0500
@@ -1,12 +1,17 @@
 #!/bin/sh
 
-mkdir -p 8bit 10bit
+mkdir -p 8bit 10bit 12bit
 
-cd 10bit
+cd 12bit
+cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
+make ${MAKEFLAGS}
+
+cd ../10bit
 cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
-make
-cp libx265.a ../8bit/libx265_main10.a
+make ${MAKEFLAGS}
 
 cd ../8bit
-cmake ../../../source -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB=x265_main10.a -DEXTRA_LINK_FLAGS=-L.
-make
+ln -sf ../10bit/libx265.a libx265_main10.a
+ln -sf ../12bit/libx265.a libx265_main12.a
+cmake ../../../source -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L.
+make ${MAKEFLAGS}
diff -r 76a314f91799 -r c2ee1d9a69d7 build/msys/multilib.sh
--- a/build/msys/multilib.sh	Wed Jul 01 17:05:52 2015 -0700
+++ b/build/msys/multilib.sh	Wed Jul 01 13:58:25 2015 -0500
@@ -1,12 +1,17 @@
 #!/bin/sh
 
-mkdir -p 8bit 10bit
+mkdir -p 8bit 10bit 12bit
 
-cd 10bit
+cd 12bit
+cmake -G "MSYS Makefiles" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
+make ${MAKEFLAGS}
+cp libx265.a ../8bit/libx265_main12.a
+
+cd ../10bit
 cmake -G "MSYS Makefiles" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
-make
+make ${MAKEFLAGS}
 cp libx265.a ../8bit/libx265_main10.a
 
 cd ../8bit
-cmake -G "MSYS Makefiles" ../../../source -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB=x265_main10.a -DEXTRA_LINK_FLAGS=-L.
-make
+cmake -G "MSYS Makefiles" ../../../source -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB="x265_main10.a x265_main12.a" -DEXTRA_LINK_FLAGS=-L.
+make ${MAKEFLAGS}
diff -r 76a314f91799 -r c2ee1d9a69d7 build/vc10-x86_64/multilib.bat
--- a/build/vc10-x86_64/multilib.bat	Wed Jul 01 17:05:52 2015 -0700
+++ b/build/vc10-x86_64/multilib.bat	Wed Jul 01 13:58:25 2015 -0500
@@ -4,9 +4,21 @@
   exit 1
 )
 
+ at mkdir 12bit
 @mkdir 10bit
 @mkdir 8bit
 
+ at cd 12bit
+if not exist x265.sln (
+  cmake  -G "Visual Studio 10 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
+)
+if exist x265.sln (
+  call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
+  MSBuild /property:Configuration="Release" x265.sln
+  copy/y Release\x265-static.lib ..\8bit\x265-static-main12.lib
+)
+ at cd ..
+
 @cd 10bit
 if not exist x265.sln (
   cmake  -G "Visual Studio 10 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
@@ -24,7 +36,7 @@
   exit 1
 )
 if not exist x265.sln (
-  cmake  -G "Visual Studio 10 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB=x265-static-main10.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+  cmake  -G "Visual Studio 10 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB="x265-static-main10.lib;x265-static-main12.lib" -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
 )
 if exist x265.sln (
   call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
diff -r 76a314f91799 -r c2ee1d9a69d7 build/vc11-x86_64/multilib.bat
--- a/build/vc11-x86_64/multilib.bat	Wed Jul 01 17:05:52 2015 -0700
+++ b/build/vc11-x86_64/multilib.bat	Wed Jul 01 13:58:25 2015 -0500
@@ -4,9 +4,21 @@
   exit 1
 )
 
+ at mkdir 12bit
 @mkdir 10bit
 @mkdir 8bit
 
+ at cd 12bit
+if not exist x265.sln (
+  cmake  -G "Visual Studio 11 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
+)
+if exist x265.sln (
+  call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
+  MSBuild /property:Configuration="Release" x265.sln
+  copy/y Release\x265-static.lib ..\8bit\x265-static-main12.lib
+)
+ at cd ..
+
 @cd 10bit
 if not exist x265.sln (
   cmake  -G "Visual Studio 11 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
@@ -24,7 +36,7 @@
   exit 1
 )
 if not exist x265.sln (
-  cmake  -G "Visual Studio 11 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB=x265-static-main10.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+  cmake  -G "Visual Studio 11 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB="x265-static-main10.lib;x265-static-main12.lib" -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
 )
 if exist x265.sln (
   call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
diff -r 76a314f91799 -r c2ee1d9a69d7 build/vc12-x86_64/multilib.bat
--- a/build/vc12-x86_64/multilib.bat	Wed Jul 01 17:05:52 2015 -0700
+++ b/build/vc12-x86_64/multilib.bat	Wed Jul 01 13:58:25 2015 -0500
@@ -4,9 +4,21 @@
   exit 1
 )
 
+ at mkdir 12bit
 @mkdir 10bit
 @mkdir 8bit
 
+ at cd 12bit
+if not exist x265.sln (
+  cmake  -G "Visual Studio 12 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
+)
+if exist x265.sln (
+  call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
+  MSBuild /property:Configuration="Release" x265.sln
+  copy/y Release\x265-static.lib ..\8bit\x265-static-main12.lib
+)
+ at cd ..
+
 @cd 10bit
 if not exist x265.sln (
   cmake  -G "Visual Studio 12 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
@@ -24,7 +36,7 @@
   exit 1
 )
 if not exist x265.sln (
-  cmake  -G "Visual Studio 12 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB=x265-static-main10.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+  cmake  -G "Visual Studio 12 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB="x265-static-main10.lib;x265-static-main12.lib" -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
 )
 if exist x265.sln (
   call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
diff -r 76a314f91799 -r c2ee1d9a69d7 build/vc9-x86_64/multilib.bat
--- a/build/vc9-x86_64/multilib.bat	Wed Jul 01 17:05:52 2015 -0700
+++ b/build/vc9-x86_64/multilib.bat	Wed Jul 01 13:58:25 2015 -0500
@@ -4,9 +4,21 @@
   exit 1
 )
 
+ at mkdir 12bit
 @mkdir 10bit
 @mkdir 8bit
 
+ at cd 12bit
+if not exist x265.sln (
+  cmake  -G "Visual Studio 9 2008 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
+)
+if exist x265.sln (
+  call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
+  MSBuild /property:Configuration="Release" x265.sln
+  copy/y Release\x265-static.lib ..\8bit\x265-static-main12.lib
+)
+ at cd ..
+
 @cd 10bit
 if not exist x265.sln (
   cmake  -G "Visual Studio 9 2008 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
@@ -24,7 +36,7 @@
   exit 1
 )
 if not exist x265.sln (
-  cmake  -G "Visual Studio 9 2008 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB=x265-static-main10.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+  cmake  -G "Visual Studio 9 2008 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DEXTRA_LIB="x265-static-main10.lib;x265-static-main12.lib" -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
 )
 if exist x265.sln (
   call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
diff -r 76a314f91799 -r c2ee1d9a69d7 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Wed Jul 01 17:05:52 2015 -0700
+++ b/source/CMakeLists.txt	Wed Jul 01 13:58:25 2015 -0500
@@ -282,12 +282,17 @@
     # build with 10bit/12bit support, but this violates the "shrink wrap
     # license" so to speak.  If it breaks you get to keep both halves.
     # You will need to disable assembly manually.
-    option(HIGH_BIT_DEPTH "Store pixel samples as 16bit values (Main10)" OFF)
+    option(HIGH_BIT_DEPTH "Store pixel samples as 16bit values (Main10/Main12)" OFF)
 endif(X64)
 if(HIGH_BIT_DEPTH)
-    add_definitions(-DHIGH_BIT_DEPTH=1)
+    option(MAIN12 "Support Main12 instead of Main10" OFF)
+    if(MAIN12)
+        add_definitions(-DHIGH_BIT_DEPTH=1 -DX265_DEPTH=12)
+    else()
+        add_definitions(-DHIGH_BIT_DEPTH=1 -DX265_DEPTH=10)
+    endif()
 else(HIGH_BIT_DEPTH)
-    add_definitions(-DHIGH_BIT_DEPTH=0)
+    add_definitions(-DHIGH_BIT_DEPTH=0 -DX265_DEPTH=8)
 endif(HIGH_BIT_DEPTH)
 
 # this option can only be used when linking multiple libx265 libraries
@@ -298,7 +303,11 @@
     set(X265_NS x265)
     add_definitions(-DEXPORT_C_API=1)
 elseif(HIGH_BIT_DEPTH)
-    set(X265_NS x265_10bit)
+    if(MAIN12)
+        set(X265_NS x265_12bit)
+    else()
+        set(X265_NS x265_10bit)
+    endif()
     add_definitions(-DEXPORT_C_API=0)
 else()
     set(X265_NS x265_8bit)
diff -r 76a314f91799 -r c2ee1d9a69d7 source/common/common.h
--- a/source/common/common.h	Wed Jul 01 17:05:52 2015 -0700
+++ b/source/common/common.h	Wed Jul 01 13:58:25 2015 -0500
@@ -126,14 +126,12 @@
 typedef uint64_t sum2_t;
 typedef uint64_t pixel4;
 typedef int64_t  ssum2_t;
-#define X265_DEPTH 10          // compile time configurable bit depth
 #else
 typedef uint8_t  pixel;
 typedef uint16_t sum_t;
 typedef uint32_t sum2_t;
 typedef uint32_t pixel4;
-typedef int32_t  ssum2_t;      //Signed sum
-#define X265_DEPTH 8           // compile time configurable bit depth
+typedef int32_t  ssum2_t; // Signed sum
 #endif // if HIGH_BIT_DEPTH
 
 #ifndef NULL
diff -r 76a314f91799 -r c2ee1d9a69d7 source/common/version.cpp
--- a/source/common/version.cpp	Wed Jul 01 17:05:52 2015 -0700
+++ b/source/common/version.cpp	Wed Jul 01 13:58:25 2015 -0500
@@ -88,12 +88,21 @@
 #define CHECKED " "
 #endif
 
-#if HIGH_BIT_DEPTH
+#if X265_DEPTH == 12
+
+#define BITDEPTH "12bit"
+const int PFX(max_bit_depth) = 12;
+
+#elif X265_DEPTH == 10
+
 #define BITDEPTH "10bit"
 const int PFX(max_bit_depth) = 10;
-#else
+
+#elif X265_DEPTH == 8
+
 #define BITDEPTH "8bit"
 const int PFX(max_bit_depth) = 8;
+
 #endif
 
 const char* PFX(version_str) = XSTR(X265_VERSION);
diff -r 76a314f91799 -r c2ee1d9a69d7 source/encoder/api.cpp
--- a/source/encoder/api.cpp	Wed Jul 01 17:05:52 2015 -0700
+++ b/source/encoder/api.cpp	Wed Jul 01 13:58:25 2015 -0500
@@ -49,6 +49,16 @@
     if (!p)
         return NULL;
 
+#if HIGH_BIT_DEPTH
+    if (X265_DEPTH != 10 && X265_DEPTH != 12)
+#else
+    if (X265_DEPTH != 8)
+#endif
+    {
+        x265_log(p, X265_LOG_ERROR, "Build error, internal bit depth mismatch\n");
+        return NULL;
+    }
+
     Encoder* encoder = NULL;
     x265_param* param = PARAM_NS::x265_param_alloc();
     x265_param* latestParam = PARAM_NS::x265_param_alloc();
@@ -424,6 +434,10 @@
 const x265_api* x265_api_get(int bitDepth);
 const x265_api* x265_api_query(int bitDepth, int apiVersion, int* err);
 }
+namespace x265_12bit {
+const x265_api* x265_api_get(int bitDepth);
+const x265_api* x265_api_query(int bitDepth, int apiVersion, int* err);
+}
 
 extern "C"
 const x265_api* x265_api_get(int bitDepth)
@@ -432,16 +446,22 @@
         return x265_8bit::x265_api_get(0);
     else if (bitDepth == 10)
         return x265_10bit::x265_api_get(0);
+    else if (bitDepth == 12)
+        return x265_12bit::x265_api_get(0);
     return NULL;
 }
 
 extern "C"
 const x265_api* x265_api_query(int bitDepth, int apiVersion, int* err)
 {
+    if (err) *err = X265_API_QUERY_ERR_NONE;
     if (!bitDepth || bitDepth == 8)
         return x265_8bit::x265_api_query(0, apiVersion, err);
     else if (bitDepth == 10)
         return x265_10bit::x265_api_query(0, apiVersion, err);
+    else if (bitDepth == 12)
+        return x265_12bit::x265_api_query(0, apiVersion, err);
+    if (err) *err = X265_API_QUERY_ERR_LIB_NOT_FOUND;
     return NULL;
 }
 #endif


More information about the x265-devel mailing list