annotate libvo/vo_pnm.c @ 25881:c6f535c5f65b

Make mov subtitles work with -ass
author reimar
date Tue, 29 Jan 2008 14:30:53 +0000
parents c9e9ac2008c2
children 2a34d9fa52ab
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 *
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
6 * Written by Ivo van Poorten. (C) Copyright 2004, 2005.
25173
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
7 *
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
8 * This program is free software; you can redistribute it and/or
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
9 * modify it under the terms of the GNU General Public License
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
10 * as published by the Free Software Foundation; either version 2
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
11 * of the License, or (at your option) any later version.
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
12 *
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
13 * This program is distributed in the hope that it will be useful,
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
16 * GNU General Public License for more details.
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
17 *
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
18 * You should have received a copy of the GNU General Public License
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
19 * along with this program; if not, write to the Free Software
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13394
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
26 /* Global Includes */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
27
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
28 #include <stdio.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
29 #include <stdlib.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
30 #include <string.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
31 #include <errno.h>
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
32 #include <sys/stat.h>
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
36 /* Local Includes */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
37
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
38 #include "config.h"
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
39 #include "subopt-helper.h"
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
40 #include "mp_msg.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
41 #include "video_out.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
42 #include "video_out_internal.h"
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
43 #include "mplayer.h" /* for exit_player() */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
44 #include "help_mp.h"
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
48 /* Defines */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
49
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
50 /* Used for temporary buffers to store file- and pathnames */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
51 #define BUFLENGTH 512
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
52
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
53 #define PNM_ASCII_MODE 0
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
54 #define PNM_RAW_MODE 1
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
55 #define PNM_TYPE_PPM 0
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
56 #define PNM_TYPE_PGM 1
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
57 #define PNM_TYPE_PGMYUV 2
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
58
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
59 #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
60 #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
61 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
62 a[b+13], a[b+14]
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
66 /* Info */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
67
25216
3aee342be929 Make vo info structs const
reimar
parents: 25173
diff changeset
68 static const vo_info_t info=
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
69 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
70 "PPM/PGM/PGMYUV file",
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
71 "pnm",
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
72 "Ivo van Poorten (ivop@euronet.nl)",
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
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
76 const LIBVO_EXTERN (pnm)
13394
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
80 /* Global Variables */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
81
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
82 int pnm_type = PNM_TYPE_PPM;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
83 int pnm_mode = PNM_RAW_MODE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
84
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
85 char *pnm_outdir = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
86 char *pnm_subdirs = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
87 int pnm_maxfiles = 1000;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
88 char *pnm_file_extension = NULL;
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
92 /** \brief An error occured while writing to a file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
93 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
94 * The program failed to write data to a file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
95 * It displays a message and exits the player.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
96 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
97 * \return nothing It does not return.
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
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
100 static void pnm_write_error(void) {
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
101 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
102 exit_player(MSGTR_Exit_error);
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 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
106
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
107 /** \brief Pre-initialisation.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
108 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
109 * 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
110 * 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
111 * (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
112 * option is stumbled upon) the player will exit.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
113 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
114 * \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
115 * output driver.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
116 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
117 * \return 0 All went well.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
118 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
119
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
120 static int preinit(const char *arg)
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
121 {
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
122 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
123 raw_mode = 0, ascii_mode = 0;
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
124 opt_t subopts[] = {
14850
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
125 {"ppm", OPT_ARG_BOOL, &ppm_type, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
126 {"pgm", OPT_ARG_BOOL, &pgm_type, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
127 {"pgmyuv", OPT_ARG_BOOL, &pgmyuv_type, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
128 {"raw", OPT_ARG_BOOL, &raw_mode, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
129 {"ascii", OPT_ARG_BOOL, &ascii_mode, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
130 {"outdir", OPT_ARG_MSTRZ, &pnm_outdir, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
131 {"subdirs", OPT_ARG_MSTRZ, &pnm_subdirs, NULL, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
132 {"maxfiles", OPT_ARG_INT, &pnm_maxfiles, (opt_test_f)int_pos, 0},
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
133 {NULL, 0, NULL, NULL, 0}
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
134 };
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
135 const char *info_message = NULL;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
136
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
137 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
138 MSGTR_VO_ParsingSuboptions);
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
139
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
140 pnm_maxfiles = 1000;
14538
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
141 pnm_outdir = strdup(".");
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
142 pnm_subdirs = NULL;
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
143
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
144 if (subopt_parse(arg, subopts) != 0) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
145 return -1;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
146 }
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
147
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
148 pnm_type = PNM_TYPE_PPM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
149 pnm_mode = PNM_RAW_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
150
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
151 if (pgmyuv_type) pnm_type = PNM_TYPE_PGMYUV;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
152 if (pgm_type) pnm_type = PNM_TYPE_PGM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
153 if (ppm_type) pnm_type = PNM_TYPE_PPM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
154 if (ascii_mode) pnm_mode = PNM_ASCII_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
155 if (raw_mode) pnm_mode = PNM_RAW_MODE;
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 switch (pnm_mode) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
158 case PNM_ASCII_MODE:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
159 info_message = MSGTR_VO_PNM_ASCIIMode;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
160 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
161 case PNM_RAW_MODE:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
162 info_message = MSGTR_VO_PNM_RawMode;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
163 break;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
164 }
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
165 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
166
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
167 switch (pnm_type) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
168 case PNM_TYPE_PPM:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
169 info_message = MSGTR_VO_PNM_PPMType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
170 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
171 case PNM_TYPE_PGM:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
172 info_message = MSGTR_VO_PNM_PGMType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
173 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
174 case PNM_TYPE_PGMYUV:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
175 info_message = MSGTR_VO_PNM_PGMYUVType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
176 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
177 }
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
178 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
179
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
180 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
181 MSGTR_VO_SuboptionsParsedOK);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
182 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
183 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
184
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
185 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
186
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
187 /** \brief Create a directory.
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 * 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
190 * 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
191 * the directory is writable or not.
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 * \param buf Pointer to directory name.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
194 * \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
195 * 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
196 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
197 * \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
198 * returns, everything went well.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
199 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
200
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
201 static void pnm_mkdir(char *buf, int verbose) {
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
202 struct stat stat_p;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
203
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
204 /* Silly MING32 bug workaround */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
205 #ifndef __MINGW32__
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
206 if ( mkdir(buf, 0755) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
207 #else
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
208 if ( mkdir(buf) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
209 #endif
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
210 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
211 and handled in the future */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
212 case EEXIST:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
213 if ( stat(buf, &stat_p ) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
214 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
215 MSGTR_VO_GenericError, strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
216 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
217 MSGTR_VO_UnableToAccess,buf);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
218 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
219 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
220 if ( !S_ISDIR(stat_p.st_mode) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
221 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
222 buf, MSGTR_VO_ExistsButNoDirectory);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
223 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
224 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
225 if ( !(stat_p.st_mode & S_IWUSR) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
226 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
227 buf, MSGTR_VO_DirExistsButNotWritable);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
228 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
229 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
230
14852
e563ad582f9e Don't print (stupid) message if output directory is .
ivo
parents: 14850
diff changeset
231 if (strcmp(buf, ".") != 0) {
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
232 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
233 buf, MSGTR_VO_DirExistsAndIsWritable);
14852
e563ad582f9e Don't print (stupid) message if output directory is .
ivo
parents: 14850
diff changeset
234 }
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
235 break;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
236
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
237 default:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
238 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
239 MSGTR_VO_GenericError, strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
240 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
241 buf, MSGTR_VO_CantCreateDirectory);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
242 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
243 } /* end switch */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
244 } else if ( verbose ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
245 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
246 buf, MSGTR_VO_DirectoryCreateSuccess);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
247 } /* end if */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
248 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
249
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
250 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
251
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
252 /** \brief Configure the video output driver.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
253 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
254 * 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
255 * 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
256 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
257 * \return 0 All went well.
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
260 static int config(uint32_t width, uint32_t height, uint32_t d_width,
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14852
diff changeset
261 uint32_t d_height, uint32_t flags, char *title,
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
262 uint32_t format)
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 char buf[BUFLENGTH];
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 if (vo_config_count > 0 ) { /* Already configured */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
267 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
268 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
269
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
270 /* Create outdir. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
271
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
272 snprintf(buf, BUFLENGTH, "%s", pnm_outdir);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
273 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
274 successful. If not, the player will exit. */
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 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
277 pnm_file_extension = strdup("ppm");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
278 } else if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
279 pnm_file_extension = strdup("pgm");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
280 } else if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
281 pnm_file_extension = strdup("pgmyuv");
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
284 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
285 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
286
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
287 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
288
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
289 /** \brief Write PNM file to output file
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 * 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
292 * 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
293 * 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
294 * a RAW or an ASCII file.
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 * \param outfile Filedescriptor of output file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
297 * \param mpi The image to write.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
298 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
299 * \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
300 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
301
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
302 static void pnm_write_pnm(FILE *outfile, mp_image_t *mpi)
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
303 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
304 uint32_t w = mpi->w;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
305 uint32_t h = mpi->h;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
306 uint8_t *rgbimage = mpi->planes[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
307 uint8_t *planeY = mpi->planes[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
308 uint8_t *planeU = mpi->planes[1];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
309 uint8_t *planeV = mpi->planes[2];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
310 uint8_t *curline;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
311 uint32_t strideY = mpi->stride[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
312 uint32_t strideU = mpi->stride[1];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
313 uint32_t strideV = mpi->stride[2];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
314
14850
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
315 unsigned int i, j;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
316
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
317 if (pnm_mode == PNM_RAW_MODE) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
318
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
319 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
320 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
321 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
322 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
323 } else if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
324 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
325 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
326 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
327 if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
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 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
330 } else if (pnm_type == PNM_TYPE_PGMYUV) {
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*3/2) < 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 w = w / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
338 h = h / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
339 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
340 if ( fwrite(planeU + i * strideU, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
341 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
342 if ( fwrite(planeV + i * strideV, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
343 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
344 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
345 } /* end if pnm_type */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
346
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
347 } else if (pnm_mode == PNM_ASCII_MODE) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
348
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
349 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
350 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
351 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
352 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
353 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
354 PNM_LINE15(rgbimage,i) ) < 0 ) pnm_write_error();
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 while (i < (w * h * 3) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
357 if ( fprintf(outfile, "%03d ", rgbimage[i]) < 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 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
360 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
361 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
362 } else if ( (pnm_type == PNM_TYPE_PGM) ||
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
363 (pnm_type == PNM_TYPE_PGMYUV) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
364
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
365 /* different header for pgm and pgmyuv. pgmyuv is 'higher' */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
366 if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
367 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
368 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
369 } else { /* PNM_TYPE_PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
370 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
371 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
372 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
373
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
374 /* output Y plane for both PGM and PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
375 for (j=0; j<h; j++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
376 curline = planeY + strideY * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
377 for (i=0; i <= w - 16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
378 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
379 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
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 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
382 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
383 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
384 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
385 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
386 if ( fputc('\n', outfile) < 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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
389 /* also output U and V planes fpr PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
390 if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
391 w = w / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
392 h = h / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
393 for (j=0; j<h; j++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
394 curline = planeU + strideU * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
395 for (i=0; i<= w-16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
396 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
397 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
398 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
399 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
400 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
401 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
402 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
403 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
404 if ( fputc('\n', outfile) < 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 curline = planeV + strideV * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
407 for (i=0; i<= w-16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
408 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
409 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
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 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
412 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
413 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
414 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
415 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
416 if ( fputc('\n', outfile) < 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 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
419
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
420 } /* end if pnm_type */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
421 } /* end if pnm_mode */
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
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 /** \brief Write a PNM image.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
427 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
428 * 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
429 * 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
430 * actually write the image to disk.
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 * \param mpi The image to write.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
433 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
434 * \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
435 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
436
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
437 static void pnm_write_image(mp_image_t *mpi)
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
438 {
14850
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
439 static int framenum = 0, framecounter = 0, subdircounter = 0;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
440 char buf[BUFLENGTH];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
441 static char subdirname[BUFLENGTH] = "";
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
442 FILE *outfile;
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 if (!mpi) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
445 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
446 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
447 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
448
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
449 /* 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
450 if ( framecounter == pnm_maxfiles ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
451 framecounter = 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
452 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
453
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
454 /* 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
455 * number and create the subdirectory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
456 * If pnm_subdirs is not set, do nothing. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
457 if ( !framecounter && pnm_subdirs ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
458 subdircounter++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
459 snprintf(subdirname, BUFLENGTH, "%s%08d", pnm_subdirs, subdircounter);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
460 snprintf(buf, BUFLENGTH, "%s/%s", pnm_outdir, subdirname);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
461 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
462 successful. If not, the player will exit. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
463 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
464
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
465 framenum++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
466 framecounter++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
467
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
468 /* snprintf the full pathname of the outputfile */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
469 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
470 framenum, pnm_file_extension);
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 if ( (outfile = fopen(buf, "wb") ) == NULL ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
473 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
474 MSGTR_VO_CantCreateFile);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
475 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
476 info.short_name, MSGTR_VO_GenericError,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
477 strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
478 exit_player(MSGTR_Exit_error);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
479 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
480
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
481 pnm_write_pnm(outfile, mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
482
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
483 fclose(outfile);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
484 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
485
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 static uint32_t draw_image(mp_image_t *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 if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Planar */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
491 if (mpi->flags & MP_IMGFLAG_YUV) { /* Planar YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
492 pnm_write_image(mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
493 return VO_TRUE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
494 } else { /* Planar RGB */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
495 return VO_FALSE;
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 } else { /* Packed */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
498 if (mpi->flags & MP_IMGFLAG_YUV) { /* Packed YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
499 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
500 } else { /* Packed RGB */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
501 pnm_write_image(mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
502 return VO_TRUE;
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 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
505
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 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
508
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
509 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
510
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
511 static int draw_frame(uint8_t *src[])
13394
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 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
514 return -1;
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
519 static int draw_slice(uint8_t *src[], int stride[], int w, int h,
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
520 int x, int y)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
521 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
522 return 0;
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
527 static int query_format(uint32_t format)
13394
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 /* 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
530 * Planar YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
531 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
532 if (format == IMGFMT_RGB24) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
533 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
534 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
535 } 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
536 if (format == IMGFMT_YV12) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
537 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
538 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
539 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
540
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
541 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
542 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
543
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
544 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
545
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
546 static int control(uint32_t request, void *data, ...)
13394
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 switch (request) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
549 case VOCTRL_QUERY_FORMAT:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
550 return query_format(*((uint32_t*)data));
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
551 case VOCTRL_DRAW_IMAGE:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
552 return draw_image(data);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
553 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
554 return VO_NOTIMPL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
555 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
556
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
557 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
558
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
559 static void uninit(void)
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 if (pnm_subdirs) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
562 free(pnm_subdirs);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
563 pnm_subdirs = NULL;
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 if (pnm_outdir) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
566 free(pnm_outdir);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
567 pnm_outdir = NULL;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
568 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
569 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
570
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
573 static void check_events(void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
574 {
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 static void draw_osd(void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
580 {
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 static void flip_page (void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
586 {
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 #undef BUFLENGTH
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
592 #undef PNM_RAW_MODE
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
593 #undef PNM_ASCII_MODE
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
594 #undef PNM_TYPE_PPM
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
595 #undef PNM_TYPE_PGM
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
596 #undef PNM_TYPE_PGMYUV
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 /* ------------------------------------------------------------------------- */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
599