From 47435a61622c7ca713187f70cdd5e4c460e5934e Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 10 May 2016 19:34:04 +0200 Subject: [PATCH] add VP8LAddPixels() to lossless.h Change-Id: I67f9118f875affa32c47adfedf9df28b0ac9957b --- src/dsp/lossless.c | 4 +--- src/dsp/lossless.h | 9 ++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index 71ae9d4a..af913efc 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -28,9 +28,7 @@ // In-place sum of each component with mod 256. static WEBP_INLINE void AddPixelsEq(uint32_t* a, uint32_t b) { - const uint32_t alpha_and_green = (*a & 0xff00ff00u) + (b & 0xff00ff00u); - const uint32_t red_and_blue = (*a & 0x00ff00ffu) + (b & 0x00ff00ffu); - *a = (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); + *a = VP8LAddPixels(*a, b); } static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) { diff --git a/src/dsp/lossless.h b/src/dsp/lossless.h index 33d5d767..e5ed59b3 100644 --- a/src/dsp/lossless.h +++ b/src/dsp/lossless.h @@ -329,7 +329,14 @@ static WEBP_INLINE void VP8LPrefixEncode(int distance, int* const code, } } -// In-place difference of each component with mod 256. +// Sum of each component, mod 256. +static WEBP_INLINE uint32_t VP8LAddPixels(uint32_t a, uint32_t b) { + const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u); + const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu); + return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); +} + +// Difference of each component with mod 256. static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) { const uint32_t alpha_and_green = 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);