Commit 938710cb authored by Rostislav Pehlivanov's avatar Rostislav Pehlivanov

Change q_segmentation to spatial_segmentation

Adds spatial prediction to standard segmentation instead of a separate
segmentation feature.
When using temporal prediction skipped blocks are flagged as mispredicted.

Change-Id: I0c32281286d3fbce66d339c9247bcc6516f37a63
parent bca03fc5
......@@ -53,11 +53,6 @@ static int alloc_seg_map(AV1_COMMON *cm, int rows, int cols) {
int i;
int seg_map_size = rows * cols;
#if CONFIG_Q_SEGMENTATION
cm->q_seg_map = (uint8_t *)aom_calloc(seg_map_size, 1);
if (!cm->q_seg_map) return 1;
#endif
for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
cm->seg_map_array[i] = (uint8_t *)aom_calloc(seg_map_size, 1);
if (cm->seg_map_array[i] == NULL) return 1;
......@@ -78,11 +73,6 @@ static int alloc_seg_map(AV1_COMMON *cm, int rows, int cols) {
static void free_seg_map(AV1_COMMON *cm) {
int i;
#if CONFIG_Q_SEGMENTATION
aom_free(cm->q_seg_map);
cm->q_seg_map = NULL;
#endif
for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
aom_free(cm->seg_map_array[i]);
cm->seg_map_array[i] = NULL;
......
......@@ -278,9 +278,6 @@ typedef struct MB_MODE_INFO {
int8_t skip_mode;
#endif // CONFIG_EXT_SKIP
int8_t segment_id;
#if CONFIG_Q_SEGMENTATION
int8_t q_segment_id;
#endif
int8_t seg_id_predicted; // valid only when temporal_update is enabled
// Only for INTRA blocks
......
......@@ -1751,9 +1751,11 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
AVERAGE_TILE_CDFS(lpf_delta_cdf);
AVERAGE_TILE_CDFS(lpf_sign_cdf);
#endif // CONFIG_LPF_SB
#if CONFIG_Q_SEGMENTATION
#if CONFIG_SPATIAL_SEGMENTATION
int j;
for (j = 0; j < Q_SEGMENT_CDF_COUNT; j++) AVERAGE_TILE_CDFS(seg.q_seg_cdf[j]);
for (j = 0; j < SPATIAL_PREDICTION_PROBS; j++) {
AVERAGE_TILE_CDFS(seg.spatial_pred_seg_cdf[j]);
}
#endif
}
......@@ -1807,10 +1809,6 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
AVERAGE_TILE_CDFS(lpf_delta_cdf);
AVERAGE_TILE_CDFS(lpf_sign_cdf);
#endif // CONFIG_LPF_SB
#if CONFIG_Q_SEGMENTATION
int j;
for (j = 0; j < Q_SEGMENT_CDF_COUNT; j++) AVERAGE_TILE_CDFS(seg.q_seg_cdf[j]);
#endif
#if CONFIG_JNT_COMP
AVERAGE_TILE_CDFS(compound_index_cdf);
#endif // CONFIG_JNT_COMP
......
......@@ -1603,9 +1603,10 @@ static const aom_cdf_prob default_seg_tree_cdf[CDF_SIZE(MAX_SEGMENTS)] = {
AOM_CDF8(4096, 8192, 12288, 16384, 20480, 24576, 28672)
};
#if CONFIG_Q_SEGMENTATION
#if CONFIG_SPATIAL_SEGMENTATION
static const aom_cdf_prob
default_q_seg_tree_cdf[Q_SEGMENT_CDF_COUNT][CDF_SIZE(MAX_SEGMENTS)] = {
default_spatial_pred_seg_tree_cdf[SPATIAL_PREDICTION_PROBS][CDF_SIZE(
MAX_SEGMENTS)] = {
{
AOM_CDF8(5622, 7893, 16093, 18233, 27809, 28373, 32533),
},
......@@ -3085,9 +3086,10 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->skip_cdfs, default_skip_cdfs);
av1_copy(fc->intra_inter_cdf, default_intra_inter_cdf);
av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf);
#if CONFIG_Q_SEGMENTATION
for (int i = 0; i < Q_SEGMENT_CDF_COUNT; i++)
av1_copy(fc->seg.q_seg_cdf[i], default_q_seg_tree_cdf[i]);
#if CONFIG_SPATIAL_SEGMENTATION
for (int i = 0; i < SPATIAL_PREDICTION_PROBS; i++)
av1_copy(fc->seg.spatial_pred_seg_cdf[i],
default_spatial_pred_seg_tree_cdf[i]);
#endif
av1_copy(fc->tx_size_cdf, default_tx_size_cdf);
av1_copy(fc->delta_q_cdf, default_delta_q_cdf);
......
......@@ -398,10 +398,11 @@ typedef struct AV1Common {
#endif
uint8_t *last_frame_seg_map;
uint8_t *current_frame_seg_map;
#if CONFIG_Q_SEGMENTATION
uint8_t *q_seg_map;
#endif
int seg_map_alloc_size;
#if CONFIG_SPATIAL_SEGMENTATION
int last_active_segid;
int preskip_segid;
#endif
InterpFilter interp_filter;
......
......@@ -20,9 +20,9 @@
extern "C" {
#endif
#if CONFIG_Q_SEGMENTATION
#if CONFIG_SPATIAL_SEGMENTATION
/* Picks CDFs based on number of matching segment IDs */
static INLINE int pick_q_seg_cdf(int prev_ul, int prev_u, int prev_l) {
static INLINE int pick_spatial_seg_cdf(int prev_ul, int prev_u, int prev_l) {
if ((prev_ul == prev_u) && (prev_ul == prev_l))
return 2;
else if ((prev_ul == prev_u) || (prev_ul == prev_l) || (prev_u == prev_l))
......@@ -31,14 +31,15 @@ static INLINE int pick_q_seg_cdf(int prev_ul, int prev_u, int prev_l) {
return 0;
}
static INLINE int pick_q_seg_pred(int prev_ul, int prev_u, int prev_l) {
static INLINE int pick_spatial_seg_pred(int prev_ul, int prev_u, int prev_l) {
/* If 2 or more are identical returns that as predictor, otherwise prev_l */
return (prev_ul == prev_u) ? prev_u : prev_l;
}
static INLINE void set_q_segment_id(const AV1_COMMON *const cm,
uint8_t *segment_ids, BLOCK_SIZE bsize,
int mi_row, int mi_col, int segment_id) {
static INLINE void set_spatial_segment_id(const AV1_COMMON *const cm,
uint8_t *segment_ids,
BLOCK_SIZE bsize, int mi_row,
int mi_col, int segment_id) {
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
......
......@@ -430,25 +430,14 @@ int16_t av1_qindex_from_ac_Q3(int ac_QTX, aom_bit_depth_t bit_depth) {
#endif // !CONFIG_DAALA_TX
int av1_get_qindex(const struct segmentation *seg, int segment_id,
#if CONFIG_Q_SEGMENTATION
int q_segment_id, int base_qindex)
#else
int base_qindex)
#endif
{
int base_qindex) {
if (segfeature_active(seg, segment_id, SEG_LVL_ALT_Q)) {
const int data = get_segdata(seg, segment_id, SEG_LVL_ALT_Q);
const int seg_qindex = base_qindex + data;
return clamp(seg_qindex, 0, MAXQ);
}
#if CONFIG_Q_SEGMENTATION
else if (q_segment_id < seg->q_lvls) {
const int seg_qindex = base_qindex + seg->q_delta[q_segment_id];
return clamp(seg_qindex, 0, MAXQ);
}
#endif
else
} else {
return base_qindex;
}
}
#if CONFIG_AOM_QM
......
......@@ -44,11 +44,7 @@ int16_t av1_ac_quant_QTX(int qindex, int delta, aom_bit_depth_t bit_depth);
int16_t av1_qindex_from_ac_Q3(int ac_Q3, aom_bit_depth_t bit_depth);
int av1_get_qindex(const struct segmentation *seg, int segment_id,
#if CONFIG_Q_SEGMENTATION
int q_segment_id, int base_qindex);
#else
int base_qindex);
#endif
#if CONFIG_AOM_QM
// Reduce the large number of quantizers to a smaller number of levels for which
// different matrices may be defined
......
......@@ -22,8 +22,8 @@ extern "C" {
#define SEG_TREE_PROBS (MAX_SEGMENTS - 1)
#define PREDICTION_PROBS 3
#if CONFIG_Q_SEGMENTATION
#define Q_SEGMENT_CDF_COUNT 3
#if CONFIG_SPATIAL_SEGMENTATION
#define SPATIAL_PREDICTION_PROBS 3
#endif
#if CONFIG_LOOPFILTER_LEVEL
......@@ -60,10 +60,6 @@ typedef enum {
struct segmentation {
uint8_t enabled;
#if CONFIG_Q_SEGMENTATION
uint8_t q_lvls;
int16_t q_delta[MAX_SEGMENTS];
#endif
uint8_t update_map;
uint8_t update_data;
uint8_t temporal_update;
......@@ -76,8 +72,9 @@ struct segmentation_probs {
aom_prob tree_probs[SEG_TREE_PROBS];
aom_cdf_prob tree_cdf[CDF_SIZE(MAX_SEGMENTS)];
aom_cdf_prob pred_cdf[PREDICTION_PROBS][CDF_SIZE(2)];
#if CONFIG_Q_SEGMENTATION
aom_cdf_prob q_seg_cdf[Q_SEGMENT_CDF_COUNT][CDF_SIZE(MAX_SEGMENTS)];
#if CONFIG_SPATIAL_SEGMENTATION
aom_cdf_prob spatial_pred_seg_cdf[SPATIAL_PREDICTION_PROBS]
[CDF_SIZE(MAX_SEGMENTS)];
#endif
};
......
......@@ -406,11 +406,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
for (int i = 0; i < MAX_SEGMENTS; i++) {
#if CONFIG_EXT_DELTA_Q
const int current_qindex =
#if CONFIG_Q_SEGMENTATION
av1_get_qindex(&cm->seg, i, i, xd->current_qindex);
#else
av1_get_qindex(&cm->seg, i, xd->current_qindex);
#endif
#else
const int current_qindex = xd->current_qindex;
#endif // CONFIG_EXT_DELTA_Q
......@@ -959,6 +955,10 @@ static void setup_segmentation(AV1_COMMON *const cm,
}
}
#if CONFIG_SPATIAL_SEGMENTATION
cm->preskip_segid = 0;
#endif
// Segmentation data update
seg->update_data = aom_rb_read_bit(rb);
if (seg->update_data) {
......@@ -969,6 +969,10 @@ static void setup_segmentation(AV1_COMMON *const cm,
int data = 0;
const int feature_enabled = aom_rb_read_bit(rb);
if (feature_enabled) {
#if CONFIG_SPATIAL_SEGMENTATION
cm->preskip_segid |= j >= SEG_LVL_REF_FRAME;
cm->last_active_segid = i;
#endif
av1_enable_segfeature(seg, i, j);
data = decode_unsigned_max(rb, av1_seg_feature_data_max(j));
if (av1_is_segfeature_signed(j))
......@@ -980,33 +984,6 @@ static void setup_segmentation(AV1_COMMON *const cm,
}
}
#if CONFIG_Q_SEGMENTATION
static void setup_q_segmentation(AV1_COMMON *const cm,
struct aom_read_bit_buffer *rb) {
struct segmentation *const seg = &cm->seg;
for (int i = 0; i < MAX_SEGMENTS; i++) {
if (segfeature_active(seg, i, SEG_LVL_ALT_Q)) {
seg->q_lvls = 0;
return;
}
}
if (!aom_rb_read_bit(rb)) {
seg->q_lvls = 0;
return;
}
seg->q_lvls = decode_unsigned_max(rb, MAX_SEGMENTS);
for (int i = 0; i < seg->q_lvls; i++) {
int val = decode_unsigned_max(rb, MAXQ);
val *= 1 - 2 * aom_rb_read_bit(rb);
seg->q_delta[i] = val;
}
}
#endif
#if CONFIG_LOOP_RESTORATION
static void decode_restoration_mode(AV1_COMMON *cm,
struct aom_read_bit_buffer *rb) {
......@@ -1279,11 +1256,7 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) {
// remaining are don't cares.
const int max_segments = cm->seg.enabled ? MAX_SEGMENTS : 1;
for (int i = 0; i < max_segments; ++i) {
#if CONFIG_Q_SEGMENTATION
const int qindex = av1_get_qindex(&cm->seg, i, i, cm->base_qindex);
#else
const int qindex = av1_get_qindex(&cm->seg, i, cm->base_qindex);
#endif
cm->y_dequant_QTX[i][0] =
av1_dc_quant_QTX(qindex, cm->y_dc_delta_q, cm->bit_depth);
cm->y_dequant_QTX[i][1] = av1_ac_quant_QTX(qindex, 0, cm->bit_depth);
......@@ -3119,9 +3092,6 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#endif // CONFIG_Q_ADAPT_PROBS
setup_segmentation(cm, rb);
#if CONFIG_Q_SEGMENTATION
setup_q_segmentation(cm, rb);
#endif
{
int delta_q_allowed = 1;
......@@ -3132,9 +3102,6 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
if (segfeature_active(seg, i, SEG_LVL_ALT_Q)) {
segment_quantizer_active = 1;
}
#if CONFIG_Q_SEGMENTATION
if (seg->q_lvls) segment_quantizer_active = 1;
#endif
}
delta_q_allowed = !segment_quantizer_active;
#endif
......@@ -3175,11 +3142,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
for (int i = 0; i < MAX_SEGMENTS; ++i) {
const int qindex = cm->seg.enabled
#if CONFIG_Q_SEGMENTATION
? av1_get_qindex(&cm->seg, i, i, cm->base_qindex)
#else
? av1_get_qindex(&cm->seg, i, cm->base_qindex)
#endif
: cm->base_qindex;
xd->lossless[i] = qindex == 0 && cm->y_dc_delta_q == 0 &&
cm->u_dc_delta_q == 0 && cm->u_ac_delta_q == 0 &&
......
......@@ -344,11 +344,7 @@ static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
return NEAREST_NEARESTMV + mode;
}
static int read_segment_id(aom_reader *r, struct segmentation_probs *segp) {
return aom_read_symbol(r, segp->tree_cdf, MAX_SEGMENTS, ACCT_STR);
}
#if CONFIG_Q_SEGMENTATION
#if CONFIG_SPATIAL_SEGMENTATION
static int neg_deinterleave(int diff, int ref, int max) {
if (!ref) return diff;
if (ref >= (max - 1)) return max - diff - 1;
......@@ -371,52 +367,49 @@ static int neg_deinterleave(int diff, int ref, int max) {
}
}
static int read_q_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int mi_row, int mi_col, aom_reader *r) {
struct segmentation *const seg = &cm->seg;
static int read_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int mi_row, int mi_col, aom_reader *r, int skip) {
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
struct segmentation_probs *const segp = &ec_ctx->seg;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
int prev_ul = 0; /* Top left segment_id */
int prev_l = 0; /* Current left segment_id */
int prev_u = 0; /* Current top segment_id */
if (!seg->q_lvls) return 0;
MODE_INFO *const mi = cm->mi + mi_row * cm->mi_stride + mi_col;
int tinfo = mi->mbmi.boundary_info;
int above = (!(tinfo & TILE_ABOVE_BOUNDARY)) && ((mi_row - 1) >= 0);
int left = (!(tinfo & TILE_LEFT_BOUNDARY)) && ((mi_col - 1) >= 0);
if (above && left)
prev_ul =
get_segment_id(cm, cm->q_seg_map, BLOCK_4X4, mi_row - 1, mi_col - 1);
prev_ul = get_segment_id(cm, cm->current_frame_seg_map, BLOCK_4X4,
mi_row - 1, mi_col - 1);
if (above)
prev_u = get_segment_id(cm, cm->q_seg_map, BLOCK_4X4, mi_row - 1, mi_col);
prev_u = get_segment_id(cm, cm->current_frame_seg_map, BLOCK_4X4,
mi_row - 1, mi_col - 0);
if (left)
prev_l = get_segment_id(cm, cm->q_seg_map, BLOCK_4X4, mi_row, mi_col - 1);
prev_l = get_segment_id(cm, cm->current_frame_seg_map, BLOCK_4X4,
mi_row - 0, mi_col - 1);
int cdf_num = pick_q_seg_cdf(prev_ul, prev_u, prev_l);
int pred = pick_q_seg_pred(prev_ul, prev_u, prev_l);
int cdf_num = pick_spatial_seg_cdf(prev_ul, prev_u, prev_l);
int pred = pick_spatial_seg_pred(prev_ul, prev_u, prev_l);
if (mbmi->skip) {
set_q_segment_id(cm, cm->q_seg_map, mbmi->sb_type, mi_row, mi_col, pred);
return 0;
}
if (skip) return pred;
aom_cdf_prob *pred_cdf = segp->q_seg_cdf[cdf_num];
aom_cdf_prob *pred_cdf = segp->spatial_pred_seg_cdf[cdf_num];
int coded_id = aom_read_symbol(r, pred_cdf, 8, ACCT_STR);
int segment_id = neg_deinterleave(coded_id, pred, seg->q_lvls);
int segment_id = neg_deinterleave(coded_id, pred, cm->last_active_segid + 1);
assert(segment_id >= 0 && segment_id < seg->q_lvls);
set_q_segment_id(cm, cm->q_seg_map, mbmi->sb_type, mi_row, mi_col,
segment_id);
assert(segment_id >= 0 && segment_id <= cm->last_active_segid);
return segment_id;
}
#else
static int read_segment_id(aom_reader *r, struct segmentation_probs *segp) {
return aom_read_symbol(r, segp->tree_cdf, MAX_SEGMENTS, ACCT_STR);
}
#endif
static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
......@@ -558,19 +551,36 @@ static void set_segment_id(AV1_COMMON *cm, int mi_offset, int x_mis, int y_mis,
}
static int read_intra_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int mi_offset, int x_mis, int y_mis,
MB_MODE_INFO *const mbmi, int mi_row,
int mi_col, int bsize, int preskip,
aom_reader *r) {
struct segmentation *const seg = &cm->seg;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw);
const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh);
FRAME_COUNTS *counts = xd->counts;
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
struct segmentation_probs *const segp = &ec_ctx->seg;
int segment_id;
if (!seg->enabled) return 0; // Default for disabled segmentation
assert(seg->update_map && !seg->temporal_update);
segment_id = read_segment_id(r, segp);
#if CONFIG_SPATIAL_SEGMENTATION
if (preskip) {
if (!cm->preskip_segid) return 0;
} else {
if (cm->preskip_segid) return mbmi->segment_id;
}
segment_id =
read_segment_id(cm, xd, mi_row, mi_col, r, preskip ? 0 : mbmi->skip);
#else
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
(void)preskip;
(void)mbmi;
segment_id = read_segment_id(r, &ec_ctx->seg);
#endif
if (counts) ++counts->seg.tree_total[segment_id];
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
return segment_id;
......@@ -588,7 +598,8 @@ static void copy_segment_id(const AV1_COMMON *cm,
}
static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int mi_row, int mi_col, aom_reader *r) {
int mi_row, int mi_col, int preskip,
aom_reader *r) {
struct segmentation *const seg = &cm->seg;
FRAME_COUNTS *counts = xd->counts;
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
......@@ -617,6 +628,25 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
return predicted_segment_id;
}
#if CONFIG_SPATIAL_SEGMENTATION
if (preskip) {
if (!cm->preskip_segid) return 0;
} else {
if (cm->preskip_segid) return mbmi->segment_id;
if (mbmi->skip) {
if (seg->temporal_update) {
const int ctx = av1_get_pred_context_seg_id(xd);
mbmi->seg_id_predicted = 0;
if (counts) ++counts->seg.pred[ctx][mbmi->seg_id_predicted];
}
segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, 0);
if (counts) ++counts->seg.tree_total[segment_id];
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
return segment_id;
}
}
#endif
(void)preskip;
if (seg->temporal_update) {
const int ctx = av1_get_pred_context_seg_id(xd);
aom_cdf_prob *pred_cdf = segp->pred_cdf[ctx];
......@@ -625,11 +655,19 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
if (mbmi->seg_id_predicted) {
segment_id = predicted_segment_id;
} else {
#if CONFIG_SPATIAL_SEGMENTATION
segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, 0);
#else
segment_id = read_segment_id(r, segp);
#endif
if (counts) ++counts->seg.tree_mispred[segment_id];
}
} else {
#if CONFIG_SPATIAL_SEGMENTATION
segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, 0);
#else
segment_id = read_segment_id(r, segp);
#endif
if (counts) ++counts->seg.tree_total[segment_id];
}
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
......@@ -1077,20 +1115,16 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
const MODE_INFO *left_mi = xd->left_mi;
const BLOCK_SIZE bsize = mbmi->sb_type;
int i;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw);
const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh);
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
mbmi->segment_id = read_intra_segment_id(cm, xd, mi_offset, x_mis, y_mis, r);
mbmi->segment_id =
read_intra_segment_id(cm, xd, mbmi, mi_row, mi_col, bsize, 1, r);
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
#if CONFIG_Q_SEGMENTATION
mbmi->q_segment_id = read_q_segment_id(cm, xd, mi_row, mi_col, r);
#if CONFIG_SPATIAL_SEGMENTATION
mbmi->segment_id =
read_intra_segment_id(cm, xd, mbmi, mi_row, mi_col, bsize, 0, r);
#endif
read_cdef(cm, r, mbmi, mi_col, mi_row);
......@@ -2334,7 +2368,7 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
mbmi->mv[0].as_int = 0;
mbmi->mv[1].as_int = 0;
mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r);
mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, 1, r);
#if CONFIG_EXT_SKIP
mbmi->skip_mode = read_skip_mode(cm, xd, mbmi->segment_id, r);
......@@ -2351,9 +2385,9 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
#endif // CONFIG_EXT_SKIP
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
#if CONFIG_Q_SEGMENTATION
mbmi->q_segment_id = read_q_segment_id(cm, xd, mi_row, mi_col, r);
#endif // CONFIG_Q_SEGMENTATION
#if CONFIG_SPATIAL_SEGMENTATION
mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, 0, r);
#endif
read_cdef(cm, r, mbmi, mi_col, mi_row);
......
......@@ -410,11 +410,7 @@ static void cyclic_refresh_update_map(AV1_COMP *const cpi) {
int mi_col = sb_col_index * cm->mib_size;
int qindex_thresh =
cpi->oxcf.content == AOM_CONTENT_SCREEN
#if CONFIG_Q_SEGMENTATION
? av1_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, 0, cm->base_qindex)
#else
? av1_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)
#endif
: 0;
assert(mi_row >= 0 && mi_row < cm->mi_rows);
assert(mi_col >= 0 && mi_col < cm->mi_cols);
......
......@@ -1642,11 +1642,7 @@ void av1_init_quantizer(AV1_COMP *cpi) {
}
void av1_init_plane_quantizers(const AV1_COMP *cpi, MACROBLOCK *x,
#if CONFIG_Q_SEGMENTATION
int segment_id, int q_segment_id) {
#else
int segment_id) {
#endif
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
const QUANTS *const quants = &cpi->quants;
......@@ -1663,12 +1659,7 @@ void av1_init_plane_quantizers(const AV1_COMP *cpi, MACROBLOCK *x,
cm->delta_q_present_flag ? cm->base_qindex + xd->delta_qindex
: cm->base_qindex));
#endif
#if CONFIG_Q_SEGMENTATION
const int qindex =
av1_get_qindex(&cm->seg, segment_id, q_segment_id, current_q_index);
#else
const int qindex = av1_get_qindex(&cm->seg, segment_id, current_q_index);
#endif
const int rdmult = av1_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q);
#if CONFIG_AOM_QM
int minqm = cm->min_qmlevel;
......@@ -1766,12 +1757,7 @@ void av1_init_plane_quantizers(const AV1_COMP *cpi, MACROBLOCK *x,
void av1_frame_init_quantizer(AV1_COMP *cpi) {
MACROBLOCK *const x = &cpi->td.mb;
MACROBLOCKD *const xd = &x->e_mbd;
#if CONFIG_Q_SEGMENTATION
av1_init_plane_quantizers(cpi, x, xd->mi[0]->mbmi.segment_id,
xd->mi[0]->mbmi.q_segment_id);
#else
av1_init_plane_quantizers(cpi, x, xd->mi[0]->mbmi.segment_id);
#endif
}
void av1_set_quantizer(AV1_COMMON *cm, int q) {
......
......@@ -107,11 +107,7 @@ struct AV1Common;
void av1_frame_init_quantizer(struct AV1_COMP *cpi);
void av1_init_plane_quantizers(const struct AV1_COMP *cpi, MACROBLOCK *x,
#if CONFIG_Q_SEGMENTATION
int segment_id, int q_segment_id);
#else
int segment_id);
#endif
void av1_build_quantizer(aom_bit_depth_t bit_depth, int y_dc_delta_q,
int u_dc_delta_q, int u_ac_delta_q, int v_dc_delta_q,
......
This diff is collapsed.
......@@ -348,29 +348,15 @@ static void set_offsets(const AV1_COMP *const cpi, const TileInfo *const tile,
#endif
mbmi->segment_id = 0;
#if CONFIG_Q_SEGMENTATION
mbmi->q_segment_id = 0;
#endif
// Setup segment ID.
#if CONFIG_Q_SEGMENTATION
if (seg->enabled || seg->q_lvls) {
#else
// Setup segment ID.
if (seg->enabled) {
#endif
if (seg->enabled && !cpi->vaq_refresh) {
const uint8_t *const map =
seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map;
mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
}
#if CONFIG_Q_SEGMENTATION
if (seg->q_lvls)