[WIP] Add column-based tiling.

This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.

There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log

Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.

The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.

Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.

TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
  should not cross tile edges, or we should emulate such borders as
  if they were off-frame, to limit error propagation to within one
  tile only. This doesn't have to be the default behaviour but could
  be an optional bitstream flag.

Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
This commit is contained in:
Ronald S. Bultje
2013-02-01 09:35:28 -08:00
parent 822864131b
commit 1407bdc243
31 changed files with 652 additions and 224 deletions

View File

@@ -254,7 +254,7 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
int t_pred_cost = INT_MAX;
int i;
int mb_row, mb_col;
int tile, mb_row, mb_col, mb_start = 0;
int temporal_predictor_count[PREDICTION_PROBS][2];
int no_pred_segcounts[MAX_MB_SEGMENTS];
@@ -266,7 +266,7 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
vp9_prob t_nopred_prob[PREDICTION_PROBS];
const int mis = cm->mode_info_stride;
MODE_INFO *mi_ptr = cm->mi, *mi;
MODE_INFO *mi_ptr, *mi;
// Set default state for the segment tree probabilities and the
// temporal coding probabilities
@@ -282,9 +282,21 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
// First of all generate stats regarding how well the last segment map
// predicts this one
for (tile = 0; tile < cm->tile_columns; tile++) {
// calculate end of tile column
const int sb_cols = (cm->mb_cols + 3) >> 2;
const int sb_end = (sb_cols * (tile + 1)) >> cpi->oxcf.tile_columns;
const int mb_end = ((sb_end << 2) > cm->mb_cols) ?
cm->mb_cols : (sb_end << 2);
cm->cur_tile_idx = tile;
cm->cur_tile_mb_col_start = mb_start;
cm->cur_tile_mb_col_end = mb_end;
mi_ptr = cm->mi + mb_start;
for (mb_row = 0; mb_row < cm->mb_rows; mb_row += 4, mi_ptr += 4 * mis) {
mi = mi_ptr;
for (mb_col = 0; mb_col < cm->mb_cols; mb_col += 4, mi += 4) {
for (mb_col = mb_start; mb_col < mb_end; mb_col += 4, mi += 4) {
if (mi->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
count_segs(cpi, mi, no_pred_segcounts, temporal_predictor_count,
t_unpred_seg_counts, 4, mb_row, mb_col);
@@ -325,6 +337,9 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
}
}
mb_start = mb_end;
}
// Work out probability tree for coding segments without prediction
// and the cost.
calc_segtree_probs(xd, no_pred_segcounts, no_pred_tree);