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