[WINDOWSCODECS]

* Sync with Wine 1.7.1.

svn path=/trunk/; revision=60202
This commit is contained in:
Amine Khaldi 2013-09-19 14:54:10 +00:00
parent 2fa5f45f26
commit 1ab78c8215
12 changed files with 362 additions and 35 deletions

View file

@ -27,6 +27,7 @@ list(APPEND SOURCE
bitmap.c
bmpdecode.c
bmpencode.c
clipper.c
clsfactory.c
colorcontext.c
colortransform.c

View file

@ -364,7 +364,7 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
bih.bV5GreenMask = This->format->greenmask;
bih.bV5BlueMask = This->format->bluemask;
bih.bV5AlphaMask = This->format->alphamask;
bih.bV5AlphaMask = LCS_DEVICE_RGB;
bih.bV5CSType = LCS_DEVICE_RGB;
}
bfh.bfSize = sizeof(BITMAPFILEHEADER) + info_size + bih.bV5SizeImage;

View file

@ -0,0 +1,260 @@
/*
* Copyright 2013 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wincodec.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
typedef struct BitmapClipper {
IWICBitmapClipper IWICBitmapClipper_iface;
LONG ref;
IWICBitmapSource *source;
WICRect rect;
CRITICAL_SECTION lock; /* must be held when initialized */
} BitmapClipper;
static inline BitmapClipper *impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
{
return CONTAINING_RECORD(iface, BitmapClipper, IWICBitmapClipper_iface);
}
static HRESULT WINAPI BitmapClipper_QueryInterface(IWICBitmapClipper *iface, REFIID iid,
void **ppv)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IWICBitmapSource, iid) ||
IsEqualIID(&IID_IWICBitmapClipper, iid))
{
*ppv = &This->IWICBitmapClipper_iface;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI BitmapClipper_AddRef(IWICBitmapClipper *iface)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI BitmapClipper_Release(IWICBitmapClipper *iface)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0)
{
This->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->lock);
if (This->source) IWICBitmapSource_Release(This->source);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI BitmapClipper_GetSize(IWICBitmapClipper *iface,
UINT *width, UINT *height)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
TRACE("(%p,%p,%p)\n", iface, width, height);
if (!width || !height)
return E_INVALIDARG;
if (!This->source)
return WINCODEC_ERR_WRONGSTATE;
*width = This->rect.Width;
*height = This->rect.Height;
return S_OK;
}
static HRESULT WINAPI BitmapClipper_GetPixelFormat(IWICBitmapClipper *iface,
WICPixelFormatGUID *format)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
TRACE("(%p,%p)\n", iface, format);
if (!format)
return E_INVALIDARG;
if (!This->source)
return WINCODEC_ERR_WRONGSTATE;
return IWICBitmapSource_GetPixelFormat(This->source, format);
}
static HRESULT WINAPI BitmapClipper_GetResolution(IWICBitmapClipper *iface,
double *dpiX, double *dpiY)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
TRACE("(%p,%p,%p)\n", iface, dpiX, dpiY);
if (!dpiX || !dpiY)
return E_INVALIDARG;
if (!This->source)
return WINCODEC_ERR_WRONGSTATE;
return IWICBitmapSource_GetResolution(This->source, dpiX, dpiY);
}
static HRESULT WINAPI BitmapClipper_CopyPalette(IWICBitmapClipper *iface,
IWICPalette *palette)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
TRACE("(%p,%p)\n", iface, palette);
if (!palette)
return E_INVALIDARG;
if (!This->source)
return WINCODEC_ERR_WRONGSTATE;
return IWICBitmapSource_CopyPalette(This->source, palette);
}
static HRESULT WINAPI BitmapClipper_CopyPixels(IWICBitmapClipper *iface,
const WICRect *rc, UINT stride, UINT buffer_size, BYTE *buffer)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
WICRect rect;
TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, buffer_size, buffer);
if (!This->source)
return WINCODEC_ERR_WRONGSTATE;
if (rc)
{
rect = *rc;
/* transform to source coordinates */
rect.X += This->rect.X;
rect.Y += This->rect.Y;
if ((rect.X + rect.Width > This->rect.X + This->rect.Width) ||
(rect.Y + rect.Height > This->rect.Y + This->rect.Height))
return E_INVALIDARG;
rc = &rect;
}
else
rc = &This->rect;
return IWICBitmapSource_CopyPixels(This->source, rc, stride, buffer_size, buffer);
}
static HRESULT WINAPI BitmapClipper_Initialize(IWICBitmapClipper *iface,
IWICBitmapSource *source, const WICRect *rc)
{
BitmapClipper *This = impl_from_IWICBitmapClipper(iface);
UINT width, height;
HRESULT hr = S_OK;
TRACE("(%p,%p,%p)\n", iface, source, rc);
EnterCriticalSection(&This->lock);
if (This->source)
{
hr = WINCODEC_ERR_WRONGSTATE;
goto end;
}
hr = IWICBitmapSource_GetSize(source, &width, &height);
if (FAILED(hr)) goto end;
if ((rc->X + rc->Width > width) || (rc->Y + rc->Height > height))
{
hr = E_INVALIDARG;
goto end;
}
This->rect = *rc;
This->source = source;
IWICBitmapSource_AddRef(This->source);
end:
LeaveCriticalSection(&This->lock);
return hr;
}
static const IWICBitmapClipperVtbl BitmapClipper_Vtbl = {
BitmapClipper_QueryInterface,
BitmapClipper_AddRef,
BitmapClipper_Release,
BitmapClipper_GetSize,
BitmapClipper_GetPixelFormat,
BitmapClipper_GetResolution,
BitmapClipper_CopyPalette,
BitmapClipper_CopyPixels,
BitmapClipper_Initialize
};
HRESULT BitmapClipper_Create(IWICBitmapClipper **clipper)
{
BitmapClipper *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapClipper));
if (!This) return E_OUTOFMEMORY;
This->IWICBitmapClipper_iface.lpVtbl = &BitmapClipper_Vtbl;
This->ref = 1;
This->source = NULL;
InitializeCriticalSection(&This->lock);
This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BitmapClipper.lock");
*clipper = &This->IWICBitmapClipper_iface;
return S_OK;
}

