diff options
author | John Koleszar <jkoleszar@google.com> | 2012-11-27 11:16:15 -0800 |
---|---|---|
committer | John Koleszar <jkoleszar@google.com> | 2012-11-27 16:38:31 -0800 |
commit | a1f15814be0eb9921a6b5bb102354df7eeb936b2 (patch) | |
tree | e854df01ab8110d6bf52370fae3caa9444386d1f /vp9/common | |
parent | 1760c39bcee3a6fc8e5998619bc7970755b528f6 (diff) | |
download | libvpx-a1f15814be0eb9921a6b5bb102354df7eeb936b2.tar libvpx-a1f15814be0eb9921a6b5bb102354df7eeb936b2.tar.gz libvpx-a1f15814be0eb9921a6b5bb102354df7eeb936b2.tar.bz2 libvpx-a1f15814be0eb9921a6b5bb102354df7eeb936b2.zip |
Clamp decoded feature data
Not all segment feature data elements are full-range powers of two, so
there are values that can be encoded that are invalid. Add a new function
to clamp values to the maximum allowed.
Change-Id: Ie47cb80ef2d54292e6b8db9f699c57214a915bc4
Diffstat (limited to 'vp9/common')
-rw-r--r-- | vp9/common/vp9_seg_common.c | 16 | ||||
-rw-r--r-- | vp9/common/vp9_seg_common.h | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/vp9/common/vp9_seg_common.c b/vp9/common/vp9_seg_common.c index 6ac27e396..46a6ee454 100644 --- a/vp9/common/vp9_seg_common.c +++ b/vp9/common/vp9_seg_common.c @@ -8,11 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <assert.h> +#include "vp9/common/vp9_blockd.h" #include "vp9/common/vp9_seg_common.h" static const int segfeaturedata_signed[SEG_LVL_MAX] = { 1, 1, 0, 0, 0, 0 }; -static const int seg_feature_data_bits[SEG_LVL_MAX] = - { QINDEX_BITS, 6, 4, 5, 8, 2 }; +static const int seg_feature_data_max[SEG_LVL_MAX] = + { MAXQ, 63, 0xf, MB_MODE_COUNT - 1, 255, TX_SIZE_MAX - 1}; // These functions provide access to new segment level features. // Eventually these function may be "optimized out" but for the moment, @@ -45,8 +47,8 @@ void vp9_disable_segfeature(MACROBLOCKD *xd, xd->segment_feature_mask[segment_id] &= ~(1 << feature_id); } -int vp9_seg_feature_data_bits(SEG_LVL_FEATURES feature_id) { - return seg_feature_data_bits[feature_id]; +int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id) { + return seg_feature_data_max[feature_id]; } int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id) { @@ -63,6 +65,12 @@ void vp9_set_segdata(MACROBLOCKD *xd, int segment_id, SEG_LVL_FEATURES feature_id, int seg_data) { + assert(seg_data <= seg_feature_data_max[feature_id]); + if (seg_data < 0) { + assert(segfeaturedata_signed[feature_id]); + assert(-seg_data <= seg_feature_data_max[feature_id]); + } + xd->segment_feature_data[segment_id][feature_id] = seg_data; } diff --git a/vp9/common/vp9_seg_common.h b/vp9/common/vp9_seg_common.h index fb0570c6b..20959a705 100644 --- a/vp9/common/vp9_seg_common.h +++ b/vp9/common/vp9_seg_common.h @@ -29,7 +29,7 @@ void vp9_disable_segfeature(MACROBLOCKD *xd, int segment_id, SEG_LVL_FEATURES feature_id); -int vp9_seg_feature_data_bits(SEG_LVL_FEATURES feature_id); +int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id); int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id); |