Commit 335b1d36 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

check_bsize_coverage cleanup.

Change-Id: Ib7803857b35c00e317c9deb8630e777e25eb278f
parent 13eed79c
...@@ -255,25 +255,20 @@ static INLINE void set_partition_seg_context(VP9_COMMON *cm, MACROBLOCKD *xd, ...@@ -255,25 +255,20 @@ static INLINE void set_partition_seg_context(VP9_COMMON *cm, MACROBLOCKD *xd,
xd->left_seg_context = cm->left_seg_context + (mi_row & MI_MASK); xd->left_seg_context = cm->left_seg_context + (mi_row & MI_MASK);
} }
static int check_bsize_coverage(VP9_COMMON *cm, int mi_row, int mi_col, // return the node index in the prob tree for binary coding
BLOCK_SIZE_TYPE bsize) { static int check_bsize_coverage(int bs, int mi_rows, int mi_cols,
int bsl = mi_width_log2(bsize), bs = 1 << bsl; int mi_row, int mi_col) {
int ms = bs / 2; const int r = (mi_row + bs < mi_rows);
const int c = (mi_col + bs < mi_cols);
if ((mi_row + ms < cm->mi_rows) && (mi_col + ms < cm->mi_cols)) if (r && c)
return 0; return 0;
// frame width/height are multiples of 8, hence 8x8 block should always if (c && !r)
// pass the above check return 1; // only allow horizontal/split partition types
assert(bsize > BLOCK_8X8);
if (r && !c)
// return the node index in the prob tree for binary coding return 2; // only allow vertical/split partition types
// only allow horizontal/split partition types
if ((mi_col + ms < cm->mi_cols) && (mi_row + ms >= cm->mi_rows))
return 1;
// only allow vertical/split partition types
if ((mi_row + ms < cm->mi_rows) && (mi_col + ms >= cm->mi_cols))
return 2;
return -1; return -1;
} }
......
...@@ -264,7 +264,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -264,7 +264,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE_TYPE bsize) { vp9_reader* r, BLOCK_SIZE_TYPE bsize) {
VP9_COMMON *const pc = &pbi->common; VP9_COMMON *const pc = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb; MACROBLOCKD *const xd = &pbi->mb;
int bs = (1 << mi_width_log2(bsize)) / 2, n; const int bs = (1 << mi_width_log2(bsize)) / 2;
PARTITION_TYPE partition = PARTITION_NONE; PARTITION_TYPE partition = PARTITION_NONE;
BLOCK_SIZE_TYPE subsize; BLOCK_SIZE_TYPE subsize;
...@@ -276,7 +276,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -276,7 +276,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
return; return;
} else { } else {
int pl; int pl;
const int idx = check_bsize_coverage(pc, mi_row, mi_col, bsize); const int idx = check_bsize_coverage(bs, pc->mi_rows, pc->mi_cols,
mi_row, mi_col);
set_partition_seg_context(pc, xd, mi_row, mi_col); set_partition_seg_context(pc, xd, mi_row, mi_col);
pl = partition_plane_context(xd, bsize); pl = partition_plane_context(xd, bsize);
...@@ -311,13 +312,14 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -311,13 +312,14 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
if (mi_col + bs < pc->mi_cols) if (mi_col + bs < pc->mi_cols)
decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize); decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize);
break; break;
case PARTITION_SPLIT: case PARTITION_SPLIT: {
int n;
for (n = 0; n < 4; n++) { for (n = 0; n < 4; n++) {
int j = n >> 1, i = n & 0x01; const int j = n >> 1, i = n & 1;
*(get_sb_index(xd, subsize)) = n; *(get_sb_index(xd, subsize)) = n;
decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize); decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize);
} }
break; } break;
default: default:
assert(!"Invalid partition type"); assert(!"Invalid partition type");
} }
......
...@@ -628,7 +628,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, ...@@ -628,7 +628,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
if (bsize >= BLOCK_8X8) { if (bsize >= BLOCK_8X8) {
int pl; int pl;
const int idx = check_bsize_coverage(cm, mi_row, mi_col, bsize); const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col); set_partition_seg_context(cm, xd, mi_row, mi_col);
pl = partition_plane_context(xd, bsize); pl = partition_plane_context(xd, bsize);
// encode the partition information // encode the partition information
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment