OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
11 #include <assert.h> | 11 #include <assert.h> |
12 #include <limits.h> | 12 #include <limits.h> |
13 #include <math.h> | 13 #include <math.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 #include <string.h> | 16 #include <string.h> |
17 | 17 |
| 18 #include "vpx_dsp/vpx_dsp_common.h" |
18 #include "vpx_mem/vpx_mem.h" | 19 #include "vpx_mem/vpx_mem.h" |
19 #include "vpx_ports/mem.h" | 20 #include "vpx_ports/mem.h" |
20 #include "vpx_ports/system_state.h" | 21 #include "vpx_ports/system_state.h" |
21 | 22 |
22 #include "vp9/common/vp9_alloccommon.h" | 23 #include "vp9/common/vp9_alloccommon.h" |
23 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" | 24 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" |
24 #include "vp9/common/vp9_common.h" | 25 #include "vp9/common/vp9_common.h" |
25 #include "vp9/common/vp9_entropymode.h" | 26 #include "vp9/common/vp9_entropymode.h" |
26 #include "vp9/common/vp9_quant_common.h" | 27 #include "vp9/common/vp9_quant_common.h" |
27 #include "vp9/common/vp9_seg_common.h" | 28 #include "vp9/common/vp9_seg_common.h" |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 int avg_qp = cpi->resize_avg_qp / cpi->resize_count; | 1843 int avg_qp = cpi->resize_avg_qp / cpi->resize_count; |
1843 // Resize down if buffer level has underflowed sufficent amount in past | 1844 // Resize down if buffer level has underflowed sufficent amount in past |
1844 // window, and we are at original resolution. | 1845 // window, and we are at original resolution. |
1845 // Resize back up if average QP is low, and we are currently in a resized | 1846 // Resize back up if average QP is low, and we are currently in a resized |
1846 // down state. | 1847 // down state. |
1847 if (cpi->resize_state == 0 && | 1848 if (cpi->resize_state == 0 && |
1848 cpi->resize_buffer_underflow > (cpi->resize_count >> 2)) { | 1849 cpi->resize_buffer_underflow > (cpi->resize_count >> 2)) { |
1849 resize_now = 1; | 1850 resize_now = 1; |
1850 cpi->resize_state = 1; | 1851 cpi->resize_state = 1; |
1851 } else if (cpi->resize_state == 1 && | 1852 } else if (cpi->resize_state == 1 && |
1852 avg_qp < 40 * cpi->rc.worst_quality / 100) { | 1853 avg_qp < 50 * cpi->rc.worst_quality / 100) { |
1853 resize_now = -1; | 1854 resize_now = -1; |
1854 cpi->resize_state = 0; | 1855 cpi->resize_state = 0; |
1855 } | 1856 } |
1856 // Reset for next window measurement. | 1857 // Reset for next window measurement. |
1857 cpi->resize_avg_qp = 0; | 1858 cpi->resize_avg_qp = 0; |
1858 cpi->resize_count = 0; | 1859 cpi->resize_count = 0; |
1859 cpi->resize_buffer_underflow = 0; | 1860 cpi->resize_buffer_underflow = 0; |
1860 } | 1861 } |
1861 } | 1862 } |
1862 // If decision is to resize, reset some quantities, and check is we should | 1863 // If decision is to resize, reset some quantities, and check is we should |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 // frame to select low QP and overshoot again. | 1982 // frame to select low QP and overshoot again. |
1982 // TODO(marpan): Check if rate correction factor should also be adjusted. | 1983 // TODO(marpan): Check if rate correction factor should also be adjusted. |
1983 cpi->rc.avg_frame_qindex[INTER_FRAME] = *q; | 1984 cpi->rc.avg_frame_qindex[INTER_FRAME] = *q; |
1984 rc->buffer_level = rc->optimal_buffer_level; | 1985 rc->buffer_level = rc->optimal_buffer_level; |
1985 rc->bits_off_target = rc->optimal_buffer_level; | 1986 rc->bits_off_target = rc->optimal_buffer_level; |
1986 return 1; | 1987 return 1; |
1987 } else { | 1988 } else { |
1988 return 0; | 1989 return 0; |
1989 } | 1990 } |
1990 } | 1991 } |
OLD | NEW |