Moving loopfilter call to vp9_decode_frame().

Inline loopfilter has been already handled in vp9_decode_frame().
Collecting all similar code in one place now.

Change-Id: I358a0280fc7c2b27cca520bc1e8c16c4eb6491dd
This commit is contained in:
Dmitry Kovalev 2014-05-12 16:19:19 -07:00
parent dbf61d2f01
commit ae7d3ef39f
9 changed files with 36 additions and 30 deletions

View File

@ -1224,7 +1224,8 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
}
}
void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd,
void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
VP9_COMMON *cm, MACROBLOCKD *xd,
int frame_filter_level,
int y_only, int partial_frame) {
int start_mi_row, end_mi_row, mi_rows_to_filter;
@ -1238,7 +1239,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd,
}
end_mi_row = start_mi_row + mi_rows_to_filter;
vp9_loop_filter_frame_init(cm, frame_filter_level);
vp9_loop_filter_rows(cm->frame_to_show, cm, xd,
vp9_loop_filter_rows(frame, cm, xd,
start_mi_row, end_mi_row,
y_only);
}

View File

@ -104,7 +104,8 @@ void vp9_loop_filter_init(struct VP9Common *cm);
// calls this function directly.
void vp9_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl);
void vp9_loop_filter_frame(struct VP9Common *cm,
void vp9_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
struct VP9Common *cm,
struct macroblockd *mbd,
int filter_level,
int y_only, int partial_frame);

View File

