michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #ifndef VP9_ENCODER_VP9_ONYX_INT_H_ michael@0: #define VP9_ENCODER_VP9_ONYX_INT_H_ michael@0: michael@0: #include michael@0: #include "./vpx_config.h" michael@0: #include "vp9/common/vp9_onyx.h" michael@0: #include "vp9/encoder/vp9_treewriter.h" michael@0: #include "vp9/encoder/vp9_tokenize.h" michael@0: #include "vp9/common/vp9_onyxc_int.h" michael@0: #include "vp9/encoder/vp9_variance.h" michael@0: #include "vp9/encoder/vp9_encodemb.h" michael@0: #include "vp9/encoder/vp9_quantize.h" michael@0: #include "vp9/common/vp9_entropy.h" michael@0: #include "vp9/common/vp9_entropymode.h" michael@0: #include "vpx_ports/mem.h" michael@0: #include "vpx/internal/vpx_codec_internal.h" michael@0: #include "vp9/encoder/vp9_mcomp.h" michael@0: #include "vp9/common/vp9_findnearmv.h" michael@0: #include "vp9/encoder/vp9_lookahead.h" michael@0: michael@0: #define DISABLE_RC_LONG_TERM_MEM 0 michael@0: michael@0: // #define MODE_TEST_HIT_STATS michael@0: michael@0: // #define SPEEDSTATS 1 michael@0: #if CONFIG_MULTIPLE_ARF michael@0: // Set MIN_GF_INTERVAL to 1 for the full decomposition. michael@0: #define MIN_GF_INTERVAL 2 michael@0: #else michael@0: #define MIN_GF_INTERVAL 4 michael@0: #endif michael@0: #define DEFAULT_GF_INTERVAL 7 michael@0: michael@0: #define KEY_FRAME_CONTEXT 5 michael@0: michael@0: #define MAX_MODES 30 michael@0: #define MAX_REFS 6 michael@0: michael@0: #define MIN_THRESHMULT 32 michael@0: #define MAX_THRESHMULT 512 michael@0: michael@0: #define GF_ZEROMV_ZBIN_BOOST 0 michael@0: #define LF_ZEROMV_ZBIN_BOOST 0 michael@0: #define MV_ZBIN_BOOST 0 michael@0: #define SPLIT_MV_ZBIN_BOOST 0 michael@0: #define INTRA_ZBIN_BOOST 0 michael@0: michael@0: typedef struct { michael@0: int nmvjointcost[MV_JOINTS]; michael@0: int nmvcosts[2][MV_VALS]; michael@0: int nmvcosts_hp[2][MV_VALS]; michael@0: michael@0: vp9_prob segment_pred_probs[PREDICTION_PROBS]; michael@0: michael@0: unsigned char *last_frame_seg_map_copy; michael@0: michael@0: // 0 = Intra, Last, GF, ARF michael@0: signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS]; michael@0: // 0 = ZERO_MV, MV michael@0: signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS]; michael@0: michael@0: int inter_mode_counts[INTER_MODE_CONTEXTS][INTER_MODES - 1][2]; michael@0: FRAME_CONTEXT fc; michael@0: } CODING_CONTEXT; michael@0: michael@0: typedef struct { michael@0: double frame; michael@0: double intra_error; michael@0: double coded_error; michael@0: double sr_coded_error; michael@0: double ssim_weighted_pred_err; michael@0: double pcnt_inter; michael@0: double pcnt_motion; michael@0: double pcnt_second_ref; michael@0: double pcnt_neutral; michael@0: double MVr; michael@0: double mvr_abs; michael@0: double MVc; michael@0: double mvc_abs; michael@0: double MVrv; michael@0: double MVcv; michael@0: double mv_in_out_count; michael@0: double new_mv_count; michael@0: double duration; michael@0: double count; michael@0: } FIRSTPASS_STATS; michael@0: michael@0: typedef struct { michael@0: int frames_so_far; michael@0: double frame_intra_error; michael@0: double frame_coded_error; michael@0: double frame_pcnt_inter; michael@0: double frame_pcnt_motion; michael@0: double frame_mvr; michael@0: double frame_mvr_abs; michael@0: double frame_mvc; michael@0: double frame_mvc_abs; michael@0: } ONEPASS_FRAMESTATS; michael@0: michael@0: typedef struct { michael@0: struct { michael@0: int err; michael@0: union { michael@0: int_mv mv; michael@0: MB_PREDICTION_MODE mode; michael@0: } m; michael@0: } ref[MAX_REF_FRAMES]; michael@0: } MBGRAPH_MB_STATS; michael@0: michael@0: typedef struct { michael@0: MBGRAPH_MB_STATS *mb_stats; michael@0: } MBGRAPH_FRAME_STATS; michael@0: michael@0: // This enumerator type needs to be kept aligned with the mode order in michael@0: // const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code. michael@0: typedef enum { michael@0: THR_NEARESTMV, michael@0: THR_NEARESTA, michael@0: THR_NEARESTG, michael@0: michael@0: THR_DC, michael@0: michael@0: THR_NEWMV, michael@0: THR_NEWA, michael@0: THR_NEWG, michael@0: michael@0: THR_NEARMV, michael@0: THR_NEARA, michael@0: THR_COMP_NEARESTLA, michael@0: THR_COMP_NEARESTGA, michael@0: michael@0: THR_TM, michael@0: michael@0: THR_COMP_NEARLA, michael@0: THR_COMP_NEWLA, michael@0: THR_NEARG, michael@0: THR_COMP_NEARGA, michael@0: THR_COMP_NEWGA, michael@0: michael@0: THR_ZEROMV, michael@0: THR_ZEROG, michael@0: THR_ZEROA, michael@0: THR_COMP_ZEROLA, michael@0: THR_COMP_ZEROGA, michael@0: michael@0: THR_H_PRED, michael@0: THR_V_PRED, michael@0: THR_D135_PRED, michael@0: THR_D207_PRED, michael@0: THR_D153_PRED, michael@0: THR_D63_PRED, michael@0: THR_D117_PRED, michael@0: THR_D45_PRED, michael@0: } THR_MODES; michael@0: michael@0: typedef enum { michael@0: THR_LAST, michael@0: THR_GOLD, michael@0: THR_ALTR, michael@0: THR_COMP_LA, michael@0: THR_COMP_GA, michael@0: THR_INTRA, michael@0: } THR_MODES_SUB8X8; michael@0: michael@0: typedef enum { michael@0: DIAMOND = 0, michael@0: NSTEP = 1, michael@0: HEX = 2, michael@0: BIGDIA = 3, michael@0: SQUARE = 4 michael@0: } SEARCH_METHODS; michael@0: michael@0: typedef enum { michael@0: USE_FULL_RD = 0, michael@0: USE_LARGESTINTRA, michael@0: USE_LARGESTINTRA_MODELINTER, michael@0: USE_LARGESTALL michael@0: } TX_SIZE_SEARCH_METHOD; michael@0: michael@0: typedef enum { michael@0: // Values should be powers of 2 so that they can be selected as bits of michael@0: // an integer flags field michael@0: michael@0: // terminate search early based on distortion so far compared to michael@0: // qp step, distortion in the neighborhood of the frame, etc. michael@0: FLAG_EARLY_TERMINATE = 1, michael@0: michael@0: // skips comp inter modes if the best so far is an intra mode michael@0: FLAG_SKIP_COMP_BESTINTRA = 2, michael@0: michael@0: // skips comp inter modes if the best single intermode so far does michael@0: // not have the same reference as one of the two references being michael@0: // tested michael@0: FLAG_SKIP_COMP_REFMISMATCH = 4, michael@0: michael@0: // skips oblique intra modes if the best so far is an inter mode michael@0: FLAG_SKIP_INTRA_BESTINTER = 8, michael@0: michael@0: // skips oblique intra modes at angles 27, 63, 117, 153 if the best michael@0: // intra so far is not one of the neighboring directions michael@0: FLAG_SKIP_INTRA_DIRMISMATCH = 16, michael@0: michael@0: // skips intra modes other than DC_PRED if the source variance michael@0: // is small michael@0: FLAG_SKIP_INTRA_LOWVAR = 32, michael@0: } MODE_SEARCH_SKIP_LOGIC; michael@0: michael@0: typedef enum { michael@0: SUBPEL_ITERATIVE = 0, michael@0: SUBPEL_TREE = 1, michael@0: // Other methods to come michael@0: } SUBPEL_SEARCH_METHODS; michael@0: michael@0: #define ALL_INTRA_MODES 0x3FF michael@0: #define INTRA_DC_ONLY 0x01 michael@0: #define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED)) michael@0: #define INTRA_DC_H_V ((1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED)) michael@0: #define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED)) michael@0: michael@0: typedef enum { michael@0: LAST_FRAME_PARTITION_OFF = 0, michael@0: LAST_FRAME_PARTITION_LOW_MOTION = 1, michael@0: LAST_FRAME_PARTITION_ALL = 2 michael@0: } LAST_FRAME_PARTITION_METHOD; michael@0: michael@0: typedef struct { michael@0: int RD; michael@0: SEARCH_METHODS search_method; michael@0: int auto_filter; michael@0: int recode_loop; michael@0: SUBPEL_SEARCH_METHODS subpel_search_method; michael@0: int subpel_iters_per_step; michael@0: int thresh_mult[MAX_MODES]; michael@0: int thresh_mult_sub8x8[MAX_REFS]; michael@0: int max_step_search_steps; michael@0: int reduce_first_step_size; michael@0: int auto_mv_step_size; michael@0: int optimize_coefficients; michael@0: int static_segmentation; michael@0: int comp_inter_joint_search_thresh; michael@0: int adaptive_rd_thresh; michael@0: int skip_encode_sb; michael@0: int skip_encode_frame; michael@0: LAST_FRAME_PARTITION_METHOD use_lastframe_partitioning; michael@0: TX_SIZE_SEARCH_METHOD tx_size_search_method; michael@0: int use_lp32x32fdct; michael@0: int use_avoid_tested_higherror; michael@0: int use_one_partition_size_always; michael@0: int less_rectangular_check; michael@0: int use_square_partition_only; michael@0: int mode_skip_start; michael@0: int reference_masking; michael@0: BLOCK_SIZE always_this_block_size; michael@0: int auto_min_max_partition_size; michael@0: BLOCK_SIZE min_partition_size; michael@0: BLOCK_SIZE max_partition_size; michael@0: int adjust_partitioning_from_last_frame; michael@0: int last_partitioning_redo_frequency; michael@0: int disable_split_mask; michael@0: int using_small_partition_info; michael@0: // TODO(jingning): combine the related motion search speed features michael@0: int adaptive_motion_search; michael@0: michael@0: // Implements various heuristics to skip searching modes michael@0: // The heuristics selected are based on flags michael@0: // defined in the MODE_SEARCH_SKIP_HEURISTICS enum michael@0: unsigned int mode_search_skip_flags; michael@0: // A source variance threshold below which the split mode is disabled michael@0: unsigned int disable_split_var_thresh; michael@0: // A source variance threshold below which filter search is disabled michael@0: // Choose a very large value (UINT_MAX) to use 8-tap always michael@0: unsigned int disable_filter_search_var_thresh; michael@0: int intra_y_mode_mask[TX_SIZES]; michael@0: int intra_uv_mode_mask[TX_SIZES]; michael@0: int use_rd_breakout; michael@0: int use_uv_intra_rd_estimate; michael@0: int use_fast_lpf_pick; michael@0: int use_fast_coef_updates; // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced michael@0: } SPEED_FEATURES; michael@0: michael@0: typedef struct VP9_COMP { michael@0: DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]); michael@0: michael@0: DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]); michael@0: michael@0: #if CONFIG_ALPHA michael@0: DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]); michael@0: DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]); michael@0: #endif michael@0: michael@0: MACROBLOCK mb; michael@0: VP9_COMMON common; michael@0: VP9_CONFIG oxcf; michael@0: struct rdcost_block_args rdcost_stack; michael@0: struct lookahead_ctx *lookahead; michael@0: struct lookahead_entry *source; michael@0: #if CONFIG_MULTIPLE_ARF michael@0: struct lookahead_entry *alt_ref_source[NUM_REF_FRAMES]; michael@0: #else michael@0: struct lookahead_entry *alt_ref_source; michael@0: #endif michael@0: michael@0: YV12_BUFFER_CONFIG *Source; michael@0: YV12_BUFFER_CONFIG *un_scaled_source; michael@0: YV12_BUFFER_CONFIG scaled_source; michael@0: michael@0: unsigned int frames_till_alt_ref_frame; michael@0: int source_alt_ref_pending; michael@0: int source_alt_ref_active; michael@0: michael@0: int is_src_frame_alt_ref; michael@0: michael@0: int gold_is_last; // gold same as last frame ( short circuit gold searches) michael@0: int alt_is_last; // Alt same as last ( short circuit altref search) michael@0: int gold_is_alt; // don't do both alt and gold search ( just do gold). michael@0: michael@0: int scaled_ref_idx[3]; michael@0: int lst_fb_idx; michael@0: int gld_fb_idx; michael@0: int alt_fb_idx; michael@0: michael@0: int current_layer; michael@0: int use_svc; michael@0: michael@0: #if CONFIG_MULTIPLE_ARF michael@0: int alt_ref_fb_idx[NUM_REF_FRAMES - 3]; michael@0: #endif michael@0: int refresh_last_frame; michael@0: int refresh_golden_frame; michael@0: int refresh_alt_ref_frame; michael@0: YV12_BUFFER_CONFIG last_frame_uf; michael@0: michael@0: TOKENEXTRA *tok; michael@0: unsigned int tok_count[4][1 << 6]; michael@0: michael@0: michael@0: unsigned int frames_since_key; michael@0: unsigned int key_frame_frequency; michael@0: unsigned int this_key_frame_forced; michael@0: unsigned int next_key_frame_forced; michael@0: #if CONFIG_MULTIPLE_ARF michael@0: // Position within a frame coding order (including any additional ARF frames). michael@0: unsigned int sequence_number; michael@0: // Next frame in naturally occurring order that has not yet been coded. michael@0: int next_frame_in_order; michael@0: #endif michael@0: michael@0: // Ambient reconstruction err target for force key frames michael@0: int ambient_err; michael@0: michael@0: unsigned int mode_chosen_counts[MAX_MODES]; michael@0: unsigned int sub8x8_mode_chosen_counts[MAX_REFS]; michael@0: int64_t mode_skip_mask; michael@0: int ref_frame_mask; michael@0: int set_ref_frame_mask; michael@0: michael@0: int rd_threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES]; michael@0: int rd_thresh_freq_fact[BLOCK_SIZES][MAX_MODES]; michael@0: int rd_thresh_sub8x8[MAX_SEGMENTS][BLOCK_SIZES][MAX_REFS]; michael@0: int rd_thresh_freq_sub8x8[BLOCK_SIZES][MAX_REFS]; michael@0: michael@0: int64_t rd_comp_pred_diff[NB_PREDICTION_TYPES]; michael@0: int64_t rd_prediction_type_threshes[4][NB_PREDICTION_TYPES]; michael@0: unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2]; michael@0: unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2]; michael@0: unsigned int single_ref_count[REF_CONTEXTS][2][2]; michael@0: unsigned int comp_ref_count[REF_CONTEXTS][2]; michael@0: michael@0: int64_t rd_tx_select_diff[TX_MODES]; michael@0: // FIXME(rbultje) can this overflow? michael@0: int rd_tx_select_threshes[4][TX_MODES]; michael@0: michael@0: int64_t rd_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; michael@0: int64_t rd_filter_threshes[4][SWITCHABLE_FILTER_CONTEXTS]; michael@0: int64_t rd_filter_cache[SWITCHABLE_FILTER_CONTEXTS]; michael@0: michael@0: int RDMULT; michael@0: int RDDIV; michael@0: michael@0: CODING_CONTEXT coding_context; michael@0: michael@0: // Rate targetting variables michael@0: int this_frame_target; michael@0: int projected_frame_size; michael@0: int last_q[2]; // Separate values for Intra/Inter michael@0: int last_boosted_qindex; // Last boosted GF/KF/ARF q michael@0: michael@0: double rate_correction_factor; michael@0: double key_frame_rate_correction_factor; michael@0: double gf_rate_correction_factor; michael@0: michael@0: unsigned int frames_since_golden; michael@0: int frames_till_gf_update_due; // Count down till next GF michael@0: michael@0: int gf_overspend_bits; // cumulative bits overspent because of GF boost michael@0: michael@0: int non_gf_bitrate_adjustment; // Following GF to recover extra bits spent michael@0: michael@0: int kf_overspend_bits; // Bits spent on key frames to be recovered on inters michael@0: int kf_bitrate_adjustment; // number of bits to recover on each inter frame. michael@0: int max_gf_interval; michael@0: int baseline_gf_interval; michael@0: int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames michael@0: int active_arnr_strength; // <= cpi->oxcf.arnr_max_strength michael@0: michael@0: int64_t key_frame_count; michael@0: int prior_key_frame_distance[KEY_FRAME_CONTEXT]; michael@0: int per_frame_bandwidth; // Current section per frame bandwidth target michael@0: int av_per_frame_bandwidth; // Average frame size target for clip michael@0: int min_frame_bandwidth; // Minimum allocation used for any frame michael@0: int inter_frame_target; michael@0: double output_framerate; michael@0: int64_t last_time_stamp_seen; michael@0: int64_t last_end_time_stamp_seen; michael@0: int64_t first_time_stamp_ever; michael@0: michael@0: int ni_av_qi; michael@0: int ni_tot_qi; michael@0: int ni_frames; michael@0: int avg_frame_qindex; michael@0: double tot_q; michael@0: double avg_q; michael@0: michael@0: int zbin_mode_boost; michael@0: int zbin_mode_boost_enabled; michael@0: michael@0: int64_t total_byte_count; michael@0: michael@0: int buffered_mode; michael@0: michael@0: int buffer_level; michael@0: int bits_off_target; michael@0: michael@0: int rolling_target_bits; michael@0: int rolling_actual_bits; michael@0: michael@0: int long_rolling_target_bits; michael@0: int long_rolling_actual_bits; michael@0: michael@0: int64_t total_actual_bits; michael@0: int total_target_vs_actual; // debug stats michael@0: michael@0: int worst_quality; michael@0: int active_worst_quality; michael@0: int best_quality; michael@0: int active_best_quality; michael@0: michael@0: int cq_target_quality; michael@0: michael@0: int y_mode_count[4][INTRA_MODES]; michael@0: int y_uv_mode_count[INTRA_MODES][INTRA_MODES]; michael@0: unsigned int partition_count[PARTITION_CONTEXTS][PARTITION_TYPES]; michael@0: michael@0: nmv_context_counts NMVcount; michael@0: michael@0: vp9_coeff_count coef_counts[TX_SIZES][BLOCK_TYPES]; michael@0: vp9_coeff_probs_model frame_coef_probs[TX_SIZES][BLOCK_TYPES]; michael@0: vp9_coeff_stats frame_branch_ct[TX_SIZES][BLOCK_TYPES]; michael@0: michael@0: int gfu_boost; michael@0: int last_boost; michael@0: int kf_boost; michael@0: int kf_zeromotion_pct; michael@0: int gf_zeromotion_pct; michael@0: michael@0: int64_t target_bandwidth; michael@0: struct vpx_codec_pkt_list *output_pkt_list; michael@0: michael@0: #if 0 michael@0: // Experimental code for lagged and one pass michael@0: ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS]; michael@0: int one_pass_frame_index; michael@0: #endif michael@0: MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS]; michael@0: int mbgraph_n_frames; // number of frames filled in the above michael@0: int static_mb_pct; // % forced skip mbs by segmentation michael@0: int seg0_progress, seg0_idx, seg0_cnt; michael@0: michael@0: int decimation_factor; michael@0: int decimation_count; michael@0: michael@0: // for real time encoding michael@0: int speed; michael@0: int compressor_speed; michael@0: michael@0: int auto_worst_q; michael@0: int cpu_used; michael@0: int pass; michael@0: michael@0: vp9_prob last_skip_false_probs[3][MBSKIP_CONTEXTS]; michael@0: int last_skip_probs_q[3]; michael@0: michael@0: int ref_frame_flags; michael@0: michael@0: SPEED_FEATURES sf; michael@0: int error_bins[1024]; michael@0: michael@0: unsigned int max_mv_magnitude; michael@0: int mv_step_param; michael@0: michael@0: unsigned char *segmentation_map; michael@0: michael@0: // segment threashold for encode breakout michael@0: int segment_encode_breakout[MAX_SEGMENTS]; michael@0: michael@0: unsigned char *active_map; michael@0: unsigned int active_map_enabled; michael@0: michael@0: fractional_mv_step_fp *find_fractional_mv_step; michael@0: fractional_mv_step_comp_fp *find_fractional_mv_step_comp; michael@0: vp9_full_search_fn_t full_search_sad; michael@0: vp9_refining_search_fn_t refining_search_sad; michael@0: vp9_diamond_search_fn_t diamond_search_sad; michael@0: vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES]; michael@0: uint64_t time_receive_data; michael@0: uint64_t time_compress_data; michael@0: uint64_t time_pick_lpf; michael@0: uint64_t time_encode_sb_row; michael@0: michael@0: struct twopass_rc { michael@0: unsigned int section_intra_rating; michael@0: unsigned int next_iiratio; michael@0: unsigned int this_iiratio; michael@0: FIRSTPASS_STATS total_stats; michael@0: FIRSTPASS_STATS this_frame_stats; michael@0: FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start; michael@0: FIRSTPASS_STATS total_left_stats; michael@0: int first_pass_done; michael@0: int64_t bits_left; michael@0: int64_t clip_bits_total; michael@0: double avg_iiratio; michael@0: double modified_error_total; michael@0: double modified_error_used; michael@0: double modified_error_left; michael@0: double kf_intra_err_min; michael@0: double gf_intra_err_min; michael@0: int frames_to_key; michael@0: int maxq_max_limit; michael@0: int maxq_min_limit; michael@0: int static_scene_max_gf_interval; michael@0: int kf_bits; michael@0: // Remaining error from uncoded frames in a gf group. Two pass use only michael@0: int64_t gf_group_error_left; michael@0: michael@0: // Projected total bits available for a key frame group of frames michael@0: int64_t kf_group_bits; michael@0: michael@0: // Error score of frames still to be coded in kf group michael@0: int64_t kf_group_error_left; michael@0: michael@0: // Projected Bits available for a group of frames including 1 GF or ARF michael@0: int64_t gf_group_bits; michael@0: // Bits for the golden frame or ARF - 2 pass only michael@0: int gf_bits; michael@0: int alt_extra_bits; michael@0: michael@0: int sr_update_lag; michael@0: double est_max_qcorrection_factor; michael@0: } twopass; michael@0: michael@0: YV12_BUFFER_CONFIG alt_ref_buffer; michael@0: YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; michael@0: int fixed_divide[512]; michael@0: michael@0: #if CONFIG_INTERNAL_STATS michael@0: int count; michael@0: double total_y; michael@0: double total_u; michael@0: double total_v; michael@0: double total; michael@0: double total_sq_error; michael@0: double totalp_y; michael@0: double totalp_u; michael@0: double totalp_v; michael@0: double totalp; michael@0: double total_sq_error2; michael@0: int bytes; michael@0: double summed_quality; michael@0: double summed_weights; michael@0: double summedp_quality; michael@0: double summedp_weights; michael@0: unsigned int tot_recode_hits; michael@0: michael@0: michael@0: double total_ssimg_y; michael@0: double total_ssimg_u; michael@0: double total_ssimg_v; michael@0: double total_ssimg_all; michael@0: michael@0: int b_calculate_ssimg; michael@0: #endif michael@0: int b_calculate_psnr; michael@0: michael@0: // Per MB activity measurement michael@0: unsigned int activity_avg; michael@0: unsigned int *mb_activity_map; michael@0: int *mb_norm_activity_map; michael@0: int output_partition; michael@0: michael@0: /* force next frame to intra when kf_auto says so */ michael@0: int force_next_frame_intra; michael@0: michael@0: int droppable; michael@0: michael@0: int dummy_packing; /* flag to indicate if packing is dummy */ michael@0: michael@0: unsigned int switchable_interp_count[SWITCHABLE_FILTER_CONTEXTS] michael@0: [SWITCHABLE_FILTERS]; michael@0: michael@0: unsigned int tx_stepdown_count[TX_SIZES]; michael@0: michael@0: int initial_width; michael@0: int initial_height; michael@0: michael@0: int number_spatial_layers; michael@0: int enable_encode_breakout; // Default value is 1. From first pass stats, michael@0: // encode_breakout may be disabled. michael@0: michael@0: #if CONFIG_MULTIPLE_ARF michael@0: // ARF tracking variables. michael@0: int multi_arf_enabled; michael@0: unsigned int frame_coding_order_period; michael@0: unsigned int new_frame_coding_order_period; michael@0: int frame_coding_order[MAX_LAG_BUFFERS * 2]; michael@0: int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2]; michael@0: int arf_weight[MAX_LAG_BUFFERS]; michael@0: int arf_buffered; michael@0: int this_frame_weight; michael@0: int max_arf_level; michael@0: #endif michael@0: michael@0: #ifdef ENTROPY_STATS michael@0: int64_t mv_ref_stats[INTER_MODE_CONTEXTS][INTER_MODES - 1][2]; michael@0: #endif michael@0: michael@0: michael@0: #ifdef MODE_TEST_HIT_STATS michael@0: // Debug / test stats michael@0: int64_t mode_test_hits[BLOCK_SIZES]; michael@0: #endif michael@0: michael@0: /* Y,U,V,(A) */ michael@0: ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; michael@0: ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; michael@0: michael@0: PARTITION_CONTEXT *above_seg_context; michael@0: PARTITION_CONTEXT left_seg_context[8]; michael@0: } VP9_COMP; michael@0: michael@0: static int get_ref_frame_idx(VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) { michael@0: if (ref_frame == LAST_FRAME) { michael@0: return cpi->lst_fb_idx; michael@0: } else if (ref_frame == GOLDEN_FRAME) { michael@0: return cpi->gld_fb_idx; michael@0: } else { michael@0: return cpi->alt_fb_idx; michael@0: } michael@0: } michael@0: michael@0: static int get_scale_ref_frame_idx(VP9_COMP *cpi, michael@0: MV_REFERENCE_FRAME ref_frame) { michael@0: if (ref_frame == LAST_FRAME) { michael@0: return 0; michael@0: } else if (ref_frame == GOLDEN_FRAME) { michael@0: return 1; michael@0: } else { michael@0: return 2; michael@0: } michael@0: } michael@0: michael@0: void vp9_encode_frame(VP9_COMP *cpi); michael@0: michael@0: void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, michael@0: unsigned long *size); michael@0: michael@0: void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x); michael@0: michael@0: void vp9_set_speed_features(VP9_COMP *cpi); michael@0: michael@0: int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest); michael@0: michael@0: void vp9_alloc_compressor_data(VP9_COMP *cpi); michael@0: michael@0: int vp9_compute_qdelta(VP9_COMP *cpi, double qstart, double qtarget); michael@0: michael@0: static int get_token_alloc(int mb_rows, int mb_cols) { michael@0: return mb_rows * mb_cols * (48 * 16 + 4); michael@0: } michael@0: michael@0: #endif // VP9_ENCODER_VP9_ONYX_INT_H_