diff options
author | Nathan Caldwell <saintdev@gmail.com> | 2012-10-18 22:58:25 -0600 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2012-10-21 23:03:26 +0200 |
commit | c854102da773fa898cc6dbc8ca474b1088ce5f12 (patch) | |
tree | babd340426cf4f8e658da03b18189088bd76d10d | |
parent | a893655bdaa726a82424367b6456d195be12ebbc (diff) | |
download | ffmpeg-c854102da773fa898cc6dbc8ca474b1088ce5f12.tar.gz |
avcodec: handle AVERROR_EXPERIMENTAL
Error out on init if a codec with CODEC_CAP_EXPERIMENTAL is requested
and strict_std_compliance is not FF_COMPLIANCE_EXPERIMENTAL.
Move the check from avconv to avcodec_open2() and return
AVERROR_EXPERIMENTAL accordingly.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | avconv.c | 36 | ||||
-rw-r--r-- | libavcodec/utils.c | 6 |
2 files changed, 23 insertions, 19 deletions
@@ -229,21 +229,18 @@ void assert_avoptions(AVDictionary *m) } } -static void assert_codec_experimental(AVCodecContext *c, int encoder) +static void abort_codec_experimental(AVCodec *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); - } + 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->name); + codec = encoder ? avcodec_find_encoder(c->id) : avcodec_find_decoder(c->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); } /* @@ -1442,7 +1439,7 @@ static void print_sdp(void) static int init_input_stream(int ist_index, char *error, int error_len) { - int i; + int i, ret; InputStream *ist = input_streams[ist_index]; if (ist->decoding_needed) { AVCodec *codec = ist->dec; @@ -1470,12 +1467,13 @@ static int init_input_stream(int ist_index, char *error, int error_len) if (!av_dict_get(ist->opts, "threads", NULL, 0)) av_dict_set(&ist->opts, "threads", "auto", 0); - if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { + if ((ret = avcodec_open2(ist->st->codec, codec, &ist->opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 0); snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d", ist->file_index, ist->st->index); - return AVERROR(EINVAL); + return ret; } - assert_codec_experimental(ist->st->codec, 0); assert_avoptions(ist->opts); } @@ -1808,13 +1806,13 @@ static int transcode_init(void) } if (!av_dict_get(ost->opts, "threads", NULL, 0)) av_dict_set(&ost->opts, "threads", "auto", 0); - if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { + if ((ret = avcodec_open2(ost->st->codec, codec, &ost->opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 1); snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); - 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 cbe527e5b3..5e22b9f6cf 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -778,6 +778,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } avctx->frame_number = 0; + if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL && + avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + ret = AVERROR_EXPERIMENTAL; + goto free_and_end; + } + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && (!avctx->time_base.num || !avctx->time_base.den)) { avctx->time_base.num = 1; |