mikroSDK Reference Manual
gl_jpeg_constants.h
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
39
41
42#ifndef JPEG_CONSTANTS_H
43#define JPEG_CONSTANTS_H
44
45#include <stdint.h>
46
47const uint8_t _JPEG_MAX_CHANNELS = 3; /* This supports only Grayscale and YCbCr images - DONT CHANGE THIS */
48const uint8_t _JPEG_MAX_BLOCKS = 6; /* To decode one logical block, we have to decode 1 to 6 blocks depending on channels and subsampling - DONT REDUCE THIS */
49const uint8_t _JPEG_MAX_HUFF_TABLES = 2; /* Each causes 2 tables -> One for AC and another for DC - DONT REDUCE THIS */
50const uint8_t _JPEG_MAX_DATA_BUF_LEN = 128; /* Increase if you have more data memory */
51
53const uint8_t _JPEG_SOF0 = 0xC0;
54const uint8_t _JPEG_DHT = 0xC4;
55const uint8_t _JPEG_SOI = 0xD8;
56const uint8_t _JPEG_EOI = 0xD9;
57const uint8_t _JPEG_SOS = 0xDA;
58const uint8_t _JPEG_DQT = 0xDB;
59const uint8_t _JPEG_DRI = 0xDD;
60const uint8_t _JPEG_APP0 = 0xE0;
61const uint8_t _JPEG_COM = 0xFE;
62
63/* The below markers doesn't have parameters */
64const uint8_t _JPEG_TEM = 0x01;
65const uint8_t _JPEG_RST0 = 0xD0;
66const uint8_t _JPEG_RST1 = 0xD1;
67const uint8_t _JPEG_RST2 = 0xD2;
68const uint8_t _JPEG_RST3 = 0xD3;
69const uint8_t _JPEG_RST4 = 0xD4;
70const uint8_t _JPEG_RST5 = 0xD5;
71const uint8_t _JPEG_RST6 = 0xD6;
72const uint8_t _JPEG_RST7 = 0xD7;
73
74const uint8_t _JPEG_SAMPLE_1x1 = 0;
75const uint8_t _JPEG_SAMPLE_1x2 = 1;
76const uint8_t _JPEG_SAMPLE_2x1 = 2;
77const uint8_t _JPEG_SAMPLE_2x2 = 3;
78
79#ifndef __MIKROC__
80#define _JPEG_MAX_CHANNELS 3 /* This supports only Grayscale and YCbCr images - DONT CHANGE THIS */
81#define _JPEG_MAX_BLOCKS 6 /* To decode one logical block, we have to decode 1 to 6 blocks depending on channels and subsampling - DONT REDUCE THIS */
82#define _JPEG_MAX_HUFF_TABLES 2 /* Each causes 2 tables -> One for AC and another for DC - DONT REDUCE THIS */
83#define _JPEG_MAX_DATA_BUF_LEN 128 /* Increase if you have more data memory */
84
86#define _JPEG_SOF0 0xC0
87#define _JPEG_DHT 0xC4
88#define _JPEG_SOI 0xD8
89#define _JPEG_EOI 0xD9
90#define _JPEG_SOS 0xDA
91#define _JPEG_DQT 0xDB
92#define _JPEG_DRI 0xDD
93#define _JPEG_APP0 0xE0
94#define _JPEG_COM 0xFE
95
96/* The below markers doesn't have parameters */
97#define _JPEG_TEM 0x01
98#define _JPEG_RST0 0xD0
99#define _JPEG_RST1 0xD1
100#define _JPEG_RST2 0xD2
101#define _JPEG_RST3 0xD3
102#define _JPEG_RST4 0xD4
103#define _JPEG_RST5 0xD5
104#define _JPEG_RST6 0xD6
105#define _JPEG_RST7 0xD7
106
107#define _JPEG_SAMPLE_1x1 0
108#define _JPEG_SAMPLE_1x2 1
109#define _JPEG_SAMPLE_2x1 2
110#define _JPEG_SAMPLE_2x2 3
111#endif
112
113const uint8_t _JPEG_ZIG_ZAG_8x8[64] =
114{
115 0, 1, 8, 16, 9, 2, 3, 10,
116 17, 24, 32, 25, 18, 11, 4, 5,
117 12, 19, 26, 33, 40, 48, 41, 34,
118 27, 20, 13, 6, 7, 14, 21, 28,
119 35, 42, 49, 56, 57, 50, 43, 36,
120 29, 22, 15, 23, 30, 37, 44, 51,
121 58, 59, 52, 45, 38, 31, 39, 46,
122 53, 60, 61, 54, 47, 55, 62, 63
123};
124
125#endif // JPEG_CONSTANTS_H
126