Merge "Cleaning up encode_sb() and encode_b() functions."

This commit is contained in:
Dmitry Kovalev 2013-12-16 12:21:38 -08:00 коммит произвёл Gerrit Code Review
Родитель f00d4e0198 b8dc52f4a3
Коммит 1a23a34419
1 изменённых файлов: 38 добавлений и 36 удалений

Просмотреть файл

@ -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