Commit db7ee15d authored by wez@chromium.org's avatar wez@chromium.org

Use libyuv for non-scaling RGB<->YUV conversions.

This switches Chromoting hosts to use libyuv for RGB->YUV and clients
to use libyuv for non-scaling rendering.

TEST=remoting_unittests
BUG=145561

Review URL: https://chromiumcodereview.appspot.com/13474013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195268 0039d316-1c4b-4281-b951-d872f2087c98
parent 79affb7e
...@@ -21,6 +21,7 @@ include_rules = [ ...@@ -21,6 +21,7 @@ include_rules = [
"+third_party/GTM/AppKit", "+third_party/GTM/AppKit",
"+third_party/libjingle", "+third_party/libjingle",
"+third_party/libvpx", "+third_party/libvpx",
"+third_party/libyuv",
"+third_party/skia/include/core", "+third_party/skia/include/core",
"+ui/base/keycodes", "+ui/base/keycodes",
] ]
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/time.h" #include "base/time.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/base/yuv_convert.h" #include "media/base/yuv_convert.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/skia/include/core/SkRegion.h" #include "third_party/skia/include/core/SkRegion.h"
#if defined(OS_POSIX) #if defined(OS_POSIX)
...@@ -65,15 +66,11 @@ void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane, ...@@ -65,15 +66,11 @@ void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
int y_offset = CalculateYOffset(x, y, y_stride); int y_offset = CalculateYOffset(x, y, y_stride);
int uv_offset = CalculateUVOffset(x, y, uv_stride);; int uv_offset = CalculateUVOffset(x, y, uv_stride);;
media::ConvertRGB32ToYUV(rgb_plane + rgb_offset, libyuv::ARGBToI420(rgb_plane + rgb_offset, rgb_stride,
y_plane + y_offset, y_plane + y_offset, y_stride,
u_plane + uv_offset, u_plane + uv_offset, uv_stride,
v_plane + uv_offset, v_plane + uv_offset, uv_stride,
width, width, height);
height,
rgb_stride,
y_stride,
uv_stride);
} }
void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane, void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
...@@ -111,7 +108,7 @@ void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane, ...@@ -111,7 +108,7 @@ void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
// See if scaling is needed. // See if scaling is needed.
if (source_size == dest_size) { if (source_size == dest_size) {
// Calculate the inner rectangle that can be copied by the optimized // Calculate the inner rectangle that can be copied by the optimized
// ConvertYUVToRGB32(). // libyuv::I420ToARGB().
SkIRect inner_rect = SkIRect inner_rect =
SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left() + 1), SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left() + 1),
RoundToTwosMultiple(dest_rect.top() + 1), RoundToTwosMultiple(dest_rect.top() + 1),
...@@ -126,16 +123,11 @@ void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane, ...@@ -126,16 +123,11 @@ void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
rgb_offset += CalculateRGBOffset(inner_rect.x(), inner_rect.y(), rgb_offset += CalculateRGBOffset(inner_rect.x(), inner_rect.y(),
dest_stride); dest_stride);
media::ConvertYUVToRGB32(source_yplane + y_offset, libyuv::I420ToARGB(source_yplane + y_offset, source_ystride,
source_uplane + uv_offset, source_uplane + uv_offset, source_uvstride,
source_vplane + uv_offset, source_vplane + uv_offset, source_uvstride,
dest_buffer + rgb_offset, dest_buffer + rgb_offset, dest_stride,
inner_rect.width(), inner_rect.width(), inner_rect.height());
inner_rect.height(),
source_ystride,
source_uvstride,
dest_stride,
media::YV12);
// Now see if some pixels weren't copied due to alignment. // Now see if some pixels weren't copied due to alignment.
if (dest_rect != inner_rect) { if (dest_rect != inner_rect) {
......
...@@ -34,7 +34,7 @@ TEST_F(VideoDecoderVp8Test, VideoEncodeAndDecode) { ...@@ -34,7 +34,7 @@ TEST_F(VideoDecoderVp8Test, VideoEncodeAndDecode) {
// frame too much. The frame used is a gradient, which does not contain sharp // frame too much. The frame used is a gradient, which does not contain sharp
// transitions, so encoding lossiness should not be too high. // transitions, so encoding lossiness should not be too high.
TEST_F(VideoDecoderVp8Test, Gradient) { TEST_F(VideoDecoderVp8Test, Gradient) {
TestGradient(320, 240, 320, 240, 0.03, 0.01); TestGradient(320, 240, 320, 240, 0.04, 0.02);
} }
TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToEven) { TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToEven) {
......
...@@ -2204,6 +2204,7 @@ ...@@ -2204,6 +2204,7 @@
'../net/net.gyp:net', '../net/net.gyp:net',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
'../third_party/libvpx/libvpx.gyp:libvpx', '../third_party/libvpx/libvpx.gyp:libvpx',
'../third_party/libyuv/libyuv.gyp:libyuv',
'../third_party/opus/opus.gyp:opus', '../third_party/opus/opus.gyp:opus',
'../third_party/protobuf/protobuf.gyp:protobuf_lite', '../third_party/protobuf/protobuf.gyp:protobuf_lite',
'../third_party/speex/speex.gyp:libspeex', '../third_party/speex/speex.gyp:libspeex',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment