windowscodecs: Move TIFF decoding to unix lib.
Signed-off-by: Esme Povirk <esme@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
26d5d384f1
commit
6abf518ece
|
@ -23,6 +23,7 @@ C_SRCS = \
|
|||
info.c \
|
||||
jpegformat.c \
|
||||
libpng.c \
|
||||
libtiff.c \
|
||||
main.c \
|
||||
metadatahandler.c \
|
||||
metadataquery.c \
|
||||
|
|
|
@ -216,9 +216,11 @@ static HRESULT WINAPI CommonDecoder_GetFrameCount(IWICBitmapDecoder *iface,
|
|||
CommonDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
if (!pCount) return E_INVALIDARG;
|
||||
|
||||
if (!This->stream) return WINCODEC_ERR_WRONGSTATE;
|
||||
if (This->stream)
|
||||
*pCount = This->file_info.frame_count;
|
||||
else
|
||||
*pCount = 0;
|
||||
|
||||
*pCount = This->file_info.frame_count;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -606,23 +608,69 @@ static HRESULT WINAPI CommonDecoderFrame_Block_GetReaderByIndex(IWICMetadataBloc
|
|||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ULARGE_INTEGER offset, length;
|
||||
|
||||
offset.QuadPart = This->metadata_blocks[nIndex].offset;
|
||||
length.QuadPart = This->metadata_blocks[nIndex].length;
|
||||
hr = IWICStream_InitializeFromIStreamRegion(stream, This->parent->stream,
|
||||
offset, length);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = ImagingFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (This->metadata_blocks[nIndex].options & DECODER_BLOCK_FULL_STREAM)
|
||||
{
|
||||
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
|
||||
&This->parent->decoder_info.block_format, NULL, This->metadata_blocks[nIndex].options,
|
||||
(IStream*)stream, ppIMetadataReader);
|
||||
LARGE_INTEGER offset;
|
||||
offset.QuadPart = This->metadata_blocks[nIndex].offset;
|
||||
|
||||
IWICComponentFactory_Release(factory);
|
||||
hr = IWICStream_InitializeFromIStream(stream, This->parent->stream);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = IWICStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ULARGE_INTEGER offset, length;
|
||||
|
||||
offset.QuadPart = This->metadata_blocks[nIndex].offset;
|
||||
length.QuadPart = This->metadata_blocks[nIndex].length;
|
||||
|
||||
hr = IWICStream_InitializeFromIStreamRegion(stream, This->parent->stream,
|
||||
offset, length);
|
||||
}
|
||||
|
||||
if (This->metadata_blocks[nIndex].options & DECODER_BLOCK_READER_CLSID)
|
||||
{
|
||||
IWICMetadataReader *reader;
|
||||
IWICPersistStream *persist;
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = create_instance(&This->metadata_blocks[nIndex].reader_clsid,
|
||||
&IID_IWICMetadataReader, (void**)&reader);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICMetadataReader_QueryInterface(reader, &IID_IWICPersistStream, (void**)&persist);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICPersistStream_LoadEx(persist, (IStream*)stream, NULL,
|
||||
This->metadata_blocks[nIndex].options & DECODER_BLOCK_OPTION_MASK);
|
||||
|
||||
IWICPersistStream_Release(persist);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
*ppIMetadataReader = reader;
|
||||
else
|
||||
IWICMetadataReader_Release(reader);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SUCCEEDED(hr))
|
||||
hr = ImagingFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
|
||||
&This->parent->decoder_info.block_format, NULL,
|
||||
This->metadata_blocks[nIndex].options & DECODER_BLOCK_OPTION_MASK,
|
||||
(IStream*)stream, ppIMetadataReader);
|
||||
|
||||
IWICComponentFactory_Release(factory);
|
||||
}
|
||||
}
|
||||
|
||||
IWICStream_Release(stream);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -191,6 +191,19 @@ HRESULT write_source(IWICBitmapFrameEncode *iface,
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT CDECL stream_getsize(IStream *stream, ULONGLONG *size)
|
||||
{
|
||||
STATSTG statstg;
|
||||
HRESULT hr;
|
||||
|
||||
hr = IStream_Stat(stream, &statstg, STATFLAG_NONAME);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
*size = statstg.cbSize.QuadPart;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT CDECL stream_read(IStream *stream, void *buffer, ULONG read, ULONG *bytes_read)
|
||||
{
|
||||
return IStream_Read(stream, buffer, read, bytes_read);
|
||||
|
@ -210,25 +223,6 @@ HRESULT CDECL stream_seek(IStream *stream, LONGLONG ofs, DWORD origin, ULONGLONG
|
|||
return hr;
|
||||
}
|
||||
|
||||
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
|
||||
{
|
||||
UINT x, y;
|
||||
BYTE *pixel, temp;
|
||||
|
||||
for (y=0; y<height; y++)
|
||||
{
|
||||
pixel = bits + stride * y;
|
||||
|
||||
for (x=0; x<width; x++)
|
||||
{
|
||||
temp = pixel[2];
|
||||
pixel[2] = pixel[0];
|
||||
pixel[0] = temp;
|
||||
pixel += bytesperpixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT get_pixelformat_bpp(const GUID *pixelformat, UINT *bpp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,6 +40,7 @@ static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
|||
static const struct unix_funcs *unix_funcs;
|
||||
|
||||
static const struct win32_funcs win32_funcs = {
|
||||
stream_getsize,
|
||||
stream_read,
|
||||
stream_seek
|
||||
};
|
||||
|
|
|
@ -47,6 +47,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
|
|||
|
||||
static const struct win32_funcs *win32_funcs;
|
||||
|
||||
HRESULT CDECL stream_getsize(IStream *stream, ULONGLONG *size)
|
||||
{
|
||||
return win32_funcs->stream_getsize(stream, size);
|
||||
}
|
||||
|
||||
HRESULT CDECL stream_read(IStream *stream, void *buffer, ULONG read, ULONG *bytes_read)
|
||||
{
|
||||
return win32_funcs->stream_read(stream, buffer, read, bytes_read);
|
||||
|
@ -62,6 +67,9 @@ HRESULT CDECL decoder_create(const CLSID *decoder_clsid, struct decoder_info *in
|
|||
if (IsEqualGUID(decoder_clsid, &CLSID_WICPngDecoder))
|
||||
return png_decoder_create(info, result);
|
||||
|
||||
if (IsEqualGUID(decoder_clsid, &CLSID_WICTiffDecoder))
|
||||
return tiff_decoder_create(info, result);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,3 +158,22 @@ HRESULT read_png_chunk(IStream *stream, BYTE *type, BYTE **data, ULONG *data_siz
|
|||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
|
||||
{
|
||||
UINT x, y;
|
||||
BYTE *pixel, temp;
|
||||
|
||||
for (y=0; y<height; y++)
|
||||
{
|
||||
pixel = bits + stride * y;
|
||||
|
||||
for (x=0; x<width; x++)
|
||||
{
|
||||
temp = pixel[2];
|
||||
pixel[2] = pixel[0];
|
||||
pixel[0] = temp;
|
||||
pixel += bytesperpixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,11 +280,15 @@ struct decoder_frame
|
|||
WICColor palette[256];
|
||||
};
|
||||
|
||||
#define DECODER_BLOCK_OPTION_MASK 0x0001000F
|
||||
#define DECODER_BLOCK_FULL_STREAM 0x80000000
|
||||
#define DECODER_BLOCK_READER_CLSID 0x40000000
|
||||
struct decoder_block
|
||||
{
|
||||
ULONGLONG offset;
|
||||
ULONGLONG length;
|
||||
DWORD options;
|
||||
GUID reader_clsid;
|
||||
};
|
||||
|
||||
struct decoder
|
||||
|
@ -305,11 +309,13 @@ struct decoder_funcs
|
|||
void (CDECL *destroy)(struct decoder* This);
|
||||
};
|
||||
|
||||
HRESULT CDECL stream_getsize(IStream *stream, ULONGLONG *size);
|
||||
HRESULT CDECL stream_read(IStream *stream, void *buffer, ULONG read, ULONG *bytes_read);
|
||||
HRESULT CDECL stream_seek(IStream *stream, LONGLONG ofs, DWORD origin, ULONGLONG *new_position);
|
||||
|
||||
struct win32_funcs
|
||||
{
|
||||
HRESULT (CDECL *stream_getsize)(IStream *stream, ULONGLONG *size);
|
||||
HRESULT (CDECL *stream_read)(IStream *stream, void *buffer, ULONG read, ULONG *bytes_read);
|
||||
HRESULT (CDECL *stream_seek)(IStream *stream, LONGLONG ofs, DWORD origin, ULONGLONG *new_position);
|
||||
};
|
||||
|
@ -326,6 +332,7 @@ HRESULT CDECL decoder_get_color_context(struct decoder* This, UINT frame, UINT n
|
|||
void CDECL decoder_destroy(struct decoder *This);
|
||||
|
||||
HRESULT CDECL png_decoder_create(struct decoder_info *info, struct decoder **result);
|
||||
HRESULT CDECL tiff_decoder_create(struct decoder_info *info, struct decoder **result);
|
||||
|
||||
struct unix_funcs
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue