summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPascal Massimino <pascal.massimino@gmail.com>2012-07-10 19:50:30 -0700
committerPascal Massimino <pascal.massimino@gmail.com>2012-07-10 19:50:30 -0700
commit44a09a3ccd82bd6fb3c68b6737d9d54715445f60 (patch)
tree48e15dd6fcfd6992244138c9f723e0c4a378b272 /doc
parent63db87dd2a3b261f96d158d019e0cf376a836c96 (diff)
downloadlibwebp-44a09a3ccd82bd6fb3c68b6737d9d54715445f60.tar.gz
add missing description of the alpha filtering methods
Change-Id: Id7bdf5e30121ce5d610b7fa00f64bcd2d7bed2bf
Diffstat (limited to 'doc')
-rw-r--r--doc/webp-container-spec.txt36
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/webp-container-spec.txt b/doc/webp-container-spec.txt
index 187616a9..6bf560ca 100644
--- a/doc/webp-container-spec.txt
+++ b/doc/webp-container-spec.txt
@@ -523,6 +523,42 @@ Filtering method (F): 2 bits
* `2`: Vertical filter.
* `3`: Gradient filter.
+For each pixel, filtering is performed using the following calculations.
+Assume the alpha values surrounding the current `X` position are labeled as:
+
+ C | B |
+ ---+---+
+ A | X |
+
+We seek to compute the alpha value at position `X`. First, a prediction is
+made depending on the filtering method:
+
+ * Method `0`: predictor = 0
+ * Method `1`: predictor = A
+ * Method `2`: predictor = B
+ * Method `3`: predictor = clip(A + B - C)
+
+where `clip(v)` is equal to:
+
+ * 0 if v < 0
+ * 255 if v > 255
+ * v otherwise
+
+The final value is derived by adding the decompressed value `X` to the
+predictor and using modulo-256 arithmetic to wrap the [256-511] range
+into the [0-255] one:
+
+`alpha = (predictor + X) % 256`
+
+There are special cases for left-most and top-most pixel positions:
+
+ * Top-left value at location (0,0) uses 0 as predictor value. Otherwise,
+ * For horizontal or gradient filtering methods, the left-most pixels at
+ location (0, y) are predicted using the location (0, y-1) just above.
+ * For vertical or gradient filtering methods, the top-most pixels at
+ location (x, 0) are predicted using the location (x-1, 0) on the left.
+
+
Pre-processing (P): 2 bits
: These INFORMATIVE bits are used to signal the pre-processing that has