Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 return primaries == other.primaries && transfer == other.transfer && | 47 return primaries == other.primaries && transfer == other.transfer && |
| 48 matrix == other.matrix && range == other.range; | 48 matrix == other.matrix && range == other.range; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool VideoColorSpace::operator!=(const VideoColorSpace& other) const { | 51 bool VideoColorSpace::operator!=(const VideoColorSpace& other) const { |
| 52 return primaries != other.primaries || transfer != other.transfer || | 52 return primaries != other.primaries || transfer != other.transfer || |
| 53 matrix != other.matrix || range != other.range; | 53 matrix != other.matrix || range != other.range; |
| 54 } | 54 } |
| 55 | 55 |
| 56 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const { | 56 gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const { |
| 57 // TODO(hubbe): Make this type-safe. | 57 gfx::ColorSpace::PrimaryID primary_id; |
| 58 return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries), | 58 gfx::ColorSpace::TransferID transfer_id; |
|
hubbe
2017/05/02 17:15:44
We should remove the CreateVideo() function from g
Uzair
2017/05/03 08:35:39
Removed CreateVideo() function from gfx::ColorSpac
| |
| 59 static_cast<int>(transfer), | 59 gfx::ColorSpace::MatrixID matrix_id; |
| 60 static_cast<int>(matrix), range); | 60 |
| 61 switch (primaries) { | |
| 62 default: | |
|
hubbe
2017/05/02 17:15:44
remove default in all of these switch statements.
Uzair
2017/05/03 08:35:39
Done.
| |
| 63 case PrimaryID::INVALID: | |
| 64 case PrimaryID::BT709: | |
| 65 case PrimaryID::UNSPECIFIED: | |
| 66 primary_id = gfx::ColorSpace::PrimaryID::BT709; | |
| 67 break; | |
| 68 case PrimaryID::BT470M: | |
| 69 primary_id = gfx::ColorSpace::PrimaryID::BT470M; | |
| 70 break; | |
| 71 case PrimaryID::BT470BG: | |
| 72 primary_id = gfx::ColorSpace::PrimaryID::BT470BG; | |
| 73 break; | |
| 74 case PrimaryID::SMPTE170M: | |
| 75 primary_id = gfx::ColorSpace::PrimaryID::SMPTE170M; | |
| 76 break; | |
| 77 case PrimaryID::SMPTE240M: | |
| 78 primary_id = gfx::ColorSpace::PrimaryID::SMPTE240M; | |
| 79 break; | |
| 80 case PrimaryID::FILM: | |
| 81 primary_id = gfx::ColorSpace::PrimaryID::FILM; | |
| 82 break; | |
| 83 case PrimaryID::BT2020: | |
| 84 primary_id = gfx::ColorSpace::PrimaryID::BT2020; | |
| 85 break; | |
| 86 case PrimaryID::SMPTEST428_1: | |
| 87 primary_id = gfx::ColorSpace::PrimaryID::SMPTEST428_1; | |
| 88 break; | |
| 89 case PrimaryID::SMPTEST431_2: | |
| 90 primary_id = gfx::ColorSpace::PrimaryID::SMPTEST431_2; | |
| 91 break; | |
| 92 case PrimaryID::SMPTEST432_1: | |
| 93 primary_id = gfx::ColorSpace::PrimaryID::SMPTEST432_1; | |
| 94 break; | |
| 95 } | |
| 96 | |
| 97 switch (transfer) { | |
| 98 default: | |
| 99 case TransferID::INVALID: | |
| 100 case TransferID::BT709: | |
| 101 case TransferID::UNSPECIFIED: | |
| 102 transfer_id = gfx::ColorSpace::TransferID::BT709; | |
| 103 break; | |
| 104 case TransferID::GAMMA22: | |
| 105 transfer_id = gfx::ColorSpace::TransferID::GAMMA22; | |
| 106 break; | |
| 107 case TransferID::GAMMA28: | |
| 108 transfer_id = gfx::ColorSpace::TransferID::GAMMA28; | |
| 109 break; | |
| 110 case TransferID::SMPTE170M: | |
| 111 transfer_id = gfx::ColorSpace::TransferID::SMPTE170M; | |
| 112 break; | |
| 113 case TransferID::SMPTE240M: | |
| 114 transfer_id = gfx::ColorSpace::TransferID::SMPTE240M; | |
| 115 break; | |
| 116 case TransferID::LINEAR: | |
| 117 transfer_id = gfx::ColorSpace::TransferID::LINEAR; | |
| 118 break; | |
| 119 case TransferID::LOG: | |
| 120 transfer_id = gfx::ColorSpace::TransferID::LOG; | |
| 121 break; | |
| 122 case TransferID::LOG_SQRT: | |
| 123 transfer_id = gfx::ColorSpace::TransferID::LOG_SQRT; | |
| 124 break; | |
| 125 case TransferID::IEC61966_2_4: | |
| 126 transfer_id = gfx::ColorSpace::TransferID::IEC61966_2_4; | |
| 127 break; | |
| 128 case TransferID::BT1361_ECG: | |
| 129 transfer_id = gfx::ColorSpace::TransferID::BT1361_ECG; | |
| 130 break; | |
| 131 case TransferID::IEC61966_2_1: | |
| 132 transfer_id = gfx::ColorSpace::TransferID::IEC61966_2_1; | |
| 133 break; | |
| 134 case TransferID::BT2020_10: | |
| 135 transfer_id = gfx::ColorSpace::TransferID::BT2020_10; | |
| 136 break; | |
| 137 case TransferID::BT2020_12: | |
| 138 transfer_id = gfx::ColorSpace::TransferID::BT2020_12; | |
| 139 break; | |
| 140 case TransferID::SMPTEST2084: | |
| 141 transfer_id = gfx::ColorSpace::TransferID::SMPTEST2084; | |
| 142 break; | |
| 143 case TransferID::SMPTEST428_1: | |
| 144 transfer_id = gfx::ColorSpace::TransferID::SMPTEST428_1; | |
| 145 break; | |
| 146 case TransferID::ARIB_STD_B67: | |
| 147 transfer_id = gfx::ColorSpace::TransferID::ARIB_STD_B67; | |
| 148 break; | |
| 149 } | |
| 150 | |
| 151 switch (matrix) { | |
| 152 case MatrixID::RGB: | |
| 153 matrix_id = gfx::ColorSpace::MatrixID::RGB; | |
| 154 break; | |
| 155 default: | |
| 156 case MatrixID::BT709: | |
| 157 case MatrixID::UNSPECIFIED: | |
| 158 matrix_id = gfx::ColorSpace::MatrixID::BT709; | |
| 159 break; | |
| 160 case MatrixID::FCC: | |
| 161 matrix_id = gfx::ColorSpace::MatrixID::FCC; | |
| 162 break; | |
| 163 case MatrixID::BT470BG: | |
| 164 matrix_id = gfx::ColorSpace::MatrixID::BT470BG; | |
| 165 break; | |
| 166 case MatrixID::SMPTE170M: | |
| 167 matrix_id = gfx::ColorSpace::MatrixID::SMPTE170M; | |
| 168 break; | |
| 169 case MatrixID::SMPTE240M: | |
| 170 matrix_id = gfx::ColorSpace::MatrixID::SMPTE240M; | |
| 171 break; | |
| 172 case MatrixID::YCOCG: | |
| 173 matrix_id = gfx::ColorSpace::MatrixID::YCOCG; | |
| 174 break; | |
| 175 case MatrixID::BT2020_NCL: | |
| 176 matrix_id = gfx::ColorSpace::MatrixID::BT2020_NCL; | |
| 177 break; | |
| 178 case MatrixID::BT2020_CL: | |
| 179 matrix_id = gfx::ColorSpace::MatrixID::BT2020_CL; | |
| 180 break; | |
| 181 case MatrixID::YDZDX: | |
| 182 matrix_id = gfx::ColorSpace::MatrixID::YDZDX; | |
| 183 break; | |
| 184 } | |
| 185 | |
| 186 return gfx::ColorSpace(primary_id, transfer_id, matrix_id, range); | |
| 61 } | 187 } |
| 62 | 188 |
| 63 VideoColorSpace VideoColorSpace::REC709() { | 189 VideoColorSpace VideoColorSpace::REC709() { |
| 64 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, | 190 return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, |
| 65 gfx::ColorSpace::RangeID::LIMITED); | 191 gfx::ColorSpace::RangeID::LIMITED); |
| 66 } | 192 } |
| 67 VideoColorSpace VideoColorSpace::REC601() { | 193 VideoColorSpace VideoColorSpace::REC601() { |
| 68 return VideoColorSpace(PrimaryID::SMPTE170M, TransferID::SMPTE170M, | 194 return VideoColorSpace(PrimaryID::SMPTE170M, TransferID::SMPTE170M, |
| 69 MatrixID::SMPTE170M, | 195 MatrixID::SMPTE170M, |
| 70 gfx::ColorSpace::RangeID::LIMITED); | 196 gfx::ColorSpace::RangeID::LIMITED); |
| 71 } | 197 } |
| 72 VideoColorSpace VideoColorSpace::JPEG() { | 198 VideoColorSpace VideoColorSpace::JPEG() { |
| 73 // TODO(ccameron): Determine which primaries and transfer function were | 199 // TODO(ccameron): Determine which primaries and transfer function were |
| 74 // intended here. | 200 // intended here. |
| 75 return VideoColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, | 201 return VideoColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, |
| 76 MatrixID::SMPTE170M, gfx::ColorSpace::RangeID::FULL); | 202 MatrixID::SMPTE170M, gfx::ColorSpace::RangeID::FULL); |
| 77 } | 203 } |
| 78 | 204 |
| 79 } // namespace | 205 } // namespace |
| OLD | NEW |