diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | README.msvc | 3 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 7 | ||||
-rw-r--r-- | gdk-pixbuf/io-jasper.c | 344 | ||||
-rw-r--r-- | gdk-pixbuf/meson.build | 1 | ||||
-rw-r--r-- | meson.build | 30 | ||||
-rw-r--r-- | meson_options.txt | 4 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | tests/pixbuf-threads.c | 2 | ||||
-rwxr-xr-x | tests/test-images/fail/file3.jp2 | bin | 242213 -> 0 bytes | |||
-rw-r--r-- | tests/test-images/randomly-modified/valid.1.jp2 | bin | 1987968 -> 0 bytes |
11 files changed, 1 insertions, 395 deletions
@@ -34,7 +34,6 @@ Depending on the image formats you want to support you will also need: - libpng's development files - libjpeg's development files - libtiff's development files - - libjasper's development files Additionally, you may need: @@ -68,9 +67,6 @@ check the current build configuration, and change its options. You can specify the following options in the command line to `meson`: - * `-Djasper=true` - Enable support for JPEG2000. This requires - [libjasper's development files](http://www.ece.uvic.ca/~frodo/jasper/) - to be installed. * `-Dgtk_doc=true` - Build the API reference documentation. This requires `gtk-doc` to be installed. * `-Drelocatable=true` - Enable application bundle relocation support. diff --git a/README.msvc b/README.msvc index dbac333a2..c5615e17c 100644 --- a/README.msvc +++ b/README.msvc @@ -28,7 +28,6 @@ part of the dependency's build process. -IJG JPEG or libjpeg-turbo (strongly recommended, use -Djpeg=false to disable)
-libpng (strongly recommended, use -Dpng=false to disable)
-libtiff (strongly recommended, use -Dtiff=false to disable)
--libjasper (optional, JPEG2000 library, use -Djpaster=true to enable)
1) Configure the build using Meson:
Set the PATH, LIB, INCLUDE and PKG_CONFIG_PATH environmental variables as
@@ -37,7 +36,7 @@ needed. Run the following in a Visual Studio command prompt: python $(PATH_TO_meson.py)\meson.py $(GDK_PIXBUF_SRCDIR) --buildtype=$(BUILD_CONFIG) --prefix=$(PREFIX) -Dman=false $(OTHER_OPTIONS)
For $(OTHER_OPTIONS), the following may be of interest, besides the png,
-jpeg, japer and tiff options. Prefix each option with -D:
+jpeg and tiff options. Prefix each option with -D:
-builtin_loaders: list of image loaders that we want to build into
the main GDK-Pixbuf DLL, or use 'all' to include all buildable image
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index ce0ed633f..58bb74879 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -649,9 +649,6 @@ gdk_pixbuf_io_init_builtin (void) #ifdef INCLUDE_icns load_one_builtin_module (icns); #endif -#ifdef INCLUDE_jasper - load_one_builtin_module (jasper); -#endif #ifdef INCLUDE_qtif load_one_builtin_module (qtif); #endif @@ -704,7 +701,6 @@ module (bmp); module (xbm); module (tga); module (icns); -module (jasper); module (qtif); module (gdip_ico); module (gdip_wmf); @@ -785,9 +781,6 @@ gdk_pixbuf_load_module_unlocked (GdkPixbufModule *image_module, #ifdef INCLUDE_icns try_module (icns,icns); #endif -#ifdef INCLUDE_jasper - try_module (jasper,jasper); -#endif #ifdef INCLUDE_qtif try_module (qtif,qtif); #endif diff --git a/gdk-pixbuf/io-jasper.c b/gdk-pixbuf/io-jasper.c deleted file mode 100644 index 103ac0a80..000000000 --- a/gdk-pixbuf/io-jasper.c +++ /dev/null @@ -1,344 +0,0 @@ -/* JPEG 2000 loader - * - * Copyright (c) 2007 Bastien Nocera <hadess@hadess.net> - * Inspired by work by Ben Karel <web+moz@eschew.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -#include <jasper/jasper.h> - -#include <glib/gi18n-lib.h> -#include "gdk-pixbuf-io.h" - -G_MODULE_EXPORT void fill_vtable (GdkPixbufModule * module); -G_MODULE_EXPORT void fill_info (GdkPixbufFormat * info); - -struct jasper_context { - GdkPixbuf *pixbuf; - - GdkPixbufModuleSizeFunc size_func; - GdkPixbufModuleUpdatedFunc updated_func; - GdkPixbufModulePreparedFunc prepared_func; - gpointer user_data; - - jas_stream_t *stream; - - int width, height; -}; - -static void -free_jasper_context (struct jasper_context *context) -{ - if (!context) - return; - - if (context->stream) { - jas_stream_close (context->stream); - context->stream = NULL; - } - - g_free (context); -} - -static gpointer -jasper_image_begin_load (GdkPixbufModuleSizeFunc size_func, - GdkPixbufModulePreparedFunc prepared_func, - GdkPixbufModuleUpdatedFunc updated_func, - gpointer user_data, GError **error) -{ - struct jasper_context *context; - jas_stream_t *stream; - - g_assert (size_func != NULL); - g_assert (prepared_func != NULL); - g_assert (updated_func != NULL); - - jas_init (); - - stream = jas_stream_memopen (NULL, 0); - if (!stream) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Couldn’t allocate memory for stream")); - return NULL; - } - - context = g_new0 (struct jasper_context, 1); - if (!context) - return NULL; - - context->size_func = size_func; - context->updated_func = updated_func; - context->prepared_func = prepared_func; - context->user_data = user_data; - context->width = context->height = -1; - - context->stream = stream; - - return context; -} - -static const char * -colourspace_to_str (int c) -{ - switch (c) { - case JAS_CLRSPC_FAM_UNKNOWN: - return "Unknown"; - case JAS_CLRSPC_FAM_XYZ: - return "XYZ"; - case JAS_CLRSPC_FAM_LAB: - return "LAB"; - case JAS_CLRSPC_FAM_GRAY: - return "GRAY"; - case JAS_CLRSPC_FAM_RGB: - return "RGB"; - case JAS_CLRSPC_FAM_YCBCR: - return "YCbCr"; - default: - return "Invalid"; - } -} - -static gboolean -jasper_image_try_load (struct jasper_context *context, GError **error) -{ - jas_image_t *raw_image, *image; - int num_components, colourspace_family; - int i, rowstride, shift; - guchar *pixels; - - raw_image = jas_image_decode (context->stream, -1, 0); - if (!raw_image) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, - _("Couldn’t decode image")); - return FALSE; - } - - if (context->width == -1 && context->height == -1) { - int width, height; - - context->width = width = jas_image_cmptwidth (raw_image, 0); - context->height = height = jas_image_cmptheight (raw_image, 0); - - (*context->size_func) (&width, &height, context->user_data); - - if (width == 0 || height == 0) { - jas_image_destroy(raw_image); - g_set_error_literal (error, - GDK_PIXBUF_ERROR, - GDK_PIXBUF_ERROR_CORRUPT_IMAGE, - _("Transformed JPEG2000 has zero width or height")); - return FALSE; - } - } - - /* We only know how to handle grayscale and RGB images */ - num_components = jas_image_numcmpts (raw_image); - colourspace_family = jas_clrspc_fam (jas_image_clrspc (raw_image)); - - if ((num_components != 3 && num_components != 4 && num_components != 1) || - (colourspace_family != JAS_CLRSPC_FAM_RGB && colourspace_family != JAS_CLRSPC_FAM_GRAY)) { - jas_image_destroy (raw_image); - g_debug ("Unsupported colourspace %s (num components: %d)", - colourspace_to_str (colourspace_family), num_components); - g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_UNKNOWN_TYPE, - _("Image type currently not supported")); - return FALSE; - } - - /* Apply the colour profile to the image, creating a new one */ - if (jas_image_clrspc (raw_image) != JAS_CLRSPC_SRGB) { - jas_cmprof_t *profile; - - profile = jas_cmprof_createfromclrspc (JAS_CLRSPC_SRGB); - if (!profile) { - jas_image_destroy (raw_image); - g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Couldn’t allocate memory for color profile")); - return FALSE; - } - - image = jas_image_chclrspc (raw_image, profile, JAS_CMXFORM_INTENT_PER); - if (!image) { - jas_image_destroy (raw_image); - g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Couldn’t allocate memory for color profile")); - return FALSE; - } - } else { - image = raw_image; - } - - if (!context->pixbuf) { - int bits_per_sample; - - /* Unfortunately, gdk-pixbuf doesn't support 16 bpp images - * bits_per_sample = jas_image_cmptprec (image, 0); - if (bits_per_sample < 8) - bits_per_sample = 8; - else if (bits_per_sample > 8) - bits_per_sample = 16; - */ - bits_per_sample = 8; - - context->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, - FALSE, bits_per_sample, - context->width, context->height); - if (context->pixbuf == NULL) { - g_set_error_literal (error, - GDK_PIXBUF_ERROR, - GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Insufficient memory to open JPEG 2000 file")); - return FALSE; - } - context->prepared_func (context->pixbuf, NULL, context->user_data); - } - - /* We calculate how much we should shift the pixel - * data by to make it fit into our pixbuf */ - shift = MAX (jas_image_cmptprec (image, 0) - gdk_pixbuf_get_bits_per_sample (context->pixbuf), 0); - - /* Loop over the 3 colourspaces */ - rowstride = gdk_pixbuf_get_rowstride (context->pixbuf); - pixels = gdk_pixbuf_get_pixels (context->pixbuf); - - for (i = 0; i < num_components; i++) { - jas_matrix_t *matrix; - int j; - - matrix = jas_matrix_create (context->height, context->width); - - if (matrix == NULL) { - g_set_error_literal (error, - GDK_PIXBUF_ERROR, - GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Insufficient memory to open JPEG 2000 file")); - return FALSE; - } - - /* in libjasper, R is 0, G is 1, etc. we're lucky :) - * but we need to handle the "opacity" channel ourselves */ - if (i != 4) { - jas_image_readcmpt (image, i, 0, 0, context->width, context->height, matrix); - } else { - jas_image_readcmpt (image, JAS_IMAGE_CT_OPACITY, 0, 0, context->width, context->height, matrix); - } - - for (j = 0; j < context->height; j++) { - int k; - - for (k = 0; k < context->width; k++) { - if (num_components == 3 || num_components == 4) { - pixels[j * rowstride + k * 3 + i] = jas_matrix_get (matrix, j, k) >> shift; - } else { - pixels[j * rowstride + k * 3] = - pixels[j * rowstride + k * 3 + 1] = - pixels[j * rowstride + k * 3 + 2] = jas_matrix_get (matrix, j, k) >> shift; - } - } - /* Update once per line for the last component, otherwise - * we might contain garbage */ - if ((i == num_components - 1) && k != 0) { - context->updated_func (context->pixbuf, 0, j, k, 1, context->user_data); - } - } - - jas_matrix_destroy (matrix); - } - - if (image != raw_image) - jas_image_destroy (image); - jas_image_destroy (raw_image); - - return TRUE; -} - -static gboolean -jasper_image_stop_load (gpointer data, GError **error) -{ - struct jasper_context *context = (struct jasper_context *) data; - gboolean ret; - - jas_stream_rewind (context->stream); - ret = jasper_image_try_load (context, error); - - free_jasper_context (context); - - return ret; -} - -static gboolean -jasper_image_load_increment (gpointer data, const guchar *buf, guint size, GError **error) -{ - struct jasper_context *context = (struct jasper_context *) data; - - if (jas_stream_write (context->stream, buf, size) < 0) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Couldn’t allocate memory to buffer image data")); - return FALSE; - } - - return TRUE; -} - -#ifndef INCLUDE_jasper -#define MODULE_ENTRY(function) G_MODULE_EXPORT void function -#else -#define MODULE_ENTRY(function) void _gdk_pixbuf__jasper_ ## function -#endif - -MODULE_ENTRY (fill_vtable) (GdkPixbufModule * module) -{ - module->begin_load = jasper_image_begin_load; - module->stop_load = jasper_image_stop_load; - module->load_increment = jasper_image_load_increment; -} - -MODULE_ENTRY (fill_info) (GdkPixbufFormat * info) -{ - static const GdkPixbufModulePattern signature[] = { - { " jP", "!!!! ", 100 }, /* file begins with 'jP' at offset 4 */ - { "\xff\x4f\xff\x51\x00", NULL, 100 }, /* file starts with FF 4F FF 51 00 */ - { NULL, NULL, 0 } - }; - static const gchar *mime_types[] = { - "image/jp2", - "image/jpeg2000", - "image/jpx", - NULL - }; - static const gchar *extensions[] = { - "jp2", - "jpc", - "jpx", - "j2k", - "jpf", - NULL - }; - - info->name = "jpeg2000"; - info->signature = (GdkPixbufModulePattern *) signature; - info->description = NC_("image format", "JPEG 2000"); - info->mime_types = (gchar **) mime_types; - info->extensions = (gchar **) extensions; - info->flags = GDK_PIXBUF_FORMAT_THREADSAFE; - info->license = "LGPL"; - info->disabled = FALSE; -} - diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build index 12f6ddbb1..fdf98da52 100644 --- a/gdk-pixbuf/meson.build +++ b/gdk-pixbuf/meson.build @@ -20,7 +20,6 @@ loaders = [ [ 'xbm', [ 'io-xbm.c' ] ], [ 'tga', [ 'io-tga.c', 'gdk-pixbuf-buffer-queue.c' ] ], [ 'icns', [ 'io-icns.c' ] ], - [ 'jasper', [ 'io-jasper.c' ], enabled_loaders.contains('jasper'), jasper_extra_cflags ], [ 'qtif', [ 'io-qtif.c' ] ] ] diff --git a/meson.build b/meson.build index 8349e5f3b..c1423ddba 100644 --- a/meson.build +++ b/meson.build @@ -347,36 +347,6 @@ if get_option('tiff') and not native_windows_loaders endif endif -jasper_extra_cflags = [] - -if get_option('jasper') - has_jasper_header = false - - if cc.get_id() == 'msvc' - # We must define JAS_WIN_MSVC_BUILD before including jasper/jasper.h on MSVC - jasper_msvc_macro = 'JAS_WIN_MSVC_BUILD' - has_jasper_header = cc.has_header('jasper/jasper.h', prefix: '#define @0@'.format(jasper_msvc_macro)) - jasper_extra_cflags = [ '-D@0@'.format(jasper_msvc_macro) ] - else - has_jasper_header = cc.has_header('jasper/jasper.h') - endif - - if has_jasper_header - jasper_dep = cc.find_library('jasper', required: false) - if not jasper_dep.found() - if cc.get_id() == 'msvc' - # on MSVC, we need to look for libjasper.lib if jasper.lib is not found, - # which corresponds to what libjasper's MSVC projects produce - jasper_dep = cc.find_library('libjasper', required: false) - endif - endif - if jasper_dep.found() and cc.has_function('jas_init', dependencies: jasper_dep) - enabled_loaders += 'jasper' - loaders_deps += jasper_dep - endif - endif -endif - # Determine whether we enable application bundle relocation support, and we use # this always on Windows if host_system == 'windows' diff --git a/meson_options.txt b/meson_options.txt index c22d29425..c1136cd96 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,10 +10,6 @@ option('jpeg', description: 'Enable JPEG loader (requires libjpeg), disabled on Windows if "native_windows_loaders" is used', type: 'boolean', value: true) -option('jasper', - description: 'Enable JPEG2000 loader (requires libjasper)', - type: 'boolean', - value: false) option('builtin_loaders', description: 'Comma-separated list of loaders to build into gdk-pixbuf, or "none", or "all" to build all buildable loaders into gdk-pixbuf', type: 'string', diff --git a/po/POTFILES.in b/po/POTFILES.in index 138e05526..bc6aa5501 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -19,7 +19,6 @@ gdk-pixbuf/io-gdip-wmf.c gdk-pixbuf/io-gif.c gdk-pixbuf/io-icns.c gdk-pixbuf/io-ico.c -gdk-pixbuf/io-jasper.c gdk-pixbuf/io-jpeg.c gdk-pixbuf/io-png.c gdk-pixbuf/io-pnm.c diff --git a/tests/pixbuf-threads.c b/tests/pixbuf-threads.c index fdcf4389f..1326eeca4 100644 --- a/tests/pixbuf-threads.c +++ b/tests/pixbuf-threads.c @@ -89,8 +89,6 @@ test_threads (void) g_thread_pool_push (pool, "valid.1.tga", NULL); if (format_supported ("tiff")) g_thread_pool_push (pool, "valid.1.tiff", NULL); - if (format_supported ("jp2")) - g_thread_pool_push (pool, "valid.1.jp2", NULL); } g_thread_pool_free (pool, FALSE, TRUE); diff --git a/tests/test-images/fail/file3.jp2 b/tests/test-images/fail/file3.jp2 Binary files differdeleted file mode 100755 index 18c130a4c..000000000 --- a/tests/test-images/fail/file3.jp2 +++ /dev/null diff --git a/tests/test-images/randomly-modified/valid.1.jp2 b/tests/test-images/randomly-modified/valid.1.jp2 Binary files differdeleted file mode 100644 index 5fc8bdb19..000000000 --- a/tests/test-images/randomly-modified/valid.1.jp2 +++ /dev/null |