| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. |
| 3 * Copyright 2010 Google Inc. | |
| 4 * | 3 * |
| 5 * Redistribution and use in source and binary forms, with or without | 4 * Use of this source code is governed by a BSD-style license |
| 6 * modification, are permitted provided that the following conditions are met: | 5 * that can be found in the LICENSE file in the root of the source |
| 7 * | 6 * tree. An additional intellectual property rights grant can be found |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 7 * in the file PATENTS. All contributing project authors may |
| 9 * this list of conditions and the following disclaimer. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 11 * this list of conditions and the following disclaimer in the documentation | |
| 12 * and/or other materials provided with the distribution. | |
| 13 * 3. The name of the author may not be used to endorse or promote products | |
| 14 * derived from this software without specific prior written permission. | |
| 15 * | |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 */ | 9 */ |
| 27 | 10 |
| 28 #include "talk/media/base/videoadapter.h" | 11 #include "webrtc/media/base/videoadapter.h" |
| 29 | 12 |
| 30 #include <limits.h> // For INT_MAX | 13 #include <limits.h> // For INT_MAX |
| 31 #include <algorithm> | 14 #include <algorithm> |
| 32 | 15 |
| 33 #include "talk/media/base/constants.h" | |
| 34 #include "talk/media/base/videocommon.h" | |
| 35 #include "talk/media/base/videoframe.h" | |
| 36 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
| 37 #include "webrtc/base/timeutils.h" | 17 #include "webrtc/base/timeutils.h" |
| 18 #include "webrtc/media/base/constants.h" |
| 19 #include "webrtc/media/base/videocommon.h" |
| 20 #include "webrtc/media/base/videoframe.h" |
| 38 | 21 |
| 39 namespace cricket { | 22 namespace cricket { |
| 40 | 23 |
| 41 // TODO(fbarchard): Make downgrades settable | 24 // TODO(fbarchard): Make downgrades settable |
| 42 static const int kMaxCpuDowngrades = 2; // Downgrade at most 2 times for CPU. | 25 static const int kMaxCpuDowngrades = 2; // Downgrade at most 2 times for CPU. |
| 43 // The number of cpu samples to require before adapting. This value depends on | 26 // The number of cpu samples to require before adapting. This value depends on |
| 44 // the cpu monitor sampling frequency being 2000ms. | 27 // the cpu monitor sampling frequency being 2000ms. |
| 45 static const int kCpuLoadMinSamples = 3; | 28 static const int kCpuLoadMinSamples = 3; |
| 46 // The amount of weight to give to each new cpu load sample. The lower the | 29 // The amount of weight to give to each new cpu load sample. The lower the |
| 47 // value, the slower we'll adapt to changing cpu conditions. | 30 // value, the slower we'll adapt to changing cpu conditions. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 << "x" << in_height | 279 << "x" << in_height |
| 297 << " i" << input_format_.interval | 280 << " i" << input_format_.interval |
| 298 << " Output: i" << output_format_.interval; | 281 << " Output: i" << output_format_.interval; |
| 299 } | 282 } |
| 300 | 283 |
| 301 return VideoFormat(); // Drop frame. | 284 return VideoFormat(); // Drop frame. |
| 302 } | 285 } |
| 303 | 286 |
| 304 const float scale = VideoAdapter::FindClosestViewScale( | 287 const float scale = VideoAdapter::FindClosestViewScale( |
| 305 in_width, in_height, output_num_pixels_); | 288 in_width, in_height, output_num_pixels_); |
| 306 const int output_width = static_cast<int>(in_width * scale + .5f); | 289 const size_t output_width = static_cast<size_t>(in_width * scale + .5f); |
| 307 const int output_height = static_cast<int>(in_height * scale + .5f); | 290 const size_t output_height = static_cast<size_t>(in_height * scale + .5f); |
| 308 | 291 |
| 309 ++frames_out_; | 292 ++frames_out_; |
| 310 if (scale != 1) | 293 if (scale != 1) |
| 311 ++frames_scaled_; | 294 ++frames_scaled_; |
| 312 // Show VAdapt log every 90 frames output. (3 seconds) | 295 // Show VAdapt log every 90 frames output. (3 seconds) |
| 313 // TODO(fbarchard): Consider GetLogSeverity() to change interval to less | 296 // TODO(fbarchard): Consider GetLogSeverity() to change interval to less |
| 314 // for LS_VERBOSE and more for LS_INFO. | 297 // for LS_VERBOSE and more for LS_INFO. |
| 315 bool show = (frames_out_) % 90 == 0; | 298 bool show = (frames_out_) % 90 == 0; |
| 316 | 299 |
| 317 // TODO(fbarchard): LOG the previous output resolution and track input | 300 // TODO(fbarchard): LOG the previous output resolution and track input |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // When any adaptation occurs, historic CPU load levels are no longer | 693 // When any adaptation occurs, historic CPU load levels are no longer |
| 711 // accurate. Clear out our state so we can re-learn at the new normal. | 694 // accurate. Clear out our state so we can re-learn at the new normal. |
| 712 cpu_load_num_samples_ = 0; | 695 cpu_load_num_samples_ = 0; |
| 713 system_load_average_ = kCpuLoadInitialAverage; | 696 system_load_average_ = kCpuLoadInitialAverage; |
| 714 } | 697 } |
| 715 | 698 |
| 716 return changed; | 699 return changed; |
| 717 } | 700 } |
| 718 | 701 |
| 719 } // namespace cricket | 702 } // namespace cricket |
| OLD | NEW |