| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 int mbs_in_frame = cpi->common.mb_rows * cpi->common.mb_cols; | 580 int mbs_in_frame = cpi->common.mb_rows * cpi->common.mb_cols; |
| 581 | 581 |
| 582 cpi->cyclic_refresh_q = Q / 2; | 582 cpi->cyclic_refresh_q = Q / 2; |
| 583 | 583 |
| 584 if (cpi->oxcf.screen_content_mode) { | 584 if (cpi->oxcf.screen_content_mode) { |
| 585 // Modify quality ramp-up based on Q. Above some Q level, increase the | 585 // Modify quality ramp-up based on Q. Above some Q level, increase the |
| 586 // number of blocks to be refreshed, and reduce it below the thredhold. | 586 // number of blocks to be refreshed, and reduce it below the thredhold. |
| 587 // Turn-off under certain conditions (i.e., away from key frame, and if | 587 // Turn-off under certain conditions (i.e., away from key frame, and if |
| 588 // we are at good quality (low Q) and most of the blocks were skipped-enco
ded | 588 // we are at good quality (low Q) and most of the blocks were skipped-enco
ded |
| 589 // in previous frame. | 589 // in previous frame. |
| 590 if (Q >= 100) { | 590 int qp_thresh = (cpi->oxcf.screen_content_mode == 2) ? 80 : 100; |
| 591 if (Q >= qp_thresh) { |
| 591 cpi->cyclic_refresh_mode_max_mbs_perframe = | 592 cpi->cyclic_refresh_mode_max_mbs_perframe = |
| 592 (cpi->common.mb_rows * cpi->common.mb_cols) / 10; | 593 (cpi->common.mb_rows * cpi->common.mb_cols) / 10; |
| 593 } else if (cpi->frames_since_key > 250 && | 594 } else if (cpi->frames_since_key > 250 && |
| 594 Q < 20 && | 595 Q < 20 && |
| 595 cpi->mb.skip_true_count > (int)(0.95 * mbs_in_frame)) { | 596 cpi->mb.skip_true_count > (int)(0.95 * mbs_in_frame)) { |
| 596 cpi->cyclic_refresh_mode_max_mbs_perframe = 0; | 597 cpi->cyclic_refresh_mode_max_mbs_perframe = 0; |
| 597 } else { | 598 } else { |
| 598 cpi->cyclic_refresh_mode_max_mbs_perframe = | 599 cpi->cyclic_refresh_mode_max_mbs_perframe = |
| 599 (cpi->common.mb_rows * cpi->common.mb_cols) / 20; | 600 (cpi->common.mb_rows * cpi->common.mb_cols) / 20; |
| 600 } | 601 } |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 /* Give a sensible default for the first frame. */ | 2005 /* Give a sensible default for the first frame. */ |
| 2005 cpi->frames_since_key = 8; | 2006 cpi->frames_since_key = 8; |
| 2006 cpi->key_frame_frequency = cpi->oxcf.key_freq; | 2007 cpi->key_frame_frequency = cpi->oxcf.key_freq; |
| 2007 cpi->this_key_frame_forced = 0; | 2008 cpi->this_key_frame_forced = 0; |
| 2008 cpi->next_key_frame_forced = 0; | 2009 cpi->next_key_frame_forced = 0; |
| 2009 | 2010 |
| 2010 cpi->source_alt_ref_pending = 0; | 2011 cpi->source_alt_ref_pending = 0; |
| 2011 cpi->source_alt_ref_active = 0; | 2012 cpi->source_alt_ref_active = 0; |
| 2012 cpi->common.refresh_alt_ref_frame = 0; | 2013 cpi->common.refresh_alt_ref_frame = 0; |
| 2013 | 2014 |
| 2015 cpi->force_maxqp = 0; |
| 2016 |
| 2014 cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; | 2017 cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; |
| 2015 #if CONFIG_INTERNAL_STATS | 2018 #if CONFIG_INTERNAL_STATS |
| 2016 cpi->b_calculate_ssimg = 0; | 2019 cpi->b_calculate_ssimg = 0; |
| 2017 | 2020 |
| 2018 cpi->count = 0; | 2021 cpi->count = 0; |
| 2019 cpi->bytes = 0; | 2022 cpi->bytes = 0; |
| 2020 | 2023 |
| 2021 if (cpi->b_calculate_psnr) | 2024 if (cpi->b_calculate_psnr) |
| 2022 { | 2025 { |
| 2023 cpi->total_sq_error = 0.0; | 2026 cpi->total_sq_error = 0.0; |
| (...skipping 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4177 } | 4180 } |
| 4178 else | 4181 else |
| 4179 zbin_oq_high = ZBIN_OQ_MAX; | 4182 zbin_oq_high = ZBIN_OQ_MAX; |
| 4180 #endif | 4183 #endif |
| 4181 | 4184 |
| 4182 /* Setup background Q adjustment for error resilient mode. | 4185 /* Setup background Q adjustment for error resilient mode. |
| 4183 * For multi-layer encodes only enable this for the base layer. | 4186 * For multi-layer encodes only enable this for the base layer. |
| 4184 */ | 4187 */ |
| 4185 if (cpi->cyclic_refresh_mode_enabled) | 4188 if (cpi->cyclic_refresh_mode_enabled) |
| 4186 { | 4189 { |
| 4187 if (cpi->current_layer==0) | 4190 // Special case for screen_content_mode with golden frame updates. |
| 4191 int disable_cr_gf = (cpi->oxcf.screen_content_mode == 2 && |
| 4192 cm->refresh_golden_frame); |
| 4193 if (cpi->current_layer == 0 && cpi->force_maxqp == 0 && !disable_cr_gf) |
| 4188 cyclic_background_refresh(cpi, Q, 0); | 4194 cyclic_background_refresh(cpi, Q, 0); |
| 4189 else | 4195 else |
| 4190 disable_segmentation(cpi); | 4196 disable_segmentation(cpi); |
| 4191 } | 4197 } |
| 4192 | 4198 |
| 4193 vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &frame_over_sho
ot_limit); | 4199 vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &frame_over_sho
ot_limit); |
| 4194 | 4200 |
| 4195 #if !(CONFIG_REALTIME_ONLY) | 4201 #if !(CONFIG_REALTIME_ONLY) |
| 4196 /* Limit Q range for the adaptive loop. */ | 4202 /* Limit Q range for the adaptive loop. */ |
| 4197 bottom_index = cpi->active_best_quality; | 4203 bottom_index = cpi->active_best_quality; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4399 * +pack coef partitions | 4405 * +pack coef partitions |
| 4400 */ | 4406 */ |
| 4401 vp8_encode_frame(cpi); | 4407 vp8_encode_frame(cpi); |
| 4402 | 4408 |
| 4403 /* cpi->projected_frame_size is not needed for RT mode */ | 4409 /* cpi->projected_frame_size is not needed for RT mode */ |
| 4404 } | 4410 } |
| 4405 #else | 4411 #else |
| 4406 /* transform / motion compensation build reconstruction frame */ | 4412 /* transform / motion compensation build reconstruction frame */ |
| 4407 vp8_encode_frame(cpi); | 4413 vp8_encode_frame(cpi); |
| 4408 | 4414 |
| 4415 if (cpi->oxcf.screen_content_mode == 2) { |
| 4416 if (vp8_drop_encodedframe_overshoot(cpi, Q)) |
| 4417 return; |
| 4418 } |
| 4419 |
| 4409 cpi->projected_frame_size -= vp8_estimate_entropy_savings(cpi); | 4420 cpi->projected_frame_size -= vp8_estimate_entropy_savings(cpi); |
| 4410 cpi->projected_frame_size = (cpi->projected_frame_size > 0) ? cpi->proje
cted_frame_size : 0; | 4421 cpi->projected_frame_size = (cpi->projected_frame_size > 0) ? cpi->proje
cted_frame_size : 0; |
| 4411 #endif | 4422 #endif |
| 4412 vp8_clear_system_state(); | 4423 vp8_clear_system_state(); |
| 4413 | 4424 |
| 4414 /* Test to see if the stats generated for this frame indicate that | 4425 /* Test to see if the stats generated for this frame indicate that |
| 4415 * we should have coded a key frame (assuming that we didn't)! | 4426 * we should have coded a key frame (assuming that we didn't)! |
| 4416 */ | 4427 */ |
| 4417 | 4428 |
| 4418 if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME | 4429 if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5990 } | 6001 } |
| 5991 | 6002 |
| 5992 return Total; | 6003 return Total; |
| 5993 } | 6004 } |
| 5994 | 6005 |
| 5995 | 6006 |
| 5996 int vp8_get_quantizer(VP8_COMP *cpi) | 6007 int vp8_get_quantizer(VP8_COMP *cpi) |
| 5997 { | 6008 { |
| 5998 return cpi->common.base_qindex; | 6009 return cpi->common.base_qindex; |
| 5999 } | 6010 } |
| OLD | NEW |