Overview

Request 4404 (accepted)

- Add patches to support building with libx264 build 155 and
high color bit depth:
* 0001-x264-bump-to-build-155.patch
* 0002-encx264-check-correct-build-number-in-ifdef.patch
* 0003-encx264-fix-apply_h264_profiles-lossless-check-for-high-bit-depth.patch

Submit package home:antlar...:Multimedia / handbrake-1.0.7 to package Multimedia / handbrake-1.0.7

handbrake.changes Changed
x
 
1
@@ -1,4 +1,13 @@
2
 -------------------------------------------------------------------
3
+Sun Feb 17 19:06:36 UTC 2019 - antonio.larrosa@gmail.com
4
+
5
+- Add patches to support building with libx264 build 155 and
6
+  high color bit depth:
7
+  * 0001-x264-bump-to-build-155.patch
8
+  * 0002-encx264-check-correct-build-number-in-ifdef.patch
9
+  * 0003-encx264-fix-apply_h264_profiles-lossless-check-for-high-bit-depth.patch
10
+
11
+-------------------------------------------------------------------
12
 Wed Jun 27 08:27:45 UTC 2018 - enzokiel@kabelmail.de
13
 
14
 - Small changes in spec file.
15
handbrake.spec Changed
21
 
1
@@ -31,6 +31,9 @@
2
 Patch1:         HandBrake-build-shared.patch
3
 Patch2:         HandBrake-build-shared-withbluray.patch
4
 Patch3:         HandBrake-ffmpeg3.patch
5
+Patch4:         0001-x264-bump-to-build-155.patch
6
+Patch5:         0002-encx264-check-correct-build-number-in-ifdef.patch
7
+Patch6:         0003-encx264-fix-apply_h264_profiles-lossless-check-for-high-bit-depth.patch
8
 Source101:      http://download.videolan.org/pub/videolan/libbluray/1.0.2/libbluray-1.0.2.tar.bz2
9
 License:        GPL-2.0+
10
 Group:          Productivity/Multimedia/Video/Editors and Convertors
11
@@ -125,6 +128,9 @@
12
 %else
13
 %endif
14
 %patch3 -p1
15
+%patch4 -p1
16
+%patch5 -p1
17
+%patch6 -p1
18
 
19
 %if %{without bluray}
20
 install -d ./download
21
0001-x264-bump-to-build-155.patch Added
170
 
1
@@ -0,0 +1,168 @@
2
+From bd19e65b00d49aed5cbda35610ee54db4d57d1c3 Mon Sep 17 00:00:00 2001
3
+From: John Stebbins <jstebbins.hb@gmail.com>
4
+Date: Tue, 26 Dec 2017 12:38:21 -0800
5
+Subject: [PATCH] x264: bump to build 155
6
+
7
+Requires NASM to build
8
+Unified 8 and 10 bit library support
9
+AVX-512 optimizations
10
+Various other bug fixes and improvements
11
+---
12
+ contrib/x264/A00-version-string.patch |  8 ++---
13
+ contrib/x264/module.defs              |  7 ++--
14
+ libhb/encx264.c                       | 48 +++++++++++++++++++++++++--
15
+ 3 files changed, 52 insertions(+), 11 deletions(-)
16
+
17
+diff --git a/contrib/x264/A00-version-string.patch b/contrib/x264/A00-version-string.patch
18
+index 8e46d601c..2f7c9f96c 100644
19
+--- a/contrib/x264/A00-version-string.patch
20
++++ b/contrib/x264/A00-version-string.patch
21
+@@ -6,7 +6,7 @@ index 2b59b92..86b7198 100644
22
+  
23
+  #include "x264_config.h"
24
+  
25
+--#define X264_BUILD 148
26
++-#define X264_BUILD 155
27
+ +/*
28
+ + * Define the full version explicitly so that it survives a git --archive.
29
+ + *
30
+@@ -22,9 +22,9 @@ index 2b59b92..86b7198 100644
31
+ +#ifdef  X264_POINTVER
32
+ +#undef  X264_POINTVER
33
+ +#endif
34
+-+#define X264_BUILD    148
35
+-+#define X264_VERSION  " r2708 86b7198"
36
+-+#define X264_POINTVER "0.148.2708 86b7198"
37
+++#define X264_BUILD    155
38
+++#define X264_VERSION " r2893 b00bcaf"
39
+++#define X264_POINTVER "0.155.2893 b00bcaf"
40
+  
41
+  /* Application developers planning to link against a shared library version of
42
+   * libx264 from a Microsoft Visual Studio or similar development environment
43
+diff --git a/contrib/x264/module.defs b/contrib/x264/module.defs
44
+index 17b1e58ec..ee71e70f1 100644
45
+--- a/contrib/x264/module.defs
46
++++ b/contrib/x264/module.defs
47
+@@ -1,16 +1,15 @@
48
+ $(eval $(call import.MODULE.defs,X264,x264,YASM PTHREADW32))
49
+ $(eval $(call import.CONTRIB.defs,X264))
50
+ 
51
+-X264.FETCH.url     = https://download.handbrake.fr/handbrake/contrib/x264-snapshot-20160920-2245-stable.tar.bz2
52
+-X264.FETCH.url    += https://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20160920-2245-stable.tar.bz2
53
+-X264.FETCH.sha256  = 6ba2d848eabbca0d9d2c2a12b263e02f856a81fce87fbc74df52a1097c88e39c
54
++X264.FETCH.url     = https://download.handbrake.fr/handbrake/contrib/x264-snapshot-20171225-2245.tar.bz2
55
++X264.FETCH.url    += https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20171225-2245.tar.bz2
56
++X264.FETCH.sha256  = ea39f32ccb3bd3aeaccd663c8d210117be5d9cfbe89e1a8b5f631e0f7ed74954
57
+ 
58
+ X264.GCC.args.c_std =
59
+ 
60
+ X264.CONFIGURE.deps   =
61
+ X264.CONFIGURE.shared =
62
+ 
63
+-X264.CONFIGURE.extra  = --bit-depth=8 --chroma-format=420
64
+ X264.CONFIGURE.extra += --disable-lavf --disable-ffms --disable-avs --disable-swscale --disable-gpac --disable-lsmash --disable-cli
65
+ 
66
+ ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
67
+diff --git a/libhb/encx264.c b/libhb/encx264.c
68
+index 4e9d12689..593111fb0 100644
69
+--- a/libhb/encx264.c
70
++++ b/libhb/encx264.c
71
+@@ -151,7 +151,11 @@ static void * x264_lib_open_ubuntu_10bit(void)
72
+ 
73
+ void hb_x264_global_init(void)
74
+ {
75
++#if X264_BUILD < 155
76
+     x264_apis[0].bit_depth                 = x264_bit_depth;
77
++#else
78
++    x264_apis[0].bit_depth                 = X264_BIT_DEPTH;
79
++#endif
80
+     x264_apis[0].param_default             = x264_param_default;
81
+     x264_apis[0].param_default_preset      = x264_param_default_preset;
82
+     x264_apis[0].param_apply_profile       = x264_param_apply_profile;
83
+@@ -164,13 +168,32 @@ void hb_x264_global_init(void)
84
+     x264_apis[0].encoder_close             = x264_encoder_close;
85
+     x264_apis[0].picture_init              = x264_picture_init;
86
+ 
87
++    if (x264_apis[0].bit_depth == 0)
88
++    {
89
++        // libx264 supports 8 and 10 bit
90
++        x264_apis[0].bit_depth                 = 8;
91
++        x264_apis[1].bit_depth                 = 10;
92
++        x264_apis[1].param_default             = x264_param_default;
93
++        x264_apis[1].param_default_preset      = x264_param_default_preset;
94
++        x264_apis[1].param_apply_profile       = x264_param_apply_profile;
95
++        x264_apis[1].param_apply_fastfirstpass = x264_param_apply_fastfirstpass;
96
++        x264_apis[1].param_parse               = x264_param_parse;
97
++        x264_apis[1].encoder_open              = x264_encoder_open;
98
++        x264_apis[1].encoder_headers           = x264_encoder_headers;
99
++        x264_apis[1].encoder_encode            = x264_encoder_encode;
100
++        x264_apis[1].encoder_delayed_frames    = x264_encoder_delayed_frames;
101
++        x264_apis[1].encoder_close             = x264_encoder_close;
102
++        x264_apis[1].picture_init              = x264_picture_init;
103
++        return;
104
++    }
105
++
106
+     // Invalidate other apis
107
+     x264_apis[1].bit_depth = -1;
108
+ 
109
+     // Attempt to dlopen a library for handling the bit-depth that we do
110
+     // not already have.
111
+     void *h;
112
+-    if (x264_bit_depth == 8)
113
++    if (x264_apis[0].bit_depth == 8)
114
+     {
115
+         h = x264_lib_open(libx264_10bit_names);
116
+ #if defined(SYS_LINUX)
117
+@@ -190,8 +213,23 @@ void hb_x264_global_init(void)
118
+     }
119
+ 
120
+     int ii;
121
++    int dll_bitdepth = 0;
122
++#if X264_BUILD < 155
123
+     int *pbit_depth                   = (int*)hb_dlsym(h, "x264_bit_depth");
124
++    if (pbit_depth != NULL)
125
++    {
126
++        dll_bitdepth = *pbit_depth;
127
++    }
128
++#endif
129
+     x264_apis[1].param_default        = hb_dlsym(h, "x264_param_default");
130
++#if X264_BUILD >= 155
131
++    if (x264_apis[1].param_default != NULL)
132
++    {
133
++        x264_param_t defaults;
134
++        x264_apis[1].param_default(&defaults);
135
++        dll_bitdepth = defaults.i_bitdepth;
136
++    }
137
++#endif
138
+     x264_apis[1].param_default_preset = hb_dlsym(h, "x264_param_default_preset");
139
+     x264_apis[1].param_apply_profile  = hb_dlsym(h, "x264_param_apply_profile");
140
+     x264_apis[1].param_apply_fastfirstpass =
141
+@@ -215,7 +253,7 @@ void hb_x264_global_init(void)
142
+     x264_apis[1].encoder_close        = hb_dlsym(h, "x264_encoder_close");
143
+     x264_apis[1].picture_init         = hb_dlsym(h, "x264_picture_init");
144
+ 
145
+-    if (pbit_depth                             != NULL &&
146
++    if (dll_bitdepth > 0 && dll_bitdepth != x264_apis[0].bit_depth &&
147
+         x264_apis[1].param_default             != NULL &&
148
+         x264_apis[1].param_default_preset      != NULL &&
149
+         x264_apis[1].param_apply_profile       != NULL &&
150
+@@ -228,7 +266,7 @@ void hb_x264_global_init(void)
151
+         x264_apis[1].encoder_close             != NULL &&
152
+         x264_apis[1].picture_init              != NULL)
153
+     {
154
+-        x264_apis[1].bit_depth = *pbit_depth;
155
++        x264_apis[1].bit_depth = dll_bitdepth;
156
+     }
157
+ }
158
+ 
159
+@@ -321,6 +359,10 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
160
+         return 1;
161
+     }
162
+ 
163
++#if X264_BUILD >= 155
164
++    param.i_bitdepth = bit_depth;
165
++#endif
166
++
167
+     /* If the PSNR or SSIM tunes are in use, enable the relevant metric */
168
+     if (job->encoder_tune != NULL && *job->encoder_tune)
169
+     {
170
0002-encx264-check-correct-build-number-in-ifdef.patch Added
52
 
1
@@ -0,0 +1,50 @@
2
+From 94f4c41daa72a6479b1d6e66d322d61be41b427f Mon Sep 17 00:00:00 2001
3
+From: John Stebbins <jstebbins.hb@gmail.com>
4
+Date: Sun, 31 Dec 2017 08:42:26 -0800
5
+Subject: [PATCH] encx264: check correct build number in ifdef
6
+
7
+The multi-lib change actually happend in build 153
8
+---
9
+ libhb/encx264.c | 8 ++++----
10
+ 1 file changed, 4 insertions(+), 4 deletions(-)
11
+
12
+diff --git a/libhb/encx264.c b/libhb/encx264.c
13
+index 593111fb0..04ac22824 100644
14
+--- a/libhb/encx264.c
15
++++ b/libhb/encx264.c
16
+@@ -151,7 +151,7 @@ static void * x264_lib_open_ubuntu_10bit(void)
17
+ 
18
+ void hb_x264_global_init(void)
19
+ {
20
+-#if X264_BUILD < 155
21
++#if X264_BUILD < 153
22
+     x264_apis[0].bit_depth                 = x264_bit_depth;
23
+ #else
24
+     x264_apis[0].bit_depth                 = X264_BIT_DEPTH;
25
+@@ -214,7 +214,7 @@ void hb_x264_global_init(void)
26
+ 
27
+     int ii;
28
+     int dll_bitdepth = 0;
29
+-#if X264_BUILD < 155
30
++#if X264_BUILD < 153
31
+     int *pbit_depth                   = (int*)hb_dlsym(h, "x264_bit_depth");
32
+     if (pbit_depth != NULL)
33
+     {
34
+@@ -222,7 +222,7 @@ void hb_x264_global_init(void)
35
+     }
36
+ #endif
37
+     x264_apis[1].param_default        = hb_dlsym(h, "x264_param_default");
38
+-#if X264_BUILD >= 155
39
++#if X264_BUILD >= 153
40
+     if (x264_apis[1].param_default != NULL)
41
+     {
42
+         x264_param_t defaults;
43
+@@ -359,7 +359,7 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
44
+         return 1;
45
+     }
46
+ 
47
+-#if X264_BUILD >= 155
48
++#if X264_BUILD >= 153
49
+     param.i_bitdepth = bit_depth;
50
+ #endif
51
+ 
52
0003-encx264-fix-apply_h264_profiles-lossless-check-for-high-bit-depth.patch Added
44
 
1
@@ -0,0 +1,42 @@
2
+From fbc98da08ae1d455d8c672c312c817336338c224 Mon Sep 17 00:00:00 2001
3
+From: Tim Walker <tdskywalker@gmail.com>
4
+Date: Sun, 18 Feb 2018 06:04:20 +0100
5
+Subject: [PATCH] encx264: fix apply_h264_profile's lossless check for high bit
6
+ depth.
7
+
8
+---
9
+ libhb/encx264.c | 16 ++++++++++++----
10
+ 1 file changed, 12 insertions(+), 4 deletions(-)
11
+
12
+diff --git a/libhb/encx264.c b/libhb/encx264.c
13
+index 4adab5cc0..984d52be9 100644
14
+--- a/libhb/encx264.c
15
++++ b/libhb/encx264.c
16
+@@ -976,15 +976,23 @@ static int apply_h264_profile(const x264_api_t *api, x264_param_t *param,
17
+         /*
18
+          * lossless requires High 4:4:4 Predictive profile
19
+          */
20
+-        if (param->rc.f_rf_constant < 1.0 &&
21
+-            param->rc.i_rc_method == X264_RC_CRF &&
22
+-            strcasecmp(h264_profile, "high444") != 0)
23
++        int qp_bd_offset = 6 * (api->bit_depth - 8);
24
++        if (strcasecmp(h264_profile, "high444") != 0 &&
25
++            ((param->rc.i_rc_method == X264_RC_CQP && param->rc.i_qp_constant <= 0) ||
26
++             (param->rc.i_rc_method == X264_RC_CRF && (int)(param->rc.f_rf_constant + qp_bd_offset) <= 0)))
27
+         {
28
+             if (verbose)
29
+             {
30
+                 hb_log("apply_h264_profile [warning]: lossless requires high444 profile, disabling");
31
+             }
32
+-            param->rc.f_rf_constant = 1.0;
33
++            if (param->rc.i_rc_method == X264_RC_CQP)
34
++            {
35
++                param->rc.i_qp_constant = 1;
36
++            }
37
++            else
38
++            {
39
++                param->rc.f_rf_constant = 1 - qp_bd_offset;
40
++            }
41
+         }
42
+         return api->param_apply_profile(param, h264_profile);
43
+     }
44
Refresh
Refresh
Request History
antlarr's avatar

antlarr created request about 6 years ago

- Add patches to support building with libx264 build 155 and
high color bit depth:
* 0001-x264-bump-to-build-155.patch
* 0002-encx264-check-correct-build-number-in-ifdef.patch
* 0003-encx264-fix-apply_h264_profiles-lossless-check-for-high-bit-depth.patch


Olaf Hering's avatar

olh accepted request about 6 years ago