On Wed, Jul 23, 2008 at 10:56 PM, Colin D Bennett <[EMAIL PROTECTED]> wrote: > On Wed, 23 Jul 2008 07:33:32 -0700 > Colin D Bennett <[EMAIL PROTECTED]> wrote: > >> On Wed, 23 Jul 2008 10:05:36 +0800 >> Bean <[EMAIL PROTECTED]> wrote: >> >> > On Wed, Jul 23, 2008 at 3:06 AM, Colin D Bennett <[EMAIL PROTECTED]> >> > wrote: >> > > On Tue, 22 Jul 2008 14:48:31 -0400 >> > > Pavel Roskin <[EMAIL PROTECTED]> wrote: >> > > >> > >> On Tue, 2008-07-22 at 08:43 -0700, Colin D Bennett wrote: >> > >> > This patch speeds up loading a TGA image on my test system from >> > >> > 29 seconds to approximately 1 second. >> > >> > >> > >> > I noticed that on my 1 GHz test system running from an IDE >> > >> > CompactFlash drive, loading a certain TGA image in GRUB takes >> > >> > about 29 seconds. >> > >> >> > >> I'm sorry for straying from your point, but maybe we should drop >> > >> TGA support. It was the first image format for GRUB to support, >> > >> but now PNG is supported, and it should be better in all aspects. >> > > >> > > I agree that TGA is not, in general, a great choice for an image >> > > format (unless it is faster to load a large background image -- a >> > > 1024x768 RGB PNG file may take more time to decompress than a TGA >> > > image would take to load -- although perhaps an uncompressed PNG >> > > file would be comparable in speed to load). However, I have not >> > > been able to load any PNG images that I have tried to use. >> > > Something about the chunk type not being supported. >> > > >> > >> > Hi, >> > >> > Please upload the png file that cause problem. >> > >> > Also note that png use DEFLATE compression. I write a decoder in >> > png, which may be a little slow. Perhaps I can import the decoder >> > from zlib, if copyright allows. >> >> Ok, after some more testing, I have found that if I create PNG images >> with ImageMagick or The GIMP, they work. However, I have an image >> that I was trying to use as a GRUB background which is from a MythTV >> theme called Titivillus. The PNG file from the MythTV theme doesn't >> load in GRUB. I get the message "error: png: block type fixed not >> supported". > > Oops! After more testing, I have found PNG images that I saved in The > GIMP which also refuse to load due to the "block type fixed not > supported" error. One ZIP file [1] contains images that all fail to > load in GRUB with that error, and the other [2] contains similar images > that load just fine. > > [1] gibibit.com/upload/grub-png-bad.zip > [2] gibibit.com/upload/grub-png-good.zip
Hi, This patch should fix the problem. -- Bean
diff --git a/video/readers/png.c b/video/readers/png.c index 608fa5e..9dac4b6 100644 --- a/video/readers/png.c +++ b/video/readers/png.c @@ -68,7 +68,7 @@ #define DEFLATE_HCLEN_BASE 4 #define DEFLATE_HCLEN_MAX 19 #define DEFLATE_HLIT_BASE 257 -#define DEFLATE_HLIT_MAX 286 +#define DEFLATE_HLIT_MAX 288 #define DEFLATE_HDIST_BASE 1 #define DEFLATE_HDIST_MAX 30 @@ -391,6 +391,41 @@ grub_png_get_huff_code (struct grub_png_data *data, struct huff_table *ht) } static grub_err_t +grub_png_init_fixed_block (struct grub_png_data *data) +{ + int i; + + grub_png_init_huff_table (&data->code_table, DEFLATE_HUFF_LEN, + data->code_values, data->code_maxval, + data->code_offset); + + for (i = 0; i < 144; i++) + grub_png_insert_huff_item (&data->code_table, i, 8); + + for (; i < 256; i++) + grub_png_insert_huff_item (&data->code_table, i, 9); + + for (; i < 280; i++) + grub_png_insert_huff_item (&data->code_table, i, 7); + + for (; i < DEFLATE_HLIT_MAX; i++) + grub_png_insert_huff_item (&data->code_table, i, 8); + + grub_png_build_huff_table (&data->code_table); + + grub_png_init_huff_table (&data->dist_table, DEFLATE_HUFF_LEN, + data->dist_values, data->dist_maxval, + data->dist_offset); + + for (i = 0; i < DEFLATE_HDIST_MAX; i++) + grub_png_insert_huff_item (&data->dist_table, i, 5); + + grub_png_build_huff_table (&data->dist_table); + + return grub_errno; +} + +static grub_err_t grub_png_init_dynamic_block (struct grub_png_data *data) { int nl, nd, nb, i, prev; @@ -699,8 +734,9 @@ grub_png_decode_image_data (struct grub_png_data *data) } case INFLATE_FIXED: - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "png: block type fixed not supported"); + grub_png_init_fixed_block (data); + grub_png_read_dynamic_block (data); + break; case INFLATE_DYNAMIC: grub_png_init_dynamic_block (data);
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel