From 029a59fc780b6ade45ad17aa9bfac5f220e7e232 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 88a7db78..dea764d6 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -139,15 +139,15 @@ var ( 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)), } } @@ -217,12 +217,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 } @@ -234,16 +234,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) }