FFmpeg: libavformat/gif.c Source File
Go to the documentation of this file. 1 /*
2 * Animated GIF muxer
3 * Copyright (c) 2000 Fabrice Bellard
4 *
5 * first version by Francois Revol <revol@free.fr>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
32
42
44 {
46
47 return 0;
48 }
49
51 {
53 int x;
54
56
58 x = bytestream2_get_byte(&gb);
60 return 0;
61
62 x = bytestream2_get_byte(&gb);
64 int block_size = bytestream2_get_byte(&gb);
65 if (!block_size)
66 break;
68 }
69
72 }
73
74 return 0;
75 }
76
78 {
85
87 }
88
90 {
94
100 }
101
105
107 int delay_pos;
108 int off = 13;
109
112
114 off += 3 * (1 << ((
pkt->
data[10] & 0x07) + 1));
115
118
120
122 off += 19;
123
126
127 /* "NETSCAPE EXTENSION" for looped animation GIF */
128 if (gif->
loop >= 0) {
131 avio_w8(pb, 0x0b);
/* Length of Application Block */
132 avio_write(pb,
"NETSCAPE2.0",
sizeof(
"NETSCAPE2.0") - 1);
133 avio_w8(pb, 0x03);
/* Length of Data Sub-Block */
136 avio_w8(pb, 0x00);
/* Data Sub-block Terminator */
137 }
138
140 if (delay_pos > 0 && delay_pos < pkt->
size - off - 2) {
144 } else {
146 }
147 } else {
149
150 if (delay_pos > 0 && delay_pos < pkt->
size - 2) {
154 } else {
156 }
157 }
158
160 if (new_pkt)
162
163 return 0;
164 }
165
167 {
170
173
175
179
180 return 0;
181 }
182
183 #define OFFSET(x) offsetof(GIFContext, x)
184 #define ENC AV_OPT_FLAG_ENCODING_PARAM
186 {
"loop",
"Number of times to loop the output: -1 - no loop, 0 - infinite loop",
OFFSET(
loop),
188 {
"final_delay",
"Force delay (in centiseconds) after the last frame",
OFFSET(last_delay),
191 };
192
198 };
199
203 .p.mime_type = "image/gif",
204 .p.extensions = "gif",
216 };
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
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
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
#define GIF_GCE_EXT_LABEL
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void avio_wl16(AVIOContext *s, unsigned int val)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
void avio_w8(AVIOContext *s, int b)
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline int bytestream2_tell(GetByteContext *g)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_NOPTS_VALUE
Undefined timestamp value.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define GIF_EXTENSION_INTRODUCER
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH
If this flag is set, it indicates that for each codec type whose corresponding default codec (i....
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define GIF_APP_EXT_LABEL
This structure stores compressed data.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Generated on Thu Sep 26 2024 23:14:58 for FFmpeg by
doxygen
1.8.17