diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-02 01:08:19 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-02 01:08:19 +0000 |
commit | 04b36141e7b2b1540b1b84a039f6d078ca770442 (patch) | |
tree | ae3b109a5c603c3382a5ae5555d599599a59d03f /remoting/base/encoder_zlib.cc | |
parent | 21a7127af3e46e81d1f2eccf9dccfb8b394d8688 (diff) | |
download | chromium_src-04b36141e7b2b1540b1b84a039f6d078ca770442.zip chromium_src-04b36141e7b2b1540b1b84a039f6d078ca770442.tar.gz chromium_src-04b36141e7b2b1540b1b84a039f6d078ca770442.tar.bz2 |
Cleanups in the video encoding decoding code. Reenable VP8.
1. Moved video-related protobuf messages from event.proto to video.proto. Removed those that we don't need anymore
2. Fixed naming for enums and some types.
3. Reenabled VP8.
4. Proper RGB-YUV converter for VP8 encoder.
5. Changed the capturer_fake to show more meaningful picture.
BUG=57374
TEST=unittests
Review URL: http://codereview.chromium.org/4136010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base/encoder_zlib.cc')
-rw-r--r-- | remoting/base/encoder_zlib.cc | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/remoting/base/encoder_zlib.cc b/remoting/base/encoder_zlib.cc index ddbe923..e184fd3 100644 --- a/remoting/base/encoder_zlib.cc +++ b/remoting/base/encoder_zlib.cc @@ -26,7 +26,7 @@ EncoderZlib::~EncoderZlib() {} void EncoderZlib::Encode(scoped_refptr<CaptureData> capture_data, bool key_frame, DataAvailableCallback* data_available_callback) { - CHECK(capture_data->pixel_format() == PixelFormatRgb32) + CHECK(capture_data->pixel_format() == PIXEL_FORMAT_RGB32) << "Zlib Encoder only works with RGB32. Got " << capture_data->pixel_format(); capture_data_ = capture_data; @@ -51,24 +51,22 @@ void EncoderZlib::EncodeRect(CompressorZlib* compressor, const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format()); const int row_size = bytes_per_pixel * rect.width(); - ChromotingHostMessage* message = new ChromotingHostMessage(); - RectangleUpdatePacket* update = message->mutable_rectangle_update(); - PrepareUpdateStart(rect, update); + VideoPacket* packet = new VideoPacket(); + PrepareUpdateStart(rect, packet); const uint8* in = capture_data_->data_planes().data[0] + rect.y() * strides + rect.x() * bytes_per_pixel; // TODO(hclam): Fill in the sequence number. - uint8* out = GetOutputBuffer(update, packet_size_); + uint8* out = GetOutputBuffer(packet, packet_size_); int filled = 0; int row_x = 0; int row_y = 0; bool compress_again = true; while (compress_again) { // Prepare a message for sending out. - if (!message) { - message = new ChromotingHostMessage(); - update = message->mutable_rectangle_update(); - out = GetOutputBuffer(update, packet_size_); + if (!packet) { + packet = new VideoPacket(); + out = GetOutputBuffer(packet, packet_size_); filled = 0; } @@ -91,15 +89,14 @@ void EncoderZlib::EncodeRect(CompressorZlib* compressor, // We have reached the end of stream. if (!compress_again) { - update->set_flags(update->flags() | RectangleUpdatePacket::LAST_PACKET); + packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET); } // If we have filled the message or we have reached the end of stream. if (filled == packet_size_ || !compress_again) { - message->mutable_rectangle_update()->mutable_encoded_rect()-> - resize(filled); - SubmitMessage(message, rect_index); - message = NULL; + packet->mutable_data()->resize(filled); + SubmitMessage(packet, rect_index); + packet = NULL; } // Reached the end of input row and we're not at the last row. @@ -112,40 +109,27 @@ void EncoderZlib::EncodeRect(CompressorZlib* compressor, } void EncoderZlib::PrepareUpdateStart(const gfx::Rect& rect, - RectangleUpdatePacket* update) { - - update->set_flags(update->flags() | RectangleUpdatePacket::FIRST_PACKET); - RectangleFormat* format = update->mutable_format(); + VideoPacket* packet) { + packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET); + VideoPacketFormat* format = packet->mutable_format(); format->set_x(rect.x()); format->set_y(rect.y()); format->set_width(rect.width()); format->set_height(rect.height()); - format->set_encoding(EncodingZlib); + format->set_encoding(VideoPacketFormat::ENCODING_ZLIB); format->set_pixel_format(capture_data_->pixel_format()); } -uint8* EncoderZlib::GetOutputBuffer(RectangleUpdatePacket* update, - size_t size) { - update->mutable_encoded_rect()->resize(size); +uint8* EncoderZlib::GetOutputBuffer(VideoPacket* packet, size_t size) { + packet->mutable_data()->resize(size); // TODO(ajwong): Is there a better way to do this at all??? return const_cast<uint8*>(reinterpret_cast<const uint8*>( - update->mutable_encoded_rect()->data())); + packet->mutable_data()->data())); } -void EncoderZlib::SubmitMessage(ChromotingHostMessage* message, - size_t rect_index) { - EncodingState state = EncodingInProgress; - const RectangleUpdatePacket& update = message->rectangle_update(); - if (rect_index == 0 && - (update.flags() | RectangleUpdatePacket::FIRST_PACKET)) { - state |= EncodingStarting; - } - if (rect_index == capture_data_->dirty_rects().size() - 1 && - (update.flags() | RectangleUpdatePacket::LAST_PACKET)) { - state |= EncodingEnded; - } - callback_->Run(message, state); +void EncoderZlib::SubmitMessage(VideoPacket* packet, size_t rect_index) { + callback_->Run(packet); } } // namespace remoting |