Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2017-05-10 11:54:29 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2017-05-10 11:54:29 +0300
commit19c1b2c7c72a6791c87947008da0e38216f63f0c (patch)
treee12943e110911ddf42b0937572f3541e465e61c0
parent79c2b35bb88e161878ee4bd30f60270bb3579233 (diff)
Map mono planar PCM formats to their non-planar type for improved media types
-rw-r--r--demuxer/Demuxers/LAVFAudioHelper.cpp29
-rw-r--r--demuxer/Demuxers/LAVFAudioHelper.h2
-rw-r--r--demuxer/Demuxers/LAVFStreamInfo.cpp2
3 files changed, 27 insertions, 6 deletions
diff --git a/demuxer/Demuxers/LAVFAudioHelper.cpp b/demuxer/Demuxers/LAVFAudioHelper.cpp
index 3aee6612..54c2f1bb 100644
--- a/demuxer/Demuxers/LAVFAudioHelper.cpp
+++ b/demuxer/Demuxers/LAVFAudioHelper.cpp
@@ -84,7 +84,7 @@ static FormatMapping audio_map[] = {
{ AV_CODEC_ID_DSD_MSBF_PLANAR, &MEDIASUBTYPE_DSD8, 0, nullptr },
};
-CMediaType CLAVFAudioHelper::initAudioType(AVCodecID codecId, unsigned int &codecTag, std::string container)
+CMediaType CLAVFAudioHelper::initAudioType(AVCodecParameters *codecpar, unsigned int &codecTag, std::string container)
{
CMediaType mediaType;
mediaType.InitMediaType();
@@ -93,21 +93,42 @@ CMediaType CLAVFAudioHelper::initAudioType(AVCodecID codecId, unsigned int &code
mediaType.formattype = FORMAT_WaveFormatEx; //default value
mediaType.SetSampleSize(256000);
+ // map mono planar pcm formats (if its mono, planar makes no difference)
+ if (codecpar->channels == 1) {
+ switch (codecpar->codec_id) {
+ case AV_CODEC_ID_PCM_S8_PLANAR:
+ codecpar->codec_id = AV_CODEC_ID_PCM_S8;
+ break;
+ case AV_CODEC_ID_PCM_S16BE_PLANAR:
+ codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
+ break;
+ case AV_CODEC_ID_PCM_S16LE_PLANAR:
+ codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+ break;
+ case AV_CODEC_ID_PCM_S24LE_PLANAR:
+ codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
+ break;
+ case AV_CODEC_ID_PCM_S32LE_PLANAR:
+ codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
+ break;
+ }
+ }
+
// Check against values from the map above
for(unsigned i = 0; i < countof(audio_map); ++i) {
- if (audio_map[i].codec == codecId) {
+ if (audio_map[i].codec == codecpar->codec_id) {
if (audio_map[i].subtype)
mediaType.subtype = *audio_map[i].subtype;
if (audio_map[i].codecTag)
codecTag = audio_map[i].codecTag;
if (audio_map[i].format)
- mediaType.formattype = *audio_map[i].format;
+ mediaType.formattype = *audio_map[i].format;
break;
}
}
// special cases
- switch(codecId)
+ switch(codecpar->codec_id)
{
case AV_CODEC_ID_PCM_F64LE:
// Qt PCM
diff --git a/demuxer/Demuxers/LAVFAudioHelper.h b/demuxer/Demuxers/LAVFAudioHelper.h
index 7913d12d..1f649a25 100644
--- a/demuxer/Demuxers/LAVFAudioHelper.h
+++ b/demuxer/Demuxers/LAVFAudioHelper.h
@@ -67,7 +67,7 @@ class CLAVFAudioHelper
{
public:
CLAVFAudioHelper() {};
- CMediaType initAudioType(AVCodecID codecId, unsigned int &codecTag, std::string container);
+ CMediaType initAudioType(AVCodecParameters *codecpar, unsigned int &codecTag, std::string container);
WAVEFORMATEX *CreateWVFMTEX(const AVStream *avstream, ULONG *size);
WAVEFORMATEXFFMPEG *CreateWVFMTEX_FF(const AVStream *avstream, ULONG *size);
diff --git a/demuxer/Demuxers/LAVFStreamInfo.cpp b/demuxer/Demuxers/LAVFStreamInfo.cpp
index 1a5844f0..e6a50c9f 100644
--- a/demuxer/Demuxers/LAVFStreamInfo.cpp
+++ b/demuxer/Demuxers/LAVFStreamInfo.cpp
@@ -69,7 +69,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStr
return E_FAIL;
}
- CMediaType mtype = g_AudioHelper.initAudioType(avstream->codecpar->codec_id, avstream->codecpar->codec_tag, m_containerFormat);
+ CMediaType mtype = g_AudioHelper.initAudioType(avstream->codecpar, avstream->codecpar->codec_tag, m_containerFormat);
if(mtype.formattype == FORMAT_WaveFormatEx) {
// Special Logic for the MPEG1 Audio Formats (MP1, MP2)