1 Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
3 Initial Package Version: 1.1.7
4 Upstream Status: Defunct
6 Description: Accumulated fixes to build with ffmpeg-4.0 (but only
7 with the limited functionality we had before).
9 diff -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
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;
23 + float rc_initial_cplx;
25 + float border_masking;
27 /* same as above for flags */
31 AVFrame ff_venc_frame;
32 AVCodecContext ff_vcontext;
33 + AVDictionary * ff_opts;
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,
46 CODEC_ID_MSMPEG4V2, CODEC_ID_MSMPEG4V3,
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,
54 + AV_CODEC_ID_WMV1, AV_CODEC_ID_WMV2,
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,
64 static const TCFormatID tc_lavc_formats[] = { TC_FORMAT_ERROR };
67 vframe_list_t *vframe)
69 avpicture_fill((AVPicture *)&pd->ff_venc_frame, vframe->video_buf,
72 pd->ff_vcontext.width, pd->ff_vcontext.height);
77 pd->ff_vcontext.width, pd->ff_vcontext.height);
78 avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
81 pd->ff_vcontext.width, pd->ff_vcontext.height);
82 ac_imgconvert(src, IMG_YUV_DEFAULT,
83 pd->ff_venc_frame.data, IMG_YUV422P,
86 pd->ff_vcontext.width, pd->ff_vcontext.height);
87 avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
90 pd->ff_vcontext.width, pd->ff_vcontext.height);
91 ac_imgconvert(src, IMG_YUV422P,
92 pd->ff_venc_frame.data, IMG_YUV420P,
94 vframe_list_t *vframe)
96 avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
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 @@
104 pd->tc_pix_fmt = TC_CODEC_YUV420P;
105 pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
108 + ? AV_PIX_FMT_YUVJ420P
109 + : AV_PIX_FMT_YUV420P;
110 pd->pre_encode_video = pre_encode_video_yuv420p;
114 pd->tc_pix_fmt = TC_CODEC_YUV422P;
115 pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
117 + ? AV_PIX_FMT_YUVJ422P
119 if (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) {
120 pd->pre_encode_video = pre_encode_video_yuv422p_huffyuv;
122 pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV)
124 : (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
127 + ? AV_PIX_FMT_YUVJ420P
128 + : AV_PIX_FMT_YUV420P;
129 pd->pre_encode_video = pre_encode_video_rgb24;
133 switch (vob->divxmultipass) {
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"
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\""
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;
160 static void tc_lavc_config_defaults(TCLavcPrivateData *pd)
162 /* first of all reinitialize lavc data */
163 +#if LIBAVCODEC_VERSION_MAJOR < 55
164 avcodec_get_context_defaults(&pd->ff_vcontext);
166 + avcodec_get_context_defaults3(&pd->ff_vcontext, NULL);
169 pd->confdata.thread_count = 1;
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;
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;
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;
231 @@ -1023,27 +1051,22 @@
233 static void tc_lavc_dispatch_settings(TCLavcPrivateData *pd)
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);
249 pd->ff_vcontext.flags = 0;
254 - SET_FLAG(pd, vdpart);
264 @@ -1061,9 +1084,49 @@
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;
273 + if (pd->confdata.flags.alt) {
274 + av_dict_set(&(pd->ff_opts), "alternate_scan", "1", 0);
276 + if (pd->confdata.flags.vdpart) {
277 + av_dict_set(&(pd->ff_opts), "data_partitioning", "1", 0);
279 + if (pd->confdata.flags.umv) {
280 + av_dict_set(&(pd->ff_opts), "umv", "1", 0);
282 + if (pd->confdata.flags.aiv) {
283 + av_dict_set(&(pd->ff_opts), "aiv", "1", 0);
285 + if (pd->confdata.flags.cbp) {
286 + av_dict_set(&(pd->ff_opts), "mpv_flags", "+cbp_rd", 0);
288 + if (pd->confdata.flags.mv0) {
289 + av_dict_set(&(pd->ff_opts), "mpv_flags", "+mv0", 0);
291 + if (pd->confdata.flags.naq) {
292 + av_dict_set(&(pd->ff_opts), "mpv_flags", "+naq", 0);
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)
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");
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 },
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 },
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 },
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 },
410 { "trell", PCTX(trellis), TCCONF_TYPE_FLAG, 0, 0, 1 },
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 },
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 @@
425 + pd->ff_opts = NULL;
427 pd->flush_flag = vob->encoder_flush;
429 /* FIXME: move into core? */
430 @@ -1387,7 +1452,7 @@
431 pd->confdata.thread_count,
432 (pd->confdata.thread_count > 1) ?"s" :"");
434 - avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
435 + pd->ff_vcontext.thread_count = pd->confdata.thread_count;
437 pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
438 if (pd->ff_vcodec == NULL) {
439 @@ -1397,11 +1462,11 @@
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;
448 - tc_log_error(MOD_NAME, "avcodec_open() failed");
449 + tc_log_error(MOD_NAME, "avcodec_open2() failed");
452 /* finally, pass up the extradata, if any */
453 diff -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 @@
460 +#if LIBAVCODEC_VERSION_MAJOR < 55
461 codeid = CODEC_ID_MP2;
463 + codeid = AV_CODEC_ID_MP2;
467 +#if LIBAVCODEC_VERSION_MAJOR < 55
468 codeid = CODEC_ID_AC3;
470 + codeid = AV_CODEC_ID_AC3;
474 tc_warn("cannot init ffmpeg with %x", o_codec);
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;
484 @@ -359,11 +367,16 @@
488 - ret = avcodec_open(&mpa_ctx, mpa_codec);
489 + ret = avcodec_open2(&mpa_ctx, mpa_codec, NULL);
490 TC_UNLOCK_LIBAVCODEC;
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)
497 + (codeid == AV_CODEC_ID_MP2)
500 return(TC_EXPORT_ERROR);
503 diff -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
507 static AVFrame *lavc_convert_frame = NULL;
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;
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>
527 - fprintf(stderr, "File for preset '%s' not found\n", arg);
528 + tc_log_error(MOD_NAME, "File for preset '%s' not found", arg);
537 avcodec_register_all();
538 TC_UNLOCK_LIBAVCODEC;
540 @@ -486,11 +486,11 @@
541 codec->name, codec->fourCC, codec->comments);
544 - lavc_venc_context = avcodec_alloc_context();
545 + lavc_venc_context = avcodec_alloc_context3(lavc_venc_codec);
546 lavc_venc_frame = avcodec_alloc_frame();
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);
553 if (lavc_venc_context == NULL || !enc_buffer || !lavc_convert_frame) {
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;
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;
572 @@ -828,18 +828,35 @@
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;
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)
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;
645 lavc_venc_context->thread_count);
648 - avcodec_thread_init(lavc_venc_context, lavc_param_threads);
649 + lavc_venc_context->thread_count = lavc_param_threads;
651 if (lavc_param_intra_matrix) {
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;
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 @@
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;
684 switch(vob->encode_fields) {
685 case TC_ENCODE_FIELDS_TOP_FIRST:
686 @@ -1102,9 +1108,9 @@
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;
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;
702 - lavc_venc_context->pix_fmt = PIX_FMT_YUV422P;
703 + lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P;
707 @@ -1121,18 +1127,18 @@
711 - lavc_venc_context->pix_fmt = PIX_FMT_YUVJ420P;
712 + lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ420P;
714 - lavc_venc_context->pix_fmt = PIX_FMT_YUV420P;
715 + lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV420P;
722 - lavc_venc_context->pix_fmt = PIX_FMT_YUVJ422P;
723 + lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ422P;
725 - lavc_venc_context->pix_fmt = PIX_FMT_YUV422P;
726 + lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P;
730 @@ -1151,7 +1157,7 @@
732 return TC_EXPORT_ERROR;
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 @@
741 return TC_EXPORT_ERROR;
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 @@
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;
758 - lavc_venc_context->me_method = ME_ZERO + lavc_param_vme;
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));
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);
774 + av_free(video_codec_name);
775 + video_codec_name = NULL;
778 tc_log_info(MOD_NAME, "After parsing preset '%s', %i options are overridden:", preset_name, opt_name_count);
779 @@ -1241,20 +1247,39 @@
783 + if (lavc_param_scan_offset) {
784 + av_dict_set(&lavc_venc_opts, "scan_offset", "1", 0);
787 + if (lavc_param_ss) {
788 + av_dict_set(&lavc_venc_opts, "structured_slices", "1", 0);
791 + if (lavc_param_alt) {
792 + av_dict_set(&lavc_venc_opts, "alternate_scan", "1", 0);
795 + if (lavc_param_umv) {
796 + av_dict_set(&lavc_venc_opts, "umv", "1", 0);
799 + if (lavc_param_data_partitioning) {
800 + av_dict_set(&lavc_venc_opts, "vdpart", "1", 0);
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;
810 tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
811 return TC_EXPORT_ERROR;
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;
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 @@
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(¶m->buffer, IMG_RGB_DEFAULT,
848 lavc_venc_frame->data, IMG_YUV420P,
849 diff -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
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;
864 //int lavc_param_atag = 0;
865 //int lavc_param_abitrate = 224;
867 -char *lavc_param_video_preset = "medium";
868 +char *lavc_param_video_preset = "none";
869 char *lavc_param_ffmpeg_datadir = "/usr/share/ffmpeg";
871 TCConfigEntry lavcopts_conf[]={
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},
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},
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},
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},
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},
921 {"trell", &lavc_param_trell, TCCONF_TYPE_FLAG, 0, 0, 1},
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},
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},
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},
969 diff -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
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];
983 diff -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
987 #include "libtc/optstr.h"
988 #include "libtc/tcavcodec.h"
989 #include "libtc/tcmodule-plugin.h"
990 +#include <libavresample/avresample.h>
996 int bytes_per_sample;
998 - ReSampleContext *resample_ctx;
999 + AVAudioResampleContext *resample_ctx;
1000 } ResamplePrivateData;
1002 static const char resample_help[] = ""
1003 diff -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
1007 // FreeType specific includes
1008 #include <ft2build.h>
1009 #include FT_FREETYPE_H
1010 +#include FT_GLYPH_H
1012 -#include <freetype/ftglyph.h>
1016 diff -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
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", ""}},
1028 {CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG2, "mpeg2video",
1030 {0, TC_CODEC_UNKNOWN, NULL, {""}}};
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",
1045 + {AV_CODEC_ID_DVVIDEO, TC_CODEC_DV, "dvvideo",
1047 + {AV_CODEC_ID_WMV1, TC_CODEC_WMV1, "wmv1",
1049 + {AV_CODEC_ID_WMV2, TC_CODEC_WMV2, "wmv2",
1051 + {AV_CODEC_ID_HUFFYUV, TC_CODEC_HUFFYUV, "hfyu",
1053 + {AV_CODEC_ID_H263I, TC_CODEC_H263I, "h263i",
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",
1061 + {AV_CODEC_ID_SVQ3, TC_CODEC_SVQ3, "svq3",
1063 + {AV_CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG2, "mpeg2video",
1065 + {0, TC_CODEC_UNKNOWN, NULL, {""}}};
1069 static struct ffmpeg_codec *find_ffmpeg_codec_id(unsigned int transcode_id)
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.");
1079 @@ -181,12 +218,12 @@
1080 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
1081 lavc_dec_context->error_resilience = 2;
1083 - lavc_dec_context->error_recognition = 2;
1084 + lavc_dec_context->err_recognition = 2;
1086 lavc_dec_context->error_concealment = 3;
1087 lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
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.",
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) {
1106 pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT,
1107 lavc_dec_context->width, lavc_dec_context->height);
1109 - case PIX_FMT_YUV411P:
1110 + case AV_PIX_FMT_YUV411P:
1111 if (picture.linesize[0] != lavc_dec_context->width) {
1113 for (y = 0; y < lavc_dec_context->height; y++) {
1115 pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT,
1116 lavc_dec_context->width, lavc_dec_context->height);
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) {
1124 for (y = 0; y < lavc_dec_context->height; y++) {
1126 pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT,
1127 lavc_dec_context->width, lavc_dec_context->height);
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) {
1135 for (y = 0; y < lavc_dec_context->height; y++) {
1136 diff -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
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",
1150 {0, TC_CODEC_UNKNOWN, NULL, {""}}};
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",
1165 + {AV_CODEC_ID_DVVIDEO, TC_CODEC_DV, "dvvideo",
1167 + {AV_CODEC_ID_WMV1, TC_CODEC_WMV1, "wmv1",
1169 + {AV_CODEC_ID_WMV2, TC_CODEC_WMV2, "wmv2",
1171 + {AV_CODEC_ID_HUFFYUV, TC_CODEC_HUFFYUV, "hfyu",
1173 + {AV_CODEC_ID_H263I, TC_CODEC_H263I, "h263i",
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",
1183 + {AV_CODEC_ID_SVQ3, TC_CODEC_SVQ3, "svq3",
1185 + {AV_CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG2, "mpeg2video",
1187 + {AV_CODEC_ID_MPEG2VIDEO, TC_CODEC_MPEG, "mpeg2video",
1189 + {AV_CODEC_ID_ASV1, TC_CODEC_ASV1, "asv1",
1191 + {AV_CODEC_ID_ASV2, TC_CODEC_ASV2, "asv2",
1193 + {AV_CODEC_ID_FFV1, TC_CODEC_FFV1, "ffv1",
1195 + {AV_CODEC_ID_RAWVIDEO, TC_CODEC_YUV420P, "raw",
1196 + {"I420", "IYUV", ""}},
1197 + {AV_CODEC_ID_RAWVIDEO, TC_CODEC_YUV422P, "raw",
1199 + {0, TC_CODEC_UNKNOWN, NULL, {""}}};
1202 #define BUFFER_SIZE SIZE_RGB_FRAME
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;
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;
1222 - lavc_dec_context->error_recognition = 2;
1223 + lavc_dec_context->err_recognition = 2;
1225 lavc_dec_context->error_concealment = 3;
1226 lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
1228 // XXX: some codecs need extra data
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;
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;
1248 default: extra_data_size = 0; break;
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;
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);
1263 // we adapt the color space
1264 +#if LIBAVCODEC_VERSION_MAJOR < 55
1265 if(codec->id == CODEC_ID_MJPEG) {
1267 + if(codec->id == AV_CODEC_ID_MJPEG) {
1269 enable_levels_filter();
1272 @@ -434,7 +499,11 @@
1275 // we adapt the color space
1276 +#if LIBAVCODEC_VERSION_MAJOR < 55
1277 if(codec->id == CODEC_ID_MJPEG) {
1279 + if(codec->id == AV_CODEC_ID_MJPEG) {
1281 enable_levels_filter();
1284 @@ -504,13 +573,25 @@
1287 // check for keyframes
1288 +#if LIBAVCODEC_VERSION_MAJOR < 55
1289 if (codec->id == CODEC_ID_MSMPEG4V3) {
1291 + if (codec->id == AV_CODEC_ID_MSMPEG4V3) {
1293 if (divx3_is_key(buffer)) bkey = 1;
1295 +#if LIBAVCODEC_VERSION_MAJOR < 55
1296 else if (codec->id == CODEC_ID_MPEG4) {
1298 + else if (codec->id == AV_CODEC_ID_MPEG4) {
1300 if (mpeg4_is_key(buffer, bytes_read)) bkey = 1;
1302 +#if LIBAVCODEC_VERSION_MAJOR < 55
1303 else if (codec->id == CODEC_ID_MJPEG) {
1305 + else if (codec->id == AV_CODEC_ID_MJPEG) {
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);
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);
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);
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);
1352 diff -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
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);
1364 /* watch out here */
1365 info->fps = 1.0/av_q2d(st->codec->time_base);
1370 - ret = av_open_input_file(&lavf_dmx_context, ipipe->name,
1372 + ret = avformat_open_input(&lavf_dmx_context, ipipe->name,
1375 tc_log_error(__FILE__, "unable to open '%s'"
1376 " (libavformat failure)",
1381 - ret = av_find_stream_info(lavf_dmx_context);
1382 + ret = avformat_find_stream_info(lavf_dmx_context, NULL);
1384 tc_log_error(__FILE__, "unable to fetch informations from '%s'"
1385 " (libavformat failure)",
1386 @@ -120,7 +120,11 @@
1388 translate_info(lavf_dmx_context, ipipe->probe_info);
1390 +#if LIBAVFORMAT_VERSION_INT > AV_VERSION_INT(53,25,0)
1391 + avformat_close_input(&lavf_dmx_context);
1393 av_close_input_file(lavf_dmx_context);
1398 diff -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
1403 #define TC_INIT_LIBAVCODEC do { \
1404 TC_LOCK_LIBAVCODEC; \
1406 avcodec_register_all(); \
1407 TC_UNLOCK_LIBAVCODEC; \