33389
|
1 /*
|
|
2 * MPlayer output to MNG file
|
|
3 *
|
|
4 * Copyright (C) 2011 Stefan Schuermans <stefan blinkenarea org>
|
|
5 *
|
|
6 * This file is part of MPlayer.
|
|
7 *
|
|
8 * MPlayer is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * MPlayer is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License along
|
|
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
21 */
|
|
22
|
|
23 #include <stdlib.h>
|
|
24 #include <string.h>
|
|
25 #include <unistd.h>
|
|
26 #include <fcntl.h>
|
|
27 #include <errno.h>
|
|
28 #include <sys/stat.h>
|
|
29 #include <sys/types.h>
|
|
30
|
|
31 #include <zlib.h>
|
|
32
|
|
33 #define MNG_INCLUDE_WRITE_PROCS
|
|
34 #define MNG_ACCESS_CHUNKS
|
|
35 #define MNG_SUPPORT_READ
|
|
36 #define MNG_SUPPORT_DISPLAY
|
|
37 #define MNG_SUPPORT_WRITE
|
|
38 #include <libmng.h>
|
|
39
|
|
40 #include "video_out.h"
|
36517
|
41 #define NO_DRAW_FRAME
|
33389
|
42 #include "video_out_internal.h"
|
|
43 #include "mp_msg.h"
|
33558
|
44 #include "subopt-helper.h"
|
33389
|
45
|
|
46 #define VOMNG_DEFAULT_DELAY_MS (100) /* default delay of a frame */
|
|
47
|
|
48 static vo_info_t info = {
|
|
49 .name = "MNG file",
|
|
50 .short_name = "mng",
|
|
51 .author = "Stefan Schuermans <stefan blinkenarea org>"
|
|
52 };
|
|
53
|
|
54 LIBVO_EXTERN(mng)
|
|
55
|
|
56 /* a frame to be written to the MNG file */
|
|
57 struct vomng_frame {
|
|
58 mng_ptr data; /**< deflate compressed data, malloc-ed */
|
|
59 mng_uint32 len; /**< length of compressed data */
|
|
60 unsigned int time_ms; /**< timestamp of frame (in ms) */
|
|
61 struct vomng_frame *next; /**< next frame */
|
|
62 };
|
|
63
|
|
64 /* properties of MNG output */
|
|
65 struct vomng_properties {
|
|
66 char *out_file_name; /**< name of output file, malloc-ed */
|
|
67 unsigned int width, height; /**< dimensions */
|
|
68 unsigned char *canvas; /**< canvas for frame,
|
|
69 canvas := row ... row,
|
|
70 row := filter_id pix ... pix,
|
|
71 pix := red green blue */
|
|
72 struct vomng_frame *frame_first; /**< list of frames */
|
|
73 struct vomng_frame *frame_last;
|
|
74 int is_init; /**< if initialized */
|
|
75 };
|
|
76
|
|
77 /* private data of MNG vo module */
|
|
78 static struct vomng_properties vomng;
|
|
79
|
|
80 /**
|
|
81 * @brief libmng callback: allocate memory
|
|
82 * @param[in] size size of requested memory block
|
|
83 * @return pointer to memory block, which is initialized to zero
|
|
84 */
|
|
85 static mng_ptr vomng_alloc(mng_size_t size)
|
|
86 {
|
|
87 return calloc(1, size);
|
|
88 }
|
|
89
|
|
90 /**
|
|
91 * @brief libmng callback: free memory
|
|
92 * @param[in] pointer to memory block
|
|
93 * @param[in] size size of requested memory block
|
|
94 */
|
|
95 static void vomng_free(mng_ptr ptr, mng_size_t size)
|
|
96 {
|
|
97 free(ptr);
|
|
98 }
|
|
99
|
|
100 /**
|
|
101 * @brief libmng callback: open stream
|
|
102 * @param[in] mng libmng handle
|
|
103 * @return if stream could be opened
|
|
104 */
|
|
105 static mng_bool vomng_openstream(mng_handle mng)
|
|
106 {
|
|
107 return MNG_TRUE; /* stream is always open wen we get here,
|
|
108 tell libmng that everything is okay */
|
|
109 }
|
|
110
|
|
111 /**
|
|
112 * @brief libmng callback: stream should be closed
|
|
113 * @param[in] mng libmng handle
|
|
114 * @return if stream could be closed
|
|
115 */
|
|
116 static mng_bool vomng_closestream(mng_handle mng)
|
|
117 {
|
|
118 return MNG_TRUE; /* stream will be closed later,
|
|
119 tell libmng that everything is okay */
|
|
120 }
|
|
121
|
|
122 /**
|
|
123 * @brief libmng callback: write libmng data to the open stream
|
|
124 * @param[in] mng libmng handle
|
|
125 * @param[in] *buf pointer to data to write
|
|
126 * @param[in] size size of data to write
|
|
127 * @param[out] *written size of data written
|
|
128 * @return if data was written successfully
|
|
129 */
|
|
130 static mng_bool vomng_writedata(mng_handle mng, mng_ptr buf,
|
|
131 mng_uint32 size, mng_uint32 *written)
|
|
132 {
|
|
133 FILE *file = mng_get_userdata(mng);
|
|
134 *written = fwrite(buf, 1, size, file);
|
|
135 /* according to the example in libmng documentation, true is always
|
|
136 returned here, short writes can be detected by libmng via *written */
|
|
137 return MNG_TRUE;
|
|
138 }
|
|
139
|
|
140 /**
|
|
141 * @brief compress frame data
|
|
142 * @param[in] width width of canvas
|
|
143 * @param[in] height height of canvas
|
|
144 * @param[in] *canvas data on canvas (including MNG filter IDs)
|
|
145 * @param[out] *out_ptr pointer to compressed data, malloc-ed
|
|
146 * @param[out] *out_len length of compressed data
|
|
147 */
|
|
148 static void vomng_canvas_to_compressed(unsigned int width, unsigned int height,
|
|
149 const unsigned char *canvas,
|
|
150 mng_ptr *out_ptr, mng_uint32 *out_len)
|
|
151 {
|
|
152 mng_uint32 raw_len;
|
|
153 unsigned char *ptr;
|
|
154 unsigned long len;
|
|
155
|
|
156 /* default: no output */
|
|
157 *out_ptr = NULL;
|
|
158 *out_len = 0;
|
|
159
|
|
160 /* raw_len := length of input data
|
|
161 - it will be significantly shorter than 32 bit
|
|
162 - the "1 +" is needed because each row starts with the filter ID */
|
|
163 raw_len = height * (1 + width * 3);
|
|
164
|
|
165 /* compress data
|
|
166 - compress2 output size will be smaller than raw_len * 1.001 + 12 (see
|
|
167 man page), so calculate the next larger integer value in len and
|
|
168 allocate abuffer of this size
|
|
169 - len will still contain a value shorter than 32 bit */
|
|
170 len = raw_len + (raw_len + 999) / 1000 + 12;
|
|
171 ptr = malloc(len);
|
|
172 if (!ptr)
|
|
173 return;
|
|
174 compress2(ptr, &len, canvas, raw_len, Z_BEST_COMPRESSION);
|
|
175
|
|
176 /* return allocated compressed data
|
|
177 - we have to convert the output length to a shorter data type as
|
|
178 libmng does not accept an unsigned long as length
|
|
179 - convert here, because we can see here that the conversion is safe
|
|
180 - see comments about raw_len and len above
|
|
181 - compress2 never increases value of len */
|
|
182 *out_ptr = ptr;
|
|
183 *out_len = len;
|
|
184 }
|
|
185
|
|
186 /**
|
|
187 * @brief write frame to MNG file
|
|
188 * @param[in] *frame the frame to write to MNG file
|
|
189 * @param[in] mng libmng handle
|
|
190 * @param[in] width width of canvas
|
|
191 * @param[in] height height of canvas
|
|
192 * @param[in] first_frame if the frame is the first one in the file
|
|
193 * @return 0 on success, 1 on error
|
|
194 */
|
|
195 static int vomng_write_frame(struct vomng_frame *frame, mng_handle mng,
|
|
196 unsigned int width, unsigned int height,
|
|
197 int first_frame)
|
|
198 {
|
|
199 unsigned int delay_ms;
|
|
200
|
|
201 /* determine delay */
|
|
202 if (frame->next)
|
|
203 delay_ms = frame->next->time_ms - frame->time_ms;
|
|
204 else
|
|
205 delay_ms = VOMNG_DEFAULT_DELAY_MS; /* default delay for last frame */
|
|
206
|
|
207 /* write frame headers to MNG file */
|
|
208 if (mng_putchunk_seek(mng, 0, MNG_NULL)) {
|
|
209 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing SEEK chunk failed\n");
|
|
210 return 1;
|
|
211 }
|
|
212 if (mng_putchunk_fram(mng, MNG_FALSE,
|
|
213 /* keep canvas if not 1st frame */
|
|
214 first_frame ? MNG_FRAMINGMODE_1
|
|
215 : MNG_FRAMINGMODE_NOCHANGE,
|
|
216 0, MNG_NULL, /* no frame name */
|
|
217 MNG_CHANGEDELAY_DEFAULT, /* change only delay */
|
|
218 MNG_CHANGETIMOUT_NO,
|
|
219 MNG_CHANGECLIPPING_NO,
|
|
220 MNG_CHANGESYNCID_NO,
|
|
221 delay_ms, /* new delay */
|
|
222 0, /* no new timeout */
|
|
223 0, 0, 0, 0, 0, /* no new boundary */
|
|
224 0, 0)) { /* no count, no IDs */
|
|
225 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing FRAM chunk failed\n");
|
|
226 return 1;
|
|
227 }
|
|
228 if (mng_putchunk_defi(mng, 0, /* no ID */
|
|
229 MNG_DONOTSHOW_VISIBLE,
|
|
230 MNG_ABSTRACT,
|
|
231 MNG_TRUE, 0, 0, /* top left location */
|
|
232 MNG_FALSE, 0, 0, 0, 0)) { /* no clipping */
|
|
233 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing DEFI chunk failed\n");
|
|
234 return 1;
|
|
235 }
|
|
236 if (mng_putchunk_ihdr(mng, width, height, /* dimensions */
|
|
237 8, MNG_COLORTYPE_RGB, /* RBG */
|
|
238 MNG_COMPRESSION_DEFLATE,
|
|
239 MNG_FILTER_ADAPTIVE,
|
|
240 MNG_INTERLACE_NONE)) {
|
|
241 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing IHDR chunk failed\n");
|
|
242 return 1;
|
|
243 }
|
|
244
|
|
245 /* write frame data */
|
|
246 if (mng_putchunk_idat(mng, frame->len, frame->data)) {
|
|
247 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing IDAT chunk failed\n");
|
|
248 return 1;
|
|
249 }
|
|
250
|
|
251 /* write frame footers to MNG file */
|
|
252 if (mng_putchunk_iend(mng)) {
|
|
253 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing IEND chunk failed\n");
|
|
254 return 1;
|
|
255 }
|
|
256
|
|
257 return 0;
|
|
258 }
|
|
259
|
|
260 /**
|
|
261 * @brief write buffered frames to MNG file
|
|
262 * @return 0 on success, 1 on error
|
|
263 */
|
|
264 static int vomng_write_file(void)
|
|
265 {
|
|
266 FILE *file;
|
|
267 mng_handle mng;
|
|
268 struct vomng_frame *frame;
|
|
269 unsigned int frames, duration_ms;
|
|
270 int first;
|
|
271
|
|
272 /* refuse to create empty MNG file */
|
|
273 if (!vomng.frame_first || !vomng.frame_last) {
|
|
274 mp_msg(MSGT_VO, MSGL_ERR, "vomng: not creating empty file\n");
|
|
275 return 1;
|
|
276 }
|
|
277
|
|
278 /* create output file */
|
|
279 file = fopen(vomng.out_file_name, "wb");
|
|
280 if (!file) {
|
|
281 mp_msg(MSGT_VO, MSGL_ERR,
|
|
282 "vomng: could not open output file \"%s\": %s\n",
|
|
283 vomng.out_file_name, strerror(errno));
|
|
284 return 1;
|
|
285 }
|
|
286
|
|
287 /* inititalize MNG library */
|
|
288 mng = mng_initialize(file, vomng_alloc, vomng_free, MNG_NULL);
|
|
289 if (!mng) {
|
|
290 mp_msg(MSGT_VO, MSGL_ERR, "vomng: could not initialize libmng\n");
|
|
291 fclose(file);
|
|
292 return 1;
|
|
293 }
|
|
294 if (mng_setcb_openstream (mng, vomng_openstream ) ||
|
|
295 mng_setcb_closestream(mng, vomng_closestream) ||
|
|
296 mng_setcb_writedata (mng, vomng_writedata )) {
|
|
297 mp_msg(MSGT_VO, MSGL_ERR, "vomng: cannot set callbacks for libmng\n");
|
|
298 mng_cleanup(&mng);
|
|
299 fclose(file);
|
|
300 return 1;
|
|
301 }
|
|
302
|
|
303 /* create new MNG image in memory */
|
|
304 if (mng_create(mng)) {
|
|
305 mp_msg(MSGT_VO, MSGL_ERR, "vomng: cannot create MNG image in memory\n");
|
|
306 mng_cleanup(&mng);
|
|
307 fclose(file);
|
|
308 return 1;
|
|
309 }
|
|
310
|
|
311 /* determine number of frames and total duration */
|
|
312 frames = 0;
|
|
313 for (frame = vomng.frame_first; frame; frame = frame->next)
|
|
314 frames++;
|
|
315 duration_ms = vomng.frame_last->time_ms - vomng.frame_first->time_ms;
|
|
316
|
|
317 /* write MNG header chunks */
|
|
318 if (mng_putchunk_mhdr(mng,
|
|
319 vomng.width, /* dimensions */
|
|
320 vomng.height,
|
|
321 1000, 0, /* ticks per second, layer */
|
|
322 frames, /* number of frames */
|
|
323 duration_ms, /* total duration */
|
|
324 MNG_SIMPLICITY_VALID |
|
|
325 MNG_SIMPLICITY_SIMPLEFEATURES |
|
|
326 MNG_SIMPLICITY_COMPLEXFEATURES) ||
|
|
327 mng_putchunk_save(mng,
|
|
328 MNG_TRUE, 0, 0) || /* empty save chunk */
|
|
329 mng_putchunk_term(mng,
|
|
330 MNG_TERMACTION_CLEAR, /* show last frame forever */
|
|
331 MNG_ITERACTION_CLEAR,
|
|
332 0, 0)) {
|
|
333 mp_msg(MSGT_VO, MSGL_ERR,
|
|
334 "vomng: writing MHDR/SAVE/TERM chunks failed\n");
|
|
335 mng_write(mng); /* write out buffered chunks before cleanup */
|
|
336 mng_cleanup(&mng);
|
|
337 fclose(file);
|
|
338 return 1;
|
|
339 }
|
|
340
|
|
341 /* write frames */
|
|
342 first = 1;
|
|
343 for (frame = vomng.frame_first; frame; frame = frame->next) {
|
|
344 if (vomng_write_frame(frame, mng, vomng.width, vomng.height, first))
|
|
345 break;
|
|
346 first = 0;
|
|
347 }
|
|
348 if (frame) {
|
|
349 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing frames failed\n");
|
|
350 mng_write(mng); /* write out buffered chunks before cleanup */
|
|
351 mng_cleanup(&mng);
|
|
352 fclose(file);
|
|
353 return 1;
|
|
354 }
|
|
355
|
|
356 /* write MNG end chunk */
|
|
357 if (mng_putchunk_mend(mng)) {
|
|
358 mp_msg(MSGT_VO, MSGL_ERR, "vomng: writing end chunk failed\n");
|
|
359 mng_write(mng); /* write out buffered chunks before cleanup */
|
|
360 mng_cleanup(&mng);
|
|
361 fclose(file);
|
|
362 return 1;
|
|
363 }
|
|
364
|
|
365 /* finish and cleanup */
|
|
366 mng_write(mng); /* write out buffered chunks before cleanup */
|
|
367 mng_cleanup(&mng);
|
|
368 fclose(file);
|
|
369
|
|
370 return 0;
|
|
371 }
|
|
372
|
|
373 /**
|
|
374 * @brief close all files and free all memory of MNG vo module
|
|
375 */
|
|
376 static void vomng_prop_reset(void)
|
|
377 {
|
|
378 struct vomng_frame *frame, *next;
|
|
379
|
|
380 /* we are initialized properly */
|
|
381 if (vomng.is_init) {
|
|
382 /* write buffered frames to MNG file */
|
|
383 if (vomng_write_file())
|
|
384 mp_msg(MSGT_VO, MSGL_ERR,
|
|
385 "vomng: writing output file failed\n");
|
|
386 }
|
|
387
|
|
388 /* reset state */
|
|
389 vomng.is_init = 0;
|
|
390 if (vomng.frame_first) {
|
|
391 frame = vomng.frame_first;
|
|
392 while (frame) {
|
|
393 next = frame->next;
|
|
394 free(frame->data);
|
|
395 free(frame);
|
|
396 frame = next;
|
|
397 }
|
|
398 vomng.frame_first = NULL;
|
|
399 vomng.frame_last = NULL;
|
|
400 }
|
|
401 free(vomng.canvas);
|
|
402 vomng.canvas = NULL;
|
|
403 vomng.width = 0;
|
|
404 vomng.height = 0;
|
|
405 }
|
|
406
|
|
407 /**
|
|
408 * @brief close files, free memory and delete private data of MNG von module
|
|
409 */
|
|
410 static void vomng_prop_cleanup(void)
|
|
411 {
|
|
412 vomng_prop_reset();
|
|
413 free(vomng.out_file_name);
|
|
414 }
|
|
415
|
|
416 /**
|
|
417 * @brief configure MNG vo module
|
|
418 * @param[in] width video width
|
|
419 * @param[in] height video height
|
|
420 * @param[in] d_width (unused)
|
|
421 * @param[in] d_height (unused)
|
|
422 * @param[in] flags (unused)
|
|
423 * @param[in] title (unused)
|
|
424 * @param[in] format video frame format
|
|
425 * @return 0 on success, 1 on error
|
|
426 */
|
|
427 static int config(uint32_t width, uint32_t height,
|
|
428 uint32_t d_width, uint32_t d_height,
|
|
429 uint32_t flags, char *title, uint32_t format)
|
|
430 {
|
|
431 uint32_t row_stride, y;
|
|
432
|
|
433 /* reset state */
|
|
434 vomng_prop_reset();
|
|
435
|
|
436 /* check format */
|
|
437 if (format != IMGFMT_RGB24) {
|
|
438 mp_msg(MSGT_VO, MSGL_ERR,
|
|
439 "vomng: config with invalid format (!= IMGFMT_RGB24)\n");
|
|
440 return 1;
|
|
441 }
|
|
442
|
|
443 /* allocate canvas */
|
|
444 vomng.width = width;
|
|
445 vomng.height = height;
|
|
446 row_stride = 1 + width * 3; /* rows contain filter IDs */
|
|
447 vomng.canvas = calloc(height * row_stride, 1);
|
|
448 if (!vomng.canvas) {
|
|
449 mp_msg(MSGT_VO, MSGL_ERR, "vomng: out of memory\n");
|
|
450 return 1;
|
|
451 }
|
|
452 /* fill in filter IDs for rows */
|
|
453 for (y = 0; y < height; y++)
|
|
454 *(vomng.canvas + row_stride * y) = MNG_FILTER_NONE;
|
|
455
|
|
456 /* we are initialized */
|
|
457 vomng.is_init = 1;
|
|
458
|
|
459 return 0;
|
|
460 }
|
|
461
|
|
462 /**
|
|
463 * @brief draw on screen display (unsupported for MNG vo module)
|
|
464 */
|
|
465 static void draw_osd(void)
|
|
466 {
|
|
467 }
|
|
468
|
|
469 /**
|
|
470 * @brief display data currently on canvas
|
|
471 */
|
|
472 static void flip_page(void)
|
|
473 {
|
|
474 unsigned int last_ms;
|
|
475 struct vomng_frame *frame;
|
|
476
|
|
477 /* get time of last frame in ms
|
|
478 (intensive testing showed that the time obtained from vo_pts
|
|
479 is the time of the previous frame) */
|
|
480 last_ms = (unsigned int)(vo_pts / 90.0 + 0.5);
|
|
481
|
|
482 /* set time of last frame */
|
|
483 if (vomng.frame_last)
|
|
484 vomng.frame_last->time_ms = last_ms;
|
|
485
|
|
486 /* create new frame */
|
|
487 frame = calloc(1, sizeof(*frame));
|
|
488 if (!frame) {
|
|
489 mp_msg(MSGT_VO, MSGL_ERR, "vomng: out of memory\n");
|
|
490 return;
|
|
491 }
|
|
492 /* time of frame is not yet known (see comment about vo_pts about 20
|
|
493 lines above), approximate time using time of last frame and the
|
|
494 default frame delay */
|
|
495 frame->time_ms = last_ms + VOMNG_DEFAULT_DELAY_MS;
|
|
496 frame->next = NULL;
|
|
497
|
|
498 /* compress canvas data */
|
|
499 vomng_canvas_to_compressed(vomng.width, vomng.height, vomng.canvas,
|
|
500 &frame->data, &frame->len);
|
|
501 if (!frame->data) {
|
|
502 mp_msg(MSGT_VO, MSGL_ERR, "vomng: compressing frame failed\n");
|
|
503 free(frame);
|
|
504 return;
|
|
505 }
|
|
506
|
|
507 /* add frame to list */
|
|
508 if (!vomng.frame_first || !vomng.frame_last) {
|
|
509 vomng.frame_first = frame;
|
|
510 vomng.frame_last = frame;
|
|
511 } else {
|
|
512 vomng.frame_last->next = frame;
|
|
513 vomng.frame_last = frame;
|
|
514 }
|
|
515 }
|
|
516
|
|
517 /**
|
|
518 * @brief deinitialize MNG vo module
|
|
519 */
|
|
520 static void uninit(void)
|
|
521 {
|
|
522 vomng_prop_cleanup();
|
|
523 }
|
|
524
|
|
525 /**
|
|
526 * @brief deal with events (not supported)
|
|
527 */
|
|
528 static void check_events(void)
|
|
529 {
|
|
530 }
|
|
531
|
|
532 /**
|
|
533 * @brief put a slice of frame data onto canvas
|
|
534 * @param[in] srcimg pointer to data
|
|
535 * @param[in] stride line stride in data
|
|
536 * @param[in] wf frame slice width
|
|
537 * @param[in] hf frame slice height
|
|
538 * @param[in] xf leftmost x coordinate of frame slice
|
|
539 * @param[in] yf topmost y coordinate of frame slice
|
|
540 * @return always 0 to indicate success
|
|
541 */
|
|
542 static int draw_slice(uint8_t *srcimg[], int stride[],
|
|
543 int wf, int hf, int xf, int yf)
|
|
544 {
|
|
545 uint8_t *line_ptr;
|
|
546 int line_len, row_stride, y;
|
|
547
|
|
548 /* put pixel data from slice to canvas */
|
|
549 line_ptr = srcimg[0];
|
|
550 line_len = stride[0];
|
|
551 row_stride = 1 + vomng.width * 3; /* rows contain filter IDs */
|
|
552 for (y = 0; y < hf; y++)
|
|
553 memcpy(vomng.canvas + (yf + y) * row_stride + 1 + xf * 3,
|
|
554 line_ptr + y * line_len, wf * 3);
|
|
555
|
|
556 return 0;
|
|
557 }
|
|
558
|
33558
|
559 /** list of suboptions */
|
|
560 static const opt_t subopts[] = {
|
|
561 {"output", OPT_ARG_MSTRZ, &vomng.out_file_name, NULL},
|
|
562 {NULL, 0, NULL, NULL}
|
|
563 };
|
|
564
|
33389
|
565 /**
|
|
566 * @brief pre-initialize MNG vo module
|
|
567 * @param[in] *arg arguments passed to MNG vo module (output file name)
|
|
568 * @return 0 on success, 1 on error
|
|
569 */
|
|
570 static int preinit(const char *arg)
|
|
571 {
|
33558
|
572 if (subopt_parse(arg, subopts)) {
|
|
573 mp_msg(MSGT_VO, MSGL_ERR,
|
|
574 "\n-vo mng command line help:\n"
|
|
575 "Example: mplayer -vo mng:output=file.mng\n"
|
|
576 "\nOptions:\n"
|
|
577 " output=<filename>\n"
|
|
578 " Specify the output file. The default is out.mng.\n"
|
|
579 "\n");
|
33389
|
580 vomng_prop_cleanup();
|
|
581 return 1;
|
|
582 }
|
33558
|
583 if (!vomng.out_file_name)
|
|
584 vomng.out_file_name = strdup("out.mng");
|
33389
|
585
|
|
586 return 0;
|
|
587 }
|
|
588
|
|
589 /**
|
|
590 * @brief get supported formats
|
|
591 * @param[in] format format to check support for
|
|
592 * @return acceptance flags
|
|
593 */
|
|
594 static int query_format(uint32_t format)
|
|
595 {
|
|
596 if (format == IMGFMT_RGB24)
|
|
597 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |
|
|
598 VFCAP_ACCEPT_STRIDE;
|
|
599 return 0;
|
|
600 }
|
|
601
|
|
602 /**
|
|
603 * @brief handle control stuff
|
|
604 * @param[in] request control request
|
|
605 * @param[in] *data data (dependent on control request)
|
|
606 * @return response to control request
|
|
607 */
|
|
608 static int control(uint32_t request, void *data)
|
|
609 {
|
|
610 switch (request) {
|
|
611 case VOCTRL_QUERY_FORMAT:
|
|
612 return query_format(*((uint32_t *)data));
|
|
613 }
|
|
614 return VO_NOTIMPL;
|
|
615 }
|
|
616
|