From e3156fa7c2b85e9b8d1dfe6a92b0920624c0e65c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 16 Mar 2021 19:27:42 +0100 Subject: avcodec/avcodec: Perform sub_charenc/iconv checks before AVCodec.init() Also move them to ff_decode_preinit(). Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'libavcodec/avcodec.c') diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 1e40e2298b..13fe3d4ebf 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -36,9 +36,6 @@ #include "frame_thread_encoder.h" #include "internal.h" #include "thread.h" -#if CONFIG_ICONV -# include -#endif #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; @@ -385,43 +382,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code ret = AVERROR(EINVAL); goto free_and_end; } - if (avctx->sub_charenc) { - if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) { - av_log(avctx, AV_LOG_ERROR, "Character encoding is only " - "supported with subtitles codecs\n"); - ret = AVERROR(EINVAL); - goto free_and_end; - } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) { - av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, " - "subtitles character encoding will be ignored\n", - avctx->codec_descriptor->name); - avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_DO_NOTHING; - } else { - /* input character encoding is set for a text based subtitle - * codec at this point */ - if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_AUTOMATIC) - avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_PRE_DECODER; - - if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_PRE_DECODER) { -#if CONFIG_ICONV - iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc); - if (cd == (iconv_t)-1) { - ret = AVERROR(errno); - av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context " - "with input character encoding \"%s\"\n", avctx->sub_charenc); - goto free_and_end; - } - iconv_close(cd); -#else - av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles " - "conversion needs a libavcodec built with iconv support " - "for this codec\n"); - ret = AVERROR(ENOSYS); - goto free_and_end; -#endif - } - } - } #if FF_API_AVCTX_TIMEBASE if (avctx->framerate.num > 0 && avctx->framerate.den > 0) -- cgit v1.2.3