tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 392dd465ebf109f7284a1c6d6f93cf238efffa66
parent c5b881d899c73a248142c21669bc9edc7cdd1c9a
Author: John Lin <jolin@mozilla.com>
Date:   Mon, 10 Nov 2025 19:55:37 +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:
Mdom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp | 16++++++++++++----
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*>(