Partial eac3 passthru.
This commit is contained in:
1 parent
3784e788d8
commit
bda8ac4b37
6 files changed
+126
-6
No files matched your search
@@ -539,7 +539,8 @@ OSStatus DecoderDataProc(AudioConverterRef inAudioConverter,
|
|||||||
inputFormat.mFramesPerPacket = 1536;
|
inputFormat.mFramesPerPacket = 1536;
|
||||||
}
|
}
|
||||||
else if ([track.sourceFormat isEqualToString:MP42AudioFormatEAC3]) {
|
else if ([track.sourceFormat isEqualToString:MP42AudioFormatEAC3]) {
|
||||||
// TODO
|
inputFormat.mFormatID = kAudioFormatEnhancedAC3;
|
||||||
|
inputFormat.mFramesPerPacket = 1536;
|
||||||
}
|
}
|
||||||
else if ([track.sourceFormat isEqualToString:MP42AudioFormatDTS]) {
|
else if ([track.sourceFormat isEqualToString:MP42AudioFormatDTS]) {
|
||||||
inputFormat.mFormatID = 'DTS ';
|
inputFormat.mFormatID = 'DTS ';
|
||||||
|
|||||||
@@ -69,8 +69,12 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
|
|||||||
|
|
||||||
readAC3Config(acmod, lfeon, &_channels, &_channelLayoutTag);
|
readAC3Config(acmod, lfeon, &_channels, &_channelLayoutTag);
|
||||||
}
|
}
|
||||||
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.ac-3.dec3")) {
|
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.ec-3.dec3")) {
|
||||||
// TODO
|
uint8_t *ppValue;
|
||||||
|
uint32_t pValueSize;
|
||||||
|
MP4GetTrackBytesProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.ec-3.dec3.content", &ppValue, &pValueSize);
|
||||||
|
|
||||||
|
readEAC3Config(ppValue, pValueSize, &_channels, &_channelLayoutTag);
|
||||||
}
|
}
|
||||||
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.alac")) {
|
else if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.alac")) {
|
||||||
uint64_t channels_count = 0;
|
uint64_t channels_count = 0;
|
||||||
|
|||||||
+10
-2
@@ -106,10 +106,18 @@
|
|||||||
return [ac3Info autorelease];
|
return [ac3Info autorelease];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(media_data_name, "ec-3")) {
|
||||||
|
if (MP4HaveTrackAtom(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.ec-3.dec3")) {
|
||||||
|
uint8_t *ppValue;
|
||||||
|
uint32_t pValueSize;
|
||||||
|
MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.ec-3.dec3.content", &ppValue, &pValueSize);
|
||||||
|
magicCookie = [NSData dataWithBytes:ppValue length:pValueSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (!strcmp(media_data_name, "alac")) {
|
else if (!strcmp(media_data_name, "alac")) {
|
||||||
if (MP4HaveTrackAtom(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.alac.alac")) {
|
if (MP4HaveTrackAtom(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.alac.alac")) {
|
||||||
uint8_t* ppValue;
|
uint8_t *ppValue;
|
||||||
uint32_t pValueSize;
|
uint32_t pValueSize;
|
||||||
MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.alac.alac.AppleLosslessMagicCookie", &ppValue, &pValueSize);
|
MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.alac.alac.AppleLosslessMagicCookie", &ppValue, &pValueSize);
|
||||||
magicCookie = [NSData dataWithBytes:ppValue length:pValueSize];
|
magicCookie = [NSData dataWithBytes:ppValue length:pValueSize];
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -214,7 +214,7 @@
|
|||||||
if ([magicCookie length] < sizeof(uint64_t) * 6)
|
if ([magicCookie length] < sizeof(uint64_t) * 6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const uint64_t * ac3Info = (const uint64_t *)[magicCookie bytes];
|
const uint64_t *ac3Info = (const uint64_t *)[magicCookie bytes];
|
||||||
|
|
||||||
dstTrackId = MP4AddAC3AudioTrack(_fileHandle,
|
dstTrackId = MP4AddAC3AudioTrack(_fileHandle,
|
||||||
timeScale,
|
timeScale,
|
||||||
@@ -230,7 +230,9 @@
|
|||||||
|
|
||||||
// EAC-3 audio tack
|
// EAC-3 audio tack
|
||||||
else if ([track isMemberOfClass:[MP42AudioTrack class]] && [track.format isEqualToString:MP42AudioFormatEAC3]) {
|
else if ([track isMemberOfClass:[MP42AudioTrack class]] && [track.format isEqualToString:MP42AudioFormatEAC3]) {
|
||||||
|
dstTrackId = MP4AddEAC3AudioTrack(_fileHandle, timeScale, magicCookie.bytes, magicCookie.length);
|
||||||
|
|
||||||
|
[helper->importer setActiveTrack:track];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ALAC audio track
|
// ALAC audio track
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ CFDataRef createDescExt_XiphVorbis(UInt32 codecPrivateSize, const void * codecPr
|
|||||||
CFDataRef createDescExt_XiphFLAC(UInt32 codecPrivateSize, const void * codecPrivate);
|
CFDataRef createDescExt_XiphFLAC(UInt32 codecPrivateSize, const void * codecPrivate);
|
||||||
|
|
||||||
int readAC3Config(uint64_t acmod, uint64_t lfeon, UInt32 *channelsCount, UInt32 *channelLayoutTag);
|
int readAC3Config(uint64_t acmod, uint64_t lfeon, UInt32 *channelsCount, UInt32 *channelLayoutTag);
|
||||||
|
int readEAC3Config(const uint8_t *cookie, uint32_t cookieLen, UInt32 *channelsCount, UInt32 *channelLayoutTag);
|
||||||
|
|
||||||
int64_t getTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id);
|
int64_t getTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id);
|
||||||
void setTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id, int64_t offset);
|
void setTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id, int64_t offset);
|
||||||
|
|||||||
@@ -657,6 +657,110 @@ int readAC3Config(uint64_t acmod, uint64_t lfeon, UInt32 *channelsCount, UInt32
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const int eac3_layout_no_lfe[8] = {
|
||||||
|
kAudioChannelLayoutTag_Stereo,
|
||||||
|
kAudioChannelLayoutTag_Mono,
|
||||||
|
kAudioChannelLayoutTag_Stereo,
|
||||||
|
kAudioChannelLayoutTag_AC3_3_0,
|
||||||
|
kAudioChannelLayoutTag_DVD_2,
|
||||||
|
kAudioChannelLayoutTag_AC3_3_1,
|
||||||
|
kAudioChannelLayoutTag_DVD_3,
|
||||||
|
kAudioChannelLayoutTag_MPEG_5_0_C};
|
||||||
|
|
||||||
|
static const int eac3_layout_lfe[8] = {
|
||||||
|
kAudioChannelLayoutTag_DVD_4,
|
||||||
|
kAudioChannelLayoutTag_AC3_1_0_1,
|
||||||
|
kAudioChannelLayoutTag_DVD_4,
|
||||||
|
kAudioChannelLayoutTag_AC3_3_0_1,
|
||||||
|
kAudioChannelLayoutTag_AC3_2_1_1,
|
||||||
|
kAudioChannelLayoutTag_AC3_3_1_1,
|
||||||
|
kAudioChannelLayoutTag_DVD_18,
|
||||||
|
kAudioChannelLayoutTag_MPEG_5_1_C,
|
||||||
|
};
|
||||||
|
|
||||||
|
int readEAC3Config(const uint8_t *cookie, uint32_t cookieLen, UInt32 *channelsCount, UInt32 *channelLayoutTag)
|
||||||
|
{
|
||||||
|
if (cookieLen < 5) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t data_rate, num_ind_sub;
|
||||||
|
|
||||||
|
data_rate = *cookie << 5;
|
||||||
|
data_rate += (*(cookie + 1) & 0xf8) >> 3;
|
||||||
|
|
||||||
|
num_ind_sub = *(cookie + 1) & 0x7;
|
||||||
|
num_ind_sub += 1;
|
||||||
|
|
||||||
|
// we support only one independent substream
|
||||||
|
for (int i = 0; i < 1; i++)
|
||||||
|
{
|
||||||
|
uint32_t fscod, bsid, asvc, bsmod, acmod, lfeon;
|
||||||
|
|
||||||
|
fscod = (*(cookie + 2) & 0xc0) >> 6;
|
||||||
|
bsid = (*(cookie + 2) & 0x3e) >> 1;
|
||||||
|
|
||||||
|
asvc = (*(cookie + 3) & 0x80) >> 7;
|
||||||
|
|
||||||
|
bsmod = (*(cookie + 3) & 0x70) >> 4;
|
||||||
|
acmod = (*(cookie + 3) & 0xe) >> 1;
|
||||||
|
|
||||||
|
lfeon = *(cookie + 3) & 0x1;
|
||||||
|
|
||||||
|
uint32_t num_dep_sub = 0;
|
||||||
|
uint32_t chan_loc = 0;
|
||||||
|
num_dep_sub = (*(cookie + 4) & 0x1e) >> 1;
|
||||||
|
|
||||||
|
if (num_dep_sub > 0 && cookieLen > 5) {
|
||||||
|
chan_loc = (*(cookie + 4) & 0x1) << 8;
|
||||||
|
chan_loc += *(cookie + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (acmod == 7 && lfeon && chan_loc != 0) {
|
||||||
|
// TODO: complete the list
|
||||||
|
if (chan_loc & 0x1) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_7_1_B;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x2) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_7_1_A;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x3) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_6_1_A;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x4) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_6_1_B;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x5) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_7_1_C;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x6) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_7_1_D;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x7) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_7_1_E;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x8) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_6_1_C;
|
||||||
|
}
|
||||||
|
else if (chan_loc & 0x9) {
|
||||||
|
*channelLayoutTag = kAudioChannelLayoutTag_EAC3_7_1_A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (lfeon) {
|
||||||
|
*channelLayoutTag = eac3_layout_lfe[acmod];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*channelLayoutTag = eac3_layout_no_lfe[acmod];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*channelsCount = AudioChannelLayoutTag_GetNumberOfChannels(*channelLayoutTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t getTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id)
|
int64_t getTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id)
|
||||||
{
|
{
|
||||||
int64_t offset = 0;
|
int64_t offset = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user