// 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.
/// The magic bytes for a bare JPEG XL codestream. pub(crate) const CODESTREAM_SIGNATURE: [u8; 2] = [0xff, 0x0a]; /// The magic bytes for a file using the JPEG XL container format. pub(crate) const CONTAINER_SIGNATURE: [u8; 12] =
[0, 0, 0, 0xc, b'J', b'X', b'L', b' ', 0xd, 0xa, 0x87, 0xa];
for st in [JxlSignatureType::Codestream, JxlSignatureType::Container] { let len = st.signature().len(); // Determine the number of bytes to compare (the length of the shorter slice) let len_to_check = prefix_len.min(len);
if file_prefix[..len_to_check] == st.signature()[..len_to_check] { // The prefix is a valid start. Now, is it complete? returnif prefix_len >= len {
Ok(Some(st))
} else {
Err(Error::OutOfBounds(len - prefix_len))
};
}
} // The prefix doesn't match the start of any known signature.
Ok(None)
}
/// Checks if the given buffer starts with a valid JPEG XL signature. /// /// # Returns /// /// A `ProcessingResult` which is: /// - `Complete(Some(_))` if a full container or codestream signature is found. /// - `Complete(None)` if the prefix is definitively not a JXL signature. /// - `NeedsMoreInput` if the prefix matches a signature but is too short. pubfn check_signature(file_prefix: &[u8]) -> ProcessingResult<Option<JxlSignatureType>, ()> {
ProcessingResult::new(check_signature_internal(file_prefix)).unwrap()
}
signature_test!(
container_with_extra_data,
&{ letmut data = CONTAINER_SIGNATURE.to_vec();
data.extend_from_slice(&[0x11, 0x22, 0x33]);
data
},
Complete(Some(JxlSignatureType::Container))
);
signature_test!(
codestream_with_extra_data,
&{ letmut data = CODESTREAM_SIGNATURE.to_vec();
data.extend_from_slice(&[0x44, 0x55, 0x66]);
data
},
Complete(Some(JxlSignatureType::Codestream))
);
}
Messung V0.5 in Prozent
¤ 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.0.6Bemerkung:
¤
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.