| 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_vp8.h" | 5 #include "remoting/base/decoder_vp8.h" |
| 6 | 6 |
| 7 #include "media/base/media.h" | 7 #include "media/base/media.h" |
| 8 #include "media/base/yuv_convert.h" | 8 #include "media/base/yuv_convert.h" |
| 9 #include "remoting/base/util.h" | 9 #include "remoting/base/util.h" |
| 10 | 10 |
| 11 extern "C" { | 11 extern "C" { |
| 12 #define VPX_CODEC_DISABLE_COMPAT 1 | 12 #define VPX_CODEC_DISABLE_COMPAT 1 |
| 13 #include "third_party/libvpx/include/vpx/vpx_codec.h" | 13 #include "third_party/libvpx/include/vpx/vpx_codec.h" |
| 14 #include "third_party/libvpx/include/vpx/vpx_decoder.h" | 14 #include "third_party/libvpx/include/vpx/vpx_decoder.h" |
| 15 #include "third_party/libvpx/include/vpx/vp8dx.h" | 15 #include "third_party/libvpx/include/vpx/vp8dx.h" |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace remoting { | 18 namespace remoting { |
| 19 | 19 |
| 20 DecoderVp8::DecoderVp8() | 20 DecoderVp8::DecoderVp8() |
| 21 : state_(kUninitialized), | 21 : reverse_rows_(true), |
| 22 state_(kUninitialized), |
| 22 codec_(NULL) { | 23 codec_(NULL) { |
| 23 } | 24 } |
| 24 | 25 |
| 25 DecoderVp8::~DecoderVp8() { | 26 DecoderVp8::~DecoderVp8() { |
| 26 if (codec_) { | 27 if (codec_) { |
| 27 vpx_codec_err_t ret = vpx_codec_destroy(codec_); | 28 vpx_codec_err_t ret = vpx_codec_destroy(codec_); |
| 28 CHECK(ret == VPX_CODEC_OK) << "Failed to destroy codec"; | 29 CHECK(ret == VPX_CODEC_OK) << "Failed to destroy codec"; |
| 29 } | 30 } |
| 30 delete codec_; | 31 delete codec_; |
| 31 } | 32 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 // Gets the decoded data. | 77 // Gets the decoded data. |
| 77 vpx_codec_iter_t iter = NULL; | 78 vpx_codec_iter_t iter = NULL; |
| 78 vpx_image_t* image = vpx_codec_get_frame(codec_, &iter); | 79 vpx_image_t* image = vpx_codec_get_frame(codec_, &iter); |
| 79 if (!image) { | 80 if (!image) { |
| 80 LOG(INFO) << "No video frame decoded"; | 81 LOG(INFO) << "No video frame decoded"; |
| 81 return DECODE_ERROR; | 82 return DECODE_ERROR; |
| 82 } | 83 } |
| 83 | 84 |
| 84 // Perform YUV conversion. | 85 // Perform YUV conversion. |
| 86 uint8* data_start = frame_->data(media::VideoFrame::kRGBPlane); |
| 87 int stride = frame_->stride(media::VideoFrame::kRGBPlane); |
| 88 if (reverse_rows_) { |
| 89 data_start = data_start + (frame_->height() - 1) * stride; |
| 90 stride = -stride; |
| 91 } |
| 92 |
| 85 media::ConvertYUVToRGB32(image->planes[0], image->planes[1], image->planes[2], | 93 media::ConvertYUVToRGB32(image->planes[0], image->planes[1], image->planes[2], |
| 86 frame_->data(media::VideoFrame::kRGBPlane), | 94 data_start, frame_->width(), frame_->height(), |
| 87 frame_->width(), frame_->height(), | 95 image->stride[0], image->stride[1], stride, |
| 88 image->stride[0], image->stride[1], | |
| 89 frame_->stride(media::VideoFrame::kRGBPlane), | |
| 90 media::YV12); | 96 media::YV12); |
| 91 return DECODE_DONE; | 97 return DECODE_DONE; |
| 92 } | 98 } |
| 93 | 99 |
| 94 void DecoderVp8::GetUpdatedRects(UpdatedRects* rects) { | 100 void DecoderVp8::GetUpdatedRects(UpdatedRects* rects) { |
| 95 } | 101 } |
| 96 | 102 |
| 97 void DecoderVp8::Reset() { | 103 void DecoderVp8::Reset() { |
| 98 frame_ = NULL; | 104 frame_ = NULL; |
| 99 state_ = kUninitialized; | 105 state_ = kUninitialized; |
| 100 } | 106 } |
| 101 | 107 |
| 102 bool DecoderVp8::IsReadyForData() { | 108 bool DecoderVp8::IsReadyForData() { |
| 103 return state_ == kReady; | 109 return state_ == kReady; |
| 104 } | 110 } |
| 105 | 111 |
| 106 VideoPacketFormat::Encoding DecoderVp8::Encoding() { | 112 VideoPacketFormat::Encoding DecoderVp8::Encoding() { |
| 107 return VideoPacketFormat::ENCODING_VP8; | 113 return VideoPacketFormat::ENCODING_VP8; |
| 108 } | 114 } |
| 109 | 115 |
| 110 } // namespace remoting | 116 } // namespace remoting |
| OLD | NEW |