kopia lustrzana https://github.com/jcs/id3-go
Clean tag and frame header bytes methods
rodzic
1052d2f5ca
commit
e6fdcb2297
10
v2/id3v2.go
10
v2/id3v2.go
|
@ -328,13 +328,11 @@ func (h Header) Size() int {
|
|||
}
|
||||
|
||||
func (h Header) Bytes() []byte {
|
||||
data := make([]byte, HeaderSize)
|
||||
data := make([]byte, 0, HeaderSize)
|
||||
|
||||
copy(data[:3], []byte("ID3"))
|
||||
copy(data[6:], encodedbytes.SynchBytes(h.size))
|
||||
data[3] = h.version
|
||||
data[4] = h.revision
|
||||
data[5] = h.flags
|
||||
data = append(data, "ID3"...)
|
||||
data = append(data, h.version, h.revision, h.flags)
|
||||
data = append(data, encodedbytes.SynchBytes(h.size)...)
|
||||
|
||||
return data
|
||||
}
|
||||
|
|
|
@ -122,10 +122,10 @@ func ParseV22Frame(reader io.Reader) Framer {
|
|||
}
|
||||
|
||||
func V22Bytes(f Framer) []byte {
|
||||
headBytes := make([]byte, V22FrameHeaderSize)
|
||||
headBytes := make([]byte, 0, V22FrameHeaderSize)
|
||||
|
||||
copy(headBytes[:3], []byte(f.Id()))
|
||||
copy(headBytes[3:6], encodedbytes.NormBytes(uint32(f.Size()))[1:])
|
||||
headBytes = append(headBytes, f.Id()...)
|
||||
headBytes = append(headBytes, encodedbytes.NormBytes(uint32(f.Size()))[1:]...)
|
||||
|
||||
return append(headBytes, f.Bytes()...)
|
||||
}
|
||||
|
|
|
@ -150,12 +150,11 @@ func ParseV23Frame(reader io.Reader) Framer {
|
|||
}
|
||||
|
||||
func V23Bytes(f Framer) []byte {
|
||||
headBytes := make([]byte, FrameHeaderSize)
|
||||
headBytes := make([]byte, 0, FrameHeaderSize)
|
||||
|
||||
copy(headBytes[:4], []byte(f.Id()))
|
||||
copy(headBytes[4:8], encodedbytes.NormBytes(uint32(f.Size())))
|
||||
headBytes[8] = f.StatusFlags()
|
||||
headBytes[9] = f.FormatFlags()
|
||||
headBytes = append(headBytes, f.Id()...)
|
||||
headBytes = append(headBytes, encodedbytes.NormBytes(uint32(f.Size()))...)
|
||||
headBytes = append(headBytes, f.StatusFlags(), f.FormatFlags())
|
||||
|
||||
return append(headBytes, f.Bytes()...)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue