diff options
Diffstat (limited to 'remoting/base/decoder_row_based.cc')
-rw-r--r-- | remoting/base/decoder_row_based.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/remoting/base/decoder_row_based.cc b/remoting/base/decoder_row_based.cc index a657331..25e738f 100644 --- a/remoting/base/decoder_row_based.cc +++ b/remoting/base/decoder_row_based.cc @@ -46,10 +46,22 @@ void DecoderRowBased::Reset() { frame_ = NULL; decompressor_->Reset(); state_ = kUninitialized; + updated_rects_.clear(); } bool DecoderRowBased::IsReadyForData() { - return state_ == kReady || state_ == kProcessing || state_ == kDone; + switch (state_) { + case kUninitialized: + case kError: + return false; + case kReady: + case kProcessing: + case kPartitionDone: + case kDone: + return true; + } + NOTREACHED(); + return false; } void DecoderRowBased::Initialize(scoped_refptr<media::VideoFrame> frame) { @@ -119,14 +131,18 @@ Decoder::DecodeResult DecoderRowBased::DecodePacket(const VideoPacket* packet) { } } - if (state_ == kDone) { + if (state_ == kPartitionDone || state_ == kDone) { if (row_y_ < clip_.height()) { state_ = kError; LOG(WARNING) << "Received LAST_PACKET, but didn't get enough data."; return DECODE_ERROR; } + updated_rects_.push_back(clip_); decompressor_->Reset(); + } + + if (state_ == kDone) { return DECODE_DONE; } else { return DECODE_IN_PROGRESS; @@ -139,7 +155,7 @@ void DecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) { } if (packet->flags() & VideoPacket::FIRST_PACKET) { - if (state_ != kReady && state_ != kDone) { + if (state_ != kReady && state_ != kDone && state_ != kPartitionDone) { state_ = kError; LOG(WARNING) << "Received unexpected FIRST_PACKET."; return; @@ -165,6 +181,15 @@ void DecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) { LOG(WARNING) << "Received unexpected LAST_PACKET."; return; } + state_ = kPartitionDone; + } + + if (packet->flags() & VideoPacket::LAST_PARTITION) { + if (state_ != kPartitionDone) { + state_ = kError; + LOG(WARNING) << "Received unexpected LAST_PARTITION."; + return; + } state_ = kDone; } @@ -172,7 +197,8 @@ void DecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) { } void DecoderRowBased::GetUpdatedRects(UpdatedRects* rects) { - rects->push_back(clip_); + rects->swap(updated_rects_); + updated_rects_.clear(); } VideoPacketFormat::Encoding DecoderRowBased::Encoding() { |