summaryrefslogtreecommitdiff
path: root/dom/media
diff options
context:
space:
mode:
authoru3shit <u3shit@gmail.com>2023-02-24 19:52:57 +0100
committeru3shit <u3shit@gmail.com>2023-02-26 13:04:53 +0100
commitf6e1f851d006bad808486d5f27449192cdd78513 (patch)
tree1dafe948aa69a9bb84d15652093db4848aecdfe1 /dom/media
parent98fef024cd7c2865f4fdaf11149a48178b802eaf (diff)
downloaduxp-f6e1f851d006bad808486d5f27449192cdd78513.tar.gz
Issue #2118 - Part 2: Add support for Identity YUVColorSpace
https://hg.mozilla.org/mozilla-central/rev/be342c90755d11551623362f2058c0326f63bbb3
Diffstat (limited to 'dom/media')
-rw-r--r--dom/media/platforms/agnostic/AOMDecoder.cpp15
-rw-r--r--dom/media/platforms/agnostic/VPXDecoder.cpp16
-rw-r--r--dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp10
3 files changed, 40 insertions, 1 deletions
diff --git a/dom/media/platforms/agnostic/AOMDecoder.cpp b/dom/media/platforms/agnostic/AOMDecoder.cpp
index b5d21375e7..693b98c949 100644
--- a/dom/media/platforms/agnostic/AOMDecoder.cpp
+++ b/dom/media/platforms/agnostic/AOMDecoder.cpp
@@ -232,6 +232,21 @@ AOMDecoder::DoDecode(MediaRawData* aSample)
RESULT_DETAIL("AOM Unknown image format"));
}
+ switch (img->mc) {
+ case AOM_CICP_MC_BT_601:
+ b.mYUVColorSpace = YUVColorSpace::BT601;
+ break;
+ case AOM_CICP_MC_BT_709:
+ b.mYUVColorSpace = YUVColorSpace::BT709;
+ break;
+ case AOM_CICP_MC_IDENTITY:
+ b.mYUVColorSpace = YUVColorSpace::IDENTITY;
+ break;
+ default:
+ LOG("Unhandled colorspace %d", img->mc);
+ break;
+ }
+
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,
mImageContainer,
diff --git a/dom/media/platforms/agnostic/VPXDecoder.cpp b/dom/media/platforms/agnostic/VPXDecoder.cpp
index f06f6e08b1..ebc85c9e51 100644
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -158,6 +158,22 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
RESULT_DETAIL("VPX Unknown image format"));
}
+ b.mYUVColorSpace = [&]() {
+ switch (img->cs) {
+ case VPX_CS_BT_601:
+ case VPX_CS_SMPTE_170:
+ case VPX_CS_SMPTE_240:
+ return YUVColorSpace::BT601;
+ case VPX_CS_BT_709:
+ return YUVColorSpace::BT709;
+ case VPX_CS_SRGB:
+ return YUVColorSpace::IDENTITY;
+ default:
+ LOG("Unhandled colorspace %d", img->cs);
+ return YUVColorSpace::BT601;
+ }
+ }();
+
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,
mImageContainer,
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
index 731e7c74cf..f76ca0f843 100644
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -24,6 +24,7 @@
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
+#define AV_PIX_FMT_GBRP PIX_FMT_GBRP
#define AV_PIX_FMT_NONE PIX_FMT_NONE
#endif
@@ -54,6 +55,9 @@ ChoosePixelFormat(AVCodecContext* aCodecContext, const AVPixelFormat* aFormats)
case AV_PIX_FMT_YUVJ420P:
FFMPEG_LOG("Requesting pixel format YUVJ420P.");
return AV_PIX_FMT_YUVJ420P;
+ case AV_PIX_FMT_GBRP:
+ FFMPEG_LOG("Requesting pixel format GBRP.");
+ return AV_PIX_FMT_GBRP;
default:
break;
}
@@ -361,7 +365,8 @@ FFmpegVideoDecoder<LIBAV_VER>::CreateImage(int64_t aOffset, int64_t aPts,
b.mPlanes[0].mWidth = mFrame->width;
b.mPlanes[0].mHeight = mFrame->height;
- if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P) {
+ if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P ||
+ mCodecContext->pix_fmt == AV_PIX_FMT_GBRP) {
b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = mFrame->width;
b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = mFrame->height;
} else {
@@ -377,6 +382,9 @@ FFmpegVideoDecoder<LIBAV_VER>::CreateImage(int64_t aOffset, int64_t aPts,
case AVCOL_SPC_BT470BG:
b.mYUVColorSpace = YUVColorSpace::BT601;
break;
+ case AVCOL_SPC_RGB:
+ b.mYUVColorSpace = YUVColorSpace::IDENTITY;
+ break;
default:
break;
}