Commit 2a4da947 authored by Jingning Han's avatar Jingning Han
Browse files

Factor out common tx_type writing codes from inter/intra frame

Change-Id: Id2626bd19db2504756d9a1dee709c2d08c79f771
parent 98d6a1f2
......@@ -1118,6 +1118,81 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
#endif // CONFIG_PALETTE
static void write_tx_type(const AV1_COMMON *const cm,
const MB_MODE_INFO *const mbmi,
#if CONFIG_SUPERTX
const int supertx_enabled,
#endif
aom_writer *w) {
const int is_inter = is_inter_block(mbmi);
if (!FIXED_TX_TYPE) {
#if CONFIG_EXT_TX
const BLOCK_SIZE bsize = mbmi->sb_type;
if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter) > 1 &&
cm->base_qindex > 0 && !mbmi->skip &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif // CONFIG_SUPERTX
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
int eset = get_ext_tx_set(mbmi->tx_size, bsize, is_inter);
if (is_inter) {
assert(ext_tx_used_inter[eset][mbmi->tx_type]);
if (eset > 0)
av1_write_token(
w, av1_ext_tx_inter_tree[eset],
cm->fc->inter_ext_tx_prob[eset][txsize_sqr_map[mbmi->tx_size]],
&ext_tx_inter_encodings[eset][mbmi->tx_type]);
} else if (ALLOW_INTRA_EXT_TX) {
if (eset > 0)
av1_write_token(
w, av1_ext_tx_intra_tree[eset],
cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode],
&ext_tx_intra_encodings[eset][mbmi->tx_type]);
}
}
#else
if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif // CONFIG_SUPERTX
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
if (is_inter) {
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_ext_tx_ind[mbmi->tx_type],
cm->fc->inter_ext_tx_cdf[mbmi->tx_size], TX_TYPES);
#else
av1_write_token(w, av1_ext_tx_tree,
cm->fc->inter_ext_tx_prob[mbmi->tx_size],
&ext_tx_encodings[mbmi->tx_type]);
#endif
} else {
#if CONFIG_DAALA_EC
aom_write_symbol(
w, av1_ext_tx_ind[mbmi->tx_type],
cm->fc->intra_ext_tx_cdf[mbmi->tx_size]
[intra_mode_to_tx_type_context[mbmi->mode]],
TX_TYPES);
#else
av1_write_token(
w, av1_ext_tx_tree,
cm->fc
->intra_ext_tx_prob[mbmi->tx_size]
[intra_mode_to_tx_type_context[mbmi->mode]],
&ext_tx_encodings[mbmi->tx_type]);
#endif
}
} else {
if (!mbmi->skip) {
#if CONFIG_SUPERTX
if (!supertx_enabled)
#endif // CONFIG_SUPERTX
assert(mbmi->tx_type == DCT_DCT);
}
}
#endif // CONFIG_EXT_TX
}
}
static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#if CONFIG_SUPERTX
int supertx_enabled,
......@@ -1531,71 +1606,11 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#endif // CONFIG_EXT_INTERP
}
if (!FIXED_TX_TYPE) {
#if CONFIG_EXT_TX
if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter) > 1 &&
cm->base_qindex > 0 && !mbmi->skip &&
write_tx_type(cm, mbmi,
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif // CONFIG_SUPERTX
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
int eset = get_ext_tx_set(mbmi->tx_size, bsize, is_inter);
if (is_inter) {
assert(ext_tx_used_inter[eset][mbmi->tx_type]);
if (eset > 0)
av1_write_token(
w, av1_ext_tx_inter_tree[eset],
cm->fc->inter_ext_tx_prob[eset][txsize_sqr_map[mbmi->tx_size]],
&ext_tx_inter_encodings[eset][mbmi->tx_type]);
} else if (ALLOW_INTRA_EXT_TX) {
if (eset > 0)
av1_write_token(
w, av1_ext_tx_intra_tree[eset],
cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode],
&ext_tx_intra_encodings[eset][mbmi->tx_type]);
}
}
#else
if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif // CONFIG_SUPERTX
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
if (is_inter) {
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_ext_tx_ind[mbmi->tx_type],
cm->fc->inter_ext_tx_cdf[mbmi->tx_size], TX_TYPES);
#else
av1_write_token(w, av1_ext_tx_tree,
cm->fc->inter_ext_tx_prob[mbmi->tx_size],
&ext_tx_encodings[mbmi->tx_type]);
supertx_enabled,
#endif
} else {
#if CONFIG_DAALA_EC
aom_write_symbol(
w, av1_ext_tx_ind[mbmi->tx_type],
cm->fc->intra_ext_tx_cdf[mbmi->tx_size]
[intra_mode_to_tx_type_context[mbmi->mode]],
TX_TYPES);
#else
av1_write_token(
w, av1_ext_tx_tree,
cm->fc
->intra_ext_tx_prob[mbmi->tx_size]
[intra_mode_to_tx_type_context[mbmi->mode]],
&ext_tx_encodings[mbmi->tx_type]);
#endif
}
} else {
if (!mbmi->skip) {
#if CONFIG_SUPERTX
if (!supertx_enabled)
#endif // CONFIG_SUPERTX
assert(mbmi->tx_type == DCT_DCT);
}
}
#endif // CONFIG_EXT_TX
}
w);
}
#if CONFIG_DELTA_Q
......@@ -1681,38 +1696,11 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
if (bsize >= BLOCK_8X8) write_filter_intra_mode_info(cm, mbmi, w);
#endif // CONFIG_FILTER_INTRA
if (!FIXED_TX_TYPE) {
#if CONFIG_EXT_TX
if (get_ext_tx_types(mbmi->tx_size, bsize, 0) > 1 && cm->base_qindex > 0 &&
!mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
ALLOW_INTRA_EXT_TX) {
int eset = get_ext_tx_set(mbmi->tx_size, bsize, 0);
if (eset > 0)
av1_write_token(
w, av1_ext_tx_intra_tree[eset],
cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode],
&ext_tx_intra_encodings[eset][mbmi->tx_type]);
}
#else
if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
#if CONFIG_DAALA_EC
aom_write_symbol(
w, av1_ext_tx_ind[mbmi->tx_type],
cm->fc->intra_ext_tx_cdf[mbmi->tx_size]
[intra_mode_to_tx_type_context[mbmi->mode]],
TX_TYPES);
#else
av1_write_token(
w, av1_ext_tx_tree,
cm->fc->intra_ext_tx_prob[mbmi->tx_size]
[intra_mode_to_tx_type_context[mbmi->mode]],
&ext_tx_encodings[mbmi->tx_type]);
write_tx_type(cm, mbmi,
#if CONFIG_SUPERTX
0,
#endif
}
#endif // CONFIG_EXT_TX
}
w);
}
#if CONFIG_SUPERTX
......
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