summaryrefslogtreecommitdiffstats
path: root/remoting/base
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 11:51:08 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 11:51:08 +0000
commit467aca55f38b251b636f638d61408d420d570c11 (patch)
treefda9063580b467a4a21fd8f1a1bd317991ce1a0b /remoting/base
parentab0fb9834c6f3b3ee9d86a8c5a6ba3a5b69b2ac8 (diff)
downloadchromium_src-467aca55f38b251b636f638d61408d420d570c11.zip
chromium_src-467aca55f38b251b636f638d61408d420d570c11.tar.gz
chromium_src-467aca55f38b251b636f638d61408d420d570c11.tar.bz2
Tidy up after CL 6573005.
Replace width/height pairs with gfx::Size objects. Avoid overloading Capturer::InvalidateFullScreen. BUG=none TEST=none Review URL: http://codereview.chromium.org/6635039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r--remoting/base/capture_data.cc7
-rw-r--r--remoting/base/capture_data.h17
-rw-r--r--remoting/base/codec_test.cc2
-rw-r--r--remoting/base/encoder_row_based.cc16
-rw-r--r--remoting/base/encoder_row_based.h3
-rw-r--r--remoting/base/encoder_vp8.cc48
-rw-r--r--remoting/base/encoder_vp8.h7
7 files changed, 41 insertions, 59 deletions
diff --git a/remoting/base/capture_data.cc b/remoting/base/capture_data.cc
index 8bf464d..15f312e 100644
--- a/remoting/base/capture_data.cc
+++ b/remoting/base/capture_data.cc
@@ -14,11 +14,10 @@ DataPlanes::DataPlanes() {
}
CaptureData::CaptureData(const DataPlanes &data_planes,
- int width,
- int height,
+ const gfx::Size& size,
media::VideoFrame::Format format) :
- data_planes_(data_planes), dirty_rects_(),
- width_(width), height_(height), pixel_format_(format) {
+ data_planes_(data_planes), dirty_rects_(), size_(size),
+ pixel_format_(format) {
}
CaptureData::~CaptureData() {}
diff --git a/remoting/base/capture_data.h b/remoting/base/capture_data.h
index dd6c4b9..1922c9c 100644
--- a/remoting/base/capture_data.h
+++ b/remoting/base/capture_data.h
@@ -27,8 +27,7 @@ struct DataPlanes {
class CaptureData : public base::RefCountedThreadSafe<CaptureData> {
public:
CaptureData(const DataPlanes &data_planes,
- int width,
- int height,
+ const gfx::Size& size,
media::VideoFrame::Format format);
// Get the data_planes data of the last capture.
@@ -38,15 +37,8 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> {
// written into |rects|.
const InvalidRects& dirty_rects() const { return dirty_rects_; }
- // TODO(simonmorris): The next two methods should be replaced by a
- // gfx::Size size(), and objects that store that size should also
- // use a gfx::Size to do so.
-
- // Get the width of the image captured.
- int width() const { return width_; }
-
- // Get the height of the image captured.
- int height() const { return height_; }
+ // Return the size of the image captured.
+ gfx::Size size() const { return size_; }
// Get the pixel format of the image captured.
media::VideoFrame::Format pixel_format() const { return pixel_format_; }
@@ -57,8 +49,7 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> {
private:
const DataPlanes data_planes_;
InvalidRects dirty_rects_;
- int width_;
- int height_;
+ gfx::Size size_;
media::VideoFrame::Format pixel_format_;
friend class base::RefCountedThreadSafe<CaptureData>;
diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc
index bfa2d64..38593fb 100644
--- a/remoting/base/codec_test.cc
+++ b/remoting/base/codec_test.cc
@@ -256,7 +256,7 @@ scoped_refptr<CaptureData> PrepareEncodeData(media::VideoFrame::Format format,
planes.strides[0] = kWidth * kBytesPerPixel;
scoped_refptr<CaptureData> data =
- new CaptureData(planes, kWidth, kHeight, format);
+ new CaptureData(planes, gfx::Size(kWidth, kHeight), format);
return data;
}
diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc
index 6159207a..d740e27 100644
--- a/remoting/base/encoder_row_based.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -42,8 +42,7 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor,
VideoPacketFormat::Encoding encoding)
: encoding_(encoding),
compressor_(compressor),
- screen_width_(0),
- screen_height_(0),
+ screen_size_(0, 0),
packet_size_(kPacketSize) {
}
@@ -52,8 +51,7 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor,
int packet_size)
: encoding_(encoding),
compressor_(compressor),
- screen_width_(0),
- screen_height_(0),
+ screen_size_(0, 0),
packet_size_(packet_size) {
}
@@ -151,12 +149,10 @@ void EncoderRowBased::PrepareUpdateStart(const gfx::Rect& rect,
format->set_width(rect.width());
format->set_height(rect.height());
format->set_encoding(encoding_);
- if ((capture_data_->width() != screen_width_) ||
- (capture_data_->height() != screen_height_)) {
- screen_width_ = capture_data_->width();
- screen_height_ = capture_data_->height();
- format->set_screen_width(screen_width_);
- format->set_screen_height(screen_height_);
+ if (capture_data_->size() != screen_size_) {
+ screen_size_ = capture_data_->size();
+ format->set_screen_width(screen_size_.width());
+ format->set_screen_height(screen_size_.height());
}
}
diff --git a/remoting/base/encoder_row_based.h b/remoting/base/encoder_row_based.h
index fe7f49c..d453ffb 100644
--- a/remoting/base/encoder_row_based.h
+++ b/remoting/base/encoder_row_based.h
@@ -62,8 +62,7 @@ class EncoderRowBased : public Encoder {
scoped_ptr<DataAvailableCallback> callback_;
// The most recent screen size.
- int screen_width_;
- int screen_height_;
+ gfx::Size screen_size_;
int packet_size_;
};
diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc
index 8d09d544..b0f35cb 100644
--- a/remoting/base/encoder_vp8.cc
+++ b/remoting/base/encoder_vp8.cc
@@ -33,8 +33,7 @@ EncoderVp8::EncoderVp8()
active_map_width_(0),
active_map_height_(0),
last_timestamp_(0),
- width_(0),
- height_(0) {
+ size_(0, 0) {
}
EncoderVp8::~EncoderVp8() {
@@ -44,9 +43,8 @@ EncoderVp8::~EncoderVp8() {
}
}
-bool EncoderVp8::Init(int width, int height) {
- width_ = width;
- height_ = height;
+bool EncoderVp8::Init(const gfx::Size& size) {
+ size_ = size;
codec_.reset(new vpx_codec_ctx_t());
image_.reset(new vpx_image_t());
memset(image_.get(), 0, sizeof(vpx_image_t));
@@ -54,20 +52,20 @@ bool EncoderVp8::Init(int width, int height) {
image_->fmt = VPX_IMG_FMT_YV12;
// libvpx seems to require both to be assigned.
- image_->d_w = width;
- image_->w = width;
- image_->d_h = height;
- image_->h = height;
+ image_->d_w = size.width();
+ image_->w = size.width();
+ image_->d_h = size.height();
+ image_->h = size.height();
// YUV image size is 1.5 times of a plane. Multiplication is performed first
// to avoid rounding error.
- const int plane_size = width * height;
- const int size = plane_size * 3 / 2;
+ const int plane_size = size.width() * size.height();
+ const int yuv_image_size = plane_size * 3 / 2;
- yuv_image_.reset(new uint8[size]);
+ yuv_image_.reset(new uint8[yuv_image_size]);
// Reset image value to 128 so we just need to fill in the y plane.
- memset(yuv_image_.get(), 128, size);
+ memset(yuv_image_.get(), 128, yuv_image_size);
// Fill in the information for |image_|.
unsigned char* image = reinterpret_cast<unsigned char*>(yuv_image_.get());
@@ -91,15 +89,15 @@ bool EncoderVp8::Init(int width, int height) {
return false;
// Initialize active map.
- active_map_width_ = (width + kMacroBlockSize - 1) / kMacroBlockSize;
- active_map_height_ = (height + kMacroBlockSize - 1) / kMacroBlockSize;
+ active_map_width_ = (size.width() + kMacroBlockSize - 1) / kMacroBlockSize;
+ active_map_height_ = (size.height() + kMacroBlockSize - 1) / kMacroBlockSize;
active_map_.reset(new uint8[active_map_width_ * active_map_height_]);
// TODO(hclam): Tune the parameters to better suit the application.
- config.rc_target_bitrate = width * height * config.rc_target_bitrate
- / config.g_w / config.g_h;
- config.g_w = width;
- config.g_h = height;
+ config.rc_target_bitrate = size.width() * size.height() *
+ config.rc_target_bitrate / config.g_w / config.g_h;
+ config.g_w = size.width();
+ config.g_h = size.height();
config.g_pass = VPX_RC_ONE_PASS;
config.g_profile = 1;
config.g_threads = 1;
@@ -147,7 +145,8 @@ bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data,
const InvalidRects& rects = capture_data->dirty_rects();
const uint8* in = capture_data->data_planes().data[0];
const int in_stride = capture_data->data_planes().strides[0];
- const int plane_size = capture_data->width() * capture_data->height();
+ const int plane_size =
+ capture_data->size().width() * capture_data->size().height();
uint8* y_out = yuv_image_.get();
uint8* u_out = yuv_image_.get() + plane_size;
uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4;
@@ -204,9 +203,8 @@ void EncoderVp8::PrepareActiveMap(
void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data,
bool key_frame,
DataAvailableCallback* data_available_callback) {
- if (!initialized_ || (capture_data->width() != width_) ||
- (capture_data->height() != height_)) {
- bool ret = Init(capture_data->width(), capture_data->height());
+ if (!initialized_ || (capture_data->size() != size_)) {
+ bool ret = Init(capture_data->size());
// TODO(hclam): Handle error better.
DCHECK(ret) << "Initialization of encoder failed";
initialized_ = ret;
@@ -269,8 +267,8 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data,
message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8);
message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET |
VideoPacket::LAST_PARTITION);
- message->mutable_format()->set_screen_width(capture_data->width());
- message->mutable_format()->set_screen_height(capture_data->height());
+ message->mutable_format()->set_screen_width(capture_data->size().width());
+ message->mutable_format()->set_screen_height(capture_data->size().height());
for (size_t i = 0; i < updated_rects.size(); ++i) {
Rect* rect = message->add_dirty_rects();
rect->set_x(updated_rects[i].x());
diff --git a/remoting/base/encoder_vp8.h b/remoting/base/encoder_vp8.h
index 2bf73dc..8fdbbc2 100644
--- a/remoting/base/encoder_vp8.h
+++ b/remoting/base/encoder_vp8.h
@@ -27,7 +27,7 @@ class EncoderVp8 : public Encoder {
private:
// Initialize the encoder. Returns true if successful.
- bool Init(int width, int height);
+ bool Init(const gfx::Size& size);
// Prepare |image_| for encoding. Write updated rectangles into
// |updated_rects|. Returns true if successful.
@@ -51,9 +51,8 @@ class EncoderVp8 : public Encoder {
// Buffer for storing the yuv image.
scoped_array<uint8> yuv_image_;
- // The current frame dimensions.
- int width_;
- int height_;
+ // The current frame size.
+ gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(EncoderVp8);
};