pub struct ConstantQualityGifEncoder { /* private fields */ }Expand description
Constant-quality GIF encoder.
Translates a floating-point quality value into concrete GifEncoderConfig
parameters using a combination of quality tiers and, optionally, content-
adaptive perceptual analysis.
§Example
use oximedia_codec::gif::quality::{ConstantQualityConfig, ConstantQualityGifEncoder};
let cfg = ConstantQualityConfig::new(0.8).non_adaptive();
let enc = ConstantQualityGifEncoder::new(cfg).expect("valid quality");
let params = enc.resolve();
assert!(params.colors() >= 128);Implementations§
Source§impl ConstantQualityGifEncoder
impl ConstantQualityGifEncoder
Sourcepub fn new(config: ConstantQualityConfig) -> CodecResult<Self>
pub fn new(config: ConstantQualityConfig) -> CodecResult<Self>
Create a new constant-quality GIF encoder.
§Errors
Returns CodecError::InvalidParameter when quality is outside [0.0, 1.0]
or min_colors > max_colors.
Sourcepub fn resolve(&self) -> ResolvedGifParams
pub fn resolve(&self) -> ResolvedGifParams
Resolve encoder parameters from quality alone (no content analysis).
Sourcepub fn resolve_with_metrics(
&self,
metrics: &PerceptualMetrics,
) -> ResolvedGifParams
pub fn resolve_with_metrics( &self, metrics: &PerceptualMetrics, ) -> ResolvedGifParams
Resolve encoder parameters using pre-computed PerceptualMetrics.
When config.content_adaptive is false this is identical to Self::resolve.
Sourcepub fn analyse_and_resolve(
&self,
rgba: &[u8],
width: usize,
height: usize,
) -> CodecResult<ResolvedGifParams>
pub fn analyse_and_resolve( &self, rgba: &[u8], width: usize, height: usize, ) -> CodecResult<ResolvedGifParams>
Analyse an RGBA pixel buffer and resolve parameters content-adaptively.
§Errors
Propagates errors from PerceptualMetrics::analyse.
Sourcepub fn tier(&self) -> QualityTier
pub fn tier(&self) -> QualityTier
Quality tier this encoder was created with.
Trait Implementations§
Source§impl Clone for ConstantQualityGifEncoder
impl Clone for ConstantQualityGifEncoder
Source§fn clone(&self) -> ConstantQualityGifEncoder
fn clone(&self) -> ConstantQualityGifEncoder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConstantQualityGifEncoder
impl RefUnwindSafe for ConstantQualityGifEncoder
impl Send for ConstantQualityGifEncoder
impl Sync for ConstantQualityGifEncoder
impl Unpin for ConstantQualityGifEncoder
impl UnsafeUnpin for ConstantQualityGifEncoder
impl UnwindSafe for ConstantQualityGifEncoder
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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