[PATCH 2/4] windowscodecs: Use IWICComponentFactory_CreateStream in GetReaderByIndex.

Rémi Bernon rbernon at codeweavers.com
Wed Jan 20 03:30:06 CST 2021


Instead of StreamImpl_Create.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/windowscodecs/decoder.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/dlls/windowscodecs/decoder.c b/dlls/windowscodecs/decoder.c
index 5970a44cd53..b05d50dfea9 100644
--- a/dlls/windowscodecs/decoder.c
+++ b/dlls/windowscodecs/decoder.c
@@ -595,7 +595,7 @@ static HRESULT WINAPI CommonDecoderFrame_Block_GetReaderByIndex(IWICMetadataBloc
 {
     CommonDecoderFrame *This = impl_from_IWICMetadataBlockReader(iface);
     HRESULT hr;
-    IWICComponentFactory* factory;
+    IWICComponentFactory* factory = NULL;
     IWICStream* stream;
 
     TRACE("%p,%d,%p\n", iface, nIndex, ppIMetadataReader);
@@ -609,7 +609,10 @@ static HRESULT WINAPI CommonDecoderFrame_Block_GetReaderByIndex(IWICMetadataBloc
         hr = E_INVALIDARG;
 
     if (SUCCEEDED(hr))
-        hr = StreamImpl_Create(&stream);
+        hr = create_instance(&CLSID_WICImagingFactory, &IID_IWICComponentFactory, (void**)&factory);
+
+    if (SUCCEEDED(hr))
+        hr = IWICComponentFactory_CreateStream(factory, &stream);
 
     if (SUCCEEDED(hr))
     {
@@ -664,23 +667,17 @@ static HRESULT WINAPI CommonDecoderFrame_Block_GetReaderByIndex(IWICMetadataBloc
         }
         else
         {
-            if (SUCCEEDED(hr))
-                hr = create_instance(&CLSID_WICImagingFactory, &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);
-            }
+            hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+                &This->parent->decoder_info.block_format, NULL,
+                This->metadata_blocks[nIndex].options & DECODER_BLOCK_OPTION_MASK,
+                (IStream*)stream, ppIMetadataReader);
         }
 
         IWICStream_Release(stream);
     }
 
+    if (factory) IWICComponentFactory_Release(factory);
+
     if (FAILED(hr))
         *ppIMetadataReader = NULL;
 
-- 
2.30.0




More information about the wine-devel mailing list