mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-29 12:38:58 -06:00
* M2: normalize JPEG2000 samples without overflowing Use bounded integer sample scaling for 1-32-bit JPX images and reject empty dimensions before chunking. Cover public decoding and continued page rendering with synthetic regressions. Co-Authored-By: OpenAI Codex <codex@openai.com> * ROADMAP: keep the JPX entry with this session's entries --------- Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
37 lines
736 B
Rust
37 lines
736 B
Rust
// Note that these polyfills can be very imprecise, but hopefully good enough
|
|
// for the vast majority of cases.
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn trunc_f64(x: f64) -> f64 {
|
|
#[cfg(feature = "std")]
|
|
{
|
|
x.trunc()
|
|
}
|
|
#[cfg(not(feature = "std"))]
|
|
{
|
|
x as i64 as f64
|
|
}
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn powi_f64(x: f64, n: u32) -> f64 {
|
|
#[cfg(feature = "std")]
|
|
{
|
|
x.powi(n as i32)
|
|
}
|
|
#[cfg(not(feature = "std"))]
|
|
{
|
|
let mut result = 1.0;
|
|
let mut base = x;
|
|
let mut exp = n;
|
|
while exp > 0 {
|
|
if exp & 1 == 1 {
|
|
result *= base;
|
|
}
|
|
base *= base;
|
|
exp >>= 1;
|
|
}
|
|
result
|
|
}
|
|
}
|