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) { ...@@ -45,28 +45,6 @@ int CalculateUVOffset(int x, int y, int stride) {
return stride * y / 2 + x / 2; 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( void ConvertAndScaleYUVToRGB32Rect(
const uint8* source_yplane, const uint8* source_yplane,
const uint8* source_uplane, const uint8* source_uplane,
......
...@@ -50,19 +50,6 @@ void ConvertAndScaleYUVToRGB32Rect( ...@@ -50,19 +50,6 @@ void ConvertAndScaleYUVToRGB32Rect(
const webrtc::DesktopRect& dest_buffer_rect, const webrtc::DesktopRect& dest_buffer_rect,
const webrtc::DesktopRect& dest_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); int RoundToTwosMultiple(int x);
// Align the sides of the rectangle to multiples of 2 (expanding outwards). // Align the sides of the rectangle to multiples of 2 (expanding outwards).
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "remoting/base/util.h" #include "remoting/base/util.h"
#include "testing/gtest/include/gtest/gtest.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" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
static const int kWidth = 32 ; static const int kWidth = 32 ;
...@@ -91,17 +92,16 @@ class YuvToRgbTester { ...@@ -91,17 +92,16 @@ class YuvToRgbTester {
FillRgbBuffer(rect); FillRgbBuffer(rect);
// RGB -> YUV // RGB -> YUV
ConvertRGB32ToYUVWithRect(rgb_buffer_.get(), libyuv::ARGBToI420(rgb_buffer_.get(),
yplane_, kRgbStride,
uplane_, yplane_,
vplane_, kYStride,
0, uplane_,
0, kUvStride,
kWidth, vplane_,
kHeight, kUvStride,
kRgbStride, kWidth,
kYStride, kHeight);
kUvStride);
// Reset RGB buffer and do opposite conversion. // Reset RGB buffer and do opposite conversion.
ResetRgbBuffer(); ResetRgbBuffer();
......
...@@ -45,7 +45,7 @@ class VideoDecoderVp8Test : public VideoDecoderVpxTest { ...@@ -45,7 +45,7 @@ class VideoDecoderVp8Test : public VideoDecoderVpxTest {
class VideoDecoderVp9Test : public VideoDecoderVpxTest { class VideoDecoderVp9Test : public VideoDecoderVpxTest {
protected: protected:
VideoDecoderVp9Test() { VideoDecoderVp9Test() {
encoder_ = VideoEncoderVpx::CreateForVP9(); encoder_ = VideoEncoderVpx::CreateForVP9I420();
decoder_ = VideoDecoderVpx::CreateForVP9(); decoder_ = VideoDecoderVpx::CreateForVP9();
} }
}; };
......
This diff is collapsed.
...@@ -23,7 +23,8 @@ class VideoEncoderVpx : public VideoEncoder { ...@@ -23,7 +23,8 @@ class VideoEncoderVpx : public VideoEncoder {
public: public:
// Create encoder for the specified protocol. // Create encoder for the specified protocol.
static scoped_ptr<VideoEncoderVpx> CreateForVP8(); static scoped_ptr<VideoEncoderVpx> CreateForVP8();
static scoped_ptr<VideoEncoderVpx> CreateForVP9(); static scoped_ptr<VideoEncoderVpx> CreateForVP9I420();
static scoped_ptr<VideoEncoderVpx> CreateForVP9I444();
virtual ~VideoEncoderVpx(); virtual ~VideoEncoderVpx();
...@@ -33,9 +34,14 @@ class VideoEncoderVpx : public VideoEncoder { ...@@ -33,9 +34,14 @@ class VideoEncoderVpx : public VideoEncoder {
private: private:
typedef base::Callback<ScopedVpxCodec(const webrtc::DesktopSize&)> 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. // Initializes the codec for frames of |size|. Returns true if successful.
bool Initialize(const webrtc::DesktopSize& size); bool Initialize(const webrtc::DesktopSize& size);
...@@ -49,17 +55,20 @@ class VideoEncoderVpx : public VideoEncoder { ...@@ -49,17 +55,20 @@ class VideoEncoderVpx : public VideoEncoder {
// given to the encoder to speed up encoding. // given to the encoder to speed up encoding.
void PrepareActiveMap(const webrtc::DesktopRegion& updated_region); void PrepareActiveMap(const webrtc::DesktopRegion& updated_region);
InitializeCodecCallback init_codec_; CreateCodecCallback create_codec_;
CreateImageCallback create_image_;
ScopedVpxCodec codec_; ScopedVpxCodec codec_;
base::TimeTicks timestamp_base_;
// VPX image and buffer to hold the actual YUV planes.
scoped_ptr<vpx_image_t> image_; 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_; scoped_ptr<uint8[]> active_map_;
int active_map_width_; int active_map_width_;
int active_map_height_; int active_map_height_;
base::TimeTicks timestamp_base_;
// Buffer for storing the yuv image.
scoped_ptr<uint8[]> yuv_image_;
DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx); DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx);
}; };
......
...@@ -450,7 +450,7 @@ scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( ...@@ -450,7 +450,7 @@ scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder(
if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>(); return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>();
} else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) {
return remoting::VideoEncoderVpx::CreateForVP9().PassAs<VideoEncoder>(); return remoting::VideoEncoderVpx::CreateForVP9I420().PassAs<VideoEncoder>();
} }
NOTREACHED(); NOTREACHED();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
'../ppapi/ppapi.gyp:ppapi_cpp', '../ppapi/ppapi.gyp:ppapi_cpp',
'../testing/gmock.gyp:gmock', '../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'../third_party/libyuv/libyuv.gyp:libyuv',
'../third_party/webrtc/modules/modules.gyp:desktop_capture', '../third_party/webrtc/modules/modules.gyp:desktop_capture',
'../ui/base/ui_base.gyp:ui_base', '../ui/base/ui_base.gyp:ui_base',
'../ui/gfx/gfx.gyp:gfx', '../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