Detect Speex in Ogg
This commit is contained in:
parent
a2b36a0b30
commit
8197374249
|
@ -247,7 +247,7 @@ startParsingSignature:
|
||||||
addNotifications(notifications);
|
addNotifications(notifications);
|
||||||
break;
|
break;
|
||||||
} case ContainerFormat::Ogg:
|
} case ContainerFormat::Ogg:
|
||||||
// Ogg is handled using OggContainer instance
|
// Ogg is handled by OggContainer instance
|
||||||
m_container = make_unique<OggContainer>(*this, m_containerOffset);
|
m_container = make_unique<OggContainer>(*this, m_containerOffset);
|
||||||
static_cast<OggContainer *>(m_container.get())->setChecksumValidationEnabled(m_forceFullParse);
|
static_cast<OggContainer *>(m_container.get())->setChecksumValidationEnabled(m_forceFullParse);
|
||||||
break;
|
break;
|
||||||
|
@ -713,16 +713,31 @@ const char *MediaFileInfo::containerFormatAbbreviation() const
|
||||||
MediaType mediaType = MediaType::Unknown;
|
MediaType mediaType = MediaType::Unknown;
|
||||||
unsigned int version = 0;
|
unsigned int version = 0;
|
||||||
switch(m_containerFormat) {
|
switch(m_containerFormat) {
|
||||||
case ContainerFormat::Ogg:
|
case ContainerFormat::Ogg: {
|
||||||
// check whether only Opus tracks are present
|
// check for video track or whether only Opus or Speex tracks are present
|
||||||
version = static_cast<unsigned int>(GeneralMediaFormat::Opus);
|
const auto &tracks = static_cast<OggContainer *>(m_container.get())->tracks();
|
||||||
|
if(tracks.empty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bool onlyOpus = true, onlySpeex = true;
|
||||||
for(const auto &track : static_cast<OggContainer *>(m_container.get())->tracks()) {
|
for(const auto &track : static_cast<OggContainer *>(m_container.get())->tracks()) {
|
||||||
|
if(track->mediaType() == MediaType::Video) {
|
||||||
|
mediaType = MediaType::Video;
|
||||||
|
}
|
||||||
if(track->format().general != GeneralMediaFormat::Opus) {
|
if(track->format().general != GeneralMediaFormat::Opus) {
|
||||||
version = 0;
|
onlyOpus = false;
|
||||||
break;
|
}
|
||||||
|
if(track->format().general != GeneralMediaFormat::Speex) {
|
||||||
|
onlySpeex = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ContainerFormat::Matroska:
|
if(onlyOpus) {
|
||||||
|
version = static_cast<unsigned int>(GeneralMediaFormat::Opus);
|
||||||
|
} else if(onlySpeex) {
|
||||||
|
version = static_cast<unsigned int>(GeneralMediaFormat::Speex);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} case ContainerFormat::Matroska:
|
||||||
case ContainerFormat::Mp4:
|
case ContainerFormat::Mp4:
|
||||||
mediaType = hasTracksOfType(MediaType::Video) ? MediaType::Video : MediaType::Audio;
|
mediaType = hasTracksOfType(MediaType::Video) ? MediaType::Video : MediaType::Audio;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -242,6 +242,7 @@ const char *MediaFormat::name() const
|
||||||
default: return "Windows Media Video";
|
default: return "Windows Media Video";
|
||||||
}
|
}
|
||||||
case GeneralMediaFormat::DvbSub: return "DVB subtitles";
|
case GeneralMediaFormat::DvbSub: return "DVB subtitles";
|
||||||
|
case GeneralMediaFormat::Speex: return "Speex";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,6 +413,7 @@ const char *MediaFormat::abbreviation() const
|
||||||
case GeneralMediaFormat::WindowsMediaAudio: return "WMA";
|
case GeneralMediaFormat::WindowsMediaAudio: return "WMA";
|
||||||
case GeneralMediaFormat::WindowsMediaVideo: return "WMV";
|
case GeneralMediaFormat::WindowsMediaVideo: return "WMV";
|
||||||
case GeneralMediaFormat::DvbSub: return "DVBSUB";
|
case GeneralMediaFormat::DvbSub: return "DVBSUB";
|
||||||
|
case GeneralMediaFormat::Speex: return "Speex";
|
||||||
default: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,6 +566,7 @@ const char *MediaFormat::shortAbbreviation() const
|
||||||
case GeneralMediaFormat::WindowsMediaAudio: return "WMA";
|
case GeneralMediaFormat::WindowsMediaAudio: return "WMA";
|
||||||
case GeneralMediaFormat::WindowsMediaVideo: return "WMV";
|
case GeneralMediaFormat::WindowsMediaVideo: return "WMV";
|
||||||
case GeneralMediaFormat::DvbSub: return "DVBSUB";
|
case GeneralMediaFormat::DvbSub: return "DVBSUB";
|
||||||
|
case GeneralMediaFormat::Speex: return "Speex";
|
||||||
default: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ enum class GeneralMediaFormat
|
||||||
WindowsMediaAudio, /**< Windows Media Audio */
|
WindowsMediaAudio, /**< Windows Media Audio */
|
||||||
WindowsMediaVideo, /**< Windows Media Video */
|
WindowsMediaVideo, /**< Windows Media Video */
|
||||||
DvbSub, /**< DVBSUB */
|
DvbSub, /**< DVBSUB */
|
||||||
|
Speex, /**< Speex */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -264,6 +264,20 @@ void OggStream::internalParseHeader()
|
||||||
}
|
}
|
||||||
// TODO: read more information about Theora stream
|
// TODO: read more information about Theora stream
|
||||||
|
|
||||||
|
} else if((sig & 0xFFFFFFFFFFFF0000u) == 0x5370656578200000u) {
|
||||||
|
// Speex header detected
|
||||||
|
switch(m_format.general) {
|
||||||
|
case GeneralMediaFormat::Unknown:
|
||||||
|
m_format = GeneralMediaFormat::Speex;
|
||||||
|
m_mediaType = MediaType::Audio;
|
||||||
|
break;
|
||||||
|
case GeneralMediaFormat::Speex:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
addNotification(NotificationType::Warning, "Stream format is inconsistent.", context);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// TODO: read more information about Speex stream
|
||||||
} else if(sig == 0x595556344D504547u) {
|
} else if(sig == 0x595556344D504547u) {
|
||||||
// YUV4MPEG header detected
|
// YUV4MPEG header detected
|
||||||
switch(m_format.general) {
|
switch(m_format.general) {
|
||||||
|
@ -280,6 +294,7 @@ void OggStream::internalParseHeader()
|
||||||
}
|
}
|
||||||
// TODO: read more information about YUV4MPEG stream
|
// TODO: read more information about YUV4MPEG stream
|
||||||
}
|
}
|
||||||
|
// currently only Vorbis, Opus, Theora, Speex and YUV4MPEG can be detected, TODO: detect more formats
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// just ignore segments of only 8 byte or even less
|
// just ignore segments of only 8 byte or even less
|
||||||
|
|
|
@ -277,6 +277,8 @@ const char *containerFormatAbbreviation(ContainerFormat containerFormat, MediaTy
|
||||||
switch(version) {
|
switch(version) {
|
||||||
case static_cast<unsigned int>(GeneralMediaFormat::Opus):
|
case static_cast<unsigned int>(GeneralMediaFormat::Opus):
|
||||||
return "opus";
|
return "opus";
|
||||||
|
case static_cast<unsigned int>(GeneralMediaFormat::Speex):
|
||||||
|
return "spx";
|
||||||
default:
|
default:
|
||||||
return "ogg";
|
return "ogg";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue