From 23f602a07a570de8a3a356b6b156fe036c38ab27 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 5 Sep 2006 17:06:14 -0700 Subject: [PATCH] Augment tinyjpeg so that we can decode straight into the buffer; clear the screen on startup. --- com32/include/tinyjpeg.h | 6 ++++-- com32/lib/jpeg/bgr24.c | 17 ++++++++++------- com32/lib/jpeg/bgra32.c | 21 +++++++++++--------- com32/lib/jpeg/grey.c | 23 +++++++++++++++------- com32/lib/jpeg/rgb24.c | 17 ++++++++++------- com32/lib/jpeg/rgba32.c | 17 ++++++++++------- com32/lib/jpeg/tinyjpeg-internal.h | 1 + com32/lib/jpeg/tinyjpeg.c | 38 ++++++++++++++++++++++++++++--------- com32/lib/jpeg/yuv420p.c | 39 ++++++++++++++++++++++---------------- com32/lib/sys/vesa/background.c | 30 ++++++++++++----------------- com32/lib/sys/vesa/initvesa.c | 2 +- 11 files changed, 128 insertions(+), 83 deletions(-) diff --git a/com32/include/tinyjpeg.h b/com32/include/tinyjpeg.h index b800a4b..d320f9b 100644 --- a/com32/include/tinyjpeg.h +++ b/com32/include/tinyjpeg.h @@ -59,8 +59,10 @@ int tinyjpeg_parse_header(struct jdec_private *priv, const unsigned char *buf, u int tinyjpeg_decode(struct jdec_private *priv, tinyjpeg_colorspace_t pixel_format); const char *tinyjpeg_get_errorstring(struct jdec_private *priv); void tinyjpeg_get_size(struct jdec_private *priv, unsigned int *width, unsigned int *height); -int tinyjpeg_get_components(struct jdec_private *priv, unsigned char **components); -int tinyjpeg_set_components(struct jdec_private *priv, unsigned char **components, unsigned int ncomponents); +int tinyjpeg_get_components(struct jdec_private *priv, unsigned char **components, unsigned int ncomponents); +int tinyjpeg_set_components(struct jdec_private *priv, unsigned char * const *components, unsigned int ncomponents); +int tinyjpeg_get_bytes_per_row(struct jdec_private *priv, unsigned int *bytes, unsigned int ncomponents); +int tinyjpeg_set_bytes_per_row(struct jdec_private *priv, const unsigned int *bytes, unsigned int ncomponents); int tinyjpeg_set_flags(struct jdec_private *priv, int flags); #ifdef __cplusplus diff --git a/com32/lib/jpeg/bgr24.c b/com32/lib/jpeg/bgr24.c index 465d58e..3f2f4f9 100644 --- a/com32/lib/jpeg/bgr24.c +++ b/com32/lib/jpeg/bgr24.c @@ -84,7 +84,7 @@ static void YCrCB_to_BGR24_1x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*3 - 8*3; + offset_to_next_row = priv->bytes_per_row[0] - 8*3; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -140,7 +140,7 @@ static void YCrCB_to_BGR24_2x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*3 - 16*3; + offset_to_next_row = priv->bytes_per_row[0] - 16*3; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -202,11 +202,11 @@ static void YCrCB_to_BGR24_1x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*3; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = 2*priv->width*3 - 8*3; + offset_to_next_row = 2*priv->bytes_per_row[0] - 8*3; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -270,11 +270,11 @@ static void YCrCB_to_BGR24_2x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*3; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = (priv->width*3*2) - 16*3; + offset_to_next_row = 2*priv->bytes_per_row[0] - 16*3; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -338,7 +338,10 @@ static int initialize_bgr24(struct jdec_private *priv, { if (priv->components[0] == NULL) priv->components[0] = (uint8_t *)malloc(priv->width * priv->height * 3); - bytes_per_blocklines[0] = priv->width * 3; + if (!priv->bytes_per_row[0]) + priv->bytes_per_row[0] = priv->width * 3; + + bytes_per_blocklines[0] = priv->bytes_per_row[0]; bytes_per_mcu[0] = 3*8; return !priv->components[0]; diff --git a/com32/lib/jpeg/bgra32.c b/com32/lib/jpeg/bgra32.c index ba0db70..fe6b813 100644 --- a/com32/lib/jpeg/bgra32.c +++ b/com32/lib/jpeg/bgra32.c @@ -84,7 +84,7 @@ static void YCrCB_to_BGRA32_1x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*4 - 8*4; + offset_to_next_row = priv->bytes_per_row[0] - 8*4; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -142,7 +142,7 @@ static void YCrCB_to_BGRA32_2x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*4 - 16*4; + offset_to_next_row = priv->bytes_per_row[0] - 16*4; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -208,11 +208,11 @@ static void YCrCB_to_BGRA32_1x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*4; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = 2*priv->width*4 - 8*4; + offset_to_next_row = 2*priv->bytes_per_row[0] - 8*4; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -280,11 +280,11 @@ static void YCrCB_to_BGRA32_2x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*4; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = (priv->width*4*2) - 16*4; + offset_to_next_row = 2*priv->bytes_per_row[0] - 16*4; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -351,12 +351,15 @@ static void YCrCB_to_BGRA32_2x2(struct jdec_private *priv) } static int initialize_bgra32(struct jdec_private *priv, - unsigned int *bytes_per_blocklines, - unsigned int *bytes_per_mcu) + unsigned int *bytes_per_blocklines, + unsigned int *bytes_per_mcu) { if (priv->components[0] == NULL) priv->components[0] = (uint8_t *)malloc(priv->width * priv->height * 4); - bytes_per_blocklines[0] = priv->width * 4; + if (!priv->bytes_per_row[0]) + priv->bytes_per_row[0] = priv->width * 4; + + bytes_per_blocklines[0] = priv->bytes_per_row[0]; bytes_per_mcu[0] = 4*8; return !priv->components[0]; diff --git a/com32/lib/jpeg/grey.c b/com32/lib/jpeg/grey.c index edeb74a..bb55b7e 100644 --- a/com32/lib/jpeg/grey.c +++ b/com32/lib/jpeg/grey.c @@ -54,7 +54,7 @@ static void YCrCB_to_Grey_1x1(struct jdec_private *priv) p = priv->plane[0]; y = priv->Y; - offset_to_next_row = priv->width; + offset_to_next_row = priv->bytes_per_row[0]; for (i=0; i<8; i++) { memcpy(p, y, 8); @@ -74,14 +74,16 @@ static void YCrCB_to_Grey_2x1(struct jdec_private *priv) const unsigned char *y; unsigned char *p; unsigned int i; + int offset_to_next_row; p = priv->plane[0]; y = priv->Y; + offset_to_next_row = priv->bytes_per_row[0]; for (i=0; i<8; i++) { memcpy(p, y, 16); y += 16; - p += priv->width; + p += offset_to_next_row; } } @@ -99,14 +101,16 @@ static void YCrCB_to_Grey_1x2(struct jdec_private *priv) const unsigned char *y; unsigned char *p; unsigned int i; + int offset_to_next_row; p = priv->plane[0]; y = priv->Y; + offset_to_next_row = priv->bytes_per_row[0]; for (i=0; i<16; i++) { memcpy(p, y, 8); y += 8; - p += priv->width; + p += offset_to_next_row; } } @@ -123,24 +127,29 @@ static void YCrCB_to_Grey_2x2(struct jdec_private *priv) const unsigned char *y; unsigned char *p; unsigned int i; + int offset_to_next_row; p = priv->plane[0]; y = priv->Y; + offset_to_next_row = priv->bytes_per_row[0]; for (i=0; i<16; i++) { memcpy(p, y, 16); y += 16; - p += priv->width; + p += offset_to_next_row; } } static int initialize_grey(struct jdec_private *priv, - unsigned int *bytes_per_blocklines, - unsigned int *bytes_per_mcu) + unsigned int *bytes_per_blocklines, + unsigned int *bytes_per_mcu) { if (priv->components[0] == NULL) priv->components[0] = (uint8_t *)malloc(priv->width * priv->height * 3); - bytes_per_blocklines[0] = priv->width * 3; + if (!priv->bytes_per_row[0]) + priv->bytes_per_row[0] = priv->width * 3; + + bytes_per_blocklines[0] = priv->bytes_per_row[0]; bytes_per_mcu[0] = 3*8; return !priv->components[0]; diff --git a/com32/lib/jpeg/rgb24.c b/com32/lib/jpeg/rgb24.c index 65c0695..d3ee07a 100644 --- a/com32/lib/jpeg/rgb24.c +++ b/com32/lib/jpeg/rgb24.c @@ -84,7 +84,7 @@ static void YCrCB_to_RGB24_1x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*3 - 8*3; + offset_to_next_row = priv->bytes_per_row[0] - 8*3; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -139,7 +139,7 @@ static void YCrCB_to_RGB24_2x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*3 - 16*3; + offset_to_next_row = priv->bytes_per_row[0] - 16*3; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -202,11 +202,11 @@ static void YCrCB_to_RGB24_1x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*3; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = 2*priv->width*3 - 8*3; + offset_to_next_row = 2*priv->bytes_per_row[0] - 8*3; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -269,11 +269,11 @@ static void YCrCB_to_RGB24_2x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*3; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = (priv->width*3*2) - 16*3; + offset_to_next_row = 2*priv->bytes_per_row[0] - 16*3; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -337,7 +337,10 @@ static int initialize_rgb24(struct jdec_private *priv, { if (priv->components[0] == NULL) priv->components[0] = (uint8_t *)malloc(priv->width * priv->height * 3); - bytes_per_blocklines[0] = priv->width * 3; + if (!priv->bytes_per_row[0]) + priv->bytes_per_row[0] = priv->width * 3; + + bytes_per_blocklines[0] = priv->bytes_per_row[0]; bytes_per_mcu[0] = 3*8; return !priv->components[0]; diff --git a/com32/lib/jpeg/rgba32.c b/com32/lib/jpeg/rgba32.c index 2934bcd..2ad9112 100644 --- a/com32/lib/jpeg/rgba32.c +++ b/com32/lib/jpeg/rgba32.c @@ -84,7 +84,7 @@ static void YCrCB_to_RGBA32_1x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*4 - 8*4; + offset_to_next_row = priv->bytes_per_row[0] - 8*4; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -140,7 +140,7 @@ static void YCrCB_to_RGBA32_2x1(struct jdec_private *priv) Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = priv->width*4 - 16*4; + offset_to_next_row = priv->bytes_per_row[0] - 16*4; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -206,11 +206,11 @@ static void YCrCB_to_RGBA32_1x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*4; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = 2*priv->width*4 - 8*4; + offset_to_next_row = 2*priv->bytes_per_row[0] - 8*4; for (i=0; i<8; i++) { for (j=0; j<8; j++) { @@ -277,11 +277,11 @@ static void YCrCB_to_RGBA32_2x2(struct jdec_private *priv) #define FIX(x) ((int)((x) * (1UL<plane[0]; - p2 = priv->plane[0] + priv->width*4; + p2 = priv->plane[0] + priv->bytes_per_row[0]; Y = priv->Y; Cb = priv->Cb; Cr = priv->Cr; - offset_to_next_row = (priv->width*4*2) - 16*4; + offset_to_next_row = 2*priv->bytes_per_row[0] - 16*4; for (i=0; i<8; i++) { for (j=0;j<8;j++) { @@ -353,7 +353,10 @@ static int initialize_rgba32(struct jdec_private *priv, { if (priv->components[0] == NULL) priv->components[0] = (uint8_t *)malloc(priv->width * priv->height * 4); - bytes_per_blocklines[0] = priv->width * 4; + if (!priv->bytes_per_row[0]) + priv->bytes_per_row[0] = priv->width * 4; + + bytes_per_blocklines[0] = priv->bytes_per_row[0]; bytes_per_mcu[0] = 4*8; return !priv->components[0]; diff --git a/com32/lib/jpeg/tinyjpeg-internal.h b/com32/lib/jpeg/tinyjpeg-internal.h index abad084..a414581 100644 --- a/com32/lib/jpeg/tinyjpeg-internal.h +++ b/com32/lib/jpeg/tinyjpeg-internal.h @@ -76,6 +76,7 @@ struct jdec_private { /* Public variables */ uint8_t *components[COMPONENTS]; + unsigned int bytes_per_row[COMPONENTS]; unsigned int width, height; /* Size of the image */ unsigned int flags; diff --git a/com32/lib/jpeg/tinyjpeg.c b/com32/lib/jpeg/tinyjpeg.c index ca180a0..a93a512 100644 --- a/com32/lib/jpeg/tinyjpeg.c +++ b/com32/lib/jpeg/tinyjpeg.c @@ -787,12 +787,6 @@ int tinyjpeg_decode(struct jdec_private *priv, const decode_MCU_fct *decode_mcu_table; convert_colorspace_fct convert_to_pixfmt; - /* To keep gcc happy initialize some array */ - bytes_per_mcu[1] = 0; - bytes_per_mcu[2] = 0; - bytes_per_blocklines[1] = 0; - bytes_per_blocklines[2] = 0; - decode_mcu_table = pixfmt->decode_mcu_table; /* Fix: check return value */ @@ -864,15 +858,17 @@ void tinyjpeg_get_size(struct jdec_private *priv, unsigned int *width, unsigned *height = priv->height; } -int tinyjpeg_get_components(struct jdec_private *priv, unsigned char **components) +int tinyjpeg_get_components(struct jdec_private *priv, unsigned char **components, unsigned int ncomponents) { int i; - for (i=0; priv->components[i] && i COMPONENTS) + ncomponents = COMPONENTS; + for (i=0; icomponents[i]; return 0; } -int tinyjpeg_set_components(struct jdec_private *priv, unsigned char **components, unsigned int ncomponents) +int tinyjpeg_set_components(struct jdec_private *priv, unsigned char * const *components, unsigned int ncomponents) { int i; if (ncomponents > COMPONENTS) @@ -882,6 +878,30 @@ int tinyjpeg_set_components(struct jdec_private *priv, unsigned char **component return 0; } +int tinyjpeg_get_bytes_per_row(struct jdec_private *priv, + unsigned int *bytes, + unsigned int ncomponents) +{ + int i; + if (ncomponents > COMPONENTS) + ncomponents = COMPONENTS; + for (i=0; ibytes_per_row[i]; + return 0; +} + +int tinyjpeg_set_bytes_per_row(struct jdec_private *priv, + const unsigned int *bytes, + unsigned int ncomponents) +{ + int i; + if (ncomponents > COMPONENTS) + ncomponents = COMPONENTS; + for (i=0; ibytes_per_row[i] = bytes[i]; + return 0; +} + int tinyjpeg_set_flags(struct jdec_private *priv, int flags) { int oldflags = priv->flags; diff --git a/com32/lib/jpeg/yuv420p.c b/com32/lib/jpeg/yuv420p.c index 5411aa8..6d2bd05 100644 --- a/com32/lib/jpeg/yuv420p.c +++ b/com32/lib/jpeg/yuv420p.c @@ -60,8 +60,8 @@ static void YCrCB_to_YUV420P_1x1(struct jdec_private *priv) for (i=0; i<8; i++) { memcpy(p, y, 8); - p+=priv->width; - y+=8; + p += priv->bytes_per_row[0]; + y += 8; } p = priv->plane[1]; @@ -71,7 +71,7 @@ static void YCrCB_to_YUV420P_1x1(struct jdec_private *priv) for (j=0; j<8; j+=2, s+=2) *p++ = *s; s += 8; /* Skip one line */ - p += priv->width/2 - 4; + p += priv->bytes_per_row[1] - 4; } p = priv->plane[2]; @@ -81,7 +81,7 @@ static void YCrCB_to_YUV420P_1x1(struct jdec_private *priv) for (j=0; j<8; j+=2, s+=2) *p++ = *s; s += 8; /* Skip one line */ - p += priv->width/2 - 4; + p += priv->bytes_per_row[2] - 4; } } @@ -102,7 +102,7 @@ static void YCrCB_to_YUV420P_2x1(struct jdec_private *priv) for (i=0; i<8; i++) { memcpy(p, y1, 16); - p += priv->width; + p += priv->bytes_per_row[0]; y1 += 16; } @@ -113,7 +113,7 @@ static void YCrCB_to_YUV420P_2x1(struct jdec_private *priv) for (j=0; j<8; j+=1, s+=1) *p++ = *s; s += 8; /* Skip one line */ - p += priv->width/2 - 8; + p += priv->bytes_per_row[1] - 8; } p = priv->plane[2]; @@ -123,7 +123,7 @@ static void YCrCB_to_YUV420P_2x1(struct jdec_private *priv) for (j=0; j<8; j+=1, s+=1) *p++ = *s; s += 8; /* Skip one line */ - p += priv->width/2 - 8; + p += priv->bytes_per_row[2] - 8; } } @@ -147,7 +147,7 @@ static void YCrCB_to_YUV420P_1x2(struct jdec_private *priv) for (i=0; i<16; i++) { memcpy(p, y, 8); - p+=priv->width; + p+=priv->bytes_per_row[0]; y+=8; } @@ -157,7 +157,7 @@ static void YCrCB_to_YUV420P_1x2(struct jdec_private *priv) { for (j=0; j<8; j+=2, s+=2) *p++ = *s; - p += priv->width/2 - 4; + p += priv->bytes_per_row[1] - 4; } p = priv->plane[2]; @@ -166,7 +166,7 @@ static void YCrCB_to_YUV420P_1x2(struct jdec_private *priv) { for (j=0; j<8; j+=2, s+=2) *p++ = *s; - p += priv->width/2 - 4; + p += priv->bytes_per_row[2] - 4; } } @@ -189,7 +189,7 @@ static void YCrCB_to_YUV420P_2x2(struct jdec_private *priv) for (i=0; i<16; i++) { memcpy(p, y1, 16); - p += priv->width; + p += priv->bytes_per_row[0]; y1 += 16; } @@ -199,7 +199,7 @@ static void YCrCB_to_YUV420P_2x2(struct jdec_private *priv) { memcpy(p, s, 8); s += 8; - p += priv->width/2; + p += priv->bytes_per_row[1]; } p = priv->plane[2]; @@ -208,7 +208,7 @@ static void YCrCB_to_YUV420P_2x2(struct jdec_private *priv) { memcpy(p, s, 8); s += 8; - p += priv->width/2; + p += priv->bytes_per_row[2]; } } @@ -222,9 +222,16 @@ static int initialize_yuv420p(struct jdec_private *priv, priv->components[1] = (uint8_t *)malloc(priv->width * priv->height/4); if (priv->components[2] == NULL) priv->components[2] = (uint8_t *)malloc(priv->width * priv->height/4); - bytes_per_blocklines[0] = priv->width; - bytes_per_blocklines[1] = priv->width/4; - bytes_per_blocklines[2] = priv->width/4; + if (!priv->bytes_per_row[0]) + priv->bytes_per_row[0] = priv->width; + if (!priv->bytes_per_row[1]) + priv->bytes_per_row[1] = priv->width/2; + if (!priv->bytes_per_row[2]) + priv->bytes_per_row[2] = priv->width/2; + + bytes_per_blocklines[0] = priv->bytes_per_row[0]; + bytes_per_blocklines[1] = priv->bytes_per_row[1]/2; + bytes_per_blocklines[2] = priv->bytes_per_row[2]/2; bytes_per_mcu[0] = 8; bytes_per_mcu[1] = 4; bytes_per_mcu[2] = 4; diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c index 026cbc7..64a4604 100644 --- a/com32/lib/sys/vesa/background.c +++ b/com32/lib/sys/vesa/background.c @@ -160,10 +160,8 @@ static int read_jpeg_file(FILE *fp, uint8_t *header, int len) size_t length_of_file = filesize(fp); unsigned int width, height; int rv = -1; - unsigned char *components[3], *in_row_ptr; - uint32_t *out_row_ptr; - int bytes_per_row, copy_bytes; - int i; + unsigned char *components[1]; + unsigned int bytes_per_row[1]; jpeg_file = malloc(length_of_file); if (!jpeg_file) @@ -181,28 +179,24 @@ static int read_jpeg_file(FILE *fp, uint8_t *header, int len) goto err; tinyjpeg_get_size(jdec, &width, &height); - if (width > 4096 || height > 4096) + if (width > VIDEO_X_SIZE || height > VIDEO_Y_SIZE) goto err; - tinyjpeg_decode(jdec, TINYJPEG_FMT_BGRA32); - tinyjpeg_get_components(jdec, components); - - bytes_per_row = width << 2; - copy_bytes = min(width, (unsigned int)VIDEO_X_SIZE) << 2; - in_row_ptr = components[0]; - out_row_ptr = (uint32_t *)&__vesacon_background[0]; + components[0] = (void *)&__vesacon_background[0]; + tinyjpeg_set_components(jdec, components, 1); + bytes_per_row[0] = VIDEO_X_SIZE << 2; + tinyjpeg_set_bytes_per_row(jdec, bytes_per_row, 1); - for (i = 0; i < (int)height; i++) { - memcpy(out_row_ptr, in_row_ptr, copy_bytes); - in_row_ptr += bytes_per_row; - out_row_ptr += VIDEO_X_SIZE; - } + tinyjpeg_decode(jdec, TINYJPEG_FMT_BGRA32); rv = 0; err: + /* Don't use tinyjpeg_free() here, since we didn't allow tinyjpeg + to allocate the frame buffer */ if (jdec) - tinyjpeg_free(jdec); + free(jdec); + if (jpeg_file) free(jpeg_file); diff --git a/com32/lib/sys/vesa/initvesa.c b/com32/lib/sys/vesa/initvesa.c index ad551a9..82c9940 100644 --- a/com32/lib/sys/vesa/initvesa.c +++ b/com32/lib/sys/vesa/initvesa.c @@ -164,7 +164,7 @@ static int vesacon_set_mode(void) /* Now set video mode */ rm.eax.w[0] = 0x4F02; /* Set SVGA video mode */ - rm.ebx.w[0] = mode | 0xC000; /* Don't clear video RAM, use linear fb */ + rm.ebx.w[0] = mode | 0x4000; /* Clear video RAM, use linear fb */ __intcall(0x10, &rm, &rm); if ( rm.eax.w[0] != 0x004F ) { rm.eax.w[0] = 0x0003; /* Set regular text mode */ -- 2.7.4