Commit a10a268e authored by Paul Wilkins's avatar Paul Wilkins

Segment Features. Removal of #ifdefs

Removal of configure #ifdefs so that segment features
always available. Removal of code supporting old
segment feature method.

Still a good deal of tidying up to do.

Change-Id: I397855f086f8c09ab1fae0a5f65d9e06d2e3e39f
parent 2370d440
......@@ -104,16 +104,12 @@ typedef enum
{
SEG_LVL_ALT_Q = 0, // Use alternate Quantizer ....
SEG_LVL_ALT_LF = 1, // Use alternate loop filter value...
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
SEG_LVL_REF_FRAME = 2, // Optional Segment reference frame
SEG_LVL_MODE = 3, // Optional Segment mode
SEG_LVL_EOB = 4, // EOB end stop marker.
SEG_LVL_TRANSFORM = 5, // Block transform size.
SEG_LVL_MAX = 6 // Number of MB level features supported
#else
SEG_LVL_MAX = 2 // Number of MB level features supported
#endif
} SEG_LVL_FEATURES;
......@@ -261,9 +257,8 @@ typedef struct MacroBlockD
// Segment features
signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
unsigned int segment_feature_mask[MAX_MB_SEGMENTS];
#endif
/* mode_based Loop filter adjustment */
unsigned char mode_ref_lf_delta_enabled;
......
......@@ -92,12 +92,6 @@ DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask[16]);
DECLARE_ALIGNED(64, short, vp8_default_zig_zag_mask_8x8[64]);//int64_t
#endif
#if CONFIG_SEGFEATURES
const int vp8_seg_feature_data_bits[SEG_LVL_MAX] = {7, 6, 4, 4, 4, 2};
#else
const int vp8_seg_feature_data_bits[SEG_LVL_MAX] = {7, 6};
#endif
/* Array indices are identical to previously-existing CONTEXT_NODE indices */
const vp8_tree_index vp8_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */
......
......@@ -106,7 +106,5 @@ extern short vp8_default_zig_zag_mask[16];
extern DECLARE_ALIGNED(64, const int, vp8_default_zig_zag1d_8x8[64]);
extern short vp8_default_zig_zag_mask_8x8[64];//int64_t
#endif
extern const int vp8_seg_feature_data_bits[SEG_LVL_MAX];
void vp8_coef_tree_initialize(void);
#endif
......@@ -14,9 +14,9 @@
#include "onyxc_int.h"
#include "vpx_mem/vpx_mem.h"
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
//#endif
typedef unsigned char uc;
......@@ -221,11 +221,8 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
// Set the baseline filter values for each segment
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( segfeature_active( xd, seg, SEG_LVL_ALT_LF ) )
#else
if ( xd->segmentation_enabled )
#endif
{
/* Abs value */
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
......
......@@ -10,9 +10,9 @@
#include "vp8/common/seg_common.h"
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
const int segfeaturedata_signed[SEG_LVL_MAX] = {1, 1, 0, 0, 0, 0};
const int vp8_seg_feature_data_bits[SEG_LVL_MAX] = {7, 6, 4, 4, 4, 2};
// These functions provide access to new segment level features.
// Eventually these function may be "optimized out" but for the moment,
......@@ -48,6 +48,11 @@ void disable_segfeature( MACROBLOCKD *xd,
xd->segment_feature_mask[segment_id] &= ~(1 << feature_id);
}
int seg_feature_data_bits( SEG_LVL_FEATURES feature_id )
{
return vp8_seg_feature_data_bits[feature_id];
}
int is_segfeature_signed( SEG_LVL_FEATURES feature_id )
{
return ( segfeaturedata_signed[feature_id] );
......@@ -103,5 +108,3 @@ int check_segref_inter(MACROBLOCKD *xd, int segment_id)
}
// TBD? Functions to read and write segment data with range / validity checking
#endif
......@@ -15,9 +15,8 @@
#include "onyxd_int.h"
#include "vp8/common/findnearmv.h"
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#if CONFIG_SEGMENTATION
#include "vp8/common/seg_common.h"
......@@ -93,21 +92,18 @@ static void vp8_kfread_modes(VP8D_COMP *pbi, MODE_INFO *m, int mb_row, int mb_co
if (pbi->mb.update_mb_segmentation_map)
vp8_read_mb_features(bc, &m->mbmi, &pbi->mb);
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( pbi->common.mb_no_coeff_skip &&
( !segfeature_active( &pbi->mb,
m->mbmi.segment_id, SEG_LVL_EOB ) ||
(pbi->mb.segment_feature_data[m->mbmi.segment_id]
[SEG_LVL_EOB] != 0) ) )
#else
// Read the macroblock coeff skip flag if this feature is in use,
// else default to 0
if (pbi->common.mb_no_coeff_skip)
#endif
{
m->mbmi.mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
}
else
{
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( segfeature_active( &pbi->mb,
m->mbmi.segment_id, SEG_LVL_EOB ) &&
(pbi->mb.segment_feature_data[m->mbmi.segment_id]
......@@ -116,7 +112,6 @@ static void vp8_kfread_modes(VP8D_COMP *pbi, MODE_INFO *m, int mb_row, int mb_co
m->mbmi.mb_skip_coeff = 1;
}
else
#endif
m->mbmi.mb_skip_coeff = 0;
}
......@@ -238,15 +233,12 @@ static MV_REFERENCE_FRAME read_ref_frame( VP8D_COMP *pbi,
MV_REFERENCE_FRAME ref_frame;
int seg_ref_active;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
MACROBLOCKD *const xd = &pbi->mb;
seg_ref_active = segfeature_active( xd,
segment_id,
SEG_LVL_REF_FRAME );
#else
seg_ref_active = 0;
#endif
// Segment reference frame features not available
if ( !seg_ref_active )
......@@ -264,7 +256,7 @@ static MV_REFERENCE_FRAME read_ref_frame( VP8D_COMP *pbi,
}
}
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
// Segment reference frame features are enabled
else
{
......@@ -335,7 +327,6 @@ static MV_REFERENCE_FRAME read_ref_frame( VP8D_COMP *pbi,
}
}
}
#endif
return (MV_REFERENCE_FRAME)ref_frame;
}
......@@ -500,15 +491,12 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
#endif
}
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( pbi->common.mb_no_coeff_skip &&
( !segfeature_active( xd,
mbmi->segment_id, SEG_LVL_EOB ) ||
(xd->segment_feature_data[mbmi->segment_id]
[SEG_LVL_EOB] != 0) ) )
#else
if (pbi->common.mb_no_coeff_skip)
#endif
{
// Read the macroblock coeff skip flag if this feature is in use,
// else default to 0
......@@ -516,7 +504,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
}
else
{
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( segfeature_active( xd,
mbmi->segment_id, SEG_LVL_EOB ) &&
(xd->segment_feature_data[mbmi->segment_id]
......@@ -525,7 +513,6 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->mb_skip_coeff = 1;
}
else
#endif
mbmi->mb_skip_coeff = 0;
}
......@@ -543,7 +530,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->ref_frame, pbi->common.ref_frame_sign_bias);
vp8_mv_ref_probs(mv_ref_p, rct);
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
// Is the segment level mode feature enabled for this segment
if ( segfeature_active( xd, mbmi->segment_id, SEG_LVL_MODE ) )
{
......@@ -554,9 +541,6 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
{
mbmi->mode = read_mv_ref(bc, mv_ref_p);
}
#else
mbmi->mode = read_mv_ref(bc, mv_ref_p);
#endif
mbmi->uv_mode = DC_PRED;
switch (mbmi->mode)
......@@ -709,12 +693,11 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
/* required for left and above block mv */
mbmi->mv.as_int = 0;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( segfeature_active( xd, mbmi->segment_id, SEG_LVL_MODE ) )
mbmi->mode = (MB_PREDICTION_MODE)
get_segdata( xd, mbmi->segment_id, SEG_LVL_MODE );
else
#endif
{
mbmi->mode = (MB_PREDICTION_MODE)
vp8_read_ymode(bc, pbi->common.fc.ymode_prob);
......@@ -741,12 +724,11 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
MODE_INFO *mi = pbi->common.mi;
int mb_row = -1;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#if 0
FILE *statsfile;
statsfile = fopen("decsegmap.stt", "a");
fprintf(statsfile, "\n" );
#endif
#endif
mb_mode_mv_init(pbi);
......@@ -772,10 +754,9 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
mb_to_bottom_edge = ((pbi->common.mb_rows - 1 - mb_row) * 16) << 3;
mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#if 0
fprintf(statsfile, "\n" );
#endif
#endif
while (++mb_col < pbi->common.mb_cols)
......@@ -818,12 +799,12 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
}
#endif
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#if 0
fprintf(statsfile, "%2d%2d%2d ",
mi->mbmi.segment_id, mi->mbmi.ref_frame, mi->mbmi.mode );
#endif
#endif
mi++; /* next macroblock */
}
......@@ -831,10 +812,10 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
mi++; /* skip left predictor each row */
}
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#if 0
fclose(statsfile);
#endif
#endif
}
......@@ -37,9 +37,8 @@
#include "decoderthreading.h"
#include "dboolhuff.h"
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#include <assert.h>
#include <stdio.h>
......@@ -81,11 +80,8 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd)
// Set the Q baseline allowing for any segment level adjustment
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( segfeature_active( xd, segment_id, SEG_LVL_ALT_Q ) )
#else
if ( xd->segmentation_enabled )
#endif
{
/* Abs Value */
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
......@@ -807,10 +803,9 @@ static void init_frame(VP8D_COMP *pbi)
// Reset the segment feature data to the default stats:
// Features disabled, 0, with delta coding (Default state).
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
vpx_memset(xd->segment_feature_mask, 0,
sizeof(xd->segment_feature_mask));
#endif
vpx_memset(xd->segment_feature_data, 0,
sizeof(xd->segment_feature_data));
......@@ -883,7 +878,6 @@ int vp8_decode_frame(VP8D_COMP *pbi)
int mb_row;
int i, j, k, l;
const int *const mb_feature_data_bits = vp8_seg_feature_data_bits;
int corrupt_tokens = 0;
int prev_independent_partitions = pbi->independent_partitions;
......@@ -1028,58 +1022,41 @@ int vp8_decode_frame(VP8D_COMP *pbi)
if (xd->update_mb_segmentation_data)
{
int data;
xd->mb_segement_abs_delta = (unsigned char)vp8_read_bit(bc);
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
clearall_segfeatures( xd );
// For each segmentation...
for (j = 0; j < MAX_MB_SEGMENTS; j++)
for (i = 0; i < MAX_MB_SEGMENTS; i++)
{
// For each of the segments features...
for (i = 0; i < SEG_LVL_MAX; i++)
{
#else
// Clear down feature data structure
vpx_memset(xd->segment_feature_data, 0,
sizeof(xd->segment_feature_data));
// For each segmentation feature...
for (i = 0; i < SEG_LVL_MAX; i++)
{
// For each segmentation...
for (j = 0; j < MAX_MB_SEGMENTS; j++)
for (j = 0; j < SEG_LVL_MAX; j++)
{
#endif
// Is the feature enabled
if (vp8_read_bit(bc))
{
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
// Update the feature data and mask
enable_segfeature(xd, j, i);
#endif
xd->segment_feature_data[j][i] =
(signed char)vp8_read_literal(
bc, mb_feature_data_bits[i]);
enable_segfeature(xd, i, j);
#if CONFIG_SEGFEATURES
data = (signed char)vp8_read_literal(
bc, seg_feature_data_bits(j));
//#if CONFIG_SEGFEATURES
// Is the segment data signed..
if ( is_segfeature_signed(i) )
#else
if ( 1 )
#endif
if ( is_segfeature_signed(j) )
{
if (vp8_read_bit(bc))
{
xd->segment_feature_data[j][i] =
-xd->segment_feature_data[j][i];
}
data = - data;
}
}
else
{
xd->segment_feature_data[j][i] = 0;
}
data = 0;
set_segdata(xd, i, j, data);
}
}
}
......
......@@ -16,9 +16,8 @@
#include "vpx_ports/mem.h"
#include "detokenize.h"
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#define BOOL_DATA UINT8
......@@ -651,7 +650,7 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd)
INT16 v;
const vp8_prob *Prob;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
int seg_eob = 16;
int segment_id = xd->mode_info_context->mbmi.segment_id;
......@@ -659,7 +658,6 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd)
{
seg_eob = xd->segment_feature_data[segment_id][SEG_LVL_EOB];
}
#endif
type = 3;
i = 0;
......@@ -701,10 +699,9 @@ BLOCK_LOOP:
Prob += v * ENTROPY_NODES;
DO_WHILE:
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( c == seg_eob )
goto BLOCK_FINISHED;
#endif
Prob += coef_bands_x[c];
DECODE_AND_BRANCH_IF_ZERO(Prob[EOB_CONTEXT_NODE], BLOCK_FINISHED);
......
......@@ -69,11 +69,10 @@ static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D
vpx_memcpy(mbd->segment_feature_data,
xd->segment_feature_data,
sizeof(xd->segment_feature_data));
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
vpx_memcpy(mbd->segment_feature_mask,
xd->segment_feature_mask,
sizeof(xd->segment_feature_mask));
#endif
/*signed char ref_lf_deltas[MAX_REF_LF_DELTAS];*/
vpx_memcpy(mbd->ref_lf_deltas, xd->ref_lf_deltas, sizeof(xd->ref_lf_deltas));
......
......@@ -25,9 +25,8 @@
#include "defaultcoefcounts.h"
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#if CONFIG_SEGMENTATION
static int segment_cost = 0;
......@@ -883,13 +882,10 @@ static void encode_ref_frame( vp8_writer *const w,
int prob_gf_coded )
{
int seg_ref_active;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
seg_ref_active = segfeature_active( xd,
segment_id,
SEG_LVL_REF_FRAME );
#else
seg_ref_active = 0;
#endif
// No segment features or segment reference frame featuure is disabled
if ( !seg_ref_active )
......@@ -913,7 +909,7 @@ static void encode_ref_frame( vp8_writer *const w,
}
}
}
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
else
{
if (rf == INTRA_FRAME)
......@@ -955,7 +951,6 @@ static void encode_ref_frame( vp8_writer *const w,
}
}
}
#endif
}
static void pack_inter_mode_mvs(VP8_COMP *const cpi)
......@@ -985,13 +980,12 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
cpi->mb.partition_info = cpi->mb.pi;
// Calculate the probabilities to be used to code the reference frame based on actual useage this frame
#if CONFIG_SEGFEATURES
// Calculate the probabilities to be used to code the reference frame
// based on actual useage this frame
//#if CONFIG_SEGFEATURES
cpi->prob_intra_coded = (rf_intra + rf_inter)
? rf_intra * 255 / (rf_intra + rf_inter) : 1;
#else
cpi->prob_intra_coded = rf_intra * 255 / (rf_intra + rf_inter);
#endif
if (!cpi->prob_intra_coded)
cpi->prob_intra_coded = 1;
......@@ -1111,13 +1105,10 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#endif
}
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( pc->mb_no_coeff_skip &&
( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
(xd->segment_feature_data[segment_id][SEG_LVL_EOB] != 0) ) )
#else
if (pc->mb_no_coeff_skip)
#endif
{
vp8_encode_bool(w, mi->mb_skip_coeff, prob_skip_false);
}
......@@ -1133,12 +1124,9 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
active_section = 6;
#endif
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
write_ymode(w, mode, pc->fc.ymode_prob);
#else
write_ymode(w, mode, pc->fc.ymode_prob);
#endif
if (mode == B_PRED)
{
......@@ -1172,15 +1160,13 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
active_section = 3;
#endif
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
// Is the segment coding of reference frame enabled
if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
{
write_mv_ref(w, mode, mv_ref_p);
}
#else
write_mv_ref(w, mode, mv_ref_p);
#endif
{
switch (mode) /* new, split require MVs */
{
......@@ -1268,9 +1254,8 @@ static void write_kfmodes(VP8_COMP *cpi)
int mb_row = -1;
int prob_skip_false = 0;
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
MACROBLOCKD *xd = &cpi->mb.e_mbd;
#endif
if (c->mb_no_coeff_skip)
{
......@@ -1332,13 +1317,10 @@ static void write_kfmodes(VP8_COMP *cpi)
#endif
}
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
if ( c->mb_no_coeff_skip &&
( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
(xd->segment_feature_data[segment_id][SEG_LVL_EOB] != 0) ) )
#else
if (c->mb_no_coeff_skip)
#endif
{
vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
}
......@@ -1591,12 +1573,10 @@ int vp8_estimate_entropy_savings(VP8_COMP *cpi)
if (cpi->common.frame_type != KEY_FRAME)
{
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
new_intra = (rf_intra + rf_inter)
? rf_intra * 255 / (rf_intra + rf_inter) : 1;
#else
new_intra = rf_intra * 255 / (rf_intra + rf_inter);
#endif
if (!new_intra)
new_intra = 1;
......@@ -1988,7 +1968,6 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
oh.version = pc->version;
oh.first_partition_length_in_bytes = 0;
mb_feature_data_bits = vp8_seg_feature_data_bits;
cx_data += 3;
#if defined(SECTIONBITS_OUTPUT)
......@@ -2049,59 +2028,44 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
vp8_write_bit(bc, (xd->mb_segement_abs_delta) ? 1 : 0);
#if CONFIG_SEGFEATURES
//#if CONFIG_SEGFEATURES
// For each segments id...
for (j = 0; j < MAX_MB_SEGMENTS; j++)
for (i = 0; i < MAX_MB_SEGMENTS; i++)
{
// For each segmentation codable feature...
for (i = 0; i < SEG_LVL_MAX; i++)
#else
// For each segmentation codable feature...
for (i = 0; i < SEG_LVL_MAX; i++)