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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « media/base/video_color_space.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/video_color_space.h"
6
7 namespace media {
8
9 VideoColorSpace::PrimaryID VideoColorSpace::GetPrimaryID(int primary) {
10 if (primary < 1 || primary > 22 || primary == 3)
11 return PrimaryID::INVALID;
12 if (primary > 12 && primary < 22)
13 return PrimaryID::INVALID;
14 return static_cast<PrimaryID>(primary);
15 }
16
17 VideoColorSpace::TransferID VideoColorSpace::GetTransferID(int transfer) {
18 if (transfer < 1 || transfer > 18 || transfer == 3)
19 return TransferID::INVALID;
20 return static_cast<TransferID>(transfer);
21 }
22
23 VideoColorSpace::MatrixID VideoColorSpace::GetMatrixID(int matrix) {
24 if (matrix < 0 || matrix > 11 || matrix == 3)
25 return MatrixID::INVALID;
26 return static_cast<MatrixID>(matrix);
27 }
28
29 VideoColorSpace::VideoColorSpace() {}
30
31 VideoColorSpace::VideoColorSpace(PrimaryID primaries,
32 TransferID transfer,
33 MatrixID matrix,
34 gfx::ColorSpace::RangeID range)
35 : primaries(primaries), transfer(transfer), matrix(matrix), range(range) {}
36
37 VideoColorSpace::VideoColorSpace(int primaries,
38 int transfer,
39 int matrix,
40 gfx::ColorSpace::RangeID range)
41 : primaries(GetPrimaryID(primaries)),
42 transfer(GetTransferID(transfer)),
43 matrix(GetMatrixID(matrix)),
44 range(range) {}
45
46 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const {
47 // TODO(hubbe): Make this type-safe.
48 return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries),
49 static_cast<int>(transfer),
50 static_cast<int>(matrix), range);
51 }
52
53 VideoColorSpace VideoColorSpace::BT709() {
54 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709,
55 gfx::ColorSpace::RangeID::LIMITED);
56 }
57
58 } // namespace
OLDNEW
« 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