diff options
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | descriptor.go | 7 | ||||
| -rw-r--r-- | iter.go | 7 | ||||
| -rw-r--r-- | reader.go | 5 | ||||
| -rw-r--r-- | writer.go | 5 |
5 files changed, 15 insertions, 13 deletions
@@ -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] +} @@ -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] -} @@ -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]) @@ -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. |