View file

@ -130,8 +130,16 @@ static HRESULT load_profile(const WCHAR *filename, BYTE **profile, UINT *len)
}
ret = ReadFile(handle, *profile, size.u.LowPart, &count, NULL);
CloseHandle(handle);
if (!ret) return HRESULT_FROM_WIN32(GetLastError());
if (count != size.u.LowPart) return E_FAIL;
if (!ret) {
HeapFree (GetProcessHeap(),0,*profile);
*profile = NULL;
return HRESULT_FROM_WIN32(GetLastError());
}
if (count != size.u.LowPart) {
HeapFree (GetProcessHeap(),0,*profile);
*profile = NULL;
return E_FAIL;
}
*len = count;
return S_OK;
}

View file

@ -1185,26 +1185,39 @@ static HRESULT WINAPI GifDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalet
GifDecoder *This = impl_from_IWICBitmapDecoder(iface);
WICColor colors[256];
ColorMapObject *cm;
int i, trans;
int i, trans, count;
ExtensionBlock *eb;
TRACE("(%p,%p)\n", iface, palette);
cm = This->gif->SColorMap;
if (!cm) return WINCODEC_ERR_FRAMEMISSING;
if (cm->ColorCount > 256)
if (cm)
{
ERR("GIF contains invalid number of colors: %d\n", cm->ColorCount);
return E_FAIL;
if (cm->ColorCount > 256)
{
ERR("GIF contains invalid number of colors: %d\n", cm->ColorCount);
return E_FAIL;
}
for (i = 0; i < cm->ColorCount; i++)
{
colors[i] = 0xff000000 | /* alpha */
cm->Colors[i].Red << 16 |
cm->Colors[i].Green << 8 |
cm->Colors[i].Blue;
}
count = cm->ColorCount;
}
for (i = 0; i < cm->ColorCount; i++)
else
{
colors[i] = 0xff000000 | /* alpha */
cm->Colors[i].Red << 16 |
cm->Colors[i].Green << 8 |
cm->Colors[i].Blue;
colors[0] = 0xff000000;
colors[1] = 0xffffffff;
for (i = 2; i < 256; i++)
colors[i] = 0xff000000;
count = 256;
}
/* look for the transparent color extension */
@ -1222,7 +1235,7 @@ static HRESULT WINAPI GifDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalet
}
}
return IWICPalette_InitializeCustom(palette, colors, cm->ColorCount);
return IWICPalette_InitializeCustom(palette, colors, count);
}
static HRESULT WINAPI GifDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,

