FFmpeg
dpx.c
Go to the documentation of this file.
1 /*
2  * DPX (.dpx) image decoder
3  * Copyright (c) 2009 Jimmy Christensen
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 "libavutil/avstring.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/intfloat.h"
25 #include "libavutil/imgutils.h"
26 #include "libavutil/timecode.h"
27 #include "avcodec.h"
28 #include "codec_internal.h"
29 #include "decode.h"
30 
31 enum DPX_TRC {
45 };
46 
50  /* 2 = N/A */
51  /* 3 = N/A */
59  /* 11 = N/A */
60  /* 12 = N/A */
61 };
62 
63 static unsigned int read16(const uint8_t **ptr, int is_big)
64 {
65  unsigned int temp;
66  if (is_big) {
67  temp = AV_RB16(*ptr);
68  } else {
69  temp = AV_RL16(*ptr);
70  }
71  *ptr += 2;
72  return temp;
73 }
74 
75 static unsigned int read32(const uint8_t **ptr, int is_big)
76 {
77  unsigned int temp;
78  if (is_big) {
79  temp = AV_RB32(*ptr);
80  } else {
81  temp = AV_RL32(*ptr);
82  }
83  *ptr += 4;
84  return temp;
85 }
86 
87 static uint16_t read10in32_gray(const uint8_t **ptr, uint32_t *lbuf,
88  int *n_datum, int is_big, int shift)
89 {
90  uint16_t temp;
91 
92  if (*n_datum)
93  (*n_datum)--;
94  else {
95  *lbuf = read32(ptr, is_big);
96  *n_datum = 2;
97  }
98 
99  temp = *lbuf >> shift & 0x3FF;
100  *lbuf = *lbuf >> 10;
101 
102  return temp;
103 }
104 
105 static uint16_t read10in32(const uint8_t **ptr, uint32_t *lbuf,
106  int *n_datum, int is_big, int shift)
107 {
108  if (*n_datum)
109  (*n_datum)--;
110  else {
111  *lbuf = read32(ptr, is_big);
112  *n_datum = 2;
113  }
114 
115  *lbuf = *lbuf << 10 | *lbuf >> shift & 0x3FFFFF;
116 
117  return *lbuf & 0x3FF;
118 }
119 
120 static uint16_t read12in32(const uint8_t **ptr, uint32_t *lbuf,
121  int *n_datum, int is_big)
122 {
123  if (*n_datum)
124  (*n_datum)--;
125  else {
126  *lbuf = read32(ptr, is_big);
127  *n_datum = 7;
128  }
129 
130  switch (*n_datum){
131  case 7: return *lbuf & 0xFFF;
132  case 6: return (*lbuf >> 12) & 0xFFF;
133  case 5: {
134  uint32_t c = *lbuf >> 24;
135  *lbuf = read32(ptr, is_big);
136  c |= *lbuf << 8;
137  return c & 0xFFF;
138  }
139  case 4: return (*lbuf >> 4) & 0xFFF;
140  case 3: return (*lbuf >> 16) & 0xFFF;
141  case 2: {
142  uint32_t c = *lbuf >> 28;
143  *lbuf = read32(ptr, is_big);
144  c |= *lbuf << 4;
145  return c & 0xFFF;
146  }
147  case 1: return (*lbuf >> 8) & 0xFFF;
148  default: return *lbuf >> 20;
149  }
150 }
151 
152 static int decode_frame(AVCodecContext *avctx, AVFrame *p,
153  int *got_frame, AVPacket *avpkt)
154 {
155  const uint8_t *buf = avpkt->data;
156  int buf_size = avpkt->size;
157  uint8_t *ptr[AV_NUM_DATA_POINTERS];
158  uint32_t header_version, version = 0;
159  char creator[101] = { 0 };
160  char input_device[33] = { 0 };
161 
162  unsigned int offset;
163  int magic_num, endian;
164  int x, y, stride, i, j, ret;
165  int w, h, bits_per_color, descriptor, elements, packing;
166  int yuv, color_trc, color_spec;
167  int encoding, need_align = 0, unpadded_10bit = 0;
168 
169  unsigned int rgbBuffer = 0;
170  int n_datum = 0;
171 
172  if (avpkt->size <= 1634) {
173  av_log(avctx, AV_LOG_ERROR, "Packet too small for DPX header\n");
174  return AVERROR_INVALIDDATA;
175  }
176 
177  magic_num = AV_RB32(buf);
178  buf += 4;
179 
180  /* Check if the files "magic number" is "SDPX" which means it uses
181  * big-endian or XPDS which is for little-endian files */
182  if (magic_num == AV_RL32("SDPX")) {
183  endian = 0;
184  } else if (magic_num == AV_RB32("SDPX")) {
185  endian = 1;
186  } else {
187  av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n");
188  return AVERROR_INVALIDDATA;
189  }
190 
191  offset = read32(&buf, endian);
192  if (avpkt->size <= offset) {
193  av_log(avctx, AV_LOG_ERROR, "Invalid data start offset\n");
194  return AVERROR_INVALIDDATA;
195  }
196 
197  header_version = read32(&buf, 0);
198  if (header_version == MKTAG('V','1','.','0'))
199  version = 1;
200  if (header_version == MKTAG('V','2','.','0'))
201  version = 2;
202  if (!version)
203  av_log(avctx, AV_LOG_WARNING, "Unknown header format version %s.\n",
204  av_fourcc2str(header_version));
205 
206  // Check encryption
207  buf = avpkt->data + 660;
208  ret = read32(&buf, endian);
209  if (ret != 0xFFFFFFFF) {
210  avpriv_report_missing_feature(avctx, "Encryption");
211  av_log(avctx, AV_LOG_WARNING, "The image is encrypted and may "
212  "not properly decode.\n");
213  }
214 
215  // Need to end in 0x304 offset from start of file
216  buf = avpkt->data + 0x304;
217  w = read32(&buf, endian);
218  h = read32(&buf, endian);
219 
220  if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
221  return ret;
222 
223  // Need to end in 0x320 to read the descriptor
224  buf += 20;
225  descriptor = buf[0];
226  color_trc = buf[1];
227  color_spec = buf[2];
228 
229  // Need to end in 0x323 to read the bits per color
230  buf += 3;
231  avctx->bits_per_raw_sample =
232  bits_per_color = buf[0];
233  buf++;
234  packing = read16(&buf, endian);
235  encoding = read16(&buf, endian);
236 
237  if (encoding) {
238  avpriv_report_missing_feature(avctx, "Encoding %d", encoding);
239  return AVERROR_PATCHWELCOME;
240  }
241 
242  if (bits_per_color > 31)
243  return AVERROR_INVALIDDATA;
244 
245  buf += 820;
246  avctx->sample_aspect_ratio.num = read32(&buf, endian);
247  avctx->sample_aspect_ratio.den = read32(&buf, endian);
248  if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0)
251  0x10000);
252  else
253  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
254 
255  /* preferred frame rate from Motion-picture film header */
256  if (offset >= 1724 + 4) {
257  buf = avpkt->data + 1724;
258  i = read32(&buf, endian);
259  if(i && i != 0xFFFFFFFF) {
260  AVRational q = av_d2q(av_int2float(i), 4096);
261  if (q.num > 0 && q.den > 0)
262  avctx->framerate = q;
263  }
264  }
265 
266  /* alternative frame rate from television header */
267  if (offset >= 1940 + 4 &&
268  !(avctx->framerate.num && avctx->framerate.den)) {
269  buf = avpkt->data + 1940;
270  i = read32(&buf, endian);
271  if(i && i != 0xFFFFFFFF) {
272  AVRational q = av_d2q(av_int2float(i), 4096);
273  if (q.num > 0 && q.den > 0)
274  avctx->framerate = q;
275  }
276  }
277 
278  /* SMPTE TC from television header */
279  if (offset >= 1920 + 4) {
280  uint32_t tc;
281  uint32_t *tc_sd;
282  char tcbuf[AV_TIMECODE_STR_SIZE];
283 
284  buf = avpkt->data + 1920;
285  // read32 to native endian, av_bswap32 to opposite of native for
286  // compatibility with av_timecode_make_smpte_tc_string2 etc
287  tc = av_bswap32(read32(&buf, endian));
288 
289  if (i != 0xFFFFFFFF) {
290  AVFrameSideData *tcside =
292  sizeof(uint32_t) * 4);
293  if (!tcside)
294  return AVERROR(ENOMEM);
295 
296  tc_sd = (uint32_t*)tcside->data;
297  tc_sd[0] = 1;
298  tc_sd[1] = tc;
299 
301  tc_sd[1], 0, 0);
302  av_dict_set(&p->metadata, "timecode", tcbuf, 0);
303  }
304  }
305 
306  /* color range from television header */
307  if (offset >= 1964 + 4) {
308  buf = avpkt->data + 1952;
309  i = read32(&buf, endian);
310 
311  buf = avpkt->data + 1964;
312  j = read32(&buf, endian);
313 
314  if (i != 0xFFFFFFFF && j != 0xFFFFFFFF) {
315  float minCV, maxCV;
316  minCV = av_int2float(i);
317  maxCV = av_int2float(j);
318  if (bits_per_color >= 1 &&
319  minCV == 0.0f && maxCV == ((1U<<bits_per_color) - 1)) {
320  avctx->color_range = AVCOL_RANGE_JPEG;
321  } else if (bits_per_color >= 8 &&
322  minCV == (1 <<(bits_per_color - 4)) &&
323  maxCV == (235<<(bits_per_color - 8))) {
324  avctx->color_range = AVCOL_RANGE_MPEG;
325  }
326  }
327  }
328 
329  switch (descriptor) {
330  case 1: // R
331  case 2: // G
332  case 3: // B
333  case 4: // A
334  case 6: // Y
335  elements = 1;
336  yuv = 1;
337  break;
338  case 50: // RGB
339  elements = 3;
340  yuv = 0;
341  break;
342  case 52: // ABGR
343  case 51: // RGBA
344  elements = 4;
345  yuv = 0;
346  break;
347  case 100: // UYVY422
348  elements = 2;
349  yuv = 1;
350  break;
351  case 102: // UYV444
352  elements = 3;
353  yuv = 1;
354  break;
355  case 103: // UYVA4444
356  elements = 4;
357  yuv = 1;
358  break;
359  default:
360  avpriv_report_missing_feature(avctx, "Descriptor %d", descriptor);
361  return AVERROR_PATCHWELCOME;
362  }
363 
364  switch (bits_per_color) {
365  case 8:
366  stride = avctx->width * elements;
367  break;
368  case 10:
369  if (!packing) {
370  av_log(avctx, AV_LOG_ERROR, "Packing to 32bit required\n");
371  return -1;
372  }
373  stride = (avctx->width * elements + 2) / 3 * 4;
374  break;
375  case 12:
376  stride = avctx->width * elements;
377  if (packing) {
378  stride *= 2;
379  } else {
380  stride *= 3;
381  if (stride % 8) {
382  stride /= 8;
383  stride++;
384  stride *= 8;
385  }
386  stride /= 2;
387  }
388  break;
389  case 16:
390  stride = 2 * avctx->width * elements;
391  break;
392  case 32:
393  stride = 4 * avctx->width * elements;
394  break;
395  case 1:
396  case 64:
397  avpriv_report_missing_feature(avctx, "Depth %d", bits_per_color);
398  return AVERROR_PATCHWELCOME;
399  default:
400  return AVERROR_INVALIDDATA;
401  }
402 
403  switch (color_trc) {
404  case DPX_TRC_LINEAR:
405  avctx->color_trc = AVCOL_TRC_LINEAR;
406  break;
407  case DPX_TRC_SMPTE_274:
408  case DPX_TRC_ITU_R_709_4:
409  avctx->color_trc = AVCOL_TRC_BT709;
410  break;
413  case DPX_TRC_SMPTE_170:
415  break;
417  avctx->color_trc = AVCOL_TRC_GAMMA28;
418  break;
421  /* Nothing to do */
422  break;
423  default:
424  av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX transfer characteristic "
425  "%d to color_trc.\n", color_trc);
426  break;
427  }
428 
429  switch (color_spec) {
433  break;
437  break;
441  break;
444  /* Nothing to do */
445  break;
446  default:
447  av_log(avctx, AV_LOG_VERBOSE, "Cannot map DPX color specification "
448  "%d to color_primaries.\n", color_spec);
449  break;
450  }
451 
452  if (yuv) {
453  switch (color_spec) {
456  avctx->colorspace = AVCOL_SPC_BT709;
457  break;
460  avctx->colorspace = AVCOL_SPC_BT470BG;
461  break;
465  break;
468  /* Nothing to do */
469  break;
470  default:
471  av_log(avctx, AV_LOG_INFO, "Cannot map DPX color specification "
472  "%d to colorspace.\n", color_spec);
473  break;
474  }
475  } else {
476  avctx->colorspace = AVCOL_SPC_RGB;
477  }
478 
479  av_strlcpy(creator, avpkt->data + 160, 100);
480  creator[100] = '\0';
481  av_dict_set(&p->metadata, "Creator", creator, 0);
482 
483  av_strlcpy(input_device, avpkt->data + 1556, 32);
484  input_device[32] = '\0';
485  av_dict_set(&p->metadata, "Input Device", input_device, 0);
486 
487  // Some devices do not pad 10bit samples to whole 32bit words per row
488  if (!memcmp(input_device, "Scanity", 7) ||
489  !memcmp(creator, "Lasergraphics Inc.", 18)) {
490  if (bits_per_color == 10)
491  unpadded_10bit = 1;
492  }
493 
494  // Table 3c: Runs will always break at scan line boundaries. Packing
495  // will always break to the next 32-bit word at scan-line boundaries.
496  // Unfortunately, the encoder produced invalid files, so attempt
497  // to detect it
498  // Also handle special case with unpadded content
499  need_align = FFALIGN(stride, 4);
500  if (need_align*avctx->height + (int64_t)offset > avpkt->size &&
501  (!unpadded_10bit || (avctx->width * avctx->height * elements + 2) / 3 * 4 + (int64_t)offset > avpkt->size)) {
502  // Alignment seems unappliable, try without
503  if (stride*avctx->height + (int64_t)offset > avpkt->size || unpadded_10bit) {
504  av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n");
505  return AVERROR_INVALIDDATA;
506  } else {
507  av_log(avctx, AV_LOG_INFO, "Decoding DPX without scanline "
508  "alignment.\n");
509  need_align = 0;
510  }
511  } else {
512  need_align -= stride;
513  stride = FFALIGN(stride, 4);
514  }
515 
516  switch (1000 * descriptor + 10 * bits_per_color + endian) {
517  case 1081:
518  case 1080:
519  case 2081:
520  case 2080:
521  case 3081:
522  case 3080:
523  case 4081:
524  case 4080:
525  case 6081:
526  case 6080:
527  avctx->pix_fmt = AV_PIX_FMT_GRAY8;
528  break;
529  case 6121:
530  case 6120:
531  avctx->pix_fmt = AV_PIX_FMT_GRAY12;
532  break;
533  case 1320:
534  case 2320:
535  case 3320:
536  case 4320:
537  case 6320:
538  avctx->pix_fmt = AV_PIX_FMT_GRAYF32LE;
539  break;
540  case 1321:
541  case 2321:
542  case 3321:
543  case 4321:
544  case 6321:
545  avctx->pix_fmt = AV_PIX_FMT_GRAYF32BE;
546  break;
547  case 50081:
548  case 50080:
549  avctx->pix_fmt = AV_PIX_FMT_RGB24;
550  break;
551  case 52081:
552  case 52080:
553  avctx->pix_fmt = AV_PIX_FMT_ABGR;
554  break;
555  case 51081:
556  case 51080:
557  avctx->pix_fmt = AV_PIX_FMT_RGBA;
558  break;
559  case 50100:
560  case 50101:
561  avctx->pix_fmt = AV_PIX_FMT_GBRP10;
562  break;
563  case 51100:
564  case 51101:
565  avctx->pix_fmt = AV_PIX_FMT_GBRAP10;
566  break;
567  case 50120:
568  case 50121:
569  avctx->pix_fmt = AV_PIX_FMT_GBRP12;
570  break;
571  case 51120:
572  case 51121:
573  avctx->pix_fmt = AV_PIX_FMT_GBRAP12;
574  break;
575  case 6100:
576  case 6101:
577  avctx->pix_fmt = AV_PIX_FMT_GRAY10;
578  break;
579  case 6161:
580  avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
581  break;
582  case 6160:
583  avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
584  break;
585  case 50161:
586  avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
587  break;
588  case 50160:
589  avctx->pix_fmt = AV_PIX_FMT_RGB48LE;
590  break;
591  case 51161:
592  avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
593  break;
594  case 51160:
595  avctx->pix_fmt = AV_PIX_FMT_RGBA64LE;
596  break;
597  case 50320:
598  avctx->pix_fmt = AV_PIX_FMT_GBRPF32LE;
599  break;
600  case 50321:
601  avctx->pix_fmt = AV_PIX_FMT_GBRPF32BE;
602  break;
603  case 51320:
605  break;
606  case 51321:
608  break;
609  case 100081:
610  avctx->pix_fmt = AV_PIX_FMT_UYVY422;
611  break;
612  case 102081:
613  avctx->pix_fmt = AV_PIX_FMT_YUV444P;
614  break;
615  case 103081:
616  avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
617  break;
618  default:
619  av_log(avctx, AV_LOG_ERROR, "Unsupported format %d\n",
620  1000 * descriptor + 10 * bits_per_color + endian);
621  return AVERROR_PATCHWELCOME;
622  }
623 
624  ff_set_sar(avctx, avctx->sample_aspect_ratio);
625 
626  if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
627  return ret;
628 
629  // Move pointer to offset from start of file
630  buf = avpkt->data + offset;
631 
632  for (i=0; i<AV_NUM_DATA_POINTERS; i++)
633  ptr[i] = p->data[i];
634 
635  switch (bits_per_color) {
636  case 10:
637  for (x = 0; x < avctx->height; x++) {
638  uint16_t *dst[4] = {(uint16_t*)ptr[0],
639  (uint16_t*)ptr[1],
640  (uint16_t*)ptr[2],
641  (uint16_t*)ptr[3]};
642  int shift = elements > 1 ? packing == 1 ? 22 : 20 : packing == 1 ? 2 : 0;
643  for (y = 0; y < avctx->width; y++) {
644  if (elements >= 3)
645  *dst[2]++ = read10in32(&buf, &rgbBuffer,
646  &n_datum, endian, shift);
647  if (elements == 1)
648  *dst[0]++ = read10in32_gray(&buf, &rgbBuffer,
649  &n_datum, endian, shift);
650  else
651  *dst[0]++ = read10in32(&buf, &rgbBuffer,
652  &n_datum, endian, shift);
653  if (elements >= 2)
654  *dst[1]++ = read10in32(&buf, &rgbBuffer,
655  &n_datum, endian, shift);
656  if (elements == 4)
657  *dst[3]++ =
658  read10in32(&buf, &rgbBuffer,
659  &n_datum, endian, shift);
660  }
661  if (!unpadded_10bit)
662  n_datum = 0;
663  for (i = 0; i < elements; i++)
664  ptr[i] += p->linesize[i];
665  }
666  break;
667  case 12:
668  for (x = 0; x < avctx->height; x++) {
669  uint16_t *dst[4] = {(uint16_t*)ptr[0],
670  (uint16_t*)ptr[1],
671  (uint16_t*)ptr[2],
672  (uint16_t*)ptr[3]};
673  int shift = packing == 1 ? 4 : 0;
674  for (y = 0; y < avctx->width; y++) {
675  if (packing) {
676  if (elements >= 3)
677  *dst[2]++ = read16(&buf, endian) >> shift & 0xFFF;
678  *dst[0]++ = read16(&buf, endian) >> shift & 0xFFF;
679  if (elements >= 2)
680  *dst[1]++ = read16(&buf, endian) >> shift & 0xFFF;
681  if (elements == 4)
682  *dst[3]++ = read16(&buf, endian) >> shift & 0xFFF;
683  } else {
684  if (elements >= 3)
685  *dst[2]++ = read12in32(&buf, &rgbBuffer,
686  &n_datum, endian);
687  *dst[0]++ = read12in32(&buf, &rgbBuffer,
688  &n_datum, endian);
689  if (elements >= 2)
690  *dst[1]++ = read12in32(&buf, &rgbBuffer,
691  &n_datum, endian);
692  if (elements == 4)
693  *dst[3]++ = read12in32(&buf, &rgbBuffer,
694  &n_datum, endian);
695  }
696  }
697  n_datum = 0;
698  for (i = 0; i < elements; i++)
699  ptr[i] += p->linesize[i];
700  // Jump to next aligned position
701  buf += need_align;
702  }
703  break;
704  case 32:
705  if (elements == 1) {
706  av_image_copy_plane(ptr[0], p->linesize[0],
707  buf, stride,
708  elements * avctx->width * 4, avctx->height);
709  } else {
710  for (y = 0; y < avctx->height; y++) {
711  ptr[0] = p->data[0] + y * p->linesize[0];
712  ptr[1] = p->data[1] + y * p->linesize[1];
713  ptr[2] = p->data[2] + y * p->linesize[2];
714  ptr[3] = p->data[3] + y * p->linesize[3];
715  for (x = 0; x < avctx->width; x++) {
716  AV_WN32(ptr[2], AV_RN32(buf));
717  AV_WN32(ptr[0], AV_RN32(buf + 4));
718  AV_WN32(ptr[1], AV_RN32(buf + 8));
719  if (avctx->pix_fmt == AV_PIX_FMT_GBRAPF32BE ||
720  avctx->pix_fmt == AV_PIX_FMT_GBRAPF32LE) {
721  AV_WN32(ptr[3], AV_RN32(buf + 12));
722  buf += 4;
723  ptr[3] += 4;
724  }
725 
726  buf += 12;
727  ptr[2] += 4;
728  ptr[0] += 4;
729  ptr[1] += 4;
730  }
731  }
732  }
733  break;
734  case 16:
735  elements *= 2;
736  case 8:
737  if ( avctx->pix_fmt == AV_PIX_FMT_YUVA444P
738  || avctx->pix_fmt == AV_PIX_FMT_YUV444P) {
739  for (x = 0; x < avctx->height; x++) {
740  ptr[0] = p->data[0] + x * p->linesize[0];
741  ptr[1] = p->data[1] + x * p->linesize[1];
742  ptr[2] = p->data[2] + x * p->linesize[2];
743  ptr[3] = p->data[3] + x * p->linesize[3];
744  for (y = 0; y < avctx->width; y++) {
745  *ptr[1]++ = *buf++;
746  *ptr[0]++ = *buf++;
747  *ptr[2]++ = *buf++;
748  if (avctx->pix_fmt == AV_PIX_FMT_YUVA444P)
749  *ptr[3]++ = *buf++;
750  }
751  }
752  } else {
753  av_image_copy_plane(ptr[0], p->linesize[0],
754  buf, stride,
755  elements * avctx->width, avctx->height);
756  }
757  break;
758  }
759 
760  *got_frame = 1;
761 
762  return buf_size;
763 }
764 
766  .p.name = "dpx",
767  CODEC_LONG_NAME("DPX (Digital Picture Exchange) image"),
768  .p.type = AVMEDIA_TYPE_VIDEO,
769  .p.id = AV_CODEC_ID_DPX,
771  .p.capabilities = AV_CODEC_CAP_DR1,
772 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AV_TIMECODE_STR_SIZE
#define AV_TIMECODE_STR_SIZE
Definition: timecode.h:33
AV_CODEC_ID_DPX
@ AV_CODEC_ID_DPX
Definition: codec_id.h:180
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
DPX_COL_SPEC_ITU_R_709_4
@ DPX_COL_SPEC_ITU_R_709_4
Definition: dpx.c:54
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1033
elements
static const ElemCat * elements[ELEMENT_COUNT]
Definition: signature.h:566
av_frame_new_side_data
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition: frame.c:812
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Definition: dpx.c:152
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:593
AV_FRAME_DATA_S12M_TIMECODE
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:152
DPX_COL_SPEC_USER_DEFINED
@ DPX_COL_SPEC_USER_DEFINED
Definition: dpx.c:48
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
AV_PIX_FMT_RGBA64BE
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:202
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1026
AV_PIX_FMT_GBRAPF32LE
@ AV_PIX_FMT_GBRAPF32LE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian.
Definition: pixfmt.h:348
read10in32_gray
static uint16_t read10in32_gray(const uint8_t **ptr, uint32_t *lbuf, int *n_datum, int is_big, int shift)
Definition: dpx.c:87
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:687
AV_PIX_FMT_GBRPF32BE
@ AV_PIX_FMT_GBRPF32BE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian.
Definition: pixfmt.h:345
AVPacket::data
uint8_t * data
Definition: packet.h:522
DPX_TRC_Z_LINEAR
@ DPX_TRC_Z_LINEAR
Definition: dpx.c:43
FFCodec
Definition: codec_internal.h:127
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:614
DPX_TRC
DPX_TRC
Definition: dpx.c:31
intfloat.h
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:94
AV_PIX_FMT_GRAYF32LE
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
Definition: pixfmt.h:368
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1807
DPX_TRC_SMPTE_274
@ DPX_TRC_SMPTE_274
Definition: dpx.c:37
AV_PIX_FMT_GRAY16BE
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
Definition: pixfmt.h:104
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:619
DPX_TRC_ITU_R_601_625
@ DPX_TRC_ITU_R_601_625
Definition: dpx.c:39
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
av_int2float
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
Definition: intfloat.h:40
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:498
timecode.h
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:590
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
AVRational::num
int num
Numerator.
Definition: rational.h:59
DPX_TRC_ITU_R_709_4
@ DPX_TRC_ITU_R_709_4
Definition: dpx.c:38
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:1019
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:502
DPX_TRC_SMPTE_170
@ DPX_TRC_SMPTE_170
Definition: dpx.c:41
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
intreadwrite.h
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:503
DPX_TRC_Z_HOMOGENEOUS
@ DPX_TRC_Z_HOMOGENEOUS
Definition: dpx.c:44
DPX_TRC_PRINTING_DENSITY
@ DPX_TRC_PRINTING_DENSITY
Definition: dpx.c:33
DPX_COL_SPEC_SMPTE_170
@ DPX_COL_SPEC_SMPTE_170
Definition: dpx.c:57
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:620
DPX_TRC_LOGARITHMIC
@ DPX_TRC_LOGARITHMIC
Definition: dpx.c:35
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1521
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
DPX_COL_SPEC_SMPTE_274
@ DPX_COL_SPEC_SMPTE_274
Definition: dpx.c:53
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
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:566
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:567
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:463
AV_PIX_FMT_GBRAPF32BE
@ AV_PIX_FMT_GBRAPF32BE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian.
Definition: pixfmt.h:347
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1043
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_PIX_FMT_RGB48LE
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:110
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:561
AV_PIX_FMT_RGBA64LE
@ AV_PIX_FMT_RGBA64LE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:203
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:362
ff_set_sar
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
Definition: utils.c:109
ff_dpx_decoder
const FFCodec ff_dpx_decoder
Definition: dpx.c:765
DPX_COL_SPEC_PRINTING_DENSITY
@ DPX_COL_SPEC_PRINTING_DENSITY
Definition: dpx.c:49
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
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
read12in32
static uint16_t read12in32(const uint8_t **ptr, uint32_t *lbuf, int *n_datum, int is_big)
Definition: dpx.c:120
DPX_TRC_ITU_R_624_4_PAL
@ DPX_TRC_ITU_R_624_4_PAL
Definition: dpx.c:42
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:1618
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
codec_internal.h
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:374
shift
static int shift(int a, int b)
Definition: bonk.c:262
av_bswap32
#define av_bswap32
Definition: bswap.h:28
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:341
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
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
AVFrameSideData::data
uint8_t * data
Definition: frame.h:248
DPX_COL_SPEC_ITU_R_601_625
@ DPX_COL_SPEC_ITU_R_601_625
Definition: dpx.c:55
DPX_TRC_UNSPECIFIED_VIDEO
@ DPX_TRC_UNSPECIFIED_VIDEO
Definition: dpx.c:36
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
version
version
Definition: libkvazaar.c:321
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:586
DPX_COL_SPEC_UNSPECIFIED_VIDEO
@ DPX_COL_SPEC_UNSPECIFIED_VIDEO
Definition: dpx.c:52
read16
static unsigned int read16(const uint8_t **ptr, int is_big)
Definition: dpx.c:63
AV_PIX_FMT_RGB48BE
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:109
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
av_timecode_make_smpte_tc_string2
char * av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Get the timecode string from the SMPTE timecode format.
Definition: timecode.c:138
read10in32
static uint16_t read10in32(const uint8_t **ptr, uint32_t *lbuf, int *n_datum, int is_big, int shift)
Definition: dpx.c:105
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:499
av_d2q
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition: rational.c:106
DPX_TRC_LINEAR
@ DPX_TRC_LINEAR
Definition: dpx.c:34
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::height
int height
Definition: avcodec.h:625
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:662
AV_PIX_FMT_GBRPF32LE
@ AV_PIX_FMT_GBRPF32LE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian.
Definition: pixfmt.h:346
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:670
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
DPX_COL_SPEC_ITU_R_624_4_PAL
@ DPX_COL_SPEC_ITU_R_624_4_PAL
Definition: dpx.c:58
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_GRAYF32BE
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:367
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:445
AVRational::den
int den
Denominator.
Definition: rational.h:60
AVFrame::metadata
AVDictionary * metadata
metadata.
Definition: frame.h:708
temp
else temp
Definition: vf_mcdeint.c:263
AVCOL_TRC_SMPTE170M
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition: pixfmt.h:591
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
tc
#define tc
Definition: regdef.h:69
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_GRAY16LE
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
Definition: pixfmt.h:105
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:246
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:88
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:625
imgutils.h
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:385
av_strlcpy
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:85
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
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
h
h
Definition: vp9dsp_template.c:2038
read32
static unsigned int read32(const uint8_t **ptr, int is_big)
Definition: dpx.c:75
avstring.h
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:464
DPX_COL_SPEC
DPX_COL_SPEC
Definition: dpx.c:47
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:615
AVCodecContext::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
Definition: avcodec.h:826
DPX_TRC_USER_DEFINED
@ DPX_TRC_USER_DEFINED
Definition: dpx.c:32
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
DPX_TRC_ITU_R_601_525
@ DPX_TRC_ITU_R_601_525
Definition: dpx.c:40
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:358
DPX_COL_SPEC_ITU_R_601_525
@ DPX_COL_SPEC_ITU_R_601_525
Definition: dpx.c:56