commit:     2a16187c2c99bd6900494d5e8c7d3dd9ccb67672
Author:     Ian Whyman <thev00d00 <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 10 17:34:32 2019 +0000
Commit:     Ian Whyman <thev00d00 <AT> gentoo <DOT> org>
CommitDate: Sun Mar 10 17:34:56 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2a16187c

media-video/handbrake: Fix nvenc build failure

Backport patch from upstream to allow enable/disable nvenc, qsv encoding

Closes: https://bugs.gentoo.org/679840
Package-Manager: Portage-2.3.62, Repoman-2.3.12
Signed-off-by: Ian Whyman <thev00d00 <AT> gentoo.org>

 ...ndbrake-1.2.2-backport-hardware-configure.patch | 88 ++++++++++++++++++++++
 ...rake-1.2.2.ebuild => handbrake-1.2.2-r1.ebuild} |  8 +-
 media-video/handbrake/metadata.xml                 |  1 +
 3 files changed, 96 insertions(+), 1 deletion(-)

diff --git 
a/media-video/handbrake/files/handbrake-1.2.2-backport-hardware-configure.patch 
b/media-video/handbrake/files/handbrake-1.2.2-backport-hardware-configure.patch
new file mode 100644
index 00000000000..0618c9004e9
--- /dev/null
+++ 
b/media-video/handbrake/files/handbrake-1.2.2-backport-hardware-configure.patch
@@ -0,0 +1,88 @@
+From c7119499f5a2da7e5be0afd50a6757778fed53e7 Mon Sep 17 00:00:00 2001
+From: Bradley Sepos <brad...@bradleysepos.com>
+Date: Sat, 23 Feb 2019 11:44:34 -0500
+Subject: [PATCH] configure: Enable hardware encoders by default on suitable
+ platforms.
+
+Print special encoders status at end of configure output, minor cosmetics.
+---
+ make/configure.py | 46 +++++++++++++++++++++++++++++-----------------
+ 1 file changed, 29 insertions(+), 17 deletions(-)
+
+diff --git a/make/configure.py b/make/configure.py
+index c8bc712fe5..e673c9c5a0 100644
+--- a/make/configure.py
++++ b/make/configure.py
+@@ -1298,36 +1298,37 @@ def createCLI():
+     grp.add_option( '--disable-gtk', default=False, action='store_true', 
help=h )
+ 
+     h = IfHost( 'disable GTK GUI update checks', '*-*-linux*', 
'*-*-freebsd*', none=optparse.SUPPRESS_HELP ).value
+-
+     grp.add_option( '--disable-gtk-update-checks', default=False, 
action='store_true', help=h )
+ 
+     h = IfHost( 'enable GTK GUI (mingw)', '*-*-mingw*', 
none=optparse.SUPPRESS_HELP ).value
+     grp.add_option( '--enable-gtk-mingw', default=False, action='store_true', 
help=h )
+ 
+     h = IfHost( 'disable GStreamer (live preview)', '*-*-linux*', 
'*-*-freebsd*', none=optparse.SUPPRESS_HELP ).value
+-
+     grp.add_option( '--disable-gst', default=False, action='store_true', 
help=h )
+ 
+-    h = IfHost( 'enable Intel Quick Sync Video (QSV) hardware acceleration. 
(Windows and Linux only)', '*-*-linux*', '*-*-mingw*', 
none=optparse.SUPPRESS_HELP ).value
+-    grp.add_option( '--enable-qsv', default=False, action='store_true', 
help=h )
++    h = IfHost( 'Intel Quick Sync Video (QSV) hardware acceleration (Windows 
and Linux only)', '*-*-linux*', '*-*-mingw*', none=optparse.SUPPRESS_HELP 
).value
++    grp.add_option( '--enable-qsv', dest="enable_qsv", default=host.match( 
'*-*-mingw*' ), action='store_true', help=(( 'enable %s' %h ) if h != 
optparse.SUPPRESS_HELP else h) )
++    grp.add_option( '--disable-qsv', dest="enable_qsv", action='store_false', 
help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) )
+ 
+-    h = IfHost( 'enable AMD VCE hardware acceleration. (Windows only)', 
'*-*-mingw*', none=optparse.SUPPRESS_HELP ).value
+-    grp.add_option( '--enable-vce', default=False, action='store_true', 
help=h )
++    h = IfHost( 'AMD VCE hardware acceleration (Windows only)', '*-*-mingw*', 
none=optparse.SUPPRESS_HELP ).value
++    grp.add_option( '--enable-vce', dest="enable_vce", default=host.match( 
'*-*-mingw*' ), action='store_true', help=(( 'enable %s' %h ) if h != 
optparse.SUPPRESS_HELP else h) )
++    grp.add_option( '--disable-vce', dest="enable_vce", action='store_false', 
help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) )
+ 
+-    h = IfHost( 'enable x265 video encoder', '*-*-*', 
none=optparse.SUPPRESS_HELP ).value
+-    grp.add_option( '--enable-x265', dest="enable_x265", default=True, 
action='store_true', help=h )
+-    grp.add_option( '--disable-x265', dest="enable_x265", 
action='store_false' )
++    h = IfHost( 'x265 video encoder', '*-*-*', none=optparse.SUPPRESS_HELP 
).value
++    grp.add_option( '--enable-x265', dest="enable_x265", default=True, 
action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
++    grp.add_option( '--disable-x265', dest="enable_x265", 
action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
+ 
+-    h = IfHost( 'enable FDK AAC audio encoder', '*-*-*', 
none=optparse.SUPPRESS_HELP ).value
+-    grp.add_option( '--enable-fdk-aac', dest="enable_fdk_aac", default=False, 
action='store_true', help=h )
+-    grp.add_option( '--disable-fdk-aac', dest="enable_fdk_aac", 
action='store_false' )
++    h = IfHost( 'FDK AAC audio encoder', '*-*-*', none=optparse.SUPPRESS_HELP 
).value
++    grp.add_option( '--enable-fdk-aac', dest="enable_fdk_aac", default=False, 
action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
++    grp.add_option( '--disable-fdk-aac', dest="enable_fdk_aac", 
action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
+ 
+-    h = IfHost( 'enable FFmpeg AAC audio encoder', '*-*-*', 
none=optparse.SUPPRESS_HELP ).value
+-    grp.add_option( '--enable-ffmpeg-aac', dest="enable_ffmpeg_aac", 
default=not host.match( '*-*-darwin*' ), action='store_true', help=h )
+-    grp.add_option( '--disable-ffmpeg-aac', dest="enable_ffmpeg_aac", 
action='store_false' )
++    h = IfHost( 'FFmpeg AAC audio encoder', '*-*-*', 
none=optparse.SUPPRESS_HELP ).value
++    grp.add_option( '--enable-ffmpeg-aac', dest="enable_ffmpeg_aac", 
default=not host.match( '*-*-darwin*' ), action='store_true', help=(( 'enable 
%s' %h ) if h != optparse.SUPPRESS_HELP else h) )
++    grp.add_option( '--disable-ffmpeg-aac', dest="enable_ffmpeg_aac", 
action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
+ 
+-    h = IfHost( 'enable Nvidia NVEnc video encoder', '*-*-*', 
none=optparse.SUPPRESS_HELP ).value
+-    grp.add_option( '--enable-nvenc', dest="enable_nvenc", default=not 
(host.match( '*-*-darwin*' ) or host.match( '*-*-freebsd*' )), 
action='store_true', help=h )
++    h = IfHost( 'Nvidia NVEnc video encoder', '*-*-*', 
none=optparse.SUPPRESS_HELP ).value
++    grp.add_option( '--enable-nvenc', dest="enable_nvenc", default=not 
(host.match( '*-*-darwin*' ) or host.match( '*-*-freebsd*' )), 
action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
++    grp.add_option( '--disable-nvenc', dest="enable_nvenc", 
action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP 
else h) )
+ 
+ 
+     cli.add_option_group( grp )
+@@ -1982,6 +1983,17 @@ class Tools:
+     else:
+         nocd = False
+ 
++    stdout.write( '%s\n' % ('-' * 79) )
++    stdout.write( 'Configured options:\n' )
++    stdout.write( 'Enable FDK-AAC:    %s\n' % options.enable_fdk_aac )
++    stdout.write( 'Enable FFmpeg AAC: %s\n' % options.enable_ffmpeg_aac )
++
++    if IfHost( True, '*-*-linux*', '*-*-mingw*', none=False ).value is True:
++        stdout.write( 'Enable NVEnc:      %s\n' % options.enable_nvenc )
++        stdout.write( 'Enable QSV:        %s\n' % options.enable_qsv )
++    if IfHost( True, '*-*-mingw*', none=False ).value is True:
++        stdout.write( 'Enable VCE:        %s\n' % options.enable_vce )
++
+     stdout.write( '%s\n' % ('-' * 79) )
+     if options.launch:
+         stdout.write( 'Build is finished!\n' )

diff --git a/media-video/handbrake/handbrake-1.2.2.ebuild 
b/media-video/handbrake/handbrake-1.2.2-r1.ebuild
similarity index 93%
rename from media-video/handbrake/handbrake-1.2.2.ebuild
rename to media-video/handbrake/handbrake-1.2.2-r1.ebuild
index b4c350e8909..4d4a09eb378 100644
--- a/media-video/handbrake/handbrake-1.2.2.ebuild
+++ b/media-video/handbrake/handbrake-1.2.2-r1.ebuild
@@ -23,7 +23,7 @@ HOMEPAGE="http://handbrake.fr/";
 LICENSE="GPL-2"
 
 SLOT="0"
-IUSE="+fdk gstreamer gtk libav libav-aac x265"
+IUSE="+fdk gstreamer gtk libav libav-aac nvenc x265 vaapi"
 
 REQUIRED_USE="^^ ( fdk libav-aac )"
 
@@ -40,6 +40,7 @@ RDEPEND="
        media-libs/libtheora
        media-libs/libvorbis
        media-libs/libvpx
+       nvenc? ( media-libs/nv-codec-headers )
        media-libs/opus
        media-libs/x264:=
        media-sound/lame
@@ -86,6 +87,9 @@ PATCHES=(
 
        # Fix missing x265 link flag
        "${FILESDIR}/${PN}-9999-fix-missing-x265-link-flag.patch"
+
+       # Allow disabling nvenc etc
+       "${FILESDIR}/${P}-backport-hardware-configure.patch"
 )
 
 pkg_setup() {
@@ -119,6 +123,8 @@ src_configure() {
                $(use_enable fdk fdk-aac) \
                $(use_enable gtk) \
                $(usex !gstreamer --disable-gst) \
+               $(use_enable nvenc) \
+               $(use_enable vaapi qsv) \
                $(use_enable x265) || die "Configure failed."
 }
 

diff --git a/media-video/handbrake/metadata.xml 
b/media-video/handbrake/metadata.xml
index 6f7dc3b848e..0bab35dd0f0 100644
--- a/media-video/handbrake/metadata.xml
+++ b/media-video/handbrake/metadata.xml
@@ -13,6 +13,7 @@
                <flag name="gtk">Install the GTK UI, ghb.</flag>
                <flag name="fdk">Support for encoding AAC using 
<pkg>media-libs/fdk-aac</pkg>.</flag>
                <flag name="libav-aac">Support for encoding AAC using 
<pkg>media-video/libav</pkg>'s internal encoder.</flag>
+               <flag name="nvenc">Adds support for NVIDIA Encoder (NVENC) API 
for hardware accelerated encoding on NVIDIA cards.</flag>
                <flag name="x265">Support for encoding h265 using 
<pkg>media-libs/x265</pkg>.</flag>
        </use>
 </pkgmetadata>

Reply via email to