Chromium Code Reviews| Index: remoting/base/decoder_vp8.cc |
| diff --git a/remoting/base/decoder_vp8.cc b/remoting/base/decoder_vp8.cc |
| index 6ce7f0358988aeeedcfa888783aa30f4c315350b..10b38fd7f35750e6a48c350d74075d91acbd80a7 100644 |
| --- a/remoting/base/decoder_vp8.cc |
| +++ b/remoting/base/decoder_vp8.cc |
| @@ -20,9 +20,8 @@ DecoderVp8::DecoderVp8() |
| : state_(kUninitialized), |
| codec_(NULL), |
| last_image_(NULL), |
| - clip_rect_(SkIRect::MakeEmpty()), |
| - horizontal_scale_ratio_(1.0), |
| - vertical_scale_ratio_(1.0) { |
| + clip_rect_(SkIRect::MakeEmpty()) { |
| + output_size_.setEmpty(); |
|
Sergey Ulanov
2011/12/20 00:05:35
Can we initialize output_size_ in the same way cli
Wez
2011/12/20 07:14:14
Done.
|
| } |
| DecoderVp8::~DecoderVp8() { |
| @@ -101,6 +100,16 @@ Decoder::DecodeResult DecoderVp8::DecodePacket(const VideoPacket* packet) { |
| remoting_rect.height())); |
| } |
| + // TODO(wez): Fix the rest of the decode pipeline not to assume the frame |
| + // size is the host dimensions, since it's not when scaling. If the host |
| + // gets smaller, then the output size will be too big and we'll overrun the |
| + // frame, so currently we render 1:1 in that case; the app will see the |
| + // host size change and resize us if need be. |
| + if ((output_size_.width() > static_cast<int>(frame_->width())) || |
| + (output_size_.height() > static_cast<int>(frame_->height()))) { |
| + output_size_.set(frame_->width(), frame_->height()); |
| + } |
| + |
| if (!DoScaling()) |
| ConvertRects(rects, &updated_rects_); |
| else |
| @@ -125,18 +134,8 @@ VideoPacketFormat::Encoding DecoderVp8::Encoding() { |
| return VideoPacketFormat::ENCODING_VP8; |
| } |
| -void DecoderVp8::SetScaleRatios(double horizontal_ratio, |
| - double vertical_ratio) { |
| - // TODO(hclam): Ratio greater than 1.0 is not supported. This is |
| - // because we need to reallocate the backing video frame and this |
| - // is not implemented yet. |
| - if (horizontal_ratio > 1.0 || horizontal_ratio <= 0.0 || |
| - vertical_ratio > 1.0 || vertical_ratio <= 0.0) { |
| - return; |
| - } |
| - |
| - horizontal_scale_ratio_ = horizontal_ratio; |
| - vertical_scale_ratio_ = vertical_ratio; |
| +void DecoderVp8::SetOutputDimensions(const SkISize& size) { |
| + output_size_ = size; |
| } |
| void DecoderVp8::SetClipRect(const SkIRect& clip_rect) { |
| @@ -151,7 +150,8 @@ void DecoderVp8::RefreshRects(const RectVector& rects) { |
| } |
| bool DecoderVp8::DoScaling() const { |
| - return horizontal_scale_ratio_ != 1.0 || vertical_scale_ratio_ != 1.0; |
| + return last_image_ && |
| + !output_size_.equals(last_image_->d_w, last_image_->d_h); |
|
Jamie
2011/12/20 00:51:57
This will change the behaviour if DoScaling is eve
Wez
2011/12/20 07:14:14
DoScaling() determines whether we use the ConvertR
|
| } |
| void DecoderVp8::ConvertRects(const RectVector& rects, |
| @@ -205,20 +205,19 @@ void DecoderVp8::ScaleAndConvertRects(const RectVector& rects, |
| output_rects->reserve(rects.size()); |
| for (size_t i = 0; i < rects.size(); ++i) { |
| // Round down the image width and height. |
| - int image_width = RoundToTwosMultiple(last_image_->d_w); |
| - int image_height = RoundToTwosMultiple(last_image_->d_h); |
| + SkISize image_size; |
| + image_size.set(RoundToTwosMultiple(last_image_->d_w), |
| + RoundToTwosMultiple(last_image_->d_h)); |
| // Clip by the rounded down dimension of the image for safety. |
| SkIRect dest_rect = rects[i]; |
| - if (!dest_rect.intersect(SkIRect::MakeWH(image_width, image_height))) |
| + if (!dest_rect.intersect(SkIRect::MakeSize(image_size))) |
| continue; |
| // Align the rectangle to avoid artifacts in color space conversion. |
| dest_rect = AlignRect(dest_rect); |
| - SkIRect scaled_rect = ScaleRect(dest_rect, |
| - horizontal_scale_ratio_, |
| - vertical_scale_ratio_); |
| + SkIRect scaled_rect = ScaleRect(dest_rect, image_size, output_size_); |
| ScaleYUVToRGB32WithRect(last_image_->planes[0], |
| last_image_->planes[1], |