Commit | Line | Data |
---|---|---|
26b4bb70 | 1 | /* |
115329f1 | 2 | * imlib2 based hook |
26b4bb70 | 3 | * Copyright (c) 2002 Philip Gladstone |
115329f1 | 4 | * |
26b4bb70 PG |
5 | * This module implements a text overlay for a video image. Currently it |
6 | * supports a fixed overlay or reading the text from a file. The string | |
7 | * is passed through strftime so that it is easy to imprint the date and | |
8 | * time onto the image. | |
9 | * | |
718eeb6a VP |
10 | * You may also overlay an image (even semi-transparent) like TV stations do. |
11 | * You may move either the text or the image around your video to create | |
12 | * scrolling credits, for example. | |
13 | * | |
14 | * Text fonts are being looked for in FONTPATH | |
15 | * | |
26b4bb70 PG |
16 | * Options: |
17 | * | |
6100cb47 RP |
18 | * -C <rgb.txt> The filename to read RGB color names from |
19 | * Defaults if none specified: | |
20 | * /usr/share/X11/rgb.txt | |
21 | * /usr/lib/X11/rgb.txt | |
26b4bb70 PG |
22 | * -c <color> The color of the text |
23 | * -F <fontname> The font face and size | |
24 | * -t <text> The text | |
25 | * -f <filename> The filename to read text from | |
1bebfde9 RP |
26 | * -x <expression> X coordinate of text or image |
27 | * -y <expression> Y coordinate of text or image | |
718eeb6a | 28 | * -i <filename> The filename to read a image from |
41e4c556 RP |
29 | * -R <expression> Value for R color |
30 | * -G <expression> Value for G color | |
31 | * -B <expression> Value for B color | |
26b4bb70 | 32 | * |
1bebfde9 | 33 | * Expressions are functions of: |
718eeb6a VP |
34 | * N // frame number (starting at zero) |
35 | * H // frame height | |
36 | * W // frame width | |
37 | * h // image height | |
38 | * w // image width | |
39 | * X // previous x | |
40 | * Y // previous y | |
41 | * | |
42 | ||
43 | Examples: | |
44 | ||
45 | FONTPATH="/cygdrive/c/WINDOWS/Fonts/" | |
46 | FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/" | |
47 | FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/" | |
48 | export FONTPATH | |
49 | ||
50 | ffmpeg -i input.avi -vhook \ | |
51 | 'vhook/imlib2.dll -x W*(0.5+0.25*sin(N/47*PI))-w/2 -y H*(0.5+0.50*cos(N/97*PI))-h/2 -i /usr/share/imlib2/data/images/bulb.png' | |
52 | -acodec copy -sameq output.avi | |
53 | ||
54 | ffmpeg -i input.avi -vhook \ | |
55 | 'vhook/imlib2.dll -c red -F Vera.ttf/20 -x 150+0.5*N -y 70+0.25*N -t Hello' | |
56 | -acodec copy -sameq output.avi | |
57 | ||
26b4bb70 | 58 | * This module is very much intended as an example of what could be done. |
26b4bb70 PG |
59 | * |
60 | * One caution is that this is an expensive process -- in particular the | |
61 | * conversion of the image into RGB and back is time consuming. For some | |
62 | * special cases -- e.g. painting black text -- it would be faster to paint | |
63 | * the text into a bitmap and then combine it directly into the YUV | |
115329f1 | 64 | * image. However, this code is fast enough to handle 10 fps of 320x240 on a |
26b4bb70 | 65 | * 900MHz Duron in maybe 15% of the CPU. |
718eeb6a VP |
66 | |
67 | * See further statistics on Pentium4, 3GHz, FFMpeg is SVN-r6798 | |
68 | * Input movie is 20.2 seconds of PAL DV on AVI | |
69 | * Output movie is DVD compliant VOB. | |
70 | * | |
71 | ffmpeg -i input.avi -target pal-dvd out.vob | |
72 | # 13.516s just transcode | |
73 | ffmpeg -i input.avi -vhook /usr/local/bin/vhook/null.dll -target pal-dvd out.vob | |
74 | # 23.546s transcode and img_convert | |
75 | ffmpeg -i input.avi -vhook \ | |
76 | 'vhook/imlib2.dll -c red -F Vera/20 -x 150-0.5*N -y 70+0.25*N -t Hello_person' \ | |
77 | -target pal-dvd out.vob | |
78 | # 21.454s transcode, img_convert and move text around | |
79 | ffmpeg -i input.avi -vhook \ | |
80 | 'vhook/imlib2.dll -x 150-0.5*N -y 70+0.25*N -i /usr/share/imlib2/data/images/bulb.png' \ | |
81 | -target pal-dvd out.vob | |
82 | # 20.828s transcode, img_convert and move image around | |
26b4bb70 | 83 | * |
b78e7197 DB |
84 | * This file is part of FFmpeg. |
85 | * | |
86 | * FFmpeg is free software; you can redistribute it and/or | |
26b4bb70 PG |
87 | * modify it under the terms of the GNU Lesser General Public |
88 | * License as published by the Free Software Foundation; either | |
b78e7197 | 89 | * version 2.1 of the License, or (at your option) any later version. |
26b4bb70 | 90 | * |
b78e7197 | 91 | * FFmpeg is distributed in the hope that it will be useful, |
26b4bb70 PG |
92 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
93 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
94 | * Lesser General Public License for more details. | |
95 | * | |
96 | * You should have received a copy of the GNU Lesser General Public | |
b78e7197 | 97 | * License along with FFmpeg; if not, write to the Free Software |
5509bffa | 98 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
26b4bb70 | 99 | */ |
00a3c8b8 AB |
100 | |
101 | #include "framehook.h" | |
67d0436c | 102 | #include "swscale.h" |
00a3c8b8 | 103 | |
26b4bb70 PG |
104 | #include <stdio.h> |
105 | #include <stdlib.h> | |
106 | #include <fcntl.h> | |
26b4bb70 PG |
107 | #include <stdarg.h> |
108 | #include <string.h> | |
109 | #include <unistd.h> | |
00a3c8b8 | 110 | #undef time |
26b4bb70 | 111 | #include <sys/time.h> |
00a3c8b8 | 112 | #include <time.h> |
115329f1 | 113 | #include <Imlib2.h> |
718eeb6a VP |
114 | #include "eval.h" |
115 | ||
116 | const char *const_names[]={ | |
117 | "PI", | |
118 | "E", | |
119 | "N", // frame number (starting at zero) | |
120 | "H", // frame height | |
121 | "W", // frame width | |
122 | "h", // image height | |
123 | "w", // image width | |
124 | "X", // previous x | |
125 | "Y", // previous y | |
126 | NULL | |
127 | }; | |
26b4bb70 | 128 | |
67d0436c VP |
129 | static int sws_flags = SWS_BICUBIC; |
130 | ||
26b4bb70 PG |
131 | typedef struct { |
132 | int dummy; | |
133 | Imlib_Font fn; | |
134 | char *text; | |
135 | char *file; | |
136 | int r, g, b; | |
41e4c556 RP |
137 | AVEvalExpr *eval_r, *eval_g, *eval_b; |
138 | char *expr_R, *expr_G, *expr_B; | |
139 | int eval_colors; | |
718eeb6a VP |
140 | double x, y; |
141 | char *fileImage; | |
26b4bb70 | 142 | struct _CachedImage *cache; |
718eeb6a VP |
143 | Imlib_Image imageOverlaid; |
144 | AVEvalExpr *eval_x, *eval_y; | |
145 | char *expr_x, *expr_y; | |
146 | int frame_number; | |
147 | int imageOverlaid_width, imageOverlaid_height; | |
67d0436c VP |
148 | |
149 | // This vhook first converts frame to RGB ... | |
150 | struct SwsContext *toRGB_convert_ctx; | |
151 | // ... and then converts back frame from RGB to initial format | |
152 | struct SwsContext *fromRGB_convert_ctx; | |
26b4bb70 PG |
153 | } ContextInfo; |
154 | ||
155 | typedef struct _CachedImage { | |
156 | struct _CachedImage *next; | |
157 | Imlib_Image image; | |
158 | int width; | |
159 | int height; | |
160 | } CachedImage; | |
161 | ||
6c11d48c PG |
162 | void Release(void *ctx) |
163 | { | |
164 | ContextInfo *ci; | |
165 | ci = (ContextInfo *) ctx; | |
166 | ||
167 | if (ci->cache) { | |
168 | imlib_context_set_image(ci->cache->image); | |
169 | imlib_free_image(); | |
170 | av_free(ci->cache); | |
171 | } | |
67d0436c | 172 | if (ctx) { |
718eeb6a VP |
173 | if (ci->imageOverlaid) { |
174 | imlib_context_set_image(ci->imageOverlaid); | |
175 | imlib_free_image(); | |
176 | } | |
4d321bff LW |
177 | ff_eval_free(ci->eval_x); |
178 | ff_eval_free(ci->eval_y); | |
179 | ff_eval_free(ci->eval_r); | |
180 | ff_eval_free(ci->eval_g); | |
181 | ff_eval_free(ci->eval_b); | |
182 | ||
183 | av_free(ci->expr_x); | |
184 | av_free(ci->expr_y); | |
185 | av_free(ci->expr_R); | |
186 | av_free(ci->expr_G); | |
187 | av_free(ci->expr_B); | |
67d0436c VP |
188 | sws_freeContext(ci->toRGB_convert_ctx); |
189 | sws_freeContext(ci->fromRGB_convert_ctx); | |
6c11d48c | 190 | av_free(ctx); |
67d0436c | 191 | } |
6c11d48c | 192 | } |
26b4bb70 PG |
193 | |
194 | int Configure(void **ctxp, int argc, char *argv[]) | |
195 | { | |
196 | int c; | |
197 | ContextInfo *ci; | |
6100cb47 | 198 | char *rgbtxt = 0; |
26b4bb70 PG |
199 | char *font = "LucidaSansDemiBold/16"; |
200 | char *fp = getenv("FONTPATH"); | |
201 | char *color = 0; | |
202 | FILE *f; | |
718eeb6a | 203 | char *p; |
26b4bb70 PG |
204 | |
205 | *ctxp = av_mallocz(sizeof(ContextInfo)); | |
206 | ci = (ContextInfo *) *ctxp; | |
207 | ||
718eeb6a VP |
208 | ci->x = 0.0; |
209 | ci->y = 0.0; | |
210 | ci->expr_x = "0.0"; | |
211 | ci->expr_y = "0.0"; | |
212 | ||
26b4bb70 PG |
213 | optind = 0; |
214 | ||
718eeb6a | 215 | /* Use ':' to split FONTPATH */ |
26b4bb70 | 216 | if (fp) |
718eeb6a VP |
217 | while (p = strchr(fp, ':')) { |
218 | *p = 0; | |
219 | imlib_add_path_to_font_path(fp); | |
220 | fp = p + 1; | |
221 | } | |
222 | if ((fp) && (*fp)) | |
26b4bb70 PG |
223 | imlib_add_path_to_font_path(fp); |
224 | ||
718eeb6a | 225 | |
41e4c556 | 226 | while ((c = getopt(argc, argv, "R:G:B:C:c:f:F:t:x:y:i:")) > 0) { |
26b4bb70 | 227 | switch (c) { |
41e4c556 RP |
228 | case 'R': |
229 | ci->expr_R = av_strdup(optarg); | |
230 | ci->eval_colors = 1; | |
231 | break; | |
232 | case 'G': | |
233 | ci->expr_G = av_strdup(optarg); | |
234 | ci->eval_colors = 1; | |
235 | break; | |
236 | case 'B': | |
237 | ci->expr_B = av_strdup(optarg); | |
238 | ci->eval_colors = 1; | |
239 | break; | |
6100cb47 RP |
240 | case 'C': |
241 | rgbtxt = optarg; | |
242 | break; | |
26b4bb70 PG |
243 | case 'c': |
244 | color = optarg; | |
245 | break; | |
246 | case 'F': | |
247 | font = optarg; | |
248 | break; | |
249 | case 't': | |
e9a9e0c2 | 250 | ci->text = av_strdup(optarg); |
26b4bb70 PG |
251 | break; |
252 | case 'f': | |
e9a9e0c2 | 253 | ci->file = av_strdup(optarg); |
26b4bb70 PG |
254 | break; |
255 | case 'x': | |
718eeb6a | 256 | ci->expr_x = av_strdup(optarg); |
26b4bb70 PG |
257 | break; |
258 | case 'y': | |
718eeb6a VP |
259 | ci->expr_y = av_strdup(optarg); |
260 | break; | |
261 | case 'i': | |
262 | ci->fileImage = av_strdup(optarg); | |
26b4bb70 PG |
263 | break; |
264 | case '?': | |
265 | fprintf(stderr, "Unrecognized argument '%s'\n", argv[optind]); | |
266 | return -1; | |
267 | } | |
268 | } | |
269 | ||
41e4c556 RP |
270 | if (ci->eval_colors && !(ci->expr_R && ci->expr_G && ci->expr_B)) |
271 | { | |
272 | fprintf(stderr, "You must specify expressions for all or no colors.\n"); | |
273 | return -1; | |
274 | } | |
275 | ||
718eeb6a | 276 | if (ci->text || ci->file) { |
ef4c82cb RP |
277 | ci->fn = imlib_load_font(font); |
278 | if (!ci->fn) { | |
279 | fprintf(stderr, "Failed to load font '%s'\n", font); | |
280 | return -1; | |
281 | } | |
282 | imlib_context_set_font(ci->fn); | |
283 | imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT); | |
718eeb6a | 284 | } |
26b4bb70 PG |
285 | |
286 | if (color) { | |
287 | char buff[256]; | |
288 | int done = 0; | |
289 | ||
41e4c556 RP |
290 | if (ci->eval_colors) |
291 | { | |
292 | fprintf(stderr, "You must not specify both a color name and expressions for the colors.\n"); | |
293 | return -1; | |
294 | } | |
295 | ||
6100cb47 RP |
296 | if (rgbtxt) |
297 | f = fopen(rgbtxt, "r"); | |
298 | else | |
299 | { | |
a661ade7 RP |
300 | f = fopen("/usr/share/X11/rgb.txt", "r"); |
301 | if (!f) | |
302 | f = fopen("/usr/lib/X11/rgb.txt", "r"); | |
6100cb47 | 303 | } |
26b4bb70 | 304 | if (!f) { |
6100cb47 | 305 | fprintf(stderr, "Failed to find RGB color names file\n"); |
26b4bb70 PG |
306 | return -1; |
307 | } | |
308 | while (fgets(buff, sizeof(buff), f)) { | |
309 | int r, g, b; | |
310 | char colname[80]; | |
311 | ||
312 | if (sscanf(buff, "%d %d %d %64s", &r, &g, &b, colname) == 4 && | |
313 | strcasecmp(colname, color) == 0) { | |
314 | ci->r = r; | |
315 | ci->g = g; | |
316 | ci->b = b; | |
317 | /* fprintf(stderr, "%s -> %d,%d,%d\n", colname, r, g, b); */ | |
318 | done = 1; | |
319 | break; | |
320 | } | |
321 | } | |
322 | fclose(f); | |
323 | if (!done) { | |
324 | fprintf(stderr, "Unable to find color '%s' in rgb.txt\n", color); | |
325 | return -1; | |
326 | } | |
41e4c556 RP |
327 | } else if (ci->eval_colors) { |
328 | if (!(ci->eval_r = ff_parse(ci->expr_R, const_names, NULL, NULL, NULL, NULL, NULL))){ | |
329 | av_log(NULL, AV_LOG_ERROR, "Couldn't parse R expression '%s'\n", ci->expr_R); | |
330 | return -1; | |
331 | } | |
332 | if (!(ci->eval_g = ff_parse(ci->expr_G, const_names, NULL, NULL, NULL, NULL, NULL))){ | |
333 | av_log(NULL, AV_LOG_ERROR, "Couldn't parse G expression '%s'\n", ci->expr_G); | |
334 | return -1; | |
335 | } | |
336 | if (!(ci->eval_b = ff_parse(ci->expr_B, const_names, NULL, NULL, NULL, NULL, NULL))){ | |
337 | av_log(NULL, AV_LOG_ERROR, "Couldn't parse B expression '%s'\n", ci->expr_B); | |
338 | return -1; | |
339 | } | |
26b4bb70 | 340 | } |
41e4c556 RP |
341 | |
342 | if (!ci->eval_colors) | |
ef4c82cb | 343 | imlib_context_set_color(ci->r, ci->g, ci->b, 255); |
718eeb6a VP |
344 | |
345 | /* load the image (for example, credits for a movie) */ | |
346 | if (ci->fileImage) { | |
347 | ci->imageOverlaid = imlib_load_image_immediately(ci->fileImage); | |
348 | if (!(ci->imageOverlaid)){ | |
349 | av_log(NULL, AV_LOG_ERROR, "Couldn't load image '%s'\n", ci->fileImage); | |
350 | return -1; | |
351 | } | |
352 | imlib_context_set_image(ci->imageOverlaid); | |
353 | ci->imageOverlaid_width = imlib_image_get_width(); | |
354 | ci->imageOverlaid_height = imlib_image_get_height(); | |
355 | } | |
356 | ||
357 | if (!(ci->eval_x = ff_parse(ci->expr_x, const_names, NULL, NULL, NULL, NULL, NULL))){ | |
358 | av_log(NULL, AV_LOG_ERROR, "Couldn't parse x expression '%s'\n", ci->expr_x); | |
359 | return -1; | |
360 | } | |
361 | ||
362 | if (!(ci->eval_y = ff_parse(ci->expr_y, const_names, NULL, NULL, NULL, NULL, NULL))){ | |
363 | av_log(NULL, AV_LOG_ERROR, "Couldn't parse y expression '%s'\n", ci->expr_y); | |
364 | return -1; | |
365 | } | |
366 | ||
26b4bb70 PG |
367 | return 0; |
368 | } | |
369 | ||
370 | static Imlib_Image get_cached_image(ContextInfo *ci, int width, int height) | |
371 | { | |
372 | CachedImage *cache; | |
373 | ||
374 | for (cache = ci->cache; cache; cache = cache->next) { | |
375 | if (width == cache->width && height == cache->height) | |
376 | return cache->image; | |
377 | } | |
378 | ||
379 | return NULL; | |
380 | } | |
381 | ||
382 | static void put_cached_image(ContextInfo *ci, Imlib_Image image, int width, int height) | |
383 | { | |
384 | CachedImage *cache = av_mallocz(sizeof(*cache)); | |
385 | ||
386 | cache->image = image; | |
387 | cache->width = width; | |
388 | cache->height = height; | |
389 | cache->next = ci->cache; | |
390 | ci->cache = cache; | |
391 | } | |
392 | ||
0c1a9eda | 393 | void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts) |
26b4bb70 PG |
394 | { |
395 | ContextInfo *ci = (ContextInfo *) ctx; | |
396 | AVPicture picture1; | |
397 | Imlib_Image image; | |
398 | DATA32 *data; | |
399 | ||
400 | image = get_cached_image(ci, width, height); | |
401 | ||
402 | if (!image) { | |
403 | image = imlib_create_image(width, height); | |
404 | put_cached_image(ci, image, width, height); | |
405 | } | |
406 | ||
407 | imlib_context_set_image(image); | |
408 | data = imlib_image_get_data(); | |
409 | ||
ef4c82cb | 410 | avpicture_fill(&picture1, (uint8_t *) data, PIX_FMT_RGB32, width, height); |
67d0436c VP |
411 | |
412 | // if we already got a SWS context, let's realloc if is not re-useable | |
413 | ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx, | |
414 | width, height, pix_fmt, | |
71e445fc | 415 | width, height, PIX_FMT_RGB32, |
67d0436c VP |
416 | sws_flags, NULL, NULL, NULL); |
417 | if (ci->toRGB_convert_ctx == NULL) { | |
418 | av_log(NULL, AV_LOG_ERROR, | |
419 | "Cannot initialize the toRGB conversion context\n"); | |
ca345e44 | 420 | return; |
26b4bb70 PG |
421 | } |
422 | ||
67d0436c VP |
423 | // img_convert parameters are 2 first destination, then 4 source |
424 | // sws_scale parameters are context, 4 first source, then 2 destination | |
425 | sws_scale(ci->toRGB_convert_ctx, | |
426 | picture->data, picture->linesize, 0, height, | |
427 | picture1.data, picture1.linesize); | |
428 | ||
26b4bb70 PG |
429 | imlib_image_set_has_alpha(0); |
430 | ||
431 | { | |
115329f1 | 432 | int wid, hig, h_a, v_a; |
26b4bb70 PG |
433 | char buff[1000]; |
434 | char tbuff[1000]; | |
435 | char *tbp = ci->text; | |
436 | time_t now = time(0); | |
437 | char *p, *q; | |
718eeb6a VP |
438 | int y; |
439 | ||
440 | double const_values[]={ | |
441 | M_PI, | |
442 | M_E, | |
443 | ci->frame_number, // frame number (starting at zero) | |
444 | height, // frame height | |
445 | width, // frame width | |
446 | ci->imageOverlaid_height, // image height | |
447 | ci->imageOverlaid_width, // image width | |
448 | ci->x, // previous x | |
449 | ci->y, // previous y | |
450 | 0 | |
451 | }; | |
26b4bb70 PG |
452 | |
453 | if (ci->file) { | |
454 | int fd = open(ci->file, O_RDONLY); | |
455 | ||
456 | if (fd < 0) { | |
457 | tbp = "[File not found]"; | |
458 | } else { | |
459 | int l = read(fd, tbuff, sizeof(tbuff) - 1); | |
460 | ||
461 | if (l >= 0) { | |
462 | tbuff[l] = 0; | |
463 | tbp = tbuff; | |
464 | } else { | |
465 | tbp = "[I/O Error]"; | |
466 | } | |
467 | close(fd); | |
468 | } | |
469 | } | |
470 | ||
718eeb6a VP |
471 | if (tbp) |
472 | strftime(buff, sizeof(buff), tbp, localtime(&now)); | |
473 | else if (!(ci->imageOverlaid)) | |
474 | strftime(buff, sizeof(buff), "[No data]", localtime(&now)); | |
26b4bb70 | 475 | |
718eeb6a VP |
476 | ci->x = ff_parse_eval(ci->eval_x, const_values, ci); |
477 | ci->y = ff_parse_eval(ci->eval_y, const_values, ci); | |
26b4bb70 PG |
478 | y = ci->y; |
479 | ||
41e4c556 RP |
480 | if (ci->eval_colors) { |
481 | ci->r = ff_parse_eval(ci->eval_r, const_values, ci); | |
482 | ci->g = ff_parse_eval(ci->eval_g, const_values, ci); | |
483 | ci->b = ff_parse_eval(ci->eval_b, const_values, ci); | |
484 | imlib_context_set_color(ci->r, ci->g, ci->b, 255); | |
485 | } | |
486 | ||
718eeb6a | 487 | if (!(ci->imageOverlaid)) |
26b4bb70 PG |
488 | for (p = buff; p; p = q) { |
489 | q = strchr(p, '\n'); | |
490 | if (q) | |
491 | *q++ = 0; | |
492 | ||
718eeb6a | 493 | imlib_text_draw_with_return_metrics(ci->x, y, p, &wid, &hig, &h_a, &v_a); |
26b4bb70 PG |
494 | y += v_a; |
495 | } | |
718eeb6a VP |
496 | |
497 | if (ci->imageOverlaid) { | |
498 | imlib_context_set_image(image); | |
499 | imlib_blend_image_onto_image(ci->imageOverlaid, 0, | |
500 | 0, 0, ci->imageOverlaid_width, ci->imageOverlaid_height, | |
501 | ci->x, ci->y, ci->imageOverlaid_width, ci->imageOverlaid_height); | |
502 | } | |
503 | ||
26b4bb70 PG |
504 | } |
505 | ||
67d0436c | 506 | ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx, |
71e445fc | 507 | width, height, PIX_FMT_RGB32, |
67d0436c VP |
508 | width, height, pix_fmt, |
509 | sws_flags, NULL, NULL, NULL); | |
510 | if (ci->fromRGB_convert_ctx == NULL) { | |
511 | av_log(NULL, AV_LOG_ERROR, | |
512 | "Cannot initialize the fromRGB conversion context\n"); | |
ca345e44 | 513 | return; |
26b4bb70 | 514 | } |
67d0436c VP |
515 | // img_convert parameters are 2 first destination, then 4 source |
516 | // sws_scale parameters are context, 4 first source, then 2 destination | |
517 | sws_scale(ci->fromRGB_convert_ctx, | |
518 | picture1.data, picture1.linesize, 0, height, | |
519 | picture->data, picture->linesize); | |
26b4bb70 | 520 | |
718eeb6a | 521 | ci->frame_number++; |
26b4bb70 PG |
522 | } |
523 |