media/libvpx/vp9/encoder/vp9_onyx_int.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp9/encoder/vp9_onyx_int.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,709 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +
    1.15 +#ifndef VP9_ENCODER_VP9_ONYX_INT_H_
    1.16 +#define VP9_ENCODER_VP9_ONYX_INT_H_
    1.17 +
    1.18 +#include <stdio.h>
    1.19 +#include "./vpx_config.h"
    1.20 +#include "vp9/common/vp9_onyx.h"
    1.21 +#include "vp9/encoder/vp9_treewriter.h"
    1.22 +#include "vp9/encoder/vp9_tokenize.h"
    1.23 +#include "vp9/common/vp9_onyxc_int.h"
    1.24 +#include "vp9/encoder/vp9_variance.h"
    1.25 +#include "vp9/encoder/vp9_encodemb.h"
    1.26 +#include "vp9/encoder/vp9_quantize.h"
    1.27 +#include "vp9/common/vp9_entropy.h"
    1.28 +#include "vp9/common/vp9_entropymode.h"
    1.29 +#include "vpx_ports/mem.h"
    1.30 +#include "vpx/internal/vpx_codec_internal.h"
    1.31 +#include "vp9/encoder/vp9_mcomp.h"
    1.32 +#include "vp9/common/vp9_findnearmv.h"
    1.33 +#include "vp9/encoder/vp9_lookahead.h"
    1.34 +
    1.35 +#define DISABLE_RC_LONG_TERM_MEM 0
    1.36 +
    1.37 +// #define MODE_TEST_HIT_STATS
    1.38 +
    1.39 +// #define SPEEDSTATS 1
    1.40 +#if CONFIG_MULTIPLE_ARF
    1.41 +// Set MIN_GF_INTERVAL to 1 for the full decomposition.
    1.42 +#define MIN_GF_INTERVAL             2
    1.43 +#else
    1.44 +#define MIN_GF_INTERVAL             4
    1.45 +#endif
    1.46 +#define DEFAULT_GF_INTERVAL         7
    1.47 +
    1.48 +#define KEY_FRAME_CONTEXT 5
    1.49 +
    1.50 +#define MAX_MODES 30
    1.51 +#define MAX_REFS  6
    1.52 +
    1.53 +#define MIN_THRESHMULT  32
    1.54 +#define MAX_THRESHMULT  512
    1.55 +
    1.56 +#define GF_ZEROMV_ZBIN_BOOST 0
    1.57 +#define LF_ZEROMV_ZBIN_BOOST 0
    1.58 +#define MV_ZBIN_BOOST        0
    1.59 +#define SPLIT_MV_ZBIN_BOOST  0
    1.60 +#define INTRA_ZBIN_BOOST     0
    1.61 +
    1.62 +typedef struct {
    1.63 +  int nmvjointcost[MV_JOINTS];
    1.64 +  int nmvcosts[2][MV_VALS];
    1.65 +  int nmvcosts_hp[2][MV_VALS];
    1.66 +
    1.67 +  vp9_prob segment_pred_probs[PREDICTION_PROBS];
    1.68 +
    1.69 +  unsigned char *last_frame_seg_map_copy;
    1.70 +
    1.71 +  // 0 = Intra, Last, GF, ARF
    1.72 +  signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
    1.73 +  // 0 = ZERO_MV, MV
    1.74 +  signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
    1.75 +
    1.76 +  int inter_mode_counts[INTER_MODE_CONTEXTS][INTER_MODES - 1][2];
    1.77 +  FRAME_CONTEXT fc;
    1.78 +} CODING_CONTEXT;
    1.79 +
    1.80 +typedef struct {
    1.81 +  double frame;
    1.82 +  double intra_error;
    1.83 +  double coded_error;
    1.84 +  double sr_coded_error;
    1.85 +  double ssim_weighted_pred_err;
    1.86 +  double pcnt_inter;
    1.87 +  double pcnt_motion;
    1.88 +  double pcnt_second_ref;
    1.89 +  double pcnt_neutral;
    1.90 +  double MVr;
    1.91 +  double mvr_abs;
    1.92 +  double MVc;
    1.93 +  double mvc_abs;
    1.94 +  double MVrv;
    1.95 +  double MVcv;
    1.96 +  double mv_in_out_count;
    1.97 +  double new_mv_count;
    1.98 +  double duration;
    1.99 +  double count;
   1.100 +} FIRSTPASS_STATS;
   1.101 +
   1.102 +typedef struct {
   1.103 +  int frames_so_far;
   1.104 +  double frame_intra_error;
   1.105 +  double frame_coded_error;
   1.106 +  double frame_pcnt_inter;
   1.107 +  double frame_pcnt_motion;
   1.108 +  double frame_mvr;
   1.109 +  double frame_mvr_abs;
   1.110 +  double frame_mvc;
   1.111 +  double frame_mvc_abs;
   1.112 +} ONEPASS_FRAMESTATS;
   1.113 +
   1.114 +typedef struct {
   1.115 +  struct {
   1.116 +    int err;
   1.117 +    union {
   1.118 +      int_mv mv;
   1.119 +      MB_PREDICTION_MODE mode;
   1.120 +    } m;
   1.121 +  } ref[MAX_REF_FRAMES];
   1.122 +} MBGRAPH_MB_STATS;
   1.123 +
   1.124 +typedef struct {
   1.125 +  MBGRAPH_MB_STATS *mb_stats;
   1.126 +} MBGRAPH_FRAME_STATS;
   1.127 +
   1.128 +// This enumerator type needs to be kept aligned with the mode order in
   1.129 +// const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code.
   1.130 +typedef enum {
   1.131 +  THR_NEARESTMV,
   1.132 +  THR_NEARESTA,
   1.133 +  THR_NEARESTG,
   1.134 +
   1.135 +  THR_DC,
   1.136 +
   1.137 +  THR_NEWMV,
   1.138 +  THR_NEWA,
   1.139 +  THR_NEWG,
   1.140 +
   1.141 +  THR_NEARMV,
   1.142 +  THR_NEARA,
   1.143 +  THR_COMP_NEARESTLA,
   1.144 +  THR_COMP_NEARESTGA,
   1.145 +
   1.146 +  THR_TM,
   1.147 +
   1.148 +  THR_COMP_NEARLA,
   1.149 +  THR_COMP_NEWLA,
   1.150 +  THR_NEARG,
   1.151 +  THR_COMP_NEARGA,
   1.152 +  THR_COMP_NEWGA,
   1.153 +
   1.154 +  THR_ZEROMV,
   1.155 +  THR_ZEROG,
   1.156 +  THR_ZEROA,
   1.157 +  THR_COMP_ZEROLA,
   1.158 +  THR_COMP_ZEROGA,
   1.159 +
   1.160 +  THR_H_PRED,
   1.161 +  THR_V_PRED,
   1.162 +  THR_D135_PRED,
   1.163 +  THR_D207_PRED,
   1.164 +  THR_D153_PRED,
   1.165 +  THR_D63_PRED,
   1.166 +  THR_D117_PRED,
   1.167 +  THR_D45_PRED,
   1.168 +} THR_MODES;
   1.169 +
   1.170 +typedef enum {
   1.171 +  THR_LAST,
   1.172 +  THR_GOLD,
   1.173 +  THR_ALTR,
   1.174 +  THR_COMP_LA,
   1.175 +  THR_COMP_GA,
   1.176 +  THR_INTRA,
   1.177 +} THR_MODES_SUB8X8;
   1.178 +
   1.179 +typedef enum {
   1.180 +  DIAMOND = 0,
   1.181 +  NSTEP = 1,
   1.182 +  HEX = 2,
   1.183 +  BIGDIA = 3,
   1.184 +  SQUARE = 4
   1.185 +} SEARCH_METHODS;
   1.186 +
   1.187 +typedef enum {
   1.188 +  USE_FULL_RD = 0,
   1.189 +  USE_LARGESTINTRA,
   1.190 +  USE_LARGESTINTRA_MODELINTER,
   1.191 +  USE_LARGESTALL
   1.192 +} TX_SIZE_SEARCH_METHOD;
   1.193 +
   1.194 +typedef enum {
   1.195 +  // Values should be powers of 2 so that they can be selected as bits of
   1.196 +  // an integer flags field
   1.197 +
   1.198 +  // terminate search early based on distortion so far compared to
   1.199 +  // qp step, distortion in the neighborhood of the frame, etc.
   1.200 +  FLAG_EARLY_TERMINATE = 1,
   1.201 +
   1.202 +  // skips comp inter modes if the best so far is an intra mode
   1.203 +  FLAG_SKIP_COMP_BESTINTRA = 2,
   1.204 +
   1.205 +  // skips comp inter modes if the best single intermode so far does
   1.206 +  // not have the same reference as one of the two references being
   1.207 +  // tested
   1.208 +  FLAG_SKIP_COMP_REFMISMATCH = 4,
   1.209 +
   1.210 +  // skips oblique intra modes if the best so far is an inter mode
   1.211 +  FLAG_SKIP_INTRA_BESTINTER = 8,
   1.212 +
   1.213 +  // skips oblique intra modes  at angles 27, 63, 117, 153 if the best
   1.214 +  // intra so far is not one of the neighboring directions
   1.215 +  FLAG_SKIP_INTRA_DIRMISMATCH = 16,
   1.216 +
   1.217 +  // skips intra modes other than DC_PRED if the source variance
   1.218 +  // is small
   1.219 +  FLAG_SKIP_INTRA_LOWVAR = 32,
   1.220 +} MODE_SEARCH_SKIP_LOGIC;
   1.221 +
   1.222 +typedef enum {
   1.223 +  SUBPEL_ITERATIVE = 0,
   1.224 +  SUBPEL_TREE = 1,
   1.225 +  // Other methods to come
   1.226 +} SUBPEL_SEARCH_METHODS;
   1.227 +
   1.228 +#define ALL_INTRA_MODES 0x3FF
   1.229 +#define INTRA_DC_ONLY 0x01
   1.230 +#define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED))
   1.231 +#define INTRA_DC_H_V ((1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED))
   1.232 +#define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED))
   1.233 +
   1.234 +typedef enum {
   1.235 +  LAST_FRAME_PARTITION_OFF = 0,
   1.236 +  LAST_FRAME_PARTITION_LOW_MOTION = 1,
   1.237 +  LAST_FRAME_PARTITION_ALL = 2
   1.238 +} LAST_FRAME_PARTITION_METHOD;
   1.239 +
   1.240 +typedef struct {
   1.241 +  int RD;
   1.242 +  SEARCH_METHODS search_method;
   1.243 +  int auto_filter;
   1.244 +  int recode_loop;
   1.245 +  SUBPEL_SEARCH_METHODS subpel_search_method;
   1.246 +  int subpel_iters_per_step;
   1.247 +  int thresh_mult[MAX_MODES];
   1.248 +  int thresh_mult_sub8x8[MAX_REFS];
   1.249 +  int max_step_search_steps;
   1.250 +  int reduce_first_step_size;
   1.251 +  int auto_mv_step_size;
   1.252 +  int optimize_coefficients;
   1.253 +  int static_segmentation;
   1.254 +  int comp_inter_joint_search_thresh;
   1.255 +  int adaptive_rd_thresh;
   1.256 +  int skip_encode_sb;
   1.257 +  int skip_encode_frame;
   1.258 +  LAST_FRAME_PARTITION_METHOD use_lastframe_partitioning;
   1.259 +  TX_SIZE_SEARCH_METHOD tx_size_search_method;
   1.260 +  int use_lp32x32fdct;
   1.261 +  int use_avoid_tested_higherror;
   1.262 +  int use_one_partition_size_always;
   1.263 +  int less_rectangular_check;
   1.264 +  int use_square_partition_only;
   1.265 +  int mode_skip_start;
   1.266 +  int reference_masking;
   1.267 +  BLOCK_SIZE always_this_block_size;
   1.268 +  int auto_min_max_partition_size;
   1.269 +  BLOCK_SIZE min_partition_size;
   1.270 +  BLOCK_SIZE max_partition_size;
   1.271 +  int adjust_partitioning_from_last_frame;
   1.272 +  int last_partitioning_redo_frequency;
   1.273 +  int disable_split_mask;
   1.274 +  int using_small_partition_info;
   1.275 +  // TODO(jingning): combine the related motion search speed features
   1.276 +  int adaptive_motion_search;
   1.277 +
   1.278 +  // Implements various heuristics to skip searching modes
   1.279 +  // The heuristics selected are based on  flags
   1.280 +  // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
   1.281 +  unsigned int mode_search_skip_flags;
   1.282 +  // A source variance threshold below which the split mode is disabled
   1.283 +  unsigned int disable_split_var_thresh;
   1.284 +  // A source variance threshold below which filter search is disabled
   1.285 +  // Choose a very large value (UINT_MAX) to use 8-tap always
   1.286 +  unsigned int disable_filter_search_var_thresh;
   1.287 +  int intra_y_mode_mask[TX_SIZES];
   1.288 +  int intra_uv_mode_mask[TX_SIZES];
   1.289 +  int use_rd_breakout;
   1.290 +  int use_uv_intra_rd_estimate;
   1.291 +  int use_fast_lpf_pick;
   1.292 +  int use_fast_coef_updates;  // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced
   1.293 +} SPEED_FEATURES;
   1.294 +
   1.295 +typedef struct VP9_COMP {
   1.296 +  DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]);
   1.297 +  DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]);
   1.298 +  DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]);
   1.299 +  DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]);
   1.300 +
   1.301 +  DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]);
   1.302 +  DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]);
   1.303 +  DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]);
   1.304 +  DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
   1.305 +
   1.306 +#if CONFIG_ALPHA
   1.307 +  DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]);
   1.308 +  DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]);
   1.309 +  DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]);
   1.310 +  DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]);
   1.311 +#endif
   1.312 +
   1.313 +  MACROBLOCK mb;
   1.314 +  VP9_COMMON common;
   1.315 +  VP9_CONFIG oxcf;
   1.316 +  struct rdcost_block_args rdcost_stack;
   1.317 +  struct lookahead_ctx    *lookahead;
   1.318 +  struct lookahead_entry  *source;
   1.319 +#if CONFIG_MULTIPLE_ARF
   1.320 +  struct lookahead_entry  *alt_ref_source[NUM_REF_FRAMES];
   1.321 +#else
   1.322 +  struct lookahead_entry  *alt_ref_source;
   1.323 +#endif
   1.324 +
   1.325 +  YV12_BUFFER_CONFIG *Source;
   1.326 +  YV12_BUFFER_CONFIG *un_scaled_source;
   1.327 +  YV12_BUFFER_CONFIG scaled_source;
   1.328 +
   1.329 +  unsigned int frames_till_alt_ref_frame;
   1.330 +  int source_alt_ref_pending;
   1.331 +  int source_alt_ref_active;
   1.332 +
   1.333 +  int is_src_frame_alt_ref;
   1.334 +
   1.335 +  int gold_is_last;  // gold same as last frame ( short circuit gold searches)
   1.336 +  int alt_is_last;  // Alt same as last ( short circuit altref search)
   1.337 +  int gold_is_alt;  // don't do both alt and gold search ( just do gold).
   1.338 +
   1.339 +  int scaled_ref_idx[3];
   1.340 +  int lst_fb_idx;
   1.341 +  int gld_fb_idx;
   1.342 +  int alt_fb_idx;
   1.343 +
   1.344 +  int current_layer;
   1.345 +  int use_svc;
   1.346 +
   1.347 +#if CONFIG_MULTIPLE_ARF
   1.348 +  int alt_ref_fb_idx[NUM_REF_FRAMES - 3];
   1.349 +#endif
   1.350 +  int refresh_last_frame;
   1.351 +  int refresh_golden_frame;
   1.352 +  int refresh_alt_ref_frame;
   1.353 +  YV12_BUFFER_CONFIG last_frame_uf;
   1.354 +
   1.355 +  TOKENEXTRA *tok;
   1.356 +  unsigned int tok_count[4][1 << 6];
   1.357 +
   1.358 +
   1.359 +  unsigned int frames_since_key;
   1.360 +  unsigned int key_frame_frequency;
   1.361 +  unsigned int this_key_frame_forced;
   1.362 +  unsigned int next_key_frame_forced;
   1.363 +#if CONFIG_MULTIPLE_ARF
   1.364 +  // Position within a frame coding order (including any additional ARF frames).
   1.365 +  unsigned int sequence_number;
   1.366 +  // Next frame in naturally occurring order that has not yet been coded.
   1.367 +  int next_frame_in_order;
   1.368 +#endif
   1.369 +
   1.370 +  // Ambient reconstruction err target for force key frames
   1.371 +  int ambient_err;
   1.372 +
   1.373 +  unsigned int mode_chosen_counts[MAX_MODES];
   1.374 +  unsigned int sub8x8_mode_chosen_counts[MAX_REFS];
   1.375 +  int64_t mode_skip_mask;
   1.376 +  int ref_frame_mask;
   1.377 +  int set_ref_frame_mask;
   1.378 +
   1.379 +  int rd_threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES];
   1.380 +  int rd_thresh_freq_fact[BLOCK_SIZES][MAX_MODES];
   1.381 +  int rd_thresh_sub8x8[MAX_SEGMENTS][BLOCK_SIZES][MAX_REFS];
   1.382 +  int rd_thresh_freq_sub8x8[BLOCK_SIZES][MAX_REFS];
   1.383 +
   1.384 +  int64_t rd_comp_pred_diff[NB_PREDICTION_TYPES];
   1.385 +  int64_t rd_prediction_type_threshes[4][NB_PREDICTION_TYPES];
   1.386 +  unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2];
   1.387 +  unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
   1.388 +  unsigned int single_ref_count[REF_CONTEXTS][2][2];
   1.389 +  unsigned int comp_ref_count[REF_CONTEXTS][2];
   1.390 +
   1.391 +  int64_t rd_tx_select_diff[TX_MODES];
   1.392 +  // FIXME(rbultje) can this overflow?
   1.393 +  int rd_tx_select_threshes[4][TX_MODES];
   1.394 +
   1.395 +  int64_t rd_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
   1.396 +  int64_t rd_filter_threshes[4][SWITCHABLE_FILTER_CONTEXTS];
   1.397 +  int64_t rd_filter_cache[SWITCHABLE_FILTER_CONTEXTS];
   1.398 +
   1.399 +  int RDMULT;
   1.400 +  int RDDIV;
   1.401 +
   1.402 +  CODING_CONTEXT coding_context;
   1.403 +
   1.404 +  // Rate targetting variables
   1.405 +  int this_frame_target;
   1.406 +  int projected_frame_size;
   1.407 +  int last_q[2];                   // Separate values for Intra/Inter
   1.408 +  int last_boosted_qindex;         // Last boosted GF/KF/ARF q
   1.409 +
   1.410 +  double rate_correction_factor;
   1.411 +  double key_frame_rate_correction_factor;
   1.412 +  double gf_rate_correction_factor;
   1.413 +
   1.414 +  unsigned int frames_since_golden;
   1.415 +  int frames_till_gf_update_due;  // Count down till next GF
   1.416 +
   1.417 +  int gf_overspend_bits;  // cumulative bits overspent because of GF boost
   1.418 +
   1.419 +  int non_gf_bitrate_adjustment;  // Following GF to recover extra bits spent
   1.420 +
   1.421 +  int kf_overspend_bits;  // Bits spent on key frames to be recovered on inters
   1.422 +  int kf_bitrate_adjustment;  // number of bits to recover on each inter frame.
   1.423 +  int max_gf_interval;
   1.424 +  int baseline_gf_interval;
   1.425 +  int active_arnr_frames;           // <= cpi->oxcf.arnr_max_frames
   1.426 +  int active_arnr_strength;         // <= cpi->oxcf.arnr_max_strength
   1.427 +
   1.428 +  int64_t key_frame_count;
   1.429 +  int prior_key_frame_distance[KEY_FRAME_CONTEXT];
   1.430 +  int per_frame_bandwidth;  // Current section per frame bandwidth target
   1.431 +  int av_per_frame_bandwidth;  // Average frame size target for clip
   1.432 +  int min_frame_bandwidth;  // Minimum allocation used for any frame
   1.433 +  int inter_frame_target;
   1.434 +  double output_framerate;
   1.435 +  int64_t last_time_stamp_seen;
   1.436 +  int64_t last_end_time_stamp_seen;
   1.437 +  int64_t first_time_stamp_ever;
   1.438 +
   1.439 +  int ni_av_qi;
   1.440 +  int ni_tot_qi;
   1.441 +  int ni_frames;
   1.442 +  int avg_frame_qindex;
   1.443 +  double tot_q;
   1.444 +  double avg_q;
   1.445 +
   1.446 +  int zbin_mode_boost;
   1.447 +  int zbin_mode_boost_enabled;
   1.448 +
   1.449 +  int64_t total_byte_count;
   1.450 +
   1.451 +  int buffered_mode;
   1.452 +
   1.453 +  int buffer_level;
   1.454 +  int bits_off_target;
   1.455 +
   1.456 +  int rolling_target_bits;
   1.457 +  int rolling_actual_bits;
   1.458 +
   1.459 +  int long_rolling_target_bits;
   1.460 +  int long_rolling_actual_bits;
   1.461 +
   1.462 +  int64_t total_actual_bits;
   1.463 +  int total_target_vs_actual;        // debug stats
   1.464 +
   1.465 +  int worst_quality;
   1.466 +  int active_worst_quality;
   1.467 +  int best_quality;
   1.468 +  int active_best_quality;
   1.469 +
   1.470 +  int cq_target_quality;
   1.471 +
   1.472 +  int y_mode_count[4][INTRA_MODES];
   1.473 +  int y_uv_mode_count[INTRA_MODES][INTRA_MODES];
   1.474 +  unsigned int partition_count[PARTITION_CONTEXTS][PARTITION_TYPES];
   1.475 +
   1.476 +  nmv_context_counts NMVcount;
   1.477 +
   1.478 +  vp9_coeff_count coef_counts[TX_SIZES][BLOCK_TYPES];
   1.479 +  vp9_coeff_probs_model frame_coef_probs[TX_SIZES][BLOCK_TYPES];
   1.480 +  vp9_coeff_stats frame_branch_ct[TX_SIZES][BLOCK_TYPES];
   1.481 +
   1.482 +  int gfu_boost;
   1.483 +  int last_boost;
   1.484 +  int kf_boost;
   1.485 +  int kf_zeromotion_pct;
   1.486 +  int gf_zeromotion_pct;
   1.487 +
   1.488 +  int64_t target_bandwidth;
   1.489 +  struct vpx_codec_pkt_list  *output_pkt_list;
   1.490 +
   1.491 +#if 0
   1.492 +  // Experimental code for lagged and one pass
   1.493 +  ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
   1.494 +  int one_pass_frame_index;
   1.495 +#endif
   1.496 +  MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
   1.497 +  int mbgraph_n_frames;             // number of frames filled in the above
   1.498 +  int static_mb_pct;                // % forced skip mbs by segmentation
   1.499 +  int seg0_progress, seg0_idx, seg0_cnt;
   1.500 +
   1.501 +  int decimation_factor;
   1.502 +  int decimation_count;
   1.503 +
   1.504 +  // for real time encoding
   1.505 +  int speed;
   1.506 +  int compressor_speed;
   1.507 +
   1.508 +  int auto_worst_q;
   1.509 +  int cpu_used;
   1.510 +  int pass;
   1.511 +
   1.512 +  vp9_prob last_skip_false_probs[3][MBSKIP_CONTEXTS];
   1.513 +  int last_skip_probs_q[3];
   1.514 +
   1.515 +  int ref_frame_flags;
   1.516 +
   1.517 +  SPEED_FEATURES sf;
   1.518 +  int error_bins[1024];
   1.519 +
   1.520 +  unsigned int max_mv_magnitude;
   1.521 +  int mv_step_param;
   1.522 +
   1.523 +  unsigned char *segmentation_map;
   1.524 +
   1.525 +  // segment threashold for encode breakout
   1.526 +  int  segment_encode_breakout[MAX_SEGMENTS];
   1.527 +
   1.528 +  unsigned char *active_map;
   1.529 +  unsigned int active_map_enabled;
   1.530 +
   1.531 +  fractional_mv_step_fp *find_fractional_mv_step;
   1.532 +  fractional_mv_step_comp_fp *find_fractional_mv_step_comp;
   1.533 +  vp9_full_search_fn_t full_search_sad;
   1.534 +  vp9_refining_search_fn_t refining_search_sad;
   1.535 +  vp9_diamond_search_fn_t diamond_search_sad;
   1.536 +  vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES];
   1.537 +  uint64_t time_receive_data;
   1.538 +  uint64_t time_compress_data;
   1.539 +  uint64_t time_pick_lpf;
   1.540 +  uint64_t time_encode_sb_row;
   1.541 +
   1.542 +  struct twopass_rc {
   1.543 +    unsigned int section_intra_rating;
   1.544 +    unsigned int next_iiratio;
   1.545 +    unsigned int this_iiratio;
   1.546 +    FIRSTPASS_STATS total_stats;
   1.547 +    FIRSTPASS_STATS this_frame_stats;
   1.548 +    FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
   1.549 +    FIRSTPASS_STATS total_left_stats;
   1.550 +    int first_pass_done;
   1.551 +    int64_t bits_left;
   1.552 +    int64_t clip_bits_total;
   1.553 +    double avg_iiratio;
   1.554 +    double modified_error_total;
   1.555 +    double modified_error_used;
   1.556 +    double modified_error_left;
   1.557 +    double kf_intra_err_min;
   1.558 +    double gf_intra_err_min;
   1.559 +    int frames_to_key;
   1.560 +    int maxq_max_limit;
   1.561 +    int maxq_min_limit;
   1.562 +    int static_scene_max_gf_interval;
   1.563 +    int kf_bits;
   1.564 +    // Remaining error from uncoded frames in a gf group. Two pass use only
   1.565 +    int64_t gf_group_error_left;
   1.566 +
   1.567 +    // Projected total bits available for a key frame group of frames
   1.568 +    int64_t kf_group_bits;
   1.569 +
   1.570 +    // Error score of frames still to be coded in kf group
   1.571 +    int64_t kf_group_error_left;
   1.572 +
   1.573 +    // Projected Bits available for a group of frames including 1 GF or ARF
   1.574 +    int64_t gf_group_bits;
   1.575 +    // Bits for the golden frame or ARF - 2 pass only
   1.576 +    int gf_bits;
   1.577 +    int alt_extra_bits;
   1.578 +
   1.579 +    int sr_update_lag;
   1.580 +    double est_max_qcorrection_factor;
   1.581 +  } twopass;
   1.582 +
   1.583 +  YV12_BUFFER_CONFIG alt_ref_buffer;
   1.584 +  YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
   1.585 +  int fixed_divide[512];
   1.586 +
   1.587 +#if CONFIG_INTERNAL_STATS
   1.588 +  int    count;
   1.589 +  double total_y;
   1.590 +  double total_u;
   1.591 +  double total_v;
   1.592 +  double total;
   1.593 +  double total_sq_error;
   1.594 +  double totalp_y;
   1.595 +  double totalp_u;
   1.596 +  double totalp_v;
   1.597 +  double totalp;
   1.598 +  double total_sq_error2;
   1.599 +  int    bytes;
   1.600 +  double summed_quality;
   1.601 +  double summed_weights;
   1.602 +  double summedp_quality;
   1.603 +  double summedp_weights;
   1.604 +  unsigned int tot_recode_hits;
   1.605 +
   1.606 +
   1.607 +  double total_ssimg_y;
   1.608 +  double total_ssimg_u;
   1.609 +  double total_ssimg_v;
   1.610 +  double total_ssimg_all;
   1.611 +
   1.612 +  int b_calculate_ssimg;
   1.613 +#endif
   1.614 +  int b_calculate_psnr;
   1.615 +
   1.616 +  // Per MB activity measurement
   1.617 +  unsigned int activity_avg;
   1.618 +  unsigned int *mb_activity_map;
   1.619 +  int *mb_norm_activity_map;
   1.620 +  int output_partition;
   1.621 +
   1.622 +  /* force next frame to intra when kf_auto says so */
   1.623 +  int force_next_frame_intra;
   1.624 +
   1.625 +  int droppable;
   1.626 +
   1.627 +  int dummy_packing;    /* flag to indicate if packing is dummy */
   1.628 +
   1.629 +  unsigned int switchable_interp_count[SWITCHABLE_FILTER_CONTEXTS]
   1.630 +                                      [SWITCHABLE_FILTERS];
   1.631 +
   1.632 +  unsigned int tx_stepdown_count[TX_SIZES];
   1.633 +
   1.634 +  int initial_width;
   1.635 +  int initial_height;
   1.636 +
   1.637 +  int number_spatial_layers;
   1.638 +  int enable_encode_breakout;   // Default value is 1. From first pass stats,
   1.639 +                                // encode_breakout may be disabled.
   1.640 +
   1.641 +#if CONFIG_MULTIPLE_ARF
   1.642 +  // ARF tracking variables.
   1.643 +  int multi_arf_enabled;
   1.644 +  unsigned int frame_coding_order_period;
   1.645 +  unsigned int new_frame_coding_order_period;
   1.646 +  int frame_coding_order[MAX_LAG_BUFFERS * 2];
   1.647 +  int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2];
   1.648 +  int arf_weight[MAX_LAG_BUFFERS];
   1.649 +  int arf_buffered;
   1.650 +  int this_frame_weight;
   1.651 +  int max_arf_level;
   1.652 +#endif
   1.653 +
   1.654 +#ifdef ENTROPY_STATS
   1.655 +  int64_t mv_ref_stats[INTER_MODE_CONTEXTS][INTER_MODES - 1][2];
   1.656 +#endif
   1.657 +
   1.658 +
   1.659 +#ifdef MODE_TEST_HIT_STATS
   1.660 +  // Debug / test stats
   1.661 +  int64_t mode_test_hits[BLOCK_SIZES];
   1.662 +#endif
   1.663 +
   1.664 +  /* Y,U,V,(A) */
   1.665 +  ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
   1.666 +  ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16];
   1.667 +
   1.668 +  PARTITION_CONTEXT *above_seg_context;
   1.669 +  PARTITION_CONTEXT left_seg_context[8];
   1.670 +} VP9_COMP;
   1.671 +
   1.672 +static int get_ref_frame_idx(VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
   1.673 +  if (ref_frame == LAST_FRAME) {
   1.674 +    return cpi->lst_fb_idx;
   1.675 +  } else if (ref_frame == GOLDEN_FRAME) {
   1.676 +    return cpi->gld_fb_idx;
   1.677 +  } else {
   1.678 +    return cpi->alt_fb_idx;
   1.679 +  }
   1.680 +}
   1.681 +
   1.682 +static int get_scale_ref_frame_idx(VP9_COMP *cpi,
   1.683 +                                   MV_REFERENCE_FRAME ref_frame) {
   1.684 +  if (ref_frame == LAST_FRAME) {
   1.685 +    return 0;
   1.686 +  } else if (ref_frame == GOLDEN_FRAME) {
   1.687 +    return 1;
   1.688 +  } else {
   1.689 +    return 2;
   1.690 +  }
   1.691 +}
   1.692 +
   1.693 +void vp9_encode_frame(VP9_COMP *cpi);
   1.694 +
   1.695 +void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
   1.696 +                        unsigned long *size);
   1.697 +
   1.698 +void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x);
   1.699 +
   1.700 +void vp9_set_speed_features(VP9_COMP *cpi);
   1.701 +
   1.702 +int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest);
   1.703 +
   1.704 +void vp9_alloc_compressor_data(VP9_COMP *cpi);
   1.705 +
   1.706 +int vp9_compute_qdelta(VP9_COMP *cpi, double qstart, double qtarget);
   1.707 +
   1.708 +static int get_token_alloc(int mb_rows, int mb_cols) {
   1.709 +  return mb_rows * mb_cols * (48 * 16 + 4);
   1.710 +}
   1.711 +
   1.712 +#endif  // VP9_ENCODER_VP9_ONYX_INT_H_

mercurial