diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-09-15 00:06:58 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-09-15 00:06:58 +0200 |
| commit | 6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114 (patch) | |
| tree | 2d4cba21bfe0f23b9ee469bb0cb46bab251857fa /iter.go | |
| parent | 63391b66a7c5d10e84d4d8c64510e3620152dc26 (diff) | |
| download | mp4-6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114.tar.gz mp4-6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114.zip | |
track: bound malformed sample tables
Diffstat (limited to 'iter.go')
| -rw-r--r-- | iter.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -32,6 +32,19 @@ func NewStszIter(data []byte) StszIter { // Count returns the total number of samples. func (it *StszIter) Count() uint32 { return it.count } +// ConstantSize reports whether the box encodes one size for every sample rather +// than a per-sample size table. +func (it *StszIter) ConstantSize() bool { return it.sampleSize != 0 } + +// SizeTableLen returns the number of per-sample size entries the box stores. It +// is zero for the constant-size form. +func (it *StszIter) SizeTableLen() int { + if it.sampleSize != 0 || len(it.buf) < 8 { + return 0 + } + return (len(it.buf) - 8) / 4 +} + // Next returns the next sample size. Returns (0, false) when done. func (it *StszIter) Next() (uint32, bool) { if it.index >= it.count { |
