OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/color_space_win.h" | 5 #include "ui/gfx/color_space_win.h" |
6 | 6 |
7 namespace gfx { | 7 namespace gfx { |
8 | 8 |
9 DXVA2_ExtendedFormat ColorSpaceWin::GetExtendedFormat( | 9 DXVA2_ExtendedFormat ColorSpaceWin::GetExtendedFormat( |
10 const ColorSpace& color_space) { | 10 const ColorSpace& color_space) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 case gfx::ColorSpace::TransferID::GAMMA24: | 127 case gfx::ColorSpace::TransferID::GAMMA24: |
128 case gfx::ColorSpace::TransferID::SMPTEST2084_NON_HDR: | 128 case gfx::ColorSpace::TransferID::SMPTEST2084_NON_HDR: |
129 case gfx::ColorSpace::TransferID::CUSTOM: | 129 case gfx::ColorSpace::TransferID::CUSTOM: |
130 // Not handled | 130 // Not handled |
131 break; | 131 break; |
132 } | 132 } |
133 | 133 |
134 return format; | 134 return format; |
135 } | 135 } |
136 | 136 |
137 DXGI_COLOR_SPACE_TYPE ColorSpaceWin::GetDXGIColorSpace( | |
138 const ColorSpace& color_space) { | |
139 if (color_space.matrix_ == gfx::ColorSpace::MatrixID::RGB) { | |
140 // For RGB, we default to FULL | |
141 if (color_space.range_ == gfx::ColorSpace::RangeID::LIMITED) { | |
142 if (color_space.primaries_ == gfx::ColorSpace::PrimaryID::BT2020) { | |
143 if (color_space.transfer_ == gfx::ColorSpace::TransferID::SMPTEST2084) { | |
144 return DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020; | |
145 } else { | |
146 return DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020; | |
147 } | |
148 } else { | |
149 return DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709; | |
150 } | |
151 } else { | |
152 if (color_space.primaries_ == gfx::ColorSpace::PrimaryID::BT2020) { | |
153 if (color_space.transfer_ == gfx::ColorSpace::TransferID::SMPTEST2084) { | |
154 return DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020; | |
155 } else { | |
156 return DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020; | |
157 } | |
158 } else { | |
159 if (color_space.transfer_ == gfx::ColorSpace::TransferID::LINEAR) { | |
160 return DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709; | |
161 } else { | |
162 return DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; | |
163 } | |
164 } | |
165 } | |
166 } else { | |
167 if (color_space.primaries_ == gfx::ColorSpace::PrimaryID::BT2020) { | |
168 if (color_space.transfer_ == gfx::ColorSpace::TransferID::SMPTEST2084) { | |
169 return DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020; | |
170 // Could also be: | |
171 // DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020 | |
172 } else { | |
173 // For YUV, we default to LIMITED | |
174 if (color_space.range_ == gfx::ColorSpace::RangeID::FULL) { | |
175 return DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020; | |
176 | |
177 } else { | |
178 return DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020; | |
179 // Could also be: | |
180 // DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020 | |
181 } | |
182 } | |
183 } else if (color_space.primaries_ == gfx::ColorSpace::PrimaryID::BT470BG || | |
184 color_space.primaries_ == | |
185 gfx::ColorSpace::PrimaryID::SMPTE170M) { | |
186 // For YUV, we default to LIMITED | |
187 if (color_space.range_ == gfx::ColorSpace::RangeID::FULL) { | |
188 return DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601; | |
189 } else { | |
190 return DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601; | |
191 } | |
192 } else { | |
193 // For YUV, we default to LIMITED | |
194 if (color_space.range_ == gfx::ColorSpace::RangeID::FULL) { | |
195 // TODO(hubbe): Check if this is correct. | |
196 if (color_space.transfer_ == gfx::ColorSpace::TransferID::SMPTE170M) { | |
197 return DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601; | |
198 } else { | |
199 return DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709; | |
200 } | |
201 } else { | |
202 return DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709; | |
203 } | |
204 } | |
205 } | |
206 } | |
207 | |
208 D3D11_VIDEO_PROCESSOR_COLOR_SPACE ColorSpaceWin::GetD3D11ColorSpace( | |
209 const ColorSpace& color_space) { | |
210 D3D11_VIDEO_PROCESSOR_COLOR_SPACE ret = {0}; | |
211 if (color_space.range_ != gfx::ColorSpace::RangeID::FULL) { | |
212 ret.RGB_Range = 1; | |
213 ret.Nominal_Range = D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_0_255; | |
214 } else { | |
215 ret.Nominal_Range = D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_16_235; | |
216 } | |
217 switch (color_space.transfer_) { | |
218 case gfx::ColorSpace::TransferID::BT709: | |
219 case gfx::ColorSpace::TransferID::SMPTE170M: | |
220 ret.YCbCr_Matrix = 1; | |
221 | |
222 default: | |
223 break; | |
224 } | |
225 return ret; | |
226 } | |
227 | |
228 } // namespace gfx | 137 } // namespace gfx |
OLD | NEW |