• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <soc/soc.h>
18 #include "driver/jpeg_dec_types.h"
19 
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define addJPEG_data_st                                         (addJPEG_Reg0x9 & 0x100)
27 #define addJPEG_ycount                                          (addJPEG_Reg0x9 & 0xff)
28 #define WORK_AREA_SIZE 4096
29 
30 #define	JD_SZBUF		1024	/* Size of stream input buffer */
31 #define JD_FORMAT		0	/* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */
32 #define	JD_USE_SCALE	1	/* Use descaling feature for output */
33 #define JD_TBLCLIP		1	/* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
34 
35 /*---------------------------------------------------------------------------*/
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /* Rectangular structure */
42 typedef struct {
43 	uint16_t left, right, top, bottom;
44 } JRECT;
45 
46 
47 /* Decompressor object structure */
48 typedef struct JDEC JDEC;
49 struct JDEC {
50 	uint16_t dctr;				/* Number of bytes available in the input buffer */
51 	uint8_t* dptr;				/* Current data read ptr */
52 	uint8_t* inbuf;				/* Bit stream input buffer */
53 	uint8_t dmsk;				/* Current bit in the current read byte */
54 	uint8_t scale;				/* Output scaling ratio */
55 	uint8_t msx, msy;			/* MCU size in unit of block (width, height) */
56 	uint8_t qtid[3];			/* Quantization table ID of each component */
57 	int16_t dcv[3];				/* Previous DC element of each component */
58 	uint16_t nrst;				/* Restart inverval */
59 	uint16_t width, height;		/* Size of the input image (pixel) */
60 	uint8_t* huffbits[2][2];	/* Huffman bit distribution tables [id][dcac] */
61 	uint16_t* huffcode[2][2];	/* Huffman code word tables [id][dcac] */
62 	uint8_t* huffdata[2][2];	/* Huffman decoded data tables [id][dcac] */
63 	int32_t* qttbl[4];			/* Dequantizer tables [id] */
64 	void* workbuf;				/* Working buffer for IDCT and RGB output */
65 	uint8_t* mcubuf;			/* Working buffer for the MCU */
66 	void* pool;					/* Pointer to available memory pool */
67 	uint16_t sz_pool;			/* Size of momory pool (bytes available) */
68 	uint16_t (*infunc)(JDEC*, uint8_t*, uint16_t);/* Pointer to jpeg stream input function */
69 	void* device;				/* Pointer to I/O device identifiler for the session */
70 };
71 
72 
73 
74 //static 	JDEC jdec; /* Decompression object */
75 
76 int jpg_dec_config(uint16_t xpixel, uint16_t ypixel, uint32_t length, unsigned char *input_buf, unsigned char * output_buf);
77 void jpeg_dec_block_int_en(bool auto_int_en);
78 void jpeg_dec_auto_frame_end_int_en(bool auto_int_en);
79 void jpeg_dec_auto_line_num_int_en(bool line_int_en, uint16_t line_num);
80 
81 JRESULT JpegdecInit(void);
82 JRESULT jd_decomp(void);
83 
84 int jpg_decoder_init(void);
85 
86 int jpg_decoder_deinit(void);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 
93 
94 
95 
96 
97 
98 
99 
100