From c92ac86da61c33f752b680c6a7e199faf547df13 Mon Sep 17 00:00:00 2001 From: Vignesh Venkat Date: Thu, 3 Oct 2024 14:13:38 -0700 Subject: [PATCH] mediacodec: Do not prefer hardware if profile != 0 PiperOrigin-RevId: 682026600 --- src/codecs/android_mediacodec.rs | 4 +++- src/parser/mp4box.rs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/codecs/android_mediacodec.rs b/src/codecs/android_mediacodec.rs index b7f2090..2b8ebdf 100644 --- a/src/codecs/android_mediacodec.rs +++ b/src/codecs/android_mediacodec.rs @@ -227,7 +227,9 @@ fn prefer_hw(config: &DecoderConfig) -> bool { // 2) category is not Alpha. We do not prefer hardware for decoding the alpha plane since // they generally tend to be monochrome images and using hardware for that is // unreliable. - prefer_hw && config.category != Category::Alpha + // 3) profile is 0. As of Sep 2024, there are no AV1 hardware decoders that support + // anything other than profile 0. + prefer_hw && config.category != Category::Alpha && config.codec_config.profile() == 0; } fn get_codec_initializers(config: &DecoderConfig) -> Vec { diff --git a/src/parser/mp4box.rs b/src/parser/mp4box.rs index b59749a..1ff2bb3 100644 --- a/src/parser/mp4box.rs +++ b/src/parser/mp4box.rs @@ -165,6 +165,12 @@ impl CodecConfiguration { Self::Av1(config) => &config.raw_data, } } + + pub fn profile(&self) -> u8 { + match self { + Self::Av1(config) => config.seq_profile, + } + } } #[derive(Clone, Debug, Default)]