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