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: ComputeBackendPreferred 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.
ComputeBackend::OpenGl: init OpenGL + CPU, skip G2DComputeBackend::G2d: init G2D + CPU, skip OpenGLComputeBackend::Cpu: init CPU onlyComputeBackend::Auto: existing env-var-driven selection
colorimetry: ColorimetryModeColorimetry/performance trade-off for convert() (see
ColorimetryMode). Defaults to ColorimetryMode::Fast. The
EDGEFIRST_COLORIMETRY environment variable (fast | exact)
overrides this setting when present.
interpolation: InterpolationHow convert() resamples when the source (or source crop) and the
destination differ in size (see Interpolation). Defaults to
Interpolation::Bilinear. The EDGEFIRST_INTERPOLATION environment
variable (nearest | bilinear) overrides this setting when present.
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 > 16Config 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 processorA 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
impl Clone for ImageProcessorConfig
Source§impl Debug for ImageProcessorConfig
impl Debug for ImageProcessorConfig
Auto Trait Implementations§
impl Freeze for ImageProcessorConfig
impl RefUnwindSafe for ImageProcessorConfig
impl Send for ImageProcessorConfig
impl Sync for ImageProcessorConfig
impl Unpin for ImageProcessorConfig
impl UnsafeUnpin for ImageProcessorConfig
impl UnwindSafe for ImageProcessorConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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