![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * V4L2 JPEG helpers header 0004 * 0005 * Copyright (C) 2019 Pengutronix, Philipp Zabel <kernel@pengutronix.de> 0006 * 0007 * For reference, see JPEG ITU-T.81 (ISO/IEC 10918-1) 0008 */ 0009 0010 #ifndef _V4L2_JPEG_H 0011 #define _V4L2_JPEG_H 0012 0013 #include <linux/v4l2-controls.h> 0014 0015 #define V4L2_JPEG_MAX_COMPONENTS 4 0016 #define V4L2_JPEG_MAX_TABLES 4 0017 0018 /** 0019 * struct v4l2_jpeg_reference - reference into the JPEG buffer 0020 * @start: pointer to the start of the referenced segment or table 0021 * @length: size of the referenced segment or table 0022 * 0023 * Wnen referencing marker segments, start points right after the marker code, 0024 * and length is the size of the segment parameters, excluding the marker code. 0025 */ 0026 struct v4l2_jpeg_reference { 0027 u8 *start; 0028 size_t length; 0029 }; 0030 0031 /* B.2.2 Frame header syntax */ 0032 0033 /** 0034 * struct v4l2_jpeg_frame_component_spec - frame component-specification 0035 * @component_identifier: C[i] 0036 * @horizontal_sampling_factor: H[i] 0037 * @vertical_sampling_factor: V[i] 0038 * @quantization_table_selector: quantization table destination selector Tq[i] 0039 */ 0040 struct v4l2_jpeg_frame_component_spec { 0041 u8 component_identifier; 0042 u8 horizontal_sampling_factor; 0043 u8 vertical_sampling_factor; 0044 u8 quantization_table_selector; 0045 }; 0046 0047 /** 0048 * struct v4l2_jpeg_frame_header - JPEG frame header 0049 * @height: Y 0050 * @width: X 0051 * @precision: P 0052 * @num_components: Nf 0053 * @component: component-specification, see v4l2_jpeg_frame_component_spec 0054 * @subsampling: decoded subsampling from component-specification 0055 */ 0056 struct v4l2_jpeg_frame_header { 0057 u16 height; 0058 u16 width; 0059 u8 precision; 0060 u8 num_components; 0061 struct v4l2_jpeg_frame_component_spec component[V4L2_JPEG_MAX_COMPONENTS]; 0062 enum v4l2_jpeg_chroma_subsampling subsampling; 0063 }; 0064 0065 /* B.2.3 Scan header syntax */ 0066 0067 /** 0068 * struct v4l2_jpeg_scan_component_spec - scan component-specification 0069 * @component_selector: Cs[j] 0070 * @dc_entropy_coding_table_selector: Td[j] 0071 * @ac_entropy_coding_table_selector: Ta[j] 0072 */ 0073 struct v4l2_jpeg_scan_component_spec { 0074 u8 component_selector; 0075 u8 dc_entropy_coding_table_selector; 0076 u8 ac_entropy_coding_table_selector; 0077 }; 0078 0079 /** 0080 * struct v4l2_jpeg_scan_header - JPEG scan header 0081 * @num_components: Ns 0082 * @component: component-specification, see v4l2_jpeg_scan_component_spec 0083 */ 0084 struct v4l2_jpeg_scan_header { 0085 u8 num_components; /* Ns */ 0086 struct v4l2_jpeg_scan_component_spec component[V4L2_JPEG_MAX_COMPONENTS]; 0087 /* Ss, Se, Ah, and Al are not used by any driver */ 0088 }; 0089 0090 /** 0091 * enum v4l2_jpeg_app14_tf - APP14 transform flag 0092 * According to Rec. ITU-T T.872 (06/2012) 6.5.3 0093 * APP14 segment is for color encoding, it contains a transform flag, 0094 * which may have values of 0, 1 and 2 and are interpreted as follows: 0095 * @V4L2_JPEG_APP14_TF_CMYK_RGB: CMYK for images encoded with four components 0096 * RGB for images encoded with three components 0097 * @V4L2_JPEG_APP14_TF_YCBCR: an image encoded with three components using YCbCr 0098 * @V4L2_JPEG_APP14_TF_YCCK: an image encoded with four components using YCCK 0099 * @V4L2_JPEG_APP14_TF_UNKNOWN: indicate app14 is not present 0100 */ 0101 enum v4l2_jpeg_app14_tf { 0102 V4L2_JPEG_APP14_TF_CMYK_RGB = 0, 0103 V4L2_JPEG_APP14_TF_YCBCR = 1, 0104 V4L2_JPEG_APP14_TF_YCCK = 2, 0105 V4L2_JPEG_APP14_TF_UNKNOWN = -1, 0106 }; 0107 0108 /** 0109 * struct v4l2_jpeg_header - parsed JPEG header 0110 * @sof: pointer to frame header and size 0111 * @sos: pointer to scan header and size 0112 * @num_dht: number of entries in @dht 0113 * @dht: pointers to huffman tables and sizes 0114 * @num_dqt: number of entries in @dqt 0115 * @dqt: pointers to quantization tables and sizes 0116 * @frame: parsed frame header 0117 * @scan: pointer to parsed scan header, optional 0118 * @quantization_tables: references to four quantization tables, optional 0119 * @huffman_tables: references to four Huffman tables in DC0, DC1, AC0, AC1 0120 * order, optional 0121 * @restart_interval: number of MCU per restart interval, Ri 0122 * @ecs_offset: buffer offset in bytes to the entropy coded segment 0123 * @app14_tf: transform flag from app14 data 0124 * 0125 * When this structure is passed to v4l2_jpeg_parse_header, the optional scan, 0126 * quantization_tables, and huffman_tables pointers must be initialized to NULL 0127 * or point at valid memory. 0128 */ 0129 struct v4l2_jpeg_header { 0130 struct v4l2_jpeg_reference sof; 0131 struct v4l2_jpeg_reference sos; 0132 unsigned int num_dht; 0133 struct v4l2_jpeg_reference dht[V4L2_JPEG_MAX_TABLES]; 0134 unsigned int num_dqt; 0135 struct v4l2_jpeg_reference dqt[V4L2_JPEG_MAX_TABLES]; 0136 0137 struct v4l2_jpeg_frame_header frame; 0138 struct v4l2_jpeg_scan_header *scan; 0139 struct v4l2_jpeg_reference *quantization_tables; 0140 struct v4l2_jpeg_reference *huffman_tables; 0141 u16 restart_interval; 0142 size_t ecs_offset; 0143 enum v4l2_jpeg_app14_tf app14_tf; 0144 }; 0145 0146 int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out); 0147 0148 int v4l2_jpeg_parse_frame_header(void *buf, size_t len, 0149 struct v4l2_jpeg_frame_header *frame_header); 0150 int v4l2_jpeg_parse_scan_header(void *buf, size_t len, 0151 struct v4l2_jpeg_scan_header *scan_header); 0152 int v4l2_jpeg_parse_quantization_tables(void *buf, size_t len, u8 precision, 0153 struct v4l2_jpeg_reference *q_tables); 0154 int v4l2_jpeg_parse_huffman_tables(void *buf, size_t len, 0155 struct v4l2_jpeg_reference *huffman_tables); 0156 0157 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |