ddraw/tests: Test if surface with DDSCAPS_ZBUFFER can be render target.
[wine.git] / dlls / windowscodecs / jpegformat.c
blobc3cd4558d89b97c972dbdba22df23479e91c7868
1 /*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include "wine/port.h"
22 #ifdef HAVE_UNISTD_H
23 # include <unistd.h>
24 #endif
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <setjmp.h>
30 #ifdef SONAME_LIBJPEG
31 /* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
32 #define XMD_H
33 #define UINT8 JPEG_UINT8
34 #define UINT16 JPEG_UINT16
35 #define boolean jpeg_boolean
36 #undef HAVE_STDLIB_H
37 # include <jpeglib.h>
38 #undef HAVE_STDLIB_H
39 #define HAVE_STDLIB_H 1
40 #undef UINT8
41 #undef UINT16
42 #undef boolean
43 #endif
45 #define COBJMACROS
47 #include "windef.h"
48 #include "winbase.h"
49 #include "objbase.h"
50 #include "wincodec.h"
52 #include "wincodecs_private.h"
54 #include "wine/debug.h"
55 #include "wine/library.h"
57 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
58 WINE_DECLARE_DEBUG_CHANNEL(jpeg);
60 #ifdef SONAME_LIBJPEG
62 static void *libjpeg_handle;
64 #define MAKE_FUNCPTR(f) static typeof(f) * p##f
65 MAKE_FUNCPTR(jpeg_CreateDecompress);
66 MAKE_FUNCPTR(jpeg_destroy_decompress);
67 MAKE_FUNCPTR(jpeg_read_header);
68 MAKE_FUNCPTR(jpeg_read_scanlines);
69 MAKE_FUNCPTR(jpeg_resync_to_restart);
70 MAKE_FUNCPTR(jpeg_start_decompress);
71 MAKE_FUNCPTR(jpeg_std_error);
72 #undef MAKE_FUNCPTR
74 static void *load_libjpeg(void)
76 if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) {
78 #define LOAD_FUNCPTR(f) \
79 if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \
80 libjpeg_handle = NULL; \
81 return NULL; \
84 LOAD_FUNCPTR(jpeg_CreateDecompress);
85 LOAD_FUNCPTR(jpeg_destroy_decompress);
86 LOAD_FUNCPTR(jpeg_read_header);
87 LOAD_FUNCPTR(jpeg_read_scanlines);
88 LOAD_FUNCPTR(jpeg_resync_to_restart);
89 LOAD_FUNCPTR(jpeg_start_decompress);
90 LOAD_FUNCPTR(jpeg_std_error);
91 #undef LOAD_FUNCPTR
93 return libjpeg_handle;
96 static void error_exit_fn(j_common_ptr cinfo)
98 char message[JMSG_LENGTH_MAX];
99 if (ERR_ON(jpeg))
101 cinfo->err->format_message(cinfo, message);
102 ERR_(jpeg)("%s\n", message);
104 longjmp(*(jmp_buf*)cinfo->client_data, 1);
107 static void emit_message_fn(j_common_ptr cinfo, int msg_level)
109 char message[JMSG_LENGTH_MAX];
111 if (msg_level < 0 && ERR_ON(jpeg))
113 cinfo->err->format_message(cinfo, message);
114 ERR_(jpeg)("%s\n", message);
116 else if (msg_level == 0 && WARN_ON(jpeg))
118 cinfo->err->format_message(cinfo, message);
119 WARN_(jpeg)("%s\n", message);
121 else if (msg_level > 0 && TRACE_ON(jpeg))
123 cinfo->err->format_message(cinfo, message);
124 TRACE_(jpeg)("%s\n", message);
128 typedef struct {
129 const IWICBitmapDecoderVtbl *lpVtbl;
130 const IWICBitmapFrameDecodeVtbl *lpFrameVtbl;
131 LONG ref;
132 BOOL initialized;
133 BOOL cinfo_initialized;
134 IStream *stream;
135 struct jpeg_decompress_struct cinfo;
136 struct jpeg_error_mgr jerr;
137 struct jpeg_source_mgr source_mgr;
138 BYTE source_buffer[1024];
139 BYTE *image_data;
140 CRITICAL_SECTION lock;
141 } JpegDecoder;
143 static inline JpegDecoder *decoder_from_decompress(j_decompress_ptr decompress)
145 return CONTAINING_RECORD(decompress, JpegDecoder, cinfo);
148 static inline JpegDecoder *decoder_from_frame(IWICBitmapFrameDecode *iface)
150 return CONTAINING_RECORD(iface, JpegDecoder, lpFrameVtbl);
153 static HRESULT WINAPI JpegDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
154 void **ppv)
156 JpegDecoder *This = (JpegDecoder*)iface;
157 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
159 if (!ppv) return E_INVALIDARG;
161 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid))
163 *ppv = This;
165 else
167 *ppv = NULL;
168 return E_NOINTERFACE;
171 IUnknown_AddRef((IUnknown*)*ppv);
172 return S_OK;
175 static ULONG WINAPI JpegDecoder_AddRef(IWICBitmapDecoder *iface)
177 JpegDecoder *This = (JpegDecoder*)iface;
178 ULONG ref = InterlockedIncrement(&This->ref);
180 TRACE("(%p) refcount=%u\n", iface, ref);
182 return ref;
185 static ULONG WINAPI JpegDecoder_Release(IWICBitmapDecoder *iface)
187 JpegDecoder *This = (JpegDecoder*)iface;
188 ULONG ref = InterlockedDecrement(&This->ref);
190 TRACE("(%p) refcount=%u\n", iface, ref);
192 if (ref == 0)
194 This->lock.DebugInfo->Spare[0] = 0;
195 DeleteCriticalSection(&This->lock);
196 if (This->cinfo_initialized) pjpeg_destroy_decompress(&This->cinfo);
197 if (This->stream) IStream_Release(This->stream);
198 HeapFree(GetProcessHeap(), 0, This->image_data);
199 HeapFree(GetProcessHeap(), 0, This);
202 return ref;
205 static HRESULT WINAPI JpegDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
206 DWORD *pdwCapability)
208 FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
209 return E_NOTIMPL;
212 static void source_mgr_init_source(j_decompress_ptr cinfo)
216 static jpeg_boolean source_mgr_fill_input_buffer(j_decompress_ptr cinfo)
218 JpegDecoder *This = decoder_from_decompress(cinfo);
219 HRESULT hr;
220 ULONG bytesread;
222 hr = IStream_Read(This->stream, This->source_buffer, 1024, &bytesread);
224 if (hr != S_OK || bytesread == 0)
226 return FALSE;
228 else
230 This->source_mgr.next_input_byte = This->source_buffer;
231 This->source_mgr.bytes_in_buffer = bytesread;
232 return TRUE;
236 static void source_mgr_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
238 JpegDecoder *This = decoder_from_decompress(cinfo);
239 LARGE_INTEGER seek;
241 if (num_bytes > This->source_mgr.bytes_in_buffer)
243 seek.QuadPart = num_bytes - This->source_mgr.bytes_in_buffer;
244 IStream_Seek(This->stream, seek, STREAM_SEEK_CUR, NULL);
245 This->source_mgr.bytes_in_buffer = 0;
247 else if (num_bytes > 0)
249 This->source_mgr.next_input_byte += num_bytes;
250 This->source_mgr.bytes_in_buffer -= num_bytes;
254 static void source_mgr_term_source(j_decompress_ptr cinfo)
258 static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
259 WICDecodeOptions cacheOptions)
261 JpegDecoder *This = (JpegDecoder*)iface;
262 int ret;
263 LARGE_INTEGER seek;
264 jmp_buf jmpbuf;
265 TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOptions);
267 EnterCriticalSection(&This->lock);
269 if (This->cinfo_initialized)
271 LeaveCriticalSection(&This->lock);
272 return WINCODEC_ERR_WRONGSTATE;
275 pjpeg_std_error(&This->jerr);
277 This->jerr.error_exit = error_exit_fn;
278 This->jerr.emit_message = emit_message_fn;
280 This->cinfo.err = &This->jerr;
282 This->cinfo.client_data = &jmpbuf;
284 if (setjmp(jmpbuf))
286 LeaveCriticalSection(&This->lock);
287 return E_FAIL;
290 pjpeg_CreateDecompress(&This->cinfo, JPEG_LIB_VERSION, sizeof(struct jpeg_decompress_struct));
292 This->cinfo_initialized = TRUE;
294 This->stream = pIStream;
295 IStream_AddRef(pIStream);
297 seek.QuadPart = 0;
298 IStream_Seek(This->stream, seek, STREAM_SEEK_SET, NULL);
300 This->source_mgr.bytes_in_buffer = 0;
301 This->source_mgr.init_source = source_mgr_init_source;
302 This->source_mgr.fill_input_buffer = source_mgr_fill_input_buffer;
303 This->source_mgr.skip_input_data = source_mgr_skip_input_data;
304 This->source_mgr.resync_to_restart = pjpeg_resync_to_restart;
305 This->source_mgr.term_source = source_mgr_term_source;
307 This->cinfo.src = &This->source_mgr;
309 ret = pjpeg_read_header(&This->cinfo, TRUE);
311 if (ret != JPEG_HEADER_OK) {
312 WARN("Jpeg image in stream has bad format, read header returned %d.\n",ret);
313 LeaveCriticalSection(&This->lock);
314 return E_FAIL;
317 switch (This->cinfo.jpeg_color_space)
319 case JCS_GRAYSCALE:
320 This->cinfo.out_color_space = JCS_GRAYSCALE;
321 break;
322 case JCS_RGB:
323 case JCS_YCbCr:
324 This->cinfo.out_color_space = JCS_RGB;
325 break;
326 case JCS_CMYK:
327 case JCS_YCCK:
328 This->cinfo.out_color_space = JCS_CMYK;
329 break;
330 default:
331 ERR("Unknown JPEG color space %i\n", This->cinfo.jpeg_color_space);
332 LeaveCriticalSection(&This->lock);
333 return E_FAIL;
336 if (!pjpeg_start_decompress(&This->cinfo))
338 ERR("jpeg_start_decompress failed\n");
339 LeaveCriticalSection(&This->lock);
340 return E_FAIL;
343 This->initialized = TRUE;
345 LeaveCriticalSection(&This->lock);
347 return S_OK;
350 static HRESULT WINAPI JpegDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
351 GUID *pguidContainerFormat)
353 memcpy(pguidContainerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID));
354 return S_OK;
357 static HRESULT WINAPI JpegDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
358 IWICBitmapDecoderInfo **ppIDecoderInfo)
360 FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
361 return E_NOTIMPL;
364 static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface,
365 IWICPalette *pIPalette)
367 TRACE("(%p,%p)\n", iface, pIPalette);
369 return WINCODEC_ERR_PALETTEUNAVAILABLE;
372 static HRESULT WINAPI JpegDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
373 IWICMetadataQueryReader **ppIMetadataQueryReader)
375 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
376 return E_NOTIMPL;
379 static HRESULT WINAPI JpegDecoder_GetPreview(IWICBitmapDecoder *iface,
380 IWICBitmapSource **ppIBitmapSource)
382 FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
383 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
386 static HRESULT WINAPI JpegDecoder_GetColorContexts(IWICBitmapDecoder *iface,
387 UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
389 FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
390 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
393 static HRESULT WINAPI JpegDecoder_GetThumbnail(IWICBitmapDecoder *iface,
394 IWICBitmapSource **ppIThumbnail)
396 FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
397 return WINCODEC_ERR_CODECNOTHUMBNAIL;
400 static HRESULT WINAPI JpegDecoder_GetFrameCount(IWICBitmapDecoder *iface,
401 UINT *pCount)
403 *pCount = 1;
404 return S_OK;
407 static HRESULT WINAPI JpegDecoder_GetFrame(IWICBitmapDecoder *iface,
408 UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
410 JpegDecoder *This = (JpegDecoder*)iface;
411 TRACE("(%p,%u,%p)\n", iface, index, ppIBitmapFrame);
413 if (!This->initialized) return WINCODEC_ERR_NOTINITIALIZED;
415 if (index != 0) return E_INVALIDARG;
417 IWICBitmapDecoder_AddRef(iface);
418 *ppIBitmapFrame = (IWICBitmapFrameDecode*)&This->lpFrameVtbl;
420 return S_OK;
423 static const IWICBitmapDecoderVtbl JpegDecoder_Vtbl = {
424 JpegDecoder_QueryInterface,
425 JpegDecoder_AddRef,
426 JpegDecoder_Release,
427 JpegDecoder_QueryCapability,
428 JpegDecoder_Initialize,
429 JpegDecoder_GetContainerFormat,
430 JpegDecoder_GetDecoderInfo,
431 JpegDecoder_CopyPalette,
432 JpegDecoder_GetMetadataQueryReader,
433 JpegDecoder_GetPreview,
434 JpegDecoder_GetColorContexts,
435 JpegDecoder_GetThumbnail,
436 JpegDecoder_GetFrameCount,
437 JpegDecoder_GetFrame
440 static HRESULT WINAPI JpegDecoder_Frame_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
441 void **ppv)
443 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
445 if (!ppv) return E_INVALIDARG;
447 if (IsEqualIID(&IID_IUnknown, iid) ||
448 IsEqualIID(&IID_IWICBitmapSource, iid) ||
449 IsEqualIID(&IID_IWICBitmapFrameDecode, iid))
451 *ppv = iface;
453 else
455 *ppv = NULL;
456 return E_NOINTERFACE;
459 IUnknown_AddRef((IUnknown*)*ppv);
460 return S_OK;
463 static ULONG WINAPI JpegDecoder_Frame_AddRef(IWICBitmapFrameDecode *iface)
465 JpegDecoder *This = decoder_from_frame(iface);
466 return IUnknown_AddRef((IUnknown*)This);
469 static ULONG WINAPI JpegDecoder_Frame_Release(IWICBitmapFrameDecode *iface)
471 JpegDecoder *This = decoder_from_frame(iface);
472 return IUnknown_Release((IUnknown*)This);
475 static HRESULT WINAPI JpegDecoder_Frame_GetSize(IWICBitmapFrameDecode *iface,
476 UINT *puiWidth, UINT *puiHeight)
478 JpegDecoder *This = decoder_from_frame(iface);
479 *puiWidth = This->cinfo.output_width;
480 *puiHeight = This->cinfo.output_height;
481 TRACE("(%p)->(%u,%u)\n", iface, *puiWidth, *puiHeight);
482 return S_OK;
485 static HRESULT WINAPI JpegDecoder_Frame_GetPixelFormat(IWICBitmapFrameDecode *iface,
486 WICPixelFormatGUID *pPixelFormat)
488 JpegDecoder *This = decoder_from_frame(iface);
489 TRACE("(%p,%p)\n", iface, pPixelFormat);
490 if (This->cinfo.out_color_space == JCS_RGB)
491 memcpy(pPixelFormat, &GUID_WICPixelFormat24bppBGR, sizeof(GUID));
492 else if (This->cinfo.out_color_space == JCS_CMYK)
493 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppCMYK, sizeof(GUID));
494 else /* This->cinfo.out_color_space == JCS_GRAYSCALE */
495 memcpy(pPixelFormat, &GUID_WICPixelFormat8bppGray, sizeof(GUID));
496 return S_OK;
499 static HRESULT WINAPI JpegDecoder_Frame_GetResolution(IWICBitmapFrameDecode *iface,
500 double *pDpiX, double *pDpiY)
502 FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
503 return E_NOTIMPL;
506 static HRESULT WINAPI JpegDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface,
507 IWICPalette *pIPalette)
509 FIXME("(%p,%p): stub\n", iface, pIPalette);
510 return E_NOTIMPL;
513 static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
514 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
516 JpegDecoder *This = decoder_from_frame(iface);
517 UINT bpp;
518 UINT stride;
519 UINT data_size;
520 UINT max_row_needed;
521 jmp_buf jmpbuf;
522 WICRect rect;
523 TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
525 if (!prc)
527 rect.X = 0;
528 rect.Y = 0;
529 rect.Width = This->cinfo.output_width;
530 rect.Height = This->cinfo.output_height;
531 prc = &rect;
533 else
535 if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->cinfo.output_width ||
536 prc->Y+prc->Height > This->cinfo.output_height)
537 return E_INVALIDARG;
540 if (This->cinfo.out_color_space == JCS_GRAYSCALE) bpp = 8;
541 else if (This->cinfo.out_color_space == JCS_CMYK) bpp = 32;
542 else bpp = 24;
544 stride = bpp * This->cinfo.output_width;
545 data_size = stride * This->cinfo.output_height;
547 max_row_needed = prc->Y + prc->Height;
548 if (max_row_needed > This->cinfo.output_height) return E_INVALIDARG;
550 EnterCriticalSection(&This->lock);
552 if (!This->image_data)
554 This->image_data = HeapAlloc(GetProcessHeap(), 0, data_size);
555 if (!This->image_data)
557 LeaveCriticalSection(&This->lock);
558 return E_OUTOFMEMORY;
562 This->cinfo.client_data = &jmpbuf;
564 if (setjmp(jmpbuf))
566 LeaveCriticalSection(&This->lock);
567 return E_FAIL;
570 while (max_row_needed > This->cinfo.output_scanline)
572 UINT first_scanline = This->cinfo.output_scanline;
573 UINT max_rows;
574 JSAMPROW out_rows[4];
575 UINT i, j;
576 JDIMENSION ret;
578 max_rows = min(This->cinfo.output_height-first_scanline, 4);
579 for (i=0; i<max_rows; i++)
580 out_rows[i] = This->image_data + stride * (first_scanline+i);
582 ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows);
584 if (ret == 0)
586 ERR("read_scanlines failed\n");
587 LeaveCriticalSection(&This->lock);
588 return E_FAIL;
591 if (bpp == 24)
593 /* libjpeg gives us RGB data and we want BGR, so byteswap the data */
594 for (i=first_scanline; i<This->cinfo.output_scanline; i++)
596 BYTE *pixel = This->image_data + stride * i;
597 for (j=0; j<This->cinfo.output_width; j++)
599 BYTE red=pixel[0];
600 BYTE blue=pixel[2];
601 pixel[0]=blue;
602 pixel[2]=red;
603 pixel+=3;
608 if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
609 /* Adobe JPEG's have inverted CMYK data. */
610 for (i=0; i<data_size; i++)
611 This->image_data[i] ^= 0xff;
614 LeaveCriticalSection(&This->lock);
616 return copy_pixels(bpp, This->image_data,
617 This->cinfo.output_width, This->cinfo.output_height, stride,
618 prc, cbStride, cbBufferSize, pbBuffer);
621 static HRESULT WINAPI JpegDecoder_Frame_GetMetadataQueryReader(IWICBitmapFrameDecode *iface,
622 IWICMetadataQueryReader **ppIMetadataQueryReader)
624 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
625 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
628 static HRESULT WINAPI JpegDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *iface,
629 UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
631 FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
632 return WINCODEC_ERR_UNSUPPORTEDOPERATION;
635 static HRESULT WINAPI JpegDecoder_Frame_GetThumbnail(IWICBitmapFrameDecode *iface,
636 IWICBitmapSource **ppIThumbnail)
638 FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
639 return WINCODEC_ERR_CODECNOTHUMBNAIL;
642 static const IWICBitmapFrameDecodeVtbl JpegDecoder_Frame_Vtbl = {
643 JpegDecoder_Frame_QueryInterface,
644 JpegDecoder_Frame_AddRef,
645 JpegDecoder_Frame_Release,
646 JpegDecoder_Frame_GetSize,
647 JpegDecoder_Frame_GetPixelFormat,
648 JpegDecoder_Frame_GetResolution,
649 JpegDecoder_Frame_CopyPalette,
650 JpegDecoder_Frame_CopyPixels,
651 JpegDecoder_Frame_GetMetadataQueryReader,
652 JpegDecoder_Frame_GetColorContexts,
653 JpegDecoder_Frame_GetThumbnail
656 HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
658 JpegDecoder *This;
659 HRESULT ret;
661 TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
663 if (!libjpeg_handle && !load_libjpeg())
665 ERR("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG);
666 return E_FAIL;
669 *ppv = NULL;
671 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
673 This = HeapAlloc(GetProcessHeap(), 0, sizeof(JpegDecoder));
674 if (!This) return E_OUTOFMEMORY;
676 This->lpVtbl = &JpegDecoder_Vtbl;
677 This->lpFrameVtbl = &JpegDecoder_Frame_Vtbl;
678 This->ref = 1;
679 This->initialized = FALSE;
680 This->cinfo_initialized = FALSE;
681 This->stream = NULL;
682 This->image_data = NULL;
683 InitializeCriticalSection(&This->lock);
684 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JpegDecoder.lock");
686 ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
687 IUnknown_Release((IUnknown*)This);
689 return ret;
692 #else /* !defined(SONAME_LIBJPEG) */
694 HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
696 ERR("Trying to load JPEG picture, but JPEG support is not compiled in.\n");
697 return E_FAIL;
700 #endif