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 |
11 | 11 |
12 #ifndef VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ | 12 #ifndef VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ |
13 #define VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ | 13 #define VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ |
14 | 14 |
| 15 #include "vpx/vpx_integer.h" |
15 #include "vp9/common/vp9_blockd.h" | 16 #include "vp9/common/vp9_blockd.h" |
16 | 17 |
17 #ifdef __cplusplus | 18 #ifdef __cplusplus |
18 extern "C" { | 19 extern "C" { |
19 #endif | 20 #endif |
20 | 21 |
21 // The segment ids used in cyclic refresh: from base (no boost) to increasing | 22 // The segment ids used in cyclic refresh: from base (no boost) to increasing |
22 // boost (higher delta-qp). | 23 // boost (higher delta-qp). |
23 #define CR_SEGMENT_ID_BASE 0 | 24 #define CR_SEGMENT_ID_BASE 0 |
24 #define CR_SEGMENT_ID_BOOST1 1 | 25 #define CR_SEGMENT_ID_BOOST1 1 |
25 #define CR_SEGMENT_ID_BOOST2 2 | 26 #define CR_SEGMENT_ID_BOOST2 2 |
26 | 27 |
27 // Maximum rate target ratio for setting segment delta-qp. | 28 // Maximum rate target ratio for setting segment delta-qp. |
28 #define CR_MAX_RATE_TARGET_RATIO 4.0 | 29 #define CR_MAX_RATE_TARGET_RATIO 4.0 |
29 | 30 |
| 31 struct CYCLIC_REFRESH { |
| 32 // Percentage of blocks per frame that are targeted as candidates |
| 33 // for cyclic refresh. |
| 34 int percent_refresh; |
| 35 // Maximum q-delta as percentage of base q. |
| 36 int max_qdelta_perc; |
| 37 // Superblock starting index for cycling through the frame. |
| 38 int sb_index; |
| 39 // Controls how long block will need to wait to be refreshed again, in |
| 40 // excess of the cycle time, i.e., in the case of all zero motion, block |
| 41 // will be refreshed every (100/percent_refresh + time_for_refresh) frames. |
| 42 int time_for_refresh; |
| 43 // Target number of (8x8) blocks that are set for delta-q. |
| 44 int target_num_seg_blocks; |
| 45 // Actual number of (8x8) blocks that were applied delta-q. |
| 46 int actual_num_seg1_blocks; |
| 47 int actual_num_seg2_blocks; |
| 48 // RD mult. parameters for segment 1. |
| 49 int rdmult; |
| 50 // Cyclic refresh map. |
| 51 signed char *map; |
| 52 // Map of the last q a block was coded at. |
| 53 uint8_t *last_coded_q_map; |
| 54 // Thresholds applied to the projected rate/distortion of the coding block, |
| 55 // when deciding whether block should be refreshed. |
| 56 int64_t thresh_rate_sb; |
| 57 int64_t thresh_dist_sb; |
| 58 // Threshold applied to the motion vector (in units of 1/8 pel) of the |
| 59 // coding block, when deciding whether block should be refreshed. |
| 60 int16_t motion_thresh; |
| 61 // Rate target ratio to set q delta. |
| 62 double rate_ratio_qdelta; |
| 63 // Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2. |
| 64 int rate_boost_fac; |
| 65 double low_content_avg; |
| 66 int qindex_delta[3]; |
| 67 }; |
| 68 |
30 struct VP9_COMP; | 69 struct VP9_COMP; |
31 | 70 |
32 struct CYCLIC_REFRESH; | |
33 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH; | 71 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH; |
34 | 72 |
35 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols); | 73 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols); |
36 | 74 |
37 void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr); | 75 void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr); |
38 | 76 |
39 // Estimate the bits, incorporating the delta-q from segment 1, after encoding | 77 // Estimate the bits, incorporating the delta-q from segment 1, after encoding |
40 // the frame. | 78 // the frame. |
41 int vp9_cyclic_refresh_estimate_bits_at_q(const struct VP9_COMP *cpi, | 79 int vp9_cyclic_refresh_estimate_bits_at_q(const struct VP9_COMP *cpi, |
42 double correction_factor); | 80 double correction_factor); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return CR_SEGMENT_ID_BOOST2; | 127 return CR_SEGMENT_ID_BOOST2; |
90 else | 128 else |
91 return CR_SEGMENT_ID_BASE; | 129 return CR_SEGMENT_ID_BASE; |
92 } | 130 } |
93 | 131 |
94 #ifdef __cplusplus | 132 #ifdef __cplusplus |
95 } // extern "C" | 133 } // extern "C" |
96 #endif | 134 #endif |
97 | 135 |
98 #endif // VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ | 136 #endif // VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ |
OLD | NEW |