Arm Framebuffer Compression (AFBC)

AFBC is a proprietary lossless image compression protocol and format.It provides fine-grained random access and minimizes the amount ofdata transferred between IP blocks.

AFBC can be enabled on drivers which support it via use of the AFBCformat modifiers defined in drm_fourcc.h. See DRM_FORMAT_MOD_ARM_AFBC(*).

All users of the AFBC modifiers must follow the usage guidelines laidout in this document, to ensure compatibility across different AFBCproducers and consumers.

Components and Ordering

AFBC streams can contain several components - where a componentcorresponds to a color channel (i.e. R, G, B, X, A, Y, Cb, Cr).The assignment of input/output color channels must be consistentbetween the encoder and the decoder for correct operation, otherwisethe consumer will interpret the decoded data incorrectly.

Furthermore, when the lossless colorspace transform is used(AFBC_FORMAT_MOD_YTR, which should be enabled for RGB buffers formaximum compression efficiency), the component order must be:

  • Component 0: R
  • Component 1: G
  • Component 2: B

The component ordering is communicated via the fourcc code in thefourcc:modifier pair. In general, component ‘0’ is considered toreside in the least-significant bits of the corresponding linearformat. For example, COMP(bits):

  • DRM_FORMAT_ABGR8888
    • Component 0: R(8)
    • Component 1: G(8)
    • Component 2: B(8)
    • Component 3: A(8)
  • DRM_FORMAT_BGR888
    • Component 0: R(8)
    • Component 1: G(8)
    • Component 2: B(8)
  • DRM_FORMAT_YUYV
    • Component 0: Y(8)
    • Component 1: Cb(8, 2x1 subsampled)
    • Component 2: Cr(8, 2x1 subsampled)

In AFBC, ‘X’ components are not treated any differently from any othercomponent. Therefore, an AFBC buffer with fourcc DRM_FORMAT_XBGR8888encodes with 4 components, like so:

  • DRM_FORMAT_XBGR8888
    • Component 0: R(8)
    • Component 1: G(8)
    • Component 2: B(8)
    • Component 3: X(8)

Please note, however, that the inclusion of a “wasted” ‘X’ channel isbad for compression efficiency, and so it’s recommended to avoidformats containing ‘X’ bits. If a fourth component isrequired/expected by the encoder/decoder, then it is recommended toinstead use an equivalent format with alpha, setting all alpha bits to‘1’. If there is no requirement for a fourth component, then a formatwhich doesn’t include alpha can be used, e.g. DRM_FORMAT_BGR888.

Number of Planes

Formats which are typically multi-planar in linear layouts (e.g. YUV420), can be encoded into one, or multiple, AFBC planes. As withcomponent order, the encoder and decoder must agree about the numberof planes in order to correctly decode the buffer. The fourcc code isused to determine the number of encoded planes in an AFBC buffer,matching the number of planes for the linear (unmodified) format.Within each plane, the component ordering also follows the fourcccode:

For example:

  • DRM_FORMAT_YUYV: nplanes = 1
    • Plane 0:
      • Component 0: Y(8)
      • Component 1: Cb(8, 2x1 subsampled)
      • Component 2: Cr(8, 2x1 subsampled)
  • DRM_FORMAT_NV12: nplanes = 2
    • Plane 0:
      • Component 0: Y(8)
    • Plane 1:
      • Component 0: Cb(8, 2x1 subsampled)
      • Component 1: Cr(8, 2x1 subsampled)

Cross-device interoperability

For maximum compatibility across devices, the table below definescanonical formats for use between AFBC-enabled devices. Formats whichare listed here must be used exactly as specified when using the AFBCmodifiers. Formats which are not listed should be avoided.

AFBC formats
Fourcc codeDescriptionPlanes/Components
DRM_FORMAT_ABGR210101010-bit per component RGB, with 2-bit alpha
Plane 0: 4 components
  • Component 0: R(10)
  • Component 1: G(10)
  • Component 2: B(10)
  • Component 3: A(2)
DRM_FORMAT_ABGR88888-bit per component RGB, with 8-bit alpha
Plane 0: 4 components
  • Component 0: R(8)
  • Component 1: G(8)
  • Component 2: B(8)
  • Component 3: A(8)
DRM_FORMAT_BGR8888-bit per component RGB
Plane 0: 3 components
  • Component 0: R(8)
  • Component 1: G(8)
  • Component 2: B(8)
DRM_FORMAT_BGR5655/6-bit per component RGB
Plane 0: 3 components
  • Component 0: R(5)
  • Component 1: G(6)
  • Component 2: B(5)
DRM_FORMAT_ABGR15555-bit per component RGB, with 1-bit alpha
Plane 0: 4 components
  • Component 0: R(5)
  • Component 1: G(5)
  • Component 2: B(5)
  • Component 3: A(1)
DRM_FORMAT_VUY8888-bit per component YCbCr 444, single plane
Plane 0: 3 components
  • Component 0: Y(8)
  • Component 1: Cb(8)
  • Component 2: Cr(8)
DRM_FORMAT_VUY10101010-bit per component YCbCr 444, single plane
Plane 0: 3 components
  • Component 0: Y(10)
  • Component 1: Cb(10)
  • Component 2: Cr(10)
DRM_FORMAT_YUYV8-bit per component YCbCr 422, single plane
Plane 0: 3 components
  • Component 0: Y(8)
  • Component 1: Cb(8, 2x1 subsampled)
  • Component 2: Cr(8, 2x1 subsampled)
DRM_FORMAT_NV168-bit per component YCbCr 422, two plane
Plane 0: 1 component
  • Component 0: Y(8)
Plane 1: 2 components
  • Component 0: Cb(8, 2x1 subsampled)
  • Component 1: Cr(8, 2x1 subsampled)
DRM_FORMAT_Y21010-bit per component YCbCr 422, single plane
Plane 0: 3 components
  • Component 0: Y(10)
  • Component 1: Cb(10, 2x1 subsampled)
  • Component 2: Cr(10, 2x1 subsampled)
DRM_FORMAT_P21010-bit per component YCbCr 422, two plane
Plane 0: 1 component
  • Component 0: Y(10)
Plane 1: 2 components
  • Component 0: Cb(10, 2x1 subsampled)
  • Component 1: Cr(10, 2x1 subsampled)
DRM_FORMAT_YUV420_8BIT8-bit per component YCbCr 420, single plane
Plane 0: 3 components
  • Component 0: Y(8)
  • Component 1: Cb(8, 2x2 subsampled)
  • Component 2: Cr(8, 2x2 subsampled)
DRM_FORMAT_YUV420_10BIT10-bit per component YCbCr 420, single plane
Plane 0: 3 components
  • Component 0: Y(10)
  • Component 1: Cb(10, 2x2 subsampled)
  • Component 2: Cr(10, 2x2 subsampled)
DRM_FORMAT_NV128-bit per component YCbCr 420, two plane
Plane 0: 1 component
  • Component 0: Y(8)
Plane 1: 2 components
  • Component 0: Cb(8, 2x2 subsampled)
  • Component 1: Cr(8, 2x2 subsampled)
DRM_FORMAT_P01010-bit per component YCbCr 420, two plane
Plane 0: 1 component
  • Component 0: Y(10)
Plane 1: 2 components
  • Component 0: Cb(10, 2x2 subsampled)
  • Component 1: Cr(10, 2x2 subsampled)