OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_encoder_vpx.h" | 5 #include "remoting/codec/video_encoder_vpx.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/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 memset(image_.get(), 0, sizeof(vpx_image_t)); | 190 memset(image_.get(), 0, sizeof(vpx_image_t)); |
191 | 191 |
192 image_->fmt = VPX_IMG_FMT_YV12; | 192 image_->fmt = VPX_IMG_FMT_YV12; |
193 | 193 |
194 // libvpx seems to require both to be assigned. | 194 // libvpx seems to require both to be assigned. |
195 image_->d_w = size.width(); | 195 image_->d_w = size.width(); |
196 image_->w = size.width(); | 196 image_->w = size.width(); |
197 image_->d_h = size.height(); | 197 image_->d_h = size.height(); |
198 image_->h = size.height(); | 198 image_->h = size.height(); |
199 | 199 |
200 // libvpx should derive this from|fmt| but currently has a bug. | |
201 image_->x_chroma_shift = 1; | |
202 image_->y_chroma_shift = 1; | |
Jamie
2013/10/21 18:28:20
Does this bug only affect VP9? If not, then this s
Wez
2013/10/22 01:13:01
We only need to set this due to a bug in libvpx. I
| |
203 | |
200 // Initialize active map. | 204 // Initialize active map. |
201 active_map_width_ = (image_->w + kMacroBlockSize - 1) / kMacroBlockSize; | 205 active_map_width_ = (image_->w + kMacroBlockSize - 1) / kMacroBlockSize; |
202 active_map_height_ = (image_->h + kMacroBlockSize - 1) / kMacroBlockSize; | 206 active_map_height_ = (image_->h + kMacroBlockSize - 1) / kMacroBlockSize; |
203 active_map_.reset(new uint8[active_map_width_ * active_map_height_]); | 207 active_map_.reset(new uint8[active_map_width_ * active_map_height_]); |
204 | 208 |
205 // YUV image size is 1.5 times of a plane. Multiplication is performed first | 209 // YUV image size is 1.5 times of a plane. Multiplication is performed first |
206 // to avoid rounding error. | 210 // to avoid rounding error. |
207 const int y_plane_size = image_->w * image_->h; | 211 const int y_plane_size = image_->w * image_->h; |
208 const int uv_width = (image_->w + 1) / 2; | 212 const int uv_width = (image_->w + 1) / 2; |
209 const int uv_height = (image_->h + 1) / 2; | 213 const int uv_height = (image_->h + 1) / 2; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 uint8* map = active_map_.get() + top * active_map_width_; | 311 uint8* map = active_map_.get() + top * active_map_width_; |
308 for (int y = top; y <= bottom; ++y) { | 312 for (int y = top; y <= bottom; ++y) { |
309 for (int x = left; x <= right; ++x) | 313 for (int x = left; x <= right; ++x) |
310 map[x] = 1; | 314 map[x] = 1; |
311 map += active_map_width_; | 315 map += active_map_width_; |
312 } | 316 } |
313 } | 317 } |
314 } | 318 } |
315 | 319 |
316 } // namespace remoting | 320 } // namespace remoting |
OLD | NEW |