diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 0a441bdf0..36e7e8300 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -234,31 +234,6 @@ typedef struct macroblockd { int q_index; } MACROBLOCKD; -static INLINE uint8_t *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE subsize) { - switch (subsize) { - case BLOCK_64X64: - case BLOCK_64X32: - case BLOCK_32X64: - case BLOCK_32X32: - return &xd->sb_index; - case BLOCK_32X16: - case BLOCK_16X32: - case BLOCK_16X16: - return &xd->mb_index; - case BLOCK_16X8: - case BLOCK_8X16: - case BLOCK_8X8: - return &xd->b_index; - case BLOCK_8X4: - case BLOCK_4X8: - case BLOCK_4X4: - return &xd->ab_index; - default: - assert(0); - return NULL; - } -} - static INLINE void update_partition_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type, BLOCK_SIZE sb_size) { const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2; diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 2f7347649..ec310f4ce 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -224,14 +224,14 @@ static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) { static void decode_modes_b(VP9D_COMP *pbi, int tile_col, int mi_row, int mi_col, - vp9_reader *r, BLOCK_SIZE bsize) { + vp9_reader *r, BLOCK_SIZE bsize, int index) { MACROBLOCKD *const xd = &pbi->mb; const int less8x8 = bsize < BLOCK_8X8; MB_MODE_INFO *mbmi; int eobtotal; if (less8x8) - if (xd->ab_index > 0) + if (index > 0) return; set_offsets(pbi, bsize, tile_col, mi_row, mi_col); @@ -271,9 +271,10 @@ static void decode_modes_b(VP9D_COMP *pbi, int tile_col, xd->corrupted |= vp9_reader_has_error(r); } + static void decode_modes_sb(VP9D_COMP *pbi, int tile_col, int mi_row, int mi_col, - vp9_reader* r, BLOCK_SIZE bsize) { + vp9_reader* r, BLOCK_SIZE bsize, int index) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; @@ -284,7 +285,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int tile_col, return; if (bsize < BLOCK_8X8) { - if (xd->ab_index != 0) + if (index > 0) return; } else { int pl; @@ -306,31 +307,27 @@ static void decode_modes_sb(VP9D_COMP *pbi, int tile_col, } subsize = get_subsize(bsize, partition); - *get_sb_index(xd, subsize) = 0; switch (partition) { case PARTITION_NONE: - decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize); + decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize, 0); break; case PARTITION_HORZ: - decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize); - *get_sb_index(xd, subsize) = 1; + decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize, 0); if (mi_row + hbs < cm->mi_rows) - decode_modes_b(pbi, tile_col, mi_row + hbs, mi_col, r, subsize); + decode_modes_b(pbi, tile_col, mi_row + hbs, mi_col, r, subsize, 1); break; case PARTITION_VERT: - decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize); - *get_sb_index(xd, subsize) = 1; + decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize, 0); if (mi_col + hbs < cm->mi_cols) - decode_modes_b(pbi, tile_col, mi_row, mi_col + hbs, r, subsize); + decode_modes_b(pbi, tile_col, mi_row, mi_col + hbs, r, subsize, 1); break; case PARTITION_SPLIT: { int n; for (n = 0; n < 4; n++) { const int j = n >> 1, i = n & 1; - *get_sb_index(xd, subsize) = n; decode_modes_sb(pbi, tile_col, mi_row + j * hbs, mi_col + i * hbs, - r, subsize); + r, subsize, n); } } break; default: @@ -611,7 +608,7 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r, int tile_col) { vp9_zero(cm->left_seg_context); for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end; mi_col += MI_BLOCK_SIZE) - decode_modes_sb(pbi, tile_col, mi_row, mi_col, r, BLOCK_64X64); + decode_modes_sb(pbi, tile_col, mi_row, mi_col, r, BLOCK_64X64, 0); if (pbi->do_loopfilter_inline) { // delay the loopfilter by 1 macroblock row. diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index bfac5a77d..ed795f031 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -565,13 +565,13 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8, static void write_modes_b(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc, TOKENEXTRA **tok, TOKENEXTRA *tok_end, - int mi_row, int mi_col) { + int mi_row, int mi_col, int index) { VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &cpi->mb.e_mbd; MODE_INFO *m = mi_8x8[0]; if (m->mbmi.sb_type < BLOCK_8X8) - if (xd->ab_index > 0) + if (index > 0) return; xd->mi_8x8 = mi_8x8; @@ -597,7 +597,8 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc, static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc, TOKENEXTRA **tok, TOKENEXTRA *tok_end, - int mi_row, int mi_col, BLOCK_SIZE bsize) { + int mi_row, int mi_col, BLOCK_SIZE bsize, + int index) { VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *xd = &cpi->mb.e_mbd; const int mis = cm->mode_info_stride; @@ -613,11 +614,10 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc, partition = partition_lookup[bsl][m->mbmi.sb_type]; - if (bsize < BLOCK_8X8) - if (xd->ab_index > 0) + if (bsize < BLOCK_8X8) { + if (index > 0) return; - - if (bsize >= BLOCK_8X8) { + } else { int pl; const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols, mi_row, mi_col); @@ -634,31 +634,28 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc, } subsize = get_subsize(bsize, partition); - *(get_sb_index(xd, subsize)) = 0; switch (partition) { case PARTITION_NONE: - write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col); + write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0); break; case PARTITION_HORZ: - write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col); - *(get_sb_index(xd, subsize)) = 1; + write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0); if ((mi_row + bs) < cm->mi_rows) write_modes_b(cpi, mi_8x8 + bs * mis, bc, tok, tok_end, mi_row + bs, - mi_col); + mi_col, 1); break; case PARTITION_VERT: - write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col); - *(get_sb_index(xd, subsize)) = 1; + write_modes_b(cpi, mi_8x8, bc, tok, tok_end, mi_row, mi_col, 0); if ((mi_col + bs) < cm->mi_cols) - write_modes_b(cpi, mi_8x8 + bs, bc, tok, tok_end, mi_row, mi_col + bs); + write_modes_b(cpi, mi_8x8 + bs, bc, tok, tok_end, mi_row, mi_col + bs, + 1); break; case PARTITION_SPLIT: for (n = 0; n < 4; n++) { - int j = n >> 1, i = n & 0x01; - *(get_sb_index(xd, subsize)) = n; + const int j = n >> 1, i = n & 1; write_modes_sb(cpi, mi_8x8 + j * bs * mis + i * bs, bc, tok, tok_end, - mi_row + j * bs, mi_col + i * bs, subsize); + mi_row + j * bs, mi_col + i * bs, subsize, n); } break; default: @@ -690,7 +687,7 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc, for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end; mi_col += MI_BLOCK_SIZE, m_8x8 += MI_BLOCK_SIZE) { write_modes_sb(cpi, m_8x8, bc, tok, tok_end, mi_row, mi_col, - BLOCK_64X64); + BLOCK_64X64, 0); } } } diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 50ada528f..2f6d458ef 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -59,6 +59,31 @@ static const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = { int enc_debug = 0; #endif +static INLINE uint8_t *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE subsize) { + switch (subsize) { + case BLOCK_64X64: + case BLOCK_64X32: + case BLOCK_32X64: + case BLOCK_32X32: + return &xd->sb_index; + case BLOCK_32X16: + case BLOCK_16X32: + case BLOCK_16X16: + return &xd->mb_index; + case BLOCK_16X8: + case BLOCK_8X16: + case BLOCK_8X8: + return &xd->b_index; + case BLOCK_8X4: + case BLOCK_4X8: + case BLOCK_4X4: + return &xd->ab_index; + default: + assert(0); + return NULL; + } +} + static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, int mi_row, int mi_col, BLOCK_SIZE bsize);