diff options
Diffstat (limited to 'vp9/encoder/vp9_encodeframe.c')
-rw-r--r-- | vp9/encoder/vp9_encodeframe.c | 106 |
1 files changed, 70 insertions, 36 deletions
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 20c4e42e7..b845bc4f1 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -857,16 +857,9 @@ static void save_context(VP9_COMP *cpi, int mi_row, int mi_col, static void encode_b(VP9_COMP *cpi, const TileInfo *const tile, TOKENEXTRA **tp, int mi_row, int mi_col, - int output_enabled, BLOCK_SIZE bsize, int sub_index) { - VP9_COMMON *const cm = &cpi->common; + int output_enabled, BLOCK_SIZE bsize) { MACROBLOCK *const x = &cpi->mb; - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; - - if (sub_index != -1) - *get_sb_index(x, bsize) = sub_index; - if (bsize < BLOCK_8X8) { // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 // there is nothing to be done. @@ -890,64 +883,73 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile, int output_enabled, BLOCK_SIZE bsize) { VP9_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &cpi->mb; - BLOCK_SIZE c1 = BLOCK_8X8; - const int bsl = b_width_log2(bsize), bs = (1 << bsl) / 4; - int pl = 0; + const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; + int ctx; PARTITION_TYPE partition; BLOCK_SIZE subsize; - int i; if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - c1 = BLOCK_4X4; if (bsize >= BLOCK_8X8) { - pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, + ctx = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, mi_row, mi_col, bsize); - c1 = *(get_sb_partitioning(x, bsize)); + subsize = *get_sb_partitioning(x, bsize); + } else { + ctx = 0; + subsize = BLOCK_4X4; } - partition = partition_lookup[bsl][c1]; + + partition = partition_lookup[bsl][subsize]; switch (partition) { case PARTITION_NONE: if (output_enabled && bsize >= BLOCK_8X8) - cm->counts.partition[pl][PARTITION_NONE]++; - encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, c1, -1); + cm->counts.partition[ctx][PARTITION_NONE]++; + encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize); break; case PARTITION_VERT: if (output_enabled) - cm->counts.partition[pl][PARTITION_VERT]++; - encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, c1, 0); - encode_b(cpi, tile, tp, mi_row, mi_col + bs, output_enabled, c1, 1); + cm->counts.partition[ctx][PARTITION_VERT]++; + *get_sb_index(x, subsize) = 0; + encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize); + if (mi_col + hbs < cm->mi_cols) { + *get_sb_index(x, subsize) = 1; + encode_b(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, subsize); + } break; case PARTITION_HORZ: if (output_enabled) - cm->counts.partition[pl][PARTITION_HORZ]++; - encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, c1, 0); - encode_b(cpi, tile, tp, mi_row + bs, mi_col, output_enabled, c1, 1); + cm->counts.partition[ctx][PARTITION_HORZ]++; + *get_sb_index(x, subsize) = 0; + encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize); + if (mi_row + hbs < cm->mi_rows) { + *get_sb_index(x, subsize) = 1; + encode_b(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, subsize); + } break; case PARTITION_SPLIT: subsize = get_subsize(bsize, PARTITION_SPLIT); - if (output_enabled) - cm->counts.partition[pl][PARTITION_SPLIT]++; + cm->counts.partition[ctx][PARTITION_SPLIT]++; - for (i = 0; i < 4; i++) { - const int x_idx = i & 1, y_idx = i >> 1; - - *get_sb_index(x, subsize) = i; - encode_sb(cpi, tile, tp, mi_row + y_idx * bs, mi_col + x_idx * bs, - output_enabled, subsize); - } + *get_sb_index(x, subsize) = 0; + encode_sb(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize); + *get_sb_index(x, subsize) = 1; + encode_sb(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, subsize); + *get_sb_index(x, subsize) = 2; + encode_sb(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, subsize); + *get_sb_index(x, subsize) = 3; + encode_sb(cpi, tile, tp, mi_row + hbs, mi_col + hbs, output_enabled, + subsize); break; default: - assert(0); - break; + assert("Invalid partition type."); } if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) update_partition_context(cpi->above_seg_context, cpi->left_seg_context, - mi_row, mi_col, c1, bsize); + mi_row, mi_col, subsize, bsize); } // Check to see if the given partition size is allowed for a specified number @@ -1686,6 +1688,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, *get_sb_index(x, subsize) = i; if (cpi->sf.adaptive_motion_search) load_pred_mv(x, get_block_context(x, bsize)); + if (cpi->sf.adaptive_pred_filter_type && bsize == BLOCK_8X8 && + partition_none_allowed) + get_block_context(x, subsize)->pred_filter_type = + get_block_context(x, bsize)->mic.mbmi.interp_filter; rd_pick_partition(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, subsize, &this_rate, &this_dist, i != 3, best_rd - sum_rd); @@ -1733,6 +1739,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, *get_sb_index(x, subsize) = 0; if (cpi->sf.adaptive_motion_search) load_pred_mv(x, get_block_context(x, bsize)); + if (cpi->sf.adaptive_pred_filter_type && bsize == BLOCK_8X8 && + partition_none_allowed) + get_block_context(x, subsize)->pred_filter_type = + get_block_context(x, bsize)->mic.mbmi.interp_filter; pick_sb_modes(cpi, tile, mi_row, mi_col, &sum_rate, &sum_dist, subsize, get_block_context(x, subsize), best_rd); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); @@ -1744,6 +1754,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, *get_sb_index(x, subsize) = 1; if (cpi->sf.adaptive_motion_search) load_pred_mv(x, get_block_context(x, bsize)); + if (cpi->sf.adaptive_pred_filter_type && bsize == BLOCK_8X8 && + partition_none_allowed) + get_block_context(x, subsize)->pred_filter_type = + get_block_context(x, bsize)->mic.mbmi.interp_filter; pick_sb_modes(cpi, tile, mi_row + ms, mi_col, &this_rate, &this_dist, subsize, get_block_context(x, subsize), best_rd - sum_rd); @@ -1778,6 +1792,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, *get_sb_index(x, subsize) = 0; if (cpi->sf.adaptive_motion_search) load_pred_mv(x, get_block_context(x, bsize)); + if (cpi->sf.adaptive_pred_filter_type && bsize == BLOCK_8X8 && + partition_none_allowed) + get_block_context(x, subsize)->pred_filter_type = + get_block_context(x, bsize)->mic.mbmi.interp_filter; pick_sb_modes(cpi, tile, mi_row, mi_col, &sum_rate, &sum_dist, subsize, get_block_context(x, subsize), best_rd); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); @@ -1788,6 +1806,10 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, *get_sb_index(x, subsize) = 1; if (cpi->sf.adaptive_motion_search) load_pred_mv(x, get_block_context(x, bsize)); + if (cpi->sf.adaptive_pred_filter_type && bsize == BLOCK_8X8 && + partition_none_allowed) + get_block_context(x, subsize)->pred_filter_type = + get_block_context(x, bsize)->mic.mbmi.interp_filter; pick_sb_modes(cpi, tile, mi_row, mi_col + ms, &this_rate, &this_dist, subsize, get_block_context(x, subsize), best_rd - sum_rd); @@ -1889,6 +1911,18 @@ static void encode_sb_row(VP9_COMP *cpi, const TileInfo *const tile, int dummy_rate; int64_t dummy_dist; + BLOCK_SIZE i; + MACROBLOCK *x = &cpi->mb; + for (i = BLOCK_4X4; i < BLOCK_8X8; ++i) { + const int num_4x4_w = num_4x4_blocks_wide_lookup[i]; + const int num_4x4_h = num_4x4_blocks_high_lookup[i]; + const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h); + for (x->sb_index = 0; x->sb_index < 4; ++x->sb_index) + for (x->mb_index = 0; x->mb_index < 4; ++x->mb_index) + for (x->b_index = 0; x->b_index < 16 / num_4x4_blk; ++x->b_index) + get_block_context(x, i)->pred_filter_type = SWITCHABLE; + } + vp9_zero(cpi->mb.pred_mv); if (cpi->sf.reference_masking) |