Partial support for reading pcm in mp4.

This commit is contained in:
Damiano Galassi committed 2017-11-07 17:51:32 +01:00
1 parent 1ea6607415
commit 4622fdc3a8
3 files changed
+30 -2

No files matched your search

+1
View File
@@ -90,6 +90,7 @@
uint64_t channels_count = 0;
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.twos.channels", &channels_count);
_channels = channels_count;
_channelLayoutTag = getDefaultChannelLayout(channels_count);
}
if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall")) {
+27 -2
View File
@@ -10,7 +10,6 @@
#import "MP42FileImporter+Private.h"
#import "MP42File.h"
#import "MP42Languages.h"
#import "MP42Sample.h"
#import "mp4v2.h"
@@ -119,7 +118,7 @@ typedef struct MP4DemuxHelper {
free(ppValue);
}
}
else {
else if (!strcmp(media_data_name, "mp4a")) {
uint8_t *ppConfig; uint32_t pConfigSize;
MP4GetTrackESConfiguration(_fileHandle, srcTrackId, &ppConfig, &pConfigSize);
magicCookie = [NSData dataWithBytes:ppConfig length:pConfigSize];
@@ -261,6 +260,32 @@ typedef struct MP4DemuxHelper {
return nil;
}
- (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42AudioTrack *)track
{
AudioStreamBasicDescription result;
bzero(&result, sizeof(AudioStreamBasicDescription));
MP42TrackId trackID = track.sourceId;
if (MP4HaveTrackAtom(_fileHandle, trackID, "mdia.minf.stbl.stsd.twos")) {
uint64_t channels_count = 0;
uint64_t sample_rate = 0;
uint64_t bit_depth = 0;
MP4GetTrackIntegerProperty(_fileHandle, trackID, "mdia.minf.stbl.stsd.twos.channels", &channels_count);
MP4GetTrackIntegerProperty(_fileHandle, trackID, "mdia.minf.stbl.stsd.twos.timeScale", &sample_rate);
MP4GetTrackIntegerProperty(_fileHandle, trackID, "mdia.minf.stbl.stsd.twos.sampleSize", &bit_depth);
result.mSampleRate = (sample_rate >> 16) + (sample_rate & 0xffff) / 65536.0;
result.mFormatID = kAudioFormatLinearPCM;
result.mFormatFlags += kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian;
result.mBitsPerChannel = bit_depth;
result.mChannelsPerFrame = channels_count;
}
return result;
}
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track;
{
return MP4HaveTrackAtom(_fileHandle, track.sourceId, "mdia.minf.stbl.sgpd");
+2
View File
@@ -228,6 +228,8 @@ FourCharCode getTrackMediaSubType(MP4FileHandle fileHandle, MP4TrackId Id)
return kMP42AudioCodecType_AC3;
else if (!strcmp(dataName, "ec-3"))
return kMP42AudioCodecType_EnhancedAC3;
else if (!strcmp(dataName, "twos"))
return kMP42AudioCodecType_LinearPCM;
else if (!strcmp(dataName, "mp4v"))
return kMP42VideoCodecType_MPEG4Video;
else if (!strcmp(dataName, "text"))