当前位置: 首页>>代码示例>>Golang>>正文


Golang BitReader.Read8方法代码示例

本文整理汇总了Golang中github.com/jfreymuth/go-vorbis/ogg.BitReader.Read8方法的典型用法代码示例。如果您正苦于以下问题:Golang BitReader.Read8方法的具体用法?Golang BitReader.Read8怎么用?Golang BitReader.Read8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jfreymuth/go-vorbis/ogg.BitReader的用法示例。


在下文中一共展示了BitReader.Read8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ReadFrom

func (x *residue) ReadFrom(r *ogg.BitReader) error {
	x.residueType = r.Read16(16)
	if x.residueType > 2 {
		return ogg.ErrCorruptStream
	}
	x.begin = r.Read32(24)
	x.end = r.Read32(24)
	x.partitionSize = r.Read32(24) + 1
	x.classifications = r.Read8(6) + 1
	x.classbook = r.Read8(8)
	x.cascade = make([]uint8, x.classifications)
	for i := range x.cascade {
		highBits := uint8(0)
		lowBits := r.Read8(3)
		if r.ReadBool() {
			highBits = r.Read8(5)
		}
		x.cascade[i] = highBits*8 + lowBits
	}

	x.books = make([][8]uint8, x.classifications)
	for i := range x.books {
		for j := 0; j < 8; j++ {
			if x.cascade[i]&(1<<uint(j)) != 0 {
				x.books[i][j] = r.Read8(8)
			} else {
				x.books[i][j] = 0xFF //unused
			}
		}
	}

	return nil
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: Decode

func (f *floor0) Decode(r *ogg.BitReader, books []codebook, n uint32) []float32 {
	amplitude := r.Read32(uint(f.amplitudeBits))
	if amplitude > 0 {
		bookNumber := r.Read8(ilog(len(f.bookList)))
		coefficients := make([]float32, f.order)
		i := 0
	readCoefficients:
		for {
			tempVector := books[f.bookList[bookNumber]].DecodeVector(r)
			for _, c := range tempVector {
				coefficients[i] = c
				i++
				if i >= len(coefficients) {
					break readCoefficients
				}
			}
		}
	}
	//TODO

	return nil
}
开发者ID:,项目名称:,代码行数:22,代码来源:

示例3: decodePacket

func (s *setup) decodePacket(r *ogg.BitReader, prev [][]float32) ([][]float32, [][]float32, error) {
	if r.ReadBool() {
		return nil, nil, ogg.ErrCorruptStream
	}
	modeNumber := r.Read8(ilog(len(s.modes) - 1))
	mode := s.modes[modeNumber]
	// decode window type
	blocktype := mode.blockflag
	longWindow := mode.blockflag == 1
	blocksize := s.blocksize[blocktype]
	spectrumSize := uint32(blocksize / 2)
	windowPrev, windowNext := false, false
	window := windowType{blocksize, blocksize, blocksize}
	if longWindow {
		windowPrev = r.ReadBool()
		windowNext = r.ReadBool()
		if !windowPrev {
			window.prev = s.blocksize[0]
		}
		if !windowNext {
			window.next = s.blocksize[0]
		}
	}

	mapping := &s.mappings[mode.mapping]
	floors := make([]floorData, s.channels)
	residueVectors := make([][]float32, s.channels)
	for ch := range residueVectors {
		residueVectors[ch] = s.residueBuffer[ch][:spectrumSize]
		for i := range residueVectors[ch] {
			residueVectors[ch][i] = 0
		}
	}

	s.decodeFloors(r, floors, mapping, spectrumSize)
	s.decodeResidue(r, residueVectors, mapping, floors, spectrumSize)
	s.inverseCoupling(mapping, residueVectors)
	s.applyFloor(floors, residueVectors)

	// inverse MDCT
	out := make([][]float32, s.channels)
	for ch := range out {
		out[ch] = make([]float32, blocksize)
		imdct(s.lookup[blocktype], residueVectors[ch], out[ch])
	}

	// apply window and overlap
	s.applyWindow(&window, out)
	center := blocksize / 2
	offset := s.blocksize[1]/4 - s.blocksize[0]/4
	final := make([][]float32, s.channels)
	next := make([][]float32, s.channels)
	if longWindow {
		for ch := range out {
			start := 0
			end := blocksize
			if !windowPrev {
				start += offset
			}
			if !windowNext {
				end -= offset
			}
			final[ch], next[ch] = out[ch][start:center], out[ch][center:end]
			if prev != nil {
				for i := range prev[ch] {
					final[ch][i] += prev[ch][i]
				}
			}
		}
	} else /*short window*/ {
		for ch := range out {
			if prev != nil && len(prev[ch]) > center {
				final[ch], next[ch] = prev[ch], out[ch][center:]
				for i := offset; i < len(final[ch]); i++ {
					final[ch][i] += out[ch][i-offset]
				}
			} else {
				final[ch], next[ch] = out[ch][:center], out[ch][center:]
				if prev != nil {
					for i := range final[ch] {
						final[ch][i] += prev[ch][i]
					}
				}
			}
		}
	}
	return final, next, nil
}
开发者ID:,项目名称:,代码行数:88,代码来源:


注:本文中的github.com/jfreymuth/go-vorbis/ogg.BitReader.Read8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。