gnu: mpg321: Fix CVE-2019-14247.
[jackhill/guix/guix.git] / gnu / packages / patches / transcode-ffmpeg.patch
CommitLineData
ce49fdc6
RG
1Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
2Date: 2018-05-14
3Initial Package Version: 1.1.7
4Upstream Status: Defunct
5Origin: From gentoo.
6Description: Accumulated fixes to build with ffmpeg-4.0 (but only
7with the limited functionality we had before).
8
9diff -Naur a/encode/encode_lavc.c b/encode/encode_lavc.c
10--- a/encode/encode_lavc.c 2011-11-19 16:50:27.000000000 +0000
11+++ b/encode/encode_lavc.c 2018-05-14 01:58:58.346408791 +0100
12@@ -74,6 +74,16 @@
13 int lmin;
14 int lmax;
15 int me_method;
16+ int luma_elim_threshold;
17+ int chroma_elim_threshold;
18+ int quantizer_noise_shaping;
19+ int inter_quant_bias;
20+ int intra_quant_bias;
21+ int scenechange_factor;
22+ int rc_strategy;
23+ float rc_initial_cplx;
24+ float rc_qsquish;
25+ float border_masking;
26
27 /* same as above for flags */
28 struct {
29@@ -114,6 +124,7 @@
30
31 AVFrame ff_venc_frame;
32 AVCodecContext ff_vcontext;
33+ AVDictionary * ff_opts;
34
35 AVCodec *ff_vcodec;
36
37@@ -164,6 +175,7 @@
38 TC_CODEC_ERROR
39 };
40
41+#if LIBAVCODEC_VERSION_MAJOR < 55
42 static const enum CodecID tc_lavc_internal_codecs[] = {
43 CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO, CODEC_ID_MPEG4,
44 CODEC_ID_H263I, CODEC_ID_H263P,
45@@ -176,6 +188,20 @@
46 CODEC_ID_MSMPEG4V2, CODEC_ID_MSMPEG4V3,
47 CODEC_ID_NONE
48 };
49+#else
50+static const enum AVCodecID tc_lavc_internal_codecs[] = {
51+ AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG4,
52+ AV_CODEC_ID_H263I, AV_CODEC_ID_H263P,
53+ AV_CODEC_ID_H264,
54+ AV_CODEC_ID_WMV1, AV_CODEC_ID_WMV2,
55+ AV_CODEC_ID_RV10,
56+ AV_CODEC_ID_HUFFYUV, AV_CODEC_ID_FFV1,
57+ AV_CODEC_ID_DVVIDEO,
58+ AV_CODEC_ID_MJPEG, AV_CODEC_ID_LJPEG,
59+ AV_CODEC_ID_MSMPEG4V2, AV_CODEC_ID_MSMPEG4V3,
60+ AV_CODEC_ID_NONE
61+};
62+#endif
63
64 static const TCFormatID tc_lavc_formats[] = { TC_FORMAT_ERROR };
65
66@@ -214,7 +240,7 @@
67 vframe_list_t *vframe)
68 {
69 avpicture_fill((AVPicture *)&pd->ff_venc_frame, vframe->video_buf,
70- PIX_FMT_YUV420P,
71+ AV_PIX_FMT_YUV420P,
72 pd->ff_vcontext.width, pd->ff_vcontext.height);
73 }
74
75@@ -228,7 +254,7 @@
76 IMG_YUV_DEFAULT,
77 pd->ff_vcontext.width, pd->ff_vcontext.height);
78 avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
79- PIX_FMT_YUV422P,
80+ AV_PIX_FMT_YUV422P,
81 pd->ff_vcontext.width, pd->ff_vcontext.height);
82 ac_imgconvert(src, IMG_YUV_DEFAULT,
83 pd->ff_venc_frame.data, IMG_YUV422P,
84@@ -244,7 +270,7 @@
85 IMG_YUV422P,
86 pd->ff_vcontext.width, pd->ff_vcontext.height);
87 avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
88- PIX_FMT_YUV420P,
89+ AV_PIX_FMT_YUV420P,
90 pd->ff_vcontext.width, pd->ff_vcontext.height);
91 ac_imgconvert(src, IMG_YUV422P,
92 pd->ff_venc_frame.data, IMG_YUV420P,
93@@ -266,7 +292,7 @@
94 vframe_list_t *vframe)
95 {
96 avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
97- PIX_FMT_YUV420P,
98+ AV_PIX_FMT_YUV420P,
99 pd->ff_vcontext.width, pd->ff_vcontext.height);
100 ac_imgconvert(&vframe->video_buf, IMG_RGB_DEFAULT,
101 pd->ff_venc_frame.data, IMG_YUV420P,
102@@ -596,15 +622,15 @@
103 } else {
104 pd->tc_pix_fmt = TC_CODEC_YUV420P;
105 pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
106- ? PIX_FMT_YUVJ420P
107- : PIX_FMT_YUV420P;
108+ ? AV_PIX_FMT_YUVJ420P
109+ : AV_PIX_FMT_YUV420P;
110 pd->pre_encode_video = pre_encode_video_yuv420p;
111 }
112 break;
113 case CODEC_YUV422:
114 pd->tc_pix_fmt = TC_CODEC_YUV422P;
115 pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
116- ? PIX_FMT_YUVJ422P
117+ ? AV_PIX_FMT_YUVJ422P
118 : PIX_FMT_YUV422P;
119 if (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) {
120 pd->pre_encode_video = pre_encode_video_yuv422p_huffyuv;
121@@ -617,8 +643,8 @@
122 pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV)
123 ? PIX_FMT_YUV422P
124 : (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
125- ? PIX_FMT_YUVJ420P
126- : PIX_FMT_YUV420P;
127+ ? AV_PIX_FMT_YUVJ420P
128+ : AV_PIX_FMT_YUV420P;
129 pd->pre_encode_video = pre_encode_video_rgb24;
130 break;
131 default:
132@@ -665,7 +691,7 @@
133 switch (vob->divxmultipass) {
134 case 1:
135 CAN_DO_MULTIPASS(multipass_flag);
136- pd->ff_vcontext.flags |= CODEC_FLAG_PASS1;
137+ pd->ff_vcontext.flags |= AV_CODEC_FLAG_PASS1;
138 pd->stats_file = fopen(vob->divxlogfile, "w");
139 if (pd->stats_file == NULL) {
140 tc_log_error(MOD_NAME, "could not create 2pass log file"
141@@ -675,7 +701,7 @@
142 break;
143 case 2:
144 CAN_DO_MULTIPASS(multipass_flag);
145- pd->ff_vcontext.flags |= CODEC_FLAG_PASS2;
146+ pd->ff_vcontext.flags |= AV_CODEC_FLAG_PASS2;
147 pd->stats_file = fopen(vob->divxlogfile, "r");
148 if (pd->stats_file == NULL){
149 tc_log_error(MOD_NAME, "could not open 2pass log file \"%s\""
150@@ -704,7 +730,7 @@
151 break;
152 case 3:
153 /* fixed qscale :p */
154- pd->ff_vcontext.flags |= CODEC_FLAG_QSCALE;
155+ pd->ff_vcontext.flags |= AV_CODEC_FLAG_QSCALE;
156 pd->ff_venc_frame.quality = vob->divxbitrate;
157 break;
158 }
159@@ -937,7 +963,11 @@
160 static void tc_lavc_config_defaults(TCLavcPrivateData *pd)
161 {
162 /* first of all reinitialize lavc data */
163+#if LIBAVCODEC_VERSION_MAJOR < 55
164 avcodec_get_context_defaults(&pd->ff_vcontext);
165+#else
166+ avcodec_get_context_defaults3(&pd->ff_vcontext, NULL);
167+#endif
168
169 pd->confdata.thread_count = 1;
170
171@@ -947,7 +977,7 @@
172 pd->confdata.rc_buffer_size = 0;
173 pd->confdata.lmin = 2;
174 pd->confdata.lmax = 31;
175- pd->confdata.me_method = ME_EPZS;
176+ pd->confdata.me_method = 0;
177
178 memset(&pd->confdata.flags, 0, sizeof(pd->confdata.flags));
179 pd->confdata.turbo_setup = 0;
180@@ -962,12 +992,12 @@
181 pd->ff_vcontext.me_range = 0;
182 pd->ff_vcontext.mb_decision = 0;
183 pd->ff_vcontext.scenechange_threshold = 0;
184- pd->ff_vcontext.scenechange_factor = 1;
185+ pd->confdata.scenechange_factor = 1;
186 pd->ff_vcontext.b_frame_strategy = 0;
187 pd->ff_vcontext.b_sensitivity = 40;
188 pd->ff_vcontext.brd_scale = 0;
189 pd->ff_vcontext.bidir_refine = 0;
190- pd->ff_vcontext.rc_strategy = 2;
191+ pd->confdata.rc_strategy = 2;
192 pd->ff_vcontext.b_quant_factor = 1.25;
193 pd->ff_vcontext.i_quant_factor = 0.8;
194 pd->ff_vcontext.b_quant_offset = 1.25;
195@@ -975,10 +1005,10 @@
196 pd->ff_vcontext.qblur = 0.5;
197 pd->ff_vcontext.qcompress = 0.5;
198 pd->ff_vcontext.mpeg_quant = 0;
199- pd->ff_vcontext.rc_initial_cplx = 0.0;
200- pd->ff_vcontext.rc_qsquish = 1.0;
201- pd->ff_vcontext.luma_elim_threshold = 0;
202- pd->ff_vcontext.chroma_elim_threshold = 0;
203+ pd->confdata.rc_initial_cplx = 0.0;
204+ pd->confdata.rc_qsquish = 1.0;
205+ pd->confdata.luma_elim_threshold = 0;
206+ pd->confdata.chroma_elim_threshold = 0;
207 pd->ff_vcontext.strict_std_compliance = 0;
208 pd->ff_vcontext.dct_algo = FF_DCT_AUTO;
209 pd->ff_vcontext.idct_algo = FF_IDCT_AUTO;
210@@ -987,7 +1017,7 @@
211 pd->ff_vcontext.temporal_cplx_masking = 0.0;
212 pd->ff_vcontext.spatial_cplx_masking = 0.0;
213 pd->ff_vcontext.p_masking = 0.0;
214- pd->ff_vcontext.border_masking = 0.0;
215+ pd->confdata.border_masking = 0.0;
216 pd->ff_vcontext.me_pre_cmp = 0;
217 pd->ff_vcontext.me_cmp = 0;
218 pd->ff_vcontext.me_sub_cmp = 0;
219@@ -999,10 +1029,8 @@
220 pd->ff_vcontext.pre_me = 1;
221 pd->ff_vcontext.me_subpel_quality = 8;
222 pd->ff_vcontext.refs = 1;
223- pd->ff_vcontext.intra_quant_bias = FF_DEFAULT_QUANT_BIAS;
224- pd->ff_vcontext.inter_quant_bias = FF_DEFAULT_QUANT_BIAS;
225 pd->ff_vcontext.noise_reduction = 0;
226- pd->ff_vcontext.quantizer_noise_shaping = 0;
227+ pd->confdata.quantizer_noise_shaping = 0;
228 pd->ff_vcontext.flags = 0;
229 }
230
231@@ -1023,27 +1051,22 @@
232 */
233 static void tc_lavc_dispatch_settings(TCLavcPrivateData *pd)
234 {
235+ char buf[1024];
236 /* some translation... */
237 pd->ff_vcontext.bit_rate_tolerance = pd->confdata.vrate_tolerance * 1000;
238 pd->ff_vcontext.rc_min_rate = pd->confdata.rc_min_rate * 1000;
239 pd->ff_vcontext.rc_max_rate = pd->confdata.rc_max_rate * 1000;
240 pd->ff_vcontext.rc_buffer_size = pd->confdata.rc_buffer_size * 1024;
241- pd->ff_vcontext.lmin = (int)(FF_QP2LAMBDA * pd->confdata.lmin + 0.5);
242- pd->ff_vcontext.lmax = (int)(FF_QP2LAMBDA * pd->confdata.lmax + 0.5);
243- pd->ff_vcontext.me_method = ME_ZERO + pd->confdata.me_method;
244+ snprintf(buf, sizeof(buf), "%i", (int)(FF_QP2LAMBDA * pd->confdata.lmin + 0.5));
245+ av_dict_set(&(pd->ff_opts), "lmin", buf, 0);
246+ snprintf(buf, sizeof(buf), "%i", (int)(FF_QP2LAMBDA * pd->confdata.lmax + 0.5));
247+ av_dict_set(&(pd->ff_opts), "lmax", buf, 0);
248
249 pd->ff_vcontext.flags = 0;
250- SET_FLAG(pd, mv0);
251- SET_FLAG(pd, cbp);
252 SET_FLAG(pd, qpel);
253- SET_FLAG(pd, alt);
254- SET_FLAG(pd, vdpart);
255- SET_FLAG(pd, naq);
256 SET_FLAG(pd, ilme);
257 SET_FLAG(pd, ildct);
258 SET_FLAG(pd, aic);
259- SET_FLAG(pd, aiv);
260- SET_FLAG(pd, umv);
261 SET_FLAG(pd, psnr);
262 SET_FLAG(pd, trell);
263 SET_FLAG(pd, gray);
264@@ -1061,9 +1084,49 @@
265 }
266 if (pd->interlacing.active) {
267 /* enforce interlacing */
268- pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_DCT;
269- pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
270+ pd->ff_vcontext.flags |= AV_CODEC_FLAG_INTERLACED_DCT;
271+ pd->ff_vcontext.flags |= AV_CODEC_FLAG_INTERLACED_ME;
272+ }
273+ if (pd->confdata.flags.alt) {
274+ av_dict_set(&(pd->ff_opts), "alternate_scan", "1", 0);
275 }
276+ if (pd->confdata.flags.vdpart) {
277+ av_dict_set(&(pd->ff_opts), "data_partitioning", "1", 0);
278+ }
279+ if (pd->confdata.flags.umv) {
280+ av_dict_set(&(pd->ff_opts), "umv", "1", 0);
281+ }
282+ if (pd->confdata.flags.aiv) {
283+ av_dict_set(&(pd->ff_opts), "aiv", "1", 0);
284+ }
285+ if (pd->confdata.flags.cbp) {
286+ av_dict_set(&(pd->ff_opts), "mpv_flags", "+cbp_rd", 0);
287+ }
288+ if (pd->confdata.flags.mv0) {
289+ av_dict_set(&(pd->ff_opts), "mpv_flags", "+mv0", 0);
290+ }
291+ if (pd->confdata.flags.naq) {
292+ av_dict_set(&(pd->ff_opts), "mpv_flags", "+naq", 0);
293+ }
294+
295+#define set_dict_opt(val, opt) \
296+ snprintf(buf, sizeof(buf), "%i", pd->confdata.val);\
297+ av_dict_set(&(pd->ff_opts), opt, buf, 0)
298+#define set_dict_float_opt(val, opt) \
299+ snprintf(buf, sizeof(buf), "%f", pd->confdata.val);\
300+ av_dict_set(&(pd->ff_opts), opt, buf, 0)
301+
302+ set_dict_opt(luma_elim_threshold, "luma_elim_threshold");
303+ set_dict_opt(chroma_elim_threshold, "chroma_elim_threshold");
304+ set_dict_opt(quantizer_noise_shaping, "quantizer_noise_shaping");
305+ set_dict_opt(inter_quant_bias, "pbias");
306+ set_dict_opt(intra_quant_bias, "ibias");
307+ set_dict_opt(me_method, "me_method");
308+ set_dict_opt(scenechange_factor, "sc_factor");
309+ set_dict_opt(rc_strategy, "rc_strategy");
310+ set_dict_float_opt(rc_initial_cplx, "rc_init_cplx");
311+ set_dict_float_opt(rc_qsquish, "qsquish");
312+ set_dict_float_opt(border_masking, "border_mask");
313 }
314
315 #undef SET_FLAG
316@@ -1121,12 +1184,12 @@
317 { "lmin", PAUX(lmin), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.01, 255.0 },
318 { "lmax", PAUX(lmax), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.01, 255.0 },
319 { "vqdiff", PCTX(max_qdiff), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31 },
320- { "vmax_b_frames", PCTX(max_b_frames), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, FF_MAX_B_FRAMES },
321+ { "vmax_b_frames", PCTX(max_b_frames), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, INT_MAX },
322 { "vme", PAUX(me_method), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 16, },
323 { "me_range", PCTX(me_range), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 16000 },
324 { "mbd", PCTX(mb_decision), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
325 { "sc_threshold", PCTX(scenechange_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000 },
326- { "sc_factor", PCTX(scenechange_factor), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16 },
327+ { "sc_factor", PAUX(scenechange_factor), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16 },
328 { "vb_strategy", PCTX(b_frame_strategy), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
329 { "b_sensitivity", PCTX(b_sensitivity), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 100 },
330 { "brd_scale", PCTX(brd_scale), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
331@@ -1137,7 +1200,7 @@
332 { "vrc_maxrate", PAUX(rc_max_rate), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 24000000 },
333 { "vrc_minrate", PAUX(rc_min_rate), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 24000000 },
334 { "vrc_buf_size", PAUX(rc_buffer_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 4, 24000000 },
335- { "vrc_strategy", PCTX(rc_strategy), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2 },
336+ { "vrc_strategy", PAUX(rc_strategy), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2 },
337 { "vb_qfactor", PCTX(b_quant_factor), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0 },
338 { "vi_qfactor", PCTX(i_quant_factor), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0 },
339 { "vb_qoffset", PCTX(b_quant_offset), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0 },
340@@ -1147,11 +1210,11 @@
341 { "mpeg_quant", PCTX(mpeg_quant), TCCONF_TYPE_FLAG, 0, 0, 1 },
342 // { "vrc_eq", }, // not yet supported
343 { "vrc_override", rc_override_buf, TCCONF_TYPE_STRING, 0, 0, 0 },
344- { "vrc_init_cplx", PCTX(rc_initial_cplx), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 9999999.0 },
345+ { "vrc_init_cplx", PAUX(rc_initial_cplx), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 9999999.0 },
346 // { "vrc_init_occupancy", }, // not yet supported
347- { "vqsquish", PCTX(rc_qsquish), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 99.0 },
348- { "vlelim", PCTX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
349- { "vcelim", PCTX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
350+ { "vqsquish", PAUX(rc_qsquish), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 99.0 },
351+ { "vlelim", PAUX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
352+ { "vcelim", PAUX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
353 { "vstrict", PCTX(strict_std_compliance), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
354 { "vpsize", PCTX(rtp_payload_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000 },
355 { "dct", PCTX(dct_algo), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
356@@ -1161,7 +1224,7 @@
357 { "tcplx_mask", PCTX(temporal_cplx_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
358 { "scplx_mask", PCTX(spatial_cplx_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
359 { "p_mask", PCTX(p_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
360- { "border_mask", PCTX(border_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
361+ { "border_mask", PAUX(border_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
362 { "pred", PCTX(prediction_method), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 4 },
363 { "precmp", PCTX(me_pre_cmp), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
364 { "cmp", PCTX(me_cmp), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
365@@ -1174,37 +1237,37 @@
366 { "pre_me", PCTX(pre_me), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000},
367 { "subq", PCTX(me_subpel_quality), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 8 },
368 { "refs", PCTX(refs), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 8 },
369- { "ibias", PCTX(intra_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
370- { "pbias", PCTX(inter_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
371+ { "ibias", PAUX(intra_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
372+ { "pbias", PAUX(inter_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
373 { "nr", PCTX(noise_reduction), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
374- { "qns", PCTX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
375+ { "qns", PAUX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
376 { "inter_matrix_file", inter_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
377 { "intra_matrix_file", intra_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
378
379- { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
380- { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
381- { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
382- { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN },
383- { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
384- { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_DCT },
385- { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_NORMALIZE_AQP },
386- { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART },
387+ { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, 1 },
388+ { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, 1 },
389+ { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_QPEL },
390+ { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, 1 },
391+ { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_INTERLACED_ME },
392+ { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_INTERLACED_DCT },
393+ { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, 1 },
394+ { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, 1 },
395 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
396 { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC },
397 #else
398- { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED },
399+ { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_AC_PRED },
400 #endif
401- { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIV },
402- { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV },
403- { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR },
404+ { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, 1 },
405+ { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, 1 },
406+ { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_PSNR },
407 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
408 { "trell", PAUX(flags.trell), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT },
409 #else
410 { "trell", PCTX(trellis), TCCONF_TYPE_FLAG, 0, 0, 1 },
411 #endif
412- { "gray", PAUX(flags.gray), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_GRAY },
413- { "v4mv", PAUX(flags.v4mv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_4MV },
414- { "closedgop", PAUX(flags.closedgop), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CLOSED_GOP },
415+ { "gray", PAUX(flags.gray), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_GRAY },
416+ { "v4mv", PAUX(flags.v4mv), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_4MV },
417+ { "closedgop", PAUX(flags.closedgop), TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_CLOSED_GOP },
418
419 // { "turbo", PAUX(turbo_setup), TCCONF_TYPE_FLAG, 0, 0, 1 }, // not yet supported
420 /* End of the config file */
421@@ -1345,6 +1408,8 @@
422
423 pd = self->userdata;
424
425+ pd->ff_opts = NULL;
426+
427 pd->flush_flag = vob->encoder_flush;
428
429 /* FIXME: move into core? */
430@@ -1387,7 +1452,7 @@
431 pd->confdata.thread_count,
432 (pd->confdata.thread_count > 1) ?"s" :"");
433 }
434- avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
435+ pd->ff_vcontext.thread_count = pd->confdata.thread_count;
436
437 pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
438 if (pd->ff_vcodec == NULL) {
439@@ -1397,11 +1462,11 @@
440 }
441
442 TC_LOCK_LIBAVCODEC;
443- ret = avcodec_open(&pd->ff_vcontext, pd->ff_vcodec);
444+ ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, &(pd->ff_opts));
445 TC_UNLOCK_LIBAVCODEC;
446
447 if (ret < 0) {
448- tc_log_error(MOD_NAME, "avcodec_open() failed");
449+ tc_log_error(MOD_NAME, "avcodec_open2() failed");
450 goto failed;
451 }
452 /* finally, pass up the extradata, if any */
453diff -Naur a/export/aud_aux.c b/export/aud_aux.c
454--- a/export/aud_aux.c 2011-11-19 16:50:27.000000000 +0000
455+++ b/export/aud_aux.c 2018-05-14 01:58:58.346408791 +0100
456@@ -326,10 +326,18 @@
457
458 switch (o_codec) {
459 case 0x50:
460+#if LIBAVCODEC_VERSION_MAJOR < 55
461 codeid = CODEC_ID_MP2;
462+#else
463+ codeid = AV_CODEC_ID_MP2;
464+#endif
465 break;
466 case 0x2000:
467+#if LIBAVCODEC_VERSION_MAJOR < 55
468 codeid = CODEC_ID_AC3;
469+#else
470+ codeid = AV_CODEC_ID_AC3;
471+#endif
472 break;
473 default:
474 tc_warn("cannot init ffmpeg with %x", o_codec);
475@@ -346,7 +354,7 @@
476
477 //-- set parameters (bitrate, channels and sample-rate) --
478 //--------------------------------------------------------
479- avcodec_get_context_defaults(&mpa_ctx);
480+ avcodec_get_context_defaults3(&mpa_ctx, mpa_codec);
481 #if LIBAVCODEC_VERSION_MAJOR < 53
482 mpa_ctx.codec_type = CODEC_TYPE_AUDIO;
483 #else
484@@ -359,11 +367,16 @@
485 //-- open codec --
486 //----------------
487 TC_LOCK_LIBAVCODEC;
488- ret = avcodec_open(&mpa_ctx, mpa_codec);
489+ ret = avcodec_open2(&mpa_ctx, mpa_codec, NULL);
490 TC_UNLOCK_LIBAVCODEC;
491 if (ret < 0) {
492 tc_warn("tc_audio_init_ffmpeg: could not open %s codec !",
493- (codeid == CODEC_ID_MP2) ?"mpa" :"ac3");
494+#if LIBAVCODEC_VERSION_MAJOR < 55
495+ (codeid == CODEC_ID_MP2)
496+#else
497+ (codeid == AV_CODEC_ID_MP2)
498+#endif
499+ ?"mpa" :"ac3");
500 return(TC_EXPORT_ERROR);
501 }
502
503diff -Naur a/export/export_ffmpeg.c b/export/export_ffmpeg.c
504--- a/export/export_ffmpeg.c 2011-11-19 16:50:27.000000000 +0000
505+++ b/export/export_ffmpeg.c 2018-05-14 01:58:58.346408791 +0100
506@@ -122,6 +122,7 @@
507 static AVFrame *lavc_convert_frame = NULL;
508
509 static AVCodec *lavc_venc_codec = NULL;
510+static AVDictionary *lavc_venc_opts = NULL;
511 static AVFrame *lavc_venc_frame = NULL;
512 static AVCodecContext *lavc_venc_context;
513 static avi_t *avifile = NULL;
514@@ -180,7 +181,7 @@
515
516
517 /* START: COPIED FROM ffmpeg-0.5_p22846(ffmpeg.c, cmdutils.c) */
518-#include <libavcodec/opt.h>
519+#include <libavutil/opt.h>
520 #include <libavutil/avstring.h>
521 #include <libswscale/swscale.h>
522
523@@ -321,7 +322,7 @@
524 }
525
526 if(!f){
527- fprintf(stderr, "File for preset '%s' not found\n", arg);
528+ tc_log_error(MOD_NAME, "File for preset '%s' not found", arg);
529 av_exit(1);
530 }
531
532@@ -470,7 +471,6 @@
533 }
534
535 TC_LOCK_LIBAVCODEC;
536- avcodec_init();
537 avcodec_register_all();
538 TC_UNLOCK_LIBAVCODEC;
539
540@@ -486,11 +486,11 @@
541 codec->name, codec->fourCC, codec->comments);
542 }
543
544- lavc_venc_context = avcodec_alloc_context();
545+ lavc_venc_context = avcodec_alloc_context3(lavc_venc_codec);
546 lavc_venc_frame = avcodec_alloc_frame();
547
548 lavc_convert_frame= avcodec_alloc_frame();
549- size = avpicture_get_size(PIX_FMT_RGB24, vob->ex_v_width, vob->ex_v_height);
550+ size = avpicture_get_size(AV_PIX_FMT_RGB24, vob->ex_v_width, vob->ex_v_height);
551 enc_buffer = tc_malloc(size);
552
553 if (lavc_venc_context == NULL || !enc_buffer || !lavc_convert_frame) {
554@@ -634,7 +634,7 @@
555 lavc_param_rc_max_rate = 2516;
556 lavc_param_rc_buffer_size = 224 * 8;
557 lavc_param_rc_buffer_aggressivity = 99;
558- lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
559+ lavc_param_scan_offset = 1;
560
561 break;
562
563@@ -674,7 +674,7 @@
564
565 lavc_param_rc_buffer_size = 224 * 8;
566 lavc_param_rc_buffer_aggressivity = 99;
567- lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
568+ lavc_param_scan_offset = 1;
569
570 break;
571
572@@ -828,18 +828,35 @@
573
574 lavc_venc_context->bit_rate = vob->divxbitrate * 1000;
575 lavc_venc_context->bit_rate_tolerance = lavc_param_vrate_tolerance * 1000;
576- lavc_venc_context->lmin= (int)(FF_QP2LAMBDA * lavc_param_lmin + 0.5);
577- lavc_venc_context->lmax= (int)(FF_QP2LAMBDA * lavc_param_lmax + 0.5);
578 lavc_venc_context->max_qdiff = lavc_param_vqdiff;
579 lavc_venc_context->qcompress = lavc_param_vqcompress;
580 lavc_venc_context->qblur = lavc_param_vqblur;
581 lavc_venc_context->max_b_frames = lavc_param_vmax_b_frames;
582 lavc_venc_context->b_quant_factor = lavc_param_vb_qfactor;
583- lavc_venc_context->rc_strategy = lavc_param_vrc_strategy;
584 lavc_venc_context->b_frame_strategy = lavc_param_vb_strategy;
585 lavc_venc_context->b_quant_offset = lavc_param_vb_qoffset;
586- lavc_venc_context->luma_elim_threshold= lavc_param_luma_elim_threshold;
587- lavc_venc_context->chroma_elim_threshold= lavc_param_chroma_elim_threshold;
588+
589+ char buf[1024];
590+#define set_dict_opt(val, opt) \
591+ snprintf(buf, sizeof(buf), "%i", val); \
592+ av_dict_set(&lavc_venc_opts, opt, buf, 0)
593+#define set_dict_float_opt(val, opt) \
594+ snprintf(buf, sizeof(buf), "%f", val); \
595+ av_dict_set(&lavc_venc_opts, opt, buf, 0)
596+ set_dict_opt(lavc_param_luma_elim_threshold, "luma_elim_threshold");
597+ set_dict_opt(lavc_param_chroma_elim_threshold, "chroma_elim_threshold");
598+ set_dict_opt((int)(FF_QP2LAMBDA * lavc_param_lmin + 0.5), "lmin");
599+ set_dict_opt((int)(FF_QP2LAMBDA * lavc_param_lmax + 0.5), "lmax");
600+ set_dict_opt(lavc_param_vrc_strategy, "rc_strategy");
601+ set_dict_float_opt(lavc_param_rc_qsquish, "qsquish");
602+ set_dict_float_opt(lavc_param_rc_qmod_amp, "rc_qmod_amp");
603+ set_dict_opt(lavc_param_rc_qmod_freq, "rc_qmod_freq");
604+ set_dict_opt(lavc_param_rc_eq, "rc_eq");
605+ set_dict_opt(lavc_param_vme, "me_method");
606+ set_dict_opt(lavc_param_ibias, "ibias");
607+ set_dict_opt(lavc_param_pbias, "pbias");
608+ set_dict_float_opt(lavc_param_rc_buffer_aggressivity, "rc_buf_aggressivity");
609+ set_dict_float_opt(lavc_param_rc_initial_cplx, "rc_init_cplx");
610 lavc_venc_context->rtp_payload_size = lavc_param_packet_size;
611 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
612 if (lavc_param_packet_size)
613@@ -848,15 +865,9 @@
614 lavc_venc_context->strict_std_compliance= lavc_param_strict;
615 lavc_venc_context->i_quant_factor = lavc_param_vi_qfactor;
616 lavc_venc_context->i_quant_offset = lavc_param_vi_qoffset;
617- lavc_venc_context->rc_qsquish = lavc_param_rc_qsquish;
618- lavc_venc_context->rc_qmod_amp = lavc_param_rc_qmod_amp;
619- lavc_venc_context->rc_qmod_freq = lavc_param_rc_qmod_freq;
620- lavc_venc_context->rc_eq = lavc_param_rc_eq;
621 lavc_venc_context->rc_max_rate = lavc_param_rc_max_rate * 1000;
622 lavc_venc_context->rc_min_rate = lavc_param_rc_min_rate * 1000;
623 lavc_venc_context->rc_buffer_size = lavc_param_rc_buffer_size * 1024;
624- lavc_venc_context->rc_buffer_aggressivity= lavc_param_rc_buffer_aggressivity;
625- lavc_venc_context->rc_initial_cplx = lavc_param_rc_initial_cplx;
626 lavc_venc_context->debug = lavc_param_debug;
627 lavc_venc_context->last_predictor_count= lavc_param_last_pred;
628 lavc_venc_context->pre_me = lavc_param_pre_me;
629@@ -864,13 +875,11 @@
630 lavc_venc_context->pre_dia_size = lavc_param_pre_dia_size;
631 lavc_venc_context->me_subpel_quality = lavc_param_me_subpel_quality;
632 lavc_venc_context->me_range = lavc_param_me_range;
633- lavc_venc_context->intra_quant_bias = lavc_param_ibias;
634- lavc_venc_context->inter_quant_bias = lavc_param_pbias;
635 lavc_venc_context->coder_type = lavc_param_coder;
636 lavc_venc_context->context_model = lavc_param_context;
637 lavc_venc_context->scenechange_threshold= lavc_param_sc_threshold;
638 lavc_venc_context->noise_reduction = lavc_param_noise_reduction;
639- lavc_venc_context->inter_threshold = lavc_param_inter_threshold;
640+ set_dict_opt(lavc_param_inter_threshold, "inter_threshold");
641 lavc_venc_context->intra_dc_precision = lavc_param_intra_dc_precision;
642 lavc_venc_context->skip_top = lavc_param_skip_top;
643 lavc_venc_context->skip_bottom = lavc_param_skip_bottom;
644@@ -887,7 +896,7 @@
645 lavc_venc_context->thread_count);
646 }
647
648- avcodec_thread_init(lavc_venc_context, lavc_param_threads);
649+ lavc_venc_context->thread_count = lavc_param_threads;
650
651 if (lavc_param_intra_matrix) {
652 char *tmp;
653@@ -1065,15 +1074,14 @@
654 lavc_venc_context->flags |= lavc_param_closedgop;
655 lavc_venc_context->flags |= lavc_param_trunc;
656 lavc_venc_context->flags |= lavc_param_aic;
657- lavc_venc_context->flags |= lavc_param_umv;
658 lavc_venc_context->flags |= lavc_param_v4mv;
659- lavc_venc_context->flags |= lavc_param_data_partitioning;
660- lavc_venc_context->flags |= lavc_param_cbp;
661+ if(lavc_param_cbp)
662+ av_dict_set(&lavc_venc_opts, "mpv_flags", "+cbp_rd", 0);
663 lavc_venc_context->flags |= lavc_param_mv0;
664- lavc_venc_context->flags |= lavc_param_qp_rd;
665- lavc_venc_context->flags |= lavc_param_scan_offset;
666- lavc_venc_context->flags |= lavc_param_ss;
667- lavc_venc_context->flags |= lavc_param_alt;
668+ if(lavc_param_qp_rd)
669+ av_dict_set(&lavc_venc_opts, "mpv_flags", "+qp_rd", 0);
670+ if (lavc_param_normalize_aqp)
671+ av_dict_set(&lavc_venc_opts, "mpv_flags", "+naq", 0);
672 lavc_venc_context->flags |= lavc_param_ilme;
673 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
674 lavc_venc_context->flags |= lavc_param_trell;
675@@ -1082,9 +1090,7 @@
676 #endif
677
678 if (lavc_param_gray)
679- lavc_venc_context->flags |= CODEC_FLAG_GRAY;
680- if (lavc_param_normalize_aqp)
681- lavc_venc_context->flags |= CODEC_FLAG_NORMALIZE_AQP;
682+ lavc_venc_context->flags |= AV_CODEC_FLAG_GRAY;
683
684 switch(vob->encode_fields) {
685 case TC_ENCODE_FIELDS_TOP_FIRST:
686@@ -1102,9 +1108,9 @@
687 }
688
689 lavc_venc_context->flags |= interlacing_active ?
690- CODEC_FLAG_INTERLACED_DCT : 0;
691+ AV_CODEC_FLAG_INTERLACED_DCT : 0;
692 lavc_venc_context->flags |= interlacing_active ?
693- CODEC_FLAG_INTERLACED_ME : 0;
694+ AV_CODEC_FLAG_INTERLACED_ME : 0;
695
696 lavc_venc_context->flags |= lavc_param_psnr;
697 do_psnr = lavc_param_psnr;
698@@ -1112,7 +1118,7 @@
699 lavc_venc_context->prediction_method = lavc_param_prediction_method;
700
701 if(is_huffyuv)
702- lavc_venc_context->pix_fmt = PIX_FMT_YUV422P;
703+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P;
704 else
705 {
706 switch(pix_fmt)
707@@ -1121,18 +1127,18 @@
708 case CODEC_RGB:
709 {
710 if(is_mjpeg)
711- lavc_venc_context->pix_fmt = PIX_FMT_YUVJ420P;
712+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ420P;
713 else
714- lavc_venc_context->pix_fmt = PIX_FMT_YUV420P;
715+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV420P;
716 break;
717 }
718
719 case CODEC_YUV422:
720 {
721 if(is_mjpeg)
722- lavc_venc_context->pix_fmt = PIX_FMT_YUVJ422P;
723+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ422P;
724 else
725- lavc_venc_context->pix_fmt = PIX_FMT_YUV422P;
726+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P;
727 break;
728 }
729
730@@ -1151,7 +1157,7 @@
731 "encoding.");
732 return TC_EXPORT_ERROR;
733 }
734- lavc_venc_context->flags |= CODEC_FLAG_PASS1;
735+ lavc_venc_context->flags |= AV_CODEC_FLAG_PASS1;
736 stats_file = fopen(vob->divxlogfile, "w");
737 if (stats_file == NULL){
738 tc_log_warn(MOD_NAME, "Could not create 2pass log file \"%s\".",
739@@ -1165,7 +1171,7 @@
740 "encoding.");
741 return TC_EXPORT_ERROR;
742 }
743- lavc_venc_context->flags |= CODEC_FLAG_PASS2;
744+ lavc_venc_context->flags |= AV_CODEC_FLAG_PASS2;
745 stats_file= fopen(vob->divxlogfile, "r");
746 if (stats_file==NULL){
747 tc_log_warn(MOD_NAME, "Could not open 2pass log file \"%s\" for "
748@@ -1196,18 +1202,16 @@
749 break;
750 case 3:
751 /* fixed qscale :p */
752- lavc_venc_context->flags |= CODEC_FLAG_QSCALE;
753+ lavc_venc_context->flags |= AV_CODEC_FLAG_QSCALE;
754 lavc_venc_frame->quality = vob->divxbitrate;
755 break;
756 }
757
758- lavc_venc_context->me_method = ME_ZERO + lavc_param_vme;
759-
760
761 /* FIXME: transcode itself contains "broken ffmpeg default settings", thus we need to override them! */
762- if (lavc_param_video_preset) {
763+ if (lavc_param_video_preset && strcmp(lavc_param_video_preset, "none")) {
764 avcodec_opts[AVMEDIA_TYPE_VIDEO] = lavc_venc_context;
765- video_codec_name = ffmpeg_codec_name(codec->name);
766+ video_codec_name = av_strdup(ffmpeg_codec_name(codec->name));
767
768 const char *preset_start = lavc_param_video_preset;
769 while (preset_start) {
770@@ -1225,6 +1229,8 @@
771 if (opt_preset("vpre", preset_name) != 0) {
772 tc_log_warn(MOD_NAME, "Parsing ffmpeg preset '%s' failed", preset_name);
773 }
774+ av_free(video_codec_name);
775+ video_codec_name = NULL;
776 if (verbose) {
777 int i;
778 tc_log_info(MOD_NAME, "After parsing preset '%s', %i options are overridden:", preset_name, opt_name_count);
779@@ -1241,20 +1247,39 @@
780 }
781 }
782
783+ if (lavc_param_scan_offset) {
784+ av_dict_set(&lavc_venc_opts, "scan_offset", "1", 0);
785+ }
786+
787+ if (lavc_param_ss) {
788+ av_dict_set(&lavc_venc_opts, "structured_slices", "1", 0);
789+ }
790+
791+ if (lavc_param_alt) {
792+ av_dict_set(&lavc_venc_opts, "alternate_scan", "1", 0);
793+ }
794+
795+ if (lavc_param_umv) {
796+ av_dict_set(&lavc_venc_opts, "umv", "1", 0);
797+ }
798+
799+ if (lavc_param_data_partitioning) {
800+ av_dict_set(&lavc_venc_opts, "vdpart", "1", 0);
801+ }
802
803 //-- open codec --
804 //----------------
805 TC_LOCK_LIBAVCODEC;
806- ret = avcodec_open(lavc_venc_context, lavc_venc_codec);
807+ ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, &lavc_venc_opts);
808 TC_UNLOCK_LIBAVCODEC;
809 if (ret < 0) {
810 tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
811 return TC_EXPORT_ERROR;
812 }
813
814- if (lavc_venc_context->codec->encode == NULL) {
815+ if (av_codec_is_encoder(lavc_venc_context->codec) == 0) {
816 tc_log_warn(MOD_NAME, "could not open FFMPEG codec "
817- "(lavc_venc_context->codec->encode == NULL)");
818+ "(av_codec_is_encoder(lavc_venc_context->codec) == 0)");
819 return TC_EXPORT_ERROR;
820 }
821
822@@ -1598,7 +1623,7 @@
823 YUV_INIT_PLANES(src, param->buffer, IMG_YUV_DEFAULT,
824 lavc_venc_context->width, lavc_venc_context->height);
825 avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer,
826- PIX_FMT_YUV422P, lavc_venc_context->width,
827+ AV_PIX_FMT_YUV422P, lavc_venc_context->width,
828 lavc_venc_context->height);
829 /* FIXME: can't use tcv_convert (see decode_lavc.c) */
830 ac_imgconvert(src, IMG_YUV_DEFAULT,
831@@ -1628,7 +1653,7 @@
832 lavc_venc_context->width,
833 lavc_venc_context->height);
834 avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer,
835- PIX_FMT_YUV420P, lavc_venc_context->width,
836+ AV_PIX_FMT_YUV420P, lavc_venc_context->width,
837 lavc_venc_context->height);
838 ac_imgconvert(src, IMG_YUV422P,
839 lavc_venc_frame->data, IMG_YUV420P,
840@@ -1639,7 +1664,7 @@
841
842 case CODEC_RGB:
843 avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer,
844- PIX_FMT_YUV420P, lavc_venc_context->width,
845+ AV_PIX_FMT_YUV420P, lavc_venc_context->width,
846 lavc_venc_context->height);
847 ac_imgconvert(&param->buffer, IMG_RGB_DEFAULT,
848 lavc_venc_frame->data, IMG_YUV420P,
849diff -Naur a/export/ffmpeg_cfg.c b/export/ffmpeg_cfg.c
850--- a/export/ffmpeg_cfg.c 2011-11-19 16:50:27.000000000 +0000
851+++ b/export/ffmpeg_cfg.c 2018-05-14 01:58:58.346408791 +0100
852@@ -95,8 +95,8 @@
853 int lavc_param_pre_me= 1;
854 int lavc_param_me_subpel_quality= 8;
855 int lavc_param_me_range=0;
856-int lavc_param_ibias=FF_DEFAULT_QUANT_BIAS;
857-int lavc_param_pbias=FF_DEFAULT_QUANT_BIAS;
858+int lavc_param_ibias=0;
859+int lavc_param_pbias=0;
860 int lavc_param_coder=0;
861 int lavc_param_context=0;
862 char *lavc_param_intra_matrix = NULL;
863@@ -126,7 +126,7 @@
864 //int lavc_param_atag = 0;
865 //int lavc_param_abitrate = 224;
866
867-char *lavc_param_video_preset = "medium";
868+char *lavc_param_video_preset = "none";
869 char *lavc_param_ffmpeg_datadir = "/usr/share/ffmpeg";
870
871 TCConfigEntry lavcopts_conf[]={
872@@ -138,7 +138,7 @@
873 {"vratetol", &lavc_param_vrate_tolerance, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 4, 24000000},
874 {"vhq", &lavc_param_mb_decision, TCCONF_TYPE_FLAG, 0, 0, 1},
875 {"mbd", &lavc_param_mb_decision, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 9},
876- {"v4mv", &lavc_param_v4mv, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_4MV},
877+ {"v4mv", &lavc_param_v4mv, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_4MV},
878 {"vme", &lavc_param_vme, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 5},
879 // {"vqscale", &lavc_param_vqscale, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
880 // {"vqmin", &lavc_param_vqmin, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
881@@ -151,7 +151,7 @@
882 {"vqcomp", &lavc_param_vqcompress, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0},
883 {"vqblur", &lavc_param_vqblur, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0},
884 {"vb_qfactor", &lavc_param_vb_qfactor, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0},
885- {"vmax_b_frames", &lavc_param_vmax_b_frames, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, FF_MAX_B_FRAMES},
886+ {"vmax_b_frames", &lavc_param_vmax_b_frames, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, INT_MAX},
887 // {"vpass", &lavc_param_vpass, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2},
888 {"vrc_strategy", &lavc_param_vrc_strategy, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2},
889 {"vb_strategy", &lavc_param_vb_strategy, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
890@@ -160,9 +160,9 @@
891 {"vcelim", &lavc_param_chroma_elim_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
892 {"vpsize", &lavc_param_packet_size, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000},
893 {"vstrict", &lavc_param_strict, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
894- {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
895+ {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, 1},
896 // {"keyint", &lavc_param_keyint, TCCONF_TYPE_INT, 0, 0, 0},
897- {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
898+ {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_GRAY},
899 {"mpeg_quant", &lavc_param_mpeg_quant, TCCONF_TYPE_FLAG, 0, 0, 1},
900 {"vi_qfactor", &lavc_param_vi_qfactor, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0},
901 {"vi_qoffset", &lavc_param_vi_qoffset, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0},
902@@ -188,7 +188,7 @@
903 {"pred", &lavc_param_prediction_method, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 20},
904 {"format", &lavc_param_format, TCCONF_TYPE_STRING, 0, 0, 0},
905 {"debug", &lavc_param_debug, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000},
906- {"psnr", &lavc_param_psnr, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR},
907+ {"psnr", &lavc_param_psnr, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_PSNR},
908 {"precmp", &lavc_param_me_pre_cmp, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000},
909 {"cmp", &lavc_param_me_cmp, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000},
910 {"subcmp", &lavc_param_me_sub_cmp, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000},
911@@ -196,9 +196,9 @@
912 {"ildctcmp", &lavc_param_ildct_cmp, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000},
913 {"predia", &lavc_param_pre_dia_size, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -2000, 2000},
914 {"dia", &lavc_param_dia_size, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -2000, 2000},
915- {"qpel", &lavc_param_qpel, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL},
916+ {"qpel", &lavc_param_qpel, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_QPEL},
917 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
918- {"trell", &lavc_param_trell, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT},
919+ {"trell", &lavc_param_trell, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_TRELLIS_QUANT},
920 #else
921 {"trell", &lavc_param_trell, TCCONF_TYPE_FLAG, 0, 0, 1},
922 #endif
923@@ -207,32 +207,32 @@
924 {"subq", &lavc_param_me_subpel_quality, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 8},
925 {"me_range", &lavc_param_me_range, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 16000},
926 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
927- {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC},
928+ {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_H263P_AIC},
929 #else
930- {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED},
931+ {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_AC_PRED},
932 #endif
933- {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV},
934+ {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, 1},
935 {"ibias", &lavc_param_ibias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
936 {"pbias", &lavc_param_pbias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
937 {"coder", &lavc_param_coder, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
938 {"context", &lavc_param_context, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
939 {"intra_matrix", &lavc_param_intra_matrix, TCCONF_TYPE_STRING, 0, 0, 0},
940 {"inter_matrix", &lavc_param_inter_matrix, TCCONF_TYPE_STRING, 0, 0, 0},
941- {"cbp", &lavc_param_cbp, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD},
942- {"mv0", &lavc_param_mv0, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0},
943+ {"cbp", &lavc_param_cbp, TCCONF_TYPE_FLAG, 0, 0, 1},
944+ {"mv0", &lavc_param_mv0, TCCONF_TYPE_FLAG, 0, 0, 1},
945 {"nr", &lavc_param_noise_reduction, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
946- {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QP_RD},
947+ {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, 1},
948 {"threads", &lavc_param_threads, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16},
949- {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_SLICE_STRUCT},
950- {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_SVCD_SCAN_OFFSET},
951- {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN},
952- {"ilme", &lavc_param_ilme, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME},
953+ {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, 1},
954+ {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, 1},
955+ {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, 1},
956+ {"ilme", &lavc_param_ilme, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_INTERLACED_ME},
957 {"inter_threshold", &lavc_param_inter_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
958 {"sc_threshold", &lavc_param_sc_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
959 {"top", &lavc_param_top, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1, 1},
960- {"gmc", &lavc_param_gmc, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_GMC},
961- {"trunc", &lavc_param_trunc, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRUNCATED},
962- {"closedgop", &lavc_param_closedgop, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CLOSED_GOP},
963+ {"gmc", &lavc_param_gmc, TCCONF_TYPE_FLAG, 0, 0, 1},
964+ {"trunc", &lavc_param_trunc, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_TRUNCATED},
965+ {"closedgop", &lavc_param_closedgop, TCCONF_TYPE_FLAG, 0, 0, AV_CODEC_FLAG_CLOSED_GOP},
966 {"intra_dc_precision", &lavc_param_intra_dc_precision, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 16},
967 {"skip_top", &lavc_param_skip_top, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000},
968 {"skip_bottom", &lavc_param_skip_bottom, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000},
969diff -Naur a/filter/filter_pp.c b/filter/filter_pp.c
970--- a/filter/filter_pp.c 2011-11-19 16:50:27.000000000 +0000
971+++ b/filter/filter_pp.c 2018-05-14 01:58:58.347408780 +0100
972@@ -38,8 +38,8 @@
973
974 /* FIXME: these use the filter ID as an index--the ID can grow
975 * arbitrarily large, so this needs to be fixed */
976-static pp_mode_t *mode[100];
977-static pp_context_t *context[100];
978+static pp_mode *mode[100];
979+static pp_context *context[100];
980 static int width[100], height[100];
981 static int pre[100];
982
983diff -Naur a/filter/filter_resample.c b/filter/filter_resample.c
984--- a/filter/filter_resample.c 2011-11-19 16:50:27.000000000 +0000
985+++ b/filter/filter_resample.c 2018-05-14 01:58:58.347408780 +0100
986@@ -37,6 +37,7 @@
987 #include "libtc/optstr.h"
988 #include "libtc/tcavcodec.h"
989 #include "libtc/tcmodule-plugin.h"
990+#include <libavresample/avresample.h>
991
992
993 typedef struct {
994@@ -45,7 +46,7 @@
995
996 int bytes_per_sample;
997
998- ReSampleContext *resample_ctx;
999+ AVAudioResampleContext *resample_ctx;
1000 } ResamplePrivateData;
1001
1002 static const char resample_help[] = ""
1003diff -Naur a/filter/subtitler/load_font.c b/filter/subtitler/load_font.c
1004--- a/filter/subtitler/load_font.c 2011-11-19 16:50:27.000000000 +0000
1005+++ b/filter/subtitler/load_font.c 2018-05-14 01:58:58.347408780 +0100
1006@@ -47,8 +47,8 @@
1007 // FreeType specific includes
1008 #include <ft2build.h>
1009 #include FT_FREETYPE_H
1010+#include FT_GLYPH_H
1011
1012-#include <freetype/ftglyph.h>
1013
1014 /**
1015 * @file bswap.h
1016diff -Naur a/import/decode_lavc.c b/import/decode_lavc.c
1017--- a/import/decode_lavc.c 2011-11-19 16:50:27.000000000 +0000
1018+++ b/import/decode_lavc.c 2018-05-14 01:58:58.347408780 +0100
1019@@ -57,6 +57,7 @@
1020 };
1021
1022 // fourCC to ID mapping taken from MPlayer's codecs.conf
1023+#if LIBAVCODEC_VERSION_MAJOR < 55
1024 static struct ffmpeg_codec ffmpeg_codecs[] = {
1025 {CODEC_ID_MSMPEG4V1, TC_CODEC_ERROR, "mp41",
1026 {"MP41", "DIV1", ""}},
1027@@ -91,6 +92,42 @@
1028 {CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG2, "mpeg2video",
1029 {"MPG2", ""}},
1030 {0, TC_CODEC_UNKNOWN, NULL, {""}}};
1031+#else
1032+static struct ffmpeg_codec ffmpeg_codecs[] = {
1033+ {AV_CODEC_ID_MSMPEG4V1, TC_CODEC_ERROR, "mp41",
1034+ {"MP41", "DIV1", ""}},
1035+ {AV_CODEC_ID_MSMPEG4V2, TC_CODEC_MP42, "mp42",
1036+ {"MP42", "DIV2", ""}},
1037+ {AV_CODEC_ID_MSMPEG4V3, TC_CODEC_DIVX3, "msmpeg4",
1038+ {"DIV3", "DIV5", "AP41", "MPG3", "MP43", ""}},
1039+ {AV_CODEC_ID_MPEG4, TC_CODEC_DIVX4, "mpeg4",
1040+ {"DIVX", "XVID", "MP4S", "M4S2", "MP4V", "UMP4", "DX50", ""}},
1041+ {AV_CODEC_ID_MJPEG, TC_CODEC_MJPEG, "mjpeg",
1042+ {"MJPG", "AVRN", "AVDJ", "JPEG", "MJPA", "JFIF", ""}},
1043+ {AV_CODEC_ID_MPEG1VIDEO, TC_CODEC_MPEG1VIDEO, "mpeg1video",
1044+ {"MPG1", ""}},
1045+ {AV_CODEC_ID_DVVIDEO, TC_CODEC_DV, "dvvideo",
1046+ {"DVSD", ""}},
1047+ {AV_CODEC_ID_WMV1, TC_CODEC_WMV1, "wmv1",
1048+ {"WMV1", ""}},
1049+ {AV_CODEC_ID_WMV2, TC_CODEC_WMV2, "wmv2",
1050+ {"WMV2", ""}},
1051+ {AV_CODEC_ID_HUFFYUV, TC_CODEC_HUFFYUV, "hfyu",
1052+ {"HFYU", ""}},
1053+ {AV_CODEC_ID_H263I, TC_CODEC_H263I, "h263i",
1054+ {"I263", ""}},
1055+ {AV_CODEC_ID_H263P, TC_CODEC_H263P, "h263p",
1056+ {"H263", "U263", "VIV1", ""}},
1057+ {AV_CODEC_ID_RV10, TC_CODEC_RV10, "rv10",
1058+ {"RV10", "RV13", ""}},
1059+ {AV_CODEC_ID_SVQ1, TC_CODEC_SVQ1, "svq1",
1060+ {"SVQ1", ""}},
1061+ {AV_CODEC_ID_SVQ3, TC_CODEC_SVQ3, "svq3",
1062+ {"SVQ3", ""}},
1063+ {AV_CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG2, "mpeg2video",
1064+ {"MPG2", ""}},
1065+ {0, TC_CODEC_UNKNOWN, NULL, {""}}};
1066+#endif
1067
1068
1069 static struct ffmpeg_codec *find_ffmpeg_codec_id(unsigned int transcode_id)
1070@@ -170,7 +207,7 @@
1071
1072 // Set these to the expected values so that ffmpeg's decoder can
1073 // properly detect interlaced input.
1074- lavc_dec_context = avcodec_alloc_context();
1075+ lavc_dec_context = avcodec_alloc_context3(NULL);
1076 if (lavc_dec_context == NULL) {
1077 tc_log_error(__FILE__, "Could not allocate enough memory.");
1078 goto decoder_error;
1079@@ -181,12 +218,12 @@
1080 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
1081 lavc_dec_context->error_resilience = 2;
1082 #else
1083- lavc_dec_context->error_recognition = 2;
1084+ lavc_dec_context->err_recognition = 2;
1085 #endif
1086 lavc_dec_context->error_concealment = 3;
1087 lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
1088
1089- if (avcodec_open(lavc_dec_context, lavc_dec_codec) < 0) {
1090+ if (avcodec_open2(lavc_dec_context, lavc_dec_codec, NULL) < 0) {
1091 tc_log_error(__FILE__, "Could not initialize the '%s' codec.",
1092 codec->name);
1093 goto decoder_error;
1094@@ -290,8 +327,8 @@
1095
1096 // Convert avcodec image to the requested YUV or RGB format
1097 switch (lavc_dec_context->pix_fmt) {
1098- case PIX_FMT_YUVJ420P:
1099- case PIX_FMT_YUV420P:
1100+ case AV_PIX_FMT_YUVJ420P:
1101+ case AV_PIX_FMT_YUV420P:
1102 // Remove "dead space" at right edge of planes, if any
1103 if (picture.linesize[0] != lavc_dec_context->width) {
1104 int y;
1105@@ -315,7 +352,7 @@
1106 pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT,
1107 lavc_dec_context->width, lavc_dec_context->height);
1108 break;
1109- case PIX_FMT_YUV411P:
1110+ case AV_PIX_FMT_YUV411P:
1111 if (picture.linesize[0] != lavc_dec_context->width) {
1112 int y;
1113 for (y = 0; y < lavc_dec_context->height; y++) {
1114@@ -334,8 +371,8 @@
1115 pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT,
1116 lavc_dec_context->width, lavc_dec_context->height);
1117 break;
1118- case PIX_FMT_YUVJ422P:
1119- case PIX_FMT_YUV422P:
1120+ case AV_PIX_FMT_YUVJ422P:
1121+ case AV_PIX_FMT_YUV422P:
1122 if (picture.linesize[0] != lavc_dec_context->width) {
1123 int y;
1124 for (y = 0; y < lavc_dec_context->height; y++) {
1125@@ -354,8 +391,8 @@
1126 pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT,
1127 lavc_dec_context->width, lavc_dec_context->height);
1128 break;
1129- case PIX_FMT_YUVJ444P:
1130- case PIX_FMT_YUV444P:
1131+ case AV_PIX_FMT_YUVJ444P:
1132+ case AV_PIX_FMT_YUV444P:
1133 if (picture.linesize[0] != lavc_dec_context->width) {
1134 int y;
1135 for (y = 0; y < lavc_dec_context->height; y++) {
1136diff -Naur a/import/import_ffmpeg.c b/import/import_ffmpeg.c
1137--- a/import/import_ffmpeg.c 2011-11-19 16:50:27.000000000 +0000
1138+++ b/import/import_ffmpeg.c 2018-05-14 01:58:58.347408780 +0100
1139@@ -58,6 +58,7 @@
1140 };
1141
1142 // fourCC to ID mapping taken from MPlayer's codecs.conf
1143+#if LIBAVCODEC_VERSION_MAJOR < 55
1144 static struct ffmpeg_codec ffmpeg_codecs[] = {
1145 {CODEC_ID_MSMPEG4V1, TC_CODEC_ERROR, "mp41",
1146 {"MP41", "DIV1", ""}},
1147@@ -106,6 +107,56 @@
1148 {CODEC_ID_RAWVIDEO, TC_CODEC_YUV422P, "raw",
1149 {"Y42B", ""}},
1150 {0, TC_CODEC_UNKNOWN, NULL, {""}}};
1151+#else
1152+static struct ffmpeg_codec ffmpeg_codecs[] = {
1153+ {AV_CODEC_ID_MSMPEG4V1, TC_CODEC_ERROR, "mp41",
1154+ {"MP41", "DIV1", ""}},
1155+ {AV_CODEC_ID_MSMPEG4V2, TC_CODEC_MP42, "mp42",
1156+ {"MP42", "DIV2", ""}},
1157+ {AV_CODEC_ID_MSMPEG4V3, TC_CODEC_DIVX3, "msmpeg4",
1158+ {"DIV3", "DIV5", "AP41", "MPG3", "MP43", ""}},
1159+ {AV_CODEC_ID_MPEG4, TC_CODEC_DIVX4, "mpeg4",
1160+ {"DIVX", "XVID", "MP4S", "M4S2", "MP4V", "UMP4", "DX50", ""}},
1161+ {AV_CODEC_ID_MJPEG, TC_CODEC_MJPEG, "mjpeg",
1162+ {"MJPG", "AVRN", "AVDJ", "JPEG", "MJPA", "JFIF", ""}},
1163+ {AV_CODEC_ID_MPEG1VIDEO, TC_CODEC_MPG1, "mpeg1video",
1164+ {"MPG1", ""}},
1165+ {AV_CODEC_ID_DVVIDEO, TC_CODEC_DV, "dvvideo",
1166+ {"DVSD", ""}},
1167+ {AV_CODEC_ID_WMV1, TC_CODEC_WMV1, "wmv1",
1168+ {"WMV1", ""}},
1169+ {AV_CODEC_ID_WMV2, TC_CODEC_WMV2, "wmv2",
1170+ {"WMV2", ""}},
1171+ {AV_CODEC_ID_HUFFYUV, TC_CODEC_HUFFYUV, "hfyu",
1172+ {"HFYU", ""}},
1173+ {AV_CODEC_ID_H263I, TC_CODEC_H263I, "h263i",
1174+ {"I263", ""}},
1175+ {AV_CODEC_ID_H263P, TC_CODEC_H263P, "h263p",
1176+ {"H263", "U263", "VIV1", ""}},
1177+ {AV_CODEC_ID_H264, TC_CODEC_H264, "h264",
1178+ {"H264", "h264", "X264", "x264", "avc1", ""}},
1179+ {AV_CODEC_ID_RV10, TC_CODEC_RV10, "rv10",
1180+ {"RV10", "RV13", ""}},
1181+ {AV_CODEC_ID_SVQ1, TC_CODEC_SVQ1, "svq1",
1182+ {"SVQ1", ""}},
1183+ {AV_CODEC_ID_SVQ3, TC_CODEC_SVQ3, "svq3",
1184+ {"SVQ3", ""}},
1185+ {AV_CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG2, "mpeg2video",
1186+ {"MPG2", ""}},
1187+ {AV_CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG, "mpeg2video",
1188+ {"MPG2", ""}},
1189+ {AV_CODEC_ID_ASV1, TC_CODEC_ASV1, "asv1",
1190+ {"ASV1", ""}},
1191+ {AV_CODEC_ID_ASV2, TC_CODEC_ASV2, "asv2",
1192+ {"ASV2", ""}},
1193+ {AV_CODEC_ID_FFV1, TC_CODEC_FFV1, "ffv1",
1194+ {"FFV1", ""}},
1195+ {AV_CODEC_ID_RAWVIDEO, TC_CODEC_YUV420P, "raw",
1196+ {"I420", "IYUV", ""}},
1197+ {AV_CODEC_ID_RAWVIDEO, TC_CODEC_YUV422P, "raw",
1198+ {"Y42B", ""}},
1199+ {0, TC_CODEC_UNKNOWN, NULL, {""}}};
1200+#endif
1201
1202 #define BUFFER_SIZE SIZE_RGB_FRAME
1203
1204@@ -302,7 +353,7 @@
1205
1206 // Set these to the expected values so that ffmpeg's decoder can
1207 // properly detect interlaced input.
1208- lavc_dec_context = avcodec_alloc_context();
1209+ lavc_dec_context = avcodec_alloc_context3(lavc_dec_codec);
1210 if (lavc_dec_context == NULL) {
1211 tc_log_error(MOD_NAME, "Could not allocate enough memory.");
1212 return TC_IMPORT_ERROR;
1213@@ -310,11 +361,11 @@
1214 lavc_dec_context->width = x_dim;
1215 lavc_dec_context->height = y_dim;
1216
1217- if (vob->decolor) lavc_dec_context->flags |= CODEC_FLAG_GRAY;
1218+ if (vob->decolor) lavc_dec_context->flags |= AV_CODEC_FLAG_GRAY;
1219 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
1220 lavc_dec_context->error_resilience = 2;
1221 #else
1222- lavc_dec_context->error_recognition = 2;
1223+ lavc_dec_context->err_recognition = 2;
1224 #endif
1225 lavc_dec_context->error_concealment = 3;
1226 lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
1227@@ -324,6 +375,7 @@
1228 // XXX: some codecs need extra data
1229 switch (codec->id)
1230 {
1231+#if LIBAVCODEC_VERSION_MAJOR < 55
1232 case CODEC_ID_MJPEG: extra_data_size = 28; break;
1233 case CODEC_ID_LJPEG: extra_data_size = 28; break;
1234 case CODEC_ID_HUFFYUV: extra_data_size = 1000; break;
1235@@ -331,6 +383,15 @@
1236 case CODEC_ID_ASV2: extra_data_size = 8; break;
1237 case CODEC_ID_WMV1: extra_data_size = 4; break;
1238 case CODEC_ID_WMV2: extra_data_size = 4; break;
1239+#else
1240+ case AV_CODEC_ID_MJPEG: extra_data_size = 28; break;
1241+ case AV_CODEC_ID_LJPEG: extra_data_size = 28; break;
1242+ case AV_CODEC_ID_HUFFYUV: extra_data_size = 1000; break;
1243+ case AV_CODEC_ID_ASV1: extra_data_size = 8; break;
1244+ case AV_CODEC_ID_ASV2: extra_data_size = 8; break;
1245+ case AV_CODEC_ID_WMV1: extra_data_size = 4; break;
1246+ case AV_CODEC_ID_WMV2: extra_data_size = 4; break;
1247+#endif
1248 default: extra_data_size = 0; break;
1249 }
1250
1251@@ -344,7 +405,7 @@
1252 }
1253
1254 TC_LOCK_LIBAVCODEC;
1255- ret = avcodec_open(lavc_dec_context, lavc_dec_codec);
1256+ ret = avcodec_open2(lavc_dec_context, lavc_dec_codec, NULL);
1257 TC_UNLOCK_LIBAVCODEC;
1258 if (ret < 0) {
1259 tc_log_warn(MOD_NAME, "Could not initialize the '%s' codec.",
1260@@ -360,7 +421,11 @@
1261 frame_size = x_dim*y_dim + 2*UV_PLANE_SIZE(IMG_YUV_DEFAULT,x_dim,y_dim);
1262
1263 // we adapt the color space
1264+#if LIBAVCODEC_VERSION_MAJOR < 55
1265 if(codec->id == CODEC_ID_MJPEG) {
1266+#else
1267+ if(codec->id == AV_CODEC_ID_MJPEG) {
1268+#endif
1269 enable_levels_filter();
1270 }
1271 break;
1272@@ -434,7 +499,11 @@
1273 }
1274
1275 // we adapt the color space
1276+#if LIBAVCODEC_VERSION_MAJOR < 55
1277 if(codec->id == CODEC_ID_MJPEG) {
1278+#else
1279+ if(codec->id == AV_CODEC_ID_MJPEG) {
1280+#endif
1281 enable_levels_filter();
1282 }
1283
1284@@ -504,13 +573,25 @@
1285 int bkey = 0;
1286
1287 // check for keyframes
1288+#if LIBAVCODEC_VERSION_MAJOR < 55
1289 if (codec->id == CODEC_ID_MSMPEG4V3) {
1290+#else
1291+ if (codec->id == AV_CODEC_ID_MSMPEG4V3) {
1292+#endif
1293 if (divx3_is_key(buffer)) bkey = 1;
1294 }
1295+#if LIBAVCODEC_VERSION_MAJOR < 55
1296 else if (codec->id == CODEC_ID_MPEG4) {
1297+#else
1298+ else if (codec->id == AV_CODEC_ID_MPEG4) {
1299+#endif
1300 if (mpeg4_is_key(buffer, bytes_read)) bkey = 1;
1301 }
1302+#if LIBAVCODEC_VERSION_MAJOR < 55
1303 else if (codec->id == CODEC_ID_MJPEG) {
1304+#else
1305+ else if (codec->id == AV_CODEC_ID_MJPEG) {
1306+#endif
1307 bkey = 1;
1308 }
1309
1310@@ -580,8 +661,8 @@
1311
1312 // Convert avcodec image to our internal YUV or RGB format
1313 switch (lavc_dec_context->pix_fmt) {
1314- case PIX_FMT_YUVJ420P:
1315- case PIX_FMT_YUV420P:
1316+ case AV_PIX_FMT_YUVJ420P:
1317+ case AV_PIX_FMT_YUV420P:
1318 src_fmt = IMG_YUV420P;
1319 YUV_INIT_PLANES(src_planes, frame, src_fmt,
1320 lavc_dec_context->width, lavc_dec_context->height);
1321@@ -612,7 +693,7 @@
1322 }
1323 break;
1324
1325- case PIX_FMT_YUV411P:
1326+ case AV_PIX_FMT_YUV411P:
1327 src_fmt = IMG_YUV411P;
1328 YUV_INIT_PLANES(src_planes, frame, src_fmt,
1329 lavc_dec_context->width, lavc_dec_context->height);
1330@@ -640,8 +721,8 @@
1331 }
1332 break;
1333
1334- case PIX_FMT_YUVJ422P:
1335- case PIX_FMT_YUV422P:
1336+ case AV_PIX_FMT_YUVJ422P:
1337+ case AV_PIX_FMT_YUV422P:
1338 src_fmt = IMG_YUV422P;
1339 YUV_INIT_PLANES(src_planes, frame, src_fmt,
1340 lavc_dec_context->width, lavc_dec_context->height);
1341@@ -669,8 +750,8 @@
1342 }
1343 break;
1344
1345- case PIX_FMT_YUVJ444P:
1346- case PIX_FMT_YUV444P:
1347+ case AV_PIX_FMT_YUVJ444P:
1348+ case AV_PIX_FMT_YUV444P:
1349 src_fmt = IMG_YUV444P;
1350 YUV_INIT_PLANES(src_planes, frame, src_fmt,
1351 lavc_dec_context->width, lavc_dec_context->height);
1352diff -Naur a/import/probe_ffmpeg.c b/import/probe_ffmpeg.c
1353--- a/import/probe_ffmpeg.c 2011-11-19 16:50:27.000000000 +0000
1354+++ b/import/probe_ffmpeg.c 2018-05-14 01:58:58.347408780 +0100
1355@@ -51,8 +51,8 @@
1356 info->bitrate = st->codec->bit_rate / 1000;
1357 info->width = st->codec->width;
1358 info->height = st->codec->height;
1359- if (st->r_frame_rate.num > 0 && st->r_frame_rate.den > 0) {
1360- info->fps = av_q2d(st->r_frame_rate);
1361+ if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0) {
1362+ info->fps = av_q2d(st->avg_frame_rate);
1363 } else {
1364 /* watch out here */
1365 info->fps = 1.0/av_q2d(st->codec->time_base);
1366@@ -99,8 +99,8 @@
1367
1368 TC_INIT_LIBAVCODEC;
1369
1370- ret = av_open_input_file(&lavf_dmx_context, ipipe->name,
1371- NULL, 0, NULL);
1372+ ret = avformat_open_input(&lavf_dmx_context, ipipe->name,
1373+ NULL, NULL);
1374 if (ret != 0) {
1375 tc_log_error(__FILE__, "unable to open '%s'"
1376 " (libavformat failure)",
1377@@ -109,7 +109,7 @@
1378 return;
1379 }
1380
1381- ret = av_find_stream_info(lavf_dmx_context);
1382+ ret = avformat_find_stream_info(lavf_dmx_context, NULL);
1383 if (ret < 0) {
1384 tc_log_error(__FILE__, "unable to fetch informations from '%s'"
1385 " (libavformat failure)",
1386@@ -120,7 +120,11 @@
1387
1388 translate_info(lavf_dmx_context, ipipe->probe_info);
1389
1390+#if LIBAVFORMAT_VERSION_INT > AV_VERSION_INT(53,25,0)
1391+ avformat_close_input(&lavf_dmx_context);
1392+#else
1393 av_close_input_file(lavf_dmx_context);
1394+#endif
1395 return;
1396 }
1397
1398diff -Naur a/libtc/tcavcodec.h b/libtc/tcavcodec.h
1399--- a/libtc/tcavcodec.h 2011-11-19 16:50:27.000000000 +0000
1400+++ b/libtc/tcavcodec.h 2018-05-14 01:58:58.347408780 +0100
1401@@ -53,7 +53,6 @@
1402
1403 #define TC_INIT_LIBAVCODEC do { \
1404 TC_LOCK_LIBAVCODEC; \
1405- avcodec_init(); \
1406 avcodec_register_all(); \
1407 TC_UNLOCK_LIBAVCODEC; \
1408 } while (0)