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.
11 #ifndef VP9_ENCODER_VP9_FIRSTPASS_H_
12 #define VP9_ENCODER_VP9_FIRSTPASS_H_
14 #include "vp9/encoder/vp9_lookahead.h"
15 #include "vp9/encoder/vp9_ratectrl.h"
21 #if CONFIG_FP_MB_STATS
23 #define FPMB_DCINTRA_MASK 0x01
25 #define FPMB_MOTION_ZERO_MASK 0x02
26 #define FPMB_MOTION_LEFT_MASK 0x04
27 #define FPMB_MOTION_RIGHT_MASK 0x08
28 #define FPMB_MOTION_UP_MASK 0x10
29 #define FPMB_MOTION_DOWN_MASK 0x20
31 #define FPMB_ERROR_SMALL_MASK 0x40
32 #define FPMB_ERROR_LARGE_MASK 0x80
33 #define FPMB_ERROR_SMALL_TH 2000
34 #define FPMB_ERROR_LARGE_TH 48000
37 uint8_t *mb_stats_start;
38 uint8_t *mb_stats_end;
46 double sr_coded_error;
49 double pcnt_second_ref;
57 double mv_in_out_count;
61 int64_t spatial_layer_id;
70 FRAME_UPDATE_TYPES = 5
75 RATE_FACTOR_LEVEL rf_level[(MAX_LAG_BUFFERS * 2) + 1];
76 FRAME_UPDATE_TYPE update_type[(MAX_LAG_BUFFERS * 2) + 1];
77 unsigned char arf_src_offset[(MAX_LAG_BUFFERS * 2) + 1];
78 unsigned char arf_update_idx[(MAX_LAG_BUFFERS * 2) + 1];
79 unsigned char arf_ref_idx[(MAX_LAG_BUFFERS * 2) + 1];
80 int bit_allocation[(MAX_LAG_BUFFERS * 2) + 1];
84 unsigned int section_intra_rating;
85 FIRSTPASS_STATS total_stats;
86 FIRSTPASS_STATS this_frame_stats;
87 const FIRSTPASS_STATS *stats_in;
88 const FIRSTPASS_STATS *stats_in_start;
89 const FIRSTPASS_STATS *stats_in_end;
90 FIRSTPASS_STATS total_left_stats;
93 double modified_error_min;
94 double modified_error_max;
95 double modified_error_left;
97 #if CONFIG_FP_MB_STATS
98 uint8_t *frame_mb_stats_buf;
99 uint8_t *this_frame_mb_stats;
100 FIRSTPASS_MB_STATS firstpass_mb_stats;
103 // Projected total bits available for a key frame group of frames
104 int64_t kf_group_bits;
106 // Error score of frames still to be coded in kf group
107 int64_t kf_group_error_left;
110 int kf_zeromotion_pct;
111 int last_kfgroup_zeromotion_pct;
112 int gf_zeromotion_pct;
114 int active_worst_quality;
121 void vp9_init_first_pass(struct VP9_COMP *cpi);
122 void vp9_rc_get_first_pass_params(struct VP9_COMP *cpi);
123 void vp9_first_pass(struct VP9_COMP *cpi, const struct lookahead_entry *source);
124 void vp9_end_first_pass(struct VP9_COMP *cpi);
126 void vp9_init_second_pass(struct VP9_COMP *cpi);
127 void vp9_rc_get_second_pass_params(struct VP9_COMP *cpi);
129 // Post encode update of the rate control parameters for 2-pass
130 void vp9_twopass_postencode_update(struct VP9_COMP *cpi);
135 #endif // VP9_ENCODER_VP9_FIRSTPASS_H_