FFmpeg
pnmdec.c
Go to the documentation of this file.
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 {
35  if (maxval <= 255) {
36  memcpy(dst, src, n);
37  } else {
38  int i;
39  for (i=0; i<n/2; i++) {
40  ((uint16_t *)dst)[i] = AV_RB16(src+2*i);
41  }
42  }
43 }
44 
45 static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
46  int *got_frame, AVPacket *avpkt)
47 {
48  const uint8_t *buf = avpkt->data;
49  int buf_size = avpkt->size;
50  PNMContext * const s = avctx->priv_data;
51  int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0;
52  unsigned char *ptr;
53  int components, sample_len, ret;
54  float scale;
55 
56  s->bytestream_start =
57  s->bytestream = buf;
58  s->bytestream_end = buf + buf_size;
59 
60  if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
61  return ret;
62 
63  if (avctx->skip_frame >= AVDISCARD_ALL)
64  return avpkt->size;
65 
66  if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
67  return ret;
68  avctx->bits_per_raw_sample = av_log2(s->maxval) + 1;
69 
70  switch (avctx->pix_fmt) {
71  default:
72  return AVERROR(EINVAL);
73  case AV_PIX_FMT_RGBA64:
74  n = avctx->width * 8;
75  components=4;
76  sample_len=16;
77  if (s->maxval < 65535)
78  upgrade = 2;
79  goto do_read;
80  case AV_PIX_FMT_RGB48:
81  n = avctx->width * 6;
82  components=3;
83  sample_len=16;
84  if (s->maxval < 65535)
85  upgrade = 2;
86  goto do_read;
87  case AV_PIX_FMT_RGBA:
88  n = avctx->width * 4;
89  components=4;
90  sample_len=8;
91  goto do_read;
92  case AV_PIX_FMT_RGB24:
93  n = avctx->width * 3;
94  components=3;
95  sample_len=8;
96  if (s->maxval < 255)
97  upgrade = 1;
98  goto do_read;
99  case AV_PIX_FMT_GRAY8:
100  n = avctx->width;
101  components=1;
102  sample_len=8;
103  if (s->maxval < 255)
104  upgrade = 1;
105  goto do_read;
106  case AV_PIX_FMT_GRAY8A:
107  n = avctx->width * 2;
108  components=2;
109  sample_len=8;
110  goto do_read;
111  case AV_PIX_FMT_GRAY16:
112  n = avctx->width * 2;
113  components=1;
114  sample_len=16;
115  if (s->maxval < 65535)
116  upgrade = 2;
117  goto do_read;
118  case AV_PIX_FMT_YA16:
119  n = avctx->width * 4;
120  components=2;
121  sample_len=16;
122  if (s->maxval < 65535)
123  upgrade = 2;
124  goto do_read;
127  n = (avctx->width + 7) >> 3;
128  components=1;
129  sample_len=1;
130  is_mono = 1;
131  do_read:
132  ptr = p->data[0];
133  linesize = p->linesize[0];
134  if (n * avctx->height > s->bytestream_end - s->bytestream)
135  return AVERROR_INVALIDDATA;
136  if(s->type < 4 || (is_mono && s->type==7)){
137  for (i=0; i<avctx->height; i++) {
138  PutBitContext pb;
139  init_put_bits(&pb, ptr, FFABS(linesize));
140  for(j=0; j<avctx->width * components; j++){
141  unsigned int c=0;
142  unsigned v=0;
143  if(s->type < 4)
144  while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
145  s->bytestream++;
146  if(s->bytestream >= s->bytestream_end)
147  return AVERROR_INVALIDDATA;
148  if (is_mono) {
149  /* read a single digit */
150  v = (*s->bytestream++)&1;
151  } else {
152  /* read a sequence of digits */
153  for (k = 0; k < 6 && c <= 9; k += 1) {
154  v = 10*v + c;
155  c = (*s->bytestream++) - '0';
156  }
157  if (v > s->maxval) {
158  av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval);
159  return AVERROR_INVALIDDATA;
160  }
161  }
162  if (sample_len == 16) {
163  ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval;
164  } else
165  put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval);
166  }
167  if (sample_len != 16)
168  flush_put_bits(&pb);
169  ptr+= linesize;
170  }
171  }else{
172  for (int i = 0; i < avctx->height; i++) {
173  if (!upgrade)
174  samplecpy(ptr, s->bytestream, n, s->maxval);
175  else if (upgrade == 1) {
176  unsigned int f = (255 * 128 + s->maxval / 2) / s->maxval;
177  for (unsigned j = 0; j < n; j++)
178  ptr[j] = (s->bytestream[j] * f + 64) >> 7;
179  } else if (upgrade == 2) {
180  unsigned int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
181  for (unsigned j = 0; j < n / 2; j++) {
182  unsigned v = AV_RB16(s->bytestream + 2*j);
183  ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
184  }
185  }
186  s->bytestream += n;
187  ptr += linesize;
188  }
189  }
190  break;
191  case AV_PIX_FMT_YUV420P:
192  case AV_PIX_FMT_YUV420P9:
194  {
195  unsigned char *ptr1, *ptr2;
196 
197  n = avctx->width;
198  ptr = p->data[0];
199  linesize = p->linesize[0];
200  if (s->maxval >= 256)
201  n *= 2;
202  if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
203  return AVERROR_INVALIDDATA;
204  for (i = 0; i < avctx->height; i++) {
205  samplecpy(ptr, s->bytestream, n, s->maxval);
206  s->bytestream += n;
207  ptr += linesize;
208  }
209  ptr1 = p->data[1];
210  ptr2 = p->data[2];
211  n >>= 1;
212  h = avctx->height >> 1;
213  for (i = 0; i < h; i++) {
214  samplecpy(ptr1, s->bytestream, n, s->maxval);
215  s->bytestream += n;
216  samplecpy(ptr2, s->bytestream, n, s->maxval);
217  s->bytestream += n;
218  ptr1 += p->linesize[1];
219  ptr2 += p->linesize[2];
220  }
221  }
222  break;
224  {
225  uint16_t *ptr1, *ptr2;
226  const int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
227  unsigned int j, v;
228 
229  n = avctx->width * 2;
230  ptr = p->data[0];
231  linesize = p->linesize[0];
232  if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
233  return AVERROR_INVALIDDATA;
234  for (i = 0; i < avctx->height; i++) {
235  for (j = 0; j < n / 2; j++) {
236  v = AV_RB16(s->bytestream + 2*j);
237  ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
238  }
239  s->bytestream += n;
240  ptr += linesize;
241  }
242  ptr1 = (uint16_t*)p->data[1];
243  ptr2 = (uint16_t*)p->data[2];
244  n >>= 1;
245  h = avctx->height >> 1;
246  for (i = 0; i < h; i++) {
247  for (j = 0; j < n / 2; j++) {
248  v = AV_RB16(s->bytestream + 2*j);
249  ptr1[j] = (v * f + 16384) >> 15;
250  }
251  s->bytestream += n;
252 
253  for (j = 0; j < n / 2; j++) {
254  v = AV_RB16(s->bytestream + 2*j);
255  ptr2[j] = (v * f + 16384) >> 15;
256  }
257  s->bytestream += n;
258 
259  ptr1 += p->linesize[1] / 2;
260  ptr2 += p->linesize[2] / 2;
261  }
262  }
263  break;
264  case AV_PIX_FMT_GBRPF32:
265  if (!s->half) {
266  if (avctx->width * avctx->height * 12LL > s->bytestream_end - s->bytestream)
267  return AVERROR_INVALIDDATA;
268  scale = 1.f / s->scale;
269  if (s->endian) {
270  float *r, *g, *b;
271 
272  r = (float *)p->data[2];
273  g = (float *)p->data[0];
274  b = (float *)p->data[1];
275  for (int i = 0; i < avctx->height; i++) {
276  for (int j = 0; j < avctx->width; j++) {
277  r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
278  g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
279  b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
280  s->bytestream += 12;
281  }
282 
283  r += p->linesize[2] / 4;
284  g += p->linesize[0] / 4;
285  b += p->linesize[1] / 4;
286  }
287  } else {
288  float *r, *g, *b;
289 
290  r = (float *)p->data[2];
291  g = (float *)p->data[0];
292  b = (float *)p->data[1];
293  for (int i = 0; i < avctx->height; i++) {
294  for (int j = 0; j < avctx->width; j++) {
295  r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
296  g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
297  b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
298  s->bytestream += 12;
299  }
300 
301  r += p->linesize[2] / 4;
302  g += p->linesize[0] / 4;
303  b += p->linesize[1] / 4;
304  }
305  }
306  } else {
307  if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream)
308  return AVERROR_INVALIDDATA;
309  scale = 1.f / s->scale;
310  if (s->endian) {
311  float *r, *g, *b;
312 
313  r = (float *)p->data[2];
314  g = (float *)p->data[0];
315  b = (float *)p->data[1];
316  for (int i = 0; i < avctx->height; i++) {
317  for (int j = 0; j < avctx->width; j++) {
318  r[j] = av_int2float(half2float(AV_RL16(s->bytestream+0), &s->h2f_tables)) * scale;
319  g[j] = av_int2float(half2float(AV_RL16(s->bytestream+2), &s->h2f_tables)) * scale;
320  b[j] = av_int2float(half2float(AV_RL16(s->bytestream+4), &s->h2f_tables)) * scale;
321  s->bytestream += 6;
322  }
323 
324  r += p->linesize[2] / 4;
325  g += p->linesize[0] / 4;
326  b += p->linesize[1] / 4;
327  }
328  } else {
329  float *r, *g, *b;
330 
331  r = (float *)p->data[2];
332  g = (float *)p->data[0];
333  b = (float *)p->data[1];
334  for (int i = 0; i < avctx->height; i++) {
335  for (int j = 0; j < avctx->width; j++) {
336  r[j] = av_int2float(half2float(AV_RB16(s->bytestream+0), &s->h2f_tables)) * scale;
337  g[j] = av_int2float(half2float(AV_RB16(s->bytestream+2), &s->h2f_tables)) * scale;
338  b[j] = av_int2float(half2float(AV_RB16(s->bytestream+4), &s->h2f_tables)) * scale;
339  s->bytestream += 6;
340  }
341 
342  r += p->linesize[2] / 4;
343  g += p->linesize[0] / 4;
344  b += p->linesize[1] / 4;
345  }
346  }
347  }
348  /* PFM is encoded from bottom to top */
349  p->data[0] += (avctx->height - 1) * p->linesize[0];
350  p->data[1] += (avctx->height - 1) * p->linesize[1];
351  p->data[2] += (avctx->height - 1) * p->linesize[2];
352  p->linesize[0] = -p->linesize[0];
353  p->linesize[1] = -p->linesize[1];
354  p->linesize[2] = -p->linesize[2];
355  break;
356  case AV_PIX_FMT_GRAYF32:
357  if (!s->half) {
358  if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
359  return AVERROR_INVALIDDATA;
360  scale = 1.f / s->scale;
361  if (s->endian) {
362  float *g = (float *)p->data[0];
363  for (int i = 0; i < avctx->height; i++) {
364  for (int j = 0; j < avctx->width; j++) {
365  g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
366  s->bytestream += 4;
367  }
368  g += p->linesize[0] / 4;
369  }
370  } else {
371  float *g = (float *)p->data[0];
372  for (int i = 0; i < avctx->height; i++) {
373  for (int j = 0; j < avctx->width; j++) {
374  g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
375  s->bytestream += 4;
376  }
377  g += p->linesize[0] / 4;
378  }
379  }
380  } else {
381  if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream)
382  return AVERROR_INVALIDDATA;
383  scale = 1.f / s->scale;
384  if (s->endian) {
385  float *g = (float *)p->data[0];
386  for (int i = 0; i < avctx->height; i++) {
387  for (int j = 0; j < avctx->width; j++) {
388  g[j] = av_int2float(half2float(AV_RL16(s->bytestream), &s->h2f_tables)) * scale;
389  s->bytestream += 2;
390  }
391  g += p->linesize[0] / 4;
392  }
393  } else {
394  float *g = (float *)p->data[0];
395  for (int i = 0; i < avctx->height; i++) {
396  for (int j = 0; j < avctx->width; j++) {
397  g[j] = av_int2float(half2float(AV_RB16(s->bytestream), &s->h2f_tables)) * scale;
398  s->bytestream += 2;
399  }
400  g += p->linesize[0] / 4;
401  }
402  }
403  }
404  /* PFM is encoded from bottom to top */
405  p->data[0] += (avctx->height - 1) * p->linesize[0];
406  p->linesize[0] = -p->linesize[0];
407  break;
408  }
409  *got_frame = 1;
410 
411  return s->bytestream - s->bytestream_start;
412 }
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,
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,
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,
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,
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,
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,
490 };
491 #endif
492 
493 #if CONFIG_PHM_DECODER
494 static av_cold int phm_dec_init(AVCodecContext *avctx)
495 {
496  PNMContext *s = avctx->priv_data;
497 
498  ff_init_half2float_tables(&s->h2f_tables);
499 
500  return 0;
501 }
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,
513 };
514 #endif
ff_pgm_decoder
const FFCodec ff_pgm_decoder
r
const char * r
Definition: vf_curves.c:127
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AV_CODEC_ID_PBM
@ AV_CODEC_ID_PBM
Definition: codec_id.h:115
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:62
AV_CODEC_ID_PFM
@ AV_CODEC_ID_PFM
Definition: codec_id.h:307
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:410
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:223
AVPacket::data
uint8_t * data
Definition: packet.h:535
AV_CODEC_ID_PPM
@ AV_CODEC_ID_PPM
Definition: codec_id.h:114
ff_phm_decoder
const FFCodec ff_phm_decoder
b
#define b
Definition: input.c:42
AV_CODEC_ID_PGM
@ AV_CODEC_ID_PGM
Definition: codec_id.h:116
AV_PIX_FMT_MONOWHITE
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
Definition: pixfmt.h:82
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:528
FFCodec
Definition: codec_internal.h:127
intfloat.h
AV_CODEC_ID_PHM
@ AV_CODEC_ID_PHM
Definition: codec_id.h:319
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:431
ff_pam_decoder
const FFCodec ff_pam_decoder
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::skip_frame
enum AVDiscard skip_frame
Skip decoding for selected frames.
Definition: avcodec.h:1662
av_int2float
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
Definition: intfloat.h:40
ff_pgmyuv_decoder
const FFCodec ff_pgmyuv_decoder
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:511
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:341
s
#define s(width, name)
Definition: cbs_vp9.c:198
g
const char * g
Definition: vf_curves.c:128
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1553
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:525
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:539
decode.h
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:565
PutBitContext
Definition: put_bits.h:50
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
if
if(ret)
Definition: filter_design.txt:179
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:221
AV_PIX_FMT_GRAY8A
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
Definition: pixfmt.h:143
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:518
AV_PIX_FMT_MONOBLACK
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
Definition: pixfmt.h:83
AV_CODEC_ID_PGMYUV
@ AV_CODEC_ID_PGMYUV
Definition: codec_id.h:117
pnm_decode_frame
static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Definition: pnmdec.c:45
samplecpy
static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval)
Definition: pnmdec.c:33
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
pnm.h
AV_CODEC_ID_PAM
@ AV_CODEC_ID_PAM
Definition: codec_id.h:118
f
f
Definition: af_crystalizer.c:122
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1611
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:536
codec_internal.h
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
ff_ppm_decoder
const FFCodec ff_ppm_decoder
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:561
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:514
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
Definition: codec_internal.h:54
PNMContext
Definition: pnm.h:28
half2float.h
AV_PIX_FMT_YA16
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:513
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCodecContext::height
int height
Definition: avcodec.h:592
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:631
avcodec.h
ret
ret
Definition: filter_design.txt:187
half2float
static uint32_t half2float(uint16_t h, const Half2FloatTables *t)
Definition: half2float.h:39
ff_init_half2float_tables
void ff_init_half2float_tables(Half2FloatTables *t)
Definition: half2float.c:39
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AVCodecContext
main external API structure.
Definition: avcodec.h:431
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_pnm_decode_header
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext *const s)
Definition: pnm.c:65
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
ff_pbm_decoder
const FFCodec ff_pbm_decoder
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
AVPacket
This structure stores compressed data.
Definition: packet.h:512
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:592
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:455
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
h
h
Definition: vp9dsp_template.c:2070
ff_pfm_decoder
const FFCodec ff_pfm_decoder
put_bits.h
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
src
#define src
Definition: vp8dsp.c:248
AV_RB16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:98