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

Delta Between Two Patch Sets: vp8l/decode.go

Issue 146910043: code review 146910043: vp8l: update comments to match latest spec. (Closed)
Left Patch Set: Created 10 years, 6 months ago
Right Patch Set: diff -r e492ffa4cad4d945baf6c597b52a306618e6f80a 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:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | vp8l/transform.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 pix, err := d.decodePix(int32(nColors), 1, 4*256, false) 123 pix, err := d.decodePix(int32(nColors), 1, 4*256, false)
124 if err != nil { 124 if err != nil {
125 return transform{}, 0, err 125 return transform{}, 0, err
126 } 126 }
127 for p := 4; p < len(pix); p += 4 { 127 for p := 4; p < len(pix); p += 4 {
128 pix[p+0] += pix[p-4] 128 pix[p+0] += pix[p-4]
129 pix[p+1] += pix[p-3] 129 pix[p+1] += pix[p-3]
130 pix[p+2] += pix[p-2] 130 pix[p+2] += pix[p-2]
131 pix[p+3] += pix[p-1] 131 pix[p+3] += pix[p-1]
132 } 132 }
133 » » // The C code fills in palette entries past the nColors upper li mit as 133 » » // The spec says that "if the index is equal or larger than colo r_table_size,
134 » » // transparent black. In Go, we re-slice up to 256 4-byte pixels . 134 » » // the argb color value should be set to 0x00000000 (transparent black)."
135 » » // We re-slice up to 256 4-byte pixels.
135 t.pix = pix[:4*256] 136 t.pix = pix[:4*256]
136 } 137 }
137 return t, w, nil 138 return t, w, nil
138 } 139 }
139 140
140 // repeatsCodeLength is the minimum code length for repeated codes. 141 // repeatsCodeLength is the minimum code length for repeated codes.
141 const repeatsCodeLength = 16 142 const repeatsCodeLength = 16
142 143
143 // These magic numbers are specified at the end of section 5.2.2. 144 // These magic numbers are specified at the end of section 5.2.2.
144 // The 3-length arrays apply to code lengths >= repeatsCodeLength. 145 // The 3-length arrays apply to code lengths >= repeatsCodeLength.
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 height++ 524 height++
524 _, err = d.read(1) // Read and ignore the hasAlpha hint. 525 _, err = d.read(1) // Read and ignore the hasAlpha hint.
525 if err != nil { 526 if err != nil {
526 return nil, 0, 0, err 527 return nil, 0, 0, err
527 } 528 }
528 version, err := d.read(3) 529 version, err := d.read(3)
529 if err != nil { 530 if err != nil {
530 return nil, 0, 0, err 531 return nil, 0, 0, err
531 } 532 }
532 if version != 0 { 533 if version != 0 {
533 » » return nil, 0, 0, errors.New("vp8l: unsupported version") 534 » » return nil, 0, 0, errors.New("vp8l: invalid version")
534 } 535 }
535 return d, int32(width), int32(height), nil 536 return d, int32(width), int32(height), nil
536 } 537 }
537 538
538 // DecodeConfig decodes the color model and dimensions of a VP8L image from r. 539 // DecodeConfig decodes the color model and dimensions of a VP8L image from r.
539 func DecodeConfig(r io.Reader) (image.Config, error) { 540 func DecodeConfig(r io.Reader) (image.Config, error) {
540 _, w, h, err := decodeHeader(r) 541 _, w, h, err := decodeHeader(r)
541 if err != nil { 542 if err != nil {
542 return image.Config{}, err 543 return image.Config{}, err
543 } 544 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 for i := nTransforms - 1; i >= 0; i-- { 591 for i := nTransforms - 1; i >= 0; i-- {
591 t := &transforms[i] 592 t := &transforms[i]
592 pix = inverseTransforms[t.transformType](t, pix, h) 593 pix = inverseTransforms[t.transformType](t, pix, h)
593 } 594 }
594 return &image.NRGBA{ 595 return &image.NRGBA{
595 Pix: pix, 596 Pix: pix,
596 Stride: 4 * int(originalW), 597 Stride: 4 * int(originalW),
597 Rect: image.Rect(0, 0, int(originalW), int(h)), 598 Rect: image.Rect(0, 0, int(originalW), int(h)),
598 }, nil 599 }, nil
599 } 600 }
LEFTRIGHT
« no previous file | vp8l/transform.go » ('j') | 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