diff options
author | John Koleszar <jkoleszar@google.com> | 2012-11-28 10:08:37 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2012-11-28 10:08:37 -0800 |
commit | 00e2c6bf7ac0c0bb0de2021987b4d4fbf5734d15 (patch) | |
tree | 416f5b7573de73d7d4fb4be1196d10f24756a2bf /vp9/encoder | |
parent | b07fcf5f6fdbd4679392ec51f8de597063f03afc (diff) | |
parent | a1f15814be0eb9921a6b5bb102354df7eeb936b2 (diff) | |
download | libvpx-00e2c6bf7ac0c0bb0de2021987b4d4fbf5734d15.tar libvpx-00e2c6bf7ac0c0bb0de2021987b4d4fbf5734d15.tar.gz libvpx-00e2c6bf7ac0c0bb0de2021987b4d4fbf5734d15.tar.bz2 libvpx-00e2c6bf7ac0c0bb0de2021987b4d4fbf5734d15.zip |
Merge "Clamp decoded feature data" into experimental
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_bitstream.c | 12 | ||||
-rw-r--r-- | vp9/encoder/vp9_boolhuff.c | 11 | ||||
-rw-r--r-- | vp9/encoder/vp9_boolhuff.h | 1 |
3 files changed, 17 insertions, 7 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index ae8a7c616..73c116766 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -1911,19 +1911,19 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, // Encode the relevant feature data if (Data < 0) { Data = - Data; - vp9_write_literal(&header_bc, Data, - vp9_seg_feature_data_bits(j)); + vp9_encode_unsigned_max(&header_bc, Data, + vp9_seg_feature_data_max(j)); vp9_write_bit(&header_bc, 1); } else { - vp9_write_literal(&header_bc, Data, - vp9_seg_feature_data_bits(j)); + vp9_encode_unsigned_max(&header_bc, Data, + vp9_seg_feature_data_max(j)); vp9_write_bit(&header_bc, 0); } } // Unsigned data element so no sign bit needed else - vp9_write_literal(&header_bc, Data, - vp9_seg_feature_data_bits(j)); + vp9_encode_unsigned_max(&header_bc, Data, + vp9_seg_feature_data_max(j)); } else vp9_write_bit(&header_bc, 0); } diff --git a/vp9/encoder/vp9_boolhuff.c b/vp9/encoder/vp9_boolhuff.c index 7619dfadf..2689ab601 100644 --- a/vp9/encoder/vp9_boolhuff.c +++ b/vp9/encoder/vp9_boolhuff.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include <assert.h> #include "vp9_boolhuff.h" #if defined(SECTIONBITS_OUTPUT) @@ -64,6 +64,15 @@ void vp9_encode_value(BOOL_CODER *br, int data, int bits) { encode_bool(br, (1 & (data >> bit)), 0x80); } +void vp9_encode_unsigned_max(BOOL_CODER *br, int data, int max) { + assert(data <= max); + while (max) { + encode_bool(br, data & 1, 128); + data >>= 1; + max >>= 1; + } +} + int vp9_recenter_nonneg(int v, int m) { if (v > (m << 1)) return v; else if (v >= m) return ((v - m) << 1); diff --git a/vp9/encoder/vp9_boolhuff.h b/vp9/encoder/vp9_boolhuff.h index 2fad86b2e..1958a41e1 100644 --- a/vp9/encoder/vp9_boolhuff.h +++ b/vp9/encoder/vp9_boolhuff.h @@ -37,6 +37,7 @@ typedef struct { extern void vp9_start_encode(BOOL_CODER *bc, unsigned char *buffer); extern void vp9_encode_value(BOOL_CODER *br, int data, int bits); +extern void vp9_encode_unsigned_max(BOOL_CODER *br, int data, int max); extern void vp9_stop_encode(BOOL_CODER *bc); extern const unsigned int vp9_prob_cost[256]; |