html-to-markdown 2.24.6 → 2.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/ext/html-to-markdown-rb/native/Cargo.lock +9 -32
- data/ext/html-to-markdown-rb/native/Cargo.toml +1 -1
- data/lib/html_to_markdown/version.rb +1 -1
- data/rust-vendor/html-to-markdown-rs/Cargo.toml +0 -1
- data/rust-vendor/html-to-markdown-rs/src/converter/main_helpers.rs +1 -1
- data/rust-vendor/html-to-markdown-rs/src/hocr/converter/hierarchy.rs +20 -5
- data/rust-vendor/html-to-markdown-rs/src/lib.rs +1 -0
- data/rust-vendor/{markup5ever_rcdom/lib.rs → html-to-markdown-rs/src/rcdom.rs} +56 -91
- data/rust-vendor/html-to-markdown-rs/tests/hocr_compliance_test.rs +157 -0
- data/rust-vendor/memmap2/.cargo-checksum.json +1 -1
- data/rust-vendor/memmap2/.cargo_vcs_info.json +1 -1
- data/rust-vendor/memmap2/CHANGELOG.md +8 -0
- data/rust-vendor/memmap2/Cargo.lock +1 -1
- data/rust-vendor/memmap2/Cargo.toml +2 -1
- data/rust-vendor/memmap2/Cargo.toml.orig +2 -1
- data/rust-vendor/memmap2/src/lib.rs +25 -1
- data/rust-vendor/memmap2/src/stub.rs +1 -4
- data/rust-vendor/memmap2/src/unix.rs +14 -1
- data/rust-vendor/png/.cargo-checksum.json +1 -1
- data/rust-vendor/png/.cargo_vcs_info.json +1 -1
- data/rust-vendor/png/CHANGES.md +44 -0
- data/rust-vendor/png/Cargo.lock +124 -171
- data/rust-vendor/png/Cargo.toml +1 -1
- data/rust-vendor/png/Cargo.toml.orig +1 -1
- data/rust-vendor/png/benches/expand_paletted.rs +5 -5
- data/rust-vendor/png/benches/unfilter.rs +3 -3
- data/rust-vendor/png/src/adam7.rs +17 -10
- data/rust-vendor/png/src/common.rs +8 -8
- data/rust-vendor/png/src/decoder/mod.rs +53 -20
- data/rust-vendor/png/src/decoder/stream.rs +263 -78
- data/rust-vendor/png/src/decoder/unfiltering_buffer.rs +210 -53
- data/rust-vendor/png/src/decoder/zlib.rs +130 -90
- data/rust-vendor/png/src/encoder.rs +4 -2
- data/rust-vendor/png/src/{filter.rs → filter/mod.rs} +100 -367
- data/rust-vendor/png/src/filter/optimization-notes.md +104 -0
- data/rust-vendor/png/src/filter/paeth.rs +398 -0
- data/rust-vendor/png/src/filter/simd.rs +308 -0
- data/rust-vendor/png/src/lib.rs +1 -0
- data/rust-vendor/syn/.cargo-checksum.json +1 -1
- data/rust-vendor/syn/.cargo_vcs_info.json +1 -1
- data/rust-vendor/syn/Cargo.lock +40 -41
- data/rust-vendor/syn/Cargo.toml +1 -1
- data/rust-vendor/syn/Cargo.toml.orig +1 -1
- data/rust-vendor/syn/src/item.rs +61 -40
- data/rust-vendor/syn/src/lib.rs +2 -1
- data/rust-vendor/syn/tests/test_item.rs +54 -0
- data/rust-vendor/unicode-ident/.cargo-checksum.json +1 -1
- data/rust-vendor/unicode-ident/.cargo_vcs_info.json +1 -1
- data/rust-vendor/unicode-ident/Cargo.lock +21 -21
- data/rust-vendor/unicode-ident/Cargo.toml +1 -1
- data/rust-vendor/unicode-ident/Cargo.toml.orig +1 -1
- data/rust-vendor/unicode-ident/src/lib.rs +1 -1
- data/rust-vendor/unicode-ident/src/tables.rs +87 -97
- data/rust-vendor/unicode-ident/tests/static_size.rs +1 -1
- metadata +7 -177
- data/rust-vendor/markup5ever_rcdom/.cargo-checksum.json +0 -1
- data/rust-vendor/markup5ever_rcdom/.cargo_vcs_info.json +0 -7
- data/rust-vendor/markup5ever_rcdom/Cargo.lock +0 -658
- data/rust-vendor/markup5ever_rcdom/Cargo.toml +0 -109
- data/rust-vendor/markup5ever_rcdom/Cargo.toml.orig +0 -42
- data/rust-vendor/markup5ever_rcdom/LICENSE-APACHE +0 -201
- data/rust-vendor/markup5ever_rcdom/LICENSE-MIT +0 -25
- data/rust-vendor/markup5ever_rcdom/README.md +0 -7
- data/rust-vendor/markup5ever_rcdom/custom-html5lib-tokenizer-tests/regression.test +0 -69
- data/rust-vendor/markup5ever_rcdom/data/test/ignore +0 -1
- data/rust-vendor/markup5ever_rcdom/examples/hello_xml.rs +0 -39
- data/rust-vendor/markup5ever_rcdom/examples/html2html.rs +0 -51
- data/rust-vendor/markup5ever_rcdom/examples/print-rcdom.rs +0 -78
- data/rust-vendor/markup5ever_rcdom/examples/xml_tree_printer.rs +0 -67
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/.gitattributes +0 -2
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/.github/workflows/downstream.yml +0 -76
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/.github/workflows/lint.yml +0 -25
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/.gitignore +0 -79
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/AUTHORS.rst +0 -34
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/LICENSE +0 -21
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/encoding/chardet/test_big5.txt +0 -51
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/encoding/scripted/tests1.dat +0 -5
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/encoding/test-yahoo-jp.dat +0 -10
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/encoding/tests1.dat +0 -388
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/encoding/tests2.dat +0 -115
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint +0 -6
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/__init__.py +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/__init__.py +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/LICENSE +0 -18
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/__init__.py +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/lexer.py +0 -211
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/lexer.pyi +0 -34
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/parser.py +0 -872
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/parser.pyi +0 -83
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/py.typed +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/util.py +0 -72
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/funcparserlib/util.pyi +0 -7
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor/vendor.txt +0 -1
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/_vendor-patches/funcparserlib.patch +0 -24
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/lint.py +0 -280
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/lint_lib/parser.py +0 -177
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/pyproject.toml +0 -7
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/serializer/core.test +0 -125
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/serializer/injectmeta.test +0 -66
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/serializer/optionaltags.test +0 -965
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/serializer/options.test +0 -60
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/serializer/whitespace.test +0 -51
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/README.md +0 -107
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/contentModelFlags.test +0 -93
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/domjs.test +0 -335
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/entities.test +0 -542
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/escapeFlag.test +0 -36
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/namedEntities.test +0 -42422
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/numericEntities.test +0 -1677
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/pendingSpecChanges.test +0 -9
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/test1.test +0 -353
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/test2.test +0 -275
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/test3.test +0 -11233
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/test4.test +0 -532
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/unicodeChars.test +0 -1577
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/unicodeCharsProblematic.test +0 -41
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tokenizer/xmlViolation.test +0 -20
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/README.md +0 -108
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/adoption01.dat +0 -354
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/adoption02.dat +0 -39
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/blocks.dat +0 -695
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/comments01.dat +0 -217
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/doctype01.dat +0 -474
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/domjs-unsafe.dat +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/entities01.dat +0 -943
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/entities02.dat +0 -309
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/foreign-fragment.dat +0 -645
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/html5test-com.dat +0 -301
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/inbody01.dat +0 -54
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/isindex.dat +0 -49
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/main-element.dat +0 -46
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/math.dat +0 -104
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/menuitem-element.dat +0 -240
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/namespace-sensitivity.dat +0 -22
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/noscript01.dat +0 -237
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/pending-spec-changes-plain-text-unsafe.dat +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/pending-spec-changes.dat +0 -46
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/plain-text-unsafe.dat +0 -0
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/quirks01.dat +0 -53
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/ruby.dat +0 -302
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/scriptdata01.dat +0 -372
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/scripted/adoption01.dat +0 -16
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/scripted/ark.dat +0 -27
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/scripted/webkit01.dat +0 -30
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/search-element.dat +0 -46
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/svg.dat +0 -104
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tables01.dat +0 -322
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/template.dat +0 -1673
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests1.dat +0 -1956
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests10.dat +0 -849
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests11.dat +0 -523
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests12.dat +0 -62
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests14.dat +0 -75
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests15.dat +0 -216
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests16.dat +0 -2602
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests17.dat +0 -179
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests18.dat +0 -558
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests19.dat +0 -1398
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests2.dat +0 -831
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests20.dat +0 -842
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests21.dat +0 -306
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests22.dat +0 -190
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests23.dat +0 -168
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests24.dat +0 -79
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests25.dat +0 -288
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests26.dat +0 -453
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests3.dat +0 -305
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests4.dat +0 -74
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests5.dat +0 -210
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests6.dat +0 -663
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests7.dat +0 -453
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests8.dat +0 -165
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests9.dat +0 -472
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tests_innerHTML_1.dat +0 -843
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/tricky01.dat +0 -336
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/webkit01.dat +0 -785
- data/rust-vendor/markup5ever_rcdom/html5lib-tests/tree-construction/webkit02.dat +0 -554
- data/rust-vendor/markup5ever_rcdom/tests/foreach_html5lib_test/mod.rs +0 -41
- data/rust-vendor/markup5ever_rcdom/tests/html-driver.rs +0 -29
- data/rust-vendor/markup5ever_rcdom/tests/html-serializer.rs +0 -265
- data/rust-vendor/markup5ever_rcdom/tests/html-tokenizer.rs +0 -487
- data/rust-vendor/markup5ever_rcdom/tests/html-tree-builder.rs +0 -298
- data/rust-vendor/markup5ever_rcdom/tests/html-tree-sink.rs +0 -141
- data/rust-vendor/markup5ever_rcdom/tests/util/find_tests.rs +0 -34
- data/rust-vendor/markup5ever_rcdom/tests/util/runner.rs +0 -48
- data/rust-vendor/markup5ever_rcdom/tests/xml-driver.rs +0 -101
- data/rust-vendor/markup5ever_rcdom/tests/xml-tokenizer.rs +0 -374
- data/rust-vendor/markup5ever_rcdom/tests/xml-tree-builder.rs +0 -237
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/AUTHORS.rst +0 -9
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/LICENSE +0 -21
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/README.md +0 -92
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/comments.test +0 -274
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/doctype.test +0 -3232
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/entities.test +0 -283
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/eof.test +0 -113
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/namedEntities.test +0 -42210
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/numericEntities.test +0 -1349
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/test1.test +0 -162
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/test2.test +0 -64
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tokenizer/unicodeChars.test +0 -1295
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tree-construction/README.md +0 -104
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tree-construction/namespace.dat +0 -119
- data/rust-vendor/markup5ever_rcdom/xml5lib-tests/tree-construction/test1.dat +0 -124
- data/rust-vendor/xml5ever/.cargo-checksum.json +0 -1
- data/rust-vendor/xml5ever/.cargo_vcs_info.json +0 -6
- data/rust-vendor/xml5ever/Cargo.lock +0 -752
- data/rust-vendor/xml5ever/Cargo.toml +0 -69
- data/rust-vendor/xml5ever/Cargo.toml.orig +0 -29
- data/rust-vendor/xml5ever/LICENSE-APACHE +0 -201
- data/rust-vendor/xml5ever/LICENSE-MIT +0 -25
- data/rust-vendor/xml5ever/README.md +0 -72
- data/rust-vendor/xml5ever/benches/xml5ever.rs +0 -77
- data/rust-vendor/xml5ever/data/bench/strong.xml +0 -1
- data/rust-vendor/xml5ever/examples/README.md +0 -223
- data/rust-vendor/xml5ever/examples/example.xml +0 -3
- data/rust-vendor/xml5ever/examples/simple_xml_tokenizer.rs +0 -81
- data/rust-vendor/xml5ever/examples/xml_tokenizer.rs +0 -115
- data/rust-vendor/xml5ever/src/driver.rs +0 -90
- data/rust-vendor/xml5ever/src/lib.rs +0 -47
- data/rust-vendor/xml5ever/src/macros.rs +0 -18
- data/rust-vendor/xml5ever/src/serialize/mod.rs +0 -216
- data/rust-vendor/xml5ever/src/tokenizer/char_ref/mod.rs +0 -456
- data/rust-vendor/xml5ever/src/tokenizer/interface.rs +0 -116
- data/rust-vendor/xml5ever/src/tokenizer/mod.rs +0 -1344
- data/rust-vendor/xml5ever/src/tokenizer/qname.rs +0 -84
- data/rust-vendor/xml5ever/src/tokenizer/states.rs +0 -167
- data/rust-vendor/xml5ever/src/tree_builder/mod.rs +0 -774
- data/rust-vendor/xml5ever/src/tree_builder/types.rs +0 -37
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
//! [the Adam7 algorithm](https://en.wikipedia.org/wiki/Adam7_algorithm).
|
|
3
3
|
use core::ops::RangeTo;
|
|
4
4
|
|
|
5
|
+
#[cfg(doc)]
|
|
6
|
+
use crate::decoder::Reader;
|
|
7
|
+
|
|
5
8
|
/// Describes which stage of
|
|
6
9
|
/// [the Adam7 algorithm](https://en.wikipedia.org/wiki/Adam7_algorithm)
|
|
7
10
|
/// applies to a decoded row.
|
|
8
11
|
///
|
|
9
|
-
/// See also [Reader
|
|
12
|
+
/// See also [`Reader::next_interlaced_row`].
|
|
10
13
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
11
14
|
pub struct Adam7Info {
|
|
12
15
|
/// The Adam7 pass number, 1..7.
|
|
@@ -41,12 +44,12 @@ impl Adam7Info {
|
|
|
41
44
|
/// * `width` describes how many pixels are in a full row of the image. The bytes in each
|
|
42
45
|
/// passline of the Adam7 are calculated from this number.
|
|
43
46
|
///
|
|
44
|
-
/// Note that in typical usage, `Adam7Info`s are returned by [Reader
|
|
47
|
+
/// Note that in typical usage, `Adam7Info`s are returned by [`Reader::next_interlaced_row`]
|
|
45
48
|
/// and there is no need to create them by calling `Adam7Info::new`. `Adam7Info::new` is
|
|
46
49
|
/// nevertheless exposed as a public API, because it helps to provide self-contained example
|
|
47
|
-
/// usage of [expand_interlaced_row](crate::expand_interlaced_row).
|
|
50
|
+
/// usage of [`expand_interlaced_row`](crate::expand_interlaced_row).
|
|
48
51
|
pub fn new(pass: u8, line: u32, width: u32) -> Self {
|
|
49
|
-
assert!(1
|
|
52
|
+
assert!((1..=7).contains(&pass));
|
|
50
53
|
assert!(width > 0);
|
|
51
54
|
|
|
52
55
|
let info = PassConstants::PASSES[pass as usize - 1];
|
|
@@ -79,7 +82,7 @@ impl Adam7Info {
|
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
#[derive(Clone, Copy)]
|
|
82
|
-
struct PassConstants {
|
|
85
|
+
pub(crate) struct PassConstants {
|
|
83
86
|
x_sampling: u8,
|
|
84
87
|
x_offset: u8,
|
|
85
88
|
y_sampling: u8,
|
|
@@ -95,13 +98,13 @@ impl PassConstants {
|
|
|
95
98
|
self.y_sampling - self.y_offset
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
fn count_samples(self, width: u32) -> u32 {
|
|
101
|
+
pub fn count_samples(self, width: u32) -> u32 {
|
|
99
102
|
width
|
|
100
103
|
.saturating_sub(u32::from(self.x_offset))
|
|
101
104
|
.div_ceil(u32::from(self.x_sampling))
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
fn count_lines(self, height: u32) -> u32 {
|
|
107
|
+
pub fn count_lines(self, height: u32) -> u32 {
|
|
105
108
|
height
|
|
106
109
|
.saturating_sub(u32::from(self.y_offset))
|
|
107
110
|
.div_ceil(u32::from(self.y_sampling))
|
|
@@ -221,7 +224,9 @@ pub enum Adam7Variant {
|
|
|
221
224
|
/// are complete. At least the invalid pixels in the buffer should be masked. However, this
|
|
222
225
|
/// performs the least amount of writes and is optimal when you're only reading full frames.
|
|
223
226
|
///
|
|
224
|
-
/// This corresponds to [`
|
|
227
|
+
/// This corresponds to [`expand_interlaced_row`].
|
|
228
|
+
///
|
|
229
|
+
/// [`expand_interlaced_row`]: crate::expand_interlaced_row.
|
|
225
230
|
#[default]
|
|
226
231
|
Sparse,
|
|
227
232
|
/// A variant of the Adam7 de-interlace that ensures that all pixels are initialized after each
|
|
@@ -229,7 +234,9 @@ pub enum Adam7Variant {
|
|
|
229
234
|
/// other variant as some pixels are touched repeatedly, but ensures the buffer can be used as
|
|
230
235
|
/// directly as possible for presentation.
|
|
231
236
|
///
|
|
232
|
-
/// This corresponds to [`
|
|
237
|
+
/// This corresponds to [`splat_interlaced_row`].
|
|
238
|
+
///
|
|
239
|
+
/// [`splat_interlaced_row`]: crate::splat_interlaced_row
|
|
233
240
|
Splat,
|
|
234
241
|
}
|
|
235
242
|
|
|
@@ -313,7 +320,7 @@ fn expand_adam7_bytes(
|
|
|
313
320
|
/// stride may be useful if the frame being decoded is a sub-region of `img`.
|
|
314
321
|
///
|
|
315
322
|
/// `interlaced_row` and `interlace_info` typically come from
|
|
316
|
-
/// [
|
|
323
|
+
/// [`Reader::next_interlaced_row`], but this is not required. In particular, before
|
|
317
324
|
/// calling `expand_interlaced_row` one may need to expand the decoded row, so that its format and
|
|
318
325
|
/// `bits_per_pixel` matches that of `img`. Note that in initial Adam7 passes the `interlaced_row`
|
|
319
326
|
/// may contain less pixels that the width of the frame being decoded (e.g. it contains only 1/8th
|
|
@@ -53,7 +53,7 @@ impl ColorType {
|
|
|
53
53
|
pub(crate) fn checked_raw_row_length(self, depth: BitDepth, width: u32) -> Option<usize> {
|
|
54
54
|
// No overflow can occur in 64 bits, we multiply 32-bit with 5 more bits.
|
|
55
55
|
let bits = u64::from(width) * u64::from(self.samples_u8()) * u64::from(depth.into_u8());
|
|
56
|
-
TryFrom::try_from(1 + (
|
|
56
|
+
TryFrom::try_from(1 + bits.div_ceil(8)).ok()
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
pub(crate) fn raw_row_length_from_width(self, depth: BitDepth, width: u32) -> usize {
|
|
@@ -320,7 +320,7 @@ impl AnimationControl {
|
|
|
320
320
|
/// the appropriate DEFLATE compression mode and PNG filter.
|
|
321
321
|
///
|
|
322
322
|
/// If you need more control over the encoding parameters,
|
|
323
|
-
/// you can set the [DeflateCompression] and [Filter] manually.
|
|
323
|
+
/// you can set the [`DeflateCompression`] and [`Filter`] manually.
|
|
324
324
|
#[derive(Debug, Clone, Copy)]
|
|
325
325
|
#[non_exhaustive]
|
|
326
326
|
pub enum Compression {
|
|
@@ -338,7 +338,7 @@ pub enum Compression {
|
|
|
338
338
|
/// implementation tuned for PNG](https://crates.io/crates/fdeflate), while still providing
|
|
339
339
|
/// better compression ratio than the fastest modes of other encoders.
|
|
340
340
|
///
|
|
341
|
-
/// Like `Compression::
|
|
341
|
+
/// Like [`Compression::Fastest`] this can currently produce files larger than `NoCompression` in
|
|
342
342
|
/// streaming mode when given incompressible data. This may change in the future.
|
|
343
343
|
Fast,
|
|
344
344
|
/// Balances encoding speed and compression ratio
|
|
@@ -353,11 +353,11 @@ impl Default for Compression {
|
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
/// Advanced compression settings with more customization options than [Compression].
|
|
356
|
+
/// Advanced compression settings with more customization options than [`Compression`].
|
|
357
357
|
///
|
|
358
358
|
/// Note that this setting only affects DEFLATE compression.
|
|
359
359
|
/// Another setting that influences the compression ratio and lets you choose
|
|
360
|
-
/// between encoding speed and compression ratio is the [Filter].
|
|
360
|
+
/// between encoding speed and compression ratio is the [`Filter`].
|
|
361
361
|
///
|
|
362
362
|
/// ### Stability guarantees
|
|
363
363
|
///
|
|
@@ -375,7 +375,7 @@ pub enum DeflateCompression {
|
|
|
375
375
|
/// Useful for incompressible images, or when speed is paramount and you don't care about size
|
|
376
376
|
/// at all.
|
|
377
377
|
///
|
|
378
|
-
/// This mode also disables filters, forcing [Filter::NoFilter].
|
|
378
|
+
/// This mode also disables filters, forcing [`Filter::NoFilter`].
|
|
379
379
|
NoCompression,
|
|
380
380
|
|
|
381
381
|
/// Excellent for creating lightly compressed PNG images very quickly.
|
|
@@ -420,12 +420,12 @@ impl DeflateCompression {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
/// An unsigned integer scaled version of a floating point value,
|
|
423
|
-
/// equivalent to an integer quotient with fixed denominator
|
|
423
|
+
/// equivalent to an integer quotient with [fixed denominator][ScaledFloat::SCALING]).
|
|
424
424
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
425
425
|
pub struct ScaledFloat(u32);
|
|
426
426
|
|
|
427
427
|
impl ScaledFloat {
|
|
428
|
-
const SCALING: f32 = 100_000.0;
|
|
428
|
+
pub const SCALING: f32 = 100_000.0;
|
|
429
429
|
|
|
430
430
|
/// Gets whether the value is within the clamped range of this type.
|
|
431
431
|
pub fn in_range(value: f32) -> bool {
|
|
@@ -180,8 +180,10 @@ impl<R: BufRead + Seek> Decoder<R> {
|
|
|
180
180
|
|
|
181
181
|
/// Read the PNG header and return the information contained within.
|
|
182
182
|
///
|
|
183
|
-
/// Most image metadata will not be read until `read_info` is called, so those fields will be
|
|
183
|
+
/// Most image metadata will not be read until [`read_info`] is called, so those fields will be
|
|
184
184
|
/// None or empty.
|
|
185
|
+
///
|
|
186
|
+
/// [`read_info`]: Self::read_info
|
|
185
187
|
pub fn read_header_info(&mut self) -> Result<&Info<'static>, DecodingError> {
|
|
186
188
|
self.read_decoder.read_header_info()
|
|
187
189
|
}
|
|
@@ -227,7 +229,9 @@ impl<R: BufRead + Seek> Decoder<R> {
|
|
|
227
229
|
reader.remaining_frames = match reader.info().animation_control.as_ref() {
|
|
228
230
|
None => 1, // No `acTL` => only expecting `IDAT` frame.
|
|
229
231
|
Some(animation) => {
|
|
230
|
-
|
|
232
|
+
// Note: limited to (2^32 - 1) frames by the APNG spec so addition does not
|
|
233
|
+
// overflow on 32-bit targets nor 64-bit targets.
|
|
234
|
+
let mut num_frames = animation.num_frames;
|
|
231
235
|
if reader.info().frame_control.is_none() {
|
|
232
236
|
// No `fcTL` before `IDAT` => `IDAT` is not part of the animation, but
|
|
233
237
|
// represents an *extra*, default frame for non-APNG-aware decoders.
|
|
@@ -292,7 +296,7 @@ pub struct Reader<R: BufRead + Seek> {
|
|
|
292
296
|
bpp: BytesPerPixel,
|
|
293
297
|
subframe: SubframeInfo,
|
|
294
298
|
/// How many frames remain to be decoded. Decremented after each `IDAT` or `fdAT` sequence.
|
|
295
|
-
remaining_frames:
|
|
299
|
+
remaining_frames: u32,
|
|
296
300
|
/// Buffer with not-yet-`unfilter`-ed image rows
|
|
297
301
|
unfiltering_buffer: UnfilteringBuffer,
|
|
298
302
|
/// Output transformations
|
|
@@ -325,12 +329,15 @@ struct SubframeInfo {
|
|
|
325
329
|
|
|
326
330
|
impl<R: BufRead + Seek> Reader<R> {
|
|
327
331
|
/// Advances to the start of the next animation frame and
|
|
328
|
-
/// returns a reference to the `FrameControl` info that describes it.
|
|
332
|
+
/// returns a reference to the [`FrameControl`] info that describes it.
|
|
329
333
|
/// Skips and discards the image data of the previous frame if necessary.
|
|
330
334
|
///
|
|
331
335
|
/// Returns a [`ParameterError`] when there are no more animation frames.
|
|
332
336
|
/// To avoid this the caller can check if [`Info::animation_control`] exists
|
|
333
337
|
/// and consult [`AnimationControl::num_frames`].
|
|
338
|
+
///
|
|
339
|
+
/// [`ParameterError`]: crate::ParameterError
|
|
340
|
+
/// [`AnimationControl::num_frames`]: crate::AnimationControl::num_frames
|
|
334
341
|
pub fn next_frame_info(&mut self) -> Result<&FrameControl, DecodingError> {
|
|
335
342
|
let remaining_frames = if self.subframe.consumed_and_flushed {
|
|
336
343
|
self.remaining_frames
|
|
@@ -363,7 +370,21 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
363
370
|
|
|
364
371
|
self.subframe = SubframeInfo::new(self.info());
|
|
365
372
|
self.bpp = self.info().bpp_in_prediction();
|
|
366
|
-
|
|
373
|
+
|
|
374
|
+
let frame_bytes = if self.info().interlaced {
|
|
375
|
+
let mut bytes = 0u64;
|
|
376
|
+
for pass in crate::adam7::PassConstants::PASSES {
|
|
377
|
+
bytes += self
|
|
378
|
+
.info()
|
|
379
|
+
.raw_row_length_from_width(pass.count_samples(self.subframe.width))
|
|
380
|
+
as u64
|
|
381
|
+
* pass.count_lines(self.subframe.height) as u64;
|
|
382
|
+
}
|
|
383
|
+
bytes
|
|
384
|
+
} else {
|
|
385
|
+
(self.subframe.rowlen as u64) * self.subframe.height as u64
|
|
386
|
+
};
|
|
387
|
+
self.unfiltering_buffer.start_frame(frame_bytes);
|
|
367
388
|
|
|
368
389
|
// Allocate output buffer.
|
|
369
390
|
let buflen = self.unguarded_output_line_size(self.subframe.width);
|
|
@@ -386,7 +407,7 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
386
407
|
///
|
|
387
408
|
/// The caller must always provide a buffer large enough to hold a complete frame (the APNG
|
|
388
409
|
/// specification restricts subframes to the dimensions given in the image header). The region
|
|
389
|
-
/// that has been written be checked afterwards by calling `info` after a successful call and
|
|
410
|
+
/// that has been written be checked afterwards by calling [`Reader::info`] after a successful call and
|
|
390
411
|
/// inspecting the `frame_control` data. This requirement may be lifted in a later version of
|
|
391
412
|
/// `png`.
|
|
392
413
|
///
|
|
@@ -489,9 +510,9 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
489
510
|
Ok(())
|
|
490
511
|
}
|
|
491
512
|
|
|
492
|
-
/// Returns the next processed row of the image (discarding `InterlaceInfo`).
|
|
513
|
+
/// Returns the next processed row of the image (discarding [`InterlaceInfo`]).
|
|
493
514
|
///
|
|
494
|
-
/// See also [`Reader
|
|
515
|
+
/// See also [`Reader::read_row`], which reads into a caller-provided buffer.
|
|
495
516
|
pub fn next_row(&mut self) -> Result<Option<Row<'_>>, DecodingError> {
|
|
496
517
|
self.next_interlaced_row()
|
|
497
518
|
.map(|v| v.map(|v| Row { data: v.data }))
|
|
@@ -499,7 +520,7 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
499
520
|
|
|
500
521
|
/// Returns the next processed row of the image.
|
|
501
522
|
///
|
|
502
|
-
/// See also [`Reader
|
|
523
|
+
/// See also [`Reader::read_row`], which reads into a caller-provided buffer.
|
|
503
524
|
pub fn next_interlaced_row(&mut self) -> Result<Option<InterlacedRow<'_>>, DecodingError> {
|
|
504
525
|
let mut output_buffer = mem::take(&mut self.scratch_buffer);
|
|
505
526
|
let max_line_size = self
|
|
@@ -522,10 +543,10 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
522
543
|
/// Reads the next row of the image into the provided `output_buffer`.
|
|
523
544
|
/// `Ok(None)` will be returned if the current image frame has no more rows.
|
|
524
545
|
///
|
|
525
|
-
/// `output_buffer` needs to be long enough to accommodate [`Reader
|
|
526
|
-
/// [`Info
|
|
546
|
+
/// `output_buffer` needs to be long enough to accommodate [`Reader::output_line_size`] for
|
|
547
|
+
/// [`Info::width`] (initial interlaced rows may need less than that).
|
|
527
548
|
///
|
|
528
|
-
/// See also [`Reader
|
|
549
|
+
/// See also [`Reader::next_row`] and [`Reader::next_interlaced_row`], which read into a
|
|
529
550
|
/// `Reader`-owned buffer.
|
|
530
551
|
pub fn read_row(
|
|
531
552
|
&mut self,
|
|
@@ -574,7 +595,6 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
574
595
|
}
|
|
575
596
|
|
|
576
597
|
self.remaining_frames = 0;
|
|
577
|
-
self.unfiltering_buffer.reset_all();
|
|
578
598
|
self.decoder.read_until_end_of_input()?;
|
|
579
599
|
|
|
580
600
|
self.finished = true;
|
|
@@ -605,7 +625,7 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
605
625
|
}
|
|
606
626
|
|
|
607
627
|
/// Returns the color type and the number of bits per sample
|
|
608
|
-
/// of the data returned by `Reader::next_row` and Reader::
|
|
628
|
+
/// of the data returned by [`Reader::next_row`] and [`Reader::next_frame`].
|
|
609
629
|
pub fn output_color_type(&self) -> (ColorType, BitDepth) {
|
|
610
630
|
use crate::common::ColorType::*;
|
|
611
631
|
let t = self.transform;
|
|
@@ -679,21 +699,34 @@ impl<R: BufRead + Seek> Reader<R> {
|
|
|
679
699
|
/// Unfilter the next raw interlaced row into `self.unfiltering_buffer`.
|
|
680
700
|
fn next_raw_interlaced_row(&mut self, rowlen: usize) -> Result<(), DecodingError> {
|
|
681
701
|
// Read image data until we have at least one full row (but possibly more than one).
|
|
682
|
-
while self.unfiltering_buffer.
|
|
702
|
+
while self.unfiltering_buffer.mutable_len_of_curr_row() < rowlen {
|
|
683
703
|
if self.subframe.consumed_and_flushed {
|
|
684
704
|
return Err(DecodingError::Format(
|
|
685
705
|
FormatErrorInner::NoMoreImageData.into(),
|
|
686
706
|
));
|
|
687
707
|
}
|
|
688
708
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
709
|
+
assert!(self.unfiltering_buffer.remaining_bytes() > 0);
|
|
710
|
+
let completion_status = self
|
|
711
|
+
.unfiltering_buffer
|
|
712
|
+
.with_unfilled_buffer(|buffer| self.decoder.decode_image_data(Some(buffer)));
|
|
713
|
+
match completion_status {
|
|
714
|
+
Ok(ImageDataCompletionStatus::ExpectingMoreData) => (),
|
|
715
|
+
Ok(ImageDataCompletionStatus::Done) => self.mark_subframe_as_consumed_and_flushed(),
|
|
716
|
+
Err(DecodingError::IoError(e))
|
|
717
|
+
if e.kind() == std::io::ErrorKind::UnexpectedEof
|
|
718
|
+
&& self.unfiltering_buffer.readable_len_of_curr_row() >= rowlen =>
|
|
719
|
+
{
|
|
720
|
+
return self
|
|
721
|
+
.unfiltering_buffer
|
|
722
|
+
.unfilter_curr_row_using_scratch_buffer(rowlen, self.bpp);
|
|
723
|
+
}
|
|
724
|
+
Err(other_error) => return Err(other_error),
|
|
693
725
|
}
|
|
694
726
|
}
|
|
695
727
|
|
|
696
|
-
self.unfiltering_buffer
|
|
728
|
+
self.unfiltering_buffer
|
|
729
|
+
.unfilter_curr_row_in_place(rowlen, self.bpp)
|
|
697
730
|
}
|
|
698
731
|
}
|
|
699
732
|
|