Hello,

In attach a patch, who fixe decompression of PRX24 Full Float.
PRX24 compression, reduce 32b float to 24b before zip step.
So the expected uncompress size in the unzip step, need to be adjust,
depends of the pixel type (uint32, and half float are not modified).

I also, split the unzip check in order to add a more precise log error.

sample, can be found here : https://we.tl/INWavynsGz
(decode failed before the patch).
This sample can also be add to ./fate-suite/exr, in order to apply the fate
test patch in attach.

Comments welcome

Martin
Jokyo Images
From 2f85b8e840529ca4f5976446ad7f77bcbc575a8e Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vign...@gmail.com>
Date: Sun, 3 Apr 2016 14:12:44 +0200
Subject: [PATCH 1/2] libavcodec/exr : fix decompress PRX24 Float

---
 libavcodec/exr.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index f6141fa..f7ffa0c 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -778,14 +778,26 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
                             int compressed_size, int uncompressed_size,
                             EXRThreadData *td)
 {
-    unsigned long dest_len = uncompressed_size;
+    unsigned long dest_len, expected_len;
     const uint8_t *in = td->tmp;
     uint8_t *out;
     int c, i, j;
-
-    if (uncompress(td->tmp, &dest_len, src, compressed_size) != Z_OK ||
-        dest_len != uncompressed_size)
+    
+    if (s->pixel_type == EXR_FLOAT)
+        expected_len = (uncompressed_size/4) * 3;/* PRX 24 store float in 24 bit instead of 32 */
+    else
+        expected_len = uncompressed_size;
+    
+    dest_len = expected_len;
+    
+    if (uncompress(td->tmp, &dest_len, src, compressed_size) != Z_OK){
+        av_log(s, AV_LOG_ERROR, "Failed in the unzip step of PXR24.");
+        return AVERROR_INVALIDDATA;
+    }
+    else if (dest_len != expected_len){
+        av_log(s, AV_LOG_ERROR, "Not enough data after unzip step. Expected : %i ; found %lu.", uncompressed_size, dest_len);
         return AVERROR_INVALIDDATA;
+    }
 
     out = td->uncompressed_data;
     for (i = 0; i < s->ysize; i++)
-- 
1.9.3 (Apple Git-50)

From 6da4e7d49651f4bb77ce0cd08bc7a2da5175eaee Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vign...@gmail.com>
Date: Sun, 3 Apr 2016 14:25:19 +0200
Subject: [PATCH 2/2] fate/exr : add test for PXR24 Float

---
 tests/fate/image.mak                             | 3 +++
 tests/ref/fate/exr-rgb-scanline-prx24-float-12x8 | 2 ++
 2 files changed, 5 insertions(+)
 create mode 100644 tests/ref/fate/exr-rgb-scanline-prx24-float-12x8

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 4155d6b..c56c9d4 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -65,6 +65,9 @@ fate-exr-slice-zip16: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_slice_zip16.e
 FATE_EXR += fate-exr-slice-pxr24
 fate-exr-slice-pxr24: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgb_slice_pxr24.exr -pix_fmt rgb48le
 
+FATE_EXR += fate-exr-rgb-scanline-prx24-float-12x8
+fate-exr-rgb-scanline-prx24-float-12x8: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgb_scanline_prx24_float_12x8.exr -pix_fmt rgb48le
+
 FATE_EXR += fate-exr-rgba-multiscanline-half-b44
 fate-exr-rgba-multiscanline-half-b44: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_multiscanline_half_b44.exr -pix_fmt rgba64le
 
diff --git a/tests/ref/fate/exr-rgb-scanline-prx24-float-12x8 b/tests/ref/fate/exr-rgb-scanline-prx24-float-12x8
new file mode 100644
index 0000000..0f3a112
--- /dev/null
+++ b/tests/ref/fate/exr-rgb-scanline-prx24-float-12x8
@@ -0,0 +1,2 @@
+#tb 0: 1/25
+0,          0,          0,        1,      576, 0x7120e072
-- 
1.9.3 (Apple Git-50)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to