changed handling of SBR/PS AAC extension

This commit is contained in:
Martchus 2015-09-24 00:19:04 +02:00
parent bb0f7519f6
commit faa40944bf
5 changed files with 41 additions and 21 deletions

View File

@ -138,7 +138,7 @@ MediaFormat MatroskaTrack::codecIdToMediaFormat(const string &codecId)
} else if(part3 == "LC") {
fmt.sub = SubFormats::AacMpeg2LowComplexityProfile;
} else if(part3 == "SBR") {
fmt.sub = SubFormats::AacMpeg2SpectralBandReplicationProfile;
fmt.sub = SubFormats::AacMpeg2LowComplexityProfile;
fmt.extension = ExtensionFormats::SpectralBandReplication;
} else if(part3 == "SSR") {
fmt.sub = SubFormats::AacMpeg2ScalableSamplingRateProfile;
@ -149,7 +149,8 @@ MediaFormat MatroskaTrack::codecIdToMediaFormat(const string &codecId)
} else if(part3 == "LC") {
fmt.sub = SubFormats::AacMpeg4LowComplexityProfile;
} else if(part3 == "SBR") {
fmt.sub = SubFormats::AacMpeg4SpectralBandReplicationProfile;
fmt.sub = SubFormats::AacMpeg4LowComplexityProfile;
fmt.extension = ExtensionFormats::SpectralBandReplication;
} else if(part3 == "SSR") {
fmt.sub = SubFormats::AacMpeg4ScalableSamplingRateProfile;
} else if(part3 == "LTP") {

View File

@ -21,11 +21,9 @@ const char *MediaFormat::name() const
switch(sub) {
case AacMpeg2MainProfile: return "Advanced Audio Coding Main Profile";
case AacMpeg2LowComplexityProfile: return "Advanced Audio Coding Low Complexity Profile";
case AacMpeg2SpectralBandReplicationProfile: return "Advanced Audio Coding Low Complexity with Spectral Band Replication Profile";
case AacMpeg2ScalableSamplingRateProfile: return "Advanced Audio Coding Scalable Sampling Rate Profile";
case AacMpeg4MainProfile: return "Advanced Audio Coding Main Profile";
case AacMpeg4LowComplexityProfile: return "Advanced Audio Coding Low Complexity Profile";
case AacMpeg4SpectralBandReplicationProfile: return "Advanced Audio Coding Low Complexity with Spectral Band Replication Profile";
case AacMpeg4ScalableSamplingRateProfile: return "Advanced Audio Coding Scaleable Sampling Rate Profile";
case AacMpeg4LongTermPrediction: return "Advanced Audio Coding Long Term Predicition";
case AacMpeg4ERLowComplecityProfile: return "Advanced Audio Coding Error Resilient Low Complexity Profile";
@ -238,11 +236,9 @@ const char *MediaFormat::abbreviation() const
switch(sub) {
case AacMpeg2MainProfile: return "MPEG-2 AAC Main";
case AacMpeg2LowComplexityProfile: return "MPEG-2 AAC-LC";
case AacMpeg2SpectralBandReplicationProfile: return "MPEG-2-SBR";
case AacMpeg2ScalableSamplingRateProfile: return "MPEG-2 AAC-SSR";
case AacMpeg4MainProfile: return "MPEG-4 AAC Main";
case AacMpeg4LowComplexityProfile: return "MPEG-4 AAC-LC";
case AacMpeg4SpectralBandReplicationProfile: return "MPEG-4 HE-AAC";
case AacMpeg4ScalableSamplingRateProfile: return "MPEG-4 AAC-SSR";
case AacMpeg4LongTermPrediction: return "MPEG-4 AAC-LTP";
case AacMpeg4ERLowComplecityProfile: return "MPEG-4 ER AAC-LC";
@ -387,4 +383,31 @@ const char *MediaFormat::abbreviation() const
}
}
/*!
* \brief Returns the abbreviation of the media format as C-style string.
*
* Returns an empty string if no abbreviation is available.
*/
const char *MediaFormat::extensionName() const
{
switch(general) {
using namespace ExtensionFormats;
case GeneralMediaFormat::Aac:
switch(extension) {
case SpectralBandReplication:
return "Spectral Band Replication / HE-AAC";
case ParametricStereo:
return "Parametric Stereo / HE-AAC v2"; // PS never comes alone?
case (SpectralBandReplication | ParametricStereo):
return "Spectral Band Replication and Parametric Stereo / HE-AAC v2";
default:
;
}
break;
default:
;
}
return "";
}
}

