Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: content/renderer/media/render_media_client.cc

Issue 2742113002: Gate support for certain EOTFs/primaries/matrices on color management / hdr flags (Closed)
Patch Set: missed updating some tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/render_media_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/media/render_media_client.h" 5 #include "content/renderer/media/render_media_client.h"
6 6
7 #include "base/command_line.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/time/default_tick_clock.h" 9 #include "base/time/default_tick_clock.h"
9 #include "content/public/common/content_client.h" 10 #include "content/public/common/content_client.h"
10 #include "content/public/renderer/content_renderer_client.h" 11 #include "content/public/renderer/content_renderer_client.h"
12 #include "media/base/media_switches.h"
13 #include "media/base/video_color_space.h"
14 #include "ui/base/ui_base_switches.h"
11 15
12 namespace content { 16 namespace content {
13 17
14 void RenderMediaClient::Initialize() { 18 void RenderMediaClient::Initialize() {
15 GetInstance(); 19 GetInstance();
16 } 20 }
17 21
18 RenderMediaClient::RenderMediaClient() 22 RenderMediaClient::RenderMediaClient()
19 : has_updated_(false), 23 : has_updated_(false),
20 is_update_needed_(true), 24 is_update_needed_(true),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #else 86 #else
83 is_update_needed_ = false; 87 is_update_needed_ = false;
84 #endif 88 #endif
85 } 89 }
86 90
87 void RenderMediaClient::RecordRapporURL(const std::string& metric, 91 void RenderMediaClient::RecordRapporURL(const std::string& metric,
88 const GURL& url) { 92 const GURL& url) {
89 GetContentClient()->renderer()->RecordRapporURL(metric, url); 93 GetContentClient()->renderer()->RecordRapporURL(metric, url);
90 } 94 }
91 95
92 bool IsTransferFunctionSupported(gfx::ColorSpace::TransferID eotf) { 96 bool IsColorSpaceSupported(const media::VideoColorSpace& color_space) {
93 switch (eotf) { 97 bool color_management =
98 base::CommandLine::ForCurrentProcess()->HasSwitch(
99 switches::kEnableHDROutput) ||
100 base::FeatureList::IsEnabled(media::kVideoColorManagement);
101 switch (color_space.primaries) {
102 case media::VideoColorSpace::PrimaryID::EBU_3213_E:
103 case media::VideoColorSpace::PrimaryID::INVALID:
104 return false;
105
94 // Transfers supported without color management. 106 // Transfers supported without color management.
95 case gfx::ColorSpace::TransferID::GAMMA22: 107 case media::VideoColorSpace::PrimaryID::BT709:
96 case gfx::ColorSpace::TransferID::BT709: 108 case media::VideoColorSpace::PrimaryID::UNSPECIFIED:
97 case gfx::ColorSpace::TransferID::SMPTE170M: 109 case media::VideoColorSpace::PrimaryID::BT470M:
98 case gfx::ColorSpace::TransferID::BT2020_10: 110 case media::VideoColorSpace::PrimaryID::BT470BG:
99 case gfx::ColorSpace::TransferID::BT2020_12: 111 case media::VideoColorSpace::PrimaryID::SMPTE170M:
100 case gfx::ColorSpace::TransferID::IEC61966_2_1: 112 break;
101 return true; 113
102 default: 114 // Supported with color management.
103 // TODO(hubbe): wire up support for HDR transfers. 115 case media::VideoColorSpace::PrimaryID::SMPTE240M:
116 case media::VideoColorSpace::PrimaryID::FILM:
117 case media::VideoColorSpace::PrimaryID::BT2020:
118 case media::VideoColorSpace::PrimaryID::SMPTEST428_1:
119 case media::VideoColorSpace::PrimaryID::SMPTEST431_2:
120 case media::VideoColorSpace::PrimaryID::SMPTEST432_1:
121 if (!color_management)
122 return false;
123 break;
124 }
125
126 switch (color_space.transfer) {
127 // Transfers supported without color management.
128 case media::VideoColorSpace::TransferID::UNSPECIFIED:
129 case media::VideoColorSpace::TransferID::GAMMA22:
130 case media::VideoColorSpace::TransferID::BT709:
131 case media::VideoColorSpace::TransferID::SMPTE170M:
132 case media::VideoColorSpace::TransferID::BT2020_10:
133 case media::VideoColorSpace::TransferID::BT2020_12:
134 case media::VideoColorSpace::TransferID::IEC61966_2_1:
135 break;
136
137 // Supported with color management.
138 case media::VideoColorSpace::TransferID::GAMMA28:
139 case media::VideoColorSpace::TransferID::SMPTE240M:
140 case media::VideoColorSpace::TransferID::LINEAR:
141 case media::VideoColorSpace::TransferID::LOG:
142 case media::VideoColorSpace::TransferID::LOG_SQRT:
143 case media::VideoColorSpace::TransferID::BT1361_ECG:
144 case media::VideoColorSpace::TransferID::SMPTEST2084:
145 case media::VideoColorSpace::TransferID::IEC61966_2_4:
146 case media::VideoColorSpace::TransferID::SMPTEST428_1:
147 case media::VideoColorSpace::TransferID::ARIB_STD_B67:
148 if (!color_management)
149 return false;
150 break;
151
152 // Never supported.
153 case media::VideoColorSpace::TransferID::INVALID:
104 return false; 154 return false;
105 } 155 }
156
157 switch (color_space.matrix) {
158 // Supported without color management.
159 case media::VideoColorSpace::MatrixID::BT709:
160 case media::VideoColorSpace::MatrixID::UNSPECIFIED:
161 case media::VideoColorSpace::MatrixID::BT470BG:
162 case media::VideoColorSpace::MatrixID::SMPTE170M:
163 case media::VideoColorSpace::MatrixID::BT2020_NCL:
164 break;
165
166 // Supported with color management.
167 case media::VideoColorSpace::MatrixID::RGB:
168 case media::VideoColorSpace::MatrixID::FCC:
169 case media::VideoColorSpace::MatrixID::SMPTE240M:
170 case media::VideoColorSpace::MatrixID::YCOCG:
171 case media::VideoColorSpace::MatrixID::YDZDX:
172 case media::VideoColorSpace::MatrixID::BT2020_CL:
173 if (!color_management)
174 return false;
175 break;
176
177 // Never supported.
178 case media::VideoColorSpace::MatrixID::INVALID:
179 return false;
180 }
181
182 if (color_space.range == gfx::ColorSpace::RangeID::INVALID)
183 return false;
184
185 return true;
106 } 186 }
107 187
108 bool RenderMediaClient::IsSupportedVideoConfig( 188 bool RenderMediaClient::IsSupportedVideoConfig(
109 const media::VideoConfig& config) { 189 const media::VideoConfig& config) {
110 // TODO(chcunningham): Query decoders for codec profile support. 190 // TODO(chcunningham): Query decoders for codec profile support.
111 switch (config.codec) { 191 switch (config.codec) {
112 case media::kCodecVP9: 192 case media::kCodecVP9:
113 // Color management required for HDR to not look terrible. 193 // Color management required for HDR to not look terrible.
114 return IsTransferFunctionSupported(config.eotf); 194 return IsColorSpaceSupported(config.color_space);
115 195
116 case media::kCodecH264: 196 case media::kCodecH264:
117 case media::kCodecVP8: 197 case media::kCodecVP8:
118 case media::kCodecTheora: 198 case media::kCodecTheora:
119 return true; 199 return true;
120 200
121 case media::kUnknownVideoCodec: 201 case media::kUnknownVideoCodec:
122 case media::kCodecVC1: 202 case media::kCodecVC1:
123 case media::kCodecMPEG2: 203 case media::kCodecMPEG2:
124 case media::kCodecMPEG4: 204 case media::kCodecMPEG4:
(...skipping 11 matching lines...) Expand all
136 tick_clock_.swap(tick_clock); 216 tick_clock_.swap(tick_clock);
137 } 217 }
138 218
139 // static 219 // static
140 RenderMediaClient* RenderMediaClient::GetInstance() { 220 RenderMediaClient* RenderMediaClient::GetInstance() {
141 static RenderMediaClient* client = new RenderMediaClient(); 221 static RenderMediaClient* client = new RenderMediaClient();
142 return client; 222 return client;
143 } 223 }
144 224
145 } // namespace content 225 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/render_media_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698