Commit 3390c105 authored by bdash's avatar bdash

2007-06-25 Alp Toker <alp.toker@collabora.co.uk>

        Reviewed by Mark.

        http://bugs.webkit.org/show_bug.cgi?id=13975
        Use system-provided libjpeg and libpng

        * WebKit.pri: Link against external libjpeg and libpng.

2007-06-25  Alp Toker  <alp.toker@collabora.co.uk>

        Reviewed by Mark.

        http://bugs.webkit.org/show_bug.cgi?id=13975
        Use system-provided libjpeg and libpng

        * WebCore.pro: Remove bundled libjpeg and libpng sources.
        * platform/image-decoders/jpeg: Remove sources.
        * platform/image-decoders/png: Remove sources.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@23763 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 374557c6
2007-06-25 Alp Toker <alp.toker@collabora.co.uk>
Reviewed by Mark.
http://bugs.webkit.org/show_bug.cgi?id=13975
Use system-provided libjpeg and libpng
* WebKit.pri: Link against external libjpeg and libpng.
2007-06-20 Adam Roben <aroben@apple.com>
Reviewed by Simon Hausmann.
......
2007-06-25 Alp Toker <alp.toker@collabora.co.uk>
Reviewed by Mark.
http://bugs.webkit.org/show_bug.cgi?id=13975
Use system-provided libjpeg and libpng
* WebCore.pro: Remove bundled libjpeg and libpng sources.
* platform/image-decoders/jpeg: Remove sources.
* platform/image-decoders/png: Remove sources.
2007-06-25 Mitz Pettel <mitz@webkit.org>
Reviewed by Darin.
......@@ -855,53 +855,7 @@ gdk-port:SOURCES += \
platform/image-decoders/gif/GIFImageDecoder.cpp \
platform/image-decoders/gif/GIFImageReader.cpp \
platform/image-decoders/png/PNGImageDecoder.cpp \
platform/image-decoders/png/png.c \
platform/image-decoders/png/pngerror.c \
platform/image-decoders/png/pnggccrd.c \
platform/image-decoders/png/pngget.c \
platform/image-decoders/png/pngmem.c \
platform/image-decoders/png/pngpread.c \
platform/image-decoders/png/pngread.c \
platform/image-decoders/png/pngrio.c \
platform/image-decoders/png/pngrtran.c \
platform/image-decoders/png/pngrutil.c \
platform/image-decoders/png/pngset.c \
platform/image-decoders/png/pngtrans.c \
platform/image-decoders/png/pngvcrd.c \
platform/image-decoders/png/pngwio.c \
platform/image-decoders/png/pngwrite.c \
platform/image-decoders/png/pngwtran.c \
platform/image-decoders/png/pngwutil.c \
platform/image-decoders/jpeg/JPEGImageDecoder.cpp \
platform/image-decoders/jpeg/jcomapi.c \
platform/image-decoders/jpeg/jdapimin.c \
platform/image-decoders/jpeg/jdapistd.c \
platform/image-decoders/jpeg/jdatadst.c \
platform/image-decoders/jpeg/jdatasrc.c \
platform/image-decoders/jpeg/jdcoefct.c \
platform/image-decoders/jpeg/jdcolor.c \
platform/image-decoders/jpeg/jddctmgr.c \
platform/image-decoders/jpeg/jdhuff.c \
platform/image-decoders/jpeg/jdinput.c \
platform/image-decoders/jpeg/jdmainct.c \
platform/image-decoders/jpeg/jdmarker.c \
platform/image-decoders/jpeg/jdmaster.c \
platform/image-decoders/jpeg/jdmerge.c \
platform/image-decoders/jpeg/jdphuff.c \
platform/image-decoders/jpeg/jdpostct.c \
platform/image-decoders/jpeg/jdsample.c \
platform/image-decoders/jpeg/jerror.c \
platform/image-decoders/jpeg/jfdctflt.c \
platform/image-decoders/jpeg/jfdctfst.c \
platform/image-decoders/jpeg/jfdctint.c \
platform/image-decoders/jpeg/jidctflt.c \
platform/image-decoders/jpeg/jidctfst.c \
platform/image-decoders/jpeg/jidctint.c \
platform/image-decoders/jpeg/jmemmgr.c \
platform/image-decoders/jpeg/jmemnobs.c \
platform/image-decoders/jpeg/jquant1.c \
platform/image-decoders/jpeg/jquant2.c \
platform/image-decoders/jpeg/jutils.c \
platform/image-decoders/bmp/BMPImageDecoder.cpp \
platform/image-decoders/ico/ICOImageDecoder.cpp \
platform/image-decoders/xbm/XBMImageDecoder.cpp
......
/*
* jcomapi.c
*
* Copyright (C) 1994-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains application interface routines that are used for both
* compression and decompression.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/*
* Abort processing of a JPEG compression or decompression operation,
* but don't destroy the object itself.
*
* For this, we merely clean up all the nonpermanent memory pools.
* Note that temp files (virtual arrays) are not allowed to belong to
* the permanent pool, so we will be able to close all temp files here.
* Closing a data source or destination, if necessary, is the application's
* responsibility.
*/
GLOBAL(void)
jpeg_abort (j_common_ptr cinfo)
{
int pool;
/* Do nothing if called on a not-initialized or destroyed JPEG object. */
if (cinfo->mem == NULL)
return;
/* Releasing pools in reverse order might help avoid fragmentation
* with some (brain-damaged) malloc libraries.
*/
for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
(*cinfo->mem->free_pool) (cinfo, pool);
}
/* Reset overall state for possible reuse of object */
if (cinfo->is_decompressor) {
cinfo->global_state = DSTATE_START;
/* Try to keep application from accessing now-deleted marker list.
* A bit kludgy to do it here, but this is the most central place.
*/
((j_decompress_ptr) cinfo)->marker_list = NULL;
} else {
cinfo->global_state = CSTATE_START;
}
}
/*
* Destruction of a JPEG object.
*
* Everything gets deallocated except the master jpeg_compress_struct itself
* and the error manager struct. Both of these are supplied by the application
* and must be freed, if necessary, by the application. (Often they are on
* the stack and so don't need to be freed anyway.)
* Closing a data source or destination, if necessary, is the application's
* responsibility.
*/
GLOBAL(void)
jpeg_destroy (j_common_ptr cinfo)
{
/* We need only tell the memory manager to release everything. */
/* NB: mem pointer is NULL if memory mgr failed to initialize. */
if (cinfo->mem != NULL)
(*cinfo->mem->self_destruct) (cinfo);
cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */
cinfo->global_state = 0; /* mark it destroyed */
}
/*
* Convenience routines for allocating quantization and Huffman tables.
* (Would jutils.c be a more reasonable place to put these?)
*/
GLOBAL(JQUANT_TBL *)
jpeg_alloc_quant_table (j_common_ptr cinfo)
{
JQUANT_TBL *tbl;
tbl = (JQUANT_TBL *)
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));
tbl->sent_table = FALSE; /* make sure this is false in any new table */
return tbl;
}
GLOBAL(JHUFF_TBL *)
jpeg_alloc_huff_table (j_common_ptr cinfo)
{
JHUFF_TBL *tbl;
tbl = (JHUFF_TBL *)
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));
tbl->sent_table = FALSE; /* make sure this is false in any new table */
return tbl;
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* jconfig.h to configure the IJG JPEG library for the Mozilla/Netscape
* environment. Note that there are also Mozilla mods in jmorecfg.h.
*/
/* We assume an ANSI C or C++ compilation environment */
#define HAVE_PROTOTYPES
#define HAVE_UNSIGNED_CHAR
#define HAVE_UNSIGNED_SHORT
/* #define void char */
/* #define const */
#ifndef HAVE_STDDEF_H
#define HAVE_STDDEF_H
#endif /* HAVE_STDDEF_H */
#ifndef HAVE_STDLIB_H
#define HAVE_STDLIB_H
#endif /* HAVE_STDLIB_H */
#undef NEED_BSD_STRINGS
#undef NEED_SYS_TYPES_H
#undef NEED_FAR_POINTERS
#undef NEED_SHORT_EXTERNAL_NAMES
/* Define this if you get warnings about undefined structures. */
#undef INCOMPLETE_TYPES_BROKEN
/* With this setting, the IJG code will work regardless of whether
* type "char" is signed or unsigned.
*/
#undef CHAR_IS_UNSIGNED
/* defines that need not be visible to callers of the IJG library */
#ifdef JPEG_INTERNALS
/* If right shift of "long" quantities is unsigned on your machine,
* you'll have to define this. Fortunately few people should need it.
*/
#undef RIGHT_SHIFT_IS_UNSIGNED
#ifdef XP_MAC /* Macintosh */
#define ALIGN_TYPE long /* for sane memory alignment */
#define NO_GETENV /* we do have the function, but it's dead */
#endif /* XP_MAC */
#endif /* JPEG_INTERNALS */
/* these defines are not interesting for building just the IJG library,
* but we leave 'em here anyway.
*/
#ifdef JPEG_CJPEG_DJPEG
#define BMP_SUPPORTED /* BMP image file format */
#define GIF_SUPPORTED /* GIF image file format */
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
#undef RLE_SUPPORTED /* Utah RLE image file format */
#define TARGA_SUPPORTED /* Targa image file format */
#undef TWO_FILE_COMMANDLINE
#undef NEED_SIGNAL_CATCHER
#undef DONT_USE_B_MODE
#undef PROGRESS_REPORT
#endif /* JPEG_CJPEG_DJPEG */
/*
* jdapimin.c
*
* Copyright (C) 1994-1998, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains application interface code for the decompression half
* of the JPEG library. These are the "minimum" API routines that may be
* needed in either the normal full-decompression case or the
* transcoding-only case.
*
* Most of the routines intended to be called directly by an application
* are in this file or in jdapistd.c. But also see jcomapi.c for routines
* shared by compression and decompression, and jdtrans.c for the transcoding
* case.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#ifdef HAVE_MMX_INTEL_MNEMONICS
int MMXAvailable;
static int mmxsupport();
#endif
#ifdef HAVE_SSE2_INTEL_MNEMONICS
int SSE2Available = 0;
static int sse2support();
#endif
/*
* Initialization of a JPEG decompression object.
* The error manager must already be set up (in case memory manager fails).
*/
GLOBAL(void)
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
{
int i;
#ifdef HAVE_MMX_INTEL_MNEMONICS
static int cpuidDetected = 0;
if(!cpuidDetected)
{
MMXAvailable = mmxsupport();
#ifdef HAVE_SSE2_INTEL_MNEMONICS
/* only do the sse2 support check if mmx is supported (so
we know the processor supports cpuid) */
if (MMXAvailable)
SSE2Available = sse2support();
#endif
cpuidDetected = 1;
}
#endif
/* For debugging purposes, zero the whole master structure.
* But error manager pointer is already there, so save and restore it.
*/
/* Guard against version mismatches between library and caller. */
cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
if (version != JPEG_LIB_VERSION)
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
if (structsize != SIZEOF(struct jpeg_decompress_struct))
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
/* For debugging purposes, we zero the whole master structure.
* But the application has already set the err pointer, and may have set
* client_data, so we have to save and restore those fields.
* Note: if application hasn't set client_data, tools like Purify may
* complain here.
*/
{
struct jpeg_error_mgr * err = cinfo->err;
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));
cinfo->err = err;
cinfo->client_data = client_data;
}
cinfo->is_decompressor = TRUE;
/* Initialize a memory manager instance for this object */
jinit_memory_mgr((j_common_ptr) cinfo);
/* Zero out pointers to permanent structures. */
cinfo->progress = NULL;
cinfo->src = NULL;
for (i = 0; i < NUM_QUANT_TBLS; i++)
cinfo->quant_tbl_ptrs[i] = NULL;
for (i = 0; i < NUM_HUFF_TBLS; i++) {
cinfo->dc_huff_tbl_ptrs[i] = NULL;
cinfo->ac_huff_tbl_ptrs[i] = NULL;
}
/* Initialize marker processor so application can override methods
* for COM, APPn markers before calling jpeg_read_header.
*/
cinfo->marker_list = NULL;
jinit_marker_reader(cinfo);
/* And initialize the overall input controller. */
jinit_input_controller(cinfo);
/* OK, I'm ready */
cinfo->global_state = DSTATE_START;
}
/*
* Destruction of a JPEG decompression object
*/
GLOBAL(void)
jpeg_destroy_decompress (j_decompress_ptr cinfo)
{
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
}
/*
* Abort processing of a JPEG decompression operation,
* but don't destroy the object itself.
*/
GLOBAL(void)
jpeg_abort_decompress (j_decompress_ptr cinfo)
{
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
}
/*
* Set default decompression parameters.
*/
LOCAL(void)
default_decompress_parms (j_decompress_ptr cinfo)
{
/* Guess the input colorspace, and set output colorspace accordingly. */
/* (Wish JPEG committee had provided a real way to specify this...) */
/* Note application may override our guesses. */
switch (cinfo->num_components) {
case 1:
cinfo->jpeg_color_space = JCS_GRAYSCALE;
cinfo->out_color_space = JCS_GRAYSCALE;
break;
case 3:
if (cinfo->saw_JFIF_marker) {
cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
} else if (cinfo->saw_Adobe_marker) {
switch (cinfo->Adobe_transform) {
case 0:
cinfo->jpeg_color_space = JCS_RGB;
break;
case 1:
cinfo->jpeg_color_space = JCS_YCbCr;
break;
default:
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
break;
}
} else {
/* Saw no special markers, try to guess from the component IDs */
int cid0 = cinfo->comp_info[0].component_id;
int cid1 = cinfo->comp_info[1].component_id;
int cid2 = cinfo->comp_info[2].component_id;
if (cid0 == 1 && cid1 == 2 && cid2 == 3)
cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
else {
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
}
}
/* Always guess RGB is proper output colorspace. */
cinfo->out_color_space = JCS_RGB;
break;
case 4:
if (cinfo->saw_Adobe_marker) {
switch (cinfo->Adobe_transform) {
case 0:
cinfo->jpeg_color_space = JCS_CMYK;
break;
case 2:
cinfo->jpeg_color_space = JCS_YCCK;
break;
default:
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
break;
}
} else {
/* No special markers, assume straight CMYK. */
cinfo->jpeg_color_space = JCS_CMYK;
}
cinfo->out_color_space = JCS_CMYK;
break;
default:
cinfo->jpeg_color_space = JCS_UNKNOWN;
cinfo->out_color_space = JCS_UNKNOWN;
break;
}
/* Set defaults for other decompression parameters. */
cinfo->scale_num = 1; /* 1:1 scaling */
cinfo->scale_denom = 1;
cinfo->output_gamma = 1.0;
cinfo->buffered_image = FALSE;
cinfo->raw_data_out = FALSE;
cinfo->dct_method = JDCT_DEFAULT;
cinfo->do_fancy_upsampling = TRUE;
cinfo->do_block_smoothing = TRUE;
cinfo->quantize_colors = FALSE;
/* We set these in case application only sets quantize_colors. */
cinfo->dither_mode = JDITHER_FS;
#ifdef QUANT_2PASS_SUPPORTED
cinfo->two_pass_quantize = TRUE;
#else
cinfo->two_pass_quantize = FALSE;
#endif
cinfo->desired_number_of_colors = 256;
cinfo->colormap = NULL;
/* Initialize for no mode change in buffered-image mode. */
cinfo->enable_1pass_quant = FALSE;
cinfo->enable_external_quant = FALSE;
cinfo->enable_2pass_quant = FALSE;
}
/*
* Decompression startup: read start of JPEG datastream to see what's there.
* Need only initialize JPEG object and supply a data source before calling.
*
* This routine will read as far as the first SOS marker (ie, actual start of
* compressed data), and will save all tables and parameters in the JPEG
* object. It will also initialize the decompression parameters to default
* values, and finally return JPEG_HEADER_OK. On return, the application may
* adjust the decompression parameters and then call jpeg_start_decompress.
* (Or, if the application only wanted to determine the image parameters,
* the data need not be decompressed. In that case, call jpeg_abort or
* jpeg_destroy to release any temporary space.)
* If an abbreviated (tables only) datastream is presented, the routine will
* return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then
* re-use the JPEG object to read the abbreviated image datastream(s).
* It is unnecessary (but OK) to call jpeg_abort in this case.
* The JPEG_SUSPENDED return code only occurs if the data source module
* requests suspension of the decompressor. In this case the application
* should load more source data and then re-call jpeg_read_header to resume
* processing.
* If a non-suspending data source is used and require_image is TRUE, then the
* return code need not be inspected since only JPEG_HEADER_OK is possible.
*
* This routine is now just a front end to jpeg_consume_input, with some
* extra error checking.
*/
GLOBAL(int)
jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
{
int retcode;
if (cinfo->global_state != DSTATE_START &&
cinfo->global_state != DSTATE_INHEADER)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
retcode = jpeg_consume_input(cinfo);
switch (retcode) {
case JPEG_REACHED_SOS:
retcode = JPEG_HEADER_OK;
break;
case JPEG_REACHED_EOI:
if (require_image) /* Complain if application wanted an image */
ERREXIT(cinfo, JERR_NO_IMAGE);
/* Reset to start state; it would be safer to require the application to
* call jpeg_abort, but we can't change it now for compatibility reasons.
* A side effect is to free any temporary memory (there shouldn't be any).
*/
jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */
retcode = JPEG_HEADER_TABLES_ONLY;
break;
case JPEG_SUSPENDED:
/* no work */
break;
}
return retcode;
}
/*
* Consume data in advance of what the decompressor requires.
* This can be called at any time once the decompressor object has
* been created and a data source has been set up.
*
* This routine is essentially a state machine that handles a couple
* of critical state-transition actions, namely initial setup and