From e0397e17696991ec7cfdd75e2b8299456fd52b9d Mon Sep 17 00:00:00 2001 From: Saxon Date: Sun, 29 Dec 2019 22:47:38 +1030 Subject: [PATCH] codec/mjpeg/jpeg.go: improve Context struct field names --- codec/mjpeg/jpeg.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/codec/mjpeg/jpeg.go b/codec/mjpeg/jpeg.go index 1f4aa099..7b51672b 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -140,15 +140,15 @@ var defaultQuantisers = []byte{ type Context struct { qTables [128][128]byte qTablesLen [128]byte - p *putBuffer - d io.Writer + buf *putBuffer + dst io.Writer } -// NewContext will return a new Context. +// NewContext will return a new Context with destination d. func NewContext(d io.Writer) *Context { return &Context{ - d: d, - p: newPutBuffer(make([]byte, maxJPEG)), + dst: d, + buf: newPutBuffer(make([]byte, maxJPEG)), } } @@ -218,12 +218,12 @@ func (c *Context) ParsePayload(p []byte, m bool) error { qLen = len(qTable) } - c.p.reset() + c.buf.reset() - writeHeader(c.p, t, width, height, qLen/64, dri, qTable) + writeHeader(c.buf, t, width, height, qLen/64, dri, qTable) } - if c.p.len() == 0 { + if c.buf.len() == 0 { // Must have missed start of frame? So ignore and wait for start. return nil } @@ -235,16 +235,16 @@ func (c *Context) ParsePayload(p []byte, m bool) error { // to determine if there are missing frames. // Write frame data - err := b.writeTo(c.p, b.remaining()) + err := b.writeTo(c.buf, b.remaining()) if err != nil { return fmt.Errorf("could not write remaining frame data to output buffer: %w", err) } if m { // End of image marker. - mark(c.p, codeEOI) + mark(c.buf, codeEOI) - _, err = c.p.writeTo(c.d) + _, err = c.buf.writeTo(c.dst) if err != nil { return fmt.Errorf("could not write JPEG to dst: %w", err) }