diff options
author | Ronald S. Bultje <rbultje@google.com> | 2012-12-10 12:09:07 -0800 |
---|---|---|
committer | Ronald S. Bultje <rbultje@google.com> | 2012-12-12 10:01:19 -0800 |
commit | 4d0ec7aacd2227b1b98d1f5100bde64c7797b962 (patch) | |
tree | 5e2e16ade1e5a05e66108f43ab992c8632b69fc1 /vp9/decoder | |
parent | d1244659757ff64212f7beebc6c8e45909d5113c (diff) | |
download | libvpx-4d0ec7aacd2227b1b98d1f5100bde64c7797b962.tar libvpx-4d0ec7aacd2227b1b98d1f5100bde64c7797b962.tar.gz libvpx-4d0ec7aacd2227b1b98d1f5100bde64c7797b962.tar.bz2 libvpx-4d0ec7aacd2227b1b98d1f5100bde64c7797b962.zip |
Consistently use get_prob(), clip_prob() and newly added clip_pixel().
Add a function clip_pixel() to clip a pixel value to the [0,255] range
of allowed values, and use this where-ever appropriate (e.g. prediction,
reconstruction). Likewise, consistently use the recently added function
clip_prob(), which calculates a binary probability in the [1,255] range.
If possible, try to use get_prob() or its sister get_binary_prob() to
calculate binary probabilities, for consistency.
Since in some places, this means that binary probability calculations
are changed (we use {255,256}*count0/(total) in a range of places,
and all of these are now changed to use 256*count0+(total>>1)/total),
this changes the encoding result, so this patch warrants some extensive
testing.
Change-Id: Ibeeff8d886496839b8e0c0ace9ccc552351f7628
Diffstat (limited to 'vp9/decoder')
-rw-r--r-- | vp9/decoder/vp9_dequantize.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/vp9/decoder/vp9_dequantize.c b/vp9/decoder/vp9_dequantize.c index 22a66716f..9e382914b 100644 --- a/vp9/decoder/vp9_dequantize.c +++ b/vp9/decoder/vp9_dequantize.c @@ -13,6 +13,7 @@ #include "vp9/decoder/vp9_dequantize.h" #include "vpx_mem/vpx_mem.h" #include "vp9/decoder/vp9_onyxd_int.h" +#include "vp9/common/vp9_common.h" static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch, uint8_t *dest, int stride, int width, int height) { @@ -20,14 +21,7 @@ static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch, for (r = 0; r < height; r++) { for (c = 0; c < width; c++) { - int a = diff[c] + pred[c]; - - if (a < 0) - a = 0; - else if (a > 255) - a = 255; - - dest[c] = (uint8_t) a; + dest[c] = clip_pixel(diff[c] + pred[c]); } dest += stride; @@ -43,14 +37,7 @@ static void add_constant_residual(const int16_t diff, const uint8_t *pred, for (r = 0; r < height; r++) { for (c = 0; c < width; c++) { - int a = diff + pred[c]; - - if (a < 0) - a = 0; - else if (a > 255) - a = 255; - - dest[c] = (uint8_t) a; + dest[c] = clip_pixel(diff + pred[c]); } dest += stride; |