annotate pnmenc.c @ 10463:9f35b262d3f0 libavcodec

Commit some functions that are used by both SIPR and AMR. Based on AMR SoC code by Robert Swain and Colin McQuillan.
author vitor
date Tue, 27 Oct 2009 23:53:18 +0000
parents 059265d3cc65
children 267588850827
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
1 /*
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
2 * PNM image format
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 8590
diff changeset
3 * Copyright (c) 2002, 2003 Fabrice Bellard
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3455
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3455
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3455
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3455
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3455
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
15 * Lesser General Public License for more details.
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
16 *
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3455
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2967
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
20 */
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
21
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
22 #include "avcodec.h"
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4985
diff changeset
23 #include "bytestream.h"
4978
95934eef9589 move pnm parser in its own file
aurel
parents: 4931
diff changeset
24 #include "pnm.h"
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
25
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
26
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
27 static int pnm_decode_frame(AVCodecContext *avctx, void *data,
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
28 int *data_size, AVPacket *avpkt)
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
29 {
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
30 const uint8_t *buf = avpkt->data;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
31 int buf_size = avpkt->size;
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
32 PNMContext * const s = avctx->priv_data;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
33 AVFrame *picture = data;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
34 AVFrame * const p = (AVFrame*)&s->picture;
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
35 int i, n, linesize, h, upgrade = 0;
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
36 unsigned char *ptr;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
37
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
38 s->bytestream_start =
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
39 s->bytestream = buf;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
40 s->bytestream_end = buf + buf_size;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
41
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
42 if (ff_pnm_decode_header(avctx, s) < 0)
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
43 return -1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
44
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
45 if (p->data[0])
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
46 avctx->release_buffer(avctx, p);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
47
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
48 p->reference = 0;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
49 if (avctx->get_buffer(avctx, p) < 0) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
50 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
51 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
52 }
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
53 p->pict_type = FF_I_TYPE;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
54 p->key_frame = 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
55
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
56 switch (avctx->pix_fmt) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
57 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
58 return -1;
9002
eb98d61af310 Support 48-bit RGB PPM image.
pross
parents: 8629
diff changeset
59 case PIX_FMT_RGB48BE:
eb98d61af310 Support 48-bit RGB PPM image.
pross
parents: 8629
diff changeset
60 n = avctx->width * 6;
eb98d61af310 Support 48-bit RGB PPM image.
pross
parents: 8629
diff changeset
61 goto do_read;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
62 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
63 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
64 goto do_read;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
65 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
66 n = avctx->width;
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
67 if (s->maxval < 255)
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
68 upgrade = 1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
69 goto do_read;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
70 case PIX_FMT_GRAY16BE:
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
71 case PIX_FMT_GRAY16LE:
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
72 n = avctx->width * 2;
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
73 if (s->maxval < 65535)
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
74 upgrade = 2;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
75 goto do_read;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
76 case PIX_FMT_MONOWHITE:
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
77 case PIX_FMT_MONOBLACK:
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
78 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
79 do_read:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
80 ptr = p->data[0];
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
81 linesize = p->linesize[0];
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
82 if (s->bytestream + n * avctx->height > s->bytestream_end)
2839
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
83 return -1;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
84 for (i = 0; i < avctx->height; i++) {
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
85 if (!upgrade)
4837
79e3bf8af72c cosmetics after last commit
ivo
parents: 4836
diff changeset
86 memcpy(ptr, s->bytestream, n);
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
87 else if (upgrade == 1) {
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
88 unsigned int j, f = (255 * 128 + s->maxval / 2) / s->maxval;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
89 for (j = 0; j < n; j++)
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
90 ptr[j] = (s->bytestream[j] * f + 64) >> 7;
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
91 } else if (upgrade == 2) {
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
92 unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
93 for (j = 0; j < n / 2; j++) {
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
94 v = be2me_16(((uint16_t *)s->bytestream)[j]);
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
95 ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
96 }
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
97 }
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
98 s->bytestream += n;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
99 ptr += linesize;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
100 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
101 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
102 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
103 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
104 unsigned char *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
105
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
106 n = avctx->width;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
107 ptr = p->data[0];
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
108 linesize = p->linesize[0];
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
109 if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
2839
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
110 return -1;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
111 for (i = 0; i < avctx->height; i++) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
112 memcpy(ptr, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
113 s->bytestream += n;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
114 ptr += linesize;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
115 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
116 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
117 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
118 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
119 h = avctx->height >> 1;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
120 for (i = 0; i < h; i++) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
121 memcpy(ptr1, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
122 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
123 memcpy(ptr2, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
124 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
125 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
126 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
127 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
128 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
129 break;
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4152
diff changeset
130 case PIX_FMT_RGB32:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
131 ptr = p->data[0];
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
132 linesize = p->linesize[0];
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
133 if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end)
2839
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
134 return -1;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
135 for (i = 0; i < avctx->height; i++) {
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
136 int j, r, g, b, a;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
137
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
138 for (j = 0; j < avctx->width; j++) {
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
139 r = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
140 g = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
141 b = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
142 a = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
143 ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
144 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
145 ptr += linesize;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
146 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
147 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
148 }
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
149 *picture = *(AVFrame*)&s->picture;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
150 *data_size = sizeof(AVPicture);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
151
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
152 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
153 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
154
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
155 static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
156 int buf_size, void *data)
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
157 {
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
158 PNMContext *s = avctx->priv_data;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
159 AVFrame *pict = data;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
160 AVFrame * const p = (AVFrame*)&s->picture;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
161 int i, h, h1, c, n, linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
162 uint8_t *ptr, *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
163
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
164 if (buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200) {
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
165 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
166 return -1;
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
167 }
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
168
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
169 *p = *pict;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
170 p->pict_type = FF_I_TYPE;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
171 p->key_frame = 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
172
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
173 s->bytestream_start =
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
174 s->bytestream = outbuf;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
175 s->bytestream_end = outbuf + buf_size;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
176
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
177 h = avctx->height;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
178 h1 = h;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
179 switch (avctx->pix_fmt) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
180 case PIX_FMT_MONOWHITE:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
181 c = '4';
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
182 n = (avctx->width + 7) >> 3;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
183 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
184 case PIX_FMT_GRAY8:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
185 c = '5';
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
186 n = avctx->width;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
187 break;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
188 case PIX_FMT_GRAY16BE:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
189 c = '5';
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
190 n = avctx->width * 2;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
191 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
192 case PIX_FMT_RGB24:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
193 c = '6';
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
194 n = avctx->width * 3;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
195 break;
9002
eb98d61af310 Support 48-bit RGB PPM image.
pross
parents: 8629
diff changeset
196 case PIX_FMT_RGB48BE:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
197 c = '6';
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
198 n = avctx->width * 6;
9002
eb98d61af310 Support 48-bit RGB PPM image.
pross
parents: 8629
diff changeset
199 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
200 case PIX_FMT_YUV420P:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
201 c = '5';
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
202 n = avctx->width;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
203 h1 = (h * 3) / 2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
204 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
205 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
206 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
207 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
208 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
209 "P%c\n%d %d\n", c, avctx->width, h1);
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
210 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
211 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
212 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
9002
eb98d61af310 Support 48-bit RGB PPM image.
pross
parents: 8629
diff changeset
213 "%d\n", (avctx->pix_fmt != PIX_FMT_GRAY16BE && avctx->pix_fmt != PIX_FMT_RGB48BE) ? 255 : 65535);
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
214 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
215 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
216
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
217 ptr = p->data[0];
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
218 linesize = p->linesize[0];
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
219 for (i = 0; i < h; i++) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
220 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
221 s->bytestream += n;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
222 ptr += linesize;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
223 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
224
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
225 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
226 h >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
227 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
228 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
229 ptr2 = p->data[2];
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
230 for (i = 0; i < h; i++) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
231 memcpy(s->bytestream, ptr1, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
232 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
233 memcpy(s->bytestream, ptr2, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
234 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
235 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
236 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
237 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
238 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
239 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
240 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
241
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
242 static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
243 int buf_size, void *data)
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
244 {
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
245 PNMContext *s = avctx->priv_data;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
246 AVFrame *pict = data;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
247 AVFrame * const p = (AVFrame*)&s->picture;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
248 int i, h, w, n, linesize, depth, maxval;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
249 const char *tuple_type;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
250 uint8_t *ptr;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
251
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
252 if (buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200) {
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
253 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
254 return -1;
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
255 }
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
256
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
257 *p = *pict;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
258 p->pict_type = FF_I_TYPE;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
259 p->key_frame = 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
260
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
261 s->bytestream_start =
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
262 s->bytestream = outbuf;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
263 s->bytestream_end = outbuf+buf_size;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
264
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
265 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
266 w = avctx->width;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
267 switch (avctx->pix_fmt) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
268 case PIX_FMT_MONOWHITE:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
269 n = (w + 7) >> 3;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
270 depth = 1;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
271 maxval = 1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
272 tuple_type = "BLACKANDWHITE";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
273 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
274 case PIX_FMT_GRAY8:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
275 n = w;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
276 depth = 1;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
277 maxval = 255;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
278 tuple_type = "GRAYSCALE";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
279 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
280 case PIX_FMT_RGB24:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
281 n = w * 3;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
282 depth = 3;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
283 maxval = 255;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
284 tuple_type = "RGB";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
285 break;
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4152
diff changeset
286 case PIX_FMT_RGB32:
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
287 n = w * 4;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
288 depth = 4;
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
289 maxval = 255;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
290 tuple_type = "RGB_ALPHA";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
291 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
292 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
293 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
294 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
295 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
296 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
297 w, h, depth, maxval, tuple_type);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
298 s->bytestream += strlen(s->bytestream);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
299
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
300 ptr = p->data[0];
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
301 linesize = p->linesize[0];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
302
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4152
diff changeset
303 if (avctx->pix_fmt == PIX_FMT_RGB32) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
304 int j;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
305 unsigned int v;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
306
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
307 for (i = 0; i < h; i++) {
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
308 for (j = 0; j < w; j++) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
309 v = ((uint32_t *)ptr)[j];
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4985
diff changeset
310 bytestream_put_be24(&s->bytestream, v);
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
311 *s->bytestream++ = v >> 24;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
312 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
313 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
314 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
315 } else {
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
316 for (i = 0; i < h; i++) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
317 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
318 s->bytestream += n;
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
319 ptr += linesize;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
320 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
321 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
322 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
323 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
324
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
325
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
326 #if CONFIG_PGM_DECODER
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
327 AVCodec pgm_decoder = {
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
328 "pgm",
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
329 CODEC_TYPE_VIDEO,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
330 CODEC_ID_PGM,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
331 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
332 ff_pnm_init,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
333 NULL,
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
334 ff_pnm_end,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
335 pnm_decode_frame,
9801
7f15f8f14e97 pgm, pgmyuv, ppm, pbm and pam decoders use get_buffer, set CODEC_CAP_DR1
bcoudurier
parents: 9355
diff changeset
336 CODEC_CAP_DR1,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
337 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
338 .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
339 };
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
340 #endif
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
341
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
342 #if CONFIG_PGM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
343 AVCodec pgm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
344 "pgm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
345 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
346 CODEC_ID_PGM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
347 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
348 ff_pnm_init,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
349 pnm_encode_frame,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
350 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
351 .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
352 };
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
353 #endif
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
354
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
355 #if CONFIG_PGMYUV_DECODER
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
356 AVCodec pgmyuv_decoder = {
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
357 "pgmyuv",
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
358 CODEC_TYPE_VIDEO,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
359 CODEC_ID_PGMYUV,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
360 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
361 ff_pnm_init,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
362 NULL,
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
363 ff_pnm_end,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
364 pnm_decode_frame,
9801
7f15f8f14e97 pgm, pgmyuv, ppm, pbm and pam decoders use get_buffer, set CODEC_CAP_DR1
bcoudurier
parents: 9355
diff changeset
365 CODEC_CAP_DR1,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
366 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
367 .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
368 };
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
369 #endif
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
370
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
371 #if CONFIG_PGMYUV_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
372 AVCodec pgmyuv_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
373 "pgmyuv",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
374 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
375 CODEC_ID_PGMYUV,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
376 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
377 ff_pnm_init,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
378 pnm_encode_frame,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
379 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
380 .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
381 };
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
382 #endif
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
383
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
384 #if CONFIG_PPM_DECODER
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
385 AVCodec ppm_decoder = {
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
386 "ppm",
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
387 CODEC_TYPE_VIDEO,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
388 CODEC_ID_PPM,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
389 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
390 ff_pnm_init,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
391 NULL,
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
392 ff_pnm_end,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
393 pnm_decode_frame,
9801
7f15f8f14e97 pgm, pgmyuv, ppm, pbm and pam decoders use get_buffer, set CODEC_CAP_DR1
bcoudurier
parents: 9355
diff changeset
394 CODEC_CAP_DR1,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
395 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
396 .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
397 };
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
398 #endif
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
399
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
400 #if CONFIG_PPM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
401 AVCodec ppm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
402 "ppm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
403 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
404 CODEC_ID_PPM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
405 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
406 ff_pnm_init,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
407 pnm_encode_frame,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
408 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
409 .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
410 };
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
411 #endif
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
412
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
413 #if CONFIG_PBM_DECODER
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
414 AVCodec pbm_decoder = {
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
415 "pbm",
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
416 CODEC_TYPE_VIDEO,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
417 CODEC_ID_PBM,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
418 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
419 ff_pnm_init,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
420 NULL,
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
421 ff_pnm_end,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
422 pnm_decode_frame,
9801
7f15f8f14e97 pgm, pgmyuv, ppm, pbm and pam decoders use get_buffer, set CODEC_CAP_DR1
bcoudurier
parents: 9355
diff changeset
423 CODEC_CAP_DR1,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
424 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
425 .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
426 };
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
427 #endif
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
428
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
429 #if CONFIG_PBM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
430 AVCodec pbm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
431 "pbm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
432 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
433 CODEC_ID_PBM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
434 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
435 ff_pnm_init,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
436 pnm_encode_frame,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
437 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
438 .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
439 };
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
440 #endif
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
441
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
442 #if CONFIG_PAM_DECODER
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
443 AVCodec pam_decoder = {
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
444 "pam",
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
445 CODEC_TYPE_VIDEO,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
446 CODEC_ID_PAM,
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
447 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
448 ff_pnm_init,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
449 NULL,
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
450 ff_pnm_end,
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
451 pnm_decode_frame,
9801
7f15f8f14e97 pgm, pgmyuv, ppm, pbm and pam decoders use get_buffer, set CODEC_CAP_DR1
bcoudurier
parents: 9355
diff changeset
452 CODEC_CAP_DR1,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
453 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
454 .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
9246
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
455 };
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
456 #endif
18b83dac1221 Split AVCodec declarations for PAM/PBM/PGM/PGMYUV/PPM decoders and encoders
diego
parents: 9002
diff changeset
457
8590
7a463923ecd1 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 7040
diff changeset
458 #if CONFIG_PAM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
459 AVCodec pam_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
460 "pam",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
461 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
462 CODEC_ID_PAM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
463 sizeof(PNMContext),
10460
059265d3cc65 Move PNM init/end functions to the PNM common code.
diego
parents: 10459
diff changeset
464 ff_pnm_init,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
465 pam_encode_frame,
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
466 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
467 .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
468 };
10459
a6bb56636f90 whitespace cosmetics: K&R coding style, prettyprinting
diego
parents: 10458
diff changeset
469 #endif