func serializeVorbisTagPictureField(cover Cover) []byte { result := make([]byte, cover.Size()+128) size := 0 // cover type // TODO care for cover type utils.WriteInt32Be(3, result[0:4]) size += 4 // mime utils.WriteInt32Be(len(cover.Mime), result[size:size+4]) copy(result[size+4:size+4+len(cover.Mime)], cover.Mime) size += 4 + len(cover.Mime) // description utils.WriteInt32Be(len(cover.Description), result[size:size+4]) copy(result[size+4:size+4+len(cover.Description)], cover.Description) size += 4 + len(cover.Description) // width, height, colour depth, colours for i := size; i < size+16; i++ { result[i] = 0 } size += 16 // image data utils.WriteInt32Be(len(cover.Data), result[size:size+4]) copy(result[size+4:size+4+len(cover.Data)], cover.Data) size += 4 + len(cover.Data) return result[:size] }
func (editor *Mp3TagEditor) serializeCover(cover Cover, frameId string, dst []byte, offset int) int { if len(frameId) != id3v2FrameIdSize { return offset } data := editor.coverToData(cover) copy(dst[offset:], frameId) utils.WriteInt32Be(len(data), dst[offset+4:offset+8]) dst[offset+8] = 0 // flag dst[offset+9] = 0 // flag copy(dst[offset+10:offset+10+len(data)], data) return offset + 10 + len(data) }
func (editor *Mp3TagEditor) serializeTextField(text, frameId string, dst []byte, offset int) int { if len(frameId) != id3v2FrameIdSize { return offset } utf16Text := utils.Utf8ToUtf16Le(text) copy(dst[offset:], frameId) utils.WriteInt32Be(len(utf16Text)+3, dst[offset+4:offset+8]) dst[offset+8] = 0 // flag dst[offset+9] = 0 // flag dst[offset+10] = 1 // text encoding dst[offset+11] = 0xFF // UTF BOM dst[offset+12] = 0xFE // UTF BOM copy(dst[offset+13:offset+13+len(utf16Text)], utf16Text) return offset + 13 + len(utf16Text) }