summaryrefslogtreecommitdiffstats
path: root/remoting/codec
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-22 10:19:20 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-22 10:19:20 +0000
commit8a4541fc6c5749ddf6d6bed49a4c69a897ff006f (patch)
tree2916ecb8ca9f19ebe1df995b20ec01fc673d89b3 /remoting/codec
parent1c4582423ff5aa1776deef53bbd0c11c1f0bc354 (diff)
downloadchromium_src-8a4541fc6c5749ddf6d6bed49a4c69a897ff006f.zip
chromium_src-8a4541fc6c5749ddf6d6bed49a4c69a897ff006f.tar.gz
chromium_src-8a4541fc6c5749ddf6d6bed49a4c69a897ff006f.tar.bz2
Simplify remoting::CaptureData
1. Previously CaptureData had pixel_format() field but we only use that class for RGB. Removed that field. 2. Removed DataPlanes because it's doesn't make sense for RGB32. Instead CaptureData class now stored data pointer and stride values. TBR=tsepez@chromium.org Review URL: https://chromiumcodereview.appspot.com/11637031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/codec')
-rw-r--r--remoting/codec/codec_test.cc36
-rw-r--r--remoting/codec/video_encoder_verbatim.cc14
-rw-r--r--remoting/codec/video_encoder_vp8.cc8
-rw-r--r--remoting/codec/video_encoder_vp8_unittest.cc16
4 files changed, 21 insertions, 53 deletions
diff --git a/remoting/codec/codec_test.cc b/remoting/codec/codec_test.cc
index fb2d1a6..7f45828 100644
--- a/remoting/codec/codec_test.cc
+++ b/remoting/codec/codec_test.cc
@@ -204,10 +204,10 @@ class VideoDecoderTester {
EXPECT_EQ(expected_region_, update_region_);
for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
const int stride = view_size_.width() * kBytesPerPixel;
- EXPECT_EQ(stride, capture_data_->data_planes().strides[0]);
+ EXPECT_EQ(stride, capture_data_->stride());
const int offset = stride * i.rect().top() +
kBytesPerPixel * i.rect().left();
- const uint8* original = capture_data_->data_planes().data[0] + offset;
+ const uint8* original = capture_data_->data() + offset;
const uint8* decoded = image_data_.get() + offset;
const int row_size = kBytesPerPixel * i.rect().width();
for (int y = 0; y < i.rect().height(); ++y) {
@@ -318,10 +318,7 @@ class VideoEncoderTester {
};
scoped_refptr<CaptureData> PrepareEncodeData(const SkISize& size,
- media::VideoFrame::Format format,
scoped_array<uint8>* memory) {
- // TODO(hclam): Support also YUV format.
- CHECK_EQ(format, media::VideoFrame::RGB32);
int memory_size = size.width() * size.height() * kBytesPerPixel;
memory->reset(new uint8[memory_size]);
@@ -331,14 +328,8 @@ scoped_refptr<CaptureData> PrepareEncodeData(const SkISize& size,
(*memory)[i] = rand() % 256;
}
- DataPlanes planes;
- memset(planes.data, 0, sizeof(planes.data));
- memset(planes.strides, 0, sizeof(planes.strides));
- planes.data[0] = memory->get();
- planes.strides[0] = size.width() * kBytesPerPixel;
-
scoped_refptr<CaptureData> data =
- new CaptureData(planes, size, format);
+ new CaptureData(memory->get(), size.width() * kBytesPerPixel, size);
return data;
}
@@ -370,7 +361,7 @@ void TestVideoEncoder(VideoEncoder* encoder, bool strict) {
for (size_t yi = 0; yi < arraysize(kSizes); ++yi) {
SkISize size = SkISize::Make(kSizes[xi], kSizes[yi]);
scoped_refptr<CaptureData> data =
- PrepareEncodeData(size, media::VideoFrame::RGB32, &memory);
+ PrepareEncodeData(size, &memory);
std::vector<std::vector<SkIRect> > test_rect_lists =
MakeTestRectLists(size);
for (size_t i = 0; i < test_rect_lists.size(); ++i) {
@@ -394,16 +385,15 @@ static void TestEncodeDecodeRects(VideoEncoder* encoder,
// Generate random data for the updated region.
srand(0);
for (int i = 0; i < count; ++i) {
- CHECK_EQ(data->pixel_format(), media::VideoFrame::RGB32);
const int bytes_per_pixel = 4; // Because of RGB32 on previous line.
const int row_size = bytes_per_pixel * rects[i].width();
- uint8* memory = data->data_planes().data[0] +
- data->data_planes().strides[0] * rects[i].top() +
+ uint8* memory = data->data() +
+ data->stride() * rects[i].top() +
bytes_per_pixel * rects[i].left();
for (int y = 0; y < rects[i].height(); ++y) {
for (int x = 0; x < row_size; ++x)
memory[x] = rand() % 256;
- memory += data->data_planes().strides[0];
+ memory += data->stride();
}
}
@@ -423,8 +413,7 @@ void TestVideoEncoderDecoder(
VideoEncoderTester encoder_tester(&message_tester);
scoped_array<uint8> memory;
- scoped_refptr<CaptureData> data =
- PrepareEncodeData(kSize, media::VideoFrame::RGB32, &memory);
+ scoped_refptr<CaptureData> data = PrepareEncodeData(kSize, &memory);
VideoDecoderTester decoder_tester(decoder, kSize, kSize);
decoder_tester.set_strict(strict);
@@ -469,14 +458,9 @@ void TestVideoEncoderDecoderGradient(VideoEncoder* encoder,
view_size.width() * view_size.height() * kBytesPerPixel]);
FillWithGradient(expected_view_data.get(), view_size, view_rect);
- DataPlanes planes;
- memset(planes.data, 0, sizeof(planes.data));
- memset(planes.strides, 0, sizeof(planes.strides));
- planes.data[0] = screen_data.get();
- planes.strides[0] = screen_size.width() * kBytesPerPixel;
-
scoped_refptr<CaptureData> capture_data =
- new CaptureData(planes, screen_size, media::VideoFrame::RGB32);
+ new CaptureData(screen_data.get(), screen_size.width() * kBytesPerPixel,
+ screen_size);
capture_data->mutable_dirty_region().op(screen_rect, SkRegion::kUnion_Op);
VideoDecoderTester decoder_tester(decoder, screen_size, view_size);
diff --git a/remoting/codec/video_encoder_verbatim.cc b/remoting/codec/video_encoder_verbatim.cc
index 0884551..0633ac2 100644
--- a/remoting/codec/video_encoder_verbatim.cc
+++ b/remoting/codec/video_encoder_verbatim.cc
@@ -29,9 +29,6 @@ void VideoEncoderVerbatim::Encode(
scoped_refptr<CaptureData> capture_data,
bool key_frame,
const DataAvailableCallback& data_available_callback) {
- CHECK(capture_data->pixel_format() == media::VideoFrame::RGB32)
- << "RowBased VideoEncoder only works with RGB32. Got "
- << capture_data->pixel_format();
capture_data_ = capture_data;
callback_ = data_available_callback;
encode_start_time_ = base::Time::Now();
@@ -49,16 +46,15 @@ void VideoEncoderVerbatim::Encode(
}
void VideoEncoderVerbatim::EncodeRect(const SkIRect& rect, bool last) {
- CHECK(capture_data_->data_planes().data[0]);
- CHECK_EQ(capture_data_->pixel_format(), media::VideoFrame::RGB32);
- const int strides = capture_data_->data_planes().strides[0];
+ CHECK(capture_data_->data());
+ const int stride = capture_data_->stride();
const int bytes_per_pixel = 4;
const int row_size = bytes_per_pixel * rect.width();
scoped_ptr<VideoPacket> packet(new VideoPacket());
PrepareUpdateStart(rect, packet.get());
- const uint8* in = capture_data_->data_planes().data[0] +
- rect.fTop * strides + rect.fLeft * bytes_per_pixel;
+ const uint8* in = capture_data_->data() +
+ rect.fTop * stride + rect.fLeft * bytes_per_pixel;
// TODO(hclam): Fill in the sequence number.
uint8* out = GetOutputBuffer(packet.get(), max_packet_size_);
int filled = 0;
@@ -82,7 +78,7 @@ void VideoEncoderVerbatim::EncodeRect(const SkIRect& rect, bool last) {
// Jump to the next row when we've reached the end of the current row.
if (row_pos == row_size) {
row_pos = 0;
- in += strides;
+ in += stride;
++row_y;
}
}
diff --git a/remoting/codec/video_encoder_vp8.cc b/remoting/codec/video_encoder_vp8.cc
index 3295904..03758ca 100644
--- a/remoting/codec/video_encoder_vp8.cc
+++ b/remoting/codec/video_encoder_vp8.cc
@@ -147,10 +147,6 @@ bool VideoEncoderVp8::Init(const SkISize& size) {
void VideoEncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data,
SkRegion* updated_region) {
- // Perform RGB->YUV conversion.
- DCHECK_EQ(capture_data->pixel_format(), media::VideoFrame::RGB32)
- << "Only RGB32 is supported";
-
const SkRegion& region = capture_data->dirty_region();
if (region.isEmpty()) {
updated_region->setEmpty();
@@ -174,8 +170,8 @@ void VideoEncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data,
SkRegion::kIntersect_Op);
// Convert the updated region to YUV ready for encoding.
- const uint8* rgb_data = capture_data->data_planes().data[0];
- const int rgb_stride = capture_data->data_planes().strides[0];
+ const uint8* rgb_data = capture_data->data();
+ const int rgb_stride = capture_data->stride();
const int y_stride = image_->stride[0];
DCHECK_EQ(image_->stride[1], image_->stride[2]);
const int uv_stride = image_->stride[1];
diff --git a/remoting/codec/video_encoder_vp8_unittest.cc b/remoting/codec/video_encoder_vp8_unittest.cc
index 5707c98..11d5ded 100644
--- a/remoting/codec/video_encoder_vp8_unittest.cc
+++ b/remoting/codec/video_encoder_vp8_unittest.cc
@@ -45,19 +45,15 @@ TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) {
VideoEncoderCallback callback;
std::vector<uint8> buffer(width * height * kBytesPerPixel);
- DataPlanes planes;
- planes.data[0] = &buffer.front();
- planes.strides[0] = width;
-
scoped_refptr<CaptureData> capture_data(new CaptureData(
- planes, SkISize::Make(width, height), media::VideoFrame::RGB32));
+ &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height)));
encoder.Encode(capture_data, false,
base::Bind(&VideoEncoderCallback::DataAvailable,
base::Unretained(&callback)));
height /= 2;
- capture_data = new CaptureData(planes, SkISize::Make(width, height),
- media::VideoFrame::RGB32);
+ capture_data = new CaptureData(
+ &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height));
encoder.Encode(capture_data, false,
base::Bind(&VideoEncoderCallback::DataAvailable,
base::Unretained(&callback)));
@@ -82,12 +78,8 @@ TEST(VideoEncoderVp8Test, TestDpiPropagation) {
VideoEncoderDpiCallback callback;
std::vector<uint8> buffer(width * height * kBytesPerPixel);
- DataPlanes planes;
- planes.data[0] = &buffer.front();
- planes.strides[0] = width;
-
scoped_refptr<CaptureData> capture_data(new CaptureData(
- planes, SkISize::Make(width, height), media::VideoFrame::RGB32));
+ &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height)));
capture_data->set_dpi(SkIPoint::Make(96, 97));
encoder.Encode(capture_data, false,
base::Bind(&VideoEncoderDpiCallback::DataAvailable,