1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
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)
{
|