Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_firstpass.c

Issue 13042014: Description: (Closed) Base URL: https://src.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 output_stats(cpi, cpi->output_pkt_list, cpi->twopass.this_frame_stats); 742 output_stats(cpi, cpi->output_pkt_list, cpi->twopass.this_frame_stats);
743 accumulate_stats(cpi->twopass.total_stats, &fps); 743 accumulate_stats(cpi->twopass.total_stats, &fps);
744 } 744 }
745 745
746 // Copy the previous Last Frame back into gf and and arf buffers if 746 // Copy the previous Last Frame back into gf and and arf buffers if
747 // the prediction is good enough... but also dont allow it to lag too far 747 // the prediction is good enough... but also dont allow it to lag too far
748 if ((cpi->twopass.sr_update_lag > 3) || 748 if ((cpi->twopass.sr_update_lag > 3) ||
749 ((cm->current_video_frame > 0) && 749 ((cm->current_video_frame > 0) &&
750 (cpi->twopass.this_frame_stats->pcnt_inter > 0.20) && 750 (cpi->twopass.this_frame_stats->pcnt_inter > 0.20) &&
751 ((cpi->twopass.this_frame_stats->intra_error / 751 ((cpi->twopass.this_frame_stats->intra_error /
752 cpi->twopass.this_frame_stats->coded_error) > 2.0))) { 752 DOUBLE_DIVIDE_CHECK(cpi->twopass.this_frame_stats->coded_error)) >
753 2.0))) {
753 vp8_yv12_copy_frame(lst_yv12, gld_yv12); 754 vp8_yv12_copy_frame(lst_yv12, gld_yv12);
754 cpi->twopass.sr_update_lag = 1; 755 cpi->twopass.sr_update_lag = 1;
755 } else 756 } else
756 cpi->twopass.sr_update_lag++; 757 cpi->twopass.sr_update_lag++;
757 758
758 // swap frame pointers so last frame refers to the frame we just compressed 759 // swap frame pointers so last frame refers to the frame we just compressed
759 vp9_swap_yv12_buffer(lst_yv12, new_yv12); 760 vp9_swap_yv12_buffer(lst_yv12, new_yv12);
760 vp8_yv12_extend_frame_borders(lst_yv12); 761 vp8_yv12_extend_frame_borders(lst_yv12);
761 762
762 // Special case for the first frame. Copy into the GF buffer as a second refer ence. 763 // Special case for the first frame. Copy into the GF buffer as a second refer ence.
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 if (cpi->twopass.frames_to_key >= (int)(cpi->twopass.total_stats->count - 1688 if (cpi->twopass.frames_to_key >= (int)(cpi->twopass.total_stats->count -
1688 cpi->common.current_video_frame)) { 1689 cpi->common.current_video_frame)) {
1689 cpi->twopass.kf_group_bits = 1690 cpi->twopass.kf_group_bits =
1690 (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0; 1691 (cpi->twopass.bits_left > 0) ? cpi->twopass.bits_left : 0;
1691 } 1692 }
1692 1693
1693 // Calculate the bits to be allocated to the group as a whole 1694 // Calculate the bits to be allocated to the group as a whole
1694 if ((cpi->twopass.kf_group_bits > 0) && 1695 if ((cpi->twopass.kf_group_bits > 0) &&
1695 (cpi->twopass.kf_group_error_left > 0)) { 1696 (cpi->twopass.kf_group_error_left > 0)) {
1696 cpi->twopass.gf_group_bits = 1697 cpi->twopass.gf_group_bits =
1697 (int)((double)cpi->twopass.kf_group_bits * 1698 (int64_t)(cpi->twopass.kf_group_bits *
1698 (gf_group_err / cpi->twopass.kf_group_error_left)); 1699 (gf_group_err / cpi->twopass.kf_group_error_left));
1699 } else 1700 } else
1700 cpi->twopass.gf_group_bits = 0; 1701 cpi->twopass.gf_group_bits = 0;
1701 1702
1702 cpi->twopass.gf_group_bits = 1703 cpi->twopass.gf_group_bits =
1703 (cpi->twopass.gf_group_bits < 0) 1704 (cpi->twopass.gf_group_bits < 0)
1704 ? 0 1705 ? 0
1705 : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits) 1706 : (cpi->twopass.gf_group_bits > cpi->twopass.kf_group_bits)
1706 ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits; 1707 ? cpi->twopass.kf_group_bits : cpi->twopass.gf_group_bits;
1707 1708
1708 // Clip cpi->twopass.gf_group_bits based on user supplied data rate 1709 // Clip cpi->twopass.gf_group_bits based on user supplied data rate
1709 // variability limit (cpi->oxcf.two_pass_vbrmax_section) 1710 // variability limit (cpi->oxcf.two_pass_vbrmax_section)
1710 if (cpi->twopass.gf_group_bits > max_bits * cpi->baseline_gf_interval) 1711 if (cpi->twopass.gf_group_bits >
1711 cpi->twopass.gf_group_bits = max_bits * cpi->baseline_gf_interval; 1712 (int64_t)max_bits * cpi->baseline_gf_interval)
1713 cpi->twopass.gf_group_bits = (int64_t)max_bits * cpi->baseline_gf_interval;
1712 1714
1713 // Reset the file position 1715 // Reset the file position
1714 reset_fpf_position(cpi, start_pos); 1716 reset_fpf_position(cpi, start_pos);
1715 1717
1716 // Update the record of error used so far (only done once per gf group) 1718 // Update the record of error used so far (only done once per gf group)
1717 cpi->twopass.modified_error_used += gf_group_err; 1719 cpi->twopass.modified_error_used += gf_group_err;
1718 1720
1719 // Assign bits to the arf or gf. 1721 // Assign bits to the arf or gf.
1720 for (i = 0; i <= (cpi->source_alt_ref_pending && cpi->common.frame_type != KEY _FRAME); i++) { 1722 for (i = 0; i <= (cpi->source_alt_ref_pending && cpi->common.frame_type != KEY _FRAME); i++) {
1721 int boost; 1723 int boost;
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 cpi->output_frame_rate); 2514 cpi->output_frame_rate);
2513 } 2515 }
2514 2516
2515 // Note the total error score of the kf group minus the key frame itself 2517 // Note the total error score of the kf group minus the key frame itself
2516 cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err); 2518 cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err);
2517 2519
2518 // Adjust the count of total modified error left. 2520 // Adjust the count of total modified error left.
2519 // The count of bits left is adjusted elsewhere based on real coded frame size s 2521 // The count of bits left is adjusted elsewhere based on real coded frame size s
2520 cpi->twopass.modified_error_left -= kf_group_err; 2522 cpi->twopass.modified_error_left -= kf_group_err;
2521 } 2523 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/x86/vp9_subpixel_8t_ssse3.asm ('k') | source/libvpx/vp9/encoder/vp9_onyx_if.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698