Commit 66de2b71 authored by Scott LaVarnway's avatar Scott LaVarnway Committed by Gerrit Code Review
Browse files

Merge "VP9: move loopfilter build masks to decode loop"

parents 388a807e 77181171
......@@ -115,6 +115,8 @@ void vp9_free_context_buffers(VP9_COMMON *cm) {
cm->above_context = NULL;
vpx_free(cm->above_seg_context);
cm->above_seg_context = NULL;
vpx_free(cm->lf.lfm);
cm->lf.lfm = NULL;
}
int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
......@@ -149,6 +151,16 @@ int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
cm->above_context_alloc_cols = cm->mi_cols;
}
vpx_free(cm->lf.lfm);
// Each lfm holds bit masks for all the 8x8 blocks in a 64x64 region. The
// stride and rows are rounded up / truncated to a multiple of 8.
cm->lf.lfm_stride = (cm->mi_cols + (MI_BLOCK_SIZE - 1)) >> 3;
cm->lf.lfm = (LOOP_FILTER_MASK *)vpx_calloc(
((cm->mi_rows + (MI_BLOCK_SIZE - 1)) >> 3) * cm->lf.lfm_stride,
sizeof(*cm->lf.lfm));
if (!cm->lf.lfm) goto fail;
return 0;
fail:
......
This diff is collapsed.
......@@ -35,24 +35,6 @@ enum lf_path {
LF_PATH_SLOW,
};
struct loopfilter {
int filter_level;
int sharpness_level;
int last_sharpness_level;
uint8_t mode_ref_delta_enabled;
uint8_t mode_ref_delta_update;
// 0 = Intra, Last, GF, ARF
signed char ref_deltas[MAX_REF_LF_DELTAS];
signed char last_ref_deltas[MAX_REF_LF_DELTAS];
// 0 = ZERO_MV, MV
signed char mode_deltas[MAX_MODE_LF_DELTAS];
signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
};
// Need to align this structure so when it is declared and
// passed it can be loaded into vector registers.
typedef struct {
......@@ -83,9 +65,29 @@ typedef struct {
uint16_t above_uv[TX_SIZES];
uint16_t int_4x4_uv;
uint8_t lfl_y[64];
uint8_t lfl_uv[16];
} LOOP_FILTER_MASK;
struct loopfilter {
int filter_level;
int sharpness_level;
int last_sharpness_level;
uint8_t mode_ref_delta_enabled;
uint8_t mode_ref_delta_update;
// 0 = Intra, Last, GF, ARF
signed char ref_deltas[MAX_REF_LF_DELTAS];
signed char last_ref_deltas[MAX_REF_LF_DELTAS];
// 0 = ZERO_MV, MV
signed char mode_deltas[MAX_MODE_LF_DELTAS];
signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
LOOP_FILTER_MASK *lfm;
int lfm_stride;
};
/* assorted loopfilter functions which get used elsewhere */
struct VP9Common;
struct macroblockd;
......@@ -116,7 +118,7 @@ void vp9_filter_block_plane_non420(struct VP9Common *cm,
void vp9_loop_filter_init(struct VP9Common *cm);
// Update the loop filter for the current frame.
// This should be called before vp9_loop_filter_rows(), vp9_loop_filter_frame()
// This should be called before vp9_loop_filter_frame(), vp9_build_mask_frame()
// calls this function directly.
void vp9_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl);
......@@ -126,11 +128,19 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
int filter_level,
int y_only, int partial_frame);
// Apply the loop filter to [start, stop) macro block rows in frame_buffer.
void vp9_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer,
struct VP9Common *cm,
struct macroblockd_plane planes[MAX_MB_PLANE],
int start, int stop, int y_only);
// Get the superblock lfm for a given mi_row, mi_col.
static INLINE LOOP_FILTER_MASK *get_lfm(const struct loopfilter *lf,
const int mi_row, const int mi_col) {
return &lf->lfm[(mi_col >> 3) + ((mi_row >> 3) * lf->lfm_stride)];
}
void vp9_build_mask(struct VP9Common *cm, const MB_MODE_INFO *mbmi, int mi_row,
int mi_col, int bw, int bh);
void vp9_adjust_mask(struct VP9Common *const cm, const int mi_row,
const int mi_col, LOOP_FILTER_MASK *lfm);
void vp9_build_mask_frame(struct VP9Common *cm, int frame_filter_level,
int partial_frame);
void vp9_reset_lfm(struct VP9Common *const cm);
typedef struct LoopFilterWorkerData {
YV12_BUFFER_CONFIG *frame_buffer;
......
......@@ -109,29 +109,27 @@ void thread_loop_filter_rows(const YV12_BUFFER_CONFIG *const frame_buffer,
for (mi_row = start; mi_row < stop;
mi_row += lf_sync->num_workers * MI_BLOCK_SIZE) {
MODE_INFO **const mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
LOOP_FILTER_MASK *lfm = get_lfm(&cm->lf, mi_row, 0);
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE, ++lfm) {
const int r = mi_row >> MI_BLOCK_SIZE_LOG2;
const int c = mi_col >> MI_BLOCK_SIZE_LOG2;
LOOP_FILTER_MASK lfm;
int plane;
sync_read(lf_sync, r, c);
vp9_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
// TODO(JBB): Make setup_mask work for non 420.
vp9_setup_mask(cm, mi_row, mi_col, mi + mi_col, cm->mi_stride,
&lfm);
vp9_adjust_mask(cm, mi_row, mi_col, lfm);
vp9_filter_block_plane_ss00(cm, &planes[0], mi_row, &lfm);
vp9_filter_block_plane_ss00(cm, &planes[0], mi_row, lfm);
for (plane = 1; plane < num_planes; ++plane) {
switch (path) {
case LF_PATH_420:
vp9_filter_block_plane_ss11(cm, &planes[plane], mi_row, &lfm);
vp9_filter_block_plane_ss11(cm, &planes[plane], mi_row, lfm);
break;
case LF_PATH_444:
vp9_filter_block_plane_ss00(cm, &planes[plane], mi_row, &lfm);
vp9_filter_block_plane_ss00(cm, &planes[plane], mi_row, lfm);
break;
case LF_PATH_SLOW:
vp9_filter_block_plane_non420(cm, &planes[plane], mi + mi_col,
......
......@@ -896,6 +896,10 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
}
xd->corrupted |= vpx_reader_has_error(r);
if (cm->lf.filter_level) {
vp9_build_mask(cm, mbmi, mi_row, mi_col, bw, bh);
}
}
static INLINE int dec_partition_plane_context(const MACROBLOCKD *xd,
......@@ -1468,6 +1472,8 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
memset(cm->above_seg_context, 0,
sizeof(*cm->above_seg_context) * aligned_cols);
vp9_reset_lfm(cm);
get_tile_buffers(pbi, data, data_end, tile_cols, tile_rows, tile_buffers);
if (pbi->tile_data == NULL ||
......@@ -1666,6 +1672,8 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
memset(cm->above_seg_context, 0,
sizeof(*cm->above_seg_context) * aligned_mi_cols);
vp9_reset_lfm(cm);
// Load tile data into tile_buffers
get_tile_buffers(pbi, data, data_end, tile_cols, tile_rows, tile_buffers);
......
......@@ -2764,6 +2764,7 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
struct loopfilter *lf = &cm->lf;
if (xd->lossless) {
lf->filter_level = 0;
} else {
......@@ -2780,6 +2781,8 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
}
if (lf->filter_level > 0) {
vp9_build_mask_frame(cm, lf->filter_level, 0);
if (cpi->num_workers > 1)
vp9_loop_filter_frame_mt(cm->frame_to_show, cm, xd->plane,
lf->filter_level, 0, 0,
......
......@@ -40,6 +40,8 @@ static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd,
VP9_COMMON *const cm = &cpi->common;
int64_t filt_err;
vp9_build_mask_frame(cm, filt_level, partial_frame);
if (cpi->num_workers > 1)
vp9_loop_filter_frame_mt(cm->frame_to_show, cm, cpi->td.mb.e_mbd.plane,
filt_level, 1, partial_frame,
......
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