Skip to content

Commit

Permalink
Fixes for MP support for LVGL 3rd party libraries
Browse files Browse the repository at this point in the history
Add missing lv_qrcode_class

Remove 'struct JDEC' from public API. This struct is needed intenally on tjpgd.c and lv_sjpg.c, but doesn't need to be exposed in the public API. When exposed, it increases Micropython binding program size and some fields are not supported today (uint8_t* huffbits[2][2]). To overcome this, moved it to a new H file which is not included in public API, only in sjpg C files

Related: lvgl/lv_binding_micropython#180
  • Loading branch information
amirgon committed Oct 14, 2021
1 parent a5793c7 commit 337076f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
2 changes: 2 additions & 0 deletions src/extra/libs/qrcode/lv_qrcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern "C" {
* DEFINES
*********************/

#define lv_qrcode_class lv_canvas_class

/**********************
* TYPEDEFS
**********************/
Expand Down
1 change: 1 addition & 0 deletions src/extra/libs/sjpg/lv_sjpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#if LV_USE_SJPG

#include "tjpgd.h"
#include "tjdec.h"
#include "lv_sjpg.h"


Expand Down
39 changes: 39 additions & 0 deletions src/extra/libs/sjpg/tjdec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef DEF_TJDEC
#define DEF_TJDEC

#include "tjpgdcnf.h"

struct JDEC {
size_t dctr; /* Number of bytes available in the input buffer */
uint8_t* dptr; /* Current data read ptr */
uint8_t* inbuf; /* Bit stream input buffer */
uint8_t dbit; /* Number of bits availavble in wreg or reading bit mask */
uint8_t scale; /* Output scaling ratio */
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
uint8_t qtid[3]; /* Quantization table ID of each component, Y, Cb, Cr */
uint8_t ncomp; /* Number of color components 1:grayscale, 3:color */
int16_t dcv[3]; /* Previous DC element of each component */
uint16_t nrst; /* Restart inverval */
uint16_t width, height; /* Size of the input image (pixel) */
uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t* qttbl[4]; /* Dequantizer tables [id] */
#if JD_FASTDECODE >= 1
uint32_t wreg; /* Working shift register */
uint8_t marker; /* Detected marker (0:None) */
#if JD_FASTDECODE == 2
uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */
uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */
uint8_t* hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */
#endif
#endif
void* workbuf; /* Working buffer for IDCT and RGB output */
jd_yuv_t* mcubuf; /* Working buffer for the MCU */
void* pool; /* Pointer to available memory pool */
size_t sz_pool; /* Size of momory pool (bytes available) */
size_t (*infunc)(struct JDEC*, uint8_t*, size_t); /* Pointer to jpeg stream input function */
void* device; /* Pointer to I/O device identifiler for the session */
};

#endif // DEF_TJDEC
1 change: 1 addition & 0 deletions src/extra/libs/sjpg/tjpgd.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "tjpgd.h"
#if LV_USE_SJPG
#include "tjdec.h"

#if JD_FASTDECODE == 2
#define HUFF_BIT 10 /* Bit length to apply fast huffman decode */
Expand Down
33 changes: 0 additions & 33 deletions src/extra/libs/sjpg/tjpgd.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,6 @@ typedef struct {

/* Decompressor object structure */
typedef struct JDEC JDEC;
struct JDEC {
size_t dctr; /* Number of bytes available in the input buffer */
uint8_t* dptr; /* Current data read ptr */
uint8_t* inbuf; /* Bit stream input buffer */
uint8_t dbit; /* Number of bits availavble in wreg or reading bit mask */
uint8_t scale; /* Output scaling ratio */
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
uint8_t qtid[3]; /* Quantization table ID of each component, Y, Cb, Cr */
uint8_t ncomp; /* Number of color components 1:grayscale, 3:color */
int16_t dcv[3]; /* Previous DC element of each component */
uint16_t nrst; /* Restart inverval */
uint16_t width, height; /* Size of the input image (pixel) */
uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t* qttbl[4]; /* Dequantizer tables [id] */
#if JD_FASTDECODE >= 1
uint32_t wreg; /* Working shift register */
uint8_t marker; /* Detected marker (0:None) */
#if JD_FASTDECODE == 2
uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */
uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */
uint8_t* hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */
#endif
#endif
void* workbuf; /* Working buffer for IDCT and RGB output */
jd_yuv_t* mcubuf; /* Working buffer for the MCU */
void* pool; /* Pointer to available memory pool */
size_t sz_pool; /* Size of momory pool (bytes available) */
size_t (*infunc)(JDEC*, uint8_t*, size_t); /* Pointer to jpeg stream input function */
void* device; /* Pointer to I/O device identifiler for the session */
};



/* TJpgDec API functions */
Expand Down

0 comments on commit 337076f

Please sign in to comment.