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