OLD | NEW |
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 #ifndef VP9_ENCODER_VP9_ONYX_INT_H_ | 11 #ifndef VP9_ENCODER_VP9_ONYX_INT_H_ |
12 #define VP9_ENCODER_VP9_ONYX_INT_H_ | 12 #define VP9_ENCODER_VP9_ONYX_INT_H_ |
13 | 13 |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
16 #include "./vpx_config.h" | 16 #include "./vpx_config.h" |
17 #include "vpx_ports/mem.h" | 17 #include "vpx_ports/mem.h" |
18 #include "vpx/internal/vpx_codec_internal.h" | 18 #include "vpx/internal/vpx_codec_internal.h" |
| 19 #include "vpx/vp8cx.h" |
19 | 20 |
| 21 #include "vp9/common/vp9_ppflags.h" |
20 #include "vp9/common/vp9_entropy.h" | 22 #include "vp9/common/vp9_entropy.h" |
21 #include "vp9/common/vp9_entropymode.h" | 23 #include "vp9/common/vp9_entropymode.h" |
22 #include "vp9/common/vp9_onyx.h" | |
23 #include "vp9/common/vp9_onyxc_int.h" | 24 #include "vp9/common/vp9_onyxc_int.h" |
24 | 25 |
| 26 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" |
25 #include "vp9/encoder/vp9_encodemb.h" | 27 #include "vp9/encoder/vp9_encodemb.h" |
26 #include "vp9/encoder/vp9_firstpass.h" | 28 #include "vp9/encoder/vp9_firstpass.h" |
27 #include "vp9/encoder/vp9_lookahead.h" | 29 #include "vp9/encoder/vp9_lookahead.h" |
28 #include "vp9/encoder/vp9_mbgraph.h" | 30 #include "vp9/encoder/vp9_mbgraph.h" |
29 #include "vp9/encoder/vp9_mcomp.h" | 31 #include "vp9/encoder/vp9_mcomp.h" |
30 #include "vp9/encoder/vp9_quantize.h" | 32 #include "vp9/encoder/vp9_quantize.h" |
31 #include "vp9/encoder/vp9_ratectrl.h" | 33 #include "vp9/encoder/vp9_ratectrl.h" |
| 34 #include "vp9/encoder/vp9_speed_features.h" |
| 35 #include "vp9/encoder/vp9_svc_layercontext.h" |
32 #include "vp9/encoder/vp9_tokenize.h" | 36 #include "vp9/encoder/vp9_tokenize.h" |
33 #include "vp9/encoder/vp9_treewriter.h" | |
34 #include "vp9/encoder/vp9_variance.h" | 37 #include "vp9/encoder/vp9_variance.h" |
35 | 38 |
36 #ifdef __cplusplus | 39 #ifdef __cplusplus |
37 extern "C" { | 40 extern "C" { |
38 #endif | 41 #endif |
39 | 42 |
40 // #define MODE_TEST_HIT_STATS | 43 // #define MODE_TEST_HIT_STATS |
41 | 44 |
42 #if CONFIG_MULTIPLE_ARF | |
43 // Set MIN_GF_INTERVAL to 1 for the full decomposition. | |
44 #define MIN_GF_INTERVAL 2 | |
45 #else | |
46 #define MIN_GF_INTERVAL 4 | |
47 #endif | |
48 #define DEFAULT_GF_INTERVAL 10 | 45 #define DEFAULT_GF_INTERVAL 10 |
49 #define DEFAULT_KF_BOOST 2000 | |
50 #define DEFAULT_GF_BOOST 2000 | |
51 | |
52 #define KEY_FRAME_CONTEXT 5 | |
53 | 46 |
54 #define MAX_MODES 30 | 47 #define MAX_MODES 30 |
55 #define MAX_REFS 6 | 48 #define MAX_REFS 6 |
56 | 49 |
57 #define MIN_THRESHMULT 32 | |
58 #define MAX_THRESHMULT 512 | |
59 | |
60 #define GF_ZEROMV_ZBIN_BOOST 0 | |
61 #define LF_ZEROMV_ZBIN_BOOST 0 | |
62 #define MV_ZBIN_BOOST 0 | |
63 #define SPLIT_MV_ZBIN_BOOST 0 | |
64 #define INTRA_ZBIN_BOOST 0 | |
65 | |
66 typedef struct { | 50 typedef struct { |
67 int nmvjointcost[MV_JOINTS]; | 51 int nmvjointcost[MV_JOINTS]; |
68 int nmvcosts[2][MV_VALS]; | 52 int nmvcosts[2][MV_VALS]; |
69 int nmvcosts_hp[2][MV_VALS]; | 53 int nmvcosts_hp[2][MV_VALS]; |
70 | 54 |
71 vp9_prob segment_pred_probs[PREDICTION_PROBS]; | 55 vp9_prob segment_pred_probs[PREDICTION_PROBS]; |
72 | 56 |
73 unsigned char *last_frame_seg_map_copy; | 57 unsigned char *last_frame_seg_map_copy; |
74 | 58 |
75 // 0 = Intra, Last, GF, ARF | 59 // 0 = Intra, Last, GF, ARF |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 typedef enum { | 109 typedef enum { |
126 THR_LAST, | 110 THR_LAST, |
127 THR_GOLD, | 111 THR_GOLD, |
128 THR_ALTR, | 112 THR_ALTR, |
129 THR_COMP_LA, | 113 THR_COMP_LA, |
130 THR_COMP_GA, | 114 THR_COMP_GA, |
131 THR_INTRA, | 115 THR_INTRA, |
132 } THR_MODES_SUB8X8; | 116 } THR_MODES_SUB8X8; |
133 | 117 |
134 typedef enum { | 118 typedef enum { |
135 DIAMOND = 0, | |
136 NSTEP = 1, | |
137 HEX = 2, | |
138 BIGDIA = 3, | |
139 SQUARE = 4, | |
140 FAST_HEX = 5 | |
141 } SEARCH_METHODS; | |
142 | |
143 typedef enum { | |
144 USE_FULL_RD = 0, | |
145 USE_LARGESTINTRA, | |
146 USE_LARGESTINTRA_MODELINTER, | |
147 USE_LARGESTALL | |
148 } TX_SIZE_SEARCH_METHOD; | |
149 | |
150 typedef enum { | |
151 NOT_IN_USE = 0, | |
152 RELAXED_NEIGHBORING_MIN_MAX = 1, | |
153 STRICT_NEIGHBORING_MIN_MAX = 2 | |
154 } AUTO_MIN_MAX_MODE; | |
155 | |
156 typedef enum { | |
157 // Values should be powers of 2 so that they can be selected as bits of | |
158 // an integer flags field | |
159 | |
160 // terminate search early based on distortion so far compared to | |
161 // qp step, distortion in the neighborhood of the frame, etc. | |
162 FLAG_EARLY_TERMINATE = 1, | |
163 | |
164 // skips comp inter modes if the best so far is an intra mode | |
165 FLAG_SKIP_COMP_BESTINTRA = 2, | |
166 | |
167 // skips comp inter modes if the best single intermode so far does | |
168 // not have the same reference as one of the two references being | |
169 // tested | |
170 FLAG_SKIP_COMP_REFMISMATCH = 4, | |
171 | |
172 // skips oblique intra modes if the best so far is an inter mode | |
173 FLAG_SKIP_INTRA_BESTINTER = 8, | |
174 | |
175 // skips oblique intra modes at angles 27, 63, 117, 153 if the best | |
176 // intra so far is not one of the neighboring directions | |
177 FLAG_SKIP_INTRA_DIRMISMATCH = 16, | |
178 | |
179 // skips intra modes other than DC_PRED if the source variance | |
180 // is small | |
181 FLAG_SKIP_INTRA_LOWVAR = 32, | |
182 } MODE_SEARCH_SKIP_LOGIC; | |
183 | |
184 typedef enum { | |
185 SUBPEL_TREE = 0, | |
186 // Other methods to come | |
187 } SUBPEL_SEARCH_METHODS; | |
188 | |
189 #define ALL_INTRA_MODES 0x3FF | |
190 #define INTRA_DC_ONLY 0x01 | |
191 #define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED)) | |
192 #define INTRA_DC_H_V ((1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED)) | |
193 #define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED)) | |
194 | |
195 typedef enum { | |
196 LAST_FRAME_PARTITION_OFF = 0, | |
197 LAST_FRAME_PARTITION_LOW_MOTION = 1, | |
198 LAST_FRAME_PARTITION_ALL = 2 | |
199 } LAST_FRAME_PARTITION_METHOD; | |
200 | |
201 typedef enum { | |
202 // No recode. | |
203 DISALLOW_RECODE = 0, | |
204 // Allow recode for KF and exceeding maximum frame bandwidth. | |
205 ALLOW_RECODE_KFMAXBW = 1, | |
206 // Allow recode only for KF/ARF/GF frames. | |
207 ALLOW_RECODE_KFARFGF = 2, | |
208 // Allow recode for all frames based on bitrate constraints. | |
209 ALLOW_RECODE = 3, | |
210 } RECODE_LOOP_TYPE; | |
211 | |
212 typedef enum { | |
213 // encode_breakout is disabled. | 119 // encode_breakout is disabled. |
214 ENCODE_BREAKOUT_DISABLED = 0, | 120 ENCODE_BREAKOUT_DISABLED = 0, |
215 // encode_breakout is enabled. | 121 // encode_breakout is enabled. |
216 ENCODE_BREAKOUT_ENABLED = 1, | 122 ENCODE_BREAKOUT_ENABLED = 1, |
217 // encode_breakout is enabled with small max_thresh limit. | 123 // encode_breakout is enabled with small max_thresh limit. |
218 ENCODE_BREAKOUT_LIMITED = 2 | 124 ENCODE_BREAKOUT_LIMITED = 2 |
219 } ENCODE_BREAKOUT_TYPE; | 125 } ENCODE_BREAKOUT_TYPE; |
220 | 126 |
221 typedef enum { | 127 typedef enum { |
222 // Search partitions using RD/NONRD criterion | 128 NORMAL = 0, |
223 SEARCH_PARTITION = 0, | 129 FOURFIVE = 1, |
| 130 THREEFIVE = 2, |
| 131 ONETWO = 3 |
| 132 } VPX_SCALING; |
224 | 133 |
225 // Always use a fixed size partition | 134 typedef enum { |
226 FIXED_PARTITION = 1, | 135 USAGE_LOCAL_FILE_PLAYBACK = 0, |
| 136 USAGE_STREAM_FROM_SERVER = 1, |
| 137 USAGE_CONSTRAINED_QUALITY = 2, |
| 138 USAGE_CONSTANT_QUALITY = 3, |
| 139 } END_USAGE; |
227 | 140 |
228 // Use a fixed size partition in every 64X64 SB, where the size is | 141 typedef enum { |
229 // determined based on source variance | 142 // Good Quality Fast Encoding. The encoder balances quality with the |
230 VAR_BASED_FIXED_PARTITION = 2, | 143 // amount of time it takes to encode the output. (speed setting |
| 144 // controls how fast) |
| 145 MODE_GOODQUALITY = 1, |
231 | 146 |
232 // Use an arbitrary partitioning scheme based on source variance within | 147 // One Pass - Best Quality. The encoder places priority on the |
233 // a 64X64 SB | 148 // quality of the output over encoding speed. The output is compressed |
234 VAR_BASED_PARTITION | 149 // at the highest possible quality. This option takes the longest |
235 } PARTITION_SEARCH_TYPE; | 150 // amount of time to encode. (speed setting ignored) |
| 151 MODE_BESTQUALITY = 2, |
236 | 152 |
237 typedef struct { | 153 // Two Pass - First Pass. The encoder generates a file of statistics |
238 // Frame level coding parameter update | 154 // for use in the second encoding pass. (speed setting controls how fast) |
239 int frame_parameter_update; | 155 MODE_FIRSTPASS = 3, |
240 | 156 |
241 // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc). | 157 // Two Pass - Second Pass. The encoder uses the statistics that were |
242 SEARCH_METHODS search_method; | 158 // generated in the first encoding pass to create the compressed |
| 159 // output. (speed setting controls how fast) |
| 160 MODE_SECONDPASS = 4, |
243 | 161 |
244 RECODE_LOOP_TYPE recode_loop; | 162 // Two Pass - Second Pass Best. The encoder uses the statistics that |
| 163 // were generated in the first encoding pass to create the compressed |
| 164 // output using the highest possible quality, and taking a |
| 165 // longer amount of time to encode. (speed setting ignored) |
| 166 MODE_SECONDPASS_BEST = 5, |
245 | 167 |
246 // Subpel_search_method can only be subpel_tree which does a subpixel | 168 // Realtime/Live Encoding. This mode is optimized for realtime |
247 // logarithmic search that keeps stepping at 1/2 pixel units until | 169 // encoding (for example, capturing a television signal or feed from |
248 // you stop getting a gain, and then goes on to 1/4 and repeats | 170 // a live camera). (speed setting controls how fast) |
249 // the same process. Along the way it skips many diagonals. | 171 MODE_REALTIME = 6, |
250 SUBPEL_SEARCH_METHODS subpel_search_method; | 172 } MODE; |
251 | 173 |
252 // Maximum number of steps in logarithmic subpel search before giving up. | 174 typedef enum { |
253 int subpel_iters_per_step; | 175 FRAMEFLAGS_KEY = 1 << 0, |
| 176 FRAMEFLAGS_GOLDEN = 1 << 1, |
| 177 FRAMEFLAGS_ALTREF = 1 << 2, |
| 178 } FRAMETYPE_FLAGS; |
254 | 179 |
255 // Control when to stop subpel search | 180 typedef enum { |
256 int subpel_force_stop; | 181 NO_AQ = 0, |
| 182 VARIANCE_AQ = 1, |
| 183 COMPLEXITY_AQ = 2, |
| 184 CYCLIC_REFRESH_AQ = 3, |
| 185 AQ_MODE_COUNT // This should always be the last member of the enum |
| 186 } AQ_MODE; |
257 | 187 |
258 // Thresh_mult is used to set a threshold for the rd score. A higher value | 188 typedef struct VP9_CONFIG { |
259 // means that we will accept the best mode so far more often. This number | 189 BITSTREAM_PROFILE profile; |
260 // is used in combination with the current block size, and thresh_freq_fact | 190 BIT_DEPTH bit_depth; |
261 // to pick a threshold. | 191 int width; // width of data passed to the compressor |
262 int thresh_mult[MAX_MODES]; | 192 int height; // height of data passed to the compressor |
263 int thresh_mult_sub8x8[MAX_REFS]; | 193 double framerate; // set to passed in framerate |
| 194 int64_t target_bandwidth; // bandwidth to be used in kilobits per second |
264 | 195 |
265 // This parameter controls the number of steps we'll do in a diamond | 196 int noise_sensitivity; // pre processing blur: recommendation 0 |
266 // search. | 197 int sharpness; // sharpening output: recommendation 0: |
267 int max_step_search_steps; | 198 int cpu_used; |
| 199 unsigned int rc_max_intra_bitrate_pct; |
268 | 200 |
269 // This parameter controls which step in the n-step process we start at. | 201 MODE mode; |
270 // It's changed adaptively based on circumstances. | |
271 int reduce_first_step_size; | |
272 | 202 |
273 // If this is set to 1, we limit the motion search range to 2 times the | 203 // Key Framing Operations |
274 // largest motion vector found in the last frame. | 204 int auto_key; // autodetect cut scenes and set the keyframes |
275 int auto_mv_step_size; | 205 int key_freq; // maximum distance to key frame. |
276 | 206 |
277 // Trellis (dynamic programming) optimization of quantized values (+1, 0). | 207 int lag_in_frames; // how many frames lag before we start encoding |
278 int optimize_coefficients; | |
279 | 208 |
280 // Always set to 0. If on it enables 0 cost background transmission | 209 // ---------------------------------------------------------------- |
281 // (except for the initial transmission of the segmentation). The feature is | 210 // DATARATE CONTROL OPTIONS |
282 // disabled because the addition of very large block sizes make the | |
283 // backgrounds very to cheap to encode, and the segmentation we have | |
284 // adds overhead. | |
285 int static_segmentation; | |
286 | 211 |
287 // If 1 we iterate finding a best reference for 2 ref frames together - via | 212 END_USAGE end_usage; // vbr or cbr |
288 // a log search that iterates 4 times (check around mv for last for best | |
289 // error of combined predictor then check around mv for alt). If 0 we | |
290 // we just use the best motion vector found for each frame by itself. | |
291 int comp_inter_joint_search_thresh; | |
292 | 213 |
293 // This variable is used to cap the maximum number of times we skip testing a | 214 // buffer targeting aggressiveness |
294 // mode to be evaluated. A high value means we will be faster. | 215 int under_shoot_pct; |
295 int adaptive_rd_thresh; | 216 int over_shoot_pct; |
296 | 217 |
297 // Enables skipping the reconstruction step (idct, recon) in the | 218 // buffering parameters |
298 // intermediate steps assuming the last frame didn't have too many intra | 219 int64_t starting_buffer_level; // in seconds |
299 // blocks and the q is less than a threshold. | |
300 int skip_encode_sb; | |
301 int skip_encode_frame; | |
302 | |
303 // This variable allows us to reuse the last frames partition choices | |
304 // (64x64 v 32x32 etc) for this frame. It can be set to only use the last | |
305 // frame as a starting point in low motion scenes or always use it. If set | |
306 // we use last partitioning_redo frequency to determine how often to redo | |
307 // the partitioning from scratch. Adjust_partitioning_from_last_frame | |
308 // enables us to adjust up or down one partitioning from the last frames | |
309 // partitioning. | |
310 LAST_FRAME_PARTITION_METHOD use_lastframe_partitioning; | |
311 | |
312 // Determine which method we use to determine transform size. We can choose | |
313 // between options like full rd, largest for prediction size, largest | |
314 // for intra and model coefs for the rest. | |
315 TX_SIZE_SEARCH_METHOD tx_size_search_method; | |
316 | |
317 // Low precision 32x32 fdct keeps everything in 16 bits and thus is less | |
318 // precise but significantly faster than the non lp version. | |
319 int use_lp32x32fdct; | |
320 | |
321 // TODO(JBB): remove this as its no longer used. | |
322 | |
323 // After looking at the first set of modes (set by index here), skip | |
324 // checking modes for reference frames that don't match the reference frame | |
325 // of the best so far. | |
326 int mode_skip_start; | |
327 | |
328 // TODO(JBB): Remove this. | |
329 int reference_masking; | |
330 | |
331 PARTITION_SEARCH_TYPE partition_search_type; | |
332 | |
333 // Used if partition_search_type = FIXED_SIZE_PARTITION | |
334 BLOCK_SIZE always_this_block_size; | |
335 | |
336 // Skip rectangular partition test when partition type none gives better | |
337 // rd than partition type split. | |
338 int less_rectangular_check; | |
339 | |
340 // Disable testing non square partitions. (eg 16x32) | |
341 int use_square_partition_only; | |
342 | |
343 // Sets min and max partition sizes for this 64x64 region based on the | |
344 // same 64x64 in last encoded frame, and the left and above neighbor. | |
345 AUTO_MIN_MAX_MODE auto_min_max_partition_size; | |
346 | |
347 // Min and max partition size we enable (block_size) as per auto | |
348 // min max, but also used by adjust partitioning, and pick_partitioning. | |
349 BLOCK_SIZE min_partition_size; | |
350 BLOCK_SIZE max_partition_size; | |
351 | |
352 // Whether or not we allow partitions one smaller or one greater than the last | |
353 // frame's partitioning. Only used if use_lastframe_partitioning is set. | |
354 int adjust_partitioning_from_last_frame; | |
355 | |
356 // How frequently we re do the partitioning from scratch. Only used if | |
357 // use_lastframe_partitioning is set. | |
358 int last_partitioning_redo_frequency; | |
359 | |
360 // Disables sub 8x8 blocksizes in different scenarios: Choices are to disable | |
361 // it always, to allow it for only Last frame and Intra, disable it for all | |
362 // inter modes or to enable it always. | |
363 int disable_split_mask; | |
364 | |
365 // TODO(jingning): combine the related motion search speed features | |
366 // This allows us to use motion search at other sizes as a starting | |
367 // point for this motion search and limits the search range around it. | |
368 int adaptive_motion_search; | |
369 | |
370 // Allows sub 8x8 modes to use the prediction filter that was determined | |
371 // best for 8x8 mode. If set to 0 we always re check all the filters for | |
372 // sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter | |
373 // was selected, and 2 means we use 8 tap if no 8x8 filter mode was selected. | |
374 int adaptive_pred_interp_filter; | |
375 | |
376 // Implements various heuristics to skip searching modes | |
377 // The heuristics selected are based on flags | |
378 // defined in the MODE_SEARCH_SKIP_HEURISTICS enum | |
379 unsigned int mode_search_skip_flags; | |
380 | |
381 // A source variance threshold below which the split mode is disabled | |
382 unsigned int disable_split_var_thresh; | |
383 | |
384 // A source variance threshold below which filter search is disabled | |
385 // Choose a very large value (UINT_MAX) to use 8-tap always | |
386 unsigned int disable_filter_search_var_thresh; | |
387 | |
388 // These bit masks allow you to enable or disable intra modes for each | |
389 // transform size separately. | |
390 int intra_y_mode_mask[TX_SIZES]; | |
391 int intra_uv_mode_mask[TX_SIZES]; | |
392 | |
393 // This variable enables an early break out of mode testing if the model for | |
394 // rd built from the prediction signal indicates a value that's much | |
395 // higher than the best rd we've seen so far. | |
396 int use_rd_breakout; | |
397 | |
398 // This enables us to use an estimate for intra rd based on dc mode rather | |
399 // than choosing an actual uv mode in the stage of encoding before the actual | |
400 // final encode. | |
401 int use_uv_intra_rd_estimate; | |
402 | |
403 // This feature controls how the loop filter level is determined: | |
404 // 0: Try the full image with different values. | |
405 // 1: Try a small portion of the image with different values. | |
406 // 2: Estimate the level based on quantizer and frame type | |
407 int use_fast_lpf_pick; | |
408 | |
409 // This feature limits the number of coefficients updates we actually do | |
410 // by only looking at counts from 1/2 the bands. | |
411 int use_fast_coef_updates; // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced | |
412 | |
413 // This flag controls the use of non-RD mode decision. | |
414 int use_nonrd_pick_mode; | |
415 | |
416 // This variable sets the encode_breakout threshold. Currently, it is only | |
417 // enabled in real time mode. | |
418 int encode_breakout_thresh; | |
419 | |
420 // A binary mask indicating if NEARESTMV, NEARMV, ZEROMV, NEWMV | |
421 // modes are disabled in order from LSB to MSB for each BLOCK_SIZE. | |
422 int disable_inter_mode_mask[BLOCK_SIZES]; | |
423 } SPEED_FEATURES; | |
424 | |
425 typedef struct { | |
426 RATE_CONTROL rc; | |
427 int target_bandwidth; | |
428 int64_t starting_buffer_level; | |
429 int64_t optimal_buffer_level; | 220 int64_t optimal_buffer_level; |
430 int64_t maximum_buffer_size; | 221 int64_t maximum_buffer_size; |
431 double framerate; | 222 |
432 int avg_frame_size; | 223 // Frame drop threshold. |
433 } LAYER_CONTEXT; | 224 int drop_frames_water_mark; |
| 225 |
| 226 // controlling quality |
| 227 int fixed_q; |
| 228 int worst_allowed_q; |
| 229 int best_allowed_q; |
| 230 int cq_level; |
| 231 int lossless; |
| 232 AQ_MODE aq_mode; // Adaptive Quantization mode |
| 233 |
| 234 // Enable feature to reduce the frame quantization every x frames. |
| 235 int frame_periodic_boost; |
| 236 |
| 237 // two pass datarate control |
| 238 int two_pass_vbrbias; // two pass datarate control tweaks |
| 239 int two_pass_vbrmin_section; |
| 240 int two_pass_vbrmax_section; |
| 241 // END DATARATE CONTROL OPTIONS |
| 242 // ---------------------------------------------------------------- |
| 243 |
| 244 // Spatial and temporal scalability. |
| 245 int ss_number_layers; // Number of spatial layers. |
| 246 int ts_number_layers; // Number of temporal layers. |
| 247 // Bitrate allocation for spatial layers. |
| 248 int ss_target_bitrate[VPX_SS_MAX_LAYERS]; |
| 249 // Bitrate allocation (CBR mode) and framerate factor, for temporal layers. |
| 250 int ts_target_bitrate[VPX_TS_MAX_LAYERS]; |
| 251 int ts_rate_decimator[VPX_TS_MAX_LAYERS]; |
| 252 |
| 253 // these parameters aren't to be used in final build don't use!!! |
| 254 int play_alternate; |
| 255 int alt_freq; |
| 256 |
| 257 int encode_breakout; // early breakout : for video conf recommend 800 |
| 258 |
| 259 /* Bitfield defining the error resiliency features to enable. |
| 260 * Can provide decodable frames after losses in previous |
| 261 * frames and decodable partitions after losses in the same frame. |
| 262 */ |
| 263 unsigned int error_resilient_mode; |
| 264 |
| 265 /* Bitfield defining the parallel decoding mode where the |
| 266 * decoding in successive frames may be conducted in parallel |
| 267 * just by decoding the frame headers. |
| 268 */ |
| 269 unsigned int frame_parallel_decoding_mode; |
| 270 |
| 271 int arnr_max_frames; |
| 272 int arnr_strength; |
| 273 int arnr_type; |
| 274 |
| 275 int tile_columns; |
| 276 int tile_rows; |
| 277 |
| 278 struct vpx_fixed_buf two_pass_stats_in; |
| 279 struct vpx_codec_pkt_list *output_pkt_list; |
| 280 |
| 281 vp8e_tuning tuning; |
| 282 } VP9_CONFIG; |
434 | 283 |
435 typedef struct VP9_COMP { | 284 typedef struct VP9_COMP { |
436 DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]); | 285 QUANTS quants; |
437 DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]); | |
438 DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]); | |
439 DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]); | |
440 | |
441 DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]); | |
442 DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]); | |
443 DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]); | |
444 DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]); | |
445 | |
446 #if CONFIG_ALPHA | |
447 DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]); | |
448 DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]); | |
449 DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]); | |
450 DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]); | |
451 #endif | |
452 | |
453 MACROBLOCK mb; | 286 MACROBLOCK mb; |
454 VP9_COMMON common; | 287 VP9_COMMON common; |
455 VP9_CONFIG oxcf; | 288 VP9_CONFIG oxcf; |
456 struct lookahead_ctx *lookahead; | 289 struct lookahead_ctx *lookahead; |
457 struct lookahead_entry *source; | 290 struct lookahead_entry *source; |
458 #if CONFIG_MULTIPLE_ARF | 291 #if CONFIG_MULTIPLE_ARF |
459 struct lookahead_entry *alt_ref_source[REF_FRAMES]; | 292 struct lookahead_entry *alt_ref_source[REF_FRAMES]; |
460 #else | 293 #else |
461 struct lookahead_entry *alt_ref_source; | 294 struct lookahead_entry *alt_ref_source; |
462 #endif | 295 #endif |
| 296 struct lookahead_entry *last_source; |
463 | 297 |
464 YV12_BUFFER_CONFIG *Source; | 298 YV12_BUFFER_CONFIG *Source; |
| 299 YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames |
465 YV12_BUFFER_CONFIG *un_scaled_source; | 300 YV12_BUFFER_CONFIG *un_scaled_source; |
466 YV12_BUFFER_CONFIG scaled_source; | 301 YV12_BUFFER_CONFIG scaled_source; |
| 302 YV12_BUFFER_CONFIG *unscaled_last_source; |
| 303 YV12_BUFFER_CONFIG scaled_last_source; |
467 | 304 |
468 int key_frame_frequency; | 305 int key_frame_frequency; |
469 | 306 |
470 int gold_is_last; // gold same as last frame ( short circuit gold searches) | 307 int gold_is_last; // gold same as last frame ( short circuit gold searches) |
471 int alt_is_last; // Alt same as last ( short circuit altref search) | 308 int alt_is_last; // Alt same as last ( short circuit altref search) |
472 int gold_is_alt; // don't do both alt and gold search ( just do gold). | 309 int gold_is_alt; // don't do both alt and gold search ( just do gold). |
473 | 310 |
474 int scaled_ref_idx[3]; | 311 int scaled_ref_idx[3]; |
475 int lst_fb_idx; | 312 int lst_fb_idx; |
476 int gld_fb_idx; | 313 int gld_fb_idx; |
(...skipping 22 matching lines...) Expand all Loading... |
499 #if CONFIG_MULTIPLE_ARF | 336 #if CONFIG_MULTIPLE_ARF |
500 // Position within a frame coding order (including any additional ARF frames). | 337 // Position within a frame coding order (including any additional ARF frames). |
501 unsigned int sequence_number; | 338 unsigned int sequence_number; |
502 // Next frame in naturally occurring order that has not yet been coded. | 339 // Next frame in naturally occurring order that has not yet been coded. |
503 int next_frame_in_order; | 340 int next_frame_in_order; |
504 #endif | 341 #endif |
505 | 342 |
506 // Ambient reconstruction err target for force key frames | 343 // Ambient reconstruction err target for force key frames |
507 int ambient_err; | 344 int ambient_err; |
508 | 345 |
| 346 // Thresh_mult is used to set a threshold for the rd score. A higher value |
| 347 // means that we will accept the best mode so far more often. This number |
| 348 // is used in combination with the current block size, and thresh_freq_fact |
| 349 // to pick a threshold. |
| 350 int rd_thresh_mult[MAX_MODES]; |
| 351 int rd_thresh_mult_sub8x8[MAX_REFS]; |
| 352 |
509 int rd_threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES]; | 353 int rd_threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES]; |
510 int rd_thresh_freq_fact[BLOCK_SIZES][MAX_MODES]; | 354 int rd_thresh_freq_fact[BLOCK_SIZES][MAX_MODES]; |
511 int rd_thresh_sub8x8[MAX_SEGMENTS][BLOCK_SIZES][MAX_REFS]; | 355 int rd_thresh_sub8x8[MAX_SEGMENTS][BLOCK_SIZES][MAX_REFS]; |
512 int rd_thresh_freq_sub8x8[BLOCK_SIZES][MAX_REFS]; | 356 int rd_thresh_freq_sub8x8[BLOCK_SIZES][MAX_REFS]; |
513 | 357 |
514 int64_t rd_comp_pred_diff[REFERENCE_MODES]; | 358 int64_t rd_comp_pred_diff[REFERENCE_MODES]; |
515 int64_t rd_prediction_type_threshes[4][REFERENCE_MODES]; | 359 int64_t rd_prediction_type_threshes[MAX_REF_FRAMES][REFERENCE_MODES]; |
516 int64_t rd_tx_select_diff[TX_MODES]; | 360 int64_t rd_tx_select_diff[TX_MODES]; |
517 // FIXME(rbultje) can this overflow? | 361 // FIXME(rbultje) can this overflow? |
518 int rd_tx_select_threshes[4][TX_MODES]; | 362 int rd_tx_select_threshes[MAX_REF_FRAMES][TX_MODES]; |
519 | 363 |
520 int64_t rd_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; | 364 int64_t rd_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; |
521 int64_t rd_filter_threshes[4][SWITCHABLE_FILTER_CONTEXTS]; | 365 int64_t rd_filter_threshes[MAX_REF_FRAMES][SWITCHABLE_FILTER_CONTEXTS]; |
522 int64_t rd_filter_cache[SWITCHABLE_FILTER_CONTEXTS]; | 366 int64_t rd_filter_cache[SWITCHABLE_FILTER_CONTEXTS]; |
523 int64_t mask_filter_rd; | 367 int64_t mask_filter_rd; |
524 | 368 |
525 int RDMULT; | 369 int RDMULT; |
526 int RDDIV; | 370 int RDDIV; |
527 | 371 |
528 CODING_CONTEXT coding_context; | 372 CODING_CONTEXT coding_context; |
529 | 373 |
530 int zbin_mode_boost; | 374 int zbin_mode_boost; |
531 int zbin_mode_boost_enabled; | 375 int zbin_mode_boost_enabled; |
532 int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames | 376 int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames |
533 int active_arnr_strength; // <= cpi->oxcf.arnr_max_strength | 377 int active_arnr_strength; // <= cpi->oxcf.arnr_max_strength |
534 | 378 |
535 double output_framerate; | 379 double output_framerate; |
536 int64_t last_time_stamp_seen; | 380 int64_t last_time_stamp_seen; |
537 int64_t last_end_time_stamp_seen; | 381 int64_t last_end_time_stamp_seen; |
538 int64_t first_time_stamp_ever; | 382 int64_t first_time_stamp_ever; |
539 | 383 |
540 RATE_CONTROL rc; | 384 RATE_CONTROL rc; |
541 | 385 |
542 int cq_target_quality; | 386 int cq_target_quality; |
543 | 387 |
544 vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES]; | 388 vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES]; |
545 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES]; | 389 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES]; |
546 vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES]; | |
547 | 390 |
548 struct vpx_codec_pkt_list *output_pkt_list; | 391 struct vpx_codec_pkt_list *output_pkt_list; |
549 | 392 |
550 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS]; | 393 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS]; |
551 int mbgraph_n_frames; // number of frames filled in the above | 394 int mbgraph_n_frames; // number of frames filled in the above |
552 int static_mb_pct; // % forced skip mbs by segmentation | 395 int static_mb_pct; // % forced skip mbs by segmentation |
553 int seg0_progress, seg0_idx, seg0_cnt; | |
554 | 396 |
555 // for real time encoding | 397 // for real time encoding |
556 int speed; | 398 int speed; |
557 | 399 |
558 int cpu_used; | 400 int cpu_used; |
559 int pass; | 401 int pass; |
560 | 402 |
561 vp9_prob last_skip_false_probs[3][SKIP_CONTEXTS]; | |
562 int last_skip_probs_q[3]; | |
563 | |
564 int ref_frame_flags; | 403 int ref_frame_flags; |
565 | 404 |
566 SPEED_FEATURES sf; | 405 SPEED_FEATURES sf; |
567 | 406 |
568 unsigned int max_mv_magnitude; | 407 unsigned int max_mv_magnitude; |
569 int mv_step_param; | 408 int mv_step_param; |
570 | 409 |
571 // Default value is 1. From first pass stats, encode_breakout may be disabled. | 410 // Default value is 1. From first pass stats, encode_breakout may be disabled. |
572 ENCODE_BREAKOUT_TYPE allow_encode_breakout; | 411 ENCODE_BREAKOUT_TYPE allow_encode_breakout; |
573 | 412 |
574 // Get threshold from external input. In real time mode, it can be | 413 // Get threshold from external input. In real time mode, it can be |
575 // overwritten according to encoding speed. | 414 // overwritten according to encoding speed. |
576 int encode_breakout; | 415 int encode_breakout; |
577 | 416 |
578 unsigned char *segmentation_map; | 417 unsigned char *segmentation_map; |
579 | 418 |
580 // segment threashold for encode breakout | 419 // segment threashold for encode breakout |
581 int segment_encode_breakout[MAX_SEGMENTS]; | 420 int segment_encode_breakout[MAX_SEGMENTS]; |
582 | 421 |
583 unsigned char *complexity_map; | 422 unsigned char *complexity_map; |
584 | 423 |
585 unsigned char *active_map; | 424 unsigned char *active_map; |
586 unsigned int active_map_enabled; | 425 unsigned int active_map_enabled; |
587 | 426 |
| 427 CYCLIC_REFRESH *cyclic_refresh; |
| 428 |
588 fractional_mv_step_fp *find_fractional_mv_step; | 429 fractional_mv_step_fp *find_fractional_mv_step; |
589 fractional_mv_step_comp_fp *find_fractional_mv_step_comp; | 430 fractional_mv_step_comp_fp *find_fractional_mv_step_comp; |
590 vp9_full_search_fn_t full_search_sad; | 431 vp9_full_search_fn_t full_search_sad; |
591 vp9_refining_search_fn_t refining_search_sad; | 432 vp9_refining_search_fn_t refining_search_sad; |
592 vp9_diamond_search_fn_t diamond_search_sad; | 433 vp9_diamond_search_fn_t diamond_search_sad; |
593 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES]; | 434 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES]; |
594 uint64_t time_receive_data; | 435 uint64_t time_receive_data; |
595 uint64_t time_compress_data; | 436 uint64_t time_compress_data; |
596 uint64_t time_pick_lpf; | 437 uint64_t time_pick_lpf; |
597 uint64_t time_encode_sb_row; | 438 uint64_t time_encode_sb_row; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 double total_ssimg_all; | 475 double total_ssimg_all; |
635 | 476 |
636 int b_calculate_ssimg; | 477 int b_calculate_ssimg; |
637 #endif | 478 #endif |
638 int b_calculate_psnr; | 479 int b_calculate_psnr; |
639 | 480 |
640 // Per MB activity measurement | 481 // Per MB activity measurement |
641 unsigned int activity_avg; | 482 unsigned int activity_avg; |
642 unsigned int *mb_activity_map; | 483 unsigned int *mb_activity_map; |
643 int *mb_norm_activity_map; | 484 int *mb_norm_activity_map; |
644 int output_partition; | |
645 | |
646 // Force next frame to intra when kf_auto says so. | |
647 int force_next_frame_intra; | |
648 | 485 |
649 int droppable; | 486 int droppable; |
650 | 487 |
651 int dummy_packing; /* flag to indicate if packing is dummy */ | 488 int dummy_packing; /* flag to indicate if packing is dummy */ |
652 | 489 |
653 unsigned int tx_stepdown_count[TX_SIZES]; | 490 unsigned int tx_stepdown_count[TX_SIZES]; |
654 | 491 |
655 int initial_width; | 492 int initial_width; |
656 int initial_height; | 493 int initial_height; |
657 | 494 |
658 int use_svc; | 495 int use_svc; |
659 | 496 |
660 struct svc { | 497 SVC svc; |
661 int spatial_layer_id; | 498 |
662 int temporal_layer_id; | 499 int use_large_partition_rate; |
663 int number_spatial_layers; | |
664 int number_temporal_layers; | |
665 // Layer context used for rate control in CBR mode, only defined for | |
666 // temporal layers for now. | |
667 LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS]; | |
668 } svc; | |
669 | 500 |
670 #if CONFIG_MULTIPLE_ARF | 501 #if CONFIG_MULTIPLE_ARF |
671 // ARF tracking variables. | 502 // ARF tracking variables. |
672 int multi_arf_enabled; | 503 int multi_arf_enabled; |
673 unsigned int frame_coding_order_period; | 504 unsigned int frame_coding_order_period; |
674 unsigned int new_frame_coding_order_period; | 505 unsigned int new_frame_coding_order_period; |
675 int frame_coding_order[MAX_LAG_BUFFERS * 2]; | 506 int frame_coding_order[MAX_LAG_BUFFERS * 2]; |
676 int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2]; | 507 int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2]; |
677 int arf_weight[MAX_LAG_BUFFERS]; | 508 int arf_weight[MAX_LAG_BUFFERS]; |
678 int arf_buffered; | 509 int arf_buffered; |
679 int this_frame_weight; | 510 int this_frame_weight; |
680 int max_arf_level; | 511 int max_arf_level; |
681 #endif | 512 #endif |
682 | 513 |
683 #ifdef ENTROPY_STATS | |
684 int64_t mv_ref_stats[INTER_MODE_CONTEXTS][INTER_MODES - 1][2]; | |
685 #endif | |
686 | |
687 | |
688 #ifdef MODE_TEST_HIT_STATS | 514 #ifdef MODE_TEST_HIT_STATS |
689 // Debug / test stats | 515 // Debug / test stats |
690 int64_t mode_test_hits[BLOCK_SIZES]; | 516 int64_t mode_test_hits[BLOCK_SIZES]; |
691 #endif | 517 #endif |
692 | |
693 // Y,U,V,(A) | |
694 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; | |
695 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; | |
696 | |
697 PARTITION_CONTEXT *above_seg_context; | |
698 PARTITION_CONTEXT left_seg_context[8]; | |
699 } VP9_COMP; | 518 } VP9_COMP; |
700 | 519 |
701 static int get_ref_frame_idx(const VP9_COMP *cpi, | 520 void vp9_initialize_enc(); |
702 MV_REFERENCE_FRAME ref_frame) { | 521 |
| 522 struct VP9_COMP *vp9_create_compressor(VP9_CONFIG *oxcf); |
| 523 void vp9_remove_compressor(VP9_COMP *cpi); |
| 524 |
| 525 void vp9_change_config(VP9_COMP *cpi, const VP9_CONFIG *oxcf); |
| 526 |
| 527 // receive a frames worth of data. caller can assume that a copy of this |
| 528 // frame is made and not just a copy of the pointer.. |
| 529 int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags, |
| 530 YV12_BUFFER_CONFIG *sd, int64_t time_stamp, |
| 531 int64_t end_time_stamp); |
| 532 |
| 533 int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, |
| 534 size_t *size, uint8_t *dest, |
| 535 int64_t *time_stamp, int64_t *time_end, int flush); |
| 536 |
| 537 int vp9_get_preview_raw_frame(VP9_COMP *cpi, YV12_BUFFER_CONFIG *dest, |
| 538 vp9_ppflags_t *flags); |
| 539 |
| 540 int vp9_use_as_reference(VP9_COMP *cpi, int ref_frame_flags); |
| 541 |
| 542 void vp9_update_reference(VP9_COMP *cpi, int ref_frame_flags); |
| 543 |
| 544 int vp9_copy_reference_enc(VP9_COMP *cpi, VP9_REFFRAME ref_frame_flag, |
| 545 YV12_BUFFER_CONFIG *sd); |
| 546 |
| 547 int vp9_get_reference_enc(VP9_COMP *cpi, int index, |
| 548 YV12_BUFFER_CONFIG **fb); |
| 549 |
| 550 int vp9_set_reference_enc(VP9_COMP *cpi, VP9_REFFRAME ref_frame_flag, |
| 551 YV12_BUFFER_CONFIG *sd); |
| 552 |
| 553 int vp9_update_entropy(VP9_COMP *cpi, int update); |
| 554 |
| 555 int vp9_set_roimap(VP9_COMP *cpi, unsigned char *map, |
| 556 unsigned int rows, unsigned int cols, |
| 557 int delta_q[MAX_SEGMENTS], |
| 558 int delta_lf[MAX_SEGMENTS], |
| 559 unsigned int threshold[MAX_SEGMENTS]); |
| 560 |
| 561 int vp9_set_active_map(VP9_COMP *cpi, unsigned char *map, |
| 562 unsigned int rows, unsigned int cols); |
| 563 |
| 564 int vp9_set_internal_size(VP9_COMP *cpi, |
| 565 VPX_SCALING horiz_mode, VPX_SCALING vert_mode); |
| 566 |
| 567 int vp9_set_size_literal(VP9_COMP *cpi, unsigned int width, |
| 568 unsigned int height); |
| 569 |
| 570 void vp9_set_svc(VP9_COMP *cpi, int use_svc); |
| 571 |
| 572 int vp9_get_quantizer(struct VP9_COMP *cpi); |
| 573 |
| 574 static INLINE int get_ref_frame_idx(const VP9_COMP *cpi, |
| 575 MV_REFERENCE_FRAME ref_frame) { |
703 if (ref_frame == LAST_FRAME) { | 576 if (ref_frame == LAST_FRAME) { |
704 return cpi->lst_fb_idx; | 577 return cpi->lst_fb_idx; |
705 } else if (ref_frame == GOLDEN_FRAME) { | 578 } else if (ref_frame == GOLDEN_FRAME) { |
706 return cpi->gld_fb_idx; | 579 return cpi->gld_fb_idx; |
707 } else { | 580 } else { |
708 return cpi->alt_fb_idx; | 581 return cpi->alt_fb_idx; |
709 } | 582 } |
710 } | 583 } |
711 | 584 |
712 static YV12_BUFFER_CONFIG *get_ref_frame_buffer(VP9_COMP *cpi, | 585 static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer( |
713 MV_REFERENCE_FRAME ref_frame) { | 586 VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) { |
714 VP9_COMMON *const cm = &cpi->common; | 587 VP9_COMMON * const cm = &cpi->common; |
715 return &cm->frame_bufs[cm->ref_frame_map[get_ref_frame_idx(cpi, | 588 return &cm->frame_bufs[cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]] |
716 ref_frame)]].buf; | 589 .buf; |
717 } | 590 } |
718 | 591 |
719 void vp9_encode_frame(VP9_COMP *cpi); | 592 // Intra only frames, golden frames (except alt ref overlays) and |
| 593 // alt ref frames tend to be coded at a higher than ambient quality |
| 594 static INLINE int vp9_frame_is_boosted(const VP9_COMP *cpi) { |
| 595 return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame || |
| 596 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref); |
| 597 } |
720 | 598 |
721 void vp9_set_speed_features(VP9_COMP *cpi); | 599 static INLINE int get_token_alloc(int mb_rows, int mb_cols) { |
| 600 // TODO(JBB): make this work for alpha channel and double check we can't |
| 601 // exceed this token count if we have a 32x32 transform crossing a boundary |
| 602 // at a multiple of 16. |
| 603 // mb_rows, cols are in units of 16 pixels. We assume 3 planes all at full |
| 604 // resolution. We assume up to 1 token per pixel, and then allow |
| 605 // a head room of 4. |
| 606 return mb_rows * mb_cols * (16 * 16 * 3 + 4); |
| 607 } |
722 | 608 |
723 int vp9_calc_ss_err(const YV12_BUFFER_CONFIG *source, | 609 int vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
724 const YV12_BUFFER_CONFIG *reference); | |
725 | 610 |
726 void vp9_alloc_compressor_data(VP9_COMP *cpi); | 611 void vp9_alloc_compressor_data(VP9_COMP *cpi); |
727 | 612 |
728 int vp9_compute_qdelta(const VP9_COMP *cpi, double qstart, double qtarget); | 613 void vp9_scale_references(VP9_COMP *cpi); |
729 | 614 |
730 static int get_token_alloc(int mb_rows, int mb_cols) { | 615 void vp9_update_reference_frames(VP9_COMP *cpi); |
731 return mb_rows * mb_cols * (48 * 16 + 4); | |
732 } | |
733 | 616 |
734 static void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, | 617 int64_t vp9_rescale(int64_t val, int64_t num, int denom); |
735 MV_REFERENCE_FRAME ref0, MV_REFERENCE_FRAME ref1) { | 618 |
| 619 static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 620 MV_REFERENCE_FRAME ref0, |
| 621 MV_REFERENCE_FRAME ref1) { |
736 xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME | 622 xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME |
737 : 0]; | 623 : 0]; |
738 xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME | 624 xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME |
739 : 0]; | 625 : 0]; |
740 } | 626 } |
741 | 627 |
742 #ifdef __cplusplus | 628 #ifdef __cplusplus |
743 } // extern "C" | 629 } // extern "C" |
744 #endif | 630 #endif |
745 | 631 |
746 #endif // VP9_ENCODER_VP9_ONYX_INT_H_ | 632 #endif // VP9_ENCODER_VP9_ONYX_INT_H_ |
OLD | NEW |