summaryrefslogtreecommitdiff
path: root/libavcodec/flashsv2enc.c
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-09-16 14:48:16 -0400
committerMichael Niedermayer <michael@niedermayer.cc>2015-09-18 22:42:38 +0200
commit0fe1c50e505125cf2b026d810458bc5cbc242792 (patch)
tree50569c6d05c686c15aca5415cda7587da77ce296 /libavcodec/flashsv2enc.c
parente47564828b9b351f874f24d66306294b7741b768 (diff)
all: do standards compliant absdiff computation
This resolves implementation defined behavior, and also silences -Wabsolute-value in clang 3.5+. Moreover, the generated asm is identical to before modulo nop padding. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/flashsv2enc.c')
-rw-r--r--libavcodec/flashsv2enc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
index c2c00f4916..65db112696 100644
--- a/libavcodec/flashsv2enc.c
+++ b/libavcodec/flashsv2enc.c
@@ -412,12 +412,14 @@ static inline unsigned pixel_color15(const uint8_t * src)
static inline unsigned int chroma_diff(unsigned int c1, unsigned int c2)
{
+#define ABSDIFF(a,b) (abs((int)(a)-(int)(b)))
+
unsigned int t1 = (c1 & 0x000000ff) + ((c1 & 0x0000ff00) >> 8) + ((c1 & 0x00ff0000) >> 16);
unsigned int t2 = (c2 & 0x000000ff) + ((c2 & 0x0000ff00) >> 8) + ((c2 & 0x00ff0000) >> 16);
- return abs(t1 - t2) + abs((c1 & 0x000000ff) - (c2 & 0x000000ff)) +
- abs(((c1 & 0x0000ff00) >> 8) - ((c2 & 0x0000ff00) >> 8)) +
- abs(((c1 & 0x00ff0000) >> 16) - ((c2 & 0x00ff0000) >> 16));
+ return ABSDIFF(t1, t2) + ABSDIFF(c1 & 0x000000ff, c2 & 0x000000ff) +
+ ABSDIFF((c1 & 0x0000ff00) >> 8 , (c2 & 0x0000ff00) >> 8) +
+ ABSDIFF((c1 & 0x00ff0000) >> 16, (c2 & 0x00ff0000) >> 16);
}
static inline int pixel_color7_fast(Palette * palette, unsigned c15)