ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

jpegformat.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2009 Vincent Povirk for CodeWeavers
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #include "config.h"
00020 #include "wine/port.h"
00021 
00022 #ifdef HAVE_UNISTD_H
00023 # include <unistd.h>
00024 #endif
00025 #include <stdarg.h>
00026 #include <stdio.h>
00027 #include <string.h>
00028 
00029 #ifdef SONAME_LIBJPEG
00030 /* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
00031 #define XMD_H
00032 #define UINT8 JPEG_UINT8
00033 #define UINT16 JPEG_UINT16
00034 #define boolean jpeg_boolean
00035 #undef HAVE_STDLIB_H
00036 # include <jpeglib.h>
00037 #undef HAVE_STDLIB_H
00038 #define HAVE_STDLIB_H 1
00039 #undef UINT8
00040 #undef UINT16
00041 #undef boolean
00042 #endif
00043 
00044 #define COBJMACROS
00045 
00046 #include "windef.h"
00047 #include "winbase.h"
00048 #include "objbase.h"
00049 #include "wincodec.h"
00050 
00051 #include "wincodecs_private.h"
00052 
00053 #include "wine/debug.h"
00054 #include "wine/library.h"
00055 
00056 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
00057 
00058 #ifdef SONAME_LIBJPEG
00059 
00060 static void *libjpeg_handle;
00061 
00062 #define MAKE_FUNCPTR(f) static typeof(f) * p##f
00063 MAKE_FUNCPTR(jpeg_CreateDecompress);
00064 MAKE_FUNCPTR(jpeg_destroy_decompress);
00065 MAKE_FUNCPTR(jpeg_read_header);
00066 MAKE_FUNCPTR(jpeg_read_scanlines);
00067 MAKE_FUNCPTR(jpeg_resync_to_restart);
00068 MAKE_FUNCPTR(jpeg_start_decompress);
00069 MAKE_FUNCPTR(jpeg_std_error);
00070 #undef MAKE_FUNCPTR
00071 
00072 static void *load_libjpeg(void)
00073 {
00074     if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) {
00075 
00076 #define LOAD_FUNCPTR(f) \
00077     if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \
00078         libjpeg_handle = NULL; \
00079         return NULL; \
00080     }
00081 
00082         LOAD_FUNCPTR(jpeg_CreateDecompress);
00083         LOAD_FUNCPTR(jpeg_destroy_decompress);
00084         LOAD_FUNCPTR(jpeg_read_header);
00085         LOAD_FUNCPTR(jpeg_read_scanlines);
00086         LOAD_FUNCPTR(jpeg_resync_to_restart);
00087         LOAD_FUNCPTR(jpeg_start_decompress);
00088         LOAD_FUNCPTR(jpeg_std_error);
00089 #undef LOAD_FUNCPTR
00090     }
00091     return libjpeg_handle;
00092 }
00093 
00094 typedef struct {
00095     const IWICBitmapDecoderVtbl *lpVtbl;
00096     const IWICBitmapFrameDecodeVtbl *lpFrameVtbl;
00097     LONG ref;
00098     BOOL initialized;
00099     BOOL cinfo_initialized;
00100     IStream *stream;
00101     struct jpeg_decompress_struct cinfo;
00102     struct jpeg_error_mgr jerr;
00103     struct jpeg_source_mgr source_mgr;
00104     BYTE source_buffer[1024];
00105     BYTE *image_data;
00106     CRITICAL_SECTION lock;
00107 } JpegDecoder;
00108 
00109 static inline JpegDecoder *decoder_from_decompress(j_decompress_ptr decompress)
00110 {
00111     return CONTAINING_RECORD(decompress, JpegDecoder, cinfo);
00112 }
00113 
00114 static inline JpegDecoder *decoder_from_frame(IWICBitmapFrameDecode *iface)
00115 {
00116     return CONTAINING_RECORD(iface, JpegDecoder, lpFrameVtbl);
00117 }
00118 
00119 static HRESULT WINAPI JpegDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
00120     void **ppv)
00121 {
00122     JpegDecoder *This = (JpegDecoder*)iface;
00123     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
00124 
00125     if (!ppv) return E_INVALIDARG;
00126 
00127     if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid))
00128     {
00129         *ppv = This;
00130     }
00131     else
00132     {
00133         *ppv = NULL;
00134         return E_NOINTERFACE;
00135     }
00136 
00137     IUnknown_AddRef((IUnknown*)*ppv);
00138     return S_OK;
00139 }
00140 
00141 static ULONG WINAPI JpegDecoder_AddRef(IWICBitmapDecoder *iface)
00142 {
00143     JpegDecoder *This = (JpegDecoder*)iface;
00144     ULONG ref = InterlockedIncrement(&This->ref);
00145 
00146     TRACE("(%p) refcount=%u\n", iface, ref);
00147 
00148     return ref;
00149 }
00150 
00151 static ULONG WINAPI JpegDecoder_Release(IWICBitmapDecoder *iface)
00152 {
00153     JpegDecoder *This = (JpegDecoder*)iface;
00154     ULONG ref = InterlockedDecrement(&This->ref);
00155 
00156     TRACE("(%p) refcount=%u\n", iface, ref);
00157 
00158     if (ref == 0)
00159     {
00160         This->lock.DebugInfo->Spare[0] = 0;
00161         DeleteCriticalSection(&This->lock);
00162         if (This->cinfo_initialized) pjpeg_destroy_decompress(&This->cinfo);
00163         if (This->stream) IStream_Release(This->stream);
00164         HeapFree(GetProcessHeap(), 0, This->image_data);
00165         HeapFree(GetProcessHeap(), 0, This);
00166     }
00167 
00168     return ref;
00169 }
00170 
00171 static HRESULT WINAPI JpegDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
00172     DWORD *pdwCapability)
00173 {
00174     FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
00175     return E_NOTIMPL;
00176 }
00177 
00178 static void source_mgr_init_source(j_decompress_ptr cinfo)
00179 {
00180 }
00181 
00182 static jpeg_boolean source_mgr_fill_input_buffer(j_decompress_ptr cinfo)
00183 {
00184     JpegDecoder *This = decoder_from_decompress(cinfo);
00185     HRESULT hr;
00186     ULONG bytesread;
00187 
00188     hr = IStream_Read(This->stream, This->source_buffer, 1024, &bytesread);
00189 
00190     if (hr != S_OK || bytesread == 0)
00191     {
00192         return FALSE;
00193     }
00194     else
00195     {
00196         This->source_mgr.next_input_byte = This->source_buffer;
00197         This->source_mgr.bytes_in_buffer = bytesread;
00198         return TRUE;
00199     }
00200 }
00201 
00202 static void source_mgr_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
00203 {
00204     JpegDecoder *This = decoder_from_decompress(cinfo);
00205     LARGE_INTEGER seek;
00206 
00207     if (num_bytes > This->source_mgr.bytes_in_buffer)
00208     {
00209         seek.QuadPart = num_bytes - This->source_mgr.bytes_in_buffer;
00210         IStream_Seek(This->stream, seek, STREAM_SEEK_CUR, NULL);
00211         This->source_mgr.bytes_in_buffer = 0;
00212     }
00213     else if (num_bytes > 0)
00214     {
00215         This->source_mgr.next_input_byte += num_bytes;
00216         This->source_mgr.bytes_in_buffer -= num_bytes;
00217     }
00218 }
00219 
00220 static void source_mgr_term_source(j_decompress_ptr cinfo)
00221 {
00222 }
00223 
00224 static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
00225     WICDecodeOptions cacheOptions)
00226 {
00227     JpegDecoder *This = (JpegDecoder*)iface;
00228     int ret;
00229     TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOptions);
00230 
00231     EnterCriticalSection(&This->lock);
00232 
00233     if (This->cinfo_initialized)
00234     {
00235         LeaveCriticalSection(&This->lock);
00236         return WINCODEC_ERR_WRONGSTATE;
00237     }
00238 
00239     This->cinfo.err = pjpeg_std_error(&This->jerr);
00240 
00241     pjpeg_CreateDecompress(&This->cinfo, JPEG_LIB_VERSION, sizeof(struct jpeg_decompress_struct));
00242 
00243     This->cinfo_initialized = TRUE;
00244 
00245     This->stream = pIStream;
00246     IStream_AddRef(pIStream);
00247 
00248     This->source_mgr.bytes_in_buffer = 0;
00249     This->source_mgr.init_source = source_mgr_init_source;
00250     This->source_mgr.fill_input_buffer = source_mgr_fill_input_buffer;
00251     This->source_mgr.skip_input_data = source_mgr_skip_input_data;
00252     This->source_mgr.resync_to_restart = pjpeg_resync_to_restart;
00253     This->source_mgr.term_source = source_mgr_term_source;
00254 
00255     This->cinfo.src = &This->source_mgr;
00256 
00257     ret = pjpeg_read_header(&This->cinfo, TRUE);
00258 
00259     if (ret != JPEG_HEADER_OK) {
00260         WARN("Jpeg image in stream has bad format, read header returned %d.\n",ret);
00261         LeaveCriticalSection(&This->lock);
00262         return E_FAIL;
00263     }
00264 
00265     if (This->cinfo.jpeg_color_space == JCS_GRAYSCALE)
00266         This->cinfo.out_color_space = JCS_GRAYSCALE;
00267     else
00268         This->cinfo.out_color_space = JCS_RGB;
00269 
00270     if (!pjpeg_start_decompress(&This->cinfo))
00271     {
00272         ERR("jpeg_start_decompress failed\n");
00273         LeaveCriticalSection(&This->lock);
00274         return E_FAIL;
00275     }
00276 
00277     This->initialized = TRUE;
00278 
00279     LeaveCriticalSection(&This->lock);
00280 
00281     return S_OK;
00282 }
00283 
00284 static HRESULT WINAPI JpegDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
00285     GUID *pguidContainerFormat)
00286 {
00287     memcpy(pguidContainerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID));
00288     return S_OK;
00289 }
00290 
00291 static HRESULT WINAPI JpegDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
00292     IWICBitmapDecoderInfo **ppIDecoderInfo)
00293 {
00294     FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
00295     return E_NOTIMPL;
00296 }
00297 
00298 static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface,
00299     IWICPalette *pIPalette)
00300 {
00301     TRACE("(%p,%p)\n", iface, pIPalette);
00302 
00303     return WINCODEC_ERR_PALETTEUNAVAILABLE;
00304 }
00305 
00306 static HRESULT WINAPI JpegDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
00307     IWICMetadataQueryReader **ppIMetadataQueryReader)
00308 {
00309     FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
00310     return E_NOTIMPL;
00311 }
00312 
00313 static HRESULT WINAPI JpegDecoder_GetPreview(IWICBitmapDecoder *iface,
00314     IWICBitmapSource **ppIBitmapSource)
00315 {
00316     FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
00317     return WINCODEC_ERR_UNSUPPORTEDOPERATION;
00318 }
00319 
00320 static HRESULT WINAPI JpegDecoder_GetColorContexts(IWICBitmapDecoder *iface,
00321     UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
00322 {
00323     FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
00324     return WINCODEC_ERR_UNSUPPORTEDOPERATION;
00325 }
00326 
00327 static HRESULT WINAPI JpegDecoder_GetThumbnail(IWICBitmapDecoder *iface,
00328     IWICBitmapSource **ppIThumbnail)
00329 {
00330     FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
00331     return WINCODEC_ERR_CODECNOTHUMBNAIL;
00332 }
00333 
00334 static HRESULT WINAPI JpegDecoder_GetFrameCount(IWICBitmapDecoder *iface,
00335     UINT *pCount)
00336 {
00337     *pCount = 1;
00338     return S_OK;
00339 }
00340 
00341 static HRESULT WINAPI JpegDecoder_GetFrame(IWICBitmapDecoder *iface,
00342     UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
00343 {
00344     JpegDecoder *This = (JpegDecoder*)iface;
00345     TRACE("(%p,%u,%p)\n", iface, index, ppIBitmapFrame);
00346 
00347     if (!This->initialized) return WINCODEC_ERR_NOTINITIALIZED;
00348 
00349     if (index != 0) return E_INVALIDARG;
00350 
00351     IWICBitmapDecoder_AddRef(iface);
00352     *ppIBitmapFrame = (IWICBitmapFrameDecode*)&This->lpFrameVtbl;
00353 
00354     return S_OK;
00355 }
00356 
00357 static const IWICBitmapDecoderVtbl JpegDecoder_Vtbl = {
00358     JpegDecoder_QueryInterface,
00359     JpegDecoder_AddRef,
00360     JpegDecoder_Release,
00361     JpegDecoder_QueryCapability,
00362     JpegDecoder_Initialize,
00363     JpegDecoder_GetContainerFormat,
00364     JpegDecoder_GetDecoderInfo,
00365     JpegDecoder_CopyPalette,
00366     JpegDecoder_GetMetadataQueryReader,
00367     JpegDecoder_GetPreview,
00368     JpegDecoder_GetColorContexts,
00369     JpegDecoder_GetThumbnail,
00370     JpegDecoder_GetFrameCount,
00371     JpegDecoder_GetFrame
00372 };
00373 
00374 static HRESULT WINAPI JpegDecoder_Frame_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
00375     void **ppv)
00376 {
00377     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
00378 
00379     if (!ppv) return E_INVALIDARG;
00380 
00381     if (IsEqualIID(&IID_IUnknown, iid) ||
00382         IsEqualIID(&IID_IWICBitmapSource, iid) ||
00383         IsEqualIID(&IID_IWICBitmapFrameDecode, iid))
00384     {
00385         *ppv = iface;
00386     }
00387     else
00388     {
00389         *ppv = NULL;
00390         return E_NOINTERFACE;
00391     }
00392 
00393     IUnknown_AddRef((IUnknown*)*ppv);
00394     return S_OK;
00395 }
00396 
00397 static ULONG WINAPI JpegDecoder_Frame_AddRef(IWICBitmapFrameDecode *iface)
00398 {
00399     JpegDecoder *This = decoder_from_frame(iface);
00400     return IUnknown_AddRef((IUnknown*)This);
00401 }
00402 
00403 static ULONG WINAPI JpegDecoder_Frame_Release(IWICBitmapFrameDecode *iface)
00404 {
00405     JpegDecoder *This = decoder_from_frame(iface);
00406     return IUnknown_Release((IUnknown*)This);
00407 }
00408 
00409 static HRESULT WINAPI JpegDecoder_Frame_GetSize(IWICBitmapFrameDecode *iface,
00410     UINT *puiWidth, UINT *puiHeight)
00411 {
00412     JpegDecoder *This = decoder_from_frame(iface);
00413     *puiWidth = This->cinfo.output_width;
00414     *puiHeight = This->cinfo.output_height;
00415     TRACE("(%p)->(%u,%u)\n", iface, *puiWidth, *puiHeight);
00416     return S_OK;
00417 }
00418 
00419 static HRESULT WINAPI JpegDecoder_Frame_GetPixelFormat(IWICBitmapFrameDecode *iface,
00420     WICPixelFormatGUID *pPixelFormat)
00421 {
00422     JpegDecoder *This = decoder_from_frame(iface);
00423     TRACE("(%p,%p)\n", iface, pPixelFormat);
00424     if (This->cinfo.out_color_space == JCS_RGB)
00425         memcpy(pPixelFormat, &GUID_WICPixelFormat24bppBGR, sizeof(GUID));
00426     else /* This->cinfo.out_color_space == JCS_GRAYSCALE */
00427         memcpy(pPixelFormat, &GUID_WICPixelFormat8bppGray, sizeof(GUID));
00428     return S_OK;
00429 }
00430 
00431 static HRESULT WINAPI JpegDecoder_Frame_GetResolution(IWICBitmapFrameDecode *iface,
00432     double *pDpiX, double *pDpiY)
00433 {
00434     FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
00435     return E_NOTIMPL;
00436 }
00437 
00438 static HRESULT WINAPI JpegDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface,
00439     IWICPalette *pIPalette)
00440 {
00441     FIXME("(%p,%p): stub\n", iface, pIPalette);
00442     return E_NOTIMPL;
00443 }
00444 
00445 static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
00446     const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
00447 {
00448     JpegDecoder *This = decoder_from_frame(iface);
00449     UINT bpp;
00450     UINT stride;
00451     UINT data_size;
00452     UINT max_row_needed;
00453     TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
00454 
00455     if (This->cinfo.out_color_space == JCS_GRAYSCALE) bpp = 8;
00456     else bpp = 24;
00457 
00458     stride = bpp * This->cinfo.output_width;
00459     data_size = stride * This->cinfo.output_height;
00460 
00461     max_row_needed = prc->Y + prc->Height;
00462     if (max_row_needed > This->cinfo.output_height) return E_INVALIDARG;
00463 
00464     EnterCriticalSection(&This->lock);
00465 
00466     if (!This->image_data)
00467     {
00468         This->image_data = HeapAlloc(GetProcessHeap(), 0, data_size);
00469         if (!This->image_data)
00470         {
00471             LeaveCriticalSection(&This->lock);
00472             return E_OUTOFMEMORY;
00473         }
00474     }
00475 
00476     while (max_row_needed > This->cinfo.output_scanline)
00477     {
00478         UINT first_scanline = This->cinfo.output_scanline;
00479         UINT max_rows;
00480         JSAMPROW out_rows[4];
00481         UINT i, j;
00482         JDIMENSION ret;
00483 
00484         max_rows = min(This->cinfo.output_height-first_scanline, 4);
00485         for (i=0; i<max_rows; i++)
00486             out_rows[i] = This->image_data + stride * (first_scanline+i);
00487 
00488         ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows);
00489 
00490         if (ret == 0)
00491         {
00492             ERR("read_scanlines failed\n");
00493             LeaveCriticalSection(&This->lock);
00494             return E_FAIL;
00495         }
00496 
00497         if (bpp == 24)
00498         {
00499             /* libjpeg gives us RGB data and we want BGR, so byteswap the data */
00500             for (i=first_scanline; i<This->cinfo.output_scanline; i++)
00501             {
00502                 BYTE *pixel = This->image_data + stride * i;
00503                 for (j=0; j<This->cinfo.output_width; j++)
00504                 {
00505                     BYTE red=pixel[0];
00506                     BYTE blue=pixel[2];
00507                     pixel[0]=blue;
00508                     pixel[2]=red;
00509                     pixel+=3;
00510                 }
00511             }
00512         }
00513     }
00514 
00515     LeaveCriticalSection(&This->lock);
00516 
00517     return copy_pixels(bpp, This->image_data,
00518         This->cinfo.output_width, This->cinfo.output_height, stride,
00519         prc, cbStride, cbBufferSize, pbBuffer);
00520 }
00521 
00522 static HRESULT WINAPI JpegDecoder_Frame_GetMetadataQueryReader(IWICBitmapFrameDecode *iface,
00523     IWICMetadataQueryReader **ppIMetadataQueryReader)
00524 {
00525     FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
00526     return WINCODEC_ERR_UNSUPPORTEDOPERATION;
00527 }
00528 
00529 static HRESULT WINAPI JpegDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *iface,
00530     UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
00531 {
00532     FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
00533     return WINCODEC_ERR_UNSUPPORTEDOPERATION;
00534 }
00535 
00536 static HRESULT WINAPI JpegDecoder_Frame_GetThumbnail(IWICBitmapFrameDecode *iface,
00537     IWICBitmapSource **ppIThumbnail)
00538 {
00539     FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
00540     return WINCODEC_ERR_CODECNOTHUMBNAIL;
00541 }
00542 
00543 static const IWICBitmapFrameDecodeVtbl JpegDecoder_Frame_Vtbl = {
00544     JpegDecoder_Frame_QueryInterface,
00545     JpegDecoder_Frame_AddRef,
00546     JpegDecoder_Frame_Release,
00547     JpegDecoder_Frame_GetSize,
00548     JpegDecoder_Frame_GetPixelFormat,
00549     JpegDecoder_Frame_GetResolution,
00550     JpegDecoder_Frame_CopyPalette,
00551     JpegDecoder_Frame_CopyPixels,
00552     JpegDecoder_Frame_GetMetadataQueryReader,
00553     JpegDecoder_Frame_GetColorContexts,
00554     JpegDecoder_Frame_GetThumbnail
00555 };
00556 
00557 HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
00558 {
00559     JpegDecoder *This;
00560     HRESULT ret;
00561 
00562     TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
00563 
00564     if (!libjpeg_handle && !load_libjpeg())
00565     {
00566         ERR("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG);
00567         return E_FAIL;
00568     }
00569 
00570     *ppv = NULL;
00571 
00572     if (pUnkOuter) return CLASS_E_NOAGGREGATION;
00573 
00574     This = HeapAlloc(GetProcessHeap(), 0, sizeof(JpegDecoder));
00575     if (!This) return E_OUTOFMEMORY;
00576 
00577     This->lpVtbl = &JpegDecoder_Vtbl;
00578     This->lpFrameVtbl = &JpegDecoder_Frame_Vtbl;
00579     This->ref = 1;
00580     This->initialized = FALSE;
00581     This->cinfo_initialized = FALSE;
00582     This->stream = NULL;
00583     This->image_data = NULL;
00584     InitializeCriticalSection(&This->lock);
00585     This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JpegDecoder.lock");
00586 
00587     ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
00588     IUnknown_Release((IUnknown*)This);
00589 
00590     return ret;
00591 }
00592 
00593 #else /* !defined(SONAME_LIBJPEG) */
00594 
00595 HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
00596 {
00597     ERR("Trying to load JPEG picture, but JPEG support is not compiled in.\n");
00598     return E_FAIL;
00599 }
00600 
00601 #endif

Generated on Sat May 26 2012 04:25:24 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.