[vlc-devel] [PATCH 4/4] mediacodec: disable HW acceleration for profiles Hi10P and higher

Martin Storsjö martin at martin.st
Sun Feb 9 22:10:55 CET 2014


On Sun, 9 Feb 2014, Martin Storsjö wrote:

> On Sun, 9 Feb 2014, Felix Abecassis wrote:
>
>> ---
>> modules/codec/omxil/android_mediacodec.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>> 
>> diff --git a/modules/codec/omxil/android_mediacodec.c 
>> b/modules/codec/omxil/android_mediacodec.c
>> index 4857f49..8c4953f 100644
>> --- a/modules/codec/omxil/android_mediacodec.c
>> +++ b/modules/codec/omxil/android_mediacodec.c
>> @@ -223,6 +223,16 @@ static int OpenDecoder(vlc_object_t *p_this)
>>         msg_Dbg(p_dec, "codec %d not supported", p_dec->fmt_in.i_codec);
>>         return VLC_EGENERIC;
>>     }
>> +
>> +    if (p_dec->fmt_in.i_codec == VLC_CODEC_H264) {
>> +	size_t i_profile = 0xFFFF;
>> +	h264_get_profile_level(&p_dec->fmt_in, &i_profile, NULL, NULL);
>> +	if (i_profile >= 110) {
>> +	    msg_Err(p_dec, "H.264 profile is too high or unknown. Disabling 
>> Hardware Acceleration.");
>> +	    return VLC_EGENERIC;
>> +	}
>> +    }
>
> Hmm, I'm not sure if it's good to error out for the unknown cases. Do we have 
> the extradata available here e.g. if playing back a TS stream? If not, we 
> would always abort even though things would actually play back just fine.

Also, I forgot to mention - while this probably is a good idea at the 
moment, we can't assume blindly that there never will be any HW decoders 
capable of Hi10P. As mentioned at fosdem, it might be good to at least try 
checking MediaCodecInfo.CodecCapabilities.profileLevels. I'm not sure how 
reliable these are, but before hardcoding too much it might at least make 
sense to try to look at it.

(Note, in Android 4.3 there's a nice method MediaCodec.getCodecInfo(), 
added by yours truly, but before that you need to remember to store the 
MediaInfo from when you iterate through MediaCodecList - if you used 
MediaCodec.createDecoderByType() there was no way to get the 
MediaCodecInfo for this codec, prior to adding getCodecInfo() in 4.3.)

// Martin


More information about the vlc-devel mailing list