FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
gif.c File Reference
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "lzw.h"
#include "gif.h"
#include "put_bits.h"

Go to the source code of this file.

Data Structures

struct  GIFContext
 

Macros

#define BITSTREAM_WRITER_LE
 
#define DEFAULT_TRANSPARENCY_INDEX   0x1f
 
#define OFFSET(x)   offsetof(GIFContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  { GF_OFFSETTING = 1<<0, GF_TRANSDIFF = 1<<1 }
 

Functions

static int is_image_translucent (AVCodecContext *avctx, const uint8_t *buf, const int linesize)
 
static int get_palette_transparency_index (const uint32_t *palette)
 
static int pick_palette_entry (const uint8_t *buf, int linesize, int w, int h)
 
static void gif_crop_translucent (AVCodecContext *avctx, const uint8_t *buf, const int linesize, int *width, int *height, int *x_start, int *y_start)
 
static void gif_crop_opaque (AVCodecContext *avctx, const uint32_t *palette, const uint8_t *buf, const int linesize, int *width, int *height, int *x_start, int *y_start)
 
static int gif_image_write_image (AVCodecContext *avctx, uint8_t **bytestream, uint8_t *end, const uint32_t *palette, const uint8_t *buf, const int linesize, AVPacket *pkt)
 
static av_cold int gif_encode_init (AVCodecContext *avctx)
 
static int gif_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static int gif_encode_close (AVCodecContext *avctx)
 

Variables

static const AVOption gif_options []
 
static const AVClass gif_class
 
AVCodec ff_gif_encoder
 

Detailed Description

GIF encoder

See also
http://www.w3.org/Graphics/GIF/spec-gif89a.txt

Definition in file gif.c.

Macro Definition Documentation

◆ BITSTREAM_WRITER_LE

#define BITSTREAM_WRITER_LE

Definition at line 33 of file gif.c.

◆ DEFAULT_TRANSPARENCY_INDEX

#define DEFAULT_TRANSPARENCY_INDEX   0x1f

Definition at line 44 of file gif.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(GIFContext, x)

Definition at line 469 of file gif.c.

◆ FLAGS

Definition at line 470 of file gif.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GF_OFFSETTING 
GF_TRANSDIFF 

Definition at line 60 of file gif.c.

Function Documentation

◆ is_image_translucent()

static int is_image_translucent ( AVCodecContext avctx,
const uint8_t buf,
const int  linesize 
)
static

Definition at line 65 of file gif.c.

Referenced by gif_image_write_image().

◆ get_palette_transparency_index()

static int get_palette_transparency_index ( const uint32_t *  palette)
static

Definition at line 86 of file gif.c.

Referenced by gif_encode_frame(), and gif_image_write_image().

◆ pick_palette_entry()

static int pick_palette_entry ( const uint8_t buf,
int  linesize,
int  w,
int  h 
)
static

Definition at line 104 of file gif.c.

Referenced by gif_image_write_image().

◆ gif_crop_translucent()

static void gif_crop_translucent ( AVCodecContext avctx,
const uint8_t buf,
const int  linesize,
int width,
int height,
int x_start,
int y_start 
)
static

Definition at line 120 of file gif.c.

Referenced by gif_image_write_image().

◆ gif_crop_opaque()

static void gif_crop_opaque ( AVCodecContext avctx,
const uint32_t *  palette,
const uint8_t buf,
const int  linesize,
int width,
int height,
int x_start,
int y_start 
)
static

Definition at line 199 of file gif.c.

Referenced by gif_image_write_image().

◆ gif_image_write_image()

static int gif_image_write_image ( AVCodecContext avctx,
uint8_t **  bytestream,
uint8_t end,
const uint32_t *  palette,
const uint8_t buf,
const int  linesize,
AVPacket pkt 
)
static

Definition at line 258 of file gif.c.

Referenced by gif_encode_frame().

◆ gif_encode_init()

static av_cold int gif_encode_init ( AVCodecContext avctx)
static

Definition at line 385 of file gif.c.

◆ gif_encode_frame()

static int gif_encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame pict,
int got_packet 
)
static

Definition at line 409 of file gif.c.

◆ gif_encode_close()

static int gif_encode_close ( AVCodecContext avctx)
static

Definition at line 457 of file gif.c.

Variable Documentation

◆ gif_options

const AVOption gif_options[]
static
Initial value:
= {
{ "gifflags", "set GIF flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = GF_OFFSETTING|GF_TRANSDIFF}, 0, INT_MAX, FLAGS, "flags" },
{ "offsetting", "enable picture offsetting", 0, AV_OPT_TYPE_CONST, {.i64=GF_OFFSETTING}, INT_MIN, INT_MAX, FLAGS, "flags" },
{ "transdiff", "enable transparency detection between frames", 0, AV_OPT_TYPE_CONST, {.i64=GF_TRANSDIFF}, INT_MIN, INT_MAX, FLAGS, "flags" },
{ "gifimage", "enable encoding only images per frame", OFFSET(image), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 471 of file gif.c.

◆ gif_class

const AVClass gif_class
static
Initial value:
= {
.class_name = "GIF encoder",
.item_name = av_default_item_name,
.option = gif_options,
}

Definition at line 479 of file gif.c.

◆ ff_gif_encoder

AVCodec ff_gif_encoder
Initial value:
= {
.name = "gif",
.long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"),
.priv_data_size = sizeof(GIFContext),
.encode2 = gif_encode_frame,
.close = gif_encode_close,
.pix_fmts = (const enum AVPixelFormat[]){
},
.priv_class = &gif_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 486 of file gif.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
FLAGS
#define FLAGS
Definition: gif.c:470
gif_encode_close
static int gif_encode_close(AVCodecContext *avctx)
Definition: gif.c:457
AV_PIX_FMT_BGR8
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:83
GF_OFFSETTING
@ GF_OFFSETTING
Definition: gif.c:61
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
AV_PIX_FMT_RGB8
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:86
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_BGR4_BYTE
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:85
OFFSET
#define OFFSET(x)
Definition: gif.c:469
GF_TRANSDIFF
@ GF_TRANSDIFF
Definition: gif.c:62
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
gif_encode_init
static av_cold int gif_encode_init(AVCodecContext *avctx)
Definition: gif.c:385
GIFContext
Definition: gif.c:46
AV_CODEC_ID_GIF
@ AV_CODEC_ID_GIF
Definition: codec_id.h:146
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
gif_class
static const AVClass gif_class
Definition: gif.c:479
AV_PIX_FMT_RGB4_BYTE
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:88
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
gif_options
static const AVOption gif_options[]
Definition: gif.c:471
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:222
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
gif_encode_frame
static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: gif.c:409
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232