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
a634c30f
Commit
a634c30f
authored
Nov 16, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Jan 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mfplat: Support compressed WAVEFORMATEX in MFCreateWaveFormatExFromMFMediaType.
parent
1939bfff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
35 deletions
+23
-35
mediatype.c
dlls/mfplat/mediatype.c
+23
-27
mfplat.c
dlls/mfplat/tests/mfplat.c
+0
-8
No files found.
dlls/mfplat/mediatype.c
View file @
a634c30f
...
...
@@ -2963,10 +2963,10 @@ HRESULT WINAPI MFUnwrapMediaType(IMFMediaType *wrapper, IMFMediaType **ret)
HRESULT
WINAPI
MFCreateWaveFormatExFromMFMediaType
(
IMFMediaType
*
mediatype
,
WAVEFORMATEX
**
ret_format
,
UINT32
*
size
,
UINT32
flags
)
{
WAVEFORMATEXTENSIBLE
*
format_ext
=
NULL
;
UINT32
value
,
extra_size
=
0
,
user_size
;
WAVEFORMATEX
*
format
;
GUID
major
,
subtype
;
UINT32
value
;
void
*
user_data
;
HRESULT
hr
;
TRACE
(
"%p, %p, %p, %#x.
\n
"
,
mediatype
,
ret_format
,
size
,
flags
);
...
...
@@ -2980,36 +2980,24 @@ HRESULT WINAPI MFCreateWaveFormatExFromMFMediaType(IMFMediaType *mediatype, WAVE
if
(
!
IsEqualGUID
(
&
major
,
&
MFMediaType_Audio
))
return
E_INVALIDARG
;
if
(
!
IsEqualGUID
(
&
subtype
,
&
MFAudioFormat_PCM
)
&&
!
IsEqualGUID
(
&
subtype
,
&
MFAudioFormat_Float
))
if
(
FAILED
(
hr
=
IMFMediaType_GetBlobSize
(
mediatype
,
&
MF_MT_USER_DATA
,
&
user_size
)
))
{
FIXME
(
"Unsupported audio format %s.
\n
"
,
debugstr_guid
(
&
subtype
));
return
E_NOTIMPL
;
if
(
!
IsEqualGUID
(
&
subtype
,
&
MFAudioFormat_PCM
)
&&
!
IsEqualGUID
(
&
subtype
,
&
MFAudioFormat_Float
))
return
hr
;
user_size
=
0
;
}
/* FIXME: probably WAVE_FORMAT_MPEG/WAVE_FORMAT_MPEGLAYER3 should be handled separately. */
if
(
flags
==
MFWaveFormatExConvertFlag_ForceExtensible
)
{
format_ext
=
CoTaskMemAlloc
(
sizeof
(
*
format_ext
));
*
size
=
sizeof
(
*
format_ext
);
format
=
(
WAVEFORMATEX
*
)
format_ext
;
}
else
{
format
=
CoTaskMemAlloc
(
sizeof
(
*
format
));
*
size
=
sizeof
(
*
format
);
}
extra_size
=
sizeof
(
WAVEFORMATEXTENSIBLE
)
-
sizeof
(
*
format
);
if
(
!
format
)
*
size
=
sizeof
(
*
format
)
+
user_size
+
extra_size
;
if
(
!
(
format
=
CoTaskMemAlloc
(
*
size
)))
return
E_OUTOFMEMORY
;
memset
(
format
,
0
,
*
size
);
if
(
format_ext
)
format
->
wFormatTag
=
WAVE_FORMAT_EXTENSIBLE
;
else
if
(
IsEqualGUID
(
&
subtype
,
&
MFAudioFormat_Float
))
format
->
wFormatTag
=
WAVE_FORMAT_IEEE_FLOAT
;
else
format
->
wFormatTag
=
WAVE_FORMAT_PCM
;
format
->
wFormatTag
=
subtype
.
Data1
;
format
->
cbSize
=
user_size
+
extra_size
;
user_data
=
format
+
1
;
if
(
SUCCEEDED
(
IMFMediaType_GetUINT32
(
mediatype
,
&
MF_MT_AUDIO_NUM_CHANNELS
,
&
value
)))
format
->
nChannels
=
value
;
...
...
@@ -3021,18 +3009,26 @@ HRESULT WINAPI MFCreateWaveFormatExFromMFMediaType(IMFMediaType *mediatype, WAVE
format
->
nBlockAlign
=
value
;
if
(
SUCCEEDED
(
IMFMediaType_GetUINT32
(
mediatype
,
&
MF_MT_AUDIO_BITS_PER_SAMPLE
,
&
value
)))
format
->
wBitsPerSample
=
value
;
if
(
format_ext
)
if
(
flags
==
MFWaveFormatExConvertFlag_ForceExtensible
)
{
format
->
cbSize
=
sizeof
(
*
format_ext
)
-
sizeof
(
*
format
);
WAVEFORMATEXTENSIBLE
*
format_ext
=
CONTAINING_RECORD
(
format
,
WAVEFORMATEXTENSIBLE
,
Format
);
format_ext
->
Format
.
wFormatTag
=
WAVE_FORMAT_EXTENSIBLE
;
format_ext
->
SubFormat
=
subtype
;
user_data
=
format_ext
+
1
;
if
(
SUCCEEDED
(
IMFMediaType_GetUINT32
(
mediatype
,
&
MF_MT_AUDIO_VALID_BITS_PER_SAMPLE
,
&
value
)))
format_ext
->
Samples
.
wSamplesPerBlock
=
value
;
if
(
SUCCEEDED
(
IMFMediaType_GetUINT32
(
mediatype
,
&
MF_MT_AUDIO_CHANNEL_MASK
,
&
value
)))
format_ext
->
dwChannelMask
=
value
;
memcpy
(
&
format_ext
->
SubFormat
,
&
KSDATAFORMAT_SUBTYPE_PCM
,
sizeof
(
format_ext
->
SubFormat
));
else
if
(
format_ext
->
Format
.
nChannels
<
ARRAY_SIZE
(
default_channel_mask
))
format_ext
->
dwChannelMask
=
default_channel_mask
[
format_ext
->
Format
.
nChannels
];
}
IMFMediaType_GetBlob
(
mediatype
,
&
MF_MT_USER_DATA
,
user_data
,
user_size
,
NULL
);
*
ret_format
=
format
;
return
S_OK
;
...
...
dlls/mfplat/tests/mfplat.c
View file @
a634c30f
...
...
@@ -7082,10 +7082,7 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
ok
(
!
memcmp
(
buff
,
(
WAVEFORMATEX
*
)
&
aacformat
+
1
,
size
),
"Unexpected user data.
\n
"
);
hr
=
MFCreateWaveFormatExFromMFMediaType
(
mediatype
,
(
WAVEFORMATEX
**
)
&
format
,
&
size
,
MFWaveFormatExConvertFlag_ForceExtensible
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
ok
(
format
->
Format
.
wFormatTag
==
WAVE_FORMAT_EXTENSIBLE
,
"got wFormatTag %#x
\n
"
,
format
->
Format
.
wFormatTag
);
ok
(
format
->
Format
.
cbSize
==
aacformat
.
wfInfo
.
wfx
.
cbSize
+
sizeof
(
WAVEFORMATEXTENSIBLE
)
-
sizeof
(
WAVEFORMATEX
),
"got cbSize %u
\n
"
,
format
->
Format
.
cbSize
);
...
...
@@ -7094,17 +7091,13 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
ok
(
format
->
Samples
.
wSamplesPerBlock
==
0
,
"got wSamplesPerBlock %u
\n
"
,
format
->
Samples
.
wSamplesPerBlock
);
ok
(
!
memcmp
(
format
+
1
,
&
aacformat
.
wfInfo
.
wfx
+
1
,
aacformat
.
wfInfo
.
wfx
.
cbSize
),
"Unexpected user data.
\n
"
);
CoTaskMemFree
(
format
);
}
/* test with invalid format size */
aacformat
.
wfInfo
.
wfx
.
cbSize
=
1
;
hr
=
IMFMediaType_SetBlob
(
mediatype
,
&
MF_MT_USER_DATA
,
buff
,
aacformat
.
wfInfo
.
wfx
.
cbSize
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
MFCreateWaveFormatExFromMFMediaType
(
mediatype
,
(
WAVEFORMATEX
**
)
&
format
,
&
size
,
MFWaveFormatExConvertFlag_ForceExtensible
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
ok
(
format
->
Format
.
wFormatTag
==
WAVE_FORMAT_EXTENSIBLE
,
"got wFormatTag %#x
\n
"
,
format
->
Format
.
wFormatTag
);
ok
(
format
->
Format
.
cbSize
==
aacformat
.
wfInfo
.
wfx
.
cbSize
+
sizeof
(
WAVEFORMATEXTENSIBLE
)
-
sizeof
(
WAVEFORMATEX
),
"got cbSize %u
\n
"
,
format
->
Format
.
cbSize
);
...
...
@@ -7113,7 +7106,6 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
ok
(
format
->
Samples
.
wSamplesPerBlock
==
0
,
"got wSamplesPerBlock %u
\n
"
,
format
->
Samples
.
wSamplesPerBlock
);
ok
(
!
memcmp
(
format
+
1
,
&
aacformat
.
wfInfo
.
wfx
+
1
,
aacformat
.
wfInfo
.
wfx
.
cbSize
),
"Unexpected user data.
\n
"
);
CoTaskMemFree
(
format
);
}
IMFMediaType_Release
(
mediatype
);
}
...
...
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