From 5385ed8d8d258e68474e3ff24b601fd9ae595677 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Sun, 23 Apr 2017 17:57:53 +0200
Subject: [PATCH 2/2] libavcodec/exr : fix float to uint16 conversion for
 negative value

the previous hack doesn't seems to work
so add an explicit sign check
---
 libavcodec/exr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 7194640..0e69a8d 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -223,9 +223,9 @@ static union av_intfloat32 exr_half2float(uint16_t hf)
 static inline uint16_t exr_flt2uint(uint32_t v)
 {
     unsigned int exp = v >> 23;
-    // "HACK": negative values result in exp<  0, so clipping them to 0
-    // is also handled by this condition, avoids explicit check for sign bit.
-    if (exp <= 127 + 7 - 24) // we would shift out all bits anyway
+    if (v >> 31 == 1)/* clamp negative value to 0*/
+        return 0;
+    if (exp <= 127 + 7 - 24)
         return 0;
     if (exp >= 127)
         return 0xffff;
-- 
1.9.3 (Apple Git-50)

