Commit 79ba4190 authored by Dmitry Kovalev's avatar Dmitry Kovalev

Removing MACROBLOCKD dependency from loop filter.

Change-Id: I9ef40f3d95ab8f94f69e92ea25678a40956bc1ce
parent b334bfc3
...@@ -1192,11 +1192,12 @@ void vp9_filter_block_plane(VP9_COMMON *const cm, ...@@ -1192,11 +1192,12 @@ void vp9_filter_block_plane(VP9_COMMON *const cm,
} }
void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
VP9_COMMON *cm, MACROBLOCKD *xd, VP9_COMMON *cm,
struct macroblockd_plane planes[MAX_MB_PLANE],
int start, int stop, int y_only) { int start, int stop, int y_only) {
const int num_planes = y_only ? 1 : MAX_MB_PLANE; const int num_planes = y_only ? 1 : MAX_MB_PLANE;
const int use_420 = y_only || (xd->plane[1].subsampling_y == 1 && const int use_420 = y_only || (planes[1].subsampling_y == 1 &&
xd->plane[1].subsampling_x == 1); planes[1].subsampling_x == 1);
LOOP_FILTER_MASK lfm; LOOP_FILTER_MASK lfm;
int mi_row, mi_col; int mi_row, mi_col;
...@@ -1206,7 +1207,7 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, ...@@ -1206,7 +1207,7 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
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) {
int plane; int plane;
vp9_setup_dst_planes(xd, frame_buffer, mi_row, mi_col); vp9_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
// TODO(JBB): Make setup_mask work for non 420. // TODO(JBB): Make setup_mask work for non 420.
if (use_420) if (use_420)
...@@ -1215,9 +1216,9 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, ...@@ -1215,9 +1216,9 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
for (plane = 0; plane < num_planes; ++plane) { for (plane = 0; plane < num_planes; ++plane) {
if (use_420) if (use_420)
vp9_filter_block_plane(cm, &xd->plane[plane], mi_row, &lfm); vp9_filter_block_plane(cm, &planes[plane], mi_row, &lfm);
else else
filter_block_plane_non420(cm, &xd->plane[plane], mi + mi_col, filter_block_plane_non420(cm, &planes[plane], mi + mi_col,
mi_row, mi_col); mi_row, mi_col);
} }
} }
...@@ -1239,7 +1240,7 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame, ...@@ -1239,7 +1240,7 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
} }
end_mi_row = start_mi_row + mi_rows_to_filter; end_mi_row = start_mi_row + mi_rows_to_filter;
vp9_loop_filter_frame_init(cm, frame_filter_level); vp9_loop_filter_frame_init(cm, frame_filter_level);
vp9_loop_filter_rows(frame, cm, xd, vp9_loop_filter_rows(frame, cm, xd->plane,
start_mi_row, end_mi_row, start_mi_row, end_mi_row,
y_only); y_only);
} }
...@@ -1247,7 +1248,7 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame, ...@@ -1247,7 +1248,7 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
int vp9_loop_filter_worker(void *arg1, void *arg2) { int vp9_loop_filter_worker(void *arg1, void *arg2) {
LFWorkerData *const lf_data = (LFWorkerData*)arg1; LFWorkerData *const lf_data = (LFWorkerData*)arg1;
(void)arg2; (void)arg2;
vp9_loop_filter_rows(lf_data->frame_buffer, lf_data->cm, &lf_data->xd, vp9_loop_filter_rows(lf_data->frame_buffer, lf_data->cm, lf_data->planes,
lf_data->start, lf_data->stop, lf_data->y_only); lf_data->start, lf_data->stop, lf_data->y_only);
return 1; return 1;
} }
...@@ -112,15 +112,15 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame, ...@@ -112,15 +112,15 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
// Apply the loop filter to [start, stop) macro block rows in frame_buffer. // Apply the loop filter to [start, stop) macro block rows in frame_buffer.
void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
struct VP9Common *cm, struct macroblockd *xd, struct VP9Common *cm,
struct macroblockd_plane planes[MAX_MB_PLANE],
int start, int stop, int y_only); int start, int stop, int y_only);
typedef struct LoopFilterWorkerData { typedef struct LoopFilterWorkerData {
const YV12_BUFFER_CONFIG *frame_buffer; const YV12_BUFFER_CONFIG *frame_buffer;
struct VP9Common *cm; struct VP9Common *cm;
struct macroblockd xd; // TODO(jzern): most of this is unnecessary to the struct macroblockd_plane planes[MAX_MB_PLANE];
// loopfilter. the planes are necessary as their state
// is changed during decode.
int start; int start;
int stop; int stop;
int y_only; int y_only;
......
...@@ -409,7 +409,7 @@ void vp9_dec_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col, ...@@ -409,7 +409,7 @@ void vp9_dec_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
} }
} }
void vp9_setup_dst_planes(MACROBLOCKD *xd, void vp9_setup_dst_planes(struct macroblockd_plane planes[MAX_MB_PLANE],
const YV12_BUFFER_CONFIG *src, const YV12_BUFFER_CONFIG *src,
int mi_row, int mi_col) { int mi_row, int mi_col) {
uint8_t *const buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer, uint8_t *const buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
...@@ -419,7 +419,7 @@ void vp9_setup_dst_planes(MACROBLOCKD *xd, ...@@ -419,7 +419,7 @@ void vp9_setup_dst_planes(MACROBLOCKD *xd,
int i; int i;
for (i = 0; i < MAX_MB_PLANE; ++i) { for (i = 0; i < MAX_MB_PLANE; ++i) {
struct macroblockd_plane *const pd = &xd->plane[i]; struct macroblockd_plane *const pd = &planes[i];
setup_pred_plane(&pd->dst, buffers[i], strides[i], mi_row, mi_col, NULL, setup_pred_plane(&pd->dst, buffers[i], strides[i], mi_row, mi_col, NULL,
pd->subsampling_x, pd->subsampling_y); pd->subsampling_x, pd->subsampling_y);
} }
......
...@@ -57,7 +57,8 @@ static INLINE void setup_pred_plane(struct buf_2d *dst, ...@@ -57,7 +57,8 @@ static INLINE void setup_pred_plane(struct buf_2d *dst,
dst->stride = stride; dst->stride = stride;
} }
void vp9_setup_dst_planes(MACROBLOCKD *xd, const YV12_BUFFER_CONFIG *src, void vp9_setup_dst_planes(struct macroblockd_plane planes[MAX_MB_PLANE],
const YV12_BUFFER_CONFIG *src,
int mi_row, int mi_col); int mi_row, int mi_col);
void vp9_setup_pre_planes(MACROBLOCKD *xd, int idx, void vp9_setup_pre_planes(MACROBLOCKD *xd, int idx,
......
...@@ -316,7 +316,7 @@ static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -316,7 +316,7 @@ static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
// as they are always compared to values that are in 1/8th pel units // as they are always compared to values that are in 1/8th pel units
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
vp9_setup_dst_planes(xd, get_frame_new_buffer(cm), mi_row, mi_col); vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
return &xd->mi[0]->mbmi; return &xd->mi[0]->mbmi;
} }
...@@ -686,7 +686,7 @@ static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile, ...@@ -686,7 +686,7 @@ static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
lf_data->frame_buffer = get_frame_new_buffer(cm); lf_data->frame_buffer = get_frame_new_buffer(cm);
lf_data->cm = cm; lf_data->cm = cm;
lf_data->xd = pbi->mb; vp9_copy(lf_data->planes, pbi->mb.plane);
lf_data->stop = 0; lf_data->stop = 0;
lf_data->y_only = 0; lf_data->y_only = 0;
vp9_loop_filter_frame_init(cm, cm->lf.filter_level); vp9_loop_filter_frame_init(cm, cm->lf.filter_level);
......
...@@ -89,7 +89,8 @@ static INLINE void sync_write(VP9LfSync *const lf_sync, int r, int c, ...@@ -89,7 +89,8 @@ static INLINE void sync_write(VP9LfSync *const lf_sync, int r, int c,
// Implement row loopfiltering for each thread. // Implement row loopfiltering for each thread.
static void loop_filter_rows_mt(const YV12_BUFFER_CONFIG *const frame_buffer, static void loop_filter_rows_mt(const YV12_BUFFER_CONFIG *const frame_buffer,
VP9_COMMON *const cm, MACROBLOCKD *const xd, VP9_COMMON *const cm,
struct macroblockd_plane planes[MAX_MB_PLANE],
int start, int stop, int y_only, int start, int stop, int y_only,
VP9LfSync *const lf_sync, int num_lf_workers) { VP9LfSync *const lf_sync, int num_lf_workers) {
const int num_planes = y_only ? 1 : MAX_MB_PLANE; const int num_planes = y_only ? 1 : MAX_MB_PLANE;
...@@ -107,11 +108,11 @@ static void loop_filter_rows_mt(const YV12_BUFFER_CONFIG *const frame_buffer, ...@@ -107,11 +108,11 @@ static void loop_filter_rows_mt(const YV12_BUFFER_CONFIG *const frame_buffer,
sync_read(lf_sync, r, c); sync_read(lf_sync, r, c);
vp9_setup_dst_planes(xd, frame_buffer, mi_row, mi_col); vp9_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
vp9_setup_mask(cm, mi_row, mi_col, mi + mi_col, cm->mi_stride, &lfm); vp9_setup_mask(cm, mi_row, mi_col, mi + mi_col, cm->mi_stride, &lfm);
for (plane = 0; plane < num_planes; ++plane) { for (plane = 0; plane < num_planes; ++plane) {
vp9_filter_block_plane(cm, &xd->plane[plane], mi_row, &lfm); vp9_filter_block_plane(cm, &planes[plane], mi_row, &lfm);
} }
sync_write(lf_sync, r, c, sb_cols); sync_write(lf_sync, r, c, sb_cols);
...@@ -124,7 +125,7 @@ static int loop_filter_row_worker(void *arg1, void *arg2) { ...@@ -124,7 +125,7 @@ static int loop_filter_row_worker(void *arg1, void *arg2) {
TileWorkerData *const tile_data = (TileWorkerData*)arg1; TileWorkerData *const tile_data = (TileWorkerData*)arg1;
LFWorkerData *const lf_data = &tile_data->lfdata; LFWorkerData *const lf_data = &tile_data->lfdata;
loop_filter_rows_mt(lf_data->frame_buffer, lf_data->cm, &lf_data->xd, loop_filter_rows_mt(lf_data->frame_buffer, lf_data->cm, lf_data->planes,
lf_data->start, lf_data->stop, lf_data->y_only, lf_data->start, lf_data->stop, lf_data->y_only,
lf_data->lf_sync, lf_data->num_lf_workers); lf_data->lf_sync, lf_data->num_lf_workers);
return 1; return 1;
...@@ -186,7 +187,7 @@ void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, ...@@ -186,7 +187,7 @@ void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame,
// Loopfilter data // Loopfilter data
lf_data->frame_buffer = frame; lf_data->frame_buffer = frame;
lf_data->cm = cm; lf_data->cm = cm;
lf_data->xd = pbi->mb; vp9_copy(lf_data->planes, pbi->mb.plane);
lf_data->start = i; lf_data->start = i;
lf_data->stop = sb_rows; lf_data->stop = sb_rows;
lf_data->y_only = y_only; // always do all planes in decoder lf_data->y_only = y_only; // always do all planes in decoder
......
...@@ -201,7 +201,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -201,7 +201,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile,
mbmi = &xd->mi[0]->mbmi; mbmi = &xd->mi[0]->mbmi;
// Set up destination pointers. // Set up destination pointers.
vp9_setup_dst_planes(xd, get_frame_new_buffer(cm), mi_row, mi_col); vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
// Set up limit values for MV components. // Set up limit values for MV components.
// Mv beyond the range do not produce new/different prediction block. // Mv beyond the range do not produce new/different prediction block.
......
...@@ -541,7 +541,7 @@ void vp9_first_pass(VP9_COMP *cpi) { ...@@ -541,7 +541,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
vp9_setup_src_planes(x, cpi->Source, 0, 0); vp9_setup_src_planes(x, cpi->Source, 0, 0);
vp9_setup_pre_planes(xd, 0, first_ref_buf, 0, 0, NULL); vp9_setup_pre_planes(xd, 0, first_ref_buf, 0, 0, NULL);
vp9_setup_dst_planes(xd, new_yv12, 0, 0); vp9_setup_dst_planes(xd->plane, new_yv12, 0, 0);
xd->mi = cm->mi_grid_visible; xd->mi = cm->mi_grid_visible;
xd->mi[0] = cm->mi; xd->mi[0] = cm->mi;
......
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