Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos. #485

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Added `new_with_info` constructor for encoder.
* Removed hard-coded memory limits.
* No longer allow zero sized images.
* Added `Reader::finish` to read all the auxillary chunks that comes after the
* Added `Reader::finish` to read all the auxiliary chunks that comes after the
image.

## 0.17.10
Expand Down
4 changes: 2 additions & 2 deletions examples/pngcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn final_channels(c: png::ColorType, trns: bool) -> u8 {
}
}
fn check_image<P: AsRef<Path>>(c: Config, fname: P) -> io::Result<()> {
// TODO improve performance by resusing allocations from decoder
// TODO improve performance by reusing allocations from decoder
use png::Decoded::*;
let mut t = term::stdout()
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "could not open terminal"))?;
Expand Down Expand Up @@ -252,7 +252,7 @@ fn check_image<P: AsRef<Path>>(c: Config, fname: P) -> io::Result<()> {
}
print!(
" at offset {:#07x}, length {}",
pos - 4, // substract chunk name length
pos - 4, // subtract chunk name length
len
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub(crate) mod transform;
mod zlib;

pub use self::stream::{DecodeOptions, Decoded, DecodingError, StreamingDecoder};
use self::stream::{FormatErrorInner, CHUNCK_BUFFER_SIZE};
use self::stream::{FormatErrorInner, CHUNK_BUFFER_SIZE};
use self::transform::{create_transform_fn, TransformFn};

use std::io::{BufRead, BufReader, Read};
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<R: Read> Decoder<R> {

Decoder {
read_decoder: ReadDecoder {
reader: BufReader::with_capacity(CHUNCK_BUFFER_SIZE, r),
reader: BufReader::with_capacity(CHUNK_BUFFER_SIZE, r),
decoder,
at_eof: false,
},
Expand All @@ -163,7 +163,7 @@ impl<R: Read> Decoder<R> {

Decoder {
read_decoder: ReadDecoder {
reader: BufReader::with_capacity(CHUNCK_BUFFER_SIZE, r),
reader: BufReader::with_capacity(CHUNK_BUFFER_SIZE, r),
decoder,
at_eof: false,
},
Expand Down
13 changes: 8 additions & 5 deletions src/decoder/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::traits::ReadBytesExt;
use crate::Limits;

/// TODO check if these size are reasonable
pub const CHUNCK_BUFFER_SIZE: usize = 32 * 1024;
pub const CHUNK_BUFFER_SIZE: usize = 32 * 1024;

/// Determines if checksum checks should be disabled globally.
///
Expand Down Expand Up @@ -314,7 +314,7 @@ impl fmt::Display for FormatError {
"Transparency chunk found for color type {:?}.",
color_type
),
InvalidBitDepth(nr) => write!(fmt, "Invalid dispose operation {}.", nr),
InvalidBitDepth(nr) => write!(fmt, "Invalid bit depth {}.", nr),
InvalidColorType(nr) => write!(fmt, "Invalid color type {}.", nr),
InvalidDisposeOp(nr) => write!(fmt, "Invalid dispose op {}.", nr),
InvalidBlendOp(nr) => write!(fmt, "Invalid blend op {}.", nr),
Expand All @@ -327,7 +327,10 @@ impl fmt::Display for FormatError {
InvalidSignature => write!(fmt, "Invalid PNG signature."),
UnexpectedEof => write!(fmt, "Unexpected end of data before image end."),
UnexpectedEndOfChunk => write!(fmt, "Unexpected end of data within a chunk."),
NoMoreImageData => write!(fmt, "IDAT or fDAT chunk is has not enough data for image."),
NoMoreImageData => write!(
fmt,
"IDAT or fDAT chunk does not have enough data for image."
),
CorruptFlateStream { err } => {
write!(fmt, "Corrupt deflate stream. ")?;
write!(fmt, "{:?}", err)
Expand Down Expand Up @@ -1499,7 +1502,7 @@ impl Default for ChunkState {
type_: ChunkType([0; 4]),
crc: Crc32::new(),
remaining: 0,
raw_bytes: Vec::with_capacity(CHUNCK_BUFFER_SIZE),
raw_bytes: Vec::with_capacity(CHUNK_BUFFER_SIZE),
}
}
}
Expand Down Expand Up @@ -1939,7 +1942,7 @@ mod tests {
panic!("No fcTL (2nd frame)");
};
// The sequence number is taken from the `fcTL` chunk that comes before the two `fdAT`
// chunks. Note that sequence numbers inside `fdAT` chunks are not publically exposed
// chunks. Note that sequence numbers inside `fdAT` chunks are not publicly exposed
// (but they are still checked when decoding to verify that they are sequential).
assert_eq!(frame_control.sequence_number, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/decoder/transform/palette.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Helpers for taking a slice of indeces (indices into `PLTE` and/or `trNS`
//! Helpers for taking a slice of indices (indices into `PLTE` and/or `trNS`
//! entries) and transforming this into RGB or RGBA output.
//!
//! # Memoization
Expand Down
6 changes: 3 additions & 3 deletions src/decoder/zlib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{stream::FormatErrorInner, DecodingError, CHUNCK_BUFFER_SIZE};
use super::{stream::FormatErrorInner, DecodingError, CHUNK_BUFFER_SIZE};

use fdeflate::Decompressor;

Expand Down Expand Up @@ -166,7 +166,7 @@ impl ZlibStream {
let current_len = self.out_buffer.len();
let desired_len = self
.out_pos
.saturating_add(CHUNCK_BUFFER_SIZE)
.saturating_add(CHUNK_BUFFER_SIZE)
.min(self.max_total_output);
if current_len >= desired_len {
return;
Expand All @@ -182,7 +182,7 @@ impl ZlibStream {
// allocation is valid and that any cursor within it will be valid.
len
// This keeps the buffer size a power-of-two, required by miniz_oxide.
.saturating_add(CHUNCK_BUFFER_SIZE.max(len))
.saturating_add(CHUNK_BUFFER_SIZE.max(len))
// Ensure all buffer indices are valid cursor positions.
// Note: both cut off and zero extension give correct results.
.min(u64::max_value() as usize)
Expand Down
6 changes: 3 additions & 3 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl<'a, W: Write> Encoder<'a, W> {
///
/// If the denominator is 0, it is to be treated as if it were 100
/// (that is, the numerator then specifies 1/100ths of a second).
/// If the the value of the numerator is 0 the decoder should render the next frame
/// If the value of the numerator is 0 the decoder should render the next frame
/// as quickly as possible, though viewers may impose a reasonable lower bound.
///
/// The default value is 0 for both the numerator and denominator.
Expand Down Expand Up @@ -846,7 +846,7 @@ impl<W: Write> Writer<W> {
///
/// If the denominator is 0, it is to be treated as if it were 100
/// (that is, the numerator then specifies 1/100ths of a second).
/// If the the value of the numerator is 0 the decoder should render the next frame
/// If the value of the numerator is 0 the decoder should render the next frame
/// as quickly as possible, though viewers may impose a reasonable lower bound.
///
/// This method will return an error if the image is not animated.
Expand Down Expand Up @@ -1393,7 +1393,7 @@ impl<'a, W: Write> StreamWriter<'a, W> {
///
/// If the denominator is 0, it is to be treated as if it were 100
/// (that is, the numerator then specifies 1/100ths of a second).
/// If the the value of the numerator is 0 the decoder should render the next frame
/// If the value of the numerator is 0 the decoder should render the next frame
/// as quickly as possible, though viewers may impose a reasonable lower bound.
///
/// This method will return an error if the image is not animated.
Expand Down
4 changes: 2 additions & 2 deletions src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod simd {

/// This is an equivalent of the `PaethPredictor` function from
/// [the spec](http://www.libpng.org/pub/png/spec/1.2/PNG-Filters.html#Filter-type-4-Paeth)
/// except that it simultaenously calculates the predictor for all SIMD lanes.
/// except that it simultaneously calculates the predictor for all SIMD lanes.
/// Mapping between parameter names and pixel positions can be found in
/// [a diagram here](https://www.w3.org/TR/png/#filter-byte-positions).
///
Expand Down Expand Up @@ -777,7 +777,7 @@ fn filter_internal(
) -> FilterType {
use self::FilterType::*;

// This value was chosen experimentally based on what acheived the best performance. The
// This value was chosen experimentally based on what achieved the best performance. The
// Rust compiler does auto-vectorization, and 32-bytes per loop iteration seems to enable
// the fastest code when doing so.
const CHUNK_SIZE: usize = 32;
Expand Down
Loading