mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add png_decode comments
This commit is contained in:
parent
76bb796610
commit
d96faec4eb
2 changed files with 20 additions and 4 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
|
@ -1209,7 +1209,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide 0.5.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1387,6 +1387,7 @@ dependencies = [
|
||||||
"locales",
|
"locales",
|
||||||
"log",
|
"log",
|
||||||
"log-server",
|
"log-server",
|
||||||
|
"miniz_oxide 0.4.4",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"qrcode",
|
"qrcode",
|
||||||
|
|
@ -2049,6 +2050,16 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
|
||||||
|
dependencies = [
|
||||||
|
"adler",
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
|
@ -2477,7 +2488,7 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"deflate",
|
"deflate",
|
||||||
"miniz_oxide",
|
"miniz_oxide 0.5.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,7 @@ impl<R: Read> DecodePng<R> {
|
||||||
// png filter specification calls for initial prior_line = [0u8]
|
// png filter specification calls for initial prior_line = [0u8]
|
||||||
// see: https://www.w3.org/TR/PNG/#9Filters
|
// see: https://www.w3.org/TR/PNG/#9Filters
|
||||||
// but [0u8] results in distortion???????
|
// but [0u8] results in distortion???????
|
||||||
|
// TODO fix this properly (probably a byte overflow or bad cast)
|
||||||
self.prior_line = vec![125u8; self.bytes_per_line];
|
self.prior_line = vec![125u8; self.bytes_per_line];
|
||||||
self.prior_px = vec![0u8; self.bytes_per_pixel];
|
self.prior_px = vec![0u8; self.bytes_per_pixel];
|
||||||
}
|
}
|
||||||
|
|
@ -425,7 +426,7 @@ impl<R: Read> DecodePng<R> {
|
||||||
self.inflated_index += 1;
|
self.inflated_index += 1;
|
||||||
if filter_type <= 4 {
|
if filter_type <= 4 {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"png decode prior_line {} filter type = {}",
|
"png decode line {} filter type = {}",
|
||||||
self.byte_index / self.bytes_per_line,
|
self.byte_index / self.bytes_per_line,
|
||||||
filter_type
|
filter_type
|
||||||
);
|
);
|
||||||
|
|
@ -440,6 +441,7 @@ impl<R: Read> DecodePng<R> {
|
||||||
|
|
||||||
// Get an inflated byte from the png idat
|
// Get an inflated byte from the png idat
|
||||||
// Note: this fn() updates inflated_index, byte_index, line_index & filter_type
|
// Note: this fn() updates inflated_index, byte_index, line_index & filter_type
|
||||||
|
// a scanline of rgb begins with a filterbyte FRGBRGBRGBRGB...
|
||||||
fn get_inflated_byte(&mut self) -> Option<u8> {
|
fn get_inflated_byte(&mut self) -> Option<u8> {
|
||||||
match self.inflated_length() {
|
match self.inflated_length() {
|
||||||
0 => None,
|
0 => None,
|
||||||
|
|
@ -462,6 +464,9 @@ impl<R: Read> DecodePng<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// in the notation from https://www.w3.org/TR/PNG/#9Filters
|
// in the notation from https://www.w3.org/TR/PNG/#9Filters
|
||||||
|
// note that a & c relate to the equivalent byte in the prior pixel
|
||||||
|
// prior_line R G B R G B c G B b G B R G B
|
||||||
|
// current_line R G B R G B a G B x
|
||||||
fn unfilter(&mut self) -> Option<u8> {
|
fn unfilter(&mut self) -> Option<u8> {
|
||||||
let filter = self.filter_type;
|
let filter = self.filter_type;
|
||||||
let index = self.line_index;
|
let index = self.line_index;
|
||||||
|
|
@ -497,7 +502,7 @@ impl<R: Read> DecodePng<R> {
|
||||||
|
|
||||||
// in the notation from https://www.w3.org/TR/PNG/#9Filters
|
// in the notation from https://www.w3.org/TR/PNG/#9Filters
|
||||||
fn average(a: u8, b: u8) -> u8 {
|
fn average(a: u8, b: u8) -> u8 {
|
||||||
((a as i16 + b as i16) >> 1) as u8
|
((a as u16 + b as u16) >> 1) as u8
|
||||||
}
|
}
|
||||||
|
|
||||||
// in the notation from https://www.w3.org/TR/PNG/#9Filters
|
// in the notation from https://www.w3.org/TR/PNG/#9Filters
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue