![]() |
Axoverlay 2 API
|
Image compression is any technique that reduces the information density of the image.
Compression can be lossless or lossy. Compression may reduce the physical storage size of an image in memory, or only the amount of stored data that need to be transferred (bandwidth compression).
Compression improves performance, both at the producer and consumer end of the pipeline. Both the producer and the consumer need to have support for the selected compression scheme.
By default, Axoverlay works with uncompressed images. When the platform supports compression, it may be enabled in Axoverlay at the user's option.
Note that different platforms support different schemes of compression, or sometimes no compression at all. To abstract over this, the user does not explicitly select a compression scheme. Rather, the user describes the rendering intent and Axoverlay suggests a supported compression scheme when applicable:
axo_detailed_format *detailed_format = axo_suggest_detailed_format(AXO_FORMAT_ARGB32,
AXO_FORMAT_FLAGS_COMPRESSED | AXO_FORMAT_FLAGS_GPU, &err);
If there is no available compression, an uncompressed format will simply be returned.
When an overlay is created, the desired detailed format shall be selected:
axo_props_set_detailed_format(props, detailed_format);
After this, Axoverlay configures the consumer end of the pipeline to expect data compressed according to that detailed format.
It is up to the user to ensure that overlay images are drawn in the correct format. Assuming that a GPU will be used to render the images, the GPU needs to be set up to use the correct compression. This is done using industry-standard APIs such as EGL. These APIs have extensions to set "modifiers" when importing buffers, to indicate a compressed format. The relevant extensions to EGL are EGL_EXT_image_dma_buf_import.txt and EGL_EXT_image_dma_buf_import_modifiers.txt.
Axoverlay contains helper functions to retrieve the correct values to pass to EGL for a particular detailed format:
uint32_t fourcc = axo_detailed_format_get_drm_fourcc(detailed_format);
uint64_t modifier = axo_detailed_format_get_drm_modifier(detailed_format, 0);
const EGLint image_attribs[] = {
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, modifier & 0xFFFFFFFF,
EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, modifier >> 32,
...
EGL_NONE
};
These APIs work for uncompressed formats as well.
For more details, refer to the official EGL documentation and to the example programs distributed with Axoverlay.
It is recommended to enable compression whenever the GPU is used for rendering.
If you experience reduced frame rate while using compression, turning compression off may help, as compression could potentially result in lower frame rate in certain overlay-heavy scenarios.