1 Fix build with ffmpeg 0.11.
2 https://bugs.gentoo.org/show_bug.cgi?id=419551
3 Author: Brennan Shacklett
4
5 diff -urN transcode-1.1.7-orig/encode/encode_lavc.c transcode-1.1.7/encode/encode_lavc.c
6 --- transcode-1.1.7-orig/encode/encode_lavc.c 2011-11-19 08:50:27.000000000 -0800
7 +++ transcode-1.1.7/encode/encode_lavc.c 2012-07-03 10:47:03.528009149 -0700
8 @@ -114,6 +114,7 @@
9
10 AVFrame ff_venc_frame;
11 AVCodecContext ff_vcontext;
12 + AVDictionary ** ff_opts;
13
14 AVCodec *ff_vcodec;
15
16 @@ -1036,14 +1037,10 @@
17 SET_FLAG(pd, mv0);
18 SET_FLAG(pd, cbp);
19 SET_FLAG(pd, qpel);
20 - SET_FLAG(pd, alt);
21 - SET_FLAG(pd, vdpart);
22 SET_FLAG(pd, naq);
23 SET_FLAG(pd, ilme);
24 SET_FLAG(pd, ildct);
25 SET_FLAG(pd, aic);
26 - SET_FLAG(pd, aiv);
27 - SET_FLAG(pd, umv);
28 SET_FLAG(pd, psnr);
29 SET_FLAG(pd, trell);
30 SET_FLAG(pd, gray);
31 @@ -1064,6 +1061,18 @@
32 pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_DCT;
33 pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
34 }
35 + if (pd->confdata.flags.alt) {
36 + av_dict_set(pd->ff_opts, "alternate_scan", "1", 0);
37 + }
38 + if (pd->confdata.flags.vdpart) {
39 + av_dict_set(pd->ff_opts, "data_partitioning", "1", 0);
40 + }
41 + if (pd->confdata.flags.umv) {
42 + av_dict_set(pd->ff_opts, "umv", "1", 0);
43 + }
44 + if (pd->confdata.flags.aiv) {
45 + av_dict_set(pd->ff_opts, "aiv", "1", 0);
46 + }
47 }
48
49 #undef SET_FLAG
50 @@ -1184,18 +1193,18 @@
51 { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
52 { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
53 { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
54 - { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN },
55 + { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, 1 },
56 { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
57 { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_DCT },
58 { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_NORMALIZE_AQP },
59 - { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART },
60 + { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, 1 },
61 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
62 { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC },
63 #else
64 { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED },
65 #endif
66 - { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIV },
67 - { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV },
68 + { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, 1 },
69 + { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, 1 },
70 { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR },
71 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
72 { "trell", PAUX(flags.trell), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT },
73 @@ -1387,7 +1396,7 @@
74 pd->confdata.thread_count,
75 (pd->confdata.thread_count > 1) ?"s" :"");
76 }
77 - avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
78 + pd->ff_vcontext.thread_count = pd->confdata.thread_count;
79
80 pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
81 if (pd->ff_vcodec == NULL) {
82 @@ -1397,11 +1406,11 @@
83 }
84
85 TC_LOCK_LIBAVCODEC;
86 - ret = avcodec_open(&pd->ff_vcontext, pd->ff_vcodec);
87 + ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, pd->ff_opts);
88 TC_UNLOCK_LIBAVCODEC;
89
90 if (ret < 0) {
91 - tc_log_error(MOD_NAME, "avcodec_open() failed");
92 + tc_log_error(MOD_NAME, "avcodec_open2() failed");
93 goto failed;
94 }
95 /* finally, pass up the extradata, if any */
96 diff -urN transcode-1.1.7-orig/export/export_ffmpeg.c transcode-1.1.7/export/export_ffmpeg.c
97 --- transcode-1.1.7-orig/export/export_ffmpeg.c 2011-11-19 08:50:27.000000000 -0800
98 +++ transcode-1.1.7/export/export_ffmpeg.c 2012-07-03 13:15:23.918019415 -0700
99 @@ -122,6 +122,7 @@
100 static AVFrame *lavc_convert_frame = NULL;
101
102 static AVCodec *lavc_venc_codec = NULL;
103 +static AVDictionary **lavc_venc_opts = NULL;
104 static AVFrame *lavc_venc_frame = NULL;
105 static AVCodecContext *lavc_venc_context;
106 static avi_t *avifile = NULL;
107 @@ -180,7 +181,7 @@
108
109
110 /* START: COPIED FROM ffmpeg-0.5_p22846(ffmpeg.c, cmdutils.c) */
111 -#include <libavcodec/opt.h>
112 +#include <libavutil/opt.h>
113 #include <libavutil/avstring.h>
114 #include <libswscale/swscale.h>
115
116 @@ -470,7 +471,6 @@
117 }
118
119 TC_LOCK_LIBAVCODEC;
120 - avcodec_init();
121 avcodec_register_all();
122 TC_UNLOCK_LIBAVCODEC;
123
124 @@ -634,7 +634,7 @@
125 lavc_param_rc_max_rate = 2516;
126 lavc_param_rc_buffer_size = 224 * 8;
127 lavc_param_rc_buffer_aggressivity = 99;
128 - lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
129 + lavc_param_scan_offset = 1;
130
131 break;
132
133 @@ -674,7 +674,7 @@
134
135 lavc_param_rc_buffer_size = 224 * 8;
136 lavc_param_rc_buffer_aggressivity = 99;
137 - lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
138 + lavc_param_scan_offset = 1;
139
140 break;
141
142 @@ -887,7 +887,7 @@
143 lavc_venc_context->thread_count);
144 }
145
146 - avcodec_thread_init(lavc_venc_context, lavc_param_threads);
147 + lavc_venc_context->thread_count = lavc_param_threads;
148
149 if (lavc_param_intra_matrix) {
150 char *tmp;
151 @@ -1065,15 +1065,10 @@
152 lavc_venc_context->flags |= lavc_param_closedgop;
153 lavc_venc_context->flags |= lavc_param_trunc;
154 lavc_venc_context->flags |= lavc_param_aic;
155 - lavc_venc_context->flags |= lavc_param_umv;
156 lavc_venc_context->flags |= lavc_param_v4mv;
157 - lavc_venc_context->flags |= lavc_param_data_partitioning;
158 lavc_venc_context->flags |= lavc_param_cbp;
159 lavc_venc_context->flags |= lavc_param_mv0;
160 lavc_venc_context->flags |= lavc_param_qp_rd;
161 - lavc_venc_context->flags |= lavc_param_scan_offset;
162 - lavc_venc_context->flags |= lavc_param_ss;
163 - lavc_venc_context->flags |= lavc_param_alt;
164 lavc_venc_context->flags |= lavc_param_ilme;
165 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
166 lavc_venc_context->flags |= lavc_param_trell;
167 @@ -1203,7 +1198,6 @@
168
169 lavc_venc_context->me_method = ME_ZERO + lavc_param_vme;
170
171 -
172 /* FIXME: transcode itself contains "broken ffmpeg default settings", thus we need to override them! */
173 if (lavc_param_video_preset) {
174 avcodec_opts[AVMEDIA_TYPE_VIDEO] = lavc_venc_context;
175 @@ -1241,20 +1235,39 @@
176 }
177 }
178
179 + if (lavc_param_scan_offset) {
180 + av_dict_set(lavc_venc_opts, "scan_offset", "1", 0);
181 + }
182 +
183 + if (lavc_param_ss) {
184 + av_dict_set(lavc_venc_opts, "structured_slices", "1", 0);
185 + }
186 +
187 + if (lavc_param_alt) {
188 + av_dict_set(lavc_venc_opts, "alternate_scan", "1", 0);
189 + }
190 +
191 + if (lavc_param_umv) {
192 + av_dict_set(lavc_venc_opts, "umv", "1", 0);
193 + }
194 +
195 + if (lavc_param_data_partitioning) {
196 + av_dict_set(lavc_venc_opts, "vdpart", "1", 0);
197 + }
198
199 //-- open codec --
200 //----------------
201 TC_LOCK_LIBAVCODEC;
202 - ret = avcodec_open(lavc_venc_context, lavc_venc_codec);
203 + ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, lavc_venc_opts);
204 TC_UNLOCK_LIBAVCODEC;
205 if (ret < 0) {
206 tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
207 return TC_EXPORT_ERROR;
208 }
209
210 - if (lavc_venc_context->codec->encode == NULL) {
211 + if (av_codec_is_encoder(lavc_venc_context->codec) == 0) {
212 tc_log_warn(MOD_NAME, "could not open FFMPEG codec "
213 - "(lavc_venc_context->codec->encode == NULL)");
214 + "(av_codec_is_encoder(lavc_venc_context->codec) == 0)");
215 return TC_EXPORT_ERROR;
216 }
217
218 diff -urN transcode-1.1.7-orig/export/ffmpeg_cfg.c transcode-1.1.7/export/ffmpeg_cfg.c
219 --- transcode-1.1.7-orig/export/ffmpeg_cfg.c 2011-11-19 08:50:27.000000000 -0800
220 +++ transcode-1.1.7/export/ffmpeg_cfg.c 2012-07-03 10:09:25.011003254 -0700
221 @@ -160,9 +160,9 @@
222 {"vcelim", &lavc_param_chroma_elim_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
223 {"vpsize", &lavc_param_packet_size, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000},
224 {"vstrict", &lavc_param_strict, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
225 - {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
226 + {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, 1},
227 // {"keyint", &lavc_param_keyint, TCCONF_TYPE_INT, 0, 0, 0},
228 - {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
229 + {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_GRAY},
230 {"mpeg_quant", &lavc_param_mpeg_quant, TCCONF_TYPE_FLAG, 0, 0, 1},
231 {"vi_qfactor", &lavc_param_vi_qfactor, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0},
232 {"vi_qoffset", &lavc_param_vi_qoffset, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0},
233 @@ -211,7 +211,7 @@
234 #else
235 {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED},
236 #endif
237 - {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV},
238 + {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, 1},
239 {"ibias", &lavc_param_ibias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
240 {"pbias", &lavc_param_pbias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
241 {"coder", &lavc_param_coder, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
242 @@ -223,9 +223,9 @@
243 {"nr", &lavc_param_noise_reduction, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
244 {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QP_RD},
245 {"threads", &lavc_param_threads, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16},
246 - {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_SLICE_STRUCT},
247 - {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_SVCD_SCAN_OFFSET},
248 - {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN},
249 + {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, 1},
250 + {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, 1},
251 + {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, 1},
252 {"ilme", &lavc_param_ilme, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME},
253 {"inter_threshold", &lavc_param_inter_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
254 {"sc_threshold", &lavc_param_sc_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
255 diff -urN transcode-1.1.7-orig/import/decode_lavc.c transcode-1.1.7/import/decode_lavc.c
256 --- transcode-1.1.7-orig/import/decode_lavc.c 2011-11-19 08:50:27.000000000 -0800
257 +++ transcode-1.1.7/import/decode_lavc.c 2012-07-03 10:21:46.085005182 -0700
258 @@ -181,7 +181,7 @@
259 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
260 lavc_dec_context->error_resilience = 2;
261 #else
262 - lavc_dec_context->error_recognition = 2;
263 + lavc_dec_context->err_recognition = 2;
264 #endif
265 lavc_dec_context->error_concealment = 3;
266 lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
267 diff -urN transcode-1.1.7-orig/import/import_ffmpeg.c transcode-1.1.7/import/import_ffmpeg.c
268 --- transcode-1.1.7-orig/import/import_ffmpeg.c 2011-11-19 08:50:27.000000000 -0800
269 +++ transcode-1.1.7/import/import_ffmpeg.c 2012-07-03 10:19:36.936004841 -0700
270 @@ -314,7 +314,7 @@
271 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
272 lavc_dec_context->error_resilience = 2;
273 #else
274 - lavc_dec_context->error_recognition = 2;
275 + lavc_dec_context->err_recognition = 2;
276 #endif
277 lavc_dec_context->error_concealment = 3;
278 lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
279 diff -urN transcode-1.1.7-orig/import/probe_ffmpeg.c transcode-1.1.7/import/probe_ffmpeg.c
280 --- transcode-1.1.7-orig/import/probe_ffmpeg.c 2011-11-19 08:50:27.000000000 -0800
281 +++ transcode-1.1.7/import/probe_ffmpeg.c 2012-07-03 10:41:42.782008306 -0700
282 @@ -99,8 +99,8 @@
283
284 TC_INIT_LIBAVCODEC;
285
286 - ret = av_open_input_file(&lavf_dmx_context, ipipe->name,
287 - NULL, 0, NULL);
288 + ret = avformat_open_input(&lavf_dmx_context, ipipe->name,
289 + NULL, NULL);
290 if (ret != 0) {
291 tc_log_error(__FILE__, "unable to open '%s'"
292 " (libavformat failure)",
293 diff -urN transcode-1.1.7-orig/libtc/tcavcodec.h transcode-1.1.7/libtc/tcavcodec.h
294 --- transcode-1.1.7-orig/libtc/tcavcodec.h 2011-11-19 08:50:27.000000000 -0800
295 +++ transcode-1.1.7/libtc/tcavcodec.h 2012-07-03 10:34:43.648007213 -0700
296 @@ -53,7 +53,6 @@
297
298 #define TC_INIT_LIBAVCODEC do { \
299 TC_LOCK_LIBAVCODEC; \
300 - avcodec_init(); \
301 avcodec_register_all(); \
302 TC_UNLOCK_LIBAVCODEC; \
303 } while (0)
|