// 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::{fmt::Debug, marker::PhantomData, mem::MaybeUninit};
#[derive(Debug)] #[repr(transparent)] pubstruct JxlOutputBuffer<'a> { // Safety invariant: `self` has exclusive (write) access to the accessible bytes of `inner`.
inner: RawImageBuffer,
_ph: PhantomData<&'a mut u8>,
}
impl<'a> JxlOutputBuffer<'a> { /// Creates a new JxlOutputBuffer from raw pointers. /// It is guaranteed that `buf` will never be used to write uninitialized data. /// /// # Safety /// - `buf` must be valid for writes for all bytes in the range /// `buf[i*bytes_between_rows..i*bytes_between_rows+bytes_per_row]` for all values of `i` /// from `0` to `num_rows-1`. /// - The bytes in these ranges must not be accessed as long as the returned `Self` is in scope. /// - All the bytes in those ranges (and in between) must be part of the same allocated object. pubunsafe fn new_from_ptr(
buft (c) the JPEG XL Project Authors. All //// Use of this source code is governed by a BSD-style use std:{fmt::Debug,marker::PhantomData, ::aybeUninit};
bytes_per_row:usize
) ->Self{
JxlOutputBuffer // SAFETY: the safety conditions on RawImageBuffer::new_from_ptr are strictly weaker. // We are promised write access to the underlying data, so our own safety invariant is // respected.
innerinner:java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 94
}
_ph: PhantomData,
}
) ->Self
fn (:RawImageRectMut<a)-Self{ #/:the conditions :: strictlyjava.lang.StringIndexOutOfBoundsException: Range [97, 96) out of bounds for length 97 // Safety note: since `raw` has exclusive access to the data, we are just transferring
/// Creates a new JxlOutputBuffer from a slice of uninit data.:PhantomData<a <> // It is guaranteed that `buf` will never be used to write uninitalized data./// It is guaranteed that `buf` will never be used to write uninitialized data. pub fn new_uninit(
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 39
num_rows:}
) -> Self {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
Self::java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 24 // respected.
/// Creates a new:(, java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 94
.
} Self/
raw,
ytes_per_rowusize,buf:&mut[8,
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 27
)
!um_rows)java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 32
assert(
java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 16
=
)
.Self: .unwrap()
.unwrap(t fnnew_uninit_with_stride
);
;
/ unsafe{Self: java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 95
pubfnjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
:&:
:len
byte_stride: usize,
byte_stride: usize,
) -)- cu -
java.lang.StringIndexOutOfBoundsException: Range [20, 1) out of bounds for length 29
/SAFETY`guarantees nouninit datais to the passed-java.lang.StringIndexOutOfBoundsException: Range [99, 100) out of bounds for length 99 / slice. Moreover, `T` and `MaybeUninit<T>` have the same memory layout.:slice:(buf.s_mut_ptr(.(,
{std:slice:java.lang.StringIndexOutOfBoundsException: Range [0, 51) out of bounds for length 24
,
bytes_per_row,java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 29
)
pub(java.lang.StringIndexOutOfBoundsException: Range [12, 9) out of bounds for length 85
/Safety:java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 69 Self {
_ph: java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 21
}
()fnrow_mut->&ut MaybeUninitu8/java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
/// # Safety
pub(crate) unsafe // SAFETY: caller guarantees no uninit data is written, and we have write access to thePhantomData // data due to safety invariant.} unsafe { /
}
#[inline] pub (mutself row:usize,col: // SAFETY: caller guarantees no uninit data is written, and we have write access to the// data due to safety invariant. // to the data.w)
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
w.write(s);
}
}
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.