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

Unified Diff: chrome/renderer/media/video_renderer_impl.cc

Issue 113890: Chrome renderer support for YV16. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/media/video_renderer_impl.cc
===================================================================
--- chrome/renderer/media/video_renderer_impl.cc (revision 16872)
+++ chrome/renderer/media/video_renderer_impl.cc (working copy)
@@ -109,12 +109,14 @@
last_converted_timestamp_ = timestamp;
media::VideoSurface frame_in;
if (video_frame->Lock(&frame_in)) {
- // TODO(hclam): Support more video formats than just YV12.
- DCHECK(frame_in.format == media::VideoSurface::YV12);
+ DCHECK(frame_in.format == media::VideoSurface::YV12 ||
+ frame_in.format == media::VideoSurface::YV16);
DCHECK(frame_in.strides[media::VideoSurface::kUPlane] ==
frame_in.strides[media::VideoSurface::kVPlane]);
DCHECK(frame_in.planes == media::VideoSurface::kNumYUVPlanes);
bitmap_.lockPixels();
+ media::YUVType yuv_type = (frame_in.format == media::VideoSurface::YV12) ?
+ media::YV12 : media::YV16;
media::ConvertYUVToRGB32(frame_in.data[media::VideoSurface::kYPlane],
frame_in.data[media::VideoSurface::kUPlane],
frame_in.data[media::VideoSurface::kVPlane],
@@ -124,7 +126,7 @@
frame_in.strides[media::VideoSurface::kYPlane],
frame_in.strides[media::VideoSurface::kUPlane],
bitmap_.rowBytes(),
- media::YV12);
+ yuv_type);
bitmap_.unlockPixels();
video_frame->Unlock();
} else {
@@ -151,12 +153,15 @@
const gfx::Rect& dest_rect) {
media::VideoSurface frame_in;
if (video_frame->Lock(&frame_in)) {
- // TODO(hclam): Support more video formats than just YV12.
- DCHECK(frame_in.format == media::VideoSurface::YV12);
+ DCHECK(frame_in.format == media::VideoSurface::YV12 ||
+ frame_in.format == media::VideoSurface::YV16);
DCHECK(frame_in.strides[media::VideoSurface::kUPlane] ==
frame_in.strides[media::VideoSurface::kVPlane]);
DCHECK(frame_in.planes == media::VideoSurface::kNumYUVPlanes);
const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(true);
+ media::YUVType yuv_type = (frame_in.format == media::VideoSurface::YV12) ?
scherkus (not reviewing) 2009/05/28 01:35:15 we really should consider consolidating these two
fbarchard 2009/05/28 02:23:32 it does stand out as weird. My longer term plan is
+ media::YV12 : media::YV16;
+ int y_shift = yuv_type; // 1 for YV12, 0 for YV16.
// Create a rectangle backed by SkScalar.
SkRect scalar_dest_rect;
@@ -216,11 +221,11 @@
// in Y, U and V planes.
size_t y_offset = frame_in.strides[media::VideoSurface::kYPlane] *
frame_clip_top + frame_clip_left;
- // Since the format is YV12, there is one U, V value per 2x2 block, thus
- // the math here.
- // TODO(hclam): handle formats other than YV12.
- size_t uv_offset = frame_in.strides[media::VideoSurface::kUPlane] *
- (frame_clip_top / 2) + frame_clip_left / 2;
+ // For format YV12, there is one U, V value per 2x2 block.
+ // For format YV16, there is one u, V value per 2x1 block.
+ size_t uv_offset = (frame_in.strides[media::VideoSurface::kUPlane] *
+ (frame_clip_top >> y_shift)) +
+ (frame_clip_left >> 1);
uint8* frame_clip_y = frame_in.data[media::VideoSurface::kYPlane] +
y_offset;
uint8* frame_clip_u = frame_in.data[media::VideoSurface::kUPlane] +
@@ -228,6 +233,7 @@
uint8* frame_clip_v = frame_in.data[media::VideoSurface::kVPlane] +
uv_offset;
bitmap.lockPixels();
+
// TODO(hclam): do rotation and mirroring here.
media::ScaleYUVToRGB32(frame_clip_y,
frame_clip_u,
@@ -240,7 +246,7 @@
frame_in.strides[media::VideoSurface::kYPlane],
frame_in.strides[media::VideoSurface::kUPlane],
bitmap.rowBytes(),
- media::YV12,
+ yuv_type,
media::ROTATE_0);
bitmap.unlockPixels();
}
« 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