Merge "configure: mingw32 targets: test for WIC support"

This commit is contained in:
pascal massimino 2011-06-10 16:11:51 -07:00 committed by Code Review
commit ea43f045b5
4 changed files with 76 additions and 11 deletions

View File

@ -35,7 +35,8 @@ PLATFORM_LDFLAGS = /SAFESEH
MT = mt.exe
CCNODBG = cl.exe /nologo /O2 /DNDEBUG
CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1
CFLAGS = /Isrc /nologo /W3 /EHsc /DWIN32 /FD /c /GS /D_CRT_SECURE_NO_WARNINGS
CFLAGS = /Isrc /nologo /W3 /EHsc /FD /c /GS
CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DHAVE_WINCODEC_H
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE $(PLATFORM_LDFLAGS)
CFLAGSLIB = /DLIBWEBP_STATICLIB
LNKDLL = link.exe /DLL

View File

@ -1,4 +1,5 @@
AC_INIT([webpdecode], [0.1])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_PROG_LIBTOOL
AM_PROG_CC_C_O
@ -74,6 +75,49 @@ AC_CHECK_HEADER(jpeglib.h,
AC_SUBST(JPEG_LIBS)
AC_SUBST(JPEG_INCLUDES)
dnl === check for WIC support ===
if test "$target_os" = "mingw32"; then
AC_CHECK_HEADERS([wincodec.h shlwapi.h windows.h])
if test "$ac_cv_header_wincodec_h" = "yes"; then
AC_MSG_CHECKING(for Windows Imaging Component support)
saved_LIBS=$LIBS
LIBS="-lshlwapi -lole32 $LIBS"
# match include structure from [cd]webp.c
wic_headers="
#define INITGUID
#define CINTERFACE
#define COBJMACROS
#define _WIN32_IE 0x500
#include <shlwapi.h>
#include <windows.h>
#include <wincodec.h>
"
# test for functions from each lib and the GUID is created properly
wic_main="
int main(void) {
CLSID_WICImagingFactory;
CoInitialize(NULL);
SHCreateStreamOnFile(NULL, 0, NULL);
return 0;
}
"
AC_LANG_PUSH(C)
AC_LINK_IFELSE(
[AC_LANG_SOURCE([
$wic_headers
$wic_main])],
[wic_support=yes],
[wic_support=no]
)
AC_LANG_POP
test "$wic_support" = "yes" || LIBS=$saved_LIBS
AC_MSG_RESULT(${wic_support-no})
fi
fi
dnl === If --enable-experimental is defined, add the flag WEBP_EXPERIMENTAL_FEATURES
USE_EXPERIMENTAL_CODE=""

View File

@ -14,6 +14,10 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WEBP_HAVE_PNG
#include <png.h>
#endif
@ -23,7 +27,10 @@
#include <jpeglib.h>
#endif
#ifdef _WIN32
#ifdef HAVE_WINCODEC_H
#ifdef __MINGW32__
#define INITGUID // Without this GUIDs are declared extern and fail to link
#endif
#define CINTERFACE
#define COBJMACROS
#define _WIN32_IE 0x500 // Workaround bug in shlwapi.h when compiling C++
@ -31,7 +38,13 @@
#include <shlwapi.h>
#include <windows.h>
#include <wincodec.h>
#ifndef GUID_WICPixelFormat24bppRGB
// From Microsoft SDK 7.0a
DEFINE_GUID(GUID_WICPixelFormat24bppRGB,
0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0d);
#endif
#endif /* HAVE_WINCODEC_H */
#include "webp/encode.h"
@ -69,7 +82,7 @@ static int ReadYUV(FILE* in_file, WebPPicture* const pic) {
return ok;
}
#ifdef _WIN32
#ifdef HAVE_WINCODEC_H
#define IFS(fn) \
do { \
@ -183,7 +196,7 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic,
return ok;
}
#else // !_WIN32
#else // !HAVE_WINCODEC_H
#ifdef WEBP_HAVE_JPEG
struct my_error_mgr {
@ -425,7 +438,7 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic,
return ok;
}
#endif // !_WIN32
#endif // !HAVE_WINCODEC_H
static void AllocExtraInfo(WebPPicture* const pic) {
const int mb_w = (pic->width + 15) / 16;
@ -589,7 +602,7 @@ static void HelpLong(void) {
printf(" cwebp [-preset <...>] [options] in_file [-o out_file]\n\n");
printf("If input size (-s) for an image is not specified, "
"it is assumed to be a PNG or JPEG file.\n");
#ifdef _WIN32
#ifdef HAVE_WINCODEC_H
printf("Windows builds can take as input any of the files handled by WIC\n");
#endif
printf("options:\n");

View File

@ -17,11 +17,18 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WEBP_HAVE_PNG
#include <png.h>
#endif
#ifdef _WIN32
#ifdef HAVE_WINCODEC_H
#ifdef __MINGW32__
#define INITGUID // Without this GUIDs are declared extern and fail to link
#endif
#define CINTERFACE
#define COBJMACROS
#define _WIN32_IE 0x500 // Workaround bug in shlwapi.h when compiling C++
@ -44,7 +51,7 @@ extern void* VP8DecGetCPUInfo; // opaque forward declaration.
static int verbose = 0;
#ifdef _WIN32
#ifdef HAVE_WINCODEC_H
#define IFS(fn) \
do { \
@ -118,7 +125,7 @@ static int WritePNG(const char* out_file_name, unsigned char* rgb, int stride,
height));
}
#elif defined(WEBP_HAVE_PNG) // !WIN32
#elif defined(WEBP_HAVE_PNG) // !HAVE_WINCODEC_H
static void PNGAPI error_function(png_structp png, png_const_charp dummy) {
(void)dummy; // remove variable-unused warning
longjmp(png_jmpbuf(png), 1);
@ -158,7 +165,7 @@ static int WritePNG(FILE* out_file, unsigned char* rgb, int stride,
png_destroy_write_struct(&png, &info);
return 1;
}
#else // !WIN32 && !WEBP_HAVE_PNG
#else // !HAVE_WINCODEC_H && !WEBP_HAVE_PNG
typedef uint32_t png_uint_32;
@ -364,7 +371,7 @@ int main(int argc, const char *argv[]) {
if (!needs_open_file || fout) {
int ok = 1;
if (format == PNG) {
#ifdef _WIN32
#ifdef HAVE_WINCODEC_H
ok &= WritePNG(out_file, out, stride, width, height, has_alpha);
#else
ok &= WritePNG(fout, out, stride, width, height, has_alpha);