Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6601fb3e
Commit
6601fb3e
authored
Mar 17, 2020
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mfplat: Implement ConvertToContiguousBuffer() for multiple buffers.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c567af73
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
26 deletions
+107
-26
buffer.c
dlls/mfplat/buffer.c
+89
-21
mfplat.c
dlls/mfplat/tests/mfplat.c
+18
-5
No files found.
dlls/mfplat/buffer.c
View file @
6601fb3e
...
...
@@ -1136,9 +1136,78 @@ static HRESULT WINAPI sample_GetBufferByIndex(IMFSample *iface, DWORD index, IMF
return
hr
;
}
static
unsigned
int
sample_get_total_length
(
struct
sample
*
sample
)
{
DWORD
total_length
=
0
,
length
;
size_t
i
;
for
(
i
=
0
;
i
<
sample
->
buffer_count
;
++
i
)
{
length
=
0
;
if
(
SUCCEEDED
(
IMFMediaBuffer_GetCurrentLength
(
sample
->
buffers
[
i
],
&
length
)))
total_length
+=
length
;
}
return
total_length
;
}
static
HRESULT
sample_copy_to_buffer
(
struct
sample
*
sample
,
IMFMediaBuffer
*
buffer
)
{
DWORD
total_length
,
dst_length
,
dst_current_length
,
src_max_length
,
current_length
;
BYTE
*
src_ptr
,
*
dst_ptr
;
BOOL
locked
;
HRESULT
hr
;
size_t
i
;
total_length
=
sample_get_total_length
(
sample
);
dst_current_length
=
0
;
dst_ptr
=
NULL
;
dst_length
=
current_length
=
0
;
locked
=
SUCCEEDED
(
hr
=
IMFMediaBuffer_Lock
(
buffer
,
&
dst_ptr
,
&
dst_length
,
&
current_length
));
if
(
locked
)
{
if
(
dst_length
<
total_length
)
hr
=
MF_E_BUFFERTOOSMALL
;
else
if
(
dst_ptr
)
{
for
(
i
=
0
;
i
<
sample
->
buffer_count
&&
SUCCEEDED
(
hr
);
++
i
)
{
src_ptr
=
NULL
;
src_max_length
=
current_length
=
0
;
if
(
SUCCEEDED
(
hr
=
IMFMediaBuffer_Lock
(
sample
->
buffers
[
i
],
&
src_ptr
,
&
src_max_length
,
&
current_length
)))
{
if
(
src_ptr
)
{
if
(
current_length
>
dst_length
)
hr
=
MF_E_BUFFERTOOSMALL
;
else
if
(
current_length
)
{
memcpy
(
dst_ptr
,
src_ptr
,
current_length
);
dst_length
-=
current_length
;
dst_current_length
+=
current_length
;
dst_ptr
+=
current_length
;
}
}
IMFMediaBuffer_Unlock
(
sample
->
buffers
[
i
]);
}
}
}
}
IMFMediaBuffer_SetCurrentLength
(
buffer
,
dst_current_length
);
if
(
locked
)
IMFMediaBuffer_Unlock
(
buffer
);
return
hr
;
}
static
HRESULT
WINAPI
sample_ConvertToContiguousBuffer
(
IMFSample
*
iface
,
IMFMediaBuffer
**
buffer
)
{
struct
sample
*
sample
=
impl_from_IMFSample
(
iface
);
unsigned
int
total_length
,
i
;
IMFMediaBuffer
*
dest_buffer
;
HRESULT
hr
=
S_OK
;
TRACE
(
"%p, %p.
\n
"
,
iface
,
buffer
);
...
...
@@ -1147,15 +1216,29 @@ static HRESULT WINAPI sample_ConvertToContiguousBuffer(IMFSample *iface, IMFMedi
if
(
sample
->
buffer_count
==
0
)
hr
=
E_UNEXPECTED
;
else
if
(
sample
->
buffer_count
==
1
)
else
if
(
sample
->
buffer_count
>
1
)
{
*
buffer
=
sample
->
buffers
[
0
];
IMFMediaBuffer_AddRef
(
*
buffer
);
total_length
=
sample_get_total_length
(
sample
);
if
(
SUCCEEDED
(
hr
=
MFCreateMemoryBuffer
(
total_length
,
&
dest_buffer
)))
{
if
(
SUCCEEDED
(
hr
=
sample_copy_to_buffer
(
sample
,
dest_buffer
)))
{
for
(
i
=
0
;
i
<
sample
->
buffer_count
;
++
i
)
IMFMediaBuffer_Release
(
sample
->
buffers
[
i
]);
sample
->
buffers
[
0
]
=
dest_buffer
;
IMFMediaBuffer_AddRef
(
sample
->
buffers
[
0
]);
sample
->
buffer_count
=
1
;
}
else
IMFMediaBuffer_Release
(
dest_buffer
);
}
}
if
(
SUCCEEDED
(
hr
))
{
FIXME
(
"Samples with multiple buffers are not supported.
\n
"
)
;
hr
=
E_NOTIMPL
;
*
buffer
=
sample
->
buffers
[
0
]
;
IMFMediaBuffer_AddRef
(
*
buffer
)
;
}
LeaveCriticalSection
(
&
sample
->
attributes
.
cs
);
...
...
@@ -1225,21 +1308,6 @@ static HRESULT WINAPI sample_RemoveAllBuffers(IMFSample *iface)
return
S_OK
;
}
static
DWORD
sample_get_total_length
(
struct
sample
*
sample
)
{
DWORD
total_length
=
0
,
length
;
size_t
i
;
for
(
i
=
0
;
i
<
sample
->
buffer_count
;
++
i
)
{
length
=
0
;
if
(
SUCCEEDED
(
IMFMediaBuffer_GetCurrentLength
(
sample
->
buffers
[
i
],
&
length
)))
total_length
+=
length
;
}
return
total_length
;
}
static
HRESULT
WINAPI
sample_GetTotalLength
(
IMFSample
*
iface
,
DWORD
*
total_length
)
{
struct
sample
*
sample
=
impl_from_IMFSample
(
iface
);
...
...
dlls/mfplat/tests/mfplat.c
View file @
6601fb3e
...
...
@@ -1778,7 +1778,7 @@ static void test_system_memory_buffer(void)
static
void
test_sample
(
void
)
{
static
const
DWORD
test_pattern
=
0x22222222
;
IMFMediaBuffer
*
buffer
,
*
buffer2
;
IMFMediaBuffer
*
buffer
,
*
buffer2
,
*
buffer3
;
DWORD
count
,
flags
,
length
;
IMFAttributes
*
attributes
;
IMFSample
*
sample
;
...
...
@@ -1998,9 +1998,15 @@ static void test_sample(void)
ok
(
buffer2
==
buffer
,
"Unexpected buffer instance.
\n
"
);
IMFMediaBuffer_Release
(
buffer2
);
hr
=
IMFMediaBuffer_SetCurrentLength
(
buffer
,
3
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
MFCreateMemoryBuffer
(
16
,
&
buffer2
);
ok
(
hr
==
S_OK
,
"Failed to create a buffer, hr %#x.
\n
"
,
hr
);
hr
=
IMFMediaBuffer_SetCurrentLength
(
buffer2
,
4
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
IMFSample_AddBuffer
(
sample
,
buffer2
);
ok
(
hr
==
S_OK
,
"Failed to add buffer, hr %#x.
\n
"
,
hr
);
IMFMediaBuffer_Release
(
buffer2
);
...
...
@@ -2009,15 +2015,22 @@ static void test_sample(void)
ok
(
hr
==
S_OK
,
"Failed to get buffer count, hr %#x.
\n
"
,
hr
);
ok
(
count
==
2
,
"Unexpected buffer count %u.
\n
"
,
count
);
hr
=
IMFSample_ConvertToContiguousBuffer
(
sample
,
&
buffer2
);
todo_wine
hr
=
IMFSample_ConvertToContiguousBuffer
(
sample
,
&
buffer3
);
ok
(
hr
==
S_OK
,
"Failed to convert, hr %#x.
\n
"
,
hr
);
hr
=
IMFMediaBuffer_GetMaxLength
(
buffer3
,
&
length
);
ok
(
hr
==
S_OK
,
"Failed to get maximum length, hr %#x.
\n
"
,
hr
);
ok
(
length
==
7
,
"Unexpected length %u.
\n
"
,
length
);
hr
=
IMFMediaBuffer_GetCurrentLength
(
buffer3
,
&
length
);
ok
(
hr
==
S_OK
,
"Failed to get maximum length, hr %#x.
\n
"
,
hr
);
ok
(
length
==
7
,
"Unexpected length %u.
\n
"
,
length
);
if
(
SUCCEEDED
(
hr
))
IMFMediaBuffer_Release
(
buffer
2
);
IMFMediaBuffer_Release
(
buffer
3
);
hr
=
IMFSample_GetBufferCount
(
sample
,
&
count
);
ok
(
hr
==
S_OK
,
"Failed to get buffer count, hr %#x.
\n
"
,
hr
);
todo_wine
ok
(
count
==
1
,
"Unexpected buffer count %u.
\n
"
,
count
);
IMFMediaBuffer_Release
(
buffer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment