windowscodecs: Add a stub TIFF decoder.

This commit is contained in:
Vincent Povirk 2010-03-08 17:07:29 -06:00 committed by Alexandre Julliard
parent 8f604afa96
commit 73cd569390
8 changed files with 398 additions and 0 deletions

71
configure vendored
View File

@ -803,6 +803,7 @@ with_oss
with_png
with_pthread
with_sane
with_tiff
with_v4l
with_xcomposite
with_xcursor
@ -1489,6 +1490,7 @@ Optional Packages:
--without-png do not use PNG
--without-pthread do not use the pthread library
--without-sane do not use SANE (scanner support)
--without-tiff do not use TIFF
--without-v4l do not use v4l1 (v4l support)
--without-xcomposite do not use the Xcomposite extension
--without-xcursor do not use the Xcursor extension
@ -2668,6 +2670,12 @@ if test "${with_sane+set}" = set; then :
fi
# Check whether --with-tiff was given.
if test "${with_tiff+set}" = set; then :
withval=$with_tiff; if test "x$withval" = "xno"; then ac_cv_header_tiffio_h=no; fi
fi
# Check whether --with-v4l was given.
if test "${with_v4l+set}" = set; then :
withval=$with_v4l;
@ -5814,6 +5822,7 @@ for ac_header in \
sys/wait.h \
syscall.h \
termios.h \
tiffio.h \
unistd.h \
utime.h \
valgrind/memcheck.h \
@ -11264,6 +11273,68 @@ This is an error since --with-png was requested." "$LINENO" 5 ;;
esac
fi
if test "$ac_cv_header_tiffio_h" = "yes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -ltiff" >&5
$as_echo_n "checking for -ltiff... " >&6; }
if test "${ac_cv_lib_soname_tiff+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_soname_save_LIBS=$LIBS
LIBS="-ltiff $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char TIFFClientOpen ();
int
main ()
{
return TIFFClientOpen ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
case "$LIBEXT" in
dll) ac_cv_lib_soname_tiff=`$ac_cv_path_LDD conftest.exe | grep "tiff" | sed -e "s/dll.*/dll/"';2,$d'` ;;
dylib) ac_cv_lib_soname_tiff=`otool -L conftest$ac_exeext | grep "libtiff\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libtiff\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
*) ac_cv_lib_soname_tiff=`$ac_cv_path_LDD conftest$ac_exeext | grep "libtiff\\.$LIBEXT" | sed -e "s/^.*\(libtiff\.$LIBEXT[^ ]*\).*$/\1/"';2,$d'` ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_soname_save_LIBS
fi
if test "x$ac_cv_lib_soname_tiff" = "x"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_soname_tiff" >&5
$as_echo "$ac_cv_lib_soname_tiff" >&6; }
cat >>confdefs.h <<_ACEOF
#define SONAME_LIBTIFF "$ac_cv_lib_soname_tiff"
_ACEOF
fi
fi
if test "x$ac_cv_lib_soname_tiff" = "x"; then :
case "x$with_tiff" in
x) as_fn_append wine_notices "|libtiff ${notice_platform}development files not found, TIFF won't be supported." ;;
xno) ;;
*) as_fn_error "libtiff ${notice_platform}development files not found, TIFF won't be supported.
This is an error since --with-tiff was requested." "$LINENO" 5 ;;
esac
fi
if test "$ac_cv_header_mpg123_h" = "yes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpg123_feed in -lmpg123" >&5

View File

@ -69,6 +69,8 @@ AC_ARG_WITH(png, AS_HELP_STRING([--without-png],[do not use PNG]),
AC_ARG_WITH(pthread, AS_HELP_STRING([--without-pthread],[do not use the pthread library]),
[if test "x$withval" = "xno"; then ac_cv_header_pthread_h=no; fi])
AC_ARG_WITH(sane, AS_HELP_STRING([--without-sane],[do not use SANE (scanner support)]))
AC_ARG_WITH(tiff, AS_HELP_STRING([--without-tiff],[do not use TIFF]),
[if test "x$withval" = "xno"; then ac_cv_header_tiffio_h=no; fi])
AC_ARG_WITH(v4l, AS_HELP_STRING([--without-v4l],[do not use v4l1 (v4l support)]))
AC_ARG_WITH(xcomposite,AS_HELP_STRING([--without-xcomposite],[do not use the Xcomposite extension]),
[if test "x$withval" = "xno"; then ac_cv_header_X11_extensions_Xcomposite_h=no; fi])
@ -435,6 +437,7 @@ AC_CHECK_HEADERS(\
sys/wait.h \
syscall.h \
termios.h \
tiffio.h \
unistd.h \
utime.h \
valgrind/memcheck.h \
@ -1458,6 +1461,14 @@ fi
WINE_WARNING_WITH(png,[test "x$ac_cv_lib_soname_png" = "x"],
[libpng ${notice_platform}development files not found, PNG won't be supported.])
dnl **** Check for libtiff ****
if test "$ac_cv_header_tiffio_h" = "yes"
then
WINE_CHECK_SONAME(tiff,TIFFClientOpen)
fi
WINE_NOTICE_WITH(tiff,[test "x$ac_cv_lib_soname_tiff" = "x"],
[libtiff ${notice_platform}development files not found, TIFF won't be supported.])
dnl **** Check for mpg123 ****
if test "$ac_cv_header_mpg123_h" = "yes"
then

View File

@ -23,6 +23,7 @@ C_SRCS = \
propertybag.c \
regsvr.c \
stream.c \
tiffformat.c \
ungif.c
RC_SRCS = version.rc

View File

@ -50,6 +50,7 @@ static classinfo wic_classes[] = {
{&CLSID_WICGifDecoder, GifDecoder_CreateInstance},
{&CLSID_WICIcoDecoder, IcoDecoder_CreateInstance},
{&CLSID_WICJpegDecoder, JpegDecoder_CreateInstance},
{&CLSID_WICTiffDecoder, TiffDecoder_CreateInstance},
{&CLSID_WICDefaultFormatConverter, FormatConverter_CreateInstance},
{0}};

View File

@ -771,6 +771,12 @@ static struct regsvr_coclass const coclass_list[] = {
"windowscodecs.dll",
"Apartment"
},
{ &CLSID_WICTiffDecoder,
"WIC TIFF Decoder",
NULL,
"windowscodecs.dll",
"Both"
},
{ &CLSID_WICDefaultFormatConverter,
"WIC Default Format Converter",
NULL,
@ -868,6 +874,27 @@ static struct decoder_pattern const png_patterns[] = {
{0}
};
static const BYTE tiff_magic_le[] = {0x49,0x49,42,0};
static const BYTE tiff_magic_be[] = {0x4d,0x4d,0,42};
static GUID const * const tiff_formats[] = {
&GUID_WICPixelFormatBlackWhite,
&GUID_WICPixelFormat4bppGray,
&GUID_WICPixelFormat8bppGray,
&GUID_WICPixelFormat4bppIndexed,
&GUID_WICPixelFormat8bppIndexed,
&GUID_WICPixelFormat32bppBGR,
&GUID_WICPixelFormat32bppBGRA,
&GUID_WICPixelFormat32bppPBGRA,
NULL
};
static struct decoder_pattern const tiff_patterns[] = {
{4,0,tiff_magic_le,mask_all,0},
{4,0,tiff_magic_be,mask_all,0},
{0}
};
static struct regsvr_decoder const decoder_list[] = {
{ &CLSID_WICBmpDecoder,
"The Wine Project",
@ -919,6 +946,16 @@ static struct regsvr_decoder const decoder_list[] = {
png_formats,
png_patterns
},
{ &CLSID_WICTiffDecoder,
"The Wine Project",
"TIFF Decoder",
"1.0.0.0",
&GUID_VendorMicrosoft,
"image/tiff",
".tif;.tiff",
tiff_formats,
tiff_patterns
},
{ NULL } /* list terminator */
};

View File

@ -0,0 +1,270 @@
/*
* Copyright 2010 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"
#include <stdarg.h>
#ifdef HAVE_TIFFIO_H
#include <tiffio.h>
#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_LIBTIFF
static CRITICAL_SECTION init_tiff_cs;
static CRITICAL_SECTION_DEBUG init_tiff_cs_debug =
{
0, 0, &init_tiff_cs,
{ &init_tiff_cs_debug.ProcessLocksList,
&init_tiff_cs_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": init_tiff_cs") }
};
static CRITICAL_SECTION init_tiff_cs = { &init_tiff_cs_debug, -1, 0, 0, 0, 0 };
static void *libtiff_handle;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
MAKE_FUNCPTR(TIFFClientOpen);
#undef MAKE_FUNCPTR
static void *load_libtiff(void)
{
void *result;
EnterCriticalSection(&init_tiff_cs);
if (!libtiff_handle &&
(libtiff_handle = wine_dlopen(SONAME_LIBTIFF, RTLD_NOW, NULL, 0)) != NULL)
{
#define LOAD_FUNCPTR(f) \
if((p##f = wine_dlsym(libtiff_handle, #f, NULL, 0)) == NULL) { \
ERR("failed to load symbol %s\n", #f); \
libtiff_handle = NULL; \
LeaveCriticalSection(&init_tiff_cs); \
return NULL; \
}
LOAD_FUNCPTR(TIFFClientOpen);
#undef LOAD_FUNCPTR
}
result = libtiff_handle;
LeaveCriticalSection(&init_tiff_cs);
return result;
}
typedef struct {
const IWICBitmapDecoderVtbl *lpVtbl;
LONG ref;
} TiffDecoder;
static HRESULT WINAPI TiffDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
void **ppv)
{
TiffDecoder *This = (TiffDecoder*)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 TiffDecoder_AddRef(IWICBitmapDecoder *iface)
{
TiffDecoder *This = (TiffDecoder*)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI TiffDecoder_Release(IWICBitmapDecoder *iface)
{
TiffDecoder *This = (TiffDecoder*)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 TiffDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
DWORD *pdwCapability)
{
FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
WICDecodeOptions cacheOptions)
{
FIXME("(%p,%p,%x): stub\n", iface, pIStream, cacheOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
GUID *pguidContainerFormat)
{
memcpy(pguidContainerFormat, &GUID_ContainerFormatTiff, sizeof(GUID));
return S_OK;
}
static HRESULT WINAPI TiffDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
IWICBitmapDecoderInfo **ppIDecoderInfo)
{
FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_CopyPalette(IWICBitmapDecoder *iface,
IWICPalette *pIPalette)
{
FIXME("(%p,%p): stub\n", iface, pIPalette);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
IWICMetadataQueryReader **ppIMetadataQueryReader)
{
FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_GetPreview(IWICBitmapDecoder *iface,
IWICBitmapSource **ppIBitmapSource)
{
FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_GetColorContexts(IWICBitmapDecoder *iface,
UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
{
FIXME("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_GetThumbnail(IWICBitmapDecoder *iface,
IWICBitmapSource **ppIThumbnail)
{
TRACE("(%p,%p)\n", iface, ppIThumbnail);
return WINCODEC_ERR_CODECNOTHUMBNAIL;
}
static HRESULT WINAPI TiffDecoder_GetFrameCount(IWICBitmapDecoder *iface,
UINT *pCount)
{
FIXME("(%p,%p)\n", iface, pCount);
return E_NOTIMPL;
}
static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface,
UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
{
FIXME("(%p,%u,%p)\n", iface, index, ppIBitmapFrame);
return E_NOTIMPL;
}
static const IWICBitmapDecoderVtbl TiffDecoder_Vtbl = {
TiffDecoder_QueryInterface,
TiffDecoder_AddRef,
TiffDecoder_Release,
TiffDecoder_QueryCapability,
TiffDecoder_Initialize,
TiffDecoder_GetContainerFormat,
TiffDecoder_GetDecoderInfo,
TiffDecoder_CopyPalette,
TiffDecoder_GetMetadataQueryReader,
TiffDecoder_GetPreview,
TiffDecoder_GetColorContexts,
TiffDecoder_GetThumbnail,
TiffDecoder_GetFrameCount,
TiffDecoder_GetFrame
};
HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
{
HRESULT ret;
TiffDecoder *This;
TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
*ppv = NULL;
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
if (!load_libtiff())
{
ERR("Failed reading TIFF because unable to load %s\n",SONAME_LIBTIFF);
return E_FAIL;
}
This = HeapAlloc(GetProcessHeap(), 0, sizeof(TiffDecoder));
if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &TiffDecoder_Vtbl;
This->ref = 1;
ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
IUnknown_Release((IUnknown*)This);
return ret;
}
#else /* !SONAME_LIBTIFF */
HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
{
ERR("Trying to load TIFF picture, but Wine was compiled without TIFF support.\n");
return E_FAIL;
}
#endif

View File

@ -28,6 +28,7 @@ extern HRESULT BmpEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void**
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 TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
extern HRESULT PaletteImpl_Create(IWICPalette **palette);
extern HRESULT StreamImpl_Create(IWICStream **stream);

View File

@ -1021,6 +1021,9 @@
/* Define to 1 if you have the `thr_kill2' function. */
#undef HAVE_THR_KILL2
/* Define to 1 if you have the <tiffio.h> header file. */
#undef HAVE_TIFFIO_H
/* Define to 1 if you have the `timegm' function. */
#undef HAVE_TIMEGM
@ -1216,6 +1219,9 @@
/* Define to the soname of the libssl library. */
#undef SONAME_LIBSSL
/* Define to the soname of the libtiff library. */
#undef SONAME_LIBTIFF
/* Define to the soname of the libv4l1 library. */
#undef SONAME_LIBV4L1