Skip to main content

ImageProcessorConfig

Struct ImageProcessorConfig 

Source
pub struct ImageProcessorConfig {
    pub egl_display: Option<EglDisplayKind>,
    pub backend: ComputeBackend,
    pub colorimetry: ColorimetryMode,
    pub interpolation: Interpolation,
    pub egl_cache_capacity: Option<usize>,
}
Expand description

Configuration for ImageProcessor construction.

Use with ImageProcessor::with_config to override the default EGL display auto-detection and backend selection. The default configuration preserves the existing auto-detection behaviour.

Fields§

§egl_display: Option<EglDisplayKind>

Force OpenGL to use this EGL display type instead of auto-detecting.

When None, the processor probes displays in priority order: GBM, PlatformDevice, Default. Use probe_egl_displays to discover which displays are available on the current system.

Ignored when EDGEFIRST_DISABLE_GL=1 is set, and on macOS and Windows (ANGLE is the only display there — Metal and Direct3D 11 respectively; a Some value logs a debug note and is otherwise ignored).

§backend: ComputeBackend

Preferred compute backend.

When set to a specific backend (not ComputeBackend::Auto), the processor initializes that backend with no fallback — returns an error if the conversion is not supported. This takes precedence over EDGEFIRST_FORCE_BACKEND and the EDGEFIRST_DISABLE_* environment variables.

§colorimetry: ColorimetryMode

Colorimetry/performance trade-off for convert() (see ColorimetryMode). Defaults to ColorimetryMode::Fast. The EDGEFIRST_COLORIMETRY environment variable (fast | exact) overrides this setting when present.

§interpolation: Interpolation

How convert() resamples when the source (or source crop) and the destination differ in size (see Interpolation), for converts whose options do not choose their own (ConvertOptions::interpolation). Defaults to Interpolation::Bilinear. The EDGEFIRST_INTERPOLATION environment variable (nearest | bilinear), read when the processor is created, overrides this setting and every per-convert choice.

§egl_cache_capacity: Option<usize>

How many buffer imports the OpenGL backend keeps cached, per cache.

None (the default) uses EDGEFIRST_EGL_CACHE_CAPACITY if set, and 16 otherwise. Precedence is:

egl_cache_capacity  >  EDGEFIRST_EGL_CACHE_CAPACITY  >  16

Config beats the environment deliberately, matching backend: an embedder that has measured its own pool must not be silently overridden by a stray environment variable in the deployment. Some(0) is rejected and falls through to the environment, then the default, exactly as an unparseable env value does.

§This is a buffer count, not a size

A cached import pins its buffer — the underlying dma-buf or IOSurface cannot be freed while an entry names it (that is what makes the cache correct as well as fast; see the “EGL image cache inside HAL” section of ARCHITECTURE.md). So the memory this holds depends entirely on how big the caller’s buffers are:

worst-case pinned bytes                                (upper bound)
    = capacity x 3 caches x frame size x live ImageProcessors

capacity 16, 640x640 RGB   (1.2 MB)  ->   59 MB per processor
capacity 16, 1080p NV12    (3.1 MB)  ->  149 MB per processor
capacity 16, 4K NV12      (12.4 MB)  ->  597 MB per processor

A ceiling rather than an exact total: the source and NV R8 caches often hold two imports of the same buffer, and two entries naming one buffer pin it once. The per-cache figure is the exact one.

The bound is per ImageProcessor, times three caches (source, destination, and the NV R8 source cache) — not per process and not per library. Two ImageProcessors in one process have six independent caches and six independent capacities. A fourth cache, the chroma-plane views of hardware-filtered NV resizes, has the same capacity but imports only buffers the NV R8 cache also holds, so it adds entries without pinning more memory.

Whether the worst case is ever approached is up to the caller. A pooled producer — V4L2 capture, typically 4–8 buffers over one or two sizes — settles at its pool size and never nears the bound. A stream that allocates a fresh buffer per frame holds the last capacity of them outright, which is the difference between “16 is free” and “16 is 597 MB”.

Size it from measurement rather than guesswork: CacheStats::peak_entries reports the working set actually reached, and CacheStats::evictions tells you when the bound is costing you re-imports (it should be zero in a steady state).

Ignored when the OpenGL backend is not in use.

Trait Implementations§

Source§

impl Clone for ImageProcessorConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImageProcessorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ImageProcessorConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more