Commit 01ce04bc authored by Paul Wilkins's avatar Paul Wilkins

Further segment feature extensions.

This quite large check in includes the following:

Merge in some code from Ronald (mbgraph.c) that scans a Gf/arf group.
This is used as a basis for a simple segmentation for the normal frames
in a gf/arf group. This code also uses satd functions from Yaowu.

Adds functionality for coding the latest possible position of an EOB for
blocks in the segment. (Currently 0-15 only, hence just for 4x4 dct).
Where the EOB position is 0 this acts like "skip" and the normal coding
of skip at the per mb level is disabled.

Added functions (seg_common.c) for setting and reading segment feature
elements. These may want to be optimized away at some point but while the
mecahnism is in a state of flux they provide a single location for making
changes and keep things a bit cleaner.

This is still proof of concept code. Currently the tested feature set:-

Quantizer,
Loop Filter level,
Reference frame,
Prediction Mode,
EOB end stop.

TBD:-

Add functions for setting and reading the feature data with range
and validity checking.

Handling of signed and unsigned feature data. At the moment all is assumed
to be signed and a sign bit is coded but many cannot be negative.

Correct handling of EOB feature with intra coded blocks.

Testing/trapping of legal/illegal ref frame and mode combinations.

Transform size switch plus merge and test with 8c8 DCT work

Merge and test with Sumans Segmenation coding optimizations

