Use Seek instead of discardN

This commit is contained in:
David Howden 2015-04-15 00:08:53 +10:00
parent 1fc6cacf34
commit 8aff503453
2 changed files with 5 additions and 8 deletions

7
mp4.go
View File

@ -69,7 +69,7 @@ func ReadAtoms(r io.ReadSeeker) (Metadata, error) {
return m, err
}
func (m metadataMP4) readAtoms(r io.Reader) error {
func (m metadataMP4) readAtoms(r io.ReadSeeker) error {
for {
var size uint32
err := binary.Read(r, binary.BigEndian, &size)
@ -96,7 +96,10 @@ func (m metadataMP4) readAtoms(r io.Reader) error {
case "moov", "udta", "ilst":
return m.readAtoms(r)
case "free":
discardN(r, int64(size-8))
_, err := r.Seek(int64(size-8), os.SEEK_CUR)
if err != nil {
return err
}
continue
case "mdat": // stop when we get to the data
return nil

View File

@ -6,14 +6,8 @@ package tag
import (
"io"
"io/ioutil"
)
func discardN(r io.Reader, n int64) error {
_, err := io.CopyN(ioutil.Discard, r, n)
return err
}
func getBit(b byte, n uint) bool {
x := byte(1 << n)
return (b & x) == x