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.

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

mercurial