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

Unified Diff: media/base/video_color_space.cc

Issue 2742113002: Gate support for certain EOTFs/primaries/matrices on color management / hdr flags (Closed)
Patch Set: missed updating some tests Created 3 years, 9 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/base/video_color_space.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_color_space.cc
diff --git a/media/base/video_color_space.cc b/media/base/video_color_space.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0501ec4e12cd6b86e8e5f82aa25b12096f676dfd
--- /dev/null
+++ b/media/base/video_color_space.cc
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/video_color_space.h"
+
+namespace media {
+
+VideoColorSpace::PrimaryID VideoColorSpace::GetPrimaryID(int primary) {
+ if (primary < 1 || primary > 22 || primary == 3)
+ return PrimaryID::INVALID;
+ if (primary > 12 && primary < 22)
+ return PrimaryID::INVALID;
+ return static_cast<PrimaryID>(primary);
+}
+
+VideoColorSpace::TransferID VideoColorSpace::GetTransferID(int transfer) {
+ if (transfer < 1 || transfer > 18 || transfer == 3)
+ return TransferID::INVALID;
+ return static_cast<TransferID>(transfer);
+}
+
+VideoColorSpace::MatrixID VideoColorSpace::GetMatrixID(int matrix) {
+ if (matrix < 0 || matrix > 11 || matrix == 3)
+ return MatrixID::INVALID;
+ return static_cast<MatrixID>(matrix);
+}
+
+VideoColorSpace::VideoColorSpace() {}
+
+VideoColorSpace::VideoColorSpace(PrimaryID primaries,
+ TransferID transfer,
+ MatrixID matrix,
+ gfx::ColorSpace::RangeID range)
+ : primaries(primaries), transfer(transfer), matrix(matrix), range(range) {}
+
+VideoColorSpace::VideoColorSpace(int primaries,
+ int transfer,
+ int matrix,
+ gfx::ColorSpace::RangeID range)
+ : primaries(GetPrimaryID(primaries)),
+ transfer(GetTransferID(transfer)),
+ matrix(GetMatrixID(matrix)),
+ range(range) {}
+
+gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const {
+ // TODO(hubbe): Make this type-safe.
+ return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries),
+ static_cast<int>(transfer),
+ static_cast<int>(matrix), range);
+}
+
+VideoColorSpace VideoColorSpace::BT709() {
+ return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709,
+ gfx::ColorSpace::RangeID::LIMITED);
+}
+
+} // namespace
« no previous file with comments | « media/base/video_color_space.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698