diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-11-12 23:58:02 +0100 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-11-13 17:14:32 +0100 |
commit | 167054b05684dc6423bc025e4f8ef657956d56fa (patch) | |
tree | 79eac044d5bd40d98615f39be7381e0b870714f6 | |
parent | e77ff396b67564f497ee1868d5cddfc1eeeffd2e (diff) | |
download | abslibre-167054b05684dc6423bc025e4f8ef657956d56fa.tar.gz abslibre-167054b05684dc6423bc025e4f8ef657956d56fa.tar.bz2 abslibre-167054b05684dc6423bc025e4f8ef657956d56fa.zip |
libre: handbrake: update to 1.3.0
The current handbrake 1.1.2 package stopped working:
$ ghb
ghb: error while loading shared libraries: libdvdread.so.4: cannot open
shared object file: No such file or directory
As handbrake 1.1.2 failed with compilation issue it could not be
fixed by rebuilding it.
Handbrake 1.2.2 and 1.3.0 also had build issues and it seemed easier
to fix 1.3.0's issues.
While the patches are not good enough quality to be upstreamed, it's
still a good start as they could be cleaned up or rewriten and
submited later.
Ideally the patches should enable the autodetection of libbluray
and libx264 like it is done for various libraries in libhb/module.defs:
ifneq ($(HAS.iconv),1)
LIBHB.dll.libs += $(CONTRIB.build/)lib/libiconv.a
else
LIBHB.GCC.l += iconv
endif
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | libre/handbrake/0001-Fix-linking-issue-when-disabling-internal-libbluray.patch | 31 | ||||
-rw-r--r-- | libre/handbrake/0002-Fix-linking-issue-when-disabling-internal-x265.patch | 43 | ||||
-rw-r--r-- | libre/handbrake/PKGBUILD | 64 | ||||
-rw-r--r-- | libre/handbrake/handbrake-no-download.patch | 15 | ||||
-rw-r--r-- | libre/handbrake/handbrake-supress-clip_id.patch | 38 | ||||
-rw-r--r-- | libre/handbrake/switch-libav-to-ffmpeg.patch | 792 |
6 files changed, 112 insertions, 871 deletions
diff --git a/libre/handbrake/0001-Fix-linking-issue-when-disabling-internal-libbluray.patch b/libre/handbrake/0001-Fix-linking-issue-when-disabling-internal-libbluray.patch new file mode 100644 index 000000000..09333b96f --- /dev/null +++ b/libre/handbrake/0001-Fix-linking-issue-when-disabling-internal-libbluray.patch @@ -0,0 +1,31 @@ +From 27812b1245d525604e9e3da09ae45134595146b9 Mon Sep 17 00:00:00 2001 +From: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +Date: Wed, 13 Nov 2019 16:07:39 +0100 +Subject: [PATCH 1/2] Fix linking issue when disabling internal libbluray + +Without that fix we have: + /usr/bin/ld: /home/gnutoo/work/projects/parabola/handbrake/build//libhb/libhandbrake.a(ports.o): + undefined reference to symbol 'dlclose@@GLIBC_2.2.5' + /usr/bin/ld: /usr/lib/libdl.so.2: error adding symbols: DSO missing from + command line + +Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +--- + gtk/configure.ac | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gtk/configure.ac b/gtk/configure.ac +index 92aabcbe8..82e8d88ce 100644 +--- a/gtk/configure.ac ++++ b/gtk/configure.ac +@@ -232,6 +232,7 @@ case $host in + HB_LIBS="$HB_LIBS -pthread" + ;; + *-*-linux*) ++ HB_LIBS="$HB_LIBS -ldl -lpthread" + if test "x$use_qsv" = "xyes" ; then + HB_LIBS="$HB_LIBS -lva -lva-drm" + fi +-- +2.24.0 + diff --git a/libre/handbrake/0002-Fix-linking-issue-when-disabling-internal-x265.patch b/libre/handbrake/0002-Fix-linking-issue-when-disabling-internal-x265.patch new file mode 100644 index 000000000..96d2442a7 --- /dev/null +++ b/libre/handbrake/0002-Fix-linking-issue-when-disabling-internal-x265.patch @@ -0,0 +1,43 @@ +From 8712791f459d5b8e36ae6f407c6f45e661a2311d Mon Sep 17 00:00:00 2001 +From: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +Date: Wed, 13 Nov 2019 16:07:39 +0100 +Subject: [PATCH 2/2] Fix linking issue when disabling internal x265 + +Without that fix we have: + /usr/bin/ld: ./libhb/libhandbrake.a(common.o): undefined reference to symbol 'x265_api_query' + /usr/bin/ld: /usr/lib/libx265.so.179: error adding symbols: DSO missing from command line + +Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +--- + gtk/configure.ac | 1 + + test/module.defs | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gtk/configure.ac b/gtk/configure.ac +index 82e8d88ce..034ccdcdb 100644 +--- a/gtk/configure.ac ++++ b/gtk/configure.ac +@@ -237,6 +237,7 @@ case $host in + HB_LIBS="$HB_LIBS -lva -lva-drm" + fi + if test "x$use_x265" = "xyes" ; then ++ HB_LIBS="$HB_LIBS -lx265" + if test "x$use_numa" = "xyes" ; then + HB_LIBS="$HB_LIBS -lnuma" + fi +diff --git a/test/module.defs b/test/module.defs +index ffc00a8b2..1895d16ee 100644 +--- a/test/module.defs ++++ b/test/module.defs +@@ -16,7 +16,7 @@ TEST.libs = $(LIBHB.a) + TEST.GCC.l = \ + ass avformat avfilter avcodec avutil swresample postproc mp3lame dvdnav \ + dvdread fribidi \ +- swscale vpx theoraenc theoradec vorbis vorbisenc ogg x264 \ ++ swscale vpx theoraenc theoradec vorbis vorbisenc ogg x264 x265 \ + bluray freetype xml2 bz2 z jansson harfbuzz opus speex lzma dav1d + + ifeq (,$(filter $(HOST.system),darwin cygwin mingw)) +-- +2.24.0 + diff --git a/libre/handbrake/PKGBUILD b/libre/handbrake/PKGBUILD index bb291b6e7..6a868070a 100644 --- a/libre/handbrake/PKGBUILD +++ b/libre/handbrake/PKGBUILD @@ -2,48 +2,57 @@ # Contributor (Arch): Giovanni Scafora <giovanni@archlinux.org> # Contributor (Arch): Sebastien Piccand <sebcactus gmail com> # Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe> +# Contributor: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> pkgname=('handbrake' 'handbrake-cli') -pkgver=1.1.2 +pkgver=1.3.0 pkgrel=1 -pkgrel+=.par3 +pkgrel+=.par1 arch=('x86_64') arch+=('i686' 'armv7h') url="https://handbrake.fr/" license=('GPL') -makedepends=('intltool' 'python2' 'yasm' 'wget' 'cmake' 'bzip2' 'gcc-libs' +makedepends=('intltool' 'python2' 'nasm' 'wget' 'cmake' 'bzip2' 'gcc-libs' 'xz' 'zlib' 'libnotify' 'gst-plugins-base' 'gtk3' 'dbus-glib' 'libass' 'lame' 'libxml2' 'opus' 'libvorbis' 'libtheora' 'libsamplerate' - 'x264' 'jansson' 'librsvg' 'libgudev') + 'speex' 'x264' 'jansson' 'librsvg' 'libgudev') +makedepends+=('dav1d' 'libbluray' 'numactl' 'meson' 'x265') makedepends+=('ffmpeg' 'libdvdnav') source=(https://download.handbrake.fr/releases/$pkgver/HandBrake-$pkgver-source.tar.bz2 https://github.com/HandBrake/HandBrake/releases/download/$pkgver/HandBrake-$pkgver-source.tar.bz2.sig - handbrake-fix-missing-x265-link-flag.patch - handbrake-no-download.patch - handbrake-supress-clip_id.patch - switch-libav-to-ffmpeg.patch) -sha256sums=('ba9a4a90a7657720f04e4ba0a2880ed055be3bd855e99c0c13af944c3904de2e' + 0001-Fix-linking-issue-when-disabling-internal-libbluray.patch + 0002-Fix-linking-issue-when-disabling-internal-x265.patch) +sha256sums=('a9a82eb5ca04a793705b3d7d11cefa29946694eeb13b40161446aaca35b31d96' 'SKIP' - '05e212e76b6e0b94a04de02cbeb7bf9db607059e19297b5bd3d0d143135285c4' - 'd8116caa83f870803581f0d02e1302b3b8990479d446e4c73bedd35bed531042' - '6407a96c59baa030a4e5fa46c53ddb3e841c7d4787613d391e032a62600d527f' - '7f82adce83d41552e19cdd74268db4084190f201be549b45802817f80fbc37bb') + '8a2818c31815764227d52ea99f7291acacec16c62487f5ae7ea64fedd52546fd' + 'a1181cba4d83a20ead3e1d92649f8f25add000ebc3293829b9604cfc6ed79326') validpgpkeys+=('1629C061B3DDE7EB4AE34B81021DB8B44E4A8645') # HandBrake Team <developers@handbrake.fr> prepare() { cd "$srcdir/HandBrake-$pkgver" - # https://bugs.gentoo.org/show_bug.cgi?id=552792 - patch -Np1 -i ../handbrake-fix-missing-x265-link-flag.patch + # Prevent fetching and use system libraries instead + _libs="\ + ffmpeg \ + libbluray \ + libdav1d \ + libdvdnav \ + libdvdread \ + libvpx \ + nvenc \ + x264 \ + x265 \ + x265_8bit \ + x265_10bit \ + x265_12bit \ + " - patch -Np1 -i ../handbrake-no-download.patch - patch -Np1 -i ../handbrake-supress-clip_id.patch - patch -Np1 -i ../switch-libav-to-ffmpeg.patch + patch -Np1 -i ../0001-Fix-linking-issue-when-disabling-internal-libbluray.patch + patch -Np1 -i ../0002-Fix-linking-issue-when-disabling-internal-x265.patch - # Use more system libs - # Bundled libbluray is kept because it is patched locally - for _lib in ffmpeg x265 libvpx libdvdnav libdvdread; do + for _lib in $_libs ; do sed -i "/MODULES += contrib\/$_lib/d" make/include/main.defs + rm -rf contrib/$_lib done } @@ -51,15 +60,18 @@ build() { cd "$srcdir/HandBrake-$pkgver" ./configure --prefix=/usr \ - --disable-gtk-update-checks + --disable-df-fetch \ + --disable-gtk-update-checks \ + --disable-nvenc \ + make -C build } package_handbrake() { pkgdesc="Multithreaded video transcoder" depends=('bzip2' 'gcc-libs' 'zlib' 'gst-plugins-base' 'libnotify' 'dbus-glib' - 'gtk3' 'libass' 'lame' 'libxml2' 'opus' 'libvorbis' 'libtheora' - 'libsamplerate' 'x264' 'jansson' 'librsvg' 'libgudev' + 'gtk3' 'xz' 'libass' 'lame' 'libxml2' 'opus' 'libvorbis' 'libtheora' + 'libsamplerate' 'speex' 'x264' 'jansson' 'librsvg' 'libgudev' 'desktop-file-utils' 'hicolor-icon-theme') depends+=('ffmpeg' 'libdvdnav') optdepends=('gst-plugins-good: for video previews' @@ -74,8 +86,8 @@ package_handbrake() { package_handbrake-cli() { pkgdesc="Multithreaded video transcoder (CLI)" - depends=('bzip2' 'gcc-libs' 'zlib' 'libass' 'lame' 'libxml2' 'opus' - 'libvorbis' 'libtheora' 'libsamplerate' 'x264' 'jansson') + depends=('bzip2' 'gcc-libs' 'zlib' 'xz' 'libass' 'lame' 'libxml2' 'opus' + 'libvorbis' 'libtheora' 'libsamplerate' 'speex' 'x264' 'jansson') depends+=('ffmpeg' 'libdvdnav') optdepends=('libdvdcss: for decoding encrypted DVDs') diff --git a/libre/handbrake/handbrake-no-download.patch b/libre/handbrake/handbrake-no-download.patch deleted file mode 100644 index 561fd98b1..000000000 --- a/libre/handbrake/handbrake-no-download.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- HandBrake-1.0.1.orig/make/include/main.defs 2016-12-29 16:07:59.000000000 -0500 -+++ HandBrake-1.0.1/make/include/main.defs 2017-01-03 17:06:19.446985505 -0500 -@@ -77,12 +77,6 @@ - MODULES += contrib/x265 - endif - --MODULES += contrib/ffmpeg --MODULES += contrib/libvpx --MODULES += contrib/libdvdread --MODULES += contrib/libdvdnav --MODULES += contrib/libbluray -- - ifneq (,$(filter $(BUILD.system),mingw)) - ifneq ($(HAS.pthread),1) - ifneq ($(HAS.pthreadGC2),1) diff --git a/libre/handbrake/handbrake-supress-clip_id.patch b/libre/handbrake/handbrake-supress-clip_id.patch deleted file mode 100644 index 0570f23e8..000000000 --- a/libre/handbrake/handbrake-supress-clip_id.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- HandBrake-1.0.1.orig/libhb/bd.c 2016-12-29 16:07:59.000000000 -0500 -+++ HandBrake-1.0.1/libhb/bd.c 2017-01-03 16:59:37.551990672 -0500 -@@ -234,24 +234,6 @@ - return 1; - } - --static void show_clip_list( BLURAY_TITLE_INFO * ti ) --{ -- int ii; -- -- for (ii = 0; ii < ti->clip_count; ii++) -- { -- BLURAY_CLIP_INFO * ci = &ti->clips[ii]; -- int64_t duration = ci->out_time - ci->in_time; -- int hh, mm, ss; -- -- hh = duration / (90000 * 60 * 60); -- mm = (duration / (90000 * 60)) % 60; -- ss = (duration / 90000) % 60; -- hb_log("bd:\t\t%s.M2TS -- Duration: %02d:%02d:%02d", -- ti->clips[ii].clip_id, hh, mm, ss); -- } --} -- - /*********************************************************************** - * hb_bd_title_scan - **********************************************************************/ -@@ -335,10 +317,6 @@ - hb_log( "bd: ignoring title (too short)" ); - goto fail; - } -- if (global_verbosity_level >= 2) -- { -- show_clip_list(ti); -- } - - BLURAY_STREAM_INFO * bdvideo = &ti->clips[0].video_streams[0]; - diff --git a/libre/handbrake/switch-libav-to-ffmpeg.patch b/libre/handbrake/switch-libav-to-ffmpeg.patch deleted file mode 100644 index 7ea2186a8..000000000 --- a/libre/handbrake/switch-libav-to-ffmpeg.patch +++ /dev/null @@ -1,792 +0,0 @@ ---- HandBrake-1.1.2.orig/gtk/configure.ac 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/gtk/configure.ac 2018-11-07 16:19:55.149573439 -0500 -@@ -170,7 +170,7 @@ - - GHB_CFLAGS="$HBINC $GHB_CFLAGS" - --HB_LIBS="-lhandbrake -lavresample -lavformat -lavcodec -lavfilter -lavutil -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lsamplerate -lx264 -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus" -+HB_LIBS="-lhandbrake -lavformat -lavfilter -lavcodec -lavutil -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lsamplerate -lx264 -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus" - - case $host in - *-*-mingw*) ---- HandBrake-1.1.2.orig/libhb/decavcodec.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/decavcodec.c 2018-11-07 16:27:29.862414400 -0500 -@@ -390,13 +390,12 @@ - //if (!(pv->qsv.decode && pv->job != NULL && (pv->job->vcodec & HB_VCODEC_QSV_MASK))) - #endif - { -- hb_avcodec_close(pv->context); -+ hb_avcodec_free_context(&pv->context); - } - } - if ( pv->context ) - { -- av_freep( &pv->context->extradata ); -- av_freep( &pv->context ); -+ hb_avcodec_free_context(&pv->context); - } - hb_audio_resample_free(pv->resample); - -@@ -821,9 +820,7 @@ - - if ( parser != NULL ) - av_parser_close( parser ); -- hb_avcodec_close( context ); -- av_freep( &context->extradata ); -- av_freep( &context ); -+ hb_avcodec_free_context(&context); - return result; - } - -@@ -1294,8 +1291,12 @@ - { - int result; - -- av_buffersrc_add_frame(pv->video_filters.input, pv->frame); -- result = av_buffersink_get_frame(pv->video_filters.output, pv->frame); -+ result = av_buffersrc_add_frame(pv->video_filters.input, pv->frame); -+ if (result < 0) { -+ hb_error("filter_video: failed to add frame"); -+ } else { -+ result = av_buffersink_get_frame(pv->video_filters.output, pv->frame); -+ } - while (result >= 0) - { - hb_buffer_t * buf = copy_frame(pv); -@@ -2101,9 +2102,7 @@ - if ( pv->title->opaque_priv == NULL ) - { - pv->video_codec_opened = 0; -- hb_avcodec_close( pv->context ); -- av_freep( &pv->context->extradata ); -- av_freep( &pv->context ); -+ hb_avcodec_free_context(&pv->context); - if ( pv->parser ) - { - av_parser_close(pv->parser); -@@ -2239,7 +2238,8 @@ - av_packet_unref(&avp); - return; - } -- out = hb_audio_resample(pv->resample, pv->frame->extended_data, -+ out = hb_audio_resample(pv->resample, -+ (const uint8_t **)pv->frame->extended_data, - pv->frame->nb_samples); - if (out != NULL && pv->drop_samples > 0) - { ---- HandBrake-1.1.2.orig/libhb/decpgssub.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/decpgssub.c 2018-11-07 16:33:05.320629765 -0500 -@@ -502,7 +502,7 @@ - { - hb_work_private_t * pv = w->private_data; - avcodec_flush_buffers( pv->context ); -- avcodec_close( pv->context ); -+ avcodec_free_context( &pv->context ); - } - - hb_work_object_t hb_decpgssub = ---- HandBrake-1.1.2.orig/libhb/encavcodec.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/encavcodec.c 2018-11-07 16:35:51.169822169 -0500 -@@ -399,12 +399,13 @@ - return; - } - hb_chapter_queue_close(&pv->chapter_queue); -- if( pv->context && pv->context->codec ) -+ if( pv->context ) - { - hb_deep_log( 2, "encavcodec: closing libavcodec" ); -- avcodec_flush_buffers( pv->context ); -- hb_avcodec_close( pv->context ); -- av_free( pv->context ); -+ if( pv->context->codec ) { -+ avcodec_flush_buffers( pv->context ); -+ } -+ hb_avcodec_free_context(&pv->context); - } - if( pv->file ) - { ---- HandBrake-1.1.2.orig/libhb/encavcodecaudio.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/encavcodecaudio.c 2018-11-07 18:16:43.503730591 -0500 -@@ -23,7 +23,7 @@ - uint8_t * input_buf; - hb_list_t * list; - -- AVAudioResampleContext *avresample; -+ SwrContext * swresample; - - int64_t last_pts; - }; -@@ -231,40 +231,40 @@ - if (context->sample_fmt != AV_SAMPLE_FMT_FLT) - { - pv->output_buf = malloc(pv->max_output_bytes); -- pv->avresample = avresample_alloc_context(); -- if (pv->avresample == NULL) -+ pv->swresample = swr_alloc(); -+ if (pv->swresample == NULL) - { -- hb_error("encavcodecaInit: avresample_alloc_context() failed"); -+ hb_error("encavcodecaInit: swr_alloc() failed"); - return 1; - } -- av_opt_set_int(pv->avresample, "in_sample_fmt", -+ av_opt_set_int(pv->swresample, "in_sample_fmt", - AV_SAMPLE_FMT_FLT, 0); -- av_opt_set_int(pv->avresample, "out_sample_fmt", -+ av_opt_set_int(pv->swresample, "out_sample_fmt", - context->sample_fmt, 0); -- av_opt_set_int(pv->avresample, "in_channel_layout", -+ av_opt_set_int(pv->swresample, "in_channel_layout", - context->channel_layout, 0); -- av_opt_set_int(pv->avresample, "out_channel_layout", -+ av_opt_set_int(pv->swresample, "out_channel_layout", - context->channel_layout, 0); - if (hb_audio_dither_is_supported(audio->config.out.codec)) - { - // dithering needs the sample rate -- av_opt_set_int(pv->avresample, "in_sample_rate", -+ av_opt_set_int(pv->swresample, "in_sample_rate", - context->sample_rate, 0); -- av_opt_set_int(pv->avresample, "out_sample_rate", -+ av_opt_set_int(pv->swresample, "out_sample_rate", - context->sample_rate, 0); -- av_opt_set_int(pv->avresample, "dither_method", -+ av_opt_set_int(pv->swresample, "dither_method", - audio->config.out.dither_method, 0); - } -- if (avresample_open(pv->avresample)) -+ if (swr_init(pv->swresample)) - { -- hb_error("encavcodecaInit: avresample_open() failed"); -- avresample_free(&pv->avresample); -+ hb_error("encavcodecaInit: swr_init() failed"); -+ swr_free(&pv->swresample); - return 1; - } - } - else - { -- pv->avresample = NULL; -+ pv->swresample = NULL; - pv->output_buf = pv->input_buf; - } - -@@ -308,10 +308,10 @@ - { - Finalize(w); - hb_deep_log(2, "encavcodecaudio: closing libavcodec"); -- if (pv->context->codec != NULL) -+ if (pv->context->codec != NULL) { - avcodec_flush_buffers(pv->context); -- hb_avcodec_close(pv->context); -- av_free( pv->context ); -+ } -+ hb_avcodec_free_context(&pv->context); - } - - if (pv->output_buf != NULL) -@@ -329,9 +329,9 @@ - hb_list_empty(&pv->list); - } - -- if (pv->avresample != NULL) -+ if (pv->swresample != NULL) - { -- avresample_free(&pv->avresample); -+ swr_free(&pv->swresample); - } - - free(pv); -@@ -404,31 +404,28 @@ - pv->input_samples * sizeof(float), &pts, &pos); - - // Prepare input frame -- int out_linesize, out_size; -+ int out_size; - AVFrame frame = { .nb_samples = pv->samples_per_frame, }; - -- out_size = av_samples_get_buffer_size(&out_linesize, -+ out_size = av_samples_get_buffer_size(NULL, - pv->context->channels, - pv->samples_per_frame, - pv->context->sample_fmt, 1); - avcodec_fill_audio_frame(&frame, - pv->context->channels, pv->context->sample_fmt, - pv->output_buf, out_size, 1); -- if (pv->avresample != NULL) -+ if (pv->swresample != NULL) - { -- int in_linesize, out_samples; -+ int out_samples; - -- av_samples_get_buffer_size(&in_linesize, pv->context->channels, -- frame.nb_samples, AV_SAMPLE_FMT_FLT, 1); -- out_samples = avresample_convert(pv->avresample, -- frame.extended_data, out_linesize, -- frame.nb_samples, &pv->input_buf, -- in_linesize, frame.nb_samples); -+ out_samples = swr_convert(pv->swresample, -+ frame.extended_data, frame.nb_samples, -+ (const uint8_t **)&pv->input_buf, frame.nb_samples); - if (out_samples != pv->samples_per_frame) - { - // we're not doing sample rate conversion, - // so this shouldn't happen -- hb_log("encavcodecaWork: avresample_convert() failed"); -+ hb_log("encavcodecaWork: swr_convert() failed"); - continue; - } - } ---- HandBrake-1.1.2.orig/libhb/hb.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/hb.c 2018-11-07 16:45:12.564522006 -0500 -@@ -102,14 +102,6 @@ - av_lockmgr_register(ff_lockmgr_cb); - av_register_all(); - avfilter_register_all(); --#ifdef _WIN64 -- // avresample's assembly optimizations can cause crashes under Win x86_64 -- // (see http://bugzilla.libav.org/show_bug.cgi?id=496) -- // disable AVX and FMA4 as a workaround -- hb_deep_log(2, "hb_avcodec_init: Windows x86_64, disabling AVX and FMA4"); -- int cpu_flags = av_get_cpu_flags() & ~AV_CPU_FLAG_AVX & ~AV_CPU_FLAG_FMA4; -- av_set_cpu_flags_mask(cpu_flags); --#endif - } - - int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, -@@ -140,11 +132,9 @@ - return ret; - } - --int hb_avcodec_close(AVCodecContext *avctx) -+void hb_avcodec_free_context(AVCodecContext **avctx) - { -- int ret; -- ret = avcodec_close(avctx); -- return ret; -+ avcodec_free_context(avctx); - } - - ---- HandBrake-1.1.2.orig/libhb/hbffmpeg.h 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/hbffmpeg.h 2018-11-07 16:47:00.726314186 -0500 -@@ -17,14 +17,14 @@ - #include "libavutil/downmix_info.h" - #include "libavutil/display.h" - #include "libswscale/swscale.h" --#include "libavresample/avresample.h" -+#include "libswresample/swresample.h" - #include "common.h" - - #define HB_FFMPEG_THREADS_AUTO (-1) // let hb_avcodec_open() decide thread_count - - void hb_avcodec_init(void); - int hb_avcodec_open(AVCodecContext *, AVCodec *, AVDictionary **, int); --int hb_avcodec_close(AVCodecContext *); -+void hb_avcodec_free_context(AVCodecContext **avctx); - const char* const* hb_av_preset_get_names(int encoder); - - uint64_t hb_ff_mixdown_xlat(int hb_mixdown, int *downmix_mode); ---- HandBrake-1.1.2.orig/libhb/module.defs 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/module.defs 2018-11-07 16:51:42.516948168 -0500 -@@ -130,7 +130,7 @@ - LIBHB.lib = $(LIBHB.build/)hb.lib - - LIBHB.dll.libs = $(foreach n, \ -- ass avcodec avformat avfilter avutil avresample dvdnav dvdread \ -+ ass avformat avfilter avcodec avutil swresample postproc dvdnav dvdread \ - freetype mp3lame samplerate swscale vpx theora vorbis vorbisenc ogg \ - x264 xml2 bluray jansson harfbuzz opus, \ - $(CONTRIB.build/)lib/lib$(n).a ) -@@ -186,7 +186,7 @@ - endif - - LIBHB.GCC.args.extra.dylib++ += -Wl,--out-implib,$(LIBHB.lib) --LIBHB.GCC.l += ws2_32 uuid ole32 -+LIBHB.GCC.l += bcrypt ws2_32 uuid ole32 - ifeq ($(HAS.dlfcn),1) - LIBHB.GCC.l += dl - endif ---- HandBrake-1.1.2.orig/libhb/muxavformat.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/muxavformat.c 2018-11-07 16:54:05.220517000 -0500 -@@ -800,7 +800,7 @@ - } - else - { -- track->st->codecpar->codec_id = AV_CODEC_ID_SSA; -+ track->st->codecpar->codec_id = AV_CODEC_ID_ASS; - need_fonts = 1; - - if (subtitle->extradata_size) -@@ -1197,10 +1197,12 @@ - { - pkt.flags |= AV_PKT_FLAG_KEY; - } -+#ifdef AV_PKT_FLAG_DISPOSABLE - if (!(buf->s.flags & HB_FLAG_FRAMETYPE_REF)) - { - pkt.flags |= AV_PKT_FLAG_DISPOSABLE; - } -+#endif - } - else if (buf->s.frametype & HB_FRAME_MASK_KEY) - { -@@ -1313,7 +1315,7 @@ - free(styleatom); - } - } -- if (track->st->codecpar->codec_id == AV_CODEC_ID_SSA && -+ if (track->st->codecpar->codec_id == AV_CODEC_ID_ASS && - job->mux == HB_MUX_AV_MKV) - { - // avformat requires the this additional information ---- HandBrake-1.1.2.orig/libhb/stream.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/stream.c 2018-11-07 16:56:19.404469782 -0500 -@@ -5315,7 +5315,7 @@ - "subtitle colors likely to be wrong" ); - break; - case AV_CODEC_ID_TEXT: -- case AV_CODEC_ID_SRT: -+ case AV_CODEC_ID_SUBRIP: - subtitle->format = TEXTSUB; - subtitle->source = UTF8SUB; - subtitle->config.dest = PASSTHRUSUB; -@@ -5327,7 +5327,7 @@ - subtitle->config.dest = PASSTHRUSUB; - subtitle->codec = WORK_DECTX3GSUB; - break; -- case AV_CODEC_ID_SSA: -+ case AV_CODEC_ID_ASS: - subtitle->format = TEXTSUB; - subtitle->source = SSASUB; - subtitle->config.dest = PASSTHRUSUB; -@@ -5852,7 +5852,7 @@ - * either field. This is not a problem because the VOB decoder can extract this - * information from the packet payload itself. - * -- * SSA subtitles (AV_CODEC_ID_SSA) do not have their duration stored in -+ * SSA subtitles (AV_CODEC_ID_ASS) do not have their duration stored in - * either field. This is not a problem because the SSA decoder can extract this - * information from the packet payload itself. - */ -@@ -5888,7 +5888,7 @@ - break; - } - if ( ffmpeg_pkt_codec == AV_CODEC_ID_TEXT || -- ffmpeg_pkt_codec == AV_CODEC_ID_SRT || -+ ffmpeg_pkt_codec == AV_CODEC_ID_SUBRIP || - ffmpeg_pkt_codec == AV_CODEC_ID_MOV_TEXT ) { - int64_t ffmpeg_pkt_duration = stream->ffmpeg_pkt.duration; - int64_t buf_duration = av_to_hb_pts( ffmpeg_pkt_duration, tsconv, 0 ); ---- HandBrake-1.1.2.orig/macosx/HandBrake.xcodeproj/project.pbxproj 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/macosx/HandBrake.xcodeproj/project.pbxproj 2018-11-07 18:29:58.654562496 -0500 -@@ -7,11 +7,14 @@ - objects = { - - /* Begin PBXBuildFile section */ -+ 1C0695AC20BD193D001543DA /* libpostproc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C0695AA20BD193D001543DA /* libpostproc.a */; }; -+ 1C0695AD20BD193D001543DA /* libpostproc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C0695AA20BD193D001543DA /* libpostproc.a */; }; -+ 1C0695AE20BD193D001543DA /* libswresample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C0695AB20BD193D001543DA /* libswresample.a */; }; -+ 1C0695AF20BD193D001543DA /* libswresample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C0695AB20BD193D001543DA /* libswresample.a */; }; - 1C6D76551CD7733300F5B943 /* libharfbuzz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C15C82B1CD7722500368223 /* libharfbuzz.a */; }; - 1C6D76561CD7733400F5B943 /* libharfbuzz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C15C82B1CD7722500368223 /* libharfbuzz.a */; }; - 1C7776A2202300DD001C31EB /* HBRenamePresetController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C7776A0202300DC001C31EB /* HBRenamePresetController.m */; }; - 1C7776A5202301D5001C31EB /* HBRenamePresetController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C7776A3202301D5001C31EB /* HBRenamePresetController.xib */; }; -- 226268E11572CC7300477B4E /* libavresample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 226268DF1572CC7300477B4E /* libavresample.a */; }; - 22DD2C4B177B95DA00EF50D3 /* libvpx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22DD2C49177B94DB00EF50D3 /* libvpx.a */; }; - 273F202314ADB8650021BE6D /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 273F202214ADB8650021BE6D /* IOKit.framework */; }; - 273F202614ADB8A40021BE6D /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 273F202514ADB8A40021BE6D /* libz.dylib */; }; -@@ -124,7 +127,6 @@ - A91CE2B41C7DABBC0068F46F /* libavcodec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72914B102DA00B785E4 /* libavcodec.a */; }; - A91CE2B51C7DABBC0068F46F /* libavfilter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A9E165511C523016003EF30E /* libavfilter.a */; }; - A91CE2B61C7DABBC0068F46F /* libavformat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72A14B102DA00B785E4 /* libavformat.a */; }; -- A91CE2B71C7DABBC0068F46F /* libavresample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 226268DF1572CC7300477B4E /* libavresample.a */; }; - A91CE2B81C7DABBC0068F46F /* libavutil.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72B14B102DA00B785E4 /* libavutil.a */; }; - A91CE2B91C7DABBC0068F46F /* libbluray.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72C14B102DA00B785E4 /* libbluray.a */; }; - A91CE2BA1C7DABBC0068F46F /* libdvdnav.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72E14B102DA00B785E4 /* libdvdnav.a */; }; -@@ -317,11 +319,12 @@ - /* End PBXCopyFilesBuildPhase section */ - - /* Begin PBXFileReference section */ -+ 1C0695AA20BD193D001543DA /* libpostproc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpostproc.a; path = "external/contrib/lib/libpostproc.a"; sourceTree = BUILT_PRODUCTS_DIR; }; -+ 1C0695AB20BD193D001543DA /* libswresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswresample.a; path = "external/contrib/lib/libswresample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 1C15C82B1CD7722500368223 /* libharfbuzz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libharfbuzz.a; path = external/contrib/lib/libharfbuzz.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 1C7776A0202300DC001C31EB /* HBRenamePresetController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBRenamePresetController.m; sourceTree = "<group>"; }; - 1C7776A1202300DC001C31EB /* HBRenamePresetController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBRenamePresetController.h; sourceTree = "<group>"; }; - 1C7776A4202301D5001C31EB /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/HBRenamePresetController.xib; sourceTree = "<group>"; }; -- 226268DF1572CC7300477B4E /* libavresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavresample.a; path = external/contrib/lib/libavresample.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 22CC9E74191EBEA500C69D81 /* libx265.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libx265.a; path = external/contrib/lib/libx265.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 22DD2C49177B94DB00EF50D3 /* libvpx.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvpx.a; path = external/contrib/lib/libvpx.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 271BA4C014B119F800BC1D2C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = external/macosx/Info.plist; sourceTree = BUILT_PRODUCTS_DIR; }; -@@ -630,7 +633,6 @@ - 27D6C74414B102DA00B785E4 /* libass.a in Frameworks */, - 27D6C74614B102DA00B785E4 /* libavcodec.a in Frameworks */, - 27D6C74814B102DA00B785E4 /* libavformat.a in Frameworks */, -- 226268E11572CC7300477B4E /* libavresample.a in Frameworks */, - 27D6C74A14B102DA00B785E4 /* libavutil.a in Frameworks */, - 27D6C74C14B102DA00B785E4 /* libbluray.a in Frameworks */, - 27D6C75014B102DA00B785E4 /* libdvdnav.a in Frameworks */, -@@ -638,11 +640,13 @@ - 27D6C75814B102DA00B785E4 /* libfreetype.a in Frameworks */, - 27D6C75A14B102DA00B785E4 /* libfribidi.a in Frameworks */, - 27D6C75F14B102DA00B785E4 /* libmp3lame.a in Frameworks */, -+ 1C0695AC20BD193D001543DA /* libpostproc.a in Frameworks */, - 27D6C76514B102DA00B785E4 /* libogg.a in Frameworks */, - 27D6C76714B102DA00B785E4 /* libsamplerate.a in Frameworks */, - 27D6C76914B102DA00B785E4 /* libswscale.a in Frameworks */, - 27D6C76B14B102DA00B785E4 /* libtheora.a in Frameworks */, - 27D6C76D14B102DA00B785E4 /* libvorbis.a in Frameworks */, -+ 1C0695AE20BD193D001543DA /* libswresample.a in Frameworks */, - 27D6C76F14B102DA00B785E4 /* libvorbisenc.a in Frameworks */, - 6F0D69A91AD0683100A39DCA /* Foundation.framework in Frameworks */, - 22DD2C4B177B95DA00EF50D3 /* libvpx.a in Frameworks */, -@@ -678,6 +682,7 @@ - A91CE2B21C7DAB550068F46F /* AudioToolbox.framework in Frameworks */, - A91CE2D41C7DABE40068F46F /* libiconv.tbd in Frameworks */, - A91CE2D21C7DABDA0068F46F /* libz.tbd in Frameworks */, -+ 1C0695AF20BD193D001543DA /* libswresample.a in Frameworks */, - A91CE2D01C7DABCE0068F46F /* libbz2.tbd in Frameworks */, - A900E6BD1D7B1B5A00CB6C0A /* libopus.a in Frameworks */, - A91CE2CE1C7DABBC0068F46F /* libvorbisfile.a in Frameworks */, -@@ -685,7 +690,6 @@ - A91CE2B41C7DABBC0068F46F /* libavcodec.a in Frameworks */, - A91CE2B51C7DABBC0068F46F /* libavfilter.a in Frameworks */, - A91CE2B61C7DABBC0068F46F /* libavformat.a in Frameworks */, -- A91CE2B71C7DABBC0068F46F /* libavresample.a in Frameworks */, - A91CE2B81C7DABBC0068F46F /* libavutil.a in Frameworks */, - A91CE2B91C7DABBC0068F46F /* libbluray.a in Frameworks */, - A91CE2BA1C7DABBC0068F46F /* libdvdnav.a in Frameworks */, -@@ -697,6 +701,7 @@ - A91CE2C01C7DABBC0068F46F /* libmp3lame.a in Frameworks */, - A91CE2C11C7DABBC0068F46F /* libogg.a in Frameworks */, - A91CE2C21C7DABBC0068F46F /* libsamplerate.a in Frameworks */, -+ 1C0695AD20BD193D001543DA /* libpostproc.a in Frameworks */, - A91CE2C31C7DABBC0068F46F /* libswscale.a in Frameworks */, - A91CE2C41C7DABBC0068F46F /* libtheora.a in Frameworks */, - A91CE2C51C7DABBC0068F46F /* libvorbis.a in Frameworks */, -@@ -723,11 +728,12 @@ - 271BA4C714B1236D00BC1D2C /* Static Libraries */ = { - isa = PBXGroup; - children = ( -+ 1C0695AA20BD193D001543DA /* libpostproc.a */, -+ 1C0695AB20BD193D001543DA /* libswresample.a */, - 27D6C72414B1019100B785E4 /* libhandbrake.a */, - 27D6C72814B102DA00B785E4 /* libass.a */, - 27D6C72914B102DA00B785E4 /* libavcodec.a */, - 27D6C72A14B102DA00B785E4 /* libavformat.a */, -- 226268DF1572CC7300477B4E /* libavresample.a */, - 27D6C72B14B102DA00B785E4 /* libavutil.a */, - 27D6C72C14B102DA00B785E4 /* libbluray.a */, - 27D6C72E14B102DA00B785E4 /* libdvdnav.a */, ---- HandBrake-1.1.2.orig/test/module.defs 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/test/module.defs 2018-11-07 17:03:22.815388083 -0500 -@@ -14,7 +14,7 @@ - TEST.libs = $(LIBHB.a) - - TEST.GCC.l = \ -- ass avresample avformat avcodec avfilter avutil mp3lame dvdnav \ -+ ass avformat avfilter avcodec avutil swresample postproc mp3lame dvdnav \ - dvdread fribidi \ - samplerate swscale vpx theoraenc theoradec vorbis vorbisenc ogg x264 \ - bluray freetype xml2 bz2 z jansson harfbuzz opus -@@ -89,7 +89,7 @@ - else - TEST.GCC.l += pthreadGC2 - endif -- TEST.GCC.l += iconv ws2_32 regex uuid ole32 -+ TEST.GCC.l += bcrypt iconv ws2_32 regex uuid ole32 - TEST.GCC.D += PTW32_STATIC_LIB - TEST.GCC.args.extra.exe++ += -static - endif # (1-mingw,$(BUILD.cross)-$(BUILD.system)) ---- HandBrake-1.1.2.orig/libhb/audio_resample.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/audio_resample.c 2018-11-07 17:49:17.441246400 -0500 -@@ -21,8 +21,8 @@ - goto fail; - } - -- // avresample context, initialized in hb_audio_resample_update() -- resample->avresample = NULL; -+ // swresample context, initialized in hb_audio_resample_update() -+ resample->swresample = NULL; - - // we don't support planar output yet - if (av_sample_fmt_is_planar(sample_fmt)) -@@ -55,8 +55,15 @@ - resample->out.channels = av_get_channel_layout_nb_channels(channel_layout); - resample->out.channel_layout = channel_layout; - resample->out.matrix_encoding = matrix_encoding; -- resample->out.normalize_mix_level = normalize_mix; - resample->out.sample_fmt = sample_fmt; -+ if (normalize_mix) -+ { -+ resample->out.maxval = 1.0; -+ } -+ else -+ { -+ resample->out.maxval = 1000; -+ } - resample->out.sample_size = av_get_bytes_per_sample(sample_fmt); - - // set default input characteristics -@@ -105,7 +112,7 @@ - // Dolby Surround is Stereo when it comes to remixing - channel_layout = AV_CH_LAYOUT_STEREO; - } -- // avresample can't remap a single-channel layout to -+ // swresample can't remap a single-channel layout to - // another single-channel layout - if (resample->out.channel_layout == AV_CH_LAYOUT_MONO && - is_mono(channel_layout)) -@@ -161,50 +168,46 @@ - resample->resample.surround_mix_level != resample->in.surround_mix_level)); - - if (resample_changed || (resample->resample_needed && -- resample->avresample == NULL)) -+ resample->swresample == NULL)) - { -- if (resample->avresample == NULL) -+ if (resample->swresample == NULL) - { -- resample->avresample = avresample_alloc_context(); -- if (resample->avresample == NULL) -+ resample->swresample = swr_alloc(); -+ if (resample->swresample == NULL) - { -- hb_error("hb_audio_resample_update: avresample_alloc_context() failed"); -+ hb_error("hb_audio_resample_update: swr_alloc() failed"); - return 1; - } - -- av_opt_set_int(resample->avresample, "out_sample_fmt", -+ av_opt_set_int(resample->swresample, "out_sample_fmt", - resample->out.sample_fmt, 0); -- av_opt_set_int(resample->avresample, "out_channel_layout", -+ av_opt_set_int(resample->swresample, "out_channel_layout", - resample->out.channel_layout, 0); -- av_opt_set_int(resample->avresample, "matrix_encoding", -+ av_opt_set_int(resample->swresample, "matrix_encoding", - resample->out.matrix_encoding, 0); -- av_opt_set_int(resample->avresample, "normalize_mix_level", -- resample->out.normalize_mix_level, 0); -- } -- else if (resample_changed) -- { -- avresample_close(resample->avresample); -+ av_opt_set_double(resample->swresample, "rematrix_maxval", -+ resample->out.maxval, 0); - } - -- av_opt_set_int(resample->avresample, "in_sample_fmt", -+ av_opt_set_int(resample->swresample, "in_sample_fmt", - resample->in.sample_fmt, 0); -- av_opt_set_int(resample->avresample, "in_channel_layout", -+ av_opt_set_int(resample->swresample, "in_channel_layout", - resample->in.channel_layout, 0); -- av_opt_set_double(resample->avresample, "lfe_mix_level", -+ av_opt_set_double(resample->swresample, "lfe_mix_level", - resample->in.lfe_mix_level, 0); -- av_opt_set_double(resample->avresample, "center_mix_level", -+ av_opt_set_double(resample->swresample, "center_mix_level", - resample->in.center_mix_level, 0); -- av_opt_set_double(resample->avresample, "surround_mix_level", -+ av_opt_set_double(resample->swresample, "surround_mix_level", - resample->in.surround_mix_level, 0); - -- if ((ret = avresample_open(resample->avresample))) -+ if ((ret = swr_init(resample->swresample))) - { - char err_desc[64]; - av_strerror(ret, err_desc, 63); -- hb_error("hb_audio_resample_update: avresample_open() failed (%s)", -+ hb_error("hb_audio_resample_update: swr_init() failed (%s)", - err_desc); -- // avresample won't open, start over -- avresample_free(&resample->avresample); -+ // swresample won't open, start over -+ swr_free(&resample->swresample); - return ret; - } - -@@ -224,25 +227,25 @@ - { - if (resample != NULL) - { -- if (resample->avresample != NULL) -+ if (resample->swresample != NULL) - { -- avresample_free(&resample->avresample); -+ swr_free(&resample->swresample); - } - free(resample); - } - } - - hb_buffer_t* hb_audio_resample(hb_audio_resample_t *resample, -- uint8_t **samples, int nsamples) -+ const uint8_t **samples, int nsamples) - { - if (resample == NULL) - { - hb_error("hb_audio_resample: resample is NULL"); - return NULL; - } -- if (resample->resample_needed && resample->avresample == NULL) -+ if (resample->resample_needed && resample->swresample == NULL) - { -- hb_error("hb_audio_resample: resample needed but libavresample context " -+ hb_error("hb_audio_resample: resample needed but libswresample context " - "is NULL"); - return NULL; - } -@@ -252,24 +255,18 @@ - - if (resample->resample_needed) - { -- int in_linesize, out_linesize; -- // set in/out linesize and out_size -- av_samples_get_buffer_size(&in_linesize, -- resample->resample.channels, nsamples, -- resample->resample.sample_fmt, 0); -- out_size = av_samples_get_buffer_size(&out_linesize, -+ out_size = av_samples_get_buffer_size(NULL, - resample->out.channels, nsamples, - resample->out.sample_fmt, 0); - out = hb_buffer_init(out_size); - -- out_samples = avresample_convert(resample->avresample, -- &out->data, out_linesize, nsamples, -- samples, in_linesize, nsamples); -+ out_samples = swr_convert(resample->swresample, &out->data, nsamples, -+ samples, nsamples); - - if (out_samples <= 0) - { - if (out_samples < 0) -- hb_log("hb_audio_resample: avresample_convert() failed"); -+ hb_log("hb_audio_resample: swr_convert() failed"); - // don't send empty buffers downstream (EOF) - hb_buffer_close(&out); - return NULL; ---- HandBrake-1.1.2.orig/libhb/audio_resample.h 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/audio_resample.h 2018-11-07 18:01:39.397808925 -0500 -@@ -7,11 +7,11 @@ - * For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - */ - --/* Implements a libavresample wrapper for convenience. -+/* Implements a libswresample wrapper for convenience. - * - * Supports sample_fmt and channel_layout conversion. - * -- * sample_rate conversion will come later (libavresample doesn't support -+ * sample_rate conversion will come later (libswresample doesn't support - * sample_rate conversion with float samples yet). */ - - #ifndef AUDIO_RESAMPLE_H -@@ -20,7 +20,7 @@ - #include <math.h> - #include <stdint.h> - #include "libavutil/channel_layout.h" --#include "libavresample/avresample.h" -+#include "libswresample/swresample.h" - - /* Default mix level for center and surround channels */ - #define HB_MIXLEV_DEFAULT ((double)M_SQRT1_2) -@@ -33,7 +33,7 @@ - int dual_mono_right_only; - - int resample_needed; -- AVAudioResampleContext *avresample; -+ SwrContext *swresample; - - struct - { -@@ -58,10 +58,10 @@ - { - int channels; - int sample_size; -- int normalize_mix_level; - uint64_t channel_layout; - enum AVSampleFormat sample_fmt; - enum AVMatrixEncoding matrix_encoding; -+ double maxval; - } out; - } hb_audio_resample_t; - -@@ -108,6 +108,6 @@ - * resampling is only done when necessary. - */ - hb_buffer_t* hb_audio_resample(hb_audio_resample_t *resample, -- uint8_t **samples, int nsamples); -+ const uint8_t **samples, int nsamples); - - #endif /* AUDIO_RESAMPLE_H */ ---- HandBrake-1.1.2.orig/libhb/common.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/common.c 2018-11-07 18:06:08.535679790 -0500 -@@ -177,12 +177,12 @@ - hb_dither_t *hb_audio_dithers_last_item = NULL; - hb_dither_internal_t hb_audio_dithers[] = - { -- { { "default", "auto", AV_RESAMPLE_DITHER_NONE - 1, }, NULL, 1, }, -- { { "none", "none", AV_RESAMPLE_DITHER_NONE, }, NULL, 1, }, -- { { "rectangular", "rectangular", AV_RESAMPLE_DITHER_RECTANGULAR, }, NULL, 1, }, -- { { "triangular", "triangular", AV_RESAMPLE_DITHER_TRIANGULAR, }, NULL, 1, }, -- { { "triangular with high pass", "triangular_hp", AV_RESAMPLE_DITHER_TRIANGULAR_HP, }, NULL, 1, }, -- { { "triangular with noise shaping", "triangular_ns", AV_RESAMPLE_DITHER_TRIANGULAR_NS, }, NULL, 1, }, -+ { { "default", "auto", SWR_DITHER_NONE - 1, }, NULL, 1, }, -+ { { "none", "none", SWR_DITHER_NONE, }, NULL, 1, }, -+ { { "rectangular", "rectangular", SWR_DITHER_RECTANGULAR, }, NULL, 1, }, -+ { { "triangular", "triangular", SWR_DITHER_TRIANGULAR, }, NULL, 1, }, -+ { { "triangular with high pass", "triangular_hp", SWR_DITHER_TRIANGULAR_HIGHPASS, }, NULL, 1, }, -+ { { "lipshitz noise shaping", "lipshitz_ns", SWR_DITHER_NS_LIPSHITZ, }, NULL, 1, }, - }; - int hb_audio_dithers_count = sizeof(hb_audio_dithers) / sizeof(hb_audio_dithers[0]); - -@@ -1675,22 +1675,13 @@ - * input could be s16 (possibly already dithered) converted to flt, so - * let's use a "low-risk" dither algorithm (standard triangular). - */ -- return AV_RESAMPLE_DITHER_TRIANGULAR; -+ return SWR_DITHER_TRIANGULAR; - } - - int hb_audio_dither_is_supported(uint32_t codec) - { -- // encoder's input sample format must be s16(p) -- switch (codec) -- { -- case HB_ACODEC_FFFLAC: -- case HB_ACODEC_FDK_AAC: -- case HB_ACODEC_FDK_HAAC: -- return 1; -- -- default: -- return 0; -- } -+ // Since dithering is performed by swresample, all codecs are supported -+ return 1; - } - - int hb_audio_dither_get_from_name(const char *name) -@@ -1857,7 +1848,7 @@ - // regular stereo (not Dolby) - case HB_AMIXDOWN_LEFT: - case HB_AMIXDOWN_RIGHT: -- return (layout == AV_CH_LAYOUT_STEREO); -+ return (layout & AV_CH_LAYOUT_STEREO); - - // mono remix always supported - // HB_AMIXDOWN_NONE always supported (for Passthru) ---- HandBrake-1.1.2.orig/libhb/declpcm.c 2018-09-04 14:35:01.000000000 -0500 -+++ HandBrake-1.1.2/libhb/declpcm.c 2018-11-07 18:10:28.433967052 -0500 -@@ -338,7 +338,8 @@ - hb_log("declpcm: hb_audio_resample_update() failed"); - return NULL; - } -- out = hb_audio_resample(pv->resample, &pv->data, pv->nsamples); -+ out = hb_audio_resample(pv->resample, (const uint8_t **)&pv->data, -+ pv->nsamples); - - if (out != NULL) - { - |