windowscodecs: Create a IWICMetadataReader when loading a TIFF frame.
dmitry at baikal.ru
Mon Jun 18 08:43:08 CDT 2012
Vincent Povirk <madewokherd at gmail.com> wrote:
> > + 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.
libtiff doesn't rely on stream positions, and my use of stream matches
MSDN guidelines on writing a WIC enabled codec.
> 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
There is no need to seek the stream back.
> 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.
No, that's not an error. TIFF always provides metadata since IFD is
the core of TIFF. If a metadata reader can't be created it's OK to
return 0 metadata items.
More information about the wine-devel