mirror of https://bitbucket.org/ausocean/av.git
codec/mjpeg/jpeg.go: renamed fields of putBuffer struct
This commit is contained in:
parent
e8fd1a8661
commit
4c04cc033a
|
@ -222,7 +222,7 @@ func (c *Context) ParsePayload(p []byte, m bool) error {
|
||||||
writeHeader(c.buf, t, width, height, qLen/64, dri, qTable)
|
writeHeader(c.buf, t, width, height, qLen/64, dri, qTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.buf.len() == 0 {
|
if c.buf.len == 0 {
|
||||||
// Must have missed start of frame? So ignore and wait for start.
|
// Must have missed start of frame? So ignore and wait for start.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -292,13 +292,13 @@ func writeHeader(p *putBuffer, _type, width, height, nbqTab, dri int, qtable []b
|
||||||
|
|
||||||
// Define huffman table.
|
// Define huffman table.
|
||||||
mark(p, codeDHT)
|
mark(p, codeDHT)
|
||||||
lenIdx := p.len()
|
lenIdx := p.len
|
||||||
p.put16(0)
|
p.put16(0)
|
||||||
writeHuffman(p, 0, 0, bitsDCLum, valDC)
|
writeHuffman(p, 0, 0, bitsDCLum, valDC)
|
||||||
writeHuffman(p, 0, 1, bitsDCChr, valDC)
|
writeHuffman(p, 0, 1, bitsDCChr, valDC)
|
||||||
writeHuffman(p, 1, 0, bitsACLum, valACLum)
|
writeHuffman(p, 1, 0, bitsACLum, valACLum)
|
||||||
writeHuffman(p, 1, 1, bitsACChr, valACChr)
|
writeHuffman(p, 1, 1, bitsACChr, valACChr)
|
||||||
p.put16At(uint16(p.len()-lenIdx), lenIdx)
|
p.put16At(uint16(p.len-lenIdx), lenIdx)
|
||||||
|
|
||||||
// Start of frame.
|
// Start of frame.
|
||||||
mark(p, codeSOF0)
|
mark(p, codeSOF0)
|
||||||
|
|
|
@ -30,49 +30,45 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type putBuffer struct {
|
type putBuffer struct {
|
||||||
i int
|
len int
|
||||||
b []byte
|
bytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPutBuffer(b []byte) *putBuffer { return &putBuffer{b: b} }
|
func newPutBuffer(b []byte) *putBuffer { return &putBuffer{bytes: b} }
|
||||||
|
|
||||||
func (p *putBuffer) Write(b []byte) (int, error) {
|
func (p *putBuffer) Write(b []byte) (int, error) {
|
||||||
copy(p.b[p.i:], b)
|
copy(p.bytes[p.len:], b)
|
||||||
p.i += len(b)
|
p.len += len(b)
|
||||||
return len(b), nil
|
return len(b), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *putBuffer) writeTo(d io.Writer) (int, error) {
|
func (p *putBuffer) writeTo(d io.Writer) (int, error) {
|
||||||
n, err := d.Write(p.b[0:p.i])
|
n, err := d.Write(p.bytes[0:p.len])
|
||||||
p.i -= n
|
p.len -= n
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *putBuffer) put16(v uint16) {
|
func (p *putBuffer) put16(v uint16) {
|
||||||
binary.BigEndian.PutUint16(p.b[p.i:], v)
|
binary.BigEndian.PutUint16(p.bytes[p.len:], v)
|
||||||
p.i += 2
|
p.len += 2
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *putBuffer) put8(v uint8) {
|
func (p *putBuffer) put8(v uint8) {
|
||||||
p.b[p.i] = byte(v)
|
p.bytes[p.len] = byte(v)
|
||||||
p.i++
|
p.len++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *putBuffer) putBuf(src []byte) {
|
func (p *putBuffer) putBuf(src []byte) {
|
||||||
copy(p.b[p.i:], src)
|
copy(p.bytes[p.len:], src)
|
||||||
p.i += len(src)
|
p.len += len(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *putBuffer) put16At(v uint16, i int) {
|
func (p *putBuffer) put16At(v uint16, i int) {
|
||||||
binary.BigEndian.PutUint16(p.b[i:], v)
|
binary.BigEndian.PutUint16(p.bytes[i:], v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *putBuffer) reset() {
|
func (p *putBuffer) reset() {
|
||||||
p.i = 0
|
p.len = 0
|
||||||
}
|
|
||||||
|
|
||||||
func (p *putBuffer) len() int {
|
|
||||||
return p.i
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type byteStream struct {
|
type byteStream struct {
|
||||||
|
|
Loading…
Reference in New Issue