]> granicus.if.org Git - libvpx/blob - vp10/encoder/firstpass.h
vp10 cleanup: remove svc code
[libvpx] / vp10 / encoder / firstpass.h
1 /*
2  *  Copyright (c) 2010 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 #ifndef VP10_ENCODER_FIRSTPASS_H_
12 #define VP10_ENCODER_FIRSTPASS_H_
13
14 #include "vp10/encoder/lookahead.h"
15 #include "vp10/encoder/ratectrl.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #if CONFIG_FP_MB_STATS
22
23 #define FPMB_DCINTRA_MASK 0x01
24
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
30
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
35
36 typedef struct {
37   uint8_t *mb_stats_start;
38   uint8_t *mb_stats_end;
39 } FIRSTPASS_MB_STATS;
40 #endif
41
42 #define VLOW_MOTION_THRESHOLD 950
43
44 typedef struct {
45   double frame;
46   double weight;
47   double intra_error;
48   double coded_error;
49   double sr_coded_error;
50   double pcnt_inter;
51   double pcnt_motion;
52   double pcnt_second_ref;
53   double pcnt_neutral;
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.
57   double MVr;
58   double mvr_abs;
59   double MVc;
60   double mvc_abs;
61   double MVrv;
62   double MVcv;
63   double mv_in_out_count;
64   double new_mv_count;
65   double duration;
66   double count;
67 } FIRSTPASS_STATS;
68
69 typedef enum {
70   KF_UPDATE = 0,
71   LF_UPDATE = 1,
72   GF_UPDATE = 2,
73   ARF_UPDATE = 3,
74   OVERLAY_UPDATE = 4,
75   FRAME_UPDATE_TYPES = 5
76 } FRAME_UPDATE_TYPE;
77
78 #define FC_ANIMATION_THRESH 0.15
79 typedef enum {
80   FC_NORMAL = 0,
81   FC_GRAPHICS_ANIMATION = 1,
82   FRAME_CONTENT_TYPES = 2
83 } FRAME_CONTENT_TYPE;
84
85 typedef struct {
86   unsigned char index;
87   RATE_FACTOR_LEVEL rf_level[(MAX_LAG_BUFFERS * 2) + 1];
88   FRAME_UPDATE_TYPE update_type[(MAX_LAG_BUFFERS * 2) + 1];
89   unsigned char arf_src_offset[(MAX_LAG_BUFFERS * 2) + 1];
90   unsigned char arf_update_idx[(MAX_LAG_BUFFERS * 2) + 1];
91   unsigned char arf_ref_idx[(MAX_LAG_BUFFERS * 2) + 1];
92   int bit_allocation[(MAX_LAG_BUFFERS * 2) + 1];
93 } GF_GROUP;
94
95 typedef struct {
96   unsigned int section_intra_rating;
97   FIRSTPASS_STATS total_stats;
98   FIRSTPASS_STATS this_frame_stats;
99   const FIRSTPASS_STATS *stats_in;
100   const FIRSTPASS_STATS *stats_in_start;
101   const FIRSTPASS_STATS *stats_in_end;
102   FIRSTPASS_STATS total_left_stats;
103   int first_pass_done;
104   int64_t bits_left;
105   double modified_error_min;
106   double modified_error_max;
107   double modified_error_left;
108   double mb_av_energy;
109
110 #if CONFIG_FP_MB_STATS
111   uint8_t *frame_mb_stats_buf;
112   uint8_t *this_frame_mb_stats;
113   FIRSTPASS_MB_STATS firstpass_mb_stats;
114 #endif
115   // An indication of the content type of the current frame
116   FRAME_CONTENT_TYPE fr_content_type;
117
118   // Projected total bits available for a key frame group of frames
119   int64_t kf_group_bits;
120
121   // Error score of frames still to be coded in kf group
122   int64_t kf_group_error_left;
123
124   // The fraction for a kf groups total bits allocated to the inter frames
125   double kfgroup_inter_fraction;
126
127   int sr_update_lag;
128
129   int kf_zeromotion_pct;
130   int last_kfgroup_zeromotion_pct;
131   int gf_zeromotion_pct;
132   int active_worst_quality;
133   int baseline_active_worst_quality;
134   int extend_minq;
135   int extend_maxq;
136   int extend_minq_fast;
137
138   GF_GROUP gf_group;
139 } TWO_PASS;
140
141 struct VP10_COMP;
142
143 void vp10_init_first_pass(struct VP10_COMP *cpi);
144 void vp10_rc_get_first_pass_params(struct VP10_COMP *cpi);
145 void vp10_first_pass(struct VP10_COMP *cpi,
146                      const struct lookahead_entry *source);
147 void vp10_end_first_pass(struct VP10_COMP *cpi);
148
149 void vp10_init_second_pass(struct VP10_COMP *cpi);
150 void vp10_rc_get_second_pass_params(struct VP10_COMP *cpi);
151 void vp10_twopass_postencode_update(struct VP10_COMP *cpi);
152
153 // Post encode update of the rate control parameters for 2-pass
154 void vp10_twopass_postencode_update(struct VP10_COMP *cpi);
155
156 void vp10_init_subsampling(struct VP10_COMP *cpi);
157
158 void vp10_calculate_coded_size(struct VP10_COMP *cpi,
159                           int *scaled_frame_width,
160                           int *scaled_frame_height);
161
162 #ifdef __cplusplus
163 }  // extern "C"
164 #endif
165
166 #endif  // VP10_ENCODER_FIRSTPASS_H_