1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

mfplat/mediatype: Implement VIDEOINFOHEADER2 dwControlFlags conversion.

This commit is contained in:
Rémi Bernon 2024-02-17 15:45:36 +01:00 committed by Alexandre Julliard
parent 5a34601606
commit 76abdf3403
2 changed files with 38 additions and 5 deletions

View file

@ -21,6 +21,7 @@
#include "mfplat_private.h"
#include <math.h>
#include "dxva.h"
#include "dxva2api.h"
#include "uuids.h"
#include "strmif.h"
@ -3815,6 +3816,24 @@ HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader2(IMFMediaType *media_type, con
mediatype_set_uint64(media_type, &MF_MT_FRAME_RATE, num, den, &hr);
}
if (vih->dwControlFlags & AMCONTROL_COLORINFO_PRESENT)
{
DXVA_ExtendedFormat *format = (DXVA_ExtendedFormat *)&vih->dwControlFlags;
if (format->VideoChromaSubsampling)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_CHROMA_SITING, format->VideoChromaSubsampling, &hr);
if (format->NominalRange)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, format->NominalRange, &hr);
if (format->VideoTransferMatrix)
mediatype_set_uint32(media_type, &MF_MT_YUV_MATRIX, format->VideoTransferMatrix, &hr);
if (format->VideoLighting)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_LIGHTING, format->VideoLighting, &hr);
if (format->VideoPrimaries)
mediatype_set_uint32(media_type, &MF_MT_VIDEO_PRIMARIES, format->VideoPrimaries, &hr);
if (format->VideoTransferFunction)
mediatype_set_uint32(media_type, &MF_MT_TRANSFER_FUNCTION, format->VideoTransferFunction, &hr);
}
return hr;
}
@ -3930,7 +3949,8 @@ static HRESULT init_am_media_type_audio_format(AM_MEDIA_TYPE *am_type, UINT32 us
static void init_video_info_header2(VIDEOINFOHEADER2 *vih, const GUID *subtype, IMFMediaType *media_type)
{
struct uncompressed_video_format *video_format = mf_get_video_format(subtype);
UINT32 image_size, bitrate, sample_size, width, height;
DXVA_ExtendedFormat *format = (DXVA_ExtendedFormat *)&vih->dwControlFlags;
UINT32 image_size, bitrate, sample_size, width, height, value;
UINT64 frame_size, frame_rate;
vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
@ -3975,6 +3995,23 @@ static void init_video_info_header2(VIDEOINFOHEADER2 *vih, const GUID *subtype,
vih->rcSource.bottom = vih->rcTarget.bottom = height;
}
}
if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_CHROMA_SITING, &value)))
format->VideoChromaSubsampling = value;
if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value)))
format->NominalRange = value;
if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_YUV_MATRIX, &value)))
format->VideoTransferMatrix = value;
if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_LIGHTING, &value)))
format->VideoLighting = value;
if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_PRIMARIES, &value)))
format->VideoPrimaries = value;
if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_TRANSFER_FUNCTION, &value)))
format->VideoTransferFunction = value;
if (format->VideoChromaSubsampling || format->NominalRange || format->VideoTransferMatrix
|| format->VideoLighting || format->VideoPrimaries || format->VideoTransferFunction)
format->SampleFormat = AMCONTROL_COLORINFO_PRESENT;
}
static HRESULT init_am_media_type_video_format(AM_MEDIA_TYPE *am_type, UINT32 user_size, IMFMediaType *media_type)

View file

@ -10348,9 +10348,7 @@ static void test_MFInitMediaTypeFromVideoInfoHeader2(void)
hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
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_SMPTE240M, "Unexpected value %#x.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value32);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
@ -10360,9 +10358,7 @@ static void test_MFInitMediaTypeFromVideoInfoHeader2(void)
hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
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, "Unexpected value %#x.\n", value32);
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32);