winegstreamer: Complete H264 current output type reported attributes.

This commit is contained in:
Rémi Bernon 2024-02-17 08:56:27 +01:00 committed by Alexandre Julliard
parent a6d77cfd06
commit 6599f2ff90

View file

@ -115,9 +115,9 @@ static HRESULT try_create_wg_transform(struct h264_decoder *decoder)
}
static HRESULT create_output_media_type(struct h264_decoder *decoder, const GUID *subtype,
IMFMediaType **media_type)
IMFMediaType *output_type, IMFMediaType **media_type)
{
IMFMediaType *default_type = decoder->output_type;
IMFMediaType *default_type = decoder->output_type, *stream_type = output_type ? output_type : decoder->stream_type;
IMFVideoMediaType *video_type;
UINT32 value, width, height;
MFVideoArea aperture;
@ -127,31 +127,31 @@ static HRESULT create_output_media_type(struct h264_decoder *decoder, const GUID
if (FAILED(hr = MFCreateVideoMediaTypeFromSubtype(subtype, &video_type)))
return hr;
if (FAILED(IMFMediaType_GetUINT64(decoder->stream_type, &MF_MT_FRAME_SIZE, &ratio)))
if (FAILED(IMFMediaType_GetUINT64(stream_type, &MF_MT_FRAME_SIZE, &ratio)))
ratio = (UINT64)1920 << 32 | 1080;
if (FAILED(hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, ratio)))
goto done;
width = ratio >> 32;
height = ratio;
if (FAILED(IMFMediaType_GetUINT64(decoder->stream_type, &MF_MT_FRAME_RATE, &ratio)))
if (FAILED(IMFMediaType_GetUINT64(stream_type, &MF_MT_FRAME_RATE, &ratio)))
ratio = (UINT64)30000 << 32 | 1001;
if (FAILED(hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_FRAME_RATE, ratio)))
goto done;
if (FAILED(IMFMediaType_GetUINT64(decoder->stream_type, &MF_MT_PIXEL_ASPECT_RATIO, &ratio)))
if (FAILED(IMFMediaType_GetUINT64(stream_type, &MF_MT_PIXEL_ASPECT_RATIO, &ratio)))
ratio = (UINT64)1 << 32 | 1;
if (FAILED(hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_PIXEL_ASPECT_RATIO, ratio)))
goto done;
if (FAILED(hr = MFCalculateImageSize(subtype, width, height, &value)))
goto done;
if (FAILED(hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_SAMPLE_SIZE, value)))
if (!output_type || FAILED(IMFMediaType_GetUINT32(output_type, &MF_MT_SAMPLE_SIZE, &value)))
hr = MFCalculateImageSize(subtype, width, height, &value);
if (FAILED(hr) || FAILED(hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_SAMPLE_SIZE, value)))
goto done;
if (FAILED(hr = MFGetStrideForBitmapInfoHeader(subtype->Data1, width, (LONG *)&value)))
goto done;
if (FAILED(hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_DEFAULT_STRIDE, value)))
if (!output_type || FAILED(IMFMediaType_GetUINT32(output_type, &MF_MT_DEFAULT_STRIDE, &value)))
hr = MFGetStrideForBitmapInfoHeader(subtype->Data1, width, (LONG *)&value);
if (FAILED(hr) || FAILED(hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_DEFAULT_STRIDE, value)))
goto done;
if (!default_type || FAILED(IMFMediaType_GetUINT32(default_type, &MF_MT_INTERLACE_MODE, &value)))
@ -174,7 +174,7 @@ static HRESULT create_output_media_type(struct h264_decoder *decoder, const GUID
if (FAILED(hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_FIXED_SIZE_SAMPLES, value)))
goto done;
if (SUCCEEDED(IMFMediaType_GetBlob(decoder->stream_type, &MF_MT_MINIMUM_DISPLAY_APERTURE,
if (SUCCEEDED(IMFMediaType_GetBlob(stream_type, &MF_MT_MINIMUM_DISPLAY_APERTURE,
(BYTE *)&aperture, sizeof(aperture), &value)))
{
if (FAILED(hr = IMFVideoMediaType_SetBlob(video_type, &MF_MT_MINIMUM_DISPLAY_APERTURE,
@ -394,7 +394,7 @@ static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWOR
return MF_E_TRANSFORM_TYPE_NOT_SET;
if (index >= decoder->output_type_count)
return MF_E_NO_MORE_TYPES;
return create_output_media_type(decoder, decoder->output_types[index], type);
return create_output_media_type(decoder, decoder->output_types[index], NULL, type);
}
static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
@ -521,17 +521,16 @@ static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD i
static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
{
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
GUID subtype;
HRESULT hr;
TRACE("iface %p, id %#lx, type %p\n", iface, id, type);
if (!decoder->output_type)
return MF_E_TRANSFORM_TYPE_NOT_SET;
if (FAILED(hr = MFCreateMediaType(type)))
if (FAILED(hr = IMFMediaType_GetGUID(decoder->output_type, &MF_MT_SUBTYPE, &subtype)))
return hr;
return IMFMediaType_CopyAllItems(decoder->output_type, (IMFAttributes *)*type);
return create_output_media_type(decoder, &subtype, decoder->output_type, type);
}
static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)