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 "vp9/common/vp9_blockd.h" | 15 #include "vp9/common/vp9_blockd.h" |
16 | 16 |
17 #ifdef __cplusplus | 17 #ifdef __cplusplus |
18 extern "C" { | 18 extern "C" { |
19 #endif | 19 #endif |
20 | 20 |
| 21 // The segment ids used in cyclic refresh: from base (no boost) to increasing |
| 22 // boost (higher delta-qp). |
| 23 #define CR_SEGMENT_ID_BASE 0 |
| 24 #define CR_SEGMENT_ID_BOOST1 1 |
| 25 #define CR_SEGMENT_ID_BOOST2 2 |
| 26 |
| 27 // Maximum rate target ratio for setting segment delta-qp. |
| 28 #define CR_MAX_RATE_TARGET_RATIO 4.0 |
| 29 |
| 30 // Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2. |
| 31 #define CR_BOOST2_FAC 1.7 |
| 32 |
21 struct VP9_COMP; | 33 struct VP9_COMP; |
22 | 34 |
23 struct CYCLIC_REFRESH; | 35 struct CYCLIC_REFRESH; |
24 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH; | 36 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH; |
25 | 37 |
26 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols); | 38 CYCLIC_REFRESH *vp9_cyclic_refresh_alloc(int mi_rows, int mi_cols); |
27 | 39 |
28 void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr); | 40 void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr); |
29 | 41 |
30 // Estimate the bits, incorporating the delta-q from segment 1, after encoding | 42 // Estimate the bits, incorporating the delta-q from segment 1, after encoding |
31 // the frame. | 43 // the frame. |
32 int vp9_cyclic_refresh_estimate_bits_at_q(const struct VP9_COMP *cpi, | 44 int vp9_cyclic_refresh_estimate_bits_at_q(const struct VP9_COMP *cpi, |
33 double correction_factor); | 45 double correction_factor); |
34 | 46 |
35 // Estimate the bits per mb, for a given q = i and a corresponding delta-q | 47 // Estimate the bits per mb, for a given q = i and a corresponding delta-q |
36 // (for segment 1), prior to encoding the frame. | 48 // (for segment 1), prior to encoding the frame. |
37 int vp9_cyclic_refresh_rc_bits_per_mb(const struct VP9_COMP *cpi, int i, | 49 int vp9_cyclic_refresh_rc_bits_per_mb(const struct VP9_COMP *cpi, int i, |
38 double correction_factor); | 50 double correction_factor); |
39 | 51 |
40 // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col), | 52 // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col), |
41 // check if we should reset the segment_id, and update the cyclic_refresh map | 53 // check if we should reset the segment_id, and update the cyclic_refresh map |
42 // and segmentation map. | 54 // and segmentation map. |
43 void vp9_cyclic_refresh_update_segment(struct VP9_COMP *const cpi, | 55 void vp9_cyclic_refresh_update_segment(struct VP9_COMP *const cpi, |
44 MB_MODE_INFO *const mbmi, | 56 MB_MODE_INFO *const mbmi, |
45 int mi_row, int mi_col, | 57 int mi_row, int mi_col, BLOCK_SIZE bsize, |
46 BLOCK_SIZE bsize, int use_rd, | 58 int64_t rate, int64_t dist); |
47 int64_t rate_sb); | |
48 | 59 |
49 // Update the segmentation map, and related quantities: cyclic refresh map, | 60 // Update the segmentation map, and related quantities: cyclic refresh map, |
50 // refresh sb_index, and target number of blocks to be refreshed. | 61 // refresh sb_index, and target number of blocks to be refreshed. |
51 void vp9_cyclic_refresh_update__map(struct VP9_COMP *const cpi); | 62 void vp9_cyclic_refresh_update__map(struct VP9_COMP *const cpi); |
52 | 63 |
53 // Update the actual number of blocks that were applied the segment delta q. | 64 // Update the actual number of blocks that were applied the segment delta q. |
54 void vp9_cyclic_refresh_update_actual_count(struct VP9_COMP *const cpi); | 65 void vp9_cyclic_refresh_update_actual_count(struct VP9_COMP *const cpi); |
55 | 66 |
56 // Set/update global/frame level refresh parameters. | 67 // Set/update global/frame level refresh parameters. |
57 void vp9_cyclic_refresh_update_parameters(struct VP9_COMP *const cpi); | 68 void vp9_cyclic_refresh_update_parameters(struct VP9_COMP *const cpi); |
58 | 69 |
59 // Setup cyclic background refresh: set delta q and segmentation map. | 70 // Setup cyclic background refresh: set delta q and segmentation map. |
60 void vp9_cyclic_refresh_setup(struct VP9_COMP *const cpi); | 71 void vp9_cyclic_refresh_setup(struct VP9_COMP *const cpi); |
61 | 72 |
62 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr); | 73 int vp9_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr); |
63 | 74 |
64 #ifdef __cplusplus | 75 #ifdef __cplusplus |
65 } // extern "C" | 76 } // extern "C" |
66 #endif | 77 #endif |
67 | 78 |
68 #endif // VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ | 79 #endif // VP9_ENCODER_VP9_AQ_CYCLICREFRESH_H_ |
OLD | NEW |