1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/encoder/onyx_int.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,724 @@ 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 __INC_VP8_INT_H 1.16 +#define __INC_VP8_INT_H 1.17 + 1.18 +#include <stdio.h> 1.19 +#include "vpx_config.h" 1.20 +#include "vp8/common/onyx.h" 1.21 +#include "treewriter.h" 1.22 +#include "tokenize.h" 1.23 +#include "vp8/common/onyxc_int.h" 1.24 +#include "vp8/common/variance.h" 1.25 +#include "encodemb.h" 1.26 +#include "quantize.h" 1.27 +#include "vp8/common/entropy.h" 1.28 +#include "vp8/common/threading.h" 1.29 +#include "vpx_ports/mem.h" 1.30 +#include "vpx/internal/vpx_codec_internal.h" 1.31 +#include "vpx/vp8.h" 1.32 +#include "mcomp.h" 1.33 +#include "vp8/common/findnearmv.h" 1.34 +#include "lookahead.h" 1.35 +#if CONFIG_TEMPORAL_DENOISING 1.36 +#include "vp8/encoder/denoising.h" 1.37 +#endif 1.38 + 1.39 +#define MIN_GF_INTERVAL 4 1.40 +#define DEFAULT_GF_INTERVAL 7 1.41 + 1.42 +#define KEY_FRAME_CONTEXT 5 1.43 + 1.44 +#define MAX_LAG_BUFFERS (CONFIG_REALTIME_ONLY? 1 : 25) 1.45 + 1.46 +#define AF_THRESH 25 1.47 +#define AF_THRESH2 100 1.48 +#define ARF_DECAY_THRESH 12 1.49 + 1.50 + 1.51 +#define MIN_THRESHMULT 32 1.52 +#define MAX_THRESHMULT 512 1.53 + 1.54 +#define GF_ZEROMV_ZBIN_BOOST 12 1.55 +#define LF_ZEROMV_ZBIN_BOOST 6 1.56 +#define MV_ZBIN_BOOST 4 1.57 +#define ZBIN_OQ_MAX 192 1.58 + 1.59 +#if !(CONFIG_REALTIME_ONLY) 1.60 +#define VP8_TEMPORAL_ALT_REF 1 1.61 +#endif 1.62 + 1.63 +#define MAX(x,y) (((x)>(y))?(x):(y)) 1.64 +#define MIN(x,y) (((x)<(y))?(x):(y)) 1.65 + 1.66 +typedef struct 1.67 +{ 1.68 + int kf_indicated; 1.69 + unsigned int frames_since_key; 1.70 + unsigned int frames_since_golden; 1.71 + int filter_level; 1.72 + int frames_till_gf_update_due; 1.73 + int recent_ref_frame_usage[MAX_REF_FRAMES]; 1.74 + 1.75 + MV_CONTEXT mvc[2]; 1.76 + int mvcosts[2][MVvals+1]; 1.77 + 1.78 +#ifdef MODE_STATS 1.79 + int y_modes[5]; 1.80 + int uv_modes[4]; 1.81 + int b_modes[10]; 1.82 + int inter_y_modes[10]; 1.83 + int inter_uv_modes[4]; 1.84 + int inter_b_modes[10]; 1.85 +#endif 1.86 + 1.87 + vp8_prob ymode_prob[4], uv_mode_prob[3]; /* interframe intra mode probs */ 1.88 + vp8_prob kf_ymode_prob[4], kf_uv_mode_prob[3]; /* keyframe "" */ 1.89 + 1.90 + int ymode_count[5], uv_mode_count[4]; /* intra MB type cts this frame */ 1.91 + 1.92 + int count_mb_ref_frame_usage[MAX_REF_FRAMES]; 1.93 + 1.94 + int this_frame_percent_intra; 1.95 + int last_frame_percent_intra; 1.96 + 1.97 + 1.98 +} CODING_CONTEXT; 1.99 + 1.100 +typedef struct 1.101 +{ 1.102 + double frame; 1.103 + double intra_error; 1.104 + double coded_error; 1.105 + double ssim_weighted_pred_err; 1.106 + double pcnt_inter; 1.107 + double pcnt_motion; 1.108 + double pcnt_second_ref; 1.109 + double pcnt_neutral; 1.110 + double MVr; 1.111 + double mvr_abs; 1.112 + double MVc; 1.113 + double mvc_abs; 1.114 + double MVrv; 1.115 + double MVcv; 1.116 + double mv_in_out_count; 1.117 + double new_mv_count; 1.118 + double duration; 1.119 + double count; 1.120 +} 1.121 +FIRSTPASS_STATS; 1.122 + 1.123 +typedef struct 1.124 +{ 1.125 + int frames_so_far; 1.126 + double frame_intra_error; 1.127 + double frame_coded_error; 1.128 + double frame_pcnt_inter; 1.129 + double frame_pcnt_motion; 1.130 + double frame_mvr; 1.131 + double frame_mvr_abs; 1.132 + double frame_mvc; 1.133 + double frame_mvc_abs; 1.134 + 1.135 +} ONEPASS_FRAMESTATS; 1.136 + 1.137 + 1.138 +typedef enum 1.139 +{ 1.140 + THR_ZERO1 = 0, 1.141 + THR_DC = 1, 1.142 + 1.143 + THR_NEAREST1 = 2, 1.144 + THR_NEAR1 = 3, 1.145 + 1.146 + THR_ZERO2 = 4, 1.147 + THR_NEAREST2 = 5, 1.148 + 1.149 + THR_ZERO3 = 6, 1.150 + THR_NEAREST3 = 7, 1.151 + 1.152 + THR_NEAR2 = 8, 1.153 + THR_NEAR3 = 9, 1.154 + 1.155 + THR_V_PRED = 10, 1.156 + THR_H_PRED = 11, 1.157 + THR_TM = 12, 1.158 + 1.159 + THR_NEW1 = 13, 1.160 + THR_NEW2 = 14, 1.161 + THR_NEW3 = 15, 1.162 + 1.163 + THR_SPLIT1 = 16, 1.164 + THR_SPLIT2 = 17, 1.165 + THR_SPLIT3 = 18, 1.166 + 1.167 + THR_B_PRED = 19 1.168 +} 1.169 +THR_MODES; 1.170 + 1.171 +typedef enum 1.172 +{ 1.173 + DIAMOND = 0, 1.174 + NSTEP = 1, 1.175 + HEX = 2 1.176 +} SEARCH_METHODS; 1.177 + 1.178 +typedef struct 1.179 +{ 1.180 + int RD; 1.181 + SEARCH_METHODS search_method; 1.182 + int improved_quant; 1.183 + int improved_dct; 1.184 + int auto_filter; 1.185 + int recode_loop; 1.186 + int iterative_sub_pixel; 1.187 + int half_pixel_search; 1.188 + int quarter_pixel_search; 1.189 + int thresh_mult[MAX_MODES]; 1.190 + int max_step_search_steps; 1.191 + int first_step; 1.192 + int optimize_coefficients; 1.193 + 1.194 + int use_fastquant_for_pick; 1.195 + int no_skip_block4x4_search; 1.196 + int improved_mv_pred; 1.197 + 1.198 +} SPEED_FEATURES; 1.199 + 1.200 +typedef struct 1.201 +{ 1.202 + MACROBLOCK mb; 1.203 + int segment_counts[MAX_MB_SEGMENTS]; 1.204 + int totalrate; 1.205 +} MB_ROW_COMP; 1.206 + 1.207 +typedef struct 1.208 +{ 1.209 + TOKENEXTRA *start; 1.210 + TOKENEXTRA *stop; 1.211 +} TOKENLIST; 1.212 + 1.213 +typedef struct 1.214 +{ 1.215 + int ithread; 1.216 + void *ptr1; 1.217 + void *ptr2; 1.218 +} ENCODETHREAD_DATA; 1.219 +typedef struct 1.220 +{ 1.221 + int ithread; 1.222 + void *ptr1; 1.223 +} LPFTHREAD_DATA; 1.224 + 1.225 +enum 1.226 +{ 1.227 + BLOCK_16X8, 1.228 + BLOCK_8X16, 1.229 + BLOCK_8X8, 1.230 + BLOCK_4X4, 1.231 + BLOCK_16X16, 1.232 + BLOCK_MAX_SEGMENTS 1.233 +}; 1.234 + 1.235 +typedef struct 1.236 +{ 1.237 + /* Layer configuration */ 1.238 + double framerate; 1.239 + int target_bandwidth; 1.240 + 1.241 + /* Layer specific coding parameters */ 1.242 + int64_t starting_buffer_level; 1.243 + int64_t optimal_buffer_level; 1.244 + int64_t maximum_buffer_size; 1.245 + int64_t starting_buffer_level_in_ms; 1.246 + int64_t optimal_buffer_level_in_ms; 1.247 + int64_t maximum_buffer_size_in_ms; 1.248 + 1.249 + int avg_frame_size_for_layer; 1.250 + 1.251 + int64_t buffer_level; 1.252 + int64_t bits_off_target; 1.253 + 1.254 + int64_t total_actual_bits; 1.255 + int total_target_vs_actual; 1.256 + 1.257 + int worst_quality; 1.258 + int active_worst_quality; 1.259 + int best_quality; 1.260 + int active_best_quality; 1.261 + 1.262 + int ni_av_qi; 1.263 + int ni_tot_qi; 1.264 + int ni_frames; 1.265 + int avg_frame_qindex; 1.266 + 1.267 + double rate_correction_factor; 1.268 + double key_frame_rate_correction_factor; 1.269 + double gf_rate_correction_factor; 1.270 + 1.271 + int zbin_over_quant; 1.272 + 1.273 + int inter_frame_target; 1.274 + int64_t total_byte_count; 1.275 + 1.276 + int filter_level; 1.277 + 1.278 + int last_frame_percent_intra; 1.279 + 1.280 + int count_mb_ref_frame_usage[MAX_REF_FRAMES]; 1.281 + 1.282 +} LAYER_CONTEXT; 1.283 + 1.284 +typedef struct VP8_COMP 1.285 +{ 1.286 + 1.287 + DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]); 1.288 + DECLARE_ALIGNED(16, short, Y1quant_shift[QINDEX_RANGE][16]); 1.289 + DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]); 1.290 + DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]); 1.291 + 1.292 + DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]); 1.293 + DECLARE_ALIGNED(16, short, Y2quant_shift[QINDEX_RANGE][16]); 1.294 + DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]); 1.295 + DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]); 1.296 + 1.297 + DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]); 1.298 + DECLARE_ALIGNED(16, short, UVquant_shift[QINDEX_RANGE][16]); 1.299 + DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]); 1.300 + DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]); 1.301 + 1.302 + DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]); 1.303 + DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]); 1.304 + DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]); 1.305 + DECLARE_ALIGNED(16, short, Y1quant_fast[QINDEX_RANGE][16]); 1.306 + DECLARE_ALIGNED(16, short, Y2quant_fast[QINDEX_RANGE][16]); 1.307 + DECLARE_ALIGNED(16, short, UVquant_fast[QINDEX_RANGE][16]); 1.308 + 1.309 + 1.310 + MACROBLOCK mb; 1.311 + VP8_COMMON common; 1.312 + vp8_writer bc[9]; /* one boolcoder for each partition */ 1.313 + 1.314 + VP8_CONFIG oxcf; 1.315 + 1.316 + struct lookahead_ctx *lookahead; 1.317 + struct lookahead_entry *source; 1.318 + struct lookahead_entry *alt_ref_source; 1.319 + struct lookahead_entry *last_source; 1.320 + 1.321 + YV12_BUFFER_CONFIG *Source; 1.322 + YV12_BUFFER_CONFIG *un_scaled_source; 1.323 + YV12_BUFFER_CONFIG scaled_source; 1.324 + YV12_BUFFER_CONFIG *last_frame_unscaled_source; 1.325 + 1.326 + unsigned int frames_till_alt_ref_frame; 1.327 + /* frame in src_buffers has been identified to be encoded as an alt ref */ 1.328 + int source_alt_ref_pending; 1.329 + /* an alt ref frame has been encoded and is usable */ 1.330 + int source_alt_ref_active; 1.331 + /* source of frame to encode is an exact copy of an alt ref frame */ 1.332 + int is_src_frame_alt_ref; 1.333 + 1.334 + /* golden frame same as last frame ( short circuit gold searches) */ 1.335 + int gold_is_last; 1.336 + /* Alt reference frame same as last ( short circuit altref search) */ 1.337 + int alt_is_last; 1.338 + /* don't do both alt and gold search ( just do gold). */ 1.339 + int gold_is_alt; 1.340 + 1.341 + YV12_BUFFER_CONFIG pick_lf_lvl_frame; 1.342 + 1.343 + TOKENEXTRA *tok; 1.344 + unsigned int tok_count; 1.345 + 1.346 + 1.347 + unsigned int frames_since_key; 1.348 + unsigned int key_frame_frequency; 1.349 + unsigned int this_key_frame_forced; 1.350 + unsigned int next_key_frame_forced; 1.351 + 1.352 + /* Ambient reconstruction err target for force key frames */ 1.353 + int ambient_err; 1.354 + 1.355 + unsigned int mode_check_freq[MAX_MODES]; 1.356 + 1.357 + int rd_baseline_thresh[MAX_MODES]; 1.358 + 1.359 + int RDMULT; 1.360 + int RDDIV ; 1.361 + 1.362 + CODING_CONTEXT coding_context; 1.363 + 1.364 + /* Rate targetting variables */ 1.365 + int64_t last_prediction_error; 1.366 + int64_t last_intra_error; 1.367 + 1.368 + int this_frame_target; 1.369 + int projected_frame_size; 1.370 + int last_q[2]; /* Separate values for Intra/Inter */ 1.371 + 1.372 + double rate_correction_factor; 1.373 + double key_frame_rate_correction_factor; 1.374 + double gf_rate_correction_factor; 1.375 + 1.376 + unsigned int frames_since_golden; 1.377 + /* Count down till next GF */ 1.378 + int frames_till_gf_update_due; 1.379 + 1.380 + /* GF interval chosen when we coded the last GF */ 1.381 + int current_gf_interval; 1.382 + 1.383 + /* Total bits overspent becasue of GF boost (cumulative) */ 1.384 + int gf_overspend_bits; 1.385 + 1.386 + /* Used in the few frames following a GF to recover the extra bits 1.387 + * spent in that GF 1.388 + */ 1.389 + int non_gf_bitrate_adjustment; 1.390 + 1.391 + /* Extra bits spent on key frames that need to be recovered */ 1.392 + int kf_overspend_bits; 1.393 + 1.394 + /* Current number of bit s to try and recover on each inter frame. */ 1.395 + int kf_bitrate_adjustment; 1.396 + int max_gf_interval; 1.397 + int baseline_gf_interval; 1.398 + int active_arnr_frames; 1.399 + 1.400 + int64_t key_frame_count; 1.401 + int prior_key_frame_distance[KEY_FRAME_CONTEXT]; 1.402 + /* Current section per frame bandwidth target */ 1.403 + int per_frame_bandwidth; 1.404 + /* Average frame size target for clip */ 1.405 + int av_per_frame_bandwidth; 1.406 + /* Minimum allocation that should be used for any frame */ 1.407 + int min_frame_bandwidth; 1.408 + int inter_frame_target; 1.409 + double output_framerate; 1.410 + int64_t last_time_stamp_seen; 1.411 + int64_t last_end_time_stamp_seen; 1.412 + int64_t first_time_stamp_ever; 1.413 + 1.414 + int ni_av_qi; 1.415 + int ni_tot_qi; 1.416 + int ni_frames; 1.417 + int avg_frame_qindex; 1.418 + 1.419 + int64_t total_byte_count; 1.420 + 1.421 + int buffered_mode; 1.422 + 1.423 + double framerate; 1.424 + double ref_framerate; 1.425 + int64_t buffer_level; 1.426 + int64_t bits_off_target; 1.427 + 1.428 + int rolling_target_bits; 1.429 + int rolling_actual_bits; 1.430 + 1.431 + int long_rolling_target_bits; 1.432 + int long_rolling_actual_bits; 1.433 + 1.434 + int64_t total_actual_bits; 1.435 + int total_target_vs_actual; /* debug stats */ 1.436 + 1.437 + int worst_quality; 1.438 + int active_worst_quality; 1.439 + int best_quality; 1.440 + int active_best_quality; 1.441 + 1.442 + int cq_target_quality; 1.443 + 1.444 + int drop_frames_allowed; /* Are we permitted to drop frames? */ 1.445 + int drop_frame; /* Drop this frame? */ 1.446 + 1.447 + vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; 1.448 + char update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; 1.449 + 1.450 + unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; 1.451 + 1.452 + int gfu_boost; 1.453 + int kf_boost; 1.454 + int last_boost; 1.455 + 1.456 + int target_bandwidth; 1.457 + struct vpx_codec_pkt_list *output_pkt_list; 1.458 + 1.459 +#if 0 1.460 + /* Experimental code for lagged and one pass */ 1.461 + ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS]; 1.462 + int one_pass_frame_index; 1.463 +#endif 1.464 + 1.465 + int decimation_factor; 1.466 + int decimation_count; 1.467 + 1.468 + /* for real time encoding */ 1.469 + int avg_encode_time; /* microsecond */ 1.470 + int avg_pick_mode_time; /* microsecond */ 1.471 + int Speed; 1.472 + int compressor_speed; 1.473 + 1.474 + int auto_gold; 1.475 + int auto_adjust_gold_quantizer; 1.476 + int auto_worst_q; 1.477 + int cpu_used; 1.478 + int pass; 1.479 + 1.480 + 1.481 + int prob_intra_coded; 1.482 + int prob_last_coded; 1.483 + int prob_gf_coded; 1.484 + int prob_skip_false; 1.485 + int last_skip_false_probs[3]; 1.486 + int last_skip_probs_q[3]; 1.487 + int recent_ref_frame_usage[MAX_REF_FRAMES]; 1.488 + 1.489 + int this_frame_percent_intra; 1.490 + int last_frame_percent_intra; 1.491 + 1.492 + int ref_frame_flags; 1.493 + 1.494 + SPEED_FEATURES sf; 1.495 + 1.496 + /* Count ZEROMV on all reference frames. */ 1.497 + int zeromv_count; 1.498 + int lf_zeromv_pct; 1.499 + 1.500 + unsigned char *segmentation_map; 1.501 + signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; 1.502 + int segment_encode_breakout[MAX_MB_SEGMENTS]; 1.503 + 1.504 + unsigned char *active_map; 1.505 + unsigned int active_map_enabled; 1.506 + 1.507 + /* Video conferencing cyclic refresh mode flags. This is a mode 1.508 + * designed to clean up the background over time in live encoding 1.509 + * scenarious. It uses segmentation. 1.510 + */ 1.511 + int cyclic_refresh_mode_enabled; 1.512 + int cyclic_refresh_mode_max_mbs_perframe; 1.513 + int cyclic_refresh_mode_index; 1.514 + int cyclic_refresh_q; 1.515 + signed char *cyclic_refresh_map; 1.516 + 1.517 + // Frame counter for the temporal pattern. Counter is rest when the temporal 1.518 + // layers are changed dynamically (run-time change). 1.519 + unsigned int temporal_pattern_counter; 1.520 + 1.521 +#if CONFIG_MULTITHREAD 1.522 + /* multithread data */ 1.523 + int * mt_current_mb_col; 1.524 + int mt_sync_range; 1.525 + int b_multi_threaded; 1.526 + int encoding_thread_count; 1.527 + int b_lpf_running; 1.528 + 1.529 + pthread_t *h_encoding_thread; 1.530 + pthread_t h_filter_thread; 1.531 + 1.532 + MB_ROW_COMP *mb_row_ei; 1.533 + ENCODETHREAD_DATA *en_thread_data; 1.534 + LPFTHREAD_DATA lpf_thread_data; 1.535 + 1.536 + /* events */ 1.537 + sem_t *h_event_start_encoding; 1.538 + sem_t h_event_end_encoding; 1.539 + sem_t h_event_start_lpf; 1.540 + sem_t h_event_end_lpf; 1.541 +#endif 1.542 + 1.543 + TOKENLIST *tplist; 1.544 + unsigned int partition_sz[MAX_PARTITIONS]; 1.545 + unsigned char *partition_d[MAX_PARTITIONS]; 1.546 + unsigned char *partition_d_end[MAX_PARTITIONS]; 1.547 + 1.548 + 1.549 + fractional_mv_step_fp *find_fractional_mv_step; 1.550 + vp8_full_search_fn_t full_search_sad; 1.551 + vp8_refining_search_fn_t refining_search_sad; 1.552 + vp8_diamond_search_fn_t diamond_search_sad; 1.553 + vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS]; 1.554 + uint64_t time_receive_data; 1.555 + uint64_t time_compress_data; 1.556 + uint64_t time_pick_lpf; 1.557 + uint64_t time_encode_mb_row; 1.558 + 1.559 + int base_skip_false_prob[128]; 1.560 + 1.561 + FRAME_CONTEXT lfc_n; /* last frame entropy */ 1.562 + FRAME_CONTEXT lfc_a; /* last alt ref entropy */ 1.563 + FRAME_CONTEXT lfc_g; /* last gold ref entropy */ 1.564 + 1.565 + 1.566 + struct twopass_rc 1.567 + { 1.568 + unsigned int section_intra_rating; 1.569 + double section_max_qfactor; 1.570 + unsigned int next_iiratio; 1.571 + unsigned int this_iiratio; 1.572 + FIRSTPASS_STATS total_stats; 1.573 + FIRSTPASS_STATS this_frame_stats; 1.574 + FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start; 1.575 + FIRSTPASS_STATS total_left_stats; 1.576 + int first_pass_done; 1.577 + int64_t bits_left; 1.578 + int64_t clip_bits_total; 1.579 + double avg_iiratio; 1.580 + double modified_error_total; 1.581 + double modified_error_used; 1.582 + double modified_error_left; 1.583 + double kf_intra_err_min; 1.584 + double gf_intra_err_min; 1.585 + int frames_to_key; 1.586 + int maxq_max_limit; 1.587 + int maxq_min_limit; 1.588 + int gf_decay_rate; 1.589 + int static_scene_max_gf_interval; 1.590 + int kf_bits; 1.591 + /* Remaining error from uncoded frames in a gf group. */ 1.592 + int gf_group_error_left; 1.593 + /* Projected total bits available for a key frame group of frames */ 1.594 + int64_t kf_group_bits; 1.595 + /* Error score of frames still to be coded in kf group */ 1.596 + int64_t kf_group_error_left; 1.597 + /* Projected Bits available for a group including 1 GF or ARF */ 1.598 + int64_t gf_group_bits; 1.599 + /* Bits for the golden frame or ARF */ 1.600 + int gf_bits; 1.601 + int alt_extra_bits; 1.602 + double est_max_qcorrection_factor; 1.603 + } twopass; 1.604 + 1.605 +#if VP8_TEMPORAL_ALT_REF 1.606 + YV12_BUFFER_CONFIG alt_ref_buffer; 1.607 + YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; 1.608 + int fixed_divide[512]; 1.609 +#endif 1.610 + 1.611 +#if CONFIG_INTERNAL_STATS 1.612 + int count; 1.613 + double total_y; 1.614 + double total_u; 1.615 + double total_v; 1.616 + double total ; 1.617 + double total_sq_error; 1.618 + double totalp_y; 1.619 + double totalp_u; 1.620 + double totalp_v; 1.621 + double totalp; 1.622 + double total_sq_error2; 1.623 + int bytes; 1.624 + double summed_quality; 1.625 + double summed_weights; 1.626 + unsigned int tot_recode_hits; 1.627 + 1.628 + 1.629 + double total_ssimg_y; 1.630 + double total_ssimg_u; 1.631 + double total_ssimg_v; 1.632 + double total_ssimg_all; 1.633 + 1.634 + int b_calculate_ssimg; 1.635 +#endif 1.636 + int b_calculate_psnr; 1.637 + 1.638 + /* Per MB activity measurement */ 1.639 + unsigned int activity_avg; 1.640 + unsigned int * mb_activity_map; 1.641 + 1.642 + /* Record of which MBs still refer to last golden frame either 1.643 + * directly or through 0,0 1.644 + */ 1.645 + unsigned char *gf_active_flags; 1.646 + int gf_active_count; 1.647 + 1.648 + int output_partition; 1.649 + 1.650 + /* Store last frame's MV info for next frame MV prediction */ 1.651 + int_mv *lfmv; 1.652 + int *lf_ref_frame_sign_bias; 1.653 + int *lf_ref_frame; 1.654 + 1.655 + /* force next frame to intra when kf_auto says so */ 1.656 + int force_next_frame_intra; 1.657 + 1.658 + int droppable; 1.659 + 1.660 +#if CONFIG_TEMPORAL_DENOISING 1.661 + VP8_DENOISER denoiser; 1.662 +#endif 1.663 + 1.664 + /* Coding layer state variables */ 1.665 + unsigned int current_layer; 1.666 + LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS]; 1.667 + 1.668 + int64_t frames_in_layer[VPX_TS_MAX_LAYERS]; 1.669 + int64_t bytes_in_layer[VPX_TS_MAX_LAYERS]; 1.670 + double sum_psnr[VPX_TS_MAX_LAYERS]; 1.671 + double sum_psnr_p[VPX_TS_MAX_LAYERS]; 1.672 + double total_error2[VPX_TS_MAX_LAYERS]; 1.673 + double total_error2_p[VPX_TS_MAX_LAYERS]; 1.674 + double sum_ssim[VPX_TS_MAX_LAYERS]; 1.675 + double sum_weights[VPX_TS_MAX_LAYERS]; 1.676 + 1.677 + double total_ssimg_y_in_layer[VPX_TS_MAX_LAYERS]; 1.678 + double total_ssimg_u_in_layer[VPX_TS_MAX_LAYERS]; 1.679 + double total_ssimg_v_in_layer[VPX_TS_MAX_LAYERS]; 1.680 + double total_ssimg_all_in_layer[VPX_TS_MAX_LAYERS]; 1.681 + 1.682 +#if CONFIG_MULTI_RES_ENCODING 1.683 + /* Number of MBs per row at lower-resolution level */ 1.684 + int mr_low_res_mb_cols; 1.685 + /* Indicate if lower-res mv info is available */ 1.686 + unsigned char mr_low_res_mv_avail; 1.687 + /* The frame number of each reference frames */ 1.688 + unsigned int current_ref_frames[MAX_REF_FRAMES]; 1.689 +#endif 1.690 + 1.691 + struct rd_costs_struct 1.692 + { 1.693 + int mvcosts[2][MVvals+1]; 1.694 + int mvsadcosts[2][MVfpvals+1]; 1.695 + int mbmode_cost[2][MB_MODE_COUNT]; 1.696 + int intra_uv_mode_cost[2][MB_MODE_COUNT]; 1.697 + int bmode_costs[10][10][10]; 1.698 + int inter_bmode_costs[B_MODE_COUNT]; 1.699 + int token_costs[BLOCK_TYPES][COEF_BANDS] 1.700 + [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; 1.701 + } rd_costs; 1.702 +} VP8_COMP; 1.703 + 1.704 +void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, 1.705 + unsigned char *dest_end, unsigned long *size); 1.706 + 1.707 +void vp8_tokenize_mb(VP8_COMP *, MACROBLOCK *, TOKENEXTRA **); 1.708 + 1.709 +void vp8_set_speed_features(VP8_COMP *cpi); 1.710 + 1.711 +#if CONFIG_DEBUG 1.712 +#define CHECK_MEM_ERROR(lval,expr) do {\ 1.713 + lval = (expr); \ 1.714 + if(!lval) \ 1.715 + vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ 1.716 + "Failed to allocate "#lval" at %s:%d", \ 1.717 + __FILE__,__LINE__);\ 1.718 + } while(0) 1.719 +#else 1.720 +#define CHECK_MEM_ERROR(lval,expr) do {\ 1.721 + lval = (expr); \ 1.722 + if(!lval) \ 1.723 + vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ 1.724 + "Failed to allocate "#lval);\ 1.725 + } while(0) 1.726 +#endif 1.727 +#endif