Patch by James Zern for Google, Inc., jzern google com
Originally committed as revision 23303 to svn://svn.ffmpeg.org/ffmpeg/trunk
... | ... |
@@ -183,6 +183,7 @@ External library support: |
183 | 183 |
--enable-libtheora enable Theora encoding via libtheora [no] |
184 | 184 |
--enable-libvorbis enable Vorbis encoding via libvorbis, |
185 | 185 |
native implementation exists [no] |
186 |
+ --enable-libvpx enable VP8 support via libvpx [no] |
|
186 | 187 |
--enable-libx264 enable H.264 encoding via x264 [no] |
187 | 188 |
--enable-libxvid enable Xvid encoding via xvidcore, |
188 | 189 |
native MPEG-4/Xvid encoder exists [no] |
... | ... |
@@ -927,6 +928,7 @@ CONFIG_LIST=" |
927 | 927 |
libspeex |
928 | 928 |
libtheora |
929 | 929 |
libvorbis |
930 |
+ libvpx |
|
930 | 931 |
libx264 |
931 | 932 |
libxvid |
932 | 933 |
lpc |
... | ... |
@@ -1349,6 +1351,7 @@ libschroedinger_encoder_deps="libschroedinger" |
1349 | 1349 |
libspeex_decoder_deps="libspeex" |
1350 | 1350 |
libtheora_encoder_deps="libtheora" |
1351 | 1351 |
libvorbis_encoder_deps="libvorbis" |
1352 |
+libvpx_decoder_deps="libvpx" |
|
1352 | 1353 |
libx264_encoder_deps="libx264" |
1353 | 1354 |
libxvid_encoder_deps="libxvid" |
1354 | 1355 |
|
... | ... |
@@ -2617,6 +2620,7 @@ enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) && |
2617 | 2617 |
enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex |
2618 | 2618 |
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg |
2619 | 2619 |
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg |
2620 |
+enabled libvpx && require2 libvpx "vpx_decoder.h vp8dx.h" "vpx_codec_dec_init_ver" -lvpx |
|
2620 | 2621 |
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm && |
2621 | 2622 |
{ check_cpp_condition x264.h "X264_BUILD >= 90" || |
2622 | 2623 |
die "ERROR: libx264 version must be >= 0.90."; } |
... | ... |
@@ -2886,6 +2890,7 @@ echo "libschroedinger enabled ${libschroedinger-no}" |
2886 | 2886 |
echo "libspeex enabled ${libspeex-no}" |
2887 | 2887 |
echo "libtheora enabled ${libtheora-no}" |
2888 | 2888 |
echo "libvorbis enabled ${libvorbis-no}" |
2889 |
+echo "libvpx enabled ${libvpx-no}" |
|
2889 | 2890 |
echo "libx264 enabled ${libx264-no}" |
2890 | 2891 |
echo "libxvid enabled ${libxvid-no}" |
2891 | 2892 |
echo "zlib enabled ${zlib-no}" |
... | ... |
@@ -437,6 +437,8 @@ following image formats are supported: |
437 | 437 |
@tab fourcc: VP50 |
438 | 438 |
@item On2 VP6 @tab @tab X |
439 | 439 |
@tab fourcc: VP60,VP61,VP62 |
440 |
+ at item VP8 @tab @tab X |
|
441 |
+ @tab fourcc: VP80, decoding supported through external library libvpx |
|
440 | 442 |
@item planar RGB @tab @tab X |
441 | 443 |
@tab fourcc: 8BPS |
442 | 444 |
@item Q-team QPEG @tab @tab X |
... | ... |
@@ -536,6 +536,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ |
536 | 536 |
OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o |
537 | 537 |
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o |
538 | 538 |
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o |
539 |
+OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o |
|
539 | 540 |
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o |
540 | 541 |
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o |
541 | 542 |
|
... | ... |
@@ -349,6 +349,7 @@ void avcodec_register_all(void) |
349 | 349 |
REGISTER_DECODER (LIBSPEEX, libspeex); |
350 | 350 |
REGISTER_ENCODER (LIBTHEORA, libtheora); |
351 | 351 |
REGISTER_ENCODER (LIBVORBIS, libvorbis); |
352 |
+ REGISTER_DECODER (LIBVPX, libvpx); |
|
352 | 353 |
REGISTER_ENCODER (LIBX264, libx264); |
353 | 354 |
REGISTER_ENCODER (LIBXVID, libxvid); |
354 | 355 |
|
... | ... |
@@ -30,8 +30,8 @@ |
30 | 30 |
#include "libavutil/avutil.h" |
31 | 31 |
|
32 | 32 |
#define LIBAVCODEC_VERSION_MAJOR 52 |
33 |
-#define LIBAVCODEC_VERSION_MINOR 68 |
|
34 |
-#define LIBAVCODEC_VERSION_MICRO 3 |
|
33 |
+#define LIBAVCODEC_VERSION_MINOR 69 |
|
34 |
+#define LIBAVCODEC_VERSION_MICRO 0 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
37 | 37 |
LIBAVCODEC_VERSION_MINOR, \ |
38 | 38 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,124 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2010, Google, Inc. |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * @file |
|
22 |
+ * VP8 decoder support via libvpx |
|
23 |
+ */ |
|
24 |
+ |
|
25 |
+#define VPX_CODEC_DISABLE_COMPAT 1 |
|
26 |
+#include <vpx_decoder.h> |
|
27 |
+#include <vp8dx.h> |
|
28 |
+ |
|
29 |
+#include "avcodec.h" |
|
30 |
+ |
|
31 |
+typedef struct VP8DecoderContext { |
|
32 |
+ struct vpx_codec_ctx decoder; |
|
33 |
+} VP8Context; |
|
34 |
+ |
|
35 |
+static av_cold int vp8_init(AVCodecContext *avctx) |
|
36 |
+{ |
|
37 |
+ VP8Context *ctx = avctx->priv_data; |
|
38 |
+ const struct vpx_codec_iface *iface = &vpx_codec_vp8_dx_algo; |
|
39 |
+ struct vpx_codec_dec_cfg deccfg = { |
|
40 |
+ /* token partitions+1 would be a decent choice */ |
|
41 |
+ .threads = FFMIN(avctx->thread_count, 16) |
|
42 |
+ }; |
|
43 |
+ |
|
44 |
+ av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); |
|
45 |
+ av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); |
|
46 |
+ |
|
47 |
+ if (vpx_codec_dec_init(&ctx->decoder, iface, &deccfg, 0) != VPX_CODEC_OK) { |
|
48 |
+ const char *error = vpx_codec_error(&ctx->decoder); |
|
49 |
+ av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n", |
|
50 |
+ error); |
|
51 |
+ return AVERROR(EINVAL); |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ avctx->pix_fmt = PIX_FMT_YUV420P; |
|
55 |
+ return 0; |
|
56 |
+} |
|
57 |
+ |
|
58 |
+static int vp8_decode(AVCodecContext *avctx, |
|
59 |
+ void *data, int *data_size, AVPacket *avpkt) |
|
60 |
+{ |
|
61 |
+ VP8Context *ctx = avctx->priv_data; |
|
62 |
+ AVFrame *picture = data; |
|
63 |
+ const void *iter = NULL; |
|
64 |
+ struct vpx_image *img; |
|
65 |
+ |
|
66 |
+ if (vpx_codec_decode(&ctx->decoder, avpkt->data, avpkt->size, NULL, 0) != |
|
67 |
+ VPX_CODEC_OK) { |
|
68 |
+ const char *error = vpx_codec_error(&ctx->decoder); |
|
69 |
+ const char *detail = vpx_codec_error_detail(&ctx->decoder); |
|
70 |
+ |
|
71 |
+ av_log(avctx, AV_LOG_ERROR, "Failed to decode frame: %s\n", error); |
|
72 |
+ if (detail) |
|
73 |
+ av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", |
|
74 |
+ detail); |
|
75 |
+ return AVERROR_INVALIDDATA; |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ if ((img = vpx_codec_get_frame(&ctx->decoder, &iter))) { |
|
79 |
+ if (img->fmt != VPX_IMG_FMT_I420) { |
|
80 |
+ av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d)\n", |
|
81 |
+ img->fmt); |
|
82 |
+ return AVERROR_INVALIDDATA; |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) { |
|
86 |
+ av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n", |
|
87 |
+ avctx->width, avctx->height, img->d_w, img->d_h); |
|
88 |
+ if (avcodec_check_dimensions(avctx, img->d_w, img->d_h)) |
|
89 |
+ return AVERROR_INVALIDDATA; |
|
90 |
+ avcodec_set_dimensions(avctx, img->d_w, img->d_h); |
|
91 |
+ } |
|
92 |
+ picture->data[0] = img->planes[0]; |
|
93 |
+ picture->data[1] = img->planes[1]; |
|
94 |
+ picture->data[2] = img->planes[2]; |
|
95 |
+ picture->data[3] = NULL; |
|
96 |
+ picture->linesize[0] = img->stride[0]; |
|
97 |
+ picture->linesize[1] = img->stride[1]; |
|
98 |
+ picture->linesize[2] = img->stride[2]; |
|
99 |
+ picture->linesize[3] = 0; |
|
100 |
+ *data_size = sizeof(AVPicture); |
|
101 |
+ } |
|
102 |
+ return avpkt->size; |
|
103 |
+} |
|
104 |
+ |
|
105 |
+static av_cold int vp8_free(AVCodecContext *avctx) |
|
106 |
+{ |
|
107 |
+ VP8Context *ctx = avctx->priv_data; |
|
108 |
+ vpx_codec_destroy(&ctx->decoder); |
|
109 |
+ return 0; |
|
110 |
+} |
|
111 |
+ |
|
112 |
+AVCodec libvpx_decoder = { |
|
113 |
+ "libvpx", |
|
114 |
+ AVMEDIA_TYPE_VIDEO, |
|
115 |
+ CODEC_ID_VP8, |
|
116 |
+ sizeof(VP8Context), |
|
117 |
+ vp8_init, |
|
118 |
+ NULL, /* encode */ |
|
119 |
+ vp8_free, |
|
120 |
+ vp8_decode, |
|
121 |
+ 0, /* capabilities */ |
|
122 |
+ .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), |
|
123 |
+}; |