// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
// Convert to slice writer to prevent buffer from growing. // `read_header` above returns buffer with capacity of `output_size`, so this doesn't realloc.
debug_assert_eq!(decoded_profile.capacity(), output_size as usize);
decoded_profile.resize(output_size as usize, 0); letmut decoded_profile_writer = Cursor::new(&mut *decoded_profile);
decoded_profile_writer.set_position(ICC_HEADER_SIZE);
// Decode tag list. let v = read_varint_from_reader(&mut commands_stream)?; iflet Some(num_tags) = v.checked_sub(1) { if (output_size - ICC_HEADER_SIZE) / 12 < num_tags {
warn!(output_size, num_tags, "num_tags too large"); return Err(Error::InvalidIccStream);
}
let num_tags = num_tags as u32;
decoded_profile_writer
.write_u32::<BigEndian>(num_tags)
.map_err(|_| Error::InvalidIccStream)?;
// Decode tag data. // Will not enter the loop if end of stream was reached while decoding tag list. whilelet Ok(command) = commands_stream.read_u8() {
read_single_command(
data_stream,
&mut commands_stream,
&mut decoded_profile_writer,
command,
)?;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.