Commit fd31112a authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: Add support for preferred vendor guid in CreateDecoderFromStream.

parent 74d53af5
...@@ -122,11 +122,11 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream( ...@@ -122,11 +122,11 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
IWICImagingFactory *iface, IStream *pIStream, const GUID *pguidVendor, IWICImagingFactory *iface, IStream *pIStream, const GUID *pguidVendor,
WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder) WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
{ {
static int fixme=0;
IEnumUnknown *enumdecoders; IEnumUnknown *enumdecoders;
IUnknown *unkdecoderinfo; IUnknown *unkdecoderinfo;
IWICBitmapDecoderInfo *decoderinfo; IWICBitmapDecoderInfo *decoderinfo;
IWICBitmapDecoder *decoder=NULL; IWICBitmapDecoder *decoder = NULL, *preferred_decoder = NULL;
GUID vendor;
HRESULT res=S_OK; HRESULT res=S_OK;
ULONG num_fetched; ULONG num_fetched;
BOOL matches; BOOL matches;
...@@ -134,13 +134,10 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream( ...@@ -134,13 +134,10 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
TRACE("(%p,%p,%s,%u,%p)\n", iface, pIStream, debugstr_guid(pguidVendor), TRACE("(%p,%p,%s,%u,%p)\n", iface, pIStream, debugstr_guid(pguidVendor),
metadataOptions, ppIDecoder); metadataOptions, ppIDecoder);
if (pguidVendor && !fixme++)
FIXME("ignoring vendor GUID\n");
res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders); res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
if (FAILED(res)) return res; if (FAILED(res)) return res;
while (!decoder) while (!preferred_decoder)
{ {
res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched); res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
...@@ -154,19 +151,36 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream( ...@@ -154,19 +151,36 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
if (SUCCEEDED(res) && matches) if (SUCCEEDED(res) && matches)
{ {
res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder); IWICBitmapDecoder *new_decoder;
res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &new_decoder);
/* FIXME: should use QueryCapability to choose a decoder */ /* FIXME: should use QueryCapability to choose a decoder */
if (SUCCEEDED(res)) if (SUCCEEDED(res))
{ {
res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions); res = IWICBitmapDecoder_Initialize(new_decoder, pIStream, metadataOptions);
if (FAILED(res)) if (SUCCEEDED(res))
{
if (pguidVendor)
{ {
IWICBitmapDecoder_Release(decoder); res = IWICBitmapDecoderInfo_GetVendorGUID(decoderinfo, &vendor);
decoder = NULL; if (SUCCEEDED(res) && IsEqualIID(&vendor, pguidVendor))
{
preferred_decoder = new_decoder;
new_decoder = NULL;
}
} }
if (new_decoder && !decoder)
{
decoder = new_decoder;
new_decoder = NULL;
}
}
if (new_decoder) IWICBitmapDecoder_Release(new_decoder);
} }
} }
...@@ -181,6 +195,13 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream( ...@@ -181,6 +195,13 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
IEnumUnknown_Release(enumdecoders); IEnumUnknown_Release(enumdecoders);
if (preferred_decoder)
{
*ppIDecoder = preferred_decoder;
if (decoder) IWICBitmapDecoder_Release(decoder);
return S_OK;
}
if (decoder) if (decoder)
{ {
*ppIDecoder = decoder; *ppIDecoder = decoder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment