OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/base/decoder_row_based.h" | 5 #include "remoting/base/decoder_row_based.h" |
6 | 6 |
7 #include "remoting/base/decompressor.h" | 7 #include "remoting/base/decompressor.h" |
8 #include "remoting/base/decompressor_zlib.h" | 8 #include "remoting/base/decompressor_zlib.h" |
9 #include "remoting/base/decompressor_verbatim.h" | 9 #include "remoting/base/decompressor_verbatim.h" |
10 #include "remoting/base/util.h" | 10 #include "remoting/base/util.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return DECODE_ERROR; | 81 return DECODE_ERROR; |
82 } | 82 } |
83 | 83 |
84 const uint8* in = reinterpret_cast<const uint8*>(packet->data().data()); | 84 const uint8* in = reinterpret_cast<const uint8*>(packet->data().data()); |
85 const int in_size = packet->data().size(); | 85 const int in_size = packet->data().size(); |
86 | 86 |
87 const int row_size = clip_.width() * kBytesPerPixel; | 87 const int row_size = clip_.width() * kBytesPerPixel; |
88 int stride = frame_->stride(media::VideoFrame::kRGBPlane); | 88 int stride = frame_->stride(media::VideoFrame::kRGBPlane); |
89 uint8* rect_begin = frame_->data(media::VideoFrame::kRGBPlane); | 89 uint8* rect_begin = frame_->data(media::VideoFrame::kRGBPlane); |
90 | 90 |
91 uint8* out = rect_begin + stride * (clip_.y() + row_y_) + | 91 uint8* out = rect_begin + stride * (clip_.fTop + row_y_) + |
92 kBytesPerPixel * clip_.x(); | 92 kBytesPerPixel * clip_.fLeft; |
93 | 93 |
94 // Consume all the data in the message. | 94 // Consume all the data in the message. |
95 bool decompress_again = true; | 95 bool decompress_again = true; |
96 int used = 0; | 96 int used = 0; |
97 while (decompress_again && used < in_size) { | 97 while (decompress_again && used < in_size) { |
98 if (row_y_ >= clip_.height()) { | 98 if (row_y_ >= clip_.height()) { |
99 state_ = kError; | 99 state_ = kError; |
100 LOG(WARNING) << "Too much data is received for the given rectangle."; | 100 LOG(WARNING) << "Too much data is received for the given rectangle."; |
101 return DECODE_ERROR; | 101 return DECODE_ERROR; |
102 } | 102 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 if (packet->flags() & VideoPacket::FIRST_PACKET) { | 145 if (packet->flags() & VideoPacket::FIRST_PACKET) { |
146 if (state_ != kReady && state_ != kDone && state_ != kPartitionDone) { | 146 if (state_ != kReady && state_ != kDone && state_ != kPartitionDone) { |
147 state_ = kError; | 147 state_ = kError; |
148 LOG(WARNING) << "Received unexpected FIRST_PACKET."; | 148 LOG(WARNING) << "Received unexpected FIRST_PACKET."; |
149 return; | 149 return; |
150 } | 150 } |
151 state_ = kProcessing; | 151 state_ = kProcessing; |
152 | 152 |
153 // Reset the buffer location status variables on the first packet. | 153 // Reset the buffer location status variables on the first packet. |
154 clip_.SetRect(packet->format().x(), packet->format().y(), | 154 clip_.setXYWH(packet->format().x(), packet->format().y(), |
155 packet->format().width(), packet->format().height()); | 155 packet->format().width(), packet->format().height()); |
156 row_pos_ = 0; | 156 row_pos_ = 0; |
157 row_y_ = 0; | 157 row_y_ = 0; |
158 } | 158 } |
159 | 159 |
160 if (state_ != kProcessing) { | 160 if (state_ != kProcessing) { |
161 state_ = kError; | 161 state_ = kError; |
162 LOG(WARNING) << "Received unexpected packet."; | 162 LOG(WARNING) << "Received unexpected packet."; |
163 return; | 163 return; |
164 } | 164 } |
(...skipping 12 matching lines...) Expand all Loading... |
177 state_ = kError; | 177 state_ = kError; |
178 LOG(WARNING) << "Received unexpected LAST_PARTITION."; | 178 LOG(WARNING) << "Received unexpected LAST_PARTITION."; |
179 return; | 179 return; |
180 } | 180 } |
181 state_ = kDone; | 181 state_ = kDone; |
182 } | 182 } |
183 | 183 |
184 return; | 184 return; |
185 } | 185 } |
186 | 186 |
187 void DecoderRowBased::GetUpdatedRects(UpdatedRects* rects) { | 187 void DecoderRowBased::GetUpdatedRects(RectVector* rects) { |
188 rects->swap(updated_rects_); | 188 rects->swap(updated_rects_); |
189 updated_rects_.clear(); | 189 updated_rects_.clear(); |
190 } | 190 } |
191 | 191 |
192 VideoPacketFormat::Encoding DecoderRowBased::Encoding() { | 192 VideoPacketFormat::Encoding DecoderRowBased::Encoding() { |
193 return encoding_; | 193 return encoding_; |
194 } | 194 } |
195 | 195 |
196 } // namespace remoting | 196 } // namespace remoting |
OLD | NEW |