mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
windowscodecs: Add stub JPEG decoder.
This commit is contained in:
parent
79292ea1c1
commit
bec465e467
@ -15,6 +15,7 @@ C_SRCS = \
|
||||
icoformat.c \
|
||||
imgfactory.c \
|
||||
info.c \
|
||||
jpegformat.c \
|
||||
main.c \
|
||||
palette.c \
|
||||
propertybag.c \
|
||||
|
@ -47,6 +47,7 @@ static classinfo wic_classes[] = {
|
||||
{&CLSID_WICBmpEncoder, BmpEncoder_CreateInstance},
|
||||
{&CLSID_WICGifDecoder, GifDecoder_CreateInstance},
|
||||
{&CLSID_WICIcoDecoder, IcoDecoder_CreateInstance},
|
||||
{&CLSID_WICJpegDecoder, JpegDecoder_CreateInstance},
|
||||
{&CLSID_WICDefaultFormatConverter, FormatConverter_CreateInstance},
|
||||
{0}};
|
||||
|
||||
|
266
dlls/windowscodecs/jpegformat.c
Normal file
266
dlls/windowscodecs/jpegformat.c
Normal file
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Copyright 2009 Vincent Povirk 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 "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef SONAME_LIBJPEG
|
||||
/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
|
||||
#define XMD_H
|
||||
#define UINT8 JPEG_UINT8
|
||||
#define UINT16 JPEG_UINT16
|
||||
#define boolean jpeg_boolean
|
||||
#undef HAVE_STDLIB_H
|
||||
# include <jpeglib.h>
|
||||
#undef HAVE_STDLIB_H
|
||||
#define HAVE_STDLIB_H 1
|
||||
#undef UINT8
|
||||
#undef UINT16
|
||||
#undef boolean
|
||||
#endif
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "objbase.h"
|
||||
#include "wincodec.h"
|
||||
|
||||
#include "wincodecs_private.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/library.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
|
||||
|
||||
#ifdef SONAME_LIBJPEG
|
||||
|
||||
static void *libjpeg_handle;
|
||||
|
||||
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
||||
MAKE_FUNCPTR(jpeg_std_error);
|
||||
#undef MAKE_FUNCPTR
|
||||
|
||||
static void *load_libjpeg(void)
|
||||
{
|
||||
if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) {
|
||||
|
||||
#define LOAD_FUNCPTR(f) \
|
||||
if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \
|
||||
libjpeg_handle = NULL; \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
LOAD_FUNCPTR(jpeg_std_error);
|
||||
#undef LOAD_FUNCPTR
|
||||
}
|
||||
return libjpeg_handle;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const IWICBitmapDecoderVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
} JpegDecoder;
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
|
||||
void **ppv)
|
||||
{
|
||||
JpegDecoder *This = (JpegDecoder*)iface;
|
||||
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
||||
|
||||
if (!ppv) return E_INVALIDARG;
|
||||
|
||||
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid))
|
||||
{
|
||||
*ppv = This;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppv = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
IUnknown_AddRef((IUnknown*)*ppv);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static ULONG WINAPI JpegDecoder_AddRef(IWICBitmapDecoder *iface)
|
||||
{
|
||||
JpegDecoder *This = (JpegDecoder*)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) refcount=%u\n", iface, ref);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI JpegDecoder_Release(IWICBitmapDecoder *iface)
|
||||
{
|
||||
JpegDecoder *This = (JpegDecoder*)iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) refcount=%u\n", iface, ref);
|
||||
|
||||
if (ref == 0)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
|
||||
DWORD *pdwCapability)
|
||||
{
|
||||
FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
|
||||
WICDecodeOptions cacheOptions)
|
||||
{
|
||||
FIXME("(%p,%p,%u): stub\n", iface, pIStream, cacheOptions);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
||||
GUID *pguidContainerFormat)
|
||||
{
|
||||
memcpy(pguidContainerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
IWICPalette *pIPalette)
|
||||
{
|
||||
TRACE("(%p,%p)\n", iface, pIPalette);
|
||||
|
||||
return WINCODEC_ERR_PALETTEUNAVAILABLE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
|
||||
IWICMetadataQueryReader **ppIMetadataQueryReader)
|
||||
{
|
||||
FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetPreview(IWICBitmapDecoder *iface,
|
||||
IWICBitmapSource **ppIBitmapSource)
|
||||
{
|
||||
FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
|
||||
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetColorContexts(IWICBitmapDecoder *iface,
|
||||
UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
|
||||
{
|
||||
FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
|
||||
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetThumbnail(IWICBitmapDecoder *iface,
|
||||
IWICBitmapSource **ppIThumbnail)
|
||||
{
|
||||
FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
|
||||
return WINCODEC_ERR_CODECNOTHUMBNAIL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetFrameCount(IWICBitmapDecoder *iface,
|
||||
UINT *pCount)
|
||||
{
|
||||
*pCount = 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_GetFrame(IWICBitmapDecoder *iface,
|
||||
UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
|
||||
{
|
||||
FIXME("(%p,%u,%p): stub\n", iface, index, ppIBitmapFrame);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IWICBitmapDecoderVtbl JpegDecoder_Vtbl = {
|
||||
JpegDecoder_QueryInterface,
|
||||
JpegDecoder_AddRef,
|
||||
JpegDecoder_Release,
|
||||
JpegDecoder_QueryCapability,
|
||||
JpegDecoder_Initialize,
|
||||
JpegDecoder_GetContainerFormat,
|
||||
JpegDecoder_GetDecoderInfo,
|
||||
JpegDecoder_CopyPalette,
|
||||
JpegDecoder_GetMetadataQueryReader,
|
||||
JpegDecoder_GetPreview,
|
||||
JpegDecoder_GetColorContexts,
|
||||
JpegDecoder_GetThumbnail,
|
||||
JpegDecoder_GetFrameCount,
|
||||
JpegDecoder_GetFrame
|
||||
};
|
||||
|
||||
HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
|
||||
{
|
||||
JpegDecoder *This;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
|
||||
|
||||
if (!libjpeg_handle && !load_libjpeg())
|
||||
{
|
||||
ERR("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
*ppv = NULL;
|
||||
|
||||
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(JpegDecoder));
|
||||
if (!This) return E_OUTOFMEMORY;
|
||||
|
||||
This->lpVtbl = &JpegDecoder_Vtbl;
|
||||
This->ref = 1;
|
||||
|
||||
ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
|
||||
IUnknown_Release((IUnknown*)This);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* !defined(SONAME_LIBJPEG) */
|
||||
|
||||
HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
|
||||
{
|
||||
ERR("Trying to load JPEG picture, but JPEG supported not compiled in.\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#endif
|
@ -753,6 +753,12 @@ static struct regsvr_coclass const coclass_list[] = {
|
||||
"windowscodecs.dll",
|
||||
"Apartment"
|
||||
},
|
||||
{ &CLSID_WICJpegDecoder,
|
||||
"WIC JPEG Decoder",
|
||||
NULL,
|
||||
"windowscodecs.dll",
|
||||
"Apartment"
|
||||
},
|
||||
{ &CLSID_WICDefaultFormatConverter,
|
||||
"WIC Default Format Converter",
|
||||
NULL,
|
||||
@ -813,6 +819,19 @@ static struct decoder_pattern const ico_patterns[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
static const BYTE jpeg_magic[] = {0xff, 0xd8, 0xff, 0xe0};
|
||||
|
||||
static GUID const * const jpeg_formats[] = {
|
||||
&GUID_WICPixelFormat24bppBGR,
|
||||
&GUID_WICPixelFormat8bppGray,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct decoder_pattern const jpeg_patterns[] = {
|
||||
{4,0,jpeg_magic,mask_all,0},
|
||||
{0}
|
||||
};
|
||||
|
||||
static struct regsvr_decoder const decoder_list[] = {
|
||||
{ &CLSID_WICBmpDecoder,
|
||||
"The Wine Project",
|
||||
@ -844,6 +863,16 @@ static struct regsvr_decoder const decoder_list[] = {
|
||||
ico_formats,
|
||||
ico_patterns
|
||||
},
|
||||
{ &CLSID_WICJpegDecoder,
|
||||
"The Wine Project",
|
||||
"JPEG Decoder",
|
||||
"1.0.0.0",
|
||||
&GUID_VendorMicrosoft,
|
||||
"image/jpeg",
|
||||
".jpg;.jpeg;.jfif",
|
||||
jpeg_formats,
|
||||
jpeg_patterns
|
||||
},
|
||||
{ NULL } /* list terminator */
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,7 @@ extern HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void*
|
||||
extern HRESULT BmpEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
|
||||
extern HRESULT GifDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv);
|
||||
extern HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
|
||||
extern HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
|
||||
|
||||
extern HRESULT PaletteImpl_Create(IWICPalette **palette);
|
||||
extern HRESULT StreamImpl_Create(IWICStream **stream);
|
||||
|
Loading…
Reference in New Issue
Block a user