From 14777566792bfd0c3d1facaf6e13632accca4b3a Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Mon, 16 Feb 2026 11:52:43 +0100 Subject: Minor cleanup --- README.md | 4 ++-- descriptor.go | 7 +++++++ iter.go | 7 ------- reader.go | 5 +++-- writer.go | 5 +++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 798c238..a3223df 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# bmff +# mp4 -Go implementation of ISO Base Media File Format (ISO/IEC 14496-12) box codec and accompanying tools. +Go implementation of ISO Base Media File Format (ISO/IEC 14496-12) box codec. diff --git a/descriptor.go b/descriptor.go index 746bec1..3c79a93 100644 --- a/descriptor.go +++ b/descriptor.go @@ -108,3 +108,10 @@ func skipDescriptorLength(data []byte, ptr, end int) int { } return -1 } + +const hexChars = "0123456789abcdef" + +// hexDigit returns the lowercase hex character for a 4-bit nibble. +func hexDigit(b byte) byte { + return hexChars[b&0x0f] +} diff --git a/iter.go b/iter.go index 2ec0e1f..4b465d2 100644 --- a/iter.go +++ b/iter.go @@ -539,10 +539,3 @@ func ReadAvcC(data []byte) string { buf[5] = hexDigit(data[3] & 0x0f) return string(buf[:]) } - -const hexChars = "0123456789abcdef" - -// hexDigit returns the lowercase hex character for a 4-bit nibble. -func hexDigit(b byte) byte { - return hexChars[b&0x0f] -} diff --git a/reader.go b/reader.go index c197882..3a96a04 100644 --- a/reader.go +++ b/reader.go @@ -289,11 +289,12 @@ func (r *Reader) ReadHdlr() [4]byte { // ReadHdlrName extracts the handler name from an hdlr box. func (r *Reader) ReadHdlrName() string { data := r.Data() - if len(data) <= 20 { + n := len(data) + if n <= 20 { return "" } end := 20 - for end < len(data) && data[end] != 0 { + for end < n && data[end] != 0 { end++ } return string(data[20:end]) diff --git a/writer.go b/writer.go index 3bb111d..e741d51 100644 --- a/writer.go +++ b/writer.go @@ -52,8 +52,9 @@ func (w *Writer) Err() error { return w.err } // Write appends raw bytes. Implements io.Writer. func (w *Writer) Write(p []byte) (int, error) { copy(w.buf[w.pos:], p) - w.pos += len(p) - return len(p), nil + n := len(p) + w.pos += n + return n, nil } // putUint8 appends a single byte. -- cgit v1.3.1