add track.go

This commit is contained in:
nareix 2016-03-18 20:11:54 +08:00
parent 7f98b69834
commit 21888f54d7
2 changed files with 41 additions and 0 deletions

View File

@ -109,6 +109,40 @@ func (self *Track) setSampleIndex(index int) (err error) {
return return
} }
start = 0
found = false
self.ptsEntryIndex = 0
for self.ptsEntryIndex < len(self.sample.TimeToSample.Entries) {
n := self.sample.TimeToSample.Entries[self.ptsEntryIndex].Count
if index >= start && index < start+n {
self.sampleIndexInPtsEntry = index-start
break
}
start += n
self.ptsEntryIndex++
}
if !found {
err = io.EOF
return
}
start = 0
found = false
self.dtsEntryIndex = 0
for self.dtsEntryIndex < len(self.sample.CompositionOffset.Entries) {
n := self.sample.CompositionOffset.Entries[self.dtsEntryIndex].Count
if index >= start && index < start+n {
self.sampleIndexInDtsEntry = index-start
break
}
start += n
self.dtsEntryIndex++
}
if !found {
err = io.EOF
return
}
self.sampleIndex = index self.sampleIndex = index
return return
} }

View File

@ -20,6 +20,13 @@ type Track struct {
sample *atom.SampleTable sample *atom.SampleTable
sampleIndex int sampleIndex int
ptsEntryIndex int
sampleIndexInPtsEntry int
dtsEntryIndex int
sampleIndexInDtsEntry int
chunkGroupIndex int chunkGroupIndex int
chunkIndex int chunkIndex int
sampleIndexInChunk int sampleIndexInChunk int