From 79ba41903ff8c5328a5b592e0da487eca2fd6d31 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Fri, 16 May 2014 09:48:26 -0700 Subject: [PATCH] Removing MACROBLOCKD dependency from loop filter. Change-Id: I9ef40f3d95ab8f94f69e92ea25678a40956bc1ce --- vp9/common/vp9_loopfilter.c | 17 +++++++++-------- vp9/common/vp9_loopfilter.h | 8 ++++---- vp9/common/vp9_reconinter.c | 4 ++-- vp9/common/vp9_reconinter.h | 3 ++- vp9/decoder/vp9_decodeframe.c | 4 ++-- vp9/decoder/vp9_dthread.c | 11 ++++++----- vp9/encoder/vp9_encodeframe.c | 2 +- vp9/encoder/vp9_firstpass.c | 2 +- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c index 201d2ea..efd0249 100644 --- a/vp9/common/vp9_loopfilter.c +++ b/vp9/common/vp9_loopfilter.c @@ -1192,11 +1192,12 @@ void vp9_filter_block_plane(VP9_COMMON *const cm, } 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) { const int num_planes = y_only ? 1 : MAX_MB_PLANE; - const int use_420 = y_only || (xd->plane[1].subsampling_y == 1 && - xd->plane[1].subsampling_x == 1); + const int use_420 = y_only || (planes[1].subsampling_y == 1 && + planes[1].subsampling_x == 1); LOOP_FILTER_MASK lfm; int mi_row, mi_col; @@ -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) { 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. if (use_420) @@ -1215,9 +1216,9 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, for (plane = 0; plane < num_planes; ++plane) { 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 - 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); } } @@ -1239,7 +1240,7 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame, } end_mi_row = start_mi_row + mi_rows_to_filter; 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, y_only); } @@ -1247,7 +1248,7 @@ void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame, int vp9_loop_filter_worker(void *arg1, void *arg2) { LFWorkerData *const lf_data = (LFWorkerData*)arg1; (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); return 1; } diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h index 83463c5..6fa2773 100644 --- a/vp9/common/vp9_loopfilter.h +++ b/vp9/common/vp9_loopfilter.h @@ -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. 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); typedef struct LoopFilterWorkerData { const YV12_BUFFER_CONFIG *frame_buffer; struct VP9Common *cm; - struct macroblockd xd; // TODO(jzern): most of this is unnecessary to the - // loopfilter. the planes are necessary as their state - // is changed during decode. + struct macroblockd_plane planes[MAX_MB_PLANE]; + int start; int stop; int y_only; diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c index e722d6a..edc36d7 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -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, int mi_row, int mi_col) { 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, int 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, pd->subsampling_x, pd->subsampling_y); } diff --git a/vp9/common/vp9_reconinter.h b/vp9/common/vp9_reconinter.h index 86f3158..58c596e 100644 --- a/vp9/common/vp9_reconinter.h +++ b/vp9/common/vp9_reconinter.h @@ -57,7 +57,8 @@ static INLINE void setup_pred_plane(struct buf_2d *dst, 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); void vp9_setup_pre_planes(MACROBLOCKD *xd, int idx, diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 099e685..3124158 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -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 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; } @@ -686,7 +686,7 @@ static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile, LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; lf_data->frame_buffer = get_frame_new_buffer(cm); lf_data->cm = cm; - lf_data->xd = pbi->mb; + vp9_copy(lf_data->planes, pbi->mb.plane); lf_data->stop = 0; lf_data->y_only = 0; vp9_loop_filter_frame_init(cm, cm->lf.filter_level); diff --git a/vp9/decoder/vp9_dthread.c b/vp9/decoder/vp9_dthread.c index 504fb9e..bc6c418 100644 --- a/vp9/decoder/vp9_dthread.c +++ b/vp9/decoder/vp9_dthread.c @@ -89,7 +89,8 @@ static INLINE void sync_write(VP9LfSync *const lf_sync, int r, int c, // Implement row loopfiltering for each thread. 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, VP9LfSync *const lf_sync, int num_lf_workers) { 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, 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); 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); @@ -124,7 +125,7 @@ static int loop_filter_row_worker(void *arg1, void *arg2) { TileWorkerData *const tile_data = (TileWorkerData*)arg1; 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->lf_sync, lf_data->num_lf_workers); return 1; @@ -186,7 +187,7 @@ void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, // Loopfilter data lf_data->frame_buffer = frame; lf_data->cm = cm; - lf_data->xd = pbi->mb; + vp9_copy(lf_data->planes, pbi->mb.plane); lf_data->start = i; lf_data->stop = sb_rows; lf_data->y_only = y_only; // always do all planes in decoder diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index e33261a..86e5986 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -201,7 +201,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, mbmi = &xd->mi[0]->mbmi; // 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. // Mv beyond the range do not produce new/different prediction block. diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index d2cc3c5..ed72d78 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -541,7 +541,7 @@ void vp9_first_pass(VP9_COMP *cpi) { vp9_setup_src_planes(x, cpi->Source, 0, 0); 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[0] = cm->mi; -- 2.7.4