pub struct BitstreamStats { /* private fields */ }Expand description
Accumulated bitstream quality statistics.
Call BitstreamStats::update_psnr and/or BitstreamStats::update_ssim
after each encoded frame to accumulate per-frame metrics. Aggregated
averages can then be retrieved via BitstreamStats::mean_psnr and
BitstreamStats::mean_ssim.
Implementations§
Source§impl BitstreamStats
impl BitstreamStats
Sourcepub fn update_psnr(&mut self, orig: &[u8], recon: &[u8], w: u32, h: u32)
pub fn update_psnr(&mut self, orig: &[u8], recon: &[u8], w: u32, h: u32)
Compute and record the PSNR between the original and reconstructed pixel buffers for one frame.
PSNR is computed on the luma (Y) plane:
MSE = sum((orig[i] - recon[i])^2) / (w * h)
PSNR = 10 * log10(255^2 / MSE)An MSE of 0.0 (identical buffers) yields +∞ dB; in that case 100.0
dB is recorded as a practical maximum.
§Parameters
orig– original uncompressed pixel buffer (u8 luma, lengthw * h).recon– reconstructed pixel buffer (same layout asorig).w– frame width in pixels.h– frame height in pixels.
§Panics
Panics if orig.len() != w * h or recon.len() != w * h.
Sourcepub fn mean_psnr(&self) -> Option<f64>
pub fn mean_psnr(&self) -> Option<f64>
Returns the mean PSNR across all recorded frames, or None if no
frames have been processed.
Sourcepub fn min_psnr(&self) -> Option<f64>
pub fn min_psnr(&self) -> Option<f64>
Returns the minimum per-frame PSNR, or None if no frames recorded.
Sourcepub fn max_psnr(&self) -> Option<f64>
pub fn max_psnr(&self) -> Option<f64>
Returns the maximum per-frame PSNR, or None if no frames recorded.
Sourcepub fn update_ssim(&mut self, orig: &[u8], recon: &[u8], w: u32, h: u32)
pub fn update_ssim(&mut self, orig: &[u8], recon: &[u8], w: u32, h: u32)
Compute and record the mean SSIM between original and reconstructed buffers for one frame.
Uses the simplified single-window SSIM formula (per-image, not per-patch) as a fast approximation:
μ_x, μ_y — mean pixel values
σ_x, σ_y — standard deviations
σ_xy — cross-covariance
SSIM = (2μ_xμ_y + C1)(2σ_xy + C2) / ((μ_x²+μ_y²+C1)(σ_x²+σ_y²+C2))with C1 = (0.01 * 255)^2 and C2 = (0.03 * 255)^2.
§Parameters
orig– original pixel buffer (u8 luma, lengthw * h).recon– reconstructed pixel buffer (same layout).w– frame width in pixels.h– frame height in pixels.
§Panics
Panics if orig.len() != w * h or recon.len() != w * h.
Sourcepub fn mean_ssim(&self) -> Option<f64>
pub fn mean_ssim(&self) -> Option<f64>
Returns the mean SSIM across all recorded frames, or None if no
frames have been processed.
Sourcepub fn min_ssim(&self) -> Option<f64>
pub fn min_ssim(&self) -> Option<f64>
Returns the minimum per-frame SSIM, or None if no frames recorded.
Sourcepub fn max_ssim(&self) -> Option<f64>
pub fn max_ssim(&self) -> Option<f64>
Returns the maximum per-frame SSIM, or None if no frames recorded.
Sourcepub fn psnr_frame_count(&self) -> u64
pub fn psnr_frame_count(&self) -> u64
Returns the number of frames that contributed to PSNR statistics.
Sourcepub fn ssim_frame_count(&self) -> u64
pub fn ssim_frame_count(&self) -> u64
Returns the number of frames that contributed to SSIM statistics.
Trait Implementations§
Source§impl Clone for BitstreamStats
impl Clone for BitstreamStats
Source§fn clone(&self) -> BitstreamStats
fn clone(&self) -> BitstreamStats
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BitstreamStats
impl Debug for BitstreamStats
Source§impl Default for BitstreamStats
impl Default for BitstreamStats
Source§fn default() -> BitstreamStats
fn default() -> BitstreamStats
Auto Trait Implementations§
impl Freeze for BitstreamStats
impl RefUnwindSafe for BitstreamStats
impl Send for BitstreamStats
impl Sync for BitstreamStats
impl Unpin for BitstreamStats
impl UnsafeUnpin for BitstreamStats
impl UnwindSafe for BitstreamStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more