Delete code relating to featureupdates experiment.
Change-Id: If218762c658bb8cbb3007cf2069123b3e05adcbc
"
EXPERIMENT_LIST="
csm
- featureupdates
comp_intra_pred
superblocks
pred_filter
signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
unsigned int segment_feature_mask[MAX_MB_SEGMENTS];
-#if CONFIG_FEATUREUPDATES
- // keep around the last set so we can figure out what updates...
- unsigned int old_segment_feature_mask[MAX_MB_SEGMENTS];
- signed char old_segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
-#endif
-
/* mode_based Loop filter adjustment */
unsigned char mode_ref_lf_delta_enabled;
unsigned char mode_ref_lf_delta_update;
}
}
-#if CONFIG_FEATUREUPDATES
-// TODO: Multiple copies of loop filtering code should be pruned and
-// cut down. This just adds yet another so that I can do an if
-// on segment.
-void vp8_loop_filter_frame_segment(VP8_COMMON *cm, MACROBLOCKD *xd,
- int default_filt_lvl, int segment) {
- YV12_BUFFER_CONFIG *post = cm->frame_to_show;
-
- unsigned char *y_ptr;
- int mb_row;
- int mb_col;
-
- loop_filter_info_n *lfi_n = &cm->lf_info;
- struct loop_filter_info lfi;
-
- int filter_level;
- FRAME_TYPE frame_type = cm->frame_type;
-
- /* Point at base of Mb MODE_INFO list */
- const MODE_INFO *mode_info_context = cm->mi;
-
-#if 0
- if (default_filt_lvl == 0) /* no filter applied */
- return;
-#endif
-
- /* Initialize the loop filter for this frame. */
- vp8_loop_filter_frame_init(cm, xd, default_filt_lvl);
-
- /* Set up the buffer pointers */
- y_ptr = post->y_buffer;
-
- /* vp8_filter each macro block */
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
- int skip_lf = (mode_info_context->mbmi.mode != B_PRED
- && mode_info_context->mbmi.mode != I8X8_PRED
- && mode_info_context->mbmi.mode != SPLITMV
- && mode_info_context->mbmi.mb_skip_coeff);
-
- const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi
- .mode];
- const int seg = mode_info_context->mbmi.segment_id;
- const int ref_frame = mode_info_context->mbmi.ref_frame;
-
- filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
-
- // check if this mb has filtering applied
- // and then whether it is the right segment or
- // if not whether the passed in segment is 0 and this
- // segment has no alt lf
-
- // TODO: Make this work for when segment 0 has the alt lv enabled
- if (filter_level
- && (seg == segment
- || (!vp9_segfeature_active(xd, seg, SEG_LVL_ALT_LF)
- && segment == 0))) {
- if (cm->filter_type == NORMAL_LOOPFILTER) {
- const int hev_index =
- lfi_n->hev_thr_lut[frame_type][filter_level];
- lfi.mblim = lfi_n->mblim[filter_level];
- lfi.blim = lfi_n->blim[filter_level];
- lfi.lim = lfi_n->lim[filter_level];
- lfi.hev_thr = lfi_n->hev_thr[hev_index];
-
- if (mb_col > 0)
- vp8_loop_filter_mbv(y_ptr, 0, 0, post->y_stride, 0,
- &lfi);
-
- if (!skip_lf)
- vp8_loop_filter_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi);
-
- /* don't apply across umv border */
- if (mb_row > 0)
- vp8_loop_filter_mbh(y_ptr, 0, 0, post->y_stride, 0,
- &lfi);
-
- if (!skip_lf)
- vp8_loop_filter_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi);
- } else {
- if (mb_col > 0)
- vp8_loop_filter_simple_mbv(y_ptr, post->y_stride,
- lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- vp8_loop_filter_simple_bv(y_ptr, post->y_stride,
- lfi_n->blim[filter_level]);
-
- /* don't apply across umv border */
- if (mb_row > 0)
- vp8_loop_filter_simple_mbh(y_ptr, post->y_stride,
- lfi_n->mblim[filter_level]);
-
- if (!skip_lf)
- vp8_loop_filter_simple_bh(y_ptr, post->y_stride,
- lfi_n->blim[filter_level]);
- }
- }
-
- y_ptr += 16;
- mode_info_context++; /* step to next MB */
-
- }
-
- y_ptr += post->y_stride * 16 - post->y_width;
- mode_info_context++; /* Skip border mb */
- }
-
-}
-#endif
void vp8_loop_filter_partial_frame
(
return xd->segment_feature_data[segment_id][feature_id];
}
-#if CONFIG_FEATUREUPDATES
-int vp9_old_segfeature_active(MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id) {
- // Return true if mask bit set and segmentation enabled.
- return (xd->segmentation_enabled &&
- (xd->old_segment_feature_mask[segment_id] &
- (0x01 << feature_id)));
-}
-
-int vp9_get_old_segdata(MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id) {
- return xd->old_segment_feature_data[segment_id][feature_id];
-}
-
-int vp9_segfeature_changed(MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id) {
- // Return true if mask bit or data is different from last time
- return
- (xd->segmentation_enabled &&
- (
- (xd->old_segment_feature_mask[segment_id] & (1 << feature_id)) !=
- (xd->segment_feature_mask[segment_id] & (1 << feature_id))
- || xd->old_segment_feature_data[segment_id][feature_id] !=
- xd->segment_feature_data[segment_id][feature_id]
- )
- );
-}
-
-void vp9_save_segment_info(MACROBLOCKD *xd) {
- int i, j;
- for (i = 0; i < MAX_MB_SEGMENTS; i++) {
- xd->old_segment_feature_mask[i] = xd->segment_feature_mask[i];
-
- // For each segmentation codable feature...
- for (j = 0; j < SEG_LVL_MAX; j++) {
- xd->old_segment_feature_data[i][j] = xd->segment_feature_data[i][j];
-
- }
- }
-}
-#endif
void vp9_clear_segref(MACROBLOCKD *xd, int segment_id) {
xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] = 0;
}
int segment_id,
SEG_LVL_FEATURES feature_id);
-#if CONFIG_FEATUREUPDATES
-
-int vp9_old_segfeature_active(MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id);
-
-int vp9_get_old_segdata(MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id);
-
-void vp9_save_segment_info(MACROBLOCKD *xd);
-
-int vp9_segfeature_changed(MACROBLOCKD *xd,
- int segment_id,
- SEG_LVL_FEATURES feature_id);
-
-
-
-#endif
-
-
void vp9_clear_segref(MACROBLOCKD *xd, int segment_id);
void vp9_set_segref(MACROBLOCKD *xd,
for (i = 0; i < MAX_MB_SEGMENTS; i++) {
// For each of the segments features...
for (j = 0; j < SEG_LVL_MAX; j++) {
-
-#if CONFIG_FEATUREUPDATES
- // feature updated?
- if (vp8_read_bit(&header_bc)) {
- int active = 1;
-
- if (vp9_segfeature_active(xd, i, j))
- active = vp8_read_bit(&header_bc);
-
- // Is the feature enabled
- if (active) {
- // Update the feature data and mask
- vp9_enable_segfeature(xd, i, j);
-
- data = (signed char)vp8_read_literal(
- &header_bc, vp9_seg_feature_data_bits(j));
-
- // Is the segment data signed..
- if (vp9_is_segfeature_signed(j)) {
- if (vp8_read_bit(&header_bc))
- data = - data;
- }
- } else
- data = 0;
-
- vp9_set_segdata(xd, i, j, data);
- }
-
-#else
// Is the feature enabled
if (vp8_read_bit(&header_bc)) {
// Update the feature data and mask
data = 0;
vp9_set_segdata(xd, i, j, data);
-#endif
}
}
}
for (j = 0; j < SEG_LVL_MAX; j++) {
Data = vp9_get_segdata(xd, i, j);
-
-#if CONFIG_FEATUREUPDATES
-
- // check if there's an update
- if (vp9_segfeature_changed(xd, i, j)) {
- vp8_write_bit(&header_bc, 1);
-
- if (vp9_segfeature_active(xd, i, j)) {
- // this bit is to say we are still
- // active/ if we were inactive
- // this is unnecessary
- if (vp9_old_segfeature_active(xd, i, j)) {
- vp8_write_bit(&header_bc, 1);
- }
- // Is the segment data signed..
- if (vp9_is_segfeature_signed(j)) {
- // Encode the relevant feature data
- if (Data < 0) {
- Data = - Data;
- vp8_write_literal(&header_bc, Data,
- vp9_seg_feature_data_bits(j));
- vp8_write_bit(&header_bc, 1);
- } else {
- vp8_write_literal(&header_bc, Data,
- vp9_seg_feature_data_bits(j));
- vp8_write_bit(&header_bc, 0);
- }
- }
- // Unsigned data element so no sign bit needed
- else
- vp8_write_literal(&header_bc, Data,
- vp9_seg_feature_data_bits(j));
- } else if (vp9_old_segfeature_active(xd, i, j)) {
- // feature is inactive now
- vp8_write_bit(&header_bc, 0);
- }
- } else {
- vp8_write_bit(&header_bc, 0);
- }
-#else
-
// If the feature is enabled...
if (vp9_segfeature_active(xd, i, j)) {
vp8_write_bit(&header_bc, 1);
vp9_seg_feature_data_bits(j));
} else
vp8_write_bit(&header_bc, 0);
-#endif
}
}
}
-
-#if CONFIG_FEATUREUPDATES
- // save the segment info for updates next frame
- vp9_save_segment_info(xd);
-#endif
-
}
// Encode the common prediction model status flag probability updates for
// Stub function for now Alt LF not used
void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val) {
}
-#if CONFIG_FEATUREUPDATES
-void vp8cx_pick_filter_level_sg(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi, int segment) {
- VP8_COMMON *cm = &cpi->common;
-
- int best_err = 0;
- int filt_err = 0;
- int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
- int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
-
- int filter_step;
- int filt_high = 0;
- int filt_mid = cm->filter_level; // Start search at previous frame filter level
- int filt_low = 0;
- int filt_best;
- int filt_direction = 0;
-
- int Bias = 0; // Bias against raising loop filter and in favour of lowering it
-
- // Make a copy of the unfiltered / processed recon buffer
-#if HAVE_ARMV7
-#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(cm->frame_to_show, &cpi->last_frame_uf);
- }
-#if CONFIG_RUNTIME_CPU_DETECT
- else
-#endif
-#endif
-#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf);
- }
-#endif
-
- if (cm->frame_type == KEY_FRAME)
- cm->sharpness_level = 0;
- else
- cm->sharpness_level = cpi->oxcf.Sharpness;
-
- // Start the search at the previous frame filter level unless it is now out of range.
- filt_mid = cm->filter_level;
-
- if (filt_mid < min_filter_level)
- filt_mid = min_filter_level;
- else if (filt_mid > max_filter_level)
- filt_mid = max_filter_level;
-
- // Define the initial step size
- filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
-
- // Get baseline error score
- vp8cx_set_alt_lf_level(cpi, filt_mid);
- vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_mid, segment);
-
- best_err = vp8_calc_ss_err(sd, cm->frame_to_show);
- filt_best = filt_mid;
-
- // Re-instate the unfiltered frame
-#if HAVE_ARMV7
-#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#if CONFIG_RUNTIME_CPU_DETECT
- else
-#endif
-#endif
-#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#endif
-
- while (filter_step > 0) {
- Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; // PGW change 12/12/06 for small images
-
- // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
- if (cpi->twopass.section_intra_rating < 20)
- Bias = Bias * cpi->twopass.section_intra_rating / 20;
-
- // yx, bias less for large block size
- if (cpi->common.txfm_mode != ONLY_4X4)
- Bias >>= 1;
-
- filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step);
- filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
- if ((filt_direction <= 0) && (filt_low != filt_mid)) {
- // Get Low filter error score
- vp8cx_set_alt_lf_level(cpi, filt_low);
- vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_low, segment);
-
- filt_err = vp8_calc_ss_err(sd, cm->frame_to_show);
-
- // Re-instate the unfiltered frame
-#if HAVE_ARMV7
-#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#if CONFIG_RUNTIME_CPU_DETECT
- else
-#endif
-#endif
-#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#endif
-
- // If value is close to the best so far then bias towards a lower loop filter value.
- if ((filt_err - Bias) < best_err) {
- // Was it actually better than the previous best?
- if (filt_err < best_err)
- best_err = filt_err;
-
- filt_best = filt_low;
- }
- }
-
- // Now look at filt_high
- if ((filt_direction >= 0) && (filt_high != filt_mid)) {
- vp8cx_set_alt_lf_level(cpi, filt_high);
- vp8_loop_filter_frame_segment(cm, &cpi->mb.e_mbd, filt_high, segment);
-
- filt_err = vp8_calc_ss_err(sd, cm->frame_to_show);
-
- // Re-instate the unfiltered frame
-#if HAVE_ARMV7
-#if CONFIG_RUNTIME_CPU_DETECT
- if (cm->rtcd.flags & HAS_NEON)
-#endif
- {
- vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#if CONFIG_RUNTIME_CPU_DETECT
- else
-#endif
-#endif
-#if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT
- {
- vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show);
- }
-#endif
-
- // Was it better than the previous best?
- if (filt_err < (best_err - Bias)) {
- best_err = filt_err;
- filt_best = filt_high;
- }
- }
-
- // Half the step distance if the best filter value was the same as last time
- if (filt_best == filt_mid) {
- filter_step = filter_step / 2;
- filt_direction = 0;
- } else {
- filt_direction = (filt_best < filt_mid) ? -1 : 1;
- filt_mid = filt_best;
- }
- }
-
- cm->filter_level = filt_best;
-}
-
-void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) {
- VP8_COMMON *oci = &cpi->common;
- MODE_INFO *mi = oci->mi;
- int filt_lev[2];
- int i, j;
- MACROBLOCKD *const xd = &cpi->mb.e_mbd;
- int max_seg;
- int mb_index = 0;
-
- // pick the loop filter for each segment after segment 0
- for (i = 1; i < MAX_MB_SEGMENTS; i++) {
- // if the segment loop filter is active
- if (vp9_segfeature_active(xd, i, SEG_LVL_ALT_LF)) {
- vp9_set_segdata(xd, i, SEG_LVL_ALT_LF, 0);
- vp8cx_pick_filter_level_sg(sd, cpi, i);
- filt_lev[i] = oci->filter_level;
- }
- }
-
- // do the 0 segment ( this filter also picks the filter value for all
- // the not enabled features )
-
- // TODO : Fix the code if segment 0 is the one with seg_lvl_alt_lf on
- // right now assumes segment 0 gets base loop filter and the rest are
- // deltas off of segment 0.
- vp9_set_segdata(xd, 0, SEG_LVL_ALT_LF, 0);
- vp8cx_pick_filter_level_sg(sd, cpi, 0);
- filt_lev[0] = oci->filter_level;
-
- // convert the best filter level for the mbs of the segment to
- // a delta from 0
- for (i = 1; i < MAX_MB_SEGMENTS; i++)
- if (vp9_segfeature_active(xd, i, SEG_LVL_ALT_LF)) {
- vp9_set_segdata(xd, i, SEG_LVL_ALT_LF, filt_lev[i] - filt_lev[0]);
- xd->update_mb_segmentation_data !=
- vp9_segfeature_changed(xd, i, SEG_LVL_ALT_LF);
- }
-}
-#else
void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) {
VP8_COMMON *cm = &cpi->common;
cm->filter_level = filt_best;
}
-#endif