| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 (uint64_t)cfg->g_timebase.num / | 81 (uint64_t)cfg->g_timebase.num / |
| 82 (uint64_t)cfg->g_timebase.den; | 82 (uint64_t)cfg->g_timebase.den; |
| 83 | 83 |
| 84 int idx = hist->frames++ % hist->samples; | 84 int idx = hist->frames++ % hist->samples; |
| 85 hist->pts[idx] = now; | 85 hist->pts[idx] = now; |
| 86 hist->sz[idx] = (int)pkt->data.frame.sz; | 86 hist->sz[idx] = (int)pkt->data.frame.sz; |
| 87 | 87 |
| 88 if (now < cfg->rc_buf_initial_sz) | 88 if (now < cfg->rc_buf_initial_sz) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 if (!cfg->rc_target_bitrate) |
| 92 return; |
| 93 |
| 91 then = now; | 94 then = now; |
| 92 | 95 |
| 93 /* Sum the size over the past rc_buf_sz ms */ | 96 /* Sum the size over the past rc_buf_sz ms */ |
| 94 for (i = hist->frames; i > 0 && hist->frames - i < hist->samples; i--) { | 97 for (i = hist->frames; i > 0 && hist->frames - i < hist->samples; i--) { |
| 95 const int i_idx = (i - 1) % hist->samples; | 98 const int i_idx = (i - 1) % hist->samples; |
| 96 | 99 |
| 97 then = hist->pts[i_idx]; | 100 then = hist->pts[i_idx]; |
| 98 if (now - then > cfg->rc_buf_sz) | 101 if (now - then > cfg->rc_buf_sz) |
| 99 break; | 102 break; |
| 100 sum_sz += hist->sz[i_idx]; | 103 sum_sz += hist->sz[i_idx]; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 for (i = 0; i < RATE_BINS; i++) { | 276 for (i = 0; i < RATE_BINS; i++) { |
| 274 if (hist->bucket[i].low == INT_MAX) | 277 if (hist->bucket[i].low == INT_MAX) |
| 275 continue; | 278 continue; |
| 276 hist->bucket[buckets++] = hist->bucket[i]; | 279 hist->bucket[buckets++] = hist->bucket[i]; |
| 277 } | 280 } |
| 278 | 281 |
| 279 fprintf(stderr, "\nRate (over %dms window):\n", cfg->rc_buf_sz); | 282 fprintf(stderr, "\nRate (over %dms window):\n", cfg->rc_buf_sz); |
| 280 scale = merge_hist_buckets(hist->bucket, max_buckets, &buckets); | 283 scale = merge_hist_buckets(hist->bucket, max_buckets, &buckets); |
| 281 show_histogram(hist->bucket, buckets, hist->total, scale); | 284 show_histogram(hist->bucket, buckets, hist->total, scale); |
| 282 } | 285 } |
| OLD | NEW |