FFmpeg coverage


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