[x265-commits] [x265] build: add example cross-compile script for Win64 on MinGW32

Steve Borho steve at borho.org
Sun Feb 16 00:57:08 CET 2014


details:   http://hg.videolan.org/x265/rev/0911885e0f28
branches:  
changeset: 6158:0911885e0f28
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 14 14:03:55 2014 -0600
description:
build: add example cross-compile script for Win64 on MinGW32
Subject: [x265] decouple input depth from internal depth; allow input depth != internal depth

details:   http://hg.videolan.org/x265/rev/b1f5fd61883a
branches:  
changeset: 6159:b1f5fd61883a
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 14 15:50:50 2014 -0600
description:
decouple input depth from internal depth; allow input depth != internal depth

Shift and mask input samples as necessary to reach internal depth. The input
depth is no longer in x265_param, where it never really belonged since
pic.bitDepth was the only number that mattered.

Add validations for input color space and bit depths. No CLI option was added
for internal bit depth since it is not currently runtime configurable.
Subject: [x265] enforce new color space requirements, improve help

details:   http://hg.videolan.org/x265/rev/76f13355e520
branches:  
changeset: 6160:76f13355e520
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 14 23:14:20 2014 -0600
description:
enforce new color space requirements, improve help
Subject: [x265] uncrustify all source - mechanically apply coding style

details:   http://hg.videolan.org/x265/rev/39ecb3aa82ee
branches:  
changeset: 6161:39ecb3aa82ee
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 14 23:30:49 2014 -0600
description:
uncrustify all source - mechanically apply coding style
Subject: [x265] non-x86 build fixes

details:   http://hg.videolan.org/x265/rev/291b3a358a22
branches:  
changeset: 6162:291b3a358a22
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 15 17:43:58 2014 -0600
description:
non-x86 build fixes

diffstat:

 build/msys/make-x86_64-w64-mingw32-Makefiles.sh     |    8 +
 build/msys/toolchain-x86_64-w64-mingw32.cmake       |    6 +
 source/CMakeLists.txt                               |    2 +-
 source/Lib/TLibCommon/TComDataCU.cpp                |    4 +-
 source/Lib/TLibCommon/TComDataCU.h                  |    1 +
 source/Lib/TLibCommon/TComPattern.h                 |    1 +
 source/Lib/TLibCommon/TComPicSym.cpp                |    1 +
 source/Lib/TLibCommon/TComPicYuv.cpp                |  214 ++++++++-----------
 source/Lib/TLibCommon/TComPrediction.cpp            |   16 +-
 source/Lib/TLibCommon/TComRom.cpp                   |  101 +++++----
 source/Lib/TLibCommon/TComRom.h                     |    2 +-
 source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp  |    4 +-
 source/Lib/TLibCommon/TComSlice.h                   |    7 +-
 source/Lib/TLibCommon/TComTrQuant.cpp               |   73 +++---
 source/Lib/TLibCommon/TComTrQuant.h                 |    2 +-
 source/Lib/TLibCommon/TComYuv.h                     |    3 +
 source/Lib/TLibCommon/TypeDef.h                     |   46 ++--
 source/Lib/TLibEncoder/TEncCfg.h                    |    1 +
 source/Lib/TLibEncoder/TEncEntropy.cpp              |    8 +-
 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp |    1 +
 source/Lib/TLibEncoder/TEncSbac.cpp                 |   11 +-
 source/Lib/TLibEncoder/TEncSearch.cpp               |   24 +-
 source/common/common.cpp                            |   31 +-
 source/common/cpu.cpp                               |   22 +-
 source/common/lowres.cpp                            |    1 +
 source/common/lowres.h                              |    4 +-
 source/common/pixel.cpp                             |    5 +-
 source/common/primitives.cpp                        |   16 +-
 source/common/threading.h                           |    2 +-
 source/common/threadpool.cpp                        |    3 +
 source/common/x86/asm-primitives.cpp                |    6 +-
 source/common/x86/pixel.h                           |    2 +-
 source/encoder/compress.cpp                         |    4 +-
 source/encoder/encoder.cpp                          |   19 +-
 source/encoder/frameencoder.cpp                     |    2 -
 source/encoder/ratecontrol.cpp                      |   20 +-
 source/encoder/slicetype.cpp                        |   17 +-
 source/encoder/weightPrediction.cpp                 |   79 +++---
 source/test/ipfilterharness.cpp                     |    1 +
 source/test/mbdstharness.cpp                        |    2 +
 source/test/pixelharness.cpp                        |   15 +-
 source/x265.cpp                                     |   47 ++-
 source/x265.h                                       |   16 +-
 43 files changed, 458 insertions(+), 392 deletions(-)

