mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
mfplat/sample: Optimize copying to 2d buffer.
This commit is contained in:
parent
ac4a2c4c75
commit
bf58285a90
1 changed files with 22 additions and 2 deletions
|
@ -796,8 +796,9 @@ static HRESULT WINAPI sample_CopyToBuffer(IMFSample *iface, IMFMediaBuffer *buff
|
|||
struct sample *sample = impl_from_IMFSample(iface);
|
||||
DWORD total_length, dst_length, dst_current_length, src_max_length, current_length;
|
||||
BYTE *src_ptr, *dst_ptr;
|
||||
BOOL locked;
|
||||
HRESULT hr;
|
||||
IMF2DBuffer *buffer2d;
|
||||
BOOL locked = FALSE;
|
||||
HRESULT hr = E_FAIL;
|
||||
size_t i;
|
||||
|
||||
TRACE("%p, %p.\n", iface, buffer);
|
||||
|
@ -807,6 +808,25 @@ static HRESULT WINAPI sample_CopyToBuffer(IMFSample *iface, IMFMediaBuffer *buff
|
|||
total_length = sample_get_total_length(sample);
|
||||
dst_current_length = 0;
|
||||
|
||||
if (sample->buffer_count == 1
|
||||
&& SUCCEEDED(IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&buffer2d)))
|
||||
{
|
||||
if (SUCCEEDED(IMFMediaBuffer_GetCurrentLength(sample->buffers[0], ¤t_length))
|
||||
&& SUCCEEDED(IMF2DBuffer_GetContiguousLength(buffer2d, &dst_length))
|
||||
&& current_length == dst_length
|
||||
&& SUCCEEDED(IMFMediaBuffer_Lock(sample->buffers[0], &src_ptr, &src_max_length, ¤t_length)))
|
||||
{
|
||||
hr = IMF2DBuffer_ContiguousCopyFrom(buffer2d, src_ptr, current_length);
|
||||
IMFMediaBuffer_Unlock(sample->buffers[0]);
|
||||
}
|
||||
IMF2DBuffer_Release(buffer2d);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
dst_current_length = current_length;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
dst_ptr = NULL;
|
||||
dst_length = current_length = 0;
|
||||
locked = SUCCEEDED(hr = IMFMediaBuffer_Lock(buffer, &dst_ptr, &dst_length, ¤t_length));
|
||||
|
|
Loading…
Reference in a new issue