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