Skip to content

Commit

Permalink
Add some more #[must_use]
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbiedert committed Apr 4, 2024
1 parent c7187d2 commit 0dee7d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions openh264/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ unsafe impl Sync for DecoderRawAPI {}
///
/// Setting missing? Please file a PR!
#[derive(Default, Copy, Clone, Debug)]
#[must_use]
pub struct DecoderConfig {
params: SDecodingParam,
num_threads: DECODER_OPTION,
Expand Down
1 change: 1 addition & 0 deletions openh264/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl Default for SpsPpsStrategy {
///
/// Setting missing? Please file a PR!
#[derive(Default, Copy, Clone, Debug)]
#[must_use]
pub struct EncoderConfig {
enable_skip_frame: bool,
target_bitrate: u32,
Expand Down
7 changes: 7 additions & 0 deletions openh264/src/formats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,36 @@ pub use rgb2yuv::YUVBuffer;
/// Allows the [Encoder](crate::encoder::Encoder) to be generic over a YUV source.
pub trait YUVSource {
/// Size of the image as `(w, h)`.
#[must_use]
fn dimension(&self) -> (i32, i32);

/// YUV strides as `(y, u, v)`.
///
/// For now you should make sure `u == v`.
#[must_use]
fn strides(&self) -> (i32, i32, i32);

/// Y buffer, should be of size `dimension.1 * strides.0`.
#[must_use]
fn y(&self) -> &[u8];

/// U buffer, should be of size `dimension.1 * strides.1`.
#[must_use]
fn u(&self) -> &[u8];

/// V buffer, should be of size `dimension.1 * strides.2`.
#[must_use]
fn v(&self) -> &[u8];

/// Estimates how many bytes you'll need to store this YUV as RGB.
#[must_use]
fn estimate_rgb_size(&self) -> usize {
let (w, h) = self.dimension();
w as usize * h as usize * 3
}

/// Estimates how many bytes you'll need to store this YUV as RGBA.
#[must_use]
fn estimate_rgba_size(&self) -> usize {
let (w, h) = self.dimension();
w as usize * h as usize * 4
Expand Down

0 comments on commit 0dee7d7

Please sign in to comment.