media/libvpx/vp9/encoder/vp9_onyx_int.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11
michael@0 12 #ifndef VP9_ENCODER_VP9_ONYX_INT_H_
michael@0 13 #define VP9_ENCODER_VP9_ONYX_INT_H_
michael@0 14
michael@0 15 #include <stdio.h>
michael@0 16 #include "./vpx_config.h"
michael@0 17 #include "vp9/common/vp9_onyx.h"
michael@0 18 #include "vp9/encoder/vp9_treewriter.h"
michael@0 19 #include "vp9/encoder/vp9_tokenize.h"
michael@0 20 #include "vp9/common/vp9_onyxc_int.h"
michael@0 21 #include "vp9/encoder/vp9_variance.h"
michael@0 22 #include "vp9/encoder/vp9_encodemb.h"
michael@0 23 #include "vp9/encoder/vp9_quantize.h"
michael@0 24 #include "vp9/common/vp9_entropy.h"
michael@0 25 #include "vp9/common/vp9_entropymode.h"
michael@0 26 #include "vpx_ports/mem.h"
michael@0 27 #include "vpx/internal/vpx_codec_internal.h"
michael@0 28 #include "vp9/encoder/vp9_mcomp.h"
michael@0 29 #include "vp9/common/vp9_findnearmv.h"
michael@0 30 #include "vp9/encoder/vp9_lookahead.h"
michael@0 31
michael@0 32 #define DISABLE_RC_LONG_TERM_MEM 0
michael@0 33
michael@0 34 // #define MODE_TEST_HIT_STATS
michael@0 35
michael@0 36 // #define SPEEDSTATS 1
michael@0 37 #if CONFIG_MULTIPLE_ARF
michael@0 38 // Set MIN_GF_INTERVAL to 1 for the full decomposition.
michael@0 39 #define MIN_GF_INTERVAL 2
michael@0 40 #else
michael@0 41 #define MIN_GF_INTERVAL 4
michael@0 42 #endif
michael@0 43 #define DEFAULT_GF_INTERVAL 7
michael@0 44
michael@0 45 #define KEY_FRAME_CONTEXT 5
michael@0 46
michael@0 47 #define MAX_MODES 30
michael@0 48 #define MAX_REFS 6
michael@0 49
michael@0 50 #define MIN_THRESHMULT 32
michael@0 51 #define MAX_THRESHMULT 512
michael@0 52
michael@0 53 #define GF_ZEROMV_ZBIN_BOOST 0
michael@0 54 #define LF_ZEROMV_ZBIN_BOOST 0
michael@0 55 #define MV_ZBIN_BOOST 0
michael@0 56 #define SPLIT_MV_ZBIN_BOOST 0
michael@0 57 #define INTRA_ZBIN_BOOST 0
michael@0 58
michael@0 59 typedef struct {
michael@0 60 int nmvjointcost[MV_JOINTS];
michael@0 61 int nmvcosts[2][MV_VALS];
michael@0 62 int nmvcosts_hp[2][MV_VALS];
michael@0 63
michael@0 64 vp9_prob segment_pred_probs[PREDICTION_PROBS];
michael@0 65
michael@0 66 unsigned char *last_frame_seg_map_copy;
michael@0 67
michael@0 68 // 0 = Intra, Last, GF, ARF
michael@0 69 signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
michael@0 70 // 0 = ZERO_MV, MV
michael@0 71 signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
michael@0 72
michael@0 73 int inter_mode_counts[INTER_MODE_CONTEXTS][INTER_MODES - 1][2];
michael@0 74 FRAME_CONTEXT fc;
michael@0 75 } CODING_CONTEXT;
michael@0 76
michael@0 77 typedef struct {
michael@0 78 double frame;
michael@0 79 double intra_error;
michael@0 80 double coded_error;
michael@0 81 double sr_coded_error;
michael@0 82 double ssim_weighted_pred_err;
michael@0 83 double pcnt_inter;
michael@0 84 double pcnt_motion;
michael@0 85 double pcnt_second_ref;
michael@0 86 double pcnt_neutral;
michael@0 87 double MVr;
michael@0 88 double mvr_abs;
michael@0 89 double MVc;
michael@0 90 double mvc_abs;
michael@0 91 double MVrv;
michael@0 92 double MVcv;
michael@0 93 double mv_in_out_count;
michael@0 94 double new_mv_count;
michael@0 95 double duration;
michael@0 96 double count;
michael@0 97 } FIRSTPASS_STATS;
michael@0 98
michael@0 99 typedef struct {
michael@0 100 int frames_so_far;
michael@0 101 double frame_intra_error;
michael@0 102 double frame_coded_error;
michael@0 103 double frame_pcnt_inter;
michael@0 104 double frame_pcnt_motion;
michael@0 105 double frame_mvr;
michael@0 106 double frame_mvr_abs;
michael@0 107 double frame_mvc;
michael@0 108 double frame_mvc_abs;
michael@0 109 } ONEPASS_FRAMESTATS;
michael@0 110
michael@0 111 typedef struct {
michael@0 112 struct {
michael@0 113 int err;
michael@0 114 union {
michael@0 115 int_mv mv;
michael@0 116 MB_PREDICTION_MODE mode;
michael@0 117 } m;
michael@0 118 } ref[MAX_REF_FRAMES];
michael@0 119 } MBGRAPH_MB_STATS;
michael@0 120
michael@0 121 typedef struct {
michael@0 122 MBGRAPH_MB_STATS *mb_stats;
michael@0 123 } MBGRAPH_FRAME_STATS;
michael@0 124
michael@0 125 // This enumerator type needs to be kept aligned with the mode order in
michael@0 126 // const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code.
michael@0 127 typedef enum {
michael@0 128 THR_NEARESTMV,
michael@0 129 THR_NEARESTA,
michael@0 130 THR_NEARESTG,
michael@0 131
michael@0 132 THR_DC,
michael@0 133
michael@0 134 THR_NEWMV,
michael@0 135 THR_NEWA,
michael@0 136 THR_NEWG,
michael@0 137
michael@0 138 THR_NEARMV,
michael@0 139 THR_NEARA,
michael@0 140 THR_COMP_NEARESTLA,
michael@0 141 THR_COMP_NEARESTGA,
michael@0 142
michael@0 143 THR_TM,
michael@0 144
michael@0 145 THR_COMP_NEARLA,
michael@0 146 THR_COMP_NEWLA,
michael@0 147 THR_NEARG,
michael@0 148 THR_COMP_NEARGA,
michael@0 149 THR_COMP_NEWGA,
michael@0 150
michael@0 151 THR_ZEROMV,
michael@0 152 THR_ZEROG,
michael@0 153 THR_ZEROA,
michael@0 154 THR_COMP_ZEROLA,
michael@0 155 THR_COMP_ZEROGA,
michael@0 156
michael@0 157 THR_H_PRED,
michael@0 158 THR_V_PRED,
michael@0 159 THR_D135_PRED,
michael@0 160 THR_D207_PRED,
michael@0 161 THR_D153_PRED,
michael@0 162 THR_D63_PRED,
michael@0 163 THR_D117_PRED,
michael@0 164 THR_D45_PRED,
michael@0 165 } THR_MODES;
michael@0 166
michael@0 167 typedef enum {
michael@0 168 THR_LAST,
michael@0 169 THR_GOLD,
michael@0 170 THR_ALTR,
michael@0 171 THR_COMP_LA,
michael@0 172 THR_COMP_GA,
michael@0 173 THR_INTRA,
michael@0 174 } THR_MODES_SUB8X8;
michael@0 175
michael@0 176 typedef enum {
michael@0 177 DIAMOND = 0,
michael@0 178 NSTEP = 1,
michael@0 179 HEX = 2,
michael@0 180 BIGDIA = 3,
michael@0 181 SQUARE = 4
michael@0 182 } SEARCH_METHODS;
michael@0 183
michael@0 184 typedef enum {
michael@0 185 USE_FULL_RD = 0,
michael@0 186 USE_LARGESTINTRA,
michael@0 187 USE_LARGESTINTRA_MODELINTER,
michael@0 188 USE_LARGESTALL
michael@0 189 } TX_SIZE_SEARCH_METHOD;
michael@0 190
michael@0 191 typedef enum {
michael@0 192 // Values should be powers of 2 so that they can be selected as bits of
michael@0 193 // an integer flags field
michael@0 194
michael@0 195 // terminate search early based on distortion so far compared to
michael@0 196 // qp step, distortion in the neighborhood of the frame, etc.
michael@0 197 FLAG_EARLY_TERMINATE = 1,
michael@0 198
michael@0 199 // skips comp inter modes if the best so far is an intra mode
michael@0 200 FLAG_SKIP_COMP_BESTINTRA = 2,
michael@0 201
michael@0 202 // skips comp inter modes if the best single intermode so far does
michael@0 203 // not have the same reference as one of the two references being
michael@0 204 // tested
michael@0 205 FLAG_SKIP_COMP_REFMISMATCH = 4,
michael@0 206
michael@0 207 // skips oblique intra modes if the best so far is an inter mode
michael@0 208 FLAG_SKIP_INTRA_BESTINTER = 8,
michael@0 209
michael@0 210 // skips oblique intra modes at angles 27, 63, 117, 153 if the best
michael@0 211 // intra so far is not one of the neighboring directions
michael@0 212 FLAG_SKIP_INTRA_DIRMISMATCH = 16,
michael@0 213
michael@0 214 // skips intra modes other than DC_PRED if the source variance
michael@0 215 // is small
michael@0 216 FLAG_SKIP_INTRA_LOWVAR = 32,
michael@0 217 } MODE_SEARCH_SKIP_LOGIC;
michael@0 218
michael@0 219 typedef enum {
michael@0 220 SUBPEL_ITERATIVE = 0,
michael@0 221 SUBPEL_TREE = 1,
michael@0 222 // Other methods to come
michael@0 223 } SUBPEL_SEARCH_METHODS;
michael@0 224
michael@0 225 #define ALL_INTRA_MODES 0x3FF
michael@0 226 #define INTRA_DC_ONLY 0x01
michael@0 227 #define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED))
michael@0 228 #define INTRA_DC_H_V ((1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED))
michael@0 229 #define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED))
michael@0 230
michael@0 231 typedef enum {
michael@0 232 LAST_FRAME_PARTITION_OFF = 0,
michael@0 233 LAST_FRAME_PARTITION_LOW_MOTION = 1,
michael@0 234 LAST_FRAME_PARTITION_ALL = 2
michael@0 235 } LAST_FRAME_PARTITION_METHOD;
michael@0 236
michael@0 237 typedef struct {
michael@0 238 int RD;
michael@0 239 SEARCH_METHODS search_method;
michael@0 240 int auto_filter;
michael@0 241 int recode_loop;
michael@0 242 SUBPEL_SEARCH_METHODS subpel_search_method;
michael@0 243 int subpel_iters_per_step;
michael@0 244 int thresh_mult[MAX_MODES];
michael@0 245 int thresh_mult_sub8x8[MAX_REFS];
michael@0 246 int max_step_search_steps;
michael@0 247 int reduce_first_step_size;
michael@0 248 int auto_mv_step_size;
michael@0 249 int optimize_coefficients;
michael@0 250 int static_segmentation;
michael@0 251 int comp_inter_joint_search_thresh;
michael@0 252 int adaptive_rd_thresh;
michael@0 253 int skip_encode_sb;
michael@0 254 int skip_encode_frame;
michael@0 255 LAST_FRAME_PARTITION_METHOD use_lastframe_partitioning;
michael@0 256 TX_SIZE_SEARCH_METHOD tx_size_search_method;
michael@0 257 int use_lp32x32fdct;
michael@0 258 int use_avoid_tested_higherror;
michael@0 259 int use_one_partition_size_always;
michael@0 260 int less_rectangular_check;
michael@0 261 int use_square_partition_only;
michael@0 262 int mode_skip_start;
michael@0 263 int reference_masking;
michael@0 264 BLOCK_SIZE always_this_block_size;
michael@0 265 int auto_min_max_partition_size;
michael@0 266 BLOCK_SIZE min_partition_size;
michael@0 267 BLOCK_SIZE max_partition_size;
michael@0 268 int adjust_partitioning_from_last_frame;
michael@0 269 int last_partitioning_redo_frequency;
michael@0 270 int disable_split_mask;
michael@0 271 int using_small_partition_info;
michael@0 272 // TODO(jingning): combine the related motion search speed features
michael@0 273 int adaptive_motion_search;
michael@0 274
michael@0 275 // Implements various heuristics to skip searching modes
michael@0 276 // The heuristics selected are based on flags
michael@0 277 // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
michael@0 278 unsigned int mode_search_skip_flags;
michael@0 279 // A source variance threshold below which the split mode is disabled
michael@0 280 unsigned int disable_split_var_thresh;
michael@0 281 // A source variance threshold below which filter search is disabled
michael@0 282 // Choose a very large value (UINT_MAX) to use 8-tap always
michael@0 283 unsigned int disable_filter_search_var_thresh;
michael@0 284 int intra_y_mode_mask[TX_SIZES];
michael@0 285 int intra_uv_mode_mask[TX_SIZES];
michael@0 286 int use_rd_breakout;
michael@0 287 int use_uv_intra_rd_estimate;
michael@0 288 int use_fast_lpf_pick;
michael@0 289 int use_fast_coef_updates; // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced
michael@0 290 } SPEED_FEATURES;
michael@0 291
michael@0 292 typedef struct VP9_COMP {
michael@0 293 DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]);
michael@0 294 DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]);
michael@0 295 DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]);
michael@0 296 DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]);
michael@0 297
michael@0 298 DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]);
michael@0 299 DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]);
michael@0 300 DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]);
michael@0 301 DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
michael@0 302
michael@0 303 #if CONFIG_ALPHA
michael@0 304 DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]);
michael@0 305 DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]);
michael@0 306 DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]);
michael@0 307 DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]);
michael@0 308 #endif
michael@0 309
michael@0 310 MACROBLOCK mb;
michael@0 311 VP9_COMMON common;
michael@0 312 VP9_CONFIG oxcf;
michael@0 313 struct rdcost_block_args rdcost_stack;
michael@0 314 struct lookahead_ctx *lookahead;
michael@0 315 struct lookahead_entry *source;
michael@0 316 #if CONFIG_MULTIPLE_ARF
michael@0 317 struct lookahead_entry *alt_ref_source[NUM_REF_FRAMES];
michael@0 318 #else
michael@0 319 struct lookahead_entry *alt_ref_source;
michael@0 320 #endif
michael@0 321
michael@0 322 YV12_BUFFER_CONFIG *Source;
michael@0 323 YV12_BUFFER_CONFIG *un_scaled_source;
michael@0 324 YV12_BUFFER_CONFIG scaled_source;
michael@0 325
michael@0 326 unsigned int frames_till_alt_ref_frame;
michael@0 327 int source_alt_ref_pending;
michael@0 328 int source_alt_ref_active;
michael@0 329
michael@0 330 int is_src_frame_alt_ref;
michael@0 331
michael@0 332 int gold_is_last; // gold same as last frame ( short circuit gold searches)
michael@0 333 int alt_is_last; // Alt same as last ( short circuit altref search)
michael@0 334 int gold_is_alt; // don't do both alt and gold search ( just do gold).
michael@0 335
michael@0 336 int scaled_ref_idx[3];
michael@0 337 int lst_fb_idx;
michael@0 338 int gld_fb_idx;
michael@0 339 int alt_fb_idx;
michael@0 340
michael@0 341 int current_layer;
michael@0 342 int use_svc;
michael@0 343
michael@0 344 #if CONFIG_MULTIPLE_ARF
michael@0 345 int alt_ref_fb_idx[NUM_REF_FRAMES - 3];
michael@0 346 #endif
michael@0 347 int refresh_last_frame;
michael@0 348 int refresh_golden_frame;
michael@0 349 int refresh_alt_ref_frame;
michael@0 350 YV12_BUFFER_CONFIG last_frame_uf;
michael@0 351
michael@0 352 TOKENEXTRA *tok;
michael@0 353 unsigned int tok_count[4][1 << 6];
michael@0 354
michael@0 355
michael@0 356 unsigned int frames_since_key;
michael@0 357 unsigned int key_frame_frequency;
michael@0 358 unsigned int this_key_frame_forced;
michael@0 359 unsigned int next_key_frame_forced;
michael@0 360 #if CONFIG_MULTIPLE_ARF
michael@0 361 // Position within a frame coding order (including any additional ARF frames).
michael@0 362 unsigned int sequence_number;
michael@0 363 // Next frame in naturally occurring order that has not yet been coded.
michael@0 364 int next_frame_in_order;
michael@0 365 #endif
michael@0 366
michael@0 367 // Ambient reconstruction err target for force key frames
michael@0 368 int ambient_err;
michael@0 369
michael@0 370 unsigned int mode_chosen_counts[MAX_MODES];
michael@0 371 unsigned int sub8x8_mode_chosen_counts[MAX_REFS];
michael@0 372 int64_t mode_skip_mask;
michael@0 373 int ref_frame_mask;
michael@0 374 int set_ref_frame_mask;
michael@0 375
michael@0 376 int rd_threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES];
michael@0 377 int rd_thresh_freq_fact[BLOCK_SIZES][MAX_MODES];
michael@0 378 int rd_thresh_sub8x8[MAX_SEGMENTS][BLOCK_SIZES][MAX_REFS];
michael@0 379 int rd_thresh_freq_sub8x8[BLOCK_SIZES][MAX_REFS];
michael@0 380
michael@0 381 int64_t rd_comp_pred_diff[NB_PREDICTION_TYPES];
michael@0 382 int64_t rd_prediction_type_threshes[4][NB_PREDICTION_TYPES];
michael@0 383 unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2];
michael@0 384 unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
michael@0 385 unsigned int single_ref_count[REF_CONTEXTS][2][2];
michael@0 386 unsigned int comp_ref_count[REF_CONTEXTS][2];
michael@0 387
michael@0 388 int64_t rd_tx_select_diff[TX_MODES];
michael@0 389 // FIXME(rbultje) can this overflow?
michael@0 390 int rd_tx_select_threshes[4][TX_MODES];
michael@0 391
michael@0 392 int64_t rd_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
michael@0 393 int64_t rd_filter_threshes[4][SWITCHABLE_FILTER_CONTEXTS];
michael@0 394 int64_t rd_filter_cache[SWITCHABLE_FILTER_CONTEXTS];
michael@0 395
michael@0 396 int RDMULT;
michael@0 397 int RDDIV;
michael@0 398
michael@0 399 CODING_CONTEXT coding_context;
michael@0 400
michael@0 401 // Rate targetting variables
michael@0 402 int this_frame_target;
michael@0 403 int projected_frame_size;
michael@0 404 int last_q[2]; // Separate values for Intra/Inter
michael@0 405 int last_boosted_qindex; // Last boosted GF/KF/ARF q
michael@0 406
michael@0 407 double rate_correction_factor;
michael@0 408 double key_frame_rate_correction_factor;
michael@0 409 double gf_rate_correction_factor;
michael@0 410
michael@0 411 unsigned int frames_since_golden;
michael@0 412 int frames_till_gf_update_due; // Count down till next GF
michael@0 413
michael@0 414 int gf_overspend_bits; // cumulative bits overspent because of GF boost
michael@0 415
michael@0 416 int non_gf_bitrate_adjustment; // Following GF to recover extra bits spent
michael@0 417
michael@0 418 int kf_overspend_bits; // Bits spent on key frames to be recovered on inters
michael@0 419 int kf_bitrate_adjustment; // number of bits to recover on each inter frame.
michael@0 420 int max_gf_interval;
michael@0 421 int baseline_gf_interval;
michael@0 422 int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
michael@0 423 int active_arnr_strength; // <= cpi->oxcf.arnr_max_strength
michael@0 424
michael@0 425 int64_t key_frame_count;
michael@0 426 int prior_key_frame_distance[KEY_FRAME_CONTEXT];
michael@0 427 int per_frame_bandwidth; // Current section per frame bandwidth target
michael@0 428 int av_per_frame_bandwidth; // Average frame size target for clip
michael@0 429 int min_frame_bandwidth; // Minimum allocation used for any frame
michael@0 430 int inter_frame_target;
michael@0 431 double output_framerate;
michael@0 432 int64_t last_time_stamp_seen;
michael@0 433 int64_t last_end_time_stamp_seen;
michael@0 434 int64_t first_time_stamp_ever;
michael@0 435
michael@0 436 int ni_av_qi;
michael@0 437 int ni_tot_qi;
michael@0 438 int ni_frames;
michael@0 439 int avg_frame_qindex;
michael@0 440 double tot_q;
michael@0 441 double avg_q;
michael@0 442
michael@0 443 int zbin_mode_boost;
michael@0 444 int zbin_mode_boost_enabled;
michael@0 445
michael@0 446 int64_t total_byte_count;
michael@0 447
michael@0 448 int buffered_mode;
michael@0 449
michael@0 450 int buffer_level;
michael@0 451 int bits_off_target;
michael@0 452
michael@0 453 int rolling_target_bits;
michael@0 454 int rolling_actual_bits;
michael@0 455
michael@0 456 int long_rolling_target_bits;
michael@0 457 int long_rolling_actual_bits;
michael@0 458
michael@0 459 int64_t total_actual_bits;
michael@0 460 int total_target_vs_actual; // debug stats
michael@0 461
michael@0 462 int worst_quality;
michael@0 463 int active_worst_quality;
michael@0 464 int best_quality;
michael@0 465 int active_best_quality;
michael@0 466
michael@0 467 int cq_target_quality;
michael@0 468
michael@0 469 int y_mode_count[4][INTRA_MODES];
michael@0 470 int y_uv_mode_count[INTRA_MODES][INTRA_MODES];
michael@0 471 unsigned int partition_count[PARTITION_CONTEXTS][PARTITION_TYPES];
michael@0 472
michael@0 473 nmv_context_counts NMVcount;
michael@0 474
michael@0 475 vp9_coeff_count coef_counts[TX_SIZES][BLOCK_TYPES];
michael@0 476 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][BLOCK_TYPES];
michael@0 477 vp9_coeff_stats frame_branch_ct[TX_SIZES][BLOCK_TYPES];
michael@0 478
michael@0 479 int gfu_boost;
michael@0 480 int last_boost;
michael@0 481 int kf_boost;
michael@0 482 int kf_zeromotion_pct;
michael@0 483 int gf_zeromotion_pct;
michael@0 484
michael@0 485 int64_t target_bandwidth;
michael@0 486 struct vpx_codec_pkt_list *output_pkt_list;
michael@0 487
michael@0 488 #if 0
michael@0 489 // Experimental code for lagged and one pass
michael@0 490 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
michael@0 491 int one_pass_frame_index;
michael@0 492 #endif
michael@0 493 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
michael@0 494 int mbgraph_n_frames; // number of frames filled in the above
michael@0 495 int static_mb_pct; // % forced skip mbs by segmentation
michael@0 496 int seg0_progress, seg0_idx, seg0_cnt;
michael@0 497
michael@0 498 int decimation_factor;
michael@0 499 int decimation_count;
michael@0 500
michael@0 501 // for real time encoding
michael@0 502 int speed;
michael@0 503 int compressor_speed;
michael@0 504
michael@0 505 int auto_worst_q;
michael@0 506 int cpu_used;
michael@0 507 int pass;
michael@0 508
michael@0 509 vp9_prob last_skip_false_probs[3][MBSKIP_CONTEXTS];
michael@0 510 int last_skip_probs_q[3];
michael@0 511
michael@0 512 int ref_frame_flags;
michael@0 513
michael@0 514 SPEED_FEATURES sf;
michael@0 515 int error_bins[1024];
michael@0 516
michael@0 517 unsigned int max_mv_magnitude;
michael@0 518 int mv_step_param;
michael@0 519
michael@0 520 unsigned char *segmentation_map;
michael@0 521
michael@0 522 // segment threashold for encode breakout
michael@0 523 int segment_encode_breakout[MAX_SEGMENTS];
michael@0 524
michael@0 525 unsigned char *active_map;
michael@0 526 unsigned int active_map_enabled;
michael@0 527
michael@0 528 fractional_mv_step_fp *find_fractional_mv_step;
michael@0 529 fractional_mv_step_comp_fp *find_fractional_mv_step_comp;
michael@0 530 vp9_full_search_fn_t full_search_sad;
michael@0 531 vp9_refining_search_fn_t refining_search_sad;
michael@0 532 vp9_diamond_search_fn_t diamond_search_sad;
michael@0 533 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES];
michael@0 534 uint64_t time_receive_data;
michael@0 535 uint64_t time_compress_data;
michael@0 536 uint64_t time_pick_lpf;
michael@0 537 uint64_t time_encode_sb_row;
michael@0 538
michael@0 539 struct twopass_rc {
michael@0 540 unsigned int section_intra_rating;
michael@0 541 unsigned int next_iiratio;
michael@0 542 unsigned int this_iiratio;
michael@0 543 FIRSTPASS_STATS total_stats;
michael@0 544 FIRSTPASS_STATS this_frame_stats;
michael@0 545 FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
michael@0 546 FIRSTPASS_STATS total_left_stats;
michael@0 547 int first_pass_done;
michael@0 548 int64_t bits_left;
michael@0 549 int64_t clip_bits_total;
michael@0 550 double avg_iiratio;
michael@0 551 double modified_error_total;
michael@0 552 double modified_error_used;
michael@0 553 double modified_error_left;
michael@0 554 double kf_intra_err_min;
michael@0 555 double gf_intra_err_min;
michael@0 556 int frames_to_key;
michael@0 557 int maxq_max_limit;
michael@0 558 int maxq_min_limit;
michael@0 559 int static_scene_max_gf_interval;
michael@0 560 int kf_bits;
michael@0 561 // Remaining error from uncoded frames in a gf group. Two pass use only
michael@0 562 int64_t gf_group_error_left;
michael@0 563
michael@0 564 // Projected total bits available for a key frame group of frames
michael@0 565 int64_t kf_group_bits;
michael@0 566
michael@0 567 // Error score of frames still to be coded in kf group
michael@0 568 int64_t kf_group_error_left;
michael@0 569
michael@0 570 // Projected Bits available for a group of frames including 1 GF or ARF
michael@0 571 int64_t gf_group_bits;
michael@0 572 // Bits for the golden frame or ARF - 2 pass only
michael@0 573 int gf_bits;
michael@0 574 int alt_extra_bits;
michael@0 575
michael@0 576 int sr_update_lag;
michael@0 577 double est_max_qcorrection_factor;
michael@0 578 } twopass;
michael@0 579
michael@0 580 YV12_BUFFER_CONFIG alt_ref_buffer;
michael@0 581 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
michael@0 582 int fixed_divide[512];
michael@0 583
michael@0 584 #if CONFIG_INTERNAL_STATS
michael@0 585 int count;
michael@0 586 double total_y;
michael@0 587 double total_u;
michael@0 588 double total_v;
michael@0 589 double total;
michael@0 590 double total_sq_error;
michael@0 591 double totalp_y;
michael@0 592 double totalp_u;
michael@0 593 double totalp_v;
michael@0 594 double totalp;
michael@0 595 double total_sq_error2;
michael@0 596 int bytes;
michael@0 597 double summed_quality;
michael@0 598 double summed_weights;
michael@0 599 double summedp_quality;
michael@0 600 double summedp_weights;
michael@0 601 unsigned int tot_recode_hits;
michael@0 602
michael@0 603
michael@0 604 double total_ssimg_y;
michael@0 605 double total_ssimg_u;
michael@0 606 double total_ssimg_v;
michael@0 607 double total_ssimg_all;
michael@0 608
michael@0 609 int b_calculate_ssimg;
michael@0 610 #endif
michael@0 611 int b_calculate_psnr;
michael@0 612
michael@0 613 // Per MB activity measurement
michael@0 614 unsigned int activity_avg;
michael@0 615 unsigned int *mb_activity_map;
michael@0 616 int *mb_norm_activity_map;
michael@0 617 int output_partition;
michael@0 618
michael@0 619 /* force next frame to intra when kf_auto says so */
michael@0 620 int force_next_frame_intra;
michael@0 621
michael@0 622 int droppable;
michael@0 623
michael@0 624 int dummy_packing; /* flag to indicate if packing is dummy */
michael@0 625
michael@0 626 unsigned int switchable_interp_count[SWITCHABLE_FILTER_CONTEXTS]
michael@0 627 [SWITCHABLE_FILTERS];
michael@0 628
michael@0 629 unsigned int tx_stepdown_count[TX_SIZES];
michael@0 630
michael@0 631 int initial_width;
michael@0 632 int initial_height;
michael@0 633
michael@0 634 int number_spatial_layers;
michael@0 635 int enable_encode_breakout; // Default value is 1. From first pass stats,
michael@0 636 // encode_breakout may be disabled.
michael@0 637
michael@0 638 #if CONFIG_MULTIPLE_ARF
michael@0 639 // ARF tracking variables.
michael@0 640 int multi_arf_enabled;
michael@0 641 unsigned int frame_coding_order_period;
michael@0 642 unsigned int new_frame_coding_order_period;
michael@0 643 int frame_coding_order[MAX_LAG_BUFFERS * 2];
michael@0 644 int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2];
michael@0 645 int arf_weight[MAX_LAG_BUFFERS];
michael@0 646 int arf_buffered;
michael@0 647 int this_frame_weight;
michael@0 648 int max_arf_level;
michael@0 649 #endif
michael@0 650
michael@0 651 #ifdef ENTROPY_STATS
michael@0 652 int64_t mv_ref_stats[INTER_MODE_CONTEXTS][INTER_MODES - 1][2];
michael@0 653 #endif
michael@0 654
michael@0 655
michael@0 656 #ifdef MODE_TEST_HIT_STATS
michael@0 657 // Debug / test stats
michael@0 658 int64_t mode_test_hits[BLOCK_SIZES];
michael@0 659 #endif
michael@0 660
michael@0 661 /* Y,U,V,(A) */
michael@0 662 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
michael@0 663 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16];
michael@0 664
michael@0 665 PARTITION_CONTEXT *above_seg_context;
michael@0 666 PARTITION_CONTEXT left_seg_context[8];
michael@0 667 } VP9_COMP;
michael@0 668
michael@0 669 static int get_ref_frame_idx(VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
michael@0 670 if (ref_frame == LAST_FRAME) {
michael@0 671 return cpi->lst_fb_idx;
michael@0 672 } else if (ref_frame == GOLDEN_FRAME) {
michael@0 673 return cpi->gld_fb_idx;
michael@0 674 } else {
michael@0 675 return cpi->alt_fb_idx;
michael@0 676 }
michael@0 677 }
michael@0 678
michael@0 679 static int get_scale_ref_frame_idx(VP9_COMP *cpi,
michael@0 680 MV_REFERENCE_FRAME ref_frame) {
michael@0 681 if (ref_frame == LAST_FRAME) {
michael@0 682 return 0;
michael@0 683 } else if (ref_frame == GOLDEN_FRAME) {
michael@0 684 return 1;
michael@0 685 } else {
michael@0 686 return 2;
michael@0 687 }
michael@0 688 }
michael@0 689
michael@0 690 void vp9_encode_frame(VP9_COMP *cpi);
michael@0 691
michael@0 692 void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
michael@0 693 unsigned long *size);
michael@0 694
michael@0 695 void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x);
michael@0 696
michael@0 697 void vp9_set_speed_features(VP9_COMP *cpi);
michael@0 698
michael@0 699 int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest);
michael@0 700
michael@0 701 void vp9_alloc_compressor_data(VP9_COMP *cpi);
michael@0 702
michael@0 703 int vp9_compute_qdelta(VP9_COMP *cpi, double qstart, double qtarget);
michael@0 704
michael@0 705 static int get_token_alloc(int mb_rows, int mb_cols) {
michael@0 706 return mb_rows * mb_cols * (48 * 16 + 4);
michael@0 707 }
michael@0 708
michael@0 709 #endif // VP9_ENCODER_VP9_ONYX_INT_H_

mercurial