From de17b2d007026cac6bc1aa7821126094e3c5e142 Mon Sep 17 00:00:00 2001
From: Rodeo <tdskywalker@gmail.com>
Date: Fri, 3 Apr 2015 14:19:28 +0000
Subject: [PATCH] Bump libx265 to version 1.6

Miscellaneous bugfixes and performance improvements.

Also, x265_cleanup lets us drop both patches.


git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7044 b64f7644-9d1e-0410-96f1-a4d463321fa5
---
 contrib/x265/A00-maxCUSize-idiocy.patch | 19 -------------------
 contrib/x265/A01-cudata-init.patch      | 12 ------------
 contrib/x265/module.defs                |  2 +-
 libhb/encx265.c                         |  3 +++
 4 files changed, 4 insertions(+), 32 deletions(-)
 delete mode 100644 contrib/x265/A00-maxCUSize-idiocy.patch
 delete mode 100644 contrib/x265/A01-cudata-init.patch

diff --git a/contrib/x265/A00-maxCUSize-idiocy.patch b/contrib/x265/A00-maxCUSize-idiocy.patch
deleted file mode 100644
index a5f718101..000000000
--- a/contrib/x265/A00-maxCUSize-idiocy.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff -r 32d72a0285e0 source/common/param.cpp
---- a/source/common/param.cpp	Tue Feb 10 21:38:22 2015 -0600
-+++ b/source/common/param.cpp	Thu Feb 12 09:12:01 2015 -0700
-@@ -1151,6 +1151,7 @@
- 
- int x265_set_globals(x265_param *param)
- {
-+#if 0
-     static int once /* = 0 */;
- 
-     if (ATOMIC_INC(&once) > 1)
-@@ -1162,6 +1163,7 @@
-         }
-     }
-     else
-+#endif
-     {
-         uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->maxCUSize];
- 
diff --git a/contrib/x265/A01-cudata-init.patch b/contrib/x265/A01-cudata-init.patch
deleted file mode 100644
index 0623dca10..000000000
--- a/contrib/x265/A01-cudata-init.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -r 018e8bbaa854 source/common/cudata.cpp
---- a/source/common/cudata.cpp	Fri Feb 27 11:46:09 2015 +0530
-+++ b/source/common/cudata.cpp	Sun Mar 01 09:24:49 2015 -0800
-@@ -161,7 +161,7 @@
-     m_vChromaShift  = CHROMA_V_SHIFT(csp);
-     m_numPartitions = NUM_4x4_PARTITIONS >> (depth * 2);
- 
--    if (!s_partSet[0])
-+    //if (!s_partSet[0])
-     {
-         s_numPartInCUSize = 1 << g_unitSizeDepth;
-         switch (g_maxLog2CUSize)
diff --git a/contrib/x265/module.defs b/contrib/x265/module.defs
index e01b0014a..177333b84 100644
--- a/contrib/x265/module.defs
+++ b/contrib/x265/module.defs
@@ -2,7 +2,7 @@ __deps__ := YASM CMAKE
 $(eval $(call import.MODULE.defs,X265,x265,$(__deps__)))
 $(eval $(call import.CONTRIB.defs,X265))
 
-X265.FETCH.url = http://download.handbrake.fr/contrib/x265-9329-0d30d2641875-1.5.tar.bz2
+X265.FETCH.url = http://download.handbrake.fr/contrib/x265-9964-cbeb7d8a4880-1.6.tar.bz2
 
 X265.CONFIGURE.exe         = cmake
 X265.CONFIGURE.args.prefix = -DCMAKE_INSTALL_PREFIX="$(X265.CONFIGURE.prefix)"
diff --git a/libhb/encx265.c b/libhb/encx265.c
index 8743b8d20..b09b0b4d2 100644
--- a/libhb/encx265.c
+++ b/libhb/encx265.c
@@ -291,6 +291,9 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job)
     job->areBframes = (param->bframes > 0) + (param->bframes   > 0 &&
                                               param->bBPyramid > 0);
 
+    /* Reset global variables before opening a new encoder */
+    x265_cleanup();
+
     pv->x265 = x265_encoder_open(param);
     if (pv->x265 == NULL)
     {
-- 
2.40.0