Updated windowscodecs-JPEG_Decoder patchset

This commit is contained in:
Alistair Leslie-Hughes 2018-02-27 12:38:43 +11:00
parent a1ec166849
commit 923358dcea

View File

@ -1,4 +1,4 @@
From 846b328efd83b161405ed8f663b6cb3465c29ee4 Mon Sep 17 00:00:00 2001
From c91028da31f4578f90c19396c37bac0e898f566a Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 18 Aug 2017 12:17:52 +0800
Subject: [PATCH] windowscodecs: Move JPEG frame image data initialization from
@ -7,11 +7,11 @@ Subject: [PATCH] windowscodecs: Move JPEG frame image data initialization from
This is how PNG decoder does things, and it avoids image data corruption
in some cases (presumably when libjpeg reuses existing scanline data).
---
dlls/windowscodecs/jpegformat.c | 151 ++++++++++++++--------------------------
1 file changed, 54 insertions(+), 97 deletions(-)
dlls/windowscodecs/jpegformat.c | 156 +++++++++++++++-------------------------
1 file changed, 59 insertions(+), 97 deletions(-)
diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c
index 97899a7..0f02b36 100644
index 97899a7..df5da36 100644
--- a/dlls/windowscodecs/jpegformat.c
+++ b/dlls/windowscodecs/jpegformat.c
@@ -155,6 +155,7 @@ typedef struct {
@ -22,16 +22,17 @@ index 97899a7..0f02b36 100644
BYTE *image_data;
CRITICAL_SECTION lock;
} JpegDecoder;
@@ -303,6 +304,8 @@ static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *
@@ -303,6 +304,9 @@ static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *
int ret;
LARGE_INTEGER seek;
jmp_buf jmpbuf;
+ UINT data_size, i;
+ UINT first_scanline = 0;
+
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOptions);
EnterCriticalSection(&This->lock);
@@ -381,6 +384,55 @@ static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *
@@ -381,6 +385,59 @@ static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *
return E_FAIL;
}
@ -51,11 +52,12 @@ index 97899a7..0f02b36 100644
+
+ while (This->cinfo.output_scanline < This->cinfo.output_height)
+ {
+ UINT first_scanline = This->cinfo.output_scanline;
+ UINT max_rows;
+ JSAMPROW out_rows[4];
+ JDIMENSION ret;
+
+ first_scanline = This->cinfo.output_scanline;
+
+ max_rows = min(This->cinfo.output_height-first_scanline, 4);
+ for (i=0; i<max_rows; i++)
+ out_rows[i] = This->image_data + This->stride * (first_scanline+i);
@ -79,15 +81,18 @@ index 97899a7..0f02b36 100644
+
+ if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
+ {
+ DWORD *pDwordData = (DWORD*) (This->image_data + This->stride * first_scanline);
+ DWORD *pDwordDataEnd = (DWORD*) (This->image_data + This->cinfo.output_scanline * This->stride);
+
+ /* Adobe JPEG's have inverted CMYK data. */
+ for (i=0; i<data_size; i++)
+ This->image_data[i] ^= 0xff;
+ while(pDwordData < pDwordDataEnd)
+ *pDwordData++ ^= 0xffffffff;
+ }
+
This->initialized = TRUE;
LeaveCriticalSection(&This->lock);
@@ -597,106 +649,11 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
@@ -597,106 +654,11 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
{
JpegDecoder *This = impl_from_IWICBitmapFrameDecode(iface);