| 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 25 matching lines...) Expand all Loading... |
| 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 | 45 |
| 46 bool VideoColorSpace::operator==(const VideoColorSpace& other) const { |
| 47 return primaries == other.primaries && transfer == other.transfer && |
| 48 matrix == other.matrix && range == other.range; |
| 49 } |
| 50 |
| 51 bool VideoColorSpace::operator!=(const VideoColorSpace& other) const { |
| 52 return primaries != other.primaries || transfer != other.transfer || |
| 53 matrix != other.matrix || range != other.range; |
| 54 } |
| 55 |
| 46 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const { | 56 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const { |
| 47 // TODO(hubbe): Make this type-safe. | 57 // TODO(hubbe): Make this type-safe. |
| 48 return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries), | 58 return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries), |
| 49 static_cast<int>(transfer), | 59 static_cast<int>(transfer), |
| 50 static_cast<int>(matrix), range); | 60 static_cast<int>(matrix), range); |
| 51 } | 61 } |
| 52 | 62 |
| 53 VideoColorSpace VideoColorSpace::BT709() { | 63 VideoColorSpace VideoColorSpace::REC709() { |
| 54 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, | 64 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, |
| 55 gfx::ColorSpace::RangeID::LIMITED); | 65 gfx::ColorSpace::RangeID::LIMITED); |
| 56 } | 66 } |
| 67 VideoColorSpace VideoColorSpace::REC601() { |
| 68 return VideoColorSpace(PrimaryID::SMPTE170M, TransferID::SMPTE170M, |
| 69 MatrixID::SMPTE170M, |
| 70 gfx::ColorSpace::RangeID::LIMITED); |
| 71 } |
| 72 VideoColorSpace VideoColorSpace::JPEG() { |
| 73 // TODO(ccameron): Determine which primaries and transfer function were |
| 74 // intended here. |
| 75 return VideoColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, |
| 76 MatrixID::SMPTE170M, gfx::ColorSpace::RangeID::FULL); |
| 77 } |
| 57 | 78 |
| 58 } // namespace | 79 } // namespace |
| OLD | NEW |