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 "remoting/codec/video_decoder_vpx.h" | 5 #include "remoting/codec/video_decoder_vpx.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 vpx_codec_err_t ret = | 54 vpx_codec_err_t ret = |
55 vpx_codec_dec_init(codec.get(), vpx_codec_vp8_dx(), &config, 0); | 55 vpx_codec_dec_init(codec.get(), vpx_codec_vp8_dx(), &config, 0); |
56 if (ret != VPX_CODEC_OK) { | 56 if (ret != VPX_CODEC_OK) { |
57 LOG(INFO) << "Cannot initialize codec."; | 57 LOG(INFO) << "Cannot initialize codec."; |
58 return scoped_ptr<VideoDecoderVpx>(); | 58 return scoped_ptr<VideoDecoderVpx>(); |
59 } | 59 } |
60 | 60 |
61 return scoped_ptr<VideoDecoderVpx>(new VideoDecoderVpx(codec.Pass())); | 61 return scoped_ptr<VideoDecoderVpx>(new VideoDecoderVpx(codec.Pass())); |
62 } | 62 } |
63 | 63 |
| 64 // static |
| 65 scoped_ptr<VideoDecoderVpx> VideoDecoderVpx::CreateForVP9() { |
| 66 ScopedVpxCodec codec(new vpx_codec_ctx_t); |
| 67 |
| 68 // TODO(hclam): Scale the number of threads with number of cores of the |
| 69 // machine. |
| 70 vpx_codec_dec_cfg config; |
| 71 config.w = 0; |
| 72 config.h = 0; |
| 73 config.threads = 2; |
| 74 vpx_codec_err_t ret = |
| 75 vpx_codec_dec_init(codec.get(), vpx_codec_vp9_dx(), &config, 0); |
| 76 if (ret != VPX_CODEC_OK) { |
| 77 LOG(INFO) << "Cannot initialize codec."; |
| 78 return scoped_ptr<VideoDecoderVpx>(); |
| 79 } |
| 80 |
| 81 return scoped_ptr<VideoDecoderVpx>(new VideoDecoderVpx(codec.Pass())); |
| 82 } |
| 83 |
64 VideoDecoderVpx::~VideoDecoderVpx() {} | 84 VideoDecoderVpx::~VideoDecoderVpx() {} |
65 | 85 |
66 void VideoDecoderVpx::Initialize(const webrtc::DesktopSize& screen_size) { | 86 void VideoDecoderVpx::Initialize(const webrtc::DesktopSize& screen_size) { |
67 DCHECK(!screen_size.is_empty()); | 87 DCHECK(!screen_size.is_empty()); |
68 | 88 |
69 screen_size_ = screen_size; | 89 screen_size_ = screen_size; |
70 | 90 |
71 transparent_region_.SetRect(webrtc::DesktopRect::MakeSize(screen_size_)); | 91 transparent_region_.SetRect(webrtc::DesktopRect::MakeSize(screen_size_)); |
72 } | 92 } |
73 | 93 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 webrtc::DesktopRegion difference = *new_desktop_shape; | 300 webrtc::DesktopRegion difference = *new_desktop_shape; |
281 difference.Subtract(desktop_shape_); | 301 difference.Subtract(desktop_shape_); |
282 updated_region_.AddRegion(difference); | 302 updated_region_.AddRegion(difference); |
283 updated_region_.IntersectWith(*new_desktop_shape); | 303 updated_region_.IntersectWith(*new_desktop_shape); |
284 | 304 |
285 // Set the new desktop shape region. | 305 // Set the new desktop shape region. |
286 desktop_shape_.Swap(new_desktop_shape); | 306 desktop_shape_.Swap(new_desktop_shape); |
287 } | 307 } |
288 | 308 |
289 } // namespace remoting | 309 } // namespace remoting |
OLD | NEW |