annotate libvo/vo_pnm.c @ 35999:135a2c940db8

Remove HideSkinBrowser(). Simply destroy the window. (It's pointless to check whether the window is existing, because it cannot be called without an existing window.)
author ib
date Fri, 29 Mar 2013 17:15:19 +0000
parents ddb45e9443ec
children cd83754e4f3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
1 /*
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
2 * PPM/PGM/PGMYUV video output driver
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
3 *
27507
25b896bc75f3 license header cosmetics
diego
parents: 26739
diff changeset
4 * copyright (C) 2004, 2005 Ivo van Poorten
25173
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
5 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
6 * This file is part of MPlayer.
25173
3e7c196c27d3 Proper license header.
ivo
parents: 25172
diff changeset
7 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
9 * it under the terms of the GNU General Public License as published by
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
11 * (at your option) any later version.
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
12 *
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
25173
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 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
18 * You should have received a copy of the GNU General Public License along
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
20 * 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 /* 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"
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
42 #include "mp_core.h" /* for exit_player() */
13394
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
25216
3aee342be929 Make vo info structs const
reimar
parents: 25173
diff changeset
67 static const vo_info_t info=
13394
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
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
75 const LIBVO_EXTERN (pnm)
13394
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
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
99 static void pnm_write_error(void) {
13394
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);
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
101 exit_player(EXIT_ERROR);
13394
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
106 /** \brief Pre-initialisation.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
107 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
108 * 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
109 * 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
110 * (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
111 * option is stumbled upon) the player will exit.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
112 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
113 * \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
114 * output driver.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
115 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
116 * \return 0 All went well.
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
119 static int preinit(const char *arg)
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
120 {
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
121 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
122 raw_mode = 0, ascii_mode = 0;
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 27507
diff changeset
123 const opt_t subopts[] = {
28922
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
124 {"ppm", OPT_ARG_BOOL, &ppm_type, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
125 {"pgm", OPT_ARG_BOOL, &pgm_type, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
126 {"pgmyuv", OPT_ARG_BOOL, &pgmyuv_type, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
127 {"raw", OPT_ARG_BOOL, &raw_mode, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
128 {"ascii", OPT_ARG_BOOL, &ascii_mode, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
129 {"outdir", OPT_ARG_MSTRZ, &pnm_outdir, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
130 {"subdirs", OPT_ARG_MSTRZ, &pnm_subdirs, NULL},
30122
1772a5171ac7 Fix function declarations to avoid casting function pointers.
reimar
parents: 29263
diff changeset
131 {"maxfiles", OPT_ARG_INT, &pnm_maxfiles, int_pos},
28922
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
132 {NULL, 0, NULL, NULL}
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
133 };
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
134 const char *info_message = NULL;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
135
31287
168e89b341b1 Reduce verbosity about suboption parsing in vo drivers.
diego
parents: 30633
diff changeset
136 mp_msg(MSGT_VO, MSGL_V, "%s: %s\n", info.short_name,
168e89b341b1 Reduce verbosity about suboption parsing in vo drivers.
diego
parents: 30633
diff changeset
137 "Parsing suboptions.");
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
138
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
139 pnm_maxfiles = 1000;
14538
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
140 pnm_outdir = strdup(".");
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14506
diff changeset
141 pnm_subdirs = NULL;
14506
f5ef32b4bdd3 1l. parser can work with pnm_maxfiles directly
ivo
parents: 14504
diff changeset
142
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
143 if (subopt_parse(arg, subopts) != 0) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
144 return -1;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
145 }
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 pnm_type = PNM_TYPE_PPM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
148 pnm_mode = PNM_RAW_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
149
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
150 if (pgmyuv_type) pnm_type = PNM_TYPE_PGMYUV;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
151 if (pgm_type) pnm_type = PNM_TYPE_PGM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
152 if (ppm_type) pnm_type = PNM_TYPE_PPM;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
153 if (ascii_mode) pnm_mode = PNM_ASCII_MODE;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
154 if (raw_mode) pnm_mode = PNM_RAW_MODE;
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 switch (pnm_mode) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
157 case PNM_ASCII_MODE:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
158 info_message = MSGTR_VO_PNM_ASCIIMode;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
159 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
160 case PNM_RAW_MODE:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
161 info_message = MSGTR_VO_PNM_RawMode;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
162 break;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
163 }
14504
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
164 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
165
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
166 switch (pnm_type) {
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
167 case PNM_TYPE_PPM:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
168 info_message = MSGTR_VO_PNM_PPMType;
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_TYPE_PGM:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
171 info_message = MSGTR_VO_PNM_PGMType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
172 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
173 case PNM_TYPE_PGMYUV:
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
174 info_message = MSGTR_VO_PNM_PGMYUVType;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
175 break;
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
176 }
e394a9cfaf3f Transition of suboption parser to subopt-helper parser.
ivo
parents: 13394
diff changeset
177 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
178
31287
168e89b341b1 Reduce verbosity about suboption parsing in vo drivers.
diego
parents: 30633
diff changeset
179 mp_msg(MSGT_VO, MSGL_V, "%s: %s\n", info.short_name,
168e89b341b1 Reduce verbosity about suboption parsing in vo drivers.
diego
parents: 30633
diff changeset
180 "Suboptions parsed OK.");
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
181 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
182 }
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 /** \brief Create a directory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
187 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
188 * 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
189 * 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
190 * the directory is writable or not.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
191 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
192 * \param buf Pointer to directory name.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
193 * \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
194 * 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
195 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
196 * \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
197 * returns, everything went well.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
198 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
199
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
200 static void pnm_mkdir(char *buf, int verbose) {
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
201 struct stat stat_p;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
202
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
203 /* Silly MING32 bug workaround */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
204 #ifndef __MINGW32__
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
205 if ( mkdir(buf, 0755) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
206 #else
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
207 if ( mkdir(buf) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
208 #endif
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
209 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
210 and handled in the future */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
211 case EEXIST:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
212 if ( stat(buf, &stat_p ) < 0 ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
213 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
214 MSGTR_VO_GenericError, strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
215 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
216 MSGTR_VO_UnableToAccess,buf);
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
217 exit_player(EXIT_ERROR);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
218 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
219 if ( !S_ISDIR(stat_p.st_mode) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
220 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
221 buf, MSGTR_VO_ExistsButNoDirectory);
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
222 exit_player(EXIT_ERROR);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
223 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
224 if ( !(stat_p.st_mode & S_IWUSR) ) {
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 buf, MSGTR_VO_DirExistsButNotWritable);
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
227 exit_player(EXIT_ERROR);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
228 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
229
14852
e563ad582f9e Don't print (stupid) message if output directory is .
ivo
parents: 14850
diff changeset
230 if (strcmp(buf, ".") != 0) {
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
231 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
232 buf, MSGTR_VO_DirExistsAndIsWritable);
14852
e563ad582f9e Don't print (stupid) message if output directory is .
ivo
parents: 14850
diff changeset
233 }
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
234 break;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
235
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
236 default:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
237 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
238 MSGTR_VO_GenericError, strerror(errno) );
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
239 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
240 buf, MSGTR_VO_CantCreateDirectory);
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
241 exit_player(EXIT_ERROR);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
242 } /* end switch */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
243 } else if ( verbose ) {
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
244 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
245 buf, MSGTR_VO_DirectoryCreateSuccess);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
246 } /* end if */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
247 }
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 /** \brief Configure the video output driver.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
252 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
253 * 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
254 * 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
255 *
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
256 * \return 0 All went well.
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
259 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
260 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
261 uint32_t format)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
262 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
263 char buf[BUFLENGTH];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
264
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
265 if (vo_config_count > 0 ) { /* Already configured */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
266 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
267 }
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 /* Create outdir. */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
270
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
271 snprintf(buf, BUFLENGTH, "%s", pnm_outdir);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
272 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
273 successful. If not, the player will exit. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
274
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
275 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
276 pnm_file_extension = strdup("ppm");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
277 } else if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
278 pnm_file_extension = strdup("pgm");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
279 } else if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
280 pnm_file_extension = strdup("pgmyuv");
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
281 }
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 return 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
284 }
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 /** \brief Write PNM file to output file
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 * 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
291 * 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
292 * 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
293 * a RAW or an ASCII file.
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 * \param outfile Filedescriptor of output file.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
296 * \param mpi The image to write.
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 * \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
299 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
300
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
301 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
302 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
303 uint32_t w = mpi->w;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
304 uint32_t h = mpi->h;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
305 uint8_t *rgbimage = mpi->planes[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
306 uint8_t *planeY = mpi->planes[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
307 uint8_t *planeU = mpi->planes[1];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
308 uint8_t *planeV = mpi->planes[2];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
309 uint8_t *curline;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
310 uint32_t strideY = mpi->stride[0];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
311 uint32_t strideU = mpi->stride[1];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
312 uint32_t strideV = mpi->stride[2];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
313
14850
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
314 unsigned int i, j;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
315
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
316 if (pnm_mode == PNM_RAW_MODE) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
317
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
318 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
319 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
320 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
321 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
322 } else if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
323 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
324 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
325 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
326 if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
327 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
328 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
329 } else if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
330 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
331 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
332 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
333 if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
334 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
335 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
336 w = w / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
337 h = h / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
338 for (i=0; i<h; i++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
339 if ( fwrite(planeU + i * strideU, w, 1, outfile) < 1 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
340 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
341 if ( fwrite(planeV + i * strideV, 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 } /* end if pnm_type */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
345
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
346 } else if (pnm_mode == PNM_ASCII_MODE) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
347
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
348 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
349 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
350 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
351 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
352 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
353 PNM_LINE15(rgbimage,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
354 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
355 while (i < (w * h * 3) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
356 if ( fprintf(outfile, "%03d ", rgbimage[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
357 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
358 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
359 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
360 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
361 } else if ( (pnm_type == PNM_TYPE_PGM) ||
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
362 (pnm_type == PNM_TYPE_PGMYUV) ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
363
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
364 /* different header for pgm and pgmyuv. pgmyuv is 'higher' */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
365 if (pnm_type == PNM_TYPE_PGM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
366 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
367 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
368 } else { /* PNM_TYPE_PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
369 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
370 pnm_write_error();
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
373 /* output Y plane for both PGM and PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
374 for (j=0; j<h; j++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
375 curline = planeY + strideY * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
376 for (i=0; i <= w - 16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
377 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
378 PNM_LINE15(curline,i) ) < 0 ) 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 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
381 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
382 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
383 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
384 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
385 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
386 }
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 /* also output U and V planes fpr PGMYUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
389 if (pnm_type == PNM_TYPE_PGMYUV) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
390 w = w / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
391 h = h / 2;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
392 for (j=0; j<h; j++) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
393 curline = planeU + strideU * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
394 for (i=0; i<= w-16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
395 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
396 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
397 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
398 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
399 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
400 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
401 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
402 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
403 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
404
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
405 curline = planeV + strideV * j;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
406 for (i=0; i<= w-16; i+=15) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
407 if ( fprintf(outfile, PNM_LINE_OF_ASCII,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
408 PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
409 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
410 while (i < w ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
411 if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
412 pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
413 i++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
414 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
415 if ( fputc('\n', outfile) < 0 ) pnm_write_error();
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
416 }
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 } /* end if pnm_type */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
420 } /* end if pnm_mode */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
421 }
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 /** \brief Write a PNM image.
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 * 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
428 * 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
429 * actually write the image to disk.
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 * \param mpi The image to write.
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 * \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
434 */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
435
18950
a943bc3f26c8 Make some functions static.
uau
parents: 16171
diff changeset
436 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
437 {
14850
ba555409718b Fix compile warnings
ivo
parents: 14736
diff changeset
438 static int framenum = 0, framecounter = 0, subdircounter = 0;
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
439 char buf[BUFLENGTH];
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
440 static char subdirname[BUFLENGTH] = "";
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
441 FILE *outfile;
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 if (!mpi) {
31834
64ba1daa147a various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents: 31287
diff changeset
444 mp_msg(MSGT_VO, MSGL_ERR, "%s: No image data supplied to video output driver\n", info.short_name );
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
445 exit_player(EXIT_ERROR);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
446 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
447
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
448 /* 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
449 if ( framecounter == pnm_maxfiles ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
450 framecounter = 0;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
451 }
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 /* 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
454 * number and create the subdirectory.
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
455 * If pnm_subdirs is not set, do nothing. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
456 if ( !framecounter && pnm_subdirs ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
457 subdircounter++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
458 snprintf(subdirname, BUFLENGTH, "%s%08d", pnm_subdirs, subdircounter);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
459 snprintf(buf, BUFLENGTH, "%s/%s", pnm_outdir, subdirname);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
460 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
461 successful. If not, the player will exit. */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
462 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
463
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
464 framenum++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
465 framecounter++;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
466
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
467 /* snprintf the full pathname of the outputfile */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
468 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
469 framenum, pnm_file_extension);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
470
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
471 if ( (outfile = fopen(buf, "wb") ) == NULL ) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
472 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
473 MSGTR_VO_CantCreateFile);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
474 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
475 info.short_name, MSGTR_VO_GenericError,
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
476 strerror(errno) );
30516
f4e017b6921a Fix exit_player() usage throughout the codebase.
diego
parents: 30122
diff changeset
477 exit_player(EXIT_ERROR);
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
478 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
479
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
480 pnm_write_pnm(outfile, mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
481
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
482 fclose(outfile);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
483 }
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 static uint32_t draw_image(mp_image_t *mpi)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
488 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
489 if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Planar */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
490 if (mpi->flags & MP_IMGFLAG_YUV) { /* Planar YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
491 pnm_write_image(mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
492 return VO_TRUE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
493 } else { /* Planar RGB */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
494 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
495 }
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
496 } else { /* Packed */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
497 if (mpi->flags & MP_IMGFLAG_YUV) { /* Packed YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
498 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
499 } else { /* Packed RGB */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
500 pnm_write_image(mpi);
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
501 return VO_TRUE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
502 }
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 return VO_FALSE;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
506 }
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
510 static int draw_frame(uint8_t *src[])
13394
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 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
513 return -1;
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
518 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
519 int x, int y)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
520 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
521 return 0;
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
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
526 static int query_format(uint32_t format)
13394
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
527 {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
528 /* 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
529 * Planar YUV */
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
530 if (pnm_type == PNM_TYPE_PPM) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
531 if (format == IMGFMT_RGB24) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
532 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
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 } 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
535 if (format == IMGFMT_YV12) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
536 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
537 }
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 return 0;
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
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
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 32537
diff changeset
545 static int control(uint32_t request, void *data)
13394
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 switch (request) {
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
548 case VOCTRL_QUERY_FORMAT:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
549 return query_format(*((uint32_t*)data));
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
550 case VOCTRL_DRAW_IMAGE:
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
551 return draw_image(data);
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 return VO_NOTIMPL;
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
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 static void uninit(void)
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
559 {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31834
diff changeset
560 free(pnm_subdirs);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31834
diff changeset
561 pnm_subdirs = NULL;
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31834
diff changeset
562 free(pnm_outdir);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31834
diff changeset
563 pnm_outdir = NULL;
13394
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 /* ------------------------------------------------------------------------- */
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 static void check_events(void)
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
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
574 static void draw_osd(void)
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 flip_page (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 #undef BUFLENGTH
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
587 #undef PNM_RAW_MODE
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
588 #undef PNM_ASCII_MODE
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
589 #undef PNM_TYPE_PPM
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
590 #undef PNM_TYPE_PGM
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
591 #undef PNM_TYPE_PGMYUV
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
592
455a5056801f New generic 'portable anymap' video output driver. It supports portable
ivo
parents:
diff changeset
593 /* ------------------------------------------------------------------------- */