pub struct FormatNegotiator<'a, F> {
pub decoder_produces: &'a [F],
pub encoder_accepts: &'a [F],
}Expand description
Automatically selects the best PixelFormat or SampleFormat that
bridges what a decoder produces and what an encoder accepts.
The negotiator first looks for a direct match (zero-cost); if none
exists it picks the conversion with the lowest cost as determined by
FormatCost::conversion_cost. If no conversion path exists it returns
FormatConversionResult::Incompatible.
§Examples
use oximedia_core::codec_negotiation::{FormatNegotiator, FormatConversionResult};
use oximedia_core::types::PixelFormat;
let neg = FormatNegotiator::<PixelFormat> {
decoder_produces: &[PixelFormat::Yuv422p],
encoder_accepts: &[PixelFormat::Yuv420p],
};
match neg.negotiate() {
FormatConversionResult::Convert { from, to, cost } => {
assert_eq!(from, PixelFormat::Yuv422p);
assert_eq!(to, PixelFormat::Yuv420p);
assert!(cost >= 1);
}
other => panic!("unexpected: {other:?}"),
}Fields§
§decoder_produces: &'a [F]Pixel / sample formats the decoder is able to output.
encoder_accepts: &'a [F]Pixel / sample formats the encoder is able to accept as input.
Implementations§
Source§impl<F> FormatNegotiator<'_, F>where
F: FormatCost + Debug,
impl<F> FormatNegotiator<'_, F>where
F: FormatCost + Debug,
Sourcepub fn negotiate(&self) -> FormatConversionResult<F>
pub fn negotiate(&self) -> FormatConversionResult<F>
Runs the negotiation and returns the best FormatConversionResult.
Auto Trait Implementations§
impl<'a, F> Freeze for FormatNegotiator<'a, F>
impl<'a, F> RefUnwindSafe for FormatNegotiator<'a, F>where
F: RefUnwindSafe,
impl<'a, F> Send for FormatNegotiator<'a, F>where
F: Sync,
impl<'a, F> Sync for FormatNegotiator<'a, F>where
F: Sync,
impl<'a, F> Unpin for FormatNegotiator<'a, F>
impl<'a, F> UnsafeUnpin for FormatNegotiator<'a, F>
impl<'a, F> UnwindSafe for FormatNegotiator<'a, F>where
F: RefUnwindSafe,
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