-
Notifications
You must be signed in to change notification settings - Fork 2
Where to go from Bytes
to DecodingResult
?
#87
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
Comments
impl Tile {
pub fn decode(&self, registry: &DecoderRegistry) -> AsyncTiffResult<DecodingResult> {
let mut res = DecodingResult::from_format_and_bit_depth(self.SampleFormat, self.bits_per_sample(), self.n_output_samples(),)?;
self.decode_into(registry, res.buf_mut())?
Ok(res)
}
/// decode into the **properly sized** buffer
pub fn decode_into(&self, registry: &DecoderRegistry, buf: &mut[u8]) -> AsyncTiffResult {
let decoder = registry[&self.compression_method];
match self.predictor {
Predictor::None => {
decoder.decode_tile(self.compressed_bytes, buf, ..)?;
fix_endianness(buf, ...);
},
Predictor::Horizontal => {
decoder.decode_tile(self.compressed_bytes, buf, ..)?;
unpredict_hdiff(buf, &self.predictor_info, self.x as _);
}
Predictor::Float => {
let mut temp_buf = vec![0u8; buf.len()]
decoder.decode_tile(self.compressed_bytes, &mut temp_buf, ..)?;
unpredict_float(temp_buf, buf, &self.predictor_info, self.x as _, self.y as _)
}
}
}
for buf in bufs {
decoder.read_exact(buf)
} was possible. The benefit is that a user can directly mosaic an entire tile-based image. There's just some bookkeeping involved with splitting the result buffer for the entire image. For a single tile, it is as much as: let bufs: Vec<_> = res.chunks_exact_mut(self.predictor_info.output_row_stride()).collect()
self.decode_into(self, registry, bufs) I think 2 is a lot of effort for marginal speed/memory savings, but haven't benched and then needing to change the decoding trait. I mainly wanted to get these thoughts out on a nice place, can still put it into #86 |
So the three questions in here are:
Some options for 2 and 3 (assuming 1 was a yes):
...maybe options 2 and 3 sidetrack this conversation, we just choose option 1 and go on discussing questions 1 and 4? For Question 4, I thought:
Footnotes
|
In decoding tiles, there is a question of where to go from network-provided
Bytes
to an output typed array (DecodingResult
).This emerged in #86 and is important, but may need some more discussion/other changes. See there for more info.
The text was updated successfully, but these errors were encountered: