The open imaging DSP library
Loading...
Searching...
No Matches
Macros | Functions
mpix/formats.h

Formats definition. More...

Macros

#define MPIX_FOURCC_TO_STR(fourcc)
 Generate a string out of a pixel format.
 
#define MPIX_FOURCC(a, b, c, d)    ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
 Define a new pixel format, with defaults for most common values.
 

Functions

uint8_t mpix_bits_per_pixel_cb (uint32_t fourcc)
 Callback for the application to add custom pixel formats.
 

RGB formats

Formats with red, green, blue channels, each pixel contain each channel.

#define MPIX_FMT_RGB332   MPIX_FOURCC('R', 'G', 'B', '1')
 
#define MPIX_FMT_RGB565   MPIX_FOURCC('R', 'G', 'B', 'P')
 
#define MPIX_FMT_RGB565X   MPIX_FOURCC('R', 'G', 'B', 'R')
 
#define MPIX_FMT_RGB24   MPIX_FOURCC('R', 'G', 'B', '3')
 

YUV formats

Formats with Luma (Y), Cb (U), and Cr (V) channels, sometimes with chroma subsampling.

#define MPIX_FMT_YUV12   MPIX_FOURCC('Y', 'U', 'V', 'C')
 12-bit per pixel, 2 pixels every 3 bytes, 4-bit per component.
 
#define MPIX_FMT_YUV24   MPIX_FOURCC('Y', 'U', 'V', '3')
 
#define MPIX_FMT_YUYV   MPIX_FOURCC('Y', 'U', 'Y', 'V')
 

Luma-only formats

Formats with only a luma (Y) channel, grayscale.

#define MPIX_FMT_GREY   MPIX_FOURCC('G', 'R', 'E', 'Y')
 

Bayer formats

Formats with bayer color filter array, one channel per pixel, red, green or blue.

#define MPIX_FMT_SBGGR8   MPIX_FOURCC('B', 'A', '8', '1')
 
#define MPIX_FMT_SGBRG8   MPIX_FOURCC('G', 'B', 'R', 'G')
 
#define MPIX_FMT_SGRBG8   MPIX_FOURCC('G', 'R', 'B', 'G')
 
#define MPIX_FMT_SRGGB8   MPIX_FOURCC('R', 'G', 'G', 'B')
 

Indexed color formats

Formats where each pixel is a reference to a color palette.

#define MPIX_FMT_PALETTE1   MPIX_FOURCC('P', 'L', 'T', '1')
 
#define MPIX_FMT_PALETTE2   MPIX_FOURCC('P', 'L', 'T', '2')
 
#define MPIX_FMT_PALETTE3   MPIX_FOURCC('P', 'L', 'T', '3')
 
#define MPIX_FMT_PALETTE4   MPIX_FOURCC('P', 'L', 'T', '4')
 
#define MPIX_FMT_PALETTE5   MPIX_FOURCC('P', 'L', 'T', '5')
 
#define MPIX_FMT_PALETTE6   MPIX_FOURCC('P', 'L', 'T', '6')
 
#define MPIX_FMT_PALETTE7   MPIX_FOURCC('P', 'L', 'T', '7')
 
#define MPIX_FMT_PALETTE8   MPIX_FOURCC('P', 'L', 'T', '8')
 

Compressed formats

Lossy and non-lossy compressed formats. The bits per pixel is defined as zero.

#define MPIX_FMT_JPEG   MPIX_FOURCC('J', 'P', 'E', 'G')
 
#define MPIX_FMT_QOI   MPIX_FOURCC('Q', 'O', 'I', 'F')
 

Detailed Description

Formats definition.

SPDX-License-Identifier: Apache-2.0

Macro Definition Documentation

◆ MPIX_FMT_GREY

#define MPIX_FMT_GREY   MPIX_FOURCC('G', 'R', 'E', 'Y')

Same as Y8 (8-bit luma-only) following the standard FOURCC naming, or L8 in some graphics libraries.

0 1 2 3
| Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | Yyyyyyyy | ...

◆ MPIX_FMT_JPEG

#define MPIX_FMT_JPEG   MPIX_FOURCC('J', 'P', 'E', 'G')

