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 {
45 if (
s->nb_streams != 1 ||
49 "GIF muxer supports only a single video GIF stream.\n");
51 }
52
54
55 return 0;
56 }
57
59 {
61 int x;
62
64
66 x = bytestream2_get_byte(&gb);
68 return 0;
69
70 x = bytestream2_get_byte(&gb);
72 int block_size = bytestream2_get_byte(&gb);
73 if (!block_size)
74 break;
76 }
77
80 }
81
82 return 0;
83 }
84
86 {
91
93 }
94
96 {
100
106 }
107
111
113 int delay_pos;
114 int off = 13;
115
118
120 off += 3 * (1 << ((
pkt->
data[10] & 0x07) + 1));
121
124
126
128 off += 19;
129
132
133 /* "NETSCAPE EXTENSION" for looped animation GIF */
134 if (gif->
loop >= 0) {
137 avio_w8(pb, 0x0b);
/* Length of Application Block */
138 avio_write(pb,
"NETSCAPE2.0",
sizeof(
"NETSCAPE2.0") - 1);
139 avio_w8(pb, 0x03);
/* Length of Data Sub-Block */
142 avio_w8(pb, 0x00);
/* Data Sub-block Terminator */
143 }
144
146 if (delay_pos > 0 && delay_pos < pkt->
size - off - 2) {
150 } else {
152 }
153 } else {
155
156 if (delay_pos > 0 && delay_pos < pkt->
size - 2) {
160 } else {
162 }
163 }
164
166 if (new_pkt)
168
169 return 0;
170 }
171
173 {
176
179
181
185
186 return 0;
187 }
188
189 #define OFFSET(x) offsetof(GIFContext, x)
190 #define ENC AV_OPT_FLAG_ENCODING_PARAM
192 {
"loop",
"Number of times to loop the output: -1 - no loop, 0 - infinite loop",
OFFSET(
loop),
194 {
"final_delay",
"Force delay (in centiseconds) after the last frame",
OFFSET(last_delay),
197 };
198
204 };
205
209 .p.mime_type = "image/gif",
210 .p.extensions = "gif",
219 };