1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// libwebp v1.6.0, src/dec/webpi_dec.h:
//
// Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Internal header: WebP decoding parameters and custom IO on buffer
//
// Author: somnath@google.com (Somnath Banerjee)
//! Translation of `src/dec/webpi_dec.h` from libwebp v1.6.0.
//!
//! Work package: WP12 (decoder integration).
//!
//! Exception: WP7 translates `WebPDecParams`, `OutputFunc`, `OutputAlphaFunc` and `OutputRowFunc` from `src/dec/webpi_dec.h`, because `VP8LDecodeImage` reads `WebPDecParams` through `io->opaque`.
//!
//! # Deviations from upstream
//!
//! Changes of representation that the ADRs allow, or behavior that the Rust
//! side cannot reproduce exactly. Each records the reason.
//!
//! 1. **`WebPHeaderStructure`** holds the input as a slice and `alpha_data` as
//! a position in it; after a successful parse, `have_all_data` is false, as
//! C's `*headers = hdrs` leaves it.
// The items below are WP7's exception in this module (`tools/units.json`):
// `WebPDecParams` and its three output function types. ADR 0003 ("Decoding
// context per call") fixes their form.
use crate;
use crateWebPRescaler;
use crate;
// upstream: src/dec/webpi_dec.h OutputFunc
/// Outputs RGB or YUV samples from the rows of one `put()` call into `output`.
/// Returns the number of rows written.
pub type OutputFunc =
fn ;
// upstream: src/dec/webpi_dec.h OutputAlphaFunc
/// Outputs the alpha channel of one `put()` call into `output`; the last
/// argument is `expected_num_out_lines`.
pub type OutputAlphaFunc =
fn ;
// upstream: src/dec/webpi_dec.h OutputRowFunc
/// Outputs one line of rescaled alpha values into `output`; the integer
/// arguments are `y_pos` and `max_out_lines`.
pub type OutputRowFunc = fn ;
// upstream: src/dec/webpi_dec.h WebPDecParams
/// Decoding output parameters. Transient internal object.
///
/// The C field `output` is not stored: the functions that write samples take the
/// output buffer next to the parameters (ADR 0003, "Decoding context per call").
/// `tmp_y`, `tmp_u` and `tmp_v` are positions in `memory`, where C has pointers
/// into it. Each rescaler owns its work rows, so `memory` holds only what C
/// carves from it besides them. `Default` is the zeroed structure of
/// `WebPResetDecParams`.
// The items below translate the rest of `src/dec/webpi_dec.h` (WP12). The
// header declares functions that `src/dec/webp_dec.c` and `src/dec/buffer_dec.c`
// define; they are in those modules.
//------------------------------------------------------------------------------
// Header parsing helpers
// upstream: src/dec/webpi_dec.h WebPHeaderStructure
/// Structure storing a description of the RIFF headers.
///
/// `data` is C's `data` and `data_size`. `alpha_data` is the position in `data`
/// of the ALPH chunk's payload, where C has a pointer into it (`None` for
/// `NULL`). The `int` flags are `bool` (ADR 0003).