Compressed frame using the JPEG format. Multiple JPEG frames can be sent back-to-back to make an MJPEG stream.

◆ MPIX_FMT_PALETTE1

#define MPIX_FMT_PALETTE1   MPIX_FOURCC('P', 'L', 'T', '1')

1-bit color palette pixel format, 2 colors in total like a bitmap. 8 pixels shown below:

0 1 2 3 4 5 6 7
| P|P|P|P|P|P|P|P | ...

◆ MPIX_FMT_PALETTE2

#define MPIX_FMT_PALETTE2   MPIX_FOURCC('P', 'L', 'T', '2')

2-bit color palette pixel format, 4 colors in total. 8 pixels shown below:

0 1 2 3 4 5 6 7
| Pp|Pp|Pp|Pp | Pp|Pp|Pp|Pp | ...

◆ MPIX_FMT_PALETTE3

#define MPIX_FMT_PALETTE3   MPIX_FOURCC('P', 'L', 'T', '3')

3-bit color palette pixel format, 8 colors in total. Padded by 1 bit to fit a 4 bit packing. 8 pixels shown below:

0 1 2 3 4 5 6 7
| -Ppp|-Ppp | -Ppp|-Ppp | -Ppp|-Ppp | -Ppp|-Ppp | ...

◆ MPIX_FMT_PALETTE4

#define MPIX_FMT_PALETTE4   MPIX_FOURCC('P', 'L', 'T', '4')

4-bit color palette pixel format, 16 colors in total. 8 pixels shown below:

0 1 2 3 4 5 6 7
| Pppp|Pppp | Pppp|Pppp | Pppp|Pppp | Pppp|Pppp | ...

◆ MPIX_FMT_PALETTE5

#define MPIX_FMT_PALETTE5   MPIX_FOURCC('P', 'L', 'T', '5')

5-bit color palette pixel format, 32 colors in total. Padded by 3 bit to fit a 8 bit packing. 8 pixels shown below:

0 1 2 3 4 5 6 7
| ---Ppppp | ---Ppppp | ---Ppppp | ---Ppppp | ---Ppppp | ---Ppppp | ---Ppppp | ---Ppppp | ...

◆ MPIX_FMT_PALETTE6

#define MPIX_FMT_PALETTE6   MPIX_FOURCC('P', 'L', 'T', '6')

6-bit color palette pixel format, 64 colors in total. Padded by 2 bit to fit a 8 bit packing. 8 pixels shown below:

0 1 2 3 4 5 6 7
| --Pppppp | --Pppppp | --Pppppp | --Pppppp | --Pppppp | --Pppppp | --Pppppp | --Pppppp | ...

◆ MPIX_FMT_PALETTE7

#define MPIX_FMT_PALETTE7   MPIX_FOURCC('P', 'L', 'T', '7')

7-bit color palette pixel format, 128 colors in total. Padded by 1 bit to fit a 8 bit packing. 8 pixels shown below:

0 1 2 3 4 5 6 7
| -Ppppppp | -Ppppppp | -Ppppppp | -Ppppppp | -Ppppppp | -Ppppppp | -Ppppppp | -Ppppppp | ...

◆ MPIX_FMT_PALETTE8

#define MPIX_FMT_PALETTE8   MPIX_FOURCC('P', 'L', 'T', '8')

8-bit color palette pixel format, 256 colors in total. 8 pixels shown below:

0 1 2 3 4 5 6 7
| Pppppppp | Pppppppp | Pppppppp | Pppppppp | Pppppppp | Pppppppp | Pppppppp | Pppppppp | ...

◆ MPIX_FMT_QOI

#define MPIX_FMT_QOI   MPIX_FOURCC('Q', 'O', 'I', 'F')

Compressed frame using the QOI format. Multiple QOI frames can be sent back-to-back to make an QOIF stream.

◆ MPIX_FMT_RGB24

#define MPIX_FMT_RGB24   MPIX_FOURCC('R', 'G', 'B', '3')

24 bit RGB format with 8 bit per component

| Rggggggg Gggggggg Bbbbbbbb | ...

◆ MPIX_FMT_RGB332

