Commit aff479fa authored by Cheng Chen's avatar Cheng Chen

Clamp loop filter levels

Clamp in range [-MAX_LOOP_FILTER, MAX_LOOP_FILTER], for experiment LOOPFILTER_LEVELS.

BUG=aomedia:970

Change-Id: Ica52242e969dcea49565f118155de5eef32a4cc4
parent 3392c436
......@@ -1184,17 +1184,21 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
const int tmp_lvl =
xd->prev_delta_lf[lf_id] +
read_delta_lflevel(cm, xd, r, lf_id, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf[lf_id] = xd->curr_delta_lf[lf_id];
}
} else {
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
const int tmp_lvl =
xd->prev_delta_lf_from_base +
read_delta_lflevel(cm, xd, r, -1, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
}
#else
......@@ -1203,7 +1207,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
read_delta_lflevel(cm, xd, r, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(current_delta_lf_from_base, 0, MAX_LOOP_FILTER);
clamp(current_delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
#endif // CONFIG_LOOPFILTER_LEVEL
}
......@@ -2716,17 +2720,21 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
const int tmp_lvl =
xd->prev_delta_lf[lf_id] +
read_delta_lflevel(cm, xd, r, lf_id, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf[lf_id] = xd->curr_delta_lf[lf_id];
}
} else {
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
const int tmp_lvl =
xd->prev_delta_lf_from_base +
read_delta_lflevel(cm, xd, r, -1, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
}
#else
......@@ -2735,7 +2743,7 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
read_delta_lflevel(cm, xd, r, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(current_delta_lf_from_base, 0, MAX_LOOP_FILTER);
clamp(current_delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
#endif // CONFIG_LOOPFILTER_LEVEL
}
......
......@@ -3389,12 +3389,14 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
for (j = 0; j < AOMMIN(cm->mib_size, cm->mi_rows - mi_row); j++) {
for (k = 0; k < AOMMIN(cm->mib_size, cm->mi_cols - mi_col); k++) {
cm->mi[(mi_row + j) * cm->mi_stride + (mi_col + k)]
.mbmi.current_delta_lf_from_base =
clamp(current_delta_lf_from_base, 0, MAX_LOOP_FILTER);
.mbmi.current_delta_lf_from_base = clamp(
current_delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
#if CONFIG_LOOPFILTER_LEVEL
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
cm->mi[(mi_row + j) * cm->mi_stride + (mi_col + k)]
.mbmi.curr_delta_lf[lf_id] = current_delta_lf_from_base;
.mbmi.curr_delta_lf[lf_id] =
clamp(current_delta_lf_from_base, -MAX_LOOP_FILTER,
MAX_LOOP_FILTER);
}
#endif // CONFIG_LOOPFILTER_LEVEL
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment