20 #if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602
22 #define _WIN32_WINNT 0x0602
29 UINT32 *pw, UINT32 *ph)
32 HRESULT hr = IMFAttributes_GetUINT64(pattr, guid, &t);
43 UINT64 t = (((UINT64)uw) << 32) | uh;
44 return IMFAttributes_SetUINT64(pattr, guid, t);
47 #define ff_MFSetAttributeRatio ff_MFSetAttributeSize
48 #define ff_MFGetAttributeRatio ff_MFGetAttributeSize
54 const MFT_REGISTER_TYPE_INFO *pInputType,
55 const MFT_REGISTER_TYPE_INFO *pOutputType,
56 IMFActivate ***pppMFTActivate, UINT32 *pnumMFTActivate)
58 HRESULT (WINAPI *MFTEnumEx_ptr)(GUID guidCategory, UINT32 Flags,
59 const MFT_REGISTER_TYPE_INFO *pInputType,
60 const MFT_REGISTER_TYPE_INFO *pOutputType,
61 IMFActivate ***pppMFTActivate,
62 UINT32 *pnumMFTActivate) =
NULL;
64 HANDLE lib = GetModuleHandleW(
L"mfplat.dll");
66 MFTEnumEx_ptr = (
void *)GetProcAddress(lib,
"MFTEnumEx");
71 MFTEnumEx_ptr = MFTEnumEx;
75 return MFTEnumEx_ptr(guidCategory,
85 #define HR(x) case x: return (char *) # x;
89 HR(MF_E_INVALIDMEDIATYPE)
90 HR(MF_E_INVALIDSTREAMNUMBER)
92 HR(MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING)
93 HR(MF_E_TRANSFORM_TYPE_NOT_SET)
94 HR(MF_E_UNSUPPORTED_D3D_TYPE)
95 HR(MF_E_TRANSFORM_NEED_MORE_INPUT)
96 HR(MF_E_TRANSFORM_STREAM_CHANGE)
98 HR(MF_E_NO_SAMPLE_TIMESTAMP)
99 HR(MF_E_NO_SAMPLE_DURATION)
115 hr = MFCreateSample(&
sample);
119 align =
FFMAX(align, 16);
121 hr = MFCreateAlignedMemoryBuffer(
size, align - 1, &
buffer);
130 IMFMediaBuffer_Release(
buffer);
131 IMFSample_Release(
sample);
136 IMFMediaBuffer_SetCurrentLength(
buffer,
size);
137 IMFMediaBuffer_Unlock(
buffer);
141 IMFMediaBuffer_Release(
buffer);
152 hr = IMFAttributes_GetUINT32(
type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &
bits);
156 hr = IMFAttributes_GetGUID(
type, &MF_MT_SUBTYPE, &subtype);
160 if (IsEqualGUID(&subtype, &MFAudioFormat_PCM)) {
166 }
else if (IsEqualGUID(&subtype, &MFAudioFormat_Float)) {
196 hr = IMFAttributes_GetGUID(
type, &MF_MT_SUBTYPE, &subtype);
224 if (
guid->Data2 == 0 &&
guid->Data3 == 0x0010 &&
225 guid->Data4[0] == 0x80 &&
226 guid->Data4[1] == 0x00 &&
227 guid->Data4[2] == 0x00 &&
228 guid->Data4[3] == 0xAA &&
229 guid->Data4[4] == 0x00 &&
230 guid->Data4[5] == 0x38 &&
231 guid->Data4[6] == 0x9B &&
232 guid->Data4[7] == 0x71) {
233 *out_fourcc =
guid->Data1;
246 #define GUID_ENTRY(var) {&(var), # var}
255 GUID_ENTRY(ff_MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT),
256 GUID_ENTRY(ff_MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT_PROGRESSIVE),
261 GUID_ENTRY(ff_MF_SA_D3D11_SHARED_WITHOUT_MUTEX),
299 GUID_ENTRY(MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION),
305 GUID_ENTRY(MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND),
311 GUID_ENTRY(MF_MT_AUDIO_VALID_BITS_PER_SAMPLE),
346 GUID_ENTRY(ff_CODECAPI_AVDecVideoThumbnailGenerationMode),
347 GUID_ENTRY(ff_CODECAPI_AVDecVideoDropPicWithMissingRef),
348 GUID_ENTRY(ff_CODECAPI_AVDecVideoSoftwareDeinterlaceMode),
349 GUID_ENTRY(ff_CODECAPI_AVDecVideoFastDecodeMode),
351 GUID_ENTRY(ff_CODECAPI_AVDecVideoH264ErrorConcealment),
352 GUID_ENTRY(ff_CODECAPI_AVDecVideoMPEG2ErrorConcealment),
355 GUID_ENTRY(ff_CODECAPI_AVDecVideoDXVABusEncryption),
356 GUID_ENTRY(ff_CODECAPI_AVDecVideoSWPowerLevel),
357 GUID_ENTRY(ff_CODECAPI_AVDecVideoMaxCodedWidth),
358 GUID_ENTRY(ff_CODECAPI_AVDecVideoMaxCodedHeight),
359 GUID_ENTRY(ff_CODECAPI_AVDecNumWorkerThreads),
360 GUID_ENTRY(ff_CODECAPI_AVDecSoftwareDynamicFormatChange),
361 GUID_ENTRY(ff_CODECAPI_AVDecDisableVideoPostProcessing),
381 "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}",
396 hr = IMFAttributes_GetCount(attrs, &count);
400 for (n = 0; n < count; n++) {
402 MF_ATTRIBUTE_TYPE
type;
403 char extra[80] = {0};
406 hr = IMFAttributes_GetItemByIndex(attrs, n, &
key,
NULL);
412 if (IsEqualGUID(&
key, &MF_MT_AUDIO_CHANNEL_MASK)) {
414 hr = IMFAttributes_GetUINT32(attrs, &
key, &v);
417 snprintf(extra,
sizeof(extra),
" (0x%x)", (
unsigned)v);
418 }
else if (IsEqualGUID(&
key, &MF_MT_FRAME_SIZE)) {
424 snprintf(extra,
sizeof(extra),
" (%dx%d)", (
int)
w, (
int)
h);
425 }
else if (IsEqualGUID(&
key, &MF_MT_PIXEL_ASPECT_RATIO) ||
426 IsEqualGUID(&
key, &MF_MT_FRAME_RATE)) {
432 snprintf(extra,
sizeof(extra),
" (%d:%d)", (
int)num, (
int)den);
435 hr = IMFAttributes_GetItemType(attrs, &
key, &
type);
440 case MF_ATTRIBUTE_UINT32: {
442 hr = IMFAttributes_GetUINT32(attrs, &
key, &v);
447 case MF_ATTRIBUTE_UINT64: {
449 hr = IMFAttributes_GetUINT64(attrs, &
key, &v);
455 case MF_ATTRIBUTE_DOUBLE: {
457 hr = IMFAttributes_GetDouble(attrs, &
key, &v);
463 case MF_ATTRIBUTE_STRING: {
465 hr = IMFAttributes_GetString(attrs, &
key,
s,
sizeof(
s),
NULL);
471 case MF_ATTRIBUTE_GUID: {
473 hr = IMFAttributes_GetGUID(attrs, &
key, &v);
479 case MF_ATTRIBUTE_BLOB: {
482 hr = IMFAttributes_GetBlobSize(attrs, &
key, &sz);
485 if (sz <=
sizeof(
buffer)) {
493 const char *hex =
"0123456789ABCDEF";
494 if (
pos * 3 + 3 >
sizeof(
str))
507 case MF_ATTRIBUTE_IUNKNOWN: {
517 if (IsEqualGUID(&
key, &MF_MT_SUBTYPE)) {
547 default:
return NULL;
555 hr = CoInitializeEx(
NULL, COINIT_MULTITHREADED);
556 if (hr == RPC_E_CHANGED_MODE) {
559 }
else if (FAILED(hr)) {
564 hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
584 MFT_REGISTER_TYPE_INFO *in_type,
585 MFT_REGISTER_TYPE_INFO *out_type,
594 IMFActivate *winner = 0;
601 flags = MFT_ENUM_FLAG_SORTANDFILTER;
604 flags |= MFT_ENUM_FLAG_HARDWARE;
606 flags |= MFT_ENUM_FLAG_SYNCMFT;
612 goto error_uninit_mf;
618 for (n = 0; n < num_activate; n++) {
625 for (n = 0; n < num_activate; n++) {
628 hr = IMFActivate_ActivateObject(
activate[n], &IID_IMFTransform,
632 IMFActivate_AddRef(winner);
637 for (n = 0; n < num_activate; n++)
644 goto error_uninit_mf;
649 IMFAttributes *attrs;
650 hr = IMFTransform_GetAttributes(*res, &attrs);
651 if (!FAILED(hr) && attrs) {
655 IMFAttributes_Release(attrs);
658 hr = IMFActivate_GetString(winner, &MFT_FRIENDLY_NAME_Attribute,
s,
665 IMFActivate_Release(winner);
677 IMFTransform_Release(*mft);