diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2022-10-17 01:07:27 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2022-11-21 23:53:04 +0800 |
commit | 040567965edc176ef36eff717222b0b315e075e1 (patch) | |
tree | c92e7c910368bfe0e0bf69ab149432e4b7bdad76 /libavcodec/mediacodecdec_common.c | |
parent | 4df9cb918eb645d3690a5209212be7f0471e35eb (diff) | |
download | ffmpeg-040567965edc176ef36eff717222b0b315e075e1.tar.gz |
avcodec/mediacodecdec: enable NDK mediacodec
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavcodec/mediacodecdec_common.c')
-rw-r--r-- | libavcodec/mediacodecdec_common.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 4a9e50b0df..ae82efaa0a 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -608,12 +608,27 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, s->codec_name = ff_AMediaCodecList_getCodecNameByType(mime, profile, 0, avctx); if (!s->codec_name) { - ret = AVERROR_EXTERNAL; - goto fail; + // getCodecNameByType() can fail due to missing JVM, while NDK + // mediacodec can be used without JVM. + if (!s->use_ndk_codec) { + ret = AVERROR_EXTERNAL; + goto fail; + } + av_log(avctx, AV_LOG_INFO, "Failed to getCodecNameByType\n"); + } else { + av_log(avctx, AV_LOG_DEBUG, "Found decoder %s\n", s->codec_name); } - av_log(avctx, AV_LOG_DEBUG, "Found decoder %s\n", s->codec_name); - s->codec = ff_AMediaCodec_createCodecByName(s->codec_name, 0); + if (s->codec_name) + s->codec = ff_AMediaCodec_createCodecByName(s->codec_name, s->use_ndk_codec); + else { + s->codec = ff_AMediaCodec_createDecoderByType(mime, s->use_ndk_codec); + if (s->codec) { + s->codec_name = ff_AMediaCodec_getName(s->codec); + if (!s->codec_name) + s->codec_name = av_strdup(mime); + } + } if (!s->codec) { av_log(avctx, AV_LOG_ERROR, "Failed to create media decoder for type %s and name %s\n", mime, s->codec_name); ret = AVERROR_EXTERNAL; |