#define MPIX_FMT_RGB332   MPIX_FOURCC('R', 'G', 'B', '1')

8 bit RGB format with 3 or 2 bit per component

| RrrGggBb | ...

◆ MPIX_FMT_RGB565

#define MPIX_FMT_RGB565   MPIX_FOURCC('R', 'G', 'B', 'P')

5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0]. This 16-bit integer is then packed in little endian format over two bytes:

7......0 15.....8
| gggBbbbb RrrrrGgg | ...

◆ MPIX_FMT_RGB565X

#define MPIX_FMT_RGB565X   MPIX_FOURCC('R', 'G', 'B', 'R')

5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0]. This 16-bit integer is then packed in big endian format over two bytes:

15.....8 7......0
| RrrrrGgg gggBbbbb | ...

◆ MPIX_FMT_SBGGR8

#define MPIX_FMT_SBGGR8   MPIX_FOURCC('B', 'A', '8', '1')
0 1 2 3
| Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ...
| Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | ...

◆ MPIX_FMT_SGBRG8

#define MPIX_FMT_SGBRG8   MPIX_FOURCC('G', 'B', 'R', 'G')
0 1 2 3
| Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | ...
| Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ...

◆ MPIX_FMT_SGRBG8

#define MPIX_FMT_SGRBG8   MPIX_FOURCC('G', 'R', 'B', 'G')
0 1 2 3
| Gggggggg | Rrrrrrrr | Gggggggg | Rrrrrrrr | ...
| Bbbbbbbb | Gggggggg | Bbbbbbbb | Gggggggg | ...

◆ MPIX_FMT_SRGGB8

#define MPIX_FMT_SRGGB8   MPIX_FOURCC('R', 'G', 'G', 'B')
0 1 2 3
| Rrrrrrrr | Gggggggg | Rrrrrrrr | Gggggggg | ...
| Gggggggg | Bbbbbbbb | Gggggggg | Bbbbbbbb | ...

◆ MPIX_FMT_YUV12

#define MPIX_FMT_YUV12   MPIX_FOURCC('Y', 'U', 'V', 'C')

12-bit per pixel, 2 pixels every 3 bytes, 4-bit per component.

2 pixels shown below:

| YyyyUuuu Vvvv|Yyyy UuuuVvvv| ...

◆ MPIX_FMT_YUV24

#define MPIX_FMT_YUV24   MPIX_FOURCC('Y', 'U', 'V', '3')
| Yyyyyyyy Uuuuuuuu Vvvvvvvv | ...

◆ MPIX_FMT_YUYV

#define MPIX_FMT_YUYV   MPIX_FOURCC('Y', 'U', 'Y', 'V')

There is either a missing channel per pixel, U or V. The value is to be averaged over 2 pixels to get the value of individual pixel.

| Yyyyyyyy Uuuuuuuu | Yyyyyyyy Vvvvvvvv | ...

◆ MPIX_FOURCC

#define MPIX_FOURCC (   a,
  b,
  c,
 
)     ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))

Define a new pixel format, with defaults for most common values.

Parameters
a1st character of the Four Character Code
b2nd character of the Four Character Code
c3rd character of the Four Character Code
d4th character of the Four Character Code

◆ MPIX_FOURCC_TO_STR

#define MPIX_FOURCC_TO_STR (   fourcc)
Value:
((char[5]){ \
(char)(((fourcc) >> 0) & 0xFF), \
(char)(((fourcc) >> 8) & 0xFF), \
(char)(((fourcc) >> 16) & 0xFF), \
(char)(((fourcc) >> 24) & 0xFF), \
'\0', \
})

Generate a string out of a pixel format.

Parameters
fourccFormat as a 32-bit four character code.
Returns
A local nul-terminated string for this four character code.

Function Documentation

◆ mpix_bits_per_pixel_cb()

uint8_t mpix_bits_per_pixel_cb ( uint32_t  fourcc)

Callback for the application to add custom pixel formats.

If a pixel format is not known by MPIX, this function is called to resolve the average number of bits per pixel. It is defined as weak so that applications can define their own variant and provide their own pixel format definition.

Parameters
fourccFour character code to query.
Returns
Average number of bits per pixel.