FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/pnmdec.c
Date: 2024-04-26 14:42:52
Exec Total Coverage
Lines: 161 289 55.7%
Functions: 2 3 66.7%
Branches: 69 154 44.8%

Line Branch Exec 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
26 #include "avcodec.h"
27 #include "codec_internal.h"
28 #include "decode.h"
29 #include "put_bits.h"
30 #include "pnm.h"
31
32 18014944 static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval)
33 {
34
2/2
✓ Branch 0 taken 18007456 times.
✓ Branch 1 taken 7488 times.
18014944 if (maxval <= 255) {
35 18007456 memcpy(dst, src, n);
36 } else {
37 int i;
38
2/2
✓ Branch 0 taken 5271552 times.
✓ Branch 1 taken 7488 times.
5279040 for (i=0; i<n/2; i++) {
39 5271552 ((uint16_t *)dst)[i] = AV_RB16(src+2*i);
40 }
41 }
42 18014944 }
43
44 34098 static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
45 int *got_frame, AVPacket *avpkt)
46 {
47 34098 const uint8_t *buf = avpkt->data;
48 34098 int buf_size = avpkt->size;
49 34098 PNMContext * const s = avctx->priv_data;
50 34098 int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0;
51 unsigned char *ptr;
52 int components, sample_len, ret;
53 float scale;
54
55 34098 s->bytestream_start =
56 34098 s->bytestream = buf;
57 34098 s->bytestream_end = buf + buf_size;
58
59
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 34098 times.
34098 if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
60 return ret;
61
62
2/2
✓ Branch 0 taken 2634 times.
✓ Branch 1 taken 31464 times.
34098 if (avctx->skip_frame >= AVDISCARD_ALL)
63 2634 return avpkt->size;
64
65
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31464 times.
31464 if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
66 return ret;
67 31464 p->pict_type = AV_PICTURE_TYPE_I;
68 31464 p->flags |= AV_FRAME_FLAG_KEY;
69 31464 avctx->bits_per_raw_sample = av_log2(s->maxval) + 1;
70
71
9/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 209 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38 times.
✓ Branch 10 taken 31074 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 26 times.
✓ Branch 13 taken 26 times.
31464 switch (avctx->pix_fmt) {
72 default:
73 return AVERROR(EINVAL);
74 case AV_PIX_FMT_RGBA64:
75 n = avctx->width * 8;
76 components=4;
77 sample_len=16;
78 if (s->maxval < 65535)
79 upgrade = 2;
80 goto do_read;
81 13 case AV_PIX_FMT_RGB48:
82 13 n = avctx->width * 6;
83 13 components=3;
84 13 sample_len=16;
85
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (s->maxval < 65535)
86 upgrade = 2;
87 13 goto do_read;
88 13 case AV_PIX_FMT_RGBA:
89 13 n = avctx->width * 4;
90 13 components=4;
91 13 sample_len=8;
92 13 goto do_read;
93 52 case AV_PIX_FMT_RGB24:
94 52 n = avctx->width * 3;
95 52 components=3;
96 52 sample_len=8;
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if (s->maxval < 255)
98 upgrade = 1;
99 52 goto do_read;
100 209 case AV_PIX_FMT_GRAY8:
101 209 n = avctx->width;
102 209 components=1;
103 209 sample_len=8;
104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if (s->maxval < 255)
105 upgrade = 1;
106 209 goto do_read;
107 case AV_PIX_FMT_GRAY8A:
108 n = avctx->width * 2;
109 components=2;
110 sample_len=8;
111 goto do_read;
112 13 case AV_PIX_FMT_GRAY16:
113 13 n = avctx->width * 2;
114 13 components=1;
115 13 sample_len=16;
116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (s->maxval < 65535)
117 upgrade = 2;
118 13 goto do_read;
119 case AV_PIX_FMT_YA16:
120 n = avctx->width * 4;
121 components=2;
122 sample_len=16;
123 if (s->maxval < 65535)
124 upgrade = 2;
125 goto do_read;
126 38 case AV_PIX_FMT_MONOWHITE:
127 case AV_PIX_FMT_MONOBLACK:
128 38 n = (avctx->width + 7) >> 3;
129 38 components=1;
130 38 sample_len=1;
131 38 is_mono = 1;
132 338 do_read:
133 338 ptr = p->data[0];
134 338 linesize = p->linesize[0];
135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if (n * avctx->height > s->bytestream_end - s->bytestream)
136 return AVERROR_INVALIDDATA;
137
5/6
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 25 times.
338 if(s->type < 4 || (is_mono && s->type==7)){
138
2/2
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 13 times.
3757 for (i=0; i<avctx->height; i++) {
139 PutBitContext pb;
140 3744 init_put_bits(&pb, ptr, FFABS(linesize));
141
2/2
✓ Branch 0 taken 1317888 times.
✓ Branch 1 taken 3744 times.
1321632 for(j=0; j<avctx->width * components; j++){
142 1317888 unsigned int c=0;
143 1317888 unsigned v=0;
144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1317888 times.
1317888 if(s->type < 4)
145 while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
146 s->bytestream++;
147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1317888 times.
1317888 if(s->bytestream >= s->bytestream_end)
148 return AVERROR_INVALIDDATA;
149
1/2
✓ Branch 0 taken 1317888 times.
✗ Branch 1 not taken.
1317888 if (is_mono) {
150 /* read a single digit */
151 1317888 v = (*s->bytestream++)&1;
152 } else {
153 /* read a sequence of digits */
154 for (k = 0; k < 6 && c <= 9; k += 1) {
155 v = 10*v + c;
156 c = (*s->bytestream++) - '0';
157 }
158 if (v > s->maxval) {
159 av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval);
160 return AVERROR_INVALIDDATA;
161 }
162 }
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1317888 times.
1317888 if (sample_len == 16) {
164 ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval;
165 } else
166 1317888 put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval);
167 }
168
1/2
✓ Branch 0 taken 3744 times.
✗ Branch 1 not taken.
3744 if (sample_len != 16)
169 3744 flush_put_bits(&pb);
170 3744 ptr+= linesize;
171 }
172 }else{
173
2/2
✓ Branch 0 taken 116320 times.
✓ Branch 1 taken 325 times.
116645 for (int i = 0; i < avctx->height; i++) {
174
1/2
✓ Branch 0 taken 116320 times.
✗ Branch 1 not taken.
116320 if (!upgrade)
175 116320 samplecpy(ptr, s->bytestream, n, s->maxval);
176 else if (upgrade == 1) {
177 unsigned int f = (255 * 128 + s->maxval / 2) / s->maxval;
178 for (unsigned j = 0; j < n; j++)
179 ptr[j] = (s->bytestream[j] * f + 64) >> 7;
180 } else if (upgrade == 2) {
181 unsigned int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
182 for (unsigned j = 0; j < n / 2; j++) {
183 unsigned v = AV_RB16(s->bytestream + 2*j);
184 ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
185 }
186 }
187 116320 s->bytestream += n;
188 116320 ptr += linesize;
189 }
190 }
191 338 break;
192 31074 case AV_PIX_FMT_YUV420P:
193 case AV_PIX_FMT_YUV420P9:
194 case AV_PIX_FMT_YUV420P10:
195 {
196 unsigned char *ptr1, *ptr2;
197
198 31074 n = avctx->width;
199 31074 ptr = p->data[0];
200 31074 linesize = p->linesize[0];
201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31074 times.
31074 if (s->maxval >= 256)
202 n *= 2;
203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31074 times.
31074 if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
204 return AVERROR_INVALIDDATA;
205
2/2
✓ Branch 0 taken 8949312 times.
✓ Branch 1 taken 31074 times.
8980386 for (i = 0; i < avctx->height; i++) {
206 8949312 samplecpy(ptr, s->bytestream, n, s->maxval);
207 8949312 s->bytestream += n;
208 8949312 ptr += linesize;
209 }
210 31074 ptr1 = p->data[1];
211 31074 ptr2 = p->data[2];
212 31074 n >>= 1;
213 31074 h = avctx->height >> 1;
214
2/2
✓ Branch 0 taken 4474656 times.
✓ Branch 1 taken 31074 times.
4505730 for (i = 0; i < h; i++) {
215 4474656 samplecpy(ptr1, s->bytestream, n, s->maxval);
216 4474656 s->bytestream += n;
217 4474656 samplecpy(ptr2, s->bytestream, n, s->maxval);
218 4474656 s->bytestream += n;
219 4474656 ptr1 += p->linesize[1];
220 4474656 ptr2 += p->linesize[2];
221 }
222 }
223 31074 break;
224 case AV_PIX_FMT_YUV420P16:
225 {
226 uint16_t *ptr1, *ptr2;
227 const int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
228 unsigned int j, v;
229
230 n = avctx->width * 2;
231 ptr = p->data[0];
232 linesize = p->linesize[0];
233 if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
234 return AVERROR_INVALIDDATA;
235 for (i = 0; i < avctx->height; i++) {
236 for (j = 0; j < n / 2; j++) {
237 v = AV_RB16(s->bytestream + 2*j);
238 ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
239 }
240 s->bytestream += n;
241 ptr += linesize;
242 }
243 ptr1 = (uint16_t*)p->data[1];
244 ptr2 = (uint16_t*)p->data[2];
245 n >>= 1;
246 h = avctx->height >> 1;
247 for (i = 0; i < h; i++) {
248 for (j = 0; j < n / 2; j++) {
249 v = AV_RB16(s->bytestream + 2*j);
250 ptr1[j] = (v * f + 16384) >> 15;
251 }
252 s->bytestream += n;
253
254 for (j = 0; j < n / 2; j++) {
255 v = AV_RB16(s->bytestream + 2*j);
256 ptr2[j] = (v * f + 16384) >> 15;
257 }
258 s->bytestream += n;
259
260 ptr1 += p->linesize[1] / 2;
261 ptr2 += p->linesize[2] / 2;
262 }
263 }
264 break;
265 26 case AV_PIX_FMT_GBRPF32:
266
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if (!s->half) {
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if (avctx->width * avctx->height * 12 > s->bytestream_end - s->bytestream)
268 return AVERROR_INVALIDDATA;
269 26 scale = 1.f / s->scale;
270
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 if (s->endian) {
271 float *r, *g, *b;
272
273 13 r = (float *)p->data[2];
274 13 g = (float *)p->data[0];
275 13 b = (float *)p->data[1];
276
2/2
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 13 times.
3757 for (int i = 0; i < avctx->height; i++) {
277
2/2
✓ Branch 0 taken 1317888 times.
✓ Branch 1 taken 3744 times.
1321632 for (int j = 0; j < avctx->width; j++) {
278 1317888 r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
279 1317888 g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
280 1317888 b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
281 1317888 s->bytestream += 12;
282 }
283
284 3744 r += p->linesize[2] / 4;
285 3744 g += p->linesize[0] / 4;
286 3744 b += p->linesize[1] / 4;
287 }
288 } else {
289 float *r, *g, *b;
290
291 13 r = (float *)p->data[2];
292 13 g = (float *)p->data[0];
293 13 b = (float *)p->data[1];
294
2/2
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 13 times.
3757 for (int i = 0; i < avctx->height; i++) {
295
2/2
✓ Branch 0 taken 1317888 times.
✓ Branch 1 taken 3744 times.
1321632 for (int j = 0; j < avctx->width; j++) {
296 1317888 r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
297 1317888 g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
298 1317888 b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
299 1317888 s->bytestream += 12;
300 }
301
302 3744 r += p->linesize[2] / 4;
303 3744 g += p->linesize[0] / 4;
304 3744 b += p->linesize[1] / 4;
305 }
306 }
307 } else {
308 if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream)
309 return AVERROR_INVALIDDATA;
310 scale = 1.f / s->scale;
311 if (s->endian) {
312 float *r, *g, *b;
313
314 r = (float *)p->data[2];
315 g = (float *)p->data[0];
316 b = (float *)p->data[1];
317 for (int i = 0; i < avctx->height; i++) {
318 for (int j = 0; j < avctx->width; j++) {
319 r[j] = av_int2float(half2float(AV_RL16(s->bytestream+0), &s->h2f_tables)) * scale;
320 g[j] = av_int2float(half2float(AV_RL16(s->bytestream+2), &s->h2f_tables)) * scale;
321 b[j] = av_int2float(half2float(AV_RL16(s->bytestream+4), &s->h2f_tables)) * scale;
322 s->bytestream += 6;
323 }
324
325 r += p->linesize[2] / 4;
326 g += p->linesize[0] / 4;
327 b += p->linesize[1] / 4;
328 }
329 } else {
330 float *r, *g, *b;
331
332 r = (float *)p->data[2];
333 g = (float *)p->data[0];
334 b = (float *)p->data[1];
335 for (int i = 0; i < avctx->height; i++) {
336 for (int j = 0; j < avctx->width; j++) {
337 r[j] = av_int2float(half2float(AV_RB16(s->bytestream+0), &s->h2f_tables)) * scale;
338 g[j] = av_int2float(half2float(AV_RB16(s->bytestream+2), &s->h2f_tables)) * scale;
339 b[j] = av_int2float(half2float(AV_RB16(s->bytestream+4), &s->h2f_tables)) * scale;
340 s->bytestream += 6;
341 }
342
343 r += p->linesize[2] / 4;
344 g += p->linesize[0] / 4;
345 b += p->linesize[1] / 4;
346 }
347 }
348 }
349 /* PFM is encoded from bottom to top */
350 26 p->data[0] += (avctx->height - 1) * p->linesize[0];
351 26 p->data[1] += (avctx->height - 1) * p->linesize[1];
352 26 p->data[2] += (avctx->height - 1) * p->linesize[2];
353 26 p->linesize[0] = -p->linesize[0];
354 26 p->linesize[1] = -p->linesize[1];
355 26 p->linesize[2] = -p->linesize[2];
356 26 break;
357 26 case AV_PIX_FMT_GRAYF32:
358
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if (!s->half) {
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
360 return AVERROR_INVALIDDATA;
361 26 scale = 1.f / s->scale;
362
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 if (s->endian) {
363 13 float *g = (float *)p->data[0];
364
2/2
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 13 times.
3757 for (int i = 0; i < avctx->height; i++) {
365
2/2
✓ Branch 0 taken 1317888 times.
✓ Branch 1 taken 3744 times.
1321632 for (int j = 0; j < avctx->width; j++) {
366 1317888 g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
367 1317888 s->bytestream += 4;
368 }
369 3744 g += p->linesize[0] / 4;
370 }
371 } else {
372 13 float *g = (float *)p->data[0];
373
2/2
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 13 times.
3757 for (int i = 0; i < avctx->height; i++) {
374
2/2
✓ Branch 0 taken 1317888 times.
✓ Branch 1 taken 3744 times.
1321632 for (int j = 0; j < avctx->width; j++) {
375 1317888 g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
376 1317888 s->bytestream += 4;
377 }
378 3744 g += p->linesize[0] / 4;
379 }
380 }
381 } else {
382 if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream)
383 return AVERROR_INVALIDDATA;
384 scale = 1.f / s->scale;
385 if (s->endian) {
386 float *g = (float *)p->data[0];
387 for (int i = 0; i < avctx->height; i++) {
388 for (int j = 0; j < avctx->width; j++) {
389 g[j] = av_int2float(half2float(AV_RL16(s->bytestream), &s->h2f_tables)) * scale;
390 s->bytestream += 2;
391 }
392 g += p->linesize[0] / 4;
393 }
394 } else {
395 float *g = (float *)p->data[0];
396 for (int i = 0; i < avctx->height; i++) {
397 for (int j = 0; j < avctx->width; j++) {
398 g[j] = av_int2float(half2float(AV_RB16(s->bytestream), &s->h2f_tables)) * scale;
399 s->bytestream += 2;
400 }
401 g += p->linesize[0] / 4;
402 }
403 }
404 }
405 /* PFM is encoded from bottom to top */
406 26 p->data[0] += (avctx->height - 1) * p->linesize[0];
407 26 p->linesize[0] = -p->linesize[0];
408 26 break;
409 }
410 31464 *got_frame = 1;
411
412 31464 return s->bytestream - s->bytestream_start;
413 }
414
415
416 #if CONFIG_PGM_DECODER
417 const FFCodec ff_pgm_decoder = {
418 .p.name = "pgm",
419 CODEC_LONG_NAME("PGM (Portable GrayMap) image"),
420 .p.type = AVMEDIA_TYPE_VIDEO,
421 .p.id = AV_CODEC_ID_PGM,
422 .p.capabilities = AV_CODEC_CAP_DR1,
423 .priv_data_size = sizeof(PNMContext),
424 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
425 FF_CODEC_DECODE_CB(pnm_decode_frame),
426 };
427 #endif
428
429 #if CONFIG_PGMYUV_DECODER
430 const FFCodec ff_pgmyuv_decoder = {
431 .p.name = "pgmyuv",
432 CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"),
433 .p.type = AVMEDIA_TYPE_VIDEO,
434 .p.id = AV_CODEC_ID_PGMYUV,
435 .p.capabilities = AV_CODEC_CAP_DR1,
436 .priv_data_size = sizeof(PNMContext),
437 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
438 FF_CODEC_DECODE_CB(pnm_decode_frame),
439 };
440 #endif
441
442 #if CONFIG_PPM_DECODER
443 const FFCodec ff_ppm_decoder = {
444 .p.name = "ppm",
445 CODEC_LONG_NAME("PPM (Portable PixelMap) image"),
446 .p.type = AVMEDIA_TYPE_VIDEO,
447 .p.id = AV_CODEC_ID_PPM,
448 .p.capabilities = AV_CODEC_CAP_DR1,
449 .priv_data_size = sizeof(PNMContext),
450 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
451 FF_CODEC_DECODE_CB(pnm_decode_frame),
452 };
453 #endif
454
455 #if CONFIG_PBM_DECODER
456 const FFCodec ff_pbm_decoder = {
457 .p.name = "pbm",
458 CODEC_LONG_NAME("PBM (Portable BitMap) image"),
459 .p.type = AVMEDIA_TYPE_VIDEO,
460 .p.id = AV_CODEC_ID_PBM,
461 .p.capabilities = AV_CODEC_CAP_DR1,
462 .priv_data_size = sizeof(PNMContext),
463 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
464 FF_CODEC_DECODE_CB(pnm_decode_frame),
465 };
466 #endif
467
468 #if CONFIG_PAM_DECODER
469 const FFCodec ff_pam_decoder = {
470 .p.name = "pam",
471 CODEC_LONG_NAME("PAM (Portable AnyMap) image"),
472 .p.type = AVMEDIA_TYPE_VIDEO,
473 .p.id = AV_CODEC_ID_PAM,
474 .p.capabilities = AV_CODEC_CAP_DR1,
475 .priv_data_size = sizeof(PNMContext),
476 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
477 FF_CODEC_DECODE_CB(pnm_decode_frame),
478 };
479 #endif
480
481 #if CONFIG_PFM_DECODER
482 const FFCodec ff_pfm_decoder = {
483 .p.name = "pfm",
484 CODEC_LONG_NAME("PFM (Portable FloatMap) image"),
485 .p.type = AVMEDIA_TYPE_VIDEO,
486 .p.id = AV_CODEC_ID_PFM,
487 .p.capabilities = AV_CODEC_CAP_DR1,
488 .priv_data_size = sizeof(PNMContext),
489 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
490 FF_CODEC_DECODE_CB(pnm_decode_frame),
491 };
492 #endif
493
494 #if CONFIG_PHM_DECODER
495 static av_cold int phm_dec_init(AVCodecContext *avctx)
496 {
497 PNMContext *s = avctx->priv_data;
498
499 ff_init_half2float_tables(&s->h2f_tables);
500
501 return 0;
502 }
503
504 const FFCodec ff_phm_decoder = {
505 .p.name = "phm",
506 CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"),
507 .p.type = AVMEDIA_TYPE_VIDEO,
508 .p.id = AV_CODEC_ID_PHM,
509 .p.capabilities = AV_CODEC_CAP_DR1,
510 .priv_data_size = sizeof(PNMContext),
511 .init = phm_dec_init,
512 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
513 FF_CODEC_DECODE_CB(pnm_decode_frame),
514 };
515 #endif
516