Skip to content

Commit 392dd46

Browse files
committed
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
1 parent c5b881d commit 392dd46

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,11 @@ void FFmpegVideoDecoder<LIBAV_VER>::InitHWDecoderIfAllowed() {
649649
}
650650
#endif // MOZ_USE_HWDECODE
651651

652+
static bool ShouldEnable8BitConversion(const struct AVCodec* aCodec) {
653+
return 0 == strncmp(aCodec->name, "libdav1d", 8) ||
654+
0 == strncmp(aCodec->name, "vp9", 3);
655+
}
656+
652657
RefPtr<MediaDataDecoder::InitPromise> FFmpegVideoDecoder<LIBAV_VER>::Init() {
653658
AUTO_PROFILER_LABEL("FFmpegVideoDecoder::Init", MEDIA_PLAYBACK);
654659
FFMPEG_LOG("FFmpegVideoDecoder, init, IsHardwareAccelerated=%d\n",
@@ -661,11 +666,9 @@ RefPtr<MediaDataDecoder::InitPromise> FFmpegVideoDecoder<LIBAV_VER>::Init() {
661666
if (NS_FAILED(rv)) {
662667
return InitPromise::CreateAndReject(rv, __func__);
663668
}
664-
// Enable 8-bit conversion only for dav1d.
665-
m8BitOutput =
666-
m8BitOutput && 0 == strncmp(mCodecContext->codec->name, "libdav1d", 8);
669+
m8BitOutput = m8BitOutput && ShouldEnable8BitConversion(mCodecContext->codec);
667670
if (m8BitOutput) {
668-
FFMPEG_LOG("Enable 8-bit output for dav1d");
671+
FFMPEG_LOG("Enable 8-bit output for %s", mCodecContext->codec->name);
669672
m8BitRecycleBin = MakeRefPtr<BufferRecycleBin>();
670673
}
671674
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
@@ -1686,6 +1689,11 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER>::CreateImage(
16861689
// that. If this shared memory buffer path also generated a
16871690
// MacIOSurfaceImage, then we could use it for HDR.
16881691
requiresCopy = (b.mColorDepth != gfx::ColorDepth::COLOR_8);
1692+
# endif
1693+
# ifdef MOZ_WIDGET_ANDROID
1694+
// Some Android devices can only render 8-bit images and cannot use high
1695+
// bit-depth decoded data directly.
1696+
requiresCopy = m8BitOutput && b.mColorDepth != gfx::ColorDepth::COLOR_8;
16891697
# endif
16901698
if (mIsUsingShmemBufferForDecode && *mIsUsingShmemBufferForDecode &&
16911699
!requiresCopy) {

0 commit comments

Comments
 (0)