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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 vp8_build_block_offsets(x); | 566 vp8_build_block_offsets(x); |
567 | 567 |
568 /* set up frame new frame for intra coded blocks */ | 568 /* set up frame new frame for intra coded blocks */ |
569 vp8_setup_intra_recon(new_yv12); | 569 vp8_setup_intra_recon(new_yv12); |
570 vp8cx_frame_init_quantizer(cpi); | 570 vp8cx_frame_init_quantizer(cpi); |
571 | 571 |
572 /* Initialise the MV cost table to the defaults */ | 572 /* Initialise the MV cost table to the defaults */ |
573 { | 573 { |
574 int flag[2] = {1, 1}; | 574 int flag[2] = {1, 1}; |
575 vp8_initialize_rd_consts(cpi, x, vp8_dc_quant(cm->base_qindex, cm->y1dc_
delta_q)); | 575 vp8_initialize_rd_consts(cpi, x, vp8_dc_quant(cm->base_qindex, cm->y1dc_
delta_q)); |
576 vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_con
text)); | 576 memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context
)); |
577 vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->
fc.mvc, flag); | 577 vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->
fc.mvc, flag); |
578 } | 578 } |
579 | 579 |
580 /* for each macroblock row in image */ | 580 /* for each macroblock row in image */ |
581 for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) | 581 for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) |
582 { | 582 { |
583 int_mv best_ref_mv; | 583 int_mv best_ref_mv; |
584 | 584 |
585 best_ref_mv.as_int = 0; | 585 best_ref_mv.as_int = 0; |
586 | 586 |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 int b_boost = 0; | 1772 int b_boost = 0; |
1773 int flash_detected; | 1773 int flash_detected; |
1774 | 1774 |
1775 cpi->twopass.gf_group_bits = 0; | 1775 cpi->twopass.gf_group_bits = 0; |
1776 cpi->twopass.gf_decay_rate = 0; | 1776 cpi->twopass.gf_decay_rate = 0; |
1777 | 1777 |
1778 vp8_clear_system_state(); | 1778 vp8_clear_system_state(); |
1779 | 1779 |
1780 start_pos = cpi->twopass.stats_in; | 1780 start_pos = cpi->twopass.stats_in; |
1781 | 1781 |
1782 vpx_memset(&next_frame, 0, sizeof(next_frame)); /* assure clean */ | 1782 memset(&next_frame, 0, sizeof(next_frame)); /* assure clean */ |
1783 | 1783 |
1784 /* Load stats for the current frame. */ | 1784 /* Load stats for the current frame. */ |
1785 mod_frame_err = calculate_modified_err(cpi, this_frame); | 1785 mod_frame_err = calculate_modified_err(cpi, this_frame); |
1786 | 1786 |
1787 /* Note the error of the frame at the start of the group (this will be | 1787 /* Note the error of the frame at the start of the group (this will be |
1788 * the GF frame error if we code a normal gf | 1788 * the GF frame error if we code a normal gf |
1789 */ | 1789 */ |
1790 gf_first_frame_err = mod_frame_err; | 1790 gf_first_frame_err = mod_frame_err; |
1791 | 1791 |
1792 /* Special treatment if the current frame is a key frame (which is also | 1792 /* Special treatment if the current frame is a key frame (which is also |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 ((mv_ratio_accumulator > 100.0) || | 1868 ((mv_ratio_accumulator > 100.0) || |
1869 (abs_mv_in_out_accumulator > 3.0) || | 1869 (abs_mv_in_out_accumulator > 3.0) || |
1870 (mv_in_out_accumulator < -2.0) || | 1870 (mv_in_out_accumulator < -2.0) || |
1871 ((boost_score - old_boost_score) < 2.0)) | 1871 ((boost_score - old_boost_score) < 2.0)) |
1872 ) ) | 1872 ) ) |
1873 { | 1873 { |
1874 boost_score = old_boost_score; | 1874 boost_score = old_boost_score; |
1875 break; | 1875 break; |
1876 } | 1876 } |
1877 | 1877 |
1878 vpx_memcpy(this_frame, &next_frame, sizeof(*this_frame)); | 1878 memcpy(this_frame, &next_frame, sizeof(*this_frame)); |
1879 | 1879 |
1880 old_boost_score = boost_score; | 1880 old_boost_score = boost_score; |
1881 } | 1881 } |
1882 | 1882 |
1883 cpi->twopass.gf_decay_rate = | 1883 cpi->twopass.gf_decay_rate = |
1884 (i > 0) ? (int)(100.0 * (1.0 - decay_accumulator)) / i : 0; | 1884 (i > 0) ? (int)(100.0 * (1.0 - decay_accumulator)) / i : 0; |
1885 | 1885 |
1886 /* When using CBR apply additional buffer related upper limits */ | 1886 /* When using CBR apply additional buffer related upper limits */ |
1887 if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) | 1887 if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) |
1888 { | 1888 { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 if (EOF == input_stats(cpi, &this_frame)) | 2438 if (EOF == input_stats(cpi, &this_frame)) |
2439 return; | 2439 return; |
2440 | 2440 |
2441 this_frame_intra_error = this_frame.intra_error; | 2441 this_frame_intra_error = this_frame.intra_error; |
2442 this_frame_coded_error = this_frame.coded_error; | 2442 this_frame_coded_error = this_frame.coded_error; |
2443 | 2443 |
2444 /* keyframe and section processing ! */ | 2444 /* keyframe and section processing ! */ |
2445 if (cpi->twopass.frames_to_key == 0) | 2445 if (cpi->twopass.frames_to_key == 0) |
2446 { | 2446 { |
2447 /* Define next KF group and assign bits to it */ | 2447 /* Define next KF group and assign bits to it */ |
2448 vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); | 2448 memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); |
2449 find_next_key_frame(cpi, &this_frame_copy); | 2449 find_next_key_frame(cpi, &this_frame_copy); |
2450 | 2450 |
2451 /* Special case: Error error_resilient_mode mode does not make much | 2451 /* Special case: Error error_resilient_mode mode does not make much |
2452 * sense for two pass but with its current meaning this code is | 2452 * sense for two pass but with its current meaning this code is |
2453 * designed to stop outlandish behaviour if someone does set it when | 2453 * designed to stop outlandish behaviour if someone does set it when |
2454 * using two pass. It effectively disables GF groups. This is | 2454 * using two pass. It effectively disables GF groups. This is |
2455 * temporary code until we decide what should really happen in this | 2455 * temporary code until we decide what should really happen in this |
2456 * case. | 2456 * case. |
2457 */ | 2457 */ |
2458 if (cpi->oxcf.error_resilient_mode) | 2458 if (cpi->oxcf.error_resilient_mode) |
2459 { | 2459 { |
2460 cpi->twopass.gf_group_bits = cpi->twopass.kf_group_bits; | 2460 cpi->twopass.gf_group_bits = cpi->twopass.kf_group_bits; |
2461 cpi->twopass.gf_group_error_left = | 2461 cpi->twopass.gf_group_error_left = |
2462 (int)cpi->twopass.kf_group_error_left; | 2462 (int)cpi->twopass.kf_group_error_left; |
2463 cpi->baseline_gf_interval = cpi->twopass.frames_to_key; | 2463 cpi->baseline_gf_interval = cpi->twopass.frames_to_key; |
2464 cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; | 2464 cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; |
2465 cpi->source_alt_ref_pending = 0; | 2465 cpi->source_alt_ref_pending = 0; |
2466 } | 2466 } |
2467 | 2467 |
2468 } | 2468 } |
2469 | 2469 |
2470 /* Is this a GF / ARF (Note that a KF is always also a GF) */ | 2470 /* Is this a GF / ARF (Note that a KF is always also a GF) */ |
2471 if (cpi->frames_till_gf_update_due == 0) | 2471 if (cpi->frames_till_gf_update_due == 0) |
2472 { | 2472 { |
2473 /* Define next gf group and assign bits to it */ | 2473 /* Define next gf group and assign bits to it */ |
2474 vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); | 2474 memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); |
2475 define_gf_group(cpi, &this_frame_copy); | 2475 define_gf_group(cpi, &this_frame_copy); |
2476 | 2476 |
2477 /* If we are going to code an altref frame at the end of the group | 2477 /* If we are going to code an altref frame at the end of the group |
2478 * and the current frame is not a key frame.... If the previous | 2478 * and the current frame is not a key frame.... If the previous |
2479 * group used an arf this frame has already benefited from that arf | 2479 * group used an arf this frame has already benefited from that arf |
2480 * boost and it should not be given extra bits If the previous | 2480 * boost and it should not be given extra bits If the previous |
2481 * group was NOT coded using arf we may want to apply some boost to | 2481 * group was NOT coded using arf we may want to apply some boost to |
2482 * this GF as well | 2482 * this GF as well |
2483 */ | 2483 */ |
2484 if (cpi->source_alt_ref_pending && (cpi->common.frame_type != KEY_FRAME)
) | 2484 if (cpi->source_alt_ref_pending && (cpi->common.frame_type != KEY_FRAME)
) |
2485 { | 2485 { |
2486 /* Assign a standard frames worth of bits from those allocated | 2486 /* Assign a standard frames worth of bits from those allocated |
2487 * to the GF group | 2487 * to the GF group |
2488 */ | 2488 */ |
2489 int bak = cpi->per_frame_bandwidth; | 2489 int bak = cpi->per_frame_bandwidth; |
2490 vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); | 2490 memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); |
2491 assign_std_frame_bits(cpi, &this_frame_copy); | 2491 assign_std_frame_bits(cpi, &this_frame_copy); |
2492 cpi->per_frame_bandwidth = bak; | 2492 cpi->per_frame_bandwidth = bak; |
2493 } | 2493 } |
2494 } | 2494 } |
2495 | 2495 |
2496 /* Otherwise this is an ordinary frame */ | 2496 /* Otherwise this is an ordinary frame */ |
2497 else | 2497 else |
2498 { | 2498 { |
2499 /* Special case: Error error_resilient_mode mode does not make much | 2499 /* Special case: Error error_resilient_mode mode does not make much |
2500 * sense for two pass but with its current meaning but this code is | 2500 * sense for two pass but with its current meaning but this code is |
2501 * designed to stop outlandish behaviour if someone does set it | 2501 * designed to stop outlandish behaviour if someone does set it |
2502 * when using two pass. It effectively disables GF groups. This is | 2502 * when using two pass. It effectively disables GF groups. This is |
2503 * temporary code till we decide what should really happen in this | 2503 * temporary code till we decide what should really happen in this |
2504 * case. | 2504 * case. |
2505 */ | 2505 */ |
2506 if (cpi->oxcf.error_resilient_mode) | 2506 if (cpi->oxcf.error_resilient_mode) |
2507 { | 2507 { |
2508 cpi->frames_till_gf_update_due = cpi->twopass.frames_to_key; | 2508 cpi->frames_till_gf_update_due = cpi->twopass.frames_to_key; |
2509 | 2509 |
2510 if (cpi->common.frame_type != KEY_FRAME) | 2510 if (cpi->common.frame_type != KEY_FRAME) |
2511 { | 2511 { |
2512 /* Assign bits from those allocated to the GF group */ | 2512 /* Assign bits from those allocated to the GF group */ |
2513 vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); | 2513 memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); |
2514 assign_std_frame_bits(cpi, &this_frame_copy); | 2514 assign_std_frame_bits(cpi, &this_frame_copy); |
2515 } | 2515 } |
2516 } | 2516 } |
2517 else | 2517 else |
2518 { | 2518 { |
2519 /* Assign bits from those allocated to the GF group */ | 2519 /* Assign bits from those allocated to the GF group */ |
2520 vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); | 2520 memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); |
2521 assign_std_frame_bits(cpi, &this_frame_copy); | 2521 assign_std_frame_bits(cpi, &this_frame_copy); |
2522 } | 2522 } |
2523 } | 2523 } |
2524 | 2524 |
2525 /* Keep a globally available copy of this and the next frame's iiratio. */ | 2525 /* Keep a globally available copy of this and the next frame's iiratio. */ |
2526 cpi->twopass.this_iiratio = (unsigned int)(this_frame_intra_error / | 2526 cpi->twopass.this_iiratio = (unsigned int)(this_frame_intra_error / |
2527 DOUBLE_DIVIDE_CHECK(this_frame_coded_error)); | 2527 DOUBLE_DIVIDE_CHECK(this_frame_coded_error)); |
2528 { | 2528 { |
2529 FIRSTPASS_STATS next_frame; | 2529 FIRSTPASS_STATS next_frame; |
2530 if ( lookup_next_frame_stats(cpi, &next_frame) != EOF ) | 2530 if ( lookup_next_frame_stats(cpi, &next_frame) != EOF ) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2651 int i; | 2651 int i; |
2652 FIRSTPASS_STATS *start_pos; | 2652 FIRSTPASS_STATS *start_pos; |
2653 | 2653 |
2654 FIRSTPASS_STATS local_next_frame; | 2654 FIRSTPASS_STATS local_next_frame; |
2655 | 2655 |
2656 double boost_score = 0.0; | 2656 double boost_score = 0.0; |
2657 double old_boost_score = 0.0; | 2657 double old_boost_score = 0.0; |
2658 double decay_accumulator = 1.0; | 2658 double decay_accumulator = 1.0; |
2659 double next_iiratio; | 2659 double next_iiratio; |
2660 | 2660 |
2661 vpx_memcpy(&local_next_frame, next_frame, sizeof(*next_frame)); | 2661 memcpy(&local_next_frame, next_frame, sizeof(*next_frame)); |
2662 | 2662 |
2663 /* Note the starting file position so we can reset to it */ | 2663 /* Note the starting file position so we can reset to it */ |
2664 start_pos = cpi->twopass.stats_in; | 2664 start_pos = cpi->twopass.stats_in; |
2665 | 2665 |
2666 /* Examine how well the key frame predicts subsequent frames */ | 2666 /* Examine how well the key frame predicts subsequent frames */ |
2667 for (i = 0 ; i < 16; i++) | 2667 for (i = 0 ; i < 16; i++) |
2668 { | 2668 { |
2669 next_iiratio = (IIKFACTOR1 * local_next_frame.intra_error / DOUBLE_D
IVIDE_CHECK(local_next_frame.coded_error)) ; | 2669 next_iiratio = (IIKFACTOR1 * local_next_frame.intra_error / DOUBLE_D
IVIDE_CHECK(local_next_frame.coded_error)) ; |
2670 | 2670 |
2671 if (next_iiratio > RMAX) | 2671 if (next_iiratio > RMAX) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 double boost_score = 0; | 2728 double boost_score = 0; |
2729 double old_boost_score = 0.0; | 2729 double old_boost_score = 0.0; |
2730 double loop_decay_rate; | 2730 double loop_decay_rate; |
2731 | 2731 |
2732 double kf_mod_err = 0.0; | 2732 double kf_mod_err = 0.0; |
2733 double kf_group_err = 0.0; | 2733 double kf_group_err = 0.0; |
2734 double kf_group_intra_err = 0.0; | 2734 double kf_group_intra_err = 0.0; |
2735 double kf_group_coded_err = 0.0; | 2735 double kf_group_coded_err = 0.0; |
2736 double recent_loop_decay[8] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}; | 2736 double recent_loop_decay[8] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}; |
2737 | 2737 |
2738 vpx_memset(&next_frame, 0, sizeof(next_frame)); | 2738 memset(&next_frame, 0, sizeof(next_frame)); |
2739 | 2739 |
2740 vp8_clear_system_state(); | 2740 vp8_clear_system_state(); |
2741 start_position = cpi->twopass.stats_in; | 2741 start_position = cpi->twopass.stats_in; |
2742 | 2742 |
2743 cpi->common.frame_type = KEY_FRAME; | 2743 cpi->common.frame_type = KEY_FRAME; |
2744 | 2744 |
2745 /* is this a forced key frame by interval */ | 2745 /* is this a forced key frame by interval */ |
2746 cpi->this_key_frame_forced = cpi->next_key_frame_forced; | 2746 cpi->this_key_frame_forced = cpi->next_key_frame_forced; |
2747 | 2747 |
2748 /* Clear the alt ref active flag as this can never be active on a key | 2748 /* Clear the alt ref active flag as this can never be active on a key |
2749 * frame | 2749 * frame |
2750 */ | 2750 */ |
2751 cpi->source_alt_ref_active = 0; | 2751 cpi->source_alt_ref_active = 0; |
2752 | 2752 |
2753 /* Kf is always a gf so clear frames till next gf counter */ | 2753 /* Kf is always a gf so clear frames till next gf counter */ |
2754 cpi->frames_till_gf_update_due = 0; | 2754 cpi->frames_till_gf_update_due = 0; |
2755 | 2755 |
2756 cpi->twopass.frames_to_key = 1; | 2756 cpi->twopass.frames_to_key = 1; |
2757 | 2757 |
2758 /* Take a copy of the initial frame details */ | 2758 /* Take a copy of the initial frame details */ |
2759 vpx_memcpy(&first_frame, this_frame, sizeof(*this_frame)); | 2759 memcpy(&first_frame, this_frame, sizeof(*this_frame)); |
2760 | 2760 |
2761 cpi->twopass.kf_group_bits = 0; | 2761 cpi->twopass.kf_group_bits = 0; |
2762 cpi->twopass.kf_group_error_left = 0; | 2762 cpi->twopass.kf_group_error_left = 0; |
2763 | 2763 |
2764 kf_mod_err = calculate_modified_err(cpi, this_frame); | 2764 kf_mod_err = calculate_modified_err(cpi, this_frame); |
2765 | 2765 |
2766 /* find the next keyframe */ | 2766 /* find the next keyframe */ |
2767 i = 0; | 2767 i = 0; |
2768 while (cpi->twopass.stats_in < cpi->twopass.stats_in_end) | 2768 while (cpi->twopass.stats_in < cpi->twopass.stats_in_end) |
2769 { | 2769 { |
2770 /* Accumulate kf group error */ | 2770 /* Accumulate kf group error */ |
2771 kf_group_err += calculate_modified_err(cpi, this_frame); | 2771 kf_group_err += calculate_modified_err(cpi, this_frame); |
2772 | 2772 |
2773 /* These figures keep intra and coded error counts for all frames | 2773 /* These figures keep intra and coded error counts for all frames |
2774 * including key frames in the group. The effect of the key frame | 2774 * including key frames in the group. The effect of the key frame |
2775 * itself can be subtracted out using the first_frame data | 2775 * itself can be subtracted out using the first_frame data |
2776 * collected above | 2776 * collected above |
2777 */ | 2777 */ |
2778 kf_group_intra_err += this_frame->intra_error; | 2778 kf_group_intra_err += this_frame->intra_error; |
2779 kf_group_coded_err += this_frame->coded_error; | 2779 kf_group_coded_err += this_frame->coded_error; |
2780 | 2780 |
2781 /* Load the next frame's stats. */ | 2781 /* Load the next frame's stats. */ |
2782 vpx_memcpy(&last_frame, this_frame, sizeof(*this_frame)); | 2782 memcpy(&last_frame, this_frame, sizeof(*this_frame)); |
2783 input_stats(cpi, this_frame); | 2783 input_stats(cpi, this_frame); |
2784 | 2784 |
2785 /* Provided that we are not at the end of the file... */ | 2785 /* Provided that we are not at the end of the file... */ |
2786 if (cpi->oxcf.auto_key | 2786 if (cpi->oxcf.auto_key |
2787 && lookup_next_frame_stats(cpi, &next_frame) != EOF) | 2787 && lookup_next_frame_stats(cpi, &next_frame) != EOF) |
2788 { | 2788 { |
2789 /* Normal scene cut check */ | 2789 /* Normal scene cut check */ |
2790 if ( ( i >= MIN_GF_INTERVAL ) && | 2790 if ( ( i >= MIN_GF_INTERVAL ) && |
2791 test_candidate_kf(cpi, &last_frame, this_frame, &next_frame) ) | 2791 test_candidate_kf(cpi, &last_frame, this_frame, &next_frame) ) |
2792 { | 2792 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2840 */ | 2840 */ |
2841 if (cpi->oxcf.auto_key | 2841 if (cpi->oxcf.auto_key |
2842 && cpi->twopass.frames_to_key > (int)cpi->key_frame_frequency ) | 2842 && cpi->twopass.frames_to_key > (int)cpi->key_frame_frequency ) |
2843 { | 2843 { |
2844 FIRSTPASS_STATS *current_pos = cpi->twopass.stats_in; | 2844 FIRSTPASS_STATS *current_pos = cpi->twopass.stats_in; |
2845 FIRSTPASS_STATS tmp_frame; | 2845 FIRSTPASS_STATS tmp_frame; |
2846 | 2846 |
2847 cpi->twopass.frames_to_key /= 2; | 2847 cpi->twopass.frames_to_key /= 2; |
2848 | 2848 |
2849 /* Copy first frame details */ | 2849 /* Copy first frame details */ |
2850 vpx_memcpy(&tmp_frame, &first_frame, sizeof(first_frame)); | 2850 memcpy(&tmp_frame, &first_frame, sizeof(first_frame)); |
2851 | 2851 |
2852 /* Reset to the start of the group */ | 2852 /* Reset to the start of the group */ |
2853 reset_fpf_position(cpi, start_position); | 2853 reset_fpf_position(cpi, start_position); |
2854 | 2854 |
2855 kf_group_err = 0; | 2855 kf_group_err = 0; |
2856 kf_group_intra_err = 0; | 2856 kf_group_intra_err = 0; |
2857 kf_group_coded_err = 0; | 2857 kf_group_coded_err = 0; |
2858 | 2858 |
2859 /* Rescan to get the correct error data for the forced kf group */ | 2859 /* Rescan to get the correct error data for the forced kf group */ |
2860 for( i = 0; i < cpi->twopass.frames_to_key; i++ ) | 2860 for( i = 0; i < cpi->twopass.frames_to_key; i++ ) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 cpi->twopass.kf_group_bits = 0; | 2962 cpi->twopass.kf_group_bits = 0; |
2963 | 2963 |
2964 /* Reset the first pass file position */ | 2964 /* Reset the first pass file position */ |
2965 reset_fpf_position(cpi, start_position); | 2965 reset_fpf_position(cpi, start_position); |
2966 | 2966 |
2967 /* determine how big to make this keyframe based on how well the | 2967 /* determine how big to make this keyframe based on how well the |
2968 * subsequent frames use inter blocks | 2968 * subsequent frames use inter blocks |
2969 */ | 2969 */ |
2970 decay_accumulator = 1.0; | 2970 decay_accumulator = 1.0; |
2971 boost_score = 0.0; | 2971 boost_score = 0.0; |
2972 loop_decay_rate = 1.00; /* Starting decay rate */ | |
2973 | 2972 |
2974 for (i = 0 ; i < cpi->twopass.frames_to_key ; i++) | 2973 for (i = 0 ; i < cpi->twopass.frames_to_key ; i++) |
2975 { | 2974 { |
2976 double r; | 2975 double r; |
2977 | 2976 |
2978 if (EOF == input_stats(cpi, &next_frame)) | 2977 if (EOF == input_stats(cpi, &next_frame)) |
2979 break; | 2978 break; |
2980 | 2979 |
2981 if (next_frame.intra_error > cpi->twopass.kf_intra_err_min) | 2980 if (next_frame.intra_error > cpi->twopass.kf_intra_err_min) |
2982 r = (IIKFACTOR2 * next_frame.intra_error / | 2981 r = (IIKFACTOR2 * next_frame.intra_error / |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 if (cpi->oxcf.allow_spatial_resampling) | 3205 if (cpi->oxcf.allow_spatial_resampling) |
3207 { | 3206 { |
3208 int resample_trigger = 0; | 3207 int resample_trigger = 0; |
3209 int last_kf_resampled = 0; | 3208 int last_kf_resampled = 0; |
3210 int kf_q; | 3209 int kf_q; |
3211 int scale_val = 0; | 3210 int scale_val = 0; |
3212 int hr, hs, vr, vs; | 3211 int hr, hs, vr, vs; |
3213 int new_width = cpi->oxcf.Width; | 3212 int new_width = cpi->oxcf.Width; |
3214 int new_height = cpi->oxcf.Height; | 3213 int new_height = cpi->oxcf.Height; |
3215 | 3214 |
3216 int projected_buffer_level = (int)cpi->buffer_level; | 3215 int projected_buffer_level; |
3217 int tmp_q; | 3216 int tmp_q; |
3218 | 3217 |
3219 double projected_bits_perframe; | 3218 double projected_bits_perframe; |
3220 double group_iiratio = (kf_group_intra_err - first_frame.intra_error) /
(kf_group_coded_err - first_frame.coded_error); | 3219 double group_iiratio = (kf_group_intra_err - first_frame.intra_error) /
(kf_group_coded_err - first_frame.coded_error); |
3221 double err_per_frame = kf_group_err / cpi->twopass.frames_to_key; | 3220 double err_per_frame = kf_group_err / cpi->twopass.frames_to_key; |
3222 double bits_per_frame; | 3221 double bits_per_frame; |
3223 double av_bits_per_frame; | 3222 double av_bits_per_frame; |
3224 double effective_size_ratio; | 3223 double effective_size_ratio; |
3225 | 3224 |
3226 if ((cpi->common.Width != cpi->oxcf.Width) || (cpi->common.Height != cpi
->oxcf.Height)) | 3225 if ((cpi->common.Width != cpi->oxcf.Width) || (cpi->common.Height != cpi
->oxcf.Height)) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3363 } | 3362 } |
3364 | 3363 |
3365 if ((cpi->common.Width != new_width) || (cpi->common.Height != new_heigh
t)) | 3364 if ((cpi->common.Width != new_width) || (cpi->common.Height != new_heigh
t)) |
3366 { | 3365 { |
3367 cpi->common.Width = new_width; | 3366 cpi->common.Width = new_width; |
3368 cpi->common.Height = new_height; | 3367 cpi->common.Height = new_height; |
3369 vp8_alloc_compressor_data(cpi); | 3368 vp8_alloc_compressor_data(cpi); |
3370 } | 3369 } |
3371 } | 3370 } |
3372 } | 3371 } |
OLD | NEW |