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

winegstreamer: Keep input / output stream info in struct color_convert.

And calculate the sizes when media type is successfully changed.
parent 076f348c
......@@ -80,8 +80,11 @@ struct color_convert
IPropertyStore IPropertyStore_iface;
IUnknown *outer;
LONG refcount;
IMFMediaType *input_type;
MFT_INPUT_STREAM_INFO input_info;
IMFMediaType *output_type;
MFT_OUTPUT_STREAM_INFO output_info;
struct wg_transform *wg_transform;
struct wg_sample_queue *wg_sample_queue;
......@@ -228,54 +231,32 @@ static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_si
static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info)
{
struct color_convert *impl = impl_from_IMFTransform(iface);
UINT32 sample_size;
UINT64 framesize;
GUID subtype;
HRESULT hr;
TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
if (!impl->input_type || !impl->output_type)
{
memset(info, 0, sizeof(*info));
return MF_E_TRANSFORM_TYPE_NOT_SET;
}
if (SUCCEEDED(hr = IMFMediaType_GetGUID(impl->input_type, &MF_MT_SUBTYPE, &subtype)) &&
SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->input_type, &MF_MT_FRAME_SIZE, &framesize)))
MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size);
else
sample_size = 0;
info->dwFlags = 0;
info->cbSize = sample_size;
info->cbAlignment = 1;
info->hnsMaxLatency = 0;
info->cbMaxLookahead = 0;
*info = impl->input_info;
return S_OK;
}
static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info)
{
struct color_convert *impl = impl_from_IMFTransform(iface);
UINT32 sample_size;
UINT64 framesize;
GUID subtype;
HRESULT hr;
TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
if (!impl->input_type || !impl->output_type)
{
memset(info, 0, sizeof(*info));
return MF_E_TRANSFORM_TYPE_NOT_SET;
}
if (SUCCEEDED(hr = IMFMediaType_GetGUID(impl->output_type, &MF_MT_SUBTYPE, &subtype)) &&
SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->output_type, &MF_MT_FRAME_SIZE, &framesize)))
MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size);
else
sample_size = 0;
info->dwFlags = 0;
info->cbSize = sample_size;
info->cbAlignment = 1;
*info = impl->output_info;
return S_OK;
}
......@@ -380,8 +361,8 @@ done:
static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
{
struct color_convert *impl = impl_from_IMFTransform(iface);
MF_ATTRIBUTE_TYPE item_type;
GUID major, subtype;
UINT64 frame_size;
HRESULT hr;
ULONG i;
......@@ -392,8 +373,7 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
return MF_E_ATTRIBUTENOTFOUND;
if (!IsEqualGUID(&major, &MFMediaType_Video)
|| FAILED(IMFMediaType_GetItemType(type, &MF_MT_FRAME_SIZE, &item_type))
|| item_type != MF_ATTRIBUTE_UINT64)
|| IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &frame_size))
return E_INVALIDARG;
for (i = 0; i < ARRAY_SIZE(input_types); ++i)
......@@ -419,14 +399,18 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
impl->input_type = NULL;
}
if (FAILED(hr) || FAILED(MFCalculateImageSize(&subtype, frame_size >> 32, (UINT32)frame_size,
(UINT32 *)&impl->input_info.cbSize)))
impl->input_info.cbSize = 0;
return hr;
}
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
{
struct color_convert *impl = impl_from_IMFTransform(iface);
MF_ATTRIBUTE_TYPE item_type;
GUID major, subtype;
UINT64 frame_size;
HRESULT hr;
ULONG i;
......@@ -437,8 +421,7 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
return MF_E_ATTRIBUTENOTFOUND;
if (!IsEqualGUID(&major, &MFMediaType_Video)
|| FAILED(IMFMediaType_GetItemType(type, &MF_MT_FRAME_SIZE, &item_type))
|| item_type != MF_ATTRIBUTE_UINT64)
|| IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &frame_size))
return E_INVALIDARG;
for (i = 0; i < ARRAY_SIZE(output_types); ++i)
......@@ -464,6 +447,10 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
impl->output_type = NULL;
}
if (FAILED(hr) || FAILED(MFCalculateImageSize(&subtype, frame_size >> 32, (UINT32)frame_size,
(UINT32 *)&impl->output_info.cbSize)))
impl->output_info.cbSize = 0;
return hr;
}
......@@ -963,6 +950,9 @@ HRESULT color_convert_create(IUnknown *outer, IUnknown **out)
impl->refcount = 1;
impl->outer = outer ? outer : &impl->IUnknown_inner;
impl->input_info.cbAlignment = 1;
impl->output_info.cbAlignment = 1;
*out = &impl->IUnknown_inner;
TRACE("Created %p\n", *out);
return S_OK;
......
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