Skip to content

Commit

Permalink
Update on 30 Jun 2023. Expand to see details.
Browse files Browse the repository at this point in the history
eb494b63b Fix crash after delete a font or pixelmap resource when page heap is enabled.
97c60f151 Fix jpeg decoding compile error with AC6.
854311469 Fix crash in debug mode when editing an invalid resource name.
305396e7d Fixed Studio crash caused by duplicate widget names (template and derived).
ff975d3c6 Correct IAR test script.
419e30052 Fixed font kerning flag issue.
36bef7f76 Fix crash on closing GUIX Studio project.
3f21aed14 Fix IAR test failures.
06b8bf46f Fix bug about gx_dave2d_png_draw not been declared when dave2d is disabled.
ea88cf27e Print JPEG decoding cycle count.
b7a410718 Declare and extern the system fonts as GX_CONST.
5f02a8d36 Added JPEG decoding IAR test projects.
4afce2633 Fix bug about the recent project path names being converted to lowercase.
74a1c62af Fixed Helium version JPEG decoding bug.
744c6f031 Optimize JPEG decode using Helium intrinsics.
f877b9aa1 Remove "Preview Version" tag to release GUIX Studio 6.2.1.2.
  • Loading branch information
bo-ms committed Jun 30, 2023
1 parent 252bda0 commit 50ead25
Show file tree
Hide file tree
Showing 40 changed files with 1,959 additions and 1,504 deletions.
8 changes: 4 additions & 4 deletions common/inc/gx_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* gx_display.h PORTABLE C */
/* 6.1.10 */
/* 6.x */
/* AUTHOR */
/* */
/* Kenneth Maxwell, Microsoft Corporation */
Expand Down Expand Up @@ -60,13 +60,15 @@
/* added language direction */
/* table set declarations, */
/* resulting in version 6.1.10 */
/* xx-xx-xxxx Ting Zhu Modified comment(s), */
/* removed unused prototypes, */
/* resulting in version 6.x */
/* */
/**************************************************************************/

#ifndef GX_DISPLAY_H
#define GX_DISPLAY_H


/* Define Display management constants. */

#define GX_DISPLAY_ID ((ULONG)0x53435245)
Expand Down Expand Up @@ -283,7 +285,6 @@ VOID _gx_display_driver_565rgb_rotated_pixelmap_blend(GX_DRAW_CONTEXT *conte
VOID _gx_display_driver_565rgb_rotated_pixelmap_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap,
INT angle, INT rot_cx, INT rot_cy);
#if defined(GX_SOFTWARE_DECODER_SUPPORT)
USHORT _gx_display_driver_565rgb_YCbCr2RGB(INT y, INT cb, INT cr);
VOID _gx_display_driver_565rgb_rotated_jpeg_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);
VOID _gx_display_driver_565rgb_rotated_png_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);
#endif
Expand All @@ -301,7 +302,6 @@ VOID _gx_display_driver_24xrgb_rotated_pixel_blend(GX_DRAW_CONTEXT *context,


#if defined(GX_SOFTWARE_DECODER_SUPPORT)
UINT _gx_display_driver_24xrgb_YCbCr2RGB(INT y, INT cb, INT cr);
VOID _gx_display_driver_24xrgb_jpeg_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);
VOID _gx_display_driver_24xrgb_png_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);
VOID _gx_display_driver_24xrgb_rotated_jpeg_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);
Expand Down
152 changes: 130 additions & 22 deletions common/inc/gx_image_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* gx_image_reader.h PORTABLE C */
/* 6.2.0 */
/* 6.x */
/* AUTHOR */
/* */
/* Kenneth Maxwell, Microsoft Corporation */
Expand All @@ -52,12 +52,19 @@
/* added definitions for fixed */
/* size table dimensions, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Ting Zhu Modified comment(s), added */
/* support for ARM Helium, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
#if defined(GX_SOFTWARE_DECODER_SUPPORT)
#ifndef GX_IMAGE_READER_H
#define GX_IMAGE_READER_H

#if defined(GX_ENABLE_ARM_HELIUM)
#include <arm_mve.h>
#endif

#define GX_IMAGE_FORMAT_1BPP 0xf0
#define GX_IMAGE_FORMAT_2BPP 0xf1
#define GX_IMAGE_FORMAT_4BPP 0xf2
Expand All @@ -83,15 +90,21 @@
GX_PNG_HUFFMAN_LIT_CODE_LEN_TABLE_SIZE + \
GX_PNG_HUFFMAN_DIST_CODE_LEN_TABLE_SIZE + \
GX_PNG_PALETTE_TABLE_SIZE)
#define JPG_MAX_COMPONENTS 3
#define HUFF_TABLE_DIMENSION 2
#define JPG_QUANT_TABLE_DIMENSION 4
#define JPG_MAX_COMPONENTS 3
#define HUFF_TABLE_DIMENSION 2
#define JPG_QUANT_TABLE_DIMENSION 4

/* Control block used internally for jpeg reader. */
typedef struct GX_HUFFCODE_INFO_STRUCT
{
USHORT start;
USHORT end;
USHORT index;
GX_UBYTE bits;
} GX_HUFFCODE_INFO;

