WMF: fix reported sample type of 8-bit audio formats.
Always report 8-bit PCM data as unsigned integer. Even though there's no API to actually know that, it's standard on Windows. 8-bit is unsigned and 16-bit is signed. Task-number: QTBUG-45540 Change-Id: I4a3c09084de688ea7afc3bc147508184fb582224 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
@@ -193,17 +193,6 @@ void MFAudioDecoderControl::handleMediaSourceReady()
|
|||||||
if (mediaType) {
|
if (mediaType) {
|
||||||
m_sourceOutputFormat = m_audioFormat;
|
m_sourceOutputFormat = m_audioFormat;
|
||||||
QAudioFormat af = m_audioFormat;
|
QAudioFormat af = m_audioFormat;
|
||||||
GUID subType;
|
|
||||||
if (SUCCEEDED(mediaType->GetGUID(MF_MT_SUBTYPE, &subType))) {
|
|
||||||
if (subType == MFAudioFormat_Float) {
|
|
||||||
m_sourceOutputFormat.setSampleType(QAudioFormat::Float);
|
|
||||||
} else {
|
|
||||||
m_sourceOutputFormat.setSampleType(QAudioFormat::SignedInt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_sourceOutputFormat.sampleType() != QAudioFormat::Float) {
|
|
||||||
m_sourceOutputFormat.setByteOrder(QAudioFormat::LittleEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32 val = 0;
|
UINT32 val = 0;
|
||||||
if (SUCCEEDED(mediaType->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &val))) {
|
if (SUCCEEDED(mediaType->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &val))) {
|
||||||
@@ -216,6 +205,20 @@ void MFAudioDecoderControl::handleMediaSourceReady()
|
|||||||
m_sourceOutputFormat.setSampleSize(int(val));
|
m_sourceOutputFormat.setSampleSize(int(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUID subType;
|
||||||
|
if (SUCCEEDED(mediaType->GetGUID(MF_MT_SUBTYPE, &subType))) {
|
||||||
|
if (subType == MFAudioFormat_Float) {
|
||||||
|
m_sourceOutputFormat.setSampleType(QAudioFormat::Float);
|
||||||
|
} else if (m_sourceOutputFormat.sampleSize() == 8) {
|
||||||
|
m_sourceOutputFormat.setSampleType(QAudioFormat::UnSignedInt);
|
||||||
|
} else {
|
||||||
|
m_sourceOutputFormat.setSampleType(QAudioFormat::SignedInt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_sourceOutputFormat.sampleType() != QAudioFormat::Float) {
|
||||||
|
m_sourceOutputFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_audioFormat.sampleType() != QAudioFormat::Float
|
if (m_audioFormat.sampleType() != QAudioFormat::Float
|
||||||
&& m_audioFormat.sampleType() != QAudioFormat::SignedInt) {
|
&& m_audioFormat.sampleType() != QAudioFormat::SignedInt) {
|
||||||
af.setSampleType(m_sourceOutputFormat.sampleType());
|
af.setSampleType(m_sourceOutputFormat.sampleType());
|
||||||
|
|||||||
@@ -556,7 +556,10 @@ QAudioFormat MFPlayerSession::audioFormatForMFMediaType(IMFMediaType *mediaType)
|
|||||||
format.setSampleSize(wfx->wBitsPerSample);
|
format.setSampleSize(wfx->wBitsPerSample);
|
||||||
format.setCodec("audio/pcm");
|
format.setCodec("audio/pcm");
|
||||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||||
format.setSampleType(QAudioFormat::SignedInt);
|
if (format.sampleSize() == 8)
|
||||||
|
format.setSampleType(QAudioFormat::UnSignedInt);
|
||||||
|
else
|
||||||
|
format.setSampleType(QAudioFormat::SignedInt);
|
||||||
|
|
||||||
CoTaskMemFree(wfx);
|
CoTaskMemFree(wfx);
|
||||||
return format;
|
return format;
|
||||||
|
|||||||
Reference in New Issue
Block a user