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 
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 (avctx->width * avctx->height / 8 > s->bytestream_end - s->bytestream)
67  return AVERROR_INVALIDDATA;
68 
69  if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
70  return ret;
71  avctx->bits_per_raw_sample = av_log2(s->maxval) + 1;
72 
73  switch (avctx->pix_fmt) {
74  default:
75  return AVERROR(EINVAL);
76  case AV_PIX_FMT_RGBA64:
77  n = avctx->width * 8;
78  components=4;
79  sample_len=16;
80  if (s->maxval < 65535)
81  upgrade = 2;
82  goto do_read;
83  case AV_PIX_FMT_RGB48:
84  n = avctx->width * 6;
85  components=3;
86  sample_len=16;
87  if (s->maxval < 65535)
88  upgrade = 2;
89  goto do_read;
90  case AV_PIX_FMT_RGBA:
91  n = avctx->width * 4;
92  components=4;
93  sample_len=8;
94  goto do_read;
95  case AV_PIX_FMT_RGB24:
96  n = avctx->width * 3;
97  components=3;
98  sample_len=8;
99  if (s->maxval < 255)
100  upgrade = 1;
101  goto do_read;
102  case AV_PIX_FMT_GRAY8:
103  n = avctx->width;
104  components=1;
105  sample_len=8;
106  if (s->maxval < 255)
107  upgrade = 1;
108  goto do_read;
109  case AV_PIX_FMT_GRAY8A:
110  n = avctx->width * 2;
111  components=2;
112  sample_len=8;
113  goto do_read;
114  case AV_PIX_FMT_GRAY16:
115  n = avctx->width * 2;
116  components=1;
117  sample_len=16;
118  if (s->maxval < 65535)
119  upgrade = 2;
120  goto do_read;
121  case AV_PIX_FMT_YA16:
122  n = avctx->width * 4;
123  components=2;
124  sample_len=16;
125  if (s->maxval < 65535)
126  upgrade = 2;
127  goto do_read;
130  n = (avctx->width + 7) >> 3;
131  components=1;
132  sample_len=1;
133  is_mono = 1;
134  do_read:
135  ptr = p->data[0];
136  linesize = p->linesize[0];
137  if (n * avctx->height > s->bytestream_end - s->bytestream)
138  return AVERROR_INVALIDDATA;
139  if(s->type < 4 || (is_mono && s->type==7)){
140  for (i=0; i<avctx->height; i++) {
141  PutBitContext pb;
142  init_put_bits(&pb, ptr, FFABS(linesize));
143  for(j=0; j<avctx->width * components; j++){
144  unsigned int c=0;
145  unsigned v=0;
146  if(s->type < 4)
147  while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
148  s->bytestream++;
149  if(s->bytestream >= s->bytestream_end)
150  return AVERROR_INVALIDDATA;
151  if (is_mono) {
152  /* read a single digit */
153  v = (*s->bytestream++)&1;
154  } else {
155  /* read a sequence of digits */
156  for (k = 0; k < 6 && c <= 9; k += 1) {
157  v = 10*v + c;
158  c = (*s->bytestream++) - '0';
159  }
160  if (v > s->maxval) {
161  av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval);
162  return AVERROR_INVALIDDATA;
163  }
164  }
165  if (sample_len == 16) {
166  ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval;
167  } else
168  put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval);
169  }
170  if (sample_len != 16)
171  flush_put_bits(&pb);
172  ptr+= linesize;
173  }
174  }else{
175  for (int i = 0; i < avctx->height; i++) {
176  if (!upgrade)
177  samplecpy(ptr, s->bytestream, n, s->maxval);
178  else if (upgrade == 1) {
179  unsigned int f = (255 * 128 + s->maxval / 2) / s->maxval;
180  for (unsigned j = 0; j < n; j++)
181  ptr[j] = (s->bytestream[j] * f + 64) >> 7;
182  } else if (upgrade == 2) {
183  unsigned int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
184  for (unsigned j = 0; j < n / 2; j++) {
185  unsigned v = AV_RB16(s->bytestream + 2*j);
186  ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
187  }
188  }
189  s->bytestream += n;
190  ptr += linesize;
191  }
192  }
193  break;
194  case AV_PIX_FMT_YUV420P:
195  case AV_PIX_FMT_YUV420P9:
197  {
198  unsigned char *ptr1, *ptr2;
199 
200  n = avctx->width;
201  ptr = p->data[0];
202  linesize = p->linesize[0];
203  if (s->maxval >= 256)
204  n *= 2;
205  if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
206  return AVERROR_INVALIDDATA;
207  for (i = 0; i < avctx->height; i++) {
208  samplecpy(ptr, s->bytestream, n, s->maxval);
209  s->bytestream += n;
210  ptr += linesize;
211  }
212  ptr1 = p->data[1];
213  ptr2 = p->data[2];
214  n >>= 1;
215  h = avctx->height >> 1;
216  for (i = 0; i < h; i++) {
217  samplecpy(ptr1, s->bytestream, n, s->maxval);
218  s->bytestream += n;
219  samplecpy(ptr2, s->bytestream, n, s->maxval);
220  s->bytestream += n;
221  ptr1 += p->linesize[1];
222  ptr2 += p->linesize[2];
223  }
224  }
225  break;
227  {
228  uint16_t *ptr1, *ptr2;
229  const int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
230  unsigned int j, v;
231 
232  n = avctx->width * 2;
233  ptr = p->data[0];
234  linesize = p->linesize[0];
235  if (n * avctx->height * 3 / 2 > s->bytestream_end - s->bytestream)
236  return AVERROR_INVALIDDATA;
237  for (i = 0; i < avctx->height; i++) {
238  for (j = 0; j < n / 2; j++) {
239  v = AV_RB16(s->bytestream + 2*j);
240  ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
241  }
242  s->bytestream += n;
243  ptr += linesize;
244  }
245  ptr1 = (uint16_t*)p->data[1];
246  ptr2 = (uint16_t*)p->data[2];
247  n >>= 1;
248  h = avctx->height >> 1;
249  for (i = 0; i < h; i++) {
250  for (j = 0; j < n / 2; j++) {
251  v = AV_RB16(s->bytestream + 2*j);
252  ptr1[j] = (v * f + 16384) >> 15;
253  }
254  s->bytestream += n;
255 
256  for (j = 0; j < n / 2; j++) {
257  v = AV_RB16(s->bytestream + 2*j);
258  ptr2[j] = (v * f + 16384) >> 15;
259  }
260  s->bytestream += n;
261 
262  ptr1 += p->linesize[1] / 2;
263  ptr2 += p->linesize[2] / 2;
264  }
265  }
266  break;
267  case AV_PIX_FMT_GBRPF32:
268  if (!s->half) {
269  if (avctx->width * avctx->height * 12LL > s->bytestream_end - s->bytestream)
270  return AVERROR_INVALIDDATA;
271  scale = 1.f / s->scale;
272  if (s->endian) {
273  float *r, *g, *b;
274 
275  r = (float *)p->data[2];
276  g = (float *)p->data[0];
277  b = (float *)p->data[1];
278  for (int i = 0; i < avctx->height; i++) {
279  for (int j = 0; j < avctx->width; j++) {
280  r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
281  g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
282  b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
283  s->bytestream += 12;
284  }
285 
286  r += p->linesize[2] / 4;
287  g += p->linesize[0] / 4;
288  b += p->linesize[1] / 4;
289  }
290  } else {
291  float *r, *g, *b;
292 
293  r = (float *)p->data[2];
294  g = (float *)p->data[0];
295  b = (float *)p->data[1];
296  for (int i = 0; i < avctx->height; i++) {
297  for (int j = 0; j < avctx->width; j++) {
298  r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
299  g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
300  b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
301  s->bytestream += 12;
302  }
303 
304  r += p->linesize[2] / 4;
305  g += p->linesize[0] / 4;
306  b += p->linesize[1] / 4;
307  }
308  }
309  } else {
310  if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream)
311  return AVERROR_INVALIDDATA;
312  scale = 1.f / s->scale;
313  if (s->endian) {
314  float *r, *g, *b;
315 
316  r = (float *)p->data[2];
317  g = (float *)p->data[0];
318  b = (float *)p->data[1];
319  for (int i = 0; i < avctx->height; i++) {
320  for (int j = 0; j < avctx->width; j++) {
321  r[j] = av_int2float(half2float(AV_RL16(s->bytestream+0), &s->h2f_tables)) * scale;
322  g[j] = av_int2float(half2float(AV_RL16(s->bytestream+2), &s->h2f_tables)) * scale;
323  b[j] = av_int2float(half2float(AV_RL16(s->bytestream+4), &s->h2f_tables)) * scale;
324  s->bytestream += 6;
325  }
326 
327  r += p->linesize[2] / 4;
328  g += p->linesize[0] / 4;
329  b += p->linesize[1] / 4;
330  }
331  } else {
332  float *r, *g, *b;
333 
334  r = (float *)p->data[2];
335  g = (float *)p->data[0];
336  b = (float *)p->data[1];
337  for (int i = 0; i < avctx->height; i++) {
338  for (int j = 0; j < avctx->width; j++) {
339  r[j] = av_int2float(half2float(AV_RB16(s->bytestream+0), &s->h2f_tables)) * scale;
340  g[j] = av_int2float(half2float(AV_RB16(s->bytestream+2), &s->h2f_tables)) * scale;
341  b[j] = av_int2float(half2float(AV_RB16(s->bytestream+4), &s->h2f_tables)) * scale;
342  s->bytestream += 6;
343  }
344 
345  r += p->linesize[2] / 4;
346  g += p->linesize[0] / 4;
347  b += p->linesize[1] / 4;
348  }
349  }
350  }
351  /* PFM is encoded from bottom to top */
352  p->data[0] += (avctx->height - 1) * p->linesize[0];
353  p->data[1] += (avctx->height - 1) * p->linesize[1];
354  p->data[2] += (avctx->height - 1) * p->linesize[2];
355  p->linesize[0] = -p->linesize[0];
356  p->linesize[1] = -p->linesize[1];
357  p->linesize[2] = -p->linesize[2];
358  break;
359  case AV_PIX_FMT_GRAYF32:
360  if (!s->half) {
361  if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
362  return AVERROR_INVALIDDATA;
363  scale = 1.f / s->scale;
364  if (s->endian) {
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_RL32(s->bytestream)) * scale;
369  s->bytestream += 4;
370  }
371  g += p->linesize[0] / 4;
372  }
373  } else {
374  float *g = (float *)p->data[0];
375  for (int i = 0; i < avctx->height; i++) {
376  for (int j = 0; j < avctx->width; j++) {
377  g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
378  s->bytestream += 4;
379  }
380  g += p->linesize[0] / 4;
381  }
382  }
383  } else {
384  if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream)
385  return AVERROR_INVALIDDATA;
386  scale = 1.f / s->scale;
387  if (s->endian) {
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_RL16(s->bytestream), &s->h2f_tables)) * scale;
392  s->bytestream += 2;
393  }
394  g += p->linesize[0] / 4;
395  }
396  } else {
397  float *g = (float *)p->data[0];
398  for (int i = 0; i < avctx->height; i++) {
399  for (int j = 0; j < avctx->width; j++) {
400  g[j] = av_int2float(half2float(AV_RB16(s->bytestream), &s->h2f_tables)) * scale;
401  s->bytestream += 2;
402  }
403  g += p->linesize[0] / 4;
404  }
405  }
406  }
407  /* PFM is encoded from bottom to top */
408  p->data[0] += (avctx->height - 1) * p->linesize[0];
409  p->linesize[0] = -p->linesize[0];
410  break;
411  }
412  *got_frame = 1;
413 
414  return s->bytestream - s->bytestream_start;
415 }
416 
417 
418 #if CONFIG_PGM_DECODER
419 const FFCodec ff_pgm_decoder = {
420  .p.name = "pgm",
421  CODEC_LONG_NAME("PGM (Portable GrayMap) image"),
422  .p.type = AVMEDIA_TYPE_VIDEO,
423  .p.id = AV_CODEC_ID_PGM,
424  .p.capabilities = AV_CODEC_CAP_DR1,
425  .priv_data_size = sizeof(PNMContext),
426  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
428 };
429 #endif
430 
431 #if CONFIG_PGMYUV_DECODER
432 const FFCodec ff_pgmyuv_decoder = {
433  .p.name = "pgmyuv",
434  CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"),
435  .p.type = AVMEDIA_TYPE_VIDEO,
436  .p.id = AV_CODEC_ID_PGMYUV,
437  .p.capabilities = AV_CODEC_CAP_DR1,
438  .priv_data_size = sizeof(PNMContext),
439  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
441 };
442 #endif
443 
444 #if CONFIG_PPM_DECODER
445 const FFCodec ff_ppm_decoder = {
446  .p.name = "ppm",
447  CODEC_LONG_NAME("PPM (Portable PixelMap) image"),
448  .p.type = AVMEDIA_TYPE_VIDEO,
449  .p.id = AV_CODEC_ID_PPM,
450  .p.capabilities = AV_CODEC_CAP_DR1,
451  .priv_data_size = sizeof(PNMContext),
452  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
454 };
455 #endif
456 
457 #if CONFIG_PBM_DECODER
458 const FFCodec ff_pbm_decoder = {
459  .p.name = "pbm",
460  CODEC_LONG_NAME("PBM (Portable BitMap) image"),
461  .p.type = AVMEDIA_TYPE_VIDEO,
462  .p.id = AV_CODEC_ID_PBM,
463  .p.capabilities = AV_CODEC_CAP_DR1,
464  .priv_data_size = sizeof(PNMContext),
465  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
467 };
468 #endif
469 
470 #if CONFIG_PAM_DECODER
471 const FFCodec ff_pam_decoder = {
472  .p.name = "pam",
473  CODEC_LONG_NAME("PAM (Portable AnyMap) image"),
474  .p.type = AVMEDIA_TYPE_VIDEO,
475  .p.id = AV_CODEC_ID_PAM,
476  .p.capabilities = AV_CODEC_CAP_DR1,
477  .priv_data_size = sizeof(PNMContext),
478  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
480 };
481 #endif
482 
483 #if CONFIG_PFM_DECODER
484 const FFCodec ff_pfm_decoder = {
485  .p.name = "pfm",
486  CODEC_LONG_NAME("PFM (Portable FloatMap) image"),
487  .p.type = AVMEDIA_TYPE_VIDEO,
488  .p.id = AV_CODEC_ID_PFM,
489  .p.capabilities = AV_CODEC_CAP_DR1,
490  .priv_data_size = sizeof(PNMContext),
491  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
493 };
494 #endif
495 
496 #if CONFIG_PHM_DECODER
497 static av_cold int phm_dec_init(AVCodecContext *avctx)
498 {
499  PNMContext *s = avctx->priv_data;
500 
501  ff_init_half2float_tables(&s->h2f_tables);
502 
503  return 0;
504 }
505 
506 const FFCodec ff_phm_decoder = {
507  .p.name = "phm",
508  CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"),
509  .p.type = AVMEDIA_TYPE_VIDEO,
510  .p.id = AV_CODEC_ID_PHM,
511  .p.capabilities = AV_CODEC_CAP_DR1,
512  .priv_data_size = sizeof(PNMContext),
513  .init = phm_dec_init,
514  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
516 };
517 #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:427
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:154
AVPacket::data
uint8_t * data
Definition: packet.h:588
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:539
FFCodec
Definition: codec_internal.h:127
intfloat.h
AV_CODEC_ID_PHM
@ AV_CODEC_ID_PHM
Definition: codec_id.h:319
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:1670
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:522
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
av_cold
#define av_cold
Definition: attributes.h:106
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:347
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:1561
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:536
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:550
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:582
PutBitContext
Definition: put_bits.h:50
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:332
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:232
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:529
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:1729
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:550
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:589
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:87
ff_ppm_decoder
const FFCodec ff_ppm_decoder
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:578
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:525
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:524
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCodecContext::height
int height
Definition: avcodec.h:600
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:639
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:439
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
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:153
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:278
ff_pbm_decoder
const FFCodec ff_pbm_decoder
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:466
AVPacket
This structure stores compressed data.
Definition: packet.h:565
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:600
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