windowscodecs: Create a IWICMetadataReader when loading a TIFF frame.

Vincent Povirk madewokherd at
Mon Jun 18 08:28:25 CDT 2012

> +        hr = IWICPersistStream_LoadEx(persist, This->parent->stream, NULL, persist_options);
> +        if (FAILED(hr))
> +            ERR("IWICPersistStream_LoadEx error %#x\n", hr);

We can't use that stream because we provide separate seek and
read/write methods to libtiff, and libtiff may rely on the stream's
position to not change between operations.

This illustrates a design flaw in WIC. Normally, we would just clone
the stream, but IWICStream doesn't implement the Clone method. I think
we are probably supposed to create a new IWICStream based on the given
stream, but the resulting stream won't be thread-safe with ours. I
think for now it's OK to re-use this stream as long as you seek it
back to where it was when you're done, but we may have to change that

Also, LoadEx should (but does not yet) save the stream so it can
create an IWICFastMetadataEncoder. If you re-use the bitmap decoder's
stream, you should also use the WICPersistOptionNoCacheStream flag
when you create the metadata reader to make sure it won't do that.

Your GetReaderByIndex method should check whether
This->metadata_reader has been set and return an error if not.

Otherwise, the patch looks good to me.

More information about the wine-devel mailing list