View file

@ -442,8 +442,8 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *
static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface,
IWICBitmapClipper **ppIBitmapClipper)
{
FIXME("(%p,%p): stub\n", iface, ppIBitmapClipper);
return E_NOTIMPL;
TRACE("(%p,%p)\n", iface, ppIBitmapClipper);
return BitmapClipper_Create(ppIBitmapClipper);
}
static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface,

View file

@ -552,16 +552,23 @@ static HRESULT WINAPI JpegDecoder_Frame_GetResolution(IWICBitmapFrameDecode *ifa
EnterCriticalSection(&This->lock);
if (This->cinfo.density_unit == 2) /* pixels per centimeter */
switch (This->cinfo.density_unit)
{
case 2: /* pixels per centimeter */
*pDpiX = This->cinfo.X_density * 2.54;
*pDpiY = This->cinfo.Y_density * 2.54;
}
else
{
/* 1 = pixels per inch, 0 = unknown */
break;
case 1: /* pixels per inch */
*pDpiX = This->cinfo.X_density;
*pDpiY = This->cinfo.Y_density;
break;
case 0: /* unknown */
default:
*pDpiX = 96.0;
*pDpiY = 96.0;
break;
}
LeaveCriticalSection(&This->lock);

View file

@ -46,8 +46,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
break;
case DLL_PROCESS_DETACH:
break;
}
return WIC_DllMain(hinstDLL, fdwReason, lpvReserved);

View file

