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 __INC_VP8_INT_H michael@0: #define __INC_VP8_INT_H michael@0: michael@0: #include michael@0: #include "vpx_config.h" michael@0: #include "vp8/common/onyx.h" michael@0: #include "treewriter.h" michael@0: #include "tokenize.h" michael@0: #include "vp8/common/onyxc_int.h" michael@0: #include "vp8/common/variance.h" michael@0: #include "encodemb.h" michael@0: #include "quantize.h" michael@0: #include "vp8/common/entropy.h" michael@0: #include "vp8/common/threading.h" michael@0: #include "vpx_ports/mem.h" michael@0: #include "vpx/internal/vpx_codec_internal.h" michael@0: #include "vpx/vp8.h" michael@0: #include "mcomp.h" michael@0: #include "vp8/common/findnearmv.h" michael@0: #include "lookahead.h" michael@0: #if CONFIG_TEMPORAL_DENOISING michael@0: #include "vp8/encoder/denoising.h" michael@0: #endif michael@0: michael@0: #define MIN_GF_INTERVAL 4 michael@0: #define DEFAULT_GF_INTERVAL 7 michael@0: michael@0: #define KEY_FRAME_CONTEXT 5 michael@0: michael@0: #define MAX_LAG_BUFFERS (CONFIG_REALTIME_ONLY? 1 : 25) michael@0: michael@0: #define AF_THRESH 25 michael@0: #define AF_THRESH2 100 michael@0: #define ARF_DECAY_THRESH 12 michael@0: michael@0: michael@0: #define MIN_THRESHMULT 32 michael@0: #define MAX_THRESHMULT 512 michael@0: michael@0: #define GF_ZEROMV_ZBIN_BOOST 12 michael@0: #define LF_ZEROMV_ZBIN_BOOST 6 michael@0: #define MV_ZBIN_BOOST 4 michael@0: #define ZBIN_OQ_MAX 192 michael@0: michael@0: #if !(CONFIG_REALTIME_ONLY) michael@0: #define VP8_TEMPORAL_ALT_REF 1 michael@0: #endif michael@0: michael@0: #define MAX(x,y) (((x)>(y))?(x):(y)) michael@0: #define MIN(x,y) (((x)<(y))?(x):(y)) michael@0: michael@0: typedef struct michael@0: { michael@0: int kf_indicated; michael@0: unsigned int frames_since_key; michael@0: unsigned int frames_since_golden; michael@0: int filter_level; michael@0: int frames_till_gf_update_due; michael@0: int recent_ref_frame_usage[MAX_REF_FRAMES]; michael@0: michael@0: MV_CONTEXT mvc[2]; michael@0: int mvcosts[2][MVvals+1]; michael@0: michael@0: #ifdef MODE_STATS michael@0: int y_modes[5]; michael@0: int uv_modes[4]; michael@0: int b_modes[10]; michael@0: int inter_y_modes[10]; michael@0: int inter_uv_modes[4]; michael@0: int inter_b_modes[10]; michael@0: #endif michael@0: michael@0: vp8_prob ymode_prob[4], uv_mode_prob[3]; /* interframe intra mode probs */ michael@0: vp8_prob kf_ymode_prob[4], kf_uv_mode_prob[3]; /* keyframe "" */ michael@0: michael@0: int ymode_count[5], uv_mode_count[4]; /* intra MB type cts this frame */ michael@0: michael@0: int count_mb_ref_frame_usage[MAX_REF_FRAMES]; michael@0: michael@0: int this_frame_percent_intra; michael@0: int last_frame_percent_intra; michael@0: michael@0: michael@0: } CODING_CONTEXT; michael@0: michael@0: typedef struct michael@0: { michael@0: double frame; michael@0: double intra_error; michael@0: double 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: } michael@0: FIRSTPASS_STATS; michael@0: michael@0: typedef struct michael@0: { 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: michael@0: } ONEPASS_FRAMESTATS; michael@0: michael@0: michael@0: typedef enum michael@0: { michael@0: THR_ZERO1 = 0, michael@0: THR_DC = 1, michael@0: michael@0: THR_NEAREST1 = 2, michael@0: THR_NEAR1 = 3, michael@0: michael@0: THR_ZERO2 = 4, michael@0: THR_NEAREST2 = 5, michael@0: michael@0: THR_ZERO3 = 6, michael@0: THR_NEAREST3 = 7, michael@0: michael@0: THR_NEAR2 = 8, michael@0: THR_NEAR3 = 9, michael@0: michael@0: THR_V_PRED = 10, michael@0: THR_H_PRED = 11, michael@0: THR_TM = 12, michael@0: michael@0: THR_NEW1 = 13, michael@0: THR_NEW2 = 14, michael@0: THR_NEW3 = 15, michael@0: michael@0: THR_SPLIT1 = 16, michael@0: THR_SPLIT2 = 17, michael@0: THR_SPLIT3 = 18, michael@0: michael@0: THR_B_PRED = 19 michael@0: } michael@0: THR_MODES; michael@0: michael@0: typedef enum michael@0: { michael@0: DIAMOND = 0, michael@0: NSTEP = 1, michael@0: HEX = 2 michael@0: } SEARCH_METHODS; michael@0: michael@0: typedef struct michael@0: { michael@0: int RD; michael@0: SEARCH_METHODS search_method; michael@0: int improved_quant; michael@0: int improved_dct; michael@0: int auto_filter; michael@0: int recode_loop; michael@0: int iterative_sub_pixel; michael@0: int half_pixel_search; michael@0: int quarter_pixel_search; michael@0: int thresh_mult[MAX_MODES]; michael@0: int max_step_search_steps; michael@0: int first_step; michael@0: int optimize_coefficients; michael@0: michael@0: int use_fastquant_for_pick; michael@0: int no_skip_block4x4_search; michael@0: int improved_mv_pred; michael@0: michael@0: } SPEED_FEATURES; michael@0: michael@0: typedef struct michael@0: { michael@0: MACROBLOCK mb; michael@0: int segment_counts[MAX_MB_SEGMENTS]; michael@0: int totalrate; michael@0: } MB_ROW_COMP; michael@0: michael@0: typedef struct michael@0: { michael@0: TOKENEXTRA *start; michael@0: TOKENEXTRA *stop; michael@0: } TOKENLIST; michael@0: michael@0: typedef struct michael@0: { michael@0: int ithread; michael@0: void *ptr1; michael@0: void *ptr2; michael@0: } ENCODETHREAD_DATA; michael@0: typedef struct michael@0: { michael@0: int ithread; michael@0: void *ptr1; michael@0: } LPFTHREAD_DATA; michael@0: michael@0: enum michael@0: { michael@0: BLOCK_16X8, michael@0: BLOCK_8X16, michael@0: BLOCK_8X8, michael@0: BLOCK_4X4, michael@0: BLOCK_16X16, michael@0: BLOCK_MAX_SEGMENTS michael@0: }; michael@0: michael@0: typedef struct michael@0: { michael@0: /* Layer configuration */ michael@0: double framerate; michael@0: int target_bandwidth; michael@0: michael@0: /* Layer specific coding parameters */ michael@0: int64_t starting_buffer_level; michael@0: int64_t optimal_buffer_level; michael@0: int64_t maximum_buffer_size; michael@0: int64_t starting_buffer_level_in_ms; michael@0: int64_t optimal_buffer_level_in_ms; michael@0: int64_t maximum_buffer_size_in_ms; michael@0: michael@0: int avg_frame_size_for_layer; michael@0: michael@0: int64_t buffer_level; michael@0: int64_t bits_off_target; michael@0: michael@0: int64_t total_actual_bits; michael@0: int total_target_vs_actual; 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 ni_av_qi; michael@0: int ni_tot_qi; michael@0: int ni_frames; michael@0: int avg_frame_qindex; 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: int zbin_over_quant; michael@0: michael@0: int inter_frame_target; michael@0: int64_t total_byte_count; michael@0: michael@0: int filter_level; michael@0: michael@0: int last_frame_percent_intra; michael@0: michael@0: int count_mb_ref_frame_usage[MAX_REF_FRAMES]; michael@0: michael@0: } LAYER_CONTEXT; michael@0: michael@0: typedef struct VP8_COMP michael@0: { michael@0: michael@0: DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y1quant_shift[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]); michael@0: michael@0: DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y2quant_shift[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]); michael@0: michael@0: DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, UVquant_shift[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]); michael@0: michael@0: DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y1quant_fast[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, Y2quant_fast[QINDEX_RANGE][16]); michael@0: DECLARE_ALIGNED(16, short, UVquant_fast[QINDEX_RANGE][16]); michael@0: michael@0: michael@0: MACROBLOCK mb; michael@0: VP8_COMMON common; michael@0: vp8_writer bc[9]; /* one boolcoder for each partition */ michael@0: michael@0: VP8_CONFIG oxcf; michael@0: michael@0: struct lookahead_ctx *lookahead; michael@0: struct lookahead_entry *source; michael@0: struct lookahead_entry *alt_ref_source; michael@0: struct lookahead_entry *last_source; 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: YV12_BUFFER_CONFIG *last_frame_unscaled_source; michael@0: michael@0: unsigned int frames_till_alt_ref_frame; michael@0: /* frame in src_buffers has been identified to be encoded as an alt ref */ michael@0: int source_alt_ref_pending; michael@0: /* an alt ref frame has been encoded and is usable */ michael@0: int source_alt_ref_active; michael@0: /* source of frame to encode is an exact copy of an alt ref frame */ michael@0: int is_src_frame_alt_ref; michael@0: michael@0: /* golden frame same as last frame ( short circuit gold searches) */ michael@0: int gold_is_last; michael@0: /* Alt reference frame same as last ( short circuit altref search) */ michael@0: int alt_is_last; michael@0: /* don't do both alt and gold search ( just do gold). */ michael@0: int gold_is_alt; michael@0: michael@0: YV12_BUFFER_CONFIG pick_lf_lvl_frame; michael@0: michael@0: TOKENEXTRA *tok; michael@0: unsigned int tok_count; 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: michael@0: /* Ambient reconstruction err target for force key frames */ michael@0: int ambient_err; michael@0: michael@0: unsigned int mode_check_freq[MAX_MODES]; michael@0: michael@0: int rd_baseline_thresh[MAX_MODES]; 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: int64_t last_prediction_error; michael@0: int64_t last_intra_error; michael@0: 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: 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: /* Count down till next GF */ michael@0: int frames_till_gf_update_due; michael@0: michael@0: /* GF interval chosen when we coded the last GF */ michael@0: int current_gf_interval; michael@0: michael@0: /* Total bits overspent becasue of GF boost (cumulative) */ michael@0: int gf_overspend_bits; michael@0: michael@0: /* Used in the few frames following a GF to recover the extra bits michael@0: * spent in that GF michael@0: */ michael@0: int non_gf_bitrate_adjustment; michael@0: michael@0: /* Extra bits spent on key frames that need to be recovered */ michael@0: int kf_overspend_bits; michael@0: michael@0: /* Current number of bit s to try and recover on each inter frame. */ michael@0: int kf_bitrate_adjustment; michael@0: int max_gf_interval; michael@0: int baseline_gf_interval; michael@0: int active_arnr_frames; michael@0: michael@0: int64_t key_frame_count; michael@0: int prior_key_frame_distance[KEY_FRAME_CONTEXT]; michael@0: /* Current section per frame bandwidth target */ michael@0: int per_frame_bandwidth; michael@0: /* Average frame size target for clip */ michael@0: int av_per_frame_bandwidth; michael@0: /* Minimum allocation that should be used for any frame */ michael@0: int min_frame_bandwidth; 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: michael@0: int64_t total_byte_count; michael@0: michael@0: int buffered_mode; michael@0: michael@0: double framerate; michael@0: double ref_framerate; michael@0: int64_t buffer_level; michael@0: int64_t 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 drop_frames_allowed; /* Are we permitted to drop frames? */ michael@0: int drop_frame; /* Drop this frame? */ michael@0: michael@0: vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; michael@0: char update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; michael@0: michael@0: unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; michael@0: michael@0: int gfu_boost; michael@0: int kf_boost; michael@0: int last_boost; michael@0: michael@0: int 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: michael@0: int decimation_factor; michael@0: int decimation_count; michael@0: michael@0: /* for real time encoding */ michael@0: int avg_encode_time; /* microsecond */ michael@0: int avg_pick_mode_time; /* microsecond */ michael@0: int Speed; michael@0: int compressor_speed; michael@0: michael@0: int auto_gold; michael@0: int auto_adjust_gold_quantizer; michael@0: int auto_worst_q; michael@0: int cpu_used; michael@0: int pass; michael@0: michael@0: michael@0: int prob_intra_coded; michael@0: int prob_last_coded; michael@0: int prob_gf_coded; michael@0: int prob_skip_false; michael@0: int last_skip_false_probs[3]; michael@0: int last_skip_probs_q[3]; michael@0: int recent_ref_frame_usage[MAX_REF_FRAMES]; michael@0: michael@0: int this_frame_percent_intra; michael@0: int last_frame_percent_intra; michael@0: michael@0: int ref_frame_flags; michael@0: michael@0: SPEED_FEATURES sf; michael@0: michael@0: /* Count ZEROMV on all reference frames. */ michael@0: int zeromv_count; michael@0: int lf_zeromv_pct; michael@0: michael@0: unsigned char *segmentation_map; michael@0: signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; michael@0: int segment_encode_breakout[MAX_MB_SEGMENTS]; michael@0: michael@0: unsigned char *active_map; michael@0: unsigned int active_map_enabled; michael@0: michael@0: /* Video conferencing cyclic refresh mode flags. This is a mode michael@0: * designed to clean up the background over time in live encoding michael@0: * scenarious. It uses segmentation. michael@0: */ michael@0: int cyclic_refresh_mode_enabled; michael@0: int cyclic_refresh_mode_max_mbs_perframe; michael@0: int cyclic_refresh_mode_index; michael@0: int cyclic_refresh_q; michael@0: signed char *cyclic_refresh_map; michael@0: michael@0: // Frame counter for the temporal pattern. Counter is rest when the temporal michael@0: // layers are changed dynamically (run-time change). michael@0: unsigned int temporal_pattern_counter; michael@0: michael@0: #if CONFIG_MULTITHREAD michael@0: /* multithread data */ michael@0: int * mt_current_mb_col; michael@0: int mt_sync_range; michael@0: int b_multi_threaded; michael@0: int encoding_thread_count; michael@0: int b_lpf_running; michael@0: michael@0: pthread_t *h_encoding_thread; michael@0: pthread_t h_filter_thread; michael@0: michael@0: MB_ROW_COMP *mb_row_ei; michael@0: ENCODETHREAD_DATA *en_thread_data; michael@0: LPFTHREAD_DATA lpf_thread_data; michael@0: michael@0: /* events */ michael@0: sem_t *h_event_start_encoding; michael@0: sem_t h_event_end_encoding; michael@0: sem_t h_event_start_lpf; michael@0: sem_t h_event_end_lpf; michael@0: #endif michael@0: michael@0: TOKENLIST *tplist; michael@0: unsigned int partition_sz[MAX_PARTITIONS]; michael@0: unsigned char *partition_d[MAX_PARTITIONS]; michael@0: unsigned char *partition_d_end[MAX_PARTITIONS]; michael@0: michael@0: michael@0: fractional_mv_step_fp *find_fractional_mv_step; michael@0: vp8_full_search_fn_t full_search_sad; michael@0: vp8_refining_search_fn_t refining_search_sad; michael@0: vp8_diamond_search_fn_t diamond_search_sad; michael@0: vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS]; 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_mb_row; michael@0: michael@0: int base_skip_false_prob[128]; michael@0: michael@0: FRAME_CONTEXT lfc_n; /* last frame entropy */ michael@0: FRAME_CONTEXT lfc_a; /* last alt ref entropy */ michael@0: FRAME_CONTEXT lfc_g; /* last gold ref entropy */ michael@0: michael@0: michael@0: struct twopass_rc michael@0: { michael@0: unsigned int section_intra_rating; michael@0: double section_max_qfactor; 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 gf_decay_rate; michael@0: int static_scene_max_gf_interval; michael@0: int kf_bits; michael@0: /* Remaining error from uncoded frames in a gf group. */ michael@0: int gf_group_error_left; michael@0: /* Projected total bits available for a key frame group of frames */ michael@0: int64_t kf_group_bits; michael@0: /* Error score of frames still to be coded in kf group */ michael@0: int64_t kf_group_error_left; michael@0: /* Projected Bits available for a group including 1 GF or ARF */ michael@0: int64_t gf_group_bits; michael@0: /* Bits for the golden frame or ARF */ michael@0: int gf_bits; michael@0: int alt_extra_bits; michael@0: double est_max_qcorrection_factor; michael@0: } twopass; michael@0: michael@0: #if VP8_TEMPORAL_ALT_REF 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: #endif 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: 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: michael@0: /* Record of which MBs still refer to last golden frame either michael@0: * directly or through 0,0 michael@0: */ michael@0: unsigned char *gf_active_flags; michael@0: int gf_active_count; michael@0: michael@0: int output_partition; michael@0: michael@0: /* Store last frame's MV info for next frame MV prediction */ michael@0: int_mv *lfmv; michael@0: int *lf_ref_frame_sign_bias; michael@0: int *lf_ref_frame; 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: #if CONFIG_TEMPORAL_DENOISING michael@0: VP8_DENOISER denoiser; michael@0: #endif michael@0: michael@0: /* Coding layer state variables */ michael@0: unsigned int current_layer; michael@0: LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS]; michael@0: michael@0: int64_t frames_in_layer[VPX_TS_MAX_LAYERS]; michael@0: int64_t bytes_in_layer[VPX_TS_MAX_LAYERS]; michael@0: double sum_psnr[VPX_TS_MAX_LAYERS]; michael@0: double sum_psnr_p[VPX_TS_MAX_LAYERS]; michael@0: double total_error2[VPX_TS_MAX_LAYERS]; michael@0: double total_error2_p[VPX_TS_MAX_LAYERS]; michael@0: double sum_ssim[VPX_TS_MAX_LAYERS]; michael@0: double sum_weights[VPX_TS_MAX_LAYERS]; michael@0: michael@0: double total_ssimg_y_in_layer[VPX_TS_MAX_LAYERS]; michael@0: double total_ssimg_u_in_layer[VPX_TS_MAX_LAYERS]; michael@0: double total_ssimg_v_in_layer[VPX_TS_MAX_LAYERS]; michael@0: double total_ssimg_all_in_layer[VPX_TS_MAX_LAYERS]; michael@0: michael@0: #if CONFIG_MULTI_RES_ENCODING michael@0: /* Number of MBs per row at lower-resolution level */ michael@0: int mr_low_res_mb_cols; michael@0: /* Indicate if lower-res mv info is available */ michael@0: unsigned char mr_low_res_mv_avail; michael@0: /* The frame number of each reference frames */ michael@0: unsigned int current_ref_frames[MAX_REF_FRAMES]; michael@0: #endif michael@0: michael@0: struct rd_costs_struct michael@0: { michael@0: int mvcosts[2][MVvals+1]; michael@0: int mvsadcosts[2][MVfpvals+1]; michael@0: int mbmode_cost[2][MB_MODE_COUNT]; michael@0: int intra_uv_mode_cost[2][MB_MODE_COUNT]; michael@0: int bmode_costs[10][10][10]; michael@0: int inter_bmode_costs[B_MODE_COUNT]; michael@0: int token_costs[BLOCK_TYPES][COEF_BANDS] michael@0: [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; michael@0: } rd_costs; michael@0: } VP8_COMP; michael@0: michael@0: void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, michael@0: unsigned char *dest_end, unsigned long *size); michael@0: michael@0: void vp8_tokenize_mb(VP8_COMP *, MACROBLOCK *, TOKENEXTRA **); michael@0: michael@0: void vp8_set_speed_features(VP8_COMP *cpi); michael@0: michael@0: #if CONFIG_DEBUG michael@0: #define CHECK_MEM_ERROR(lval,expr) do {\ michael@0: lval = (expr); \ michael@0: if(!lval) \ michael@0: vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ michael@0: "Failed to allocate "#lval" at %s:%d", \ michael@0: __FILE__,__LINE__);\ michael@0: } while(0) michael@0: #else michael@0: #define CHECK_MEM_ERROR(lval,expr) do {\ michael@0: lval = (expr); \ michael@0: if(!lval) \ michael@0: vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ michael@0: "Failed to allocate "#lval);\ michael@0: } while(0) michael@0: #endif michael@0: #endif