annotate libvo/vo_pnm.c @ 14707:1fbfc19c5f75

outdated EDL limit reference
author reynaldo
date Tue, 15 Feb 2005 22:48:40 +0000
parents 00c3c4111017
children 2ef20aa3623b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
1 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
2
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
3 /*
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
4 * vo_pnm.c, PPM/PGM/PGMYUV Video Output Driver for MPlayer
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
5 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
6 *
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
7 * Written by Ivo van Poorten. (C) Copyright 2004, 2005.
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
8 * Licensed under GNU General Public License version 2.
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
9 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
10 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
11 * Changelog
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
12 *
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
13 * 2004-01-15 Replaced suboption parser by call to subopt-helper.
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
14 * Got rid of stupid malloc_failed function.
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
15 * 2004-09-16 Second draft. It now acts on VOCTRL_DRAW_IMAGE and does not
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
16 * maintain a local copy of the image if the format is YV12.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
17 * Speed improvement and uses less memory.
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
18 * 2004-09-09 First draft.
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
19 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
20 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
21 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
22
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
23 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
24
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
25 /* Global Includes */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
26
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
27 #include <stdio.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
28 #include <stdlib.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
29 #include <string.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
30 #include <errno.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
31 #include <sys/stat.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
32
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
33 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
34
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
35 /* Local Includes */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
36
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
37 #include "config.h"
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
38 #include "subopt-helper.h"
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
39 #include "mp_msg.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
40 #include "video_out.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
41 #include "video_out_internal.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
42 #include "mplayer.h" /* for exit_player() */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
43 #include "help_mp.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
44
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
45 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
46
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
47 /* Defines */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
48
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
49 /* Used for temporary buffers to store file- and pathnames */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
50 #define BUFLENGTH 512
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
51
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
52 #define PNM_ASCII_MODE 0
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
53 #define PNM_RAW_MODE 1
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
54 #define PNM_TYPE_PPM 0
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
55 #define PNM_TYPE_PGM 1
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
56 #define PNM_TYPE_PGMYUV 2
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
57
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
58 #define PNM_LINE_OF_ASCII "%03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d\n"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
59 #define PNM_LINE15(a,b) a[b], a[b+1], a[b+2], a[b+3], a[b+4], a[b+5], a[b+6], \
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
60 a[b+7], a[b+8], a[b+9], a[b+10], a[b+11], a[b+12], \
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
61 a[b+13], a[b+14]
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
62
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
63 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
64
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
65 /* Info */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
66
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
67 static vo_info_t info=
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
68 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
69 "PPM/PGM/PGMYUV file",
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
70 "pnm",
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
71 "Ivo van Poorten (ivop@euronet.nl)",
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
72 ""
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
73 };
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
74
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
75 LIBVO_EXTERN (pnm)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
76
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
77 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
78
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
79 /* Global Variables */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
80
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
81 int pnm_type = PNM_TYPE_PPM;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
82 int pnm_mode = PNM_RAW_MODE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
83
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
84 char *pnm_outdir = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
85 char *pnm_subdirs = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
86 int pnm_maxfiles = 1000;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
87 char *pnm_file_extension = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
88
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
89 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
90
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
91 /** \brief An error occured while writing to a file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
92 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
93 * The program failed to write data to a file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
94 * It displays a message and exits the player.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
95 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
96 * \return nothing It does not return.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
97 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
98
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
99 void pnm_write_error(void) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
100 mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
101 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
102 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
103
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
104 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
105
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
106 /** \brief Validation function for maxfiles
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
107 */
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
108
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
109 static int int_pos(int *mf)
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
110 {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
111 if ( *mf > 0 )
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
112 return 1;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
113 return 0;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
114 }
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
115
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
116 /** \brief Pre-initialisation.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
117 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
118 * This function is called before initialising the video output driver. It
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
119 * parses all suboptions and sets variables accordingly. If an error occurs
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
120 * (like an option being out of range, not having any value or an unknown
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
121 * option is stumbled upon) the player will exit.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
122 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
123 * \param arg A string containing all the suboptions passed to the video
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
124 * output driver.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
125 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
126 * \return 0 All went well.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
127 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
128
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
129 static uint32_t preinit(const char *arg)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
130 {
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
131 int ppm_type = 0, pgm_type = 0, pgmyuv_type = 0,
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
132 raw_mode = 0, ascii_mode = 0;
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
133 opt_t subopts[] = {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
134 {"ppm", OPT_ARG_BOOL, &ppm_type, NULL},
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
135 {"pgm", OPT_ARG_BOOL, &pgm_type, NULL},
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
136 {"pgmyuv", OPT_ARG_BOOL, &pgmyuv_type, NULL},
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
137 {"raw", OPT_ARG_BOOL, &raw_mode, NULL},
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
138 {"ascii", OPT_ARG_BOOL, &ascii_mode, NULL},
14538
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
139 {"outdir", OPT_ARG_MSTRZ, &pnm_outdir, NULL},
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
140 {"subdirs", OPT_ARG_MSTRZ, &pnm_subdirs, NULL},
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
141 {"maxfiles", OPT_ARG_INT, &pnm_maxfiles, (opt_test_f)int_pos},
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
142 {NULL}
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
143 };
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
144 const char *info_message = NULL;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
145
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
146 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
147 MSGTR_VO_ParsingSuboptions);
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
148
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
149 pnm_maxfiles = 1000;
14538
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
150 pnm_outdir = strdup(".");
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
151 pnm_subdirs = NULL;
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
152
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
153 if (subopt_parse(arg, subopts) != 0) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
154 return -1;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
155 }
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
156
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
157 pnm_type = PNM_TYPE_PPM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
158 pnm_mode = PNM_RAW_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
159
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
160 if (pgmyuv_type) pnm_type = PNM_TYPE_PGMYUV;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
161 if (pgm_type) pnm_type = PNM_TYPE_PGM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
162 if (ppm_type) pnm_type = PNM_TYPE_PPM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
163 if (ascii_mode) pnm_mode = PNM_ASCII_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
164 if (raw_mode) pnm_mode = PNM_RAW_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
165
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
166 switch (pnm_mode) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
167 case PNM_ASCII_MODE:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
168 info_message = MSGTR_VO_PNM_ASCIIMode;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
169 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
170 case PNM_RAW_MODE:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
171 info_message = MSGTR_VO_PNM_RawMode;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
172 break;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
173 }
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
174 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
175
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
176 switch (pnm_type) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
177 case PNM_TYPE_PPM:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
178 info_message = MSGTR_VO_PNM_PPMType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
179 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
180 case PNM_TYPE_PGM:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
181 info_message = MSGTR_VO_PNM_PGMType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
182 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
183 case PNM_TYPE_PGMYUV:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
184 info_message = MSGTR_VO_PNM_PGMYUVType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
185 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
186 }
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
187 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
188
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
189 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
190 MSGTR_VO_SuboptionsParsedOK);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
191 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
192 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
193
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
194 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
195
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
196 /** \brief Create a directory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
197 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
198 * This function creates a directory. If it already exists, it tests if
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
199 * it's a directory and not something else, and if it is, it tests whether
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
200 * the directory is writable or not.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
201 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
202 * \param buf Pointer to directory name.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
203 * \param verbose Verbose on success. If verbose is non-zero, it will print
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
204 * a message if it was successful in creating the directory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
205 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
206 * \return nothing In case anything fails, the player will exit. If it
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
207 * returns, everything went well.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
208 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
209
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
210 void pnm_mkdir(char *buf, int verbose) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
211 struct stat stat_p;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
212
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
213 /* Silly MING32 bug workaround */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
214 #ifndef __MINGW32__
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
215 if ( mkdir(buf, 0755) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
216 #else
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
217 if ( mkdir(buf) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
218 #endif
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
219 switch (errno) { /* use switch in case other errors need to be caught
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
220 and handled in the future */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
221 case EEXIST:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
222 if ( stat(buf, &stat_p ) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
223 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
224 MSGTR_VO_GenericError, strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
225 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
226 MSGTR_VO_UnableToAccess,buf);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
227 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
228 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
229 if ( !S_ISDIR(stat_p.st_mode) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
230 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
231 buf, MSGTR_VO_ExistsButNoDirectory);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
232 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
233 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
234 if ( !(stat_p.st_mode & S_IWUSR) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
235 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
236 buf, MSGTR_VO_DirExistsButNotWritable);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
237 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
238 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
239
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
240 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
241 buf, MSGTR_VO_DirExistsAndIsWritable);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
242 break;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
243
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
244 default:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
245 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
246 MSGTR_VO_GenericError, strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
247 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
248 buf, MSGTR_VO_CantCreateDirectory);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
249 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
250 } /* end switch */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
251 } else if ( verbose ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
252 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
253 buf, MSGTR_VO_DirectoryCreateSuccess);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
254 } /* end if */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
255 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
256
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
257 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
258
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
259 /** \brief Configure the video output driver.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
260 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
261 * This functions configures the video output driver. It determines the
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
262 * width and height of the image(s) and creates the output directory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
263 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
264 * \return 0 All went well.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
265 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
266
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
267 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
268 uint32_t d_height, uint32_t fullscreen, char *title,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
269 uint32_t format)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
270 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
271 char buf[BUFLENGTH];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
272
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
273 if (vo_config_count > 0 ) { /* Already configured */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
274 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
275 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
276
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
277 /* Create outdir. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
278
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
279 snprintf(buf, BUFLENGTH, "%s", pnm_outdir);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
280 pnm_mkdir(buf, 1); /* This function only returns if creation was
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
281 successful. If not, the player will exit. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
282
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
283 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
284 pnm_file_extension = strdup("ppm");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
285 } else if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
286 pnm_file_extension = strdup("pgm");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
287 } else if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
288 pnm_file_extension = strdup("pgmyuv");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
289 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
290
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
291 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
292 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
293
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
294 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
295
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
296 /** \brief Write PNM file to output file
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
297 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
298 * This function writes PPM, PGM or PGMYUV data to an output file, depending
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
299 * on which type was selected on the commandline. pnm_type and pnm_mode are
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
300 * global variables. Depending on which mode was selected, it will write
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
301 * a RAW or an ASCII file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
302 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
303 * \param outfile Filedescriptor of output file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
304 * \param mpi The image to write.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
305 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
306 * \return none The player will exit if anything goes wrong.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
307 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
308
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
309 void pnm_write_pnm(FILE *outfile, mp_image_t *mpi)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
310 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
311 uint32_t w = mpi->w;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
312 uint32_t h = mpi->h;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
313 uint8_t *rgbimage = mpi->planes[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
314 uint8_t *planeY = mpi->planes[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
315 uint8_t *planeU = mpi->planes[1];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
316 uint8_t *planeV = mpi->planes[2];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
317 uint8_t *curline;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
318 uint32_t strideY = mpi->stride[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
319 uint32_t strideU = mpi->stride[1];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
320 uint32_t strideV = mpi->stride[2];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
321
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
322 int i, j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
323
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
324 if (pnm_mode == PNM_RAW_MODE) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
325
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
326 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
327 if ( fprintf(outfile, "P6\n%d %d\n255\n", w, h) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
328 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
329 if ( fwrite(rgbimage, w * 3, h, outfile) < h ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
330 } else if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
331 if ( fprintf(outfile, "P5\n%d %d\n255\n", w, h) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
332 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
333 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
334 if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
335 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
336 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
337 } else if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
338 if ( fprintf(outfile, "P5\n%d %d\n255\n", w, h*3/2) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
339 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
340 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
341 if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
342 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
343 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
344 w = w / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
345 h = h / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
346 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
347 if ( fwrite(planeU + i * strideU, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
348 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
349 if ( fwrite(planeV + i * strideV, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
350 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
351 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
352 } /* end if pnm_type */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
353
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
354 } else if (pnm_mode == PNM_ASCII_MODE) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
355
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
356 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
357 if ( fprintf(outfile, "P3\n%d %d\n255\n", w, h) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
358 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
359 for (i=0; i <= w * h * 3 - 16 ; i += 15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
360 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
361 PNM_LINE15(rgbimage,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
362 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
363 while (i < (w * h * 3) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
364 if ( fprintf(outfile, "%03d ", rgbimage[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
365 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
366 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
367 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
368 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
369 } else if ( (pnm_type == PNM_TYPE_PGM) ||
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
370 (pnm_type == PNM_TYPE_PGMYUV) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
371
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
372 /* different header for pgm and pgmyuv. pgmyuv is 'higher' */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
373 if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
374 if ( fprintf(outfile, "P2\n%d %d\n255\n", w, h) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
375 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
376 } else { /* PNM_TYPE_PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
377 if ( fprintf(outfile, "P2\n%d %d\n255\n", w, h*3/2) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
378 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
379 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
380
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
381 /* output Y plane for both PGM and PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
382 for (j=0; j<h; j++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
383 curline = planeY + strideY * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
384 for (i=0; i <= w - 16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
385 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
386 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
387 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
388 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
389 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
390 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
391 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
392 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
393 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
394 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
395
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
396 /* also output U and V planes fpr PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
397 if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
398 w = w / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
399 h = h / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
400 for (j=0; j<h; j++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
401 curline = planeU + strideU * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
402 for (i=0; i<= w-16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
403 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
404 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
405 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
406 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
407 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
408 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
409 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
410 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
411 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
412
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
413 curline = planeV + strideV * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
414 for (i=0; i<= w-16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
415 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
416 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
417 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
418 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
419 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
420 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
421 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
422 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
423 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
424 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
425 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
426
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
427 } /* end if pnm_type */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
428 } /* end if pnm_mode */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
429 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
430
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
431 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
432
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
433 /** \brief Write a PNM image.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
434 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
435 * This function gets called first if a PNM image has to be written to disk.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
436 * It contains the subdirectory framework and it calls pnm_write_pnm() to
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
437 * actually write the image to disk.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
438 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
439 * \param mpi The image to write.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
440 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
441 * \return none The player will exit if anything goes wrong.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
442 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
443
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
444 void pnm_write_image(mp_image_t *mpi)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
445 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
446 static uint32_t framenum = 0, framecounter = 0, subdircounter = 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
447 char buf[BUFLENGTH];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
448 static char subdirname[BUFLENGTH] = "";
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
449 FILE *outfile;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
450
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
451 if (!mpi) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
452 mp_msg(MSGT_VO, MSGL_ERR, "%s: No image data suplied to video output driver\n", info.short_name );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
453 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
454 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
455
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
456 /* Start writing to new subdirectory after a certain amount of frames */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
457 if ( framecounter == pnm_maxfiles ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
458 framecounter = 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
459 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
460
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
461 /* If framecounter is zero (or reset to zero), increment subdirectory
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
462 * number and create the subdirectory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
463 * If pnm_subdirs is not set, do nothing. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
464 if ( !framecounter && pnm_subdirs ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
465 subdircounter++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
466 snprintf(subdirname, BUFLENGTH, "%s%08d", pnm_subdirs, subdircounter);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
467 snprintf(buf, BUFLENGTH, "%s/%s", pnm_outdir, subdirname);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
468 pnm_mkdir(buf, 0); /* This function only returns if creation was
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
469 successful. If not, the player will exit. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
470 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
471
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
472 framenum++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
473 framecounter++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
474
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
475 /* snprintf the full pathname of the outputfile */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
476 snprintf(buf, BUFLENGTH, "%s/%s/%08d.%s", pnm_outdir, subdirname,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
477 framenum, pnm_file_extension);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
478
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
479 if ( (outfile = fopen(buf, "wb") ) == NULL ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
480 mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
481 MSGTR_VO_CantCreateFile);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
482 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
483 info.short_name, MSGTR_VO_GenericError,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
484 strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
485 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
486 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
487
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
488 pnm_write_pnm(outfile, mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
489
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
490 fclose(outfile);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
491 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
492
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
493 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
494
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
495 static uint32_t draw_image(mp_image_t *mpi)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
496 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
497 if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Planar */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
498 if (mpi->flags & MP_IMGFLAG_YUV) { /* Planar YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
499 pnm_write_image(mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
500 return VO_TRUE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
501 } else { /* Planar RGB */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
502 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
503 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
504 } else { /* Packed */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
505 if (mpi->flags & MP_IMGFLAG_YUV) { /* Packed YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
506 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
507 } else { /* Packed RGB */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
508 pnm_write_image(mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
509 return VO_TRUE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
510 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
511 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
512
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
513 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
514 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
515
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
516 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
517
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
518 static uint32_t draw_frame(uint8_t *src[])
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
519 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
520 mp_msg(MSGT_VO, MSGL_V, "%s: draw_frame() is called!\n", info.short_name);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
521 return -1;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
522 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
523
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
524 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
525
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
526 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
527 int x, int y)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
528 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
529 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
530 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
531
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
532 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
533
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
534 static uint32_t query_format(uint32_t format)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
535 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
536 /* Ensure that for PPM we get Packed RGB and for PGM(YUV) we get
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
537 * Planar YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
538 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
539 if (format == IMGFMT_RGB24) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
540 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
541 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
542 } else if ( (pnm_type == PNM_TYPE_PGM) || (pnm_type == PNM_TYPE_PGMYUV) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
543 if (format == IMGFMT_YV12) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
544 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
545 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
546 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
547
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
548 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
549 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
550
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
551 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
552
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
553 static uint32_t control(uint32_t request, void *data, ...)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
554 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
555 switch (request) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
556 case VOCTRL_QUERY_FORMAT:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
557 return query_format(*((uint32_t*)data));
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
558 case VOCTRL_DRAW_IMAGE:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
559 return draw_image(data);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
560 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
561 return VO_NOTIMPL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
562 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
563
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
564 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
565
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
566 static void uninit(void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
567 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
568 if (pnm_subdirs) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
569 free(pnm_subdirs);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
570 pnm_subdirs = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
571 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
572 if (pnm_outdir) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
573 free(pnm_outdir);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
574 pnm_outdir = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
575 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
576 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
577
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
578 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
579
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
580 static void check_events(void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
581 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
582 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
583
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
584 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
585
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
586 static void draw_osd(void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
587 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
588 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
589
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
590 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
591
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
592 static void flip_page (void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
593 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
594 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
595
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
596 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
597
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
598 #undef BUFLENGTH
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
599 #undef PNM_RAW_MODE
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
600 #undef PNM_ASCII_MODE
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
601 #undef PNM_TYPE_PPM
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
602 #undef PNM_TYPE_PGM
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
603 #undef PNM_TYPE_PGMYUV
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
604
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
605 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
606