From e452abc5c2441356d1aa22ffcd8a9183aa1fac33 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Thu, 2 Jun 2016 10:42:25 +0200 Subject: lavc/mediacodec: refactor ff_AMediaCodecList_getCodecByType Allows to select a codec (encoder or decoder) only if it supports a specific profile. Adds ff_AMediaCodecProfile_getProfileFromAVCodecContext to convert an AVCodecContext profile to a MediaCodec profile. It only supports H264 for now. The codepath using MediaCodecList.findDecoderForFormat() (Android >= 5.0) has been dropped as this method does not allow to select a decoder compatible with a specific profile. --- libavcodec/mediacodecdec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libavcodec/mediacodecdec.c') diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 676ade73a1..0b08f02089 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -308,10 +308,16 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, { int ret = 0; int status; + int profile; s->first_buffer_at = av_gettime(); - s->codec_name = ff_AMediaCodecList_getCodecNameByType(mime, avctx); + profile = ff_AMediaCodecProfile_getProfileFromAVCodecContext(avctx); + if (profile < 0) { + av_log(avctx, AV_LOG_WARNING, "Unsupported or unknown profile"); + } + + s->codec_name = ff_AMediaCodecList_getCodecNameByType(mime, profile, 0, avctx); if (!s->codec_name) { ret = AVERROR_EXTERNAL; goto fail; -- cgit v1.2.3