[FFmpeg-devel] [PATCH] avcodec/libvpx: set CODEC_CAP_EXPERIMENTAL correctly instead of testing at codec open time

Michael Niedermayer michaelni at gmx.at
Sun Dec 8 14:19:09 CET 2013


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/libvpx.c    |   13 ++++---------
 libavcodec/libvpx.h    |    2 +-
 libavcodec/libvpxdec.c |    4 +---
 libavcodec/libvpxenc.c |    4 +---
 4 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/libavcodec/libvpx.c b/libavcodec/libvpx.c
index 9ff2e91..5d29893 100644
--- a/libavcodec/libvpx.c
+++ b/libavcodec/libvpx.c
@@ -22,14 +22,9 @@
 
 #include "libvpx.h"
 
-int ff_vp9_check_experimental(AVCodecContext *avctx)
+av_cold void ff_vp9_init_static(AVCodec *codec)
 {
-    if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
-        (vpx_codec_version_major() < 1 ||
-         (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Non-experimental support of VP9 requires libvpx >= 1.3.0\n");
-        return AVERROR_EXPERIMENTAL;
-    }
-    return 0;
+    if (    vpx_codec_version_major() < 1
+        || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
+        codec->capabilities |= CODEC_CAP_EXPERIMENTAL;
 }
diff --git a/libavcodec/libvpx.h b/libavcodec/libvpx.h
index 2c901f9..36a275c 100644
--- a/libavcodec/libvpx.h
+++ b/libavcodec/libvpx.h
@@ -23,6 +23,6 @@
 
 #include "avcodec.h"
 
-int ff_vp9_check_experimental(AVCodecContext *avctx);
+void ff_vp9_init_static(AVCodec *codec);
 
 #endif /* AVCODEC_LIBVPX_H */
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 8d608c3..94e1e4d 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -133,9 +133,6 @@ AVCodec ff_libvpx_vp8_decoder = {
 #if CONFIG_LIBVPX_VP9_DECODER
 static av_cold int vp9_init(AVCodecContext *avctx)
 {
-    int ret;
-    if ((ret = ff_vp9_check_experimental(avctx)))
-        return ret;
     return vpx_init(avctx, &vpx_codec_vp9_dx_algo);
 }
 
@@ -149,5 +146,6 @@ AVCodec ff_libvpx_vp9_decoder = {
     .close          = vp8_free,
     .decode         = vp8_decode,
     .capabilities   = CODEC_CAP_AUTO_THREADS | CODEC_CAP_DR1,
+    .init_static_data = ff_vp9_init_static,
 };
 #endif /* CONFIG_LIBVPX_VP9_DECODER */
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 8883801..197d84f 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -850,9 +850,6 @@ AVCodec ff_libvpx_vp8_encoder = {
 #if CONFIG_LIBVPX_VP9_ENCODER
 static av_cold int vp9_init(AVCodecContext *avctx)
 {
-    int ret;
-    if ((ret = ff_vp9_check_experimental(avctx)))
-        return ret;
     return vpx_init(avctx, &vpx_codec_vp9_cx_algo);
 }
 
@@ -876,5 +873,6 @@ AVCodec ff_libvpx_vp9_encoder = {
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
     .priv_class     = &class_vp9,
     .defaults       = defaults,
+    .init_static_data = ff_vp9_init_static,
 };
 #endif /* CONFIG_LIBVPX_VP9_ENCODER */
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list