2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
12 #ifndef VP9_ENCODER_VP9_RATECTRL_H_
13 #define VP9_ENCODER_VP9_RATECTRL_H_
15 #include "vp9/encoder/vp9_onyx_int.h"
17 #define FRAME_OVERHEAD_BITS 200
19 void vp9_save_coding_context(VP9_COMP *cpi);
20 void vp9_restore_coding_context(VP9_COMP *cpi);
22 void vp9_setup_key_frame(VP9_COMP *cpi);
23 void vp9_setup_inter_frame(VP9_COMP *cpi);
25 double vp9_convert_qindex_to_q(int qindex);
27 // Updates rate correction factors
28 void vp9_rc_update_rate_correction_factors(VP9_COMP *cpi, int damp_var);
30 // initialize luts for minq
31 void vp9_rc_init_minq_luts(void);
33 // return of 0 means drop frame
34 // Changes only rc.this_frame_target and rc.sb64_rate_target
35 int vp9_rc_pick_frame_size_target(VP9_COMP *cpi);
37 void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi,
38 int this_frame_target,
39 int *frame_under_shoot_limit,
40 int *frame_over_shoot_limit);
42 // Picks q and q bounds given the target for bits
43 int vp9_rc_pick_q_and_adjust_q_bounds(const VP9_COMP *cpi,
47 // Estimates q to achieve a target bits per frame
48 int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame,
49 int active_best_quality, int active_worst_quality);
51 // Post encode update of the rate control parameters based
53 void vp9_rc_postencode_update(VP9_COMP *cpi,
56 // estimates bits per mb for a given qindex and correction factor
57 int vp9_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex,
58 double correction_factor);
60 // Post encode update of the rate control parameters for 2-pass
61 void vp9_twopass_postencode_update(VP9_COMP *cpi,
64 // Decide if we should drop this frame: For 1-pass CBR.
65 int vp9_drop_frame(VP9_COMP *cpi);
67 // Update the buffer level.
68 void vp9_update_buffer_level(VP9_COMP *cpi, int encoded_frame_size);
70 #endif // VP9_ENCODER_VP9_RATECTRL_H_