Commit c4ad3273 authored by Dmitry Kovalev's avatar Dmitry Kovalev

Moving segmentation related vars into separate struct.

Adding segmentation struct to vp9_seg_common.h. Struct members are from
macroblockd and VP9Common structs. Moving segmentation related constants
and enums to vp9_seg_common.h.

Change-Id: I23fabc33f11a359249f5f80d161daf569d02ec03
parent f70c021d
......@@ -13,18 +13,19 @@
#define VP9_COMMON_VP9_BLOCKD_H_
#include "./vpx_config.h"
#include "vpx_ports/mem.h"
#include "vpx_scale/yv12config.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_common_data.h"
#include "vp9/common/vp9_convolve.h"
#include "vp9/common/vp9_enums.h"
#include "vp9/common/vp9_mv.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_treecoder.h"
#include "vpx_ports/mem.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_enums.h"
#include "vp9/common/vp9_common_data.h"
#define BLOCK_SIZE_GROUPS 4
#define MAX_MB_SEGMENTS 8
#define MB_SEG_TREE_PROBS (MAX_MB_SEGMENTS-1)
#define PREDICTION_PROBS 3
......@@ -34,8 +35,6 @@
#define MAX_MODE_LF_DELTAS 2
/* Segment Feature Masks */
#define SEGMENT_DELTADATA 0
#define SEGMENT_ABSDATA 1
#define MAX_MV_REF_CANDIDATES 2
#define INTRA_INTER_CONTEXTS 4
......@@ -92,15 +91,6 @@ static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= NEWMV;
}
// Segment level features.
typedef enum {
SEG_LVL_ALT_Q = 0, // Use alternate Quantizer ....
SEG_LVL_ALT_LF = 1, // Use alternate loop filter value...
SEG_LVL_REF_FRAME = 2, // Optional Segment reference frame
SEG_LVL_SKIP = 3, // Optional Segment (0,0) + skip mode
SEG_LVL_MAX = 4 // Number of MB level features supported
} SEG_LVL_FEATURES;
// Segment level features.
typedef enum {
TX_4X4 = 0, // 4x4 dct transform
......@@ -253,32 +243,12 @@ typedef struct macroblockd {
int left_available;
int right_available;
struct segmentation seg;
// partition contexts
PARTITION_CONTEXT *above_seg_context;
PARTITION_CONTEXT *left_seg_context;
/* 0 (disable) 1 (enable) segmentation */
unsigned char segmentation_enabled;
/* 0 (do not update) 1 (update) the macroblock segmentation map. */
unsigned char update_mb_segmentation_map;
/* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
unsigned char update_mb_segmentation_data;
/* 0 (do not update) 1 (update) the macroblock segmentation feature data. */
unsigned char mb_segment_abs_delta;
/* Per frame flags that define which MB level features (such as quantizer or loop filter level) */
/* are enabled and when enabled the proabilities used to decode the per MB flags in MB_MODE_INFO */
// Probability Tree used to code Segment number
vp9_prob mb_segment_tree_probs[MB_SEG_TREE_PROBS];
// Segment features
int16_t segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
unsigned int segment_feature_mask[MAX_MB_SEGMENTS];
/* mode_based Loop filter adjustment */
unsigned char mode_ref_lf_delta_enabled;
unsigned char mode_ref_lf_delta_update;
......
......@@ -460,8 +460,8 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
// Reset the segment feature data to the default stats:
// Features disabled, 0, with delta coding (Default state).
int i;
vp9_clearall_segfeatures(xd);
xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
vp9_clearall_segfeatures(&xd->seg);
xd->seg.abs_delta = SEGMENT_DELTADATA;
if (cm->last_frame_seg_map)
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
......
......@@ -92,9 +92,9 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm, MACROBLOCKD *xd,
int lvl_seg = default_filt_lvl, ref, mode, intra_lvl;
// Set the baseline filter values for each segment
if (vp9_segfeature_active(xd, seg, SEG_LVL_ALT_LF)) {
const int data = vp9_get_segdata(xd, seg, SEG_LVL_ALT_LF);
lvl_seg = xd->mb_segment_abs_delta == SEGMENT_ABSDATA
if (vp9_segfeature_active(&xd->seg, seg, SEG_LVL_ALT_LF)) {
const int data = vp9_get_segdata(&xd->seg, seg, SEG_LVL_ALT_LF);
lvl_seg = xd->seg.abs_delta == SEGMENT_ABSDATA
? data
: clamp(default_filt_lvl + data, 0, MAX_LOOP_FILTER);
}
......
......@@ -13,7 +13,9 @@
#include "vpx_ports/mem.h"
#include "vpx_config.h"
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_seg_common.h"
#define MAX_LOOP_FILTER 63
#define MAX_SHARPNESS 7
......
......@@ -247,10 +247,6 @@ typedef struct VP9Common {
[VP9_INTRA_MODES - 1];
vp9_prob kf_uv_mode_prob[VP9_INTRA_MODES] [VP9_INTRA_MODES - 1];
// Context probabilities when using predictive coding of segment id
vp9_prob segment_pred_probs[PREDICTION_PROBS];
unsigned char temporal_update;
// Context probabilities for reference frame prediction
int allow_comp_inter_inter;
MV_REFERENCE_FRAME comp_fixed_ref;
......
......@@ -32,7 +32,7 @@ static INLINE unsigned char vp9_get_pred_context_seg_id(const VP9_COMMON *cm,
static INLINE vp9_prob vp9_get_pred_prob_seg_id(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = vp9_get_pred_context_seg_id(cm, xd);
return cm->segment_pred_probs[pred_context];
return xd->seg.pred_probs[pred_context];
}
static INLINE unsigned char vp9_get_pred_flag_seg_id(
const MACROBLOCKD * const xd) {
......
......@@ -57,9 +57,9 @@ int16_t vp9_ac_quant(int qindex, int delta) {
int vp9_get_qindex(MACROBLOCKD *xd, int segment_id, int base_qindex) {
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
const int data = vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
return xd->mb_segment_abs_delta == SEGMENT_ABSDATA ?
if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_ALT_Q)) {
const int data = vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_ALT_Q);
return xd->seg.abs_delta == SEGMENT_ABSDATA ?
data : // Abs value
clamp(base_qindex + data, 0, MAXQ); // Delta value
} else {
......
......@@ -9,8 +9,11 @@
*/
#include <assert.h>
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_loopfilter.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_quant_common.h"
static const int seg_feature_data_signed[SEG_LVL_MAX] = { 1, 1, 0, 0 };
......@@ -22,25 +25,25 @@ static const int seg_feature_data_max[SEG_LVL_MAX] = {
// the coding mechanism is still subject to change so these provide a
// convenient single point of change.
int vp9_segfeature_active(const MACROBLOCKD *xd, int segment_id,
int vp9_segfeature_active(const struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id) {
return xd->segmentation_enabled &&
(xd->segment_feature_mask[segment_id] & (1 << feature_id));
return seg->enabled &&
(seg->feature_mask[segment_id] & (1 << feature_id));
}
void vp9_clearall_segfeatures(MACROBLOCKD *xd) {
vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
vpx_memset(xd->segment_feature_mask, 0, sizeof(xd->segment_feature_mask));
void vp9_clearall_segfeatures(struct segmentation *seg) {
vpx_memset(seg->feature_data, 0, sizeof(seg->feature_data));
vpx_memset(seg->feature_mask, 0, sizeof(seg->feature_mask));
}
void vp9_enable_segfeature(MACROBLOCKD *xd, int segment_id,
void vp9_enable_segfeature(struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id) {
xd->segment_feature_mask[segment_id] |= 1 << feature_id;
seg->feature_mask[segment_id] |= 1 << feature_id;
}
void vp9_disable_segfeature(MACROBLOCKD *xd, int segment_id,
void vp9_disable_segfeature(struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id) {
xd->segment_feature_mask[segment_id] &= ~(1 << feature_id);
seg->feature_mask[segment_id] &= ~(1 << feature_id);
}
int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id) {
......@@ -51,12 +54,12 @@ int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id) {
return seg_feature_data_signed[feature_id];
}
void vp9_clear_segdata(MACROBLOCKD *xd, int segment_id,
void vp9_clear_segdata(struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id) {
xd->segment_feature_data[segment_id][feature_id] = 0;
seg->feature_data[segment_id][feature_id] = 0;
}
void vp9_set_segdata(MACROBLOCKD *xd, int segment_id,
void vp9_set_segdata(struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id, int seg_data) {
assert(seg_data <= seg_feature_data_max[feature_id]);
if (seg_data < 0) {
......@@ -64,12 +67,12 @@ void vp9_set_segdata(MACROBLOCKD *xd, int segment_id,
assert(-seg_data <= seg_feature_data_max[feature_id]);
}
xd->segment_feature_data[segment_id][feature_id] = seg_data;
seg->feature_data[segment_id][feature_id] = seg_data;
}
int vp9_get_segdata(const MACROBLOCKD *xd, int segment_id,
int vp9_get_segdata(const struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id) {
return xd->segment_feature_data[segment_id][feature_id];
return seg->feature_data[segment_id][feature_id];
}
......
......@@ -8,23 +8,54 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vp9/common/vp9_onyxc_int.h"
#include "vp9/common/vp9_blockd.h"
#ifndef VP9_COMMON_VP9_SEG_COMMON_H_
#define VP9_COMMON_VP9_SEG_COMMON_H_
int vp9_segfeature_active(const MACROBLOCKD *xd,
#include "vp9/common/vp9_treecoder.h"
#define SEGMENT_DELTADATA 0
#define SEGMENT_ABSDATA 1
#define MAX_MB_SEGMENTS 8
#define MB_SEG_TREE_PROBS (MAX_MB_SEGMENTS-1)
#define PREDICTION_PROBS 3
// Segment level features.
typedef enum {
SEG_LVL_ALT_Q = 0, // Use alternate Quantizer ....
SEG_LVL_ALT_LF = 1, // Use alternate loop filter value...
SEG_LVL_REF_FRAME = 2, // Optional Segment reference frame
SEG_LVL_SKIP = 3, // Optional Segment (0,0) + skip mode
SEG_LVL_MAX = 4 // Number of MB level features supported
} SEG_LVL_FEATURES;
struct segmentation {
uint8_t enabled;
uint8_t update_map;
uint8_t update_data;
uint8_t abs_delta;
uint8_t temporal_update;
vp9_prob tree_probs[MB_SEG_TREE_PROBS];
vp9_prob pred_probs[PREDICTION_PROBS];
int16_t feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
unsigned int feature_mask[MAX_MB_SEGMENTS];
};
int vp9_segfeature_active(const struct segmentation *seg,
int segment_id,
SEG_LVL_FEATURES feature_id);
void vp9_clearall_segfeatures(MACROBLOCKD *xd);
void vp9_clearall_segfeatures(struct segmentation *seg);
void vp9_enable_segfeature(MACROBLOCKD *xd,
void vp9_enable_segfeature(struct segmentation *seg,
int segment_id,
SEG_LVL_FEATURES feature_id);
void vp9_disable_segfeature(MACROBLOCKD *xd,
void vp9_disable_segfeature(struct segmentation *seg,
int segment_id,
SEG_LVL_FEATURES feature_id);
......@@ -32,16 +63,16 @@ int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id);
int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id);
void vp9_clear_segdata(MACROBLOCKD *xd,
void vp9_clear_segdata(struct segmentation *seg,
int segment_id,
SEG_LVL_FEATURES feature_id);
void vp9_set_segdata(MACROBLOCKD *xd,
void vp9_set_segdata(struct segmentation *seg,
int segment_id,
SEG_LVL_FEATURES feature_id,
int seg_data);
int vp9_get_segdata(const MACROBLOCKD *xd,
int vp9_get_segdata(const struct segmentation *seg,
int segment_id,
SEG_LVL_FEATURES feature_id);
......
......@@ -44,8 +44,8 @@ static MB_PREDICTION_MODE read_inter_mode(vp9_reader *r, const vp9_prob *p) {
return (MB_PREDICTION_MODE)treed_read(r, vp9_sb_mv_ref_tree, p);
}
static int read_segment_id(vp9_reader *r, MACROBLOCKD *xd) {
return treed_read(r, vp9_segment_tree, xd->mb_segment_tree_probs);
static int read_segment_id(vp9_reader *r, const struct segmentation *seg) {
return treed_read(r, vp9_segment_tree, seg->tree_probs);
}
static TX_SIZE read_selected_txfm_size(VP9_COMMON *cm, MACROBLOCKD *xd,
......@@ -105,13 +105,13 @@ static void set_segment_id(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
static int read_intra_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
struct segmentation *const seg = &xd->seg;
const BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
if (xd->segmentation_enabled && xd->update_mb_segmentation_map) {
const int segment_id = read_segment_id(r, xd);
set_segment_id(cm, bsize, mi_row, mi_col, segment_id);
if (seg->enabled && seg->update_map) {
const int segment_id = read_segment_id(r, seg);
set_segment_id(&pbi->common, bsize, mi_row, mi_col, segment_id);
return segment_id;
} else {
return 0;
......@@ -121,7 +121,7 @@ static int read_intra_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
static uint8_t read_skip_coeff(VP9D_COMP *pbi, int segment_id, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
int skip_coeff = vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP);
int skip_coeff = vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP);
if (!skip_coeff) {
const uint8_t ctx = vp9_get_pred_context_mbskip(cm, xd);
skip_coeff = vp9_read(r, vp9_get_pred_prob_mbskip(cm, xd));
......@@ -290,8 +290,8 @@ static void read_ref_frame(VP9D_COMP *pbi, vp9_reader *r,
MACROBLOCKD *const xd = &pbi->mb;
FRAME_CONTEXT *const fc = &cm->fc;
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME)) {
ref_frame[0] = vp9_get_segdata(xd, segment_id, SEG_LVL_REF_FRAME);
if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
ref_frame[0] = vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME);
ref_frame[1] = NONE;
} else {
const int comp_ctx = vp9_get_pred_context_comp_inter_inter(cm, xd);
......@@ -366,26 +366,28 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
struct segmentation *const seg = &xd->seg;
const BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
int pred_segment_id;
int segment_id;
if (!xd->segmentation_enabled)
if (!seg->enabled)
return 0; // Default for disabled segmentation
pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map,
bsize, mi_row, mi_col);
if (!xd->update_mb_segmentation_map)
bsize, mi_row, mi_col);
if (!seg->update_map)
return pred_segment_id;
if (cm->temporal_update) {
if (seg->temporal_update) {
const vp9_prob pred_prob = vp9_get_pred_prob_seg_id(cm, xd);
const int pred_flag = vp9_read(r, pred_prob);
vp9_set_pred_flag_seg_id(xd, bsize, pred_flag);
segment_id = pred_flag ? pred_segment_id
: read_segment_id(r, xd);
: read_segment_id(r, seg);
} else {
segment_id = read_segment_id(r, xd);
segment_id = read_segment_id(r, seg);
}
set_segment_id(cm, bsize, mi_row, mi_col, segment_id);
return segment_id;
......@@ -455,14 +457,14 @@ static MV_REFERENCE_FRAME read_reference_frame(VP9D_COMP *pbi, int segment_id,
MACROBLOCKD *const xd = &pbi->mb;
MV_REFERENCE_FRAME ref;
if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME)) {
if (!vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
const int ctx = vp9_get_pred_context_intra_inter(cm, xd);
ref = (MV_REFERENCE_FRAME)
vp9_read(r, vp9_get_pred_prob_intra_inter(cm, xd));
cm->fc.intra_inter_count[ctx][ref != INTRA_FRAME]++;
} else {
ref = (MV_REFERENCE_FRAME)
vp9_get_segdata(xd, segment_id, SEG_LVL_REF_FRAME) != INTRA_FRAME;
ref = (MV_REFERENCE_FRAME) vp9_get_segdata(&xd->seg, segment_id,
SEG_LVL_REF_FRAME) != INTRA_FRAME;
}
return ref;
}
......@@ -515,7 +517,7 @@ static void read_inter_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
mv_ref_p = cm->fc.inter_mode_probs[mbmi->mb_mode_context[ref0]];
if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_SKIP)) {
if (vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
mbmi->mode = ZEROMV;
} else if (bsize >= BLOCK_SIZE_SB8X8) {
mbmi->mode = read_inter_mode(r, mv_ref_p);
......
......@@ -174,7 +174,7 @@ static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
vp9_reset_sb_tokens_context(xd, bsize);
return -1;
} else {
if (xd->segmentation_enabled)
if (xd->seg.enabled)
mb_init_dequantizer(&pbi->common, xd);
// TODO(dkovalev) if (!vp9_reader_has_error(r))
......@@ -395,55 +395,53 @@ static void read_coef_probs(FRAME_CONTEXT *fc, TXFM_MODE txfm_mode,
read_coef_probs_common(fc, TX_32X32, r);
}
static void setup_segmentation(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) {
static void setup_segmentation(struct segmentation *seg,
struct vp9_read_bit_buffer *rb) {
int i, j;
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
xd->update_mb_segmentation_map = 0;
xd->update_mb_segmentation_data = 0;
seg->update_map = 0;
seg->update_data = 0;
xd->segmentation_enabled = vp9_rb_read_bit(rb);
if (!xd->segmentation_enabled)
seg->enabled = vp9_rb_read_bit(rb);
if (!seg->enabled)
return;
// Segmentation map update
xd->update_mb_segmentation_map = vp9_rb_read_bit(rb);
if (xd->update_mb_segmentation_map) {
seg->update_map = vp9_rb_read_bit(rb);
if (seg->update_map) {
for (i = 0; i < MB_SEG_TREE_PROBS; i++)
xd->mb_segment_tree_probs[i] = vp9_rb_read_bit(rb) ?
vp9_rb_read_literal(rb, 8) : MAX_PROB;
seg->tree_probs[i] = vp9_rb_read_bit(rb) ? vp9_rb_read_literal(rb, 8)
: MAX_PROB;
cm->temporal_update = vp9_rb_read_bit(rb);
if (cm->temporal_update) {
seg->temporal_update = vp9_rb_read_bit(rb);
if (seg->temporal_update) {
for (i = 0; i < PREDICTION_PROBS; i++)
cm->segment_pred_probs[i] = vp9_rb_read_bit(rb) ?
vp9_rb_read_literal(rb, 8) : MAX_PROB;
seg->pred_probs[i] = vp9_rb_read_bit(rb) ? vp9_rb_read_literal(rb, 8)
: MAX_PROB;
} else {
for (i = 0; i < PREDICTION_PROBS; i++)
cm->segment_pred_probs[i] = MAX_PROB;
seg->pred_probs[i] = MAX_PROB;
}
}
// Segmentation data update
xd->update_mb_segmentation_data = vp9_rb_read_bit(rb);
if (xd->update_mb_segmentation_data) {
xd->mb_segment_abs_delta = vp9_rb_read_bit(rb);
seg->update_data = vp9_rb_read_bit(rb);
if (seg->update_data) {
seg->abs_delta = vp9_rb_read_bit(rb);
vp9_clearall_segfeatures(xd);
vp9_clearall_segfeatures(seg);
for (i = 0; i < MAX_MB_SEGMENTS; i++) {
for (j = 0; j < SEG_LVL_MAX; j++) {
int data = 0;
const int feature_enabled = vp9_rb_read_bit(rb);
if (feature_enabled) {
vp9_enable_segfeature(xd, i, j);
vp9_enable_segfeature(seg, i, j);
data = decode_unsigned_max(rb, vp9_seg_feature_data_max(j));
if (vp9_is_segfeature_signed(j))
data = vp9_rb_read_bit(rb) ? -data : data;
}
vp9_set_segdata(xd, i, j, data);
vp9_set_segdata(seg, i, j, data);
}
}
}
......@@ -902,7 +900,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
setup_loopfilter(pbi, rb);
setup_quantization(pbi, rb);
setup_segmentation(pbi, rb);
setup_segmentation(&pbi->mb.seg, rb);
setup_tile_info(cm, rb);
......
......@@ -278,8 +278,8 @@ SKIP_START:
return c;
}
static int get_eob(MACROBLOCKD* const xd, int segment_id, int eob_max) {
return vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
static int get_eob(struct segmentation *seg, int segment_id, int eob_max) {
return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
}
struct decode_block_args {
......@@ -300,7 +300,7 @@ static void decode_block(int plane, int block,
struct macroblockd_plane* pd = &xd->plane[plane];
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const TX_SIZE ss_tx_size = ss_txfrm_size / 2;
const int seg_eob = get_eob(xd, segment_id, 16 << ss_txfrm_size);
const int seg_eob = get_eob(&xd->seg, segment_id, 16 << ss_txfrm_size);
const int off = block >> ss_txfrm_size;
const int mod = bw - ss_tx_size - pd->subsampling_x;
const int aoff = (off & ((1 << mod) - 1)) << ss_tx_size;
......
......@@ -216,7 +216,7 @@ static void write_selected_txfm_size(const VP9_COMP *cpi, TX_SIZE tx_size,
static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
vp9_writer *w) {
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) {
if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)) {
return 1;
} else {
const int skip_coeff = m->mbmi.mb_skip_coeff;
......@@ -356,10 +356,10 @@ static void write_sb_mv_ref(vp9_writer *w, MB_PREDICTION_MODE m,
}
static void write_segment_id(vp9_writer *w, const MACROBLOCKD *xd,
static void write_segment_id(vp9_writer *w, const struct segmentation *seg,
int segment_id) {
if (xd->segmentation_enabled && xd->update_mb_segmentation_map)
treed_write(w, vp9_segment_tree, xd->mb_segment_tree_probs, segment_id, 3);
if (seg->enabled && seg->update_map)
treed_write(w, vp9_segment_tree, seg->tree_probs, segment_id, 3);
}
// This function encodes the reference frame
......@@ -369,7 +369,7 @@ static void encode_ref_frame(VP9_COMP *cpi, vp9_writer *bc) {
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mi = &xd->mode_info_context->mbmi;
const int segment_id = mi->segment_id;
int seg_ref_active = vp9_segfeature_active(xd, segment_id,
int seg_ref_active = vp9_segfeature_active(&xd->seg, segment_id,
SEG_LVL_REF_FRAME);
// If segment level coding of this signal is disabled...
// or the segment allows multiple reference frame options
......@@ -396,7 +396,7 @@ static void encode_ref_frame(VP9_COMP *cpi, vp9_writer *bc) {
}
} else {
assert(mi->ref_frame[1] <= INTRA_FRAME);
assert(vp9_get_segdata(xd, segment_id, SEG_LVL_REF_FRAME) ==
assert(vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME) ==
mi->ref_frame[0]);
}
......@@ -410,6 +410,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
const nmv_context *nmvc = &pc->fc.nmvc;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
struct segmentation *seg = &xd->seg;
MB_MODE_INFO *const mi = &m->mbmi;
const MV_REFERENCE_FRAME rf = mi->ref_frame[0];
const MB_PREDICTION_MODE mode = mi->mode;
......@@ -423,33 +424,27 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
active_section = 9;
#endif
if (cpi->mb.e_mbd.update_mb_segmentation_map) {
// Is temporal coding of the segment map enabled
if (pc->temporal_update) {
if (seg->update_map) {
if (seg->temporal_update) {
unsigned char prediction_flag = vp9_get_pred_flag_seg_id(xd);
vp9_prob pred_prob = vp9_get_pred_prob_seg_id(pc, xd);
// Code the segment id prediction flag for this mb
vp9_write(bc, prediction_flag, pred_prob);
// If the mb segment id wasn't predicted code explicitly
if (!prediction_flag)
write_segment_id(bc, xd, mi->segment_id);
write_segment_id(bc, seg, mi->segment_id);
} else {
// Normal unpredicted coding
write_segment_id(bc, xd, mi->segment_id);
write_segment_id(bc, seg, mi->segment_id);
}
}
skip_coeff = write_skip_coeff(cpi, segment_id, m, bc);
if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME))
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME))
vp9_write(bc, rf != INTRA_FRAME,
vp9_get_pred_prob_intra_inter(pc, xd));
if (mi->sb_type >= BLOCK_SIZE_SB8X8 && pc->txfm_mode == TX_MODE_SELECT &&