and strict_std_compliance is not FF_COMPLIANCE_EXPERIMENTAL.

This moves the check from avconv to avcodec_open2().
---
I am not sure of the correct wording of the error message. Telling the user
to set '-strict experimental' doesn't make much sense for a library user, but
telling the user to set 'strict_std_compliance == FF_COMPLIANCE_EXPERIMENTAL'
makes even less sense for avconv users.

 avconv.c           |   19 -------------------
 libavcodec/utils.c |   23 +++++++++++++++++++++++
 2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/avconv.c b/avconv.c
index 4d9c7c0..711f488 100644
--- a/avconv.c
+++ b/avconv.c
@@ -229,23 +229,6 @@ void assert_avoptions(AVDictionary *m)
     }
 }
 
-static void assert_codec_experimental(AVCodecContext *c, int encoder)
-{
-    const char *codec_string = encoder ? "encoder" : "decoder";
-    AVCodec *codec;
-    if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
-        c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
-        av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce 
bad "
-                "results.\nAdd '-strict experimental' if you want to use 
it.\n",
-                codec_string, c->codec->name);
-        codec = encoder ? avcodec_find_encoder(c->codec->id) : 
avcodec_find_decoder(c->codec->id);
-        if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL))
-            av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s 
'%s'.\n",
-                   codec_string, codec->name);
-        exit(1);
-    }
-}
-
 /*
  * Update the requested input sample format based on the output sample format.
  * This is currently only used to request float output from decoders which
@@ -1475,7 +1458,6 @@ static int init_input_stream(int ist_index, char *error, 
int error_len)
                     ist->file_index, ist->st->index);
             return AVERROR(EINVAL);
         }
-        assert_codec_experimental(ist->st->codec, 0);
         assert_avoptions(ist->opts);
     }
 
@@ -1814,7 +1796,6 @@ static int transcode_init(void)
                 ret = AVERROR(EINVAL);
                 goto dump_format;
             }
-            assert_codec_experimental(ost->st->codec, 1);
             assert_avoptions(ost->opts);
             if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
                 av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too 
low."
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 2b8940c..0f60d31 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -142,6 +142,26 @@ void avcodec_register(AVCodec *codec)
         codec->init_static_data(codec);
 }
 
+static int avcodec_experimental(AVCodecContext *avctx)
+{
+    const char *codec_string = av_codec_is_encoder(avctx->codec) ? "encoder"
+                                                                 : "decoder";
+    AVCodec *codec;
+    if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
+        avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+        av_log(avctx, AV_LOG_FATAL, "%s '%s' is experimental and might produce 
"
+                "bad results.\nAdd '-strict experimental' if you want to use 
it.\n",
+                codec_string, avctx->codec->name);
+        codec = av_codec_is_encoder(avctx->codec) ? 
avcodec_find_encoder(avctx->codec->id)
+                                                  : 
avcodec_find_decoder(avctx->codec->id);
+        if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL))
+            av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s 
'%s'.\n",
+                   codec_string, codec->name);
+        return AVERROR(EINVAL);
+    }
+    return 0;
+}
+
 unsigned avcodec_get_edge_width(void)
 {
     return EDGE_WIDTH;
@@ -778,6 +798,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
     }
     avctx->frame_number = 0;
 
+    if ((ret = avcodec_experimental(avctx)) < 0)
+        goto free_and_end;
+
     if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
         (!avctx->time_base.num || !avctx->time_base.den)) {
         avctx->time_base.num = 1;
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to