[FFmpeg-cvslog] avcodec/exr: preserve half-float NaN bits and add fate test

Mark Reid git at videolan.org
Wed Dec 9 13:32:10 EET 2020


ffmpeg | branch: master | Mark Reid <mindmark at gmail.com> | Sun Nov 22 20:32:15 2020 -0800| [8d19b3c4a5176c181dc1751e08834193b549162c] | committer: Paul B Mahol

avcodec/exr: preserve half-float NaN bits and add fate test

Handles NaNs more like the official implementation handles them, preserving
the original bits.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d19b3c4a5176c181dc1751e08834193b549162c
---

 libavcodec/exr.c                                    | 3 +--
 tests/fate/image.mak                                | 2 ++
 tests/ref/fate/exr-rgb-scanline-zip-half-0x0-0xFFFF | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index d233dd43fb..6e6ce4275c 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -193,8 +193,7 @@ static union av_intfloat32 exr_half2float(uint16_t hf)
         // half-float NaNs will be converted to a single precision NaN
         // half-float Infs will be converted to a single precision Inf
         exp = FLOAT_MAX_BIASED_EXP;
-        if (mantissa)
-            mantissa = (1 << 23) - 1;    // set all bits to indicate a NaN
+        mantissa <<= 13; // preserve half-float NaN bits if set
     } else if (exp == 0x0) {
         // convert half-float zero/denorm to single precision value
         if (mantissa) {
diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 22072a62f1..c453f0f79c 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -317,6 +317,8 @@ fate-exr-rgb-scanline-half-zip-dw-outside: CMD = framecrc -i $(TARGET_SAMPLES)/e
 FATE_EXR += fate-exr-rgb-tile-half-zip-dw-outside
 fate-exr-rgb-tile-half-zip-dw-outside: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgb_tile_half_zip_dw_outside.exr -pix_fmt gbrpf32le
 
+FATE_EXR += fate-exr-rgb-scanline-zip-half-0x0-0xFFFF
+fate-exr-rgb-scanline-zip-half-0x0-0xFFFF: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgb_scanline_zip_half_float_0x0_to_0xFFFF.exr -pix_fmt gbrpf32le
 
 FATE_EXR-$(call DEMDEC, IMAGE2, EXR) += $(FATE_EXR)
 
diff --git a/tests/ref/fate/exr-rgb-scanline-zip-half-0x0-0xFFFF b/tests/ref/fate/exr-rgb-scanline-zip-half-0x0-0xFFFF
new file mode 100644
index 0000000000..b6201116fe
--- /dev/null
+++ b/tests/ref/fate/exr-rgb-scanline-zip-half-0x0-0xFFFF
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x256
+#sar 0: 1/1
+0,          0,          0,        1,   786432, 0x1445e411



More information about the ffmpeg-cvslog mailing list