30 #define GCE_DISPOSAL_NONE 0
31 #define GCE_DISPOSAL_INPLACE 1
32 #define GCE_DISPOSAL_BACKGROUND 2
33 #define GCE_DISPOSAL_RESTORE 3
68 int is_interleaved, has_local_palette, y,
pass, y1, linesize, n, i;
69 uint8_t *ptr, *spal, *
palette, *ptr1;
76 is_interleaved = flags & 0x40;
77 has_local_palette = flags & 0x80;
78 bits_per_pixel = (flags & 0x07) + 1;
80 av_dlog(s->
avctx,
"gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
82 if (has_local_palette) {
96 n = (1 << bits_per_pixel);
98 for(i = 0; i < n; i++) {
109 code_size = bytestream_get_byte(&s->
bytestream);
119 for (y = 0; y <
height; y++) {
121 if (is_interleaved) {
138 while (y1 >= height) {
140 ptr = ptr1 + linesize * y1;
155 int ext_code, ext_len, i, gce_flags, gce_transparent_index;
158 ext_code = bytestream_get_byte(&s->
bytestream);
159 ext_len = bytestream_get_byte(&s->
bytestream);
161 av_dlog(s->
avctx,
"gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
168 gce_flags = bytestream_get_byte(&s->
bytestream);
170 gce_transparent_index = bytestream_get_byte(&s->
bytestream);
171 if (gce_flags & 0x01)
177 av_dlog(s->
avctx,
"gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n",
181 ext_len = bytestream_get_byte(&s->
bytestream);
187 while (ext_len != 0) {
188 for (i = 0; i < ext_len; i++)
190 ext_len = bytestream_get_byte(&s->
bytestream);
201 int has_global_palette;
224 has_global_palette = (v & 0x80);
229 av_dlog(s->
avctx,
"gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
233 if (has_global_palette) {
245 int code = bytestream_get_byte(&s->
bytestream);
281 const uint8_t *buf = avpkt->
data;
282 int buf_size = avpkt->
size;
int transparent_color_index
int ff_lzw_decode(LZWState *p, uint8_t *buf, int len)
Decode given number of bytes NOTE: the algorithm here is inspired from the LZW GIF decoder written by...
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
void ff_lzw_decode_tail(LZWState *p)
const uint8_t * bytestream
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
AVFrame * coded_frame
the picture in the bitstream
static int gif_parse_next_image(GifState *s)
av_cold void ff_lzw_decode_close(LZWState **p)
av_cold void ff_lzw_decode_open(LZWState **p)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static int gif_read_extension(GifState *s)
static av_cold int gif_decode_close(AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
const uint8_t * ff_lzw_cur_ptr(LZWState *p)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int gif_read_image(GifState *s)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
static av_cold int gif_decode_init(AVCodecContext *avctx)
static const uint8_t gif89a_sig[6]
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
const uint8_t * bytestream_end
main external API structure.
static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct AVPicture AVPicture
four components are given, that's all.
int background_color_index
uint8_t local_palette[256 *3]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_RB24
static const uint8_t gif87a_sig[6]
8 bit with PIX_FMT_RGB32 palette
int ff_lzw_decode_init(LZWState *p, int csize, const uint8_t *buf, int buf_size, int mode)
Initialize LZW decoder.
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
static int gif_read_header1(GifState *s)
uint8_t global_palette[256 *3]