diff options
Diffstat (limited to 'vp8/common')
-rw-r--r-- | vp8/common/blockd.h | 2 | ||||
-rw-r--r-- | vp8/common/loopfilter.c | 27 | ||||
-rw-r--r-- | vp8/common/seg_common.c | 55 | ||||
-rw-r--r-- | vp8/common/seg_common.h | 34 |
4 files changed, 105 insertions, 13 deletions
diff --git a/vp8/common/blockd.h b/vp8/common/blockd.h index 782e0a987..27bc25314 100644 --- a/vp8/common/blockd.h +++ b/vp8/common/blockd.h @@ -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 diff --git a/vp8/common/loopfilter.c b/vp8/common/loopfilter.c index a8855531e..56baca809 100644 --- a/vp8/common/loopfilter.c +++ b/vp8/common/loopfilter.c @@ -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; diff --git a/vp8/common/seg_common.c b/vp8/common/seg_common.c new file mode 100644 index 000000000..ef77dfc53 --- /dev/null +++ b/vp8/common/seg_common.c @@ -0,0 +1,55 @@ +/* + * 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" + +const int segfeaturedata_signed[SEG_LVL_MAX] = {1, 1, 0, 0, 0, 0}; + + +// 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 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 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); +} + +int is_segfeature_signed( SEG_LVL_FEATURES feature_id ) +{ + return ( segfeaturedata_signed[feature_id] ); +} + +// TBD? Functions to read and write segment data with range / validity checking
\ No newline at end of file diff --git a/vp8/common/seg_common.h b/vp8/common/seg_common.h new file mode 100644 index 000000000..cea16c885 --- /dev/null +++ b/vp8/common/seg_common.h @@ -0,0 +1,34 @@ +/* + * 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 clearall_segfeatures( MACROBLOCKD *xd ); + +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 ); + +int is_segfeature_signed( SEG_LVL_FEATURES feature_id ); + +#endif /* __INC_SEG_COMMON_H__ */ + |