Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: source/libvpx/vp9/decoder/vp9_decodeframe.c

Issue 1169543007: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c ('k') | source/libvpx/vp9/decoder/vp9_decodemv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/decoder/vp9_decodeframe.c
diff --git a/source/libvpx/vp9/decoder/vp9_decodeframe.c b/source/libvpx/vp9/decoder/vp9_decodeframe.c
index 0e9b1c523b92815d8c7d6fa0c483bab71846ffa2..30ca2d08a7ee4286332527c8d9b75d7e02f66b43 100644
--- a/source/libvpx/vp9/decoder/vp9_decodeframe.c
+++ b/source/libvpx/vp9/decoder/vp9_decodeframe.c
@@ -290,9 +290,7 @@ static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block,
}
struct intra_args {
- VP9_COMMON *cm;
MACROBLOCKD *xd;
- FRAME_COUNTS *counts;
vp9_reader *r;
int seg_id;
};
@@ -301,7 +299,6 @@ static void predict_and_reconstruct_intra_block(int plane, int block,
BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, void *arg) {
struct intra_args *const args = (struct intra_args *)arg;
- VP9_COMMON *const cm = args->cm;
MACROBLOCKD *const xd = args->xd;
struct macroblockd_plane *const pd = &xd->plane[plane];
MODE_INFO *const mi = xd->mi[0];
@@ -318,7 +315,7 @@ static void predict_and_reconstruct_intra_block(int plane, int block,
x, y, plane);
if (!mi->mbmi.skip) {
- const int eob = vp9_decode_block_tokens(cm, xd, args->counts, plane, block,
+ const int eob = vp9_decode_block_tokens(xd, plane, block,
plane_bsize, x, y, tx_size,
args->r, args->seg_id);
inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride,
@@ -327,10 +324,8 @@ static void predict_and_reconstruct_intra_block(int plane, int block,
}
struct inter_args {
- VP9_COMMON *cm;
MACROBLOCKD *xd;
vp9_reader *r;
- FRAME_COUNTS *counts;
int *eobtotal;
int seg_id;
};
@@ -339,12 +334,11 @@ static void reconstruct_inter_block(int plane, int block,
BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, void *arg) {
struct inter_args *args = (struct inter_args *)arg;
- VP9_COMMON *const cm = args->cm;
MACROBLOCKD *const xd = args->xd;
struct macroblockd_plane *const pd = &xd->plane[plane];
int x, y, eob;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y);
- eob = vp9_decode_block_tokens(cm, xd, args->counts, plane, block, plane_bsize,
+ eob = vp9_decode_block_tokens(xd, plane, block, plane_bsize,
x, y, tx_size, args->r, args->seg_id);
inverse_transform_block(xd, plane, block, tx_size,
&pd->dst.buf[4 * y * pd->dst.stride + 4 * x],
@@ -381,14 +375,22 @@ static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
}
static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
- FRAME_COUNTS *counts,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &pbi->common;
const int less8x8 = bsize < BLOCK_8X8;
MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
- vp9_read_mode_info(pbi, xd, counts, tile, mi_row, mi_col, r);
+
+ if (bsize >= BLOCK_8X8 && (cm->subsampling_x || cm->subsampling_y)) {
+ const BLOCK_SIZE uv_subsize =
+ ss_size_lookup[bsize][cm->subsampling_x][cm->subsampling_y];
+ if (uv_subsize == BLOCK_INVALID)
+ vpx_internal_error(xd->error_info,
+ VPX_CODEC_CORRUPT_FRAME, "Invalid block size.");
+ }
+
+ vp9_read_mode_info(pbi, xd, tile, mi_row, mi_col, r);
if (less8x8)
bsize = BLOCK_8X8;
@@ -398,7 +400,7 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
}
if (!is_inter_block(mbmi)) {
- struct intra_args arg = {cm, xd, counts, r, mbmi->segment_id};
+ struct intra_args arg = {xd, r, mbmi->segment_id};
vp9_foreach_transformed_block(xd, bsize,
predict_and_reconstruct_intra_block, &arg);
} else {
@@ -408,7 +410,7 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
// Reconstruction
if (!mbmi->skip) {
int eobtotal = 0;
- struct inter_args arg = {cm, xd, r, counts, &eobtotal, mbmi->segment_id};
+ struct inter_args arg = {xd, r, &eobtotal, mbmi->segment_id};
vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg);
if (!less8x8 && eobtotal == 0)
mbmi->skip = 1; // skip loopfilter
@@ -419,13 +421,14 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
}
static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd,
- FRAME_COUNTS *counts, int hbs,
+ int hbs,
int mi_row, int mi_col, BLOCK_SIZE bsize,
vp9_reader *r) {
const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
const vp9_prob *const probs = get_partition_probs(cm, ctx);
const int has_rows = (mi_row + hbs) < cm->mi_rows;
const int has_cols = (mi_col + hbs) < cm->mi_cols;
+ FRAME_COUNTS *counts = xd->counts;
PARTITION_TYPE p;
if (has_rows && has_cols)
@@ -437,56 +440,48 @@ static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd,
else
p = PARTITION_SPLIT;
- if (!cm->frame_parallel_decoding_mode)
+ if (counts)
++counts->partition[ctx][p];
return p;
}
static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd,
- FRAME_COUNTS *counts,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &pbi->common;
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
PARTITION_TYPE partition;
- BLOCK_SIZE subsize, uv_subsize;
+ BLOCK_SIZE subsize;
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
- partition = read_partition(cm, xd, counts, hbs, mi_row, mi_col, bsize, r);
+ partition = read_partition(cm, xd, hbs, mi_row, mi_col, bsize, r);
subsize = get_subsize(bsize, partition);
- uv_subsize = ss_size_lookup[subsize][cm->subsampling_x][cm->subsampling_y];
- if (subsize >= BLOCK_8X8 && uv_subsize == BLOCK_INVALID)
- vpx_internal_error(xd->error_info,
- VPX_CODEC_CORRUPT_FRAME, "Invalid block size.");
- if (subsize < BLOCK_8X8) {
- decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize);
+ if (bsize == BLOCK_8X8) {
+ decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize);
} else {
switch (partition) {
case PARTITION_NONE:
- decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize);
+ decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize);
break;
case PARTITION_HORZ:
- decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize);
+ decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize);
if (mi_row + hbs < cm->mi_rows)
- decode_block(pbi, xd, counts, tile, mi_row + hbs, mi_col, r, subsize);
+ decode_block(pbi, xd, tile, mi_row + hbs, mi_col, r, subsize);
break;
case PARTITION_VERT:
- decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize);
+ decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize);
if (mi_col + hbs < cm->mi_cols)
- decode_block(pbi, xd, counts, tile, mi_row, mi_col + hbs, r, subsize);
+ decode_block(pbi, xd, tile, mi_row, mi_col + hbs, r, subsize);
break;
case PARTITION_SPLIT:
- decode_partition(pbi, xd, counts, tile, mi_row, mi_col, r, subsize);
- decode_partition(pbi, xd, counts, tile, mi_row, mi_col + hbs, r,
- subsize);
- decode_partition(pbi, xd, counts, tile, mi_row + hbs, mi_col, r,
- subsize);
- decode_partition(pbi, xd, counts, tile, mi_row + hbs, mi_col + hbs, r,
- subsize);
+ decode_partition(pbi, xd, tile, mi_row, mi_col, r, subsize);
+ decode_partition(pbi, xd, tile, mi_row, mi_col + hbs, r, subsize);
+ decode_partition(pbi, xd, tile, mi_row + hbs, mi_col, r, subsize);
+ decode_partition(pbi, xd, tile, mi_row + hbs, mi_col + hbs, r, subsize);
break;
default:
assert(0 && "Invalid partition type");
@@ -931,7 +926,8 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
int mi_row, mi_col;
TileData *tile_data = NULL;
- if (cm->lf.filter_level && pbi->lf_worker.data1 == NULL) {
+ if (cm->lf.filter_level && !cm->skip_loop_filter &&
+ 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;
@@ -941,7 +937,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
}
}
- if (cm->lf.filter_level) {
+ if (cm->lf.filter_level && !cm->skip_loop_filter) {
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
// Be sure to sync as we might be resuming after a failed frame decode.
winterface->sync(&pbi->lf_worker);
@@ -981,6 +977,8 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
tile_data->cm = cm;
tile_data->xd = pbi->mb;
tile_data->xd.corrupted = 0;
+ tile_data->xd.counts = cm->frame_parallel_decoding_mode ?
+ NULL : &cm->counts;
vp9_tile_init(&tile, tile_data->cm, tile_row, tile_col);
setup_token_decoder(buf->data, data_end, buf->size, &cm->error,
&tile_data->bit_reader, pbi->decrypt_cb,
@@ -1003,7 +1001,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
vp9_zero(tile_data->xd.left_seg_context);
for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end;
mi_col += MI_BLOCK_SIZE) {
- decode_partition(pbi, &tile_data->xd, &cm->counts, &tile, mi_row,
+ decode_partition(pbi, &tile_data->xd, &tile, mi_row,
mi_col, &tile_data->bit_reader, BLOCK_64X64);
}
pbi->mb.corrupted |= tile_data->xd.corrupted;
@@ -1012,7 +1010,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
"Failed to decode tile data");
}
// Loopfilter one row.
- if (cm->lf.filter_level) {
+ if (cm->lf.filter_level && !cm->skip_loop_filter) {
const int lf_start = mi_row - MI_BLOCK_SIZE;
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
@@ -1041,7 +1039,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
}
// Loopfilter remaining rows in the frame.
- if (cm->lf.filter_level) {
+ if (cm->lf.filter_level && !cm->skip_loop_filter) {
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
winterface->sync(&pbi->lf_worker);
lf_data->start = lf_data->stop;
@@ -1076,7 +1074,7 @@ static int tile_worker_hook(TileWorkerData *const tile_data,
vp9_zero(tile_data->xd.left_seg_context);
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE) {
- decode_partition(tile_data->pbi, &tile_data->xd, &tile_data->counts,
+ decode_partition(tile_data->pbi, &tile_data->xd,
tile, mi_row, mi_col, &tile_data->bit_reader,
BLOCK_64X64);
}
@@ -1200,6 +1198,8 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
tile_data->pbi = pbi;
tile_data->xd = pbi->mb;
tile_data->xd.corrupted = 0;
+ tile_data->xd.counts = cm->frame_parallel_decoding_mode ?
+ 0 : &tile_data->counts;
vp9_tile_init(tile, cm, 0, buf->col);
setup_token_decoder(buf->data, data_end, buf->size, &cm->error,
&tile_data->bit_reader, pbi->decrypt_cb,
@@ -1663,7 +1663,7 @@ void vp9_decode_frame(VP9Decoder *pbi,
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Decode failed. Frame data header is corrupted.");
- if (cm->lf.filter_level) {
+ if (cm->lf.filter_level && !cm->skip_loop_filter) {
vp9_loop_filter_frame_init(cm, cm->lf.filter_level);
}
@@ -1689,11 +1689,13 @@ void vp9_decode_frame(VP9Decoder *pbi,
// Multi-threaded tile decoder
*p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end);
if (!xd->corrupted) {
- // If multiple threads are used to decode tiles, then we use those threads
- // to do parallel loopfiltering.
- vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane, cm->lf.filter_level,
- 0, 0, pbi->tile_workers, pbi->num_tile_workers,
- &pbi->lf_row_sync);
+ if (!cm->skip_loop_filter) {
+ // If multiple threads are used to decode tiles, then we use those
+ // threads to do parallel loopfiltering.
+ vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane,
+ cm->lf.filter_level, 0, 0, pbi->tile_workers,
+ pbi->num_tile_workers, &pbi->lf_row_sync);
+ }
} else {
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Decode failed. Frame data is corrupted.");
« no previous file with comments | « source/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c ('k') | source/libvpx/vp9/decoder/vp9_decodemv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698