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 
26 #include "avcodec.h"
27 #include "codec_internal.h"
28 #include "decode.h"
29 #include "put_bits.h"
30 #include "pnm.h"
31 
32 static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval)
33 {
34  if (maxval <= 255) {
35  memcpy(dst, src, n);
36  } else {
37  int i;
38  for (i=0; i<n/2; i++) {
39  ((uint16_t *)dst)[i] = AV_RB16(src+2*i);
40  }
41  }
42 }
43 
44 static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
45  int *got_frame, AVPacket *avpkt)
46 {
47  const uint8_t *buf = avpkt->data;
48  int buf_size = avpkt->size;
49  PNMContext * const s = avctx->priv_data;
50  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  s->bytestream_start =
56  s->bytestream = buf;
57  s->bytestream_end = buf + buf_size;
58 
59  if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
60  return ret;
61 
62  if (avctx->skip_frame >= AVDISCARD_ALL)
63  return avpkt->size;
64 
65  if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
66  return ret;
68  p->key_frame = 1;
69  avctx->bits_per_raw_sample = av_log2(s->maxval) + 1;
70 
71  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  case AV_PIX_FMT_RGB48:
82  n = avctx->width * 6;
83  components=3;
84  sample_len=16;
85  if (s->maxval < 65535)
86  upgrade = 2;
87  goto do_read;
88  case AV_PIX_FMT_RGBA:
89  n = avctx->width * 4;
90  components=4;
91  sample_len=8;
92  goto do_read;
93  case AV_PIX_FMT_RGB24:
94  n = avctx->width * 3;
95  components=3;
96  sample_len=8;
97  if (s->maxval < 255)
98  upgrade = 1;
99  goto do_read;
100  case AV_PIX_FMT_GRAY8:
101  n = avctx->width;
102  components=1;
103  sample_len=8;
104  if (s->maxval < 255)
105  upgrade = 1;
106  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  case AV_PIX_FMT_GRAY16:
113  n = avctx->width * 2;
114  components=1;
115  sample_len=16;
116  if (s->maxval < 65535)
117  upgrade = 2;
118  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;
128  n = (avctx->width + 7) >> 3;
129  components=1;
130  sample_len=1;
131  is_mono = 1;
132  do_read:
133  ptr = p->data[0];
134  linesize = p->linesize[0];
135  if (n * avctx->height > s->bytestream_end - s->bytestream)
136  return AVERROR_INVALIDDATA;
137  if(s->type < 4 || (is_mono && s->type==7)){
138  for (i=0; i<avctx->height; i++) {
139  PutBitContext pb;
140  init_put_bits(&pb, ptr, linesize);
141  for(j=0; j<avctx->width * components; j++){
142  unsigned int c=0;
143  unsigned v=0;
144  if(s->type < 4)
145  while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
146  s->bytestream++;
147  if(s->bytestream >= s->bytestream_end)
148  return AVERROR_INVALIDDATA;
149  if (is_mono) {
150  /* read a single digit */
151  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  if (sample_len == 16) {
164  ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval;
165  } else
166  put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval);
167  }
168  if (sample_len != 16)
169  flush_put_bits(&pb);
170  ptr+= linesize;
171  }
172  }else{
173  for (int i = 0; i < avctx->height; i++) {
174  if (!upgrade)
175  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  s->bytestream += n;
188  ptr += linesize;
189  }
190  }
191  break;
192  case AV_PIX_FMT_YUV420P:
193  case AV_PIX_FMT_YUV420P9:
195  {
196  unsigned char *ptr1, *ptr2;
197 
198  n = avctx->width;
199  ptr = p->data[0];
200  linesize = p->linesize[0];
201  if (s->maxval >= 256)
202  n *= 2;
203  if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
204  return AVERROR_INVALIDDATA;
205  for (i = 0; i < avctx->height; i++) {
206  samplecpy(ptr, s->bytestream, n, s->maxval);
207  s->bytestream += n;
208  ptr += linesize;
209  }
210  ptr1 = p->data[1];
211  ptr2 = p->data[2];
212  n >>= 1;
213  h = avctx->height >> 1;
214  for (i = 0; i < h; i++) {
215  samplecpy(ptr1, s->bytestream, n, s->maxval);
216  s->bytestream += n;
217  samplecpy(ptr2, s->bytestream, n, s->maxval);
218  s->bytestream += n;
219  ptr1 += p->linesize[1];
220  ptr2 += p->linesize[2];
221  }
222  }
223  break;
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  case AV_PIX_FMT_GBRPF32:
266  if (!s->half) {
267  if (avctx->width * avctx->height * 12 > s->bytestream_end - s->bytestream)
268  return AVERROR_INVALIDDATA;
269  scale = 1.f / s->scale;
270  if (s->endian) {
271  float *r, *g, *b;
272 
273  r = (float *)p->data[2];
274  g = (float *)p->data[0];
275  b = (float *)p->data[1];
276  for (int i = 0; i < avctx->height; i++) {
277  for (int j = 0; j < avctx->width; j++) {
278  r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
279  g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
280  b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
281  s->bytestream += 12;
282  }
283 
284  r += p->linesize[2] / 4;
285  g += p->linesize[0] / 4;
286  b += p->linesize[1] / 4;
287  }
288  } else {
289  float *r, *g, *b;
290 
291  r = (float *)p->data[2];
292  g = (float *)p->data[0];
293  b = (float *)p->data[1];
294  for (int i = 0; i < avctx->height; i++) {
295  for (int j = 0; j < avctx->width; j++) {
296  r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
297  g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
298  b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
299  s->bytestream += 12;
300  }
301 
302  r += p->linesize[2] / 4;
303  g += p->linesize[0] / 4;
304  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  break;
350  case AV_PIX_FMT_GRAYF32:
351  if (!s->half) {
352  if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
353  return AVERROR_INVALIDDATA;
354  scale = 1.f / s->scale;
355  if (s->endian) {
356  float *g = (float *)p->data[0];
357  for (int i = 0; i < avctx->height; i++) {
358  for (int j = 0; j < avctx->width; j++) {
359  g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
360  s->bytestream += 4;
361  }
362  g += p->linesize[0] / 4;
363  }
364  } else {
365  float *g = (float *)p->data[0];
366  for (int i = 0; i < avctx->height; i++) {
367  for (int j = 0; j < avctx->width; j++) {
368  g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
369  s->bytestream += 4;
370  }
371  g += p->linesize[0] / 4;
372  }
373  }
374  } else {
375  if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream)
376  return AVERROR_INVALIDDATA;
377  scale = 1.f / s->scale;
378  if (s->endian) {
379  float *g = (float *)p->data[0];
380  for (int i = 0; i < avctx->height; i++) {
381  for (int j = 0; j < avctx->width; j++) {
382  g[j] = av_int2float(half2float(AV_RL16(s->bytestream), &s->h2f_tables)) * scale;
383  s->bytestream += 2;
384  }
385  g += p->linesize[0] / 4;
386  }
387  } else {
388  float *g = (float *)p->data[0];
389  for (int i = 0; i < avctx->height; i++) {
390  for (int j = 0; j < avctx->width; j++) {
391  g[j] = av_int2float(half2float(AV_RB16(s->bytestream), &s->h2f_tables)) * scale;
392  s->bytestream += 2;
393  }
394  g += p->linesize[0] / 4;
395  }
396  }
397  }
398  break;
399  }
400  *got_frame = 1;
401 
402  return s->bytestream - s->bytestream_start;
403 }
404 
405 
406 #if CONFIG_PGM_DECODER
407 const FFCodec ff_pgm_decoder = {
408  .p.name = "pgm",
409  CODEC_LONG_NAME("PGM (Portable GrayMap) image"),
410  .p.type = AVMEDIA_TYPE_VIDEO,
411  .p.id = AV_CODEC_ID_PGM,
412  .p.capabilities = AV_CODEC_CAP_DR1,
413  .priv_data_size = sizeof(PNMContext),
414  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
416 };
417 #endif
418 
419 #if CONFIG_PGMYUV_DECODER
420 const FFCodec ff_pgmyuv_decoder = {
421  .p.name = "pgmyuv",
422  CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"),
423  .p.type = AVMEDIA_TYPE_VIDEO,
424  .p.id = AV_CODEC_ID_PGMYUV,
425  .p.capabilities = AV_CODEC_CAP_DR1,
426  .priv_data_size = sizeof(PNMContext),
427  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
429 };
430 #endif
431 
432 #if CONFIG_PPM_DECODER
433 const FFCodec ff_ppm_decoder = {
434  .p.name = "ppm",
435  CODEC_LONG_NAME("PPM (Portable PixelMap) image"),
436  .p.type = AVMEDIA_TYPE_VIDEO,
437  .p.id = AV_CODEC_ID_PPM,
438  .p.capabilities = AV_CODEC_CAP_DR1,
439  .priv_data_size = sizeof(PNMContext),
440  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
442 };
443 #endif
444 
445 #if CONFIG_PBM_DECODER
446 const FFCodec ff_pbm_decoder = {
447  .p.name = "pbm",
448  CODEC_LONG_NAME("PBM (Portable BitMap) image"),
449  .p.type = AVMEDIA_TYPE_VIDEO,
450  .p.id = AV_CODEC_ID_PBM,
451  .p.capabilities = AV_CODEC_CAP_DR1,
452  .priv_data_size = sizeof(PNMContext),
453  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
455 };
456 #endif
457 
458 #if CONFIG_PAM_DECODER
459 const FFCodec ff_pam_decoder = {
460  .p.name = "pam",
461  CODEC_LONG_NAME("PAM (Portable AnyMap) image"),
462  .p.type = AVMEDIA_TYPE_VIDEO,
463  .p.id = AV_CODEC_ID_PAM,
464  .p.capabilities = AV_CODEC_CAP_DR1,
465  .priv_data_size = sizeof(PNMContext),
466  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
468 };
469 #endif
470 
471 #if CONFIG_PFM_DECODER
472 const FFCodec ff_pfm_decoder = {
473  .p.name = "pfm",
474  CODEC_LONG_NAME("PFM (Portable FloatMap) image"),
475  .p.type = AVMEDIA_TYPE_VIDEO,
476  .p.id = AV_CODEC_ID_PFM,
477  .p.capabilities = AV_CODEC_CAP_DR1,
478  .priv_data_size = sizeof(PNMContext),
479  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
481 };
482 #endif
483 
484 #if CONFIG_PHM_DECODER
485 static av_cold int phm_dec_init(AVCodecContext *avctx)
486 {
487  PNMContext *s = avctx->priv_data;
488 
489  ff_init_half2float_tables(&s->h2f_tables);
490 
491  return 0;
492 }
493 
494 const FFCodec ff_phm_decoder = {
495  .p.name = "phm",
496  CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"),
497  .p.type = AVMEDIA_TYPE_VIDEO,
498  .p.id = AV_CODEC_ID_PHM,
499  .p.capabilities = AV_CODEC_CAP_DR1,
500  .priv_data_size = sizeof(PNMContext),
501  .init = phm_dec_init,
502  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
504 };
505 #endif
ff_pgm_decoder
const FFCodec ff_pgm_decoder
r
const char * r
Definition: vf_curves.c:126
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:306
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:221
AVPacket::data
uint8_t * data
Definition: packet.h:374
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:41
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:75
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:459
FFCodec
Definition: codec_internal.h:119
AV_CODEC_ID_PHM
@ AV_CODEC_ID_PHM
Definition: codec_id.h:318
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:346
ff_pam_decoder
const FFCodec ff_pam_decoder
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:123
AVCodecContext::skip_frame
enum AVDiscard skip_frame
Skip decoding for selected frames.
Definition: avcodec.h:1698
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
AVFrame::key_frame
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:417
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:443
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:298
s
#define s(width, name)
Definition: cbs_vp9.c:256
g
const char * g
Definition: vf_curves.c:127
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:363
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1451
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:456
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:470
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:66
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:491
PutBitContext
Definition: put_bits.h:50
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:264
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
if
if(ret)
Definition: filter_design.txt:179
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:76
AV_PIX_FMT_GRAY8A
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
Definition: pixfmt.h:136
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:449
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:76
AV_CODEC_ID_PGMYUV
@ AV_CODEC_ID_PGMYUV
Definition: codec_id.h:117
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
pnm_decode_frame
static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Definition: pnmdec.c:44
samplecpy
static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval)
Definition: pnmdec.c:32
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
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
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:422
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1450
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
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:375
codec_internal.h
ff_ppm_decoder
const FFCodec ff_ppm_decoder
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:488
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:445
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:444
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:211
AVCodecContext::height
int height
Definition: avcodec.h:571
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:608
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:398
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
ff_pbm_decoder
const FFCodec ff_pbm_decoder
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:425
AVPacket
This structure stores compressed data.
Definition: packet.h:351
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:571
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:370
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:2038
ff_pfm_decoder
const FFCodec ff_pfm_decoder
put_bits.h
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
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