Line 0
Link Here
|
|
|
1 |
Index: encode/encode_lavc.c |
2 |
=================================================================== |
3 |
--- encode/encode_lavc.c.orig |
4 |
+++ encode/encode_lavc.c |
5 |
@@ -233,7 +233,7 @@ static void pre_encode_video_yuv420p(TCL |
6 |
vframe_list_t *vframe) |
7 |
{ |
8 |
avpicture_fill((AVPicture *)&pd->ff_venc_frame, vframe->video_buf, |
9 |
- PIX_FMT_YUV420P, |
10 |
+ AV_PIX_FMT_YUV420P, |
11 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
12 |
} |
13 |
|
14 |
@@ -247,7 +247,7 @@ static void pre_encode_video_yuv420p_huf |
15 |
IMG_YUV_DEFAULT, |
16 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
17 |
avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf, |
18 |
- PIX_FMT_YUV422P, |
19 |
+ AV_PIX_FMT_YUV422P, |
20 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
21 |
ac_imgconvert(src, IMG_YUV_DEFAULT, |
22 |
pd->ff_venc_frame.data, IMG_YUV422P, |
23 |
@@ -263,7 +263,7 @@ static void pre_encode_video_yuv422p(TCL |
24 |
IMG_YUV422P, |
25 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
26 |
avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf, |
27 |
- PIX_FMT_YUV420P, |
28 |
+ AV_PIX_FMT_YUV420P, |
29 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
30 |
ac_imgconvert(src, IMG_YUV422P, |
31 |
pd->ff_venc_frame.data, IMG_YUV420P, |
32 |
@@ -275,7 +275,7 @@ static void pre_encode_video_yuv422p_huf |
33 |
vframe_list_t *vframe) |
34 |
{ |
35 |
avpicture_fill((AVPicture *)&pd->ff_venc_frame, vframe->video_buf, |
36 |
- PIX_FMT_YUV422P, |
37 |
+ AV_PIX_FMT_YUV422P, |
38 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
39 |
|
40 |
} |
41 |
@@ -285,7 +285,7 @@ static void pre_encode_video_rgb24(TCLav |
42 |
vframe_list_t *vframe) |
43 |
{ |
44 |
avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf, |
45 |
- PIX_FMT_YUV420P, |
46 |
+ AV_PIX_FMT_YUV420P, |
47 |
pd->ff_vcontext.width, pd->ff_vcontext.height); |
48 |
ac_imgconvert(&vframe->video_buf, IMG_RGB_DEFAULT, |
49 |
pd->ff_venc_frame.data, IMG_YUV420P, |
50 |
@@ -610,21 +610,21 @@ static int tc_lavc_set_pix_fmt(TCLavcPri |
51 |
case CODEC_YUV: |
52 |
if (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) { |
53 |
pd->tc_pix_fmt = TC_CODEC_YUV422P; |
54 |
- pd->ff_vcontext.pix_fmt = PIX_FMT_YUV422P; |
55 |
+ pd->ff_vcontext.pix_fmt = AV_PIX_FMT_YUV422P; |
56 |
pd->pre_encode_video = pre_encode_video_yuv420p_huffyuv; |
57 |
} else { |
58 |
pd->tc_pix_fmt = TC_CODEC_YUV420P; |
59 |
pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG) |
60 |
- ? PIX_FMT_YUVJ420P |
61 |
- : PIX_FMT_YUV420P; |
62 |
+ ? AV_PIX_FMT_YUVJ420P |
63 |
+ : AV_PIX_FMT_YUV420P; |
64 |
pd->pre_encode_video = pre_encode_video_yuv420p; |
65 |
} |
66 |
break; |
67 |
case CODEC_YUV422: |
68 |
pd->tc_pix_fmt = TC_CODEC_YUV422P; |
69 |
pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG) |
70 |
- ? PIX_FMT_YUVJ422P |
71 |
- : PIX_FMT_YUV422P; |
72 |
+ ? AV_PIX_FMT_YUVJ422P |
73 |
+ : AV_PIX_FMT_YUV422P; |
74 |
if (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) { |
75 |
pd->pre_encode_video = pre_encode_video_yuv422p_huffyuv; |
76 |
} else { |
77 |
@@ -634,10 +634,10 @@ static int tc_lavc_set_pix_fmt(TCLavcPri |
78 |
case CODEC_RGB: |
79 |
pd->tc_pix_fmt = TC_CODEC_RGB; |
80 |
pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) |
81 |
- ? PIX_FMT_YUV422P |
82 |
+ ? AV_PIX_FMT_YUV422P |
83 |
: (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG) |
84 |
- ? PIX_FMT_YUVJ420P |
85 |
- : PIX_FMT_YUV420P; |
86 |
+ ? AV_PIX_FMT_YUVJ420P |
87 |
+ : AV_PIX_FMT_YUV420P; |
88 |
pd->pre_encode_video = pre_encode_video_rgb24; |
89 |
break; |
90 |
default: |
91 |
@@ -1390,7 +1390,7 @@ static int tc_lavc_configure(TCModuleIns |
92 |
/* FIXME: move into core? */ |
93 |
TC_INIT_LIBAVCODEC; |
94 |
|
95 |
- avcodec_get_frame_defaults(&pd->ff_venc_frame); |
96 |
+ av_frame_unref(&pd->ff_venc_frame); |
97 |
/* |
98 |
* auxiliary config data needs to be blanked too |
99 |
* before any other operation |
100 |
@@ -1523,6 +1523,8 @@ static int tc_lavc_encode_video(TCModule |
101 |
vframe_list_t *outframe) |
102 |
{ |
103 |
TCLavcPrivateData *pd = NULL; |
104 |
+ AVPacket pkt; |
105 |
+ int ret, got_packet = 0; |
106 |
|
107 |
TC_MODULE_SELF_CHECK(self, "encode_video"); |
108 |
|
109 |
@@ -1537,12 +1539,15 @@ static int tc_lavc_encode_video(TCModule |
110 |
|
111 |
pd->pre_encode_video(pd, inframe); |
112 |
|
113 |
+ av_init_packet(&pkt); |
114 |
+ pkt.data = outframe->video_buf; |
115 |
+ pkt.size = inframe->video_size; |
116 |
+ |
117 |
TC_LOCK_LIBAVCODEC; |
118 |
- outframe->video_len = avcodec_encode_video(&pd->ff_vcontext, |
119 |
- outframe->video_buf, |
120 |
- inframe->video_size, |
121 |
- &pd->ff_venc_frame); |
122 |
+ ret = avcodec_encode_video2(&pd->ff_vcontext, &pkt, |
123 |
+ &pd->ff_venc_frame, &got_packet); |
124 |
TC_UNLOCK_LIBAVCODEC; |
125 |
+ outframe->video_len = ret ? ret : pkt.size; |
126 |
|
127 |
if (outframe->video_len < 0) { |
128 |
tc_log_warn(MOD_NAME, "encoder error: size (%i)", |
129 |
Index: export/export_ffmpeg.c |
130 |
=================================================================== |
131 |
--- export/export_ffmpeg.c.orig |
132 |
+++ export/export_ffmpeg.c |
133 |
@@ -250,9 +250,9 @@ int opt_default(const char *opt, const c |
134 |
for(type=0; type<AVMEDIA_TYPE_NB && ret>= 0; type++){ |
135 |
/* GLUE: +if */ |
136 |
if (type == AVMEDIA_TYPE_VIDEO) { |
137 |
- const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]); |
138 |
- if(o2) |
139 |
- ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); |
140 |
+ o = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]); |
141 |
+ if(o) |
142 |
+ ret = av_opt_set(avcodec_opts[type], opt, arg, 0); |
143 |
/* GLUE: +if */ |
144 |
} |
145 |
} |
146 |
@@ -267,7 +267,10 @@ int opt_default(const char *opt, const c |
147 |
if(opt[0] == 'a') |
148 |
ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o); |
149 |
else */ if(opt[0] == 'v') |
150 |
- ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); |
151 |
+ { |
152 |
+ o = av_opt_find(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, NULL, 0, 0); |
153 |
+ ret = av_opt_set(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 0); |
154 |
+ } |
155 |
/* GLUE: disabling |
156 |
else if(opt[0] == 's') |
157 |
ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); |
158 |
@@ -487,10 +490,10 @@ MOD_init |
159 |
} |
160 |
|
161 |
lavc_venc_context = avcodec_alloc_context3(lavc_venc_codec); |
162 |
- lavc_venc_frame = avcodec_alloc_frame(); |
163 |
+ lavc_venc_frame = av_frame_alloc(); |
164 |
|
165 |
- lavc_convert_frame= avcodec_alloc_frame(); |
166 |
- size = avpicture_get_size(PIX_FMT_RGB24, vob->ex_v_width, vob->ex_v_height); |
167 |
+ lavc_convert_frame= av_frame_alloc(); |
168 |
+ size = avpicture_get_size(AV_PIX_FMT_RGB24, vob->ex_v_width, vob->ex_v_height); |
169 |
enc_buffer = tc_malloc(size); |
170 |
|
171 |
if (lavc_venc_context == NULL || !enc_buffer || !lavc_convert_frame) { |
172 |
@@ -1114,7 +1117,7 @@ MOD_init |
173 |
lavc_venc_context->prediction_method = lavc_param_prediction_method; |
174 |
|
175 |
if(is_huffyuv) |
176 |
- lavc_venc_context->pix_fmt = PIX_FMT_YUV422P; |
177 |
+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P; |
178 |
else |
179 |
{ |
180 |
switch(pix_fmt) |
181 |
@@ -1123,18 +1126,18 @@ MOD_init |
182 |
case CODEC_RGB: |
183 |
{ |
184 |
if(is_mjpeg) |
185 |
- lavc_venc_context->pix_fmt = PIX_FMT_YUVJ420P; |
186 |
+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ420P; |
187 |
else |
188 |
- lavc_venc_context->pix_fmt = PIX_FMT_YUV420P; |
189 |
+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV420P; |
190 |
break; |
191 |
} |
192 |
|
193 |
case CODEC_YUV422: |
194 |
{ |
195 |
if(is_mjpeg) |
196 |
- lavc_venc_context->pix_fmt = PIX_FMT_YUVJ422P; |
197 |
+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ422P; |
198 |
else |
199 |
- lavc_venc_context->pix_fmt = PIX_FMT_YUV422P; |
200 |
+ lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P; |
201 |
break; |
202 |
} |
203 |
|
204 |
@@ -1596,6 +1599,8 @@ MOD_encode |
205 |
|
206 |
int out_size; |
207 |
const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; |
208 |
+ AVPacket pkt; |
209 |
+ int ret, got_packet = 0; |
210 |
|
211 |
if (param->flag == TC_VIDEO) { |
212 |
|
213 |
@@ -1620,7 +1625,7 @@ MOD_encode |
214 |
YUV_INIT_PLANES(src, param->buffer, IMG_YUV_DEFAULT, |
215 |
lavc_venc_context->width, lavc_venc_context->height); |
216 |
avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer, |
217 |
- PIX_FMT_YUV422P, lavc_venc_context->width, |
218 |
+ AV_PIX_FMT_YUV422P, lavc_venc_context->width, |
219 |
lavc_venc_context->height); |
220 |
/* FIXME: can't use tcv_convert (see decode_lavc.c) */ |
221 |
ac_imgconvert(src, IMG_YUV_DEFAULT, |
222 |
@@ -1650,7 +1655,7 @@ MOD_encode |
223 |
lavc_venc_context->width, |
224 |
lavc_venc_context->height); |
225 |
avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer, |
226 |
- PIX_FMT_YUV420P, lavc_venc_context->width, |
227 |
+ AV_PIX_FMT_YUV420P, lavc_venc_context->width, |
228 |
lavc_venc_context->height); |
229 |
ac_imgconvert(src, IMG_YUV422P, |
230 |
lavc_venc_frame->data, IMG_YUV420P, |
231 |
@@ -1661,7 +1666,7 @@ MOD_encode |
232 |
|
233 |
case CODEC_RGB: |
234 |
avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer, |
235 |
- PIX_FMT_YUV420P, lavc_venc_context->width, |
236 |
+ AV_PIX_FMT_YUV420P, lavc_venc_context->width, |
237 |
lavc_venc_context->height); |
238 |
ac_imgconvert(¶m->buffer, IMG_RGB_DEFAULT, |
239 |
lavc_venc_frame->data, IMG_YUV420P, |
240 |
@@ -1674,13 +1679,17 @@ MOD_encode |
241 |
return TC_EXPORT_ERROR; |
242 |
} |
243 |
|
244 |
+ av_init_packet(&pkt); |
245 |
+ pkt.data = enc_buffer; |
246 |
+ pkt.size = size; |
247 |
|
248 |
TC_LOCK_LIBAVCODEC; |
249 |
- out_size = avcodec_encode_video(lavc_venc_context, |
250 |
- enc_buffer, size, |
251 |
- lavc_venc_frame); |
252 |
+ ret = avcodec_encode_video2(lavc_venc_context, &pkt, |
253 |
+ lavc_venc_frame, &got_packet); |
254 |
TC_UNLOCK_LIBAVCODEC; |
255 |
|
256 |
+ out_size = ret ? ret : pkt.size; |
257 |
+ |
258 |
if (out_size < 0) { |
259 |
tc_log_warn(MOD_NAME, "encoder error: size (%d)", out_size); |
260 |
return TC_EXPORT_ERROR; |
261 |
Index: import/decode_lavc.c |
262 |
=================================================================== |
263 |
--- import/decode_lavc.c.orig |
264 |
+++ import/decode_lavc.c |
265 |
@@ -327,8 +327,8 @@ void decode_lavc(decode_t *decode) |
266 |
|
267 |
// Convert avcodec image to the requested YUV or RGB format |
268 |
switch (lavc_dec_context->pix_fmt) { |
269 |
- case PIX_FMT_YUVJ420P: |
270 |
- case PIX_FMT_YUV420P: |
271 |
+ case AV_PIX_FMT_YUVJ420P: |
272 |
+ case AV_PIX_FMT_YUV420P: |
273 |
// Remove "dead space" at right edge of planes, if any |
274 |
if (picture.linesize[0] != lavc_dec_context->width) { |
275 |
int y; |
276 |
@@ -352,7 +352,7 @@ void decode_lavc(decode_t *decode) |
277 |
pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT, |
278 |
lavc_dec_context->width, lavc_dec_context->height); |
279 |
break; |
280 |
- case PIX_FMT_YUV411P: |
281 |
+ case AV_PIX_FMT_YUV411P: |
282 |
if (picture.linesize[0] != lavc_dec_context->width) { |
283 |
int y; |
284 |
for (y = 0; y < lavc_dec_context->height; y++) { |
285 |
@@ -371,8 +371,8 @@ void decode_lavc(decode_t *decode) |
286 |
pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT, |
287 |
lavc_dec_context->width, lavc_dec_context->height); |
288 |
break; |
289 |
- case PIX_FMT_YUVJ422P: |
290 |
- case PIX_FMT_YUV422P: |
291 |
+ case AV_PIX_FMT_YUVJ422P: |
292 |
+ case AV_PIX_FMT_YUV422P: |
293 |
if (picture.linesize[0] != lavc_dec_context->width) { |
294 |
int y; |
295 |
for (y = 0; y < lavc_dec_context->height; y++) { |
296 |
@@ -391,8 +391,8 @@ void decode_lavc(decode_t *decode) |
297 |
pix_fmt==TC_CODEC_YUV420P ? IMG_YUV420P : IMG_RGB_DEFAULT, |
298 |
lavc_dec_context->width, lavc_dec_context->height); |
299 |
break; |
300 |
- case PIX_FMT_YUVJ444P: |
301 |
- case PIX_FMT_YUV444P: |
302 |
+ case AV_PIX_FMT_YUVJ444P: |
303 |
+ case AV_PIX_FMT_YUV444P: |
304 |
if (picture.linesize[0] != lavc_dec_context->width) { |
305 |
int y; |
306 |
for (y = 0; y < lavc_dec_context->height; y++) { |
307 |
Index: import/import_ffmpeg.c |
308 |
=================================================================== |
309 |
--- import/import_ffmpeg.c.orig |
310 |
+++ import/import_ffmpeg.c |
311 |
@@ -661,8 +661,8 @@ retry: |
312 |
|
313 |
// Convert avcodec image to our internal YUV or RGB format |
314 |
switch (lavc_dec_context->pix_fmt) { |
315 |
- case PIX_FMT_YUVJ420P: |
316 |
- case PIX_FMT_YUV420P: |
317 |
+ case AV_PIX_FMT_YUVJ420P: |
318 |
+ case AV_PIX_FMT_YUV420P: |
319 |
src_fmt = IMG_YUV420P; |
320 |
YUV_INIT_PLANES(src_planes, frame, src_fmt, |
321 |
lavc_dec_context->width, lavc_dec_context->height); |
322 |
@@ -693,7 +693,7 @@ retry: |
323 |
} |
324 |
break; |
325 |
|
326 |
- case PIX_FMT_YUV411P: |
327 |
+ case AV_PIX_FMT_YUV411P: |
328 |
src_fmt = IMG_YUV411P; |
329 |
YUV_INIT_PLANES(src_planes, frame, src_fmt, |
330 |
lavc_dec_context->width, lavc_dec_context->height); |
331 |
@@ -721,8 +721,8 @@ retry: |
332 |
} |
333 |
break; |
334 |
|
335 |
- case PIX_FMT_YUVJ422P: |
336 |
- case PIX_FMT_YUV422P: |
337 |
+ case AV_PIX_FMT_YUVJ422P: |
338 |
+ case AV_PIX_FMT_YUV422P: |
339 |
src_fmt = IMG_YUV422P; |
340 |
YUV_INIT_PLANES(src_planes, frame, src_fmt, |
341 |
lavc_dec_context->width, lavc_dec_context->height); |
342 |
@@ -750,8 +750,8 @@ retry: |
343 |
} |
344 |
break; |
345 |
|
346 |
- case PIX_FMT_YUVJ444P: |
347 |
- case PIX_FMT_YUV444P: |
348 |
+ case AV_PIX_FMT_YUVJ444P: |
349 |
+ case AV_PIX_FMT_YUV444P: |
350 |
src_fmt = IMG_YUV444P; |
351 |
YUV_INIT_PLANES(src_planes, frame, src_fmt, |
352 |
lavc_dec_context->width, lavc_dec_context->height); |