Only require -strict experimental if libvpx was built with
--enable-experimental .
---
libavcodec/Makefile | 8 +++----
libavcodec/libvpx_common.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/libvpx_common.h | 21 ++++++++++++++++++
libavcodec/libvpxdec.c | 7 +++++-
libavcodec/libvpxenc.c | 6 +++++-
5 files changed, 89 insertions(+), 6 deletions(-)
create mode 100644 libavcodec/libvpx_common.c
create mode 100644 libavcodec/libvpx_common.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 318ed7d..50d051a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -599,10 +599,10 @@ OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) +=
libvo-aacenc.o mpeg4audio.o
OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o \
vorbis_data.o vorbis_parser.o
-OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
-OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
-OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
-OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
+OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o libvpx_common.o
+OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o libvpx_common.o
+OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx_common.o
+OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx_common.o
OBJS-$(CONFIG_LIBWAVPACK_ENCODER) += libwavpackenc.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o
diff --git a/libavcodec/libvpx_common.c b/libavcodec/libvpx_common.c
new file mode 100644
index 0000000..3b62d6b
--- /dev/null
+++ b/libavcodec/libvpx_common.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, Google, Inc.
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <string.h>
+
+#include <vpx/vpx_codec.h>
+
+#include "avcodec.h"
+#include "libvpx_common.h"
+
+static int is_experimental(void)
+{
+ const char *enabled = "--enable-experimental";
+ const char *disabled = "--disable-experimental";
+ const char *conf = vpx_codec_build_config();
+
+ while (conf = strstr(conf, enabled)) {
+ conf = strstr(conf, disabled);
+ if (!conf)
+ return 1;
+ }
+
+ return 0;
+}
+
+int ff_vpx_check_experimental(AVCodecContext *avctx)
+{
+ if (is_experimental() &&
+ avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+ av_log(avctx, AV_LOG_ERROR,
+ "libvpx was built with --enable-experimental, "
+ "but libav is not being run with -strict experimental\n");
+ return AVERROR_EXPERIMENTAL;
+ }
+ return 0;
+}
diff --git a/libavcodec/libvpx_common.h b/libavcodec/libvpx_common.h
new file mode 100644
index 0000000..b465547
--- /dev/null
+++ b/libavcodec/libvpx_common.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2013, Google, Inc.
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+int ff_vpx_check_experimental(AVCodecContext *avctx);
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 237b0f6..6a7a2d8 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -31,6 +31,7 @@
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "internal.h"
+#include "libvpx_common.h"
typedef struct VP8DecoderContext {
struct vpx_codec_ctx decoder;
@@ -39,6 +40,7 @@ typedef struct VP8DecoderContext {
static av_cold int vpx_init(AVCodecContext *avctx,
const struct vpx_codec_iface *iface)
{
+ int ret;
VP8Context *ctx = avctx->priv_data;
struct vpx_codec_dec_cfg deccfg = {
/* token partitions+1 would be a decent choice */
@@ -48,6 +50,9 @@ static av_cold int vpx_init(AVCodecContext *avctx,
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
+ if ((ret = ff_vpx_check_experimental(avctx)) < 0)
+ return ret;
+
if (vpx_codec_dec_init(&ctx->decoder, iface, &deccfg, 0) != VPX_CODEC_OK) {
const char *error = vpx_codec_error(&ctx->decoder);
av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n",
@@ -143,7 +148,7 @@ AVCodec ff_libvpx_vp9_decoder = {
.init = vp9_init,
.close = vp8_free,
.decode = vp8_decode,
- .capabilities = CODEC_CAP_AUTO_THREADS | CODEC_CAP_EXPERIMENTAL,
+ .capabilities = CODEC_CAP_AUTO_THREADS,
.long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"),
};
#endif /* CONFIG_LIBVPX_VP9_DECODER */
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 0ecc2f9..eaf9f50 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -30,6 +30,7 @@
#include "avcodec.h"
#include "internal.h"
+#include "libvpx_common.h"
#include "libavutil/base64.h"
#include "libavutil/common.h"
#include "libavutil/mathematics.h"
@@ -224,6 +225,9 @@ static av_cold int vpx_init(AVCodecContext *avctx,
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
+ if ((res = ff_vpx_check_experimental(avctx)) < 0)
+ return res;
+
if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) !=
VPX_CODEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
vpx_codec_err_to_string(res));
@@ -623,7 +627,7 @@ AVCodec ff_libvpx_vp9_encoder = {
.init = vp9_init,
.encode2 = vp8_encode,
.close = vp8_free,
- .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS |
CODEC_CAP_EXPERIMENTAL,
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"),
.priv_class = &class_vp9,
--
1.8.3
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel