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
;
42 #define VLOW_MOTION_THRESHOLD 950
49 double sr_coded_error
;
52 double pcnt_second_ref
;
54 double intra_skip_pct
;
55 double inactive_zone_rows
; // Image mask rows top and bottom.
56 double inactive_zone_cols
; // Image mask columns at left and right edges.
63 double mv_in_out_count
;
67 int64_t spatial_layer_id
;
76 FRAME_UPDATE_TYPES
= 5
79 #define FC_ANIMATION_THRESH 0.15
82 FC_GRAPHICS_ANIMATION
= 1,
83 FRAME_CONTENT_TYPES
= 2
88 RATE_FACTOR_LEVEL rf_level
[(MAX_LAG_BUFFERS
* 2) + 1];
89 FRAME_UPDATE_TYPE update_type
[(MAX_LAG_BUFFERS
* 2) + 1];
90 unsigned char arf_src_offset
[(MAX_LAG_BUFFERS
* 2) + 1];
91 unsigned char arf_update_idx
[(MAX_LAG_BUFFERS
* 2) + 1];
92 unsigned char arf_ref_idx
[(MAX_LAG_BUFFERS
* 2) + 1];
93 int bit_allocation
[(MAX_LAG_BUFFERS
* 2) + 1];
97 unsigned int section_intra_rating
;
98 FIRSTPASS_STATS total_stats
;
99 FIRSTPASS_STATS this_frame_stats
;
100 const FIRSTPASS_STATS
*stats_in
;
101 const FIRSTPASS_STATS
*stats_in_start
;
102 const FIRSTPASS_STATS
*stats_in_end
;
103 FIRSTPASS_STATS total_left_stats
;
106 double modified_error_min
;
107 double modified_error_max
;
108 double modified_error_left
;
111 #if CONFIG_FP_MB_STATS
112 uint8_t *frame_mb_stats_buf
;
113 uint8_t *this_frame_mb_stats
;
114 FIRSTPASS_MB_STATS firstpass_mb_stats
;
116 // An indication of the content type of the current frame
117 FRAME_CONTENT_TYPE fr_content_type
;
119 // Projected total bits available for a key frame group of frames
120 int64_t kf_group_bits
;
122 // Error score of frames still to be coded in kf group
123 int64_t kf_group_error_left
;
125 // The fraction for a kf groups total bits allocated to the inter frames
126 double kfgroup_inter_fraction
;
130 int kf_zeromotion_pct
;
131 int last_kfgroup_zeromotion_pct
;
132 int gf_zeromotion_pct
;
133 int active_worst_quality
;
134 int baseline_active_worst_quality
;
137 int extend_minq_fast
;
144 void vp9_init_first_pass(struct VP9_COMP
*cpi
);
145 void vp9_rc_get_first_pass_params(struct VP9_COMP
*cpi
);
146 void vp9_first_pass(struct VP9_COMP
*cpi
, const struct lookahead_entry
*source
);
147 void vp9_end_first_pass(struct VP9_COMP
*cpi
);
149 void vp9_init_second_pass(struct VP9_COMP
*cpi
);
150 void vp9_rc_get_second_pass_params(struct VP9_COMP
*cpi
);
151 void vp9_twopass_postencode_update(struct VP9_COMP
*cpi
);
153 // Post encode update of the rate control parameters for 2-pass
154 void vp9_twopass_postencode_update(struct VP9_COMP
*cpi
);
156 void vp9_init_subsampling(struct VP9_COMP
*cpi
);
158 void calculate_coded_size(struct VP9_COMP
*cpi
,
159 int *scaled_frame_width
,
160 int *scaled_frame_height
);
166 #endif // VP9_ENCODER_VP9_FIRSTPASS_H_