Go to the documentation of this file.
85 version = bytestream2_get_be16(&
s->gb);
93 s->channel_count = bytestream2_get_be16(&
s->gb);
94 if ((
s->channel_count < 1) || (
s->channel_count > 56)) {
99 s->height = bytestream2_get_be32(&
s->gb);
103 "Height > 30000 is experimental, add "
104 "'-strict %d' if you want to try to decode the picture.\n",
109 s->width = bytestream2_get_be32(&
s->gb);
112 "Width > 30000 is experimental, add "
113 "'-strict %d' if you want to try to decode the picture.\n",
121 s->channel_depth = bytestream2_get_be16(&
s->gb);
123 color_mode = bytestream2_get_be16(&
s->gb);
124 switch (color_mode) {
155 len_section = bytestream2_get_be32(&
s->gb);
156 if (len_section < 0) {
168 for (j = HAVE_BIGENDIAN; j < 3 + HAVE_BIGENDIAN; j++)
169 for (
i = 0;
i <
FFMIN(256, len_section / 3);
i++)
170 s->palette[
i * 4 + (HAVE_BIGENDIAN ? j : 2 - j)] = bytestream2_get_byteu(&
s->gb);
171 len_section -=
i * 3;
176 len_section = bytestream2_get_be32(&
s->gb);
177 if (len_section < 0) {
189 len_section = bytestream2_get_be32(&
s->gb);
190 if (len_section < 0) {
207 s->compression = bytestream2_get_be16(&
s->gb);
208 switch (
s->compression) {
227 unsigned int scanline_count;
228 unsigned int sl, count;
229 unsigned long target_index = 0;
232 unsigned int repeat_count;
235 scanline_count =
s->height *
s->channel_count;
245 for (sl = 0; sl < scanline_count; sl++) {
248 while (count < s->line_size) {
249 rle_char = bytestream2_get_byte(&
s->gb);
252 repeat_count = rle_char * -1;
259 if (target_index + repeat_count >=
s->uncompressed_size) {
264 v = bytestream2_get_byte(&
s->gb);
265 for (p = 0; p <= repeat_count; p++) {
266 s->tmp[target_index++] = v;
268 count += repeat_count + 1;
275 if (target_index + rle_char >=
s->uncompressed_size) {
280 for (p = 0; p <= rle_char; p++) {
281 v = bytestream2_get_byte(&
s->gb);
282 s->tmp[target_index++] = v;
284 count += rle_char + 1;
297 const uint8_t *ptr_data;
298 int index_out,
c, y, x, p;
299 uint8_t eq_channel[4] = {2,0,1,3};
300 uint8_t plane_number;
304 s->channel_count = 0;
305 s->channel_depth = 0;
314 s->pixel_size =
s->channel_depth >> 3;
315 s->line_size =
s->width *
s->pixel_size;
317 switch (
s->color_mode) {
319 if (
s->channel_depth != 1 ||
s->channel_count != 1) {
321 "Invalid bitmap file (channel_depth %d, channel_count %d)\n",
322 s->channel_depth,
s->channel_count);
325 s->line_size =
s->width + 7 >> 3;
329 if (
s->channel_depth != 8 ||
s->channel_count != 1) {
331 "Invalid indexed file (channel_depth %d, channel_count %d)\n",
332 s->channel_depth,
s->channel_count);
338 if (
s->channel_count == 4) {
339 if (
s->channel_depth == 8) {
341 }
else if (
s->channel_depth == 16) {
347 }
else if (
s->channel_count == 5) {
348 if (
s->channel_depth == 8) {
350 }
else if (
s->channel_depth == 16) {
362 if (
s->channel_count == 3) {
363 if (
s->channel_depth == 8) {
365 }
else if (
s->channel_depth == 16) {
371 }
else if (
s->channel_count == 4) {
372 if (
s->channel_depth == 8) {
374 }
else if (
s->channel_depth == 16) {
388 if (
s->channel_count == 1) {
389 if (
s->channel_depth == 8) {
391 }
else if (
s->channel_depth == 16) {
393 }
else if (
s->channel_depth == 32) {
399 }
else if (
s->channel_count == 2) {
400 if (
s->channel_depth == 8) {
402 }
else if (
s->channel_depth == 16) {
418 s->uncompressed_size =
s->line_size *
s->height *
s->channel_count;
442 ptr_data =
s->gb.buffer;
447 ptr = picture->
data[0];
448 for (
c = 0;
c <
s->channel_count;
c++) {
449 for (y = 0; y <
s->height; y++) {
450 for (x = 0; x <
s->width; x++) {
451 index_out = y * picture->
linesize[0] + x *
s->channel_count *
s->pixel_size +
c *
s->pixel_size;
452 for (p = 0; p <
s->pixel_size; p++) {
453 ptr[index_out + p] = *ptr_data;
460 uint8_t *dst[4] = { picture->
data[0], picture->
data[1], picture->
data[2], picture->
data[3] };
461 const uint8_t *
src[5] = { ptr_data };
462 src[1] =
src[0] +
s->line_size *
s->height;
463 src[2] =
src[1] +
s->line_size *
s->height;
464 src[3] =
src[2] +
s->line_size *
s->height;
465 src[4] =
src[3] +
s->line_size *
s->height;
466 if (
s->channel_depth == 8) {
467 for (y = 0; y <
s->height; y++) {
468 for (x = 0; x <
s->width; x++) {
470 int r =
src[0][x] * k;
471 int g =
src[1][x] * k;
472 int b =
src[2][x] * k;
473 dst[0][x] =
g * 257 >> 16;
474 dst[1][x] =
b * 257 >> 16;
475 dst[2][x] =
r * 257 >> 16;
480 src[0] +=
s->line_size;
481 src[1] +=
s->line_size;
482 src[2] +=
s->line_size;
483 src[3] +=
s->line_size;
486 for (y = 0; y <
s->height; y++) {
487 memcpy(dst[3],
src[4],
s->line_size);
488 src[4] +=
s->line_size;
493 for (y = 0; y <
s->height; y++) {
494 for (x = 0; x <
s->width; x++) {
499 AV_WB16(&dst[0][x * 2],
g * 65537 >> 32);
500 AV_WB16(&dst[1][x * 2],
b * 65537 >> 32);
501 AV_WB16(&dst[2][x * 2],
r * 65537 >> 32);
506 src[0] +=
s->line_size;
507 src[1] +=
s->line_size;
508 src[2] +=
s->line_size;
509 src[3] +=
s->line_size;
512 for (y = 0; y <
s->height; y++) {
513 memcpy(dst[3],
src[4],
s->line_size);
514 src[4] +=
s->line_size;
520 if (
s->channel_count == 1)
523 for (
c = 0;
c <
s->channel_count;
c++) {
524 plane_number = eq_channel[
c];
525 ptr = picture->
data[plane_number];
526 for (y = 0; y <
s->height; y++) {
527 memcpy(ptr, ptr_data,
s->line_size);
528 ptr += picture->
linesize[plane_number];
529 ptr_data +=
s->line_size;
535 #if FF_API_PALETTE_HAS_CHANGED
#define FF_ENABLE_DEPRECATION_WARNINGS
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
attribute_deprecated int palette_has_changed
Tell user application that palette has changed from previous frame.
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_PIX_FMT_YA8
8 bits gray, 8 bits alpha
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
This structure describes decoded (raw) audio or video data.
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
AVCodec p
The public AVCodec.
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
static const char signature[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Describe the class of an AVClass context structure.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
@ AV_PICTURE_TYPE_I
Intra.
static int decode_header(PSDContext *s)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
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
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
enum AVPictureType pict_type
Picture type of the frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
enum PsdCompr compression
@ AV_PIX_FMT_YA16BE
16 bits gray, 16 bits alpha (big-endian)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define i(width, name, range_min, range_max)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
uint8_t palette[AVPALETTE_SIZE]
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
main external API structure.
const FFCodec ff_psd_decoder
enum PsdColorMode color_mode
static int decode_rle(PSDContext *s)
#define FF_DISABLE_DEPRECATION_WARNINGS
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
uint64_t uncompressed_size
#define avpriv_request_sample(...)
This structure stores compressed data.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
#define MKTAG(a, b, c, d)
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