typedef struct GX_JPEG_INFO_STRUCT
{
UINT (*gx_jpeg_mcu_draw)(struct GX_JPEG_INFO_STRUCT *, INT, INT);
USHORT gx_jpeg_width;
USHORT gx_jpeg_height;
INT gx_jpeg_num_of_components;
Expand All @@ -101,22 +114,35 @@ typedef struct GX_JPEG_INFO_STRUCT
GX_UBYTE gx_jpeg_dc_table_index[JPG_MAX_COMPONENTS];
GX_UBYTE gx_jpeg_ac_table_index[JPG_MAX_COMPONENTS];
INT gx_jpeg_quantization_table[JPG_QUANT_TABLE_DIMENSION][64];
INT *gx_jpeg_huffman_table[HUFF_TABLE_DIMENSION][HUFF_TABLE_DIMENSION];
GX_VALUE gx_jpeg_huffman_bits_count[HUFF_TABLE_DIMENSION][HUFF_TABLE_DIMENSION][16];
GX_UBYTE *gx_jpeg_huffman_table[HUFF_TABLE_DIMENSION][HUFF_TABLE_DIMENSION];
GX_HUFFCODE_INFO gx_jpeg_huffman_code_info[HUFF_TABLE_DIMENSION][HUFF_TABLE_DIMENSION][16];
INT gx_jpeg_restart_interval;
GX_UBYTE gx_jpeg_Y_block[256];
GX_UBYTE gx_jpeg_Cr_block[64];
GX_UBYTE gx_jpeg_Cb_block[64];
GX_BYTE gx_jpeg_Y_block[256];
GX_BYTE gx_jpeg_Cr_block[64];
GX_BYTE gx_jpeg_Cb_block[64];
INT gx_jpeg_pre_dc[JPG_MAX_COMPONENTS];
INT gx_jpeg_vecter[64];
GX_UBYTE *gx_jpeg_data;
INT gx_jpeg_data_size;
INT gx_jpeg_data_index;
GX_UBYTE *gx_jpeg_decoded_data;
UINT gx_jpeg_decoded_data_size;
GX_DRAW_CONTEXT *gx_jpeg_draw_context;
INT gx_jpeg_draw_xpos;
INT gx_jpeg_draw_ypos;
UINT gx_jpeg_bit_buffer;
UINT gx_jpeg_bit_count;
#if defined(GX_ENABLE_ARM_HELIUM)
VOID (*gx_jpeg_pixel_write_helium)(struct GX_JPEG_INFO_STRUCT *jpeg_info, uint8x16_t vred, uint8x16_t vgreen, uint8x16_t vblue, INT size);
#else
VOID (*gx_jpeg_pixel_write)(struct GX_JPEG_INFO_STRUCT *jpeg_info, GX_UBYTE red, GX_UBYTE green, GX_UBYTE blue);
#endif
GX_UBYTE *gx_jpeg_output_buffer;
USHORT gx_jpeg_output_width;
USHORT gx_jpeg_output_height;
INT gx_jpeg_output_stride;
GX_RECTANGLE gx_jpeg_output_clip;
INT gx_jpeg_output_xpos;
INT gx_jpeg_output_ypos;
GX_UBYTE gx_jpeg_output_bpp;
GX_UBYTE gx_jpeg_output_color_format;
USHORT gx_jpeg_output_rotation_angle;
GX_UBYTE *gx_jpeg_putdata;
} GX_JPEG_INFO;

