Commit 409392df authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

evr/mixer: Add partial implementation of sample processing.

parent 292b54f3
......@@ -1163,6 +1163,65 @@ static HRESULT video_mixer_get_d3d_device(struct video_mixer *mixer, IDirect3DDe
return hr;
}
static void video_mixer_scale_rect(RECT *rect, unsigned int width, unsigned int height,
const MFVideoNormalizedRect *scale)
{
if (rect->left == 0.0f && rect->top == 0.0f && rect->right == 1.0f && rect->bottom == 1.0f)
{
SetRect(rect, 0, 0, width, height);
}
else
{
rect->left = width * scale->left;
rect->right = width * scale->right;
rect->top = height * scale->top;
rect->bottom = height * scale->bottom;
}
}
static void video_mixer_render(struct video_mixer *mixer, IDirect3DSurface9 *rt)
{
DXVA2_VideoSample samples[1] = {{ 0 }};
DXVA2_VideoProcessBltParams params = { 0 };
MFVideoNormalizedRect zoom_rect;
struct input_stream *stream;
IDirect3DSurface9 *surface;
D3DSURFACE_DESC desc;
HRESULT hr;
IDirect3DSurface9_GetDesc(rt, &desc);
if (FAILED(IMFAttributes_GetBlob(mixer->attributes, &VIDEO_ZOOM_RECT, (UINT8 *)&zoom_rect,
sizeof(zoom_rect), NULL)))
{
zoom_rect.left = zoom_rect.top = 0.0f;
zoom_rect.right = zoom_rect.bottom = 1.0f;
}
video_mixer_scale_rect(&params.TargetRect, desc.Width, desc.Height, &zoom_rect);
/* FIXME: for now only handle reference stream. */
video_mixer_get_input(mixer, 0, &stream);
if (FAILED(hr = video_mixer_get_sample_surface(stream->sample, &surface)))
{
WARN("Failed to get source surface, hr %#x.\n", hr);
return;
}
IDirect3DSurface9_GetDesc(surface, &desc);
samples[0].SrcSurface = surface;
SetRect(&samples[0].SrcRect, 0, 0, desc.Width, desc.Height);
video_mixer_scale_rect(&samples[0].DstRect, desc.Width, desc.Height, &stream->rect);
if (FAILED(hr = IDirectXVideoProcessor_VideoProcessBlt(mixer->processor, rt, &params, samples, 1, NULL)))
WARN("Failed to process samples, hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
}
static HRESULT WINAPI video_mixer_transform_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count,
MFT_OUTPUT_DATA_BUFFER *buffers, DWORD *status)
{
......@@ -1197,12 +1256,14 @@ static HRESULT WINAPI video_mixer_transform_ProcessOutput(IMFTransform *iface, D
}
}
/* FIXME: for now discard input */
if (SUCCEEDED(hr))
video_mixer_render(mixer, surface);
if (SUCCEEDED(hr))
{
for (i = 0; i < mixer->input_count; ++i)
{
if (mixer->inputs[i].sample)
IMFSample_Release(mixer->inputs[i].sample);
mixer->inputs[i].sample = NULL;
video_mixer_request_sample(mixer, i);
......
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