]> Pileus Git - ~andy/gtk/commitdiff
applied patch from maemo-gtk which avoids the allocation of an
authorMichael Natterer <mitch@imendio.com>
Wed, 14 Dec 2005 12:47:49 +0000 (12:47 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Wed, 14 Dec 2005 12:47:49 +0000 (12:47 +0000)
2005-12-14  Michael Natterer  <mitch@imendio.com>

* gdk-pixbuf/io-jpeg.c: applied patch from maemo-gtk which avoids
the allocation of an intermediate buffer for non-progressive
jpegs. Fixed bug #305894.

* tests/test-images/valid_jpeg_progressive_test: new test image so
we can test both loading code paths in io-jpeg.c

ChangeLog
ChangeLog.pre-2-10
gdk-pixbuf/io-jpeg.c
tests/test-images/valid_jpeg_progressive_test [new file with mode: 0644]

index 6b0093a178c59774b600b228d5dda0d95b36a214..6e268032884cf9eb42a603a59b852b06a4d03f7f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-12-14  Michael Natterer  <mitch@imendio.com>
+
+       * gdk-pixbuf/io-jpeg.c: applied patch from maemo-gtk which avoids
+       the allocation of an intermediate buffer for non-progressive
+       jpegs. Fixed bug #305894.
+
+       * tests/test-images/valid_jpeg_progressive_test: new test image so
+       we can test both loading code paths in io-jpeg.c
+
 Tue Dec 13 09:47:20 2005  Tim Janik  <timj@gtk.org>
 
        * README.in: added a link to the fgloating reference docs in the
index 6b0093a178c59774b600b228d5dda0d95b36a214..6e268032884cf9eb42a603a59b852b06a4d03f7f 100644 (file)
@@ -1,3 +1,12 @@
+2005-12-14  Michael Natterer  <mitch@imendio.com>
+
+       * gdk-pixbuf/io-jpeg.c: applied patch from maemo-gtk which avoids
+       the allocation of an intermediate buffer for non-progressive
+       jpegs. Fixed bug #305894.
+
+       * tests/test-images/valid_jpeg_progressive_test: new test image so
+       we can test both loading code paths in io-jpeg.c
+
 Tue Dec 13 09:47:20 2005  Tim Janik  <timj@gtk.org>
 
        * README.in: added a link to the fgloating reference docs in the
index fe49c256f02efd1da45928ac7f92eb60c5baae81..9c3c064f931fd575a7a6bca4f427ab460d39670c 100644 (file)
@@ -694,7 +694,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
                        int rc;                 
                        
                        /* start decompression */
-                       cinfo->buffered_image = TRUE;
+                       cinfo->buffered_image = cinfo->progressive_mode;
                        rc = jpeg_start_decompress (cinfo);
                        cinfo->do_fancy_upsampling = FALSE;
                        cinfo->do_block_smoothing = FALSE;
@@ -703,8 +703,73 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
                                continue;
 
                        context->did_prescan = TRUE;
+               } else if (!cinfo->buffered_image) {
+                        /* we're decompressing unbuffered so
+                         * get scanline by scanline from jpeg lib
+                         *
+                         * except for handling multiple passes this is
+                         * virtually identical to the next branch
+                         */
+                       guchar *lines[4];
+                       guchar **lptr;
+                       guchar *rowptr;
+                       gint   nlines, i;
+
+                       /* keep going until we've done all scanlines */
+                       while (cinfo->output_scanline < cinfo->output_height) {
+                               lptr = lines;
+                               rowptr = context->dptr;
+                               for (i=0; i < cinfo->rec_outbuf_height; i++) {
+                                       *lptr++ = rowptr;
+                                       rowptr += context->pixbuf->rowstride;
+                               }
+
+                               nlines = jpeg_read_scanlines (cinfo, lines,
+                                                             cinfo->rec_outbuf_height);
+                               if (nlines == 0)
+                                       break;
+
+                               switch (cinfo->out_color_space) {
+                                   case JCS_GRAYSCALE:
+                                           explode_gray_into_buf (cinfo, lines);
+                                           break;
+                                   case JCS_RGB:
+                                           /* do nothing */
+                                           break;
+                                   case JCS_CMYK:
+                                           convert_cmyk_to_rgb (cinfo, lines);
+                                           break;
+                                   default:
+                                           if (error && *error == NULL) {
+                                                   g_set_error (error,
+                                                                GDK_PIXBUF_ERROR,
+                                                                GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
+                                                                _("Unsupported JPEG color space (%s)"),
+                                                                colorspace_name (cinfo->out_color_space));
+                                           }
+
+                                           return FALSE;
+                               }
+
+                               context->dptr += nlines * context->pixbuf->rowstride;
+
+                               /* send updated signal */
+                               (* context->updated_func) (context->pixbuf,
+                                                          0,
+                                                          cinfo->output_scanline-1,
+                                                          cinfo->image_width,
+                                                          nlines,
+                                                          context->user_data);
+                       }
+
+                       if (cinfo->output_scanline >= cinfo->output_height)
+                               return TRUE;
                } else {
-                       /* we're decompressing so feed jpeg lib scanlines */
+                        /* we're decompressing so feed jpeg lib scanlines
+                         *
+                         * except for handling multiple passes this is
+                         * virtually identical to the previous branch
+                         */
                        guchar *lines[4];
                        guchar **lptr;
                        guchar *rowptr;
diff --git a/tests/test-images/valid_jpeg_progressive_test b/tests/test-images/valid_jpeg_progressive_test
new file mode 100644 (file)
index 0000000..a8d5c47
Binary files /dev/null and b/tests/test-images/valid_jpeg_progressive_test differ