Пример #1
0
func (editor *FlacTagEditor) getSizesAndPositions() (int, int, int, int) {
	commentPosition := 0
	commentSize := 0
	picturePosition := 0
	pictureSize := 0

	data := editor.file[4:]
	lastBlock := false
	currentPosition := 4

	for len(data) > 3 && !lastBlock {
		blockType := data[0] & (^lastMetaBlockFlag)
		blockSize := utils.ReadInt24Be(data[1:4]) + 4

		switch blockType {
		case commentBlockType:
			commentPosition = currentPosition
			commentSize = blockSize
		case pictureBlockType:
			if blockSize > pictureSize {
				picturePosition = currentPosition
				pictureSize = blockSize
			}
		}

		lastBlock = data[0]&lastMetaBlockFlag == lastMetaBlockFlag
		currentPosition += blockSize
		data = data[blockSize:]
	}

	return commentPosition, commentSize, picturePosition, pictureSize
}
Пример #2
0
func (editor *FlacTagEditor) findAndRemoveLastMetaBlockFlag(blocks []byte) bool {
	for len(blocks) > 3 {
		if blocks[0]&lastMetaBlockFlag == lastMetaBlockFlag {
			blocks[0] &= (^lastMetaBlockFlag)
			return true
		}
		blockSize := utils.ReadInt24Be(blocks[1:4]) + 4
		blocks = blocks[blockSize:]
	}
	return false
}