1 /*
2 * webp muxer
3 * Copyright (c) 2014 Michael Niedermayer
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
26
35
37 {
39
43 }
48 }
50
51 return 0;
52 }
53
55 {
57 int skip = 0;
59
61 return 0;
63 skip = 12;
64
65 if (pkt->
size < skip + 4)
66 return 0;
68 flags |= pkt->
data[skip + 4 + 4];
69 }
70
71 if (flags & 2) // ANIMATION_FLAG is on
72 return 1;
73 }
74 return 0;
75 }
76
78 {
81
83 int skip = 0;
85 int vp8x = 0;
86
88 return 0;
90 skip = 12;
91
93 return 0; // Safe to do this as a valid WebP bitstream is >=30 bytes.
96 vp8x = 1;
98 }
99
104 w->
frame_count = 1;
// so we don't count previous empty packets.
105 }
106
108 if (!trailer) {
109 vp8x = 1;
110 flags |= 2 + 16;
111 }
112
113 if (vp8x) {
120 }
121 if (!trailer) {
126 }
127 }
128
138 } else
141 }
144 }
145
146 return 0;
147 }
148
150 {
153
157 } else {
158 int ret;
159 if ((ret =
flush(s, 0, pkt->
pts)) < 0)
160 return ret;
162 }
164
165 return 0;
166 }
167
169 {
170 unsigned filesize;
172
177 }
178 } else {
179 int ret;
181 return ret;
182
186 // Note: without the following, avio only writes 8 bytes to the file.
188 }
189
190 return 0;
191 }
192
193 #define OFFSET(x) offsetof(WebpContext, x)
194 #define ENC AV_OPT_FLAG_ENCODING_PARAM
196 {
"loop",
"Number of times to loop the output: 0 - infinite loop",
OFFSET(
loop),
199 };
200
206 };
210 .extensions = "webp",
216 .priv_class = &webp_muxer_class,
218 };
void avio_wl16(AVIOContext *s, unsigned int val)
#define LIBAVUTIL_VERSION_INT
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void avio_wl32(AVIOContext *s, unsigned int val)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream ** streams
A list of all streams in the file.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVOption options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int using_webp_anim_encoder
AVCodecContext * codec
Codec context associated with this stream.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int width
picture width / height.
static int write_trailer(AVFormatContext *s1)
static int webp_write_header(AVFormatContext *s)
static int is_animated_webp_packet(AVPacket *pkt)
static const AVClass webp_muxer_class
AVIOContext * pb
I/O context.
void avio_w8(AVIOContext *s, int b)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
Describe the class of an AVClass context structure.
void avio_wl24(AVIOContext *s, unsigned int val)
static int flush(AVFormatContext *s, int trailer, int64_t pts)
static int64_t pts
Global timestamp for the audio frames.
static int webp_write_packet(AVFormatContext *s, AVPacket *pkt)
AVOutputFormat ff_webp_muxer
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
static int webp_write_trailer(AVFormatContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.