/src/ffmpeg/libavcodec/pnmdec.c
Line | Count | Source |
1 | | /* |
2 | | * PNM image format |
3 | | * Copyright (c) 2002, 2003 Fabrice Bellard |
4 | | * |
5 | | * This file is part of FFmpeg. |
6 | | * |
7 | | * FFmpeg is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation; either |
10 | | * version 2.1 of the License, or (at your option) any later version. |
11 | | * |
12 | | * FFmpeg is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with FFmpeg; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #include "config_components.h" |
23 | | |
24 | | #include "libavutil/half2float.h" |
25 | | #include "libavutil/intfloat.h" |
26 | | |
27 | | #include "avcodec.h" |
28 | | #include "codec_internal.h" |
29 | | #include "decode.h" |
30 | | #include "put_bits.h" |
31 | | #include "pnm.h" |
32 | | |
33 | | static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval) |
34 | 1.51M | { |
35 | 1.51M | if (maxval <= 255) { |
36 | 1.49M | memcpy(dst, src, n); |
37 | 1.49M | } else { |
38 | 21.0k | int i; |
39 | 132k | for (i=0; i<n/2; i++) { |
40 | 111k | ((uint16_t *)dst)[i] = AV_RB16(src+2*i); |
41 | 111k | } |
42 | 21.0k | } |
43 | 1.51M | } |
44 | | |
45 | | static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, |
46 | | int *got_frame, AVPacket *avpkt) |
47 | 3.95M | { |
48 | 3.95M | const uint8_t *buf = avpkt->data; |
49 | 3.95M | int buf_size = avpkt->size; |
50 | 3.95M | PNMContext * const s = avctx->priv_data; |
51 | 3.95M | int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0; |
52 | 3.95M | unsigned char *ptr; |
53 | 3.95M | int components, sample_len, ret; |
54 | 3.95M | float scale; |
55 | | |
56 | 3.95M | s->bytestream_start = |
57 | 3.95M | s->bytestream = buf; |
58 | 3.95M | s->bytestream_end = buf + buf_size; |
59 | | |
60 | 3.95M | if ((ret = ff_pnm_decode_header(avctx, s)) < 0) |
61 | 695k | return ret; |
62 | | |
63 | 3.25M | if (avctx->skip_frame >= AVDISCARD_ALL) |
64 | 260k | return avpkt->size; |
65 | | |
66 | 2.99M | if ((ret = ff_get_buffer(avctx, p, 0)) < 0) |
67 | 41.9k | return ret; |
68 | 2.95M | avctx->bits_per_raw_sample = av_log2(s->maxval) + 1; |
69 | | |
70 | 2.95M | switch (avctx->pix_fmt) { |
71 | 0 | default: |
72 | 0 | return AVERROR(EINVAL); |
73 | 3.70k | case AV_PIX_FMT_RGBA64: |
74 | 3.70k | n = avctx->width * 8; |
75 | 3.70k | components=4; |
76 | 3.70k | sample_len=16; |
77 | 3.70k | if (s->maxval < 65535) |
78 | 1.94k | upgrade = 2; |
79 | 3.70k | goto do_read; |
80 | 7.40k | case AV_PIX_FMT_RGB48: |
81 | 7.40k | n = avctx->width * 6; |
82 | 7.40k | components=3; |
83 | 7.40k | sample_len=16; |
84 | 7.40k | if (s->maxval < 65535) |
85 | 4.93k | upgrade = 2; |
86 | 7.40k | goto do_read; |
87 | 2.58k | case AV_PIX_FMT_RGBA: |
88 | 2.58k | n = avctx->width * 4; |
89 | 2.58k | components=4; |
90 | 2.58k | sample_len=8; |
91 | 2.58k | goto do_read; |
92 | 38.2k | case AV_PIX_FMT_RGB24: |
93 | 38.2k | n = avctx->width * 3; |
94 | 38.2k | components=3; |
95 | 38.2k | sample_len=8; |
96 | 38.2k | if (s->maxval < 255) |
97 | 17.5k | upgrade = 1; |
98 | 38.2k | goto do_read; |
99 | 222k | case AV_PIX_FMT_GRAY8: |
100 | 222k | n = avctx->width; |
101 | 222k | components=1; |
102 | 222k | sample_len=8; |
103 | 222k | if (s->maxval < 255) |
104 | 190k | upgrade = 1; |
105 | 222k | goto do_read; |
106 | 2.43k | case AV_PIX_FMT_GRAY8A: |
107 | 2.43k | n = avctx->width * 2; |
108 | 2.43k | components=2; |
109 | 2.43k | sample_len=8; |
110 | 2.43k | goto do_read; |
111 | 10.4k | case AV_PIX_FMT_GRAY16: |
112 | 10.4k | n = avctx->width * 2; |
113 | 10.4k | components=1; |
114 | 10.4k | sample_len=16; |
115 | 10.4k | if (s->maxval < 65535) |
116 | 8.88k | upgrade = 2; |
117 | 10.4k | goto do_read; |
118 | 3.97k | case AV_PIX_FMT_YA16: |
119 | 3.97k | n = avctx->width * 4; |
120 | 3.97k | components=2; |
121 | 3.97k | sample_len=16; |
122 | 3.97k | if (s->maxval < 65535) |
123 | 2.60k | upgrade = 2; |
124 | 3.97k | goto do_read; |
125 | 2.21M | case AV_PIX_FMT_MONOWHITE: |
126 | 2.21M | case AV_PIX_FMT_MONOBLACK: |
127 | 2.21M | n = (avctx->width + 7) >> 3; |
128 | 2.21M | components=1; |
129 | 2.21M | sample_len=1; |
130 | 2.21M | is_mono = 1; |
131 | 2.51M | do_read: |
132 | 2.51M | ptr = p->data[0]; |
133 | 2.51M | linesize = p->linesize[0]; |
134 | 2.51M | if (n * avctx->height > s->bytestream_end - s->bytestream) |
135 | 73.2k | return AVERROR_INVALIDDATA; |
136 | 2.43M | if(s->type < 4 || (is_mono && s->type==7)){ |
137 | 4.44M | for (i=0; i<avctx->height; i++) { |
138 | 2.27M | PutBitContext pb; |
139 | 2.27M | init_put_bits(&pb, ptr, FFABS(linesize)); |
140 | 4.90M | for(j=0; j<avctx->width * components; j++){ |
141 | 2.68M | unsigned int c=0; |
142 | 2.68M | unsigned v=0; |
143 | 2.68M | if(s->type < 4) |
144 | 10.5M | while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' )) |
145 | 8.01M | s->bytestream++; |
146 | 2.68M | if(s->bytestream >= s->bytestream_end) |
147 | 42.8k | return AVERROR_INVALIDDATA; |
148 | 2.63M | if (is_mono) { |
149 | | /* read a single digit */ |
150 | 2.52M | v = (*s->bytestream++)&1; |
151 | 2.52M | } else { |
152 | | /* read a sequence of digits */ |
153 | 413k | for (k = 0; k < 6 && c <= 9; k += 1) { |
154 | 295k | v = 10*v + c; |
155 | 295k | c = (*s->bytestream++) - '0'; |
156 | 295k | } |
157 | 118k | if (v > s->maxval) { |
158 | 9.37k | av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval); |
159 | 9.37k | return AVERROR_INVALIDDATA; |
160 | 9.37k | } |
161 | 118k | } |
162 | 2.63M | if (sample_len == 16) { |
163 | 14.7k | ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval; |
164 | 14.7k | } else |
165 | 2.61M | put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval); |
166 | 2.63M | } |
167 | 2.22M | if (sample_len != 16) |
168 | 2.21M | flush_put_bits(&pb); |
169 | 2.22M | ptr+= linesize; |
170 | 2.22M | } |
171 | 2.22M | }else{ |
172 | 2.17M | for (int i = 0; i < avctx->height; i++) { |
173 | 1.96M | if (!upgrade) |
174 | 1.38M | samplecpy(ptr, s->bytestream, n, s->maxval); |
175 | 584k | else if (upgrade == 1) { |
176 | 569k | unsigned int f = (255 * 128 + s->maxval / 2) / s->maxval; |
177 | 2.91M | for (unsigned j = 0; j < n; j++) |
178 | 2.34M | ptr[j] = (s->bytestream[j] * f + 64) >> 7; |
179 | 569k | } else if (upgrade == 2) { |
180 | 14.6k | unsigned int f = (65535 * 32768 + s->maxval / 2) / s->maxval; |
181 | 371k | for (unsigned j = 0; j < n / 2; j++) { |
182 | 356k | unsigned v = AV_RB16(s->bytestream + 2*j); |
183 | 356k | ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15; |
184 | 356k | } |
185 | 14.6k | } |
186 | 1.96M | s->bytestream += n; |
187 | 1.96M | ptr += linesize; |
188 | 1.96M | } |
189 | 211k | } |
190 | 2.38M | break; |
191 | 2.38M | case AV_PIX_FMT_YUV420P: |
192 | 2.37k | case AV_PIX_FMT_YUV420P9: |
193 | 2.64k | case AV_PIX_FMT_YUV420P10: |
194 | 2.64k | { |
195 | 2.64k | unsigned char *ptr1, *ptr2; |
196 | | |
197 | 2.64k | n = avctx->width; |
198 | 2.64k | ptr = p->data[0]; |
199 | 2.64k | linesize = p->linesize[0]; |
200 | 2.64k | if (s->maxval >= 256) |
201 | 1.08k | n *= 2; |
202 | 2.64k | if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream) |
203 | 887 | return AVERROR_INVALIDDATA; |
204 | 70.3k | for (i = 0; i < avctx->height; i++) { |
205 | 68.5k | samplecpy(ptr, s->bytestream, n, s->maxval); |
206 | 68.5k | s->bytestream += n; |
207 | 68.5k | ptr += linesize; |
208 | 68.5k | } |
209 | 1.75k | ptr1 = p->data[1]; |
210 | 1.75k | ptr2 = p->data[2]; |
211 | 1.75k | n >>= 1; |
212 | 1.75k | h = avctx->height >> 1; |
213 | 36.0k | for (i = 0; i < h; i++) { |
214 | 34.2k | samplecpy(ptr1, s->bytestream, n, s->maxval); |
215 | 34.2k | s->bytestream += n; |
216 | 34.2k | samplecpy(ptr2, s->bytestream, n, s->maxval); |
217 | 34.2k | s->bytestream += n; |
218 | 34.2k | ptr1 += p->linesize[1]; |
219 | 34.2k | ptr2 += p->linesize[2]; |
220 | 34.2k | } |
221 | 1.75k | } |
222 | 0 | break; |
223 | 816 | case AV_PIX_FMT_YUV420P16: |
224 | 816 | { |
225 | 816 | uint16_t *ptr1, *ptr2; |
226 | 816 | const int f = (65535 * 32768 + s->maxval / 2) / s->maxval; |
227 | 816 | unsigned int j, v; |
228 | | |
229 | 816 | n = avctx->width * 2; |
230 | 816 | ptr = p->data[0]; |
231 | 816 | linesize = p->linesize[0]; |
232 | 816 | if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream) |
233 | 256 | return AVERROR_INVALIDDATA; |
234 | 2.76k | for (i = 0; i < avctx->height; i++) { |
235 | 8.97k | for (j = 0; j < n / 2; j++) { |
236 | 6.77k | v = AV_RB16(s->bytestream + 2*j); |
237 | 6.77k | ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15; |
238 | 6.77k | } |
239 | 2.20k | s->bytestream += n; |
240 | 2.20k | ptr += linesize; |
241 | 2.20k | } |
242 | 560 | ptr1 = (uint16_t*)p->data[1]; |
243 | 560 | ptr2 = (uint16_t*)p->data[2]; |
244 | 560 | n >>= 1; |
245 | 560 | h = avctx->height >> 1; |
246 | 1.66k | for (i = 0; i < h; i++) { |
247 | 2.79k | for (j = 0; j < n / 2; j++) { |
248 | 1.69k | v = AV_RB16(s->bytestream + 2*j); |
249 | 1.69k | ptr1[j] = (v * f + 16384) >> 15; |
250 | 1.69k | } |
251 | 1.10k | s->bytestream += n; |
252 | | |
253 | 2.79k | for (j = 0; j < n / 2; j++) { |
254 | 1.69k | v = AV_RB16(s->bytestream + 2*j); |
255 | 1.69k | ptr2[j] = (v * f + 16384) >> 15; |
256 | 1.69k | } |
257 | 1.10k | s->bytestream += n; |
258 | | |
259 | 1.10k | ptr1 += p->linesize[1] / 2; |
260 | 1.10k | ptr2 += p->linesize[2] / 2; |
261 | 1.10k | } |
262 | 560 | } |
263 | 0 | break; |
264 | 51.5k | case AV_PIX_FMT_GBRPF32: |
265 | 51.5k | if (!s->half) { |
266 | 24.7k | if (avctx->width * avctx->height * 12LL > s->bytestream_end - s->bytestream) |
267 | 4.98k | return AVERROR_INVALIDDATA; |
268 | 19.7k | scale = 1.f / s->scale; |
269 | 19.7k | if (s->endian) { |
270 | 2.75k | float *r, *g, *b; |
271 | | |
272 | 2.75k | r = (float *)p->data[2]; |
273 | 2.75k | g = (float *)p->data[0]; |
274 | 2.75k | b = (float *)p->data[1]; |
275 | 16.5k | for (int i = 0; i < avctx->height; i++) { |
276 | 92.0k | for (int j = 0; j < avctx->width; j++) { |
277 | 78.2k | r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale; |
278 | 78.2k | g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale; |
279 | 78.2k | b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale; |
280 | 78.2k | s->bytestream += 12; |
281 | 78.2k | } |
282 | | |
283 | 13.7k | r += p->linesize[2] / 4; |
284 | 13.7k | g += p->linesize[0] / 4; |
285 | 13.7k | b += p->linesize[1] / 4; |
286 | 13.7k | } |
287 | 17.0k | } else { |
288 | 17.0k | float *r, *g, *b; |
289 | | |
290 | 17.0k | r = (float *)p->data[2]; |
291 | 17.0k | g = (float *)p->data[0]; |
292 | 17.0k | b = (float *)p->data[1]; |
293 | 66.0k | for (int i = 0; i < avctx->height; i++) { |
294 | 275k | for (int j = 0; j < avctx->width; j++) { |
295 | 226k | r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale; |
296 | 226k | g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale; |
297 | 226k | b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale; |
298 | 226k | s->bytestream += 12; |
299 | 226k | } |
300 | | |
301 | 48.9k | r += p->linesize[2] / 4; |
302 | 48.9k | g += p->linesize[0] / 4; |
303 | 48.9k | b += p->linesize[1] / 4; |
304 | 48.9k | } |
305 | 17.0k | } |
306 | 26.7k | } else { |
307 | 26.7k | if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream) |
308 | 2.95k | return AVERROR_INVALIDDATA; |
309 | 23.7k | scale = 1.f / s->scale; |
310 | 23.7k | if (s->endian) { |
311 | 11.3k | float *r, *g, *b; |
312 | | |
313 | 11.3k | r = (float *)p->data[2]; |
314 | 11.3k | g = (float *)p->data[0]; |
315 | 11.3k | b = (float *)p->data[1]; |
316 | 28.0k | for (int i = 0; i < avctx->height; i++) { |
317 | 201k | for (int j = 0; j < avctx->width; j++) { |
318 | 185k | r[j] = av_int2float(half2float(AV_RL16(s->bytestream+0), &s->h2f_tables)) * scale; |
319 | 185k | g[j] = av_int2float(half2float(AV_RL16(s->bytestream+2), &s->h2f_tables)) * scale; |
320 | 185k | b[j] = av_int2float(half2float(AV_RL16(s->bytestream+4), &s->h2f_tables)) * scale; |
321 | 185k | s->bytestream += 6; |
322 | 185k | } |
323 | | |
324 | 16.6k | r += p->linesize[2] / 4; |
325 | 16.6k | g += p->linesize[0] / 4; |
326 | 16.6k | b += p->linesize[1] / 4; |
327 | 16.6k | } |
328 | 12.4k | } else { |
329 | 12.4k | float *r, *g, *b; |
330 | | |
331 | 12.4k | r = (float *)p->data[2]; |
332 | 12.4k | g = (float *)p->data[0]; |
333 | 12.4k | b = (float *)p->data[1]; |
334 | 324k | for (int i = 0; i < avctx->height; i++) { |
335 | 813k | for (int j = 0; j < avctx->width; j++) { |
336 | 501k | r[j] = av_int2float(half2float(AV_RB16(s->bytestream+0), &s->h2f_tables)) * scale; |
337 | 501k | g[j] = av_int2float(half2float(AV_RB16(s->bytestream+2), &s->h2f_tables)) * scale; |
338 | 501k | b[j] = av_int2float(half2float(AV_RB16(s->bytestream+4), &s->h2f_tables)) * scale; |
339 | 501k | s->bytestream += 6; |
340 | 501k | } |
341 | | |
342 | 311k | r += p->linesize[2] / 4; |
343 | 311k | g += p->linesize[0] / 4; |
344 | 311k | b += p->linesize[1] / 4; |
345 | 311k | } |
346 | 12.4k | } |
347 | 23.7k | } |
348 | | /* PFM is encoded from bottom to top */ |
349 | 43.5k | p->data[0] += (avctx->height - 1) * p->linesize[0]; |
350 | 43.5k | p->data[1] += (avctx->height - 1) * p->linesize[1]; |
351 | 43.5k | p->data[2] += (avctx->height - 1) * p->linesize[2]; |
352 | 43.5k | p->linesize[0] = -p->linesize[0]; |
353 | 43.5k | p->linesize[1] = -p->linesize[1]; |
354 | 43.5k | p->linesize[2] = -p->linesize[2]; |
355 | 43.5k | break; |
356 | 389k | case AV_PIX_FMT_GRAYF32: |
357 | 389k | if (!s->half) { |
358 | 192k | if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream) |
359 | 3.35k | return AVERROR_INVALIDDATA; |
360 | 188k | scale = 1.f / s->scale; |
361 | 188k | if (s->endian) { |
362 | 3.52k | float *g = (float *)p->data[0]; |
363 | 70.4k | for (int i = 0; i < avctx->height; i++) { |
364 | 276k | for (int j = 0; j < avctx->width; j++) { |
365 | 209k | g[j] = av_int2float(AV_RL32(s->bytestream)) * scale; |
366 | 209k | s->bytestream += 4; |
367 | 209k | } |
368 | 66.9k | g += p->linesize[0] / 4; |
369 | 66.9k | } |
370 | 185k | } else { |
371 | 185k | float *g = (float *)p->data[0]; |
372 | 1.16M | for (int i = 0; i < avctx->height; i++) { |
373 | 2.13M | for (int j = 0; j < avctx->width; j++) { |
374 | 1.15M | g[j] = av_int2float(AV_RB32(s->bytestream)) * scale; |
375 | 1.15M | s->bytestream += 4; |
376 | 1.15M | } |
377 | 979k | g += p->linesize[0] / 4; |
378 | 979k | } |
379 | 185k | } |
380 | 197k | } else { |
381 | 197k | if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream) |
382 | 2.05k | return AVERROR_INVALIDDATA; |
383 | 195k | scale = 1.f / s->scale; |
384 | 195k | if (s->endian) { |
385 | 2.63k | float *g = (float *)p->data[0]; |
386 | 58.6k | for (int i = 0; i < avctx->height; i++) { |
387 | 236k | for (int j = 0; j < avctx->width; j++) { |
388 | 180k | g[j] = av_int2float(half2float(AV_RL16(s->bytestream), &s->h2f_tables)) * scale; |
389 | 180k | s->bytestream += 2; |
390 | 180k | } |
391 | 56.0k | g += p->linesize[0] / 4; |
392 | 56.0k | } |
393 | 192k | } else { |
394 | 192k | float *g = (float *)p->data[0]; |
395 | 853k | for (int i = 0; i < avctx->height; i++) { |
396 | 3.16M | for (int j = 0; j < avctx->width; j++) { |
397 | 2.50M | g[j] = av_int2float(half2float(AV_RB16(s->bytestream), &s->h2f_tables)) * scale; |
398 | 2.50M | s->bytestream += 2; |
399 | 2.50M | } |
400 | 660k | g += p->linesize[0] / 4; |
401 | 660k | } |
402 | 192k | } |
403 | 195k | } |
404 | | /* PFM is encoded from bottom to top */ |
405 | 383k | p->data[0] += (avctx->height - 1) * p->linesize[0]; |
406 | 383k | p->linesize[0] = -p->linesize[0]; |
407 | 383k | break; |
408 | 2.95M | } |
409 | 2.81M | *got_frame = 1; |
410 | | |
411 | 2.81M | return s->bytestream - s->bytestream_start; |
412 | 2.95M | } |
413 | | |
414 | | |
415 | | #if CONFIG_PGM_DECODER |
416 | | const FFCodec ff_pgm_decoder = { |
417 | | .p.name = "pgm", |
418 | | CODEC_LONG_NAME("PGM (Portable GrayMap) image"), |
419 | | .p.type = AVMEDIA_TYPE_VIDEO, |
420 | | .p.id = AV_CODEC_ID_PGM, |
421 | | .p.capabilities = AV_CODEC_CAP_DR1, |
422 | | .priv_data_size = sizeof(PNMContext), |
423 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
424 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
425 | | }; |
426 | | #endif |
427 | | |
428 | | #if CONFIG_PGMYUV_DECODER |
429 | | const FFCodec ff_pgmyuv_decoder = { |
430 | | .p.name = "pgmyuv", |
431 | | CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"), |
432 | | .p.type = AVMEDIA_TYPE_VIDEO, |
433 | | .p.id = AV_CODEC_ID_PGMYUV, |
434 | | .p.capabilities = AV_CODEC_CAP_DR1, |
435 | | .priv_data_size = sizeof(PNMContext), |
436 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
437 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
438 | | }; |
439 | | #endif |
440 | | |
441 | | #if CONFIG_PPM_DECODER |
442 | | const FFCodec ff_ppm_decoder = { |
443 | | .p.name = "ppm", |
444 | | CODEC_LONG_NAME("PPM (Portable PixelMap) image"), |
445 | | .p.type = AVMEDIA_TYPE_VIDEO, |
446 | | .p.id = AV_CODEC_ID_PPM, |
447 | | .p.capabilities = AV_CODEC_CAP_DR1, |
448 | | .priv_data_size = sizeof(PNMContext), |
449 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
450 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
451 | | }; |
452 | | #endif |
453 | | |
454 | | #if CONFIG_PBM_DECODER |
455 | | const FFCodec ff_pbm_decoder = { |
456 | | .p.name = "pbm", |
457 | | CODEC_LONG_NAME("PBM (Portable BitMap) image"), |
458 | | .p.type = AVMEDIA_TYPE_VIDEO, |
459 | | .p.id = AV_CODEC_ID_PBM, |
460 | | .p.capabilities = AV_CODEC_CAP_DR1, |
461 | | .priv_data_size = sizeof(PNMContext), |
462 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
463 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
464 | | }; |
465 | | #endif |
466 | | |
467 | | #if CONFIG_PAM_DECODER |
468 | | const FFCodec ff_pam_decoder = { |
469 | | .p.name = "pam", |
470 | | CODEC_LONG_NAME("PAM (Portable AnyMap) image"), |
471 | | .p.type = AVMEDIA_TYPE_VIDEO, |
472 | | .p.id = AV_CODEC_ID_PAM, |
473 | | .p.capabilities = AV_CODEC_CAP_DR1, |
474 | | .priv_data_size = sizeof(PNMContext), |
475 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
476 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
477 | | }; |
478 | | #endif |
479 | | |
480 | | #if CONFIG_PFM_DECODER |
481 | | const FFCodec ff_pfm_decoder = { |
482 | | .p.name = "pfm", |
483 | | CODEC_LONG_NAME("PFM (Portable FloatMap) image"), |
484 | | .p.type = AVMEDIA_TYPE_VIDEO, |
485 | | .p.id = AV_CODEC_ID_PFM, |
486 | | .p.capabilities = AV_CODEC_CAP_DR1, |
487 | | .priv_data_size = sizeof(PNMContext), |
488 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
489 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
490 | | }; |
491 | | #endif |
492 | | |
493 | | #if CONFIG_PHM_DECODER |
494 | | static av_cold int phm_dec_init(AVCodecContext *avctx) |
495 | 5.14k | { |
496 | 5.14k | PNMContext *s = avctx->priv_data; |
497 | | |
498 | 5.14k | ff_init_half2float_tables(&s->h2f_tables); |
499 | | |
500 | 5.14k | return 0; |
501 | 5.14k | } |
502 | | |
503 | | const FFCodec ff_phm_decoder = { |
504 | | .p.name = "phm", |
505 | | CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"), |
506 | | .p.type = AVMEDIA_TYPE_VIDEO, |
507 | | .p.id = AV_CODEC_ID_PHM, |
508 | | .p.capabilities = AV_CODEC_CAP_DR1, |
509 | | .priv_data_size = sizeof(PNMContext), |
510 | | .init = phm_dec_init, |
511 | | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
512 | | FF_CODEC_DECODE_CB(pnm_decode_frame), |
513 | | }; |
514 | | #endif |