Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chromium/patches/to_upstream/15_webp_ffmpeg.patch

Issue 9290059: Initial commit of all previous Chrome build scripts. (Closed) Base URL: http://git.chromium.org/chromium/third_party/ffmpeg.git@master
Patch Set: Drop deprecated subfolder. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 diff -wurp -N orig/libavformat/Makefile ffmpeg/libavformat/Makefile
2 --- orig/libavformat/Makefile 2011-07-12 20:48:57.664216904 -0700
3 +++ ffmpeg/libavformat/Makefile 2011-07-12 20:48:57.714181059 -0700
4 @@ -299,6 +299,8 @@ OBJS-$(CONFIG_WC3_DEMUXER)
5 OBJS-$(CONFIG_WEBM_MUXER) += matroskaenc.o matroska.o \
6 riff.o isom.o avc.o \
7 flacenc_header.o avlanguage.o
8 +OBJS-$(CONFIG_WEBP_DEMUXER) += webpdec.o webp.o
9 +OBJS-$(CONFIG_WEBP_MUXER) += webpenc.o webp.o
10 OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o
11 OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o
12 OBJS-$(CONFIG_WTV_DEMUXER) += wtvdec.o wtv.o asfdec.o asf.o asfcr ypt.o \
13 diff -wurp -N orig/libavformat/allformats.c ffmpeg/libavformat/allformats.c
14 --- orig/libavformat/allformats.c 2011-07-12 20:48:57.664216904 -0700
15 +++ ffmpeg/libavformat/allformats.c 2011-07-12 20:48:57.714181059 -0700
16 @@ -222,6 +222,7 @@ void av_register_all(void)
17 REGISTER_MUXDEMUX (WAV, wav);
18 REGISTER_DEMUXER (WC3, wc3);
19 REGISTER_MUXER (WEBM, webm);
20 + REGISTER_MUXDEMUX (WEBP, webp);
21 REGISTER_DEMUXER (WSAUD, wsaud);
22 REGISTER_DEMUXER (WSVQA, wsvqa);
23 REGISTER_DEMUXER (WTV, wtv);
24 diff -wurp -N orig/libavformat/webp.c ffmpeg/libavformat/webp.c
25 --- orig/libavformat/webp.c 1969-12-31 16:00:00.000000000 -0800
26 +++ ffmpeg/libavformat/webp.c 2011-07-12 20:48:57.714181059 -0700
27 @@ -0,0 +1,34 @@
28 +/*
29 + * Copyright (c) 2010, Google, Inc.
30 + *
31 + * This file is part of FFmpeg.
32 + *
33 + * FFmpeg is free software; you can redistribute it and/or
34 + * modify it under the terms of the GNU Lesser General Public
35 + * License as published by the Free Software Foundation; either
36 + * version 2.1 of the License, or (at your option) any later version.
37 + *
38 + * FFmpeg is distributed in the hope that it will be useful,
39 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41 + * Lesser General Public License for more details.
42 + *
43 + * You should have received a copy of the GNU Lesser General Public
44 + * License along with FFmpeg; if not, write to the Free Software
45 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
46 + */
47 +
48 +/*
49 + * @file
50 + * common code for WebP muxer/demuxer
51 + */
52 +
53 +#include "webp.h"
54 +
55 +const AVMetadataConv ff_webp_metadata_conv[] = {
56 + { "IART", "artist" },
57 + { "ICOP", "copyright" },
58 + { "INAM", "title" },
59 + { "ICMT", "comment" },
60 + { 0 }
61 +};
62 diff -wurp -N orig/libavformat/webp.h ffmpeg/libavformat/webp.h
63 --- orig/libavformat/webp.h 1969-12-31 16:00:00.000000000 -0800
64 +++ ffmpeg/libavformat/webp.h 2011-07-12 20:48:57.714181059 -0700
65 @@ -0,0 +1,35 @@
66 +/*
67 + * Copyright (c) 2010, Google, Inc.
68 + *
69 + * This file is part of FFmpeg.
70 + *
71 + * FFmpeg is free software; you can redistribute it and/or
72 + * modify it under the terms of the GNU Lesser General Public
73 + * License as published by the Free Software Foundation; either
74 + * version 2.1 of the License, or (at your option) any later version.
75 + *
76 + * FFmpeg is distributed in the hope that it will be useful,
77 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
78 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79 + * Lesser General Public License for more details.
80 + *
81 + * You should have received a copy of the GNU Lesser General Public
82 + * License along with FFmpeg; if not, write to the Free Software
83 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
84 + */
85 +
86 +/*
87 + * @file
88 + * common header for WebP muxer/demuxer
89 + */
90 +
91 +#ifndef AVFORMAT_WEBP_H
92 +#define AVFORMAT_WEBP_H
93 +
94 +#include "avformat.h"
95 +#include "riff.h"
96 +#include "metadata.h"
97 +
98 +extern const AVMetadataConv ff_webp_metadata_conv[];
99 +
100 +#endif /* AVFORMAT_WEBP_H */
101 diff -wurp -N orig/libavformat/webpdec.c ffmpeg/libavformat/webpdec.c
102 --- orig/libavformat/webpdec.c 1969-12-31 16:00:00.000000000 -0800
103 +++ ffmpeg/libavformat/webpdec.c 2011-07-12 20:48:57.714181059 -0700
104 @@ -0,0 +1,132 @@
105 +/*
106 + * Copyright (c) 2010, Google, Inc.
107 + *
108 + * This file is part of FFmpeg.
109 + *
110 + * FFmpeg is free software; you can redistribute it and/or
111 + * modify it under the terms of the GNU Lesser General Public
112 + * License as published by the Free Software Foundation; either
113 + * version 2.1 of the License, or (at your option) any later version.
114 + *
115 + * FFmpeg is distributed in the hope that it will be useful,
116 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
117 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
118 + * Lesser General Public License for more details.
119 + *
120 + * You should have received a copy of the GNU Lesser General Public
121 + * License along with FFmpeg; if not, write to the Free Software
122 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
123 + */
124 +
125 +/*
126 + * @file
127 + * WebP demuxer
128 + * http://code.google.com/p/webp
129 + *
130 + * supports metadata: artist, copyright, title, comment
131 + * Encoding/decoding examples:
132 + * ffmpeg -i my_image
133 + * -metadata artist=me -metadata title="sunset"
134 + * -metadata copyright=2010 -metadata comment="nice pic!"
135 + * -profile 1 -qmin 5 my_image.webp
136 + * ffmpeg -i my_image.webp -y my_image.png
137 + */
138 +
139 +#include "webp.h"
140 +#include "libavutil/intreadwrite.h"
141 +
142 +static const AVCodecTag webp_codec_tags[] = {
143 + { CODEC_ID_VP8, MKTAG('V', 'P', '8', ' ') },
144 + { CODEC_ID_NONE, 0 }
145 +};
146 +
147 +static int probe(AVProbeData *p)
148 +{
149 + if (!memcmp(p->buf, "RIFF", 4) && !memcmp(p->buf + 8, "WEBP", 4))
150 + return AVPROBE_SCORE_MAX;
151 +
152 + return 0;
153 +}
154 +
155 +static int read_header(AVFormatContext *s, AVFormatParameters *ap)
156 +{
157 + AVStream *st;
158 + uint32_t riff_size;
159 +
160 + if (get_le32(s->pb) != AV_RL32("RIFF"))
161 + return AVERROR(EINVAL);
162 + riff_size = get_le32(s->pb);
163 + if (get_le32(s->pb) != AV_RL32("WEBP"))
164 + return AVERROR(EINVAL);
165 +
166 + st = av_new_stream(s, 0);
167 + if (!st)
168 + return AVERROR(ENOMEM);
169 +
170 + st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
171 + st->codec->codec_tag = AV_RL32("VP8 ");
172 + st->codec->codec_id = ff_codec_get_id(webp_codec_tags,
173 + st->codec->codec_tag);
174 + av_set_pts_info(st, 24, 1, 1000);
175 +
176 + return 0;
177 +}
178 +
179 +static int set_metadata(ByteIOContext* pb, AVMetadata** metadata,
180 + const char* generic_key, uint32_t size)
181 +{
182 + char* const value = av_malloc(size + 1);
183 + if (!value)
184 + return AVERROR(ENOMEM);
185 + if (get_buffer(pb, value, size) < 0)
186 + return AVERROR(EINVAL);
187 + value[size] = 0;
188 + if (av_metadata_set2(metadata, generic_key, value, 0))
189 + return AVERROR(EINVAL);
190 + av_free(value);
191 + return size;
192 +}
193 +
194 +static int read_packet(AVFormatContext *s, AVPacket *pkt)
195 +{
196 + int ret = -1;
197 + AVStream *stream = s->streams[pkt->stream_index];
198 + uint32_t tag = get_le32(s->pb);
199 + uint32_t chunk_size = get_le32(s->pb);
200 + if (tag == stream->codec->codec_tag) {
201 + ret = av_get_packet(s->pb, pkt, chunk_size);
202 + pkt->flags |= AV_PKT_FLAG_KEY;
203 + }
204 + else {
205 + int i;
206 + for (i = 0; ff_webp_metadata_conv[i].native; ++i) {
207 + const char* native_tag = ff_webp_metadata_conv[i].native;
208 + if (tag == AV_RL32(native_tag)) {
209 + ret = set_metadata(s->pb, &stream->metadata,
210 + ff_webp_metadata_conv[i].generic,
211 + chunk_size);
212 + break;
213 + }
214 + }
215 + }
216 + return ret;
217 +}
218 +
219 +static int read_close(struct AVFormatContext *s)
220 +{
221 + return 0;
222 +}
223 +
224 +AVInputFormat webp_demuxer = {
225 + .name = "webp",
226 + .long_name = NULL_IF_CONFIG_SMALL("WebP"),
227 + .priv_data_size = 0,
228 + .read_probe = probe,
229 + .read_header = read_header,
230 + .read_packet = read_packet,
231 + .read_close = read_close,
232 + .flags = AVFMT_GENERIC_INDEX,
233 + .extensions = "webp",
234 + .value = CODEC_ID_VP8,
235 + .codec_tag = (const AVCodecTag*[]){webp_codec_tags, 0},
236 +};
237 diff -wurp -N orig/libavformat/webpenc.c ffmpeg/libavformat/webpenc.c
238 --- orig/libavformat/webpenc.c 1969-12-31 16:00:00.000000000 -0800
239 +++ ffmpeg/libavformat/webpenc.c 2011-07-12 20:48:57.714181059 -0700
240 @@ -0,0 +1,123 @@
241 +/*
242 + * Copyright (c) 2010, Google, Inc.
243 + *
244 + * This file is part of FFmpeg.
245 + *
246 + * FFmpeg is free software; you can redistribute it and/or
247 + * modify it under the terms of the GNU Lesser General Public
248 + * License as published by the Free Software Foundation; either
249 + * version 2.1 of the License, or (at your option) any later version.
250 + *
251 + * FFmpeg is distributed in the hope that it will be useful,
252 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
253 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
254 + * Lesser General Public License for more details.
255 + *
256 + * You should have received a copy of the GNU Lesser General Public
257 + * License along with FFmpeg; if not, write to the Free Software
258 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
259 + */
260 +
261 +/*
262 + * @file
263 + * WebP muxer
264 + * http://code.google.com/p/webp
265 + *
266 + * supports metadata: artist, copyright, title, comment
267 + * Encoding/decoding examples:
268 + * ffmpeg -i my_image
269 + * -metadata artist=me -metadata title="sunset"
270 + * -metadata copyright=2010 -metadata comment="nice pic!"
271 + * -profile 1 -qmin 5 my_image.webp
272 + * ffmpeg -i my_image.webp -y my_image.png
273 + */
274 +
275 +#include "webp.h"
276 +
277 +typedef struct {
278 + uint64_t riff_start;
279 +} WEBPContext;
280 +
281 +static int write_header(AVFormatContext *s)
282 +{
283 + ByteIOContext *pb = s->pb;
284 + WEBPContext *webp = s->priv_data;
285 + AVStream *stream;
286 + AVCodecContext *codec;
287 +
288 + if (s->nb_streams != 1) {
289 + av_log(s, AV_LOG_ERROR, "muxer only support 1 video stream.");
290 + return AVERROR(EINVAL);
291 + }
292 + stream = s->streams[0];
293 + codec = stream->codec;
294 + if (codec->codec_type != AVMEDIA_TYPE_VIDEO)
295 + return AVERROR(EINVAL);
296 + if (codec->codec_id != CODEC_ID_VP8)
297 + return AVERROR(EINVAL);
298 +
299 + webp->riff_start = ff_start_tag(pb, "RIFF");
300 + put_tag(pb, "WEBP");
301 + return 0;
302 +}
303 +
304 +static int write_packet(AVFormatContext *s, AVPacket *pkt)
305 +{
306 + AVStream *stream = s->streams[pkt->stream_index];
307 + AVCodecContext *codec = stream->codec;
308 + ByteIOContext *pb = s->pb;
309 + uint64_t vp8_start;
310 +
311 + if (codec->codec_id != CODEC_ID_VP8) {
312 + av_log(s, AV_LOG_ERROR, "muxer only supports VP8 codec.");
313 + return AVERROR(EINVAL);
314 + }
315 + vp8_start = ff_start_tag(pb, "VP8 ");
316 + put_buffer(pb, pkt->data, pkt->size);
317 + if (pkt->size & 1) put_byte(pb, 0); // pad
318 + ff_end_tag(pb, vp8_start);
319 + put_flush_packet(pb);
320 + return 0;
321 +}
322 +
323 +static void put_metadata(AVFormatContext *s,
324 + const AVMetadataConv* metadata)
325 +{
326 + ByteIOContext *pb = s->pb;
327 + AVMetadataTag *t;
328 + uint64_t pos;
329 + int len;
330 + t = av_metadata_get(s->metadata, metadata->generic, NULL, 0);
331 + if (!t) return;
332 + pos = ff_start_tag(pb, metadata->native);
333 + len = strlen(t->value) + 1;
334 + put_buffer(pb, t->value, len);
335 + if (len & 1) put_byte(pb, 0); // pad
336 + ff_end_tag(pb, pos);
337 +}
338 +
339 +static int write_trailer(AVFormatContext *s)
340 +{
341 + ByteIOContext *pb = s->pb;
342 + WEBPContext *webp = s->priv_data;
343 + int i;
344 + for (i = 0; ff_webp_metadata_conv[i].native; ++i) {
345 + put_metadata(s, &ff_webp_metadata_conv[i]);
346 + }
347 + ff_end_tag(pb, webp->riff_start);
348 + put_flush_packet(pb);
349 + return 0;
350 +}
351 +
352 +AVOutputFormat webp_muxer = {
353 + .name = "webp",
354 + .long_name = NULL_IF_CONFIG_SMALL("WebP"),
355 + .mime_type = "image/webp",
356 + .extensions = "webp",
357 + .priv_data_size = sizeof(WEBPContext),
358 + .audio_codec = CODEC_ID_NONE,
359 + .video_codec = CODEC_ID_VP8,
360 + .write_header = write_header,
361 + .write_packet = write_packet,
362 + .write_trailer = write_trailer,
363 +};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698