Commit eac5ad2a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

mfplat/mediatype: Implement MFInitMediaTypeFromMFVideoFormat.

parent 899abeaf
......@@ -3761,8 +3761,95 @@ HRESULT WINAPI MFCreateVideoMediaTypeFromVideoInfoHeader(const KS_VIDEOINFOHEADE
*/
HRESULT WINAPI MFInitMediaTypeFromMFVideoFormat(IMFMediaType *media_type, const MFVIDEOFORMAT *format, UINT32 size)
{
FIXME("%p, %p, %u\n", media_type, format, size);
return E_NOTIMPL;
UINT32 stride, sample_size, palette_size, user_data_size, value;
struct uncompressed_video_format *video_format;
const void *user_data;
HRESULT hr = S_OK;
TRACE("%p, %p, %u\n", media_type, format, size);
if (!format || size < sizeof(*format) || format->dwSize != size)
return E_INVALIDARG;
if (size < offsetof(MFVIDEOFORMAT, surfaceInfo.Palette[format->surfaceInfo.PaletteEntries + 1]))
return E_INVALIDARG;
mediatype_set_guid(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video, &hr);
if (!IsEqualGUID(&format->guidFormat, &GUID_NULL))
mediatype_set_guid(media_type, &MF_MT_SUBTYPE, &format->guidFormat, &hr);
if ((video_format = mf_get_video_format(&format->guidFormat)))
{
mediatype_set_uint32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1, &hr);
mediatype_set_uint32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1, &hr);
}
if (format->videoInfo.dwWidth && format->videoInfo.dwHeight)
{
mediatype_set_uint64(media_type, &MF_MT_FRAME_SIZE, format->videoInfo.dwWidth, format->videoInfo.dwHeight, &hr);
if (video_format && (stride = mf_get_stride_for_format(video_format, format->videoInfo.dwWidth)))
{
if (!video_format->yuv && (format->videoInfo.VideoFlags & MFVideoFlag_BottomUpLinearRep))
stride = -stride;
mediatype_set_uint32(media_type, &MF_MT_DEFAULT_STRIDE, stride, &hr);
}
if (SUCCEEDED(MFCalculateImageSize(&format->guidFormat, format->videoInfo.dwWidth, format->videoInfo.dwHeight, &sample_size)))
mediatype_set_uint32(media_type, &MF_MT_SAMPLE_SIZE, sample_size, &hr);
}
if (format->videoInfo.PixelAspectRatio.Denominator)
mediatype_set_uint64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, format->videoInfo.PixelAspectRatio.Numerator,
format->videoInfo.PixelAspectRatio.Denominator, &hr);
if (format->videoInfo.SourceChromaSubsampling)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_CHROMA_SITING, format->videoInfo.SourceChromaSubsampling, &hr);
if (format->videoInfo.InterlaceMode)
mediatype_set_uint32(media_type, &MF_MT_INTERLACE_MODE, format->videoInfo.InterlaceMode, &hr);
if (format->videoInfo.TransferFunction)
mediatype_set_uint32(media_type, &MF_MT_TRANSFER_FUNCTION, format->videoInfo.TransferFunction, &hr);
if (format->videoInfo.ColorPrimaries)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_PRIMARIES, format->videoInfo.ColorPrimaries, &hr);
if (format->videoInfo.TransferMatrix)
mediatype_set_uint32(media_type, &MF_MT_YUV_MATRIX, format->videoInfo.TransferMatrix, &hr);
if (format->videoInfo.SourceLighting)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_LIGHTING, format->videoInfo.SourceLighting, &hr);
if (format->videoInfo.FramesPerSecond.Denominator)
mediatype_set_uint64(media_type, &MF_MT_FRAME_RATE, format->videoInfo.FramesPerSecond.Numerator,
format->videoInfo.FramesPerSecond.Denominator, &hr);
if (format->videoInfo.NominalRange)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, format->videoInfo.NominalRange, &hr);
if (format->videoInfo.GeometricAperture.Area.cx && format->videoInfo.GeometricAperture.Area.cy)
mediatype_set_blob(media_type, &MF_MT_GEOMETRIC_APERTURE, (BYTE *)&format->videoInfo.GeometricAperture,
sizeof(format->videoInfo.GeometricAperture), &hr);
if (format->videoInfo.MinimumDisplayAperture.Area.cx && format->videoInfo.MinimumDisplayAperture.Area.cy)
mediatype_set_blob(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, (BYTE *)&format->videoInfo.MinimumDisplayAperture,
sizeof(format->videoInfo.MinimumDisplayAperture), &hr);
if (format->videoInfo.PanScanAperture.Area.cx && format->videoInfo.PanScanAperture.Area.cy)
mediatype_set_blob(media_type, &MF_MT_PAN_SCAN_APERTURE, (BYTE *)&format->videoInfo.PanScanAperture,
sizeof(format->videoInfo.PanScanAperture), &hr);
if ((value = !!(format->videoInfo.VideoFlags & MFVideoFlag_PanScanEnabled)))
mediatype_set_uint32(media_type, &MF_MT_PAN_SCAN_ENABLED, value, &hr);
if ((value = format->videoInfo.VideoFlags & MFVideoFlag_PAD_TO_Mask))
mediatype_set_uint32(media_type, &MF_MT_PAD_CONTROL_FLAGS, value, &hr);
if ((value = format->videoInfo.VideoFlags & MFVideoFlag_SrcContentHintMask))
mediatype_set_uint32(media_type, &MF_MT_SOURCE_CONTENT_HINT, value >> 2, &hr);
if ((value = format->videoInfo.VideoFlags & (MFVideoFlag_AnalogProtected | MFVideoFlag_DigitallyProtected)))
mediatype_set_uint32(media_type, &MF_MT_DRM_FLAGS, value >> 5, &hr);
if (format->compressedInfo.AvgBitrate)
mediatype_set_uint32(media_type, &MF_MT_AVG_BITRATE, format->compressedInfo.AvgBitrate, &hr);
if (format->compressedInfo.AvgBitErrorRate)
mediatype_set_uint32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, format->compressedInfo.AvgBitErrorRate, &hr);
if (format->compressedInfo.MaxKeyFrameSpacing)
mediatype_set_uint32(media_type, &MF_MT_MAX_KEYFRAME_SPACING, format->compressedInfo.MaxKeyFrameSpacing, &hr);
if ((palette_size = format->surfaceInfo.PaletteEntries * sizeof(*format->surfaceInfo.Palette)))
mediatype_set_blob(media_type, &MF_MT_PALETTE, (BYTE *)format->surfaceInfo.Palette, palette_size, &hr);
user_data = &format->surfaceInfo.Palette[format->surfaceInfo.PaletteEntries + 1];
if ((user_data_size = (BYTE *)format + format->dwSize - (BYTE *)user_data))
mediatype_set_blob(media_type, &MF_MT_USER_DATA, user_data, user_data_size, &hr);
return hr;
}
/***********************************************************************
......
......@@ -7874,27 +7874,21 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, NULL, 0);
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
memset(&format, 0, sizeof(format));
format.dwSize = sizeof(format) - 1;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format) - 1);
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
format.dwSize = sizeof(format);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format) - 1);
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(IsEqualGUID(&guid, &MFMediaType_Video), "got %s.\n", debugstr_guid(&guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -7902,13 +7896,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.guidFormat = MFVideoFormat_H264;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(IsEqualGUID(&guid, &MFVideoFormat_H264), "got %s.\n", debugstr_guid(&guid));
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -7918,25 +7909,18 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.guidFormat = MFVideoFormat_RGB32;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(IsEqualGUID(&guid, &MFVideoFormat_RGB32), "got %s.\n", debugstr_guid(&guid));
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 1, "got %u.\n", value32);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 1, "got %u.\n", value32);
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -7952,7 +7936,6 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "Unexpected hr %#lx.\n", hr);
format.videoInfo.dwWidth = 123;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -7963,25 +7946,18 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "Unexpected hr %#lx.\n", hr);
format.videoInfo.dwHeight = 456;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value64 = 0xdeadbeef;
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value64 == (((UINT64)123 << 32) | 456), "got %#I64x.\n", value64);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 123 * 4, "got %u.\n", value32);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 123 * 4 * 456, "got %u.\n", value32);
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -7990,26 +7966,20 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
/* MFVideoFlag_BottomUpLinearRep flag inverts the stride */
format.videoInfo.VideoFlags = MFVideoFlag_BottomUpLinearRep;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == -123 * 4, "got %u.\n", value32);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 123 * 4 * 456, "got %u.\n", value32);
IMFMediaType_DeleteAllItems(media_type);
/* MFVideoFlag_BottomUpLinearRep flag only works with RGB formats */
format.guidFormat = MFVideoFormat_H264;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8019,38 +7989,30 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.guidFormat = MFVideoFormat_NV12;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 124, "got %u.\n", value32);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 124 * 456 * 3 / 2, "got %u.\n", value32);
IMFMediaType_DeleteAllItems(media_type);
format.videoInfo.PixelAspectRatio.Numerator = 7;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
IMFMediaType_DeleteAllItems(media_type);
format.videoInfo.PixelAspectRatio.Denominator = 8;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value64 = 0xdeadbeef;
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value64 == (((UINT64)7 << 32) | 8), "got %#I64x.\n", value64);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_CHROMA_SITING, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8058,13 +8020,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.SourceChromaSubsampling = MFVideoChromaSubsampling_MPEG2;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_CHROMA_SITING, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFVideoChromaSubsampling_MPEG2, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8072,13 +8031,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.InterlaceMode = MFVideoInterlace_MixedInterlaceOrProgressive;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFVideoInterlace_MixedInterlaceOrProgressive, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_TRANSFER_FUNCTION, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8086,13 +8042,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.TransferFunction = MFVideoTransFunc_709;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_TRANSFER_FUNCTION, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFVideoTransFunc_709, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_PRIMARIES, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8100,13 +8053,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.ColorPrimaries = MFVideoPrimaries_BT709;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_PRIMARIES, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFVideoPrimaries_BT709, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_YUV_MATRIX, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8114,13 +8064,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.TransferMatrix = MFVideoTransferMatrix_BT709;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_YUV_MATRIX, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFVideoTransferMatrix_BT709, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_LIGHTING, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8128,13 +8075,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.SourceLighting = MFVideoLighting_bright;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_LIGHTING, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFVideoLighting_bright, "got %u.\n", value32);
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8142,20 +8086,16 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.FramesPerSecond.Numerator = 30000;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
IMFMediaType_DeleteAllItems(media_type);
format.videoInfo.FramesPerSecond.Denominator = 1001;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value64 = 0xdeadbeef;
hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value64 == (((UINT64)30000 << 32) | 1001), "got %#I64x.\n", value64);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8163,13 +8103,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.NominalRange = MFNominalRange_Wide;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == MFNominalRange_Wide, "got %u.\n", value32);
hr = IMFMediaType_GetBlobSize(media_type, &MF_MT_GEOMETRIC_APERTURE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8181,22 +8118,17 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.GeometricAperture.OffsetY.fract = 4;
format.videoInfo.GeometricAperture.Area.cx = -120;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetBlob(media_type, &MF_MT_GEOMETRIC_APERTURE, (BYTE *)&aperture, sizeof(aperture), &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
format.videoInfo.GeometricAperture.Area.cy = -450;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
memset(&aperture, 0xcd, sizeof(aperture));
hr = IMFMediaType_GetBlob(media_type, &MF_MT_GEOMETRIC_APERTURE, (BYTE *)&aperture, sizeof(aperture), &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == sizeof(aperture), "got %u.\n", value32);
todo_wine
ok(!memcmp(&format.videoInfo.GeometricAperture, &aperture, sizeof(aperture)), "Unexpected aperture.\n");
hr = IMFMediaType_GetBlobSize(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8208,22 +8140,17 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.MinimumDisplayAperture.OffsetY.fract = 4;
format.videoInfo.MinimumDisplayAperture.Area.cx = 120;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetBlob(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, (BYTE *)&aperture, sizeof(aperture), &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
format.videoInfo.MinimumDisplayAperture.Area.cy = 450;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
memset(&aperture, 0xcd, sizeof(aperture));
hr = IMFMediaType_GetBlob(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, (BYTE *)&aperture, sizeof(aperture), &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == sizeof(aperture), "got %u.\n", value32);
todo_wine
ok(!memcmp(&format.videoInfo.MinimumDisplayAperture, &aperture, sizeof(aperture)), "Unexpected aperture.\n");
hr = IMFMediaType_GetBlobSize(media_type, &MF_MT_PAN_SCAN_APERTURE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8235,22 +8162,17 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.PanScanAperture.OffsetY.fract = 4;
format.videoInfo.PanScanAperture.Area.cx = 120;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetBlob(media_type, &MF_MT_PAN_SCAN_APERTURE, (BYTE *)&aperture, sizeof(aperture), &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
format.videoInfo.PanScanAperture.Area.cy = 450;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
memset(&aperture, 0xcd, sizeof(aperture));
hr = IMFMediaType_GetBlob(media_type, &MF_MT_PAN_SCAN_APERTURE, (BYTE *)&aperture, sizeof(aperture), &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == sizeof(aperture), "got %u.\n", value32);
todo_wine
ok(!memcmp(&format.videoInfo.PanScanAperture, &aperture, sizeof(aperture)), "Unexpected aperture.\n");
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_PAN_SCAN_ENABLED, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8258,13 +8180,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.VideoFlags |= MFVideoFlag_PanScanEnabled;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_PAN_SCAN_ENABLED, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 1, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_PAD_CONTROL_FLAGS, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8272,13 +8191,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.VideoFlags |= MFVideoFlag_PAD_TO_16x9;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_PAD_CONTROL_FLAGS, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 2, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SOURCE_CONTENT_HINT, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8286,13 +8202,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.VideoFlags |= MFVideoFlag_SrcContentHint16x9;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SOURCE_CONTENT_HINT, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 1, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DRM_FLAGS, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8300,13 +8213,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.videoInfo.VideoFlags |= MFVideoFlag_DigitallyProtected;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DRM_FLAGS, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 2, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8314,13 +8224,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.compressedInfo.AvgBitrate = 123456;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 123456, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8328,13 +8235,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.compressedInfo.AvgBitErrorRate = 654321;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == 654321, "got %u.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_MAX_KEYFRAME_SPACING, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8342,13 +8246,10 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.compressedInfo.MaxKeyFrameSpacing = -123;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_MAX_KEYFRAME_SPACING, &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == -123, "got %u.\n", value32);
hr = IMFMediaType_GetBlobSize(media_type, &MF_MT_PALETTE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8358,7 +8259,6 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
format.guidFormat = MFVideoFormat_H264;
format.surfaceInfo.Format = MFVideoFormat_H264.Data1;
hr = MFInitMediaTypeFromMFVideoFormat(media_type, &format, sizeof(format));
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetBlobSize(media_type, &MF_MT_PALETTE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8372,21 +8272,16 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
/* format sizes needs to include an extra palette entry */
format_buf->dwSize = offsetof(MFVIDEOFORMAT, surfaceInfo.Palette[ARRAY_SIZE(expect_palette)]);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, format_buf, sizeof(format));
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
format_buf->dwSize = offsetof(MFVIDEOFORMAT, surfaceInfo.Palette[ARRAY_SIZE(expect_palette) + 1]);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, format_buf, format_buf->dwSize);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
memset(&palette, 0xcd, sizeof(palette));
hr = IMFMediaType_GetBlob(media_type, &MF_MT_PALETTE, (BYTE *)&palette, sizeof(palette), &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == sizeof(expect_palette), "got %u.\n", value32);
todo_wine
ok(!memcmp(palette, expect_palette, value32), "Unexpected palette.\n");
hr = IMFMediaType_GetBlobSize(media_type, &MF_MT_USER_DATA, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
......@@ -8395,16 +8290,12 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
memcpy(buffer + format_buf->dwSize, expect_user_data, sizeof(expect_user_data));
format_buf->dwSize += sizeof(expect_user_data);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, format_buf, format_buf->dwSize);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
memset(&user_data, 0xcd, sizeof(user_data));
hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, (BYTE *)user_data, sizeof(user_data), &value32);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(value32 == sizeof(expect_user_data), "got %u.\n", value32);
todo_wine
ok(!memcmp(user_data, expect_user_data, value32), "Unexpected user data.\n");
IMFMediaType_DeleteAllItems(media_type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment