gdiplus: Support decoders with multiple signatures.
This commit is contained in:
parent
416eb191cb
commit
738059baf8
@ -2517,10 +2517,11 @@ static const struct image_codec codecs[NUM_CODECS];
|
|||||||
static GpStatus get_decoder_info(IStream* stream, const struct image_codec **result)
|
static GpStatus get_decoder_info(IStream* stream, const struct image_codec **result)
|
||||||
{
|
{
|
||||||
BYTE signature[8];
|
BYTE signature[8];
|
||||||
|
const BYTE *pattern, *mask;
|
||||||
LARGE_INTEGER seek;
|
LARGE_INTEGER seek;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
UINT bytesread;
|
UINT bytesread;
|
||||||
int i, j;
|
int i, j, sig;
|
||||||
|
|
||||||
/* seek to the start of the stream */
|
/* seek to the start of the stream */
|
||||||
seek.QuadPart = 0;
|
seek.QuadPart = 0;
|
||||||
@ -2528,7 +2529,7 @@ static GpStatus get_decoder_info(IStream* stream, const struct image_codec **res
|
|||||||
if (FAILED(hr)) return hresult_to_status(hr);
|
if (FAILED(hr)) return hresult_to_status(hr);
|
||||||
|
|
||||||
/* read the first 8 bytes */
|
/* read the first 8 bytes */
|
||||||
/* FIXME: This assumes all codecs have one signature <= 8 bytes in length */
|
/* FIXME: This assumes all codecs have signatures <= 8 bytes in length */
|
||||||
hr = IStream_Read(stream, signature, 8, &bytesread);
|
hr = IStream_Read(stream, signature, 8, &bytesread);
|
||||||
if (FAILED(hr)) return hresult_to_status(hr);
|
if (FAILED(hr)) return hresult_to_status(hr);
|
||||||
if (hr == S_FALSE || bytesread == 0) return GenericError;
|
if (hr == S_FALSE || bytesread == 0) return GenericError;
|
||||||
@ -2537,13 +2538,18 @@ static GpStatus get_decoder_info(IStream* stream, const struct image_codec **res
|
|||||||
if ((codecs[i].info.Flags & ImageCodecFlagsDecoder) &&
|
if ((codecs[i].info.Flags & ImageCodecFlagsDecoder) &&
|
||||||
bytesread >= codecs[i].info.SigSize)
|
bytesread >= codecs[i].info.SigSize)
|
||||||
{
|
{
|
||||||
for (j=0; j<codecs[i].info.SigSize; j++)
|
for (sig=0; sig<codecs[i].info.SigCount; sig++)
|
||||||
if ((signature[j] & codecs[i].info.SigMask[j]) != codecs[i].info.SigPattern[j])
|
|
||||||
break;
|
|
||||||
if (j == codecs[i].info.SigSize)
|
|
||||||
{
|
{
|
||||||
*result = &codecs[i];
|
pattern = &codecs[i].info.SigPattern[codecs[i].info.SigSize*sig];
|
||||||
return Ok;
|
mask = &codecs[i].info.SigMask[codecs[i].info.SigSize*sig];
|
||||||
|
for (j=0; j<codecs[i].info.SigSize; j++)
|
||||||
|
if ((signature[j] & mask[j]) != pattern[j])
|
||||||
|
break;
|
||||||
|
if (j == codecs[i].info.SigSize)
|
||||||
|
{
|
||||||
|
*result = &codecs[i];
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user