| 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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 sizeof(FIRSTPASS_STATS)); | 851 sizeof(FIRSTPASS_STATS)); |
| 852 output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.this_frame_stats); | 852 output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.this_frame_stats); |
| 853 accumulate_stats(&cpi->twopass.total_stats, &fps); | 853 accumulate_stats(&cpi->twopass.total_stats, &fps); |
| 854 } | 854 } |
| 855 | 855 |
| 856 /* Copy the previous Last Frame into the GF buffer if specific | 856 /* Copy the previous Last Frame into the GF buffer if specific |
| 857 * conditions for doing so are met | 857 * conditions for doing so are met |
| 858 */ | 858 */ |
| 859 if ((cm->current_video_frame > 0) && | 859 if ((cm->current_video_frame > 0) && |
| 860 (cpi->twopass.this_frame_stats.pcnt_inter > 0.20) && | 860 (cpi->twopass.this_frame_stats.pcnt_inter > 0.20) && |
| 861 ((cpi->twopass.this_frame_stats.intra_error / cpi->twopass.this_frame_st
ats.coded_error) > 2.0)) | 861 ((cpi->twopass.this_frame_stats.intra_error / |
| 862 DOUBLE_DIVIDE_CHECK(cpi->twopass.this_frame_stats.coded_error)) > |
| 863 2.0)) |
| 862 { | 864 { |
| 863 vp8_yv12_copy_frame(lst_yv12, gld_yv12); | 865 vp8_yv12_copy_frame(lst_yv12, gld_yv12); |
| 864 } | 866 } |
| 865 | 867 |
| 866 /* swap frame pointers so last frame refers to the frame we just | 868 /* swap frame pointers so last frame refers to the frame we just |
| 867 * compressed | 869 * compressed |
| 868 */ | 870 */ |
| 869 vp8_swap_yv12_buffer(lst_yv12, new_yv12); | 871 vp8_swap_yv12_buffer(lst_yv12, new_yv12); |
| 870 vp8_yv12_extend_frame_borders(lst_yv12); | 872 vp8_yv12_extend_frame_borders(lst_yv12); |
| 871 | 873 |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 { | 2111 { |
| 2110 cpi->twopass.kf_group_bits = | 2112 cpi->twopass.kf_group_bits = |
| 2111 (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0; | 2113 (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0; |
| 2112 } | 2114 } |
| 2113 | 2115 |
| 2114 /* Calculate the bits to be allocated to the group as a whole */ | 2116 /* Calculate the bits to be allocated to the group as a whole */ |
| 2115 if ((cpi->twopass.kf_group_bits > 0) && | 2117 if ((cpi->twopass.kf_group_bits > 0) && |
| 2116 (cpi->twopass.kf_group_error_left > 0)) | 2118 (cpi->twopass.kf_group_error_left > 0)) |
| 2117 { | 2119 { |
| 2118 cpi->twopass.gf_group_bits = | 2120 cpi->twopass.gf_group_bits = |
| 2119 (int)((double)cpi->twopass.kf_group_bits * | 2121 (int64_t)(cpi->twopass.kf_group_bits * |
| 2120 (gf_group_err / (double)cpi->twopass.kf_group_error_left)); | 2122 (gf_group_err / cpi->twopass.kf_group_error_left)); |
| 2121 } | 2123 } |
| 2122 else | 2124 else |
| 2123 cpi->twopass.gf_group_bits = 0; | 2125 cpi->twopass.gf_group_bits = 0; |
| 2124 | 2126 |
| 2125 cpi->twopass.gf_group_bits = (int)( | 2127 cpi->twopass.gf_group_bits = |
| 2126 (cpi->twopass.gf_group_bits < 0) | 2128 (cpi->twopass.gf_group_bits < 0) |
| 2127 ? 0 | 2129 ? 0 |
| 2128 : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits) | 2130 : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits) |
| 2129 ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits); | 2131 ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits; |
| 2130 | 2132 |
| 2131 /* Clip cpi->twopass.gf_group_bits based on user supplied data rate | 2133 /* Clip cpi->twopass.gf_group_bits based on user supplied data rate |
| 2132 * variability limit (cpi->oxcf.two_pass_vbrmax_section) | 2134 * variability limit (cpi->oxcf.two_pass_vbrmax_section) |
| 2133 */ | 2135 */ |
| 2134 if (cpi->twopass.gf_group_bits > max_bits * cpi->baseline_gf_interval) | 2136 if (cpi->twopass.gf_group_bits > |
| 2135 cpi->twopass.gf_group_bits = max_bits * cpi->baseline_gf_interval; | 2137 (int64_t)max_bits * cpi->baseline_gf_interval) |
| 2138 cpi->twopass.gf_group_bits = |
| 2139 (int64_t)max_bits * cpi->baseline_gf_interval; |
| 2136 | 2140 |
| 2137 /* Reset the file position */ | 2141 /* Reset the file position */ |
| 2138 reset_fpf_position(cpi, start_pos); | 2142 reset_fpf_position(cpi, start_pos); |
| 2139 | 2143 |
| 2140 /* Update the record of error used so far (only done once per gf group) */ | 2144 /* Update the record of error used so far (only done once per gf group) */ |
| 2141 cpi->twopass.modified_error_used += gf_group_err; | 2145 cpi->twopass.modified_error_used += gf_group_err; |
| 2142 | 2146 |
| 2143 /* Assign bits to the arf or gf. */ | 2147 /* Assign bits to the arf or gf. */ |
| 2144 for (i = 0; i <= (cpi->source_alt_ref_pending && cpi->common.frame_type != K
EY_FRAME); i++) { | 2148 for (i = 0; i <= (cpi->source_alt_ref_pending && cpi->common.frame_type != K
EY_FRAME); i++) { |
| 2145 int Boost; | 2149 int Boost; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 | 2443 |
| 2440 /* Special case: Error error_resilient_mode mode does not make much | 2444 /* Special case: Error error_resilient_mode mode does not make much |
| 2441 * sense for two pass but with its current meaning but this code is | 2445 * sense for two pass but with its current meaning but this code is |
| 2442 * designed to stop outlandish behaviour if someone does set it when | 2446 * designed to stop outlandish behaviour if someone does set it when |
| 2443 * using two pass. It effectively disables GF groups. This is | 2447 * using two pass. It effectively disables GF groups. This is |
| 2444 * temporary code till we decide what should really happen in this | 2448 * temporary code till we decide what should really happen in this |
| 2445 * case. | 2449 * case. |
| 2446 */ | 2450 */ |
| 2447 if (cpi->oxcf.error_resilient_mode) | 2451 if (cpi->oxcf.error_resilient_mode) |
| 2448 { | 2452 { |
| 2449 cpi->twopass.gf_group_bits = (int)cpi->twopass.kf_group_bits; | 2453 cpi->twopass.gf_group_bits = cpi->twopass.kf_group_bits; |
| 2450 cpi->twopass.gf_group_error_left = | 2454 cpi->twopass.gf_group_error_left = |
| 2451 (int)cpi->twopass.kf_group_error_left; | 2455 (int)cpi->twopass.kf_group_error_left; |
| 2452 cpi->baseline_gf_interval = cpi->twopass.frames_to_key; | 2456 cpi->baseline_gf_interval = cpi->twopass.frames_to_key; |
| 2453 cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; | 2457 cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; |
| 2454 cpi->source_alt_ref_pending = 0; | 2458 cpi->source_alt_ref_pending = 0; |
| 2455 } | 2459 } |
| 2456 | 2460 |
| 2457 } | 2461 } |
| 2458 | 2462 |
| 2459 /* Is this a GF / ARF (Note that a KF is always also a GF) */ | 2463 /* Is this a GF / ARF (Note that a KF is always also a GF) */ |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3352 } | 3356 } |
| 3353 | 3357 |
| 3354 if ((cpi->common.Width != new_width) || (cpi->common.Height != new_heigh
t)) | 3358 if ((cpi->common.Width != new_width) || (cpi->common.Height != new_heigh
t)) |
| 3355 { | 3359 { |
| 3356 cpi->common.Width = new_width; | 3360 cpi->common.Width = new_width; |
| 3357 cpi->common.Height = new_height; | 3361 cpi->common.Height = new_height; |
| 3358 vp8_alloc_compressor_data(cpi); | 3362 vp8_alloc_compressor_data(cpi); |
| 3359 } | 3363 } |
| 3360 } | 3364 } |
| 3361 } | 3365 } |
| OLD | NEW |