aboutsummaryrefslogtreecommitdiff
path: root/iter.go
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-15 00:06:58 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-15 00:06:58 +0200
commit6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114 (patch)
tree2d4cba21bfe0f23b9ee469bb0cb46bab251857fa /iter.go
parent63391b66a7c5d10e84d4d8c64510e3620152dc26 (diff)
downloadmp4-6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114.tar.gz
mp4-6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114.zip
track: bound malformed sample tables
Diffstat (limited to 'iter.go')
-rw-r--r--iter.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/iter.go b/iter.go
index 4b465d2..f9b47f4 100644
--- a/iter.go
+++ b/iter.go
@@ -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 {