OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 #define MIN_GF_INTERVAL 4 | 36 #define MIN_GF_INTERVAL 4 |
37 #define DEFAULT_GF_INTERVAL 7 | 37 #define DEFAULT_GF_INTERVAL 7 |
38 | 38 |
39 #define KEY_FRAME_CONTEXT 5 | 39 #define KEY_FRAME_CONTEXT 5 |
40 | 40 |
41 #define MAX_LAG_BUFFERS (CONFIG_REALTIME_ONLY? 1 : 25) | 41 #define MAX_LAG_BUFFERS (CONFIG_REALTIME_ONLY? 1 : 25) |
42 | 42 |
43 #define AF_THRESH 25 | 43 #define AF_THRESH 25 |
44 #define AF_THRESH2 100 | 44 #define AF_THRESH2 100 |
45 #define ARF_DECAY_THRESH 12 | 45 #define ARF_DECAY_THRESH 12 |
46 #define MAX_MODES 20 | 46 |
47 | 47 |
48 #define MIN_THRESHMULT 32 | 48 #define MIN_THRESHMULT 32 |
49 #define MAX_THRESHMULT 512 | 49 #define MAX_THRESHMULT 512 |
50 | 50 |
51 #define GF_ZEROMV_ZBIN_BOOST 12 | 51 #define GF_ZEROMV_ZBIN_BOOST 12 |
52 #define LF_ZEROMV_ZBIN_BOOST 6 | 52 #define LF_ZEROMV_ZBIN_BOOST 6 |
53 #define MV_ZBIN_BOOST 4 | 53 #define MV_ZBIN_BOOST 4 |
54 #define ZBIN_OQ_MAX 192 | 54 #define ZBIN_OQ_MAX 192 |
55 | 55 |
56 #if !(CONFIG_REALTIME_ONLY) | 56 #if !(CONFIG_REALTIME_ONLY) |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 unsigned int frames_since_key; | 343 unsigned int frames_since_key; |
344 unsigned int key_frame_frequency; | 344 unsigned int key_frame_frequency; |
345 unsigned int this_key_frame_forced; | 345 unsigned int this_key_frame_forced; |
346 unsigned int next_key_frame_forced; | 346 unsigned int next_key_frame_forced; |
347 | 347 |
348 /* Ambient reconstruction err target for force key frames */ | 348 /* Ambient reconstruction err target for force key frames */ |
349 int ambient_err; | 349 int ambient_err; |
350 | 350 |
351 unsigned int mode_check_freq[MAX_MODES]; | 351 unsigned int mode_check_freq[MAX_MODES]; |
352 unsigned int mode_test_hit_counts[MAX_MODES]; | |
353 unsigned int mode_chosen_counts[MAX_MODES]; | 352 unsigned int mode_chosen_counts[MAX_MODES]; |
354 unsigned int mbs_tested_so_far; | |
355 | 353 |
356 int rd_thresh_mult[MAX_MODES]; | |
357 int rd_baseline_thresh[MAX_MODES]; | 354 int rd_baseline_thresh[MAX_MODES]; |
358 int rd_threshes[MAX_MODES]; | |
359 | 355 |
360 int RDMULT; | 356 int RDMULT; |
361 int RDDIV ; | 357 int RDDIV ; |
362 | 358 |
363 CODING_CONTEXT coding_context; | 359 CODING_CONTEXT coding_context; |
364 | 360 |
365 /* Rate targetting variables */ | 361 /* Rate targetting variables */ |
366 int64_t prediction_error; | |
367 int64_t last_prediction_error; | 362 int64_t last_prediction_error; |
368 int64_t intra_error; | |
369 int64_t last_intra_error; | 363 int64_t last_intra_error; |
370 | 364 |
371 int this_frame_target; | 365 int this_frame_target; |
372 int projected_frame_size; | 366 int projected_frame_size; |
373 int last_q[2]; /* Separate values for Intra/Inter */ | 367 int last_q[2]; /* Separate values for Intra/Inter */ |
374 | 368 |
375 double rate_correction_factor; | 369 double rate_correction_factor; |
376 double key_frame_rate_correction_factor; | 370 double key_frame_rate_correction_factor; |
377 double gf_rate_correction_factor; | 371 double gf_rate_correction_factor; |
378 | 372 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 double output_frame_rate; | 405 double output_frame_rate; |
412 int64_t last_time_stamp_seen; | 406 int64_t last_time_stamp_seen; |
413 int64_t last_end_time_stamp_seen; | 407 int64_t last_end_time_stamp_seen; |
414 int64_t first_time_stamp_ever; | 408 int64_t first_time_stamp_ever; |
415 | 409 |
416 int ni_av_qi; | 410 int ni_av_qi; |
417 int ni_tot_qi; | 411 int ni_tot_qi; |
418 int ni_frames; | 412 int ni_frames; |
419 int avg_frame_qindex; | 413 int avg_frame_qindex; |
420 | 414 |
421 int zbin_over_quant; | |
422 int zbin_mode_boost; | |
423 int zbin_mode_boost_enabled; | |
424 int last_zbin_over_quant; | |
425 int last_zbin_mode_boost; | |
426 | |
427 int64_t total_byte_count; | 415 int64_t total_byte_count; |
428 | 416 |
429 int buffered_mode; | 417 int buffered_mode; |
430 | 418 |
431 double frame_rate; | 419 double frame_rate; |
432 double ref_frame_rate; | 420 double ref_frame_rate; |
433 int64_t buffer_level; | 421 int64_t buffer_level; |
434 int64_t bits_off_target; | 422 int64_t bits_off_target; |
435 | 423 |
436 int rolling_target_bits; | 424 int rolling_target_bits; |
437 int rolling_actual_bits; | 425 int rolling_actual_bits; |
438 | 426 |
439 int long_rolling_target_bits; | 427 int long_rolling_target_bits; |
440 int long_rolling_actual_bits; | 428 int long_rolling_actual_bits; |
441 | 429 |
442 int64_t total_actual_bits; | 430 int64_t total_actual_bits; |
443 int total_target_vs_actual; /* debug stats */ | 431 int total_target_vs_actual; /* debug stats */ |
444 | 432 |
445 int worst_quality; | 433 int worst_quality; |
446 int active_worst_quality; | 434 int active_worst_quality; |
447 int best_quality; | 435 int best_quality; |
448 int active_best_quality; | 436 int active_best_quality; |
449 | 437 |
450 int cq_target_quality; | 438 int cq_target_quality; |
451 | 439 |
452 int drop_frames_allowed; /* Are we permitted to drop frames? */ | 440 int drop_frames_allowed; /* Are we permitted to drop frames? */ |
453 int drop_frame; /* Drop this frame? */ | 441 int drop_frame; /* Drop this frame? */ |
454 | 442 |
455 int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */ | |
456 int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */ | |
457 | |
458 unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */ | |
459 | |
460 unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MA
X_ENTROPY_TOKENS]; /* for this frame */ | |
461 | |
462 vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [E
NTROPY_NODES]; | 443 vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [E
NTROPY_NODES]; |
463 char update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_N
ODES]; | 444 char update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_N
ODES]; |
464 | 445 |
465 unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS]
[ENTROPY_NODES][2]; | 446 unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS]
[ENTROPY_NODES][2]; |
466 | 447 |
467 int gfu_boost; | 448 int gfu_boost; |
468 int kf_boost; | 449 int kf_boost; |
469 int last_boost; | 450 int last_boost; |
470 | 451 |
471 int target_bandwidth; | 452 int target_bandwidth; |
472 struct vpx_codec_pkt_list *output_pkt_list; | 453 struct vpx_codec_pkt_list *output_pkt_list; |
473 | 454 |
474 #if 0 | 455 #if 0 |
475 /* Experimental code for lagged and one pass */ | 456 /* Experimental code for lagged and one pass */ |
476 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS]; | 457 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS]; |
477 int one_pass_frame_index; | 458 int one_pass_frame_index; |
478 #endif | 459 #endif |
479 | 460 |
480 int decimation_factor; | 461 int decimation_factor; |
481 int decimation_count; | 462 int decimation_count; |
482 | 463 |
483 /* for real time encoding */ | 464 /* for real time encoding */ |
484 int avg_encode_time; /* microsecond */ | 465 int avg_encode_time; /* microsecond */ |
485 int avg_pick_mode_time; /* microsecond */ | 466 int avg_pick_mode_time; /* microsecond */ |
486 int Speed; | 467 int Speed; |
487 int compressor_speed; | 468 int compressor_speed; |
488 | 469 |
489 int interquantizer; | |
490 int auto_gold; | 470 int auto_gold; |
491 int auto_adjust_gold_quantizer; | 471 int auto_adjust_gold_quantizer; |
492 int auto_worst_q; | 472 int auto_worst_q; |
493 int cpu_used; | 473 int cpu_used; |
494 int pass; | 474 int pass; |
495 | 475 |
496 | 476 |
497 int prob_intra_coded; | 477 int prob_intra_coded; |
498 int prob_last_coded; | 478 int prob_last_coded; |
499 int prob_gf_coded; | 479 int prob_gf_coded; |
500 int prob_skip_false; | 480 int prob_skip_false; |
501 int last_skip_false_probs[3]; | 481 int last_skip_false_probs[3]; |
502 int last_skip_probs_q[3]; | 482 int last_skip_probs_q[3]; |
503 int recent_ref_frame_usage[MAX_REF_FRAMES]; | 483 int recent_ref_frame_usage[MAX_REF_FRAMES]; |
504 | 484 |
505 int count_mb_ref_frame_usage[MAX_REF_FRAMES]; | |
506 int this_frame_percent_intra; | 485 int this_frame_percent_intra; |
507 int last_frame_percent_intra; | 486 int last_frame_percent_intra; |
508 | 487 |
509 int ref_frame_flags; | 488 int ref_frame_flags; |
510 | 489 |
511 SPEED_FEATURES sf; | 490 SPEED_FEATURES sf; |
512 int error_bins[1024]; | |
513 | 491 |
514 /* Data used for real time conferencing mode to help determine if it | |
515 * would be good to update the gf | |
516 */ | |
517 int inter_zz_count; | |
518 /* Count ZEROMV on all reference frames. */ | 492 /* Count ZEROMV on all reference frames. */ |
519 int zeromv_count; | 493 int zeromv_count; |
520 int lf_zeromv_pct; | 494 int lf_zeromv_pct; |
521 int gf_bad_count; | |
522 int gf_update_recommended; | |
523 int skip_true_count; | |
524 | 495 |
525 unsigned char *segmentation_map; | 496 unsigned char *segmentation_map; |
526 signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; | 497 signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; |
527 int segment_encode_breakout[MAX_MB_SEGMENTS]; | 498 int segment_encode_breakout[MAX_MB_SEGMENTS]; |
528 | 499 |
529 unsigned char *active_map; | 500 unsigned char *active_map; |
530 unsigned int active_map_enabled; | 501 unsigned int active_map_enabled; |
531 | 502 |
532 /* Video conferencing cyclic refresh mode flags. This is a mode | 503 /* Video conferencing cyclic refresh mode flags. This is a mode |
533 * designed to clean up the background over time in live encoding | 504 * designed to clean up the background over time in live encoding |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 double total_ssimg_v; | 623 double total_ssimg_v; |
653 double total_ssimg_all; | 624 double total_ssimg_all; |
654 | 625 |
655 int b_calculate_ssimg; | 626 int b_calculate_ssimg; |
656 #endif | 627 #endif |
657 int b_calculate_psnr; | 628 int b_calculate_psnr; |
658 | 629 |
659 /* Per MB activity measurement */ | 630 /* Per MB activity measurement */ |
660 unsigned int activity_avg; | 631 unsigned int activity_avg; |
661 unsigned int * mb_activity_map; | 632 unsigned int * mb_activity_map; |
662 int * mb_norm_activity_map; | |
663 | 633 |
664 /* Record of which MBs still refer to last golden frame either | 634 /* Record of which MBs still refer to last golden frame either |
665 * directly or through 0,0 | 635 * directly or through 0,0 |
666 */ | 636 */ |
667 unsigned char *gf_active_flags; | 637 unsigned char *gf_active_flags; |
668 int gf_active_count; | 638 int gf_active_count; |
669 | 639 |
670 int output_partition; | 640 int output_partition; |
671 | 641 |
672 /* Store last frame's MV info for next frame MV prediction */ | 642 /* Store last frame's MV info for next frame MV prediction */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 int mvsadcosts[2][MVfpvals+1]; | 686 int mvsadcosts[2][MVfpvals+1]; |
717 int mbmode_cost[2][MB_MODE_COUNT]; | 687 int mbmode_cost[2][MB_MODE_COUNT]; |
718 int intra_uv_mode_cost[2][MB_MODE_COUNT]; | 688 int intra_uv_mode_cost[2][MB_MODE_COUNT]; |
719 int bmode_costs[10][10][10]; | 689 int bmode_costs[10][10][10]; |
720 int inter_bmode_costs[B_MODE_COUNT]; | 690 int inter_bmode_costs[B_MODE_COUNT]; |
721 int token_costs[BLOCK_TYPES][COEF_BANDS] | 691 int token_costs[BLOCK_TYPES][COEF_BANDS] |
722 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; | 692 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; |
723 } rd_costs; | 693 } rd_costs; |
724 } VP8_COMP; | 694 } VP8_COMP; |
725 | 695 |
726 void control_data_rate(VP8_COMP *cpi); | 696 void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, |
| 697 unsigned char *dest_end, unsigned long *size); |
727 | 698 |
728 void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned char *dest_
end, unsigned long *size); | 699 void vp8_tokenize_mb(VP8_COMP *, MACROBLOCK *, TOKENEXTRA **); |
729 | |
730 int rd_cost_intra_mb(MACROBLOCKD *x); | |
731 | |
732 void vp8_tokenize_mb(VP8_COMP *, MACROBLOCKD *, TOKENEXTRA **); | |
733 | 700 |
734 void vp8_set_speed_features(VP8_COMP *cpi); | 701 void vp8_set_speed_features(VP8_COMP *cpi); |
735 | 702 |
736 #if CONFIG_DEBUG | 703 #if CONFIG_DEBUG |
737 #define CHECK_MEM_ERROR(lval,expr) do {\ | 704 #define CHECK_MEM_ERROR(lval,expr) do {\ |
738 lval = (expr); \ | 705 lval = (expr); \ |
739 if(!lval) \ | 706 if(!lval) \ |
740 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ | 707 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ |
741 "Failed to allocate "#lval" at %s:%d", \ | 708 "Failed to allocate "#lval" at %s:%d", \ |
742 __FILE__,__LINE__);\ | 709 __FILE__,__LINE__);\ |
743 } while(0) | 710 } while(0) |
744 #else | 711 #else |
745 #define CHECK_MEM_ERROR(lval,expr) do {\ | 712 #define CHECK_MEM_ERROR(lval,expr) do {\ |
746 lval = (expr); \ | 713 lval = (expr); \ |
747 if(!lval) \ | 714 if(!lval) \ |
748 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ | 715 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\ |
749 "Failed to allocate "#lval);\ | 716 "Failed to allocate "#lval);\ |
750 } while(0) | 717 } while(0) |
751 #endif | 718 #endif |
752 #endif | 719 #endif |
OLD | NEW |