diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 1693817ef..1e0120382 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -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); } -static int check_bsize_coverage(VP9_COMMON *cm, int mi_row, int mi_col, - BLOCK_SIZE_TYPE bsize) { - int bsl = mi_width_log2(bsize), bs = 1 << bsl; - int ms = bs / 2; +// return the node index in the prob tree for binary coding +static int check_bsize_coverage(int bs, int mi_rows, int mi_cols, + int mi_row, int mi_col) { + 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; - // frame width/height are multiples of 8, hence 8x8 block should always - // pass the above check - assert(bsize > BLOCK_8X8); + if (c && !r) + return 1; // only allow horizontal/split partition types - // return the node index in the prob tree for binary coding - // 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; + if (r && !c) + return 2; // only allow vertical/split partition types return -1; } diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 70e85f95a..7f7d66b4b 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -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_COMMON *const pc = &pbi->common; 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; BLOCK_SIZE_TYPE subsize; @@ -276,7 +276,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, return; } else { 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); pl = partition_plane_context(xd, bsize); @@ -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) decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize); break; - case PARTITION_SPLIT: + case PARTITION_SPLIT: { + int 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; decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize); } - break; + } break; default: assert(!"Invalid partition type"); } diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 54f83a127..f6846e7fe 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -628,7 +628,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, if (bsize >= BLOCK_8X8) { 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); pl = partition_plane_context(xd, bsize); // encode the partition information