View File

@ -108,11 +108,9 @@ enum Mpeg1AudioLayer : unsigned char {
enum AacProfile : unsigned char {
AacMpeg2MainProfile = 1,
AacMpeg2LowComplexityProfile,
AacMpeg2SpectralBandReplicationProfile,
AacMpeg2ScalableSamplingRateProfile,
AacMpeg4MainProfile,
AacMpeg4LowComplexityProfile,
AacMpeg4SpectralBandReplicationProfile,
AacMpeg4ScalableSamplingRateProfile,
AacMpeg4LongTermPrediction,
AacMpeg4ERLowComplecityProfile,
@ -248,6 +246,7 @@ public:
const char *name() const;
const char *abbreviation() const;
const char *extensionName() const;
operator bool() const;
MediaFormat &operator+=(const MediaFormat &other);

View File

@ -236,7 +236,7 @@ LIB_EXPORT MediaFormat idToMediaFormat(byte mpeg4AudioObjectId, bool sbrPresent,
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4MainProfile);
break;
case AacLc:
fmt = MediaFormat(GeneralMediaFormat::Aac, sbrPresent ? SubFormats::AacMpeg4SpectralBandReplicationProfile : SubFormats::AacMpeg4LowComplexityProfile);
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LowComplexityProfile);
break;
case AacSsr:
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4ScalableSamplingRateProfile);
@ -244,6 +244,9 @@ LIB_EXPORT MediaFormat idToMediaFormat(byte mpeg4AudioObjectId, bool sbrPresent,
case AacLtp:
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LongTermPrediction);
break;
case Sbr:
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LowComplexityProfile, ExtensionFormats::SpectralBandReplication);
break;
case AacScalable:
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4ScalableSamplingRateProfile);
break;
@ -256,6 +259,9 @@ LIB_EXPORT MediaFormat idToMediaFormat(byte mpeg4AudioObjectId, bool sbrPresent,
case ErAacLd:
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4ERLowDelay);
break;
case Ps:
fmt = MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LowComplexityProfile, ExtensionFormats::ParametricStereo);
break;
case Layer1:
fmt = MediaFormat(GeneralMediaFormat::Mpeg1Audio, SubFormats::Mpeg1Layer1);
break;

View File

@ -26,15 +26,6 @@ namespace Media {
DateTime startDate = DateTime::fromDate(1904, 1, 1);
MediaFormat fmtTable[] = {
GeneralMediaFormat::Unknown,
MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4MainProfile),
MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LowComplexityProfile),
MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4ScalableSamplingRateProfile),
MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LongTermPrediction),
MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4SpectralBandReplicationProfile)
};
Mpeg4AudioSpecificConfig::Mpeg4AudioSpecificConfig() :
audioObjectType(0),
sampleFrequencyIndex(0xF),
@ -610,7 +601,7 @@ unique_ptr<Mpeg4AudioSpecificConfig> Mp4Track::parseAudioSpecificConfig(StatusPr
switch(audioCfg->audioObjectType) {
case Sbr:
case Ps:
audioCfg->extensionAudioObjectType = Sbr;
audioCfg->extensionAudioObjectType = audioCfg->audioObjectType;
audioCfg->sbrPresent = true;
if((audioCfg->extensionSampleFrequencyIndex = bitReader.readBits<byte>(4)) == 0xF) {
audioCfg->extensionSampleFrequency = bitReader.readBits<uint32>(24);
@ -620,7 +611,7 @@ unique_ptr<Mpeg4AudioSpecificConfig> Mp4Track::parseAudioSpecificConfig(StatusPr
}
break;
}
switch(audioCfg->audioObjectType) {
switch(audioCfg->extensionAudioObjectType) {
case Ps:
audioCfg->psPresent = true;
break;
@ -681,7 +672,7 @@ unique_ptr<Mpeg4AudioSpecificConfig> Mp4Track::parseAudioSpecificConfig(StatusPr
}
break;
}
if(audioCfg->extensionAudioObjectType != 5 && bitReader.bitsAvailable() >= 16) {
if(audioCfg->extensionAudioObjectType != Sbr && audioCfg->extensionAudioObjectType != Ps && bitReader.bitsAvailable() >= 16) {
uint16 syncExtensionType = bitReader.readBits<uint16>(11);
if(syncExtensionType == 0x2B7) {
if((audioCfg->extensionAudioObjectType = getAudioObjectType()) == Sbr) {