Change-Id: Iee12e83661c7abbd1e0ce6810915eb4ec35e2d8e
parent 152ce6b2
......@@ -108,7 +108,7 @@ typedef enum
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 = 6, // Block transform size.
SEG_LVL_TRANSFORM = 5, // Block transform size.
SEG_LVL_MAX = 6 // Number of MB level features supported
#else
......
......@@ -14,6 +14,10 @@
#include "onyxc_int.h"
#include "vpx_mem/vpx_mem.h"
#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
typedef unsigned char uc;
prototype_loopfilter(vp8_loop_filter_horizontal_edge_c);
......@@ -194,7 +198,7 @@ void vp8_loop_filter_init(VP8_COMMON *cm)
}
void vp8_loop_filter_frame_init(VP8_COMMON *cm,
MACROBLOCKD *mbd,
MACROBLOCKD *xd,
int default_filt_lvl)
{
int seg, /* segment number */
......@@ -218,25 +222,24 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
// Set the baseline filter values for each segment
#if CONFIG_SEGFEATURES
if ( mbd->segmentation_enabled &&
( mbd->segment_feature_mask[seg] & (1 << SEG_LVL_ALT_LF) ) )
if ( segfeature_active( xd, seg, SEG_LVL_ALT_LF ) )
#else
if ( mbd->segmentation_enabled )
if ( xd->segmentation_enabled )
#endif
{
/* Abs value */
if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
{
lvl_seg = mbd->segment_feature_data[seg][SEG_LVL_ALT_LF];
lvl_seg = xd->segment_feature_data[seg][SEG_LVL_ALT_LF];
}
else /* Delta Value */
{
lvl_seg += mbd->segment_feature_data[seg][SEG_LVL_ALT_LF];
lvl_seg += xd->segment_feature_data[seg][SEG_LVL_ALT_LF];
lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
}
}
if (!mbd->mode_ref_lf_delta_enabled)
if (!xd->mode_ref_lf_delta_enabled)
{
/* we could get rid of this if we assume that deltas are set to
* zero when not in use; encoder always uses deltas
......@@ -251,12 +254,12 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
ref = INTRA_FRAME;
/* Apply delta for reference frame */
lvl_ref += mbd->ref_lf_deltas[ref];
lvl_ref += xd->ref_lf_deltas[ref];
/* Apply delta for Intra modes */
mode = 0; /* B_PRED */
/* Only the split mode BPRED has a further special case */
lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode];
lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
lfi->lvl[seg][ref][mode] = lvl_mode;
......@@ -271,12 +274,12 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
int lvl_ref = lvl_seg;
/* Apply delta for reference frame */
lvl_ref += mbd->ref_lf_deltas[ref];
lvl_ref += xd->ref_lf_deltas[ref];
/* Apply delta for Inter modes */
for (mode = 1; mode < 4; mode++)
{
lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode];
lvl_mode = lvl_ref + xd->mode_lf_deltas[mode];
lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
lfi->lvl[seg][ref][mode] = lvl_mode;
......
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vp8/common/seg_common.h"
// These functions provide access to new segment level features.
// Eventually these function may be "optimized out" but for the moment,
// the coding mechanism is still subject to change so these provide a
// convenient single point of change.
int segfeature_active( MACROBLOCKD *xd,
int segment_id,
SEG_LVL_FEATURES feature_id )
{
// Return true if mask bit set and segmentation enabled.
return ( xd->segmentation_enabled &&
( xd->segment_feature_mask[segment_id] &
(0x01 << feature_id) ) );
}
void enable_segfeature( MACROBLOCKD *xd,
int segment_id,
SEG_LVL_FEATURES feature_id )
{
xd->segment_feature_mask[segment_id] |= (0x01 << feature_id);
}
void disable_segfeature( MACROBLOCKD *xd,
int segment_id,
SEG_LVL_FEATURES feature_id )
{
xd->segment_feature_mask[segment_id] &= ~(1 << feature_id);
}
// TBD? Functions to read and write segment data with range / validity checking
\ No newline at end of file
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "type_aliases.h"
#include "vp8/common/blockd.h"
#ifndef __INC_SEG_COMMON_H__
#define __INC_SEG_COMMON_H__ 1
int segfeature_active( MACROBLOCKD *xd,
int segment_id,
SEG_LVL_FEATURES feature_id );
void enable_segfeature( MACROBLOCKD *xd,
int segment_id,
SEG_LVL_FEATURES feature_id );
void disable_segfeature( MACROBLOCKD *xd,
int segment_id,
SEG_LVL_FEATURES feature_id );
#endif /* __INC_SEG_COMMON_H__ */
......@@ -15,6 +15,14 @@
#include "onyxd_int.h"
#include "vp8/common/findnearmv.h"
#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#if CONFIG_SEGMENTATION
#include "vp8/common/seg_common.h"
#endif
#if CONFIG_DEBUG
#include <assert.h>
#endif
......@@ -85,11 +93,33 @@ 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);
/* Read the macroblock coeff skip flag if this feature is in use, else default to 0 */
#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
m->mbmi.mb_skip_coeff = 0;
{
#if CONFIG_SEGFEATURES
if ( segfeature_active( &pbi->mb,
m->mbmi.segment_id, SEG_LVL_EOB ) &&
(pbi->mb.segment_feature_data[m->mbmi.segment_id]
[SEG_LVL_EOB] == 0) )
{
m->mbmi.mb_skip_coeff = 1;
}
else
#endif
m->mbmi.mb_skip_coeff = 0;
}
#if CONFIG_QIMODE
y_mode = (MB_PREDICTION_MODE) vp8_kfread_ymode(bc,
pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]);
......@@ -210,7 +240,7 @@ static MV_REFERENCE_FRAME read_ref_frame( VP8D_COMP *pbi,
MACROBLOCKD *const xd = &pbi->mb;
// Is the segment level refernce frame feature enabled for this segment
if ( xd->segment_feature_mask[segment_id] & (0x01 << SEG_LVL_REF_FRAME) )
if ( segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) )
{
ref_frame =
xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME];
......@@ -398,12 +428,34 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
#endif
}
/* Read the macroblock coeff skip flag if this feature is in use, else default to 0 */
#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
mbmi->mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
}
else
mbmi->mb_skip_coeff = 0;
{
#if CONFIG_SEGFEATURES
if ( segfeature_active( xd,
mbmi->segment_id, SEG_LVL_EOB ) &&
(xd->segment_feature_data[mbmi->segment_id]
[SEG_LVL_EOB] == 0) )
{
mbmi->mb_skip_coeff = 1;
}
else
#endif
mbmi->mb_skip_coeff = 0;
}
// Read the reference frame
mbmi->ref_frame = read_ref_frame( pbi, mbmi->segment_id );
......@@ -421,8 +473,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
#if CONFIG_SEGFEATURES
// Is the segment level mode feature enabled for this segment
if ( xd->segment_feature_mask[mbmi->segment_id] &
(0x01 << SEG_LVL_MODE) )
if ( segfeature_active( xd, mbmi->segment_id, SEG_LVL_MODE ) )
{
mbmi->mode =
xd->segment_feature_data[mbmi->segment_id][SEG_LVL_MODE];
......
......@@ -37,6 +37,10 @@
#include "decoderthreading.h"
#include "dboolhuff.h"
#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#include <assert.h>
#include <stdio.h>
......@@ -78,8 +82,7 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd)
// Set the Q baseline allowing for any segment level adjustment
#if CONFIG_SEGFEATURES
if ( xd->segmentation_enabled &&
( xd->segment_feature_mask[segment_id] & (1 << SEG_LVL_ALT_Q) ) )
if ( segfeature_active( xd, segment_id, SEG_LVL_ALT_Q ) )
#else
if ( xd->segmentation_enabled )
#endif
......@@ -1056,9 +1059,8 @@ int vp8_decode_frame(VP8D_COMP *pbi)
{
#if CONFIG_SEGFEATURES
// Update the feature data and mask
xd->segment_feature_mask[j] |= (1 << i);
enable_segfeature(xd, j, i);
#endif
xd->segment_feature_data[j][i] = (signed char)vp8_read_literal(bc, mb_feature_data_bits[i]);
if (vp8_read_bit(bc))
......
......@@ -16,6 +16,10 @@
#include "vpx_ports/mem.h"
#include "detokenize.h"
#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#define BOOL_DATA UINT8
#define OCB_X PREV_COEF_CONTEXTS * ENTROPY_NODES
......@@ -611,15 +615,15 @@ BLOCK_FINISHED_8x8:
}
#endif
int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x)
int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd)
{
ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context;
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)xd->left_context;
const FRAME_CONTEXT * const fc = &dx->common.fc;
BOOL_DECODER *bc = x->current_bc;
BOOL_DECODER *bc = xd->current_bc;
char *eobs = x->eobs;
char *eobs = xd->eobs;
ENTROPY_CONTEXT *a;
ENTROPY_CONTEXT *l;
......@@ -647,17 +651,27 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x)
INT16 v;
const vp8_prob *Prob;
#if CONFIG_SEGFEATURES
int seg_eob = 16;
int segment_id = xd->mode_info_context->mbmi.segment_id;
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
{
seg_eob = xd->segment_feature_data[segment_id][SEG_LVL_EOB];
}
#endif
type = 3;
i = 0;
stop = 16;
scan = vp8_default_zig_zag1d;
qcoeff_ptr = &x->qcoeff[0];
if (x->mode_info_context->mbmi.mode != B_PRED &&
qcoeff_ptr = &xd->qcoeff[0];
if (xd->mode_info_context->mbmi.mode != B_PRED &&
#if CONFIG_I8X8
x->mode_info_context->mbmi.mode != I8X8_PRED &&
xd->mode_info_context->mbmi.mode != I8X8_PRED &&
#endif
x->mode_info_context->mbmi.mode != SPLITMV)
xd->mode_info_context->mbmi.mode != SPLITMV)
{
i = 24;
stop = 24;
......@@ -687,6 +701,11 @@ BLOCK_LOOP:
Prob += v * ENTROPY_NODES;
DO_WHILE:
#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);
......
......@@ -24,9 +24,15 @@
#include "bitstream.h"
#include "defaultcoefcounts.h"
#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#if CONFIG_SEGMENTATION
static int segment_cost = 0;
#endif
const int vp8cx_base_skip_false_prob[128] =
{
255, 255, 255, 255, 255, 255, 255, 255,
......@@ -954,6 +960,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
const MB_MODE_INFO *const mi = & m->mbmi;
const MV_REFERENCE_FRAME rf = mi->ref_frame;
const MB_PREDICTION_MODE mode = mi->mode;
const int segment_id = mi->segment_id;
//MACROBLOCKD *xd = &cpi->mb.e_mbd;
......@@ -973,7 +980,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#ifdef MODE_STATS
#if CONFIG_SEGMENTATION
segment_modes_inter[mi->segment_id]++;
segment_modes_inter[segment_id]++;
#endif
#endif
if (cpi->mb.e_mbd.update_mb_segmentation_map)
......@@ -997,13 +1004,13 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
vp8_write(w,1,xd->mb_segment_tree_probs[3+sum]);
segment_cost += vp8_cost_one(xd->mb_segment_tree_probs[3+sum]);
write_mb_features(w, mi, &cpi->mb.e_mbd);
cpi->segmentation_map[index] = mi->segment_id;
cpi->segmentation_map[index] = segment_id;
}
}
else
{
write_mb_features(w, mi, &cpi->mb.e_mbd);
cpi->segmentation_map[index] = mi->segment_id;
cpi->segmentation_map[index] = segment_id;
}
index++;
#else
......@@ -1011,15 +1018,22 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#endif
}
#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)
vp8_encode_bool(w, m->mbmi.mb_skip_coeff, prob_skip_false);
#endif
{
vp8_encode_bool(w, mi->mb_skip_coeff, prob_skip_false);
}
if (rf == INTRA_FRAME)
{
#if CONFIG_SEGFEATURES
// Is the segment coding of reference frame enabled
if ( !( xd->segment_feature_mask[mi->segment_id] &
(0x01 << SEG_LVL_REF_FRAME) ) )
if ( !segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) )
#endif
{
vp8_write(w, 0, cpi->prob_intra_coded);
......@@ -1047,9 +1061,8 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
vp8_prob mv_ref_p [VP8_MVREFS-1];
#if CONFIG_SEGFEATURES
// Is the segment coding of reference frame enabled
if ( !( xd->segment_feature_mask[mi->segment_id] &
(0x01 << SEG_LVL_REF_FRAME) ) )
// Test to see if segment level coding of ref frame is enabled
if ( !segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) )
#endif
{
vp8_write(w, 1, cpi->prob_intra_coded);
......@@ -1082,8 +1095,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#if CONFIG_SEGFEATURES
// Is the segment coding of reference frame enabled
if ( !( xd->segment_feature_mask[mi->segment_id] &
(0x01 << SEG_LVL_MODE) ) )
if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
#endif
{
write_mv_ref(w, mode, mv_ref_p);
......@@ -1174,6 +1186,10 @@ static void write_kfmodes(VP8_COMP *cpi)
int mb_row = -1;
int prob_skip_false = 0;
#if CONFIG_SEGFEATURES
MACROBLOCKD *xd = &cpi->mb.e_mbd;
#endif
if (c->mb_no_coeff_skip)
{
prob_skip_false = cpi->skip_false_count * 256 / (cpi->skip_false_count + cpi->skip_true_count);
......@@ -1202,6 +1218,8 @@ static void write_kfmodes(VP8_COMP *cpi)
while (++mb_col < c->mb_cols)
{
const int ym = m->mbmi.mode;
int segment_id = m->mbmi.segment_id;
#if CONFIG_SEGMENTATION
MACROBLOCKD *xd = &cpi->mb.e_mbd;
xd->up_available = (mb_row != 0);
......@@ -1209,7 +1227,7 @@ static void write_kfmodes(VP8_COMP *cpi)
#endif
#ifdef MODE_STATS
#if CONFIG_SEGMENTATION
segment_modes_intra[m->mbmi.segment_id]++;
segment_modes_intra[segment_id]++;
#endif
#endif
......@@ -1218,15 +1236,23 @@ static void write_kfmodes(VP8_COMP *cpi)
#if CONFIG_SEGMENTATION
write_mb_features(bc, &m->mbmi, &cpi->mb.e_mbd);
cpi->segmentation_map[index] = m->mbmi.segment_id;
cpi->segmentation_map[index] = segment_id;
index++;
#else
write_mb_features(bc, &m->mbmi, &cpi->mb.e_mbd);
#endif
}
#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);
}
#if CONFIG_QIMODE
kfwrite_ymode(bc, ym, c->kf_ymode_prob[c->kf_ymode_probs_index]);
#else
......@@ -1952,7 +1978,7 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
#if CONFIG_SEGFEATURES
// If the feature is enabled...
if ( xd->segment_feature_mask[j] & (0x01 << i))
if ( segfeature_active( xd, j, i ) )
#else
// If the feature is enabled...Indicated by non zero
// value in VP8
......
......@@ -46,8 +46,9 @@ typedef struct
int src;
int src_stride;
// MV enc_mv;
int force_empty;
#if CONFIG_SEGFEATURES
int eob_max_offset;
#endif
} BLOCK;
......
......@@ -31,6 +31,9 @@
#include "vp8/common/subpixel.h"
#include "vpx_ports/vpx_timer.h"
#if CONFIG_SEGFEATURES
//#define DBG_PRNT_SEGMAP 1
#endif
#if CONFIG_RUNTIME_CPU_DETECT
#define RTCD(x) &cpi->common.rtcd.x
......@@ -750,18 +753,7 @@ void encode_mb_row(VP8_COMP *cpi,
else
cpi->cyclic_refresh_map[map_index+mb_col] = 1;
}
#if CONFIG_SEGFEATURES
else if ( cm->refresh_alt_ref_frame &&
(cm->frame_type != KEY_FRAME) )
{
// Update the global segmentation map to reflect
// the segment choice made for this MB.
cpi->segmentation_map[map_index+mb_col] =
xd->mode_info_context->mbmi.segment_id;
}
#endif
}
}
cpi->tplist[mb_row].stop = *tp;
......@@ -856,7 +848,7 @@ void encode_mb_row(VP8_COMP *cpi,
#if CONFIG_SEGFEATURES
// debug output
#if 0
#if DBG_PRNT_SEGMAP
{
FILE *statsfile;
statsfile = fopen("segmap2.stt", "a");
......@@ -867,30 +859,6 @@ void encode_mb_row(VP8_COMP *cpi,
#endif
}
#if CONFIG_SEGFEATURES
// Funtion to test out new segment features
void segfeature_test_function(VP8_COMP *cpi, MACROBLOCKD * xd)
{
VP8_COMMON *const cm = & cpi->common;
// Only update segment map for a frame that is an arf but not a kf.
if ( cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME) )
{
// Test code to code features at the segment level
if ( (xd->mode_info_context->mbmi.mode ==
cpi->segment_feature_data[1][SEG_LVL_MODE]) &&
(xd->mode_info_context->mbmi.ref_frame ==
cpi->segment_feature_data[1][SEG_LVL_REF_FRAME]) )
{
xd->mode_info_context->mbmi.segment_id = 1;
}
else
xd->mode_info_context->mbmi.segment_id = 0;
}
}
#endif
void init_encode_frame_mb_context(VP8_COMP *cpi)
{
MACROBLOCK *const x = & cpi->mb;
......@@ -1695,8 +1663,8 @@ int vp8cx_encode_inter_macroblock
#if CONFIG_SEGFEATURES
else
{
segfeature_test_function(cpi, xd);
#if 0
//segfeature_test_function(cpi, xd);
#if DBG_PRNT_SEGMAP
// Debug output
{
FILE *statsfile;
......
......@@ -355,9 +355,10 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
/*
z->block[i].src = x->block[i].src;
*/
z->block[i].src_stride = x->block[i].src_stride;
z->block[i].force_empty = x->block[i].force_empty;
z->block[i].src_stride = x->block[i].src_stride;
#if CONFIG_SEGFEATURES
z->block[i].eob_max_offset = x->block[i].eob_max_offset;
#endif
}
{
......
......@@ -110,7 +110,7 @@ void vp8_cmachine_specific_config(VP8_COMP *cpi)
#endif
#endif
// Pure C:
cpi->rtcd.variance.satd16x16 = vp8_satd16x16_c;
vp8_yv12_copy_partial_frame_ptr = vp8_yv12_copy_partial_frame;
#if ARCH_X86 || ARCH_X86_64
......
This diff is collapsed.
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef __INC_MBGRAPH_H__
#define __INC_MBGRAPH_H__ 1
extern void vp8_update_mbgraph_stats(VP8_COMP *cpi);
#endif /* __INC_MBGRAPH_H__ */
This diff is collapsed.
......@@ -133,6 +133,21 @@ typedef struct
} ONEPASS_FRAMESTATS;
typedef struct
{
struct {
int err;
union {
int_mv mv;
MB_PREDICTION_MODE mode;
} m;
} ref[MAX_REF_FRAMES];
} MBGRAPH_MB_STATS;
typedef struct
{
MBGRAPH_MB_STATS *mb_stats;
} MBGRAPH_FRAME_STATS;
typedef enum
{
......@@ -431,6 +446,13 @@ typedef struct VP8_COMP
ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
int one_pass_frame_index;
#endif
MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
int mbgraph_n_frames; // number of frames filled in the above
int mbgraph_use_arf_segmentation; // set if part of an ARF is considered to be a
// poor predictor, and thus coeffs are skipped
// or coded at a higher Q using MB-segmentation
// this value is the number of MBs that are
// poor predictors (> 0 and < common.MBs)
int decimation_factor;
int decimation_count;
......@@ -483,12 +505,6 @@ typedef struct VP8_COMP
unsigned char *segmentation_map;
// Segment data (can be deltas or absolute values)
signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
#if CONFIG_SEGFEATURES
unsigned int segment_feature_mask[MAX_MB_SEGMENTS];
#endif
// segment threashold for encode breakout
int segment_encode_breakout[MAX_MB_SEGMENTS];
......
......@@ -27,6 +27,10 @@
#include "rdopt.h"
#include "vpx_mem/vpx_mem.h"
#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
#endif
#if CONFIG_RUNTIME_CPU_DETECT
#define IF_RTCD(x) (x)
#else
......@@ -517,21 +521,19 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
#if CONFIG_SEGFEATURES
// Experimental use of Segment features.
if ( !cm->refresh_alt_ref_frame )
if ( xd->segmentation_enabled && !cm->refresh_alt_ref_frame )
{
unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;