view release on metacpan or search on metacpan
src/Source/FreeImage.h view on Meta::CPAN
#define JPEG_QUALITYSUPERB 0x80 //! save with superb quality (100:1)
#define JPEG_QUALITYGOOD 0x0100 //! save with good quality (75:1)
#define JPEG_QUALITYNORMAL 0x0200 //! save with normal quality (50:1)
#define JPEG_QUALITYAVERAGE 0x0400 //! save with average quality (25:1)
#define JPEG_QUALITYBAD 0x0800 //! save with bad quality (10:1)
#define JPEG_PROGRESSIVE 0x2000 //! save as a progressive-JPEG (use | to combine with other save flags)
#define JPEG_SUBSAMPLING_411 0x1000 //! save with high 4x1 chroma subsampling (4:1:1)
#define JPEG_SUBSAMPLING_420 0x4000 //! save with medium 2x2 medium chroma subsampling (4:2:0) - default value
#define JPEG_SUBSAMPLING_422 0x8000 //! save with low 2x1 chroma subsampling (4:2:2)
#define JPEG_SUBSAMPLING_444 0x10000 //! save with no chroma subsampling (4:4:4)
#define JPEG_OPTIMIZE 0x20000 //! on saving, compute optimal Huffman coding tables (can reduce a few percent of file size)
#define JPEG_BASELINE 0x40000 //! save basic JPEG, without metadata or any markers
#define KOALA_DEFAULT 0
#define LBM_DEFAULT 0
#define MNG_DEFAULT 0
#define PCD_DEFAULT 0
#define PCD_BASE 1 //! load the bitmap sized 768 x 512
#define PCD_BASEDIV4 2 //! load the bitmap sized 384 x 256
#define PCD_BASEDIV16 3 //! load the bitmap sized 192 x 128
#define PCX_DEFAULT 0
#define PFM_DEFAULT 0
src/Source/FreeImage.h view on Meta::CPAN
DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib);
// upsampling / downsampling
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM));
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE));
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RescaleRect(FIBITMAP *dib, int dst_width, int dst_height, int left, int top, int right, int bottom, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM), unsigned flags FI_DEFAULT(0));
// color manipulation routines (point operations)
DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel);
DLL_API BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *dib, double gamma);
DLL_API BOOL DLL_CALLCONV FreeImage_AdjustBrightness(FIBITMAP *dib, double percentage);
DLL_API BOOL DLL_CALLCONV FreeImage_AdjustContrast(FIBITMAP *dib, double percentage);
DLL_API BOOL DLL_CALLCONV FreeImage_Invert(FIBITMAP *dib);
DLL_API BOOL DLL_CALLCONV FreeImage_GetHistogram(FIBITMAP *dib, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel FI_DEFAULT(FICC_BLACK));
DLL_API int DLL_CALLCONV FreeImage_GetAdjustColorsLookupTable(BYTE *LUT, double brightness, double contrast, double gamma, BOOL invert);
DLL_API BOOL DLL_CALLCONV FreeImage_AdjustColors(FIBITMAP *dib, double brightness, double contrast, double gamma, BOOL invert FI_DEFAULT(FALSE));
DLL_API unsigned DLL_CALLCONV FreeImage_ApplyColorMapping(FIBITMAP *dib, RGBQUAD *srccolors, RGBQUAD *dstcolors, unsigned count, BOOL ignore_alpha, BOOL swap);
DLL_API unsigned DLL_CALLCONV FreeImage_SwapColors(FIBITMAP *dib, RGBQUAD *color_a, RGBQUAD *color_b, BOOL ignore_alpha);
DLL_API unsigned DLL_CALLCONV FreeImage_ApplyPaletteIndexMapping(FIBITMAP *dib, BYTE *srcindices, BYTE *dstindices, unsigned count, BOOL swap);
DLL_API unsigned DLL_CALLCONV FreeImage_SwapPaletteIndices(FIBITMAP *dib, BYTE *index_a, BYTE *index_b);
// channel processing routines
src/Source/FreeImage/ColorLookup.cpp view on Meta::CPAN
// lookup color
i = FreeImage_LookupNamedColor(szColor, X11ColorMap, sizeof(X11ColorMap)/sizeof(X11ColorMap[0]));
if (i >= 0) {
*nRed = X11ColorMap[i].r;
*nGreen = X11ColorMap[i].g;
*nBlue = X11ColorMap[i].b;
return TRUE;
}
// not found, try for grey color with attached percent value
if ( (szColor[0] == 'g' || szColor[0] == 'G') &&
(szColor[1] == 'r' || szColor[1] == 'R') &&
(szColor[2] == 'e' || szColor[2] == 'E' || szColor[2] == 'a' || szColor[2] == 'A' ) &&
(szColor[3] == 'y' || szColor[3] == 'Y' ) ) {
// grey<num>, or gray<num>, num 1...100
i = strtol(szColor+4, NULL, 10);
*nRed = (BYTE)(255.0/100.0 * i);
*nGreen = *nRed;
*nBlue = *nRed;
src/Source/FreeImage/ColorLookup.cpp view on Meta::CPAN
// lookup color
i = FreeImage_LookupNamedColor(szColor, SVGColorMap, sizeof(SVGColorMap)/sizeof(SVGColorMap[0]));
if (i >= 0) {
*nRed = SVGColorMap[i].r;
*nGreen = SVGColorMap[i].g;
*nBlue = SVGColorMap[i].b;
return TRUE;
}
// not found, try for grey color with attached percent value
if ( (szColor[0] == 'g' || szColor[0] == 'G') &&
(szColor[1] == 'r' || szColor[1] == 'R') &&
(szColor[2] == 'e' || szColor[2] == 'E' || szColor[2] == 'a' || szColor[2] == 'A' ) &&
(szColor[3] == 'y' || szColor[3] == 'Y' ) ) {
// grey<num>, or gray<num>, num 1...100
i = strtol(szColor+4, NULL, 10);
*nRed = (BYTE)(255.0/100.0 * i);
*nGreen = *nRed;
*nBlue = *nRed;
src/Source/FreeImage/tmoColorConvert.cpp view on Meta::CPAN
*minLum = vY.at( int(minPrct * vY.size()) );
*maxLum = vY.at( int(maxPrct * vY.size()) );
}
/**
Clipping function<br>
Remove any extremely bright and/or extremely dark pixels
and normalize between 0 and 1.
@param Y Input/Output image
@param minPrct Minimum percentile
@param maxPrct Maximum percentile
*/
void
NormalizeY(FIBITMAP *Y, float minPrct, float maxPrct) {
int x, y;
float maxLum, minLum;
if(minPrct > maxPrct) {
// swap values
float t = minPrct; minPrct = maxPrct; maxPrct = t;
}
src/Source/FreeImageToolkit/Colors.cpp view on Meta::CPAN
LUT[i] = (BYTE)floor(color + 0.5);
}
// Apply the gamma correction
return FreeImage_AdjustCurve(src, LUT, FICC_RGB);
}
/** @brief Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount.
@param src Input image to be processed.
@param percentage Where -100 <= percentage <= 100<br>
A value 0 means no change, less than 0 will make the image darker
and greater than 0 will make the image brighter.
@return Returns TRUE if successful, FALSE otherwise.
*/
BOOL DLL_CALLCONV
FreeImage_AdjustBrightness(FIBITMAP *src, double percentage) {
BYTE LUT[256]; // Lookup table
double value;
if(!FreeImage_HasPixels(src))
return FALSE;
// Build the lookup table
const double scale = (100 + percentage) / 100;
for(int i = 0; i < 256; i++) {
value = i * scale;
value = MAX(0.0, MIN(value, 255.0));
LUT[i] = (BYTE)floor(value + 0.5);
}
return FreeImage_AdjustCurve(src, LUT, FICC_RGB);
}
/** @brief Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount.
@param src Input image to be processed.
@param percentage Where -100 <= percentage <= 100<br>
A value 0 means no change, less than 0 will decrease the contrast
and greater than 0 will increase the contrast of the image.
@return Returns TRUE if successful, FALSE otherwise.
*/
BOOL DLL_CALLCONV
FreeImage_AdjustContrast(FIBITMAP *src, double percentage) {
BYTE LUT[256]; // Lookup table
double value;
if(!FreeImage_HasPixels(src))
return FALSE;
// Build the lookup table
const double scale = (100 + percentage) / 100;
for(int i = 0; i < 256; i++) {
value = 128 + (i - 128) * scale;
value = MAX(0.0, MIN(value, 255.0));
LUT[i] = (BYTE)floor(value + 0.5);
}
return FreeImage_AdjustCurve(src, LUT, FICC_RGB);
}
/** @brief Computes image histogram
src/Source/LibJPEG/cdjpeg.c view on Meta::CPAN
#endif
#ifdef SIGTERM /* not all systems have SIGTERM */
signal(SIGTERM, signal_catcher);
#endif
}
#endif
/*
* Optional progress monitor: display a percent-done figure on stderr.
*/
#ifdef PROGRESS_REPORT
METHODDEF(void)
progress_monitor (j_common_ptr cinfo)
{
cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress;
int total_passes = prog->pub.total_passes + prog->total_extra_passes;
int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit);
if (percent_done != prog->percent_done) {
prog->percent_done = percent_done;
if (total_passes > 1) {
fprintf(stderr, "\rPass %d/%d: %3d%% ",
prog->pub.completed_passes + prog->completed_extra_passes + 1,
total_passes, percent_done);
} else {
fprintf(stderr, "\r %3d%% ", percent_done);
}
fflush(stderr);
}
}
GLOBAL(void)
start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress)
{
/* Enable progress display, unless trace output is on */
if (cinfo->err->trace_level == 0) {
progress->pub.progress_monitor = progress_monitor;
progress->completed_extra_passes = 0;
progress->total_extra_passes = 0;
progress->percent_done = -1;
cinfo->progress = &progress->pub;
}
}
GLOBAL(void)
end_progress_monitor (j_common_ptr cinfo)
{
/* Clear away progress display */
if (cinfo->err->trace_level == 0) {
src/Source/LibJPEG/cdjpeg.h view on Meta::CPAN
* the source/destination file format. The JPEG library does not know
* about these passes, but we'd like them to be counted by the progress
* monitor. We use an expanded progress monitor object to hold the
* additional pass count.
*/
struct cdjpeg_progress_mgr {
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
int completed_extra_passes; /* extra passes completed */
int total_extra_passes; /* total extra */
/* last printed percentage stored here to avoid multiple printouts */
int percent_done;
};
typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jinit_read_bmp jIRdBMP
#define jinit_write_bmp jIWrBMP
src/Source/LibJPEG/install.txt view on Meta::CPAN
is the right thing if you say
make install-lib
OPTIONAL STUFF
==============
Progress monitor:
If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display
of percent-done progress reports. The routine provided in cdjpeg.c merely
prints percentages to stderr, but you can customize it to do something
fancier.
Utah RLE file format support:
We distribute the software with support for RLE image files (Utah Raster
Toolkit format) disabled, because the RLE support won't compile without the
Utah library. If you have URT version 3.1 or later, you can enable RLE
support as follows:
1. #define RLE_SUPPORTED in jconfig.h.
2. Add a -I option to CFLAGS in the Makefile for the directory
src/Source/LibJPEG/jchuff.c view on Meta::CPAN
* zero bytes in the final file). In any case the difference is tiny.
*
* The JPEG standard requires Huffman codes to be no more than 16 bits long.
* If some symbols have a very small but nonzero probability, the Huffman tree
* must be adjusted to meet the code length restriction. We currently use
* the adjustment method suggested in JPEG section K.2. This method is *not*
* optimal; it may not choose the best possible limited-length code. But
* typically only very-low-frequency symbols will be given less-than-optimal
* lengths, so the code is almost optimal. Experimental comparisons against
* an optimal limited-length-code algorithm indicate that the difference is
* microscopic --- usually less than a hundredth of a percent of total size.
* So the extra complexity of an optimal algorithm doesn't seem worthwhile.
*/
LOCAL(void)
jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
{
#define MAX_CLEN 32 /* assumed maximum initial code length */
UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */
int codesize[257]; /* codesize[k] = code length of symbol k */
int others[257]; /* next symbol in current branch of tree */
src/Source/LibJPEG/jconfig.h view on Meta::CPAN
*/
#undef NEED_SIGNAL_CATCHER
/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
* This is necessary on systems that distinguish text files from binary files,
* and is harmless on most systems that don't. If you have one of the rare
* systems that complains about the "b" spec, define this symbol.
*/
#undef DONT_USE_B_MODE
/* Define this if you want percent-done progress reports from cjpeg/djpeg.
*/
#undef PROGRESS_REPORT
#endif /* JPEG_CJPEG_DJPEG */
src/Source/LibJPEG/jconfig.txt view on Meta::CPAN
*/
#undef NEED_SIGNAL_CATCHER
/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
* This is necessary on systems that distinguish text files from binary files,
* and is harmless on most systems that don't. If you have one of the rare
* systems that complains about the "b" spec, define this symbol.
*/
#undef DONT_USE_B_MODE
/* Define this if you want percent-done progress reports from cjpeg/djpeg.
*/
#undef PROGRESS_REPORT
#endif /* JPEG_CJPEG_DJPEG */
src/Source/LibJPEG/jcparam.c view on Meta::CPAN
/*
* Quantization table setup routines
*/
GLOBAL(void)
jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
int scale_factor, boolean force_baseline)
/* Define a quantization table equal to the basic_table times
* a scale factor (given as a percentage).
* If force_baseline is TRUE, the computed quantization table entries
* are limited to 1..255 for JPEG baseline compatibility.
*/
{
JQUANT_TBL ** qtblptr;
int i;
long temp;
/* Safety check to ensure start_compress not called yet. */
if (cinfo->global_state != CSTATE_START)
src/Source/LibJPEG/jcparam.c view on Meta::CPAN
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
GLOBAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
/* Set or change the 'quality' (quantization) setting, using default tables
* and straight percentage-scaling quality scales.
* This entry point allows different scalings for luminance and chrominance.
*/
{
/* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
cinfo->q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
}
GLOBAL(void)
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
boolean force_baseline)
/* Set or change the 'quality' (quantization) setting, using default tables
* and a straight percentage-scaling quality scale. In most cases it's better
* to use jpeg_set_quality (below); this entry point is provided for
* applications that insist on a linear percentage scaling.
*/
{
/* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
scale_factor, force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
scale_factor, force_baseline);
}
GLOBAL(int)
jpeg_quality_scaling (int quality)
/* Convert a user-specified quality rating to a percentage scaling factor
* for an underlying quantization table, using our recommended scaling curve.
* The input 'quality' factor should be 0 (terrible) to 100 (very good).
*/
{
/* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */
if (quality <= 0) quality = 1;
if (quality > 100) quality = 100;
/* The basic table is used as-is (scaling 100) for a quality of 50.
* Qualities 50..100 are converted to scaling percentage 200 - 2*Q;
* note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table
* to make all the table entries 1 (hence, minimum quantization loss).
* Qualities 1..50 are converted to scaling percentage 5000/Q.
*/
if (quality < 50)
quality = 5000 / quality;
else
quality = 200 - quality*2;
return quality;
}
GLOBAL(void)
jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
/* Set or change the 'quality' (quantization) setting, using default tables.
* This is the standard quality-adjusting entry point for typical user
* interfaces; only those who want detailed control over quantization tables
* would use the preceding routines directly.
*/
{
/* Convert user 0-100 rating to percentage scaling */
quality = jpeg_quality_scaling(quality);
/* Set up standard quality tables */
jpeg_set_linear_quality(cinfo, quality, force_baseline);
}
/*
* Huffman table setup routines
*/
src/Source/LibJPEG/jpeglib.h view on Meta::CPAN
int num_components; /* # of color components in JPEG image */
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
int q_scale_factor[NUM_QUANT_TBLS];
/* ptrs to coefficient quantization tables, or NULL if not defined,
* and corresponding scale factors (percentage, initialized 100).
*/
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
/* ptrs to Huffman coding tables, or NULL if not defined */
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
compatibility. In the current implementation, this only makes a
difference for quality settings below 25, and it effectively prevents
very small/low quality files from being generated. The IJG decoder
is capable of reading the non-baseline files generated at low quality
settings when force_baseline is FALSE, but other decoders may not be.
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
boolean force_baseline)
Same as jpeg_set_quality() except that the generated tables are the
sample tables given in the JPEC spec section K.1, multiplied by the
specified scale factor (which is expressed as a percentage; thus
scale_factor = 100 reproduces the spec's tables). Note that larger
scale factors give lower quality. This entry point is useful for
conforming to the Adobe PostScript DCT conventions, but we do not
recommend linear scaling as a user-visible quality scale otherwise.
force_baseline again constrains the computed table entries to 1..255.
int jpeg_quality_scaling (int quality)
Converts a value on the IJG-recommended quality scale to a linear
scaling percentage. Note that this routine may change or go away
in future releases --- IJG may choose to adopt a scaling method that
can't be expressed as a simple scalar multiplier, in which case the
premise of this routine collapses. Caveat user.
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
Set default quantization tables with linear q_scale_factor[] values
(see below).
jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
Two values are currently possible: JCT_NONE and JCT_SUBTRACT_GREEN.
Set this value for lossless RGB application *before* calling
jpeg_set_colorspace(), because entropy table assignment in
jpeg_set_colorspace() depends on color_transform.
boolean optimize_coding
TRUE causes the compressor to compute optimal Huffman coding tables
for the image. This requires an extra pass over the data and
therefore costs a good deal of space and time. The default is
FALSE, which tells the compressor to use the supplied or default
Huffman tables. In most cases optimal tables save only a few percent
of file size compared to the default tables. Note that when this is
TRUE, you need not supply Huffman tables at all, and any you do
supply will be overwritten.
unsigned int restart_interval
int restart_in_rows
To emit restart markers in the JPEG file, set one of these nonzero.
Set restart_interval to specify the exact interval in MCU blocks.
Set restart_in_rows to specify the interval in MCU rows. (If
restart_in_rows is not 0, then restart_interval is set after the
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]
Pointers to coefficient quantization tables, one per table slot,
or NULL if no table is defined for a slot. Usually these should
be set via one of the above helper routines; jpeg_add_quant_table()
is general enough to define any quantization table. The other
routines will set up table slot 0 for luminance quality and table
slot 1 for chrominance.
int q_scale_factor[NUM_QUANT_TBLS]
Linear quantization scaling factors (percentage, initialized 100)
for use with jpeg_default_qtables().
See rdswitch.c and cjpeg.c for an example of usage.
Note that the q_scale_factor[] fields are the "linear" scales, so you
have to convert from user-defined ratings via jpeg_quality_scaling().
Here is an example code which corresponds to cjpeg -quality 90,70:
jpeg_set_defaults(cinfo);
/* Set luminance quality 90. */
cinfo->q_scale_factor[0] = jpeg_quality_scaling(90);
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
emitting abbreviated JPEG files by accident. If you really want to emit an
abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables'
individual sent_table flags, between calling jpeg_write_coefficients() and
jpeg_finish_compress().
Progress monitoring
-------------------
Some applications may need to regain control from the JPEG library every so
often. The typical use of this feature is to produce a percent-done bar or
other progress display. (For a simple example, see cjpeg.c or djpeg.c.)
Although you do get control back frequently during the data-transferring pass
(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes
will occur inside jpeg_finish_compress or jpeg_start_decompress; those
routines may take a long time to execute, and you don't get control back
until they are done.
You can define a progress-monitor routine which will be called periodically
by the library. No guarantees are made about how often this call will occur,
so we don't recommend you use it for mouse tracking or anything like that.
src/Source/LibJPEG/rdswitch.c view on Meta::CPAN
int tblno;
char ch;
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
if (*arg) {
ch = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c", &val, &ch) < 1)
return FALSE;
if (ch != ',') /* syntax check */
return FALSE;
/* Convert user 0-100 rating to percentage scaling */
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
;
} else {
/* reached end of parameter, set remaining factors to last value */
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
}
}
jpeg_default_qtables(cinfo, force_baseline);
return TRUE;
src/Source/LibJPEG/structure.txt view on Meta::CPAN
for other behaviors, the surrounding application may provide its own
destination manager.
* Memory manager: allocates and releases memory, controls virtual arrays
(with backing store management, where required).
* Error handler: performs formatting and output of error and trace messages;
determines handling of nonfatal errors. The surrounding application may
override some or all of this object's methods to change error handling.
* Progress monitor: supports output of "percent-done" progress reports.
This object represents an optional callback to the surrounding application:
if wanted, it must be supplied by the application.
The error handler, destination manager, and progress monitor objects are
defined as separate objects in order to simplify application-specific
customization of the JPEG library. A surrounding application may override
individual methods or supply its own all-new implementation of one of these
objects. The object interfaces for these objects are therefore treated as
part of the application interface of the library, whereas the other objects
are internal to the library.
src/Source/LibJPEG/usage.txt view on Meta::CPAN
to get a satisfactory conversion. -smooth 10 or so is often helpful.
Avoid running an image through a series of JPEG compression/decompression
cycles. Image quality loss will accumulate; after ten or so cycles the image
may be noticeably worse than it was after one cycle. It's best to use a
lossless format while manipulating an image, then convert to JPEG format when
you are ready to file the image away.
The -optimize option to cjpeg is worth using when you are making a "final"
version for posting or archiving. It's also a win when you are using low
quality settings to make very small JPEG files; the percentage improvement
is often a lot more than it is on larger files. (At present, -optimize
mode is always selected when generating progressive JPEG files.)
GIF input files are no longer supported, to avoid the Unisys LZW patent
(now expired).
(Conversion of GIF files to JPEG is usually a bad idea anyway.)
HINTS FOR DJPEG
src/Source/LibOpenJPEG/tcd.c view on Meta::CPAN
} \
\
l_current_precinct = l_band->precincts; \
for (precno = 0; precno < l_nb_precincts; ++precno) { \
OPJ_INT32 tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend; \
OPJ_INT32 cbgxstart = tlcbgxstart + (OPJ_INT32)(precno % l_res->pw) * (1 << cbgwidthexpn); \
OPJ_INT32 cbgystart = tlcbgystart + (OPJ_INT32)(precno / l_res->pw) * (1 << cbgheightexpn); \
OPJ_INT32 cbgxend = cbgxstart + (1 << cbgwidthexpn); \
OPJ_INT32 cbgyend = cbgystart + (1 << cbgheightexpn); \
/*fprintf(stderr, "\t precno=%d; bandno=%d, resno=%d; compno=%d\n", precno, bandno , resno, compno);*/ \
/*fprintf(stderr, "\t tlcbgxstart(=%d) + (precno(=%d) percent res->pw(=%d)) * (1 << cbgwidthexpn(=%d)) \n",tlcbgxstart,precno,l_res->pw,cbgwidthexpn);*/ \
\
/* precinct size (global) */ \
/*fprintf(stderr, "\t cbgxstart=%d, l_band->x0 = %d \n",cbgxstart, l_band->x0);*/ \
\
l_current_precinct->x0 = opj_int_max(cbgxstart, l_band->x0); \
l_current_precinct->y0 = opj_int_max(cbgystart, l_band->y0); \
l_current_precinct->x1 = opj_int_min(cbgxend, l_band->x1); \
l_current_precinct->y1 = opj_int_min(cbgyend, l_band->y1); \
/*fprintf(stderr, "\t prc_x0=%d; prc_y0=%d, prc_x1=%d; prc_y1=%d\n",l_current_precinct->x0, l_current_precinct->y0 ,l_current_precinct->x1, l_current_precinct->y1);*/ \
\
src/Source/LibPNG/CHANGES view on Meta::CPAN
Version 1.5.6beta05 [October 12, 2011]
Speed up png_combine_row() for interlaced images. This reduces the generality
of the code, allowing it to be optimized for Adam7 interlace. The masks
passed to png_combine_row() are now generated internally, avoiding
some code duplication and localizing the interlace handling somewhat.
Align png_struct::row_buf - previously it was always unaligned, caused by
a bug in the code that attempted to align it; the code needs to subtract
one from the pointer to take account of the filter byte prepended to
each row.
Optimized png_combine_row() when rows are aligned. This gains a small
percentage for 16-bit and 32-bit pixels in the typical case where the
output row buffers are appropriately aligned. The optimization was not
previously possible because the png_struct buffer was always misaligned.
Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
Version 1.5.6beta06 [October 17, 2011]
Removed two redundant tests for unitialized row.
Fixed a relatively harmless memory overwrite in compressed text writing
with a 1 byte zlib buffer.
Add ability to call png_read_update_info multiple times to pngvalid.c.
Fixes for multiple calls to png_read_update_info. These fixes attend to
src/Source/LibPNG/libpng-manual.txt view on Meta::CPAN
png_set_flush(png_ptr, nrows);
Note that the distance between rows is from the last time png_write_flush()
was called, or the first row of the image if it has never been called.
So if you write 50 lines, and then png_set_flush 25, it will flush the
output on the next scanline, and every 25 lines thereafter, unless
png_write_flush() is called before 25 more lines have been written.
If nrows is too small (less than about 10 lines for a 640 pixel wide
RGB image) the image compression may decrease noticeably (although this
may be acceptable for real-time applications). Infrequent flushing will
only degrade the compression performance by a few percent over images
that do not use flushing.
Writing the image data
That's it for the transformations. Now you can write the image data.
The simplest way to do this is in one function call. If you have the
whole image in memory, you can just call png_write_image() and libpng
will write the image. You will need to pass in an array of pointers to
each row. This function automatically handles interlacing, so you don't
need to call png_set_interlace_handling() or call this function multiple
src/Source/LibPNG/libpng.3 view on Meta::CPAN
png_set_flush(png_ptr, nrows);
Note that the distance between rows is from the last time png_write_flush()
was called, or the first row of the image if it has never been called.
So if you write 50 lines, and then png_set_flush 25, it will flush the
output on the next scanline, and every 25 lines thereafter, unless
png_write_flush() is called before 25 more lines have been written.
If nrows is too small (less than about 10 lines for a 640 pixel wide
RGB image) the image compression may decrease noticeably (although this
may be acceptable for real-time applications). Infrequent flushing will
only degrade the compression performance by a few percent over images
that do not use flushing.
.SS Writing the image data
That's it for the transformations. Now you can write the image data.
The simplest way to do this is in one function call. If you have the
whole image in memory, you can just call png_write_image() and libpng
will write the image. You will need to pass in an array of pointers to
each row. This function automatically handles interlacing, so you don't
need to call png_set_interlace_handling() or call this function multiple
src/Source/LibPNG/png.c view on Meta::CPAN
}
/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM
* chunk chromaticities. Earlier checks used to simply look for the overflow
* condition (where the determinant of the matrix to solve for XYZ ends up zero
* because the chromaticity values are not all distinct.) Despite this it is
* theoretically possible to produce chromaticities that are apparently valid
* but that rapidly degrade to invalid, potentially crashing, sets because of
* arithmetic inaccuracies when calculations are performed on them. The new
* check is to round-trip xy -> XYZ -> xy and then check that the result is
* within a small percentage of the original.
*/
static int
png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy)
{
int result;
png_xy xy_test;
/* As a side-effect this routine also returns the XYZ endpoints. */
result = png_XYZ_from_xy(XYZ, xy);
if (result != 0)
src/Source/LibRawLite/LICENSE.CDDL view on Meta::CPAN
code in which modifications are made and (b) associated
documentation included in or with such code.
1.13. You (or Your) means an individual or a legal entity
exercising rights under, and complying with all of the terms of,
this License. For legal entities, You includes any entity which
controls, is controlled by, or is under common control with You.
For purposes of this definition, control means (a) the power,
direct or indirect, to cause the direction or management of such
entity, whether by contract or otherwise, or (b) ownership of
more than fifty percent (50%) of the outstanding shares or
beneficial ownership of such entity.
2. License Grants.
2.1. The Initial Developer Grant. Conditioned upon Your
compliance with Section 3.1 below and subject to third party
intellectual property claims, the Initial Developer hereby
grants You a world-wide, royalty-free, non-exclusive license:
(a) under intellectual property rights (other than patent or
src/Source/LibRawLite/dcraw/dcraw.c view on Meta::CPAN
{
struct tiff_hdr th;
uchar *ppm;
ushort *ppm2;
int c, row, col, soff, rstep, cstep;
int perc, val, total, t_white=0x2000;
#ifdef LIBRAW_LIBRARY_BUILD
perc = width * height * auto_bright_thr;
#else
perc = width * height * 0.01; /* 99th percentile white level */
#endif
if (fuji_width) perc /= 2;
if (!((highlight & ~2) || no_auto_bright))
for (t_white=c=0; c < colors; c++) {
for (val=0x2000, total=0; --val > 32; )
if ((total += histogram[c][val]) > perc) break;
if (t_white < val) t_white = val;
}
gamma_curve (gamm[0], gamm[1], 2, (t_white << 3)/bright);
iheight = height;
src/Source/LibRawLite/internal/dcraw_common.cpp view on Meta::CPAN
{
struct tiff_hdr th;
uchar *ppm;
ushort *ppm2;
int c, row, col, soff, rstep, cstep;
int perc, val, total, t_white=0x2000;
#ifdef LIBRAW_LIBRARY_BUILD
perc = width * height * auto_bright_thr;
#else
perc = width * height * 0.01; /* 99th percentile white level */
#endif
if (fuji_width) perc /= 2;
if (!((highlight & ~2) || no_auto_bright))
for (t_white=c=0; c < colors; c++) {
for (val=0x2000, total=0; --val > 32; )
if ((total += histogram[c][val]) > perc) break;
if (t_white < val) t_white = val;
}
gamma_curve (gamm[0], gamm[1], 2, (t_white << 3)/bright);
iheight = height;
src/Source/LibRawLite/src/libraw_cxx.cpp view on Meta::CPAN
libraw_internal_data.output_data.histogram = t_hist;
// make curve output curve!
ushort (*t_curve) = (ushort*) calloc(sizeof(C.curve),1);
merror (t_curve, "LibRaw::kodak_thumb_loader()");
memmove(t_curve,C.curve,sizeof(C.curve));
memset(C.curve,0,sizeof(C.curve));
{
int perc, val, total, t_white=0x2000,c;
perc = S.width * S.height * 0.01; /* 99th percentile white level */
if (IO.fuji_width) perc /= 2;
if (!((O.highlight & ~2) || O.no_auto_bright))
for (t_white=c=0; c < P1.colors; c++) {
for (val=0x2000, total=0; --val > 32; )
if ((total += libraw_internal_data.output_data.histogram[c][val]) > perc) break;
if (t_white < val) t_white = val;
}
gamma_curve (O.gamm[0], O.gamm[1], 2, (t_white << 3)/O.bright);
}
src/Source/LibWebP/src/enc/enc.alpha.c view on Meta::CPAN
return 1;
}
int VP8EncFinishAlpha(VP8Encoder* const enc) {
if (enc->has_alpha_) {
if (enc->thread_level_ > 0) {
WebPWorker* const worker = &enc->alpha_worker_;
if (!WebPGetWorkerInterface()->Sync(worker)) return 0; // error
}
}
return WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
}
int VP8EncDeleteAlpha(VP8Encoder* const enc) {
int ok = 1;
if (enc->thread_level_ > 0) {
WebPWorker* const worker = &enc->alpha_worker_;
// finish anything left in flight
ok = WebPGetWorkerInterface()->Sync(worker);
// still need to end the worker, even if !ok
WebPGetWorkerInterface()->End(worker);
src/Source/LibWebP/src/enc/enc.analysis.c view on Meta::CPAN
int n;
for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) {
DefaultMBInfo(&enc->mb_info_[n]);
}
// Default susceptibilities.
enc->dqm_[0].alpha_ = 0;
enc->dqm_[0].beta_ = 0;
// Note: we can't compute this alpha_ / uv_alpha_ -> set to default value.
enc->alpha_ = 0;
enc->uv_alpha_ = 0;
WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
}
// struct used to collect job result
typedef struct {
WebPWorker worker;
int alphas[MAX_ALPHA + 1];
int alpha, uv_alpha;
VP8EncIterator it;
int delta_progress;
} SegmentJob;
src/Source/LibWebP/src/enc/enc.frame.c view on Meta::CPAN
q = Clamp(q, 0.f, 100.f);
VP8SetSegmentParams(enc, q); // setup segment quantizations and filters
SetSegmentProbas(enc); // compute segment probabilities
ResetStats(enc);
ResetSSE(enc);
}
static uint64_t OneStatPass(VP8Encoder* const enc, VP8RDLevel rd_opt,
int nb_mbs, int percent_delta,
PassStats* const s) {
VP8EncIterator it;
uint64_t size = 0;
uint64_t size_p0 = 0;
uint64_t distortion = 0;
const uint64_t pixel_count = nb_mbs * 384;
VP8IteratorInit(enc, &it);
SetLoopParams(enc, s->q);
do {
VP8ModeScore info;
VP8IteratorImport(&it, NULL);
if (VP8Decimate(&it, &info, rd_opt)) {
// Just record the number of skips and act like skip_proba is not used.
enc->proba_.nb_skip_++;
}
RecordResiduals(&it, &info);
size += info.R + info.H;
size_p0 += info.H;
distortion += info.D;
if (percent_delta && !VP8IteratorProgress(&it, percent_delta))
return 0;
VP8IteratorSaveBoundary(&it);
} while (VP8IteratorNext(&it) && --nb_mbs > 0);
size_p0 += enc->segment_hdr_.size_;
if (s->do_size_search) {
size += FinalizeSkipProba(enc);
size += FinalizeTokenProbas(&enc->proba_);
size = ((size + size_p0 + 1024) >> 11) + HEADER_SIZE_ESTIMATE;
s->value = (double)size;
src/Source/LibWebP/src/enc/enc.frame.c view on Meta::CPAN
s->value = GetPSNR(distortion, pixel_count);
}
return size_p0;
}
static int StatLoop(VP8Encoder* const enc) {
const int method = enc->method_;
const int do_search = enc->do_search_;
const int fast_probe = ((method == 0 || method == 3) && !do_search);
int num_pass_left = enc->config_->pass;
const int task_percent = 20;
const int percent_per_pass =
(task_percent + num_pass_left / 2) / num_pass_left;
const int final_percent = enc->percent_ + task_percent;
const VP8RDLevel rd_opt =
(method >= 3 || do_search) ? RD_OPT_BASIC : RD_OPT_NONE;
int nb_mbs = enc->mb_w_ * enc->mb_h_;
PassStats stats;
InitPassStats(enc, &stats);
ResetTokenStats(enc);
// Fast mode: quick analysis pass over few mbs. Better than nothing.
if (fast_probe) {
src/Source/LibWebP/src/enc/enc.frame.c view on Meta::CPAN
} else {
nb_mbs = (nb_mbs > 200) ? nb_mbs >> 2 : 50;
}
}
while (num_pass_left-- > 0) {
const int is_last_pass = (fabs(stats.dq) <= DQ_LIMIT) ||
(num_pass_left == 0) ||
(enc->max_i4_header_bits_ == 0);
const uint64_t size_p0 =
OneStatPass(enc, rd_opt, nb_mbs, percent_per_pass, &stats);
if (size_p0 == 0) return 0;
#if (DEBUG_SEARCH > 0)
printf("#%d value:%.1lf -> %.1lf q:%.2f -> %.2f\n",
num_pass_left, stats.last_value, stats.value, stats.last_q, stats.q);
#endif
if (enc->max_i4_header_bits_ > 0 && size_p0 > PARTITION0_SIZE_LIMIT) {
++num_pass_left;
enc->max_i4_header_bits_ >>= 1; // strengthen header bit limitation...
continue; // ...and start over
}
src/Source/LibWebP/src/enc/enc.frame.c view on Meta::CPAN
ComputeNextQ(&stats);
if (fabs(stats.dq) <= DQ_LIMIT) break;
}
}
if (!do_search || !stats.do_size_search) {
// Need to finalize probas now, since it wasn't done during the search.
FinalizeSkipProba(enc);
FinalizeTokenProbas(&enc->proba_);
}
VP8CalculateLevelCosts(&enc->proba_); // finalize costs
return WebPReportProgress(enc->pic_, final_percent, &enc->percent_);
}
//------------------------------------------------------------------------------
// Main loops
//
static const int kAverageBytesPerMB[8] = { 50, 24, 16, 9, 7, 5, 3, 2 };
static int PreLoopInitialize(VP8Encoder* const enc) {
int p;
src/Source/LibWebP/src/enc/enc.frame.c view on Meta::CPAN
ComputeNextQ(&stats); // Adjust q
}
}
if (ok) {
if (!stats.do_size_search) {
FinalizeTokenProbas(&enc->proba_);
}
ok = VP8EmitTokens(&enc->tokens_, enc->parts_ + 0,
(const uint8_t*)proba->coeffs_, 1);
}
ok = ok && WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
return PostLoopFinalize(&it, ok);
}
#else
int VP8EncTokenLoop(VP8Encoder* const enc) {
(void)enc;
return 0; // we shouldn't be here.
}
src/Source/LibWebP/src/enc/enc.iterator.c view on Meta::CPAN
void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) {
it->enc_ = enc;
it->y_stride_ = enc->pic_->y_stride;
it->uv_stride_ = enc->pic_->uv_stride;
it->yuv_in_ = (uint8_t*)DO_ALIGN(it->yuv_mem_);
it->yuv_out_ = it->yuv_in_ + YUV_SIZE;
it->yuv_out2_ = it->yuv_out_ + YUV_SIZE;
it->yuv_p_ = it->yuv_out2_ + YUV_SIZE;
it->lf_stats_ = enc->lf_stats_;
it->percent0_ = enc->percent_;
it->y_left_ = (uint8_t*)DO_ALIGN(it->yuv_left_mem_ + 1);
it->u_left_ = it->y_left_ + 16 + 16;
it->v_left_ = it->u_left_ + 16;
VP8IteratorReset(it);
}
int VP8IteratorProgress(const VP8EncIterator* const it, int delta) {
VP8Encoder* const enc = it->enc_;
if (delta && enc->pic_->progress_hook != NULL) {
const int done = it->count_down0_ - it->count_down_;
const int percent = (it->count_down0_ <= 0)
? it->percent0_
: it->percent0_ + delta * done / it->count_down0_;
return WebPReportProgress(enc->pic_, percent, &enc->percent_);
}
return 1;
}
//------------------------------------------------------------------------------
// Import the source samples into the cache. Takes care of replicating
// boundary pixels if necessary.
static WEBP_INLINE int MinSize(int a, int b) { return (a < b) ? a : b; }
src/Source/LibWebP/src/enc/enc.syntax.c view on Meta::CPAN
int p;
VP8BitWriterWipeOut(&enc->bw_);
for (p = 0; p < enc->num_parts_; ++p) {
VP8BitWriterWipeOut(enc->parts_ + p);
}
}
int VP8EncWrite(VP8Encoder* const enc) {
WebPPicture* const pic = enc->pic_;
VP8BitWriter* const bw = &enc->bw_;
const int task_percent = 19;
const int percent_per_part = task_percent / enc->num_parts_;
const int final_percent = enc->percent_ + task_percent;
int ok = 0;
size_t vp8_size, pad, riff_size;
int p;
// Partition #0 with header and partition sizes
ok = GeneratePartition0(enc);
if (!ok) return 0;
// Compute VP8 size
vp8_size = VP8_FRAME_HEADER_SIZE +
src/Source/LibWebP/src/enc/enc.syntax.c view on Meta::CPAN
VP8BitWriterWipeOut(bw); // will free the internal buffer.
}
// Token partitions
for (p = 0; p < enc->num_parts_; ++p) {
const uint8_t* const buf = VP8BitWriterBuf(enc->parts_ + p);
const size_t size = VP8BitWriterSize(enc->parts_ + p);
if (size)
ok = ok && pic->writer(buf, size, pic);
VP8BitWriterWipeOut(enc->parts_ + p); // will free the internal buffer.
ok = ok && WebPReportProgress(pic, enc->percent_ + percent_per_part,
&enc->percent_);
}
// Padding byte
if (ok && pad) {
ok = PutPaddingByte(pic);
}
enc->coded_size_ = (int)(CHUNK_HEADER_SIZE + riff_size);
ok = ok && WebPReportProgress(pic, final_percent, &enc->percent_);
return ok;
}
//------------------------------------------------------------------------------