From: Jingning Han Date: Sat, 11 May 2013 20:24:03 +0000 (-0700) Subject: Move get_sb_index to vp9_blockd.h X-Git-Tag: v1.3.0~1106^2~4^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2117d4ee9652ccd1f9243b51ed553d41fffbd32d;p=libvpx Move get_sb_index to vp9_blockd.h Use common function to fetch/assign sb_index in rd loop, bit-stream writing and reading. Change-Id: I1d8a214a57ed9cbcd026040436ef33e5e39d65b7 --- diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 004054d10..d14ed45d9 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -401,10 +401,39 @@ typedef struct macroblockd { int sb_index; // index of 32x32 block inside the 64x64 block int mb_index; // index of 16x16 block inside the 32x32 block int b_index; // index of 8x8 block inside the 16x16 block +#if CONFIG_AB4X4 + int ab_index; // index of 4x4 block inside the 8x8 block +#endif int q_index; } MACROBLOCKD; +static int *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE_TYPE subsize) { + switch (subsize) { + case BLOCK_SIZE_SB64X32: + case BLOCK_SIZE_SB32X64: + case BLOCK_SIZE_SB32X32: + return &xd->sb_index; + case BLOCK_SIZE_SB32X16: + case BLOCK_SIZE_SB16X32: + case BLOCK_SIZE_MB16X16: + return &xd->mb_index; + case BLOCK_SIZE_SB16X8: + case BLOCK_SIZE_SB8X16: + case BLOCK_SIZE_SB8X8: + return &xd->b_index; +#if CONFIG_AB4X4 + case BLOCK_SIZE_SB8X4: + case BLOCK_SIZE_SB4X8: + case BLOCK_SIZE_AB4X4: + return &xd->ab_index; +#endif + default: + assert(0); + return NULL; + } +} + static INLINE void update_partition_context(MACROBLOCKD *xd, BLOCK_SIZE_TYPE sb_type, BLOCK_SIZE_TYPE sb_size) { diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 70db06dc1..af21d1cc7 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -468,12 +468,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, case PARTITION_SPLIT: for (n = 0; n < 4; n++) { int j = n >> 1, i = n & 0x01; - if (subsize == BLOCK_SIZE_SB32X32) - xd->sb_index = n; - else if (subsize == BLOCK_SIZE_MB16X16) - xd->mb_index = n; - else - xd->b_index = n; + *(get_sb_index(xd, subsize)) = n; decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize); } break; diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index da0bb2128..0c3d225c8 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -905,6 +905,7 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, case PARTITION_SPLIT: for (n = 0; n < 4; n++) { int j = n >> 1, i = n & 0x01; + *(get_sb_index(xd, subsize)) = n; write_modes_sb(cpi, m + j * bs * mis + i * bs, bc, tok, tok_end, mi_row + j * bs, mi_col + i * bs, subsize); } diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 3345f8965..1f7b259a0 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -765,26 +765,6 @@ static PICK_MODE_CONTEXT *get_block_context(MACROBLOCK *x, } } -static int *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE_TYPE subsize) { - switch (subsize) { - case BLOCK_SIZE_SB64X32: - case BLOCK_SIZE_SB32X64: - case BLOCK_SIZE_SB32X32: - return &xd->sb_index; - case BLOCK_SIZE_SB32X16: - case BLOCK_SIZE_SB16X32: - case BLOCK_SIZE_MB16X16: - return &xd->mb_index; - case BLOCK_SIZE_SB16X8: - case BLOCK_SIZE_SB8X16: - case BLOCK_SIZE_SB8X8: - return &xd->b_index; - default: - assert(0); - return NULL; - } -} - static BLOCK_SIZE_TYPE *get_sb_partitioning(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { MACROBLOCKD *xd = &x->e_mbd;