mirror of https://bitbucket.org/ausocean/av.git
Merge branch 'master' of http://bitbucket.org/ausocean/av
This commit is contained in:
commit
7f2e03e181
|
@ -36,6 +36,87 @@ const (
|
||||||
naMbPartPredMode
|
naMbPartPredMode
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// fieldReader provides methods for reading bool and int fields from a
|
||||||
|
// bits.BitReader with a sticky error that may be checked after a series of
|
||||||
|
// parsing read calls.
|
||||||
|
type fieldReader struct {
|
||||||
|
e error
|
||||||
|
br *bits.BitReader
|
||||||
|
}
|
||||||
|
|
||||||
|
// newFieldReader returns a new fieldReader.
|
||||||
|
func newFieldReader(br *bits.BitReader) fieldReader {
|
||||||
|
return fieldReader{br: br}
|
||||||
|
}
|
||||||
|
|
||||||
|
// readBitsInt returns an int from reading n bits from br. If we have an error
|
||||||
|
// already, we do not continue with the read.
|
||||||
|
func (r fieldReader) readBits(n int) uint64 {
|
||||||
|
if r.e != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var b uint64
|
||||||
|
b, r.e = r.br.ReadBits(n)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// readUe parses a syntax element of ue(v) descriptor, i.e. an unsigned integer
|
||||||
|
// Exp-Golomb-coded element using method as specified in section 9.1 of ITU-T
|
||||||
|
// H.264 and return as an int. The read does not happen if the fieldReader
|
||||||
|
// has a non-nil error.
|
||||||
|
func (r fieldReader) readUe() int {
|
||||||
|
if r.e != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var i int
|
||||||
|
i, r.e = readUe(r.br)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
// readTe parses a syntax element of te(v) descriptor i.e, truncated
|
||||||
|
// Exp-Golomb-coded syntax element using method as specified in section 9.1
|
||||||
|
// and returns as an int. The read does not happen if the fieldReader
|
||||||
|
// has a non-nil error.
|
||||||
|
func (r fieldReader) readTe(x uint) int {
|
||||||
|
if r.e != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var i int
|
||||||
|
i, r.e = readTe(r.br, x)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
// readSe parses a syntax element with descriptor se(v), i.e. a signed integer
|
||||||
|
// Exp-Golomb-coded syntax element, using the method described in sections
|
||||||
|
// 9.1 and 9.1.1 and returns as int. The read does not happen if the fieldReader
|
||||||
|
// has a non-nil error.
|
||||||
|
func (r fieldReader) readSe() int {
|
||||||
|
if r.e != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var i int
|
||||||
|
i, r.e = readSe(r.br)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
// readMe parses a syntax element of me(v) descriptor, i.e. mapped
|
||||||
|
// Exp-Golomb-coded element, using methods described in sections 9.1 and 9.1.2
|
||||||
|
// and returns as int. The read does not happen if the fieldReader has a
|
||||||
|
// non-nil error.
|
||||||
|
func (r fieldReader) readMe(chromaArrayType uint, mpm mbPartPredMode) int {
|
||||||
|
if r.e != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var i uint
|
||||||
|
i, r.e = readMe(r.br, chromaArrayType, mpm)
|
||||||
|
return int(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// err returns the fieldReader's error e.
|
||||||
|
func (r fieldReader) err() error {
|
||||||
|
return r.e
|
||||||
|
}
|
||||||
|
|
||||||
// readUe parses a syntax element of ue(v) descriptor, i.e. an unsigned integer
|
// readUe parses a syntax element of ue(v) descriptor, i.e. an unsigned integer
|
||||||
// Exp-Golomb-coded element using method as specified in section 9.1 of ITU-T H.264.
|
// Exp-Golomb-coded element using method as specified in section 9.1 of ITU-T H.264.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue