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


Golang BitReader.ReadBool方法代码示例

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


在下文中一共展示了BitReader.ReadBool方法的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 *floor1) Decode(r *ogg.BitReader, books []codebook, n uint32) []uint32 {
	if !r.ReadBool() {
		return nil
	}

	range_ := [4]uint32{256, 128, 86, 64}[f.multiplier-1]
	y := make([]uint32, 0, len(f.xList))
	y = append(y, r.Read32(ilog(int(range_)-1)), r.Read32(ilog(int(range_)-1)))
	for _, classIndex := range f.partitionClassList {
		class := f.classes[classIndex]
		cdim := class.dimension
		cbits := class.subclass
		csub := (uint32(1) << cbits) - 1
		cval := uint32(0)
		if cbits > 0 {
			cval = books[class.masterbook].DecodeScalar(r)
		}
		for j := 0; j < int(cdim); j++ {
			book := class.subclassBooks[cval&csub]
			cval >>= cbits
			if book != 0xFF {
				y = append(y, books[book].DecodeScalar(r))
			} else {
				y = append(y, 0)
			}
		}
	}
	return y
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例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.ReadBool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。