diffs (truncated from 2258 to 300 lines):

diff -r 289b4ef4ecee -r 291b3a358a22 build/msys/make-x86_64-w64-mingw32-Makefiles.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/msys/make-x86_64-w64-mingw32-Makefiles.sh	Sat Feb 15 17:43:58 2014 -0600
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# This will generate a cross-compile environment, compiling an x86_64
+# Win64 target from a 32bit MinGW32 host environment.  If your MinGW
+# install is 64bit, you can use the native compiler batch file:
+# make-Makefiles.sh
+
+cmake -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-w64-mingw32.cmake ../../source && cmake-gui ../../source
diff -r 289b4ef4ecee -r 291b3a358a22 build/msys/toolchain-x86_64-w64-mingw32.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/msys/toolchain-x86_64-w64-mingw32.cmake	Sat Feb 15 17:43:58 2014 -0600
@@ -0,0 +1,6 @@
+SET(CMAKE_SYSTEM_NAME Windows)
+SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
+SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
+SET(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)
+SET(CMAKE_ASM_YASM_COMPILER yasm)
diff -r 289b4ef4ecee -r 291b3a358a22 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Sat Feb 15 08:12:30 2014 +0530
+++ b/source/CMakeLists.txt	Sat Feb 15 17:43:58 2014 -0600
@@ -40,7 +40,7 @@ if("${SYSPROC}" STREQUAL "i386"   OR "${
 elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv6l")
     message(STATUS "Detected ARM system processor")
     set(ARM 1)
-    add_definitions(-DX265_ARCH_ARM=1)
+    add_definitions(-DX265_ARCH_ARM=1 -DHAVE_ARMV6=1)
 else()
     message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
     message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}")
