FFmpeg
psd.c
Go to the documentation of this file.
1 /*
2  * Photoshop (PSD) image decoder
3  * Copyright (c) 2016 Jokyo Images
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/mem.h"
23 #include "bytestream.h"
24 #include "codec_internal.h"
25 #include "decode.h"
26 
27 enum PsdCompr {
32 };
33 
43 };
44 
45 typedef struct PSDContext {
46  AVClass *class;
50 
51  uint8_t * tmp;
52 
53  uint16_t channel_count;
54  uint16_t channel_depth;
55  uint16_t primary_channels;
56 
58  unsigned int pixel_size;/* 1 for 8 bits, 2 for 16 bits */
59  uint64_t line_size;/* length of src data (even width) */
60 
61  int width;
62  int height;
63 
64  int16_t layer_count;
65 
68 
70 } PSDContext;
71 
72 static int decode_header(PSDContext * s)
73 {
74  int signature, version, color_mode;
75  int64_t len_section;
76  int ret = 0;
77 
78  if (bytestream2_get_bytes_left(&s->gb) < 30) {/* File header section + color map data section length */
79  av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
80  return AVERROR_INVALIDDATA;
81  }
82 
83  signature = bytestream2_get_le32(&s->gb);
84  if (signature != MKTAG('8','B','P','S')) {
85  av_log(s->avctx, AV_LOG_ERROR, "Wrong signature %d.\n", signature);
86  return AVERROR_INVALIDDATA;
87  }
88 
89  version = bytestream2_get_be16(&s->gb);
90  if (version != 1) {
91  av_log(s->avctx, AV_LOG_ERROR, "Wrong version %d.\n", version);
92  return AVERROR_INVALIDDATA;
93  }
94 
95  bytestream2_skip(&s->gb, 6);/* reserved */
96 
97  s->channel_count = bytestream2_get_be16(&s->gb);
98  if ((s->channel_count < 1) || (s->channel_count > 56)) {
99  av_log(s->avctx, AV_LOG_ERROR, "Invalid channel count %d.\n", s->channel_count);
100  return AVERROR_INVALIDDATA;
101  }
102 
103  s->height = bytestream2_get_be32(&s->gb);
104 
105  if ((s->height > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
106  av_log(s->avctx, AV_LOG_ERROR,
107  "Height > 30000 is experimental, add "
108  "'-strict %d' if you want to try to decode the picture.\n",
110  return AVERROR_EXPERIMENTAL;
111  }
112 
113  s->width = bytestream2_get_be32(&s->gb);
114  if ((s->width > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
115  av_log(s->avctx, AV_LOG_ERROR,
116  "Width > 30000 is experimental, add "
117  "'-strict %d' if you want to try to decode the picture.\n",
119  return AVERROR_EXPERIMENTAL;
120  }
121 
122  if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
123  return ret;
124 
125  s->channel_depth = bytestream2_get_be16(&s->gb);
126 
127  color_mode = bytestream2_get_be16(&s->gb);
128  switch (color_mode) {
129  case 0:
130  s->color_mode = PSD_BITMAP;
131  break;
132  case 1:
133  s->color_mode = PSD_GRAYSCALE;
134  break;
135  case 2:
136  s->color_mode = PSD_INDEXED;
137  break;
138  case 3:
139  s->color_mode = PSD_RGB;
140  break;
141  case 4:
142  s->color_mode = PSD_CMYK;
143  break;
144  case 7:
145  s->color_mode = PSD_MULTICHANNEL;
146  break;
147  case 8:
148  s->color_mode = PSD_DUOTONE;
149  break;
150  case 9:
151  s->color_mode = PSD_LAB;
152  break;
153  default:
154  av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n", color_mode);
155  return AVERROR_INVALIDDATA;
156  }
157 
158  /* color map data */
159  len_section = bytestream2_get_be32(&s->gb);
160  if (len_section < 0) {
161  av_log(s->avctx, AV_LOG_ERROR, "Negative size for color map data section.\n");
162  return AVERROR_INVALIDDATA;
163  }
164 
165  if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) { /* section and len next section */
166  av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
167  return AVERROR_INVALIDDATA;
168  }
169  if (len_section) {
170  int i,j;
171  memset(s->palette, 0xff, AVPALETTE_SIZE);
172  for (j = HAVE_BIGENDIAN; j < 3 + HAVE_BIGENDIAN; j++)
173  for (i = 0; i < FFMIN(256, len_section / 3); i++)
174  s->palette[i * 4 + (HAVE_BIGENDIAN ? j : 2 - j)] = bytestream2_get_byteu(&s->gb);
175  len_section -= i * 3;
176  }
177  bytestream2_skip(&s->gb, len_section);
178 
179  /* image resources */
180  len_section = bytestream2_get_be32(&s->gb);
181  if (len_section < 0) {
182  av_log(s->avctx, AV_LOG_ERROR, "Negative size for image resources section.\n");
183  return AVERROR_INVALIDDATA;
184  }
185 
186  if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) { /* section and len next section */
187  av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
188  return AVERROR_INVALIDDATA;
189  }
190  bytestream2_skip(&s->gb, len_section);
191 
192  /* layers and masks */
193  len_section = bytestream2_get_be32(&s->gb);
194  if (len_section < 0) {
195  av_log(s->avctx, AV_LOG_ERROR, "Negative size for layers and masks data section.\n");
196  return AVERROR_INVALIDDATA;
197  }
198 
199  if (len_section >= 6) {
200  /* layer count (in layers and masks section) */
201  bytestream2_skip(&s->gb, 4);
202  s->layer_count = bytestream2_get_be16(&s->gb);
203  len_section -= 6;
204  }
205 
206  if (bytestream2_get_bytes_left(&s->gb) < len_section) {
207  av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
208  return AVERROR_INVALIDDATA;
209  }
210  bytestream2_skip(&s->gb, len_section);
211 
212  /* image section */
213  if (bytestream2_get_bytes_left(&s->gb) < 2) {
214  av_log(s->avctx, AV_LOG_ERROR, "File without image data section.\n");
215  return AVERROR_INVALIDDATA;
216  }
217 
218  s->compression = bytestream2_get_be16(&s->gb);
219  switch (s->compression) {
220  case 0:
221  case 1:
222  break;
223  case 2:
224  avpriv_request_sample(s->avctx, "ZIP without predictor compression");
225  return AVERROR_PATCHWELCOME;
226  case 3:
227  avpriv_request_sample(s->avctx, "ZIP with predictor compression");
228  return AVERROR_PATCHWELCOME;
229  default:
230  av_log(s->avctx, AV_LOG_ERROR, "Unknown compression %d.\n", s->compression);
231  return AVERROR_INVALIDDATA;
232  }
233 
234  return ret;
235 }
236 
237 static int decode_rle(PSDContext * s){
238  unsigned int scanline_count;
239  unsigned int sl, count;
240  unsigned long target_index = 0;
241  unsigned int p;
242  int8_t rle_char;
243  unsigned int repeat_count;
244  uint8_t v;
245 
246  scanline_count = s->height * s->channel_count;
247 
248  /* scanline table */
249  if (bytestream2_get_bytes_left(&s->gb) < scanline_count * 2) {
250  av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle scanline table.\n");
251  return AVERROR_INVALIDDATA;
252  }
253  bytestream2_skip(&s->gb, scanline_count * 2);/* size of each scanline */
254 
255  /* decode rle data scanline by scanline */
256  for (sl = 0; sl < scanline_count; sl++) {
257  count = 0;
258 
259  while (count < s->line_size) {
260  rle_char = bytestream2_get_byte(&s->gb);
261 
262  if (rle_char <= 0) {/* byte repeat */
263  repeat_count = rle_char * -1;
264 
265  if (bytestream2_get_bytes_left(&s->gb) < 1) {
266  av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle scanline.\n");
267  return AVERROR_INVALIDDATA;
268  }
269 
270  if (target_index + repeat_count >= s->uncompressed_size) {
271  av_log(s->avctx, AV_LOG_ERROR, "Invalid rle char.\n");
272  return AVERROR_INVALIDDATA;
273  }
274 
275  v = bytestream2_get_byte(&s->gb);
276  for (p = 0; p <= repeat_count; p++) {
277  s->tmp[target_index++] = v;
278  }
279  count += repeat_count + 1;
280  } else {
281  if (bytestream2_get_bytes_left(&s->gb) < rle_char) {
282  av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle scanline.\n");
283  return AVERROR_INVALIDDATA;
284  }
285 
286  if (target_index + rle_char >= s->uncompressed_size) {
287  av_log(s->avctx, AV_LOG_ERROR, "Invalid rle char.\n");
288  return AVERROR_INVALIDDATA;
289  }
290 
291  for (p = 0; p <= rle_char; p++) {
292  v = bytestream2_get_byte(&s->gb);
293  s->tmp[target_index++] = v;
294  }
295  count += rle_char + 1;
296  }
297  }
298  }
299 
300  return 0;
301 }
302 
303 static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
304  int *got_frame, AVPacket *avpkt)
305 {
306  int ret;
307  uint8_t *ptr;
308  const uint8_t *ptr_data;
309  int index_out, c, y, x, p;
310  uint8_t eq_channel[4] = {2,0,1,3};/* RGBA -> GBRA channel order */
311  uint8_t plane_number;
312 
313  PSDContext *s = avctx->priv_data;
314  s->avctx = avctx;
315  s->channel_count = 0;
316  s->channel_depth = 0;
317  s->primary_channels = 0;
318  s->tmp = NULL;
319  s->line_size = 0;
320  s->layer_count = 0;
321 
322  bytestream2_init(&s->gb, avpkt->data, avpkt->size);
323 
324  if ((ret = decode_header(s)) < 0)
325  return ret;
326 
327  s->pixel_size = s->channel_depth >> 3;/* in byte */
328  s->line_size = s->width * s->pixel_size;
329 
330  switch (s->color_mode) {
331  case PSD_BITMAP:
332  if (s->channel_depth != 1 || s->channel_count < 1) {
333  av_log(s->avctx, AV_LOG_ERROR,
334  "Invalid bitmap file (channel_depth %d, channel_count %d)\n",
335  s->channel_depth, s->channel_count);
336  return AVERROR_INVALIDDATA;
337  }
338  s->line_size = s->width + 7 >> 3;
339  s->primary_channels = 1;
340  avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
341  break;
342  case PSD_INDEXED:
343  if (s->channel_depth != 8 || s->channel_count < 1) {
344  av_log(s->avctx, AV_LOG_ERROR,
345  "Invalid indexed file (channel_depth %d, channel_count %d)\n",
346  s->channel_depth, s->channel_count);
347  return AVERROR_INVALIDDATA;
348  }
349  s->primary_channels = 1;
350  avctx->pix_fmt = AV_PIX_FMT_PAL8;
351  break;
352  case PSD_CMYK:
353  if (s->layer_count < 0 && s->channel_count >= 5) {
354  if (s->channel_depth == 8) {
355  avctx->pix_fmt = AV_PIX_FMT_GBRAP;
356  } else if (s->channel_depth == 16) {
357  avctx->pix_fmt = AV_PIX_FMT_GBRAP16BE;
358  } else {
359  avpriv_report_missing_feature(avctx, "channel depth %d for cmyk", s->channel_depth);
360  return AVERROR_PATCHWELCOME;
361  }
362  s->primary_channels = 5;
363  } else if (s->channel_count >= 4) {
364  if (s->channel_depth == 8) {
365  avctx->pix_fmt = AV_PIX_FMT_GBRP;
366  } else if (s->channel_depth == 16) {
367  avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
368  } else {
369  avpriv_report_missing_feature(avctx, "channel depth %d for cmyk", s->channel_depth);
370  return AVERROR_PATCHWELCOME;
371  }
372  s->primary_channels = 4;
373  } else {
374  av_log(s->avctx, AV_LOG_ERROR,
375  "Invalid cmyk file (channel_count %d)\n",
376  s->channel_count);
377  return AVERROR_INVALIDDATA;
378  }
379  break;
380  case PSD_RGB:
381  if (s->layer_count < 0 && s->channel_count >= 4) {
382  if (s->channel_depth == 8) {
383  avctx->pix_fmt = AV_PIX_FMT_GBRAP;
384  } else if (s->channel_depth == 16) {
385  avctx->pix_fmt = AV_PIX_FMT_GBRAP16BE;
386  } else {
387  avpriv_report_missing_feature(avctx, "channel depth %d for rgb", s->channel_depth);
388  return AVERROR_PATCHWELCOME;
389  }
390  s->primary_channels = 4;
391  } else if (s->channel_count >= 3) {
392  if (s->channel_depth == 8) {
393  avctx->pix_fmt = AV_PIX_FMT_GBRP;
394  } else if (s->channel_depth == 16) {
395  avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
396  } else {
397  avpriv_report_missing_feature(avctx, "channel depth %d for rgb", s->channel_depth);
398  return AVERROR_PATCHWELCOME;
399  }
400  s->primary_channels = 3;
401  } else {
402  av_log(s->avctx, AV_LOG_ERROR,
403  "Invalid rgb file (channel_count %d)\n",
404  s->channel_count);
405  return AVERROR_INVALIDDATA;
406  }
407  break;
408  case PSD_DUOTONE:
409  av_log(avctx, AV_LOG_WARNING, "ignoring unknown duotone specification.\n");
410  case PSD_GRAYSCALE:
411  if (s->layer_count < 0 && s->channel_count >= 2) {
412  if (s->channel_depth == 8) {
413  avctx->pix_fmt = AV_PIX_FMT_YA8;
414  } else if (s->channel_depth == 16) {
415  avctx->pix_fmt = AV_PIX_FMT_YA16BE;
416  } else {
417  avpriv_report_missing_feature(avctx, "channel depth %d for grayscale", s->channel_depth);
418  return AVERROR_PATCHWELCOME;
419  }
420  s->primary_channels = 2;
421  } else if (s->channel_count >= 1) {
422  if (s->channel_depth == 8) {
423  avctx->pix_fmt = AV_PIX_FMT_GRAY8;
424  } else if (s->channel_depth == 16) {
425  avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
426  } else if (s->channel_depth == 32) {
427  avctx->pix_fmt = AV_PIX_FMT_GRAYF32BE;
428  } else {
429  avpriv_report_missing_feature(avctx, "channel depth %d for grayscale", s->channel_depth);
430  return AVERROR_PATCHWELCOME;
431  }
432  s->primary_channels = 1;
433  } else {
434  av_log(s->avctx, AV_LOG_ERROR,
435  "Invalid grayscale file (channel_count %d)\n",
436  s->channel_count);
437  return AVERROR_INVALIDDATA;
438  }
439  break;
440  default:
441  avpriv_report_missing_feature(avctx, "color mode %d", s->color_mode);
442  return AVERROR_PATCHWELCOME;
443  }
444 
445  s->uncompressed_size = s->line_size * s->height * s->channel_count;
446 
447  /* decode picture if need */
448  if (s->compression == PSD_RLE) {
449  s->tmp = av_malloc(s->uncompressed_size);
450  if (!s->tmp)
451  return AVERROR(ENOMEM);
452 
453  ret = decode_rle(s);
454 
455  if (ret < 0) {
456  av_freep(&s->tmp);
457  return ret;
458  }
459 
460  ptr_data = s->tmp;
461  } else {
462  if (bytestream2_get_bytes_left(&s->gb) < s->uncompressed_size) {
463  av_log(s->avctx, AV_LOG_ERROR, "Not enough data for raw image data section.\n");
464  return AVERROR_INVALIDDATA;
465  }
466  ptr_data = s->gb.buffer;
467  }
468 
469  if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
470  return ret;
471 
472  /* Store data */
473  if ((avctx->pix_fmt == AV_PIX_FMT_YA8)||(avctx->pix_fmt == AV_PIX_FMT_YA16BE)){/* Interleaved */
474  ptr = picture->data[0];
475  for (c = 0; c < 2; c++) {
476  for (y = 0; y < s->height; y++) {
477  for (x = 0; x < s->width; x++) {
478  index_out = y * picture->linesize[0] + x * 2 * s->pixel_size + c * s->pixel_size;
479  for (p = 0; p < s->pixel_size; p++) {
480  ptr[index_out + p] = *ptr_data;
481  ptr_data ++;
482  }
483  }
484  }
485  }
486  } else if (s->color_mode == PSD_CMYK) {
487  uint8_t *dst[4] = { picture->data[0], picture->data[1], picture->data[2], picture->data[3] };
488  const uint8_t *src[5] = { ptr_data };
489  src[1] = src[0] + s->line_size * s->height;
490  src[2] = src[1] + s->line_size * s->height;
491  src[3] = src[2] + s->line_size * s->height;
492  src[4] = src[3] + s->line_size * s->height;
493  if (s->channel_depth == 8) {
494  for (y = 0; y < s->height; y++) {
495  for (x = 0; x < s->width; x++) {
496  int k = src[3][x];
497  int r = src[0][x] * k;
498  int g = src[1][x] * k;
499  int b = src[2][x] * k;
500  dst[0][x] = g * 257 >> 16;
501  dst[1][x] = b * 257 >> 16;
502  dst[2][x] = r * 257 >> 16;
503  }
504  dst[0] += picture->linesize[0];
505  dst[1] += picture->linesize[1];
506  dst[2] += picture->linesize[2];
507  src[0] += s->line_size;
508  src[1] += s->line_size;
509  src[2] += s->line_size;
510  src[3] += s->line_size;
511  }
512  if (avctx->pix_fmt == AV_PIX_FMT_GBRAP) {
513  for (y = 0; y < s->height; y++) {
514  memcpy(dst[3], src[4], s->line_size);
515  src[4] += s->line_size;
516  dst[3] += picture->linesize[3];
517  }
518  }
519  } else {
520  for (y = 0; y < s->height; y++) {
521  for (x = 0; x < s->width; x++) {
522  int64_t k = AV_RB16(&src[3][x * 2]);
523  int64_t r = AV_RB16(&src[0][x * 2]) * k;
524  int64_t g = AV_RB16(&src[1][x * 2]) * k;
525  int64_t b = AV_RB16(&src[2][x * 2]) * k;
526  AV_WB16(&dst[0][x * 2], g * 65537 >> 32);
527  AV_WB16(&dst[1][x * 2], b * 65537 >> 32);
528  AV_WB16(&dst[2][x * 2], r * 65537 >> 32);
529  }
530  dst[0] += picture->linesize[0];
531  dst[1] += picture->linesize[1];
532  dst[2] += picture->linesize[2];
533  src[0] += s->line_size;
534  src[1] += s->line_size;
535  src[2] += s->line_size;
536  src[3] += s->line_size;
537  }
538  if (avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) {
539  for (y = 0; y < s->height; y++) {
540  memcpy(dst[3], src[4], s->line_size);
541  src[4] += s->line_size;
542  dst[3] += picture->linesize[3];
543  }
544  }
545  }
546  } else {/* Planar */
547  if (s->primary_channels == 1)/* bitmap, indexed, grayscale */
548  eq_channel[0] = 0;/* assign first channel, to first plane */
549 
550  for (c = 0; c < s->primary_channels; c++) {
551  plane_number = eq_channel[c];
552  ptr = picture->data[plane_number];/* get the right plane */
553  for (y = 0; y < s->height; y++) {
554  memcpy(ptr, ptr_data, s->line_size);
555  ptr += picture->linesize[plane_number];
556  ptr_data += s->line_size;
557  }
558  }
559  }
560 
561  if (s->color_mode == PSD_INDEXED) {
562  memcpy(picture->data[1], s->palette, AVPALETTE_SIZE);
563  }
564 
565  av_freep(&s->tmp);
566 
567  picture->pict_type = AV_PICTURE_TYPE_I;
568  *got_frame = 1;
569 
570  return avpkt->size;
571 }
572 
574  .p.name = "psd",
575  CODEC_LONG_NAME("Photoshop PSD file"),
576  .p.type = AVMEDIA_TYPE_VIDEO,
577  .p.id = AV_CODEC_ID_PSD,
578  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
579  .priv_data_size = sizeof(PSDContext),
581 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AVERROR_EXPERIMENTAL
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition: error.h:74
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
PSDContext::height
int height
Definition: psd.c:62
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:140
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
Definition: bytestream.h:158
PSDContext::primary_channels
uint16_t primary_channels
Definition: psd.c:55
GetByteContext
Definition: bytestream.h:33
AV_PIX_FMT_GBRP16BE
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:171
PSDContext::channel_depth
uint16_t channel_depth
Definition: psd.c:54
int64_t
long long int64_t
Definition: coverity.c:34
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
AVPacket::data
uint8_t * data
Definition: packet.h:588
b
#define b
Definition: input.c:42
PsdColorMode
PsdColorMode
Definition: psd.c:34
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
PSD_RGB
@ PSD_RGB
Definition: psd.c:38
FFCodec
Definition: codec_internal.h:127
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: defs.h:62
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:91
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
AV_PIX_FMT_GRAY16BE
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
Definition: pixfmt.h:104
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
PSDContext::line_size
uint64_t line_size
Definition: psd.c:59
signature
static const char signature[]
Definition: ipmovie.c:592
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
AV_PIX_FMT_GBRAP16BE
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:213
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
PSD_LAB
@ PSD_LAB
Definition: psd.c:42
g
const char * g
Definition: vf_curves.c:128
PSD_GRAYSCALE
@ PSD_GRAYSCALE
Definition: psd.c:36
decode.h
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:332
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:95
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
PsdCompr
PsdCompr
Definition: psd.c:27
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
PSDContext
Definition: psd.c:45
AV_WB16
#define AV_WB16(p, v)
Definition: intreadwrite.h:401
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:278
decode_header
static int decode_header(PSDContext *s)
Definition: psd.c:72
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
PSD_ZIP_WITHOUT_P
@ PSD_ZIP_WITHOUT_P
Definition: psd.c:30
PSD_DUOTONE
@ PSD_DUOTONE
Definition: psd.c:41
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
PSD_INDEXED
@ PSD_INDEXED
Definition: psd.c:37
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:519
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1729
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
PSD_BITMAP
@ PSD_BITMAP
Definition: psd.c:35
AVPacket::size
int size
Definition: packet.h:589
codec_internal.h
PSD_CMYK
@ PSD_CMYK
Definition: psd.c:39
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
PSDContext::compression
enum PsdCompr compression
Definition: psd.c:66
AV_PIX_FMT_YA16BE
@ AV_PIX_FMT_YA16BE
16 bits gray, 16 bits alpha (big-endian)
Definition: pixfmt.h:209
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.
version
version
Definition: libkvazaar.c:313
PSDContext::width
int width
Definition: psd.c:61
PSDContext::avctx
AVCodecContext * avctx
Definition: psd.c:48
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:639
PSD_RAW
@ PSD_RAW
Definition: psd.c:28
PSDContext::gb
GetByteContext gb
Definition: psd.c:49
PSD_RLE
@ PSD_RLE
Definition: psd.c:29
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
ret
ret
Definition: filter_design.txt:187
PSDContext::palette
uint8_t palette[AVPALETTE_SIZE]
Definition: psd.c:69
av_malloc
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:98
AV_PIX_FMT_GRAYF32BE
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:363
AVCodecContext
main external API structure.
Definition: avcodec.h:439
PSDContext::layer_count
int16_t layer_count
Definition: psd.c:64
PSD_ZIP_WITH_P
@ PSD_ZIP_WITH_P
Definition: psd.c:31
AV_CODEC_ID_PSD
@ AV_CODEC_ID_PSD
Definition: codec_id.h:277
ff_psd_decoder
const FFCodec ff_psd_decoder
Definition: psd.c:573
PSDContext::color_mode
enum PsdColorMode color_mode
Definition: psd.c:67
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
decode_rle
static int decode_rle(PSDContext *s)
Definition: psd.c:237
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
PSDContext::channel_count
uint16_t channel_count
Definition: psd.c:53
PSDContext::picture
AVFrame * picture
Definition: psd.c:47
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
PSDContext::pixel_size
unsigned int pixel_size
Definition: psd.c:58
mem.h
PSDContext::uncompressed_size
uint64_t uncompressed_size
Definition: psd.c:57
PSD_MULTICHANNEL
@ PSD_MULTICHANNEL
Definition: psd.c:40
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
PSDContext::tmp
uint8_t * tmp
Definition: psd.c:51
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:466
AVPacket
This structure stores compressed data.
Definition: packet.h:565
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
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:472
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
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
Definition: psd.c:303
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
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