mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-14 04:54:54 +08:00
avcodec/avcodec: Perform sub_charenc/iconv checks before AVCodec.init()
Also move them to ff_decode_preinit(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
@@ -2031,6 +2031,41 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
avctx->codec->max_lowres);
|
||||
avctx->lowres = avctx->codec->max_lowres;
|
||||
}
|
||||
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");
|
||||
return AVERROR(EINVAL);
|
||||
} 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);
|
||||
return ret;
|
||||
}
|
||||
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");
|
||||
return AVERROR(ENOSYS);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
avctx->pts_correction_num_faulty_pts =
|
||||
avctx->pts_correction_num_faulty_dts = 0;
|
||||
|
Reference in New Issue
Block a user