annotate pnmenc.c @ 9137:f32faa6e149b libavcodec

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