commit b34e51f3b751e0547d5e20fadcd6c7fda79d98dc
parent d738f8c352cccb0418238cef0adc98a1c890ac0a
Author: John Lin <jolin@mozilla.com>
Date: Tue, 11 Nov 2025 23:41:24 +0000
Bug 1997997 - add VP9 8-bit output conversion to FFmpegVideoDecoder. r=media-playback-reviewers,alwu
Some Android GPUs doesn't support 10/12/16-bit image and need conversion
from the decoder. It's not added to VPXDecoder because only I420/I44 are
supported there.
Differential Revision: https://phabricator.services.mozilla.com/D271671
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -649,6 +649,11 @@ void FFmpegVideoDecoder<LIBAV_VER>::InitHWDecoderIfAllowed() {
}
#endif // MOZ_USE_HWDECODE
+static bool ShouldEnable8BitConversion(const struct AVCodec* aCodec) {
+ return 0 == strncmp(aCodec->name, "libdav1d", 8) ||
+ 0 == strncmp(aCodec->name, "vp9", 3);
+}
+
RefPtr<MediaDataDecoder::InitPromise> FFmpegVideoDecoder<LIBAV_VER>::Init() {
AUTO_PROFILER_LABEL("FFmpegVideoDecoder::Init", MEDIA_PLAYBACK);
FFMPEG_LOG("FFmpegVideoDecoder, init, IsHardwareAccelerated=%d\n",
@@ -661,11 +666,9 @@ RefPtr<MediaDataDecoder::InitPromise> FFmpegVideoDecoder<LIBAV_VER>::Init() {
if (NS_FAILED(rv)) {
return InitPromise::CreateAndReject(rv, __func__);
}
- // Enable 8-bit conversion only for dav1d.
- m8BitOutput =
- m8BitOutput && 0 == strncmp(mCodecContext->codec->name, "libdav1d", 8);
+ m8BitOutput = m8BitOutput && ShouldEnable8BitConversion(mCodecContext->codec);
if (m8BitOutput) {
- FFMPEG_LOG("Enable 8-bit output for dav1d");
+ FFMPEG_LOG("Enable 8-bit output for %s", mCodecContext->codec->name);
m8BitRecycleBin = MakeRefPtr<BufferRecycleBin>();
}
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
@@ -1687,6 +1690,11 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER>::CreateImage(
// MacIOSurfaceImage, then we could use it for HDR.
requiresCopy = (b.mColorDepth != gfx::ColorDepth::COLOR_8);
# endif
+# ifdef MOZ_WIDGET_ANDROID
+ // Some Android devices can only render 8-bit images and cannot use high
+ // bit-depth decoded data directly.
+ requiresCopy = m8BitOutput && b.mColorDepth != gfx::ColorDepth::COLOR_8;
+# endif
if (mIsUsingShmemBufferForDecode && *mIsUsingShmemBufferForDecode &&
!requiresCopy) {
RefPtr<ImageBufferWrapper> wrapper = static_cast<ImageBufferWrapper*>(