OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/video_color_space.h" | 5 #include "media/base/video_color_space.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 VideoColorSpace::PrimaryID VideoColorSpace::GetPrimaryID(int primary) { | 9 VideoColorSpace::PrimaryID VideoColorSpace::GetPrimaryID(int primary) { |
10 if (primary < 1 || primary > 22 || primary == 3) | 10 if (primary < 1 || primary > 22 || primary == 3) |
(...skipping 23 matching lines...) Expand all Loading... |
34 gfx::ColorSpace::RangeID range) | 34 gfx::ColorSpace::RangeID range) |
35 : primaries(primaries), transfer(transfer), matrix(matrix), range(range) {} | 35 : primaries(primaries), transfer(transfer), matrix(matrix), range(range) {} |
36 | 36 |
37 VideoColorSpace::VideoColorSpace(int primaries, | 37 VideoColorSpace::VideoColorSpace(int primaries, |
38 int transfer, | 38 int transfer, |
39 int matrix, | 39 int matrix, |
40 gfx::ColorSpace::RangeID range) | 40 gfx::ColorSpace::RangeID range) |
41 : primaries(GetPrimaryID(primaries)), | 41 : primaries(GetPrimaryID(primaries)), |
42 transfer(GetTransferID(transfer)), | 42 transfer(GetTransferID(transfer)), |
43 matrix(GetMatrixID(matrix)), | 43 matrix(GetMatrixID(matrix)), |
44 range(range) {} | 44 range(range) { |
| 45 primaries_union.primaries = GetPrimaryID(primaries); |
| 46 transfer_union.transfer = GetTransferID(transfer); |
| 47 matrix_union.matrix = GetMatrixID(matrix); |
| 48 } |
45 | 49 |
46 bool VideoColorSpace::operator==(const VideoColorSpace& other) const { | 50 bool VideoColorSpace::operator==(const VideoColorSpace& other) const { |
47 return primaries == other.primaries && transfer == other.transfer && | 51 return primaries == other.primaries && transfer == other.transfer && |
48 matrix == other.matrix && range == other.range; | 52 matrix == other.matrix && range == other.range; |
49 } | 53 } |
50 | 54 |
51 bool VideoColorSpace::operator!=(const VideoColorSpace& other) const { | 55 bool VideoColorSpace::operator!=(const VideoColorSpace& other) const { |
52 return primaries != other.primaries || transfer != other.transfer || | 56 return primaries != other.primaries || transfer != other.transfer || |
53 matrix != other.matrix || range != other.range; | 57 matrix != other.matrix || range != other.range; |
54 } | 58 } |
55 | 59 |
56 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const { | 60 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const { |
57 // TODO(hubbe): Make this type-safe. | 61 return gfx::ColorSpace::CreateVideo(primaries_union.primary_id, |
58 return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries), | 62 transfer_union.transfer_id, |
59 static_cast<int>(transfer), | 63 matrix_union.matrix_id, range); |
60 static_cast<int>(matrix), range); | |
61 } | 64 } |
62 | 65 |
63 VideoColorSpace VideoColorSpace::REC709() { | 66 VideoColorSpace VideoColorSpace::REC709() { |
64 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, | 67 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, |
65 gfx::ColorSpace::RangeID::LIMITED); | 68 gfx::ColorSpace::RangeID::LIMITED); |
66 } | 69 } |
67 VideoColorSpace VideoColorSpace::REC601() { | 70 VideoColorSpace VideoColorSpace::REC601() { |
68 return VideoColorSpace(PrimaryID::SMPTE170M, TransferID::SMPTE170M, | 71 return VideoColorSpace(PrimaryID::SMPTE170M, TransferID::SMPTE170M, |
69 MatrixID::SMPTE170M, | 72 MatrixID::SMPTE170M, |
70 gfx::ColorSpace::RangeID::LIMITED); | 73 gfx::ColorSpace::RangeID::LIMITED); |
71 } | 74 } |
72 VideoColorSpace VideoColorSpace::JPEG() { | 75 VideoColorSpace VideoColorSpace::JPEG() { |
73 // TODO(ccameron): Determine which primaries and transfer function were | 76 // TODO(ccameron): Determine which primaries and transfer function were |
74 // intended here. | 77 // intended here. |
75 return VideoColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, | 78 return VideoColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, |
76 MatrixID::SMPTE170M, gfx::ColorSpace::RangeID::FULL); | 79 MatrixID::SMPTE170M, gfx::ColorSpace::RangeID::FULL); |
77 } | 80 } |
78 | 81 |
79 } // namespace | 82 } // namespace |
OLD | NEW |