Add support for up to 64 tracks when reading from mkv.
This commit is contained in:
1 parent
a31c8377e4
commit
598bb185c9
3 files changed
+17
-16
No files matched your search
@@ -478,8 +478,8 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
uint32_t Track, FrameSize, FrameFlags;
|
uint32_t Track, FrameSize, FrameFlags;
|
||||||
|
|
||||||
// mask other tracks because we don't need them
|
// mask other tracks because we don't need them
|
||||||
unsigned int TrackMask = ~0;
|
unsigned long TrackMask = ~0;
|
||||||
TrackMask &= ~(1 << Id);
|
TrackMask &= ~(1l << Id);
|
||||||
|
|
||||||
mkv_SetTrackMask(_matroskaFile, TrackMask);
|
mkv_SetTrackMask(_matroskaFile, TrackMask);
|
||||||
mkv_ReadFrame(_matroskaFile, 0, &Track, &StartTime, &EndTime, &FilePos, &FrameSize, &FrameFlags);
|
mkv_ReadFrame(_matroskaFile, 0, &Track, &StartTime, &EndTime, &FilePos, &FrameSize, &FrameFlags);
|
||||||
@@ -526,7 +526,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
return [magicCookie autorelease];
|
return [magicCookie autorelease];
|
||||||
}
|
}
|
||||||
else if (!strcmp(trackInfo->CodecID, "A_AC3") || !strcmp(trackInfo->CodecID, "A_EAC3")) {
|
else if (!strcmp(trackInfo->CodecID, "A_AC3") || !strcmp(trackInfo->CodecID, "A_EAC3")) {
|
||||||
mkv_SetTrackMask(_matroskaFile, ~(1 << track.sourceId));
|
mkv_SetTrackMask(_matroskaFile, ~(1l << track.sourceId));
|
||||||
|
|
||||||
uint64_t StartTime, EndTime, FilePos;
|
uint64_t StartTime, EndTime, FilePos;
|
||||||
uint32_t rt, FrameSize, FrameFlags;
|
uint32_t rt, FrameSize, FrameFlags;
|
||||||
@@ -643,12 +643,12 @@ static NSString * TrackNameToString(TrackInfo *track)
|
|||||||
const unsigned int bufferSize = 20;
|
const unsigned int bufferSize = 20;
|
||||||
|
|
||||||
/* mask other tracks because we don't need them */
|
/* mask other tracks because we don't need them */
|
||||||
unsigned int TrackMask = ~0;
|
unsigned long TrackMask = ~0;
|
||||||
|
|
||||||
NSArray<MP42Track *> *inputTracks = self.inputTracks;
|
NSArray<MP42Track *> *inputTracks = self.inputTracks;
|
||||||
|
|
||||||
for (MP42Track *track in inputTracks) {
|
for (MP42Track *track in inputTracks) {
|
||||||
TrackMask &= ~(1 << [track sourceId]);
|
TrackMask &= ~(1l << track.sourceId);
|
||||||
track.muxer_helper->demuxer_context = [[MatroskaDemuxHelper alloc] init];
|
track.muxer_helper->demuxer_context = [[MatroskaDemuxHelper alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-10
@@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
#define MAX_STRING_LEN 1023
|
#define MAX_STRING_LEN 1023
|
||||||
#define QSEGSIZE 512
|
#define QSEGSIZE 512
|
||||||
#define MAX_TRACKS 32
|
#define MAX_TRACKS 64
|
||||||
#define MAX_READAHEAD (256*1024)
|
#define MAX_READAHEAD (256*1024)
|
||||||
|
|
||||||
#define MAXCLUSTER (64*1048576)
|
#define MAXCLUSTER (64*1048576)
|
||||||
@@ -201,7 +201,7 @@ struct MatroskaFile {
|
|||||||
struct QueueEntry **QBlocks;
|
struct QueueEntry **QBlocks;
|
||||||
struct Queue *Queues;
|
struct Queue *Queues;
|
||||||
ulonglong readPosition;
|
ulonglong readPosition;
|
||||||
unsigned int trackMask;
|
unsigned long trackMask;
|
||||||
ulonglong pSegmentTop; // offset of next byte after the segment
|
ulonglong pSegmentTop; // offset of next byte after the segment
|
||||||
ulonglong tcCluster; // current cluster timecode
|
ulonglong tcCluster; // current cluster timecode
|
||||||
|
|
||||||
@@ -2174,7 +2174,7 @@ blockex:
|
|||||||
|
|
||||||
for (tracknum=0;tracknum<mf->nTracks;++tracknum)
|
for (tracknum=0;tracknum<mf->nTracks;++tracknum)
|
||||||
if (mf->Tracks[tracknum]->Number == trackid) {
|
if (mf->Tracks[tracknum]->Number == trackid) {
|
||||||
if (mf->trackMask & (1<<tracknum)) // ignore this block
|
if (mf->trackMask & (1l<<tracknum)) // ignore this block
|
||||||
break;
|
break;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -2673,7 +2673,7 @@ ok:
|
|||||||
mf->readPosition = mf->Cues[mf->nCues - 1].Position + mf->pSegment;
|
mf->readPosition = mf->Cues[mf->nCues - 1].Position + mf->pSegment;
|
||||||
mf->tcCluster = mf->Cues[mf->nCues - 1].Time / mf->Seg.TimecodeScale;
|
mf->tcCluster = mf->Cues[mf->nCues - 1].Time / mf->Seg.TimecodeScale;
|
||||||
}
|
}
|
||||||
mf->trackMask = ~(1 << vtrack);
|
mf->trackMask = ~(1l << vtrack);
|
||||||
|
|
||||||
do
|
do
|
||||||
while (mf->Queues[vtrack].head)
|
while (mf->Queues[vtrack].head)
|
||||||
@@ -3020,7 +3020,7 @@ void mkv_Seek(MatroskaFile *mf,ulonglong timecode,unsigned flags) {
|
|||||||
found:
|
found:
|
||||||
|
|
||||||
for (n=0;n<mf->nTracks;++n)
|
for (n=0;n<mf->nTracks;++n)
|
||||||
if (!(mf->trackMask & (1<<n)) && m_kftime[n]==MAXU64 &&
|
if (!(mf->trackMask & (1l<<n)) && m_kftime[n]==MAXU64 &&
|
||||||
m_seendf[n] && j>0)
|
m_seendf[n] && j>0)
|
||||||
{
|
{
|
||||||
// we need to restart the search from prev cue
|
// we need to restart the search from prev cue
|
||||||
@@ -3137,9 +3137,9 @@ int mkv_TruncFloat(MKFLOAT f) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FTRACK 0xffffffff
|
#define FTRACK 0xFFFFFFFFFFFFFFFF
|
||||||
|
|
||||||
void mkv_SetTrackMask(MatroskaFile *mf,unsigned int mask) {
|
void mkv_SetTrackMask(MatroskaFile *mf,unsigned long mask) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (mf->flags & MPF_ERROR)
|
if (mf->flags & MPF_ERROR)
|
||||||
@@ -3148,7 +3148,7 @@ void mkv_SetTrackMask(MatroskaFile *mf,unsigned int mask) {
|
|||||||
mf->trackMask = mask;
|
mf->trackMask = mask;
|
||||||
|
|
||||||
for (i=0;i<mf->nTracks;++i)
|
for (i=0;i<mf->nTracks;++i)
|
||||||
if (mask & (1<<i))
|
if (mask & (1l<<i))
|
||||||
ClearQueue(mf,&mf->Queues[i]);
|
ClearQueue(mf,&mf->Queues[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3158,7 +3158,8 @@ int mkv_ReadFrame(MatroskaFile *mf,
|
|||||||
ulonglong *FilePos,unsigned int *FrameSize,
|
ulonglong *FilePos,unsigned int *FrameSize,
|
||||||
unsigned int *FrameFlags)
|
unsigned int *FrameFlags)
|
||||||
{
|
{
|
||||||
unsigned int i,j;
|
unsigned int i;
|
||||||
|
unsigned long j;
|
||||||
struct QueueEntry *qe;
|
struct QueueEntry *qe;
|
||||||
|
|
||||||
if (setjmp(mf->jb)!=0)
|
if (setjmp(mf->jb)!=0)
|
||||||
@@ -3167,7 +3168,7 @@ int mkv_ReadFrame(MatroskaFile *mf,
|
|||||||
do {
|
do {
|
||||||
// extract required frame, use block with the lowest timecode
|
// extract required frame, use block with the lowest timecode
|
||||||
for (j=FTRACK,i=0;i<mf->nTracks;++i)
|
for (j=FTRACK,i=0;i<mf->nTracks;++i)
|
||||||
if (!(mask & (1<<i)) && mf->Queues[i].head) {
|
if (!(mask & (1l<<i)) && mf->Queues[i].head) {
|
||||||
j = i;
|
j = i;
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ X int mkv_TruncFloat(MKFLOAT f);
|
|||||||
* will be ignored when reading file data.
|
* will be ignored when reading file data.
|
||||||
* This call discards all parsed and queued frames
|
* This call discards all parsed and queued frames
|
||||||
*/
|
*/
|
||||||
X void mkv_SetTrackMask(/* in */ MatroskaFile *mf,/* in */ unsigned int mask);
|
X void mkv_SetTrackMask(/* in */ MatroskaFile *mf,/* in */ unsigned long mask);
|
||||||
|
|
||||||
/* Read one frame from the queue.
|
/* Read one frame from the queue.
|
||||||
* mask specifies what tracks to ignore.
|
* mask specifies what tracks to ignore.
|
||||||
|
|||||||
Reference in new issue
Block a user