diff -r 289b4ef4ecee -r 291b3a358a22 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Sat Feb 15 08:12:30 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Sat Feb 15 17:43:58 2014 -0600
@@ -2494,6 +2494,7 @@ uint32_t TComDataCU::getIntraSizeIdx(uin
 
     UChar width = m_width[absPartIdx] >> shift;
     uint32_t  cnt = 0;
+
     while (width)
     {
         cnt++;
@@ -2869,13 +2870,14 @@ uint32_t TComDataCU::getCoefScanIdx(uint
 {
     uint32_t scanIdx;
     uint32_t dirMode;
+
     if (!bIsIntra)
     {
         return SCAN_DIAG;
     }
     //check that MDCS can be used for this TU
 
-    uint32_t height = width; 
+    uint32_t height = width;
     if (bIsLuma)
     {
         const uint32_t maximumWidth  = MDCS_MAXIMUM_WIDTH;
diff -r 289b4ef4ecee -r 291b3a358a22 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Sat Feb 15 08:12:30 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.h	Sat Feb 15 17:43:58 2014 -0600
@@ -483,6 +483,7 @@ public:
     int           getHorzChromaShift()  { return m_hChromaShift; }
 
     int           getVertChromaShift()  { return m_vChromaShift; }
+
     int           getChromaFormat()     { return m_chromaFormat; }
 };
 
diff -r 289b4ef4ecee -r 291b3a358a22 source/Lib/TLibCommon/TComPattern.h
--- a/source/Lib/TLibCommon/TComPattern.h	Sat Feb 15 08:12:30 2014 +0530
+++ b/source/Lib/TLibCommon/TComPattern.h	Sat Feb 15 17:43:58 2014 -0600
@@ -77,6 +77,7 @@ public:
     /// set chroma parameters from CU data for accessing ADI data
     void  initAdiPatternChroma(TComDataCU* cu, uint32_t zOrderIdxInPart, uint32_t partDepth,
                                Pel* adiBuf, int strideOrig, int heightOrig, int chromaId);
+
 private:
 
     /// padding of unavailable reference samples for intra prediction
diff -r 289b4ef4ecee -r 291b3a358a22 source/Lib/TLibCommon/TComPicSym.cpp
--- a/source/Lib/TLibCommon/TComPicSym.cpp	Sat Feb 15 08:12:30 2014 +0530
+++ b/source/Lib/TLibCommon/TComPicSym.cpp	Sat Feb 15 17:43:58 2014 -0600
@@ -98,6 +98,7 @@ bool TComPicSym::create(int picWidth, in
         if (!m_cuData[i]->create(m_numPartitions, m_maxCUWidth, m_maxCUHeight, m_maxCUWidth >> m_totalDepth, picCsp))
             return false;
     }
+
     return true;
 }
 
diff -r 289b4ef4ecee -r 291b3a358a22 source/Lib/TLibCommon/TComPicYuv.cpp
--- a/source/Lib/TLibCommon/TComPicYuv.cpp	Sat Feb 15 08:12:30 2014 +0530
+++ b/source/Lib/TLibCommon/TComPicYuv.cpp	Sat Feb 15 17:43:58 2014 -0600
@@ -118,6 +118,7 @@ bool TComPicYuv::create(int picWidth, in
             m_buOffsetC[(buRow << maxCUDepth) + buCol] = getCStride() * buRow * ((maxCUHeight >> m_vChromaShift) >> maxCUDepth) + buCol * ((maxCUWidth >> m_hChromaShift) >> maxCUDepth);
         }
     }
+
     return true;
 
 fail:
@@ -146,15 +147,10 @@ uint32_t TComPicYuv::getCUHeight(int row
     return height;
 }
 
-/* Copy pixels from an input picture (C structure) into internal TComPicYuv instance
- * Upscale pixels from 8bits to 16 bits when required, but do not modify
- * pixels. */
+/* Copy pixels from an x265_picture into internal TComPicYuv instance.
+ * Shift pixels as necessary, mask off bits above X265_DEPTH for safety. */
 void TComPicYuv::copyFromPicture(const x265_picture& pic, int32_t *pad)
 {
-    Pel *Y = getLumaAddr();
-    Pel *U = getCbAddr();
-    Pel *V = getCrAddr();
-
     /* m_picWidth is the width that is being encoded, padx indicates how many
      * of those pixels are padding to reach multiple of MinCU(4) size.
      *
@@ -182,27 +178,24 @@ void TComPicYuv::copyFromPicture(const x
      * warnings from valgrind about using uninitialized pixels */
     padx++; pady++;
 
-#if HIGH_BIT_DEPTH
-    if (pic.bitDepth > 8)
+    if (pic.bitDepth < X265_DEPTH)
     {
-        uint16_t *y = (uint16_t*)pic.planes[0];
-        uint16_t *u = (uint16_t*)pic.planes[1];
-        uint16_t *v = (uint16_t*)pic.planes[2];
+        /* 8bit input, 10bit internal depth. Do a simple up-shift of 2 bits */
+        assert(g_bitDepth == 10);
 
-        /* defensive programming, mask off bits that are supposed to be zero */
-        uint16_t mask = (1 << X265_DEPTH) - 1;
+        pixel *Y = getLumaAddr();
+        pixel *U = getCbAddr();
+        pixel *V = getCrAddr();
 
-        // Manually copy pixels to up-size them
+        uint8_t *y = (uint8_t*)pic.planes[0];
+        uint8_t *u = (uint8_t*)pic.planes[1];
+        uint8_t *v = (uint8_t*)pic.planes[2];
+
         for (int r = 0; r < height; r++)
         {
             for (int c = 0; c < width; c++)
             {
-                Y[c] = (pixel)(y[c] & mask);
-            }
-
-            for (int x = 0; x < padx; x++)
-            {
-                Y[width + x] = Y[width - 1];
+                Y[c] = ((pixel)y[c]) << 2;
             }
 
             Y += getStride();
@@ -213,14 +206,8 @@ void TComPicYuv::copyFromPicture(const x
         {
             for (int c = 0; c < width >> m_hChromaShift; c++)
             {
-                U[c] = (pixel)(u[c] & mask);
-                V[c] = (pixel)(v[c] & mask);
-            }
-
-            for (int x = 0; x < padx >> m_hChromaShift; x++)
-            {
-                U[(width >> m_hChromaShift) + x] = U[(width >> m_hChromaShift) - 1];
-                V[(width >> m_hChromaShift) + x] = V[(width >> m_hChromaShift) - 1];
+                U[c] = ((pixel)u[c]) << 2;
+                V[c] = ((pixel)v[c]) << 2;
             }
 
             U += getCStride();
@@ -228,43 +215,22 @@ void TComPicYuv::copyFromPicture(const x
             u += pic.stride[1];
             v += pic.stride[2];
         }
+    }
+    else if (pic.bitDepth == 8)
+    {
+        pixel *Y = getLumaAddr();
+        pixel *U = getCbAddr();
+        pixel *V = getCrAddr();
 
-        /* extend the bottom if height is not multiple of the minimum CU size */
-        if (pady)
-        {
-            Y = getLumaAddr() + (height - 1) * getStride();
-            U = getCbAddr() + ((height >> m_vChromaShift) - 1) * getCStride();
-            V = getCrAddr() + ((height >> m_vChromaShift) - 1) * getCStride();
-
-            for (uint32_t i = 1; i <= pady; i++)
-            {
-                memcpy(Y + i * getStride(), Y, (width + padx) * sizeof(Pel));
-            }
-
-            for (uint32_t j = 1; j <= pady >> m_vChromaShift; j++)
-            {
-                memcpy(U + j * getCStride(), U, ((width + padx) >> m_hChromaShift) * sizeof(Pel));
-                memcpy(V + j * getCStride(), V, ((width + padx) >> m_hChromaShift) * sizeof(Pel));
-            }
-        }
-    }
-    else
-    {
         uint8_t *y = (uint8_t*)pic.planes[0];
         uint8_t *u = (uint8_t*)pic.planes[1];
         uint8_t *v = (uint8_t*)pic.planes[2];
 
-        // Manually copy pixels to up-size them
         for (int r = 0; r < height; r++)
         {
             for (int c = 0; c < width; c++)
             {
-                Y[c] = (Pel)y[c];
-            }
-
-            for (int x = 0; x < padx; x++)
-            {
-                Y[width + x] = Y[width - 1];
+                Y[c] = (pixel)y[c];
             }
 
             Y += getStride();
@@ -275,10 +241,76 @@ void TComPicYuv::copyFromPicture(const x
         {
             for (int c = 0; c < width >> m_hChromaShift; c++)
             {
-                U[c] = (Pel)u[c];
-                V[c] = (Pel)v[c];
+                U[c] = (pixel)u[c];
+                V[c] = (pixel)v[c];
             }
 
+            U += getCStride();
+            V += getCStride();
+            u += pic.stride[1];
+            v += pic.stride[2];
+        }
+    }
+    else /* pic.bitDepth > 8 */
+    {
+        pixel *Y = getLumaAddr();
+        pixel *U = getCbAddr();
+        pixel *V = getCrAddr();
+
+        uint16_t *y = (uint16_t*)pic.planes[0];
+        uint16_t *u = (uint16_t*)pic.planes[1];
+        uint16_t *v = (uint16_t*)pic.planes[2];
+
+        /* defensive programming, mask off bits that are supposed to be zero */
+        uint16_t mask = (1 << X265_DEPTH) - 1;
+        int shift = X265_MAX(0, pic.bitDepth - X265_DEPTH);
+
+        /* shift and mask pixels to final size */
+        for (int r = 0; r < height; r++)
+        {
+            for (int c = 0; c < width; c++)
+            {
+                Y[c] = (pixel)((y[c] >> shift) & mask);
+            }
+
+            Y += getStride();
+            y += pic.stride[0];
+        }
+
+        for (int r = 0; r < height >> m_vChromaShift; r++)
+        {
+            for (int c = 0; c < width >> m_hChromaShift; c++)
+            {
+                U[c] = (pixel)((u[c] >> shift) & mask);
+                V[c] = (pixel)((v[c] >> shift) & mask);
+            }
+
+            U += getCStride();
+            V += getCStride();
+            u += pic.stride[1];
+            v += pic.stride[2];
+        }
+    }
+
+    /* extend the right edge if width was not multiple of the minimum CU size */
+    if (padx)
+    {
+        pixel *Y = getLumaAddr();
+        pixel *U = getCbAddr();
+        pixel *V = getCrAddr();
+
+        for (int r = 0; r < height; r++)
+        {
+            for (int x = 0; x < padx; x++)
+            {
+                Y[width + x] = Y[width - 1];
+            }


More information about the x265-commits mailing list