summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 20:16:36 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 20:16:36 +0000
commitb10b847afa383deba1d0da676c8fbebc5b6e6ab9 (patch)
tree29fe272d9a579b953a9c03f4f8c47dda0e35db1d /chrome
parente8e5ad19a0031aafebba26c17a12ec465ce12ffe (diff)
downloadchromium_src-b10b847afa383deba1d0da676c8fbebc5b6e6ab9.zip
chromium_src-b10b847afa383deba1d0da676c8fbebc5b6e6ab9.tar.gz
chromium_src-b10b847afa383deba1d0da676c8fbebc5b6e6ab9.tar.bz2
Chrome renderer support for YV16.
Review URL: http://codereview.chromium.org/113890 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/renderer/media/video_renderer_impl.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/chrome/renderer/media/video_renderer_impl.cc b/chrome/renderer/media/video_renderer_impl.cc
index d411321..0064abd 100644
--- a/chrome/renderer/media/video_renderer_impl.cc
+++ b/chrome/renderer/media/video_renderer_impl.cc
@@ -109,12 +109,14 @@ void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame,
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 @@ void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame,
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 @@ void VideoRendererImpl::FastPaint(media::VideoFrame* video_frame,
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) ?
+ 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 @@ void VideoRendererImpl::FastPaint(media::VideoFrame* video_frame,
// 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 @@ void VideoRendererImpl::FastPaint(media::VideoFrame* video_frame,
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 @@ void VideoRendererImpl::FastPaint(media::VideoFrame* video_frame,
frame_in.strides[media::VideoSurface::kYPlane],
frame_in.strides[media::VideoSurface::kUPlane],
bitmap.rowBytes(),
- media::YV12,
+ yuv_type,
media::ROTATE_0);
bitmap.unlockPixels();
}