FFmpeg: libavformat/webpenc.c Source File
Go to the documentation of this file. 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 {
40
42
43 if (
s->nb_streams != 1) {
46 }
51 }
53
54 return 0;
55 }
56
58 {
59 int skip = 0;
61
65 skip = 12;
66 // Safe to do this as a valid WebP bitstream is >=30 bytes.
71 }
72
73 if (
flags & 2)
// ANIMATION_FLAG is on
74 return 1;
75 return 0;
76 }
77
79 {
82
83 if (
w->last_pkt->size) {
84 int skip = 0;
86 int vp8x = 0;
87
89 skip = 12;
90
92 flags |=
w->last_pkt->data[skip + 4 + 4];
93 vp8x = 1;
94 skip +=
AV_RL32(
w->last_pkt->data + skip + 4) + 8;
95 }
96
97 if (!
w->wrote_webp_header) {
99 w->wrote_webp_header = 1;
100 if (
w->frame_count > 1)
// first non-empty packet
101 w->frame_count = 1;
// so we don't count previous empty packets.
102 }
103
104 if (
w->frame_count == 1) {
105 if (!trailer) {
106 vp8x = 1;
108 }
109
110 if (vp8x) {
117 }
118 if (!trailer) {
123 }
124 }
125
126 if (
w->frame_count > trailer) {
135 } else
138 }
139 avio_write(
s->pb,
w->last_pkt->data + skip,
w->last_pkt->size - skip);
141 }
142
143 return 0;
144 }
145
147 {
150
152 return 0;
156 w->using_webp_anim_encoder |=
ret;
157
158 if (
w->using_webp_anim_encoder) {
160 w->wrote_webp_header = 1;
// for good measure
161 } else {
166 }
168
169 return 0;
170 }
171
173 {
174 unsigned filesize;
176
177 if (
w->using_webp_anim_encoder) {
178 if (
w->loop) {
// Write loop count.
181 }
182 } else {
186
190 // Note: without the following, avio only writes 8 bytes to the file.
192 }
193
194 return 0;
195 }
196
197 #define OFFSET(x) offsetof(WebpContext, x)
198 #define ENC AV_OPT_FLAG_ENCODING_PARAM
200 {
"loop",
"Number of times to loop the output: 0 - infinite loop",
OFFSET(
loop),
203 };
204
210 };
214 .extensions = "webp",
222 };
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
int using_webp_anim_encoder
const AVOutputFormat ff_webp_muxer
void avio_wl16(AVIOContext *s, unsigned int val)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static const AVOption options[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static int write_trailer(AVFormatContext *s1)
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.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int is_animated_webp_packet(AVPacket *pkt)
#define AV_NOPTS_VALUE
Undefined timestamp value.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wl32(AVIOContext *s, unsigned int val)
static const AVClass webp_muxer_class
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int flush(AVFormatContext *s, int trailer, int64_t pts)
static int webp_write_packet(AVFormatContext *s, AVPacket *pkt)
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...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
static int webp_init(AVFormatContext *s)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void avio_wl24(AVIOContext *s, unsigned int val)
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
static int webp_write_trailer(AVFormatContext *s)
Generated on Wed Aug 24 2022 21:42:21 for FFmpeg by
doxygen
1.8.17