@ -676,13 +676,13 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
}
static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
vp9_reader *r) {
int do_loopfilter_inline, vp9_reader *r) {
const int num_threads = pbi->max_threads;
VP9_COMMON *const cm = &pbi->common;
int mi_row, mi_col;
MACROBLOCKD *xd = &pbi->mb;
if (pbi->do_loopfilter_inline) {
if (do_loopfilter_inline) {
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
lf_data->frame_buffer = get_frame_new_buffer(cm);
lf_data->cm = cm;
@ -702,7 +702,7 @@ static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
decode_partition(cm, xd, tile, mi_row, mi_col, r, BLOCK_64X64);
}
if (pbi->do_loopfilter_inline) {
if (do_loopfilter_inline) {
const int lf_start = mi_row - MI_BLOCK_SIZE;
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
@ -723,7 +723,7 @@ static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
}
}
if (pbi->do_loopfilter_inline) {
if (do_loopfilter_inline) {
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
vp9_worker_sync(&pbi->lf_worker);
@ -790,7 +790,8 @@ typedef struct TileBuffer {
static const uint8_t *decode_tiles(VP9Decoder *pbi,
const uint8_t *data,
const uint8_t *data_end) {
const uint8_t *data_end,
int do_loopfilter_inline) {
VP9_COMMON *const cm = &pbi->common;
const int aligned_cols = mi_cols_aligned_to_sb(cm->mi_cols);
const int tile_cols = 1 << cm->log2_tile_cols;
@ -837,7 +838,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
vp9_tile_init(&tile, cm, tile_row, col);
setup_token_decoder(buf->data, data_end, buf->size, &cm->error, &r,
pbi->decrypt_cb, pbi->decrypt_state);
decode_tile(pbi, &tile, &r);
decode_tile(pbi, &tile, do_loopfilter_inline, &r);
if (last_tile)
end = vp9_reader_find_end(&r);
@ -1305,6 +1306,8 @@ int vp9_decode_frame(VP9Decoder *pbi,
const int tile_rows = 1 << cm->log2_tile_rows;
const int tile_cols = 1 << cm->log2_tile_cols;
YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm);
const int do_loopfilter_inline = tile_rows == 1 && tile_cols == 1 &&
cm->lf.filter_level;
xd->cur_buf = new_fb;
if (!first_partition_size) {
@ -1321,9 +1324,7 @@ int vp9_decode_frame(VP9Decoder *pbi,
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt header length");
pbi->do_loopfilter_inline =
(cm->log2_tile_rows | cm->log2_tile_cols) == 0 && cm->lf.filter_level;
if (pbi->do_loopfilter_inline && pbi->lf_worker.data1 == NULL) {
if (do_loopfilter_inline && pbi->lf_worker.data1 == NULL) {
CHECK_MEM_ERROR(cm, pbi->lf_worker.data1,
vpx_memalign(32, sizeof(LFWorkerData)));
pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker;
@ -1356,7 +1357,8 @@ int vp9_decode_frame(VP9Decoder *pbi,
cm->frame_parallel_decoding_mode) {
*p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end);
} else {
*p_data_end = decode_tiles(pbi, data + first_partition_size, data_end);
*p_data_end = decode_tiles(pbi, data + first_partition_size, data_end,
do_loopfilter_inline);
}
new_fb->corrupted |= xd->corrupted;
@ -1385,5 +1387,16 @@ int vp9_decode_frame(VP9Decoder *pbi,
if (cm->refresh_frame_context)
cm->frame_contexts[cm->frame_context_idx] = cm->fc;
// Loopfilter
if (!do_loopfilter_inline) {
// If multiple threads are used to decode tiles, then we use those threads
// to do parallel loopfiltering.
if (pbi->num_tile_workers) {
vp9_loop_filter_frame_mt(new_fb, pbi, cm, cm->lf.filter_level, 0, 0);
} else {
vp9_loop_filter_frame(new_fb, cm, &pbi->mb, cm->lf.filter_level, 0, 0);
}
}
return 0;
}

View File

@ -279,16 +279,6 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
swap_frame_buffers(pbi);
if (!pbi->do_loopfilter_inline) {
// If multiple threads are used to decode tiles, then we use those threads
// to do parallel loopfiltering.
if (pbi->num_tile_workers) {
vp9_loop_filter_frame_mt(pbi, cm, cm->lf.filter_level, 0, 0);
} else {
vp9_loop_filter_frame(cm, &pbi->mb, cm->lf.filter_level, 0, 0);
}
}
vp9_clear_system_state();
cm->last_width = cm->width;

View File

@ -39,7 +39,6 @@ typedef struct VP9Decoder {
int decoded_key_frame;
int do_loopfilter_inline; // apply loopfilter to available rows immediately
VP9Worker lf_worker;
VP9Worker *tile_workers;

View File

@ -132,8 +132,8 @@ static int loop_filter_row_worker(void *arg1, void *arg2) {
// VP9 decoder: Implement multi-threaded loopfilter that uses the tile
// threads.
void vp9_loop_filter_frame_mt(VP9Decoder *pbi,
VP9_COMMON *cm,
void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame,
VP9Decoder *pbi, VP9_COMMON *cm,
int frame_filter_level,
int y_only, int partial_frame) {
VP9LfSync *const lf_sync = &pbi->lf_row_sync;
@ -184,7 +184,7 @@ void vp9_loop_filter_frame_mt(VP9Decoder *pbi,
worker->hook = (VP9WorkerHook)loop_filter_row_worker;
// Loopfilter data
lf_data->frame_buffer = get_frame_new_buffer(cm);
lf_data->frame_buffer = frame;
lf_data->cm = cm;
lf_data->xd = pbi->mb;
lf_data->start = i;

View File

@ -48,7 +48,8 @@ void vp9_loop_filter_alloc(struct VP9Common *cm, VP9LfSync *lf_sync,
void vp9_loop_filter_dealloc(VP9LfSync *lf_sync, int rows);
// Multi-threaded loopfilter that uses the tile threads.
void vp9_loop_filter_frame_mt(struct VP9Decoder *pbi,
void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame,
struct VP9Decoder *pbi,
struct VP9Common *cm,
int frame_filter_level,
int y_only, int partial_frame);

View File

@ -1617,7 +1617,7 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
}
if (lf->filter_level > 0) {
vp9_loop_filter_frame(cm, xd, lf->filter_level, 0, 0);
vp9_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
}
vp9_extend_frame_inner_borders(cm->frame_to_show);

View File

@ -38,7 +38,8 @@ static int try_filter_frame(const YV12_BUFFER_CONFIG *sd, VP9_COMP *const cpi,
VP9_COMMON *const cm = &cpi->common;
int filt_err;
vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_level, 1, partial_frame);
vp9_loop_filter_frame(cm->frame_to_show, cm, &cpi->mb.e_mbd, filt_level, 1,
partial_frame);
filt_err = vp9_get_y_sse(sd, cm->frame_to_show);
// Re-instate the unfiltered frame