Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(176)

Delta Between Two Patch Sets: vp8l/decode.go

Issue 143610043: code review 143610043: go.image/vp8l: follow the default code length. (Closed)
Left Patch Set: diff -r 250a212e718aa7084d77870efe8eba3702657b99 https://code.google.com/p/go.image Created 10 years, 6 months ago
Right Patch Set: diff -r 250a212e718aa7084d77870efe8eba3702657b99 https://code.google.com/p/go.image Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package vp8l implements a decoder for the VP8L lossless image format. 5 // Package vp8l implements a decoder for the VP8L lossless image format.
6 // 6 //
7 // The VP8L specification is at: 7 // The VP8L specification is at:
8 // https://developers.google.com/speed/webp/docs/riff_container 8 // https://developers.google.com/speed/webp/docs/riff_container
9 package vp8l 9 package vp8l
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ms, err := d.read(n) 173 ms, err := d.read(n)
174 if err != nil { 174 if err != nil {
175 return err 175 return err
176 } 176 }
177 maxSymbol = int(ms) + 2 177 maxSymbol = int(ms) + 2
178 if maxSymbol > len(dst) { 178 if maxSymbol > len(dst) {
179 return errInvalidCodeLengths 179 return errInvalidCodeLengths
180 } 180 }
181 } 181 }
182 182
183 // The spec says that "if code 16 [meaning repeat] is used before
184 // a non-zero value has been emitted, a value of 8 is repeated."
183 prevCodeLength := uint32(8) 185 prevCodeLength := uint32(8)
186
184 for symbol := 0; symbol < len(dst); { 187 for symbol := 0; symbol < len(dst); {
185 if maxSymbol == 0 { 188 if maxSymbol == 0 {
186 break 189 break
187 } 190 }
188 maxSymbol-- 191 maxSymbol--
189 codeLength, err := h.next(d) 192 codeLength, err := h.next(d)
190 if err != nil { 193 if err != nil {
191 return err 194 return err
192 } 195 }
193 if codeLength < repeatsCodeLength { 196 if codeLength < repeatsCodeLength {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 for i := nTransforms - 1; i >= 0; i-- { 594 for i := nTransforms - 1; i >= 0; i-- {
592 t := &transforms[i] 595 t := &transforms[i]
593 pix = inverseTransforms[t.transformType](t, pix, h) 596 pix = inverseTransforms[t.transformType](t, pix, h)
594 } 597 }
595 return &image.NRGBA{ 598 return &image.NRGBA{
596 Pix: pix, 599 Pix: pix,
597 Stride: 4 * int(originalW), 600 Stride: 4 * int(originalW),
598 Rect: image.Rect(0, 0, int(originalW), int(h)), 601 Rect: image.Rect(0, 0, int(originalW), int(h)),
599 }, nil 602 }, nil
600 } 603 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b