diff options
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index f7367143c3..bed15bc7d8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -886,15 +886,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) goto free_and_end; - if (codec->capabilities & CODEC_CAP_EXPERIMENTAL) - if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { - av_log(avctx, AV_LOG_ERROR, - "Codec %s is experimental but experimental codecs are not enabled, try -strict %d\n", - codec->name, FF_COMPLIANCE_EXPERIMENTAL); - ret = -1; - goto free_and_end; - } - //We only call avcodec_set_dimensions() for non h264 codecs so as not to overwrite previously setup dimensions if (!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == AV_CODEC_ID_H264)){ @@ -937,6 +928,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code avctx->frame_number = 0; avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id); + if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL && + avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + av_log(avctx, AV_LOG_ERROR, + "Codec %s is experimental but experimental codecs are not enabled, try -strict %d\n", + codec->name, 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; @@ -1961,13 +1961,14 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) } } -AVCodec *avcodec_find_encoder(enum AVCodecID id) +static AVCodec *find_encdec(enum AVCodecID id, int encoder) { AVCodec *p, *experimental = NULL; p = first_avcodec; id= remap_deprecated_codec_id(id); while (p) { - if (av_codec_is_encoder(p) && p->id == id) { + if ((encoder ? av_codec_is_encoder(p) : av_codec_is_decoder(p)) && + p->id == id) { if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { experimental = p; } else @@ -1978,6 +1979,11 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id) return experimental; } +AVCodec *avcodec_find_encoder(enum AVCodecID id) +{ + return find_encdec(id, 1); +} + AVCodec *avcodec_find_encoder_by_name(const char *name) { AVCodec *p; @@ -1994,19 +2000,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name) AVCodec *avcodec_find_decoder(enum AVCodecID id) { - AVCodec *p, *experimental=NULL; - p = first_avcodec; - id= remap_deprecated_codec_id(id); - while (p) { - if (av_codec_is_decoder(p) && p->id == id) { - if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { - experimental = p; - } else - return p; - } - p = p->next; - } - return experimental; + return find_encdec(id, 0); } AVCodec *avcodec_find_decoder_by_name(const char *name) |