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

Side by Side Diff: media/blink/skcanvas_video_renderer.cc

Issue 1236313002: Use skia to do accelerated YUV conversion for rec709 'HD' color space in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/blink/skcanvas_video_renderer.h" 5 #include "media/blink/skcanvas_video_renderer.h"
6 6
7 #include "gpu/GLES2/gl2extchromium.h" 7 #include "gpu/GLES2/gl2extchromium.h"
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "gpu/command_buffer/common/mailbox_holder.h" 9 #include "gpu/command_buffer/common/mailbox_holder.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 GrBackendObject handles[3] = { 147 GrBackendObject handles[3] = {
148 source_textures[0], source_textures[1], source_textures[2]}; 148 source_textures[0], source_textures[1], source_textures[2]};
149 149
150 SkISize yuvSizes[] = { 150 SkISize yuvSizes[] = {
151 {ya_tex_size.width(), ya_tex_size.height()}, 151 {ya_tex_size.width(), ya_tex_size.height()},
152 {uv_tex_size.width(), uv_tex_size.height()}, 152 {uv_tex_size.width(), uv_tex_size.height()},
153 {uv_tex_size.width(), uv_tex_size.height()}, 153 {uv_tex_size.width(), uv_tex_size.height()},
154 }; 154 };
155 155
156 // TODO(dcastagna): Skia currently doesn't support Rec709 YUV conversion.
157 DCHECK(!CheckColorSpace(video_frame, media::COLOR_SPACE_HD_REC709));
158 SkYUVColorSpace color_space = kRec601_SkYUVColorSpace; 156 SkYUVColorSpace color_space = kRec601_SkYUVColorSpace;
159 if (CheckColorSpace(video_frame, media::COLOR_SPACE_JPEG)) 157 if (CheckColorSpace(video_frame, media::COLOR_SPACE_JPEG))
160 color_space = kJPEG_SkYUVColorSpace; 158 color_space = kJPEG_SkYUVColorSpace;
159 else if (CheckColorSpace(video_frame, media::COLOR_SPACE_HD_REC709))
160 color_space = kRec709_SkYUVColorSpace;
161 161
162 SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context, 162 SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context,
163 color_space, handles, yuvSizes, 163 color_space, handles, yuvSizes,
164 kTopLeft_GrSurfaceOrigin); 164 kTopLeft_GrSurfaceOrigin);
165 DCHECK(img); 165 DCHECK(img);
166 gl->DeleteTextures(3, source_textures); 166 gl->DeleteTextures(3, source_textures);
167 SyncPointClientImpl client(gl); 167 SyncPointClientImpl client(gl);
168 video_frame->UpdateReleaseSyncPoint(&client); 168 video_frame->UpdateReleaseSyncPoint(&client);
169 return make_scoped_ptr(img); 169 return make_scoped_ptr(img);
170 } 170 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels( 225 SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels(
226 frame_, pixels, row_bytes); 226 frame_, pixels, row_bytes);
227 return kSuccess; 227 return kSuccess;
228 } 228 }
229 229
230 bool onGetYUV8Planes(SkISize sizes[3], 230 bool onGetYUV8Planes(SkISize sizes[3],
231 void* planes[3], 231 void* planes[3],
232 size_t row_bytes[3], 232 size_t row_bytes[3],
233 SkYUVColorSpace* color_space) override { 233 SkYUVColorSpace* color_space) override {
234 if (!frame_.get() || !media::IsYuvPlanar(frame_->format()) || 234 if (!frame_.get() || !media::IsYuvPlanar(frame_->format()) ||
235 // TODO(rileya): Skia currently doesn't support Rec709 YUV conversion, 235 // TODO(rileya): Skia currently doesn't support YUVA conversion. Remove
236 // or YUVA conversion. Remove this case once it does. As-is we will 236 // this case once it does. As-is we will fall back on the pure-software
237 // fall back on the pure-software path in this case. 237 // path in this case.
238 CheckColorSpace(frame_, COLOR_SPACE_HD_REC709) ||
239 frame_->format() == PIXEL_FORMAT_YV12A) { 238 frame_->format() == PIXEL_FORMAT_YV12A) {
240 return false; 239 return false;
241 } 240 }
242 241
243 if (color_space) { 242 if (color_space) {
244 if (CheckColorSpace(frame_, COLOR_SPACE_JPEG)) 243 if (CheckColorSpace(frame_, COLOR_SPACE_JPEG))
245 *color_space = kJPEG_SkYUVColorSpace; 244 *color_space = kJPEG_SkYUVColorSpace;
245 else if (CheckColorSpace(frame_, COLOR_SPACE_HD_REC709))
246 *color_space = kRec709_SkYUVColorSpace;
246 else 247 else
247 *color_space = kRec601_SkYUVColorSpace; 248 *color_space = kRec601_SkYUVColorSpace;
248 } 249 }
249 250
250 for (int plane = VideoFrame::kYPlane; plane <= VideoFrame::kVPlane; 251 for (int plane = VideoFrame::kYPlane; plane <= VideoFrame::kVPlane;
251 ++plane) { 252 ++plane) {
252 if (sizes) { 253 if (sizes) {
253 const gfx::Size size = 254 const gfx::Size size =
254 VideoFrame::PlaneSize(frame_->format(), plane, 255 VideoFrame::PlaneSize(frame_->format(), plane,
255 gfx::Size(frame_->visible_rect().width(), 256 gfx::Size(frame_->visible_rect().width(),
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 674 }
674 675
675 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { 676 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() {
676 accelerated_last_image_.reset(); 677 accelerated_last_image_.reset();
677 accelerated_last_frame_.reset(); 678 accelerated_last_frame_.reset();
678 accelerated_generator_ = nullptr; 679 accelerated_generator_ = nullptr;
679 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); 680 accelerated_last_frame_timestamp_ = media::kNoTimestamp();
680 } 681 }
681 682
682 } // namespace media 683 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698