OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 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 | 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. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 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 | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 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, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 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 | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/media/base/videoadapter.h" | 28 #include "webrtc/media/base/videoadapter.h" |
29 | 29 |
30 #include <limits.h> // For INT_MAX | 30 #include <limits.h> // For INT_MAX |
31 #include <algorithm> | 31 #include <algorithm> |
32 | 32 |
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" | 33 #include "webrtc/base/logging.h" |
37 #include "webrtc/base/timeutils.h" | 34 #include "webrtc/base/timeutils.h" |
| 35 #include "webrtc/media/base/constants.h" |
| 36 #include "webrtc/media/base/videocommon.h" |
| 37 #include "webrtc/media/base/videoframe.h" |
38 | 38 |
39 namespace cricket { | 39 namespace cricket { |
40 | 40 |
41 // TODO(fbarchard): Make downgrades settable | 41 // TODO(fbarchard): Make downgrades settable |
42 static const int kMaxCpuDowngrades = 2; // Downgrade at most 2 times for CPU. | 42 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 | 43 // The number of cpu samples to require before adapting. This value depends on |
44 // the cpu monitor sampling frequency being 2000ms. | 44 // the cpu monitor sampling frequency being 2000ms. |
45 static const int kCpuLoadMinSamples = 3; | 45 static const int kCpuLoadMinSamples = 3; |
46 // The amount of weight to give to each new cpu load sample. The lower the | 46 // 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. | 47 // 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 | 296 << "x" << in_height |
297 << " i" << input_format_.interval | 297 << " i" << input_format_.interval |
298 << " Output: i" << output_format_.interval; | 298 << " Output: i" << output_format_.interval; |
299 } | 299 } |
300 | 300 |
301 return VideoFormat(); // Drop frame. | 301 return VideoFormat(); // Drop frame. |
302 } | 302 } |
303 | 303 |
304 const float scale = VideoAdapter::FindClosestViewScale( | 304 const float scale = VideoAdapter::FindClosestViewScale( |
305 in_width, in_height, output_num_pixels_); | 305 in_width, in_height, output_num_pixels_); |
306 const int output_width = static_cast<int>(in_width * scale + .5f); | 306 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); | 307 const size_t output_height = static_cast<size_t>(in_height * scale + .5f); |
308 | 308 |
309 ++frames_out_; | 309 ++frames_out_; |
310 if (scale != 1) | 310 if (scale != 1) |
311 ++frames_scaled_; | 311 ++frames_scaled_; |
312 // Show VAdapt log every 90 frames output. (3 seconds) | 312 // Show VAdapt log every 90 frames output. (3 seconds) |
313 // TODO(fbarchard): Consider GetLogSeverity() to change interval to less | 313 // TODO(fbarchard): Consider GetLogSeverity() to change interval to less |
314 // for LS_VERBOSE and more for LS_INFO. | 314 // for LS_VERBOSE and more for LS_INFO. |
315 bool show = (frames_out_) % 90 == 0; | 315 bool show = (frames_out_) % 90 == 0; |
316 | 316 |
317 // TODO(fbarchard): LOG the previous output resolution and track input | 317 // 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 | 710 // 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. | 711 // accurate. Clear out our state so we can re-learn at the new normal. |
712 cpu_load_num_samples_ = 0; | 712 cpu_load_num_samples_ = 0; |
713 system_load_average_ = kCpuLoadInitialAverage; | 713 system_load_average_ = kCpuLoadInitialAverage; |
714 } | 714 } |
715 | 715 |
716 return changed; | 716 return changed; |
717 } | 717 } |
718 | 718 |
719 } // namespace cricket | 719 } // namespace cricket |
OLD | NEW |