/* control block used internally for png reader */
Expand Down Expand Up @@ -165,11 +191,9 @@ UINT _gx_image_reader_create(GX_IMAGE_READER *image_reader,

/* Define internal function prototypes. */
UINT _gx_image_reader_png_decode(GX_CONST GX_UBYTE *read_data, ULONG read_data_size, GX_PIXELMAP *outmap);
UINT _gx_image_reader_jpeg_decode(GX_CONST GX_UBYTE *read_data, ULONG data_size, GX_PIXELMAP *outmap);
UINT _gx_image_reader_jpeg_mcu_decode(GX_CONST GX_UBYTE * read_data, ULONG data_size,
GX_DRAW_CONTEXT * context, INT xpos, INT ypos,
UINT(draw_function)(GX_JPEG_INFO *, INT, INT));

UINT _gx_image_reader_jpeg_decode(GX_IMAGE_READER *image_reader, GX_PIXELMAP *outmap);
UINT _gx_image_reader_jpeg_mcu_decode(GX_CONST GX_UBYTE *read_data, ULONG data_size,
GX_DRAW_CONTEXT *context, INT xpos, INT ypos);

UINT _gx_image_reader_pixel_read_callback_set(GX_IMAGE_READER *image_reader, GX_PIXELMAP *outmap);
UINT _gx_image_reader_pixel_write_callback_set(GX_IMAGE_READER *image_reader, GX_PIXELMAP *outmap);
Expand All @@ -194,6 +218,90 @@ UINT _gxe_image_reader_palette_set(GX_IMAGE_READER *image_reader, GX_COLOR *pal,
UINT _gxe_image_reader_start(GX_IMAGE_READER *image_reader, GX_PIXELMAP *outmap);


#endif
#endif
#define GX_JPEG_DECODE_YCBCR2RGB(red, green, blue, y, cb, cr) \
red = y + cr + (cr >> 2) + (cr >> 3) + 128; \
green = y - ((cb >> 2) + (cb >> 4) + (cb >> 5)) - ((cr >> 1) + (cr >> 3) + (cr >> 4) + (cr >> 5)) + 128; \
blue = y + cb + (cb >> 1) + (cb >> 2) + (cb >> 6) + 128;

#if defined(GX_ENABLE_ARM_HELIUM)

/* This offset table contains four offset vectors that used to gather load 16 cb/cr values to a 8x16 vector.
The table index represents the subsampling factor in horizontal. */
static uint8x16_t _gx_jpeg_cbcr_offset_table[7] = {
{0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0}, /* h = 1 */
{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}, /* h = 2 */
{0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7}, /* h = 2 */
{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3}, /* h = 4 */
{0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4}, /* h = 4 */
{0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4}, /* h = 4 */
{0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4}, /* h = 4 */
};

static uint8x16_t _gx_jpeg_cbcr_offset_rotated_table_cw[3] = {
{0, 8, 16, 24, 32, 40, 48, 56, 0, 0, 0, 0, 0, 0, 0, 0}, /* cw, v = 1 */
{0, 0, 8, 8, 16, 16, 24, 24, 32, 32, 40, 40, 48, 48, 56, 56}, /* cw, v = 2 */
{0, 8, 8, 16, 16, 24, 24, 32, 32, 40, 40, 48, 48, 56, 56, 56} /* cw, v = 2 */
};

static uint8x16_t _gx_jpeg_cbcr_offset_rotated_table_ccw[2] = {
{56, 48, 40, 32, 24, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* ccw, v = 1 */
{56, 56, 48, 48, 40, 40, 32, 32, 24, 24, 16, 16, 8, 8, 0, 0}, /* ccw, v = 2 */
};

static uint8x16_t _gx_jpeg_y_offset_rotated_table_cw[3] = {
{0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120}, /* cw, h = 1, v = 1 */
{0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240}, /* cw, h = 2, v = 1 or v = 2 */
{0, 32, 64, 96, 128, 160, 192, 224, 224, 224, 224, 224, 224, 224, 224, 224} /* cw, h = 4, v = 1 */
};

static uint8x16_t _gx_jpeg_y_offset_rotated_table_ccw[4] = {
{56, 48, 40, 32, 24, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* ccw, h = 1, v = 1 */
{112, 96, 80, 64, 48, 32, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* ccw, h = 2, v = 1 */
{240, 224, 208, 192, 176, 160, 144, 128, 112, 96, 80, 64, 48, 32, 16, 0}, /* ccw, h = 2, v = 2 */
{224, 192, 160, 128, 96, 64, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* ccw, h = 4, v = 1 */
};


#define GX_JPEG_DECODE_YCBCR2RGB_HELIUM(vred, vgreen, vblue, y, cb, cr) \
{ \
int8x16_t vt; \
vred = (uint8x16_t)vqaddq_s8(y, cr); \
vt = vshrq_n_s8(cr, 2); \
vred = (uint8x16_t)vqaddq_s8((int8x16_t)vred, vt); \
vt = vshrq_n_s8(cr, 3); \
vred = (uint8x16_t)vqaddq_s8((int8x16_t)vred, vt); \
vred = vaddq_n_u8(vred, 128); \
\
vt = vshrq_n_s8(cb, 2); \
vgreen = (uint8x16_t)vshrq_n_s8(cb, 4); \
vgreen = (uint8x16_t)vqaddq_s8((int8x16_t)vgreen, vt); \
vt = vshrq_n_s8(cb, 5); \
vgreen = (uint8x16_t)vqaddq_s8((int8x16_t)vgreen, vt); \
vt = vshrq_n_s8(cr, 1); \
vgreen = (uint8x16_t)vqaddq_s8((int8x16_t)vgreen, vt); \
vt = vshrq_n_s8(cr, 3); \
vgreen = (uint8x16_t)vqaddq_s8((int8x16_t)vgreen, vt); \
vt = vshrq_n_s8(cr, 4); \
vgreen = (uint8x16_t)vqaddq_s8((int8x16_t)vgreen, vt); \
vt = vshrq_n_s8(cr, 5); \
vgreen = (uint8x16_t)vqaddq_s8((int8x16_t)vgreen, vt); \
vgreen = (uint8x16_t)vqsubq_s8(y, (int8x16_t)vgreen); \
vgreen = vaddq_n_u8(vgreen, 128); \
\
vblue = (uint8x16_t)vqaddq_s8(y, cb); \
vt = vshrq_n_s8(cb, 1); \
vblue = (uint8x16_t)vqaddq_s8((int8x16_t)vblue, vt); \
vt = vshrq_n_s8(cb, 2); \
vblue = (uint8x16_t)vqaddq_s8((int8x16_t)vblue, vt); \
vt = vshrq_n_s8(cb, 6); \
vblue = (uint8x16_t)vqaddq_s8((int8x16_t)vblue, vt); \
vblue = vaddq_n_u8(vblue, 128); \
}


#endif /* GX_ENABLE_ARM_HELIUM */

#endif /* GX_IMAGE_READER_H */

#endif /* GX_SOFTWARE_DECODER_SUPPORT */

10 changes: 9 additions & 1 deletion common/inc/gx_user_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* gx_user.h PORTABLE C */
/* 6.1.10 */
/* 6.x */
/* AUTHOR */
/* */
/* Kenneth Maxwell, Microsoft Corporation */
Expand All @@ -45,6 +45,10 @@
/* 01-31-2022 Kenneth Maxwell Modified comment(s), */
/* fixed typo, */
/* resulting in version 6.1.10 */
/* xx-xx-xxxx Ting Zhu Modified comment(s), */
/* added GX_ENABLE_ARM_HELIUM */
/* definition, */
/* resulting in version 6.x */
/* */
/**************************************************************************/

Expand All @@ -68,5 +72,9 @@
/* This can be defined to insert an application specific data
field into the GX_WIDGET control block */
/* #define GX_WIDGET_USER_DATA */

/* This can be defined to enable the use of ARM Helium intrinsics for
JPEG decoding. */
/* #define GX_ENABLE_ARM_HELIUM */
#endif

Loading

0 comments on commit 50ead25

Please sign in to comment.