comparison pnmenc.c @ 10459:a6bb56636f90 libavcodec

whitespace cosmetics: K&R coding style, prettyprinting
author diego
date Tue, 27 Oct 2009 16:57:35 +0000
parents 511cbeb9fb4b
children 059265d3cc65
comparison
equal deleted inserted replaced
10458:511cbeb9fb4b 10459:a6bb56636f90
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public 17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software 18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21
21 #include "avcodec.h" 22 #include "avcodec.h"
22 #include "bytestream.h" 23 #include "bytestream.h"
23 #include "pnm.h" 24 #include "pnm.h"
24 25
25 26
26 static av_cold int common_init(AVCodecContext *avctx){ 27 static av_cold int common_init(AVCodecContext *avctx)
28 {
27 PNMContext *s = avctx->priv_data; 29 PNMContext *s = avctx->priv_data;
28 30
29 avcodec_get_frame_defaults((AVFrame*)&s->picture); 31 avcodec_get_frame_defaults((AVFrame*)&s->picture);
30 avctx->coded_frame= (AVFrame*)&s->picture; 32 avctx->coded_frame = (AVFrame*)&s->picture;
31 33
32 return 0; 34 return 0;
33 } 35 }
34 36
35 static int pnm_decode_frame(AVCodecContext *avctx, 37 static int pnm_decode_frame(AVCodecContext *avctx, void *data,
36 void *data, int *data_size, 38 int *data_size, AVPacket *avpkt)
37 AVPacket *avpkt)
38 { 39 {
39 const uint8_t *buf = avpkt->data; 40 const uint8_t *buf = avpkt->data;
40 int buf_size = avpkt->size; 41 int buf_size = avpkt->size;
41 PNMContext * const s = avctx->priv_data; 42 PNMContext * const s = avctx->priv_data;
42 AVFrame *picture = data; 43 AVFrame *picture = data;
43 AVFrame * const p= (AVFrame*)&s->picture; 44 AVFrame * const p = (AVFrame*)&s->picture;
44 int i, n, linesize, h, upgrade = 0; 45 int i, n, linesize, h, upgrade = 0;
45 unsigned char *ptr; 46 unsigned char *ptr;
46 47
47 s->bytestream_start= 48 s->bytestream_start =
48 s->bytestream= buf; 49 s->bytestream = buf;
49 s->bytestream_end= buf + buf_size; 50 s->bytestream_end = buf + buf_size;
50 51
51 if(ff_pnm_decode_header(avctx, s) < 0) 52 if (ff_pnm_decode_header(avctx, s) < 0)
52 return -1; 53 return -1;
53 54
54 if(p->data[0]) 55 if (p->data[0])
55 avctx->release_buffer(avctx, p); 56 avctx->release_buffer(avctx, p);
56 57
57 p->reference= 0; 58 p->reference = 0;
58 if(avctx->get_buffer(avctx, p) < 0){ 59 if (avctx->get_buffer(avctx, p) < 0) {
59 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); 60 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
60 return -1; 61 return -1;
61 } 62 }
62 p->pict_type= FF_I_TYPE; 63 p->pict_type = FF_I_TYPE;
63 p->key_frame= 1; 64 p->key_frame = 1;
64 65
65 switch(avctx->pix_fmt) { 66 switch (avctx->pix_fmt) {
66 default: 67 default:
67 return -1; 68 return -1;
68 case PIX_FMT_RGB48BE: 69 case PIX_FMT_RGB48BE:
69 n = avctx->width * 6; 70 n = avctx->width * 6;
70 goto do_read; 71 goto do_read;
84 goto do_read; 85 goto do_read;
85 case PIX_FMT_MONOWHITE: 86 case PIX_FMT_MONOWHITE:
86 case PIX_FMT_MONOBLACK: 87 case PIX_FMT_MONOBLACK:
87 n = (avctx->width + 7) >> 3; 88 n = (avctx->width + 7) >> 3;
88 do_read: 89 do_read:
89 ptr = p->data[0]; 90 ptr = p->data[0];
90 linesize = p->linesize[0]; 91 linesize = p->linesize[0];
91 if(s->bytestream + n*avctx->height > s->bytestream_end) 92 if (s->bytestream + n * avctx->height > s->bytestream_end)
92 return -1; 93 return -1;
93 for(i = 0; i < avctx->height; i++) { 94 for (i = 0; i < avctx->height; i++) {
94 if (!upgrade) 95 if (!upgrade)
95 memcpy(ptr, s->bytestream, n); 96 memcpy(ptr, s->bytestream, n);
96 else if (upgrade == 1) { 97 else if (upgrade == 1) {
97 unsigned int j, f = (255*128 + s->maxval/2) / s->maxval; 98 unsigned int j, f = (255 * 128 + s->maxval / 2) / s->maxval;
98 for (j=0; j<n; j++) 99 for (j = 0; j < n; j++)
99 ptr[j] = (s->bytestream[j] * f + 64) >> 7; 100 ptr[j] = (s->bytestream[j] * f + 64) >> 7;
100 } else if (upgrade == 2) { 101 } else if (upgrade == 2) {
101 unsigned int j, v, f = (65535*32768 + s->maxval/2) / s->maxval; 102 unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval;
102 for (j=0; j<n/2; j++) { 103 for (j = 0; j < n / 2; j++) {
103 v = be2me_16(((uint16_t *)s->bytestream)[j]); 104 v = be2me_16(((uint16_t *)s->bytestream)[j]);
104 ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15; 105 ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
105 } 106 }
106 } 107 }
107 s->bytestream += n; 108 s->bytestream += n;
108 ptr += linesize; 109 ptr += linesize;
109 } 110 }
110 break; 111 break;
111 case PIX_FMT_YUV420P: 112 case PIX_FMT_YUV420P:
112 { 113 {
113 unsigned char *ptr1, *ptr2; 114 unsigned char *ptr1, *ptr2;
114 115
115 n = avctx->width; 116 n = avctx->width;
116 ptr = p->data[0]; 117 ptr = p->data[0];
117 linesize = p->linesize[0]; 118 linesize = p->linesize[0];
118 if(s->bytestream + n*avctx->height*3/2 > s->bytestream_end) 119 if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
119 return -1; 120 return -1;
120 for(i = 0; i < avctx->height; i++) { 121 for (i = 0; i < avctx->height; i++) {
121 memcpy(ptr, s->bytestream, n); 122 memcpy(ptr, s->bytestream, n);
122 s->bytestream += n; 123 s->bytestream += n;
123 ptr += linesize; 124 ptr += linesize;
124 } 125 }
125 ptr1 = p->data[1]; 126 ptr1 = p->data[1];
126 ptr2 = p->data[2]; 127 ptr2 = p->data[2];
127 n >>= 1; 128 n >>= 1;
128 h = avctx->height >> 1; 129 h = avctx->height >> 1;
129 for(i = 0; i < h; i++) { 130 for (i = 0; i < h; i++) {
130 memcpy(ptr1, s->bytestream, n); 131 memcpy(ptr1, s->bytestream, n);
131 s->bytestream += n; 132 s->bytestream += n;
132 memcpy(ptr2, s->bytestream, n); 133 memcpy(ptr2, s->bytestream, n);
133 s->bytestream += n; 134 s->bytestream += n;
134 ptr1 += p->linesize[1]; 135 ptr1 += p->linesize[1];
135 ptr2 += p->linesize[2]; 136 ptr2 += p->linesize[2];
136 } 137 }
137 } 138 }
138 break; 139 break;
139 case PIX_FMT_RGB32: 140 case PIX_FMT_RGB32:
140 ptr = p->data[0]; 141 ptr = p->data[0];
141 linesize = p->linesize[0]; 142 linesize = p->linesize[0];
142 if(s->bytestream + avctx->width*avctx->height*4 > s->bytestream_end) 143 if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end)
143 return -1; 144 return -1;
144 for(i = 0; i < avctx->height; i++) { 145 for (i = 0; i < avctx->height; i++) {
145 int j, r, g, b, a; 146 int j, r, g, b, a;
146 147
147 for(j = 0;j < avctx->width; j++) { 148 for (j = 0; j < avctx->width; j++) {
148 r = *s->bytestream++; 149 r = *s->bytestream++;
149 g = *s->bytestream++; 150 g = *s->bytestream++;
150 b = *s->bytestream++; 151 b = *s->bytestream++;
151 a = *s->bytestream++; 152 a = *s->bytestream++;
152 ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b; 153 ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
153 } 154 }
154 ptr += linesize; 155 ptr += linesize;
155 } 156 }
156 break; 157 break;
157 } 158 }
158 *picture= *(AVFrame*)&s->picture; 159 *picture = *(AVFrame*)&s->picture;
159 *data_size = sizeof(AVPicture); 160 *data_size = sizeof(AVPicture);
160 161
161 return s->bytestream - s->bytestream_start; 162 return s->bytestream - s->bytestream_start;
162 } 163 }
163 164
164 static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){ 165 static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
165 PNMContext *s = avctx->priv_data; 166 int buf_size, void *data)
166 AVFrame *pict = data; 167 {
167 AVFrame * const p= (AVFrame*)&s->picture; 168 PNMContext *s = avctx->priv_data;
169 AVFrame *pict = data;
170 AVFrame * const p = (AVFrame*)&s->picture;
168 int i, h, h1, c, n, linesize; 171 int i, h, h1, c, n, linesize;
169 uint8_t *ptr, *ptr1, *ptr2; 172 uint8_t *ptr, *ptr1, *ptr2;
170 173
171 if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){ 174 if (buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200) {
172 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); 175 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
173 return -1; 176 return -1;
174 } 177 }
175 178
176 *p = *pict; 179 *p = *pict;
177 p->pict_type= FF_I_TYPE; 180 p->pict_type = FF_I_TYPE;
178 p->key_frame= 1; 181 p->key_frame = 1;
179 182
180 s->bytestream_start= 183 s->bytestream_start =
181 s->bytestream= outbuf; 184 s->bytestream = outbuf;
182 s->bytestream_end= outbuf+buf_size; 185 s->bytestream_end = outbuf + buf_size;
183 186
184 h = avctx->height; 187 h = avctx->height;
185 h1 = h; 188 h1 = h;
186 switch(avctx->pix_fmt) { 189 switch (avctx->pix_fmt) {
187 case PIX_FMT_MONOWHITE: 190 case PIX_FMT_MONOWHITE:
188 c = '4'; 191 c = '4';
189 n = (avctx->width + 7) >> 3; 192 n = (avctx->width + 7) >> 3;
190 break; 193 break;
191 case PIX_FMT_GRAY8: 194 case PIX_FMT_GRAY8:
192 c = '5'; 195 c = '5';
193 n = avctx->width; 196 n = avctx->width;
194 break; 197 break;
195 case PIX_FMT_GRAY16BE: 198 case PIX_FMT_GRAY16BE:
196 c = '5'; 199 c = '5';
197 n = avctx->width * 2; 200 n = avctx->width * 2;
198 break; 201 break;
199 case PIX_FMT_RGB24: 202 case PIX_FMT_RGB24:
200 c = '6'; 203 c = '6';
201 n = avctx->width * 3; 204 n = avctx->width * 3;
202 break; 205 break;
203 case PIX_FMT_RGB48BE: 206 case PIX_FMT_RGB48BE:
204 c = '6'; 207 c = '6';
205 n = avctx->width * 6; 208 n = avctx->width * 6;
206 break; 209 break;
207 case PIX_FMT_YUV420P: 210 case PIX_FMT_YUV420P:
208 c = '5'; 211 c = '5';
209 n = avctx->width; 212 n = avctx->width;
210 h1 = (h * 3) / 2; 213 h1 = (h * 3) / 2;
211 break; 214 break;
212 default: 215 default:
213 return -1; 216 return -1;
214 } 217 }
215 snprintf(s->bytestream, s->bytestream_end - s->bytestream, 218 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
216 "P%c\n%d %d\n", 219 "P%c\n%d %d\n", c, avctx->width, h1);
217 c, avctx->width, h1);
218 s->bytestream += strlen(s->bytestream); 220 s->bytestream += strlen(s->bytestream);
219 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) { 221 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
220 snprintf(s->bytestream, s->bytestream_end - s->bytestream, 222 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
221 "%d\n", (avctx->pix_fmt != PIX_FMT_GRAY16BE && avctx->pix_fmt != PIX_FMT_RGB48BE) ? 255 : 65535); 223 "%d\n", (avctx->pix_fmt != PIX_FMT_GRAY16BE && avctx->pix_fmt != PIX_FMT_RGB48BE) ? 255 : 65535);
222 s->bytestream += strlen(s->bytestream); 224 s->bytestream += strlen(s->bytestream);
223 } 225 }
224 226
225 ptr = p->data[0]; 227 ptr = p->data[0];
226 linesize = p->linesize[0]; 228 linesize = p->linesize[0];
227 for(i=0;i<h;i++) { 229 for (i = 0; i < h; i++) {
228 memcpy(s->bytestream, ptr, n); 230 memcpy(s->bytestream, ptr, n);
229 s->bytestream += n; 231 s->bytestream += n;
230 ptr += linesize; 232 ptr += linesize;
231 } 233 }
232 234
233 if (avctx->pix_fmt == PIX_FMT_YUV420P) { 235 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
234 h >>= 1; 236 h >>= 1;
235 n >>= 1; 237 n >>= 1;
236 ptr1 = p->data[1]; 238 ptr1 = p->data[1];
237 ptr2 = p->data[2]; 239 ptr2 = p->data[2];
238 for(i=0;i<h;i++) { 240 for (i = 0; i < h; i++) {
239 memcpy(s->bytestream, ptr1, n); 241 memcpy(s->bytestream, ptr1, n);
240 s->bytestream += n; 242 s->bytestream += n;
241 memcpy(s->bytestream, ptr2, n); 243 memcpy(s->bytestream, ptr2, n);
242 s->bytestream += n; 244 s->bytestream += n;
243 ptr1 += p->linesize[1]; 245 ptr1 += p->linesize[1];
245 } 247 }
246 } 248 }
247 return s->bytestream - s->bytestream_start; 249 return s->bytestream - s->bytestream_start;
248 } 250 }
249 251
250 static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){ 252 static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
251 PNMContext *s = avctx->priv_data; 253 int buf_size, void *data)
252 AVFrame *pict = data; 254 {
253 AVFrame * const p= (AVFrame*)&s->picture; 255 PNMContext *s = avctx->priv_data;
256 AVFrame *pict = data;
257 AVFrame * const p = (AVFrame*)&s->picture;
254 int i, h, w, n, linesize, depth, maxval; 258 int i, h, w, n, linesize, depth, maxval;
255 const char *tuple_type; 259 const char *tuple_type;
256 uint8_t *ptr; 260 uint8_t *ptr;
257 261
258 if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){ 262 if (buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200) {
259 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); 263 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
260 return -1; 264 return -1;
261 } 265 }
262 266
263 *p = *pict; 267 *p = *pict;
264 p->pict_type= FF_I_TYPE; 268 p->pict_type = FF_I_TYPE;
265 p->key_frame= 1; 269 p->key_frame = 1;
266 270
267 s->bytestream_start= 271 s->bytestream_start =
268 s->bytestream= outbuf; 272 s->bytestream = outbuf;
269 s->bytestream_end= outbuf+buf_size; 273 s->bytestream_end = outbuf+buf_size;
270 274
271 h = avctx->height; 275 h = avctx->height;
272 w = avctx->width; 276 w = avctx->width;
273 switch(avctx->pix_fmt) { 277 switch (avctx->pix_fmt) {
274 case PIX_FMT_MONOWHITE: 278 case PIX_FMT_MONOWHITE:
275 n = (w + 7) >> 3; 279 n = (w + 7) >> 3;
276 depth = 1; 280 depth = 1;
277 maxval = 1; 281 maxval = 1;
278 tuple_type = "BLACKANDWHITE"; 282 tuple_type = "BLACKANDWHITE";
279 break; 283 break;
280 case PIX_FMT_GRAY8: 284 case PIX_FMT_GRAY8:
281 n = w; 285 n = w;
282 depth = 1; 286 depth = 1;
283 maxval = 255; 287 maxval = 255;
284 tuple_type = "GRAYSCALE"; 288 tuple_type = "GRAYSCALE";
285 break; 289 break;
286 case PIX_FMT_RGB24: 290 case PIX_FMT_RGB24:
287 n = w * 3; 291 n = w * 3;
288 depth = 3; 292 depth = 3;
289 maxval = 255; 293 maxval = 255;
290 tuple_type = "RGB"; 294 tuple_type = "RGB";
291 break; 295 break;
292 case PIX_FMT_RGB32: 296 case PIX_FMT_RGB32:
293 n = w * 4; 297 n = w * 4;
294 depth = 4; 298 depth = 4;
295 maxval = 255; 299 maxval = 255;
296 tuple_type = "RGB_ALPHA"; 300 tuple_type = "RGB_ALPHA";
297 break; 301 break;
298 default: 302 default:
299 return -1; 303 return -1;
300 } 304 }
301 snprintf(s->bytestream, s->bytestream_end - s->bytestream, 305 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
302 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n", 306 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n",
303 w, h, depth, maxval, tuple_type); 307 w, h, depth, maxval, tuple_type);
304 s->bytestream += strlen(s->bytestream); 308 s->bytestream += strlen(s->bytestream);
305 309
306 ptr = p->data[0]; 310 ptr = p->data[0];
307 linesize = p->linesize[0]; 311 linesize = p->linesize[0];
308 312
309 if (avctx->pix_fmt == PIX_FMT_RGB32) { 313 if (avctx->pix_fmt == PIX_FMT_RGB32) {
310 int j; 314 int j;
311 unsigned int v; 315 unsigned int v;
312 316
313 for(i=0;i<h;i++) { 317 for (i = 0; i < h; i++) {
314 for(j=0;j<w;j++) { 318 for (j = 0; j < w; j++) {
315 v = ((uint32_t *)ptr)[j]; 319 v = ((uint32_t *)ptr)[j];
316 bytestream_put_be24(&s->bytestream, v); 320 bytestream_put_be24(&s->bytestream, v);
317 *s->bytestream++ = v >> 24; 321 *s->bytestream++ = v >> 24;
318 } 322 }
319 ptr += linesize; 323 ptr += linesize;
320 } 324 }
321 } else { 325 } else {
322 for(i=0;i<h;i++) { 326 for (i = 0; i < h; i++) {
323 memcpy(s->bytestream, ptr, n); 327 memcpy(s->bytestream, ptr, n);
324 s->bytestream += n; 328 s->bytestream += n;
325 ptr += linesize; 329 ptr += linesize;
326 } 330 }
327 } 331 }
328 return s->bytestream - s->bytestream_start; 332 return s->bytestream - s->bytestream_start;
329 } 333 }
330 334
331 static av_cold int common_end(AVCodecContext *avctx){ 335 static av_cold int common_end(AVCodecContext *avctx)
336 {
332 PNMContext *s = avctx->priv_data; 337 PNMContext *s = avctx->priv_data;
333 338
334 if (s->picture.data[0]) 339 if (s->picture.data[0])
335 avctx->release_buffer(avctx, &s->picture); 340 avctx->release_buffer(avctx, &s->picture);
336 341
347 common_init, 352 common_init,
348 NULL, 353 NULL,
349 common_end, 354 common_end,
350 pnm_decode_frame, 355 pnm_decode_frame,
351 CODEC_CAP_DR1, 356 CODEC_CAP_DR1,
352 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, 357 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
353 .long_name= NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), 358 .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
354 }; 359 };
355 #endif 360 #endif
356 361
357 #if CONFIG_PGM_ENCODER 362 #if CONFIG_PGM_ENCODER
358 AVCodec pgm_encoder = { 363 AVCodec pgm_encoder = {
360 CODEC_TYPE_VIDEO, 365 CODEC_TYPE_VIDEO,
361 CODEC_ID_PGM, 366 CODEC_ID_PGM,
362 sizeof(PNMContext), 367 sizeof(PNMContext),
363 common_init, 368 common_init,
364 pnm_encode_frame, 369 pnm_encode_frame,
365 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, 370 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
366 .long_name= NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), 371 .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
367 }; 372 };
368 #endif // CONFIG_PGM_ENCODER 373 #endif
369 374
370 #if CONFIG_PGMYUV_DECODER 375 #if CONFIG_PGMYUV_DECODER
371 AVCodec pgmyuv_decoder = { 376 AVCodec pgmyuv_decoder = {
372 "pgmyuv", 377 "pgmyuv",
373 CODEC_TYPE_VIDEO, 378 CODEC_TYPE_VIDEO,
376 common_init, 381 common_init,
377 NULL, 382 NULL,
378 common_end, 383 common_end,
379 pnm_decode_frame, 384 pnm_decode_frame,
380 CODEC_CAP_DR1, 385 CODEC_CAP_DR1,
381 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, 386 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
382 .long_name= NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), 387 .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
383 }; 388 };
384 #endif 389 #endif
385 390
386 #if CONFIG_PGMYUV_ENCODER 391 #if CONFIG_PGMYUV_ENCODER
387 AVCodec pgmyuv_encoder = { 392 AVCodec pgmyuv_encoder = {
389 CODEC_TYPE_VIDEO, 394 CODEC_TYPE_VIDEO,
390 CODEC_ID_PGMYUV, 395 CODEC_ID_PGMYUV,
391 sizeof(PNMContext), 396 sizeof(PNMContext),
392 common_init, 397 common_init,
393 pnm_encode_frame, 398 pnm_encode_frame,
394 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, 399 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
395 .long_name= NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), 400 .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
396 }; 401 };
397 #endif // CONFIG_PGMYUV_ENCODER 402 #endif
398 403
399 #if CONFIG_PPM_DECODER 404 #if CONFIG_PPM_DECODER
400 AVCodec ppm_decoder = { 405 AVCodec ppm_decoder = {
401 "ppm", 406 "ppm",
402 CODEC_TYPE_VIDEO, 407 CODEC_TYPE_VIDEO,
405 common_init, 410 common_init,
406 NULL, 411 NULL,
407 common_end, 412 common_end,
408 pnm_decode_frame, 413 pnm_decode_frame,
409 CODEC_CAP_DR1, 414 CODEC_CAP_DR1,
410 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, 415 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
411 .long_name= NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), 416 .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
412 }; 417 };
413 #endif 418 #endif
414 419
415 #if CONFIG_PPM_ENCODER 420 #if CONFIG_PPM_ENCODER
416 AVCodec ppm_encoder = { 421 AVCodec ppm_encoder = {
418 CODEC_TYPE_VIDEO, 423 CODEC_TYPE_VIDEO,
419 CODEC_ID_PPM, 424 CODEC_ID_PPM,
420 sizeof(PNMContext), 425 sizeof(PNMContext),
421 common_init, 426 common_init,
422 pnm_encode_frame, 427 pnm_encode_frame,
423 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, 428 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
424 .long_name= NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), 429 .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
425 }; 430 };
426 #endif // CONFIG_PPM_ENCODER 431 #endif
427 432
428 #if CONFIG_PBM_DECODER 433 #if CONFIG_PBM_DECODER
429 AVCodec pbm_decoder = { 434 AVCodec pbm_decoder = {
430 "pbm", 435 "pbm",
431 CODEC_TYPE_VIDEO, 436 CODEC_TYPE_VIDEO,
434 common_init, 439 common_init,
435 NULL, 440 NULL,
436 common_end, 441 common_end,
437 pnm_decode_frame, 442 pnm_decode_frame,
438 CODEC_CAP_DR1, 443 CODEC_CAP_DR1,
439 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, 444 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
440 .long_name= NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), 445 .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
441 }; 446 };
442 #endif 447 #endif
443 448
444 #if CONFIG_PBM_ENCODER 449 #if CONFIG_PBM_ENCODER
445 AVCodec pbm_encoder = { 450 AVCodec pbm_encoder = {
447 CODEC_TYPE_VIDEO, 452 CODEC_TYPE_VIDEO,
448 CODEC_ID_PBM, 453 CODEC_ID_PBM,
449 sizeof(PNMContext), 454 sizeof(PNMContext),
450 common_init, 455 common_init,
451 pnm_encode_frame, 456 pnm_encode_frame,
452 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, 457 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
453 .long_name= NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), 458 .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
454 }; 459 };
455 #endif // CONFIG_PBM_ENCODER 460 #endif
456 461
457 #if CONFIG_PAM_DECODER 462 #if CONFIG_PAM_DECODER
458 AVCodec pam_decoder = { 463 AVCodec pam_decoder = {
459 "pam", 464 "pam",
460 CODEC_TYPE_VIDEO, 465 CODEC_TYPE_VIDEO,
463 common_init, 468 common_init,
464 NULL, 469 NULL,
465 common_end, 470 common_end,
466 pnm_decode_frame, 471 pnm_decode_frame,
467 CODEC_CAP_DR1, 472 CODEC_CAP_DR1,
468 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, 473 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
469 .long_name= NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), 474 .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
470 }; 475 };
471 #endif 476 #endif
472 477
473 #if CONFIG_PAM_ENCODER 478 #if CONFIG_PAM_ENCODER
474 AVCodec pam_encoder = { 479 AVCodec pam_encoder = {
476 CODEC_TYPE_VIDEO, 481 CODEC_TYPE_VIDEO,
477 CODEC_ID_PAM, 482 CODEC_ID_PAM,
478 sizeof(PNMContext), 483 sizeof(PNMContext),
479 common_init, 484 common_init,
480 pam_encode_frame, 485 pam_encode_frame,
481 .pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, 486 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
482 .long_name= NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), 487 .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
483 }; 488 };
484 #endif // CONFIG_PAM_ENCODER 489 #endif