mirror of https://bitbucket.org/ausocean/av.git
codec/mjpeg: renamed Ctx type to Context and name value of this type ctx instead of c
This commit is contained in:
parent
b5f87481ba
commit
c691d4c1ff
|
@ -48,7 +48,7 @@ func NewExtractor() *Extractor { return &Extractor{} }
|
||||||
// function expects that each read from src will provide a single RTP packet.
|
// function expects that each read from src will provide a single RTP packet.
|
||||||
func (e *Extractor) Extract(dst io.Writer, src io.Reader, delay time.Duration) error {
|
func (e *Extractor) Extract(dst io.Writer, src io.Reader, delay time.Duration) error {
|
||||||
buf := make([]byte, maxRTPSize)
|
buf := make([]byte, maxRTPSize)
|
||||||
c := NewCtx(dst)
|
ctx := NewContext(dst)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
n, err := src.Read(buf)
|
n, err := src.Read(buf)
|
||||||
|
@ -72,7 +72,7 @@ func (e *Extractor) Extract(dst io.Writer, src io.Reader, delay time.Duration) e
|
||||||
return fmt.Errorf("could not read RTP marker: %w", err)
|
return fmt.Errorf("could not read RTP marker: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.ParsePayload(p, m)
|
err = ctx.ParsePayload(p, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not parse JPEG scan: %w", err)
|
return fmt.Errorf("could not parse JPEG scan: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,25 +135,25 @@ var defaultQuantisers = []byte{
|
||||||
99, 99, 99, 99, 99, 99, 99, 99,
|
99, 99, 99, 99, 99, 99, 99, 99,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ctx describes a RTP/JPEG parsing context that will keep track of the current
|
// Context describes a RTP/JPEG parsing context that will keep track of the current
|
||||||
// JPEG (held by p), and the state of the quantization tables.
|
// JPEG (held by p), and the state of the quantization tables.
|
||||||
type Ctx struct {
|
type Context struct {
|
||||||
qTables [128][128]byte
|
qTables [128][128]byte
|
||||||
qTablesLen [128]byte
|
qTablesLen [128]byte
|
||||||
p *putBuffer
|
p *putBuffer
|
||||||
d io.Writer
|
d io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCTX will return a new Ctx.
|
// NewContext will return a new Context.
|
||||||
func NewCtx(d io.Writer) *Ctx {
|
func NewContext(d io.Writer) *Context {
|
||||||
return &Ctx{
|
return &Context{
|
||||||
d: d,
|
d: d,
|
||||||
p: newPutBuffer(make([]byte, maxJPEG)),
|
p: newPutBuffer(make([]byte, maxJPEG)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePayload will parse an RTP/JPEG payload and append to current image.
|
// ParsePayload will parse an RTP/JPEG payload and append to current image.
|
||||||
func (c *Ctx) ParsePayload(p []byte, m bool) error {
|
func (c *Context) ParsePayload(p []byte, m bool) error {
|
||||||
b := newByteStream(p)
|
b := newByteStream(p)
|
||||||
_ = b.get8() // Ignore type-specific flag
|
_ = b.get8() // Ignore type-specific flag
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue