annotate pnmenc.c @ 7328:9309e19c2b98 libavcodec

read 'coupling in use' parameter from bitstream into decoder context first, then copy to the local variable.
author jbr
date Sat, 19 Jul 2008 22:01:46 +0000
parents e943e1409077
children 7a463923ecd1
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
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
3 * Copyright (c) 2002, 2003 Fabrice Bellard.
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 */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
21 #include "avcodec.h"
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4985
diff changeset
22 #include "bytestream.h"
4978
95934eef9589 move pnm parser in its own file
aurel
parents: 4931
diff changeset
23 #include "pnm.h"
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
24
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
25
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6272
diff changeset
26 static av_cold int common_init(AVCodecContext *avctx){
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
27 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
28
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
29 avcodec_get_frame_defaults((AVFrame*)&s->picture);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
30 avctx->coded_frame= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
31
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
32 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
33 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
34
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
35 static int pnm_decode_frame(AVCodecContext *avctx,
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
36 void *data, int *data_size,
6272
ec8c482d17c1 some const
michael
parents: 5089
diff changeset
37 const uint8_t *buf, int buf_size)
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
38 {
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
39 PNMContext * const s = avctx->priv_data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
40 AVFrame *picture = data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
41 AVFrame * const p= (AVFrame*)&s->picture;
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
42 int i, n, linesize, h, upgrade = 0;
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
43 unsigned char *ptr;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
44
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
45 s->bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
46 s->bytestream= buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
47 s->bytestream_end= buf + buf_size;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
48
4978
95934eef9589 move pnm parser in its own file
aurel
parents: 4931
diff changeset
49 if(ff_pnm_decode_header(avctx, s) < 0)
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
50 return -1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
51
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
52 if(p->data[0])
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
53 avctx->release_buffer(avctx, p);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
54
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
55 p->reference= 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
56 if(avctx->get_buffer(avctx, p) < 0){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
57 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
58 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
59 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
60 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
61 p->key_frame= 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
62
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
63 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
64 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
65 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
66 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
67 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
68 goto do_read;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
69 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
70 n = avctx->width;
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
71 if (s->maxval < 255)
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
72 upgrade = 1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
73 goto do_read;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
74 case PIX_FMT_GRAY16BE:
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
75 case PIX_FMT_GRAY16LE:
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
76 n = avctx->width * 2;
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
77 if (s->maxval < 65535)
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
78 upgrade = 2;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
79 goto do_read;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
80 case PIX_FMT_MONOWHITE:
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
81 case PIX_FMT_MONOBLACK:
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
82 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
83 do_read:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
84 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
85 linesize = p->linesize[0];
2839
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
86 if(s->bytestream + n*avctx->height > s->bytestream_end)
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
87 return -1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
88 for(i = 0; i < avctx->height; i++) {
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
89 if (!upgrade)
4837
79e3bf8af72c cosmetics after last commit
ivo
parents: 4836
diff changeset
90 memcpy(ptr, s->bytestream, n);
4836
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
91 else if (upgrade == 1) {
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
92 unsigned int j, f = (255*128 + s->maxval/2) / s->maxval;
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
93 for (j=0; j<n; j++)
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
94 ptr[j] = (s->bytestream[j] * f + 64) >> 7;
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
95 } else if (upgrade == 2) {
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
96 unsigned int j, v, f = (65535*32768 + s->maxval/2) / s->maxval;
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
97 for (j=0; j<n/2; j++) {
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
98 v = be2me_16(((uint16_t *)s->bytestream)[j]);
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
99 ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
100 }
ae19d863073f Add support for grayscale images with arbitrary maxvals.
ivo
parents: 4494
diff changeset
101 }
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
102 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
103 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
104 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
105 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
106 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
107 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
108 unsigned char *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
109
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
110 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
111 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
112 linesize = p->linesize[0];
2839
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
113 if(s->bytestream + n*avctx->height*3/2 > s->bytestream_end)
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
114 return -1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
115 for(i = 0; i < avctx->height; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
116 memcpy(ptr, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
117 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
118 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
119 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
120 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
121 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
122 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
123 h = avctx->height >> 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
124 for(i = 0; i < h; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
125 memcpy(ptr1, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
126 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
127 memcpy(ptr2, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
128 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
129 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
130 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
131 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
132 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
133 break;
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4152
diff changeset
134 case PIX_FMT_RGB32:
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
135 ptr = p->data[0];
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
136 linesize = p->linesize[0];
2839
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
137 if(s->bytestream + avctx->width*avctx->height*4 > s->bytestream_end)
b857807dfe30 segfault fix
michael
parents: 2661
diff changeset
138 return -1;
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
139 for(i = 0; i < avctx->height; i++) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
140 int j, r, g, b, a;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
141
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
142 for(j = 0;j < avctx->width; j++) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
143 r = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
144 g = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
145 b = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
146 a = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
147 ((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
148 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
149 ptr += linesize;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
150 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
151 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
152 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
153 *picture= *(AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
154 *data_size = sizeof(AVPicture);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
155
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
156 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
157 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
158
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
159 static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
160 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
161 AVFrame *pict = data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
162 AVFrame * const p= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
163 int i, h, h1, c, n, linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
164 uint8_t *ptr, *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
165
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
166 if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
167 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
168 return -1;
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
169 }
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
170
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
171 *p = *pict;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
172 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
173 p->key_frame= 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
174
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
175 s->bytestream_start=
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
176 s->bytestream= outbuf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
177 s->bytestream_end= outbuf+buf_size;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
178
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
179 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
180 h1 = h;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
181 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
182 case PIX_FMT_MONOWHITE:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
183 c = '4';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
184 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
185 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
186 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
187 c = '5';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
188 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
189 break;
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
190 case PIX_FMT_GRAY16BE:
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
191 c = '5';
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
192 n = avctx->width * 2;
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
193 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
194 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
195 c = '6';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
196 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
197 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
198 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
199 c = '5';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
200 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
201 h1 = (h * 3) / 2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
202 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
203 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
204 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
205 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
206 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
207 "P%c\n%d %d\n",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
208 c, avctx->width, h1);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
209 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
210 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
211 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
4068
186e51891c8c PGM 16-bit gray support
kostya
parents: 3947
diff changeset
212 "%d\n", (avctx->pix_fmt != PIX_FMT_GRAY16BE) ? 255 : 65535);
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
213 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
214 }
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 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
217 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
218 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
219 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
220 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
221 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
222 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
223
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
224 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
225 h >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
226 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
227 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
228 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
229 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
230 memcpy(s->bytestream, ptr1, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
231 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
232 memcpy(s->bytestream, ptr2, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
233 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
234 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
235 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
236 }
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 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
239 }
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 static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
242 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
243 AVFrame *pict = data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
244 AVFrame * const p= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
245 int i, h, w, n, linesize, depth, maxval;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
246 const char *tuple_type;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
247 uint8_t *ptr;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
248
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
249 if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
250 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
251 return -1;
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
252 }
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
253
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
254 *p = *pict;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
255 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
256 p->key_frame= 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
257
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
258 s->bytestream_start=
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
259 s->bytestream= outbuf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
260 s->bytestream_end= outbuf+buf_size;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
261
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
262 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
263 w = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
264 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
265 case PIX_FMT_MONOWHITE:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
266 n = (w + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
267 depth = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
268 maxval = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
269 tuple_type = "BLACKANDWHITE";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
270 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
271 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
272 n = w;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
273 depth = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
274 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
275 tuple_type = "GRAYSCALE";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
276 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
277 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
278 n = w * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
279 depth = 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
280 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
281 tuple_type = "RGB";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
282 break;
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4152
diff changeset
283 case PIX_FMT_RGB32:
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
284 n = w * 4;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
285 depth = 4;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
286 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
287 tuple_type = "RGB_ALPHA";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
288 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
289 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
290 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
291 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
292 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
293 "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
294 w, h, depth, maxval, tuple_type);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
295 s->bytestream += strlen(s->bytestream);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
296
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
297 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
298 linesize = p->linesize[0];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2864
diff changeset
299
4494
ce643a22f049 Replace deprecated PIX_FMT names by the newer variants.
diego
parents: 4152
diff changeset
300 if (avctx->pix_fmt == PIX_FMT_RGB32) {
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
301 int j;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
302 unsigned int v;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
303
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
304 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
305 for(j=0;j<w;j++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
306 v = ((uint32_t *)ptr)[j];
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4985
diff changeset
307 bytestream_put_be24(&s->bytestream, v);
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
308 *s->bytestream++ = v >> 24;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
309 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
310 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
311 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
312 } else {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
313 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
314 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
315 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
316 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
317 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
318 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
319 return s->bytestream - s->bytestream_start;
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 #if 0
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
323 static int pnm_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
324 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
325 const char *p = pd->buf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
326 if (pd->buf_size >= 8 &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
327 p[0] == 'P' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
328 p[1] >= '4' && p[1] <= '6' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
329 pnm_space(p[2]) )
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
330 return AVPROBE_SCORE_MAX - 1; /* to permit pgmyuv probe */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
331 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
332 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
333 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
334
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
335 static int pgmyuv_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
336 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
337 if (match_ext(pd->filename, "pgmyuv"))
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
338 return AVPROBE_SCORE_MAX;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
339 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
340 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
341 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
342
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
343 static int pam_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
344 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
345 const char *p = pd->buf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
346 if (pd->buf_size >= 8 &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
347 p[0] == 'P' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
348 p[1] == '7' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
349 p[2] == '\n')
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
350 return AVPROBE_SCORE_MAX;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
351 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
352 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
353 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
354 #endif
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
355
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
356
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
357 #ifdef CONFIG_PGM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
358 AVCodec pgm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
359 "pgm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
360 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
361 CODEC_ID_PGM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
362 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
363 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
364 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
365 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
366 pnm_decode_frame,
6788
e1302edb0f69 Replace some occurrences of -1 with PIX_FMT_NONE.
cehoyos
parents: 6722
diff changeset
367 .pix_fmts= (enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6788
diff changeset
368 .long_name= NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
369 };
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
370 #endif // CONFIG_PGM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
371
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
372 #ifdef CONFIG_PGMYUV_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
373 AVCodec pgmyuv_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
374 "pgmyuv",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
375 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
376 CODEC_ID_PGMYUV,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
377 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
378 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
379 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
380 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
381 pnm_decode_frame,
6788
e1302edb0f69 Replace some occurrences of -1 with PIX_FMT_NONE.
cehoyos
parents: 6722
diff changeset
382 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6788
diff changeset
383 .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
384 };
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
385 #endif // CONFIG_PGMYUV_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
386
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
387 #ifdef CONFIG_PPM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
388 AVCodec ppm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
389 "ppm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
390 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
391 CODEC_ID_PPM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
392 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
393 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
394 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
395 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
396 pnm_decode_frame,
6788
e1302edb0f69 Replace some occurrences of -1 with PIX_FMT_NONE.
cehoyos
parents: 6722
diff changeset
397 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_NONE},
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6788
diff changeset
398 .long_name= NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
399 };
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
400 #endif // CONFIG_PPM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
401
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
402 #ifdef CONFIG_PBM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
403 AVCodec pbm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
404 "pbm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
405 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
406 CODEC_ID_PBM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
407 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
408 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
409 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
410 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
411 pnm_decode_frame,
6788
e1302edb0f69 Replace some occurrences of -1 with PIX_FMT_NONE.
cehoyos
parents: 6722
diff changeset
412 .pix_fmts= (enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6788
diff changeset
413 .long_name= NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
414 };
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
415 #endif // CONFIG_PBM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
416
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
417 #ifdef CONFIG_PAM_ENCODER
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
418 AVCodec pam_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
419 "pam",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
420 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
421 CODEC_ID_PAM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
422 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
423 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
424 pam_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
425 NULL, //encode_end,
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
426 pnm_decode_frame,
6788
e1302edb0f69 Replace some occurrences of -1 with PIX_FMT_NONE.
cehoyos
parents: 6722
diff changeset
427 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6788
diff changeset
428 .long_name= NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
429 };
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2453
diff changeset
430 #endif // CONFIG_PAM_ENCODER