Commit 3684eb98 authored by wez@chromium.org's avatar wez@chromium.org

Implement VP9/I444 encode support in the Chromoting host.

This will be selectable by clients that want to avoid I420 artefacts.

BUG=260879,134202

Review URL: https://codereview.chromium.org/261753013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269774 0039d316-1c4b-4281-b951-d872f2087c98
parent dd1ae25d
......@@ -45,28 +45,6 @@ int CalculateUVOffset(int x, int y, int stride) {
return stride * y / 2 + x / 2;
}
void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
uint8* y_plane,
uint8* u_plane,
uint8* v_plane,
int x,
int y,
int width,
int height,
int rgb_stride,
int y_stride,
int uv_stride) {
int rgb_offset = CalculateRGBOffset(x, y, rgb_stride);
int y_offset = CalculateYOffset(x, y, y_stride);
int uv_offset = CalculateUVOffset(x, y, uv_stride);;
libyuv::ARGBToI420(rgb_plane + rgb_offset, rgb_stride,
y_plane + y_offset, y_stride,
u_plane + uv_offset, uv_stride,
v_plane + uv_offset, uv_stride,
width, height);
}
void ConvertAndScaleYUVToRGB32Rect(
const uint8* source_yplane,
const uint8* source_uplane,
......
......@@ -50,19 +50,6 @@ void ConvertAndScaleYUVToRGB32Rect(
const webrtc::DesktopRect& dest_buffer_rect,
const webrtc::DesktopRect& dest_rect);
// Convert RGB32 to YUV on a specific rectangle.
void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
uint8* y_plane,
uint8* u_plane,
uint8* v_plane,
int x,
int y,
int width,
int height,
int rgb_stride,
int y_stride,
int uv_stride);
int RoundToTwosMultiple(int x);
// Align the sides of the rectangle to multiples of 2 (expanding outwards).
......
......@@ -6,6 +6,7 @@
#include "remoting/base/util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libyuv/include/libyuv/convert_from_argb.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
static const int kWidth = 32 ;
......@@ -91,17 +92,16 @@ class YuvToRgbTester {
FillRgbBuffer(rect);
// RGB -> YUV
ConvertRGB32ToYUVWithRect(rgb_buffer_.get(),
yplane_,
uplane_,
vplane_,
0,
0,
kWidth,
kHeight,
kRgbStride,
kYStride,
kUvStride);
libyuv::ARGBToI420(rgb_buffer_.get(),
kRgbStride,
yplane_,
kYStride,
uplane_,
kUvStride,
vplane_,
kUvStride,
kWidth,
kHeight);
// Reset RGB buffer and do opposite conversion.
ResetRgbBuffer();
......
......@@ -45,7 +45,7 @@ class VideoDecoderVp8Test : public VideoDecoderVpxTest {
class VideoDecoderVp9Test : public VideoDecoderVpxTest {
protected:
VideoDecoderVp9Test() {
encoder_ = VideoEncoderVpx::CreateForVP9();
encoder_ = VideoEncoderVpx::CreateForVP9I420();
decoder_ = VideoDecoderVpx::CreateForVP9();
}
};
......
This diff is collapsed.
......@@ -23,7 +23,8 @@ class VideoEncoderVpx : public VideoEncoder {
public:
// Create encoder for the specified protocol.
static scoped_ptr<VideoEncoderVpx> CreateForVP8();
static scoped_ptr<VideoEncoderVpx> CreateForVP9();
static scoped_ptr<VideoEncoderVpx> CreateForVP9I420();
static scoped_ptr<VideoEncoderVpx> CreateForVP9I444();
virtual ~VideoEncoderVpx();
......@@ -33,9 +34,14 @@ class VideoEncoderVpx : public VideoEncoder {
private:
typedef base::Callback<ScopedVpxCodec(const webrtc::DesktopSize&)>
InitializeCodecCallback;
CreateCodecCallback;
typedef base::Callback<void(const webrtc::DesktopSize&,
scoped_ptr<vpx_image_t>* out_image,
scoped_ptr<uint8[]>* out_image_buffer)>
CreateImageCallback;
VideoEncoderVpx(const InitializeCodecCallback& init_codec);
VideoEncoderVpx(const CreateCodecCallback& create_codec,
const CreateImageCallback& create_image);
// Initializes the codec for frames of |size|. Returns true if successful.
bool Initialize(const webrtc::DesktopSize& size);
......@@ -49,17 +55,20 @@ class VideoEncoderVpx : public VideoEncoder {
// given to the encoder to speed up encoding.
void PrepareActiveMap(const webrtc::DesktopRegion& updated_region);
InitializeCodecCallback init_codec_;
CreateCodecCallback create_codec_;
CreateImageCallback create_image_;
ScopedVpxCodec codec_;
base::TimeTicks timestamp_base_;
// VPX image and buffer to hold the actual YUV planes.
scoped_ptr<vpx_image_t> image_;
scoped_ptr<uint8[]> image_buffer_;
// Active map used to optimize out processing of un-changed macroblocks.
scoped_ptr<uint8[]> active_map_;
int active_map_width_;
int active_map_height_;
base::TimeTicks timestamp_base_;
// Buffer for storing the yuv image.
scoped_ptr<uint8[]> yuv_image_;
DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx);
};
......
......@@ -450,7 +450,7 @@ scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder(
if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>();
} else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) {
return remoting::VideoEncoderVpx::CreateForVP9().PassAs<VideoEncoder>();
return remoting::VideoEncoderVpx::CreateForVP9I420().PassAs<VideoEncoder>();
}
NOTREACHED();
......
......@@ -17,6 +17,7 @@
'../ppapi/ppapi.gyp:ppapi_cpp',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/libyuv/libyuv.gyp:libyuv',
'../third_party/webrtc/modules/modules.gyp:desktop_capture',
'../ui/base/ui_base.gyp:ui_base',
'../ui/gfx/gfx.gyp:gfx',
......
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