From 082cc20e64d7ad41a575cd01571aaeeb4fe485c5 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Fri, 27 Aug 2021 08:47:00 +1200 Subject: [PATCH 1/2] Fix ECX register access Signed-off-by: Kimball Thurston --- src/lib/OpenEXRCore/unpack.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/OpenEXRCore/unpack.c b/src/lib/OpenEXRCore/unpack.c index ecb77d6a11..f5db38dda7 100644 --- a/src/lib/OpenEXRCore/unpack.c +++ b/src/lib/OpenEXRCore/unpack.c @@ -144,11 +144,13 @@ static void (*half_to_float_buffer) (float*, const uint16_t*, int) = static void choose_half_to_float_impl () { + // regs[2] in the extended block is ECX, where f16c indicator lives # ifdef _WIN32 int regs[4]; __cpuid (regs, 0); if (regs[0] >= 1) { __cpuidex (regs, 1, 0); } + else regs[2] = 0; # else unsigned int regs[4]; __get_cpuid (0, ®s[0], ®s[1], ®s[2], ®s[3]); @@ -156,9 +158,11 @@ choose_half_to_float_impl () { __get_cpuid (1, ®s[0], ®s[1], ®s[2], ®s[3]); } + else + regs[2] = 0; # endif /* F16C is indicated by bit 29 */ - if (regs[0] & (1 << 29)) half_to_float_buffer = &half_to_float_buffer_f16c; + if (regs[2] & (1 << 29)) half_to_float_buffer = &half_to_float_buffer_f16c; } # else /* when we explicitly compile against f16, force it in */ From 9a3cff90b4dfa74e518c1fe45e3a38baf3faf287 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Fri, 27 Aug 2021 08:48:27 +1200 Subject: [PATCH 2/2] Fix copy/paste error in special case unpack routine Signed-off-by: Kimball Thurston --- src/lib/OpenEXRCore/unpack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/OpenEXRCore/unpack.c b/src/lib/OpenEXRCore/unpack.c index f5db38dda7..7587eb2b11 100644 --- a/src/lib/OpenEXRCore/unpack.c +++ b/src/lib/OpenEXRCore/unpack.c @@ -417,7 +417,7 @@ unpack_16bit_3chan_planar (exr_decode_pipeline_t* decode) { in0 = (const uint16_t*) srcbuffer; in1 = in0 + w; - in2 = in1 + 1; + in2 = in1 + w; srcbuffer += w * 6; // 3 * sizeof(uint16_t), avoid type conversion /* specialise to memcpy if we can */ #if EXR_HOST_IS_NOT_LITTLE_ENDIAN @@ -471,7 +471,7 @@ unpack_half_to_float_3chan_planar (exr_decode_pipeline_t* decode) { in0 = (const uint16_t*) srcbuffer; in1 = in0 + w; - in2 = in1 + 1; + in2 = in1 + w; srcbuffer += w * 6; // 3 * sizeof(uint16_t), avoid type conversion /* specialise to memcpy if we can */ half_to_float_buffer ((float*) out0, in0, w);