Skip to main content

webp/dec/
alphai_dec.rs

1// libwebp v1.6.0, src/dec/alphai_dec.h:
2//
3// Copyright 2013 Google Inc. All Rights Reserved.
4//
5// Use of this source code is governed by a BSD-style license
6// that can be found in the COPYING file in the root of the source
7// tree. An additional intellectual property rights grant can be found
8// in the file PATENTS. All contributing project authors may
9// be found in the AUTHORS file in the root of the source tree.
10// -----------------------------------------------------------------------------
11//
12// Alpha decoder: internal header.
13//
14// Author: Urvang (urvang@google.com)
15
16//! Translation of `src/dec/alphai_dec.h` from libwebp v1.6.0.
17//!
18//! Work package: WP7 (VP8L decoder).
19
20// The header also declares `WebPDeallocateAlphaMemory`, which
21// `src/dec/alpha_dec.c` defines; it belongs to that module (WP6).
22
23use crate::dec::vp8_dec::VP8Io;
24use crate::dec::vp8li_dec::VP8LDecoder;
25use crate::dsp::dsp::WEBP_FILTER_TYPE;
26
27// upstream: src/dec/alphai_dec.h ALPHDecoder
28/// The alpha decoder. `Default` is the zeroed structure of `ALPHNew`.
29///
30/// The C field `output` is not stored: the alpha plane belongs to the VP8
31/// decoder, which passes it to each call, and `prev_line` is a position in it
32/// (ADR 0003, "Decoding context per call"). `io` keeps no `opaque` that points
33/// back here; the VP8L alpha functions take this decoder instead.
34#[derive(Default)]
35pub struct ALPHDecoder {
36    /// Width of the alpha plane.
37    pub width: i32,
38    /// Height of the alpha plane.
39    pub height: i32,
40    /// Compression method (`ALPHA_NO_COMPRESSION` or `ALPHA_LOSSLESS_COMPRESSION`).
41    pub method: i32,
42    /// Prediction filter of the alpha plane.
43    pub filter: WEBP_FILTER_TYPE,
44    /// Pre-processing level.
45    pub pre_processing: i32,
46    /// The lossless decoder of the alpha data; `None` where C has `NULL`.
47    pub vp8l_dec: Option<Box<VP8LDecoder>>,
48    /// Dimensions and crop window of the decoding.
49    pub io: VP8Io,
50    /// Although the alpha channel requires only one byte per pixel, the VP8L
51    /// decoder sometimes needs four bytes per pixel internally during decoding.
52    pub use_8b_decode: bool,
53    /// Last output row, as a position in the alpha plane; `None` where C has
54    /// `NULL`.
55    pub prev_line: Option<usize>,
56}