@ -180,7 +180,7 @@ MAKE_FUNCPTR(png_get_tRNS);
MAKE_FUNCPTR(png_set_bgr);
MAKE_FUNCPTR(png_set_crc_action);
MAKE_FUNCPTR(png_set_error_fn);
#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
#ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
MAKE_FUNCPTR(png_set_expand_gray_1_2_4_to_8);
#else
MAKE_FUNCPTR(png_set_gray_1_2_4_to_8);
@ -229,7 +229,7 @@ static void *load_libpng(void)
LOAD_FUNCPTR(png_set_bgr);
LOAD_FUNCPTR(png_set_crc_action);
LOAD_FUNCPTR(png_set_error_fn);
#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
#ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8);
#else
LOAD_FUNCPTR(png_set_gray_1_2_4_to_8);
@ -471,7 +471,7 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
{
if (bit_depth < 8)
{
#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
#ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
ppng_set_expand_gray_1_2_4_to_8(This->png_ptr);
#else
ppng_set_gray_1_2_4_to_8(This->png_ptr);
@ -870,7 +870,8 @@ static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *i
UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
{
PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
png_charp name, profile;
png_charp name;
BYTE *profile;
png_uint_32 len;
int compression_type;
HRESULT hr;
@ -881,11 +882,11 @@ static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *i
EnterCriticalSection(&This->lock);
if (ppng_get_iCCP(This->png_ptr, This->info_ptr, &name, &compression_type, &profile, &len))
if (ppng_get_iCCP(This->png_ptr, This->info_ptr, &name, &compression_type, (void *)&profile, &len))
{
if (cCount && ppIColorContexts)
{
hr = IWICColorContext_InitializeFromMemory(*ppIColorContexts, (const BYTE *)profile, len);
hr = IWICColorContext_InitializeFromMemory(*ppIColorContexts, profile, len);
if (FAILED(hr))
{
LeaveCriticalSection(&This->lock);

View file

@ -36,6 +36,7 @@
#include <windef.h>
#include <winbase.h>
#include <objbase.h>
#include <oleauto.h>
//#include "wincodec.h"
#include <wincodecsdk.h>
@ -48,6 +49,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
#ifdef SONAME_LIBTIFF
/* Workaround for broken libtiff 4.x headers on some 64-bit hosts which
* define TIFF_UINT64_T/toff_t as 32-bit for 32-bit builds, while they
* are supposed to be always 64-bit.
* TIFF_UINT64_T doesn't exist in libtiff 3.x, it was introduced in 4.x.
*/
#ifdef TIFF_UINT64_T
# undef toff_t
# define toff_t UINT64
#endif
static CRITICAL_SECTION init_tiff_cs;
static CRITICAL_SECTION_DEBUG init_tiff_cs_debug =
{
@ -58,6 +69,9 @@ static CRITICAL_SECTION_DEBUG init_tiff_cs_debug =
};
static CRITICAL_SECTION init_tiff_cs = { &init_tiff_cs_debug, -1, 0, 0, 0, 0 };
static const WCHAR wszTiffCompressionMethod[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0};
static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0};
static void *libtiff_handle;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
MAKE_FUNCPTR(TIFFClientOpen);
@ -210,8 +224,8 @@ static TIFF* tiff_open_stream(IStream *stream, const char *mode)
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
return pTIFFClientOpen("<IStream object>", mode, stream, tiff_stream_read,
tiff_stream_write, tiff_stream_seek, tiff_stream_close,
tiff_stream_size, tiff_stream_map, tiff_stream_unmap);
tiff_stream_write, (void *)tiff_stream_seek, tiff_stream_close,
(void *)tiff_stream_size, (void *)tiff_stream_map, (void *)tiff_stream_unmap);
}
typedef struct {
@ -1913,7 +1927,31 @@ static HRESULT WINAPI TiffEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
if (SUCCEEDED(hr))
{
hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions);
PROPBAG2 opts[2]= {{0}};
opts[0].pstrName = (LPOLESTR)wszTiffCompressionMethod;
opts[0].vt = VT_UI1;
opts[0].dwType = PROPBAG2_TYPE_DATA;
opts[1].pstrName = (LPOLESTR)wszCompressionQuality;
opts[1].vt = VT_R4;
opts[1].dwType = PROPBAG2_TYPE_DATA;
hr = CreatePropertyBag2(opts, 2, ppIEncoderOptions);
if (SUCCEEDED(hr))
{
VARIANT v;
VariantInit(&v);
V_VT(&v) = VT_UI1;
V_UNION(&v, bVal) = WICTiffCompressionDontCare;
hr = IPropertyBag2_Write(*ppIEncoderOptions, 1, opts, &v);
VariantClear(&v);
if (FAILED(hr))
{
IPropertyBag2_Release(*ppIEncoderOptions);
*ppIEncoderOptions = NULL;
}
}
}
if (SUCCEEDED(hr))

View file

@ -54,6 +54,7 @@ extern HRESULT PaletteImpl_Create(IWICPalette **palette) DECLSPEC_HIDDEN;
extern HRESULT StreamImpl_Create(IWICStream **stream) DECLSPEC_HIDDEN;
extern HRESULT ColorContext_Create(IWICColorContext **context) DECLSPEC_HIDDEN;
extern HRESULT ColorTransform_Create(IWICColorTransform **transform) DECLSPEC_HIDDEN;
extern HRESULT BitmapClipper_Create(IWICBitmapClipper **clipper) DECLSPEC_HIDDEN;
extern HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
UINT srcwidth, UINT srcheight, INT srcstride,

View file

@ -199,7 +199,7 @@ reactos/dll/win32/vbscript # Synced to Wine-1.5.26
reactos/dll/win32/version # Autosync
reactos/dll/win32/wbemprox # Synced to Wine-1.5.26
reactos/dll/win32/wer # Autosync
reactos/dll/win32/windowscodecs # Synced to Wine-1.5.26
reactos/dll/win32/windowscodecs # Synced to Wine-1.7.1
reactos/dll/win32/winemp3.acm # Synced to Wine-1.5.19
reactos/dll/win32/wing32 # Out of sync
reactos/dll/win32/winhttp # Synced to Wine-1.5.26