cvedia::rt::iface::JpegEncoder¶
Interface for JPEG encoders. More...
#include <jpeg_encoder.h>
Public Functions¶
| Name | |
|---|---|
| virtual | ~JpegEncoder() =default |
| virtual expected< std::vector< uint8_t > > | encode(cbuffer const & buffer, int quality =85) =0 Encode a buffer to JPEG format. |
| virtual expected< std::vector< uint8_t > > | encode(BufferBackend const * backend, int quality =85) =0 Encode a buffer backend directly to JPEG format. |
| virtual std::string | getTransportUri() const =0 Get the transport URI this encoder is registered for. |
| virtual bool | isZeroCopy() const =0 Check if this encoder supports zero-copy encoding. |
Detailed Description¶
class cvedia::rt::iface::JpegEncoder;
Interface for JPEG encoders.
Provides a unified interface for hardware-accelerated (VPL, NVENC) and software (libjpeg-turbo) JPEG encoding. Encoders are registered against transport URIs and automatically selected based on buffer location for zero-copy encoding.
Usage:
auto encoder = JpegEncoderRegistry::getEncoder(buffer->getTransportUri());
auto jpeg = encoder->encode(buffer, 85); // Blocks until worker available
Public Functions Documentation¶
function ~JpegEncoder¶
virtual ~JpegEncoder() =default
function encode¶
virtual expected< std::vector< uint8_t > > encode(
cbuffer const & buffer,
int quality =85
) =0
Encode a buffer to JPEG format.
Parameters:
- buffer Input buffer to encode (NV12 format expected)
- quality JPEG quality (1-100, default 85)
Return: JPEG-encoded bytes on success, error code on failure
Blocks until a worker is available from the encoder's pool, then encodes synchronously. For hardware encoders, this attempts zero-copy encoding when the buffer is on a compatible surface (D3D11, VAAPI).
Thread-safe: Multiple threads can call encode() concurrently; the worker pool serializes access to hardware encoder sessions.
function encode¶
virtual expected< std::vector< uint8_t > > encode(
BufferBackend const * backend,
int quality =85
) =0
Encode a buffer backend directly to JPEG format.
Parameters:
- backend Input buffer backend to encode
- quality JPEG quality (1-100, default 85)
Return: JPEG-encoded bytes on success, error code on failure
Backend-level encoding for use within buffer plugins. Allows encoding without requiring a Buffer wrapper (cbuffer).
function getTransportUri¶
virtual std::string getTransportUri() const =0
Get the transport URI this encoder is registered for.
Return: Transport URI (e.g., "opencl://0-0", "vaapi://0", "cpu://")
function isZeroCopy¶
virtual bool isZeroCopy() const =0
Check if this encoder supports zero-copy encoding.
Return: true if the encoder can encode directly from GPU memory without downloading to CPU first, false for software encoders