diff options
-rw-r--r-- | libre/handbrake/PKGBUILD | 51 | ||||
-rw-r--r-- | libre/handbrake/switch-libav-to-ffmpeg.patch | 792 |
2 files changed, 820 insertions, 23 deletions
diff --git a/libre/handbrake/PKGBUILD b/libre/handbrake/PKGBUILD index e3e5a6732..e4e2baabe 100644 --- a/libre/handbrake/PKGBUILD +++ b/libre/handbrake/PKGBUILD @@ -1,31 +1,33 @@ -# $Id$ # Maintainer (Arch): Evangelos Foutras <evangelos@foutrelis.com> # Contributor (Arch): Giovanni Scafora <giovanni@archlinux.org> # Contributor (Arch): Sebastien Piccand <sebcactus gmail com> # Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe> pkgname=('handbrake' 'handbrake-cli') -pkgver=1.1.0 -pkgrel=1.parabola1 -arch=('i686' 'x86_64' 'armv7h') +pkgver=1.1.2 +pkgrel=1 +pkgrel+=.par1 +arch=('x86_64') +arch+=('i686' 'armv7h') url="https://handbrake.fr/" license=('GPL') -makedepends=('intltool' 'python2' 'yasm' 'wget' 'bzip2' 'gcc-libs' 'libnotify' - 'gst-plugins-base' 'gtk3' 'dbus-glib' 'fribidi' 'libass' 'lame' - 'fontconfig' 'freetype2' 'libxml2' 'libogg' 'libvorbis' 'cmake' - 'libtheora' 'libsamplerate' 'ffmpeg' 'x264' 'libx264' 'x265' - 'libvpx' 'libdvdnav' 'jansson' 'librsvg' 'libgudev' - 'libdvdread' 'libbluray') +makedepends=('intltool' 'python2' 'yasm' 'wget' 'cmake' 'bzip2' 'gcc-libs' + 'zlib' 'libnotify' 'gst-plugins-base' 'gtk3' 'dbus-glib' 'libass' + 'lame' 'libxml2' 'opus' 'libvorbis' 'libtheora' 'libsamplerate' + 'x264' 'jansson' 'librsvg' 'libgudev') +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) -sha256sums=('a02e7c6f8bd8dc28eea4623663deb5971dcbca1ad59da9eb74aceb481d8c40da' + handbrake-supress-clip_id.patch + switch-libav-to-ffmpeg.patch) +sha256sums=('ba9a4a90a7657720f04e4ba0a2880ed055be3bd855e99c0c13af944c3904de2e' 'SKIP' '05e212e76b6e0b94a04de02cbeb7bf9db607059e19297b5bd3d0d143135285c4' 'd8116caa83f870803581f0d02e1302b3b8990479d446e4c73bedd35bed531042' - '6407a96c59baa030a4e5fa46c53ddb3e841c7d4787613d391e032a62600d527f') + '6407a96c59baa030a4e5fa46c53ddb3e841c7d4787613d391e032a62600d527f' + '7f82adce83d41552e19cdd74268db4084190f201be549b45802817f80fbc37bb') validpgpkeys+=('1629C061B3DDE7EB4AE34B81021DB8B44E4A8645') # HandBrake Team <developers@handbrake.fr> prepare() { @@ -33,8 +35,10 @@ prepare() { # https://bugs.gentoo.org/show_bug.cgi?id=552792 patch -Np1 -i ../handbrake-fix-missing-x265-link-flag.patch + patch -Np1 -i ../handbrake-no-download.patch patch -Np1 -i ../handbrake-supress-clip_id.patch + patch -Np1 -i ../switch-libav-to-ffmpeg.patch # Use more system libs # Bundled libbluray is kept because it is patched locally @@ -46,21 +50,21 @@ prepare() { build() { cd "$srcdir/HandBrake-$pkgver" - ./configure \ - --prefix=/usr \ + ./configure --prefix=/usr \ --disable-gtk-update-checks make -C build } package_handbrake() { pkgdesc="Multithreaded video transcoder" - depends=('bzip2' 'gcc-libs' 'gst-plugins-base' 'libnotify' 'dbus-glib' - 'fribidi' 'libass' 'lame' 'gtk3' 'fontconfig' 'freetype2' 'libxml2' - 'libogg' 'libvorbis' 'libtheora' 'libsamplerate' 'ffmpeg' 'libx264' - 'x265' 'libvpx' 'libdvdnav' 'jansson' 'librsvg' 'libgudev' + depends=('bzip2' 'gcc-libs' 'zlib' 'gst-plugins-base' 'libnotify' 'dbus-glib' + 'gtk3' 'libass' 'lame' 'libxml2' 'opus' 'libvorbis' 'libtheora' + 'libsamplerate' 'x264' 'jansson' 'librsvg' 'libgudev' 'desktop-file-utils' 'hicolor-icon-theme') + depends+=('ffmpeg' 'libdvdnav') optdepends=('gst-plugins-good: for video previews' - 'gst-libav: for video previews') + 'gst-libav: for video previews' + 'libdvdcss: for decoding encrypted DVDs') cd "$srcdir/HandBrake-$pkgver/build" @@ -70,9 +74,10 @@ package_handbrake() { package_handbrake-cli() { pkgdesc="Multithreaded video transcoder (CLI)" - depends=('bzip2' 'gcc-libs' 'zlib' 'fribidi' 'libass' 'lame' 'libxml2' - 'libtheora' 'libsamplerate' 'ffmpeg' 'libx264' 'x265' 'libvpx' - 'libdvdnav' 'jansson') + depends=('bzip2' 'gcc-libs' 'zlib' 'libass' 'lame' 'libxml2' 'opus' + 'libvorbis' 'libtheora' 'libsamplerate' 'x264' 'jansson') + depends+=('ffmpeg' 'libdvdnav') + optdepends=('libdvdcss: for decoding encrypted DVDs') cd "$srcdir/HandBrake-$pkgver/build" install -D HandBrakeCLI "$pkgdir/usr/bin/HandBrakeCLI" diff --git a/libre/handbrake/switch-libav-to-ffmpeg.patch b/libre/handbrake/switch-libav-to-ffmpeg.patch new file mode 100644 index 000000000..7ea2186a8 --- /dev/null +++ b/libre/handbrake/switch-libav-to-ffmpeg.patch @@ -0,0 +1,792 @@ +--- 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) + { + |