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 */ 10 11 #ifndef VPX_VP8_ENCODER_ONYX_INT_H_ 12 #define VPX_VP8_ENCODER_ONYX_INT_H_ 13 14 #include <assert.h> 15 #include <stdio.h> 16 17 #include "vpx_config.h" 18 #include "vp8/common/onyx.h" 19 #include "treewriter.h" 20 #include "tokenize.h" 21 #include "vp8/common/onyxc_int.h" 22 #include "vpx_dsp/variance.h" 23 #include "vpx_util/vpx_pthread.h" 24 #include "encodemb.h" 25 #include "vp8/encoder/quantize.h" 26 #include "vp8/common/entropy.h" 27 #include "vp8/common/threading.h" 28 #include "vpx_ports/mem.h" 29 #include "vpx/internal/vpx_codec_internal.h" 30 #include "vpx/vp8.h" 31 #include "mcomp.h" 32 #include "vp8/common/findnearmv.h" 33 #include "lookahead.h" 34 #if CONFIG_TEMPORAL_DENOISING 35 #include "vp8/encoder/denoising.h" 36 #endif 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define MIN_GF_INTERVAL 4 43 #define DEFAULT_GF_INTERVAL 7 44 45 #define KEY_FRAME_CONTEXT 5 46 47 #define MAX_LAG_BUFFERS (CONFIG_REALTIME_ONLY ? 1 : 25) 48 49 #define AF_THRESH 25 50 #define AF_THRESH2 100 51 #define ARF_DECAY_THRESH 12 52 53 #define MIN_THRESHMULT 32 54 #define MAX_THRESHMULT 512 55 56 #define GF_ZEROMV_ZBIN_BOOST 12 57 #define LF_ZEROMV_ZBIN_BOOST 6 58 #define MV_ZBIN_BOOST 4 59 #define ZBIN_OQ_MAX 192 60 61 #define VP8_TEMPORAL_ALT_REF !CONFIG_REALTIME_ONLY 62 63 /* vp8 uses 10,000,000 ticks/second as time stamp */ 64 #define TICKS_PER_SEC 10000000 65 66 typedef struct { 67 int kf_indicated; 68 unsigned int frames_since_key; 69 unsigned int frames_since_golden; 70 int filter_level; 71 int frames_till_gf_update_due; 72 int recent_ref_frame_usage[MAX_REF_FRAMES]; 73 74 MV_CONTEXT mvc[2]; 75 int mvcosts[2][MVvals + 1]; 76 77 #ifdef MODE_STATS 78 int y_modes[5]; 79 int uv_modes[4]; 80 int b_modes[10]; 81 int inter_y_modes[10]; 82 int inter_uv_modes[4]; 83 int inter_b_modes[10]; 84 #endif 85 86 vp8_prob ymode_prob[4], uv_mode_prob[3]; /* interframe intra mode probs */ 87 vp8_prob kf_ymode_prob[4], kf_uv_mode_prob[3]; /* keyframe "" */ 88 89 int ymode_count[5], uv_mode_count[4]; /* intra MB type cts this frame */ 90 91 int count_mb_ref_frame_usage[MAX_REF_FRAMES]; 92 93 int this_frame_percent_intra; 94 int last_frame_percent_intra; 95 96 } CODING_CONTEXT; 97 98 typedef struct { 99 double frame; 100 double intra_error; 101 double coded_error; 102 double ssim_weighted_pred_err; 103 double pcnt_inter; 104 double pcnt_motion; 105 double pcnt_second_ref; 106 double pcnt_neutral; 107 double MVr; 108 double mvr_abs; 109 double MVc; 110 double mvc_abs; 111 double MVrv; 112 double MVcv; 113 double mv_in_out_count; 114 double new_mv_count; 115 double duration; 116 double count; 117 } FIRSTPASS_STATS; 118 119 typedef struct { 120 int frames_so_far; 121 double frame_intra_error; 122 double frame_coded_error; 123 double frame_pcnt_inter; 124 double frame_pcnt_motion; 125 double frame_mvr; 126 double frame_mvr_abs; 127 double frame_mvc; 128 double frame_mvc_abs; 129 130 } ONEPASS_FRAMESTATS; 131 132 typedef enum { 133 THR_ZERO1 = 0, 134 THR_DC = 1, 135 136 THR_NEAREST1 = 2, 137 THR_NEAR1 = 3, 138 139 THR_ZERO2 = 4, 140 THR_NEAREST2 = 5, 141 142 THR_ZERO3 = 6, 143 THR_NEAREST3 = 7, 144 145 THR_NEAR2 = 8, 146 THR_NEAR3 = 9, 147 148 THR_V_PRED = 10, 149 THR_H_PRED = 11, 150 THR_TM = 12, 151 152 THR_NEW1 = 13, 153 THR_NEW2 = 14, 154 THR_NEW3 = 15, 155 156 THR_SPLIT1 = 16, 157 THR_SPLIT2 = 17, 158 THR_SPLIT3 = 18, 159 160 THR_B_PRED = 19 161 } THR_MODES; 162 163 typedef enum { DIAMOND = 0, NSTEP = 1, HEX = 2 } SEARCH_METHODS; 164 165 typedef struct { 166 int RD; 167 SEARCH_METHODS search_method; 168 int improved_quant; 169 int improved_dct; 170 int auto_filter; 171 int recode_loop; 172 int iterative_sub_pixel; 173 int half_pixel_search; 174 int quarter_pixel_search; 175 int thresh_mult[MAX_MODES]; 176 int max_step_search_steps; 177 int first_step; 178 int optimize_coefficients; 179 180 int use_fastquant_for_pick; 181 int no_skip_block4x4_search; 182 int improved_mv_pred; 183 184 } SPEED_FEATURES; 185 186 typedef struct { 187 MACROBLOCK mb; 188 int segment_counts[MAX_MB_SEGMENTS]; 189 int totalrate; 190 } MB_ROW_COMP; 191 192 typedef struct { 193 TOKENEXTRA *start; 194 TOKENEXTRA *stop; 195 } TOKENLIST; 196 197 typedef struct { 198 int ithread; 199 void *ptr1; 200 void *ptr2; 201 } ENCODETHREAD_DATA; 202 typedef struct { 203 int ithread; 204 void *ptr1; 205 } LPFTHREAD_DATA; 206 207 enum { 208 BLOCK_16X8, 209 BLOCK_8X16, 210 BLOCK_8X8, 211 BLOCK_4X4, 212 BLOCK_16X16, 213 BLOCK_MAX_SEGMENTS 214 }; 215 216 typedef struct { 217 /* Layer configuration */ 218 double framerate; 219 int target_bandwidth; /* bits per second */ 220 221 /* Layer specific coding parameters */ 222 int64_t starting_buffer_level; 223 int64_t optimal_buffer_level; 224 int64_t maximum_buffer_size; 225 int64_t starting_buffer_level_in_ms; 226 int64_t optimal_buffer_level_in_ms; 227 int64_t maximum_buffer_size_in_ms; 228 229 int avg_frame_size_for_layer; 230 231 int64_t buffer_level; 232 int64_t bits_off_target; 233 234 int64_t total_actual_bits; 235 int64_t total_target_vs_actual; 236 237 int worst_quality; 238 int active_worst_quality; 239 int best_quality; 240 int active_best_quality; 241 242 int ni_av_qi; 243 int ni_tot_qi; 244 int ni_frames; 245 int avg_frame_qindex; 246 247 double rate_correction_factor; 248 double key_frame_rate_correction_factor; 249 double gf_rate_correction_factor; 250 251 int zbin_over_quant; 252 253 int inter_frame_target; 254 int64_t total_byte_count; 255 256 int filter_level; 257 258 int frames_since_last_drop_overshoot; 259 260 int force_maxqp; 261 262 int last_frame_percent_intra; 263 264 int count_mb_ref_frame_usage[MAX_REF_FRAMES]; 265 266 int last_q[2]; 267 } LAYER_CONTEXT; 268 269 typedef struct VP8_COMP { 270 DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]); 271 DECLARE_ALIGNED(16, short, Y1quant_shift[QINDEX_RANGE][16]); 272 DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]); 273 DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]); 274 275 DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]); 276 DECLARE_ALIGNED(16, short, Y2quant_shift[QINDEX_RANGE][16]); 277 DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]); 278 DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]); 279 280 DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]); 281 DECLARE_ALIGNED(16, short, UVquant_shift[QINDEX_RANGE][16]); 282 DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]); 283 DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]); 284 285 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]); 286 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]); 287 DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]); 288 DECLARE_ALIGNED(16, short, Y1quant_fast[QINDEX_RANGE][16]); 289 DECLARE_ALIGNED(16, short, Y2quant_fast[QINDEX_RANGE][16]); 290 DECLARE_ALIGNED(16, short, UVquant_fast[QINDEX_RANGE][16]); 291 292 MACROBLOCK mb; 293 VP8_COMMON common; 294 vp8_writer bc[9]; /* one boolcoder for each partition */ 295 296 VP8_CONFIG oxcf; 297 298 struct lookahead_ctx *lookahead; 299 struct lookahead_entry *source; 300 struct lookahead_entry *alt_ref_source; 301 struct lookahead_entry *last_source; 302 303 YV12_BUFFER_CONFIG *Source; 304 YV12_BUFFER_CONFIG *un_scaled_source; 305 YV12_BUFFER_CONFIG scaled_source; 306 YV12_BUFFER_CONFIG *last_frame_unscaled_source; 307 308 unsigned int frames_till_alt_ref_frame; 309 /* frame in src_buffers has been identified to be encoded as an alt ref */ 310 int source_alt_ref_pending; 311 /* an alt ref frame has been encoded and is usable */ 312 int source_alt_ref_active; 313 /* source of frame to encode is an exact copy of an alt ref frame */ 314 int is_src_frame_alt_ref; 315 316 /* golden frame same as last frame ( short circuit gold searches) */ 317 int gold_is_last; 318 /* Alt reference frame same as last ( short circuit altref search) */ 319 int alt_is_last; 320 /* don't do both alt and gold search ( just do gold). */ 321 int gold_is_alt; 322 323 YV12_BUFFER_CONFIG pick_lf_lvl_frame; 324 325 TOKENEXTRA *tok; 326 unsigned int tok_count; 327 328 unsigned int frames_since_key; 329 unsigned int key_frame_frequency; 330 unsigned int this_key_frame_forced; 331 unsigned int next_key_frame_forced; 332 333 /* Ambient reconstruction err target for force key frames */ 334 int ambient_err; 335 336 unsigned int mode_check_freq[MAX_MODES]; 337 338 int rd_baseline_thresh[MAX_MODES]; 339 340 int RDMULT; 341 int RDDIV; 342 343 CODING_CONTEXT coding_context; 344 345 /* Rate targeting variables */ 346 int64_t last_prediction_error; 347 int64_t last_intra_error; 348 349 int this_frame_target; 350 int projected_frame_size; 351 int last_q[2]; /* Separate values for Intra/Inter */ 352 353 double rate_correction_factor; 354 double key_frame_rate_correction_factor; 355 double gf_rate_correction_factor; 356 357 int frames_since_golden; 358 /* Count down till next GF */ 359 int frames_till_gf_update_due; 360 361 /* GF interval chosen when we coded the last GF */ 362 int current_gf_interval; 363 364 /* Total bits overspent because of GF boost (cumulative) */ 365 int gf_overspend_bits; 366 367 /* Used in the few frames following a GF to recover the extra bits 368 * spent in that GF 369 */ 370 int non_gf_bitrate_adjustment; 371 372 /* Extra bits spent on key frames that need to be recovered */ 373 int kf_overspend_bits; 374 375 /* Current number of bit s to try and recover on each inter frame. */ 376 int kf_bitrate_adjustment; 377 int max_gf_interval; 378 int baseline_gf_interval; 379 int active_arnr_frames; 380 381 int64_t key_frame_count; 382 int prior_key_frame_distance[KEY_FRAME_CONTEXT]; 383 /* Current section per frame bandwidth target */ 384 int per_frame_bandwidth; 385 /* Average frame size target for clip */ 386 int av_per_frame_bandwidth; 387 /* Minimum allocation that should be used for any frame */ 388 int min_frame_bandwidth; 389 int inter_frame_target; 390 double output_framerate; 391 int64_t last_time_stamp_seen; 392 int64_t last_end_time_stamp_seen; 393 int64_t first_time_stamp_ever; 394 395 int ni_av_qi; 396 int ni_tot_qi; 397 int ni_frames; 398 int avg_frame_qindex; 399 400 int64_t total_byte_count; 401 402 int buffered_mode; 403 404 double framerate; 405 double ref_framerate; 406 int64_t buffer_level; 407 int64_t bits_off_target; 408 409 int rolling_target_bits; 410 int rolling_actual_bits; 411 412 int long_rolling_target_bits; 413 int long_rolling_actual_bits; 414 415 int64_t total_actual_bits; 416 int64_t total_target_vs_actual; /* debug stats */ 417 418 int worst_quality; 419 int active_worst_quality; 420 int best_quality; 421 int active_best_quality; 422 423 int cq_target_quality; 424 425 int drop_frames_allowed; /* Are we permitted to drop frames? */ 426 int drop_frame; /* Drop this frame? */ 427 #if defined(DROP_UNCODED_FRAMES) 428 int drop_frame_count; 429 #endif 430 431 vp8_prob frame_coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] 432 [ENTROPY_NODES]; 433 char update_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; 434 435 unsigned int frame_branch_ct[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] 436 [ENTROPY_NODES][2]; 437 438 int gfu_boost; 439 int kf_boost; 440 int last_boost; 441 442 int target_bandwidth; /* bits per second */ 443 struct vpx_codec_pkt_list *output_pkt_list; 444 445 #if 0 446 /* Experimental code for lagged and one pass */ 447 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS]; 448 int one_pass_frame_index; 449 #endif 450 451 int decimation_factor; 452 int decimation_count; 453 454 /* for real time encoding */ 455 int avg_encode_time; /* microsecond */ 456 int avg_pick_mode_time; /* microsecond */ 457 int Speed; 458 int compressor_speed; 459 460 int auto_gold; 461 int auto_adjust_gold_quantizer; 462 int auto_worst_q; 463 int cpu_used; 464 int pass; 465 466 int prob_intra_coded; 467 int prob_last_coded; 468 int prob_gf_coded; 469 int prob_skip_false; 470 int last_skip_false_probs[3]; 471 int last_skip_probs_q[3]; 472 int recent_ref_frame_usage[MAX_REF_FRAMES]; 473 474 int this_frame_percent_intra; 475 int last_frame_percent_intra; 476 477 int ref_frame_flags; 478 479 SPEED_FEATURES sf; 480 481 /* Count ZEROMV on all reference frames. */ 482 int zeromv_count; 483 int lf_zeromv_pct; 484 485 unsigned char *skin_map; 486 487 unsigned char *segmentation_map; 488 signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; 489 unsigned int segment_encode_breakout[MAX_MB_SEGMENTS]; 490 491 unsigned char *active_map; 492 unsigned int active_map_enabled; 493 494 /* Video conferencing cyclic refresh mode flags. This is a mode 495 * designed to clean up the background over time in live encoding 496 * scenarious. It uses segmentation. 497 */ 498 int cyclic_refresh_mode_enabled; 499 int cyclic_refresh_mode_max_mbs_perframe; 500 int cyclic_refresh_mode_index; 501 int cyclic_refresh_q; 502 signed char *cyclic_refresh_map; 503 // Count on how many (consecutive) times a macroblock uses ZER0MV_LAST. 504 unsigned char *consec_zero_last; 505 // Counter that is reset when a block is checked for a mode-bias against 506 // ZEROMV_LASTREF. 507 unsigned char *consec_zero_last_mvbias; 508 509 // Frame counter for the temporal pattern. Counter is rest when the temporal 510 // layers are changed dynamically (run-time change). 511 unsigned int temporal_pattern_counter; 512 // Temporal layer id. 513 int temporal_layer_id; 514 515 // Measure of average squared difference between source and denoised signal. 516 int mse_source_denoised; 517 518 int force_maxqp; 519 int frames_since_last_drop_overshoot; 520 int last_pred_err_mb; 521 522 // GF update for 1 pass cbr. 523 int gf_update_onepass_cbr; 524 int gf_interval_onepass_cbr; 525 int gf_noboost_onepass_cbr; 526 527 #if CONFIG_MULTITHREAD 528 /* multithread data */ 529 vpx_atomic_int *mt_current_mb_col; 530 int mt_current_mb_col_size; 531 int mt_sync_range; 532 vpx_atomic_int b_multi_threaded; 533 int encoding_thread_count; 534 int b_lpf_running; 535 536 pthread_t *h_encoding_thread; 537 pthread_t h_filter_thread; 538 539 MB_ROW_COMP *mb_row_ei; 540 ENCODETHREAD_DATA *en_thread_data; 541 LPFTHREAD_DATA lpf_thread_data; 542 543 /* events */ 544 vp8_sem_t *h_event_start_encoding; 545 vp8_sem_t *h_event_end_encoding; 546 vp8_sem_t h_event_start_lpf; 547 vp8_sem_t h_event_end_lpf; 548 #endif 549 550 TOKENLIST *tplist; 551 unsigned int partition_sz[MAX_PARTITIONS]; 552 unsigned char *partition_d[MAX_PARTITIONS]; 553 unsigned char *partition_d_end[MAX_PARTITIONS]; 554 555 fractional_mv_step_fp *find_fractional_mv_step; 556 vp8_refining_search_fn_t refining_search_sad; 557 vp8_diamond_search_fn_t diamond_search_sad; 558 vp8_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SEGMENTS]; 559 uint64_t time_receive_data; 560 uint64_t time_compress_data; 561 uint64_t time_pick_lpf; 562 uint64_t time_encode_mb_row; 563 564 int base_skip_false_prob[128]; 565 566 FRAME_CONTEXT lfc_n; /* last frame entropy */ 567 FRAME_CONTEXT lfc_a; /* last alt ref entropy */ 568 FRAME_CONTEXT lfc_g; /* last gold ref entropy */ 569 570 struct twopass_rc { 571 unsigned int section_intra_rating; 572 double section_max_qfactor; 573 unsigned int next_iiratio; 574 unsigned int this_iiratio; 575 FIRSTPASS_STATS total_stats; 576 FIRSTPASS_STATS this_frame_stats; 577 FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start; 578 FIRSTPASS_STATS total_left_stats; 579 int first_pass_done; 580 int64_t bits_left; 581 int64_t clip_bits_total; 582 double avg_iiratio; 583 double modified_error_total; 584 double modified_error_used; 585 double modified_error_left; 586 double kf_intra_err_min; 587 double gf_intra_err_min; 588 int frames_to_key; 589 int maxq_max_limit; 590 int maxq_min_limit; 591 int gf_decay_rate; 592 int static_scene_max_gf_interval; 593 int kf_bits; 594 /* Remaining error from uncoded frames in a gf group. */ 595 int gf_group_error_left; 596 /* Projected total bits available for a key frame group of frames */ 597 int64_t kf_group_bits; 598 /* Error score of frames still to be coded in kf group */ 599 int64_t kf_group_error_left; 600 /* Projected Bits available for a group including 1 GF or ARF */ 601 int64_t gf_group_bits; 602 /* Bits for the golden frame or ARF */ 603 int gf_bits; 604 int alt_extra_bits; 605 double est_max_qcorrection_factor; 606 } twopass; 607 608 #if VP8_TEMPORAL_ALT_REF 609 YV12_BUFFER_CONFIG alt_ref_buffer; 610 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; 611 int fixed_divide[512]; 612 #endif 613 614 #if CONFIG_INTERNAL_STATS 615 int count; 616 double total_y; 617 double total_u; 618 double total_v; 619 double total; 620 double total_sq_error; 621 double totalp_y; 622 double totalp_u; 623 double totalp_v; 624 double totalp; 625 double total_sq_error2; 626 uint64_t bytes; 627 double summed_quality; 628 double summed_weights; 629 unsigned int tot_recode_hits; 630 631 int b_calculate_ssimg; 632 #endif 633 int b_calculate_psnr; 634 635 /* Per MB activity measurement */ 636 unsigned int activity_avg; 637 unsigned int *mb_activity_map; 638 639 /* Record of which MBs still refer to last golden frame either 640 * directly or through 0,0 641 */ 642 unsigned char *gf_active_flags; 643 int gf_active_count; 644 645 int output_partition; 646 647 /* Store last frame's MV info for next frame MV prediction */ 648 int_mv *lfmv; 649 int *lf_ref_frame_sign_bias; 650 int *lf_ref_frame; 651 652 /* force next frame to intra when kf_auto says so */ 653 int force_next_frame_intra; 654 655 int droppable; 656 657 int initial_width; 658 int initial_height; 659 660 #if CONFIG_TEMPORAL_DENOISING 661 VP8_DENOISER denoiser; 662 #endif 663 664 /* Coding layer state variables */ 665 unsigned int current_layer; 666 LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS]; 667 668 int64_t frames_in_layer[VPX_TS_MAX_LAYERS]; 669 int64_t bytes_in_layer[VPX_TS_MAX_LAYERS]; 670 double sum_psnr[VPX_TS_MAX_LAYERS]; 671 double sum_psnr_p[VPX_TS_MAX_LAYERS]; 672 double total_error2[VPX_TS_MAX_LAYERS]; 673 double total_error2_p[VPX_TS_MAX_LAYERS]; 674 double sum_ssim[VPX_TS_MAX_LAYERS]; 675 double sum_weights[VPX_TS_MAX_LAYERS]; 676 677 double total_ssimg_y_in_layer[VPX_TS_MAX_LAYERS]; 678 double total_ssimg_u_in_layer[VPX_TS_MAX_LAYERS]; 679 double total_ssimg_v_in_layer[VPX_TS_MAX_LAYERS]; 680 double total_ssimg_all_in_layer[VPX_TS_MAX_LAYERS]; 681 682 #if CONFIG_MULTI_RES_ENCODING 683 /* Number of MBs per row at lower-resolution level */ 684 int mr_low_res_mb_cols; 685 /* Indicate if lower-res mv info is available */ 686 unsigned char mr_low_res_mv_avail; 687 #endif 688 /* The frame number of each reference frames */ 689 unsigned int current_ref_frames[MAX_REF_FRAMES]; 690 // Closest reference frame to current frame. 691 MV_REFERENCE_FRAME closest_reference_frame; 692 693 struct rd_costs_struct { 694 int mvcosts[2][MVvals + 1]; 695 int mvsadcosts[2][MVfpvals + 1]; 696 int mbmode_cost[2][MB_MODE_COUNT]; 697 int intra_uv_mode_cost[2][MB_MODE_COUNT]; 698 int bmode_costs[10][10][10]; 699 int inter_bmode_costs[B_MODE_COUNT]; 700 int token_costs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] 701 [MAX_ENTROPY_TOKENS]; 702 } rd_costs; 703 704 // Use the static threshold from ROI settings. 705 int use_roi_static_threshold; 706 707 int ext_refresh_frame_flags_pending; 708 709 // Always update correction factor used for rate control after each frame for 710 // realtime encoding. 711 int rt_always_update_correction_factor; 712 713 // Flag to indicate frame may be dropped due to large expected overshoot, 714 // and re-encoded on next frame at max_qp. 715 int rt_drop_recode_on_overshoot; 716 } VP8_COMP; 717 718 void vp8_initialize_enc(void); 719 720 void vp8_alloc_compressor_data(VP8_COMP *cpi); 721 int vp8_reverse_trans(int x); 722 void vp8_reset_temporal_layer_change(VP8_COMP *cpi, const VP8_CONFIG *oxcf, 723 const int prev_num_layers); 724 void vp8_init_temporal_layer_context(VP8_COMP *cpi, const VP8_CONFIG *oxcf, 725 const int layer, 726 double prev_layer_framerate); 727 void vp8_update_layer_contexts(VP8_COMP *cpi); 728 void vp8_save_layer_context(VP8_COMP *cpi); 729 void vp8_restore_layer_context(VP8_COMP *cpi, const int layer); 730 void vp8_new_framerate(VP8_COMP *cpi, double framerate); 731 void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm); 732 733 void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, 734 unsigned char *dest_end, size_t *size); 735 736 void vp8_tokenize_mb(VP8_COMP *, MACROBLOCK *, TOKENEXTRA **); 737 738 void vp8_set_speed_features(VP8_COMP *cpi); 739 740 int vp8_check_drop_buffer(VP8_COMP *cpi); 741 742 #ifdef __cplusplus 743 } // extern "C" 744 #endif 745 746 #endif // VPX_VP8_ENCODER_ONYX_INT_H_ 747