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),
268 GUID_ENTRY(MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION),
274 GUID_ENTRY(MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND),
280 GUID_ENTRY(MF_MT_AUDIO_VALID_BITS_PER_SAMPLE),
315 GUID_ENTRY(ff_CODECAPI_AVDecVideoThumbnailGenerationMode),
316 GUID_ENTRY(ff_CODECAPI_AVDecVideoDropPicWithMissingRef),
317 GUID_ENTRY(ff_CODECAPI_AVDecVideoSoftwareDeinterlaceMode),
318 GUID_ENTRY(ff_CODECAPI_AVDecVideoFastDecodeMode),
320 GUID_ENTRY(ff_CODECAPI_AVDecVideoH264ErrorConcealment),
321 GUID_ENTRY(ff_CODECAPI_AVDecVideoMPEG2ErrorConcealment),
324 GUID_ENTRY(ff_CODECAPI_AVDecVideoDXVABusEncryption),
325 GUID_ENTRY(ff_CODECAPI_AVDecVideoSWPowerLevel),
326 GUID_ENTRY(ff_CODECAPI_AVDecVideoMaxCodedWidth),
327 GUID_ENTRY(ff_CODECAPI_AVDecVideoMaxCodedHeight),
328 GUID_ENTRY(ff_CODECAPI_AVDecNumWorkerThreads),
329 GUID_ENTRY(ff_CODECAPI_AVDecSoftwareDynamicFormatChange),
330 GUID_ENTRY(ff_CODECAPI_AVDecDisableVideoPostProcessing),
350 "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}",
365 hr = IMFAttributes_GetCount(attrs, &count);
369 for (n = 0; n < count; n++) {
371 MF_ATTRIBUTE_TYPE
type;
372 char extra[80] = {0};
375 hr = IMFAttributes_GetItemByIndex(attrs, n, &
key,
NULL);
381 if (IsEqualGUID(&
key, &MF_MT_AUDIO_CHANNEL_MASK)) {
383 hr = IMFAttributes_GetUINT32(attrs, &
key, &v);
386 snprintf(extra,
sizeof(extra),
" (0x%x)", (
unsigned)v);
387 }
else if (IsEqualGUID(&
key, &MF_MT_FRAME_SIZE)) {
393 snprintf(extra,
sizeof(extra),
" (%dx%d)", (
int)
w, (
int)
h);
394 }
else if (IsEqualGUID(&
key, &MF_MT_PIXEL_ASPECT_RATIO) ||
395 IsEqualGUID(&
key, &MF_MT_FRAME_RATE)) {
401 snprintf(extra,
sizeof(extra),
" (%d:%d)", (
int)num, (
int)den);
404 hr = IMFAttributes_GetItemType(attrs, &
key, &
type);
409 case MF_ATTRIBUTE_UINT32: {
411 hr = IMFAttributes_GetUINT32(attrs, &
key, &v);
416 case MF_ATTRIBUTE_UINT64: {
418 hr = IMFAttributes_GetUINT64(attrs, &
key, &v);
424 case MF_ATTRIBUTE_DOUBLE: {
426 hr = IMFAttributes_GetDouble(attrs, &
key, &v);
432 case MF_ATTRIBUTE_STRING: {
434 hr = IMFAttributes_GetString(attrs, &
key,
s,
sizeof(
s),
NULL);
440 case MF_ATTRIBUTE_GUID: {
442 hr = IMFAttributes_GetGUID(attrs, &
key, &v);
448 case MF_ATTRIBUTE_BLOB: {
451 hr = IMFAttributes_GetBlobSize(attrs, &
key, &sz);
454 if (sz <=
sizeof(
buffer)) {
462 const char *hex =
"0123456789ABCDEF";
463 if (
pos * 3 + 3 >
sizeof(str))
467 str[
pos * 3 + 2] =
' ';
469 str[
pos * 3 + 0] = 0;
476 case MF_ATTRIBUTE_IUNKNOWN: {
486 if (IsEqualGUID(&
key, &MF_MT_SUBTYPE)) {
517 default:
return NULL;
525 hr = CoInitializeEx(
NULL, COINIT_MULTITHREADED);
526 if (hr == RPC_E_CHANGED_MODE) {
529 }
else if (FAILED(hr)) {
534 hr =
f->MFStartup(MF_VERSION, MFSTARTUP_FULL);
555 MFT_REGISTER_TYPE_INFO *in_type,
556 MFT_REGISTER_TYPE_INFO *out_type,
565 IMFActivate *winner = 0;
572 flags = MFT_ENUM_FLAG_SORTANDFILTER;
575 flags |= MFT_ENUM_FLAG_HARDWARE;
577 flags |= MFT_ENUM_FLAG_SYNCMFT;
583 goto error_uninit_mf;
589 for (n = 0; n < num_activate; n++) {
596 for (n = 0; n < num_activate; n++) {
599 hr = IMFActivate_ActivateObject(
activate[n], &IID_IMFTransform,
603 IMFActivate_AddRef(winner);
608 for (n = 0; n < num_activate; n++)
615 goto error_uninit_mf;
620 IMFAttributes *attrs;
621 hr = IMFTransform_GetAttributes(*res, &attrs);
622 if (!FAILED(hr) && attrs) {
626 IMFAttributes_Release(attrs);
629 hr = IMFActivate_GetString(winner, &MFT_FRIENDLY_NAME_Attribute,
s,
636 IMFActivate_Release(winner);
648 IMFTransform_Release(*mft);