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


Golang ogg.BitReader类代码示例

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


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

示例1: Lookup

func (t huffmanTable) Lookup(r *ogg.BitReader) uint32 {
	i := uint32(0)
	for i&0x80000000 == 0 {
		i = t[i*2+r.Read1()]
	}
	return i & 0x7FFFFFFF
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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: ReadFrom

func (i *identification) ReadFrom(r *ogg.BitReader) error {
	if r.Read8(8) != headerTypeIdentification {
		return ogg.ErrCorruptStream
	}
	if r.Read64(48) != pattern {
		return ogg.ErrCorruptStream
	}
	if r.Read32(32) != 0 {
		return ogg.ErrCorruptStream
	}
	i.audioChannels = r.Read8(8)
	i.audioSampleRate = r.Read32(32)
	i.bitrateMaximum = r.Read32(32)
	i.bitrateNominal = r.Read32(32)
	i.bitrateMinimum = r.Read32(32)
	i.blocksize0 = uint16(1) << r.Read8(4)
	i.blocksize1 = uint16(1) << r.Read8(4)
	if !r.ReadBool() {
		return ogg.ErrCorruptStream
	}
	return nil
}
开发者ID:,项目名称:,代码行数:22,代码来源:

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