Commit ef354da5 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Set the MF_MT_DEFAULT_STRIDE attribute in mf_media_type_from_wg_format().

parent 98d20975
......@@ -821,7 +821,7 @@ static void test_source_reader(const char *filename, bool video)
(unsigned int)(framesize >> 32), (unsigned int)framesize);
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_DEFAULT_STRIDE, &stride);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
IMFMediaType_Release(mediatype);
......@@ -845,8 +845,8 @@ static void test_source_reader(const char *filename, bool video)
ok(IsEqualGUID(&subtype, &MFVideoFormat_NV12), "Got subtype %s.\n", debugstr_guid(&subtype));
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_DEFAULT_STRIDE, &stride);
todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine ok(stride == 160, "Got stride %u.\n", stride);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(stride == 160, "Got stride %u.\n", stride);
IMFMediaType_Release(mediatype);
......
......@@ -148,6 +148,10 @@ HRESULT wg_transform_read_dmo(struct wg_transform *transform, DMO_OUTPUT_DATA_BU
HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj);
unsigned int wg_format_get_stride(const struct wg_format *format);
bool wg_video_format_is_rgb(enum wg_video_format format);
HRESULT aac_decoder_create(REFIID riid, void **ret);
HRESULT h264_decoder_create(REFIID riid, void **ret);
HRESULT video_processor_create(REFIID riid, void **ret);
......
......@@ -413,6 +413,70 @@ bool wg_transform_set_output_format(struct wg_transform *transform, struct wg_fo
return !WINE_UNIX_CALL(unix_wg_transform_set_output_format, &params);
}
#define ALIGN(n, alignment) (((n) + (alignment) - 1) & ~((alignment) - 1))
unsigned int wg_format_get_stride(const struct wg_format *format)
{
const unsigned int width = format->u.video.width;
switch (format->u.video.format)
{
case WG_VIDEO_FORMAT_AYUV:
return width * 4;
case WG_VIDEO_FORMAT_BGRA:
case WG_VIDEO_FORMAT_BGRx:
return width * 4;
case WG_VIDEO_FORMAT_BGR:
return ALIGN(width * 3, 4);
case WG_VIDEO_FORMAT_UYVY:
case WG_VIDEO_FORMAT_YUY2:
case WG_VIDEO_FORMAT_YVYU:
return ALIGN(width * 2, 4);
case WG_VIDEO_FORMAT_RGB15:
case WG_VIDEO_FORMAT_RGB16:
return ALIGN(width * 2, 4);
case WG_VIDEO_FORMAT_I420:
case WG_VIDEO_FORMAT_NV12:
case WG_VIDEO_FORMAT_YV12:
return ALIGN(width, 4); /* Y plane */
case WG_VIDEO_FORMAT_UNKNOWN:
FIXME("Cannot calculate stride for unknown video format.\n");
}
return 0;
}
bool wg_video_format_is_rgb(enum wg_video_format format)
{
switch (format)
{
case WG_VIDEO_FORMAT_BGRA:
case WG_VIDEO_FORMAT_BGRx:
case WG_VIDEO_FORMAT_BGR:
case WG_VIDEO_FORMAT_RGB15:
case WG_VIDEO_FORMAT_RGB16:
return true;
case WG_VIDEO_FORMAT_AYUV:
case WG_VIDEO_FORMAT_I420:
case WG_VIDEO_FORMAT_NV12:
case WG_VIDEO_FORMAT_UYVY:
case WG_VIDEO_FORMAT_YUY2:
case WG_VIDEO_FORMAT_YV12:
case WG_VIDEO_FORMAT_YVYU:
case WG_VIDEO_FORMAT_UNKNOWN:
break;
}
return false;
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
......
......@@ -511,6 +511,7 @@ static IMFMediaType *mf_media_type_from_wg_format_video(const struct wg_format *
{
if (format->u.video.format == video_formats[i].format)
{
unsigned int stride = wg_format_get_stride(format);
int32_t height = abs(format->u.video.height);
int32_t width = format->u.video.width;
......@@ -526,6 +527,12 @@ static IMFMediaType *mf_media_type_from_wg_format_video(const struct wg_format *
IMFMediaType_SetUINT32(type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
IMFMediaType_SetUINT32(type, &MF_MT_VIDEO_ROTATION, MFVideoRotationFormat_0);
if (wg_video_format_is_rgb(format->u.video.format))
stride = -stride;
if (format->u.video.height < 0)
stride = -stride;
IMFMediaType_SetUINT32(type, &MF_MT_DEFAULT_STRIDE, stride);
if (!IsRectEmpty(&format->u.video.padding))
{
MFVideoArea aperture =
......
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