Class: Pura::Webp::Decoder
- Inherits:
-
Object
- Object
- Pura::Webp::Decoder
- Defined in:
- lib/pura/webp/decoder.rb
Overview
VP8 keyframe (lossy WebP) decoder. This is a Ruby port of golang.org/x/image/vp8, specifically the files decode.go, partition.go, pred.go, predfunc.go, idct.go, token.go, quant.go and reconstruct.go. The port is as line-by-line as practical, including variable names and the ybr workspace layout, so bugs can be cross-checked against the upstream Go source.
Not yet ported: filter.go (loop filter). Pixel-accuracy tests allow tolerance for the small steps this introduces at block edges.
Constant Summary collapse
- N_PRED =
—- Predictor mode constants (pred.go) —-
10- PRED_DC =
0- PRED_TM =
1- PRED_VE =
2- PRED_HE =
3- PRED_RD =
4- PRED_VR =
5- PRED_LD =
6- PRED_VL =
7- PRED_HD =
8- PRED_HU =
9- PRED_DC_TOP =
10- PRED_DC_LEFT =
11- PRED_DC_TOPLEFT =
12- PLANE_Y1_WITH_Y2 =
—- Token plane enumeration (token.go) —-
0- PLANE_Y2 =
1- PLANE_UV =
2- PLANE_Y1_SANS_Y2 =
3- B_COEFF_BASE =
—- ybr workspace offsets (reconstruct.go) —-
256- R_COEFF_BASE =
256 + 64
- WHT_COEFF_BASE =
256 + 128
- YBR_Y_X =
8- YBR_Y_Y =
1- YBR_B_X =
8- YBR_B_Y =
18- YBR_R_X =
24- YBR_R_Y =
18- UNIFORM_PROB =
128
Class Method Summary collapse
-
.decode(input) ⇒ Object
—- Entry points —-.
Instance Method Summary collapse
- #decode ⇒ Object
-
#initialize(data) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(data) ⇒ Decoder
Returns a new instance of Decoder.
72 73 74 75 |
# File 'lib/pura/webp/decoder.rb', line 72 def initialize(data) @data = data.b @pos = 0 end |
Class Method Details
.decode(input) ⇒ Object
—- Entry points —-
63 64 65 66 67 68 69 70 |
# File 'lib/pura/webp/decoder.rb', line 63 def self.decode(input) data = if input.is_a?(String) && !input.include?("\0") && input.length < 4096 && File.exist?(input) File.binread(input) else input end new(data).decode end |
Instance Method Details
#decode ⇒ Object
77 78 79 |
# File 'lib/pura/webp/decoder.rb', line 77 def decode parse_riff end |