ReactOS 0.4.16-dev-927-g467dec4
wmpformat.c File Reference
#include "objbase.h"
#include "wincodec.h"
#include "wine/test.h"
Include dependency graph for wmpformat.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void test_decode (void)
 
 START_TEST (wmpformat)
 

Variables

unsigned char wmp_imagedata []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 17 of file wmpformat.c.

Function Documentation

◆ START_TEST()

START_TEST ( wmpformat  )

Definition at line 175 of file wmpformat.c.

176{
178
179 test_decode();
180
182}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
static void test_decode(void)
Definition: wmpformat.c:63

◆ test_decode()

static void test_decode ( void  )
static

Definition at line 63 of file wmpformat.c.

64{
66 IWICBitmapFrameDecode *framedecode;
69 HRESULT hr;
70 HGLOBAL hwmpdata;
71 char *wmpdata;
72 IStream *wmpstream;
74 UINT count = 0, width = 0, height = 0;
75 BYTE imagedata[5 * 4] = {1};
76 UINT i, j;
77
78 const BYTE expected_imagedata[5 * 4] = {
79 0x6d, 0xb0, 0xfc, 0x00, 0x6d, 0xb0, 0xfc, 0x00, 0x6d, 0xb0,
80 0xfc, 0x00, 0x6d, 0xb0, 0xfc, 0x00, 0x6d, 0xb0, 0xfc, 0x00,
81 };
82
83 const BYTE broken_imagedata[5 * 4] = {
84 0x74, 0xa2, 0xd6, 0x28, 0x73, 0xa1, 0xd4, 0x29, 0x71, 0xa9,
85 0xe7, 0x16, 0x71, 0xa9, 0xe7, 0x16, 0x70, 0xa7, 0xe5, 0x17
86 };
87
88 hr = CoCreateInstance(&CLSID_WICWmpDecoder, NULL, CLSCTX_INPROC_SERVER,
89 &IID_IWICBitmapDecoder, (void **)&decoder);
90 if (FAILED(hr))
91 {
92 win_skip("WmpDecoder isn't available, skipping test\n");
93 return;
94 }
95
96 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
97 &IID_IWICImagingFactory, (void **)&factory);
98 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%lx\n", hr);
99
100 hwmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(wmp_imagedata));
101 ok(hwmpdata != 0, "GlobalAlloc failed\n");
102
103 wmpdata = GlobalLock(hwmpdata);
104 memcpy(wmpdata, wmp_imagedata, sizeof(wmp_imagedata));
105 GlobalUnlock(hwmpdata);
106
107 hr = CreateStreamOnHGlobal(hwmpdata, FALSE, &wmpstream);
108 ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%lx\n", hr);
109
110 hr = IWICBitmapDecoder_Initialize(decoder, wmpstream, WICDecodeMetadataCacheOnLoad);
111 ok(hr == S_OK, "Initialize failed, hr=%lx\n", hr);
112
113 hr = IWICBitmapDecoder_Initialize(decoder, wmpstream, WICDecodeMetadataCacheOnLoad);
114 ok(hr == WINCODEC_ERR_WRONGSTATE, "Initialize returned %lx\n", hr);
115
116 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format);
117 ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%lx\n", hr);
118 ok(IsEqualGUID(&format, &GUID_ContainerFormatWmp),
119 "unexpected container format\n");
120
121 hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
122 ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%lx\n", hr);
123 ok(count == 1, "unexpected count %u\n", count);
124
125 hr = IWICBitmapDecoder_GetFrame(decoder, 0, NULL);
126 ok(hr == E_INVALIDARG, "GetFrame(NULL) returned hr=%lx\n", hr);
127
128 for (j = 2; j > 0; --j)
129 {
130 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
131 ok(SUCCEEDED(hr), "GetFrame failed, hr=%lx\n", hr);
132
133 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
134 ok(SUCCEEDED(hr), "GetSize failed, hr=%lx\n", hr);
135 ok(width == 1, "expected width=1, got %u\n", width);
136 ok(height == 5, "expected height=5, got %u\n", height);
137
138 hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &format);
139 ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%lx\n", hr);
140 ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA),
141 "unexpected pixel format: %s\n", wine_dbgstr_guid(&format));
142
143 for (i = 2; i > 0; --i)
144 {
145 memset(imagedata, 0, sizeof(imagedata));
146 hr = IWICBitmapFrameDecode_CopyPixels(
147 framedecode, NULL, 4, sizeof(imagedata), imagedata);
148 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%lx\n", hr);
149 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)) ||
150 broken(!memcmp(imagedata, broken_imagedata, sizeof(imagedata)) /* w2008s64 */),
151 "unexpected image data\n");
152 }
153
154 hr = IWICImagingFactory_CreatePalette(factory, &palette);
155 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%lx\n", hr);
156
157 hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
158 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#lx.\n", hr);
159
160 hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
161 ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#lx.\n", hr);
162
163 IWICPalette_Release(palette);
164
165 IWICBitmapFrameDecode_Release(framedecode);
166 }
167
168 IStream_Release(wmpstream);
169 GlobalFree(hwmpdata);
170
171 IWICBitmapDecoder_Release(decoder);
172 IWICImagingFactory_Release(factory);
173}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define E_INVALIDARG
Definition: ddrawi.h:101
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HPALETTE palette
Definition: clipboard.c:1345
unsigned int UINT
Definition: ndis.h:50
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define win_skip
Definition: test.h:164
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
Definition: main.c:439
Definition: format.c:58
#define GMEM_MOVEABLE
Definition: winbase.h:320
@ WICDecodeMetadataCacheOnLoad
Definition: wincodec.idl:30
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3281
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3292
unsigned char wmp_imagedata[]
Definition: wmpformat.c:24
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

Variable Documentation

◆ wmp_imagedata

unsigned char wmp_imagedata[]

Definition at line 24 of file wmpformat.c.

Referenced by test_decode().