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;
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, FFABS(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 * 12LL > 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  /* PFM is encoded from bottom to top */
350  p->data[0] += (avctx->height - 1) * p->linesize[0];
351  p->data[1] += (avctx->height - 1) * p->linesize[1];
352  p->data[2] += (avctx->height - 1) * p->linesize[2];
353  p->linesize[0] = -p->linesize[0];
354  p->linesize[1] = -p->linesize[1];
355  p->linesize[2] = -p->linesize[2];
356  break;
357  case AV_PIX_FMT_GRAYF32:
358  if (!s->half) {
359  if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
360  return AVERROR_INVALIDDATA;
361  scale = 1.f / s->scale;
362  if (s->endian) {
363  float *g = (float *)p->data[0];
364  for (int i = 0; i < avctx->height; i++) {
365  for (int j = 0; j < avctx->width; j++) {
366  g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
367  s->bytestream += 4;
368  }
369  g += p->linesize[0] / 4;
370  }
371  } else {
372  float *g = (float *)p->data[0];
373  for (int i = 0; i < avctx->height; i++) {
374  for (int j = 0; j < avctx->width; j++) {
375  g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
376  s->bytestream += 4;
377  }
378  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  p->data[0] += (avctx->height - 1) * p->linesize[0];
407  p->linesize[0] = -p->linesize[0];
408  break;
409  }
410  *got_frame = 1;
411 
412  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,
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,
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,
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,
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,
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,
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,
514 };
515 #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:303
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:222
AVPacket::data
uint8_t * data
Definition: packet.h:522
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:82
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
FFCodec
Definition: codec_internal.h:127
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:616
AV_CODEC_ID_PHM
@ AV_CODEC_ID_PHM
Definition: codec_id.h:315
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
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:1819
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:462
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
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:595
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
s
#define s(width, name)
Definition: cbs_vp9.c:198
g
const char * g
Definition: vf_curves.c:127
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1574
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:475
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
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:511
PutBitContext
Definition: put_bits.h:50
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
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:72
if
if(ret)
Definition: filter_design.txt:179
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
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:468
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
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
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: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:121
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:446
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1569
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
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:523
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: vvc_intra.c:291
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:508
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:464
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:463
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::height
int height
Definition: avcodec.h:618
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:657
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:445
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:472
AVPacket
This structure stores compressed data.
Definition: packet.h:499
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
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:389
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