]> granicus.if.org Git - libvpx/blob - vp10/encoder/aq_cyclicrefresh.h
vp10 cleanup: remove svc code
[libvpx] / vp10 / encoder / aq_cyclicrefresh.h
1 /*
2  *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11
12 #ifndef VP10_ENCODER_AQ_CYCLICREFRESH_H_
13 #define VP10_ENCODER_AQ_CYCLICREFRESH_H_
14
15 #include "vp10/common/blockd.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
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 struct VP10_COMP;
31
32 struct CYCLIC_REFRESH;
33 typedef struct CYCLIC_REFRESH CYCLIC_REFRESH;
34
35 CYCLIC_REFRESH *vp10_cyclic_refresh_alloc(int mi_rows, int mi_cols);
36
37 void vp10_cyclic_refresh_free(CYCLIC_REFRESH *cr);
38
39 // Estimate the bits, incorporating the delta-q from segment 1, after encoding
40 // the frame.
41 int vp10_cyclic_refresh_estimate_bits_at_q(const struct VP10_COMP *cpi,
42                                           double correction_factor);
43
44 // Estimate the bits per mb, for a given q = i and a corresponding delta-q
45 // (for segment 1), prior to encoding the frame.
46 int vp10_cyclic_refresh_rc_bits_per_mb(const struct VP10_COMP *cpi, int i,
47                                       double correction_factor);
48
49 // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col),
50 // check if we should reset the segment_id, and update the cyclic_refresh map
51 // and segmentation map.
52 void vp10_cyclic_refresh_update_segment(struct VP10_COMP *const cpi,
53                                        MB_MODE_INFO *const mbmi,
54                                        int mi_row, int mi_col, BLOCK_SIZE bsize,
55                                        int64_t rate, int64_t dist, int skip);
56
57 // Update the segmentation map, and related quantities: cyclic refresh map,
58 // refresh sb_index, and target number of blocks to be refreshed.
59 void vp10_cyclic_refresh_update__map(struct VP10_COMP *const cpi);
60
61 // Update the actual number of blocks that were applied the segment delta q.
62 void vp10_cyclic_refresh_postencode(struct VP10_COMP *const cpi);
63
64 // Set golden frame update interval, for 1 pass CBR mode.
65 void vp10_cyclic_refresh_set_golden_update(struct VP10_COMP *const cpi);
66
67 // Check if we should not update golden reference, based on past refresh stats.
68 void vp10_cyclic_refresh_check_golden_update(struct VP10_COMP *const cpi);
69
70 // Set/update global/frame level refresh parameters.
71 void vp10_cyclic_refresh_update_parameters(struct VP10_COMP *const cpi);
72
73 // Setup cyclic background refresh: set delta q and segmentation map.
74 void vp10_cyclic_refresh_setup(struct VP10_COMP *const cpi);
75
76 int vp10_cyclic_refresh_get_rdmult(const CYCLIC_REFRESH *cr);
77
78 void vp10_cyclic_refresh_reset_resize(struct VP10_COMP *const cpi);
79
80 static INLINE int cyclic_refresh_segment_id_boosted(int segment_id) {
81   return segment_id == CR_SEGMENT_ID_BOOST1 ||
82          segment_id == CR_SEGMENT_ID_BOOST2;
83 }
84
85 static INLINE int cyclic_refresh_segment_id(int segment_id) {
86   if (segment_id == CR_SEGMENT_ID_BOOST1)
87     return CR_SEGMENT_ID_BOOST1;
88   else if (segment_id == CR_SEGMENT_ID_BOOST2)
89     return CR_SEGMENT_ID_BOOST2;
90   else
91     return CR_SEGMENT_ID_BASE;
92 }
93
94 #ifdef __cplusplus
95 }  // extern "C"
96 #endif
97
98 #endif  // VP10_ENCODER_AQ_CYCLICREFRESH_H_