diff options
author | H. Peter Anvin <hpa@zytor.com> | 2006-09-05 17:06:14 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2006-09-05 17:06:14 -0700 |
commit | 23f602a07a570de8a3a356b6b156fe036c38ab27 (patch) | |
tree | df0746687069b53ef0ffa6ccfee955b67ad184c9 /com32/lib/sys/vesa/background.c | |
parent | 0cd5e05574453627bc9d5fba7bb9c6a6b2d3dd22 (diff) | |
download | syslinux-23f602a07a570de8a3a356b6b156fe036c38ab27.tar.gz syslinux-23f602a07a570de8a3a356b6b156fe036c38ab27.tar.xz syslinux-23f602a07a570de8a3a356b6b156fe036c38ab27.zip |
Augment tinyjpeg so that we can decode straight into the buffer;
clear the screen on startup.
Diffstat (limited to 'com32/lib/sys/vesa/background.c')
-rw-r--r-- | com32/lib/sys/vesa/background.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c index 026cbc75..64a46045 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); |