Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_onyx_int.h

Issue 168343002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_onyx_if.c ('k') | source/libvpx/vp9/encoder/vp9_picklpf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
12 #ifndef VP9_ENCODER_VP9_ONYX_INT_H_ 11 #ifndef VP9_ENCODER_VP9_ONYX_INT_H_
13 #define VP9_ENCODER_VP9_ONYX_INT_H_ 12 #define VP9_ENCODER_VP9_ONYX_INT_H_
14 13
15 #include <stdio.h> 14 #include <stdio.h>
15
16 #include "./vpx_config.h" 16 #include "./vpx_config.h"
17 #include "vp9/common/vp9_onyx.h" 17 #include "vpx_ports/mem.h"
18 #include "vp9/encoder/vp9_treewriter.h" 18 #include "vpx/internal/vpx_codec_internal.h"
19 #include "vp9/encoder/vp9_tokenize.h" 19
20 #include "vp9/common/vp9_onyxc_int.h"
21 #include "vp9/encoder/vp9_variance.h"
22 #include "vp9/encoder/vp9_encodemb.h"
23 #include "vp9/encoder/vp9_quantize.h"
24 #include "vp9/common/vp9_entropy.h" 20 #include "vp9/common/vp9_entropy.h"
25 #include "vp9/common/vp9_entropymode.h" 21 #include "vp9/common/vp9_entropymode.h"
26 #include "vpx_ports/mem.h" 22 #include "vp9/common/vp9_onyx.h"
27 #include "vpx/internal/vpx_codec_internal.h" 23 #include "vp9/common/vp9_onyxc_int.h"
24
25 #include "vp9/encoder/vp9_encodemb.h"
26 #include "vp9/encoder/vp9_firstpass.h"
27 #include "vp9/encoder/vp9_lookahead.h"
28 #include "vp9/encoder/vp9_mbgraph.h"
28 #include "vp9/encoder/vp9_mcomp.h" 29 #include "vp9/encoder/vp9_mcomp.h"
29 #include "vp9/encoder/vp9_lookahead.h" 30 #include "vp9/encoder/vp9_quantize.h"
31 #include "vp9/encoder/vp9_ratectrl.h"
32 #include "vp9/encoder/vp9_tokenize.h"
33 #include "vp9/encoder/vp9_treewriter.h"
34 #include "vp9/encoder/vp9_variance.h"
30 35
31 #ifdef __cplusplus 36 #ifdef __cplusplus
32 extern "C" { 37 extern "C" {
33 #endif 38 #endif
34 39
35 #define DISABLE_RC_LONG_TERM_MEM 0
36 // #define MODE_TEST_HIT_STATS 40 // #define MODE_TEST_HIT_STATS
37 41
38 // #define SPEEDSTATS 1
39 #if CONFIG_MULTIPLE_ARF 42 #if CONFIG_MULTIPLE_ARF
40 // Set MIN_GF_INTERVAL to 1 for the full decomposition. 43 // Set MIN_GF_INTERVAL to 1 for the full decomposition.
41 #define MIN_GF_INTERVAL 2 44 #define MIN_GF_INTERVAL 2
42 #else 45 #else
43 #define MIN_GF_INTERVAL 4 46 #define MIN_GF_INTERVAL 4
44 #endif 47 #endif
45 #define DEFAULT_GF_INTERVAL 7 48 #define DEFAULT_GF_INTERVAL 10
49 #define DEFAULT_KF_BOOST 2000
50 #define DEFAULT_GF_BOOST 2000
46 51
47 #define KEY_FRAME_CONTEXT 5 52 #define KEY_FRAME_CONTEXT 5
48 53
49 #define MAX_MODES 30 54 #define MAX_MODES 30
50 #define MAX_REFS 6 55 #define MAX_REFS 6
51 56
52 #define MIN_THRESHMULT 32 57 #define MIN_THRESHMULT 32
53 #define MAX_THRESHMULT 512 58 #define MAX_THRESHMULT 512
54 59
55 #define GF_ZEROMV_ZBIN_BOOST 0 60 #define GF_ZEROMV_ZBIN_BOOST 0
(...skipping 12 matching lines...) Expand all
68 unsigned char *last_frame_seg_map_copy; 73 unsigned char *last_frame_seg_map_copy;
69 74
70 // 0 = Intra, Last, GF, ARF 75 // 0 = Intra, Last, GF, ARF
71 signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS]; 76 signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
72 // 0 = ZERO_MV, MV 77 // 0 = ZERO_MV, MV
73 signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS]; 78 signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
74 79
75 FRAME_CONTEXT fc; 80 FRAME_CONTEXT fc;
76 } CODING_CONTEXT; 81 } CODING_CONTEXT;
77 82
78 typedef struct {
79 double frame;
80 double intra_error;
81 double coded_error;
82 double sr_coded_error;
83 double ssim_weighted_pred_err;
84 double pcnt_inter;
85 double pcnt_motion;
86 double pcnt_second_ref;
87 double pcnt_neutral;
88 double MVr;
89 double mvr_abs;
90 double MVc;
91 double mvc_abs;
92 double MVrv;
93 double MVcv;
94 double mv_in_out_count;
95 double new_mv_count;
96 double duration;
97 double count;
98 } FIRSTPASS_STATS;
99
100 typedef struct {
101 int frames_so_far;
102 double frame_intra_error;
103 double frame_coded_error;
104 double frame_pcnt_inter;
105 double frame_pcnt_motion;
106 double frame_mvr;
107 double frame_mvr_abs;
108 double frame_mvc;
109 double frame_mvc_abs;
110 } ONEPASS_FRAMESTATS;
111
112 typedef struct {
113 struct {
114 int err;
115 union {
116 int_mv mv;
117 MB_PREDICTION_MODE mode;
118 } m;
119 } ref[MAX_REF_FRAMES];
120 } MBGRAPH_MB_STATS;
121
122 typedef struct {
123 MBGRAPH_MB_STATS *mb_stats;
124 } MBGRAPH_FRAME_STATS;
125
126 // This enumerator type needs to be kept aligned with the mode order in 83 // This enumerator type needs to be kept aligned with the mode order in
127 // const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code. 84 // const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code.
128 typedef enum { 85 typedef enum {
129 THR_NEARESTMV, 86 THR_NEARESTMV,
130 THR_NEARESTA, 87 THR_NEARESTA,
131 THR_NEARESTG, 88 THR_NEARESTG,
132 89
133 THR_DC, 90 THR_DC,
134 91
135 THR_NEWMV, 92 THR_NEWMV,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } SEARCH_METHODS; 140 } SEARCH_METHODS;
184 141
185 typedef enum { 142 typedef enum {
186 USE_FULL_RD = 0, 143 USE_FULL_RD = 0,
187 USE_LARGESTINTRA, 144 USE_LARGESTINTRA,
188 USE_LARGESTINTRA_MODELINTER, 145 USE_LARGESTINTRA_MODELINTER,
189 USE_LARGESTALL 146 USE_LARGESTALL
190 } TX_SIZE_SEARCH_METHOD; 147 } TX_SIZE_SEARCH_METHOD;
191 148
192 typedef enum { 149 typedef enum {
150 NOT_IN_USE = 0,
151 RELAXED_NEIGHBORING_MIN_MAX = 1,
152 STRICT_NEIGHBORING_MIN_MAX = 2
153 } AUTO_MIN_MAX_MODE;
154
155 typedef enum {
193 // Values should be powers of 2 so that they can be selected as bits of 156 // Values should be powers of 2 so that they can be selected as bits of
194 // an integer flags field 157 // an integer flags field
195 158
196 // terminate search early based on distortion so far compared to 159 // terminate search early based on distortion so far compared to
197 // qp step, distortion in the neighborhood of the frame, etc. 160 // qp step, distortion in the neighborhood of the frame, etc.
198 FLAG_EARLY_TERMINATE = 1, 161 FLAG_EARLY_TERMINATE = 1,
199 162
200 // skips comp inter modes if the best so far is an intra mode 163 // skips comp inter modes if the best so far is an intra mode
201 FLAG_SKIP_COMP_BESTINTRA = 2, 164 FLAG_SKIP_COMP_BESTINTRA = 2,
202 165
(...skipping 24 matching lines...) Expand all
227 #define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED)) 190 #define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED))
228 #define INTRA_DC_H_V ((1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED)) 191 #define INTRA_DC_H_V ((1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED))
229 #define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED)) 192 #define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED))
230 193
231 typedef enum { 194 typedef enum {
232 LAST_FRAME_PARTITION_OFF = 0, 195 LAST_FRAME_PARTITION_OFF = 0,
233 LAST_FRAME_PARTITION_LOW_MOTION = 1, 196 LAST_FRAME_PARTITION_LOW_MOTION = 1,
234 LAST_FRAME_PARTITION_ALL = 2 197 LAST_FRAME_PARTITION_ALL = 2
235 } LAST_FRAME_PARTITION_METHOD; 198 } LAST_FRAME_PARTITION_METHOD;
236 199
200 typedef enum {
201 // No recode.
202 DISALLOW_RECODE = 0,
203 // Allow recode for KF and exceeding maximum frame bandwidth.
204 ALLOW_RECODE_KFMAXBW = 1,
205 // Allow recode only for KF/ARF/GF frames.
206 ALLOW_RECODE_KFARFGF = 2,
207 // Allow recode for all frames based on bitrate constraints.
208 ALLOW_RECODE = 3,
209 } RECODE_LOOP_TYPE;
210
211 typedef enum {
212 // encode_breakout is disabled.
213 ENCODE_BREAKOUT_DISABLED = 0,
214 // encode_breakout is enabled.
215 ENCODE_BREAKOUT_ENABLED = 1,
216 // encode_breakout is enabled with small max_thresh limit.
217 ENCODE_BREAKOUT_LIMITED = 2
218 } ENCODE_BREAKOUT_TYPE;
219
237 typedef struct { 220 typedef struct {
238 // This flag refers to whether or not to perform rd optimization. 221 // Frame level coding parameter update
239 int RD; 222 int frame_parameter_update;
240 223
241 // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc). 224 // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
242 SEARCH_METHODS search_method; 225 SEARCH_METHODS search_method;
243 226
244 // Recode_loop can be: 227 RECODE_LOOP_TYPE recode_loop;
245 // 0 means we only encode a frame once
246 // 1 means we can re-encode based on bitrate constraints on any frame
247 // 2 means we can only recode gold, alt, and key frames.
248 int recode_loop;
249 228
250 // Subpel_search_method can only be subpel_tree which does a subpixel 229 // Subpel_search_method can only be subpel_tree which does a subpixel
251 // logarithmic search that keeps stepping at 1/2 pixel units until 230 // logarithmic search that keeps stepping at 1/2 pixel units until
252 // you stop getting a gain, and then goes on to 1/4 and repeats 231 // you stop getting a gain, and then goes on to 1/4 and repeats
253 // the same process. Along the way it skips many diagonals. 232 // the same process. Along the way it skips many diagonals.
254 SUBPEL_SEARCH_METHODS subpel_search_method; 233 SUBPEL_SEARCH_METHODS subpel_search_method;
255 234
256 // Maximum number of steps in logarithmic subpel search before giving up. 235 // Maximum number of steps in logarithmic subpel search before giving up.
257 int subpel_iters_per_step; 236 int subpel_iters_per_step;
258 237
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // of the best so far. 318 // of the best so far.
340 int mode_skip_start; 319 int mode_skip_start;
341 320
342 // TODO(JBB): Remove this. 321 // TODO(JBB): Remove this.
343 int reference_masking; 322 int reference_masking;
344 323
345 // Used in conjunction with use_one_partition_size_always. 324 // Used in conjunction with use_one_partition_size_always.
346 BLOCK_SIZE always_this_block_size; 325 BLOCK_SIZE always_this_block_size;
347 326
348 // Sets min and max partition sizes for this 64x64 region based on the 327 // Sets min and max partition sizes for this 64x64 region based on the
349 // same superblock in last encoded frame, and the left and above neighbor 328 // same 64x64 in last encoded frame, and the left and above neighbor.
350 // in this block. 329 AUTO_MIN_MAX_MODE auto_min_max_partition_size;
351 int auto_min_max_partition_size;
352 330
353 // Min and max partition size we enable (block_size) as per auto 331 // Min and max partition size we enable (block_size) as per auto
354 // min max, but also used by adjust partitioning, and pick_partitioning. 332 // min max, but also used by adjust partitioning, and pick_partitioning.
355 BLOCK_SIZE min_partition_size; 333 BLOCK_SIZE min_partition_size;
356 BLOCK_SIZE max_partition_size; 334 BLOCK_SIZE max_partition_size;
357 335
358 // Whether or not we allow partitions one smaller or one greater than the last 336 // Whether or not we allow partitions one smaller or one greater than the last
359 // frame's partitioning. Only used if use_lastframe_partitioning is set. 337 // frame's partitioning. Only used if use_lastframe_partitioning is set.
360 int adjust_partitioning_from_last_frame; 338 int adjust_partitioning_from_last_frame;
361 339
362 // How frequently we re do the partitioning from scratch. Only used if 340 // How frequently we re do the partitioning from scratch. Only used if
363 // use_lastframe_partitioning is set. 341 // use_lastframe_partitioning is set.
364 int last_partitioning_redo_frequency; 342 int last_partitioning_redo_frequency;
365 343
366 // Disables sub 8x8 blocksizes in different scenarios: Choices are to disable 344 // Disables sub 8x8 blocksizes in different scenarios: Choices are to disable
367 // it always, to allow it for only Last frame and Intra, disable it for all 345 // it always, to allow it for only Last frame and Intra, disable it for all
368 // inter modes or to enable it always. 346 // inter modes or to enable it always.
369 int disable_split_mask; 347 int disable_split_mask;
370 348
371 // TODO(jbb): Remove this and everything that uses it. It's only valid if
372 // we were doing small to large partition checks. We currently do the
373 // reverse.
374 int using_small_partition_info;
375
376 // TODO(jingning): combine the related motion search speed features 349 // TODO(jingning): combine the related motion search speed features
377 // This allows us to use motion search at other sizes as a starting 350 // This allows us to use motion search at other sizes as a starting
378 // point for this motion search and limits the search range around it. 351 // point for this motion search and limits the search range around it.
379 int adaptive_motion_search; 352 int adaptive_motion_search;
380 353
381 // Allows sub 8x8 modes to use the prediction filter that was determined 354 // Allows sub 8x8 modes to use the prediction filter that was determined
382 // best for 8x8 mode. If set to 0 we always re check all the filters for 355 // best for 8x8 mode. If set to 0 we always re check all the filters for
383 // sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter 356 // sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter
384 // was selected, and 2 means we use 8 tap if no 8x8 filter mode was selected. 357 // was selected, and 2 means we use 8 tap if no 8x8 filter mode was selected.
385 int adaptive_pred_interp_filter; 358 int adaptive_pred_interp_filter;
(...skipping 27 matching lines...) Expand all
413 386
414 // This feature controls how the loop filter level is determined: 387 // This feature controls how the loop filter level is determined:
415 // 0: Try the full image with different values. 388 // 0: Try the full image with different values.
416 // 1: Try a small portion of the image with different values. 389 // 1: Try a small portion of the image with different values.
417 // 2: Estimate the level based on quantizer and frame type 390 // 2: Estimate the level based on quantizer and frame type
418 int use_fast_lpf_pick; 391 int use_fast_lpf_pick;
419 392
420 // This feature limits the number of coefficients updates we actually do 393 // This feature limits the number of coefficients updates we actually do
421 // by only looking at counts from 1/2 the bands. 394 // by only looking at counts from 1/2 the bands.
422 int use_fast_coef_updates; // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced 395 int use_fast_coef_updates; // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced
396
397 // This flag controls the use of non-RD mode decision.
398 int use_pick_mode;
399
400 // This variable sets the encode_breakout threshold. Currently, it is only
401 // enabled in real time mode.
402 int encode_breakout_thresh;
423 } SPEED_FEATURES; 403 } SPEED_FEATURES;
424 404
425 typedef struct { 405 typedef struct {
426 // Rate targetting variables 406 RATE_CONTROL rc;
427 int this_frame_target; 407 int target_bandwidth;
428 int projected_frame_size; 408 int64_t starting_buffer_level;
429 int sb64_target_rate; 409 int64_t optimal_buffer_level;
430 int last_q[3]; // Separate values for Intra/Inter/ARF-GF 410 int64_t maximum_buffer_size;
431 int last_boosted_qindex; // Last boosted GF/KF/ARF q 411 double framerate;
432 412 int avg_frame_size;
433 int gfu_boost; 413 } LAYER_CONTEXT;
434 int last_boost;
435 int kf_boost;
436
437 double rate_correction_factor;
438 double key_frame_rate_correction_factor;
439 double gf_rate_correction_factor;
440
441 unsigned int frames_since_golden;
442 unsigned int frames_till_gf_update_due; // Count down till next GF
443 unsigned int max_gf_interval;
444 unsigned int baseline_gf_interval;
445 unsigned int frames_to_key;
446 unsigned int frames_since_key;
447 unsigned int this_key_frame_forced;
448 unsigned int next_key_frame_forced;
449 unsigned int source_alt_ref_pending;
450 unsigned int source_alt_ref_active;
451 unsigned int is_src_frame_alt_ref;
452
453 int per_frame_bandwidth; // Current section per frame bandwidth target
454 int av_per_frame_bandwidth; // Average frame size target for clip
455 int min_frame_bandwidth; // Minimum allocation used for any frame
456 int max_frame_bandwidth; // Maximum burst rate allowed for a frame.
457
458 int ni_av_qi;
459 int ni_tot_qi;
460 int ni_frames;
461 int avg_frame_qindex[3]; // 0 - KEY, 1 - INTER, 2 - ARF/GF
462 double tot_q;
463 double avg_q;
464
465 int buffer_level;
466 int bits_off_target;
467
468 int decimation_factor;
469 int decimation_count;
470
471 int rolling_target_bits;
472 int rolling_actual_bits;
473
474 int long_rolling_target_bits;
475 int long_rolling_actual_bits;
476
477 int64_t total_actual_bits;
478 int total_target_vs_actual; // debug stats
479
480 int worst_quality;
481 int active_worst_quality;
482 int best_quality;
483 // int active_best_quality;
484 } RATE_CONTROL;
485 414
486 typedef struct VP9_COMP { 415 typedef struct VP9_COMP {
487 DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]); 416 DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]);
488 DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]); 417 DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]);
489 DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]); 418 DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]);
490 DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]); 419 DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]);
491 420
492 DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]); 421 DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]);
493 DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]); 422 DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]);
494 DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]); 423 DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]);
495 DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]); 424 DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
496 425
497 #if CONFIG_ALPHA 426 #if CONFIG_ALPHA
498 DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]); 427 DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]);
499 DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]); 428 DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]);
500 DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]); 429 DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]);
501 DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]); 430 DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]);
502 #endif 431 #endif
503 432
504 MACROBLOCK mb; 433 MACROBLOCK mb;
505 VP9_COMMON common; 434 VP9_COMMON common;
506 VP9_CONFIG oxcf; 435 VP9_CONFIG oxcf;
507 struct rdcost_block_args rdcost_stack;
508 struct lookahead_ctx *lookahead; 436 struct lookahead_ctx *lookahead;
509 struct lookahead_entry *source; 437 struct lookahead_entry *source;
510 #if CONFIG_MULTIPLE_ARF 438 #if CONFIG_MULTIPLE_ARF
511 struct lookahead_entry *alt_ref_source[REF_FRAMES]; 439 struct lookahead_entry *alt_ref_source[REF_FRAMES];
512 #else 440 #else
513 struct lookahead_entry *alt_ref_source; 441 struct lookahead_entry *alt_ref_source;
514 #endif 442 #endif
515 443
516 YV12_BUFFER_CONFIG *Source; 444 YV12_BUFFER_CONFIG *Source;
517 YV12_BUFFER_CONFIG *un_scaled_source; 445 YV12_BUFFER_CONFIG *un_scaled_source;
518 YV12_BUFFER_CONFIG scaled_source; 446 YV12_BUFFER_CONFIG scaled_source;
519 447
520 unsigned int key_frame_frequency; 448 unsigned int key_frame_frequency;
521 449
522 int gold_is_last; // gold same as last frame ( short circuit gold searches) 450 int gold_is_last; // gold same as last frame ( short circuit gold searches)
523 int alt_is_last; // Alt same as last ( short circuit altref search) 451 int alt_is_last; // Alt same as last ( short circuit altref search)
524 int gold_is_alt; // don't do both alt and gold search ( just do gold). 452 int gold_is_alt; // don't do both alt and gold search ( just do gold).
525 453
526 int scaled_ref_idx[3]; 454 int scaled_ref_idx[3];
527 int lst_fb_idx; 455 int lst_fb_idx;
528 int gld_fb_idx; 456 int gld_fb_idx;
529 int alt_fb_idx; 457 int alt_fb_idx;
530 458
531 int current_layer;
532 int use_svc;
533
534 #if CONFIG_MULTIPLE_ARF 459 #if CONFIG_MULTIPLE_ARF
535 int alt_ref_fb_idx[REF_FRAMES - 3]; 460 int alt_ref_fb_idx[REF_FRAMES - 3];
536 #endif 461 #endif
537 int refresh_last_frame; 462 int refresh_last_frame;
538 int refresh_golden_frame; 463 int refresh_golden_frame;
539 int refresh_alt_ref_frame; 464 int refresh_alt_ref_frame;
540 465
541 int ext_refresh_frame_flags_pending; 466 int ext_refresh_frame_flags_pending;
542 int ext_refresh_last_frame; 467 int ext_refresh_last_frame;
543 int ext_refresh_golden_frame; 468 int ext_refresh_golden_frame;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 int64_t first_time_stamp_ever; 524 int64_t first_time_stamp_ever;
600 525
601 RATE_CONTROL rc; 526 RATE_CONTROL rc;
602 527
603 int cq_target_quality; 528 int cq_target_quality;
604 529
605 vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES]; 530 vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
606 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES]; 531 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES];
607 vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES]; 532 vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES];
608 533
609 int64_t target_bandwidth;
610 struct vpx_codec_pkt_list *output_pkt_list; 534 struct vpx_codec_pkt_list *output_pkt_list;
611 535
612 #if 0
613 // Experimental code for lagged and one pass
614 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
615 int one_pass_frame_index;
616 #endif
617 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS]; 536 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
618 int mbgraph_n_frames; // number of frames filled in the above 537 int mbgraph_n_frames; // number of frames filled in the above
619 int static_mb_pct; // % forced skip mbs by segmentation 538 int static_mb_pct; // % forced skip mbs by segmentation
620 int seg0_progress, seg0_idx, seg0_cnt; 539 int seg0_progress, seg0_idx, seg0_cnt;
621 540
622 // for real time encoding 541 // for real time encoding
623 int speed; 542 int speed;
624 int compressor_speed;
625 543
626 int cpu_used; 544 int cpu_used;
627 int pass; 545 int pass;
628 546
629 vp9_prob last_skip_false_probs[3][MBSKIP_CONTEXTS]; 547 vp9_prob last_skip_false_probs[3][SKIP_CONTEXTS];
630 int last_skip_probs_q[3]; 548 int last_skip_probs_q[3];
631 549
632 int ref_frame_flags; 550 int ref_frame_flags;
633 551
634 SPEED_FEATURES sf; 552 SPEED_FEATURES sf;
635 553
636 unsigned int max_mv_magnitude; 554 unsigned int max_mv_magnitude;
637 int mv_step_param; 555 int mv_step_param;
638 556
557 // Default value is 1. From first pass stats, encode_breakout may be disabled.
558 ENCODE_BREAKOUT_TYPE allow_encode_breakout;
559
560 // Get threshold from external input. In real time mode, it can be
561 // overwritten according to encoding speed.
562 int encode_breakout;
563
639 unsigned char *segmentation_map; 564 unsigned char *segmentation_map;
640 565
641 // segment threashold for encode breakout 566 // segment threashold for encode breakout
642 int segment_encode_breakout[MAX_SEGMENTS]; 567 int segment_encode_breakout[MAX_SEGMENTS];
643 568
644 unsigned char *complexity_map; 569 unsigned char *complexity_map;
645 570
646 unsigned char *active_map; 571 unsigned char *active_map;
647 unsigned int active_map_enabled; 572 unsigned int active_map_enabled;
648 573
649 fractional_mv_step_fp *find_fractional_mv_step; 574 fractional_mv_step_fp *find_fractional_mv_step;
650 fractional_mv_step_comp_fp *find_fractional_mv_step_comp; 575 fractional_mv_step_comp_fp *find_fractional_mv_step_comp;
651 vp9_full_search_fn_t full_search_sad; 576 vp9_full_search_fn_t full_search_sad;
652 vp9_refining_search_fn_t refining_search_sad; 577 vp9_refining_search_fn_t refining_search_sad;
653 vp9_diamond_search_fn_t diamond_search_sad; 578 vp9_diamond_search_fn_t diamond_search_sad;
654 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES]; 579 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES];
655 uint64_t time_receive_data; 580 uint64_t time_receive_data;
656 uint64_t time_compress_data; 581 uint64_t time_compress_data;
657 uint64_t time_pick_lpf; 582 uint64_t time_pick_lpf;
658 uint64_t time_encode_sb_row; 583 uint64_t time_encode_sb_row;
659 584
660 struct twopass_rc { 585 struct twopass_rc twopass;
661 unsigned int section_intra_rating;
662 unsigned int next_iiratio;
663 unsigned int this_iiratio;
664 FIRSTPASS_STATS total_stats;
665 FIRSTPASS_STATS this_frame_stats;
666 FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
667 FIRSTPASS_STATS total_left_stats;
668 int first_pass_done;
669 int64_t bits_left;
670 int64_t clip_bits_total;
671 double avg_iiratio;
672 double modified_error_min;
673 double modified_error_max;
674 double modified_error_total;
675 double modified_error_left;
676 double kf_intra_err_min;
677 double gf_intra_err_min;
678 int static_scene_max_gf_interval;
679 int kf_bits;
680 // Remaining error from uncoded frames in a gf group. Two pass use only
681 int64_t gf_group_error_left;
682
683 // Projected total bits available for a key frame group of frames
684 int64_t kf_group_bits;
685
686 // Error score of frames still to be coded in kf group
687 int64_t kf_group_error_left;
688
689 // Projected Bits available for a group of frames including 1 GF or ARF
690 int64_t gf_group_bits;
691 // Bits for the golden frame or ARF - 2 pass only
692 int gf_bits;
693 int alt_extra_bits;
694
695 int sr_update_lag;
696
697 int kf_zeromotion_pct;
698 int gf_zeromotion_pct;
699 } twopass;
700 586
701 YV12_BUFFER_CONFIG alt_ref_buffer; 587 YV12_BUFFER_CONFIG alt_ref_buffer;
702 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; 588 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
703 int fixed_divide[512]; 589 int fixed_divide[512];
704 590
705 #if CONFIG_INTERNAL_STATS 591 #if CONFIG_INTERNAL_STATS
706 int count; 592 int count;
707 double total_y; 593 double total_y;
708 double total_u; 594 double total_u;
709 double total_v; 595 double total_v;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 632
747 int droppable; 633 int droppable;
748 634
749 int dummy_packing; /* flag to indicate if packing is dummy */ 635 int dummy_packing; /* flag to indicate if packing is dummy */
750 636
751 unsigned int tx_stepdown_count[TX_SIZES]; 637 unsigned int tx_stepdown_count[TX_SIZES];
752 638
753 int initial_width; 639 int initial_width;
754 int initial_height; 640 int initial_height;
755 641
756 int number_spatial_layers; 642 int use_svc;
757 int enable_encode_breakout; // Default value is 1. From first pass stats, 643
758 // encode_breakout may be disabled. 644 struct svc {
645 int spatial_layer_id;
646 int temporal_layer_id;
647 int number_spatial_layers;
648 int number_temporal_layers;
649 // Layer context used for rate control in CBR mode, only defined for
650 // temporal layers for now.
651 LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS];
652 } svc;
759 653
760 #if CONFIG_MULTIPLE_ARF 654 #if CONFIG_MULTIPLE_ARF
761 // ARF tracking variables. 655 // ARF tracking variables.
762 int multi_arf_enabled; 656 int multi_arf_enabled;
763 unsigned int frame_coding_order_period; 657 unsigned int frame_coding_order_period;
764 unsigned int new_frame_coding_order_period; 658 unsigned int new_frame_coding_order_period;
765 int frame_coding_order[MAX_LAG_BUFFERS * 2]; 659 int frame_coding_order[MAX_LAG_BUFFERS * 2];
766 int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2]; 660 int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2];
767 int arf_weight[MAX_LAG_BUFFERS]; 661 int arf_weight[MAX_LAG_BUFFERS];
768 int arf_buffered; 662 int arf_buffered;
(...skipping 26 matching lines...) Expand all
795 } else if (ref_frame == GOLDEN_FRAME) { 689 } else if (ref_frame == GOLDEN_FRAME) {
796 return cpi->gld_fb_idx; 690 return cpi->gld_fb_idx;
797 } else { 691 } else {
798 return cpi->alt_fb_idx; 692 return cpi->alt_fb_idx;
799 } 693 }
800 } 694 }
801 695
802 static YV12_BUFFER_CONFIG *get_ref_frame_buffer(VP9_COMP *cpi, 696 static YV12_BUFFER_CONFIG *get_ref_frame_buffer(VP9_COMP *cpi,
803 MV_REFERENCE_FRAME ref_frame) { 697 MV_REFERENCE_FRAME ref_frame) {
804 VP9_COMMON *const cm = &cpi->common; 698 VP9_COMMON *const cm = &cpi->common;
805 return &cm->yv12_fb[cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]]; 699 return &cm->frame_bufs[cm->ref_frame_map[get_ref_frame_idx(cpi,
700 ref_frame)]].buf;
806 } 701 }
807 702
808 void vp9_encode_frame(VP9_COMP *cpi); 703 void vp9_encode_frame(VP9_COMP *cpi);
809 704
810 void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, size_t *size); 705 void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, size_t *size);
811 706
812 void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x);
813
814 void vp9_set_speed_features(VP9_COMP *cpi); 707 void vp9_set_speed_features(VP9_COMP *cpi);
815 708
816 int vp9_calc_ss_err(const YV12_BUFFER_CONFIG *source, 709 int vp9_calc_ss_err(const YV12_BUFFER_CONFIG *source,
817 const YV12_BUFFER_CONFIG *reference); 710 const YV12_BUFFER_CONFIG *reference);
818 711
819 void vp9_alloc_compressor_data(VP9_COMP *cpi); 712 void vp9_alloc_compressor_data(VP9_COMP *cpi);
820 713
821 int vp9_compute_qdelta(const VP9_COMP *cpi, double qstart, double qtarget); 714 int vp9_compute_qdelta(const VP9_COMP *cpi, double qstart, double qtarget);
822 715
823 static int get_token_alloc(int mb_rows, int mb_cols) { 716 static int get_token_alloc(int mb_rows, int mb_cols) {
824 return mb_rows * mb_cols * (48 * 16 + 4); 717 return mb_rows * mb_cols * (48 * 16 + 4);
825 } 718 }
826 719
827 static void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, 720 static void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd,
828 MV_REFERENCE_FRAME ref0, MV_REFERENCE_FRAME ref1) { 721 MV_REFERENCE_FRAME ref0, MV_REFERENCE_FRAME ref1) {
829 xd->block_refs[0] = &cm->frame_refs[ref0 - LAST_FRAME]; 722 xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME
830 xd->block_refs[1] = &cm->frame_refs[ref1 - LAST_FRAME]; 723 : 0];
724 xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME
725 : 0];
831 } 726 }
832 727
833 #ifdef __cplusplus 728 #ifdef __cplusplus
834 } // extern "C" 729 } // extern "C"
835 #endif 730 #endif
836 731
837 #endif // VP9_ENCODER_VP9_ONYX_INT_H_ 732 #endif // VP9_ENCODER_VP9_ONYX_INT_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_onyx_if.c ('k') | source/libvpx/vp9/encoder/vp9_picklpf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698