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
52 #define HR(x) case x: return (char *) # x;
56 HR(MF_E_INVALIDMEDIATYPE)
57 HR(MF_E_INVALIDSTREAMNUMBER)
59 HR(MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING)
60 HR(MF_E_TRANSFORM_TYPE_NOT_SET)
61 HR(MF_E_UNSUPPORTED_D3D_TYPE)
62 HR(MF_E_TRANSFORM_NEED_MORE_INPUT)
63 HR(MF_E_TRANSFORM_STREAM_CHANGE)
65 HR(MF_E_NO_SAMPLE_TIMESTAMP)
66 HR(MF_E_NO_SAMPLE_DURATION)
83 hr =
f->MFCreateSample(&
sample);
98 IMFMediaBuffer_Release(
buffer);
104 IMFMediaBuffer_SetCurrentLength(
buffer,
size);
105 IMFMediaBuffer_Unlock(
buffer);
109 IMFMediaBuffer_Release(
buffer);
120 hr = IMFAttributes_GetUINT32(
type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &
bits);
124 hr = IMFAttributes_GetGUID(
type, &MF_MT_SUBTYPE, &subtype);
128 if (IsEqualGUID(&subtype, &MFAudioFormat_PCM)) {
134 }
else if (IsEqualGUID(&subtype, &MFAudioFormat_Float)) {
164 hr = IMFAttributes_GetGUID(
type, &MF_MT_SUBTYPE, &subtype);
192 if (
guid->Data2 == 0 &&
guid->Data3 == 0x0010 &&
193 guid->Data4[0] == 0x80 &&
194 guid->Data4[1] == 0x00 &&
195 guid->Data4[2] == 0x00 &&
196 guid->Data4[3] == 0xAA &&
197 guid->Data4[4] == 0x00 &&
198 guid->Data4[5] == 0x38 &&
199 guid->Data4[6] == 0x9B &&
200 guid->Data4[7] == 0x71) {
201 *out_fourcc =
guid->Data1;
214 #define GUID_ENTRY(var) {&(var), # var}
223 GUID_ENTRY(ff_MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT),
224 GUID_ENTRY(ff_MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT_PROGRESSIVE),
229 GUID_ENTRY(ff_MF_SA_D3D11_SHARED_WITHOUT_MUTEX),
267 GUID_ENTRY(MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION),
273 GUID_ENTRY(MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND),
279 GUID_ENTRY(MF_MT_AUDIO_VALID_BITS_PER_SAMPLE),
314 GUID_ENTRY(ff_CODECAPI_AVDecVideoThumbnailGenerationMode),
315 GUID_ENTRY(ff_CODECAPI_AVDecVideoDropPicWithMissingRef),
316 GUID_ENTRY(ff_CODECAPI_AVDecVideoSoftwareDeinterlaceMode),
317 GUID_ENTRY(ff_CODECAPI_AVDecVideoFastDecodeMode),
319 GUID_ENTRY(ff_CODECAPI_AVDecVideoH264ErrorConcealment),
320 GUID_ENTRY(ff_CODECAPI_AVDecVideoMPEG2ErrorConcealment),
323 GUID_ENTRY(ff_CODECAPI_AVDecVideoDXVABusEncryption),
324 GUID_ENTRY(ff_CODECAPI_AVDecVideoSWPowerLevel),
325 GUID_ENTRY(ff_CODECAPI_AVDecVideoMaxCodedWidth),
326 GUID_ENTRY(ff_CODECAPI_AVDecVideoMaxCodedHeight),
327 GUID_ENTRY(ff_CODECAPI_AVDecNumWorkerThreads),
328 GUID_ENTRY(ff_CODECAPI_AVDecSoftwareDynamicFormatChange),
329 GUID_ENTRY(ff_CODECAPI_AVDecDisableVideoPostProcessing),
349 "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}",
364 hr = IMFAttributes_GetCount(attrs, &count);
368 for (n = 0; n < count; n++) {
370 MF_ATTRIBUTE_TYPE
type;
371 char extra[80] = {0};
374 hr = IMFAttributes_GetItemByIndex(attrs, n, &
key,
NULL);
380 if (IsEqualGUID(&
key, &MF_MT_AUDIO_CHANNEL_MASK)) {
382 hr = IMFAttributes_GetUINT32(attrs, &
key, &v);
385 snprintf(extra,
sizeof(extra),
" (0x%x)", (
unsigned)v);
386 }
else if (IsEqualGUID(&
key, &MF_MT_FRAME_SIZE)) {
392 snprintf(extra,
sizeof(extra),
" (%dx%d)", (
int)
w, (
int)
h);
393 }
else if (IsEqualGUID(&
key, &MF_MT_PIXEL_ASPECT_RATIO) ||
394 IsEqualGUID(&
key, &MF_MT_FRAME_RATE)) {
400 snprintf(extra,
sizeof(extra),
" (%d:%d)", (
int)num, (
int)den);
403 hr = IMFAttributes_GetItemType(attrs, &
key, &
type);
408 case MF_ATTRIBUTE_UINT32: {
410 hr = IMFAttributes_GetUINT32(attrs, &
key, &v);
415 case MF_ATTRIBUTE_UINT64: {
417 hr = IMFAttributes_GetUINT64(attrs, &
key, &v);
423 case MF_ATTRIBUTE_DOUBLE: {
425 hr = IMFAttributes_GetDouble(attrs, &
key, &v);
431 case MF_ATTRIBUTE_STRING: {
433 hr = IMFAttributes_GetString(attrs, &
key,
s,
sizeof(
s),
NULL);
439 case MF_ATTRIBUTE_GUID: {
441 hr = IMFAttributes_GetGUID(attrs, &
key, &v);
447 case MF_ATTRIBUTE_BLOB: {
450 hr = IMFAttributes_GetBlobSize(attrs, &
key, &sz);
453 if (sz <=
sizeof(
buffer)) {
461 const char *hex =
"0123456789ABCDEF";
462 if (
pos * 3 + 3 >
sizeof(str))
466 str[
pos * 3 + 2] =
' ';
468 str[
pos * 3 + 0] = 0;
475 case MF_ATTRIBUTE_IUNKNOWN: {
485 if (IsEqualGUID(&
key, &MF_MT_SUBTYPE)) {
515 default:
return NULL;
523 hr = CoInitializeEx(
NULL, COINIT_MULTITHREADED);
524 if (hr == RPC_E_CHANGED_MODE) {
527 }
else if (FAILED(hr)) {
532 hr =
f->MFStartup(MF_VERSION, MFSTARTUP_FULL);
553 MFT_REGISTER_TYPE_INFO *in_type,
554 MFT_REGISTER_TYPE_INFO *out_type,
563 IMFActivate *winner = 0;
570 flags = MFT_ENUM_FLAG_SORTANDFILTER;
573 flags |= MFT_ENUM_FLAG_HARDWARE;
575 flags |= MFT_ENUM_FLAG_SYNCMFT;
581 goto error_uninit_mf;
587 for (n = 0; n < num_activate; n++) {
594 for (n = 0; n < num_activate; n++) {
597 hr = IMFActivate_ActivateObject(
activate[n], &IID_IMFTransform,
601 IMFActivate_AddRef(winner);
606 for (n = 0; n < num_activate; n++)
613 goto error_uninit_mf;
618 IMFAttributes *attrs;
619 hr = IMFTransform_GetAttributes(*res, &attrs);
620 if (!FAILED(hr) && attrs) {
624 IMFAttributes_Release(attrs);
627 hr = IMFActivate_GetString(winner, &MFT_FRIENDLY_NAME_Attribute,
s,
634 IMFActivate_Release(winner);
646 IMFTransform_Release(*mft);