31 #define GCE_DISPOSAL_NONE 0
32 #define GCE_DISPOSAL_INPLACE 1
33 #define GCE_DISPOSAL_BACKGROUND 2
34 #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;
71 left = bytestream2_get_le16(&s->
gb);
72 top = bytestream2_get_le16(&s->
gb);
73 width = bytestream2_get_le16(&s->
gb);
74 height = bytestream2_get_le16(&s->
gb);
75 flags = bytestream2_get_byte(&s->
gb);
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) {
99 n = (1 << bits_per_pixel);
101 for(i = 0; i < n; i++) {
112 code_size = bytestream2_get_byte(&s->
gb);
122 for (y = 0; y <
height; y++) {
124 if (is_interleaved) {
141 while (y1 >= height) {
143 ptr = ptr1 + linesize * y1;
159 int ext_code, ext_len, i, gce_flags, gce_transparent_index;
162 ext_code = bytestream2_get_byte(&s->
gb);
163 ext_len = bytestream2_get_byte(&s->
gb);
165 av_dlog(s->
avctx,
"gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
172 gce_flags = bytestream2_get_byte(&s->
gb);
174 gce_transparent_index = bytestream2_get_byte(&s->
gb);
175 if (gce_flags & 0x01)
181 av_dlog(s->
avctx,
"gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n",
185 ext_len = bytestream2_get_byte(&s->
gb);
191 while (ext_len != 0) {
192 for (i = 0; i < ext_len; i++)
193 bytestream2_get_byte(&s->
gb);
194 ext_len = bytestream2_get_byte(&s->
gb);
205 int has_global_palette;
226 v = bytestream2_get_byte(&s->
gb);
228 has_global_palette = (v & 0x80);
231 bytestream2_get_byte(&s->
gb);
233 av_dlog(s->
avctx,
"gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
237 if (has_global_palette) {
249 int code = bytestream2_get_byte(&s->
gb);
288 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...
void ff_lzw_decode_tail(LZWState *p)
This structure describes decoded (raw) audio or video data.
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)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
av_cold void ff_lzw_decode_close(LZWState **p)
av_cold void ff_lzw_decode_open(LZWState **p)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
8 bit with PIX_FMT_RGB32 palette
static int gif_read_extension(GifState *s)
static av_cold int gif_decode_close(AVCodecContext *avctx)
static int init(AVCodecParserContext *s)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
int ff_lzw_size_read(LZWState *p)
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)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
static const uint8_t gif89a_sig[6]
static av_always_inline int bytestream2_tell(GetByteContext *g)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
int background_color_index
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
uint8_t local_palette[256 *3]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const uint8_t gif87a_sig[6]
common internal api header.
#define AVERROR_INVALIDDATA
int ff_lzw_decode_init(LZWState *p, int csize, const uint8_t *buf, int buf_size, int mode)
Initialize LZW decoder.
static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int gif_read_header1(GifState *s)
uint8_t global_palette[256 *3]
This structure stores compressed data.