From: Mark Reid <mindm...@gmail.com> Hi, This patch handles NaNs more like the offical implentation handles them, preserving the original bits.
https://github.com/AcademySoftwareFoundation/openexr/blob/RB-2.5/IlmBase/Half/toFloat.cpp#L111 It also adds a fate test that is a 256x256 exr containing all possible 16bit half-float values. Here is a link to download the fate test file, if someone could add it to fate me https://www.dropbox.com/s/2q4jg8w489aunsf/rgb_scanline_zip_half_float_0x0_to_0xFFFF.exr --- 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(-) create mode 100644 tests/ref/fate/exr-rgb-scanline-zip-half-0x0-0xFFFF 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 -- 2.29.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".