Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1086)

Unified Diff: media/filters/vpx_video_decoder.cc

Issue 2247403002: Assign color spaces to video frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use static_assert Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/vpx_video_decoder.cc
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index 4f6e412381ad439158168687838ea7eb97439714..ca567b1165ccb4c89de9fc56d31820c0ef2ec5b2 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -585,6 +585,59 @@ bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer,
(*video_frame)
->metadata()
->SetInteger(VideoFrameMetadata::COLOR_SPACE, color_space);
+
+ gfx::ColorSpace::PrimaryID primaries =
+ gfx::ColorSpace::PrimaryID::UNSPECIFIED;
+ gfx::ColorSpace::TransferID transfer =
+ gfx::ColorSpace::TransferID::UNSPECIFIED;
+ gfx::ColorSpace::MatrixID matrix = gfx::ColorSpace::MatrixID::UNSPECIFIED;
+ gfx::ColorSpace::RangeID range = vpx_image->range == VPX_CR_FULL_RANGE
+ ? gfx::ColorSpace::RangeID::FULL
+ : gfx::ColorSpace::RangeID::LIMITED;
+
+ switch (vpx_image->cs) {
+ case VPX_CS_BT_601:
+ case VPX_CS_SMPTE_170:
+ primaries = gfx::ColorSpace::PrimaryID::SMPTE170M;
+ transfer = gfx::ColorSpace::TransferID::SMPTE170M;
+ matrix = gfx::ColorSpace::MatrixID::SMPTE170M;
+ break;
+ case VPX_CS_SMPTE_240:
+ primaries = gfx::ColorSpace::PrimaryID::SMPTE240M;
+ transfer = gfx::ColorSpace::TransferID::SMPTE240M;
+ matrix = gfx::ColorSpace::MatrixID::SMPTE240M;
+ break;
+ case VPX_CS_BT_709:
+ primaries = gfx::ColorSpace::PrimaryID::BT709;
+ transfer = gfx::ColorSpace::TransferID::BT709;
+ matrix = gfx::ColorSpace::MatrixID::BT709;
+ break;
+ case VPX_CS_BT_2020:
+ primaries = gfx::ColorSpace::PrimaryID::BT2020;
+ if (vpx_image->bit_depth >= 12) {
+ transfer = gfx::ColorSpace::TransferID::BT2020_12;
+ } else if (vpx_image->bit_depth >= 10) {
+ transfer = gfx::ColorSpace::TransferID::BT2020_10;
+ } else {
+ transfer = gfx::ColorSpace::TransferID::BT709;
+ }
+ matrix = gfx::ColorSpace::MatrixID::BT2020_NCL; // is this right?
+ break;
+ case VPX_CS_SRGB:
+ primaries = gfx::ColorSpace::PrimaryID::BT709;
+ transfer = gfx::ColorSpace::TransferID::IEC61966_2_1;
+ matrix = gfx::ColorSpace::MatrixID::BT709;
+ break;
+
+ default:
+ break;
+ }
+
+ if (primaries != gfx::ColorSpace::PrimaryID::UNSPECIFIED) {
+ (*video_frame)
+ ->set_color_space(gfx::ColorSpace(primaries, transfer, matrix, range));
+ }
+
return true;
}
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698