[PATCH 5/5] amstream: Use current format to create surface in AMDirectDrawStream::CreateSample.
Anton Baskanov
baskanov at gmail.com
Sat Aug 29 08:51:33 CDT 2020
Signed-off-by: Anton Baskanov <baskanov at gmail.com>
---
dlls/amstream/ddrawstream.c | 24 +++---
dlls/amstream/tests/amstream.c | 142 +++++++++++++++++++++++++++++++++
2 files changed, 153 insertions(+), 13 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c
index 5dc29bed033..da5cd18df99 100644
--- a/dlls/amstream/ddrawstream.c
+++ b/dlls/amstream/ddrawstream.c
@@ -1364,19 +1364,17 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
return hr;
}
- desc.dwSize = sizeof(desc);
- desc.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT;
- desc.dwHeight = 100;
- desc.dwWidth = 100;
- desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
- desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
- desc.ddpfPixelFormat.u1.dwRGBBitCount = 32;
- desc.ddpfPixelFormat.u2.dwRBitMask = 0xff0000;
- desc.ddpfPixelFormat.u3.dwGBitMask = 0x00ff00;
- desc.ddpfPixelFormat.u4.dwBBitMask = 0x0000ff;
- desc.ddpfPixelFormat.u5.dwRGBAlphaBitMask = 0;
- desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN;
- desc.lpSurface = NULL;
+ desc = object->parent->format;
+ if (!(desc.dwFlags & DDSD_PIXELFORMAT))
+ {
+ desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
+ desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ desc.ddpfPixelFormat.u1.dwRGBBitCount = 32;
+ desc.ddpfPixelFormat.u2.dwRBitMask = 0xff0000;
+ desc.ddpfPixelFormat.u3.dwGBitMask = 0x00ff00;
+ desc.ddpfPixelFormat.u4.dwBBitMask = 0x0000ff;
+ }
+ desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
hr = IDirectDraw_CreateSurface(ddraw, &desc, &object->surface, NULL);
IDirectDraw_Release(ddraw);
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index 7c02bd223d4..173ab9cac62 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -6424,6 +6424,81 @@ static void test_audiostreamsample_get_audio_data(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+static void get_ddrawstream_create_sample_desc(const DDSURFACEDESC *format1, const DDSURFACEDESC *format2, const AM_MEDIA_TYPE *mt, DDSURFACEDESC *desc)
+{
+ IAMMultiMediaStream *mmstream = create_ammultimediastream();
+ IDirectDrawMediaStream *ddraw_stream;
+ IDirectDrawStreamSample *sample;
+ IDirectDrawSurface *surface;
+ struct testfilter source;
+ IGraphBuilder *graph;
+ IMediaStream *stream;
+ HRESULT hr;
+ ULONG ref;
+ IPin *pin;
+
+ hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ testfilter_init(&source);
+
+ hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ if (format1)
+ {
+ hr = IDirectDrawMediaStream_SetFormat(ddraw_stream, format1, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ }
+ if (format2)
+ {
+ hr = IDirectDrawMediaStream_SetFormat(ddraw_stream, format2, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ }
+ if (mt)
+ {
+ hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IGraphBuilder_Disconnect(graph, pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ }
+
+ hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IDirectDrawStreamSample_GetSurface(sample, &surface, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!!surface, "Expected non-NULL sufrace.\n");
+
+ desc->dwSize = sizeof(*desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(surface, desc);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ref = IDirectDrawStreamSample_Release(sample);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IDirectDrawSurface_Release(surface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IGraphBuilder_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ IPin_Release(pin);
+ IDirectDrawMediaStream_Release(ddraw_stream);
+ ref = IMediaStream_Release(stream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
static void test_ddrawstream_create_sample(void)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
@@ -6431,6 +6506,8 @@ static void test_ddrawstream_create_sample(void)
DDSURFACEDESC desc = { sizeof(desc) };
IDirectDrawMediaStream *ddraw_stream;
IDirectDrawStreamSample *sample;
+ DDSURFACEDESC format1;
+ DDSURFACEDESC format2;
IMediaStream *stream;
IDirectDraw *ddraw;
HRESULT hr;
@@ -6532,6 +6609,71 @@ static void test_ddrawstream_create_sample(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IDirectDraw_Release(ddraw);
ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ format1 = rgb8_format;
+ format1.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
+ format1.dwWidth = 333;
+ format1.dwHeight = 444;
+ format2 = rgb8_format;
+ format2.dwFlags = 0;
+ get_ddrawstream_create_sample_desc(&format1, &format2, NULL, &desc);
+ ok(desc.dwWidth == 333, "Got width %u.\n", desc.dwWidth);
+ ok(desc.dwHeight == 444, "Got height %u.\n", desc.dwHeight);
+ ok(desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got flags %#x.\n", desc.ddpfPixelFormat.dwFlags);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 32, "Got rgb bit count %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+ ok(desc.ddpfPixelFormat.dwRBitMask == 0xff0000, "Got r bit mask %#x.\n", desc.ddpfPixelFormat.dwRBitMask);
+ ok(desc.ddpfPixelFormat.dwGBitMask == 0x00ff00, "Got g bit mask %#x.\n", desc.ddpfPixelFormat.dwGBitMask);
+ ok(desc.ddpfPixelFormat.dwBBitMask == 0x0000ff, "Got b bit mask %#x.\n", desc.ddpfPixelFormat.dwBBitMask);
+
+ get_ddrawstream_create_sample_desc(NULL, NULL, &rgb8_mt, &desc);
+ ok(desc.dwWidth == 333, "Got width %u.\n", desc.dwWidth);
+ ok(desc.dwHeight == 444, "Got height %u.\n", desc.dwHeight);
+ ok(desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got flags %#x.\n", desc.ddpfPixelFormat.dwFlags);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 32, "Got rgb bit count %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+ ok(desc.ddpfPixelFormat.dwRBitMask == 0xff0000, "Got r bit mask %#x.\n", desc.ddpfPixelFormat.dwRBitMask);
+ ok(desc.ddpfPixelFormat.dwGBitMask == 0x00ff00, "Got g bit mask %#x.\n", desc.ddpfPixelFormat.dwGBitMask);
+ ok(desc.ddpfPixelFormat.dwBBitMask == 0x0000ff, "Got b bit mask %#x.\n", desc.ddpfPixelFormat.dwBBitMask);
+
+ get_ddrawstream_create_sample_desc(&rgb565_format, NULL, NULL, &desc);
+ ok(desc.dwWidth == 100, "Got width %u.\n", desc.dwWidth);
+ ok(desc.dwHeight == 100, "Got height %u.\n", desc.dwHeight);
+ ok(desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got flags %#x.\n", desc.ddpfPixelFormat.dwFlags);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Got rgb bit count %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+ ok(desc.ddpfPixelFormat.dwRBitMask == 0xf800, "Got r bit mask %#x.\n", desc.ddpfPixelFormat.dwRBitMask);
+ ok(desc.ddpfPixelFormat.dwGBitMask == 0x07e0, "Got g bit mask %#x.\n", desc.ddpfPixelFormat.dwGBitMask);
+ ok(desc.ddpfPixelFormat.dwBBitMask == 0x001f, "Got b bit mask %#x.\n", desc.ddpfPixelFormat.dwBBitMask);
+
+ format1 = rgb32_format;
+ format1.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
+ format1.ddpfPixelFormat.dwRGBAlphaBitMask = 0xff000000;
+ get_ddrawstream_create_sample_desc(&format1, NULL, NULL, &desc);
+ ok(desc.dwWidth == 100, "Got width %u.\n", desc.dwWidth);
+ ok(desc.dwHeight == 100, "Got height %u.\n", desc.dwHeight);
+ ok(desc.ddpfPixelFormat.dwFlags == (DDPF_RGB | DDPF_ALPHAPIXELS), "Got flags %#x.\n", desc.ddpfPixelFormat.dwFlags);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 32, "Got rgb bit count %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+ ok(desc.ddpfPixelFormat.dwRBitMask == 0xff0000, "Got r bit mask %#x.\n", desc.ddpfPixelFormat.dwRBitMask);
+ ok(desc.ddpfPixelFormat.dwGBitMask == 0x00ff00, "Got g bit mask %#x.\n", desc.ddpfPixelFormat.dwGBitMask);
+ ok(desc.ddpfPixelFormat.dwBBitMask == 0x0000ff, "Got b bit mask %#x.\n", desc.ddpfPixelFormat.dwBBitMask);
+ ok(desc.ddpfPixelFormat.dwRGBAlphaBitMask == 0xff000000,
+ "Got alpha bit mask %#x.\n", desc.ddpfPixelFormat.dwBBitMask);
+
+ format1 = rgb32_format;
+ format1.dwFlags |= DDSD_CKSRCBLT;
+ format1.ddckCKSrcBlt.dwColorSpaceLowValue = 0xff00ff;
+ format1.ddckCKSrcBlt.dwColorSpaceHighValue = 0xff00ff;
+ get_ddrawstream_create_sample_desc(&format1, NULL, NULL, &desc);
+ ok(!(desc.dwFlags & DDSD_CKSRCBLT), "Expected unset DDSD_CKSRCBLT.\n");
+ ok(desc.dwWidth == 100, "Got width %u.\n", desc.dwWidth);
+ ok(desc.dwHeight == 100, "Got height %u.\n", desc.dwHeight);
+ ok(desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got flags %#x.\n", desc.ddpfPixelFormat.dwFlags);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 32, "Got rgb bit count %u.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+ ok(desc.ddpfPixelFormat.dwRBitMask == 0xff0000, "Got r bit mask %#x.\n", desc.ddpfPixelFormat.dwRBitMask);
+ ok(desc.ddpfPixelFormat.dwGBitMask == 0x00ff00, "Got g bit mask %#x.\n", desc.ddpfPixelFormat.dwGBitMask);
+ ok(desc.ddpfPixelFormat.dwBBitMask == 0x0000ff, "Got b bit mask %#x.\n", desc.ddpfPixelFormat.dwBBitMask);
+ ok(desc.ddckCKSrcBlt.dwColorSpaceLowValue == 0, "Got color key low value %#x.\n",
+ desc.ddckCKSrcBlt.dwColorSpaceLowValue);
+ ok(desc.ddckCKSrcBlt.dwColorSpaceHighValue == 0, "Got color key high value %#x.\n",
+ desc.ddckCKSrcBlt.dwColorSpaceHighValue);
}
static void test_ddrawstreamsample_get_media_stream(void)
--
2.17.1
More information about the wine-devel
mailing list