Move index from GF_GROUP to AV1_COMP Moved the element index of gf_group into cpi as gf_frame_index. Future CLs will move the the element gf_group to the primary context, thus, making it common to all frame contexts. However, as the gf_frame_index will be unique for each frame, this CL moves it out of gf_group into cpi. Change-Id: Ie3972dbf58458f96ba9838b360e84494151c09eb
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c index a4ee6d5..9f68195 100644 --- a/av1/encoder/encode_strategy.c +++ b/av1/encoder/encode_strategy.c
@@ -168,7 +168,7 @@ static INLINE void update_gf_group_index(AV1_COMP *cpi) { // Increment the gf group index ready for the next frame. - ++cpi->gf_group.index; + ++cpi->gf_frame_index; } static void update_rc_counts(AV1_COMP *cpi) { @@ -216,7 +216,7 @@ // TODO(jingning): This table should be a lot simpler with the new // ARF system in place. Keep frame_params for the time being as we are // still evaluating a few design options. - switch (cpi->gf_group.layer_depth[cpi->gf_group.index]) { + switch (cpi->gf_group.layer_depth[cpi->gf_frame_index]) { case 0: return 0; case 1: return 1; case MAX_ARF_LAYERS: @@ -238,7 +238,7 @@ // In large scale case, always use Last frame's frame contexts. // Note(yunqing): In other cases, primary_ref_frame is chosen based on - // cpi->gf_group.layer_depth[cpi->gf_group.index], which also controls + // cpi->gf_group.layer_depth[cpi->gf_frame_index], which also controls // frame bit allocation. if (cm->tiles.large_scale) return (LAST_FRAME - LAST_FRAME); @@ -376,7 +376,7 @@ struct lookahead_entry *source = NULL; // Source index in lookahead buffer. - int src_index = gf_group->arf_src_offset[gf_group->index]; + int src_index = gf_group->arf_src_offset[cpi->gf_frame_index]; // TODO(Aasaipriya): Forced key frames need to be fixed when rc_mode != AOM_Q if (src_index && @@ -395,7 +395,7 @@ // If this is a key frame and keyframe filtering is enabled with overlay, // then do not pop. if (*pop_lookahead && cpi->oxcf.kf_cfg.enable_keyframe_filtering > 1 && - gf_group->update_type[gf_group->index] == ARF_UPDATE && + gf_group->update_type[cpi->gf_frame_index] == ARF_UPDATE && !is_stat_generation_stage(cpi) && cpi->ppi->lookahead) { if (cpi->ppi->lookahead->read_ctxs[cpi->compressor_stage].sz && (*flush || @@ -873,7 +873,8 @@ const AV1EncoderConfig *const oxcf = &cpi->oxcf; AV1_COMMON *const cm = &cpi->common; const GF_GROUP *const gf_group = &cpi->gf_group; - FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); // Decide whether to apply temporal filtering to the source frame. int apply_filtering = 0; @@ -911,7 +912,7 @@ int show_existing_alt_ref = 0; // TODO(bohanli): figure out why we need frame_type in cm here. cm->current_frame.frame_type = frame_params->frame_type; - int arf_src_index = gf_group->arf_src_offset[gf_group->index]; + int arf_src_index = gf_group->arf_src_offset[cpi->gf_frame_index]; int is_forward_keyframe = 0; if (!frame_params->show_frame && cpi->no_show_fwd_kf) { // TODO(angiebird): Figure out why this condition yields forward keyframe. @@ -944,12 +945,12 @@ // Don't do tpl for fwd key frames or fwd key frame overlays allow_tpl = allow_tpl && !cpi->sf.tpl_sf.disable_filtered_key_tpl && !cpi->no_show_fwd_kf && - gf_group->update_type[gf_group->index] != OVERLAY_UPDATE; + gf_group->update_type[cpi->gf_frame_index] != OVERLAY_UPDATE; } else { // Do tpl after ARF is filtered, or if no ARF, at the second frame of GF // group. // TODO(bohanli): if no ARF, just do it at the first frame. - int gf_index = gf_group->index; + int gf_index = cpi->gf_frame_index; allow_tpl = allow_tpl && (gf_group->update_type[gf_index] == ARF_UPDATE || gf_group->update_type[gf_index] == GF_UPDATE); if (allow_tpl) { @@ -962,7 +963,7 @@ if (allow_tpl == 0) { // Avoid the use of unintended TPL stats from previous GOP's results. - if (gf_group->index == 0) av1_init_tpl_stats(&cpi->tpl_data); + if (cpi->gf_frame_index == 0) av1_init_tpl_stats(&cpi->tpl_data); } else { if (!cpi->tpl_data.skip_tpl_setup_stats) av1_tpl_setup_stats(cpi, 0, frame_params, frame_input); @@ -1148,19 +1149,19 @@ // If this is a forward keyframe, mark as a show_existing_frame // TODO(bohanli): find a consistent condition for fwd keyframes if (oxcf->kf_cfg.fwd_kf_enabled && - gf_group->update_type[gf_group->index] == OVERLAY_UPDATE && + gf_group->update_type[cpi->gf_frame_index] == OVERLAY_UPDATE && cpi->rc.frames_to_key == 0) { frame_params.show_existing_frame = 1; } else { frame_params.show_existing_frame = (cpi->show_existing_alt_ref && - gf_group->update_type[gf_group->index] == OVERLAY_UPDATE) || - gf_group->update_type[gf_group->index] == INTNL_OVERLAY_UPDATE; + gf_group->update_type[cpi->gf_frame_index] == OVERLAY_UPDATE) || + gf_group->update_type[cpi->gf_frame_index] == INTNL_OVERLAY_UPDATE; } frame_params.show_existing_frame &= allow_show_existing(cpi, *frame_flags); // Reset show_existing_alt_ref decision to 0 after it is used. - if (gf_group->update_type[gf_group->index] == OVERLAY_UPDATE) { + if (gf_group->update_type[cpi->gf_frame_index] == OVERLAY_UPDATE) { cpi->show_existing_alt_ref = 0; } } else { @@ -1228,17 +1229,18 @@ av1_get_one_pass_rt_params(cpi, &frame_params, *frame_flags); if (cpi->oxcf.speed >= 5 && cm->number_spatial_layers == 1 && cm->number_temporal_layers == 1) - av1_set_reference_structure_one_pass_rt(cpi, gf_group->index == 0); + av1_set_reference_structure_one_pass_rt(cpi, cpi->gf_frame_index == 0); #else if (use_one_pass_rt_params) { av1_get_one_pass_rt_params(cpi, &frame_params, *frame_flags); if (cpi->oxcf.speed >= 5 && cm->number_spatial_layers == 1 && cm->number_temporal_layers == 1) - av1_set_reference_structure_one_pass_rt(cpi, gf_group->index == 0); + av1_set_reference_structure_one_pass_rt(cpi, cpi->gf_frame_index == 0); } #endif - FRAME_UPDATE_TYPE frame_update_type = get_frame_update_type(gf_group); + FRAME_UPDATE_TYPE frame_update_type = + get_frame_update_type(gf_group, cpi->gf_frame_index); if (frame_params.show_existing_frame && frame_params.frame_type != KEY_FRAME) { @@ -1321,7 +1323,7 @@ frame_params.primary_ref_frame = choose_primary_ref_frame(cpi, &frame_params); - frame_params.order_offset = gf_group->arf_src_offset[gf_group->index]; + frame_params.order_offset = gf_group->arf_src_offset[cpi->gf_frame_index]; frame_params.refresh_frame_flags = av1_get_refresh_frame_flags( cpi, &frame_params, frame_update_type, &cpi->ref_buffer_stack);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 63e3158..35305ed 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -329,7 +329,7 @@ const GF_GROUP *const gf_group = &cpi->gf_group; const CommonModeInfoParams *const mi_params = &cm->mi_params; MACROBLOCK *x = &td->mb; - const int frame_idx = cpi->gf_group.index; + const int frame_idx = cpi->gf_frame_index; TplParams *const tpl_data = &cpi->tpl_data; TplDepFrame *tpl_frame = &tpl_data->tpl_frame[frame_idx]; const uint8_t block_mis_log2 = tpl_data->tpl_stats_block_mis_log2; @@ -337,7 +337,7 @@ av1_zero(x->tpl_keep_ref_frame); if (tpl_frame->is_valid == 0) return; - if (!is_frame_tpl_eligible(gf_group, gf_group->index)) return; + if (!is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) return; if (frame_idx >= MAX_TPL_FRAME_IDX) return; if (cpi->oxcf.q_cfg.aq_mode != NO_AQ) return; @@ -430,8 +430,8 @@ const int orig_rdmult = cpi->rd.RDMULT; assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); - const int gf_group_index = cpi->gf_group.index; + cpi->gf_frame_index < cpi->gf_group.size)); + const int gf_group_index = cpi->gf_frame_index; if (cpi->oxcf.algo_cfg.enable_tpl_model && cpi->oxcf.q_cfg.aq_mode == NO_AQ && cpi->oxcf.q_cfg.deltaq_mode == NO_DELTA_Q && gf_group_index > 0 && cpi->gf_group.update_type[gf_group_index] == ARF_UPDATE) { @@ -1281,7 +1281,8 @@ if (features->allow_warped_motion && cpi->sf.inter_sf.prune_warped_prob_thresh > 0) { - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); if (frame_probs->warped_probs[update_type] < cpi->sf.inter_sf.prune_warped_prob_thresh) features->allow_warped_motion = 0; @@ -1383,7 +1384,7 @@ const GF_GROUP *gf_group = &cpi->gf_group; if (cm->delta_q_info.delta_q_present_flag) { if (deltaq_mode == DELTA_Q_OBJECTIVE && - !is_frame_tpl_eligible(gf_group, gf_group->index)) + !is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) cm->delta_q_info.delta_q_present_flag = 0; } @@ -1503,7 +1504,8 @@ features->tx_mode = select_tx_mode(cm, tx_search_type); if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) { - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); for (i = 0; i < TX_SIZES_ALL; i++) { int sum = 0; @@ -1528,7 +1530,8 @@ if (cpi->sf.inter_sf.prune_obmc_prob_thresh > 0 && cpi->sf.inter_sf.prune_obmc_prob_thresh < INT_MAX) { - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); for (i = 0; i < BLOCK_SIZES_ALL; i++) { int sum = 0; @@ -1543,7 +1546,8 @@ if (features->allow_warped_motion && cpi->sf.inter_sf.prune_warped_prob_thresh > 0) { - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); int sum = 0; for (i = 0; i < 2; i++) sum += cpi->td.rd_counts.warped_used[i]; const int new_prob = sum ? 128 * cpi->td.rd_counts.warped_used[1] / sum : 0; @@ -1554,7 +1558,8 @@ if (cm->current_frame.frame_type != KEY_FRAME && cpi->sf.interp_sf.adaptive_interp_filter_search == 2 && features->interp_filter == SWITCHABLE) { - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) { int sum = 0;
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c index 232db44..27f306f 100644 --- a/av1/encoder/encodeframe_utils.c +++ b/av1/encoder/encodeframe_utils.c
@@ -88,12 +88,13 @@ const AV1_COMMON *const cm = &cpi->common; const GF_GROUP *const gf_group = &cpi->gf_group; assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); - const int tpl_idx = cpi->gf_group.index; + cpi->gf_frame_index < cpi->gf_group.size)); + const int tpl_idx = cpi->gf_frame_index; const TplDepFrame *tpl_frame = &cpi->tpl_data.tpl_frame[tpl_idx]; const int deltaq_rdmult = set_deltaq_rdmult(cpi, x); if (tpl_frame->is_valid == 0) return deltaq_rdmult; - if (!is_frame_tpl_eligible(gf_group, gf_group->index)) return deltaq_rdmult; + if (!is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) + return deltaq_rdmult; if (tpl_idx >= MAX_TPL_FRAME_IDX) return deltaq_rdmult; if (cpi->oxcf.q_cfg.aq_mode != NO_AQ) return deltaq_rdmult; @@ -684,8 +685,8 @@ AV1_COMMON *const cm = &cpi->common; const GF_GROUP *const gf_group = &cpi->gf_group; assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); - const int tpl_idx = cpi->gf_group.index; + cpi->gf_frame_index < cpi->gf_group.size)); + const int tpl_idx = cpi->gf_frame_index; TplParams *const tpl_data = &cpi->tpl_data; TplDepFrame *tpl_frame = &tpl_data->tpl_frame[tpl_idx]; TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr; @@ -698,9 +699,9 @@ if (tpl_frame->is_valid == 0) return orig_rdmult; - if (!is_frame_tpl_eligible(gf_group, gf_group->index)) return orig_rdmult; + if (!is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) return orig_rdmult; - if (cpi->gf_group.index >= MAX_TPL_FRAME_IDX) return orig_rdmult; + if (cpi->gf_frame_index >= MAX_TPL_FRAME_IDX) return orig_rdmult; int mi_count = 0; const int mi_col_sr = @@ -814,14 +815,15 @@ if (!cpi->oxcf.algo_cfg.enable_tpl_model) return; if (cpi->common.current_frame.frame_type == KEY_FRAME) return; - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); if (update_type == INTNL_OVERLAY_UPDATE || update_type == OVERLAY_UPDATE) return; assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); + cpi->gf_frame_index < cpi->gf_group.size)); AV1_COMMON *const cm = &cpi->common; - const int gf_group_index = cpi->gf_group.index; + const int gf_group_index = cpi->gf_frame_index; TplParams *const tpl_data = &cpi->tpl_data; TplDepFrame *tpl_frame = &tpl_data->tpl_frame[gf_group_index]; TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr; @@ -891,8 +893,8 @@ AV1_COMMON *const cm = &cpi->common; const GF_GROUP *const gf_group = &cpi->gf_group; assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); - const int tpl_idx = cpi->gf_group.index; + cpi->gf_frame_index < cpi->gf_group.size)); + const int tpl_idx = cpi->gf_frame_index; TplParams *const tpl_data = &cpi->tpl_data; TplDepFrame *tpl_frame = &tpl_data->tpl_frame[tpl_idx]; TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr; @@ -906,9 +908,9 @@ if (tpl_frame->is_valid == 0) return base_qindex; - if (!is_frame_tpl_eligible(gf_group, gf_group->index)) return base_qindex; + if (!is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) return base_qindex; - if (cpi->gf_group.index >= MAX_TPL_FRAME_IDX) return base_qindex; + if (cpi->gf_frame_index >= MAX_TPL_FRAME_IDX) return base_qindex; int mi_count = 0; const int mi_col_sr =
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index 9407082..5c6333a 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -2904,8 +2904,8 @@ int superres_largest_tile_ids[SCALE_NUMERATOR]; // Use superres for Key-frames and Alt-ref frames only. const GF_GROUP *const gf_group = &cpi->gf_group; - if (gf_group->update_type[gf_group->index] != OVERLAY_UPDATE && - gf_group->update_type[gf_group->index] != INTNL_OVERLAY_UPDATE) { + if (gf_group->update_type[cpi->gf_frame_index] != OVERLAY_UPDATE && + gf_group->update_type[cpi->gf_frame_index] != INTNL_OVERLAY_UPDATE) { for (int denom = SCALE_NUMERATOR + 1; denom <= 2 * SCALE_NUMERATOR; ++denom) { superres_cfg->superres_scale_denominator = denom;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index b3135dc..994f691 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -2357,6 +2357,11 @@ GF_GROUP gf_group; /*! + * The frame processing order within a GOP. + */ + unsigned char gf_frame_index; + + /*! * Track prior gf group state. */ GF_STATE gf_state; @@ -2958,7 +2963,8 @@ static INLINE int frame_is_kf_gf_arf(const AV1_COMP *cpi) { const GF_GROUP *const gf_group = &cpi->gf_group; - const FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_group->index]; + const FRAME_UPDATE_TYPE update_type = + gf_group->update_type[cpi->gf_frame_index]; return frame_is_intra_only(&cpi->common) || update_type == ARF_UPDATE || update_type == GF_UPDATE; @@ -3237,9 +3243,9 @@ } // Get update type of the current frame. -static INLINE FRAME_UPDATE_TYPE -get_frame_update_type(const GF_GROUP *gf_group) { - return gf_group->update_type[gf_group->index]; +static INLINE FRAME_UPDATE_TYPE get_frame_update_type(const GF_GROUP *gf_group, + int gf_frame_index) { + return gf_group->update_type[gf_frame_index]; } static INLINE int av1_pixels_to_mi(int pixels) {
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c index c3d0cf8..db6a763 100644 --- a/av1/encoder/encoder_utils.c +++ b/av1/encoder/encoder_utils.c
@@ -462,9 +462,9 @@ const GF_GROUP *const gf_group = &cpi->gf_group; AV1_COMMON *const cm = &cpi->common; - assert(IMPLIES(gf_group->size > 0, gf_group->index < gf_group->size)); + assert(IMPLIES(gf_group->size > 0, cpi->gf_frame_index < gf_group->size)); - const int tpl_idx = gf_group->index; + const int tpl_idx = cpi->gf_frame_index; TplParams *const tpl_data = &cpi->tpl_data; TplDepFrame *tpl_frame = &tpl_data->tpl_frame[tpl_idx]; TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr; @@ -497,7 +497,7 @@ } else { aom_clear_system_state(); cpi->rd.r0 = (double)intra_cost_base / mc_dep_cost_base; - if (is_frame_tpl_eligible(gf_group, gf_group->index)) { + if (is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) { if (cpi->lap_enabled) { double min_boost_factor = sqrt(cpi->rc.baseline_gf_interval); const int gfu_boost = get_gfu_boost_from_r0_lap( @@ -531,7 +531,7 @@ #if !CONFIG_REALTIME_ONLY GF_GROUP *gf_group = &cpi->gf_group; if (cpi->oxcf.algo_cfg.enable_tpl_model && - is_frame_tpl_eligible(gf_group, gf_group->index)) { + is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) { process_tpl_stats_frame(cpi); av1_tpl_rdmult_setup(cpi); } @@ -539,7 +539,7 @@ // Decide q and q bounds. *q = av1_rc_pick_q_and_bounds(cpi, &cpi->rc, cm->width, cm->height, - cpi->gf_group.index, bottom_index, top_index); + cpi->gf_frame_index, bottom_index, top_index); // Configure experimental use of segmentation for enhanced coding of // static regions if indicated. @@ -1301,8 +1301,8 @@ "show_frame=%d, show_existing_frame=%d, source_alt_ref_active=%d, " "refresh_alt_ref_frame=%d, " "y_stride=%4d, uv_stride=%4d, cm->width=%4d, cm->height=%4d\n\n", - current_frame->frame_number, cpi->gf_group.index, - cpi->gf_group.update_type[cpi->gf_group.index], current_frame->order_hint, + current_frame->frame_number, cpi->gf_frame_index, + cpi->gf_group.update_type[cpi->gf_frame_index], current_frame->order_hint, cm->show_frame, cm->show_existing_frame, cpi->rc.source_alt_ref_active, cpi->refresh_frame.alt_ref_frame, recon_buf->y_stride, recon_buf->uv_stride, cm->width, cm->height);
diff --git a/av1/encoder/firstpass.h b/av1/encoder/firstpass.h index 22969e8..e3706d9 100644 --- a/av1/encoder/firstpass.h +++ b/av1/encoder/firstpass.h
@@ -170,8 +170,6 @@ */ typedef struct { /*!\cond */ - // The frame processing order within a GOP - unsigned char index; // Frame update type, e.g. ARF/GF/LF/Overlay FRAME_UPDATE_TYPE update_type[MAX_STATIC_GF_GROUP_LENGTH]; unsigned char arf_src_offset[MAX_STATIC_GF_GROUP_LENGTH];
diff --git a/av1/encoder/global_motion_facade.c b/av1/encoder/global_motion_facade.c index 31c69da..3a7af51 100644 --- a/av1/encoder/global_motion_facade.c +++ b/av1/encoder/global_motion_facade.c
@@ -286,7 +286,7 @@ int *num_future_ref_frames = &num_ref_frames[1]; const GF_GROUP *gf_group = &cpi->gf_group; int ref_pruning_enabled = is_frame_eligible_for_ref_pruning( - gf_group, cpi->sf.inter_sf.selective_ref_frame, 1, gf_group->index); + gf_group, cpi->sf.inter_sf.selective_ref_frame, 1, cpi->gf_frame_index); for (int frame = ALTREF_FRAME; frame >= LAST_FRAME; --frame) { const MV_REFERENCE_FRAME ref_frame[2] = { frame, NONE_FRAME };
diff --git a/av1/encoder/interp_search.c b/av1/encoder/interp_search.c index 0066c35..6d4f4ec 100644 --- a/av1/encoder/interp_search.c +++ b/av1/encoder/interp_search.c
@@ -449,7 +449,8 @@ interp_search_flags->interp_filter_search_mask; if (cpi->sf.interp_sf.adaptive_interp_filter_search == 2) { - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); const int ctx0 = av1_get_pred_context_switchable_interp(xd, 0); const int ctx1 = av1_get_pred_context_switchable_interp(xd, 1); const int *switchable_interp_p0 =
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c index 96b77b7..198bcd8 100644 --- a/av1/encoder/motion_search_facade.c +++ b/av1/encoder/motion_search_facade.c
@@ -41,7 +41,7 @@ // Allow more mesh searches for screen content type on the ARF. static int use_fine_search_interval(const AV1_COMP *const cpi) { return cpi->is_screen_content_type && - cpi->gf_group.update_type[cpi->gf_group.index] == ARF_UPDATE && + cpi->gf_group.update_type[cpi->gf_frame_index] == ARF_UPDATE && cpi->oxcf.speed <= 2; }
diff --git a/av1/encoder/mv_prec.h b/av1/encoder/mv_prec.h index 89f95f5..05a95ee 100644 --- a/av1/encoder/mv_prec.h +++ b/av1/encoder/mv_prec.h
@@ -21,7 +21,7 @@ void av1_collect_mv_stats(AV1_COMP *cpi, int current_q); static AOM_INLINE int av1_frame_allows_smart_mv(const AV1_COMP *cpi) { - const int gf_group_index = cpi->gf_group.index; + const int gf_group_index = cpi->gf_frame_index; const int gf_update_type = cpi->gf_group.update_type[gf_group_index]; return !frame_is_intra_only(&cpi->common) && !(gf_update_type == INTNL_OVERLAY_UPDATE ||
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c index 47f7414..2c1897d 100644 --- a/av1/encoder/partition_search.c +++ b/av1/encoder/partition_search.c
@@ -4267,7 +4267,7 @@ // prediction block. print_partition_timing_stats_with_rdcost( part_timing_stats, mi_row, mi_col, bsize, - cpi->gf_group.update_type[cpi->gf_group.index], + cpi->gf_group.update_type[cpi->gf_frame_index], cm->current_frame.frame_number, &best_rdc, "part_timing.csv"); /* print_partition_timing_stats(part_timing_stats, cm->show_frame,
diff --git a/av1/encoder/partition_strategy.h b/av1/encoder/partition_strategy.h index 0527a94..ee890bb 100644 --- a/av1/encoder/partition_strategy.h +++ b/av1/encoder/partition_strategy.h
@@ -268,15 +268,15 @@ BLOCK_SIZE sb_size, int mi_row, int mi_col) { assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); + cpi->gf_frame_index < cpi->gf_group.size)); const AV1_COMMON *const cm = &cpi->common; return !frame_is_intra_only(cm) && !cpi->use_screen_content_tools && cpi->sf.part_sf.auto_max_partition_based_on_simple_motion != NOT_IN_USE && sb_size == BLOCK_128X128 && is_full_sb(&cm->mi_params, mi_row, mi_col, sb_size) && - cpi->gf_group.update_type[cpi->gf_group.index] != OVERLAY_UPDATE && - cpi->gf_group.update_type[cpi->gf_group.index] != INTNL_OVERLAY_UPDATE; + cpi->gf_group.update_type[cpi->gf_frame_index] != OVERLAY_UPDATE && + cpi->gf_group.update_type[cpi->gf_frame_index] != INTNL_OVERLAY_UPDATE; } #endif // AOM_AV1_ENCODER_PARTITION_STRATEGY_H_
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c index 2ff82d9..4cd2ea3 100644 --- a/av1/encoder/pass2_strategy.c +++ b/av1/encoder/pass2_strategy.c
@@ -2345,6 +2345,7 @@ // frame in which case it will already have been done. if (!is_intra_only) { av1_zero(cpi->gf_group); + cpi->gf_frame_index = 0; } aom_clear_system_state(); @@ -2627,8 +2628,8 @@ frame_params->frame_type = rc->frames_since_key == 0 ? KEY_FRAME : INTER_FRAME; frame_params->show_frame = - !(gf_group->update_type[gf_group->index] == ARF_UPDATE || - gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE); + !(gf_group->update_type[cpi->gf_frame_index] == ARF_UPDATE || + gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE); // TODO(jingning): Generalize this condition. if (is_final_pass) { @@ -3170,6 +3171,7 @@ // Reset the GF group data structures. av1_zero(*gf_group); + cpi->gf_frame_index = 0; // KF is always a GF so clear frames till next gf counter. rc->frames_till_gf_update_due = 0; @@ -3425,7 +3427,7 @@ TWO_PASS *const twopass = &cpi->twopass; if (cpi->oxcf.rc_cfg.mode != AOM_Q && current_frame->frame_number == 0 && - cpi->gf_group.index == 0 && cpi->twopass.stats_buf_ctx->total_stats && + cpi->gf_frame_index == 0 && cpi->twopass.stats_buf_ctx->total_stats && cpi->twopass.stats_buf_ctx->total_left_stats) { if (cpi->lap_enabled) { /* @@ -3490,7 +3492,7 @@ RATE_CONTROL *const rc = &cpi->rc; GF_GROUP *const gf_group = &cpi->gf_group; - int target_rate = gf_group->bit_allocation[gf_group->index]; + int target_rate = gf_group->bit_allocation[cpi->gf_frame_index]; if (has_no_stats_stage(cpi)) { av1_rc_set_frame_target(cpi, target_rate, cpi->common.width, @@ -3513,11 +3515,11 @@ if (is_stat_consumption_stage(cpi) && !twopass->stats_in) return; - const int update_type = gf_group->update_type[gf_group->index]; - frame_params->frame_type = gf_group->frame_type[gf_group->index]; + const int update_type = gf_group->update_type[cpi->gf_frame_index]; + frame_params->frame_type = gf_group->frame_type[cpi->gf_frame_index]; - if (gf_group->index < gf_group->size && !(frame_flags & FRAMEFLAGS_KEY)) { - assert(gf_group->index < gf_group->size); + if (cpi->gf_frame_index < gf_group->size && !(frame_flags & FRAMEFLAGS_KEY)) { + assert(cpi->gf_frame_index < gf_group->size); setup_target_rate(cpi); @@ -3541,7 +3543,7 @@ av1_zero(this_frame); // call above fn if (is_stat_consumption_stage(cpi)) { - if (gf_group->index < gf_group->size || rc->frames_to_key == 0) + if (cpi->gf_frame_index < gf_group->size || rc->frames_to_key == 0) process_first_pass_stats(cpi, &this_frame); } else { rc->active_worst_quality = oxcf->rc_cfg.cq_level; @@ -3552,7 +3554,7 @@ this_frame_copy = this_frame; int is_overlay_forward_kf = rc->frames_to_key == 0 && - gf_group->update_type[gf_group->index] == OVERLAY_UPDATE; + gf_group->update_type[cpi->gf_frame_index] == OVERLAY_UPDATE; if (rc->frames_to_key <= 0 && !is_overlay_forward_kf) { assert(rc->frames_to_key >= -1); // Define next KF group and assign bits to it. @@ -3602,9 +3604,9 @@ } // Define a new GF/ARF group. (Should always enter here for key frames). - if (gf_group->index == gf_group->size) { + if (cpi->gf_frame_index == gf_group->size) { assert(cpi->common.current_frame.frame_number == 0 || - gf_group->index == gf_group->size); + cpi->gf_frame_index == gf_group->size); const FIRSTPASS_STATS *const start_position = twopass->stats_in; if (cpi->lap_enabled && cpi->rc.enable_scenecut_detection) { @@ -3717,14 +3719,14 @@ } define_gf_group(cpi, &this_frame, frame_params, max_gop_length, 0); - if (gf_group->update_type[gf_group->index] != ARF_UPDATE && + if (gf_group->update_type[cpi->gf_frame_index] != ARF_UPDATE && rc->frames_since_key > 0) process_first_pass_stats(cpi, &this_frame); define_gf_group(cpi, &this_frame, frame_params, max_gop_length, 1); rc->frames_till_gf_update_due = rc->baseline_gf_interval; - assert(gf_group->index == 0); + assert(cpi->gf_frame_index == 0); #if ARF_STATS_OUTPUT { FILE *fpfile; @@ -3739,10 +3741,10 @@ } #endif } - assert(gf_group->index < gf_group->size); + assert(cpi->gf_frame_index < gf_group->size); - if (gf_group->update_type[gf_group->index] == ARF_UPDATE || - gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE) { + if (gf_group->update_type[cpi->gf_frame_index] == ARF_UPDATE || + gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE) { reset_fpf_position(twopass, start_pos); } else { // Update the total stats remaining structure. @@ -3751,7 +3753,7 @@ &this_frame_copy); } - frame_params->frame_type = gf_group->frame_type[gf_group->index]; + frame_params->frame_type = gf_group->frame_type[cpi->gf_frame_index]; // Do the firstpass stats indicate that this frame is skippable for the // partition search? @@ -3888,7 +3890,7 @@ // Update the active best quality pyramid. if (!rc->is_src_frame_alt_ref) { - const int pyramid_level = cpi->gf_group.layer_depth[cpi->gf_group.index]; + const int pyramid_level = cpi->gf_group.layer_depth[cpi->gf_frame_index]; int i; for (i = pyramid_level; i <= MAX_ARF_LAYERS; ++i) { rc->active_best_quality[i] = cpi->common.quant_params.base_qindex;
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c index d1f0893..3ab1597 100644 --- a/av1/encoder/ratectrl.c +++ b/av1/encoder/ratectrl.c
@@ -452,8 +452,9 @@ GF_ARF_LOW, // INTNL_ARF_UPDATE }; -static RATE_FACTOR_LEVEL get_rate_factor_level(const GF_GROUP *const gf_group) { - const FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_group->index]; +static RATE_FACTOR_LEVEL get_rate_factor_level(const GF_GROUP *const gf_group, + int gf_frame_index) { + const FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_frame_index]; assert(update_type < FRAME_UPDATE_TYPES); return rate_factor_levels[update_type]; } @@ -480,7 +481,8 @@ if (cpi->common.current_frame.frame_type == KEY_FRAME) { rcf = rc->rate_correction_factors[KF_STD]; } else if (is_stat_consumption_stage(cpi)) { - const RATE_FACTOR_LEVEL rf_lvl = get_rate_factor_level(&cpi->gf_group); + const RATE_FACTOR_LEVEL rf_lvl = + get_rate_factor_level(&cpi->gf_group, cpi->gf_frame_index); rcf = rc->rate_correction_factors[rf_lvl]; } else { if ((refresh_frame_flags->alt_ref_frame || @@ -524,7 +526,8 @@ if (cpi->common.current_frame.frame_type == KEY_FRAME) { rc->rate_correction_factors[KF_STD] = factor; } else if (is_stat_consumption_stage(cpi)) { - const RATE_FACTOR_LEVEL rf_lvl = get_rate_factor_level(&cpi->gf_group); + const RATE_FACTOR_LEVEL rf_lvl = + get_rate_factor_level(&cpi->gf_group, cpi->gf_frame_index); rc->rate_correction_factors[rf_lvl] = factor; } else { if ((refresh_frame_flags->alt_ref_frame || @@ -1252,9 +1255,10 @@ 1.0 }; int av1_frame_type_qdelta(const AV1_COMP *cpi, int q) { const GF_GROUP *const gf_group = &cpi->gf_group; - const RATE_FACTOR_LEVEL rf_lvl = get_rate_factor_level(gf_group); - const FRAME_TYPE frame_type = gf_group->frame_type[gf_group->index]; - const int arf_layer = AOMMIN(gf_group->layer_depth[gf_group->index], 6); + const RATE_FACTOR_LEVEL rf_lvl = + get_rate_factor_level(gf_group, cpi->gf_frame_index); + const FRAME_TYPE frame_type = gf_group->frame_type[cpi->gf_frame_index]; + const int arf_layer = AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], 6); const double rate_factor = (rf_lvl == INTER_NORMAL) ? 1.0 : arf_layer_deltas[arf_layer]; @@ -1597,7 +1601,7 @@ const int bit_depth = cm->seq_params.bit_depth; if (oxcf->q_cfg.use_fixed_qp_offsets) { - return get_q_using_fixed_offsets(oxcf, rc, gf_group, gf_group->index, + return get_q_using_fixed_offsets(oxcf, rc, gf_group, cpi->gf_frame_index, cq_level, bit_depth); } @@ -1760,7 +1764,7 @@ const RefreshFrameFlagsInfo *const refresh_frame_flags = &cpi->refresh_frame; const int is_intrnl_arf = - gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE; + gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; const int qindex = cm->quant_params.base_qindex; @@ -2367,7 +2371,7 @@ rc->constrained_gf_group = (rc->baseline_gf_interval >= rc->frames_to_key) ? 1 : 0; rc->frames_till_gf_update_due = rc->baseline_gf_interval; - gf_group->index = 0; + cpi->gf_frame_index = 0; // SVC does not use GF as periodic boost. // TODO(marpan): Find better way to disable this for SVC. if (cpi->use_svc) { @@ -2574,9 +2578,9 @@ cm->current_frame.frame_number != 0 && rc->frames_to_key == 0; rc->frames_to_key = cpi->oxcf.kf_cfg.key_freq_max; rc->kf_boost = DEFAULT_KF_BOOST_RT; - gf_group->update_type[gf_group->index] = KF_UPDATE; - gf_group->frame_type[gf_group->index] = KEY_FRAME; - gf_group->refbuf_state[gf_group->index] = REFBUF_RESET; + gf_group->update_type[cpi->gf_frame_index] = KF_UPDATE; + gf_group->frame_type[cpi->gf_frame_index] = KEY_FRAME; + gf_group->refbuf_state[cpi->gf_frame_index] = REFBUF_RESET; if (cpi->use_svc) { if (cm->current_frame.frame_number > 0) av1_svc_reset_temporal_layers(cpi, 1); @@ -2584,9 +2588,9 @@ } } else { frame_params->frame_type = INTER_FRAME; - gf_group->update_type[gf_group->index] = LF_UPDATE; - gf_group->frame_type[gf_group->index] = INTER_FRAME; - gf_group->refbuf_state[gf_group->index] = REFBUF_UPDATE; + gf_group->update_type[cpi->gf_frame_index] = LF_UPDATE; + gf_group->frame_type[cpi->gf_frame_index] = INTER_FRAME; + gf_group->refbuf_state[cpi->gf_frame_index] = REFBUF_UPDATE; if (cpi->use_svc) { LAYER_CONTEXT *lc = &svc->layer_context[layer]; lc->is_key_frame = @@ -2628,14 +2632,14 @@ target = av1_calc_iframe_target_size_one_pass_cbr(cpi); } else { target = av1_calc_pframe_target_size_one_pass_cbr( - cpi, gf_group->update_type[gf_group->index]); + cpi, gf_group->update_type[cpi->gf_frame_index]); } } else { if (frame_params->frame_type == KEY_FRAME) { target = av1_calc_iframe_target_size_one_pass_vbr(cpi); } else { target = av1_calc_pframe_target_size_one_pass_vbr( - cpi, gf_group->update_type[gf_group->index]); + cpi, gf_group->update_type[cpi->gf_frame_index]); } } if (cpi->oxcf.rc_cfg.mode == AOM_Q)
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c index aedb10e..6260ade 100644 --- a/av1/encoder/rd.c +++ b/av1/encoder/rd.c
@@ -375,7 +375,8 @@ (cpi->common.current_frame.frame_type != KEY_FRAME)) { const GF_GROUP *const gf_group = &cpi->gf_group; const int boost_index = AOMMIN(15, (cpi->rc.gfu_boost / 100)); - const int layer_depth = AOMMIN(gf_group->layer_depth[gf_group->index], 6); + const int layer_depth = + AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], 6); // Layer depth adjustment rdmult = (rdmult * rd_layer_depth_factor[layer_depth]) >> 7;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 8cea21b..a695335 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -1355,7 +1355,8 @@ // Do not search OBMC if the probability of selecting it is below a // predetermined threshold for this update_type and block size. - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); const int prune_obmc = cpi->frame_probs.obmc_probs[update_type][bsize] < cpi->sf.inter_sf.prune_obmc_prob_thresh; if ((!cpi->oxcf.motion_mode_cfg.enable_obmc || @@ -2171,11 +2172,11 @@ static AOM_INLINE void get_block_level_tpl_stats( AV1_COMP *cpi, BLOCK_SIZE bsize, int mi_row, int mi_col, int *valid_refs, PruneInfoFromTpl *inter_cost_info_from_tpl) { - const GF_GROUP *const gf_group = &cpi->gf_group; AV1_COMMON *const cm = &cpi->common; - assert(IMPLIES(gf_group->size > 0, gf_group->index < gf_group->size)); - const int tpl_idx = gf_group->index; + assert(IMPLIES(cpi->gf_group.size > 0, + cpi->gf_frame_index < cpi->gf_group.size)); + const int tpl_idx = cpi->gf_frame_index; TplParams *const tpl_data = &cpi->tpl_data; const TplDepFrame *tpl_frame = &tpl_data->tpl_frame[tpl_idx]; if (tpl_idx >= MAX_TPL_FRAME_IDX || !tpl_frame->is_valid) { @@ -2589,8 +2590,7 @@ const int is_comp_pred = has_second_ref(mbmi); const PREDICTION_MODE this_mode = mbmi->mode; - const GF_GROUP *const gf_group = &cpi->gf_group; - const int tpl_idx = gf_group->index; + const int tpl_idx = cpi->gf_frame_index; TplDepFrame *tpl_frame = &cpi->tpl_data.tpl_frame[tpl_idx]; const int prune_modes_based_on_tpl = cpi->sf.inter_sf.prune_inter_modes_based_on_tpl && @@ -3807,7 +3807,8 @@ } av1_count_overlappable_neighbors(cm, xd); - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); const int prune_obmc = cpi->frame_probs.obmc_probs[update_type][bsize] < cpi->sf.inter_sf.prune_obmc_prob_thresh; if (cpi->oxcf.motion_mode_cfg.enable_obmc && !prune_obmc) {
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c index d3d8008..24e5136 100644 --- a/av1/encoder/speed_features.c +++ b/av1/encoder/speed_features.c
@@ -656,7 +656,7 @@ const GF_GROUP *const gf_group = &cpi->gf_group; const int boosted = frame_is_boosted(cpi); const int is_boosted_arf2_bwd_type = - boosted || gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE; + boosted || gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; const int allow_screen_content_tools = cm->features.allow_screen_content_tools; const int use_hbd = cpi->oxcf.use_highbitdepth; @@ -878,10 +878,10 @@ frame_is_intra_only(&cpi->common) ? 0 : 1; sf->winner_mode_sf.enable_winner_mode_for_use_tx_domain_dist = 1; sf->winner_mode_sf.motion_mode_for_winner_cand = - boosted - ? 0 - : gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE ? 1 - : 2; + boosted ? 0 + : gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE + ? 1 + : 2; // TODO(any): evaluate if these lpf features can be moved to speed 2. // For screen content, "prune_sgr_based_on_wiener = 2" cause large quality @@ -1831,7 +1831,7 @@ const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; const int is_arf2_bwd_type = - cpi->gf_group.update_type[cpi->gf_group.index] == INTNL_ARF_UPDATE; + cpi->gf_group.update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; if (cpi->oxcf.mode == REALTIME) return;
diff --git a/av1/encoder/superres_scale.c b/av1/encoder/superres_scale.c index bcd3fef..fb892de 100644 --- a/av1/encoder/superres_scale.c +++ b/av1/encoder/superres_scale.c
@@ -109,12 +109,13 @@ #define SUPERRES_ENERGY_BY_AC_THRESH 0.2 static double get_energy_by_q2_thresh(const GF_GROUP *gf_group, - const RATE_CONTROL *rc) { + const RATE_CONTROL *rc, + int gf_frame_index) { // TODO(now): Return keyframe thresh * factor based on frame type / pyramid // level. - if (gf_group->update_type[gf_group->index] == ARF_UPDATE) { + if (gf_group->update_type[gf_frame_index] == ARF_UPDATE) { return SUPERRES_ENERGY_BY_Q2_THRESH_ARFFRAME; - } else if (gf_group->update_type[gf_group->index] == KF_UPDATE) { + } else if (gf_group->update_type[gf_frame_index] == KF_UPDATE) { if (rc->frames_to_key <= 1) return SUPERRES_ENERGY_BY_Q2_THRESH_KEYFRAME_SOLO; else @@ -143,14 +144,14 @@ int sr_kf, int sr_arf) { // Use superres for Key-frames and Alt-ref frames only. const GF_GROUP *gf_group = &cpi->gf_group; - if (gf_group->update_type[gf_group->index] != KF_UPDATE && - gf_group->update_type[gf_group->index] != ARF_UPDATE) { + if (gf_group->update_type[cpi->gf_frame_index] != KF_UPDATE && + gf_group->update_type[cpi->gf_frame_index] != ARF_UPDATE) { return SCALE_NUMERATOR; } - if (gf_group->update_type[gf_group->index] == KF_UPDATE && !sr_kf) { + if (gf_group->update_type[cpi->gf_frame_index] == KF_UPDATE && !sr_kf) { return SCALE_NUMERATOR; } - if (gf_group->update_type[gf_group->index] == ARF_UPDATE && !sr_arf) { + if (gf_group->update_type[cpi->gf_frame_index] == ARF_UPDATE && !sr_arf) { return SCALE_NUMERATOR; } @@ -158,7 +159,7 @@ analyze_hor_freq(cpi, energy); const double energy_by_q2_thresh = - get_energy_by_q2_thresh(gf_group, &cpi->rc); + get_energy_by_q2_thresh(gf_group, &cpi->rc, cpi->gf_frame_index); int denom = get_superres_denom_from_qindex_energy( qindex, energy, energy_by_q2_thresh, SUPERRES_ENERGY_BY_AC_THRESH); /* @@ -166,7 +167,7 @@ for (int k = 1; k < 16; ++k) printf("%f, ", energy[k]); printf("]\n"); printf("boost = %d\n", - (gf_group->update_type[gf_group->index] == KF_UPDATE) + (gf_group->update_type[cpi->gf_frame_index] == KF_UPDATE) ? cpi->rc.kf_boost : cpi->rc.gfu_boost); printf("denom = %d\n", denom); @@ -223,7 +224,7 @@ int bottom_index, top_index; const int q = av1_rc_pick_q_and_bounds( cpi, &cpi->rc, frm_dim_cfg->width, frm_dim_cfg->height, - cpi->gf_group.index, &bottom_index, &top_index); + cpi->gf_frame_index, &bottom_index, &top_index); const int qthresh = (frame_is_intra_only(&cpi->common)) ? superres_cfg->superres_kf_qthresh @@ -244,7 +245,7 @@ int bottom_index, top_index; const int q = av1_rc_pick_q_and_bounds( cpi, &cpi->rc, frm_dim_cfg->width, frm_dim_cfg->height, - cpi->gf_group.index, &bottom_index, &top_index); + cpi->gf_frame_index, &bottom_index, &top_index); const SUPERRES_AUTO_SEARCH_TYPE sr_search_type = cpi->sf.hl_sf.superres_auto_search_type;
diff --git a/av1/encoder/svc_layercontext.c b/av1/encoder/svc_layercontext.c index f76b34c..8e3fbf0 100644 --- a/av1/encoder/svc_layercontext.c +++ b/av1/encoder/svc_layercontext.c
@@ -165,7 +165,6 @@ } void av1_restore_layer_context(AV1_COMP *const cpi) { - GF_GROUP *const gf_group = &cpi->gf_group; SVC *const svc = &cpi->svc; const AV1_COMMON *const cm = &cpi->common; LAYER_CONTEXT *const lc = get_layer_context(cpi); @@ -174,7 +173,7 @@ // Restore layer rate control. cpi->rc = lc->rc; cpi->oxcf.rc_cfg.target_bandwidth = lc->target_bandwidth; - gf_group->index = 0; + cpi->gf_frame_index = 0; cpi->mv_search_params.max_mv_magnitude = lc->max_mv_magnitude; if (cpi->mv_search_params.max_mv_magnitude == 0) cpi->mv_search_params.max_mv_magnitude = AOMMAX(cm->width, cm->height); @@ -212,13 +211,12 @@ } void av1_save_layer_context(AV1_COMP *const cpi) { - GF_GROUP *const gf_group = &cpi->gf_group; SVC *const svc = &cpi->svc; const AV1_COMMON *const cm = &cpi->common; LAYER_CONTEXT *lc = get_layer_context(cpi); lc->rc = cpi->rc; lc->target_bandwidth = (int)cpi->oxcf.rc_cfg.target_bandwidth; - lc->group_index = gf_group->index; + lc->group_index = cpi->gf_frame_index; lc->max_mv_magnitude = cpi->mv_search_params.max_mv_magnitude; if (svc->spatial_layer_id == 0) svc->base_framerate = cpi->framerate; // For spatial-svc, allow cyclic-refresh to be applied on the spatial layers,
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c index 676e110..8e09880 100644 --- a/av1/encoder/temporal_filter.c +++ b/av1/encoder/temporal_filter.c
@@ -746,7 +746,7 @@ int av1_get_q(const AV1_COMP *cpi) { const GF_GROUP *gf_group = &cpi->gf_group; - const FRAME_TYPE frame_type = gf_group->frame_type[gf_group->index]; + const FRAME_TYPE frame_type = gf_group->frame_type[cpi->gf_frame_index]; const int q = (int)av1_convert_qindex_to_q( cpi->rc.avg_frame_qindex[frame_type], cpi->common.seq_params.bit_depth); return q; @@ -939,8 +939,8 @@ const int lookahead_depth = av1_lookahead_depth(cpi->ppi->lookahead, cpi->compressor_stage); - int arf_src_offset = cpi->gf_group.arf_src_offset[cpi->gf_group.index]; - const FRAME_TYPE frame_type = cpi->gf_group.frame_type[cpi->gf_group.index]; + int arf_src_offset = cpi->gf_group.arf_src_offset[cpi->gf_frame_index]; + const FRAME_TYPE frame_type = cpi->gf_group.frame_type[cpi->gf_frame_index]; // Temporal filtering should not go beyond key frames const int key_to_curframe = @@ -1175,7 +1175,7 @@ MultiThreadInfo *const mt_info = &cpi->mt_info; // Basic informaton of the current frame. const GF_GROUP *const gf_group = &cpi->gf_group; - const uint8_t group_idx = gf_group->index; + const uint8_t group_idx = cpi->gf_frame_index; TemporalFilterCtx *tf_ctx = &cpi->tf_ctx; TemporalFilterData *tf_data = &cpi->td.tf_data; // Filter one more ARF if the lookahead index is leq 7 (w.r.t. 9-th frame).
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c index 22f6d98..2643665 100644 --- a/av1/encoder/tpl_model.c +++ b/av1/encoder/tpl_model.c
@@ -1253,7 +1253,7 @@ GF_GROUP *gf_group, int gop_eval, int *tpl_group_frames, const EncodeFrameInput *const frame_input, int *pframe_qindex) { AV1_COMMON *cm = &cpi->common; - int cur_frame_idx = gf_group->index; + int cur_frame_idx = cpi->gf_frame_index; *pframe_qindex = 0; RefBufferStack ref_buffer_stack = cpi->ref_buffer_stack; @@ -1467,7 +1467,8 @@ } cm->current_frame.frame_type = frame_params->frame_type; - for (int gf_index = gf_group->index; gf_index < gf_group->size; ++gf_index) { + for (int gf_index = cpi->gf_frame_index; gf_index < gf_group->size; + ++gf_index) { cm->current_frame.frame_type = gf_group->frame_type[gf_index]; av1_configure_buffer_updates(cpi, &this_frame_params.refresh_frame, gf_group->update_type[gf_index], @@ -1506,7 +1507,7 @@ cm->features.allow_high_precision_mv, cpi->td.mb.mv_costs); // Backward propagation from tpl_group_frames to 1. - for (int frame_idx = gf_group->index; frame_idx < tpl_gf_group_frames; + for (int frame_idx = cpi->gf_frame_index; frame_idx < tpl_gf_group_frames; ++frame_idx) { if (gf_group->update_type[frame_idx] == INTNL_OVERLAY_UPDATE || gf_group->update_type[frame_idx] == OVERLAY_UPDATE) @@ -1526,8 +1527,8 @@ av1_num_planes(cm)); } - for (int frame_idx = tpl_gf_group_frames - 1; frame_idx >= gf_group->index; - --frame_idx) { + for (int frame_idx = tpl_gf_group_frames - 1; + frame_idx >= cpi->gf_frame_index; --frame_idx) { if (gf_group->update_type[frame_idx] == INTNL_OVERLAY_UPDATE || gf_group->update_type[frame_idx] == OVERLAY_UPDATE) continue; @@ -1536,7 +1537,7 @@ } av1_configure_buffer_updates(cpi, &this_frame_params.refresh_frame, - gf_group->update_type[gf_group->index], + gf_group->update_type[cpi->gf_frame_index], frame_params->frame_type, 0); cm->current_frame.frame_type = frame_params->frame_type; cm->show_frame = frame_params->show_frame; @@ -1602,10 +1603,9 @@ void av1_tpl_rdmult_setup(AV1_COMP *cpi) { const AV1_COMMON *const cm = &cpi->common; - const GF_GROUP *const gf_group = &cpi->gf_group; - const int tpl_idx = gf_group->index; + const int tpl_idx = cpi->gf_frame_index; - assert(IMPLIES(gf_group->size > 0, tpl_idx < gf_group->size)); + assert(IMPLIES(cpi->gf_group.size > 0, tpl_idx < cpi->gf_group.size)); TplParams *const tpl_data = &cpi->tpl_data; const TplDepFrame *const tpl_frame = &tpl_data->tpl_frame[tpl_idx]; @@ -1659,12 +1659,12 @@ AV1_COMMON *const cm = &cpi->common; GF_GROUP *gf_group = &cpi->gf_group; assert(IMPLIES(cpi->gf_group.size > 0, - cpi->gf_group.index < cpi->gf_group.size)); - const int tpl_idx = cpi->gf_group.index; + cpi->gf_frame_index < cpi->gf_group.size)); + const int tpl_idx = cpi->gf_frame_index; TplDepFrame *tpl_frame = &cpi->tpl_data.tpl_frame[tpl_idx]; if (tpl_frame->is_valid == 0) return; - if (!is_frame_tpl_eligible(gf_group, gf_group->index)) return; + if (!is_frame_tpl_eligible(gf_group, cpi->gf_frame_index)) return; if (tpl_idx >= MAX_TPL_FRAME_IDX) return; if (cpi->oxcf.q_cfg.aq_mode != NO_AQ) return;
diff --git a/av1/encoder/tune_vmaf.c b/av1/encoder/tune_vmaf.c index 507cac9..6008d64 100644 --- a/av1/encoder/tune_vmaf.c +++ b/av1/encoder/tune_vmaf.c
@@ -388,7 +388,7 @@ const GF_GROUP *const gf_group = &cpi->gf_group; const int layer_depth = - AOMMIN(gf_group->layer_depth[gf_group->index], MAX_ARF_LAYERS - 1); + AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], MAX_ARF_LAYERS - 1); const double best_frame_unsharp_amount = get_layer_value(cpi->vmaf_info.last_frame_unsharp_amount, layer_depth); @@ -433,7 +433,7 @@ const GF_GROUP *const gf_group = &cpi->gf_group; const int layer_depth = - AOMMIN(gf_group->layer_depth[gf_group->index], MAX_ARF_LAYERS - 1); + AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], MAX_ARF_LAYERS - 1); const double last_frame_unsharp_amount = get_layer_value(cpi->vmaf_info.last_frame_unsharp_amount, layer_depth); @@ -475,7 +475,7 @@ const GF_GROUP *const gf_group = &cpi->gf_group; const int layer_depth = - AOMMIN(gf_group->layer_depth[gf_group->index], MAX_ARF_LAYERS - 1); + AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], MAX_ARF_LAYERS - 1); const double last_frame_unsharp_amount = get_layer_value(cpi->vmaf_info.last_frame_unsharp_amount, layer_depth); @@ -891,7 +891,7 @@ const AV1_COMMON *const cm = &cpi->common; const GF_GROUP *gf_group = &cpi->gf_group; const int src_index = - cm->show_frame != 0 ? 0 : gf_group->arf_src_offset[gf_group->index]; + cm->show_frame != 0 ? 0 : gf_group->arf_src_offset[cpi->gf_frame_index]; struct lookahead_entry *last_entry = av1_lookahead_peek( cpi->ppi->lookahead, src_index - 1, cpi->compressor_stage); struct lookahead_entry *next_entry = av1_lookahead_peek( @@ -911,7 +911,7 @@ aom_clear_system_state(); const GF_GROUP *const gf_group = &cpi->gf_group; const int layer_depth = - AOMMIN(gf_group->layer_depth[gf_group->index], MAX_ARF_LAYERS - 1); + AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], MAX_ARF_LAYERS - 1); const double last_frame_ysse = get_layer_value(cpi->vmaf_info.last_frame_ysse, layer_depth); const double last_frame_vmaf = @@ -928,7 +928,7 @@ } YV12_BUFFER_CONFIG *cur_buf = cpi->source; if (cm->show_frame == 0) { - const int src_index = gf_group->arf_src_offset[gf_group->index]; + const int src_index = gf_group->arf_src_offset[cpi->gf_frame_index]; struct lookahead_entry *cur_entry = av1_lookahead_peek( cpi->ppi->lookahead, src_index, cpi->compressor_stage); cur_buf = &cur_entry->img; @@ -1086,7 +1086,7 @@ const int bit_depth = cpi->td.mb.e_mbd.bd; const GF_GROUP *const gf_group = &cpi->gf_group; const int layer_depth = - AOMMIN(gf_group->layer_depth[gf_group->index], MAX_ARF_LAYERS - 1); + AOMMIN(gf_group->layer_depth[cpi->gf_frame_index], MAX_ARF_LAYERS - 1); double base_score; const bool cal_vmaf_neg = cpi->oxcf.tune_cfg.tuning == AOM_TUNE_VMAF_NEG_MAX_GAIN;
diff --git a/av1/encoder/tx_search.c b/av1/encoder/tx_search.c index 68b4416..ef56d35 100644 --- a/av1/encoder/tx_search.c +++ b/av1/encoder/tx_search.c
@@ -2024,7 +2024,8 @@ assert(plane == 0); allowed_tx_mask = ext_tx_used_flag; int num_allowed = 0; - const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group); + const FRAME_UPDATE_TYPE update_type = + get_frame_update_type(&cpi->gf_group, cpi->gf_frame_index); const int *tx_type_probs = cpi->frame_probs.tx_type_probs[update_type][tx_size]; int i;