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

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

Issue 1328593002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encoder.h ('k') | source/libvpx/vp9/encoder/vp9_firstpass.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 VP9_COMMON *cm = &cpi->common; 679 VP9_COMMON *cm = &cpi->common;
680 int mi_size = cm->mi_cols * cm->mi_rows; 680 int mi_size = cm->mi_cols * cm->mi_rows;
681 681
682 cpi->mbmi_ext_base = vpx_calloc(mi_size, sizeof(*cpi->mbmi_ext_base)); 682 cpi->mbmi_ext_base = vpx_calloc(mi_size, sizeof(*cpi->mbmi_ext_base));
683 if (!cpi->mbmi_ext_base) 683 if (!cpi->mbmi_ext_base)
684 return 1; 684 return 1;
685 685
686 return 0; 686 return 0;
687 } 687 }
688 688
689 void vp9_alloc_compressor_data(VP9_COMP *cpi) { 689 static void alloc_compressor_data(VP9_COMP *cpi) {
690 VP9_COMMON *cm = &cpi->common; 690 VP9_COMMON *cm = &cpi->common;
691 691
692 vp9_alloc_context_buffers(cm, cm->width, cm->height); 692 vp9_alloc_context_buffers(cm, cm->width, cm->height);
693 693
694 alloc_context_buffers_ext(cpi); 694 alloc_context_buffers_ext(cpi);
695 695
696 vpx_free(cpi->tile_tok[0][0]); 696 vpx_free(cpi->tile_tok[0][0]);
697 697
698 { 698 {
699 unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols); 699 unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 768
769 cm->profile = oxcf->profile; 769 cm->profile = oxcf->profile;
770 cm->bit_depth = oxcf->bit_depth; 770 cm->bit_depth = oxcf->bit_depth;
771 #if CONFIG_VP9_HIGHBITDEPTH 771 #if CONFIG_VP9_HIGHBITDEPTH
772 cm->use_highbitdepth = oxcf->use_highbitdepth; 772 cm->use_highbitdepth = oxcf->use_highbitdepth;
773 #endif 773 #endif
774 cm->color_space = oxcf->color_space; 774 cm->color_space = oxcf->color_space;
775 775
776 cm->width = oxcf->width; 776 cm->width = oxcf->width;
777 cm->height = oxcf->height; 777 cm->height = oxcf->height;
778 vp9_alloc_compressor_data(cpi); 778 alloc_compressor_data(cpi);
779 779
780 cpi->svc.temporal_layering_mode = oxcf->temporal_layering_mode; 780 cpi->svc.temporal_layering_mode = oxcf->temporal_layering_mode;
781 781
782 // Single thread case: use counts in common. 782 // Single thread case: use counts in common.
783 cpi->td.counts = &cm->counts; 783 cpi->td.counts = &cm->counts;
784 784
785 // Spatial scalability. 785 // Spatial scalability.
786 cpi->svc.number_spatial_layers = oxcf->ss_number_layers; 786 cpi->svc.number_spatial_layers = oxcf->ss_number_layers;
787 // Temporal scalability. 787 // Temporal scalability.
788 cpi->svc.number_temporal_layers = oxcf->ts_number_layers; 788 cpi->svc.number_temporal_layers = oxcf->ts_number_layers;
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 cm->interp_filter = cpi->sf.default_interp_filter; 1503 cm->interp_filter = cpi->sf.default_interp_filter;
1504 1504
1505 cm->display_width = cpi->oxcf.width; 1505 cm->display_width = cpi->oxcf.width;
1506 cm->display_height = cpi->oxcf.height; 1506 cm->display_height = cpi->oxcf.height;
1507 cm->width = cpi->oxcf.width; 1507 cm->width = cpi->oxcf.width;
1508 cm->height = cpi->oxcf.height; 1508 cm->height = cpi->oxcf.height;
1509 1509
1510 if (cpi->initial_width) { 1510 if (cpi->initial_width) {
1511 if (cm->width > cpi->initial_width || cm->height > cpi->initial_height) { 1511 if (cm->width > cpi->initial_width || cm->height > cpi->initial_height) {
1512 vp9_free_context_buffers(cm); 1512 vp9_free_context_buffers(cm);
1513 vp9_alloc_compressor_data(cpi); 1513 alloc_compressor_data(cpi);
1514 realloc_segmentation_maps(cpi); 1514 realloc_segmentation_maps(cpi);
1515 cpi->initial_width = cpi->initial_height = 0; 1515 cpi->initial_width = cpi->initial_height = 0;
1516 } 1516 }
1517 } 1517 }
1518 update_frame_size(cpi); 1518 update_frame_size(cpi);
1519 1519
1520 if ((cpi->svc.number_temporal_layers > 1 && 1520 if ((cpi->svc.number_temporal_layers > 1 &&
1521 cpi->oxcf.rc_mode == VPX_CBR) || 1521 cpi->oxcf.rc_mode == VPX_CBR) ||
1522 ((cpi->svc.number_temporal_layers > 1 || 1522 ((cpi->svc.number_temporal_layers > 1 ||
1523 cpi->svc.number_spatial_layers > 1) && 1523 cpi->svc.number_spatial_layers > 1) &&
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 apply_active_map(cpi); 3263 apply_active_map(cpi);
3264 vp9_encode_frame(cpi); 3264 vp9_encode_frame(cpi);
3265 } 3265 }
3266 } 3266 }
3267 3267
3268 // Update some stats from cyclic refresh, and check if we should not update 3268 // Update some stats from cyclic refresh, and check if we should not update
3269 // golden reference, for non-SVC 1 pass CBR. 3269 // golden reference, for non-SVC 1 pass CBR.
3270 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && 3270 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
3271 cm->frame_type != KEY_FRAME && 3271 cm->frame_type != KEY_FRAME &&
3272 !cpi->use_svc && 3272 !cpi->use_svc &&
3273 cpi->ext_refresh_frame_flags_pending == 0 &&
3273 (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR)) 3274 (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR))
3274 vp9_cyclic_refresh_check_golden_update(cpi); 3275 vp9_cyclic_refresh_check_golden_update(cpi);
3275 3276
3276 // Update the skip mb flag probabilities based on the distribution 3277 // Update the skip mb flag probabilities based on the distribution
3277 // seen in the last encoder iteration. 3278 // seen in the last encoder iteration.
3278 // update_base_skip_probs(cpi); 3279 // update_base_skip_probs(cpi);
3279 vpx_clear_system_state(); 3280 vpx_clear_system_state();
3280 } 3281 }
3281 3282
3282 static void encode_with_recode_loop(VP9_COMP *cpi, 3283 static void encode_with_recode_loop(VP9_COMP *cpi,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3571 // Note: The overrides are valid only for the next frame passed 3572 // Note: The overrides are valid only for the next frame passed
3572 // to encode_frame_to_data_rate() function 3573 // to encode_frame_to_data_rate() function
3573 if (cpi->ext_refresh_frame_context_pending) { 3574 if (cpi->ext_refresh_frame_context_pending) {
3574 cpi->common.refresh_frame_context = cpi->ext_refresh_frame_context; 3575 cpi->common.refresh_frame_context = cpi->ext_refresh_frame_context;
3575 cpi->ext_refresh_frame_context_pending = 0; 3576 cpi->ext_refresh_frame_context_pending = 0;
3576 } 3577 }
3577 if (cpi->ext_refresh_frame_flags_pending) { 3578 if (cpi->ext_refresh_frame_flags_pending) {
3578 cpi->refresh_last_frame = cpi->ext_refresh_last_frame; 3579 cpi->refresh_last_frame = cpi->ext_refresh_last_frame;
3579 cpi->refresh_golden_frame = cpi->ext_refresh_golden_frame; 3580 cpi->refresh_golden_frame = cpi->ext_refresh_golden_frame;
3580 cpi->refresh_alt_ref_frame = cpi->ext_refresh_alt_ref_frame; 3581 cpi->refresh_alt_ref_frame = cpi->ext_refresh_alt_ref_frame;
3581 cpi->ext_refresh_frame_flags_pending = 0;
3582 } 3582 }
3583 } 3583 }
3584 3584
3585 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, 3585 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
3586 YV12_BUFFER_CONFIG *unscaled, 3586 YV12_BUFFER_CONFIG *unscaled,
3587 YV12_BUFFER_CONFIG *scaled) { 3587 YV12_BUFFER_CONFIG *scaled) {
3588 if (cm->mi_cols * MI_SIZE != unscaled->y_width || 3588 if (cm->mi_cols * MI_SIZE != unscaled->y_width ||
3589 cm->mi_rows * MI_SIZE != unscaled->y_height) { 3589 cm->mi_rows * MI_SIZE != unscaled->y_height) {
3590 #if CONFIG_VP9_HIGHBITDEPTH 3590 #if CONFIG_VP9_HIGHBITDEPTH
3591 if (unscaled->y_width == (scaled->y_width << 1) && 3591 if (unscaled->y_width == (scaled->y_width << 1) &&
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3740 } 3740 }
3741 3741
3742 // For 1 pass CBR, check if we are dropping this frame. 3742 // For 1 pass CBR, check if we are dropping this frame.
3743 // Never drop on key frame. 3743 // Never drop on key frame.
3744 if (oxcf->pass == 0 && 3744 if (oxcf->pass == 0 &&
3745 oxcf->rc_mode == VPX_CBR && 3745 oxcf->rc_mode == VPX_CBR &&
3746 cm->frame_type != KEY_FRAME) { 3746 cm->frame_type != KEY_FRAME) {
3747 if (vp9_rc_drop_frame(cpi)) { 3747 if (vp9_rc_drop_frame(cpi)) {
3748 vp9_rc_postencode_update_drop_frame(cpi); 3748 vp9_rc_postencode_update_drop_frame(cpi);
3749 ++cm->current_video_frame; 3749 ++cm->current_video_frame;
3750 cpi->ext_refresh_frame_flags_pending = 0;
3750 return; 3751 return;
3751 } 3752 }
3752 } 3753 }
3753 3754
3754 vpx_clear_system_state(); 3755 vpx_clear_system_state();
3755 3756
3756 #if CONFIG_INTERNAL_STATS 3757 #if CONFIG_INTERNAL_STATS
3757 memset(cpi->mode_chosen_counts, 0, 3758 memset(cpi->mode_chosen_counts, 0,
3758 MAX_MODES * sizeof(*cpi->mode_chosen_counts)); 3759 MAX_MODES * sizeof(*cpi->mode_chosen_counts));
3759 #endif 3760 #endif
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) 3822 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode)
3822 vp9_adapt_coef_probs(cm); 3823 vp9_adapt_coef_probs(cm);
3823 3824
3824 if (!frame_is_intra_only(cm)) { 3825 if (!frame_is_intra_only(cm)) {
3825 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { 3826 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) {
3826 vp9_adapt_mode_probs(cm); 3827 vp9_adapt_mode_probs(cm);
3827 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); 3828 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv);
3828 } 3829 }
3829 } 3830 }
3830 3831
3832 cpi->ext_refresh_frame_flags_pending = 0;
3833
3831 if (cpi->refresh_golden_frame == 1) 3834 if (cpi->refresh_golden_frame == 1)
3832 cpi->frame_flags |= FRAMEFLAGS_GOLDEN; 3835 cpi->frame_flags |= FRAMEFLAGS_GOLDEN;
3833 else 3836 else
3834 cpi->frame_flags &= ~FRAMEFLAGS_GOLDEN; 3837 cpi->frame_flags &= ~FRAMEFLAGS_GOLDEN;
3835 3838
3836 if (cpi->refresh_alt_ref_frame == 1) 3839 if (cpi->refresh_alt_ref_frame == 1)
3837 cpi->frame_flags |= FRAMEFLAGS_ALTREF; 3840 cpi->frame_flags |= FRAMEFLAGS_ALTREF;
3838 else 3841 else
3839 cpi->frame_flags &= ~FRAMEFLAGS_ALTREF; 3842 cpi->frame_flags &= ~FRAMEFLAGS_ALTREF;
3840 3843
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
4725 if (flags & VP8_EFLAG_NO_UPD_ARF) 4728 if (flags & VP8_EFLAG_NO_UPD_ARF)
4726 upd ^= VP9_ALT_FLAG; 4729 upd ^= VP9_ALT_FLAG;
4727 4730
4728 vp9_update_reference(cpi, upd); 4731 vp9_update_reference(cpi, upd);
4729 } 4732 }
4730 4733
4731 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) { 4734 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) {
4732 vp9_update_entropy(cpi, 0); 4735 vp9_update_entropy(cpi, 0);
4733 } 4736 }
4734 } 4737 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encoder.h ('k') | source/libvpx/vp9/encoder/vp9_firstpass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698