Clean up REF_FRAMES_NRS This unifies REF_FRAMES_NRS and REF_FRAMES Change-Id: I1b0d45f175147fc9570751fd784faf8cbc2ce0d1
diff --git a/av1/av1_iface_common.h b/av1/av1_iface_common.h index 274fd53..9ecf732 100644 --- a/av1/av1_iface_common.h +++ b/av1/av1_iface_common.h
@@ -32,7 +32,7 @@ int ref_frame_pyr_level_nrs[INTER_REFS_PER_FRAME_NRS]; int ref_frame_disp_order_nrs[INTER_REFS_PER_FRAME_NRS]; int is_valid_ref_frame_nrs[INTER_REFS_PER_FRAME_NRS]; - unsigned int ref_frame_map_nrs[REF_FRAMES_NRS]; + unsigned int ref_frame_map_nrs[REF_FRAMES]; #endif // CONFIG_NEW_REF_SIGNALING int ref_frame_pyr_level[INTER_REFS_PER_FRAME]; int ref_frame_disp_order[INTER_REFS_PER_FRAME];
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h index 533857c..977fca3 100644 --- a/av1/common/av1_common_int.h +++ b/av1/common/av1_common_int.h
@@ -190,11 +190,7 @@ int interp_filter_selected[SWITCHABLE]; // Inter frame reference frame delta for loop filter -#if CONFIG_NEW_REF_SIGNALING - int8_t ref_deltas[REF_FRAMES_NRS]; -#else int8_t ref_deltas[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING // 0 = ZERO_MV, MV int8_t mode_deltas[MAX_MODE_LF_DELTAS]; @@ -980,7 +976,7 @@ * Note: INTRA_FRAME always refers to the current frame, so there's no need to * have a remapped index for the same. */ - int remapped_ref_idx[REF_FRAMES_NRS]; + int remapped_ref_idx[REF_FRAMES]; #else /*! * For encoder, we have a two-level mapping from reference frame type to the @@ -1362,7 +1358,7 @@ #if CONFIG_NEW_REF_SIGNALING static INLINE int get_ref_frame_map_idx(const AV1_COMMON *const cm, const int ref_frame) { - return (ref_frame >= 0 && ref_frame < REF_FRAMES_NRS) + return (ref_frame >= 0 && ref_frame < REF_FRAMES) ? cm->remapped_ref_idx[ref_frame] : INVALID_IDX; }
diff --git a/av1/common/av1_loopfilter.h b/av1/common/av1_loopfilter.h index 4004f53..78afea2 100644 --- a/av1/common/av1_loopfilter.h +++ b/av1/common/av1_loopfilter.h
@@ -90,14 +90,9 @@ uint8_t mode_ref_delta_enabled; uint8_t mode_ref_delta_update; -#if CONFIG_NEW_REF_SIGNALING - // In ranked order - int8_t ref_deltas[REF_FRAMES_NRS]; -#else - // 0 = Intra, Last, Last2+Last3, - // GF, BRF, ARF2, ARF + // In NRS: in ranked order + // Otherwise: 0 = Intra, Last, Last2+Last3, GF, BRF, ARF2, ARF int8_t ref_deltas[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING // 0 = ZERO_MV, MV int8_t mode_deltas[MAX_MODE_LF_DELTAS];
diff --git a/av1/common/enums.h b/av1/common/enums.h index 8580d68..3b96649 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -755,7 +755,7 @@ #if CONFIG_NEW_REF_SIGNALING #define INTER_REFS_PER_FRAME_NRS 7 -#define REF_FRAMES_NRS (INTER_REFS_PER_FRAME_NRS + 1) +#define REF_FRAMES (INTER_REFS_PER_FRAME_NRS + 1) #define MODE_CTX_REF_FRAMES \ (INTER_REFS_PER_FRAME_NRS * (INTER_REFS_PER_FRAME_NRS + 1) / 2 + 1) #define INTRA_FRAME_NRS \
diff --git a/av1/common/pred_common.c b/av1/common/pred_common.c index d4093ff..c674c5f 100644 --- a/av1/common/pred_common.c +++ b/av1/common/pred_common.c
@@ -105,15 +105,15 @@ #define JOINT_DIST_QINDEX_ORDERING 1 void av1_get_ref_frames(AV1_COMMON *cm, int cur_frame_disp, RefFrameMapPair *ref_frame_map_pairs) { - RefScoreData scores[REF_FRAMES_NRS]; - memset(scores, 0, REF_FRAMES_NRS * sizeof(*scores)); - for (int i = 0; i < REF_FRAMES_NRS; i++) scores[i].score = INT_MAX; - for (int i = 0; i < REF_FRAMES_NRS; i++) { + RefScoreData scores[REF_FRAMES]; + memset(scores, 0, REF_FRAMES * sizeof(*scores)); + for (int i = 0; i < REF_FRAMES; i++) scores[i].score = INT_MAX; + for (int i = 0; i < REF_FRAMES; i++) { cm->remapped_ref_idx[i] = INVALID_IDX; } int n_ranked = 0; // Compute a score for each reference buffer - for (int i = 0; i < REF_FRAMES_NRS; i++) { + for (int i = 0; i < REF_FRAMES; i++) { // Get reference frame buffer RefFrameMapPair cur_ref = ref_frame_map_pairs[i]; if (cur_ref.disp_order == -1) continue; @@ -175,7 +175,7 @@ cm->new_ref_frame_data.n_cur_refs = n_cur; // Fill any slots that are empty (should only happen for the first 7 frames) - for (int i = 0; i < REF_FRAMES_NRS; i++) { + for (int i = 0; i < REF_FRAMES; i++) { if (cm->remapped_ref_idx[i] == INVALID_IDX) cm->remapped_ref_idx[i] = 0; } }
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 1d28eed..937c87b 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -2176,11 +2176,7 @@ if (lf->mode_ref_delta_enabled) { lf->mode_ref_delta_update = aom_rb_read_bit(rb); if (lf->mode_ref_delta_update) { -#if CONFIG_NEW_REF_SIGNALING - for (int i = 0; i < REF_FRAMES_NRS; i++) -#else for (int i = 0; i < REF_FRAMES; i++) -#endif // CONFIG_NEW_REF_SIGNALING if (aom_rb_read_bit(rb)) lf->ref_deltas[i] = aom_rb_read_inv_signed_literal(rb, 6);
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index d602da3..ae021b2 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -2449,11 +2449,7 @@ return 0; } const RefCntBuffer *buf = get_primary_ref_frame_buf(cm); -#if CONFIG_NEW_REF_SIGNALING - int8_t last_ref_deltas[REF_FRAMES_NRS]; -#else int8_t last_ref_deltas[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING int8_t last_mode_deltas[MAX_MODE_LF_DELTAS]; if (buf == NULL) { av1_set_default_ref_deltas(last_ref_deltas); @@ -2462,11 +2458,7 @@ memcpy(last_ref_deltas, buf->ref_deltas, sizeof(last_ref_deltas)); memcpy(last_mode_deltas, buf->mode_deltas, MAX_MODE_LF_DELTAS); } -#if CONFIG_NEW_REF_SIGNALING - for (int i = 0; i < REF_FRAMES_NRS; i++) { -#else for (int i = 0; i < REF_FRAMES; i++) { -#endif // CONFIG_NEW_REF_SIGNALING if (lf->ref_deltas[i] != last_ref_deltas[i]) { return true; } @@ -2508,11 +2500,7 @@ } const RefCntBuffer *buf = get_primary_ref_frame_buf(cm); -#if CONFIG_NEW_REF_SIGNALING - int8_t last_ref_deltas[REF_FRAMES_NRS]; -#else int8_t last_ref_deltas[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING int8_t last_mode_deltas[MAX_MODE_LF_DELTAS]; if (buf == NULL) { av1_set_default_ref_deltas(last_ref_deltas); @@ -2521,11 +2509,7 @@ memcpy(last_ref_deltas, buf->ref_deltas, sizeof(last_ref_deltas)); memcpy(last_mode_deltas, buf->mode_deltas, MAX_MODE_LF_DELTAS); } -#if CONFIG_NEW_REF_SIGNALING - for (int i = 0; i < REF_FRAMES_NRS; i++) { -#else for (int i = 0; i < REF_FRAMES; i++) { -#endif // CONFIG_NEW_REF_SIGNALING const int delta = lf->ref_deltas[i]; const int changed = delta != last_ref_deltas[i]; aom_wb_write_bit(wb, changed);
diff --git a/av1/encoder/block.h b/av1/encoder/block.h index a63aba0..c034e3a 100644 --- a/av1/encoder/block.h +++ b/av1/encoder/block.h
@@ -1162,24 +1162,11 @@ * * This is used to measure how viable a reference frame is. */ -#if CONFIG_NEW_REF_SIGNALING - int pred_mv_sad[REF_FRAMES_NRS]; -#else int pred_mv_sad[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING //! The minimum of \ref pred_mv_sad. int best_pred_mv_sad; -#if CONFIG_NEW_REF_SIGNALING - /*! \brief Disables certain ref frame pruning based on tpl. - * - * Determines whether a given ref frame is "good" based on data from the TPL - * model. If so, this stops selective_ref frame from pruning the given ref - * frame at block level. - */ - uint8_t tpl_keep_ref_frame[REF_FRAMES_NRS]; -#else /*! \brief Disables certain ref frame pruning based on tpl. * * Determines whether a given ref frame is "good" based on data from the TPL @@ -1187,7 +1174,6 @@ * frame at block level. */ uint8_t tpl_keep_ref_frame[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING /*! \brief Reference frames picked by the square subblocks in a superblock. * @@ -1321,11 +1307,7 @@ * This context is defined as the \f$l_\inf\f$ norm of the best ref_mvs for * each frame. */ -#if CONFIG_NEW_REF_SIGNALING - unsigned int max_mv_context[REF_FRAMES_NRS]; -#else unsigned int max_mv_context[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING /*! \brief Limit for the range of motion vectors. * @@ -1368,11 +1350,7 @@ //! Variance of the source frame. unsigned int source_variance; //! SSE of the current predictor. -#if CONFIG_NEW_REF_SIGNALING - unsigned int pred_sse[REF_FRAMES_NRS]; -#else unsigned int pred_sse[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING #if CONFIG_EXT_RECUR_PARTITIONS //! Simple motion search buffers. SimpleMotionDataBufs *sms_bufs;
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c index 58a1620..4e8a286 100644 --- a/av1/encoder/encode_strategy.c +++ b/av1/encoder/encode_strategy.c
@@ -498,11 +498,7 @@ // If more than one frame is refreshed, it doesn't matter which one we // pick so pick the first. LST sometimes doesn't refresh any: this is ok -#if CONFIG_NEW_REF_SIGNALING - for (int i = 0; i < REF_FRAMES_NRS; i++) { -#else for (int i = 0; i < REF_FRAMES; i++) { -#endif // CONFIG_NEW_REF_SIGNALING if (cm->current_frame.refresh_frame_flags & (1 << i)) { fb_of_context_type[current_frame_ref_type] = i; break; @@ -762,11 +758,7 @@ int av1_get_refresh_ref_frame_map(int refresh_frame_flags) { int ref_map_index = INVALID_IDX; -#if CONFIG_NEW_REF_SIGNALING - for (ref_map_index = 0; ref_map_index < REF_FRAMES_NRS; ++ref_map_index) -#else for (ref_map_index = 0; ref_map_index < REF_FRAMES; ++ref_map_index) -#endif // CONFIG_NEW_REF_SIGNALING if ((refresh_frame_flags >> ref_map_index) & 1) break; return ref_map_index; @@ -868,64 +860,10 @@ return 1 << refresh_idx; } -#if CONFIG_NEW_REF_SIGNALING -int av1_get_refresh_frame_flags( - const AV1_COMP *const cpi, const EncodeFrameParams *const frame_params, - FRAME_UPDATE_TYPE frame_update_type, int gf_index, int cur_disp_order, - RefFrameMapPair ref_frame_map_pairs[REF_FRAMES_NRS]) { - const SVC *const svc = &cpi->svc; - // Switch frames and shown key-frames overwrite all reference slots - if ((frame_params->frame_type == KEY_FRAME && !cpi->no_show_fwd_kf) || - frame_params->frame_type == S_FRAME) - return 0xFF; - - // show_existing_frames don't actually send refresh_frame_flags so set the - // flags to 0 to keep things consistent. - if (frame_params->show_existing_frame && - (!frame_params->error_resilient_mode || - frame_params->frame_type == KEY_FRAME)) { - return 0; - } - - if (is_frame_droppable(svc)) return 0; - - int refresh_mask = 0; - - // Search for the open slot to store the current frame. - int free_fb_index = get_free_ref_map_index(ref_frame_map_pairs); - - if (use_subgop_cfg(&cpi->gf_group, gf_index)) { - return get_refresh_frame_flags_subgop_cfg(cpi, gf_index, cur_disp_order, - ref_frame_map_pairs, refresh_mask, - free_fb_index); - } - - // No refresh necessary for these frame types - if (frame_update_type == OVERLAY_UPDATE || - frame_update_type == KFFLT_OVERLAY_UPDATE || - frame_update_type == INTNL_OVERLAY_UPDATE) - return refresh_mask; - - // If there is an open slot, refresh that one instead of replacing a reference - if (free_fb_index != INVALID_IDX) { - refresh_mask = 1 << free_fb_index; - return refresh_mask; - } - - const int update_arf = frame_update_type == ARF_UPDATE; - const int refresh_idx = - get_refresh_idx(update_arf, -1, cur_disp_order, ref_frame_map_pairs); - return 1 << refresh_idx; -} -#else int av1_get_refresh_frame_flags( const AV1_COMP *const cpi, const EncodeFrameParams *const frame_params, FRAME_UPDATE_TYPE frame_update_type, int gf_index, int cur_disp_order, RefFrameMapPair ref_frame_map_pairs[REF_FRAMES]) { - const AV1_COMMON *const cm = &cpi->common; - const ExtRefreshFrameFlagsInfo *const ext_refresh_frame_flags = - &cpi->ext_flags.refresh_frame; - const SVC *const svc = &cpi->svc; // Switch frames and shown key-frames overwrite all reference slots if ((frame_params->frame_type == KEY_FRAME && !cpi->no_show_fwd_kf) || @@ -940,9 +878,13 @@ return 0; } - if (is_frame_droppable(svc, ext_refresh_frame_flags)) return 0; - int refresh_mask = 0; +#if CONFIG_NEW_REF_SIGNALING + if (is_frame_droppable(svc)) return 0; +#else + const AV1_COMMON *const cm = &cpi->common; + const ExtRefreshFrameFlagsInfo *const ext_refresh_frame_flags = + &cpi->ext_flags.refresh_frame; if (ext_refresh_frame_flags->update_pending) { if (svc->external_ref_frame_config) { @@ -988,6 +930,7 @@ } return refresh_mask; } +#endif // CONFIG_NEW_REF_SIGNALING // Search for the open slot to store the current frame. int free_fb_index = get_free_ref_map_index(ref_frame_map_pairs); @@ -1015,7 +958,6 @@ get_refresh_idx(update_arf, -1, cur_disp_order, ref_frame_map_pairs); return 1 << refresh_idx; } -#endif // CONFIG_NEW_REF_SIGNALING #if !CONFIG_REALTIME_ONLY void setup_mi(AV1_COMP *const cpi, YV12_BUFFER_CONFIG *src) { @@ -1441,11 +1383,7 @@ frame_params.existing_fb_idx_to_show = INVALID_IDX; // Find the frame buffer to show based on display order if (frame_params.show_existing_frame) { -#if CONFIG_NEW_REF_SIGNALING - for (int frame = 0; frame < REF_FRAMES_NRS; frame++) { -#else for (int frame = 0; frame < REF_FRAMES; frame++) { -#endif // CONFIG_NEW_REF_SIGNALING const RefCntBuffer *const buf = cm->ref_frame_map[frame]; if (buf == NULL) continue; const int frame_order = (int)buf->display_order_hint; @@ -1463,13 +1401,8 @@ // frame_params->remapped_ref_idx here and they will be used when encoding // this frame. If frame_params->remapped_ref_idx is setup independently of // cm->remapped_ref_idx then update_ref_frame_map() will have no effect. -#if CONFIG_NEW_REF_SIGNALING - memcpy(frame_params.remapped_ref_idx, cm->remapped_ref_idx, - REF_FRAMES_NRS * sizeof(*frame_params.remapped_ref_idx)); -#else memcpy(frame_params.remapped_ref_idx, cm->remapped_ref_idx, REF_FRAMES * sizeof(*frame_params.remapped_ref_idx)); -#endif // CONFIG_NEW_REF_SIGNALING cpi->td.mb.delta_qindex = 0;
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index 77216f7..0f9eb26 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -1882,12 +1882,7 @@ BufferPool *const pool = cm->buffer_pool; cm->cur_frame = NULL; -#if CONFIG_NEW_REF_SIGNALING - for (i = 0; i < REF_FRAMES_NRS; ++i) -#else - for (i = 0; i < REF_FRAMES; ++i) -#endif // CONFIG_NEW_REF_SIGNALING - cm->ref_frame_map[i] = NULL; + for (i = 0; i < REF_FRAMES; ++i) cm->ref_frame_map[i] = NULL; for (i = 0; i < FRAME_BUFFERS; ++i) { pool->frame_bufs[i].ref_count = 0; @@ -3277,16 +3272,13 @@ cm->show_existing_frame = frame_params->show_existing_frame; cpi->existing_fb_idx_to_show = frame_params->existing_fb_idx_to_show; -#if CONFIG_NEW_REF_SIGNALING - memcpy(cm->remapped_ref_idx, frame_params->remapped_ref_idx, - REF_FRAMES_NRS * sizeof(*cm->remapped_ref_idx)); -#else memcpy(cm->remapped_ref_idx, frame_params->remapped_ref_idx, REF_FRAMES * sizeof(*cm->remapped_ref_idx)); +#if !CONFIG_NEW_REF_SIGNALING memcpy(&cpi->refresh_frame, &frame_params->refresh_frame, sizeof(cpi->refresh_frame)); -#endif // CONFIG_NEW_REF_SIGNALING +#endif // !CONFIG_NEW_REF_SIGNALING if (current_frame->frame_type == KEY_FRAME && !cpi->no_show_fwd_kf) { current_frame->key_frame_number += current_frame->frame_number;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index 097f0f6..f14c893 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -2282,13 +2282,7 @@ * choose our primary reference frame (which is the most recent reference * frame of the same type as the current frame). */ - int fb_of_context_type[ -#if CONFIG_NEW_REF_SIGNALING - REF_FRAMES_NRS -#else - REF_FRAMES -#endif // CONFIG_NEW_REF_SIGNALING - ]; + int fb_of_context_type[REF_FRAMES]; /*! * Flags signalled by the external interface at frame level.
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c index e411f55..078d34d 100644 --- a/av1/encoder/nonrd_pickmode.c +++ b/av1/encoder/nonrd_pickmode.c
@@ -434,15 +434,13 @@ * \c frame_mv array */ #endif // CONFIG_NEW_REF_SIGNALING -static INLINE void find_predictors( - AV1_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, -#if CONFIG_NEW_REF_SIGNALING - int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES_NRS], -#else - int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], -#endif // CONFIG_NEW_REF_SIGNALING - TileDataEnc *tile_data, struct buf_2d yv12_mb[8][MAX_MB_PLANE], - BLOCK_SIZE bsize, int force_skip_low_temp_var) { +static INLINE void find_predictors(AV1_COMP *cpi, MACROBLOCK *x, + MV_REFERENCE_FRAME ref_frame, + int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], + TileDataEnc *tile_data, + struct buf_2d yv12_mb[8][MAX_MB_PLANE], + BLOCK_SIZE bsize, + int force_skip_low_temp_var) { AV1_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = xd->mi[0]; @@ -596,12 +594,7 @@ static void estimate_comp_ref_frame_costs( const AV1_COMMON *cm, const MACROBLOCKD *xd, const ModeCosts *mode_costs, - int segment_id, -#if CONFIG_NEW_REF_SIGNALING - unsigned int (*ref_costs_comp)[REF_FRAMES_NRS]) { -#else - unsigned int (*ref_costs_comp)[REF_FRAMES]) { -#endif // CONFIG_NEW_REF_SIGNALING + int segment_id, unsigned int (*ref_costs_comp)[REF_FRAMES]) { #if CONFIG_NEW_REF_SIGNALING (void)segment_id; const int seg_ref_active = 0; @@ -618,8 +611,8 @@ int intra_inter_ctx = av1_get_intra_inter_context(xd); unsigned int base_cost = mode_costs->intra_inter_cost[intra_inter_ctx][1]; if (cm->current_frame.reference_mode != SINGLE_REFERENCE) { - for (int i = 0; i < REF_FRAMES_NRS; i++) - for (int j = 0; j < REF_FRAMES_NRS; j++) ref_costs_comp[i][j] = INT_MAX; + for (int i = 0; i < REF_FRAMES; i++) + for (int j = 0; j < REF_FRAMES; j++) ref_costs_comp[i][j] = INT_MAX; const int n_refs = cm->new_ref_frame_data.n_total_refs; for (int i = 0; i < n_refs - 1; i++) { @@ -645,8 +638,8 @@ } } } else { - for (int ref0 = 0; ref0 < REF_FRAMES_NRS; ++ref0) { - for (int ref1 = ref0 + 1; ref1 < REF_FRAMES_NRS; ++ref1) + for (int ref0 = 0; ref0 < REF_FRAMES; ++ref0) { + for (int ref1 = ref0 + 1; ref1 < REF_FRAMES; ++ref1) ref_costs_comp[ref0][ref1] = 512; } } @@ -2314,30 +2307,18 @@ static mode_search_stat ms_stat; #endif MV_REFERENCE_FRAME ref_frame; -#if CONFIG_NEW_REF_SIGNALING - int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES_NRS]; - uint8_t mode_checked[MB_MODE_COUNT][REF_FRAMES_NRS]; - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE]; -#else int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES]; uint8_t mode_checked[MB_MODE_COUNT][REF_FRAMES]; struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE]; -#endif // CONFIG_NEW_REF_SIGNALING RD_STATS this_rdc, best_rdc; const unsigned char segment_id = mi->segment_id; const int *const rd_threshes = cpi->rd.threshes[segment_id][bsize]; const int *const rd_thresh_freq_fact = x->thresh_freq_fact[bsize]; const InterpFilter filter_ref = cm->features.interp_filter; int best_early_term = 0; -#if CONFIG_NEW_REF_SIGNALING - unsigned int ref_costs_single[REF_FRAMES_NRS]; - unsigned int ref_costs_comp[REF_FRAMES_NRS][REF_FRAMES_NRS]; - int use_ref_frame_mask[REF_FRAMES_NRS] = { 0 }; -#else unsigned int ref_costs_single[REF_FRAMES], ref_costs_comp[REF_FRAMES][REF_FRAMES]; int use_ref_frame_mask[REF_FRAMES] = { 0 }; -#endif // CONFIG_NEW_REF_SIGNALING int force_skip_low_temp_var = 0; unsigned int sse_zeromv_norm = UINT_MAX; int num_inter_modes = RT_INTER_MODES;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 3c9606d..a208f08 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -995,11 +995,7 @@ static AOM_INLINE void estimate_ref_frame_costs( const AV1_COMMON *cm, const MACROBLOCKD *xd, const ModeCosts *mode_costs, int segment_id, unsigned int *ref_costs_single, -#if CONFIG_NEW_REF_SIGNALING - unsigned int (*ref_costs_comp)[REF_FRAMES_NRS]) { -#else unsigned int (*ref_costs_comp)[REF_FRAMES]) { -#endif // CONFIG_NEW_REF_SIGNALING #if CONFIG_NEW_REF_SIGNALING (void)segment_id; int seg_ref_active = 0; @@ -1010,15 +1006,9 @@ if (seg_ref_active) { memset(ref_costs_single, 0, REF_FRAMES * sizeof(*ref_costs_single)); int ref_frame; -#if CONFIG_NEW_REF_SIGNALING - for (ref_frame = 0; ref_frame < REF_FRAMES_NRS; ++ref_frame) - memset(ref_costs_comp[ref_frame], 0, - REF_FRAMES_NRS * sizeof((*ref_costs_comp)[0])); -#else for (ref_frame = 0; ref_frame < REF_FRAMES; ++ref_frame) memset(ref_costs_comp[ref_frame], 0, REF_FRAMES * sizeof((*ref_costs_comp)[0])); -#endif // CONFIG_NEW_REF_SIGNALING } else { #if CONFIG_NEW_REF_SIGNALING int intra_inter_ctx = av1_get_intra_inter_context(xd); @@ -1096,8 +1086,8 @@ #if CONFIG_NEW_REF_SIGNALING if (cm->current_frame.reference_mode != SINGLE_REFERENCE) { - for (int i = 0; i < REF_FRAMES_NRS; i++) - for (int j = 0; j < REF_FRAMES_NRS; j++) ref_costs_comp[i][j] = INT_MAX; + for (int i = 0; i < REF_FRAMES; i++) + for (int j = 0; j < REF_FRAMES; j++) ref_costs_comp[i][j] = INT_MAX; for (int i = 0; i < n_refs - 1; i++) { int prev_cost = base_cost; @@ -1158,8 +1148,8 @@ } #endif // NDEBUG } else { - for (int ref0 = 0; ref0 < REF_FRAMES_NRS; ++ref0) { - for (int ref1 = ref0 + 1; ref1 < REF_FRAMES_NRS; ++ref1) { + for (int ref0 = 0; ref0 < REF_FRAMES; ++ref0) { + for (int ref1 = ref0 + 1; ref1 < REF_FRAMES; ++ref1) { ref_costs_comp[ref0][ref1] = 512; ref_costs_comp[ref1][ref0] = 512; } @@ -1288,13 +1278,7 @@ static AOM_INLINE void setup_buffer_ref_mvs_inter( const AV1_COMP *const cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, - BLOCK_SIZE block_size, -#if CONFIG_NEW_REF_SIGNALING - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE] -#else - struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE] -#endif // CONFIG_NEW_REF_SIGNALING -) { + BLOCK_SIZE block_size, struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE]) { const AV1_COMMON *cm = &cpi->common; const int num_planes = av1_num_planes(cm); const YV12_BUFFER_CONFIG *scaled_ref_frame = @@ -4092,12 +4076,7 @@ static AOM_INLINE void rd_pick_skip_mode( RD_STATS *rd_cost, InterModeSearchState *search_state, const AV1_COMP *const cpi, MACROBLOCK *const x, BLOCK_SIZE bsize, -#if CONFIG_NEW_REF_SIGNALING - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE] -#else - struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE] -#endif // CONFIG_NEW_REF_SIGNALING -) { + struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE]) { const AV1_COMMON *const cm = &cpi->common; const SkipModeInfo *const skip_mode_info = &cm->current_frame.skip_mode_info; const int num_planes = av1_num_planes(cm); @@ -4318,12 +4297,8 @@ static AOM_INLINE void refine_winner_mode_tx( const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, MB_MODE_INFO *best_mbmode, -#if CONFIG_NEW_REF_SIGNALING - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE], -#else - struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE], -#endif // CONFIG_NEW_REF_SIGNALING - int best_rate_y, int best_rate_uv, int *best_skip2, int winner_mode_count) { + struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE], int best_rate_y, + int best_rate_uv, int *best_skip2, int winner_mode_count) { const AV1_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = xd->mi[0]; @@ -4442,23 +4417,6 @@ } } -#if CONFIG_NEW_REF_SIGNALING -// TODO(debargha, sarahparker): Keeping the same type name since -// REF_FRAMES_NRS and REF_FRAMES are the same. Needs to be cleaned up later. -/*!\cond */ -typedef struct { - // Mask for each reference frame, specifying which prediction modes to NOT try - // during search. - uint32_t pred_modes[REF_FRAMES_NRS]; - // If ref_combo[i][j + 1] is true, do NOT try prediction using combination of - // reference frames (i, j). - // NOTE: Indexing for the references has the order the INTER references - // followed by INTRA. Indexing with 'j + 1' for the 2nd reference is due to - // the fact that 2nd reference can be -1 (INVALID_IDX). - bool ref_combo[REF_FRAMES_NRS][REF_FRAMES_NRS + 1]; -} mode_skip_mask_t; -/*!\endcond */ -#else /*!\cond */ typedef struct { // Mask for each reference frame, specifying which prediction modes to NOT try @@ -4466,20 +4424,20 @@ uint32_t pred_modes[REF_FRAMES]; // If ref_combo[i][j + 1] is true, do NOT try prediction using combination of // reference frames (i, j). - // Note: indexing with 'j + 1' is due to the fact that 2nd reference can be -1 - // (NONE_FRAME). + // Indexing with 'j + 1' for the 2nd reference is due to the fact that 2nd + // reference can be -1 (INVALID_IDX). + // NOTE: In CONFIG_NEW_REF_SIGNALING, indexing for the references has the + // order the INTER references followed by INTRA. bool ref_combo[REF_FRAMES][REF_FRAMES + 1]; } mode_skip_mask_t; /*!\endcond */ -#endif // !CONFIG_NEW_REF_SIGNALING #if CONFIG_NEW_REF_SIGNALING // Update 'ref_combo' mask to disable given 'ref' in single and compound modes. static AOM_INLINE void disable_reference( - MV_REFERENCE_FRAME ref, - bool ref_combo[REF_FRAMES_NRS][REF_FRAMES_NRS + 1]) { + MV_REFERENCE_FRAME ref, bool ref_combo[REF_FRAMES][REF_FRAMES + 1]) { ref = (ref == INTRA_FRAME_NRS ? INTER_REFS_PER_FRAME_NRS : ref); - for (MV_REFERENCE_FRAME ref2 = INVALID_IDX; ref2 < REF_FRAMES_NRS; ++ref2) { + for (MV_REFERENCE_FRAME ref2 = INVALID_IDX; ref2 < REF_FRAMES; ++ref2) { ref_combo[ref][ref2 + 1] = true; } } @@ -4510,9 +4468,8 @@ { INTRA_FRAME_NRS, INVALID_IDX }, }; -static void set_mask_combo_bit_nrs( - bool ref_combo[REF_FRAMES_NRS][REF_FRAMES_NRS + 1], - const MV_REFERENCE_FRAME *refs, bool val) { +static void set_mask_combo_bit_nrs(bool ref_combo[REF_FRAMES][REF_FRAMES + 1], + const MV_REFERENCE_FRAME *refs, bool val) { const MV_REFERENCE_FRAME r0 = (refs[0] == INTRA_FRAME_NRS ? INTER_REFS_PER_FRAME_NRS : refs[0]); const MV_REFERENCE_FRAME r1 = @@ -4521,7 +4478,7 @@ } static bool get_mask_combo_bit_nrs( - const bool ref_combo[REF_FRAMES_NRS][REF_FRAMES_NRS + 1], + const bool ref_combo[REF_FRAMES][REF_FRAMES + 1], const MV_REFERENCE_FRAME *refs) { const MV_REFERENCE_FRAME r0 = (refs[0] == INTRA_FRAME_NRS ? INTER_REFS_PER_FRAME_NRS : refs[0]); @@ -4580,11 +4537,7 @@ memset(mask->pred_modes, 0, sizeof(mask->pred_modes)); // All references disabled first. bool *mask_ref_combo = &mask->ref_combo[0][0]; -#if CONFIG_NEW_REF_SIGNALING - for (int k = 0; k < REF_FRAMES_NRS * (REF_FRAMES_NRS + 1); k++) -#else for (int k = 0; k < REF_FRAMES * (REF_FRAMES + 1); k++) -#endif // CONFIG_NEW_REF_SIGNALING mask_ref_combo[k] = true; const MV_REFERENCE_FRAME(*ref_set_combos)[2]; @@ -4913,12 +4866,7 @@ static AOM_INLINE void set_params_rd_pick_inter_mode( const AV1_COMP *cpi, MACROBLOCK *x, HandleInterModeArgs *args, BLOCK_SIZE bsize, mode_skip_mask_t *mode_skip_mask, int skip_ref_frame_mask, - unsigned int *ref_costs_single, -#if CONFIG_NEW_REF_SIGNALING - unsigned int (*ref_costs_comp)[REF_FRAMES_NRS], -#else - unsigned int (*ref_costs_comp)[REF_FRAMES], -#endif // CONFIG_NEW_REF_SIGNALING + unsigned int *ref_costs_single, unsigned int (*ref_costs_comp)[REF_FRAMES], struct buf_2d (*yv12_mb)[MAX_MB_PLANE]) { const AV1_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; @@ -6048,11 +5996,7 @@ const AV1_COMP *const cpi, MACROBLOCK *const x, RD_STATS *const rd_cost, HandleInterModeArgs *const args, TileDataEnc *const tile_data, PICK_MODE_CONTEXT *const ctx, -#if CONFIG_NEW_REF_SIGNALING - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE], -#else struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE], -#endif // CONFIG_NEW_REF_SIGNALING const motion_mode_best_st_candidate *const best_motion_mode_cands, int do_tx_search, const BLOCK_SIZE bsize, int64_t *const best_est_rd, InterModeSearchState *const search_state) { @@ -6322,13 +6266,9 @@ static void tx_search_best_inter_candidates( AV1_COMP *cpi, TileDataEnc *tile_data, MACROBLOCK *x, int64_t best_rd_so_far, BLOCK_SIZE bsize, -#if CONFIG_NEW_REF_SIGNALING - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE], -#else - struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE], -#endif // CONFIG_NEW_REF_SIGNALING - int mi_row, int mi_col, InterModeSearchState *search_state, - RD_STATS *rd_cost, PICK_MODE_CONTEXT *ctx) { + struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE], int mi_row, int mi_col, + InterModeSearchState *search_state, RD_STATS *rd_cost, + PICK_MODE_CONTEXT *ctx) { AV1_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; TxfmSearchInfo *txfm_info = &x->txfm_search_info; @@ -6533,11 +6473,7 @@ for (i = 0; i < MAX_WINNER_MOTION_MODES; ++i) best_motion_mode_cands.motion_mode_cand[i].rd_cost = INT64_MAX; -#if CONFIG_NEW_REF_SIGNALING - for (i = 0; i < REF_FRAMES_NRS; ++i) x->pred_sse[i] = INT_MAX; -#else for (i = 0; i < REF_FRAMES; ++i) x->pred_sse[i] = INT_MAX; -#endif // CONFIG_NEW_REF_SIGNALING av1_invalid_rd_stats(rd_cost); @@ -6560,15 +6496,9 @@ const int skip_ref_frame_mask = picked_ref_frames_mask ? ~picked_ref_frames_mask : 0; mode_skip_mask_t mode_skip_mask; -#if CONFIG_NEW_REF_SIGNALING - struct buf_2d yv12_mb[REF_FRAMES_NRS][MAX_MB_PLANE]; - unsigned int ref_costs_single[REF_FRAMES_NRS]; - unsigned int ref_costs_comp[REF_FRAMES_NRS][REF_FRAMES_NRS]; -#else struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE]; unsigned int ref_costs_single[REF_FRAMES]; unsigned int ref_costs_comp[REF_FRAMES][REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING // init params, set frame modes, speed features set_params_rd_pick_inter_mode(cpi, x, &args, bsize, &mode_skip_mask, skip_ref_frame_mask, ref_costs_single, @@ -7223,13 +7153,8 @@ const int comp_pred = 0; int i; int64_t best_pred_diff[REFERENCE_MODES]; -#if CONFIG_NEW_REF_SIGNALING - unsigned int ref_costs_single[REF_FRAMES_NRS]; - unsigned int ref_costs_comp[REF_FRAMES_NRS][REF_FRAMES_NRS]; -#else unsigned int ref_costs_single[REF_FRAMES]; unsigned int ref_costs_comp[REF_FRAMES][REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING const ModeCosts *mode_costs = &x->mode_costs; const int *comp_inter_cost = mode_costs->comp_inter_cost[av1_get_reference_mode_context(cm, xd)]; @@ -7245,11 +7170,10 @@ estimate_ref_frame_costs(cm, xd, mode_costs, segment_id, ref_costs_single, ref_costs_comp); -#if CONFIG_NEW_REF_SIGNALING - for (i = 0; i < REF_FRAMES_NRS; ++i) x->pred_sse[i] = INT_MAX; - for (i = 0; i < REF_FRAMES_NRS; ++i) x->pred_mv_sad[i] = INT_MAX; -#else for (i = 0; i < REF_FRAMES; ++i) x->pred_sse[i] = INT_MAX; +#if CONFIG_NEW_REF_SIGNALING + for (i = 0; i < REF_FRAMES; ++i) x->pred_mv_sad[i] = INT_MAX; +#else for (i = LAST_FRAME; i < REF_FRAMES; ++i) x->pred_mv_sad[i] = INT_MAX; #endif // CONFIG_NEW_REF_SIGNALING
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c index dbc11a2..8b60eb6 100644 --- a/av1/encoder/tpl_model.c +++ b/av1/encoder/tpl_model.c
@@ -972,11 +972,7 @@ AV1_COMMON *cm = &cpi->common; int cur_frame_idx = gf_group->index; *pframe_qindex = 0; -#if CONFIG_NEW_REF_SIGNALING - RefFrameMapPair ref_frame_map_pairs[REF_FRAMES_NRS]; -#else RefFrameMapPair ref_frame_map_pairs[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING init_ref_map_pair( cm, ref_frame_map_pairs, cpi->gf_group.update_type[cpi->gf_group.index] == KEY_FRAME); @@ -984,17 +980,9 @@ EncodeFrameParams frame_params = *init_frame_params; TplParams *const tpl_data = &cpi->tpl_data; -#if CONFIG_NEW_REF_SIGNALING - int ref_picture_map[REF_FRAMES_NRS]; -#else int ref_picture_map[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING -#if CONFIG_NEW_REF_SIGNALING - for (int i = 0; i < REF_FRAMES_NRS; ++i) { -#else for (int i = 0; i < REF_FRAMES; ++i) { -#endif // CONFIG_NEW_REF_SIGNALING if (frame_params.frame_type == KEY_FRAME || gop_eval) { tpl_data->tpl_frame[-i - 1].gf_picture = NULL; tpl_data->tpl_frame[-1 - 1].rec_picture = NULL; @@ -1079,11 +1067,7 @@ gf_index, true_disp, ref_frame_map_pairs); int refresh_frame_map_index = av1_get_refresh_ref_frame_map(refresh_mask); -#if CONFIG_NEW_REF_SIGNALING - if (refresh_frame_map_index < REF_FRAMES_NRS) { -#else if (refresh_frame_map_index < REF_FRAMES) { -#endif // CONFIG_NEW_REF_SIGNALING ref_frame_map_pairs[refresh_frame_map_index].disp_order = AOMMAX(0, true_disp); ref_frame_map_pairs[refresh_frame_map_index].pyr_level = @@ -1179,11 +1163,7 @@ av1_get_refresh_frame_flags(cpi, &frame_params, frame_update_type, -1, true_disp, ref_frame_map_pairs); int refresh_frame_map_index = av1_get_refresh_ref_frame_map(refresh_mask); -#if CONFIG_NEW_REF_SIGNALING - if (refresh_frame_map_index < REF_FRAMES_NRS) { -#else if (refresh_frame_map_index < REF_FRAMES) { -#endif // CONFIG_NEW_REF_SIGNALING ref_frame_map_pairs[refresh_frame_map_index].disp_order = AOMMAX(0, true_disp); ref_frame_map_pairs[refresh_frame_map_index].pyr_level =
diff --git a/av1/encoder/tpl_model.h b/av1/encoder/tpl_model.h index e465983..e90c946 100644 --- a/av1/encoder/tpl_model.h +++ b/av1/encoder/tpl_model.h
@@ -78,11 +78,7 @@ #define MAX_TPL_FRAME_IDX (2 * MAX_LAG_BUFFERS) // The first REF_FRAMES + 1 buffers are reserved. // tpl_data->tpl_frame starts after REF_FRAMES + 1 -#if CONFIG_NEW_REF_SIGNALING -#define MAX_LENGTH_TPL_FRAME_STATS (MAX_TPL_FRAME_IDX + REF_FRAMES_NRS + 1) -#else #define MAX_LENGTH_TPL_FRAME_STATS (MAX_TPL_FRAME_IDX + REF_FRAMES + 1) -#endif // CONFIG_NEW_REF_SIGNALING #define MAX_TPL_EXTEND (MAX_LAG_BUFFERS - MAX_GF_INTERVAL) #define TPL_DEP_COST_SCALE_LOG2 4 @@ -109,11 +105,7 @@ TplDepStats *tpl_stats_ptr; const YV12_BUFFER_CONFIG *gf_picture; YV12_BUFFER_CONFIG *rec_picture; -#if CONFIG_NEW_REF_SIGNALING - int ref_map_index[REF_FRAMES_NRS]; -#else int ref_map_index[REF_FRAMES]; -#endif // CONFIG_NEW_REF_SIGNALING int stride; int width; int height;