2 * Copyright 2019 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "d3d9types.h"
26 #include "wine/debug.h"
36 IMFAttributes IMFAttributes_iface
;
39 struct attribute
*attributes
;
44 extern HRESULT
init_attributes_object(struct attributes
*object
, UINT32 size
);
45 extern void clear_attributes_object(struct attributes
*object
);
46 extern const char *debugstr_attr(const GUID
*guid
);
47 extern const char *debugstr_mf_guid(const GUID
*guid
);
49 extern HRESULT
attributes_GetItem(struct attributes
*object
, REFGUID key
, PROPVARIANT
*value
);
50 extern HRESULT
attributes_GetItemType(struct attributes
*object
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
);
51 extern HRESULT
attributes_CompareItem(struct attributes
*object
, REFGUID key
, REFPROPVARIANT value
,
53 extern HRESULT
attributes_Compare(struct attributes
*object
, IMFAttributes
*theirs
,
54 MF_ATTRIBUTES_MATCH_TYPE match_type
, BOOL
*ret
);
55 extern HRESULT
attributes_GetUINT32(struct attributes
*object
, REFGUID key
, UINT32
*value
);
56 extern HRESULT
attributes_GetUINT64(struct attributes
*object
, REFGUID key
, UINT64
*value
);
57 extern HRESULT
attributes_GetDouble(struct attributes
*object
, REFGUID key
, double *value
);
58 extern HRESULT
attributes_GetGUID(struct attributes
*object
, REFGUID key
, GUID
*value
);
59 extern HRESULT
attributes_GetStringLength(struct attributes
*object
, REFGUID key
, UINT32
*length
);
60 extern HRESULT
attributes_GetString(struct attributes
*object
, REFGUID key
, WCHAR
*value
, UINT32 size
,
62 extern HRESULT
attributes_GetAllocatedString(struct attributes
*object
, REFGUID key
, WCHAR
**value
,
64 extern HRESULT
attributes_GetBlobSize(struct attributes
*object
, REFGUID key
, UINT32
*size
);
65 extern HRESULT
attributes_GetBlob(struct attributes
*object
, REFGUID key
, UINT8
*buf
, UINT32 bufsize
,
67 extern HRESULT
attributes_GetAllocatedBlob(struct attributes
*object
, REFGUID key
, UINT8
**buf
,
69 extern HRESULT
attributes_GetUnknown(struct attributes
*object
, REFGUID key
, REFIID riid
, void **out
);
70 extern HRESULT
attributes_SetItem(struct attributes
*object
, REFGUID key
, REFPROPVARIANT value
);
71 extern HRESULT
attributes_DeleteItem(struct attributes
*object
, REFGUID key
);
72 extern HRESULT
attributes_DeleteAllItems(struct attributes
*object
);
73 extern HRESULT
attributes_SetUINT32(struct attributes
*object
, REFGUID key
, UINT32 value
);
74 extern HRESULT
attributes_SetUINT64(struct attributes
*object
, REFGUID key
, UINT64 value
);
75 extern HRESULT
attributes_SetDouble(struct attributes
*object
, REFGUID key
, double value
);
76 extern HRESULT
attributes_SetGUID(struct attributes
*object
, REFGUID key
, REFGUID value
);
77 extern HRESULT
attributes_SetString(struct attributes
*object
, REFGUID key
, const WCHAR
*value
);
78 extern HRESULT
attributes_SetBlob(struct attributes
*object
, REFGUID key
, const UINT8
*buf
,
80 extern HRESULT
attributes_SetUnknown(struct attributes
*object
, REFGUID key
, IUnknown
*unknown
);
81 extern HRESULT
attributes_LockStore(struct attributes
*object
);
82 extern HRESULT
attributes_UnlockStore(struct attributes
*object
);
83 extern HRESULT
attributes_GetCount(struct attributes
*object
, UINT32
*items
);
84 extern HRESULT
attributes_GetItemByIndex(struct attributes
*object
, UINT32 index
, GUID
*key
,
86 extern HRESULT
attributes_CopyAllItems(struct attributes
*object
, IMFAttributes
*dest
);
88 static inline BOOL
mf_array_reserve(void **elements
, size_t *capacity
, size_t count
, size_t size
)
90 size_t new_capacity
, max_capacity
;
93 if (count
<= *capacity
)
96 max_capacity
= ~(SIZE_T
)0 / size
;
97 if (count
> max_capacity
)
100 new_capacity
= max(4, *capacity
);
101 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
103 if (new_capacity
< count
)
104 new_capacity
= max_capacity
;
106 if (!(new_elements
= realloc(*elements
, new_capacity
* size
)))
109 *elements
= new_elements
;
110 *capacity
= new_capacity
;
115 extern unsigned int mf_format_get_stride(const GUID
*subtype
, unsigned int width
, BOOL
*is_yuv
);
117 static inline const char *debugstr_propvar(const PROPVARIANT
*v
)
125 return wine_dbg_sprintf("%p {VT_EMPTY}", v
);
127 return wine_dbg_sprintf("%p {VT_NULL}", v
);
129 return wine_dbg_sprintf("%p {VT_UI4: %ld}", v
, v
->ulVal
);
131 return wine_dbg_sprintf("%p {VT_UI8: %s}", v
, wine_dbgstr_longlong(v
->uhVal
.QuadPart
));
133 return wine_dbg_sprintf("%p {VT_I8: %s}", v
, wine_dbgstr_longlong(v
->hVal
.QuadPart
));
135 return wine_dbg_sprintf("%p {VT_R4: %.8e}", v
, v
->fltVal
);
137 return wine_dbg_sprintf("%p {VT_R8: %lf}", v
, v
->dblVal
);
139 return wine_dbg_sprintf("%p {VT_CLSID: %s}", v
, debugstr_mf_guid(v
->puuid
));
141 return wine_dbg_sprintf("%p {VT_LPWSTR: %s}", v
, wine_dbgstr_w(v
->pwszVal
));
142 case VT_VECTOR
| VT_UI1
:
143 return wine_dbg_sprintf("%p {VT_VECTOR|VT_UI1: %p}", v
, v
->caub
.pElems
);
145 return wine_dbg_sprintf("%p {VT_UNKNOWN: %p}", v
, v
->punkVal
);
147 return wine_dbg_sprintf("%p {vt %#x}", v
, v
->vt
);
151 static inline const char *mf_debugstr_fourcc(DWORD format
)
153 static const struct format_name
159 { D3DFMT_R8G8B8
, "R8G8B8" },
160 { D3DFMT_A8R8G8B8
, "A8R8G8B8" },
161 { D3DFMT_X8R8G8B8
, "X8R8G8B8" },
162 { D3DFMT_R5G6B5
, "R5G6B5" },
163 { D3DFMT_X1R5G5B5
, "X1R5G6B5" },
164 { D3DFMT_A2B10G10R10
, "A2B10G10R10" },
167 { D3DFMT_D16
, "D16" },
168 { D3DFMT_L16
, "L16" },
169 { D3DFMT_A16B16G16R16F
, "A16B16G16R16F" },
173 if ((format
& 0xff) == format
)
175 for (i
= 0; i
< ARRAY_SIZE(formats
); ++i
)
177 if (formats
[i
].format
== format
)
178 return wine_dbg_sprintf("%s", wine_dbgstr_an(formats
[i
].name
, -1));
181 return wine_dbg_sprintf("%#lx", format
);
184 return wine_dbgstr_an((char *)&format
, 4);
187 static inline const char *debugstr_time(LONGLONG time
)
189 ULONGLONG abstime
= time
>= 0 ? time
: -time
;
190 unsigned int i
= 0, j
= 0;
191 char buffer
[23], rev
[23];
193 while (abstime
|| i
<= 8)
195 buffer
[i
++] = '0' + (abstime
% 10);
197 if (i
== 7) buffer
[i
++] = '.';
199 if (time
< 0) buffer
[i
++] = '-';
201 while (i
--) rev
[j
++] = buffer
[i
];
202 while (rev
[j
-1] == '0' && rev
[j
-2] != '.') --j
;
205 return wine_dbg_sprintf("%s", rev
);