2.29. V4L2 JPEG header related functions and data structures¶
-
struct v4l2_jpeg_reference¶
reference into the JPEG buffer
Definition:
struct v4l2_jpeg_reference {
u8 *start;
size_t length;
};
Members
startpointer to the start of the referenced segment or table
lengthsize of the referenced segment or table
Description
Wnen referencing marker segments, start points right after the marker code, and length is the size of the segment parameters, excluding the marker code.
-
struct v4l2_jpeg_frame_component_spec¶
frame component-specification
Definition:
struct v4l2_jpeg_frame_component_spec {
u8 component_identifier;
u8 horizontal_sampling_factor;
u8 vertical_sampling_factor;
u8 quantization_table_selector;
};
Members
component_identifierC[i]
horizontal_sampling_factorH[i]
vertical_sampling_factorV[i]
quantization_table_selectorquantization table destination selector Tq[i]
-
struct v4l2_jpeg_frame_header¶
JPEG frame header
Definition:
struct v4l2_jpeg_frame_header {
u16 height;
u16 width;
u8 precision;
u8 num_components;
struct v4l2_jpeg_frame_component_spec component[V4L2_JPEG_MAX_COMPONENTS];
enum v4l2_jpeg_chroma_subsampling subsampling;
};
Members
heightY
widthX
precisionP
num_componentsNf
componentcomponent-specification, see v4l2_jpeg_frame_component_spec
subsamplingdecoded subsampling from component-specification
-
struct v4l2_jpeg_scan_component_spec¶
scan component-specification
Definition:
struct v4l2_jpeg_scan_component_spec {
u8 component_selector;
u8 dc_entropy_coding_table_selector;
u8 ac_entropy_coding_table_selector;
};
Members
component_selectorCs[j]
dc_entropy_coding_table_selectorTd[j]
ac_entropy_coding_table_selectorTa[j]
-
struct v4l2_jpeg_scan_header¶
JPEG scan header
Definition:
struct v4l2_jpeg_scan_header {
u8 num_components;
struct v4l2_jpeg_scan_component_spec component[V4L2_JPEG_MAX_COMPONENTS];
};
Members
num_componentsNs
componentcomponent-specification, see v4l2_jpeg_scan_component_spec
-
enum v4l2_jpeg_app14_tf¶
APP14 transform flag According to Rec. ITU-T T.872 (06/2012) 6.5.3 APP14 segment is for color encoding, it contains a transform flag, which may have values of 0, 1 and 2 and are interpreted as follows:
Constants
V4L2_JPEG_APP14_TF_CMYK_RGBCMYK for images encoded with four components RGB for images encoded with three components
V4L2_JPEG_APP14_TF_YCBCRan image encoded with three components using YCbCr
V4L2_JPEG_APP14_TF_YCCKan image encoded with four components using YCCK
V4L2_JPEG_APP14_TF_UNKNOWNindicate app14 is not present
-
struct v4l2_jpeg_header¶
parsed JPEG header
Definition:
struct v4l2_jpeg_header {
struct v4l2_jpeg_reference sof;
struct v4l2_jpeg_reference sos;
unsigned int num_dht;
struct v4l2_jpeg_reference dht[V4L2_JPEG_MAX_TABLES];
unsigned int num_dqt;
struct v4l2_jpeg_reference dqt[V4L2_JPEG_MAX_TABLES];
struct v4l2_jpeg_frame_header frame;
struct v4l2_jpeg_scan_header *scan;
struct v4l2_jpeg_reference *quantization_tables;
struct v4l2_jpeg_reference *huffman_tables;
u16 restart_interval;
size_t ecs_offset;
enum v4l2_jpeg_app14_tf app14_tf;
};
Members
sofpointer to frame header and size
sospointer to scan header and size
num_dhtnumber of entries in dht
dhtpointers to huffman tables and sizes
num_dqtnumber of entries in dqt
dqtpointers to quantization tables and sizes
frameparsed frame header
scanpointer to parsed scan header, optional
quantization_tablesreferences to four quantization tables, optional
huffman_tablesreferences to four Huffman tables in DC0, DC1, AC0, AC1 order, optional
restart_intervalnumber of MCU per restart interval, Ri
ecs_offsetbuffer offset in bytes to the entropy coded segment
app14_tftransform flag from app14 data
Description
When this structure is passed to v4l2_jpeg_parse_header, the optional scan, quantization_tables, and huffman_tables pointers must be initialized to NULL or point at valid memory.
-
int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)¶
locate marker segments and optionally parse headers
Parameters
void *bufaddress of the JPEG buffer, should start with a SOI marker
size_t lenlength of the JPEG buffer
struct v4l2_jpeg_header *outreturns marker segment positions and optionally parsed headers
Description
The out->scan_header pointer must be initialized to NULL or point to a valid v4l2_jpeg_scan_header structure. The out->huffman_tables and out->quantization_tables pointers must be initialized to NULL or point to a valid array of 4 v4l2_jpeg_reference structures each.
Returns 0 or negative error if parsing failed.
-
int v4l2_jpeg_parse_frame_header(void *buf, size_t len, struct v4l2_jpeg_frame_header *frame_header)¶
parse frame header
Parameters
void *bufaddress of the frame header, after the SOF0 marker
size_t lenlength of the frame header
struct v4l2_jpeg_frame_header *frame_headerreturns the parsed frame header
Description
Returns 0 or negative error if parsing failed.
-
int v4l2_jpeg_parse_scan_header(void *buf, size_t len, struct v4l2_jpeg_scan_header *scan_header)¶
parse scan header
Parameters
void *bufaddress of the scan header, after the SOS marker
size_t lenlength of the scan header
struct v4l2_jpeg_scan_header *scan_headerreturns the parsed scan header
Description
Returns 0 or negative error if parsing failed.
-
int v4l2_jpeg_parse_quantization_tables(void *buf, size_t len, u8 precision, struct v4l2_jpeg_reference *q_tables)¶
parse quantization tables segment
Parameters
void *bufaddress of the quantization table segment, after the DQT marker
size_t lenlength of the quantization table segment
u8 precisionsample precision (P) in bits per component
struct v4l2_jpeg_reference *q_tablesreturns four references into the buffer for the four possible quantization table destinations
Description
Returns 0 or negative error if parsing failed.
-
int v4l2_jpeg_parse_huffman_tables(void *buf, size_t len, struct v4l2_jpeg_reference *huffman_tables)¶
parse huffman tables segment
Parameters
void *bufaddress of the Huffman table segment, after the DHT marker
size_t lenlength of the Huffman table segment
struct v4l2_jpeg_reference *huffman_tablesreturns four references into the buffer for the four possible Huffman table destinations, in the order DC0, DC1, AC0, AC1
Description
Returns 0 or negative error if parsing failed.