| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 482 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
| 483 "Failed to reallocate alt_ref_buffer"); | 483 "Failed to reallocate alt_ref_buffer"); |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 | 486 |
| 487 void vp9_new_framerate(VP9_COMP *cpi, double framerate) { | 487 void vp9_new_framerate(VP9_COMP *cpi, double framerate) { |
| 488 cpi->framerate = framerate < 0.1 ? 30 : framerate; | 488 cpi->framerate = framerate < 0.1 ? 30 : framerate; |
| 489 vp9_rc_update_framerate(cpi); | 489 vp9_rc_update_framerate(cpi); |
| 490 } | 490 } |
| 491 | 491 |
| 492 int64_t vp9_rescale(int64_t val, int64_t num, int denom) { | |
| 493 int64_t llnum = num; | |
| 494 int64_t llden = denom; | |
| 495 int64_t llval = val; | |
| 496 | |
| 497 return (llval * llnum / llden); | |
| 498 } | |
| 499 | |
| 500 static void set_tile_limits(VP9_COMP *cpi) { | 492 static void set_tile_limits(VP9_COMP *cpi) { |
| 501 VP9_COMMON *const cm = &cpi->common; | 493 VP9_COMMON *const cm = &cpi->common; |
| 502 | 494 |
| 503 int min_log2_tile_cols, max_log2_tile_cols; | 495 int min_log2_tile_cols, max_log2_tile_cols; |
| 504 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); | 496 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); |
| 505 | 497 |
| 506 cm->log2_tile_cols = clamp(cpi->oxcf.tile_columns, | 498 cm->log2_tile_cols = clamp(cpi->oxcf.tile_columns, |
| 507 min_log2_tile_cols, max_log2_tile_cols); | 499 min_log2_tile_cols, max_log2_tile_cols); |
| 508 cm->log2_tile_rows = cpi->oxcf.tile_rows; | 500 cm->log2_tile_rows = cpi->oxcf.tile_rows; |
| 509 } | 501 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 526 | 518 |
| 527 cm->width = oxcf->width; | 519 cm->width = oxcf->width; |
| 528 cm->height = oxcf->height; | 520 cm->height = oxcf->height; |
| 529 vp9_alloc_compressor_data(cpi); | 521 vp9_alloc_compressor_data(cpi); |
| 530 | 522 |
| 531 // Spatial scalability. | 523 // Spatial scalability. |
| 532 cpi->svc.number_spatial_layers = oxcf->ss_number_layers; | 524 cpi->svc.number_spatial_layers = oxcf->ss_number_layers; |
| 533 // Temporal scalability. | 525 // Temporal scalability. |
| 534 cpi->svc.number_temporal_layers = oxcf->ts_number_layers; | 526 cpi->svc.number_temporal_layers = oxcf->ts_number_layers; |
| 535 | 527 |
| 536 if ((cpi->svc.number_temporal_layers > 1 && | 528 if ((cpi->svc.number_temporal_layers > 1 && cpi->oxcf.rc_mode == VPX_CBR) || |
| 537 cpi->oxcf.rc_mode == VPX_CBR) || | 529 (cpi->svc.number_spatial_layers > 1 && cpi->oxcf.pass == 2)) { |
| 538 (cpi->svc.number_spatial_layers > 1 && | |
| 539 cpi->oxcf.mode == TWO_PASS_SECOND_BEST)) { | |
| 540 vp9_init_layer_context(cpi); | 530 vp9_init_layer_context(cpi); |
| 541 } | 531 } |
| 542 | 532 |
| 543 // change includes all joint functionality | 533 // change includes all joint functionality |
| 544 vp9_change_config(cpi, oxcf); | 534 vp9_change_config(cpi, oxcf); |
| 545 | 535 |
| 546 cpi->static_mb_pct = 0; | 536 cpi->static_mb_pct = 0; |
| 547 cpi->ref_frame_flags = 0; | 537 cpi->ref_frame_flags = 0; |
| 548 | 538 |
| 549 init_buffer_indices(cpi); | 539 init_buffer_indices(cpi); |
| 550 | 540 |
| 551 set_tile_limits(cpi); | 541 set_tile_limits(cpi); |
| 552 } | 542 } |
| 553 | 543 |
| 544 static void set_rc_buffer_sizes(RATE_CONTROL *rc, |
| 545 const VP9EncoderConfig *oxcf) { |
| 546 const int64_t bandwidth = oxcf->target_bandwidth; |
| 547 const int64_t starting = oxcf->starting_buffer_level_ms; |
| 548 const int64_t optimal = oxcf->optimal_buffer_level_ms; |
| 549 const int64_t maximum = oxcf->maximum_buffer_size_ms; |
| 550 |
| 551 rc->starting_buffer_level = starting * bandwidth / 1000; |
| 552 rc->optimal_buffer_level = (optimal == 0) ? bandwidth / 8 |
| 553 : optimal * bandwidth / 1000; |
| 554 rc->maximum_buffer_size = (maximum == 0) ? bandwidth / 8 |
| 555 : maximum * bandwidth / 1000; |
| 556 } |
| 557 |
| 554 void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { | 558 void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { |
| 555 VP9_COMMON *const cm = &cpi->common; | 559 VP9_COMMON *const cm = &cpi->common; |
| 556 RATE_CONTROL *const rc = &cpi->rc; | 560 RATE_CONTROL *const rc = &cpi->rc; |
| 557 | 561 |
| 558 if (cm->profile != oxcf->profile) | 562 if (cm->profile != oxcf->profile) |
| 559 cm->profile = oxcf->profile; | 563 cm->profile = oxcf->profile; |
| 560 cm->bit_depth = oxcf->bit_depth; | 564 cm->bit_depth = oxcf->bit_depth; |
| 561 | 565 |
| 562 if (cm->profile <= PROFILE_1) | 566 if (cm->profile <= PROFILE_1) |
| 563 assert(cm->bit_depth == BITS_8); | 567 assert(cm->bit_depth == BITS_8); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 577 vp9_set_high_precision_mv(cpi, 0); | 581 vp9_set_high_precision_mv(cpi, 0); |
| 578 | 582 |
| 579 { | 583 { |
| 580 int i; | 584 int i; |
| 581 | 585 |
| 582 for (i = 0; i < MAX_SEGMENTS; i++) | 586 for (i = 0; i < MAX_SEGMENTS; i++) |
| 583 cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout; | 587 cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout; |
| 584 } | 588 } |
| 585 cpi->encode_breakout = cpi->oxcf.encode_breakout; | 589 cpi->encode_breakout = cpi->oxcf.encode_breakout; |
| 586 | 590 |
| 587 // local file playback mode == really big buffer | 591 set_rc_buffer_sizes(rc, &cpi->oxcf); |
| 588 if (cpi->oxcf.rc_mode == VPX_VBR) { | |
| 589 cpi->oxcf.starting_buffer_level_ms = 60000; | |
| 590 cpi->oxcf.optimal_buffer_level_ms = 60000; | |
| 591 cpi->oxcf.maximum_buffer_size_ms = 240000; | |
| 592 } | |
| 593 | 592 |
| 594 rc->starting_buffer_level = vp9_rescale(cpi->oxcf.starting_buffer_level_ms, | |
| 595 cpi->oxcf.target_bandwidth, 1000); | |
| 596 | |
| 597 // Set or reset optimal and maximum buffer levels. | |
| 598 if (cpi->oxcf.optimal_buffer_level_ms == 0) | |
| 599 rc->optimal_buffer_level = cpi->oxcf.target_bandwidth / 8; | |
| 600 else | |
| 601 rc->optimal_buffer_level = vp9_rescale(cpi->oxcf.optimal_buffer_level_ms, | |
| 602 cpi->oxcf.target_bandwidth, 1000); | |
| 603 | |
| 604 if (cpi->oxcf.maximum_buffer_size_ms == 0) | |
| 605 rc->maximum_buffer_size = cpi->oxcf.target_bandwidth / 8; | |
| 606 else | |
| 607 rc->maximum_buffer_size = vp9_rescale(cpi->oxcf.maximum_buffer_size_ms, | |
| 608 cpi->oxcf.target_bandwidth, 1000); | |
| 609 // Under a configuration change, where maximum_buffer_size may change, | 593 // Under a configuration change, where maximum_buffer_size may change, |
| 610 // keep buffer level clipped to the maximum allowed buffer size. | 594 // keep buffer level clipped to the maximum allowed buffer size. |
| 611 rc->bits_off_target = MIN(rc->bits_off_target, rc->maximum_buffer_size); | 595 rc->bits_off_target = MIN(rc->bits_off_target, rc->maximum_buffer_size); |
| 612 rc->buffer_level = MIN(rc->buffer_level, rc->maximum_buffer_size); | 596 rc->buffer_level = MIN(rc->buffer_level, rc->maximum_buffer_size); |
| 613 | 597 |
| 614 // Set up frame rate and related parameters rate control values. | 598 // Set up frame rate and related parameters rate control values. |
| 615 vp9_new_framerate(cpi, cpi->framerate); | 599 vp9_new_framerate(cpi, cpi->framerate); |
| 616 | 600 |
| 617 // Set absolute upper and lower quality limits | 601 // Set absolute upper and lower quality limits |
| 618 rc->worst_quality = cpi->oxcf.worst_allowed_q; | 602 rc->worst_quality = cpi->oxcf.worst_allowed_q; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 cm->error.setjmp = 1; | 708 cm->error.setjmp = 1; |
| 725 | 709 |
| 726 vp9_rtcd(); | 710 vp9_rtcd(); |
| 727 | 711 |
| 728 cpi->use_svc = 0; | 712 cpi->use_svc = 0; |
| 729 | 713 |
| 730 init_config(cpi, oxcf); | 714 init_config(cpi, oxcf); |
| 731 vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); | 715 vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); |
| 732 | 716 |
| 733 cm->current_video_frame = 0; | 717 cm->current_video_frame = 0; |
| 734 | |
| 735 cpi->gold_is_last = 0; | |
| 736 cpi->alt_is_last = 0; | |
| 737 cpi->gold_is_alt = 0; | |
| 738 | |
| 739 cpi->skippable_frame = 0; | 718 cpi->skippable_frame = 0; |
| 740 | 719 |
| 741 // Create the encoder segmentation map and set all entries to 0 | 720 // Create the encoder segmentation map and set all entries to 0 |
| 742 CHECK_MEM_ERROR(cm, cpi->segmentation_map, | 721 CHECK_MEM_ERROR(cm, cpi->segmentation_map, |
| 743 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); | 722 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); |
| 744 | 723 |
| 745 // Create a complexity map used for rd adjustment | 724 // Create a complexity map used for rd adjustment |
| 746 CHECK_MEM_ERROR(cm, cpi->complexity_map, | 725 CHECK_MEM_ERROR(cm, cpi->complexity_map, |
| 747 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); | 726 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); |
| 748 | 727 |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1909 if (loop) { | 1888 if (loop) { |
| 1910 loop_count++; | 1889 loop_count++; |
| 1911 | 1890 |
| 1912 #if CONFIG_INTERNAL_STATS | 1891 #if CONFIG_INTERNAL_STATS |
| 1913 cpi->tot_recode_hits++; | 1892 cpi->tot_recode_hits++; |
| 1914 #endif | 1893 #endif |
| 1915 } | 1894 } |
| 1916 } while (loop); | 1895 } while (loop); |
| 1917 } | 1896 } |
| 1918 | 1897 |
| 1919 static void get_ref_frame_flags(VP9_COMP *cpi) { | 1898 static int get_ref_frame_flags(const VP9_COMP *cpi) { |
| 1920 if (cpi->refresh_last_frame & cpi->refresh_golden_frame) | 1899 const int *const map = cpi->common.ref_frame_map; |
| 1921 cpi->gold_is_last = 1; | 1900 const int gold_is_last = map[cpi->gld_fb_idx] == map[cpi->lst_fb_idx]; |
| 1922 else if (cpi->refresh_last_frame ^ cpi->refresh_golden_frame) | 1901 const int alt_is_last = map[cpi->alt_fb_idx] == map[cpi->lst_fb_idx]; |
| 1923 cpi->gold_is_last = 0; | 1902 const int gold_is_alt = map[cpi->gld_fb_idx] == map[cpi->alt_fb_idx]; |
| 1903 int flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; |
| 1924 | 1904 |
| 1925 if (cpi->refresh_last_frame & cpi->refresh_alt_ref_frame) | 1905 if (gold_is_last) |
| 1926 cpi->alt_is_last = 1; | 1906 flags &= ~VP9_GOLD_FLAG; |
| 1927 else if (cpi->refresh_last_frame ^ cpi->refresh_alt_ref_frame) | |
| 1928 cpi->alt_is_last = 0; | |
| 1929 | |
| 1930 if (cpi->refresh_alt_ref_frame & cpi->refresh_golden_frame) | |
| 1931 cpi->gold_is_alt = 1; | |
| 1932 else if (cpi->refresh_alt_ref_frame ^ cpi->refresh_golden_frame) | |
| 1933 cpi->gold_is_alt = 0; | |
| 1934 | |
| 1935 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; | |
| 1936 | |
| 1937 if (cpi->gold_is_last) | |
| 1938 cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; | |
| 1939 | 1907 |
| 1940 if (cpi->rc.frames_till_gf_update_due == INT_MAX && | 1908 if (cpi->rc.frames_till_gf_update_due == INT_MAX && |
| 1941 !is_spatial_svc(cpi)) | 1909 !is_spatial_svc(cpi)) |
| 1942 cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; | 1910 flags &= ~VP9_GOLD_FLAG; |
| 1943 | 1911 |
| 1944 if (cpi->alt_is_last) | 1912 if (alt_is_last) |
| 1945 cpi->ref_frame_flags &= ~VP9_ALT_FLAG; | 1913 flags &= ~VP9_ALT_FLAG; |
| 1946 | 1914 |
| 1947 if (cpi->gold_is_alt) | 1915 if (gold_is_alt) |
| 1948 cpi->ref_frame_flags &= ~VP9_ALT_FLAG; | 1916 flags &= ~VP9_ALT_FLAG; |
| 1917 |
| 1918 return flags; |
| 1949 } | 1919 } |
| 1950 | 1920 |
| 1951 static void set_ext_overrides(VP9_COMP *cpi) { | 1921 static void set_ext_overrides(VP9_COMP *cpi) { |
| 1952 // Overrides the defaults with the externally supplied values with | 1922 // Overrides the defaults with the externally supplied values with |
| 1953 // vp9_update_reference() and vp9_update_entropy() calls | 1923 // vp9_update_reference() and vp9_update_entropy() calls |
| 1954 // Note: The overrides are valid only for the next frame passed | 1924 // Note: The overrides are valid only for the next frame passed |
| 1955 // to encode_frame_to_data_rate() function | 1925 // to encode_frame_to_data_rate() function |
| 1956 if (cpi->ext_refresh_frame_context_pending) { | 1926 if (cpi->ext_refresh_frame_context_pending) { |
| 1957 cpi->common.refresh_frame_context = cpi->ext_refresh_frame_context; | 1927 cpi->common.refresh_frame_context = cpi->ext_refresh_frame_context; |
| 1958 cpi->ext_refresh_frame_context_pending = 0; | 1928 cpi->ext_refresh_frame_context_pending = 0; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 arf_sign_bias = cpi->rc.source_alt_ref_active && | 1977 arf_sign_bias = cpi->rc.source_alt_ref_active && |
| 2008 (!cpi->refresh_alt_ref_frame || | 1978 (!cpi->refresh_alt_ref_frame || |
| 2009 (gf_group->rf_level[gf_group->index] == GF_ARF_LOW)); | 1979 (gf_group->rf_level[gf_group->index] == GF_ARF_LOW)); |
| 2010 } else { | 1980 } else { |
| 2011 arf_sign_bias = | 1981 arf_sign_bias = |
| 2012 (cpi->rc.source_alt_ref_active && !cpi->refresh_alt_ref_frame); | 1982 (cpi->rc.source_alt_ref_active && !cpi->refresh_alt_ref_frame); |
| 2013 } | 1983 } |
| 2014 cm->ref_frame_sign_bias[ALTREF_FRAME] = arf_sign_bias; | 1984 cm->ref_frame_sign_bias[ALTREF_FRAME] = arf_sign_bias; |
| 2015 } | 1985 } |
| 2016 | 1986 |
| 1987 static void set_mv_search_params(VP9_COMP *cpi) { |
| 1988 const VP9_COMMON *const cm = &cpi->common; |
| 1989 const unsigned int max_mv_def = MIN(cm->width, cm->height); |
| 1990 |
| 1991 // Default based on max resolution. |
| 1992 cpi->mv_step_param = vp9_init_search_range(max_mv_def); |
| 1993 |
| 1994 if (cpi->sf.mv.auto_mv_step_size) { |
| 1995 if (frame_is_intra_only(cm)) { |
| 1996 // Initialize max_mv_magnitude for use in the first INTER frame |
| 1997 // after a key/intra-only frame. |
| 1998 cpi->max_mv_magnitude = max_mv_def; |
| 1999 } else { |
| 2000 if (cm->show_frame) |
| 2001 // Allow mv_steps to correspond to twice the max mv magnitude found |
| 2002 // in the previous frame, capped by the default max_mv_magnitude based |
| 2003 // on resolution. |
| 2004 cpi->mv_step_param = |
| 2005 vp9_init_search_range(MIN(max_mv_def, 2 * cpi->max_mv_magnitude)); |
| 2006 cpi->max_mv_magnitude = 0; |
| 2007 } |
| 2008 } |
| 2009 } |
| 2010 |
| 2017 static void encode_frame_to_data_rate(VP9_COMP *cpi, | 2011 static void encode_frame_to_data_rate(VP9_COMP *cpi, |
| 2018 size_t *size, | 2012 size_t *size, |
| 2019 uint8_t *dest, | 2013 uint8_t *dest, |
| 2020 unsigned int *frame_flags) { | 2014 unsigned int *frame_flags) { |
| 2021 VP9_COMMON *const cm = &cpi->common; | 2015 VP9_COMMON *const cm = &cpi->common; |
| 2016 struct segmentation *const seg = &cm->seg; |
| 2022 TX_SIZE t; | 2017 TX_SIZE t; |
| 2023 int q; | 2018 int q; |
| 2024 int top_index; | 2019 int top_index; |
| 2025 int bottom_index; | 2020 int bottom_index; |
| 2026 | 2021 |
| 2027 const SPEED_FEATURES *const sf = &cpi->sf; | |
| 2028 const unsigned int max_mv_def = MIN(cm->width, cm->height); | |
| 2029 struct segmentation *const seg = &cm->seg; | |
| 2030 set_ext_overrides(cpi); | 2022 set_ext_overrides(cpi); |
| 2031 | 2023 |
| 2032 cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source, | 2024 cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source, |
| 2033 &cpi->scaled_source); | 2025 &cpi->scaled_source); |
| 2034 | 2026 |
| 2035 if (cpi->unscaled_last_source != NULL) | 2027 if (cpi->unscaled_last_source != NULL) |
| 2036 cpi->Last_Source = vp9_scale_if_required(cm, cpi->unscaled_last_source, | 2028 cpi->Last_Source = vp9_scale_if_required(cm, cpi->unscaled_last_source, |
| 2037 &cpi->scaled_last_source); | 2029 &cpi->scaled_last_source); |
| 2038 | 2030 |
| 2039 vp9_scale_references(cpi); | 2031 vp9_scale_references(cpi); |
| 2040 | 2032 |
| 2041 vp9_clear_system_state(); | 2033 vp9_clear_system_state(); |
| 2042 | 2034 |
| 2043 // Enable or disable mode based tweaking of the zbin. | 2035 // Enable or disable mode based tweaking of the zbin. |
| 2044 // For 2 pass only used where GF/ARF prediction quality | 2036 // For 2 pass only used where GF/ARF prediction quality |
| 2045 // is above a threshold. | 2037 // is above a threshold. |
| 2046 cpi->zbin_mode_boost = 0; | 2038 cpi->zbin_mode_boost = 0; |
| 2047 cpi->zbin_mode_boost_enabled = 0; | 2039 cpi->zbin_mode_boost_enabled = 0; |
| 2048 | 2040 |
| 2049 // Set the arf sign bias for this frame. | 2041 // Set the arf sign bias for this frame. |
| 2050 set_arf_sign_bias(cpi); | 2042 set_arf_sign_bias(cpi); |
| 2051 | 2043 |
| 2052 // Set default state for segment based loop filter update flags. | 2044 // Set default state for segment based loop filter update flags. |
| 2053 cm->lf.mode_ref_delta_update = 0; | 2045 cm->lf.mode_ref_delta_update = 0; |
| 2054 | 2046 |
| 2055 // Initialize cpi->mv_step_param to default based on max resolution. | 2047 set_mv_search_params(cpi); |
| 2056 cpi->mv_step_param = vp9_init_search_range(max_mv_def); | |
| 2057 // Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate. | |
| 2058 if (sf->mv.auto_mv_step_size) { | |
| 2059 if (frame_is_intra_only(cm)) { | |
| 2060 // Initialize max_mv_magnitude for use in the first INTER frame | |
| 2061 // after a key/intra-only frame. | |
| 2062 cpi->max_mv_magnitude = max_mv_def; | |
| 2063 } else { | |
| 2064 if (cm->show_frame) | |
| 2065 // Allow mv_steps to correspond to twice the max mv magnitude found | |
| 2066 // in the previous frame, capped by the default max_mv_magnitude based | |
| 2067 // on resolution. | |
| 2068 cpi->mv_step_param = vp9_init_search_range(MIN(max_mv_def, 2 * | |
| 2069 cpi->max_mv_magnitude)); | |
| 2070 cpi->max_mv_magnitude = 0; | |
| 2071 } | |
| 2072 } | |
| 2073 | 2048 |
| 2074 // Set various flags etc to special state if it is a key frame. | 2049 // Set various flags etc to special state if it is a key frame. |
| 2075 if (frame_is_intra_only(cm)) { | 2050 if (frame_is_intra_only(cm)) { |
| 2076 // Reset the loop filter deltas and segmentation map. | 2051 // Reset the loop filter deltas and segmentation map. |
| 2077 vp9_reset_segment_features(&cm->seg); | 2052 vp9_reset_segment_features(&cm->seg); |
| 2078 | 2053 |
| 2079 // If segmentation is enabled force a map update for key frames. | 2054 // If segmentation is enabled force a map update for key frames. |
| 2080 if (seg->enabled) { | 2055 if (seg->enabled) { |
| 2081 seg->update_map = 1; | 2056 seg->update_map = 1; |
| 2082 seg->update_data = 1; | 2057 seg->update_data = 1; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 if (cpi->refresh_golden_frame == 1) | 2215 if (cpi->refresh_golden_frame == 1) |
| 2241 cpi->frame_flags |= FRAMEFLAGS_GOLDEN; | 2216 cpi->frame_flags |= FRAMEFLAGS_GOLDEN; |
| 2242 else | 2217 else |
| 2243 cpi->frame_flags &= ~FRAMEFLAGS_GOLDEN; | 2218 cpi->frame_flags &= ~FRAMEFLAGS_GOLDEN; |
| 2244 | 2219 |
| 2245 if (cpi->refresh_alt_ref_frame == 1) | 2220 if (cpi->refresh_alt_ref_frame == 1) |
| 2246 cpi->frame_flags |= FRAMEFLAGS_ALTREF; | 2221 cpi->frame_flags |= FRAMEFLAGS_ALTREF; |
| 2247 else | 2222 else |
| 2248 cpi->frame_flags &= ~FRAMEFLAGS_ALTREF; | 2223 cpi->frame_flags &= ~FRAMEFLAGS_ALTREF; |
| 2249 | 2224 |
| 2250 get_ref_frame_flags(cpi); | 2225 cpi->ref_frame_flags = get_ref_frame_flags(cpi); |
| 2251 | 2226 |
| 2252 cm->last_frame_type = cm->frame_type; | 2227 cm->last_frame_type = cm->frame_type; |
| 2253 vp9_rc_postencode_update(cpi, *size); | 2228 vp9_rc_postencode_update(cpi, *size); |
| 2254 | 2229 |
| 2255 #if 0 | 2230 #if 0 |
| 2256 output_frame_level_debug_stats(cpi); | 2231 output_frame_level_debug_stats(cpi); |
| 2257 #endif | 2232 #endif |
| 2258 | 2233 |
| 2259 if (cm->frame_type == KEY_FRAME) { | 2234 if (cm->frame_type == KEY_FRAME) { |
| 2260 // Tell the caller that the frame was coded as a key frame | 2235 // Tell the caller that the frame was coded as a key frame |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2966 if (flags & VP8_EFLAG_NO_UPD_ARF) | 2941 if (flags & VP8_EFLAG_NO_UPD_ARF) |
| 2967 upd ^= VP9_ALT_FLAG; | 2942 upd ^= VP9_ALT_FLAG; |
| 2968 | 2943 |
| 2969 vp9_update_reference(cpi, upd); | 2944 vp9_update_reference(cpi, upd); |
| 2970 } | 2945 } |
| 2971 | 2946 |
| 2972 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) { | 2947 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) { |
| 2973 vp9_update_entropy(cpi, 0); | 2948 vp9_update_entropy(cpi, 0); |
| 2974 } | 2949 } |
| 2975 } | 2950 } |
| OLD | NEW |