Commit 5dcef7d2 authored by Cheng Chen's avatar Cheng Chen
Browse files

LPF_SB: make it work with seg and ext_delta_q

Clean up unused code. Now lpf_sb works as baseline loop filter. It
is compatible with seg feature and ext_delta_q.

Change-Id: If5deb10d9f35cc3037463e7e8420bcd6b2b0255e
parent bf3d4964
......@@ -326,20 +326,8 @@ static uint8_t get_filter_level(const AV1_COMMON *cm,
const loop_filter_info_n *lfi_n,
#if CONFIG_LOOPFILTER_LEVEL
const int dir_idx, int plane,
#endif
#if CONFIG_LPF_SB
int mi_row, int mi_col,
#endif
const MB_MODE_INFO *mbmi) {
#if CONFIG_LPF_SB
#if CONFIG_LOOPFILTER_LEVEL
const int lvl_idx = plane == 0 ? dir_idx : plane + 1;
return cm->mi[mi_row * cm->mi_stride + mi_col].mbmi.filt_lvl[lvl_idx];
#else
return cm->mi[mi_row * cm->mi_stride + mi_col].mbmi.filt_lvl;
#endif
#endif
const int segment_id = mbmi->segment_id;
if (cm->delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
......@@ -390,10 +378,6 @@ static uint8_t get_filter_level(const AV1_COMMON *cm,
#else
static uint8_t get_filter_level(const loop_filter_info_n *lfi_n,
const MB_MODE_INFO *mbmi) {
#if CONFIG_LPF_SB
return mbmi->filt_lvl;
#endif
const int segment_id = mbmi->segment_id;
return lfi_n->lvl[segment_id][mbmi->ref_frame[0]][mode_lf_lut[mbmi->mode]];
}
......@@ -414,35 +398,6 @@ void av1_loop_filter_init(AV1_COMMON *cm) {
memset(lfi->lfthr[lvl].hev_thr, (lvl >> 4), SIMD_WIDTH);
}
#if CONFIG_LPF_SB
void av1_loop_filter_sb_level_init(AV1_COMMON *cm, int mi_row, int mi_col,
#if CONFIG_LOOPFILTER_LEVEL
int plane, int dir,
#endif
int lvl) {
const int mi_row_start = AOMMAX(0, mi_row - FILT_BOUNDARY_MI_OFFSET);
const int mi_col_start = AOMMAX(0, mi_col - FILT_BOUNDARY_MI_OFFSET);
const int mi_row_range = mi_row - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE;
const int mi_col_range = mi_col - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE;
const int mi_row_end = AOMMIN(mi_row_range, cm->mi_rows);
const int mi_col_end = AOMMIN(mi_col_range, cm->mi_cols);
int row, col;
for (row = mi_row_start; row < mi_row_end; ++row) {
for (col = mi_col_start; col < mi_col_end; ++col) {
// Note: can't use cm->mi_grid_visible. Because for each partition,
// all visible pointers will point to the first of the partition.
#if CONFIG_LOOPFILTER_LEVEL
const int lvl_idx = plane == 0 ? dir : plane + 1;
cm->mi[row * cm->mi_stride + col].mbmi.filt_lvl[lvl_idx] = lvl;
#else
cm->mi[row * cm->mi_stride + col].mbmi.filt_lvl = lvl;
#endif // CONFIG_LOOPFILTER_LEVEL
}
}
}
#endif // CONFIG_LPF_SB
void av1_loop_filter_frame_init(AV1_COMMON *cm, int default_filt_lvl,
int default_filt_lvl_r
#if CONFIG_LOOPFILTER_LEVEL
......@@ -934,17 +889,9 @@ static void build_masks(AV1_COMMON *const cm,
txsize_vert_map[uv_txsize_lookup[block_size][mbmi->tx_size][1][1]];
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
#if CONFIG_LPF_SB
const int filter_level = get_filter_level(cm, lfi_n, 0, 0, 0, 0, mbmi);
#else
const int filter_level = get_filter_level(cm, lfi_n, 0, 0, mbmi);
#endif
#else
#if CONFIG_LPF_SB
const int filter_level = get_filter_level(cm, lfi_n, 0, 0, mbmi);
#else
const int filter_level = get_filter_level(cm, lfi_n, mbmi);
#endif // CONFIG_LPF_SB
#endif
#else
const int filter_level = get_filter_level(lfi_n, mbmi);
......@@ -1032,17 +979,9 @@ static void build_y_mask(AV1_COMMON *const cm,
const BLOCK_SIZE block_size = mbmi->sb_type;
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
#if CONFIG_LPF_SB
const int filter_level = get_filter_level(cm, lfi_n, 0, 0, 0, 0, mbmi);
#else
const int filter_level = get_filter_level(cm, lfi_n, 0, 0, mbmi);
#endif
#else
#if CONFIG_LPF_SB
const int filter_level = get_filter_level(cm, lfi_n, 0, 0, mbmi);
#else
const int filter_level = get_filter_level(cm, lfi_n, mbmi);
#endif // CONFIG_LPF_SB
#endif
#else
const int filter_level = get_filter_level(lfi_n, mbmi);
......@@ -1509,21 +1448,10 @@ static void get_filter_level_and_masks_non420(
// Filter level can vary per MI
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
#if CONFIG_LPF_SB
if (!(lfl_r[c_step] = get_filter_level(cm, &cm->lf_info, 0, 0, 0, 0, mbmi)))
continue;
#else
if (!(lfl_r[c_step] = get_filter_level(cm, &cm->lf_info, 0, 0, mbmi)))
continue;
#endif
#else
#if CONFIG_LPF_SB
if (!(lfl_r[c_step] =
get_filter_level(cm, &cm->lf_info, mi_row, mi_col, mbmi)))
continue;
#else
if (!(lfl_r[c_step] = get_filter_level(cm, &cm->lf_info, mbmi))) continue;
#endif // CONFIG_LPF_SB
#endif
#else
if (!(lfl_r[c_step] = get_filter_level(&cm->lf_info, mbmi))) continue;
......@@ -2169,20 +2097,10 @@ static void set_lpf_parameters(
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
#if CONFIG_LPF_SB
const uint32_t curr_level = get_filter_level(cm, &cm->lf_info, edge_dir,
plane, mi_row, mi_col, mbmi);
#else
const uint32_t curr_level =
get_filter_level(cm, &cm->lf_info, edge_dir, plane, mbmi);
#endif
#else
#if CONFIG_LPF_SB
const uint32_t curr_level =
get_filter_level(cm, &cm->lf_info, mi_row, mi_col, mbmi);
#else
const uint32_t curr_level = get_filter_level(cm, &cm->lf_info, mbmi);
#endif // CONFIG_LPF_SB
#endif
#else
const uint32_t curr_level = get_filter_level(&cm->lf_info, mbmi);
......@@ -2216,22 +2134,11 @@ static void set_lpf_parameters(
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
#if CONFIG_LPF_SB
const uint32_t pv_lvl =
get_filter_level(cm, &cm->lf_info, edge_dir, plane, mi_row,
mi_col, &mi_prev->mbmi);
#else
const uint32_t pv_lvl = get_filter_level(cm, &cm->lf_info, edge_dir,
plane, &mi_prev->mbmi);
#endif
#else
#if CONFIG_LPF_SB
const uint32_t pv_lvl = get_filter_level(cm, &cm->lf_info, pv_row,
pv_col, &mi_prev->mbmi);
#else
const uint32_t pv_lvl =
get_filter_level(cm, &cm->lf_info, &mi_prev->mbmi);
#endif // CONFIG_LPF_SB
#endif
#else
const uint32_t pv_lvl =
......@@ -2630,19 +2537,11 @@ void av1_loop_filter_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
#endif
#endif
#if CONFIG_LPF_SB
#if CONFIG_LOOPFILTER_LEVEL
if (partial_frame && !frame_filter_level && !frame_filter_level_r) return;
#else
if (partial_frame && !frame_filter_level) return;
#endif // CONFIG_LOOPFILTER_LEVEL
#else // !CONFIG_LPF_SB
#if CONFIG_LOOPFILTER_LEVEL
if (!frame_filter_level && !frame_filter_level_r) return;
#else
if (!frame_filter_level) return;
#endif
#endif // CONFIG_LPF_SB
#if CONFIG_LPF_SB
int start_mi_col;
int end_mi_col;
......@@ -2659,15 +2558,6 @@ void av1_loop_filter_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
const int mi_col_range = mi_col - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE;
end_mi_row = AOMMIN(mi_row_range, cm->mi_rows);
end_mi_col = AOMMIN(mi_col_range, cm->mi_cols);
#if CONFIG_LOOPFILTER_LEVEL
av1_loop_filter_sb_level_init(cm, mi_row, mi_col, y_only, 0,
frame_filter_level);
av1_loop_filter_sb_level_init(cm, mi_row, mi_col, y_only, 1,
frame_filter_level_r);
#else
av1_loop_filter_sb_level_init(cm, mi_row, mi_col, frame_filter_level);
#endif
} else {
start_mi_row = 0;
mi_rows_to_filter = cm->mi_rows;
......
......@@ -2156,11 +2156,8 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
cm->lf.filter_level_v, 2, 1, mi_row, mi_col);
}
#else
// apply deblocking filtering right after each superblock is decoded
const int filter_lvl =
cm->mi[mi_row * cm->mi_stride + mi_col].mbmi.filt_lvl;
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, &pbi->mb,
filter_lvl, 0, 1, mi_row, mi_col);
cm->lf.filter_level, 0, 1, mi_row, mi_col);
#endif // CONFIG_LOOPFILTER_LEVEL
}
#endif // CONFIG_LPF_SB
......
......@@ -3252,9 +3252,6 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
filter_lvl = lf->filter_level;
av1_loop_filter_frame(get_frame_new_buffer(cm), cm, xd, filter_lvl, 0, 1,
mi_row, mi_col);
// if filter_lvl is 0, we still need to set mi info
if (filter_lvl == 0)
av1_loop_filter_sb_level_init(cm, mi_row, mi_col, filter_lvl);
#endif // CONFIG_LOOPFILTER_LEVEL
}
#endif // CONFIG_LPF_SB
......
......@@ -48,7 +48,7 @@ int av1_get_max_filter_level(const AV1_COMP *cpi) {
}
}
#if !CONFIG_LPF_SB // CONFIG_LPF_SB
#if !CONFIG_LPF_SB
static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd,
AV1_COMP *const cpi, int filt_level,
int partial_frame
......@@ -278,7 +278,7 @@ void av1_pick_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level);
#endif
} else {
#if !CONFIG_LPF_SB // !CONFIG_LPF_SB
#if !CONFIG_LPF_SB
#if CONFIG_LOOPFILTER_LEVEL
lf->filter_level[0] = lf->filter_level[1] = search_filter_level(
sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL, 0, 2);
......@@ -295,6 +295,6 @@ void av1_pick_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
lf->filter_level =
search_filter_level(sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL);
#endif // CONFIG_LOOPFILTER_LEVEL
#endif // CONFIG_LPF_SB
#endif // !CONFIG_LPF_SB
}
}
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