| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/cast/video_receiver/codecs/vp8/vp8_decoder.h" | 5 #include "media/cast/video_receiver/codecs/vp8/vp8_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "third_party/libvpx/source/libvpx/vpx/vp8dx.h" | 10 #include "third_party/libvpx/source/libvpx/vpx/vp8dx.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const base::TimeTicks render_time, | 35 const base::TimeTicks render_time, |
| 36 const VideoFrameDecodedCallback& frame_decoded_cb) { | 36 const VideoFrameDecodedCallback& frame_decoded_cb) { |
| 37 const int frame_id_int = static_cast<int>(encoded_frame->frame_id); | 37 const int frame_id_int = static_cast<int>(encoded_frame->frame_id); |
| 38 VLOG(1) << "VP8 decode frame:" << frame_id_int | 38 VLOG(1) << "VP8 decode frame:" << frame_id_int |
| 39 << " sized:" << encoded_frame->data.size(); | 39 << " sized:" << encoded_frame->data.size(); |
| 40 | 40 |
| 41 if (encoded_frame->data.empty()) return false; | 41 if (encoded_frame->data.empty()) return false; |
| 42 | 42 |
| 43 vpx_codec_iter_t iter = NULL; | 43 vpx_codec_iter_t iter = NULL; |
| 44 vpx_image_t* img; | 44 vpx_image_t* img; |
| 45 if (vpx_codec_decode(decoder_.get(), | 45 if (vpx_codec_decode( |
| 46 encoded_frame->data.data(), | 46 decoder_.get(), |
| 47 static_cast<unsigned int>(encoded_frame->data.size()), | 47 reinterpret_cast<const uint8*>(encoded_frame->data.data()), |
| 48 0, | 48 static_cast<unsigned int>(encoded_frame->data.size()), |
| 49 1 /* real time*/)) { | 49 0, |
| 50 1 /* real time*/)) { |
| 50 VLOG(1) << "Failed to decode VP8 frame."; | 51 VLOG(1) << "Failed to decode VP8 frame."; |
| 51 return false; | 52 return false; |
| 52 } | 53 } |
| 53 | 54 |
| 54 img = vpx_codec_get_frame(decoder_.get(), &iter); | 55 img = vpx_codec_get_frame(decoder_.get(), &iter); |
| 55 if (img == NULL) { | 56 if (img == NULL) { |
| 56 VLOG(1) << "Skip rendering VP8 frame:" << frame_id_int; | 57 VLOG(1) << "Skip rendering VP8 frame:" << frame_id_int; |
| 57 return false; | 58 return false; |
| 58 } | 59 } |
| 59 | 60 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 88 // Frame decoded - return frame to the user via callback. | 89 // Frame decoded - return frame to the user via callback. |
| 89 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 90 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
| 90 base::Bind(frame_decoded_cb, base::Passed(&decoded_frame), render_time)); | 91 base::Bind(frame_decoded_cb, base::Passed(&decoded_frame), render_time)); |
| 91 | 92 |
| 92 return true; | 93 return true; |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace cast | 96 } // namespace cast |
| 96 } // namespace media | 97 } // namespace media |
| 97 | 98 |
| OLD | NEW |