Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_ratectrl.h

Issue 168343002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_quantize.c ('k') | source/libvpx/vp9/encoder/vp9_ratectrl.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11
12 #ifndef VP9_ENCODER_VP9_RATECTRL_H_ 12 #ifndef VP9_ENCODER_VP9_RATECTRL_H_
13 #define VP9_ENCODER_VP9_RATECTRL_H_ 13 #define VP9_ENCODER_VP9_RATECTRL_H_
14 14
15 #include "vp9/encoder/vp9_onyx_int.h"
16
17 #ifdef __cplusplus 15 #ifdef __cplusplus
18 extern "C" { 16 extern "C" {
19 #endif 17 #endif
20 18
21 #define FRAME_OVERHEAD_BITS 200 19 #define FRAME_OVERHEAD_BITS 200
22 20
23 void vp9_save_coding_context(VP9_COMP *cpi); 21 typedef struct {
24 void vp9_restore_coding_context(VP9_COMP *cpi); 22 // Rate targetting variables
23 int this_frame_target;
24 int projected_frame_size;
25 int sb64_target_rate;
26 int last_q[3]; // Separate values for Intra/Inter/ARF-GF
27 int last_boosted_qindex; // Last boosted GF/KF/ARF q
25 28
26 void vp9_setup_key_frame(VP9_COMP *cpi); 29 int gfu_boost;
27 void vp9_setup_inter_frame(VP9_COMP *cpi); 30 int last_boost;
31 int kf_boost;
32
33 double rate_correction_factor;
34 double key_frame_rate_correction_factor;
35 double gf_rate_correction_factor;
36
37 unsigned int frames_since_golden;
38 unsigned int frames_till_gf_update_due; // Count down till next GF
39 unsigned int max_gf_interval;
40 unsigned int baseline_gf_interval;
41 unsigned int frames_to_key;
42 unsigned int frames_since_key;
43 unsigned int this_key_frame_forced;
44 unsigned int next_key_frame_forced;
45 unsigned int source_alt_ref_pending;
46 unsigned int source_alt_ref_active;
47 unsigned int is_src_frame_alt_ref;
48
49 int av_per_frame_bandwidth; // Average frame size target for clip
50 int min_frame_bandwidth; // Minimum allocation used for any frame
51 int max_frame_bandwidth; // Maximum burst rate allowed for a frame.
52
53 int ni_av_qi;
54 int ni_tot_qi;
55 int ni_frames;
56 int avg_frame_qindex[3]; // 0 - KEY, 1 - INTER, 2 - ARF/GF
57 double tot_q;
58 double avg_q;
59
60 int buffer_level;
61 int bits_off_target;
62
63 int decimation_factor;
64 int decimation_count;
65
66 int rolling_target_bits;
67 int rolling_actual_bits;
68
69 int long_rolling_target_bits;
70 int long_rolling_actual_bits;
71
72 int64_t total_actual_bits;
73 int total_target_vs_actual; // debug stats
74
75 int worst_quality;
76 int best_quality;
77 // int active_best_quality;
78 } RATE_CONTROL;
79
80 struct VP9_COMP;
81
82 void vp9_save_coding_context(struct VP9_COMP *cpi);
83 void vp9_restore_coding_context(struct VP9_COMP *cpi);
84
85 void vp9_setup_key_frame(struct VP9_COMP *cpi);
86 void vp9_setup_inter_frame(struct VP9_COMP *cpi);
28 87
29 double vp9_convert_qindex_to_q(int qindex); 88 double vp9_convert_qindex_to_q(int qindex);
30 89
31 // Updates rate correction factors
32 void vp9_rc_update_rate_correction_factors(VP9_COMP *cpi, int damp_var);
33
34 // initialize luts for minq 90 // initialize luts for minq
35 void vp9_rc_init_minq_luts(void); 91 void vp9_rc_init_minq_luts(void);
36 92
37 // return of 0 means drop frame 93 // Generally at the high level, the following flow is expected
38 // Changes only rc.this_frame_target and rc.sb64_rate_target 94 // to be enforced for rate control:
39 int vp9_rc_pick_frame_size_target(VP9_COMP *cpi); 95 // First call per frame, one of:
96 // vp9_rc_get_one_pass_vbr_params()
97 // vp9_rc_get_one_pass_cbr_params()
98 // vp9_rc_get_svc_params()
99 // vp9_rc_get_first_pass_params()
100 // vp9_rc_get_second_pass_params()
101 // depending on the usage to set the rate control encode parameters desired.
102 //
103 // Then, call encode_frame_to_data_rate() to perform the
104 // actual encode. This function will in turn call encode_frame()
105 // one or more times, followed by one of:
106 // vp9_rc_postencode_update()
107 // vp9_rc_postencode_update_drop_frame()
108 //
109 // The majority of rate control parameters are only expected
110 // to be set in the vp9_rc_get_..._params() functions and
111 // updated during the vp9_rc_postencode_update...() functions.
112 // The only exceptions are vp9_rc_drop_frame() and
113 // vp9_rc_update_rate_correction_factors() functions.
40 114
41 void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi, 115 // Functions to set parameters for encoding before the actual
116 // encode_frame_to_data_rate() function.
117 void vp9_rc_get_one_pass_vbr_params(struct VP9_COMP *cpi);
118 void vp9_rc_get_one_pass_cbr_params(struct VP9_COMP *cpi);
119 void vp9_rc_get_svc_params(struct VP9_COMP *cpi);
120
121 // Post encode update of the rate control parameters based
122 // on bytes used
123 void vp9_rc_postencode_update(struct VP9_COMP *cpi,
124 uint64_t bytes_used);
125 // Post encode update of the rate control parameters for dropped frames
126 void vp9_rc_postencode_update_drop_frame(struct VP9_COMP *cpi);
127
128 // Updates rate correction factors
129 // Changes only the rate correction factors in the rate control structure.
130 void vp9_rc_update_rate_correction_factors(struct VP9_COMP *cpi, int damp_var);
131
132 // Decide if we should drop this frame: For 1-pass CBR.
133 // Changes only the decimation count in the rate control structure
134 int vp9_rc_drop_frame(struct VP9_COMP *cpi);
135
136 // Computes frame size bounds.
137 void vp9_rc_compute_frame_size_bounds(const struct VP9_COMP *cpi,
42 int this_frame_target, 138 int this_frame_target,
43 int *frame_under_shoot_limit, 139 int *frame_under_shoot_limit,
44 int *frame_over_shoot_limit); 140 int *frame_over_shoot_limit);
45 141
46 // Picks q and q bounds given the target for bits 142 // Picks q and q bounds given the target for bits
47 int vp9_rc_pick_q_and_adjust_q_bounds(const VP9_COMP *cpi, 143 int vp9_rc_pick_q_and_bounds(const struct VP9_COMP *cpi,
48 int *bottom_index, 144 int *bottom_index,
49 int *top_index); 145 int *top_index);
50 146
51 // Estimates q to achieve a target bits per frame 147 // Estimates q to achieve a target bits per frame
52 int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame, 148 int vp9_rc_regulate_q(const struct VP9_COMP *cpi, int target_bits_per_frame,
53 int active_best_quality, int active_worst_quality); 149 int active_best_quality, int active_worst_quality);
54 150
55 // Post encode update of the rate control parameters based 151 // Estimates bits per mb for a given qindex and correction factor.
56 // on bytes used
57 void vp9_rc_postencode_update(VP9_COMP *cpi,
58 uint64_t bytes_used);
59 // for dropped frames
60 void vp9_rc_postencode_update_drop_frame(VP9_COMP *cpi);
61
62 // estimates bits per mb for a given qindex and correction factor
63 int vp9_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex, 152 int vp9_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex,
64 double correction_factor); 153 double correction_factor);
65 154
66 // Post encode update of the rate control parameters for 2-pass 155 // Clamping utilities for bitrate targets for iframes and pframes.
67 void vp9_twopass_postencode_update(VP9_COMP *cpi, 156 int vp9_rc_clamp_iframe_target_size(const struct VP9_COMP *const cpi,
68 uint64_t bytes_used); 157 int target);
69 158 int vp9_rc_clamp_pframe_target_size(const struct VP9_COMP *const cpi,
70 // Decide if we should drop this frame: For 1-pass CBR. 159 int target);
71 int vp9_drop_frame(VP9_COMP *cpi); 160 // Utility to set frame_target into the RATE_CONTROL structure
72 161 // This function is called only from the vp9_rc_get_..._params() functions.
73 // Update the buffer level. 162 void vp9_rc_set_frame_target(struct VP9_COMP *cpi, int target);
74 void vp9_update_buffer_level(VP9_COMP *cpi, int encoded_frame_size);
75 163
76 #ifdef __cplusplus 164 #ifdef __cplusplus
77 } // extern "C" 165 } // extern "C"
78 #endif 166 #endif
79 167
80 #endif // VP9_ENCODER_VP9_RATECTRL_H_ 168 #endif // VP9_ENCODER_VP9_RATECTRL_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_quantize.c ('k') | source/libvpx/vp9/encoder/vp9_ratectrl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698