Commit 64550b6a authored by Yue Chen's avatar Yue Chen

Refactor write_modes_b() and decode_block()

In order to reduce the code complexity for handling parameter
coding and recon separately for each 64x64 in non-causal obmc
experiment, we break them down to two steps calling separate
functions, one for params, the other dealing with coefficients
and recon(decoder side).
Note: actually the non-causal prediction can use the original
syntax, but right now in the decoder coeff detoken and recon are
heavily nested.

Change-Id: I72d9c42ab8f38b57850d6b0481551893f1702822
parent d5dfa96e
......@@ -1378,37 +1378,36 @@ static void set_segment_id_supertx(const AV1_COMMON *const cm, const int mi_row,
}
#endif // CONFIG_SUPERTX
static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
static void decode_mbmi_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
#if CONFIG_SUPERTX
int supertx_enabled,
int supertx_enabled,
#endif // CONFIG_SUPERTX
int mi_row, int mi_col, aom_reader *r,
int mi_row, int mi_col, aom_reader *r,
#if CONFIG_EXT_PARTITION_TYPES
PARTITION_TYPE partition,
PARTITION_TYPE partition,
#endif // CONFIG_EXT_PARTITION_TYPES
BLOCK_SIZE bsize) {
BLOCK_SIZE bsize) {
AV1_COMMON *const cm = &pbi->common;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
const int x_mis = AOMMIN(bw, cm->mi_cols - mi_col);
const int y_mis = AOMMIN(bh, cm->mi_rows - mi_row);
MB_MODE_INFO *mbmi;
#if CONFIG_ACCOUNTING
aom_accounting_set_context(&pbi->accounting, mi_col, mi_row);
#endif
#if CONFIG_SUPERTX
if (supertx_enabled) {
mbmi = set_mb_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
set_mb_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
} else {
mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
}
#if CONFIG_EXT_PARTITION_TYPES
xd->mi[0]->mbmi.partition = partition;
#endif
av1_read_mode_info(pbi, xd, supertx_enabled, mi_row, mi_col, r, x_mis, y_mis);
#else
mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
#if CONFIG_EXT_PARTITION_TYPES
xd->mi[0]->mbmi.partition = partition;
#endif
......@@ -1424,14 +1423,24 @@ static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
}
#if CONFIG_SUPERTX
mbmi->segment_id_supertx = MAX_SEGMENTS;
if (supertx_enabled) {
xd->corrupted |= aom_reader_has_error(r);
return;
}
xd->mi[0]->mbmi.segment_id_supertx = MAX_SEGMENTS;
#endif // CONFIG_SUPERTX
xd->corrupted |= aom_reader_has_error(r);
}
static void decode_token_and_recon_block(AV1Decoder *const pbi,
MACROBLOCKD *const xd, int mi_row,
int mi_col, aom_reader *r,
BLOCK_SIZE bsize) {
AV1_COMMON *const cm = &pbi->common;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
const int x_mis = AOMMIN(bw, cm->mi_cols - mi_col);
const int y_mis = AOMMIN(bh, cm->mi_rows - mi_row);
MB_MODE_INFO *mbmi;
mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
#if CONFIG_DELTA_Q
if (cm->delta_q_present_flag) {
int i;
......@@ -1691,6 +1700,30 @@ static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
xd->corrupted |= aom_reader_has_error(r);
}
static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif // CONFIG_SUPERTX
int mi_row, int mi_col, aom_reader *r,
#if CONFIG_EXT_PARTITION_TYPES
PARTITION_TYPE partition,
#endif // CONFIG_EXT_PARTITION_TYPES
BLOCK_SIZE bsize) {
decode_mbmi_block(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
mi_row, mi_col, r,
#if CONFIG_EXT_PARTITION_TYPES
partition,
#endif
bsize);
#if CONFIG_SUPERTX
if (!supertx_enabled)
#endif // CONFIG_SUPERTX
decode_token_and_recon_block(pbi, xd, mi_row, mi_col, r, bsize);
}
static PARTITION_TYPE read_partition(AV1_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int mi_col, aom_reader *r,
int has_rows, int has_cols,
......
......@@ -1810,25 +1810,16 @@ PVQ_INFO *get_pvq_block(PVQ_QUEUE *pvq_q) {
}
#endif
static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
aom_writer *w, const TOKENEXTRA **tok,
const TOKENEXTRA *const tok_end,
static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile,
aom_writer *w,
#if CONFIG_SUPERTX
int supertx_enabled,
int supertx_enabled,
#endif
int mi_row, int mi_col) {
int mi_row, int mi_col) {
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
MODE_INFO *m;
int plane;
int bh, bw;
#if CONFIG_PVQ
MB_MODE_INFO *mbmi;
BLOCK_SIZE bsize;
od_adapt_ctx *adapt;
(void)tok;
(void)tok_end;
#endif
xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col);
m = xd->mi[0];
......@@ -1840,11 +1831,6 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
cpi->td.mb.mbmi_ext = cpi->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#if CONFIG_PVQ
mbmi = &m->mbmi;
bsize = mbmi->sb_type;
adapt = &cpi->td.mb.daala_enc.state.adapt;
#endif
if (frame_is_intra_only(cm)) {
write_mb_modes_kf(cm, xd, xd->mi, w);
......@@ -1890,7 +1876,42 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
#endif
w);
}
}
static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
aom_writer *w, const TOKENEXTRA **tok,
const TOKENEXTRA *const tok_end, int mi_row,
int mi_col) {
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
MODE_INFO *m;
int plane;
int bh, bw;
#if CONFIG_PVQ
MB_MODE_INFO *mbmi;
BLOCK_SIZE bsize;
od_adapt_ctx *adapt;
(void)tok;
(void)tok_end;
#endif
xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col);
m = xd->mi[0];
assert(m->mbmi.sb_type <= cm->sb_size);
bh = mi_size_high[m->mbmi.sb_type];
bw = mi_size_wide[m->mbmi.sb_type];
cpi->td.mb.mbmi_ext = cpi->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#if CONFIG_PVQ
mbmi = &m->mbmi;
bsize = mbmi->sb_type;
adapt = &cpi->td.mb.daala_enc.state.adapt;
#endif
#if !CONFIG_PVQ
#if CONFIG_PALETTE
for (plane = 0; plane <= 1; ++plane) {
if (m->mbmi.palette_mode_info.palette_size[plane] > 0) {
......@@ -1905,10 +1926,6 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
}
}
#endif // CONFIG_PALETTE
#if !CONFIG_PVQ
#if CONFIG_SUPERTX
if (supertx_enabled) return;
#endif // CONFIG_SUPERTX
#if CONFIG_COEF_INTERLEAVE
if (!m->mbmi.skip) {
......@@ -2162,6 +2179,24 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
#endif
}
static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
aom_writer *w, const TOKENEXTRA **tok,
const TOKENEXTRA *const tok_end,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif
int mi_row, int mi_col) {
write_mbmi_b(cpi, tile, w,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
mi_row, mi_col);
#if !CONFIG_PVQ && CONFIG_SUPERTX
if (!supertx_enabled)
#endif
write_tokens_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
}
static void write_partition(const AV1_COMMON *const cm,
const MACROBLOCKD *const xd, int hbs, int mi_row,
int mi_col, PARTITION_TYPE p, BLOCK_SIZE bsize,
......
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