Improve code formatting consistency
With rare exceptions ...
- Always separate line continuation characters by one space from
preceding code.
- Always use two-space indentation. Never use tabs.
- Always use K&R-style conditional blocks.
- Always surround operators with spaces, except in raw assembly code.
- Always put a space after, but not before, a comma.
- Never put a space between type casts and variables/function calls.
- Never put a space between the function name and the argument list in
function declarations and prototypes.
- Always surround braces ('{' and '}') with spaces.
- Always surround statements (if, for, else, catch, while, do, switch)
with spaces.
- Always attach pointer symbols ('*' and '**') to the variable or
function name.
- Always precede pointer symbols ('*' and '**') by a space in type
casts.
- Use the MIN() macro from jpegint.h within the libjpeg and TurboJPEG
API libraries (using min() from tjutil.h is still necessary for
TJBench.)
- Where it makes sense (particularly in the TurboJPEG code), put a blank
line after variable declaration blocks.
- Always separate statements in one-liners by two spaces.
The purpose of this was to ease maintenance on my part and also to make
it easier for contributors to figure out how to format patch
submissions. This was admittedly confusing (even to me sometimes) when
we had 3 or 4 different style conventions in the same source tree. The
new convention is more consistent with the formatting of other OSS code
bases.
This commit corrects deviations from the chosen formatting style in the
libjpeg API code and reformats the TurboJPEG API code such that it
conforms to the same standard.
NOTES:
- Although it is no longer necessary for the function name in function
declarations to begin in Column 1 (this was historically necessary
because of the ansi2knr utility, which allowed libjpeg to be built
with non-ANSI compilers), we retain that formatting for the libjpeg
code because it improves readability when using libjpeg's function
attribute macros (GLOBAL(), etc.)
- This reformatting project was accomplished with the help of AStyle and
Uncrustify, although neither was completely up to the task, and thus
a great deal of manual tweaking was required. Note to developers of
code formatting utilities: the libjpeg-turbo code base is an
excellent test bed, because AFAICT, it breaks every single one of the
utilities that are currently available.
- The legacy (MMX, SSE, 3DNow!) assembly code for i386 has been
formatted to match the SSE2 code (refer to
ff5685d5344273df321eb63a005eaae19d2496e3.) I hadn't intended to
bother with this, but the Loongson MMI implementation demonstrated
that there is still academic value to the MMX implementation, as an
algorithmic model for other 64-bit vector implementations. Thus, it
is desirable to improve its readability in the same manner as that of
the SSE2 implementation.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#define JMAKE_ENUM_LIST
|
||||
#else
|
||||
/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
|
||||
#define JMESSAGE(code,string)
|
||||
#define JMESSAGE(code, string)
|
||||
#endif /* CDERROR_H */
|
||||
#endif /* JMESSAGE */
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
|
||||
typedef enum {
|
||||
|
||||
#define JMESSAGE(code,string) code ,
|
||||
#define JMESSAGE(code, string) code,
|
||||
|
||||
#endif /* JMAKE_ENUM_LIST */
|
||||
|
||||
JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */
|
||||
JMESSAGE(JMSG_FIRSTADDONCODE = 1000, NULL) /* Must be first entry! */
|
||||
|
||||
#ifdef BMP_SUPPORTED
|
||||
JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
|
||||
|
||||
21
cdjpeg.c
21
cdjpeg.c
@@ -28,11 +28,12 @@
|
||||
#ifdef PROGRESS_REPORT
|
||||
|
||||
METHODDEF(void)
|
||||
progress_monitor (j_common_ptr cinfo)
|
||||
progress_monitor(j_common_ptr cinfo)
|
||||
{
|
||||
cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress;
|
||||
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);
|
||||
int percent_done =
|
||||
(int)(prog->pub.pass_counter * 100L / prog->pub.pass_limit);
|
||||
|
||||
if (percent_done != prog->percent_done) {
|
||||
prog->percent_done = percent_done;
|
||||
@@ -49,7 +50,7 @@ progress_monitor (j_common_ptr cinfo)
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress)
|
||||
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) {
|
||||
@@ -63,7 +64,7 @@ start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress)
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
end_progress_monitor (j_common_ptr cinfo)
|
||||
end_progress_monitor(j_common_ptr cinfo)
|
||||
{
|
||||
/* Clear away progress display */
|
||||
if (cinfo->err->trace_level == 0) {
|
||||
@@ -82,7 +83,7 @@ end_progress_monitor (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
keymatch (char *arg, const char *keyword, int minchars)
|
||||
keymatch(char *arg, const char *keyword, int minchars)
|
||||
{
|
||||
register int ca, ck;
|
||||
register int nmatched = 0;
|
||||
@@ -109,9 +110,9 @@ keymatch (char *arg, const char *keyword, int minchars)
|
||||
*/
|
||||
|
||||
GLOBAL(FILE *)
|
||||
read_stdin (void)
|
||||
read_stdin(void)
|
||||
{
|
||||
FILE * input_file = stdin;
|
||||
FILE *input_file = stdin;
|
||||
|
||||
#ifdef USE_SETMODE /* need to hack file mode? */
|
||||
setmode(fileno(stdin), O_BINARY);
|
||||
@@ -127,9 +128,9 @@ read_stdin (void)
|
||||
|
||||
|
||||
GLOBAL(FILE *)
|
||||
write_stdout (void)
|
||||
write_stdout(void)
|
||||
{
|
||||
FILE * output_file = stdout;
|
||||
FILE *output_file = stdout;
|
||||
|
||||
#ifdef USE_SETMODE /* need to hack file mode? */
|
||||
setmode(fileno(stdout), O_BINARY);
|
||||
|
||||
45
cdjpeg.h
45
cdjpeg.h
@@ -96,43 +96,42 @@ typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
|
||||
|
||||
/* Module selection routines for I/O modules. */
|
||||
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_bmp (j_compress_ptr cinfo,
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
|
||||
boolean use_inversion_array);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_bmp (j_decompress_ptr cinfo,
|
||||
boolean is_os2,
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
|
||||
boolean use_inversion_array);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_gif (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_gif (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_ppm (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_ppm (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_rle (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_rle (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_targa (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_targa (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_rle(j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_rle(j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
|
||||
|
||||
/* cjpeg support routines (in rdswitch.c) */
|
||||
|
||||
EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char *filename,
|
||||
EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
|
||||
boolean force_baseline);
|
||||
EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char *filename);
|
||||
EXTERN(boolean) set_quality_ratings (j_compress_ptr cinfo, char *arg,
|
||||
EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
|
||||
EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
|
||||
boolean force_baseline);
|
||||
EXTERN(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg);
|
||||
EXTERN(boolean) set_sample_factors (j_compress_ptr cinfo, char *arg);
|
||||
EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
|
||||
EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
|
||||
|
||||
/* djpeg support routines (in rdcolmap.c) */
|
||||
|
||||
EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE *infile);
|
||||
EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
|
||||
|
||||
/* common support routines (in cdjpeg.c) */
|
||||
|
||||
EXTERN(void) enable_signal_catcher (j_common_ptr cinfo);
|
||||
EXTERN(void) start_progress_monitor (j_common_ptr cinfo,
|
||||
EXTERN(void) enable_signal_catcher(j_common_ptr cinfo);
|
||||
EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
|
||||
cd_progress_ptr progress);
|
||||
EXTERN(void) end_progress_monitor (j_common_ptr cinfo);
|
||||
EXTERN(boolean) keymatch (char *arg, const char *keyword, int minchars);
|
||||
EXTERN(FILE *) read_stdin (void);
|
||||
EXTERN(FILE *) write_stdout (void);
|
||||
EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
|
||||
EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
|
||||
EXTERN(FILE *) read_stdin(void);
|
||||
EXTERN(FILE *) write_stdout(void);
|
||||
|
||||
/* miscellaneous useful macros */
|
||||
|
||||
|
||||
2
cjpeg.1
2
cjpeg.1
@@ -46,7 +46,7 @@ compressing a grayscale BMP file, because
|
||||
.B cjpeg
|
||||
isn't bright enough to notice whether a BMP file uses only shades of gray.
|
||||
By saying
|
||||
.BR \-grayscale ,
|
||||
.BR \-grayscale,
|
||||
you'll get a smaller JPEG file that takes less time to process.
|
||||
.TP
|
||||
.B \-rgb
|
||||
|
||||
47
cjpeg.c
47
cjpeg.c
@@ -32,8 +32,8 @@
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
|
||||
@@ -49,7 +49,7 @@ extern void free (void *ptr);
|
||||
|
||||
/* Create the add-on message string table. */
|
||||
|
||||
#define JMESSAGE(code,string) string ,
|
||||
#define JMESSAGE(code, string) string,
|
||||
|
||||
static const char * const cdjpeg_message_table[] = {
|
||||
#include "cderror.h"
|
||||
@@ -87,7 +87,7 @@ static boolean is_targa; /* records user -targa switch */
|
||||
|
||||
|
||||
LOCAL(cjpeg_source_ptr)
|
||||
select_file_type (j_compress_ptr cinfo, FILE *infile)
|
||||
select_file_type(j_compress_ptr cinfo, FILE *infile)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -150,7 +150,7 @@ boolean memdst; /* for -memdst switch */
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
usage (void)
|
||||
usage(void)
|
||||
/* complain about bad command line */
|
||||
{
|
||||
fprintf(stderr, "usage: %s [switches] ", progname);
|
||||
@@ -215,7 +215,7 @@ usage (void)
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
||||
int last_file_arg_seen, boolean for_real)
|
||||
/* Parse optional switches.
|
||||
* Returns argv[] index of first file-name argument (== argc if none).
|
||||
@@ -292,7 +292,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
/* On first -d, print version identification */
|
||||
static boolean printed_version = FALSE;
|
||||
|
||||
if (! printed_version) {
|
||||
if (!printed_version) {
|
||||
fprintf(stderr, "%s version %s (build %s)\n",
|
||||
PACKAGE_NAME, VERSION, BUILD);
|
||||
fprintf(stderr, "%s\n\n", JCOPYRIGHT);
|
||||
@@ -307,7 +307,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
PACKAGE_NAME, VERSION, BUILD);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
||||
} else if (keymatch(arg, "grayscale", 2) ||
|
||||
keymatch(arg, "greyscale", 2)) {
|
||||
/* Force a monochrome JPEG file to be generated. */
|
||||
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
||||
|
||||
@@ -406,10 +407,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
if (lval < 0 || lval > 65535L)
|
||||
usage();
|
||||
if (ch == 'b' || ch == 'B') {
|
||||
cinfo->restart_interval = (unsigned int) lval;
|
||||
cinfo->restart_interval = (unsigned int)lval;
|
||||
cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */
|
||||
} else {
|
||||
cinfo->restart_in_rows = (int) lval;
|
||||
cinfo->restart_in_rows = (int)lval;
|
||||
/* restart_interval will be computed during startup */
|
||||
}
|
||||
|
||||
@@ -464,19 +465,19 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
/* Set quantization tables for selected quality. */
|
||||
/* Some or all may be overridden if -qtables is present. */
|
||||
if (qualityarg != NULL) /* process -quality if it was present */
|
||||
if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
|
||||
if (!set_quality_ratings(cinfo, qualityarg, force_baseline))
|
||||
usage();
|
||||
|
||||
if (qtablefile != NULL) /* process -qtables if it was present */
|
||||
if (! read_quant_tables(cinfo, qtablefile, force_baseline))
|
||||
if (!read_quant_tables(cinfo, qtablefile, force_baseline))
|
||||
usage();
|
||||
|
||||
if (qslotsarg != NULL) /* process -qslots if it was present */
|
||||
if (! set_quant_slots(cinfo, qslotsarg))
|
||||
if (!set_quant_slots(cinfo, qslotsarg))
|
||||
usage();
|
||||
|
||||
if (samplearg != NULL) /* process -sample if it was present */
|
||||
if (! set_sample_factors(cinfo, samplearg))
|
||||
if (!set_sample_factors(cinfo, samplearg))
|
||||
usage();
|
||||
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
@@ -486,7 +487,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
if (scansarg != NULL) /* process -scans if it was present */
|
||||
if (! read_scan_script(cinfo, scansarg))
|
||||
if (!read_scan_script(cinfo, scansarg))
|
||||
usage();
|
||||
#endif
|
||||
}
|
||||
@@ -500,7 +501,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
@@ -556,14 +557,14 @@ main (int argc, char **argv)
|
||||
if (!memdst) {
|
||||
/* Must have either -outfile switch or explicit output file name */
|
||||
if (outfilename == NULL) {
|
||||
if (file_index != argc-2) {
|
||||
if (file_index != argc - 2) {
|
||||
fprintf(stderr, "%s: must name one input and one output file\n",
|
||||
progname);
|
||||
usage();
|
||||
}
|
||||
outfilename = argv[file_index+1];
|
||||
outfilename = argv[file_index + 1];
|
||||
} else {
|
||||
if (file_index != argc-1) {
|
||||
if (file_index != argc - 1) {
|
||||
fprintf(stderr, "%s: must name one input and one output file\n",
|
||||
progname);
|
||||
usage();
|
||||
@@ -572,7 +573,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
#else
|
||||
/* Unix style: expect zero or one file name */
|
||||
if (file_index < argc-1) {
|
||||
if (file_index < argc - 1) {
|
||||
fprintf(stderr, "%s: only one input file\n", progname);
|
||||
usage();
|
||||
}
|
||||
@@ -628,7 +629,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
start_progress_monitor((j_common_ptr) &cinfo, &progress);
|
||||
start_progress_monitor((j_common_ptr)&cinfo, &progress);
|
||||
#endif
|
||||
|
||||
/* Figure out the input file format, and set up to read it. */
|
||||
@@ -661,7 +662,7 @@ main (int argc, char **argv)
|
||||
/* Process data */
|
||||
while (cinfo.next_scanline < cinfo.image_height) {
|
||||
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
|
||||
(void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
|
||||
(void)jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
|
||||
}
|
||||
|
||||
/* Finish compression and release memory */
|
||||
@@ -676,7 +677,7 @@ main (int argc, char **argv)
|
||||
fclose(output_file);
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
end_progress_monitor((j_common_ptr) &cinfo);
|
||||
end_progress_monitor((j_common_ptr)&cinfo);
|
||||
#endif
|
||||
|
||||
if (memdst) {
|
||||
|
||||
15
cmyk.h
15
cmyk.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* cmyk.h
|
||||
*
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* Copyright (C) 2017-2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -11,16 +11,13 @@
|
||||
* system.
|
||||
*/
|
||||
|
||||
#include <jpeglib.h>
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifndef CMYK_H
|
||||
#define CMYK_H
|
||||
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
#include <jinclude.h>
|
||||
#define JPEG_INTERNALS
|
||||
#include <jpeglib.h>
|
||||
#include "jconfigint.h"
|
||||
|
||||
|
||||
/* Fully reversible */
|
||||
@@ -33,7 +30,7 @@ rgb_to_cmyk(JSAMPLE r, JSAMPLE g, JSAMPLE b, JSAMPLE *c, JSAMPLE *m,
|
||||
double ctmp = 1.0 - ((double)r / 255.0);
|
||||
double mtmp = 1.0 - ((double)g / 255.0);
|
||||
double ytmp = 1.0 - ((double)b / 255.0);
|
||||
double ktmp = min(min(ctmp, mtmp), ytmp);
|
||||
double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
|
||||
|
||||
if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
|
||||
else {
|
||||
|
||||
47
djpeg.c
47
djpeg.c
@@ -33,7 +33,7 @@
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare free() */
|
||||
extern void free (void *ptr);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
#include <ctype.h> /* to declare isprint() */
|
||||
@@ -51,7 +51,7 @@ extern void free (void *ptr);
|
||||
|
||||
/* Create the add-on message string table. */
|
||||
|
||||
#define JMESSAGE(code,string) string ,
|
||||
#define JMESSAGE(code, string) string,
|
||||
|
||||
static const char * const cdjpeg_message_table[] = {
|
||||
#include "cderror.h"
|
||||
@@ -103,7 +103,7 @@ JDIMENSION crop_x, crop_y, crop_width, crop_height;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
usage (void)
|
||||
usage(void)
|
||||
/* complain about bad command line */
|
||||
{
|
||||
fprintf(stderr, "usage: %s [switches] ", progname);
|
||||
@@ -186,7 +186,7 @@ usage (void)
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
|
||||
int last_file_arg_seen, boolean for_real)
|
||||
/* Parse optional switches.
|
||||
* Returns argv[] index of first file-name argument (== argc if none).
|
||||
@@ -270,7 +270,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
/* On first -d, print version identification */
|
||||
static boolean printed_version = FALSE;
|
||||
|
||||
if (! printed_version) {
|
||||
if (!printed_version) {
|
||||
fprintf(stderr, "%s version %s (build %s)\n",
|
||||
PACKAGE_NAME, VERSION, BUILD);
|
||||
fprintf(stderr, "%s\n\n", JCOPYRIGHT);
|
||||
@@ -289,7 +289,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
/* Select recommended processing options for quick-and-dirty output. */
|
||||
cinfo->two_pass_quantize = FALSE;
|
||||
cinfo->dither_mode = JDITHER_ORDERED;
|
||||
if (! cinfo->quantize_colors) /* don't override an earlier -colors */
|
||||
if (!cinfo->quantize_colors) /* don't override an earlier -colors */
|
||||
cinfo->desired_number_of_colors = 216;
|
||||
cinfo->dct_method = JDCT_FASTEST;
|
||||
cinfo->do_fancy_upsampling = FALSE;
|
||||
@@ -298,7 +298,8 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
/* GIF output format. */
|
||||
requested_fmt = FMT_GIF;
|
||||
|
||||
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
||||
} else if (keymatch(arg, "grayscale", 2) ||
|
||||
keymatch(arg, "greyscale", 2)) {
|
||||
/* Force monochrome output. */
|
||||
cinfo->out_color_space = JCS_GRAYSCALE;
|
||||
|
||||
@@ -433,13 +434,13 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
*/
|
||||
|
||||
LOCAL(unsigned int)
|
||||
jpeg_getc (j_decompress_ptr cinfo)
|
||||
jpeg_getc(j_decompress_ptr cinfo)
|
||||
/* Read next byte */
|
||||
{
|
||||
struct jpeg_source_mgr *datasrc = cinfo->src;
|
||||
|
||||
if (datasrc->bytes_in_buffer == 0) {
|
||||
if (! (*datasrc->fill_input_buffer) (cinfo))
|
||||
if (!(*datasrc->fill_input_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
datasrc->bytes_in_buffer--;
|
||||
@@ -448,7 +449,7 @@ jpeg_getc (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
METHODDEF(boolean)
|
||||
print_text_marker (j_decompress_ptr cinfo)
|
||||
print_text_marker(j_decompress_ptr cinfo)
|
||||
{
|
||||
boolean traceit = (cinfo->err->trace_level >= 1);
|
||||
long length;
|
||||
@@ -461,10 +462,10 @@ print_text_marker (j_decompress_ptr cinfo)
|
||||
|
||||
if (traceit) {
|
||||
if (cinfo->unread_marker == JPEG_COM)
|
||||
fprintf(stderr, "Comment, length %ld:\n", (long) length);
|
||||
fprintf(stderr, "Comment, length %ld:\n", (long)length);
|
||||
else /* assume it is an APPn otherwise */
|
||||
fprintf(stderr, "APP%d, length %ld:\n",
|
||||
cinfo->unread_marker - JPEG_APP0, (long) length);
|
||||
cinfo->unread_marker - JPEG_APP0, (long)length);
|
||||
}
|
||||
|
||||
while (--length >= 0) {
|
||||
@@ -503,7 +504,7 @@ print_text_marker (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
@@ -542,7 +543,7 @@ main (int argc, char **argv)
|
||||
* but don't try to override APP0 or APP14 this way (see libjpeg.txt).
|
||||
*/
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_APP0 + 12, print_text_marker);
|
||||
|
||||
/* Scan command line to find file names. */
|
||||
/* It is convenient to use just one switch-parsing routine, but the switch
|
||||
@@ -557,14 +558,14 @@ main (int argc, char **argv)
|
||||
#ifdef TWO_FILE_COMMANDLINE
|
||||
/* Must have either -outfile switch or explicit output file name */
|
||||
if (outfilename == NULL) {
|
||||
if (file_index != argc-2) {
|
||||
if (file_index != argc - 2) {
|
||||
fprintf(stderr, "%s: must name one input and one output file\n",
|
||||
progname);
|
||||
usage();
|
||||
}
|
||||
outfilename = argv[file_index+1];
|
||||
outfilename = argv[file_index + 1];
|
||||
} else {
|
||||
if (file_index != argc-1) {
|
||||
if (file_index != argc - 1) {
|
||||
fprintf(stderr, "%s: must name one input and one output file\n",
|
||||
progname);
|
||||
usage();
|
||||
@@ -572,7 +573,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
#else
|
||||
/* Unix style: expect zero or one file name */
|
||||
if (file_index < argc-1) {
|
||||
if (file_index < argc - 1) {
|
||||
fprintf(stderr, "%s: only one input file\n", progname);
|
||||
usage();
|
||||
}
|
||||
@@ -601,7 +602,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
start_progress_monitor((j_common_ptr) &cinfo, &progress);
|
||||
start_progress_monitor((j_common_ptr)&cinfo, &progress);
|
||||
#endif
|
||||
|
||||
/* Specify data source for decompression */
|
||||
@@ -631,7 +632,7 @@ main (int argc, char **argv)
|
||||
jpeg_stdio_src(&cinfo, input_file);
|
||||
|
||||
/* Read file header, set default decompression parameters */
|
||||
(void) jpeg_read_header(&cinfo, TRUE);
|
||||
(void)jpeg_read_header(&cinfo, TRUE);
|
||||
|
||||
/* Adjust default decompression parameters by re-parsing the options */
|
||||
file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
|
||||
@@ -675,7 +676,7 @@ main (int argc, char **argv)
|
||||
dest_mgr->output_file = output_file;
|
||||
|
||||
/* Start decompressor */
|
||||
(void) jpeg_start_decompress(&cinfo);
|
||||
(void)jpeg_start_decompress(&cinfo);
|
||||
|
||||
/* Skip rows */
|
||||
if (skip) {
|
||||
@@ -797,7 +798,7 @@ main (int argc, char **argv)
|
||||
* of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
|
||||
*/
|
||||
(*dest_mgr->finish_output) (&cinfo, dest_mgr);
|
||||
(void) jpeg_finish_decompress(&cinfo);
|
||||
(void)jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
||||
/* Close files, if we opened them */
|
||||
@@ -807,7 +808,7 @@ main (int argc, char **argv)
|
||||
fclose(output_file);
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
end_progress_monitor((j_common_ptr) &cinfo);
|
||||
end_progress_monitor((j_common_ptr)&cinfo);
|
||||
#endif
|
||||
|
||||
if (memsrc && inbuffer != NULL)
|
||||
|
||||
22
example.txt
22
example.txt
@@ -83,7 +83,7 @@ extern int image_width; /* Number of columns in image */
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
write_JPEG_file (char *filename, int quality)
|
||||
write_JPEG_file(char *filename, int quality)
|
||||
{
|
||||
/* This struct contains the JPEG compression parameters and pointers to
|
||||
* working space (which is allocated as needed by the JPEG library).
|
||||
@@ -172,8 +172,8 @@ write_JPEG_file (char *filename, int quality)
|
||||
* Here the array is only one element long, but you could pass
|
||||
* more than one scanline at a time if that's more convenient.
|
||||
*/
|
||||
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
|
||||
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
row_pointer[0] = &image_buffer[cinfo.next_scanline * row_stride];
|
||||
(void)jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
|
||||
/* Step 6: Finish compression */
|
||||
@@ -274,10 +274,10 @@ typedef struct my_error_mgr *my_error_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
my_error_exit (j_common_ptr cinfo)
|
||||
my_error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
|
||||
my_error_ptr myerr = (my_error_ptr) cinfo->err;
|
||||
my_error_ptr myerr = (my_error_ptr)cinfo->err;
|
||||
|
||||
/* Always display the message. */
|
||||
/* We could postpone this until after returning, if we chose. */
|
||||
@@ -295,7 +295,7 @@ my_error_exit (j_common_ptr cinfo)
|
||||
|
||||
|
||||
GLOBAL(int)
|
||||
read_JPEG_file (char *filename)
|
||||
read_JPEG_file(char *filename)
|
||||
{
|
||||
/* This struct contains the JPEG decompression parameters and pointers to
|
||||
* working space (which is allocated as needed by the JPEG library).
|
||||
@@ -345,7 +345,7 @@ read_JPEG_file (char *filename)
|
||||
|
||||
/* Step 3: read file parameters with jpeg_read_header() */
|
||||
|
||||
(void) jpeg_read_header(&cinfo, TRUE);
|
||||
(void)jpeg_read_header(&cinfo, TRUE);
|
||||
/* We can ignore the return value from jpeg_read_header since
|
||||
* (a) suspension is not possible with the stdio data source, and
|
||||
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
|
||||
@@ -360,7 +360,7 @@ read_JPEG_file (char *filename)
|
||||
|
||||
/* Step 5: Start decompressor */
|
||||
|
||||
(void) jpeg_start_decompress(&cinfo);
|
||||
(void)jpeg_start_decompress(&cinfo);
|
||||
/* We can ignore the return value since suspension is not possible
|
||||
* with the stdio data source.
|
||||
*/
|
||||
@@ -375,7 +375,7 @@ read_JPEG_file (char *filename)
|
||||
row_stride = cinfo.output_width * cinfo.output_components;
|
||||
/* Make a one-row-high sample array that will go away when done with image */
|
||||
buffer = (*cinfo.mem->alloc_sarray)
|
||||
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||
((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||
|
||||
/* Step 6: while (scan lines remain to be read) */
|
||||
/* jpeg_read_scanlines(...); */
|
||||
@@ -388,14 +388,14 @@ read_JPEG_file (char *filename)
|
||||
* Here the array is only one element long, but you could ask for
|
||||
* more than one scanline at a time if that's more convenient.
|
||||
*/
|
||||
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
|
||||
(void)jpeg_read_scanlines(&cinfo, buffer, 1);
|
||||
/* Assume put_scanline_someplace wants a pointer and sample count. */
|
||||
put_scanline_someplace(buffer[0], row_stride);
|
||||
}
|
||||
|
||||
/* Step 7: Finish decompression */
|
||||
|
||||
(void) jpeg_finish_decompress(&cinfo);
|
||||
(void)jpeg_finish_decompress(&cinfo);
|
||||
/* We can ignore the return value since suspension is not possible
|
||||
* with the stdio data source.
|
||||
*/
|
||||
|
||||
@@ -29,9 +29,10 @@
|
||||
* implementation (jbig_tab.c).
|
||||
*/
|
||||
|
||||
#define V(i,a,b,c,d) (((JLONG)a << 16) | ((JLONG)c << 8) | ((JLONG)d << 7) | b)
|
||||
#define V(i, a, b, c, d) \
|
||||
(((JLONG)a << 16) | ((JLONG)c << 8) | ((JLONG)d << 7) | b)
|
||||
|
||||
const JLONG jpeg_aritab[113+1] = {
|
||||
const JLONG jpeg_aritab[113 + 1] = {
|
||||
/*
|
||||
* Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.libjpegturbo.turbojpeg.*;
|
||||
|
||||
class TJBench {
|
||||
|
||||
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1;
|
||||
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvPad = 1;
|
||||
static boolean compOnly, decompOnly, doTile, doYUV, write = true;
|
||||
|
||||
static final String[] pixFormatStr = {
|
||||
@@ -96,6 +96,7 @@ class TJBench {
|
||||
static String sigFig(double val, int figs) {
|
||||
String format;
|
||||
int digitsAfterDecimal = figs - (int)Math.ceil(Math.log10(Math.abs(val)));
|
||||
|
||||
if (digitsAfterDecimal < 1)
|
||||
format = new String("%.0f");
|
||||
else
|
||||
@@ -107,10 +108,12 @@ class TJBench {
|
||||
static byte[] loadImage(String fileName, int[] w, int[] h, int pixelFormat)
|
||||
throws Exception {
|
||||
BufferedImage img = ImageIO.read(new File(fileName));
|
||||
|
||||
if (img == null)
|
||||
throw new Exception("Could not read " + fileName);
|
||||
w[0] = img.getWidth();
|
||||
h[0] = img.getHeight();
|
||||
|
||||
int[] rgb = img.getRGB(0, 0, w[0], h[0], null, 0, w[0]);
|
||||
int ps = TJ.getPixelSize(pixelFormat);
|
||||
int rindex = TJ.getRedOffset(pixelFormat);
|
||||
@@ -118,6 +121,7 @@ class TJBench {
|
||||
int bindex = TJ.getBlueOffset(pixelFormat);
|
||||
byte[] dstBuf = new byte[w[0] * h[0] * ps];
|
||||
int pixels = w[0] * h[0], dstPtr = 0, rgbPtr = 0;
|
||||
|
||||
while (pixels-- > 0) {
|
||||
dstBuf[dstPtr + rindex] = (byte)((rgb[rgbPtr] >> 16) & 0xff);
|
||||
dstBuf[dstPtr + gindex] = (byte)((rgb[rgbPtr] >> 8) & 0xff);
|
||||
@@ -137,11 +141,13 @@ class TJBench {
|
||||
int rindex = TJ.getRedOffset(pixelFormat);
|
||||
int gindex = TJ.getGreenOffset(pixelFormat);
|
||||
int bindex = TJ.getBlueOffset(pixelFormat);
|
||||
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++, srcPtr += ps) {
|
||||
int pixel = (srcBuf[srcPtr + rindex] & 0xff) << 16 |
|
||||
(srcBuf[srcPtr + gindex] & 0xff) << 8 |
|
||||
(srcBuf[srcPtr + bindex] & 0xff);
|
||||
|
||||
img.setRGB(x, y, pixel);
|
||||
}
|
||||
}
|
||||
@@ -177,7 +183,8 @@ class TJBench {
|
||||
if (doYUV) {
|
||||
int width = doTile ? tilew : scaledw;
|
||||
int height = doTile ? tileh : scaledh;
|
||||
yuvImage = new YUVImage(width, yuvpad, height, subsamp);
|
||||
|
||||
yuvImage = new YUVImage(width, yuvPad, height, subsamp);
|
||||
Arrays.fill(yuvImage.getBuf(), (byte)127);
|
||||
}
|
||||
|
||||
@@ -187,13 +194,15 @@ class TJBench {
|
||||
while (true) {
|
||||
int tile = 0;
|
||||
double start = getTime();
|
||||
|
||||
for (int y = 0; y < h; y += tileh) {
|
||||
for (int x = 0; x < w; x += tilew, tile++) {
|
||||
int width = doTile ? Math.min(tilew, w - x) : scaledw;
|
||||
int height = doTile ? Math.min(tileh, h - y) : scaledh;
|
||||
|
||||
tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]);
|
||||
if (doYUV) {
|
||||
yuvImage.setBuf(yuvImage.getBuf(), width, yuvpad, height, subsamp);
|
||||
yuvImage.setBuf(yuvImage.getBuf(), width, yuvPad, height, subsamp);
|
||||
try {
|
||||
tjd.decompressToYUV(yuvImage, flags);
|
||||
} catch (TJException e) { handleTJException(e); }
|
||||
@@ -221,7 +230,7 @@ class TJBench {
|
||||
elapsed = elapsedDecode = 0.0;
|
||||
}
|
||||
}
|
||||
if(doYUV)
|
||||
if (doYUV)
|
||||
elapsed -= elapsedDecode;
|
||||
|
||||
tjd = null;
|
||||
@@ -232,16 +241,18 @@ class TJBench {
|
||||
|
||||
if (quiet != 0) {
|
||||
System.out.format("%-6s%s",
|
||||
sigFig((double)(w * h) / 1000000. * (double)iter / elapsed, 4),
|
||||
sigFig((double)(w * h) / 1000000. *
|
||||
(double)iter / elapsed, 4),
|
||||
quiet == 2 ? "\n" : " ");
|
||||
if (doYUV)
|
||||
System.out.format("%s\n",
|
||||
sigFig((double)(w * h) / 1000000. * (double)iter / elapsedDecode, 4));
|
||||
sigFig((double)(w * h) / 1000000. *
|
||||
(double)iter / elapsedDecode, 4));
|
||||
else if (quiet != 2)
|
||||
System.out.print("\n");
|
||||
} else {
|
||||
System.out.format("%s --> Frame rate: %f fps\n",
|
||||
(doYUV ? "Decomp to YUV":"Decompress "),
|
||||
(doYUV ? "Decomp to YUV" : "Decompress "),
|
||||
(double)iter / elapsed);
|
||||
System.out.format(" Throughput: %f Megapixels/sec\n",
|
||||
(double)(w * h) / 1000000. * (double)iter / elapsed);
|
||||
@@ -249,7 +260,8 @@ class TJBench {
|
||||
System.out.format("YUV Decode --> Frame rate: %f fps\n",
|
||||
(double)iter / elapsedDecode);
|
||||
System.out.format(" Throughput: %f Megapixels/sec\n",
|
||||
(double)(w * h) / 1000000. * (double)iter / elapsedDecode);
|
||||
(double)(w * h) / 1000000. *
|
||||
(double)iter / elapsedDecode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +294,7 @@ class TJBench {
|
||||
int lum = (int)((double)(srcBuf[rindex] & 0xff) * 0.299 +
|
||||
(double)(srcBuf[gindex] & 0xff) * 0.587 +
|
||||
(double)(srcBuf[bindex] & 0xff) * 0.114 + 0.5);
|
||||
|
||||
if (lum > 255) lum = 255;
|
||||
if (lum < 0) lum = 0;
|
||||
dstBuf[rindex] = (byte)Math.abs((dstBuf[rindex] & 0xff) - lum);
|
||||
@@ -318,7 +331,8 @@ class TJBench {
|
||||
|
||||
if (quiet == 0)
|
||||
System.out.format(">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", pfStr,
|
||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down",
|
||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
||||
"Bottom-up" : "Top-down",
|
||||
subNameLong[subsamp], jpegQual);
|
||||
|
||||
tjc = new TJCompressor();
|
||||
@@ -346,7 +360,7 @@ class TJBench {
|
||||
tjc.setSubsamp(subsamp);
|
||||
|
||||
if (doYUV) {
|
||||
yuvImage = new YUVImage(tilew, yuvpad, tileh, subsamp);
|
||||
yuvImage = new YUVImage(tilew, yuvPad, tileh, subsamp);
|
||||
Arrays.fill(yuvImage.getBuf(), (byte)127);
|
||||
}
|
||||
|
||||
@@ -355,16 +369,19 @@ class TJBench {
|
||||
elapsed = elapsedEncode = 0.0;
|
||||
while (true) {
|
||||
int tile = 0;
|
||||
|
||||
totalJpegSize = 0;
|
||||
start = getTime();
|
||||
for (int y = 0; y < h; y += tileh) {
|
||||
for (int x = 0; x < w; x += tilew, tile++) {
|
||||
int width = Math.min(tilew, w - x);
|
||||
int height = Math.min(tileh, h - y);
|
||||
|
||||
tjc.setSourceImage(srcBuf, x, y, width, pitch, height, pf);
|
||||
if (doYUV) {
|
||||
double startEncode = getTime();
|
||||
yuvImage.setBuf(yuvImage.getBuf(), width, yuvpad, height,
|
||||
|
||||
yuvImage.setBuf(yuvImage.getBuf(), width, yuvPad, height,
|
||||
subsamp);
|
||||
tjc.encodeYUV(yuvImage, flags);
|
||||
if (iter >= 0)
|
||||
@@ -394,13 +411,16 @@ class TJBench {
|
||||
if (quiet != 0) {
|
||||
if (doYUV)
|
||||
System.out.format("%-6s%s",
|
||||
sigFig((double)(w * h) / 1000000. * (double)iter / elapsedEncode, 4),
|
||||
sigFig((double)(w * h) / 1000000. *
|
||||
(double)iter / elapsedEncode, 4),
|
||||
quiet == 2 ? "\n" : " ");
|
||||
System.out.format("%-6s%s",
|
||||
sigFig((double)(w * h) / 1000000. * (double)iter / elapsed, 4),
|
||||
sigFig((double)(w * h) / 1000000. *
|
||||
(double)iter / elapsed, 4),
|
||||
quiet == 2 ? "\n" : " ");
|
||||
System.out.format("%-6s%s",
|
||||
sigFig((double)(w * h * ps) / (double)totalJpegSize, 4),
|
||||
sigFig((double)(w * h * ps) / (double)totalJpegSize,
|
||||
4),
|
||||
quiet == 2 ? "\n" : " ");
|
||||
} else {
|
||||
System.out.format("\n%s size: %d x %d\n", doTile ? "Tile" : "Image",
|
||||
@@ -413,9 +433,11 @@ class TJBench {
|
||||
System.out.format(" Compression ratio: %f:1\n",
|
||||
(double)(w * h * ps) / (double)yuvImage.getSize());
|
||||
System.out.format(" Throughput: %f Megapixels/sec\n",
|
||||
(double)(w * h) / 1000000. * (double)iter / elapsedEncode);
|
||||
(double)(w * h) / 1000000. *
|
||||
(double)iter / elapsedEncode);
|
||||
System.out.format(" Output bit stream: %f Megabits/sec\n",
|
||||
(double)yuvImage.getSize() * 8. / 1000000. * (double)iter / elapsedEncode);
|
||||
(double)yuvImage.getSize() * 8. / 1000000. *
|
||||
(double)iter / elapsedEncode);
|
||||
}
|
||||
System.out.format("%s --> Frame rate: %f fps\n",
|
||||
doYUV ? "Comp from YUV" : "Compress ",
|
||||
@@ -427,12 +449,14 @@ class TJBench {
|
||||
System.out.format(" Throughput: %f Megapixels/sec\n",
|
||||
(double)(w * h) / 1000000. * (double)iter / elapsed);
|
||||
System.out.format(" Output bit stream: %f Megabits/sec\n",
|
||||
(double)totalJpegSize * 8. / 1000000. * (double)iter / elapsed);
|
||||
(double)totalJpegSize * 8. / 1000000. *
|
||||
(double)iter / elapsed);
|
||||
}
|
||||
if (tilew == w && tileh == h && write) {
|
||||
String tempStr = fileName + "_" + subName[subsamp] + "_" + "Q" +
|
||||
jpegQual + ".jpg";
|
||||
FileOutputStream fos = new FileOutputStream(tempStr);
|
||||
|
||||
fos.write(jpegBuf[0], 0, jpegSize[0]);
|
||||
fos.close();
|
||||
if (quiet == 0)
|
||||
@@ -494,7 +518,8 @@ class TJBench {
|
||||
} else if (quiet == 0)
|
||||
System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n",
|
||||
formatName(subsamp, cs), pixFormatStr[pf],
|
||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down");
|
||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
||||
"Bottom-up" : "Top-down");
|
||||
|
||||
for (int tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ;
|
||||
tilew *= 2, tileh *= 2) {
|
||||
@@ -557,7 +582,8 @@ class TJBench {
|
||||
}
|
||||
|
||||
TJTransform[] t = new TJTransform[_ntilesw * _ntilesh];
|
||||
jpegBuf = new byte[_ntilesw * _ntilesh][TJ.bufSize(_tilew, _tileh, subsamp)];
|
||||
jpegBuf =
|
||||
new byte[_ntilesw * _ntilesh][TJ.bufSize(_tilew, _tileh, subsamp)];
|
||||
|
||||
for (y = 0, tile = 0; y < _h; y += _tileh) {
|
||||
for (x = 0; x < _w; x += _tilew, tile++) {
|
||||
@@ -599,7 +625,8 @@ class TJBench {
|
||||
System.out.format("%-6s%s%-6s%s",
|
||||
sigFig((double)(w * h) / 1000000. / elapsed, 4),
|
||||
quiet == 2 ? "\n" : " ",
|
||||
sigFig((double)(w * h * ps) / (double)totalJpegSize, 4),
|
||||
sigFig((double)(w * h * ps) /
|
||||
(double)totalJpegSize, 4),
|
||||
quiet == 2 ? "\n" : " ");
|
||||
} else if (quiet == 0) {
|
||||
System.out.format("Transform --> Frame rate: %f fps\n",
|
||||
@@ -715,9 +742,9 @@ class TJBench {
|
||||
|
||||
|
||||
public static void main(String[] argv) {
|
||||
byte[] srcBuf = null; int w = 0, h = 0;
|
||||
int minQual = -1, maxQual = -1;
|
||||
int minArg = 1; int retval = 0;
|
||||
byte[] srcBuf = null;
|
||||
int w = 0, h = 0, minQual = -1, maxQual = -1;
|
||||
int minArg = 1, retval = 0;
|
||||
int subsamp = -1;
|
||||
|
||||
try {
|
||||
@@ -754,24 +781,19 @@ class TJBench {
|
||||
for (int i = minArg; i < argv.length; i++) {
|
||||
if (argv[i].equalsIgnoreCase("-tile")) {
|
||||
doTile = true; xformOpt |= TJTransform.OPT_CROP;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
System.out.println("Using fast upsampling code\n");
|
||||
flags |= TJ.FLAG_FASTUPSAMPLE;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
System.out.println("Using fastest DCT/IDCT algorithm\n");
|
||||
flags |= TJ.FLAG_FASTDCT;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
System.out.println("Using most accurate DCT/IDCT algorithm\n");
|
||||
flags |= TJ.FLAG_ACCURATEDCT;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-progressive")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-progressive")) {
|
||||
System.out.println("Using progressive entropy coding\n");
|
||||
flags |= TJ.FLAG_PROGRESSIVE;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-rgb"))
|
||||
} else if (argv[i].equalsIgnoreCase("-rgb"))
|
||||
pf = TJ.PF_RGB;
|
||||
else if (argv[i].equalsIgnoreCase("-rgbx"))
|
||||
pf = TJ.PF_RGBX;
|
||||
@@ -793,13 +815,15 @@ class TJBench {
|
||||
int temp1 = 0, temp2 = 0;
|
||||
boolean match = false, scanned = true;
|
||||
Scanner scanner = new Scanner(argv[++i]).useDelimiter("/");
|
||||
|
||||
try {
|
||||
temp1 = scanner.nextInt();
|
||||
temp2 = scanner.nextInt();
|
||||
} catch(Exception e) {}
|
||||
} catch (Exception e) {}
|
||||
if (temp2 <= 0) temp2 = 1;
|
||||
if (temp1 > 0) {
|
||||
TJScalingFactor[] scalingFactors = TJ.getScalingFactors();
|
||||
|
||||
for (int j = 0; j < scalingFactors.length; j++) {
|
||||
if ((double)temp1 / (double)temp2 ==
|
||||
(double)scalingFactors[j].getNum() /
|
||||
@@ -811,8 +835,7 @@ class TJBench {
|
||||
if (!match) usage();
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-hflip"))
|
||||
} else if (argv[i].equalsIgnoreCase("-hflip"))
|
||||
xformOp = TJTransform.OP_HFLIP;
|
||||
else if (argv[i].equalsIgnoreCase("-vflip"))
|
||||
xformOp = TJTransform.OP_VFLIP;
|
||||
@@ -832,8 +855,10 @@ class TJBench {
|
||||
xformOpt |= TJTransform.OPT_NOOUTPUT;
|
||||
else if (argv[i].equalsIgnoreCase("-copynone"))
|
||||
xformOpt |= TJTransform.OPT_COPYNONE;
|
||||
else if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) {
|
||||
else if (argv[i].equalsIgnoreCase("-benchtime") &&
|
||||
i < argv.length - 1) {
|
||||
double temp = -1;
|
||||
|
||||
try {
|
||||
temp = Double.parseDouble(argv[++i]);
|
||||
} catch (NumberFormatException e) {}
|
||||
@@ -841,20 +866,32 @@ class TJBench {
|
||||
benchTime = temp;
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-yuv")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-warmup") &&
|
||||
i < argv.length - 1) {
|
||||
double temp = -1;
|
||||
|
||||
try {
|
||||
temp = Double.parseDouble(argv[++i]);
|
||||
} catch (NumberFormatException e) {}
|
||||
if (temp >= 0.0) {
|
||||
warmup = temp;
|
||||
System.out.format("Warmup time = %.1f seconds\n\n", warmup);
|
||||
} else
|
||||
usage();
|
||||
} else if (argv[i].equalsIgnoreCase("-yuv")) {
|
||||
System.out.println("Testing YUV planar encoding/decoding\n");
|
||||
doYUV = true;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
|
||||
} else if (argv[i].equalsIgnoreCase("-yuvpad") &&
|
||||
i < argv.length - 1) {
|
||||
int temp = 0;
|
||||
|
||||
try {
|
||||
temp = Integer.parseInt(argv[++i]);
|
||||
} catch (NumberFormatException e) {}
|
||||
if (temp >= 1)
|
||||
yuvpad = temp;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
|
||||
yuvPad = temp;
|
||||
} else if (argv[i].equalsIgnoreCase("-subsamp") &&
|
||||
i < argv.length - 1) {
|
||||
i++;
|
||||
if (argv[i].toUpperCase().startsWith("G"))
|
||||
subsamp = TJ.SAMP_GRAY;
|
||||
@@ -868,22 +905,10 @@ class TJBench {
|
||||
subsamp = TJ.SAMP_420;
|
||||
else if (argv[i].equals("411"))
|
||||
subsamp = TJ.SAMP_411;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-componly"))
|
||||
} else if (argv[i].equalsIgnoreCase("-componly"))
|
||||
compOnly = true;
|
||||
else if (argv[i].equalsIgnoreCase("-nowrite"))
|
||||
write = false;
|
||||
else if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
|
||||
double temp = -1;
|
||||
try {
|
||||
temp = Double.parseDouble(argv[++i]);
|
||||
} catch (NumberFormatException e) {}
|
||||
if (temp >= 0.0) {
|
||||
warmup = temp;
|
||||
System.out.format("Warmup time = %.1f seconds\n\n", warmup);
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-stoponwarning"))
|
||||
flags |= TJ.FLAG_STOPONWARNING;
|
||||
else usage();
|
||||
@@ -901,6 +926,7 @@ class TJBench {
|
||||
|
||||
if (!decompOnly) {
|
||||
int[] width = new int[1], height = new int[1];
|
||||
|
||||
srcBuf = loadImage(argv[0], width, height, pf);
|
||||
w = width[0]; h = height[0];
|
||||
int index = -1;
|
||||
@@ -911,7 +937,8 @@ class TJBench {
|
||||
if (quiet == 1 && !decompOnly) {
|
||||
System.out.println("All performance values in Mpixels/sec\n");
|
||||
System.out.format("Bitmap JPEG JPEG %s %s ",
|
||||
(doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image"));
|
||||
(doTile ? "Tile " : "Image"),
|
||||
(doTile ? "Tile " : "Image"));
|
||||
if (doYUV)
|
||||
System.out.print("Encode ");
|
||||
System.out.print("Comp Comp Decomp ");
|
||||
@@ -959,6 +986,7 @@ class TJBench {
|
||||
} catch (Exception e) {
|
||||
if (e instanceof TJException) {
|
||||
TJException tje = (TJException)e;
|
||||
|
||||
System.out.println((tje.getErrorCode() == TJ.ERR_WARNING ?
|
||||
"WARNING: " : "ERROR: ") + tje.getMessage());
|
||||
} else
|
||||
|
||||
@@ -70,7 +70,7 @@ public class TJExample implements TJCustomFilter {
|
||||
}
|
||||
|
||||
|
||||
private static final void usage() throws Exception {
|
||||
private static void usage() throws Exception {
|
||||
System.out.println("\nUSAGE: java [Java options] " + classname +
|
||||
" <Input image> <Output image> [options]\n");
|
||||
|
||||
@@ -187,8 +187,7 @@ public class TJExample implements TJCustomFilter {
|
||||
}
|
||||
if (match != 1)
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].length() > 2 &&
|
||||
} else if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 3).equalsIgnoreCase("-su") &&
|
||||
i < argv.length - 1) {
|
||||
i++;
|
||||
@@ -202,8 +201,7 @@ public class TJExample implements TJCustomFilter {
|
||||
outSubsamp = TJ.SAMP_420;
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].substring(0, 2).equalsIgnoreCase("-q") &&
|
||||
} else if (argv[i].substring(0, 2).equalsIgnoreCase("-q") &&
|
||||
i < argv.length - 1) {
|
||||
outQual = Integer.parseInt(argv[++i]);
|
||||
if (outQual < 1 || outQual > 100)
|
||||
@@ -240,22 +238,18 @@ public class TJExample implements TJCustomFilter {
|
||||
xform.height < 1)
|
||||
usage();
|
||||
xform.options |= TJTransform.OPT_CROP;
|
||||
}
|
||||
else if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
|
||||
} else if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
|
||||
display = true;
|
||||
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
System.out.println("Using fast upsampling code");
|
||||
flags |= TJ.FLAG_FASTUPSAMPLE;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
System.out.println("Using fastest DCT/IDCT algorithm");
|
||||
flags |= TJ.FLAG_FASTDCT;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
System.out.println("Using most accurate DCT/IDCT algorithm");
|
||||
flags |= TJ.FLAG_ACCURATEDCT;
|
||||
}
|
||||
else usage();
|
||||
} else usage();
|
||||
}
|
||||
|
||||
/* Determine input and output image formats based on file extensions. */
|
||||
@@ -395,7 +389,7 @@ public class TJExample implements TJCustomFilter {
|
||||
ImageIO.write(img, outFormat, outFile);
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class TJUnitTest {
|
||||
|
||||
private static int biTypePF(int biType) {
|
||||
ByteOrder byteOrder = ByteOrder.nativeOrder();
|
||||
switch(biType) {
|
||||
switch (biType) {
|
||||
case BufferedImage.TYPE_3BYTE_BGR:
|
||||
return TJ.PF_BGR;
|
||||
case BufferedImage.TYPE_4BYTE_ABGR:
|
||||
@@ -116,7 +116,7 @@ public class TJUnitTest {
|
||||
}
|
||||
|
||||
private static String biTypeStr(int biType) {
|
||||
switch(biType) {
|
||||
switch (biType) {
|
||||
case BufferedImage.TYPE_3BYTE_BGR:
|
||||
return "3BYTE_BGR";
|
||||
case BufferedImage.TYPE_4BYTE_ABGR:
|
||||
@@ -242,6 +242,7 @@ public class TJUnitTest {
|
||||
throws Exception {
|
||||
WritableRaster wr = img.getRaster();
|
||||
int imgType = img.getType();
|
||||
|
||||
if (imgType == BufferedImage.TYPE_INT_RGB ||
|
||||
imgType == BufferedImage.TYPE_INT_BGR ||
|
||||
imgType == BufferedImage.TYPE_INT_ARGB ||
|
||||
@@ -381,7 +382,7 @@ public class TJUnitTest {
|
||||
checkVal255(row, col, a, "A");
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("\n" + e.getMessage());
|
||||
retval = 0;
|
||||
}
|
||||
@@ -471,7 +472,7 @@ public class TJUnitTest {
|
||||
checkVal255(row, col, a, "A");
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("\n" + e.getMessage());
|
||||
retval = 0;
|
||||
}
|
||||
@@ -578,7 +579,7 @@ public class TJUnitTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("\n" + e.getMessage());
|
||||
retval = 0;
|
||||
}
|
||||
@@ -728,7 +729,7 @@ public class TJUnitTest {
|
||||
|
||||
if (doYUV) {
|
||||
System.out.format("JPEG -> YUV %s ", subNameLong[subsamp]);
|
||||
if(!sf.isOne())
|
||||
if (!sf.isOne())
|
||||
System.out.format("%d/%d ... ", sf.getNum(), sf.getDenom());
|
||||
else System.out.print("... ");
|
||||
YUVImage yuvImage = tjd.decompressToYUV(scaledWidth, pad, scaledHeight,
|
||||
@@ -745,7 +746,7 @@ public class TJUnitTest {
|
||||
tjd.setSourceImage(yuvImage);
|
||||
} else {
|
||||
System.out.format("JPEG -> %s %s ", pfStrLong, buStrLong);
|
||||
if(!sf.isOne())
|
||||
if (!sf.isOne())
|
||||
System.out.format("%d/%d ... ", sf.getNum(), sf.getDenom());
|
||||
else System.out.print("... ");
|
||||
}
|
||||
@@ -827,7 +828,7 @@ public class TJUnitTest {
|
||||
}
|
||||
}
|
||||
System.out.print("--------------------\n\n");
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
if (tjc != null) tjc.close();
|
||||
if (tjd != null) tjd.close();
|
||||
throw e;
|
||||
@@ -888,7 +889,7 @@ public class TJUnitTest {
|
||||
}
|
||||
}
|
||||
System.out.println("Done. ");
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
if (tjc != null) tjc.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -949,7 +950,7 @@ public class TJUnitTest {
|
||||
doTest(48, 48, onlyRGB, TJ.SAMP_GRAY, "javatest_yuv0");
|
||||
doTest(48, 48, onlyGray, TJ.SAMP_GRAY, "javatest_yuv0");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
exitStatus = -1;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ package org.libjpegturbo.turbojpeg;
|
||||
*/
|
||||
public final class TJ {
|
||||
|
||||
|
||||
/**
|
||||
* The number of chrominance subsampling options
|
||||
*/
|
||||
|
||||
@@ -199,7 +199,7 @@ public class TJCompressor implements Closeable {
|
||||
throw new IllegalArgumentException("Invalid argument in setSourceImage()");
|
||||
srcX = x;
|
||||
srcY = y;
|
||||
srcWidth = (width == 0) ? srcImage.getWidth(): width;
|
||||
srcWidth = (width == 0) ? srcImage.getWidth() : width;
|
||||
srcHeight = (height == 0) ? srcImage.getHeight() : height;
|
||||
if (x + width > srcImage.getWidth() || y + height > srcImage.getHeight())
|
||||
throw new IllegalArgumentException("Compression region exceeds the bounds of the source image");
|
||||
@@ -208,7 +208,7 @@ public class TJCompressor implements Closeable {
|
||||
boolean intPixels = false;
|
||||
if (byteOrder == null)
|
||||
byteOrder = ByteOrder.nativeOrder();
|
||||
switch(srcImage.getType()) {
|
||||
switch (srcImage.getType()) {
|
||||
case BufferedImage.TYPE_3BYTE_BGR:
|
||||
pixelFormat = TJ.PF_BGR; break;
|
||||
case BufferedImage.TYPE_4BYTE_ABGR:
|
||||
@@ -447,7 +447,7 @@ public class TJCompressor implements Closeable {
|
||||
*/
|
||||
@Deprecated
|
||||
public void encodeYUV(byte[] dstBuf, int flags) throws TJException {
|
||||
if(dstBuf == null)
|
||||
if (dstBuf == null)
|
||||
throw new IllegalArgumentException("Invalid argument in encodeYUV()");
|
||||
checkSourceImage();
|
||||
checkSubsampling();
|
||||
@@ -475,7 +475,7 @@ public class TJCompressor implements Closeable {
|
||||
public YUVImage encodeYUV(int pad, int flags) throws TJException {
|
||||
checkSourceImage();
|
||||
checkSubsampling();
|
||||
if(pad < 1 || ((pad & (pad - 1)) != 0))
|
||||
if (pad < 1 || ((pad & (pad - 1)) != 0))
|
||||
throw new IllegalStateException("Invalid argument in encodeYUV()");
|
||||
YUVImage yuvImage = new YUVImage(srcWidth, pad, srcHeight, subsamp);
|
||||
encodeYUV(yuvImage, flags);
|
||||
@@ -571,7 +571,7 @@ public class TJCompressor implements Closeable {
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
close();
|
||||
} catch(TJException e) {
|
||||
} catch (TJException e) {
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ public class TJDecompressor implements Closeable {
|
||||
int pixelFormat; boolean intPixels = false;
|
||||
if (byteOrder == null)
|
||||
byteOrder = ByteOrder.nativeOrder();
|
||||
switch(dstImage.getType()) {
|
||||
switch (dstImage.getType()) {
|
||||
case BufferedImage.TYPE_3BYTE_BGR:
|
||||
pixelFormat = TJ.PF_BGR; break;
|
||||
case BufferedImage.TYPE_4BYTE_ABGR:
|
||||
@@ -862,7 +862,7 @@ public class TJDecompressor implements Closeable {
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
close();
|
||||
} catch(TJException e) {
|
||||
} catch (TJException e) {
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
@@ -208,12 +208,12 @@ public class YUVImage {
|
||||
* @param subsamp the level of chrominance subsampling used in the YUV
|
||||
* image (one of {@link TJ#SAMP_444 TJ.SAMP_*})
|
||||
*/
|
||||
public void setBuf(byte[][] planes, int[] offsets, int width, int strides[],
|
||||
public void setBuf(byte[][] planes, int[] offsets, int width, int[] strides,
|
||||
int height, int subsamp) {
|
||||
setBuf(planes, offsets, width, strides, height, subsamp, false);
|
||||
}
|
||||
|
||||
private void setBuf(byte[][] planes, int[] offsets, int width, int strides[],
|
||||
private void setBuf(byte[][] planes, int[] offsets, int width, int[] strides,
|
||||
int height, int subsamp, boolean alloc) {
|
||||
if ((planes == null && !alloc) || width < 1 || height < 1 || subsamp < 0 ||
|
||||
subsamp >= TJ.NUMSAMP)
|
||||
@@ -428,7 +428,7 @@ public class YUVImage {
|
||||
return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp);
|
||||
}
|
||||
|
||||
private static final int PAD(int v, int p) {
|
||||
private static int PAD(int v, int p) {
|
||||
return (v + p - 1) & (~(p - 1));
|
||||
}
|
||||
|
||||
|
||||
44
jcapimin.c
44
jcapimin.c
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -41,7 +41,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
||||
if (structsize != sizeof(struct jpeg_compress_struct))
|
||||
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
||||
(int) sizeof(struct jpeg_compress_struct), (int) structsize);
|
||||
(int)sizeof(struct jpeg_compress_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
|
||||
@@ -59,7 +59,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
cinfo->is_decompressor = FALSE;
|
||||
|
||||
/* Initialize a memory manager instance for this object */
|
||||
jinit_memory_mgr((j_common_ptr) cinfo);
|
||||
jinit_memory_mgr((j_common_ptr)cinfo);
|
||||
|
||||
/* Zero out pointers to permanent structures. */
|
||||
cinfo->progress = NULL;
|
||||
@@ -83,7 +83,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
/* Must do it here for emit_dqt in case jpeg_write_tables is used */
|
||||
cinfo->block_size = DCTSIZE;
|
||||
cinfo->natural_order = jpeg_natural_order;
|
||||
cinfo->lim_Se = DCTSIZE2-1;
|
||||
cinfo->lim_Se = DCTSIZE2 - 1;
|
||||
#endif
|
||||
|
||||
cinfo->script_space = NULL;
|
||||
@@ -100,9 +100,9 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_destroy_compress (j_compress_ptr cinfo)
|
||||
jpeg_destroy_compress(j_compress_ptr cinfo)
|
||||
{
|
||||
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@@ -112,9 +112,9 @@ jpeg_destroy_compress (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_abort_compress (j_compress_ptr cinfo)
|
||||
jpeg_abort_compress(j_compress_ptr cinfo)
|
||||
{
|
||||
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_abort((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ jpeg_abort_compress (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
|
||||
jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress)
|
||||
{
|
||||
int i;
|
||||
JQUANT_TBL *qtbl;
|
||||
@@ -159,7 +159,7 @@ jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
jpeg_finish_compress(j_compress_ptr cinfo)
|
||||
{
|
||||
JDIMENSION iMCU_row;
|
||||
|
||||
@@ -172,18 +172,18 @@ jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
} else if (cinfo->global_state != CSTATE_WRCOEFS)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
/* Perform any remaining passes */
|
||||
while (! cinfo->master->is_last_pass) {
|
||||
while (!cinfo->master->is_last_pass) {
|
||||
(*cinfo->master->prepare_for_pass) (cinfo);
|
||||
for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) iMCU_row;
|
||||
cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)iMCU_row;
|
||||
cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
/* We bypass the main controller and invoke coef controller directly;
|
||||
* all work is being done from the coefficient buffer.
|
||||
*/
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL))
|
||||
if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
(*cinfo->master->finish_pass) (cinfo);
|
||||
@@ -192,7 +192,7 @@ jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
(*cinfo->marker->write_file_trailer) (cinfo);
|
||||
(*cinfo->dest->term_destination) (cinfo);
|
||||
/* We can use jpeg_abort to release memory and reset global_state */
|
||||
jpeg_abort((j_common_ptr) cinfo);
|
||||
jpeg_abort((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,8 +204,8 @@ jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
const JOCTET *dataptr, unsigned int datalen)
|
||||
jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr,
|
||||
unsigned int datalen)
|
||||
{
|
||||
void (*write_marker_byte) (j_compress_ptr info, int val);
|
||||
|
||||
@@ -226,7 +226,7 @@ jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
/* Same, but piecemeal. */
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
jpeg_write_m_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
{
|
||||
if (cinfo->next_scanline != 0 ||
|
||||
(cinfo->global_state != CSTATE_SCANNING &&
|
||||
@@ -238,7 +238,7 @@ jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_m_byte (j_compress_ptr cinfo, int val)
|
||||
jpeg_write_m_byte(j_compress_ptr cinfo, int val)
|
||||
{
|
||||
(*cinfo->marker->write_marker_byte) (cinfo, val);
|
||||
}
|
||||
@@ -266,13 +266,13 @@ jpeg_write_m_byte (j_compress_ptr cinfo, int val)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_tables (j_compress_ptr cinfo)
|
||||
jpeg_write_tables(j_compress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state != CSTATE_START)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
|
||||
/* (Re)initialize error mgr and destination modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->dest->init_destination) (cinfo);
|
||||
/* Initialize the marker writer ... bit of a crock to do it here. */
|
||||
jinit_marker_writer(cinfo);
|
||||
|
||||
22
jcapistd.c
22
jcapistd.c
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
|
||||
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
|
||||
{
|
||||
if (cinfo->global_state != CSTATE_START)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
@@ -45,7 +45,7 @@ jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
|
||||
jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
|
||||
|
||||
/* (Re)initialize error mgr and destination modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->dest->init_destination) (cinfo);
|
||||
/* Perform master selection of active modules */
|
||||
jinit_compress_master(cinfo);
|
||||
@@ -75,7 +75,7 @@ jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION row_ctr, rows_left;
|
||||
@@ -87,9 +87,9 @@ jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Give master control module another chance if this is first call to
|
||||
@@ -118,7 +118,7 @@ jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION lines_per_iMCU_row;
|
||||
@@ -132,9 +132,9 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Give master control module another chance if this is first call to
|
||||
@@ -151,7 +151,7 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
/* Directly compress the row. */
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, data)) {
|
||||
if (!(*cinfo->coef->compress_data) (cinfo, data)) {
|
||||
/* If compressor did not consume the whole row, suspend processing. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
75
jcarith.c
75
jcarith.c
@@ -105,25 +105,25 @@ typedef arith_entropy_encoder *arith_entropy_ptr;
|
||||
|
||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#define ISHIFT_TEMPS int ishift_temp;
|
||||
#define IRIGHT_SHIFT(x,shft) \
|
||||
#define IRIGHT_SHIFT(x, shft) \
|
||||
((ishift_temp = (x)) < 0 ? \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
||||
(ishift_temp >> (shft)))
|
||||
#else
|
||||
#define ISHIFT_TEMPS
|
||||
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_byte (int val, j_compress_ptr cinfo)
|
||||
emit_byte(int val, j_compress_ptr cinfo)
|
||||
/* Write next output byte; we do not support suspension in this module. */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = cinfo->dest;
|
||||
|
||||
*dest->next_output_byte++ = (JOCTET) val;
|
||||
*dest->next_output_byte++ = (JOCTET)val;
|
||||
if (--dest->free_in_buffer == 0)
|
||||
if (! (*dest->empty_output_buffer) (cinfo))
|
||||
if (!(*dest->empty_output_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
|
||||
@@ -133,9 +133,9 @@ emit_byte (int val, j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass (j_compress_ptr cinfo)
|
||||
finish_pass(j_compress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
|
||||
JLONG temp;
|
||||
|
||||
/* Section D.1.8: Termination of encoding */
|
||||
@@ -219,9 +219,9 @@ finish_pass (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
arith_encode(j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
{
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
|
||||
register unsigned char nl, nm;
|
||||
register JLONG qe, temp;
|
||||
register int sv;
|
||||
@@ -319,9 +319,9 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_restart (j_compress_ptr cinfo, int restart_num)
|
||||
emit_restart(j_compress_ptr cinfo, int restart_num)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@@ -362,9 +362,9 @@ emit_restart (j_compress_ptr cinfo, int restart_num)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int blkn, ci, tbl;
|
||||
@@ -391,7 +391,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Compute the DC value after the required point transform by Al.
|
||||
* This is simply an arithmetic right shift.
|
||||
*/
|
||||
m = IRIGHT_SHIFT((int) ((*block)[0]), cinfo->Al);
|
||||
m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
|
||||
|
||||
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
|
||||
|
||||
@@ -432,9 +432,9 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
arith_encode(cinfo, st, 0);
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] += 8; /* large diff category */
|
||||
/* Figure F.9: Encoding the magnitude bit pattern of v */
|
||||
st += 14;
|
||||
@@ -453,9 +453,9 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, k, ke;
|
||||
@@ -552,9 +552,9 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
unsigned char *st;
|
||||
int Al, blkn;
|
||||
|
||||
@@ -587,9 +587,9 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, k, ke, kex;
|
||||
@@ -680,9 +680,9 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
jpeg_component_info *compptr;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
@@ -747,9 +747,9 @@ encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
arith_encode(cinfo, st, 0);
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] += 8; /* large diff category */
|
||||
/* Figure F.9: Encoding the magnitude bit pattern of v */
|
||||
st += 14;
|
||||
@@ -822,9 +822,9 @@ encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@@ -862,8 +862,8 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->dc_stats[tbl] == NULL)
|
||||
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->last_dc_val[ci] = 0;
|
||||
@@ -875,13 +875,14 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->ac_stats[tbl] == NULL)
|
||||
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
|
||||
#ifdef CALCULATE_SPECTRAL_CONDITIONING
|
||||
if (cinfo->progressive_mode)
|
||||
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
|
||||
cinfo->arith_ac_K[tbl] = cinfo->Ss + ((8 + cinfo->Se - cinfo->Ss) >> 4);
|
||||
cinfo->arith_ac_K[tbl] = cinfo->Ss +
|
||||
((8 + cinfo->Se - cinfo->Ss) >> 4);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -905,15 +906,15 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_arith_encoder (j_compress_ptr cinfo)
|
||||
jinit_arith_encoder(j_compress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(arith_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
|
||||
|
||||
102
jccoefct.c
102
jccoefct.c
@@ -58,21 +58,19 @@ typedef my_coef_controller *my_coef_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) compress_data
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
#ifdef FULL_COEF_BUFFER_SUPPORTED
|
||||
METHODDEF(boolean) compress_first_pass
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_output
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_first_pass(j_compress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
start_iMCU_row (j_compress_ptr cinfo)
|
||||
start_iMCU_row(j_compress_ptr cinfo)
|
||||
/* Reset within-iMCU-row counters for a new row */
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||
@@ -81,7 +79,7 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
if (cinfo->comps_in_scan > 1) {
|
||||
coef->MCU_rows_per_iMCU_row = 1;
|
||||
} else {
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||
else
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||
@@ -97,9 +95,9 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
coef->iMCU_row_num = 0;
|
||||
start_iMCU_row(cinfo);
|
||||
@@ -140,9 +138,9 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
@@ -167,31 +165,33 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
blkn = 0;
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||
: compptr->last_col_width;
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
|
||||
compptr->last_col_width;
|
||||
xpos = MCU_col_num * compptr->MCU_sample_width;
|
||||
ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||
yoffset+yindex < compptr->last_row_height) {
|
||||
yoffset + yindex < compptr->last_row_height) {
|
||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||
input_buf[compptr->component_index],
|
||||
coef->MCU_buffer[blkn],
|
||||
ypos, xpos, (JDIMENSION) blockcnt);
|
||||
ypos, xpos, (JDIMENSION)blockcnt);
|
||||
if (blockcnt < compptr->MCU_width) {
|
||||
/* Create some dummy blocks at the right edge of the image. */
|
||||
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
|
||||
jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
|
||||
(compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
|
||||
for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
|
||||
coef->MCU_buffer[blkn + bi][0][0] =
|
||||
coef->MCU_buffer[blkn + bi - 1][0][0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Create a row of dummy blocks at the bottom of the image. */
|
||||
jzero_far((void *) coef->MCU_buffer[blkn],
|
||||
jzero_far((void *)coef->MCU_buffer[blkn],
|
||||
compptr->MCU_width * sizeof(JBLOCK));
|
||||
for (bi = 0; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
|
||||
coef->MCU_buffer[blkn + bi][0][0] =
|
||||
coef->MCU_buffer[blkn - 1][0][0];
|
||||
}
|
||||
}
|
||||
blkn += compptr->MCU_width;
|
||||
@@ -201,7 +201,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
/* Try to write the MCU. In event of a suspension failure, we will
|
||||
* re-DCT the MCU on restart (a bit inefficient, could be fixed...)
|
||||
*/
|
||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->mcu_ctr = MCU_col_num;
|
||||
@@ -242,9 +242,9 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
JDIMENSION blocks_across, MCUs_across, MCUindex;
|
||||
int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
|
||||
@@ -257,21 +257,21 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
ci++, compptr++) {
|
||||
/* Align the virtual buffer for this component. */
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||
(JDIMENSION)compptr->v_samp_factor, TRUE);
|
||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||
if (coef->iMCU_row_num < last_iMCU_row)
|
||||
block_rows = compptr->v_samp_factor;
|
||||
else {
|
||||
/* NB: can't use last_row_height here, since may not be set! */
|
||||
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||
}
|
||||
blocks_across = compptr->width_in_blocks;
|
||||
h_samp_factor = compptr->h_samp_factor;
|
||||
/* Count number of dummy blocks to be added at the right margin. */
|
||||
ndummy = (int) (blocks_across % h_samp_factor);
|
||||
ndummy = (int)(blocks_across % h_samp_factor);
|
||||
if (ndummy > 0)
|
||||
ndummy = h_samp_factor - ndummy;
|
||||
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call
|
||||
@@ -281,12 +281,12 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
thisblockrow = buffer[block_row];
|
||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||
input_buf[ci], thisblockrow,
|
||||
(JDIMENSION) (block_row * DCTSIZE),
|
||||
(JDIMENSION) 0, blocks_across);
|
||||
(JDIMENSION)(block_row * DCTSIZE),
|
||||
(JDIMENSION)0, blocks_across);
|
||||
if (ndummy > 0) {
|
||||
/* Create dummy blocks at the right edge of the image. */
|
||||
thisblockrow += blocks_across; /* => first dummy block */
|
||||
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
||||
jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
|
||||
lastDC = thisblockrow[-1][0];
|
||||
for (bi = 0; bi < ndummy; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
@@ -304,11 +304,11 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (block_row = block_rows; block_row < compptr->v_samp_factor;
|
||||
block_row++) {
|
||||
thisblockrow = buffer[block_row];
|
||||
lastblockrow = buffer[block_row-1];
|
||||
jzero_far((void *) thisblockrow,
|
||||
(size_t) (blocks_across * sizeof(JBLOCK)));
|
||||
lastblockrow = buffer[block_row - 1];
|
||||
jzero_far((void *)thisblockrow,
|
||||
(size_t)(blocks_across * sizeof(JBLOCK)));
|
||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||
lastDC = lastblockrow[h_samp_factor - 1][0];
|
||||
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
}
|
||||
@@ -338,9 +338,9 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
int blkn, ci, xindex, yindex, yoffset;
|
||||
JDIMENSION start_col;
|
||||
@@ -355,9 +355,9 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
||||
}
|
||||
|
||||
/* Loop to process one whole iMCU row */
|
||||
@@ -371,14 +371,14 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
start_col = MCU_col_num * compptr->MCU_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
||||
for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
||||
coef->MCU_buffer[blkn++] = buffer_ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to write the MCU. */
|
||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->mcu_ctr = MCU_col_num;
|
||||
@@ -402,14 +402,14 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_c_coef_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_coef_ptr coef;
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
|
||||
coef->pub.start_pass = start_pass_coef;
|
||||
|
||||
/* Create the coefficient buffer. */
|
||||
@@ -423,12 +423,12 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
||||
(long) compptr->h_samp_factor),
|
||||
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||
(long) compptr->v_samp_factor),
|
||||
(JDIMENSION) compptr->v_samp_factor);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
||||
(JDIMENSION)jround_up((long)compptr->width_in_blocks,
|
||||
(long)compptr->h_samp_factor),
|
||||
(JDIMENSION)jround_up((long)compptr->height_in_blocks,
|
||||
(long)compptr->v_samp_factor),
|
||||
(JDIMENSION)compptr->v_samp_factor);
|
||||
}
|
||||
#else
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@@ -439,7 +439,7 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
int i;
|
||||
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
|
||||
46
jccolext.c
46
jccolext.c
@@ -29,13 +29,13 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_ycc_convert_internal (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG * ctab = cconvert->rgb_ycc_tab;
|
||||
register JLONG *ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
register JDIMENSION col;
|
||||
@@ -58,17 +58,14 @@ rgb_ycc_convert_internal (j_compress_ptr cinfo,
|
||||
* need the general RIGHT_SHIFT macro.
|
||||
*/
|
||||
/* Y */
|
||||
outptr0[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
/* Cb */
|
||||
outptr1[col] = (JSAMPLE)
|
||||
((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
|
||||
ctab[b + B_CB_OFF]) >> SCALEBITS);
|
||||
/* Cr */
|
||||
outptr2[col] = (JSAMPLE)
|
||||
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
|
||||
ctab[b + B_CR_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,13 +83,13 @@ rgb_ycc_convert_internal (j_compress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_gray_convert_internal (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG * ctab = cconvert->rgb_ycc_tab;
|
||||
register JLONG *ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -108,9 +105,8 @@ rgb_gray_convert_internal (j_compress_ptr cinfo,
|
||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,9 +119,9 @@ rgb_gray_convert_internal (j_compress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb_convert_internal (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_rgb_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
|
||||
99
jccolor.c
99
jccolor.c
@@ -63,9 +63,9 @@ typedef my_color_converter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define CBCR_OFFSET ((JLONG) CENTERJSAMPLE << SCALEBITS)
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define CBCR_OFFSET ((JLONG)CENTERJSAMPLE << SCALEBITS)
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
/* We allocate one big table and divide it up into eight parts, instead of
|
||||
* doing eight alloc_small requests. This lets us use a single table base
|
||||
@@ -74,15 +74,15 @@ typedef my_color_converter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define R_Y_OFF 0 /* offset to R => Y section */
|
||||
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
|
||||
#define R_CB_OFF (3*(MAXJSAMPLE+1))
|
||||
#define G_CB_OFF (4*(MAXJSAMPLE+1))
|
||||
#define B_CB_OFF (5*(MAXJSAMPLE+1))
|
||||
#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
|
||||
#define R_CB_OFF (3 * (MAXJSAMPLE + 1))
|
||||
#define G_CB_OFF (4 * (MAXJSAMPLE + 1))
|
||||
#define B_CB_OFF (5 * (MAXJSAMPLE + 1))
|
||||
#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */
|
||||
#define G_CR_OFF (6*(MAXJSAMPLE+1))
|
||||
#define B_CR_OFF (7*(MAXJSAMPLE+1))
|
||||
#define TABLE_SIZE (8*(MAXJSAMPLE+1))
|
||||
#define G_CR_OFF (6 * (MAXJSAMPLE + 1))
|
||||
#define B_CR_OFF (7 * (MAXJSAMPLE + 1))
|
||||
#define TABLE_SIZE (8 * (MAXJSAMPLE + 1))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
@@ -195,33 +195,33 @@ typedef my_color_converter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_ycc_start (j_compress_ptr cinfo)
|
||||
rgb_ycc_start(j_compress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
JLONG *rgb_ycc_tab;
|
||||
JLONG i;
|
||||
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * sizeof(JLONG)));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i;
|
||||
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i;
|
||||
rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
|
||||
rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
|
||||
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
||||
* This ensures that the maximum output will round to MAXJSAMPLE
|
||||
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
||||
*/
|
||||
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
|
||||
/* B=>Cb and R=>Cr tables are the same
|
||||
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
rgb_ycc_tab[i + R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
|
||||
*/
|
||||
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i;
|
||||
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i;
|
||||
rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
|
||||
rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,9 +231,8 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -280,9 +279,8 @@ rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -326,9 +324,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_rgb_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -376,11 +373,10 @@ rgb_rgb_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
cmyk_ycck_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG *ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
@@ -408,17 +404,14 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
* need the general RIGHT_SHIFT macro.
|
||||
*/
|
||||
/* Y */
|
||||
outptr0[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
/* Cb */
|
||||
outptr1[col] = (JSAMPLE)
|
||||
((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
|
||||
ctab[b + B_CB_OFF]) >> SCALEBITS);
|
||||
/* Cr */
|
||||
outptr2[col] = (JSAMPLE)
|
||||
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
|
||||
ctab[b + B_CR_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,9 +424,8 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
grayscale_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -460,8 +452,7 @@ grayscale_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
null_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
@@ -522,7 +513,7 @@ null_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
null_method (j_compress_ptr cinfo)
|
||||
null_method(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work needed */
|
||||
}
|
||||
@@ -533,14 +524,14 @@ null_method (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_color_converter (j_compress_ptr cinfo)
|
||||
jinit_color_converter(j_compress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_color_converter));
|
||||
cinfo->cconvert = (struct jpeg_color_converter *) cconvert;
|
||||
cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
|
||||
/* set start_pass to null method until we find out differently */
|
||||
cconvert->pub.start_pass = null_method;
|
||||
|
||||
|
||||
98
jcdctmgr.c
98
jcdctmgr.c
@@ -41,7 +41,7 @@ typedef void (*float_quantize_method_ptr) (JCOEFPTR coef_block,
|
||||
FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace);
|
||||
|
||||
METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);
|
||||
METHODDEF(void) quantize(JCOEFPTR, DCTELEM *, DCTELEM *);
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_forward_dct pub; /* public fields */
|
||||
@@ -80,7 +80,7 @@ typedef my_fdct_controller *my_fdct_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
flss (UINT16 val)
|
||||
flss(UINT16 val)
|
||||
{
|
||||
int bit;
|
||||
|
||||
@@ -170,7 +170,7 @@ flss (UINT16 val)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
compute_reciprocal(UINT16 divisor, DCTELEM *dtbl)
|
||||
{
|
||||
UDCTELEM2 fq, fr;
|
||||
UDCTELEM c;
|
||||
@@ -182,10 +182,10 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
* identity function. Since only the C quantization algorithm is used in
|
||||
* these cases, the scale value is irrelevant.
|
||||
*/
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM) 1; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM) 0; /* correction */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM) 1; /* scale */
|
||||
dtbl[DCTSIZE2 * 3] = -(DCTELEM) (sizeof(DCTELEM) * 8); /* shift */
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM)1; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM)0; /* correction */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM)1; /* scale */
|
||||
dtbl[DCTSIZE2 * 3] = -(DCTELEM)(sizeof(DCTELEM) * 8); /* shift */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -207,14 +207,14 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
fq++;
|
||||
}
|
||||
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM) fq; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM)fq; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM)c; /* correction + roundfactor */
|
||||
#ifdef WITH_SIMD
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */
|
||||
#else
|
||||
dtbl[DCTSIZE2 * 2] = 1;
|
||||
#endif
|
||||
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
|
||||
dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */
|
||||
|
||||
if (r <= 16) return 0;
|
||||
else return 1;
|
||||
@@ -233,9 +233,9 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
start_pass_fdctmgr(j_compress_ptr cinfo)
|
||||
{
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
|
||||
int ci, qtblno, i;
|
||||
jpeg_component_info *compptr;
|
||||
JQUANT_TBL *qtbl;
|
||||
@@ -259,7 +259,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
*/
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(DCTSIZE2 * 4) * sizeof(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
@@ -269,7 +269,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
fdct->quantize == jsimd_quantize)
|
||||
fdct->quantize = quantize;
|
||||
#else
|
||||
dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;
|
||||
dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@@ -299,23 +299,23 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(DCTSIZE2 * 4) * sizeof(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
if (!compute_reciprocal(
|
||||
DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],
|
||||
(JLONG) aanscales[i]),
|
||||
CONST_BITS-3), &dtbl[i]) &&
|
||||
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
|
||||
(JLONG)aanscales[i]),
|
||||
CONST_BITS - 3), &dtbl[i]) &&
|
||||
fdct->quantize == jsimd_quantize)
|
||||
fdct->quantize = quantize;
|
||||
#else
|
||||
dtbl[i] = (DCTELEM)
|
||||
DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],
|
||||
(JLONG) aanscales[i]),
|
||||
CONST_BITS-3);
|
||||
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
|
||||
(JLONG)aanscales[i]),
|
||||
CONST_BITS - 3);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
|
||||
if (fdct->float_divisors[qtblno] == NULL) {
|
||||
fdct->float_divisors[qtblno] = (FAST_FLOAT *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
DCTSIZE2 * sizeof(FAST_FLOAT));
|
||||
}
|
||||
fdtbl = fdct->float_divisors[qtblno];
|
||||
@@ -349,7 +349,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
for (row = 0; row < DCTSIZE; row++) {
|
||||
for (col = 0; col < DCTSIZE; col++) {
|
||||
fdtbl[i] = (FAST_FLOAT)
|
||||
(1.0 / (((double) qtbl->quantval[i] *
|
||||
(1.0 / (((double)qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col] * 8.0)));
|
||||
i++;
|
||||
}
|
||||
@@ -370,7 +370,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
|
||||
convsamp(JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
|
||||
{
|
||||
register DCTELEM *workspaceptr;
|
||||
register JSAMPROW elemptr;
|
||||
@@ -405,7 +405,7 @@ convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
{
|
||||
int i;
|
||||
DCTELEM temp;
|
||||
@@ -426,15 +426,15 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
if (temp < 0) {
|
||||
temp = -temp;
|
||||
product = (UDCTELEM2)(temp + corr) * recip;
|
||||
product >>= shift + sizeof(DCTELEM)*8;
|
||||
product >>= shift + sizeof(DCTELEM) * 8;
|
||||
temp = (DCTELEM)product;
|
||||
temp = -temp;
|
||||
} else {
|
||||
product = (UDCTELEM2)(temp + corr) * recip;
|
||||
product >>= shift + sizeof(DCTELEM)*8;
|
||||
product >>= shift + sizeof(DCTELEM) * 8;
|
||||
temp = (DCTELEM)product;
|
||||
}
|
||||
output_ptr[i] = (JCOEF) temp;
|
||||
output_ptr[i] = (JCOEF)temp;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -457,20 +457,20 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
* If your machine's division is fast enough, define FAST_DIVIDE.
|
||||
*/
|
||||
#ifdef FAST_DIVIDE
|
||||
#define DIVIDE_BY(a,b) a /= b
|
||||
#define DIVIDE_BY(a, b) a /= b
|
||||
#else
|
||||
#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0
|
||||
#define DIVIDE_BY(a, b) if (a >= b) a /= b; else a = 0
|
||||
#endif
|
||||
if (temp < 0) {
|
||||
temp = -temp;
|
||||
temp += qval>>1; /* for rounding */
|
||||
temp += qval >> 1; /* for rounding */
|
||||
DIVIDE_BY(temp, qval);
|
||||
temp = -temp;
|
||||
} else {
|
||||
temp += qval>>1; /* for rounding */
|
||||
temp += qval >> 1; /* for rounding */
|
||||
DIVIDE_BY(temp, qval);
|
||||
}
|
||||
output_ptr[i] = (JCOEF) temp;
|
||||
output_ptr[i] = (JCOEF)temp;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -487,14 +487,13 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
forward_DCT (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||
JDIMENSION start_row, JDIMENSION start_col,
|
||||
JDIMENSION num_blocks)
|
||||
JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks)
|
||||
/* This version is used for integer DCT implementations. */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
|
||||
DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
|
||||
DCTELEM *workspace;
|
||||
JDIMENSION bi;
|
||||
@@ -522,9 +521,9 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace)
|
||||
convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
register FAST_FLOAT *workspaceptr;
|
||||
register JSAMPROW elemptr;
|
||||
@@ -555,7 +554,8 @@ convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *worksp
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace)
|
||||
quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
register FAST_FLOAT temp;
|
||||
register int i;
|
||||
@@ -571,20 +571,20 @@ quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace
|
||||
* The maximum coefficient size is +-16K (for 12-bit data), so this
|
||||
* code should work for either 16-bit or 32-bit ints.
|
||||
*/
|
||||
output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);
|
||||
output_ptr[i] = (JCOEF)((int)(temp + (FAST_FLOAT)16384.5) - 16384);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||
JDIMENSION start_row, JDIMENSION start_col,
|
||||
JDIMENSION num_blocks)
|
||||
/* This version is used for floating-point DCT implementations. */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
|
||||
FAST_FLOAT *divisors = fdct->float_divisors[compptr->quant_tbl_no];
|
||||
FAST_FLOAT *workspace;
|
||||
JDIMENSION bi;
|
||||
@@ -618,15 +618,15 @@ forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_forward_dct (j_compress_ptr cinfo)
|
||||
jinit_forward_dct(j_compress_ptr cinfo)
|
||||
{
|
||||
my_fdct_ptr fdct;
|
||||
int i;
|
||||
|
||||
fdct = (my_fdct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_fdct_controller));
|
||||
cinfo->fdct = (struct jpeg_forward_dct *) fdct;
|
||||
cinfo->fdct = (struct jpeg_forward_dct *)fdct;
|
||||
fdct->pub.start_pass = start_pass_fdctmgr;
|
||||
|
||||
/* First determine the DCT... */
|
||||
@@ -703,12 +703,12 @@ jinit_forward_dct (j_compress_ptr cinfo)
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
if (cinfo->dct_method == JDCT_FLOAT)
|
||||
fdct->float_workspace = (FAST_FLOAT *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(FAST_FLOAT) * DCTSIZE2);
|
||||
else
|
||||
#endif
|
||||
fdct->workspace = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(DCTELEM) * DCTSIZE2);
|
||||
|
||||
/* Mark divisor tables unallocated */
|
||||
|
||||
148
jchuff.c
148
jchuff.c
@@ -55,10 +55,6 @@
|
||||
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
/* Expanded entropy encoder object for Huffman encoding.
|
||||
*
|
||||
@@ -78,10 +74,10 @@ typedef struct {
|
||||
*/
|
||||
|
||||
#ifndef NO_STRUCT_ASSIGN
|
||||
#define ASSIGN_STATE(dest,src) ((dest) = (src))
|
||||
#define ASSIGN_STATE(dest, src) ((dest) = (src))
|
||||
#else
|
||||
#if MAX_COMPS_IN_SCAN == 4
|
||||
#define ASSIGN_STATE(dest,src) \
|
||||
#define ASSIGN_STATE(dest, src) \
|
||||
((dest).put_buffer = (src).put_buffer, \
|
||||
(dest).put_bits = (src).put_bits, \
|
||||
(dest).last_dc_val[0] = (src).last_dc_val[0], \
|
||||
@@ -128,12 +124,12 @@ typedef struct {
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_huff (j_compress_ptr cinfo);
|
||||
METHODDEF(boolean) encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_huff(j_compress_ptr cinfo);
|
||||
#ifdef ENTROPY_OPT_SUPPORTED
|
||||
METHODDEF(boolean) encode_mcu_gather (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_gather(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_gather (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather(j_compress_ptr cinfo);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -144,9 +140,9 @@ METHODDEF(void) finish_pass_gather (j_compress_ptr cinfo);
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci, dctbl, actbl;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@@ -180,12 +176,12 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||
if (entropy->dc_count_ptrs[dctbl] == NULL)
|
||||
entropy->dc_count_ptrs[dctbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * sizeof(long));
|
||||
if (entropy->ac_count_ptrs[actbl] == NULL)
|
||||
entropy->ac_count_ptrs[actbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->ac_count_ptrs[actbl], 257 * sizeof(long));
|
||||
#endif
|
||||
@@ -193,9 +189,9 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Compute derived values for Huffman tables */
|
||||
/* We may do this more than once for a table, but it's not expensive */
|
||||
jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl,
|
||||
& entropy->dc_derived_tbls[dctbl]);
|
||||
&entropy->dc_derived_tbls[dctbl]);
|
||||
jpeg_make_c_derived_tbl(cinfo, FALSE, actbl,
|
||||
& entropy->ac_derived_tbls[actbl]);
|
||||
&entropy->ac_derived_tbls[actbl]);
|
||||
}
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->saved.last_dc_val[ci] = 0;
|
||||
@@ -219,7 +215,7 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
c_derived_tbl **pdtbl)
|
||||
{
|
||||
JHUFF_TBL *htbl;
|
||||
@@ -244,7 +240,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (c_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(c_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
|
||||
@@ -252,11 +248,11 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
|
||||
p = 0;
|
||||
for (l = 1; l <= 16; l++) {
|
||||
i = (int) htbl->bits[l];
|
||||
i = (int)htbl->bits[l];
|
||||
if (i < 0 || p + i > 256) /* protect against table overrun */
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
while (i--)
|
||||
huffsize[p++] = (char) l;
|
||||
huffsize[p++] = (char)l;
|
||||
}
|
||||
huffsize[p] = 0;
|
||||
lastp = p;
|
||||
@@ -268,14 +264,14 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
si = huffsize[0];
|
||||
p = 0;
|
||||
while (huffsize[p]) {
|
||||
while (((int) huffsize[p]) == si) {
|
||||
while (((int)huffsize[p]) == si) {
|
||||
huffcode[p++] = code;
|
||||
code++;
|
||||
}
|
||||
/* code is now 1 more than the last code used for codelength si; but
|
||||
* it must still fit in si bits, since no code is allowed to be all ones.
|
||||
*/
|
||||
if (((JLONG) code) >= (((JLONG) 1) << si))
|
||||
if (((JLONG)code) >= (((JLONG)1) << si))
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
code <<= 1;
|
||||
si++;
|
||||
@@ -310,20 +306,21 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* Outputting bytes to the file */
|
||||
|
||||
/* Emit a byte, taking 'action' if must suspend. */
|
||||
#define emit_byte(state,val,action) \
|
||||
{ *(state)->next_output_byte++ = (JOCTET) (val); \
|
||||
#define emit_byte(state, val, action) { \
|
||||
*(state)->next_output_byte++ = (JOCTET)(val); \
|
||||
if (--(state)->free_in_buffer == 0) \
|
||||
if (! dump_buffer(state)) \
|
||||
{ action; } }
|
||||
if (!dump_buffer(state)) \
|
||||
{ action; } \
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
dump_buffer (working_state *state)
|
||||
dump_buffer(working_state *state)
|
||||
/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = state->cinfo->dest;
|
||||
|
||||
if (! (*dest->empty_output_buffer) (state->cinfo))
|
||||
if (!(*dest->empty_output_buffer) (state->cinfo))
|
||||
return FALSE;
|
||||
/* After a successful buffer dump, must reset buffer pointers */
|
||||
state->next_output_byte = dest->next_output_byte;
|
||||
@@ -349,7 +346,7 @@ dump_buffer (working_state *state)
|
||||
*buffer++ = c; \
|
||||
if (c == 0xFF) /* need to stuff a zero byte? */ \
|
||||
*buffer++ = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
#define PUT_BITS(code, size) { \
|
||||
put_bits += size; \
|
||||
@@ -387,7 +384,7 @@ dump_buffer (working_state *state)
|
||||
#error Cannot determine word size
|
||||
#endif
|
||||
|
||||
#if SIZEOF_SIZE_T==8 || defined(_WIN64)
|
||||
#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
|
||||
|
||||
#define EMIT_BITS(code, size) { \
|
||||
CHECKBUF47() \
|
||||
@@ -395,11 +392,11 @@ dump_buffer (working_state *state)
|
||||
}
|
||||
|
||||
#define EMIT_CODE(code, size) { \
|
||||
temp2 &= (((JLONG) 1)<<nbits) - 1; \
|
||||
temp2 &= (((JLONG)1) << nbits) - 1; \
|
||||
CHECKBUF31() \
|
||||
PUT_BITS(code, size) \
|
||||
PUT_BITS(temp2, nbits) \
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -409,12 +406,12 @@ dump_buffer (working_state *state)
|
||||
}
|
||||
|
||||
#define EMIT_CODE(code, size) { \
|
||||
temp2 &= (((JLONG) 1)<<nbits) - 1; \
|
||||
temp2 &= (((JLONG)1) << nbits) - 1; \
|
||||
PUT_BITS(code, size) \
|
||||
CHECKBUF15() \
|
||||
PUT_BITS(temp2, nbits) \
|
||||
CHECKBUF15() \
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -434,34 +431,33 @@ dump_buffer (working_state *state)
|
||||
if (state->free_in_buffer < BUFSIZE) { \
|
||||
localbuf = 1; \
|
||||
buffer = _buffer; \
|
||||
} \
|
||||
else buffer = state->next_output_byte; \
|
||||
}
|
||||
} else \
|
||||
buffer = state->next_output_byte; \
|
||||
}
|
||||
|
||||
#define STORE_BUFFER() { \
|
||||
if (localbuf) { \
|
||||
bytes = buffer - _buffer; \
|
||||
buffer = _buffer; \
|
||||
while (bytes > 0) { \
|
||||
bytestocopy = min(bytes, state->free_in_buffer); \
|
||||
bytestocopy = MIN(bytes, state->free_in_buffer); \
|
||||
MEMCOPY(state->next_output_byte, buffer, bytestocopy); \
|
||||
state->next_output_byte += bytestocopy; \
|
||||
buffer += bytestocopy; \
|
||||
state->free_in_buffer -= bytestocopy; \
|
||||
if (state->free_in_buffer == 0) \
|
||||
if (! dump_buffer(state)) return FALSE; \
|
||||
if (!dump_buffer(state)) return FALSE; \
|
||||
bytes -= bytestocopy; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
} else { \
|
||||
state->free_in_buffer -= (buffer - state->next_output_byte); \
|
||||
state->next_output_byte = buffer; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
flush_bits (working_state *state)
|
||||
flush_bits(working_state *state)
|
||||
{
|
||||
JOCTET _buffer[BUFSIZE], *buffer;
|
||||
size_t put_buffer; int put_bits;
|
||||
@@ -486,7 +482,7 @@ flush_bits (working_state *state)
|
||||
/* Encode a single block's worth of coefficients */
|
||||
|
||||
LOCAL(boolean)
|
||||
encode_one_block_simd (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
encode_one_block_simd(working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl, c_derived_tbl *actbl)
|
||||
{
|
||||
JOCTET _buffer[BUFSIZE], *buffer;
|
||||
@@ -503,7 +499,7 @@ encode_one_block_simd (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
}
|
||||
|
||||
LOCAL(boolean)
|
||||
encode_one_block (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl, c_derived_tbl *actbl)
|
||||
{
|
||||
int temp, temp2, temp3;
|
||||
@@ -544,7 +540,7 @@ encode_one_block (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
EMIT_BITS(code, size)
|
||||
|
||||
/* Mask off any extra bits in code */
|
||||
temp2 &= (((JLONG) 1)<<nbits) - 1;
|
||||
temp2 &= (((JLONG)1) << nbits) - 1;
|
||||
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
@@ -616,11 +612,11 @@ encode_one_block (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
emit_restart (working_state *state, int restart_num)
|
||||
emit_restart(working_state *state, int restart_num)
|
||||
{
|
||||
int ci;
|
||||
|
||||
if (! flush_bits(state))
|
||||
if (!flush_bits(state))
|
||||
return FALSE;
|
||||
|
||||
emit_byte(state, 0xFF, return FALSE);
|
||||
@@ -641,9 +637,9 @@ emit_restart (working_state *state, int restart_num)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
working_state state;
|
||||
int blkn, ci;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -657,7 +653,7 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Emit restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! emit_restart(&state, entropy->next_restart_num))
|
||||
if (!emit_restart(&state, entropy->next_restart_num))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -666,7 +662,7 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
ci = cinfo->MCU_membership[blkn];
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
if (! encode_one_block_simd(&state,
|
||||
if (!encode_one_block_simd(&state,
|
||||
MCU_data[blkn][0], state.cur.last_dc_val[ci],
|
||||
entropy->dc_derived_tbls[compptr->dc_tbl_no],
|
||||
entropy->ac_derived_tbls[compptr->ac_tbl_no]))
|
||||
@@ -678,7 +674,7 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
ci = cinfo->MCU_membership[blkn];
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
if (! encode_one_block(&state,
|
||||
if (!encode_one_block(&state,
|
||||
MCU_data[blkn][0], state.cur.last_dc_val[ci],
|
||||
entropy->dc_derived_tbls[compptr->dc_tbl_no],
|
||||
entropy->ac_derived_tbls[compptr->ac_tbl_no]))
|
||||
@@ -712,9 +708,9 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_huff (j_compress_ptr cinfo)
|
||||
finish_pass_huff(j_compress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
working_state state;
|
||||
|
||||
/* Load up working state ... flush_bits needs it */
|
||||
@@ -724,7 +720,7 @@ finish_pass_huff (j_compress_ptr cinfo)
|
||||
state.cinfo = cinfo;
|
||||
|
||||
/* Flush out the last data */
|
||||
if (! flush_bits(&state))
|
||||
if (!flush_bits(&state))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
|
||||
/* Update state */
|
||||
@@ -751,7 +747,7 @@ finish_pass_huff (j_compress_ptr cinfo)
|
||||
/* Process a single block's worth of coefficients */
|
||||
|
||||
LOCAL(void)
|
||||
htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
long dc_counts[], long ac_counts[])
|
||||
{
|
||||
register int temp;
|
||||
@@ -773,7 +769,7 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
/* Check for out-of-range coefficient values.
|
||||
* Since we're encoding a difference, the range limit is twice as much.
|
||||
*/
|
||||
if (nbits > MAX_COEF_BITS+1)
|
||||
if (nbits > MAX_COEF_BITS + 1)
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Count the Huffman symbol for the number of bits */
|
||||
@@ -824,9 +820,9 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_gather(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int blkn, ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@@ -884,10 +880,10 @@ encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
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 */
|
||||
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 */
|
||||
int c1, c2;
|
||||
@@ -987,8 +983,8 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
j--;
|
||||
|
||||
bits[i] -= 2; /* remove two symbols */
|
||||
bits[i-1]++; /* one goes in this length */
|
||||
bits[j+1] += 2; /* two new symbols in this length */
|
||||
bits[i - 1]++; /* one goes in this length */
|
||||
bits[j + 1] += 2; /* two new symbols in this length */
|
||||
bits[j]--; /* symbol of this length is now a prefix */
|
||||
}
|
||||
}
|
||||
@@ -1009,7 +1005,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
for (i = 1; i <= MAX_CLEN; i++) {
|
||||
for (j = 0; j <= 255; j++) {
|
||||
if (codesize[j] == i) {
|
||||
htbl->huffval[p] = (UINT8) j;
|
||||
htbl->huffval[p] = (UINT8)j;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
@@ -1025,9 +1021,9 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_gather (j_compress_ptr cinfo)
|
||||
finish_pass_gather(j_compress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci, dctbl, actbl;
|
||||
jpeg_component_info *compptr;
|
||||
JHUFF_TBL **htblptr;
|
||||
@@ -1044,17 +1040,17 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
dctbl = compptr->dc_tbl_no;
|
||||
actbl = compptr->ac_tbl_no;
|
||||
if (! did_dc[dctbl]) {
|
||||
htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl];
|
||||
if (!did_dc[dctbl]) {
|
||||
htblptr = &cinfo->dc_huff_tbl_ptrs[dctbl];
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]);
|
||||
did_dc[dctbl] = TRUE;
|
||||
}
|
||||
if (! did_ac[actbl]) {
|
||||
htblptr = & cinfo->ac_huff_tbl_ptrs[actbl];
|
||||
if (!did_ac[actbl]) {
|
||||
htblptr = &cinfo->ac_huff_tbl_ptrs[actbl];
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]);
|
||||
did_ac[actbl] = TRUE;
|
||||
}
|
||||
@@ -1070,15 +1066,15 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_huff_encoder (j_compress_ptr cinfo)
|
||||
jinit_huff_encoder(j_compress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(huff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_huff;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
|
||||
9
jchuff.h
9
jchuff.h
@@ -34,10 +34,9 @@ typedef struct {
|
||||
} c_derived_tbl;
|
||||
|
||||
/* Expand a Huffman table definition into the derived format */
|
||||
EXTERN(void) jpeg_make_c_derived_tbl
|
||||
(j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
c_derived_tbl ** pdtbl);
|
||||
EXTERN(void) jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC,
|
||||
int tblno, c_derived_tbl **pdtbl);
|
||||
|
||||
/* Generate an optimal table definition given the specified counts */
|
||||
EXTERN(void) jpeg_gen_optimal_table
|
||||
(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[]);
|
||||
EXTERN(void) jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl,
|
||||
long freq[]);
|
||||
|
||||
6
jcicc.c
6
jcicc.c
@@ -46,7 +46,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_icc_profile (j_compress_ptr cinfo, const JOCTET *icc_data_ptr,
|
||||
jpeg_write_icc_profile(j_compress_ptr cinfo, const JOCTET *icc_data_ptr,
|
||||
unsigned int icc_data_len)
|
||||
{
|
||||
unsigned int num_markers; /* total number of markers we'll write */
|
||||
@@ -72,7 +72,7 @@ jpeg_write_icc_profile (j_compress_ptr cinfo, const JOCTET *icc_data_ptr,
|
||||
|
||||
/* Write the JPEG marker header (APP2 code and marker length) */
|
||||
jpeg_write_m_header(cinfo, ICC_MARKER,
|
||||
(unsigned int) (length + ICC_OVERHEAD_LEN));
|
||||
(unsigned int)(length + ICC_OVERHEAD_LEN));
|
||||
|
||||
/* Write the marker identifying string "ICC_PROFILE" (null-terminated). We
|
||||
* code it in this less-than-transparent way so that the code works even if
|
||||
@@ -93,7 +93,7 @@ jpeg_write_icc_profile (j_compress_ptr cinfo, const JOCTET *icc_data_ptr,
|
||||
|
||||
/* Add the sequencing info */
|
||||
jpeg_write_m_byte(cinfo, cur_marker);
|
||||
jpeg_write_m_byte(cinfo, (int) num_markers);
|
||||
jpeg_write_m_byte(cinfo, (int)num_markers);
|
||||
|
||||
/* Add the profile data */
|
||||
while (length--) {
|
||||
|
||||
10
jcinit.c
10
jcinit.c
@@ -28,13 +28,13 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_compress_master (j_compress_ptr cinfo)
|
||||
jinit_compress_master(j_compress_ptr cinfo)
|
||||
{
|
||||
/* Initialize master control (includes parameter checking/processing) */
|
||||
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
||||
|
||||
/* Preprocessing */
|
||||
if (! cinfo->raw_data_in) {
|
||||
if (!cinfo->raw_data_in) {
|
||||
jinit_color_converter(cinfo);
|
||||
jinit_downsampler(cinfo);
|
||||
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
|
||||
@@ -60,14 +60,14 @@ jinit_compress_master (j_compress_ptr cinfo)
|
||||
}
|
||||
|
||||
/* Need a full-image coefficient buffer in any multi-pass mode. */
|
||||
jinit_c_coef_controller(cinfo,
|
||||
(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
|
||||
jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
|
||||
cinfo->optimize_coding));
|
||||
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
|
||||
|
||||
jinit_marker_writer(cinfo);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Write the datastream header (SOI) immediately.
|
||||
* Frame and scan headers are postponed till later.
|
||||
|
||||
38
jcmainct.c
38
jcmainct.c
@@ -39,8 +39,9 @@ typedef my_main_controller *my_main_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) process_data_simple_main
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
METHODDEF(void) process_data_simple_main(j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail);
|
||||
|
||||
|
||||
@@ -49,9 +50,9 @@ METHODDEF(void) process_data_simple_main
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
/* Do nothing in raw-data mode. */
|
||||
if (cinfo->raw_data_in)
|
||||
@@ -75,19 +76,18 @@ start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_simple_main (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail)
|
||||
process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (main_ptr->rowgroup_ctr < DCTSIZE)
|
||||
(*cinfo->prep->pre_process_data) (cinfo,
|
||||
input_buf, in_row_ctr, in_rows_avail,
|
||||
main_ptr->buffer, &main_ptr->rowgroup_ctr,
|
||||
(JDIMENSION) DCTSIZE);
|
||||
(*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr,
|
||||
in_rows_avail, main_ptr->buffer,
|
||||
&main_ptr->rowgroup_ctr,
|
||||
(JDIMENSION)DCTSIZE);
|
||||
|
||||
/* If we don't have a full iMCU row buffered, return to application for
|
||||
* more data. Note that preprocessor will always pad to fill the iMCU row
|
||||
@@ -97,14 +97,14 @@ process_data_simple_main (j_compress_ptr cinfo,
|
||||
return;
|
||||
|
||||
/* Send the completed row to the compressor */
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, main_ptr->buffer)) {
|
||||
if (!(*cinfo->coef->compress_data) (cinfo, main_ptr->buffer)) {
|
||||
/* If compressor did not consume the whole row, then we must need to
|
||||
* suspend processing and return to the application. In this situation
|
||||
* we pretend we didn't yet consume the last input row; otherwise, if
|
||||
* it happened to be the last row of the image, the application would
|
||||
* think we were done.
|
||||
*/
|
||||
if (! main_ptr->suspended) {
|
||||
if (!main_ptr->suspended) {
|
||||
(*in_row_ctr)--;
|
||||
main_ptr->suspended = TRUE;
|
||||
}
|
||||
@@ -128,16 +128,16 @@ process_data_simple_main (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_main_ptr main_ptr;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
main_ptr = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_main_controller));
|
||||
cinfo->main = (struct jpeg_c_main_controller *) main_ptr;
|
||||
cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
|
||||
main_ptr->pub.start_pass = start_pass_main;
|
||||
|
||||
/* We don't need to create a buffer in raw-data mode. */
|
||||
@@ -154,9 +154,9 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
compptr->width_in_blocks * DCTSIZE,
|
||||
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
|
||||
(JDIMENSION)(compptr->v_samp_factor * DCTSIZE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
91
jcmarker.c
91
jcmarker.c
@@ -110,30 +110,30 @@ typedef my_marker_writer *my_marker_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_byte (j_compress_ptr cinfo, int val)
|
||||
emit_byte(j_compress_ptr cinfo, int val)
|
||||
/* Emit a byte */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = cinfo->dest;
|
||||
|
||||
*(dest->next_output_byte)++ = (JOCTET) val;
|
||||
*(dest->next_output_byte)++ = (JOCTET)val;
|
||||
if (--dest->free_in_buffer == 0) {
|
||||
if (! (*dest->empty_output_buffer) (cinfo))
|
||||
if (!(*dest->empty_output_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark)
|
||||
emit_marker(j_compress_ptr cinfo, JPEG_MARKER mark)
|
||||
/* Emit a marker code */
|
||||
{
|
||||
emit_byte(cinfo, 0xFF);
|
||||
emit_byte(cinfo, (int) mark);
|
||||
emit_byte(cinfo, (int)mark);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_2bytes (j_compress_ptr cinfo, int value)
|
||||
emit_2bytes(j_compress_ptr cinfo, int value)
|
||||
/* Emit a 2-byte integer; these are always MSB first in JPEG files */
|
||||
{
|
||||
emit_byte(cinfo, (value >> 8) & 0xFF);
|
||||
@@ -146,7 +146,7 @@ emit_2bytes (j_compress_ptr cinfo, int value)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
emit_dqt (j_compress_ptr cinfo, int index)
|
||||
emit_dqt(j_compress_ptr cinfo, int index)
|
||||
/* Emit a DQT marker */
|
||||
/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
|
||||
{
|
||||
@@ -163,19 +163,19 @@ emit_dqt (j_compress_ptr cinfo, int index)
|
||||
prec = 1;
|
||||
}
|
||||
|
||||
if (! qtbl->sent_table) {
|
||||
if (!qtbl->sent_table) {
|
||||
emit_marker(cinfo, M_DQT);
|
||||
|
||||
emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2);
|
||||
emit_2bytes(cinfo, prec ? DCTSIZE2 * 2 + 1 + 2 : DCTSIZE2 + 1 + 2);
|
||||
|
||||
emit_byte(cinfo, index + (prec<<4));
|
||||
emit_byte(cinfo, index + (prec << 4));
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
/* The table entries must be emitted in zigzag order. */
|
||||
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
|
||||
if (prec)
|
||||
emit_byte(cinfo, (int) (qval >> 8));
|
||||
emit_byte(cinfo, (int) (qval & 0xFF));
|
||||
emit_byte(cinfo, (int)(qval >> 8));
|
||||
emit_byte(cinfo, (int)(qval & 0xFF));
|
||||
}
|
||||
|
||||
qtbl->sent_table = TRUE;
|
||||
@@ -186,7 +186,7 @@ emit_dqt (j_compress_ptr cinfo, int index)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
emit_dht(j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
/* Emit a DHT marker */
|
||||
{
|
||||
JHUFF_TBL *htbl;
|
||||
@@ -202,7 +202,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
if (htbl == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
|
||||
|
||||
if (! htbl->sent_table) {
|
||||
if (!htbl->sent_table) {
|
||||
emit_marker(cinfo, M_DHT);
|
||||
|
||||
length = 0;
|
||||
@@ -224,7 +224,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_dac (j_compress_ptr cinfo)
|
||||
emit_dac(j_compress_ptr cinfo)
|
||||
/* Emit a DAC marker */
|
||||
/* Since the useful info is so small, we want to emit all the tables in */
|
||||
/* one DAC marker. Therefore this routine does its own scan of the table. */
|
||||
@@ -255,7 +255,7 @@ emit_dac (j_compress_ptr cinfo)
|
||||
if (length) {
|
||||
emit_marker(cinfo, M_DAC);
|
||||
|
||||
emit_2bytes(cinfo, length*2 + 2);
|
||||
emit_2bytes(cinfo, length * 2 + 2);
|
||||
|
||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||
if (dc_in_use[i]) {
|
||||
@@ -273,19 +273,19 @@ emit_dac (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_dri (j_compress_ptr cinfo)
|
||||
emit_dri(j_compress_ptr cinfo)
|
||||
/* Emit a DRI marker */
|
||||
{
|
||||
emit_marker(cinfo, M_DRI);
|
||||
|
||||
emit_2bytes(cinfo, 4); /* fixed length */
|
||||
|
||||
emit_2bytes(cinfo, (int) cinfo->restart_interval);
|
||||
emit_2bytes(cinfo, (int)cinfo->restart_interval);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
emit_sof(j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
/* Emit a SOF marker */
|
||||
{
|
||||
int ci;
|
||||
@@ -296,13 +296,12 @@ emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
|
||||
|
||||
/* Make sure image isn't bigger than SOF field can handle */
|
||||
if ((long) cinfo->_jpeg_height > 65535L ||
|
||||
(long) cinfo->_jpeg_width > 65535L)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
|
||||
if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)65535);
|
||||
|
||||
emit_byte(cinfo, cinfo->data_precision);
|
||||
emit_2bytes(cinfo, (int) cinfo->_jpeg_height);
|
||||
emit_2bytes(cinfo, (int) cinfo->_jpeg_width);
|
||||
emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
|
||||
emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
|
||||
|
||||
emit_byte(cinfo, cinfo->num_components);
|
||||
|
||||
@@ -316,7 +315,7 @@ emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_sos (j_compress_ptr cinfo)
|
||||
emit_sos(j_compress_ptr cinfo)
|
||||
/* Emit a SOS marker */
|
||||
{
|
||||
int i, td, ta;
|
||||
@@ -351,7 +350,7 @@ emit_sos (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_jfif_app0 (j_compress_ptr cinfo)
|
||||
emit_jfif_app0(j_compress_ptr cinfo)
|
||||
/* Emit a JFIF-compliant APP0 marker */
|
||||
{
|
||||
/*
|
||||
@@ -378,15 +377,15 @@ emit_jfif_app0 (j_compress_ptr cinfo)
|
||||
emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
|
||||
emit_byte(cinfo, cinfo->JFIF_minor_version);
|
||||
emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
|
||||
emit_2bytes(cinfo, (int) cinfo->X_density);
|
||||
emit_2bytes(cinfo, (int) cinfo->Y_density);
|
||||
emit_2bytes(cinfo, (int)cinfo->X_density);
|
||||
emit_2bytes(cinfo, (int)cinfo->Y_density);
|
||||
emit_byte(cinfo, 0); /* No thumbnail image */
|
||||
emit_byte(cinfo, 0);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_adobe_app14 (j_compress_ptr cinfo)
|
||||
emit_adobe_app14(j_compress_ptr cinfo)
|
||||
/* Emit an Adobe APP14 marker */
|
||||
{
|
||||
/*
|
||||
@@ -440,19 +439,19 @@ emit_adobe_app14 (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
write_marker_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
/* Emit an arbitrary marker header */
|
||||
{
|
||||
if (datalen > (unsigned int) 65533) /* safety check */
|
||||
if (datalen > (unsigned int)65533) /* safety check */
|
||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||
|
||||
emit_marker(cinfo, (JPEG_MARKER) marker);
|
||||
emit_marker(cinfo, (JPEG_MARKER)marker);
|
||||
|
||||
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
|
||||
emit_2bytes(cinfo, (int)(datalen + 2)); /* total length */
|
||||
}
|
||||
|
||||
METHODDEF(void)
|
||||
write_marker_byte (j_compress_ptr cinfo, int val)
|
||||
write_marker_byte(j_compress_ptr cinfo, int val)
|
||||
/* Emit one byte of marker parameters following write_marker_header */
|
||||
{
|
||||
emit_byte(cinfo, val);
|
||||
@@ -471,9 +470,9 @@ write_marker_byte (j_compress_ptr cinfo, int val)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_file_header (j_compress_ptr cinfo)
|
||||
write_file_header(j_compress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
|
||||
emit_marker(cinfo, M_SOI); /* first the SOI */
|
||||
|
||||
@@ -496,7 +495,7 @@ write_file_header (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_frame_header (j_compress_ptr cinfo)
|
||||
write_frame_header(j_compress_ptr cinfo)
|
||||
{
|
||||
int ci, prec;
|
||||
boolean is_baseline;
|
||||
@@ -556,9 +555,9 @@ write_frame_header (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_scan_header (j_compress_ptr cinfo)
|
||||
write_scan_header(j_compress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
int i;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@@ -600,7 +599,7 @@ write_scan_header (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_file_trailer (j_compress_ptr cinfo)
|
||||
write_file_trailer(j_compress_ptr cinfo)
|
||||
{
|
||||
emit_marker(cinfo, M_EOI);
|
||||
}
|
||||
@@ -614,7 +613,7 @@ write_file_trailer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_tables_only (j_compress_ptr cinfo)
|
||||
write_tables_only(j_compress_ptr cinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -622,10 +621,10 @@ write_tables_only (j_compress_ptr cinfo)
|
||||
|
||||
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
||||
if (cinfo->quant_tbl_ptrs[i] != NULL)
|
||||
(void) emit_dqt(cinfo, i);
|
||||
(void)emit_dqt(cinfo, i);
|
||||
}
|
||||
|
||||
if (! cinfo->arith_code) {
|
||||
if (!cinfo->arith_code) {
|
||||
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
||||
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
|
||||
emit_dht(cinfo, i, FALSE);
|
||||
@@ -643,15 +642,15 @@ write_tables_only (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_marker_writer (j_compress_ptr cinfo)
|
||||
jinit_marker_writer(j_compress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker;
|
||||
|
||||
/* Create the subobject */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_marker_writer));
|
||||
cinfo->marker = (struct jpeg_marker_writer *) marker;
|
||||
cinfo->marker = (struct jpeg_marker_writer *)marker;
|
||||
/* Initialize method pointers */
|
||||
marker->pub.write_file_header = write_file_header;
|
||||
marker->pub.write_frame_header = write_frame_header;
|
||||
|
||||
115
jcmaster.c
115
jcmaster.c
@@ -66,7 +66,7 @@ typedef my_comp_master *my_master_ptr;
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||
jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
/* Hardwire it to "no scaling" */
|
||||
@@ -79,7 +79,7 @@ jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
initial_setup(j_compress_ptr cinfo, boolean transcode_only)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
int ci;
|
||||
@@ -95,19 +95,19 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
#endif
|
||||
|
||||
/* Sanity check on image dimensions */
|
||||
if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0
|
||||
|| cinfo->num_components <= 0 || cinfo->input_components <= 0)
|
||||
if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
|
||||
cinfo->num_components <= 0 || cinfo->input_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
/* Make sure image isn't bigger than I can handle */
|
||||
if ((long) cinfo->_jpeg_height > (long) JPEG_MAX_DIMENSION ||
|
||||
(long) cinfo->_jpeg_width > (long) JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
|
||||
(long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
|
||||
|
||||
/* Width of an input scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
if ((long) jd_samplesperrow != samplesperrow)
|
||||
samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
|
||||
jd_samplesperrow = (JDIMENSION)samplesperrow;
|
||||
if ((long)jd_samplesperrow != samplesperrow)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
@@ -124,8 +124,10 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
cinfo->max_v_samp_factor = 1;
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
||||
if (compptr->h_samp_factor <= 0 ||
|
||||
compptr->h_samp_factor > MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor <= 0 ||
|
||||
compptr->v_samp_factor > MAX_SAMP_FACTOR)
|
||||
ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
||||
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
||||
compptr->h_samp_factor);
|
||||
@@ -146,18 +148,18 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
#endif
|
||||
/* Size in DCT blocks */
|
||||
compptr->width_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
compptr->height_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
/* Size in samples */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||
(long) cinfo->max_h_samp_factor);
|
||||
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
|
||||
(long)cinfo->max_h_samp_factor);
|
||||
compptr->downsampled_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||
(long) cinfo->max_v_samp_factor);
|
||||
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
|
||||
(long)cinfo->max_v_samp_factor);
|
||||
/* Mark component needed (this flag isn't actually used for compression) */
|
||||
compptr->component_needed = TRUE;
|
||||
}
|
||||
@@ -166,15 +168,15 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
* main controller will call coefficient controller).
|
||||
*/
|
||||
cinfo->total_iMCU_rows = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
}
|
||||
|
||||
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
|
||||
LOCAL(void)
|
||||
validate_script (j_compress_ptr cinfo)
|
||||
validate_script(j_compress_ptr cinfo)
|
||||
/* Verify that the scan script in cinfo->scan_info[] is valid; also
|
||||
* determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
|
||||
*/
|
||||
@@ -196,10 +198,10 @@ validate_script (j_compress_ptr cinfo)
|
||||
* for progressive JPEG, no scan can have this.
|
||||
*/
|
||||
scanptr = cinfo->scan_info;
|
||||
if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) {
|
||||
if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
cinfo->progressive_mode = TRUE;
|
||||
last_bitpos_ptr = & last_bitpos[0][0];
|
||||
last_bitpos_ptr = &last_bitpos[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (coefi = 0; coefi < DCTSIZE2; coefi++)
|
||||
*last_bitpos_ptr++ = -1;
|
||||
@@ -222,7 +224,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
if (thisi < 0 || thisi >= cinfo->num_components)
|
||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||
/* Components must appear in SOF order within each scan */
|
||||
if (ci > 0 && thisi <= scanptr->component_index[ci-1])
|
||||
if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
|
||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||
}
|
||||
/* Validate progression parameters */
|
||||
@@ -255,7 +257,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
}
|
||||
for (ci = 0; ci < ncomps; ci++) {
|
||||
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
|
||||
last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
|
||||
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
for (coefi = Ss; coefi <= Se; coefi++) {
|
||||
@@ -265,7 +267,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
} else {
|
||||
/* not first scan */
|
||||
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
|
||||
if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
}
|
||||
last_bitpos_ptr[coefi] = Al;
|
||||
@@ -274,7 +276,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
#endif
|
||||
} else {
|
||||
/* For sequential JPEG, all progression parameters must be these: */
|
||||
if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
|
||||
if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
/* Make sure components are not sent twice */
|
||||
for (ci = 0; ci < ncomps; ci++) {
|
||||
@@ -301,7 +303,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
#endif
|
||||
} else {
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
if (! component_sent[ci])
|
||||
if (!component_sent[ci])
|
||||
ERREXIT(cinfo, JERR_MISSING_DATA);
|
||||
}
|
||||
}
|
||||
@@ -311,7 +313,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
select_scan_parameters (j_compress_ptr cinfo)
|
||||
select_scan_parameters(j_compress_ptr cinfo)
|
||||
/* Set up the scan parameters for the current scan */
|
||||
{
|
||||
int ci;
|
||||
@@ -319,7 +321,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
if (cinfo->scan_info != NULL) {
|
||||
/* Prepare for current scan --- the script is already validated */
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
|
||||
|
||||
cinfo->comps_in_scan = scanptr->comps_in_scan;
|
||||
@@ -331,8 +333,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
cinfo->Se = scanptr->Se;
|
||||
cinfo->Ah = scanptr->Ah;
|
||||
cinfo->Al = scanptr->Al;
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* Prepare for single sequential-JPEG scan containing all components */
|
||||
@@ -344,7 +345,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
|
||||
}
|
||||
cinfo->Ss = 0;
|
||||
cinfo->Se = DCTSIZE2-1;
|
||||
cinfo->Se = DCTSIZE2 - 1;
|
||||
cinfo->Ah = 0;
|
||||
cinfo->Al = 0;
|
||||
}
|
||||
@@ -352,7 +353,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
per_scan_setup (j_compress_ptr cinfo)
|
||||
per_scan_setup(j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before processing a JPEG scan */
|
||||
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */
|
||||
{
|
||||
@@ -377,7 +378,7 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
/* For noninterleaved scans, it is convenient to define last_row_height
|
||||
* as the number of block rows present in the last iMCU row.
|
||||
*/
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||
compptr->last_row_height = tmp;
|
||||
|
||||
@@ -394,11 +395,11 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
|
||||
/* Overall image size in MCUs */
|
||||
cinfo->MCUs_per_row = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_width,
|
||||
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_width,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
|
||||
cinfo->blocks_in_MCU = 0;
|
||||
|
||||
@@ -410,10 +411,10 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
||||
compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
|
||||
/* Figure number of non-dummy blocks in last MCU column & row */
|
||||
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
|
||||
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
|
||||
if (tmp == 0) tmp = compptr->MCU_width;
|
||||
compptr->last_col_width = tmp;
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
|
||||
if (tmp == 0) tmp = compptr->MCU_height;
|
||||
compptr->last_row_height = tmp;
|
||||
/* Prepare array describing MCU composition */
|
||||
@@ -430,8 +431,8 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
/* Convert restart specified in rows to actual MCU count. */
|
||||
/* Note that count must fit in 16 bits, so we provide limiting. */
|
||||
if (cinfo->restart_in_rows > 0) {
|
||||
long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row;
|
||||
cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L);
|
||||
long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
|
||||
cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,9 +446,9 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
prepare_for_pass (j_compress_ptr cinfo)
|
||||
prepare_for_pass(j_compress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
switch (master->pass_type) {
|
||||
case main_pass:
|
||||
@@ -456,7 +457,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
*/
|
||||
select_scan_parameters(cinfo);
|
||||
per_scan_setup(cinfo);
|
||||
if (! cinfo->raw_data_in) {
|
||||
if (!cinfo->raw_data_in) {
|
||||
(*cinfo->cconvert->start_pass) (cinfo);
|
||||
(*cinfo->downsample->start_pass) (cinfo);
|
||||
(*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
|
||||
@@ -496,7 +497,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
case output_pass:
|
||||
/* Do a data-output pass. */
|
||||
/* We need not repeat per-scan setup if prior optimization pass did it. */
|
||||
if (! cinfo->optimize_coding) {
|
||||
if (!cinfo->optimize_coding) {
|
||||
select_scan_parameters(cinfo);
|
||||
per_scan_setup(cinfo);
|
||||
}
|
||||
@@ -512,7 +513,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||
}
|
||||
|
||||
master->pub.is_last_pass = (master->pass_number == master->total_passes-1);
|
||||
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
|
||||
|
||||
/* Set up progress monitor's pass info if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
@@ -533,7 +534,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pass_startup (j_compress_ptr cinfo)
|
||||
pass_startup(j_compress_ptr cinfo)
|
||||
{
|
||||
cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
|
||||
|
||||
@@ -547,9 +548,9 @@ pass_startup (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_master (j_compress_ptr cinfo)
|
||||
finish_pass_master(j_compress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
/* The entropy coder always needs an end-of-pass call,
|
||||
* either to analyze statistics or to flush its output buffer.
|
||||
@@ -563,7 +564,7 @@ finish_pass_master (j_compress_ptr cinfo)
|
||||
* or output of scan 1 (if no optimization).
|
||||
*/
|
||||
master->pass_type = output_pass;
|
||||
if (! cinfo->optimize_coding)
|
||||
if (!cinfo->optimize_coding)
|
||||
master->scan_number++;
|
||||
break;
|
||||
case huff_opt_pass:
|
||||
@@ -587,14 +588,14 @@ finish_pass_master (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
|
||||
{
|
||||
my_master_ptr master;
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_comp_master));
|
||||
cinfo->master = (struct jpeg_comp_master *) master;
|
||||
cinfo->master = (struct jpeg_comp_master *)master;
|
||||
master->pub.prepare_for_pass = prepare_for_pass;
|
||||
master->pub.pass_startup = pass_startup;
|
||||
master->pub.finish_pass = finish_pass_master;
|
||||
|
||||
12
jcomapi.c
12
jcomapi.c
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_abort (j_common_ptr cinfo)
|
||||
jpeg_abort(j_common_ptr cinfo)
|
||||
{
|
||||
int pool;
|
||||
|
||||
@@ -40,7 +40,7 @@ jpeg_abort (j_common_ptr cinfo)
|
||||
/* Releasing pools in reverse order might help avoid fragmentation
|
||||
* with some (brain-damaged) malloc libraries.
|
||||
*/
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
|
||||
(*cinfo->mem->free_pool) (cinfo, pool);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ jpeg_abort (j_common_ptr cinfo)
|
||||
/* 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;
|
||||
((j_decompress_ptr)cinfo)->marker_list = NULL;
|
||||
} else {
|
||||
cinfo->global_state = CSTATE_START;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ jpeg_abort (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_destroy (j_common_ptr cinfo)
|
||||
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. */
|
||||
@@ -86,7 +86,7 @@ jpeg_destroy (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(JQUANT_TBL *)
|
||||
jpeg_alloc_quant_table (j_common_ptr cinfo)
|
||||
jpeg_alloc_quant_table(j_common_ptr cinfo)
|
||||
{
|
||||
JQUANT_TBL *tbl;
|
||||
|
||||
@@ -98,7 +98,7 @@ jpeg_alloc_quant_table (j_common_ptr cinfo)
|
||||
|
||||
|
||||
GLOBAL(JHUFF_TBL *)
|
||||
jpeg_alloc_huff_table (j_common_ptr cinfo)
|
||||
jpeg_alloc_huff_table(j_common_ptr cinfo)
|
||||
{
|
||||
JHUFF_TBL *tbl;
|
||||
|
||||
|
||||
80
jcparam.c
80
jcparam.c
@@ -25,9 +25,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
const unsigned int *basic_table,
|
||||
int scale_factor, boolean force_baseline)
|
||||
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
|
||||
@@ -45,19 +45,19 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
|
||||
ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl);
|
||||
|
||||
qtblptr = & cinfo->quant_tbl_ptrs[which_tbl];
|
||||
qtblptr = &cinfo->quant_tbl_ptrs[which_tbl];
|
||||
|
||||
if (*qtblptr == NULL)
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo);
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)cinfo);
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
temp = ((long) basic_table[i] * scale_factor + 50L) / 100L;
|
||||
temp = ((long)basic_table[i] * scale_factor + 50L) / 100L;
|
||||
/* limit the values to the valid range */
|
||||
if (temp <= 0L) temp = 1L;
|
||||
if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
|
||||
if (force_baseline && temp > 255L)
|
||||
temp = 255L; /* limit to baseline range if requested */
|
||||
(*qtblptr)->quantval[i] = (UINT16) temp;
|
||||
(*qtblptr)->quantval[i] = (UINT16)temp;
|
||||
}
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
@@ -93,7 +93,7 @@ static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
|
||||
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
GLOBAL(void)
|
||||
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||
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.
|
||||
@@ -109,7 +109,7 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
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
|
||||
@@ -126,7 +126,7 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_quality_scaling (int quality)
|
||||
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).
|
||||
@@ -145,14 +145,14 @@ jpeg_quality_scaling (int quality)
|
||||
if (quality < 50)
|
||||
quality = 5000 / quality;
|
||||
else
|
||||
quality = 200 - quality*2;
|
||||
quality = 200 - quality * 2;
|
||||
|
||||
return quality;
|
||||
}
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
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
|
||||
@@ -178,7 +178,7 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
jpeg_set_defaults(j_compress_ptr cinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -192,7 +192,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
*/
|
||||
if (cinfo->comp_info == NULL)
|
||||
cinfo->comp_info = (jpeg_component_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
MAX_COMPONENTS * sizeof(jpeg_component_info));
|
||||
|
||||
/* Initialize everything not dependent on the color space */
|
||||
@@ -205,7 +205,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
/* Set up two quantization tables using default quality of 75 */
|
||||
jpeg_set_quality(cinfo, 75, TRUE);
|
||||
/* Set up two Huffman tables */
|
||||
std_huff_tables((j_common_ptr) cinfo);
|
||||
std_huff_tables((j_common_ptr)cinfo);
|
||||
|
||||
/* Initialize default arithmetic coding conditioning */
|
||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||
@@ -278,7 +278,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||
jpeg_default_colorspace(j_compress_ptr cinfo)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
@@ -320,12 +320,12 @@ jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
{
|
||||
jpeg_component_info *compptr;
|
||||
int ci;
|
||||
|
||||
#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \
|
||||
#define SET_COMP(index, id, hsamp, vsamp, quant, dctbl, actbl) \
|
||||
(compptr = &cinfo->comp_info[index], \
|
||||
compptr->component_id = (id), \
|
||||
compptr->h_samp_factor = (hsamp), \
|
||||
@@ -352,39 +352,39 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->num_components = 1;
|
||||
/* JFIF specifies component ID 1 */
|
||||
SET_COMP(0, 1, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 1, 1, 1, 0, 0, 0);
|
||||
break;
|
||||
case JCS_RGB:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
||||
cinfo->num_components = 3;
|
||||
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0);
|
||||
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 0x52 /* 'R' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(1, 0x47 /* 'G' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(2, 0x42 /* 'B' */, 1, 1, 0, 0, 0);
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->num_components = 3;
|
||||
/* JFIF specifies component IDs 1,2,3 */
|
||||
/* We default to 2x2 subsamples of chrominance */
|
||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||
SET_COMP(0, 1, 2, 2, 0, 0, 0);
|
||||
SET_COMP(1, 2, 1, 1, 1, 1, 1);
|
||||
SET_COMP(2, 3, 1, 1, 1, 1, 1);
|
||||
break;
|
||||
case JCS_CMYK:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
||||
cinfo->num_components = 4;
|
||||
SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0);
|
||||
SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0);
|
||||
SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 0x43 /* 'C' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(1, 0x4D /* 'M' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(2, 0x59 /* 'Y' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(3, 0x4B /* 'K' */, 1, 1, 0, 0, 0);
|
||||
break;
|
||||
case JCS_YCCK:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
||||
cinfo->num_components = 4;
|
||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||
SET_COMP(3, 4, 2,2, 0, 0,0);
|
||||
SET_COMP(0, 1, 2, 2, 0, 0, 0);
|
||||
SET_COMP(1, 2, 1, 1, 1, 1, 1);
|
||||
SET_COMP(2, 3, 1, 1, 1, 1, 1);
|
||||
SET_COMP(3, 4, 2, 2, 0, 0, 0);
|
||||
break;
|
||||
case JCS_UNKNOWN:
|
||||
cinfo->num_components = cinfo->input_components;
|
||||
@@ -392,7 +392,7 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||
MAX_COMPONENTS);
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
SET_COMP(ci, ci, 1,1, 0, 0,0);
|
||||
SET_COMP(ci, ci, 1, 1, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -404,8 +404,7 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
|
||||
LOCAL(jpeg_scan_info *)
|
||||
fill_a_scan (jpeg_scan_info *scanptr, int ci,
|
||||
int Ss, int Se, int Ah, int Al)
|
||||
fill_a_scan(jpeg_scan_info *scanptr, int ci, int Ss, int Se, int Ah, int Al)
|
||||
/* Support routine: generate one scan for specified component */
|
||||
{
|
||||
scanptr->comps_in_scan = 1;
|
||||
@@ -419,8 +418,7 @@ fill_a_scan (jpeg_scan_info *scanptr, int ci,
|
||||
}
|
||||
|
||||
LOCAL(jpeg_scan_info *)
|
||||
fill_scans (jpeg_scan_info *scanptr, int ncomps,
|
||||
int Ss, int Se, int Ah, int Al)
|
||||
fill_scans(jpeg_scan_info *scanptr, int ncomps, int Ss, int Se, int Ah, int Al)
|
||||
/* Support routine: generate one scan for each component */
|
||||
{
|
||||
int ci;
|
||||
@@ -438,7 +436,7 @@ fill_scans (jpeg_scan_info *scanptr, int ncomps,
|
||||
}
|
||||
|
||||
LOCAL(jpeg_scan_info *)
|
||||
fill_dc_scans (jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||
fill_dc_scans(jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||
/* Support routine: generate interleaved DC scan if possible, else N scans */
|
||||
{
|
||||
int ci;
|
||||
@@ -466,7 +464,7 @@ fill_dc_scans (jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
jpeg_simple_progression(j_compress_ptr cinfo)
|
||||
{
|
||||
int ncomps = cinfo->num_components;
|
||||
int nscans;
|
||||
@@ -498,7 +496,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
||||
cinfo->script_space_size = MAX(nscans, 10);
|
||||
cinfo->script_space = (jpeg_scan_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
||||
}
|
||||
scanptr = cinfo->script_space;
|
||||
|
||||
116
jcphuff.c
116
jcphuff.c
@@ -111,26 +111,26 @@ typedef phuff_entropy_encoder *phuff_entropy_ptr;
|
||||
|
||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#define ISHIFT_TEMPS int ishift_temp;
|
||||
#define IRIGHT_SHIFT(x,shft) \
|
||||
#define IRIGHT_SHIFT(x, shft) \
|
||||
((ishift_temp = (x)) < 0 ? \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
||||
(ishift_temp >> (shft)))
|
||||
#else
|
||||
#define ISHIFT_TEMPS
|
||||
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) encode_mcu_DC_first (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_DC_first(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_AC_first (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_AC_first(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_DC_refine (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_DC_refine(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_AC_refine (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_AC_refine(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_phuff (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather_phuff (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_phuff(j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather_phuff(j_compress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@@ -138,9 +138,9 @@ METHODDEF(void) finish_pass_gather_phuff (j_compress_ptr cinfo);
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
boolean is_DC_band;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -166,7 +166,7 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* AC refinement needs a correction bit buffer */
|
||||
if (entropy->bit_buffer == NULL)
|
||||
entropy->bit_buffer = (char *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
MAX_CORR_BITS * sizeof(char));
|
||||
}
|
||||
}
|
||||
@@ -199,14 +199,14 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||
if (entropy->count_ptrs[tbl] == NULL)
|
||||
entropy->count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
|
||||
} else {
|
||||
/* Compute derived values for Huffman table */
|
||||
/* We may do this more than once for a table, but it's not expensive */
|
||||
jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
|
||||
& entropy->derived_tbls[tbl]);
|
||||
&entropy->derived_tbls[tbl]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,19 +230,20 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
*/
|
||||
|
||||
/* Emit a byte */
|
||||
#define emit_byte(entropy,val) \
|
||||
{ *(entropy)->next_output_byte++ = (JOCTET) (val); \
|
||||
#define emit_byte(entropy, val) { \
|
||||
*(entropy)->next_output_byte++ = (JOCTET)(val); \
|
||||
if (--(entropy)->free_in_buffer == 0) \
|
||||
dump_buffer(entropy); }
|
||||
dump_buffer(entropy); \
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
dump_buffer (phuff_entropy_ptr entropy)
|
||||
dump_buffer(phuff_entropy_ptr entropy)
|
||||
/* Empty the output buffer; we do not support suspension in this module. */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
|
||||
|
||||
if (! (*dest->empty_output_buffer) (entropy->cinfo))
|
||||
if (!(*dest->empty_output_buffer) (entropy->cinfo))
|
||||
ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
|
||||
/* After a successful buffer dump, must reset buffer pointers */
|
||||
entropy->next_output_byte = dest->next_output_byte;
|
||||
@@ -259,11 +260,11 @@ dump_buffer (phuff_entropy_ptr entropy)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
/* Emit some bits, unless we are in gather mode */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding tightly. */
|
||||
register size_t put_buffer = (size_t) code;
|
||||
register size_t put_buffer = (size_t)code;
|
||||
register int put_bits = entropy->put_bits;
|
||||
|
||||
/* if size is 0, caller used an invalid Huffman table entry */
|
||||
@@ -273,7 +274,7 @@ emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
if (entropy->gather_statistics)
|
||||
return; /* do nothing if we're only getting stats */
|
||||
|
||||
put_buffer &= (((size_t) 1)<<size) - 1; /* mask off any extra bits in code */
|
||||
put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
|
||||
|
||||
put_bits += size; /* new number of bits in buffer */
|
||||
|
||||
@@ -282,7 +283,7 @@ emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
|
||||
|
||||
while (put_bits >= 8) {
|
||||
int c = (int) ((put_buffer >> 16) & 0xFF);
|
||||
int c = (int)((put_buffer >> 16) & 0xFF);
|
||||
|
||||
emit_byte(entropy, c);
|
||||
if (c == 0xFF) { /* need to stuff a zero byte? */
|
||||
@@ -298,7 +299,7 @@ emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
flush_bits (phuff_entropy_ptr entropy)
|
||||
flush_bits(phuff_entropy_ptr entropy)
|
||||
{
|
||||
emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
|
||||
entropy->put_buffer = 0; /* and reset bit-buffer to empty */
|
||||
@@ -311,7 +312,7 @@ flush_bits (phuff_entropy_ptr entropy)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||
emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||
{
|
||||
if (entropy->gather_statistics)
|
||||
entropy->count_ptrs[tbl_no][symbol]++;
|
||||
@@ -327,14 +328,14 @@ emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_buffered_bits (phuff_entropy_ptr entropy, char *bufstart,
|
||||
emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart,
|
||||
unsigned int nbits)
|
||||
{
|
||||
if (entropy->gather_statistics)
|
||||
return; /* no real work */
|
||||
|
||||
while (nbits > 0) {
|
||||
emit_bits(entropy, (unsigned int) (*bufstart), 1);
|
||||
emit_bits(entropy, (unsigned int)(*bufstart), 1);
|
||||
bufstart++;
|
||||
nbits--;
|
||||
}
|
||||
@@ -346,7 +347,7 @@ emit_buffered_bits (phuff_entropy_ptr entropy, char *bufstart,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_eobrun (phuff_entropy_ptr entropy)
|
||||
emit_eobrun(phuff_entropy_ptr entropy)
|
||||
{
|
||||
register int temp, nbits;
|
||||
|
||||
@@ -375,13 +376,13 @@ emit_eobrun (phuff_entropy_ptr entropy)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_restart (phuff_entropy_ptr entropy, int restart_num)
|
||||
emit_restart(phuff_entropy_ptr entropy, int restart_num)
|
||||
{
|
||||
int ci;
|
||||
|
||||
emit_eobrun(entropy);
|
||||
|
||||
if (! entropy->gather_statistics) {
|
||||
if (!entropy->gather_statistics) {
|
||||
flush_bits(entropy);
|
||||
emit_byte(entropy, 0xFF);
|
||||
emit_byte(entropy, JPEG_RST0 + restart_num);
|
||||
@@ -405,9 +406,9 @@ emit_restart (phuff_entropy_ptr entropy, int restart_num)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp, temp2, temp3;
|
||||
register int nbits;
|
||||
int blkn, ci;
|
||||
@@ -433,7 +434,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Compute the DC value after the required point transform by Al.
|
||||
* This is simply an arithmetic right shift.
|
||||
*/
|
||||
temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);
|
||||
temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
|
||||
|
||||
/* DC differences are figured on the point-transformed values. */
|
||||
temp = temp2 - entropy->last_dc_val[ci];
|
||||
@@ -457,7 +458,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Check for out-of-range coefficient values.
|
||||
* Since we're encoding a difference, the range limit is twice as much.
|
||||
*/
|
||||
if (nbits > MAX_COEF_BITS+1)
|
||||
if (nbits > MAX_COEF_BITS + 1)
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||
@@ -466,7 +467,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
if (nbits) /* emit_bits rejects calls with size 0 */
|
||||
emit_bits(entropy, (unsigned int) temp2, nbits);
|
||||
emit_bits(entropy, (unsigned int)temp2, nbits);
|
||||
}
|
||||
|
||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||
@@ -492,9 +493,9 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp, temp2, temp3;
|
||||
register int nbits;
|
||||
register int r, k;
|
||||
@@ -559,7 +560,7 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
emit_bits(entropy, (unsigned int) temp2, nbits);
|
||||
emit_bits(entropy, (unsigned int)temp2, nbits);
|
||||
|
||||
r = 0; /* reset zero run length */
|
||||
}
|
||||
@@ -594,9 +595,9 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp;
|
||||
int blkn;
|
||||
int Al = cinfo->Al;
|
||||
@@ -616,7 +617,7 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* We simply emit the Al'th bit of the DC coefficient value. */
|
||||
temp = (*block)[0];
|
||||
emit_bits(entropy, (unsigned int) (temp >> Al), 1);
|
||||
emit_bits(entropy, (unsigned int)(temp >> Al), 1);
|
||||
}
|
||||
|
||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||
@@ -641,9 +642,9 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp, temp3;
|
||||
register int r, k;
|
||||
int EOB;
|
||||
@@ -716,7 +717,7 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
if (temp > 1) {
|
||||
/* The correction bit is the next bit of the absolute value. */
|
||||
BR_buffer[BR++] = (char) (temp & 1);
|
||||
BR_buffer[BR++] = (char)(temp & 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -728,7 +729,7 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* Emit output bit for newly-nonzero coef */
|
||||
temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1;
|
||||
emit_bits(entropy, (unsigned int) temp, 1);
|
||||
emit_bits(entropy, (unsigned int)temp, 1);
|
||||
|
||||
/* Emit buffered correction bits that must be associated with this code */
|
||||
emit_buffered_bits(entropy, BR_buffer, BR);
|
||||
@@ -744,7 +745,8 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* 1. overflow of the EOB counter;
|
||||
* 2. overflow of the correction bit buffer during the next MCU.
|
||||
*/
|
||||
if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1))
|
||||
if (entropy->EOBRUN == 0x7FFF ||
|
||||
entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
|
||||
emit_eobrun(entropy);
|
||||
}
|
||||
|
||||
@@ -770,9 +772,9 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_phuff (j_compress_ptr cinfo)
|
||||
finish_pass_phuff(j_compress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
@@ -791,9 +793,9 @@ finish_pass_phuff (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
finish_pass_gather_phuff(j_compress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
boolean is_DC_band;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -819,13 +821,13 @@ finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
} else {
|
||||
tbl = compptr->ac_tbl_no;
|
||||
}
|
||||
if (! did[tbl]) {
|
||||
if (!did[tbl]) {
|
||||
if (is_DC_band)
|
||||
htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
|
||||
htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
|
||||
else
|
||||
htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
|
||||
htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
|
||||
did[tbl] = TRUE;
|
||||
}
|
||||
@@ -838,15 +840,15 @@ finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_phuff_encoder (j_compress_ptr cinfo)
|
||||
jinit_phuff_encoder(j_compress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (phuff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(phuff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_phuff;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
|
||||
80
jcprepct.c
80
jcprepct.c
@@ -78,9 +78,9 @@ typedef my_prep_controller *my_prep_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_prep(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
|
||||
if (pass_mode != JBUF_PASS_THRU)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@@ -106,14 +106,14 @@ start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,
|
||||
int input_rows, int output_rows)
|
||||
expand_bottom_edge(JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
|
||||
int output_rows)
|
||||
{
|
||||
register int row;
|
||||
|
||||
for (row = input_rows; row < output_rows; row++) {
|
||||
jcopy_sample_rows(image_data, input_rows-1, image_data, row,
|
||||
1, num_cols);
|
||||
jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
|
||||
num_cols);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,13 +128,12 @@ expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pre_process_data (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail,
|
||||
pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
|
||||
JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
|
||||
JDIMENSION out_row_groups_avail)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
int numrows, ci;
|
||||
JDIMENSION inrows;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -144,10 +143,10 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
/* Do color conversion to fill the conversion buffer. */
|
||||
inrows = in_rows_avail - *in_row_ctr;
|
||||
numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
|
||||
numrows = (int) MIN((JDIMENSION) numrows, inrows);
|
||||
numrows = (int)MIN((JDIMENSION)numrows, inrows);
|
||||
(*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
|
||||
prep->color_buf,
|
||||
(JDIMENSION) prep->next_buf_row,
|
||||
(JDIMENSION)prep->next_buf_row,
|
||||
numrows);
|
||||
*in_row_ctr += numrows;
|
||||
prep->next_buf_row += numrows;
|
||||
@@ -164,7 +163,7 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
/* If we've filled the conversion buffer, empty it. */
|
||||
if (prep->next_buf_row == cinfo->max_v_samp_factor) {
|
||||
(*cinfo->downsample->downsample) (cinfo,
|
||||
prep->color_buf, (JDIMENSION) 0,
|
||||
prep->color_buf, (JDIMENSION)0,
|
||||
output_buf, *out_row_group_ctr);
|
||||
prep->next_buf_row = 0;
|
||||
(*out_row_group_ctr)++;
|
||||
@@ -172,14 +171,12 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
/* If at bottom of image, pad the output to a full iMCU height.
|
||||
* Note we assume the caller is providing a one-iMCU-height output buffer!
|
||||
*/
|
||||
if (prep->rows_to_go == 0 &&
|
||||
*out_row_group_ctr < out_row_groups_avail) {
|
||||
if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
expand_bottom_edge(output_buf[ci],
|
||||
compptr->width_in_blocks * DCTSIZE,
|
||||
(int) (*out_row_group_ctr * compptr->v_samp_factor),
|
||||
(int) (out_row_groups_avail * compptr->v_samp_factor));
|
||||
expand_bottom_edge(output_buf[ci], compptr->width_in_blocks * DCTSIZE,
|
||||
(int)(*out_row_group_ctr * compptr->v_samp_factor),
|
||||
(int)(out_row_groups_avail * compptr->v_samp_factor));
|
||||
}
|
||||
*out_row_group_ctr = out_row_groups_avail;
|
||||
break; /* can exit outer loop without test */
|
||||
@@ -195,13 +192,12 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pre_process_context (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail,
|
||||
pre_process_context(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
|
||||
JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
|
||||
JDIMENSION out_row_groups_avail)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
int numrows, ci;
|
||||
int buf_height = cinfo->max_v_samp_factor * 3;
|
||||
JDIMENSION inrows;
|
||||
@@ -211,19 +207,18 @@ pre_process_context (j_compress_ptr cinfo,
|
||||
/* Do color conversion to fill the conversion buffer. */
|
||||
inrows = in_rows_avail - *in_row_ctr;
|
||||
numrows = prep->next_buf_stop - prep->next_buf_row;
|
||||
numrows = (int) MIN((JDIMENSION) numrows, inrows);
|
||||
numrows = (int)MIN((JDIMENSION)numrows, inrows);
|
||||
(*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
|
||||
prep->color_buf,
|
||||
(JDIMENSION) prep->next_buf_row,
|
||||
(JDIMENSION)prep->next_buf_row,
|
||||
numrows);
|
||||
/* Pad at top of image, if first time through */
|
||||
if (prep->rows_to_go == cinfo->image_height) {
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
int row;
|
||||
for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
|
||||
jcopy_sample_rows(prep->color_buf[ci], 0,
|
||||
prep->color_buf[ci], -row,
|
||||
1, cinfo->image_width);
|
||||
jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
|
||||
-row, 1, cinfo->image_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,9 +240,8 @@ pre_process_context (j_compress_ptr cinfo,
|
||||
}
|
||||
/* If we've gotten enough data, downsample a row group. */
|
||||
if (prep->next_buf_row == prep->next_buf_stop) {
|
||||
(*cinfo->downsample->downsample) (cinfo,
|
||||
prep->color_buf,
|
||||
(JDIMENSION) prep->this_row_group,
|
||||
(*cinfo->downsample->downsample) (cinfo, prep->color_buf,
|
||||
(JDIMENSION)prep->this_row_group,
|
||||
output_buf, *out_row_group_ctr);
|
||||
(*out_row_group_ctr)++;
|
||||
/* Advance pointers with wraparound as necessary. */
|
||||
@@ -267,9 +261,9 @@ pre_process_context (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_context_buffer (j_compress_ptr cinfo)
|
||||
create_context_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
int rgroup_height = cinfo->max_v_samp_factor;
|
||||
int ci, i;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -279,7 +273,7 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
* we need five row groups' worth of pointers for each component.
|
||||
*/
|
||||
fake_buffer = (JSAMPARRAY)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(cinfo->num_components * 5 * rgroup_height) *
|
||||
sizeof(JSAMPROW));
|
||||
|
||||
@@ -290,10 +284,10 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
* horizontally within the buffer, if it so chooses.
|
||||
*/
|
||||
true_buffer = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
|
||||
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
|
||||
(JDIMENSION) (3 * rgroup_height));
|
||||
(JDIMENSION)(3 * rgroup_height));
|
||||
/* Copy true buffer row pointers into the middle of the fake row array */
|
||||
MEMCOPY(fake_buffer + rgroup_height, true_buffer,
|
||||
3 * rgroup_height * sizeof(JSAMPROW));
|
||||
@@ -315,7 +309,7 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_prep_ptr prep;
|
||||
int ci;
|
||||
@@ -325,9 +319,9 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
|
||||
prep = (my_prep_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_prep_controller));
|
||||
cinfo->prep = (struct jpeg_c_prep_controller *) prep;
|
||||
cinfo->prep = (struct jpeg_c_prep_controller *)prep;
|
||||
prep->pub.start_pass = start_pass_prep;
|
||||
|
||||
/* Allocate the color conversion buffer.
|
||||
@@ -348,10 +342,10 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
|
||||
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
|
||||
(JDIMENSION) cinfo->max_v_samp_factor);
|
||||
(JDIMENSION)cinfo->max_v_samp_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
96
jcsample.c
96
jcsample.c
@@ -79,7 +79,7 @@ typedef my_downsampler *my_downsample_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_downsample (j_compress_ptr cinfo)
|
||||
start_pass_downsample(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work for now */
|
||||
}
|
||||
@@ -91,14 +91,14 @@ start_pass_downsample (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
expand_right_edge (JSAMPARRAY image_data, int num_rows,
|
||||
JDIMENSION input_cols, JDIMENSION output_cols)
|
||||
expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols,
|
||||
JDIMENSION output_cols)
|
||||
{
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE pixval;
|
||||
register int count;
|
||||
int row;
|
||||
int numcols = (int) (output_cols - input_cols);
|
||||
int numcols = (int)(output_cols - input_cols);
|
||||
|
||||
if (numcols > 0) {
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
@@ -118,11 +118,11 @@ expand_right_edge (JSAMPARRAY image_data, int num_rows,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
sep_downsample (j_compress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_index,
|
||||
JSAMPIMAGE output_buf, JDIMENSION out_row_group_index)
|
||||
sep_downsample(j_compress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_index, JSAMPIMAGE output_buf,
|
||||
JDIMENSION out_row_group_index)
|
||||
{
|
||||
my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
|
||||
my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
JSAMPARRAY in_ptr, out_ptr;
|
||||
@@ -144,7 +144,7 @@ sep_downsample (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
|
||||
@@ -156,14 +156,14 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
|
||||
v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
|
||||
numpix = h_expand * v_expand;
|
||||
numpix2 = numpix/2;
|
||||
numpix2 = numpix / 2;
|
||||
|
||||
/* Expand input data enough to let all the output samples be generated
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
* efficient.
|
||||
*/
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, output_cols * h_expand);
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
output_cols * h_expand);
|
||||
|
||||
inrow = 0;
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
@@ -172,12 +172,12 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
outcol++, outcol_h += h_expand) {
|
||||
outvalue = 0;
|
||||
for (v = 0; v < v_expand; v++) {
|
||||
inptr = input_data[inrow+v] + outcol_h;
|
||||
inptr = input_data[inrow + v] + outcol_h;
|
||||
for (h = 0; h < h_expand; h++) {
|
||||
outvalue += (JLONG) GETJSAMPLE(*inptr++);
|
||||
outvalue += (JLONG)GETJSAMPLE(*inptr++);
|
||||
}
|
||||
}
|
||||
*outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
|
||||
*outptr++ = (JSAMPLE)((outvalue + numpix2) / numpix);
|
||||
}
|
||||
inrow += v_expand;
|
||||
}
|
||||
@@ -191,15 +191,15 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
/* Copy the data */
|
||||
jcopy_sample_rows(input_data, 0, output_data, 0,
|
||||
cinfo->max_v_samp_factor, cinfo->image_width);
|
||||
jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width);
|
||||
/* Edge-expand */
|
||||
expand_right_edge(output_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, compptr->width_in_blocks * DCTSIZE);
|
||||
expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
compptr->width_in_blocks * DCTSIZE);
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int outrow;
|
||||
@@ -229,16 +229,16 @@ h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
* efficient.
|
||||
*/
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, output_cols * 2);
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
output_cols * 2);
|
||||
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr = input_data[outrow];
|
||||
bias = 0; /* bias = 0,1,0,1,... for successive samples */
|
||||
for (outcol = 0; outcol < output_cols; outcol++) {
|
||||
*outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
|
||||
+ bias) >> 1);
|
||||
*outptr++ =
|
||||
(JSAMPLE)((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) + bias) >> 1);
|
||||
bias ^= 1; /* 0=>1, 1=>0 */
|
||||
inptr += 2;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int inrow, outrow;
|
||||
@@ -266,19 +266,19 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
* efficient.
|
||||
*/
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, output_cols * 2);
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
output_cols * 2);
|
||||
|
||||
inrow = 0;
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr0 = input_data[inrow];
|
||||
inptr1 = input_data[inrow+1];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
bias = 1; /* bias = 1,2,1,2,... for successive samples */
|
||||
for (outcol = 0; outcol < output_cols; outcol++) {
|
||||
*outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||
GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1])
|
||||
+ bias) >> 2);
|
||||
*outptr++ =
|
||||
(JSAMPLE)((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||
GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + bias) >> 2);
|
||||
bias ^= 3; /* 1=>2, 2=>1 */
|
||||
inptr0 += 2; inptr1 += 2;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int inrow, outrow;
|
||||
@@ -332,9 +332,9 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr0 = input_data[inrow];
|
||||
inptr1 = input_data[inrow+1];
|
||||
above_ptr = input_data[inrow-1];
|
||||
below_ptr = input_data[inrow+2];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
above_ptr = input_data[inrow - 1];
|
||||
below_ptr = input_data[inrow + 2];
|
||||
|
||||
/* Special case for first column: pretend column -1 is same as column 0 */
|
||||
membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||
@@ -347,7 +347,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) +
|
||||
GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
||||
|
||||
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
||||
@@ -367,7 +367,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* form final output scaled up by 2^16 */
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
/* round, descale and output it */
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) +
|
||||
GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]);
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
|
||||
inrow += 2;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int outrow;
|
||||
@@ -425,8 +425,8 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr = input_data[outrow];
|
||||
above_ptr = input_data[outrow-1];
|
||||
below_ptr = input_data[outrow+1];
|
||||
above_ptr = input_data[outrow - 1];
|
||||
below_ptr = input_data[outrow + 1];
|
||||
|
||||
/* Special case for first column */
|
||||
colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) +
|
||||
@@ -436,7 +436,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
GETJSAMPLE(*inptr);
|
||||
neighsum = colsum + (colsum - membersum) + nextcolsum;
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
lastcolsum = colsum; colsum = nextcolsum;
|
||||
|
||||
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
||||
@@ -446,7 +446,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
GETJSAMPLE(*inptr);
|
||||
neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
lastcolsum = colsum; colsum = nextcolsum;
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
membersum = GETJSAMPLE(*inptr);
|
||||
neighsum = lastcolsum + (colsum - membersum) + colsum;
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -468,7 +468,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_downsampler (j_compress_ptr cinfo)
|
||||
jinit_downsampler(j_compress_ptr cinfo)
|
||||
{
|
||||
my_downsample_ptr downsample;
|
||||
int ci;
|
||||
@@ -476,9 +476,9 @@ jinit_downsampler (j_compress_ptr cinfo)
|
||||
boolean smoothok = TRUE;
|
||||
|
||||
downsample = (my_downsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_downsampler));
|
||||
cinfo->downsample = (struct jpeg_downsampler *) downsample;
|
||||
cinfo->downsample = (struct jpeg_downsampler *)downsample;
|
||||
downsample->pub.start_pass = start_pass_downsample;
|
||||
downsample->pub.downsample = sep_downsample;
|
||||
downsample->pub.need_context_rows = FALSE;
|
||||
|
||||
20
jcstest.c
20
jcstest.c
@@ -51,13 +51,13 @@ typedef struct _error_mgr {
|
||||
static void my_error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
error_mgr *myerr = (error_mgr *)cinfo->err;
|
||||
(*cinfo->err->output_message)(cinfo);
|
||||
(*cinfo->err->output_message) (cinfo);
|
||||
longjmp(myerr->jb, 1);
|
||||
}
|
||||
|
||||
static void my_output_message(j_common_ptr cinfo)
|
||||
{
|
||||
(*cinfo->err->format_message)(cinfo, lasterror);
|
||||
(*cinfo->err->format_message) (cinfo, lasterror);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
@@ -67,11 +67,11 @@ int main(void)
|
||||
error_mgr jerr;
|
||||
|
||||
printf("libjpeg-turbo colorspace extensions:\n");
|
||||
#if JCS_EXTENSIONS
|
||||
#if JCS_EXTENSIONS
|
||||
printf(" Present at compile time\n");
|
||||
#else
|
||||
#else
|
||||
printf(" Not present at compile time\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
@@ -90,7 +90,7 @@ int main(void)
|
||||
jpeg_default_colorspace(&cinfo);
|
||||
jcs_valid = 1;
|
||||
|
||||
done:
|
||||
done:
|
||||
if (jcs_valid)
|
||||
printf(" Working properly\n");
|
||||
else
|
||||
@@ -98,11 +98,11 @@ int main(void)
|
||||
lasterror);
|
||||
|
||||
printf("libjpeg-turbo alpha colorspace extensions:\n");
|
||||
#if JCS_ALPHA_EXTENSIONS
|
||||
#if JCS_ALPHA_EXTENSIONS
|
||||
printf(" Present at compile time\n");
|
||||
#else
|
||||
#else
|
||||
printf(" Not present at compile time\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (setjmp(jerr.jb)) {
|
||||
/* this will execute if libjpeg has an error */
|
||||
@@ -114,7 +114,7 @@ int main(void)
|
||||
jpeg_default_colorspace(&cinfo);
|
||||
jcs_alpha_valid = 1;
|
||||
|
||||
done2:
|
||||
done2:
|
||||
if (jcs_alpha_valid)
|
||||
printf(" Working properly\n");
|
||||
else
|
||||
|
||||
66
jctrans.c
66
jctrans.c
@@ -20,10 +20,10 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(void) transencode_master_selection
|
||||
(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
|
||||
LOCAL(void) transencode_coef_controller
|
||||
(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
|
||||
LOCAL(void) transencode_master_selection(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays);
|
||||
LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays);
|
||||
|
||||
|
||||
/*
|
||||
@@ -39,14 +39,14 @@ LOCAL(void) transencode_coef_controller
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||
jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||
{
|
||||
if (cinfo->global_state != CSTATE_START)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
/* Mark all tables to be written */
|
||||
jpeg_suppress_tables(cinfo, FALSE);
|
||||
/* (Re)initialize error mgr and destination modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->dest->init_destination) (cinfo);
|
||||
/* Perform master selection of active modules */
|
||||
transencode_master_selection(cinfo, coef_arrays);
|
||||
@@ -64,8 +64,7 @@ jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
j_compress_ptr dstinfo)
|
||||
jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
||||
{
|
||||
JQUANT_TBL **qtblptr;
|
||||
jpeg_component_info *incomp, *outcomp;
|
||||
@@ -97,11 +96,10 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
/* Copy the source's quantization tables. */
|
||||
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
|
||||
if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
|
||||
qtblptr = & dstinfo->quant_tbl_ptrs[tblno];
|
||||
qtblptr = &dstinfo->quant_tbl_ptrs[tblno];
|
||||
if (*qtblptr == NULL)
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
||||
MEMCOPY((*qtblptr)->quantval,
|
||||
srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)dstinfo);
|
||||
MEMCOPY((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
||||
sizeof((*qtblptr)->quantval));
|
||||
(*qtblptr)->sent_table = FALSE;
|
||||
}
|
||||
@@ -165,7 +163,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
transencode_master_selection (j_compress_ptr cinfo,
|
||||
transencode_master_selection(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays)
|
||||
{
|
||||
/* Although we don't actually use input_components for transcoding,
|
||||
@@ -199,7 +197,7 @@ transencode_master_selection (j_compress_ptr cinfo,
|
||||
jinit_marker_writer(cinfo);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Write the datastream header (SOI, JFIF) immediately.
|
||||
* Frame and scan headers are postponed till later.
|
||||
@@ -238,10 +236,10 @@ typedef my_coef_controller *my_coef_ptr;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
start_iMCU_row (j_compress_ptr cinfo)
|
||||
start_iMCU_row(j_compress_ptr cinfo)
|
||||
/* Reset within-iMCU-row counters for a new row */
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||
@@ -250,7 +248,7 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
if (cinfo->comps_in_scan > 1) {
|
||||
coef->MCU_rows_per_iMCU_row = 1;
|
||||
} else {
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||
else
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||
@@ -266,9 +264,9 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
if (pass_mode != JBUF_CRANK_DEST)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@@ -289,9 +287,9 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
@@ -306,9 +304,9 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
||||
}
|
||||
|
||||
/* Loop to process one whole iMCU row */
|
||||
@@ -321,13 +319,13 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
start_col = MCU_col_num * compptr->MCU_width;
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||
: compptr->last_col_width;
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
|
||||
compptr->last_col_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||
yindex+yoffset < compptr->last_row_height) {
|
||||
yindex + yoffset < compptr->last_row_height) {
|
||||
/* Fill in pointers to real blocks in this row */
|
||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
||||
for (xindex = 0; xindex < blockcnt; xindex++)
|
||||
MCU_buffer[blkn++] = buffer_ptr++;
|
||||
} else {
|
||||
@@ -342,13 +340,13 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
for (; xindex < compptr->MCU_width; xindex++) {
|
||||
MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
||||
MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
||||
MCU_buffer[blkn][0][0] = MCU_buffer[blkn - 1][0][0];
|
||||
blkn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to write the MCU. */
|
||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->mcu_ctr = MCU_col_num;
|
||||
@@ -374,7 +372,7 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
transencode_coef_controller (j_compress_ptr cinfo,
|
||||
transencode_coef_controller(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays)
|
||||
{
|
||||
my_coef_ptr coef;
|
||||
@@ -382,9 +380,9 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
int i;
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
|
||||
coef->pub.start_pass = start_pass_coef;
|
||||
coef->pub.compress_data = compress_output;
|
||||
|
||||
@@ -393,9 +391,9 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
|
||||
/* Allocate and pre-zero space for dummy DCT blocks. */
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
jzero_far((void *)buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->dummy_buffer[i] = buffer + i;
|
||||
}
|
||||
|
||||
40
jdapimin.c
40
jdapimin.c
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -41,7 +41,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
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);
|
||||
(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
|
||||
@@ -50,8 +50,8 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
* complain here.
|
||||
*/
|
||||
{
|
||||
struct jpeg_error_mgr * err = cinfo->err;
|
||||
void * client_data = cinfo->client_data; /* ignore Purify complaint 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;
|
||||
@@ -59,7 +59,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
cinfo->is_decompressor = TRUE;
|
||||
|
||||
/* Initialize a memory manager instance for this object */
|
||||
jinit_memory_mgr((j_common_ptr) cinfo);
|
||||
jinit_memory_mgr((j_common_ptr)cinfo);
|
||||
|
||||
/* Zero out pointers to permanent structures. */
|
||||
cinfo->progress = NULL;
|
||||
@@ -89,7 +89,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
* here.
|
||||
*/
|
||||
cinfo->master = (struct jpeg_decomp_master *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_decomp_master));
|
||||
MEMZERO(cinfo->master, sizeof(my_decomp_master));
|
||||
}
|
||||
@@ -100,9 +100,9 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_destroy_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_destroy_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@@ -112,9 +112,9 @@ jpeg_destroy_decompress (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_abort_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_abort_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_abort((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ jpeg_abort_decompress (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
default_decompress_parms (j_decompress_ptr cinfo)
|
||||
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...) */
|
||||
@@ -250,7 +250,7 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
|
||||
{
|
||||
int retcode;
|
||||
|
||||
@@ -271,7 +271,7 @@ jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||
* 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 */
|
||||
jpeg_abort((j_common_ptr)cinfo); /* sets state = DSTATE_START */
|
||||
retcode = JPEG_HEADER_TABLES_ONLY;
|
||||
break;
|
||||
case JPEG_SUSPENDED:
|
||||
@@ -296,7 +296,7 @@ jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||
*/
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_consume_input (j_decompress_ptr cinfo)
|
||||
jpeg_consume_input(j_decompress_ptr cinfo)
|
||||
{
|
||||
int retcode = JPEG_SUSPENDED;
|
||||
|
||||
@@ -343,7 +343,7 @@ jpeg_consume_input (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_input_complete (j_decompress_ptr cinfo)
|
||||
jpeg_input_complete(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Check for valid jpeg object */
|
||||
if (cinfo->global_state < DSTATE_START ||
|
||||
@@ -358,7 +358,7 @@ jpeg_input_complete (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_has_multiple_scans (j_decompress_ptr cinfo)
|
||||
jpeg_has_multiple_scans(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Only valid after jpeg_read_header completes */
|
||||
if (cinfo->global_state < DSTATE_READY ||
|
||||
@@ -378,10 +378,10 @@ jpeg_has_multiple_scans (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_finish_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_finish_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
if ((cinfo->global_state == DSTATE_SCANNING ||
|
||||
cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {
|
||||
cinfo->global_state == DSTATE_RAW_OK) && !cinfo->buffered_image) {
|
||||
/* Terminate final pass of non-buffered mode */
|
||||
if (cinfo->output_scanline < cinfo->output_height)
|
||||
ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
|
||||
@@ -395,13 +395,13 @@ jpeg_finish_decompress (j_decompress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
}
|
||||
/* Read until EOI */
|
||||
while (! cinfo->inputctl->eoi_reached) {
|
||||
while (!cinfo->inputctl->eoi_reached) {
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return FALSE; /* Suspend, come back later */
|
||||
}
|
||||
/* Do final cleanup */
|
||||
(*cinfo->src->term_source) (cinfo);
|
||||
/* We can use jpeg_abort to release memory and reset global_state */
|
||||
jpeg_abort((j_common_ptr) cinfo);
|
||||
jpeg_abort((j_common_ptr)cinfo);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
85
jdapistd.c
85
jdapistd.c
@@ -25,7 +25,7 @@
|
||||
#include "jmemsys.h"
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(boolean) output_pass_setup (j_decompress_ptr cinfo);
|
||||
LOCAL(boolean) output_pass_setup(j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@@ -40,7 +40,7 @@ LOCAL(boolean) output_pass_setup (j_decompress_ptr cinfo);
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_start_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state == DSTATE_READY) {
|
||||
/* First call: initialize master control, select active modules */
|
||||
@@ -60,7 +60,7 @@ jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
int retcode;
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL)
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
/* Absorb some more input */
|
||||
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
||||
if (retcode == JPEG_SUSPENDED)
|
||||
@@ -72,7 +72,7 @@ jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
|
||||
if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
|
||||
/* jdmaster underestimated number of scans; ratchet up one scan */
|
||||
cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
|
||||
cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
output_pass_setup (j_decompress_ptr cinfo)
|
||||
output_pass_setup(j_decompress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state != DSTATE_PRESCAN) {
|
||||
/* First call: do pass setup */
|
||||
@@ -113,14 +113,14 @@ output_pass_setup (j_decompress_ptr cinfo)
|
||||
JDIMENSION last_scanline;
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
/* Process some data */
|
||||
last_scanline = cinfo->output_scanline;
|
||||
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
|
||||
&cinfo->output_scanline, (JDIMENSION) 0);
|
||||
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
|
||||
&cinfo->output_scanline, (JDIMENSION)0);
|
||||
if (cinfo->output_scanline == last_scanline)
|
||||
return FALSE; /* No progress made, must suspend */
|
||||
}
|
||||
@@ -150,7 +150,7 @@ output_pass_setup (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
JDIMENSION *width)
|
||||
{
|
||||
int ci, align, orig_downsampled_width;
|
||||
@@ -210,11 +210,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
/* Set the first and last iMCU columns that we must decompress. These values
|
||||
* will be used in single-scan decompressions.
|
||||
*/
|
||||
cinfo->master->first_iMCU_col =
|
||||
(JDIMENSION) (long) (*xoffset) / (long) align;
|
||||
cinfo->master->first_iMCU_col = (JDIMENSION)(long)(*xoffset) / (long)align;
|
||||
cinfo->master->last_iMCU_col =
|
||||
(JDIMENSION) jdiv_round_up((long) (*xoffset + cinfo->output_width),
|
||||
(long) align) - 1;
|
||||
(JDIMENSION)jdiv_round_up((long)(*xoffset + cinfo->output_width),
|
||||
(long)align) - 1;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
@@ -224,9 +223,9 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
/* Set downsampled_width to the new output width. */
|
||||
orig_downsampled_width = compptr->downsampled_width;
|
||||
compptr->downsampled_width =
|
||||
(JDIMENSION) jdiv_round_up((long) (cinfo->output_width *
|
||||
(JDIMENSION)jdiv_round_up((long)(cinfo->output_width *
|
||||
compptr->h_samp_factor),
|
||||
(long) cinfo->max_h_samp_factor);
|
||||
(long)cinfo->max_h_samp_factor);
|
||||
if (compptr->downsampled_width < 2 && orig_downsampled_width >= 2)
|
||||
reinit_upsampler = TRUE;
|
||||
|
||||
@@ -234,11 +233,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
* values will be used in multi-scan decompressions.
|
||||
*/
|
||||
cinfo->master->first_MCU_col[ci] =
|
||||
(JDIMENSION) (long) (*xoffset * hsf) / (long) align;
|
||||
(JDIMENSION)(long)(*xoffset * hsf) / (long)align;
|
||||
cinfo->master->last_MCU_col[ci] =
|
||||
(JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) *
|
||||
hsf),
|
||||
(long) align) - 1;
|
||||
(JDIMENSION)jdiv_round_up((long)((*xoffset + cinfo->output_width) * hsf),
|
||||
(long)align) - 1;
|
||||
}
|
||||
|
||||
if (reinit_upsampler) {
|
||||
@@ -263,7 +261,7 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
JDIMENSION max_lines)
|
||||
{
|
||||
JDIMENSION row_ctr;
|
||||
@@ -277,9 +275,9 @@ jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Process some data */
|
||||
@@ -292,7 +290,7 @@ jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
|
||||
/* Dummy color convert function used by jpeg_skip_scanlines() */
|
||||
LOCAL(void)
|
||||
noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
noop_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
}
|
||||
@@ -300,7 +298,7 @@ noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
|
||||
/* Dummy quantize function used by jpeg_skip_scanlines() */
|
||||
LOCAL(void)
|
||||
noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
noop_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
}
|
||||
@@ -315,7 +313,7 @@ noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION n;
|
||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
@@ -346,10 +344,10 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
increment_simple_rowgroup_ctr (j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
increment_simple_rowgroup_ctr(j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
{
|
||||
JDIMENSION rows_left;
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
/* Increment the counter to the next row group after the skipped rows. */
|
||||
main_ptr->rowgroup_ctr += rows / cinfo->max_v_samp_factor;
|
||||
@@ -375,11 +373,11 @@ increment_simple_rowgroup_ctr (j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JDIMENSION i, x;
|
||||
int y;
|
||||
JDIMENSION lines_per_iMCU_row, lines_left_in_iMCU_row, lines_after_iMCU_row;
|
||||
@@ -544,7 +542,7 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION max_lines)
|
||||
{
|
||||
JDIMENSION lines_per_iMCU_row;
|
||||
@@ -558,9 +556,9 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Verify that at least one iMCU row can be returned. */
|
||||
@@ -569,7 +567,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
/* Decompress directly into user's buffer. */
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo, data))
|
||||
if (!(*cinfo->coef->decompress_data) (cinfo, data))
|
||||
return 0; /* suspension forced, can do nothing more */
|
||||
|
||||
/* OK, we processed one iMCU row. */
|
||||
@@ -587,7 +585,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
|
||||
jpeg_start_output(j_decompress_ptr cinfo, int scan_number)
|
||||
{
|
||||
if (cinfo->global_state != DSTATE_BUFIMAGE &&
|
||||
cinfo->global_state != DSTATE_PRESCAN)
|
||||
@@ -595,8 +593,7 @@ jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
|
||||
/* Limit scan number to valid range */
|
||||
if (scan_number <= 0)
|
||||
scan_number = 1;
|
||||
if (cinfo->inputctl->eoi_reached &&
|
||||
scan_number > cinfo->input_scan_number)
|
||||
if (cinfo->inputctl->eoi_reached && scan_number > cinfo->input_scan_number)
|
||||
scan_number = cinfo->input_scan_number;
|
||||
cinfo->output_scan_number = scan_number;
|
||||
/* Perform any dummy output passes, and set up for the real pass */
|
||||
@@ -612,7 +609,7 @@ jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_finish_output (j_decompress_ptr cinfo)
|
||||
jpeg_finish_output(j_decompress_ptr cinfo)
|
||||
{
|
||||
if ((cinfo->global_state == DSTATE_SCANNING ||
|
||||
cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {
|
||||
@@ -626,7 +623,7 @@ jpeg_finish_output (j_decompress_ptr cinfo)
|
||||
}
|
||||
/* Read markers looking for SOS or EOI */
|
||||
while (cinfo->input_scan_number <= cinfo->output_scan_number &&
|
||||
! cinfo->inputctl->eoi_reached) {
|
||||
!cinfo->inputctl->eoi_reached) {
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return FALSE; /* Suspend, come back later */
|
||||
}
|
||||
|
||||
81
jdarith.c
81
jdarith.c
@@ -68,13 +68,13 @@ typedef arith_entropy_decoder *arith_entropy_ptr;
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
get_byte (j_decompress_ptr cinfo)
|
||||
get_byte(j_decompress_ptr cinfo)
|
||||
/* Read next input byte; we do not support suspension in this module. */
|
||||
{
|
||||
struct jpeg_source_mgr *src = cinfo->src;
|
||||
|
||||
if (src->bytes_in_buffer == 0)
|
||||
if (! (*src->fill_input_buffer) (cinfo))
|
||||
if (!(*src->fill_input_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
src->bytes_in_buffer--;
|
||||
return GETJOCTET(*src->next_input_byte++);
|
||||
@@ -109,9 +109,9 @@ get_byte (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
arith_decode (j_decompress_ptr cinfo, unsigned char *st)
|
||||
arith_decode(j_decompress_ptr cinfo, unsigned char *st)
|
||||
{
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
|
||||
register unsigned char nl, nm;
|
||||
register JLONG qe, temp;
|
||||
register int sv, data;
|
||||
@@ -193,14 +193,14 @@ arith_decode (j_decompress_ptr cinfo, unsigned char *st)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
process_restart (j_decompress_ptr cinfo)
|
||||
process_restart(j_decompress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
if (!(*cinfo->marker->read_restart_marker) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
|
||||
/* Re-initialize statistics areas */
|
||||
@@ -244,9 +244,9 @@ process_restart (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int blkn, ci, tbl, sign;
|
||||
@@ -294,9 +294,9 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
|
||||
else
|
||||
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
|
||||
@@ -310,7 +310,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
|
||||
(*block)[0] = (JCOEF)LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -323,9 +323,9 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, sign, k;
|
||||
@@ -385,7 +385,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) ((unsigned)v << cinfo->Al);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)((unsigned)v << cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -397,9 +397,9 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
unsigned char *st;
|
||||
int p1, blkn;
|
||||
|
||||
@@ -430,9 +430,9 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
JCOEFPTR thiscoef;
|
||||
unsigned char *st;
|
||||
@@ -499,9 +499,9 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
jpeg_component_info *compptr;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
@@ -552,9 +552,9 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
|
||||
else
|
||||
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
|
||||
@@ -568,7 +568,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
if (block)
|
||||
(*block)[0] = (JCOEF) entropy->last_dc_val[ci];
|
||||
(*block)[0] = (JCOEF)entropy->last_dc_val[ci];
|
||||
|
||||
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
|
||||
|
||||
@@ -613,7 +613,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
if (block)
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) v;
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,9 +626,9 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass (j_decompress_ptr cinfo)
|
||||
start_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@@ -647,11 +647,11 @@ start_pass (j_decompress_ptr cinfo)
|
||||
}
|
||||
if (cinfo->Ah != 0) {
|
||||
/* Successive approximation refinement scan: must have Al = Ah-1. */
|
||||
if (cinfo->Ah-1 != cinfo->Al)
|
||||
if (cinfo->Ah - 1 != cinfo->Al)
|
||||
goto bad;
|
||||
}
|
||||
if (cinfo->Al > 13) { /* need not check for < 0 */
|
||||
bad:
|
||||
bad:
|
||||
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
|
||||
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
|
||||
}
|
||||
@@ -661,7 +661,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
|
||||
int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
|
||||
int *coef_bit_ptr = &cinfo->coef_bits[cindex][0];
|
||||
if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
|
||||
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
|
||||
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
|
||||
@@ -702,8 +702,8 @@ start_pass (j_decompress_ptr cinfo)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->dc_stats[tbl] == NULL)
|
||||
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->last_dc_val[ci] = 0;
|
||||
@@ -714,8 +714,8 @@ start_pass (j_decompress_ptr cinfo)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->ac_stats[tbl] == NULL)
|
||||
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
|
||||
}
|
||||
}
|
||||
@@ -735,15 +735,15 @@ start_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
jinit_arith_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(arith_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
@@ -759,9 +759,10 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
/* Create progression status table */
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*sizeof(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 *
|
||||
sizeof(int));
|
||||
coef_bit_ptr = &cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
*coef_bit_ptr++ = -1;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "jerror.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ typedef my_mem_destination_mgr *my_mem_dest_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
init_mem_destination (j_compress_ptr cinfo)
|
||||
init_mem_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@@ -84,17 +84,17 @@ init_mem_destination (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
empty_mem_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
size_t nextsize;
|
||||
JOCTET *nextbuffer;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
|
||||
if (!dest->alloc) ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
/* Try to allocate new buffer with double size */
|
||||
nextsize = dest->bufsize * 2;
|
||||
nextbuffer = (JOCTET *) malloc(nextsize);
|
||||
nextbuffer = (JOCTET *)malloc(nextsize);
|
||||
|
||||
if (nextbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
@@ -126,9 +126,9 @@ empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
term_mem_destination (j_compress_ptr cinfo)
|
||||
term_mem_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
|
||||
if (dest->alloc) *dest->outbuffer = dest->buffer;
|
||||
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
|
||||
@@ -147,9 +147,8 @@ term_mem_destination (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_dest_tj (j_compress_ptr cinfo,
|
||||
unsigned char **outbuffer, unsigned long *outsize,
|
||||
boolean alloc)
|
||||
jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
unsigned long *outsize, boolean alloc)
|
||||
{
|
||||
boolean reused = FALSE;
|
||||
my_mem_dest_ptr dest;
|
||||
@@ -162,9 +161,9 @@ jpeg_mem_dest_tj (j_compress_ptr cinfo,
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_mem_destination_mgr));
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
dest->newbuffer = NULL;
|
||||
dest->buffer = NULL;
|
||||
} else if (cinfo->dest->init_destination != init_mem_destination) {
|
||||
@@ -174,7 +173,7 @@ jpeg_mem_dest_tj (j_compress_ptr cinfo,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
dest->pub.init_destination = init_mem_destination;
|
||||
dest->pub.empty_output_buffer = empty_mem_output_buffer;
|
||||
dest->pub.term_destination = term_mem_destination;
|
||||
@@ -187,12 +186,12 @@ jpeg_mem_dest_tj (j_compress_ptr cinfo,
|
||||
if (*outbuffer == NULL || *outsize == 0) {
|
||||
if (alloc) {
|
||||
/* Allocate initial buffer */
|
||||
dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
|
||||
dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
|
||||
if (dest->newbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
*outsize = OUTPUT_BUF_SIZE;
|
||||
}
|
||||
else ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer = *outbuffer;
|
||||
|
||||
48
jdatadst.c
48
jdatadst.c
@@ -24,8 +24,8 @@
|
||||
#include "jerror.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,13 +66,13 @@ typedef my_mem_destination_mgr *my_mem_dest_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
init_destination (j_compress_ptr cinfo)
|
||||
init_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||
|
||||
/* Allocate the output buffer --- it will be released when done with image */
|
||||
dest->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * sizeof(JOCTET));
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
@@ -81,7 +81,7 @@ init_destination (j_compress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(void)
|
||||
init_mem_destination (j_compress_ptr cinfo)
|
||||
init_mem_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@@ -112,12 +112,12 @@ init_mem_destination (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
empty_output_buffer (j_compress_ptr cinfo)
|
||||
empty_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||
|
||||
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
|
||||
(size_t) OUTPUT_BUF_SIZE)
|
||||
(size_t)OUTPUT_BUF_SIZE)
|
||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
@@ -128,15 +128,15 @@ empty_output_buffer (j_compress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(boolean)
|
||||
empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
empty_mem_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
size_t nextsize;
|
||||
JOCTET *nextbuffer;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
|
||||
/* Try to allocate new buffer with double size */
|
||||
nextsize = dest->bufsize * 2;
|
||||
nextbuffer = (JOCTET *) malloc(nextsize);
|
||||
nextbuffer = (JOCTET *)malloc(nextsize);
|
||||
|
||||
if (nextbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
@@ -169,9 +169,9 @@ empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
term_destination (j_compress_ptr cinfo)
|
||||
term_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
|
||||
|
||||
/* Write any data remaining in the buffer */
|
||||
@@ -187,9 +187,9 @@ term_destination (j_compress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(void)
|
||||
term_mem_destination (j_compress_ptr cinfo)
|
||||
term_mem_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
|
||||
*dest->outbuffer = dest->buffer;
|
||||
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
|
||||
@@ -204,7 +204,7 @@ term_mem_destination (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
||||
{
|
||||
my_dest_ptr dest;
|
||||
|
||||
@@ -213,7 +213,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_destination_mgr));
|
||||
} else if (cinfo->dest->init_destination != init_destination) {
|
||||
/* It is unsafe to reuse the existing destination manager unless it was
|
||||
@@ -225,7 +225,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
dest = (my_dest_ptr) cinfo->dest;
|
||||
dest = (my_dest_ptr)cinfo->dest;
|
||||
dest->pub.init_destination = init_destination;
|
||||
dest->pub.empty_output_buffer = empty_output_buffer;
|
||||
dest->pub.term_destination = term_destination;
|
||||
@@ -249,8 +249,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
unsigned char **outbuffer, unsigned long *outsize)
|
||||
jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
unsigned long *outsize)
|
||||
{
|
||||
my_mem_dest_ptr dest;
|
||||
|
||||
@@ -262,7 +262,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_mem_destination_mgr));
|
||||
} else if (cinfo->dest->init_destination != init_mem_destination) {
|
||||
/* It is unsafe to reuse the existing destination manager unless it was
|
||||
@@ -271,7 +271,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
dest->pub.init_destination = init_mem_destination;
|
||||
dest->pub.empty_output_buffer = empty_mem_output_buffer;
|
||||
dest->pub.term_destination = term_mem_destination;
|
||||
@@ -281,7 +281,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
|
||||
if (*outbuffer == NULL || *outsize == 0) {
|
||||
/* Allocate initial buffer */
|
||||
dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
|
||||
dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
|
||||
if (dest->newbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
*outsize = OUTPUT_BUF_SIZE;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
init_mem_source (j_decompress_ptr cinfo)
|
||||
init_mem_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@@ -70,10 +70,10 @@ init_mem_source (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
fill_mem_input_buffer(j_decompress_ptr cinfo)
|
||||
{
|
||||
static const JOCTET mybuffer[4] = {
|
||||
(JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0
|
||||
(JOCTET)0xFF, (JOCTET)JPEG_EOI, 0, 0
|
||||
};
|
||||
|
||||
/* The whole JPEG data is expected to reside in the supplied memory
|
||||
@@ -104,7 +104,7 @@ fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
|
||||
{
|
||||
struct jpeg_source_mgr *src = cinfo->src;
|
||||
|
||||
@@ -113,15 +113,15 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
* any trouble anyway --- large skips are infrequent.
|
||||
*/
|
||||
if (num_bytes > 0) {
|
||||
while (num_bytes > (long) src->bytes_in_buffer) {
|
||||
num_bytes -= (long) src->bytes_in_buffer;
|
||||
(void) (*src->fill_input_buffer) (cinfo);
|
||||
while (num_bytes > (long)src->bytes_in_buffer) {
|
||||
num_bytes -= (long)src->bytes_in_buffer;
|
||||
(void)(*src->fill_input_buffer) (cinfo);
|
||||
/* note we assume that fill_input_buffer will never return FALSE,
|
||||
* so suspension need not be handled.
|
||||
*/
|
||||
}
|
||||
src->next_input_byte += (size_t) num_bytes;
|
||||
src->bytes_in_buffer -= (size_t) num_bytes;
|
||||
src->next_input_byte += (size_t)num_bytes;
|
||||
src->bytes_in_buffer -= (size_t)num_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
term_source (j_decompress_ptr cinfo)
|
||||
term_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@@ -157,8 +157,8 @@ term_source (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_src_tj (j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer, unsigned long insize)
|
||||
jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
|
||||
unsigned long insize)
|
||||
{
|
||||
struct jpeg_source_mgr *src;
|
||||
|
||||
@@ -171,7 +171,7 @@ jpeg_mem_src_tj (j_decompress_ptr cinfo,
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(struct jpeg_source_mgr));
|
||||
} else if (cinfo->src->init_source != init_mem_source) {
|
||||
/* It is unsafe to reuse the existing source manager unless it was created
|
||||
@@ -186,6 +186,6 @@ jpeg_mem_src_tj (j_decompress_ptr cinfo,
|
||||
src->skip_input_data = skip_input_data;
|
||||
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
|
||||
src->term_source = term_source;
|
||||
src->bytes_in_buffer = (size_t) insize;
|
||||
src->next_input_byte = (const JOCTET *) inbuffer;
|
||||
src->bytes_in_buffer = (size_t)insize;
|
||||
src->next_input_byte = (const JOCTET *)inbuffer;
|
||||
}
|
||||
|
||||
52
jdatasrc.c
52
jdatasrc.c
@@ -45,9 +45,9 @@ typedef my_source_mgr *my_src_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
init_source (j_decompress_ptr cinfo)
|
||||
init_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_src_ptr src = (my_src_ptr) cinfo->src;
|
||||
my_src_ptr src = (my_src_ptr)cinfo->src;
|
||||
|
||||
/* We reset the empty-input-file flag for each image,
|
||||
* but we don't clear the input buffer.
|
||||
@@ -58,7 +58,7 @@ init_source (j_decompress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(void)
|
||||
init_mem_source (j_decompress_ptr cinfo)
|
||||
init_mem_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@@ -99,9 +99,9 @@ init_mem_source (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
fill_input_buffer (j_decompress_ptr cinfo)
|
||||
fill_input_buffer(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_src_ptr src = (my_src_ptr) cinfo->src;
|
||||
my_src_ptr src = (my_src_ptr)cinfo->src;
|
||||
size_t nbytes;
|
||||
|
||||
nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE);
|
||||
@@ -111,8 +111,8 @@ fill_input_buffer (j_decompress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_INPUT_EMPTY);
|
||||
WARNMS(cinfo, JWRN_JPEG_EOF);
|
||||
/* Insert a fake EOI marker */
|
||||
src->buffer[0] = (JOCTET) 0xFF;
|
||||
src->buffer[1] = (JOCTET) JPEG_EOI;
|
||||
src->buffer[0] = (JOCTET)0xFF;
|
||||
src->buffer[1] = (JOCTET)JPEG_EOI;
|
||||
nbytes = 2;
|
||||
}
|
||||
|
||||
@@ -125,10 +125,10 @@ fill_input_buffer (j_decompress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(boolean)
|
||||
fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
fill_mem_input_buffer(j_decompress_ptr cinfo)
|
||||
{
|
||||
static const JOCTET mybuffer[4] = {
|
||||
(JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0
|
||||
(JOCTET)0xFF, (JOCTET)JPEG_EOI, 0, 0
|
||||
};
|
||||
|
||||
/* The whole JPEG data is expected to reside in the supplied memory
|
||||
@@ -160,7 +160,7 @@ fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
|
||||
{
|
||||
struct jpeg_source_mgr *src = cinfo->src;
|
||||
|
||||
@@ -169,15 +169,15 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
* any trouble anyway --- large skips are infrequent.
|
||||
*/
|
||||
if (num_bytes > 0) {
|
||||
while (num_bytes > (long) src->bytes_in_buffer) {
|
||||
num_bytes -= (long) src->bytes_in_buffer;
|
||||
(void) (*src->fill_input_buffer) (cinfo);
|
||||
while (num_bytes > (long)src->bytes_in_buffer) {
|
||||
num_bytes -= (long)src->bytes_in_buffer;
|
||||
(void)(*src->fill_input_buffer) (cinfo);
|
||||
/* note we assume that fill_input_buffer will never return FALSE,
|
||||
* so suspension need not be handled.
|
||||
*/
|
||||
}
|
||||
src->next_input_byte += (size_t) num_bytes;
|
||||
src->bytes_in_buffer -= (size_t) num_bytes;
|
||||
src->next_input_byte += (size_t)num_bytes;
|
||||
src->bytes_in_buffer -= (size_t)num_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
term_source (j_decompress_ptr cinfo)
|
||||
term_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@@ -214,7 +214,7 @@ term_source (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
|
||||
{
|
||||
my_src_ptr src;
|
||||
|
||||
@@ -225,11 +225,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_source_mgr));
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src = (my_src_ptr)cinfo->src;
|
||||
src->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
INPUT_BUF_SIZE * sizeof(JOCTET));
|
||||
} else if (cinfo->src->init_source != init_source) {
|
||||
/* It is unsafe to reuse the existing source manager unless it was created
|
||||
@@ -241,7 +241,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src = (my_src_ptr)cinfo->src;
|
||||
src->pub.init_source = init_source;
|
||||
src->pub.fill_input_buffer = fill_input_buffer;
|
||||
src->pub.skip_input_data = skip_input_data;
|
||||
@@ -260,8 +260,8 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer, unsigned long insize)
|
||||
jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *inbuffer,
|
||||
unsigned long insize)
|
||||
{
|
||||
struct jpeg_source_mgr *src;
|
||||
|
||||
@@ -274,7 +274,7 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(struct jpeg_source_mgr));
|
||||
} else if (cinfo->src->init_source != init_mem_source) {
|
||||
/* It is unsafe to reuse the existing source manager unless it was created
|
||||
@@ -289,7 +289,7 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
src->skip_input_data = skip_input_data;
|
||||
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
|
||||
src->term_source = term_source;
|
||||
src->bytes_in_buffer = (size_t) insize;
|
||||
src->next_input_byte = (const JOCTET *) inbuffer;
|
||||
src->bytes_in_buffer = (size_t)insize;
|
||||
src->next_input_byte = (const JOCTET *)inbuffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
235
jdcoefct.c
235
jdcoefct.c
@@ -25,16 +25,15 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(int) decompress_onepass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
METHODDEF(int) decompress_onepass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE output_buf);
|
||||
#ifdef D_MULTISCAN_FILES_SUPPORTED
|
||||
METHODDEF(int) decompress_data
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
METHODDEF(int) decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
#endif
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
LOCAL(boolean) smoothing_ok (j_decompress_ptr cinfo);
|
||||
METHODDEF(int) decompress_smooth_data
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
LOCAL(boolean) smoothing_ok(j_decompress_ptr cinfo);
|
||||
METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE output_buf);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -43,7 +42,7 @@ METHODDEF(int) decompress_smooth_data
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_input_pass (j_decompress_ptr cinfo)
|
||||
start_input_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
cinfo->input_iMCU_row = 0;
|
||||
start_iMCU_row(cinfo);
|
||||
@@ -55,10 +54,10 @@ start_input_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_output_pass (j_decompress_ptr cinfo)
|
||||
start_output_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* If multipass, check to see whether to use block smoothing on this pass */
|
||||
if (coef->pub.coef_arrays != NULL) {
|
||||
@@ -83,9 +82,9 @@ start_output_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
@@ -101,9 +100,9 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||
MCU_col_num++) {
|
||||
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
||||
jzero_far((void *) coef->MCU_buffer[0],
|
||||
(size_t) (cinfo->blocks_in_MCU * sizeof(JBLOCK)));
|
||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
jzero_far((void *)coef->MCU_buffer[0],
|
||||
(size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
|
||||
if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->MCU_ctr = MCU_col_num;
|
||||
@@ -124,24 +123,24 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
/* Don't bother to IDCT an uninteresting component. */
|
||||
if (! compptr->component_needed) {
|
||||
if (!compptr->component_needed) {
|
||||
blkn += compptr->MCU_blocks;
|
||||
continue;
|
||||
}
|
||||
inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
|
||||
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||
: compptr->last_col_width;
|
||||
useful_width = (MCU_col_num < last_MCU_col) ?
|
||||
compptr->MCU_width : compptr->last_col_width;
|
||||
output_ptr = output_buf[compptr->component_index] +
|
||||
yoffset * compptr->_DCT_scaled_size;
|
||||
start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
|
||||
compptr->MCU_sample_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
if (cinfo->input_iMCU_row < last_iMCU_row ||
|
||||
yoffset+yindex < compptr->last_row_height) {
|
||||
yoffset + yindex < compptr->last_row_height) {
|
||||
output_col = start_col;
|
||||
for (xindex = 0; xindex < useful_width; xindex++) {
|
||||
(*inverse_DCT) (cinfo, compptr,
|
||||
(JCOEFPTR) coef->MCU_buffer[blkn+xindex],
|
||||
(JCOEFPTR)coef->MCU_buffer[blkn + xindex],
|
||||
output_ptr, output_col);
|
||||
output_col += compptr->_DCT_scaled_size;
|
||||
}
|
||||
@@ -172,7 +171,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
dummy_consume_data (j_decompress_ptr cinfo)
|
||||
dummy_consume_data(j_decompress_ptr cinfo)
|
||||
{
|
||||
return JPEG_SUSPENDED; /* Always indicate nothing was done */
|
||||
}
|
||||
@@ -188,9 +187,9 @@ dummy_consume_data (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
consume_data (j_decompress_ptr cinfo)
|
||||
consume_data(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
int blkn, ci, xindex, yindex, yoffset;
|
||||
JDIMENSION start_col;
|
||||
@@ -202,9 +201,9 @@ consume_data (j_decompress_ptr cinfo)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
||||
cinfo->input_iMCU_row * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||
(JDIMENSION)compptr->v_samp_factor, TRUE);
|
||||
/* Note: entropy decoder expects buffer to be zeroed,
|
||||
* but this is handled automatically by the memory manager
|
||||
* because we requested a pre-zeroed array.
|
||||
@@ -222,14 +221,14 @@ consume_data (j_decompress_ptr cinfo)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
start_col = MCU_col_num * compptr->MCU_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
||||
for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
||||
coef->MCU_buffer[blkn++] = buffer_ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to fetch the MCU. */
|
||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->MCU_ctr = MCU_col_num;
|
||||
@@ -259,9 +258,9 @@ consume_data (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
JDIMENSION block_num;
|
||||
int ci, block_row, block_rows;
|
||||
@@ -276,7 +275,7 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
while (cinfo->input_scan_number < cinfo->output_scan_number ||
|
||||
(cinfo->input_scan_number == cinfo->output_scan_number &&
|
||||
cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
|
||||
if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return JPEG_SUSPENDED;
|
||||
}
|
||||
|
||||
@@ -284,19 +283,19 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Don't bother to IDCT an uninteresting component. */
|
||||
if (! compptr->component_needed)
|
||||
if (!compptr->component_needed)
|
||||
continue;
|
||||
/* Align the virtual buffer for this component. */
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
cinfo->output_iMCU_row * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||
if (cinfo->output_iMCU_row < last_iMCU_row)
|
||||
block_rows = compptr->v_samp_factor;
|
||||
else {
|
||||
/* NB: can't use last_row_height here; it is input-side-dependent! */
|
||||
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||
}
|
||||
inverse_DCT = cinfo->idct->inverse_DCT[ci];
|
||||
@@ -307,8 +306,8 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
output_col = 0;
|
||||
for (block_num = cinfo->master->first_MCU_col[ci];
|
||||
block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
|
||||
output_ptr, output_col);
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
|
||||
output_col);
|
||||
buffer_ptr++;
|
||||
output_col += compptr->_DCT_scaled_size;
|
||||
}
|
||||
@@ -350,9 +349,9 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
smoothing_ok (j_decompress_ptr cinfo)
|
||||
smoothing_ok(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
boolean smoothing_useful = FALSE;
|
||||
int ci, coefi;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -360,13 +359,13 @@ smoothing_ok (j_decompress_ptr cinfo)
|
||||
int *coef_bits;
|
||||
int *coef_bits_latch;
|
||||
|
||||
if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
|
||||
if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Allocate latch area if not already done */
|
||||
if (coef->coef_bits_latch == NULL)
|
||||
coef->coef_bits_latch = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components *
|
||||
(SAVED_COEFS * sizeof(int)));
|
||||
coef_bits_latch = coef->coef_bits_latch;
|
||||
@@ -406,9 +405,9 @@ smoothing_ok (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
JDIMENSION block_num, last_block_column;
|
||||
int ci, block_row, block_rows, access_rows;
|
||||
@@ -422,8 +421,8 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
JCOEF *workspace;
|
||||
int *coef_bits;
|
||||
JQUANT_TBL *quanttbl;
|
||||
JLONG Q00,Q01,Q02,Q10,Q11,Q20, num;
|
||||
int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
|
||||
JLONG Q00, Q01, Q02, Q10, Q11, Q20, num;
|
||||
int DC1, DC2, DC3, DC4, DC5, DC6, DC7, DC8, DC9;
|
||||
int Al, pred;
|
||||
|
||||
/* Keep a local variable to avoid looking it up more than once */
|
||||
@@ -431,7 +430,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
|
||||
/* Force some input to be done if we are getting ahead of the input. */
|
||||
while (cinfo->input_scan_number <= cinfo->output_scan_number &&
|
||||
! cinfo->inputctl->eoi_reached) {
|
||||
!cinfo->inputctl->eoi_reached) {
|
||||
if (cinfo->input_scan_number == cinfo->output_scan_number) {
|
||||
/* If input is working on current scan, we ordinarily want it to
|
||||
* have completed the current row. But if input scan is DC,
|
||||
@@ -439,10 +438,10 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
* values are up to date.
|
||||
*/
|
||||
JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
|
||||
if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
|
||||
if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
|
||||
break;
|
||||
}
|
||||
if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return JPEG_SUSPENDED;
|
||||
}
|
||||
|
||||
@@ -450,7 +449,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Don't bother to IDCT an uninteresting component. */
|
||||
if (! compptr->component_needed)
|
||||
if (!compptr->component_needed)
|
||||
continue;
|
||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||
if (cinfo->output_iMCU_row < last_iMCU_row) {
|
||||
@@ -459,7 +458,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
last_row = FALSE;
|
||||
} else {
|
||||
/* NB: can't use last_row_height here; it is input-side-dependent! */
|
||||
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||
access_rows = block_rows; /* this iMCU row only */
|
||||
last_row = TRUE;
|
||||
@@ -468,15 +467,15 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
if (cinfo->output_iMCU_row > 0) {
|
||||
access_rows += compptr->v_samp_factor; /* prior iMCU row too */
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
(cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
|
||||
(JDIMENSION) access_rows, FALSE);
|
||||
(JDIMENSION)access_rows, FALSE);
|
||||
buffer += compptr->v_samp_factor; /* point to current iMCU row */
|
||||
first_row = FALSE;
|
||||
} else {
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
(JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
(JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
|
||||
first_row = TRUE;
|
||||
}
|
||||
/* Fetch component-dependent info */
|
||||
@@ -496,111 +495,111 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
if (first_row && block_row == 0)
|
||||
prev_block_row = buffer_ptr;
|
||||
else
|
||||
prev_block_row = buffer[block_row-1];
|
||||
if (last_row && block_row == block_rows-1)
|
||||
prev_block_row = buffer[block_row - 1];
|
||||
if (last_row && block_row == block_rows - 1)
|
||||
next_block_row = buffer_ptr;
|
||||
else
|
||||
next_block_row = buffer[block_row+1];
|
||||
next_block_row = buffer[block_row + 1];
|
||||
/* We fetch the surrounding DC values using a sliding-register approach.
|
||||
* Initialize all nine here so as to do the right thing on narrow pics.
|
||||
*/
|
||||
DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
|
||||
DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
|
||||
DC7 = DC8 = DC9 = (int) next_block_row[0][0];
|
||||
DC1 = DC2 = DC3 = (int)prev_block_row[0][0];
|
||||
DC4 = DC5 = DC6 = (int)buffer_ptr[0][0];
|
||||
DC7 = DC8 = DC9 = (int)next_block_row[0][0];
|
||||
output_col = 0;
|
||||
last_block_column = compptr->width_in_blocks - 1;
|
||||
for (block_num = cinfo->master->first_MCU_col[ci];
|
||||
block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
|
||||
/* Fetch current DCT block into workspace so we can modify it. */
|
||||
jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
|
||||
jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
|
||||
/* Update DC values */
|
||||
if (block_num < last_block_column) {
|
||||
DC3 = (int) prev_block_row[1][0];
|
||||
DC6 = (int) buffer_ptr[1][0];
|
||||
DC9 = (int) next_block_row[1][0];
|
||||
DC3 = (int)prev_block_row[1][0];
|
||||
DC6 = (int)buffer_ptr[1][0];
|
||||
DC9 = (int)next_block_row[1][0];
|
||||
}
|
||||
/* Compute coefficient estimates per K.8.
|
||||
* An estimate is applied only if coefficient is still zero,
|
||||
* and is not known to be fully accurate.
|
||||
*/
|
||||
/* AC01 */
|
||||
if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
|
||||
if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
|
||||
num = 36 * Q00 * (DC4 - DC6);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q01<<7) + num) / (Q01<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q01<<7) - num) / (Q01<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[1] = (JCOEF) pred;
|
||||
workspace[1] = (JCOEF)pred;
|
||||
}
|
||||
/* AC10 */
|
||||
if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
|
||||
if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
|
||||
num = 36 * Q00 * (DC2 - DC8);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q10<<7) + num) / (Q10<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q10<<7) - num) / (Q10<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[8] = (JCOEF) pred;
|
||||
workspace[8] = (JCOEF)pred;
|
||||
}
|
||||
/* AC20 */
|
||||
if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
|
||||
num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
|
||||
if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
|
||||
num = 9 * Q00 * (DC2 + DC8 - 2 * DC5);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q20<<7) + num) / (Q20<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q20<<7) - num) / (Q20<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[16] = (JCOEF) pred;
|
||||
workspace[16] = (JCOEF)pred;
|
||||
}
|
||||
/* AC11 */
|
||||
if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
|
||||
if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
|
||||
num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q11<<7) + num) / (Q11<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q11<<7) - num) / (Q11<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[9] = (JCOEF) pred;
|
||||
workspace[9] = (JCOEF)pred;
|
||||
}
|
||||
/* AC02 */
|
||||
if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
|
||||
num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
|
||||
if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
|
||||
num = 9 * Q00 * (DC4 + DC6 - 2 * DC5);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q02<<7) + num) / (Q02<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q02<<7) - num) / (Q02<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[2] = (JCOEF) pred;
|
||||
workspace[2] = (JCOEF)pred;
|
||||
}
|
||||
/* OK, do the IDCT */
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
|
||||
output_ptr, output_col);
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
|
||||
output_col);
|
||||
/* Advance for next column */
|
||||
DC1 = DC2; DC2 = DC3;
|
||||
DC4 = DC5; DC5 = DC6;
|
||||
@@ -625,14 +624,14 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_coef_ptr coef;
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_d_coef_controller *) coef;
|
||||
cinfo->coef = (struct jpeg_d_coef_controller *)coef;
|
||||
coef->pub.start_input_pass = start_input_pass;
|
||||
coef->pub.start_output_pass = start_output_pass;
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
@@ -657,12 +656,12 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
access_rows *= 3;
|
||||
#endif
|
||||
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
|
||||
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
||||
(long) compptr->h_samp_factor),
|
||||
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||
(long) compptr->v_samp_factor),
|
||||
(JDIMENSION) access_rows);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
|
||||
(JDIMENSION)jround_up((long)compptr->width_in_blocks,
|
||||
(long)compptr->h_samp_factor),
|
||||
(JDIMENSION)jround_up((long)compptr->height_in_blocks,
|
||||
(long)compptr->v_samp_factor),
|
||||
(JDIMENSION)access_rows);
|
||||
}
|
||||
coef->pub.consume_data = consume_data;
|
||||
coef->pub.decompress_data = decompress_data;
|
||||
@@ -676,7 +675,7 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
int i;
|
||||
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
@@ -688,6 +687,6 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
/* Allocate the workspace buffer */
|
||||
coef->workspace = (JCOEF *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(JCOEF) * DCTSIZE2);
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ typedef my_coef_controller *my_coef_ptr;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
start_iMCU_row (j_decompress_ptr cinfo)
|
||||
start_iMCU_row(j_decompress_ptr cinfo)
|
||||
/* Reset within-iMCU-row counters for a new row (input side) */
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||
@@ -71,7 +71,7 @@ start_iMCU_row (j_decompress_ptr cinfo)
|
||||
if (cinfo->comps_in_scan > 1) {
|
||||
coef->MCU_rows_per_iMCU_row = 1;
|
||||
} else {
|
||||
if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
|
||||
if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||
else
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||
|
||||
88
jdcol565.c
88
jdcol565.c
@@ -17,22 +17,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register int * Crrtab = cconvert->Cr_r_tab;
|
||||
register int * Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG * Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG * Cbgtab = cconvert->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
register int *Crrtab = cconvert->Cr_r_tab;
|
||||
register int *Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
@@ -53,7 +53,7 @@ ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,22 +96,22 @@ ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register int * Crrtab = cconvert->Cr_r_tab;
|
||||
register int * Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG * Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG * Cbgtab = cconvert->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
register int *Crrtab = cconvert->Cr_r_tab;
|
||||
register int *Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
SHIFT_TEMPS
|
||||
|
||||
@@ -134,7 +134,7 @@ ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,9 +182,9 @@ ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
@@ -206,7 +206,7 @@ rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
g = GETJSAMPLE(*inptr1++);
|
||||
b = GETJSAMPLE(*inptr2++);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
g = GETJSAMPLE(*inptr1);
|
||||
b = GETJSAMPLE(*inptr2);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,14 +237,14 @@ rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
SHIFT_TEMPS
|
||||
@@ -263,7 +263,7 @@ rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1++), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2++), d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2), d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,9 +296,9 @@ rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -313,7 +313,7 @@ gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
g = *inptr++;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
if (num_cols & 1) {
|
||||
g = *inptr;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,13 +336,13 @@ gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
|
||||
@@ -356,7 +356,7 @@ gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = *inptr++;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = *inptr;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
jdcolext.c
32
jdcolext.c
@@ -28,22 +28,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register int * Crrtab = cconvert->Cr_r_tab;
|
||||
register int * Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG * Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG * Cbgtab = cconvert->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
register int *Crrtab = cconvert->Cr_r_tab;
|
||||
register int *Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
@@ -59,7 +59,7 @@ ycc_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
||||
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
|
||||
outptr[RGB_GREEN] = range_limit[y +
|
||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
|
||||
/* Set unused byte to 0xFF so it can be interpreted as an opaque */
|
||||
@@ -81,9 +81,9 @@ ycc_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -112,9 +112,9 @@ gray_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JSAMPROW outptr;
|
||||
|
||||
134
jdcolor.c
134
jdcolor.c
@@ -74,8 +74,8 @@ typedef my_color_deconverter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
/* We allocate one big table for RGB->Y conversion and divide it up into
|
||||
* three parts, instead of doing three alloc_small requests. This lets us
|
||||
@@ -85,9 +85,9 @@ typedef my_color_deconverter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define R_Y_OFF 0 /* offset to R => Y section */
|
||||
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
|
||||
#define TABLE_SIZE (3*(MAXJSAMPLE+1))
|
||||
#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
|
||||
#define TABLE_SIZE (3 * (MAXJSAMPLE + 1))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
@@ -208,25 +208,25 @@ typedef my_color_deconverter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
cconvert->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
cconvert->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
cconvert->Cr_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
cconvert->Cb_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
@@ -238,10 +238,10 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
cconvert->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
cconvert->Cr_g_tab[i] = (-FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
cconvert->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,9 +251,8 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -300,21 +299,21 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
build_rgb_y_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
JLONG *rgb_y_tab;
|
||||
JLONG i;
|
||||
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_y_tab = rgb_y_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * sizeof(JLONG)));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_y_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_y_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_y_tab[i + R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_y_tab[i + G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_y_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,11 +323,10 @@ build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_gray_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG *ctab = cconvert->rgb_y_tab;
|
||||
register JSAMPROW outptr;
|
||||
@@ -347,9 +345,8 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
g = GETJSAMPLE(inptr1[col]);
|
||||
b = GETJSAMPLE(inptr2[col]);
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,9 +358,8 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
null_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
null_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -423,12 +419,11 @@ null_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
grayscale_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
grayscale_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,
|
||||
num_rows, cinfo->output_width);
|
||||
jcopy_sample_rows(input_buf[0], (int)input_row, output_buf, 0, num_rows,
|
||||
cinfo->output_width);
|
||||
}
|
||||
|
||||
|
||||
@@ -437,9 +432,8 @@ grayscale_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -483,9 +477,8 @@ gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -532,11 +525,10 @@ rgb_rgb_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2, inptr3;
|
||||
@@ -564,7 +556,7 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
||||
outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
|
||||
outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
|
||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS)))];
|
||||
outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */
|
||||
/* K passes through unchanged */
|
||||
@@ -662,9 +654,8 @@ static INLINE boolean is_big_endian(void)
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
ycc_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@@ -674,9 +665,8 @@ ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
ycc_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@@ -686,9 +676,8 @@ ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
rgb_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@@ -698,9 +687,8 @@ rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
rgb_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@@ -710,9 +698,8 @@ rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
gray_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@@ -722,9 +709,8 @@ gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
gray_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@@ -738,7 +724,7 @@ gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_dcolor (j_decompress_ptr cinfo)
|
||||
start_pass_dcolor(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work needed */
|
||||
}
|
||||
@@ -749,15 +735,15 @@ start_pass_dcolor (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
jinit_color_deconverter(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert;
|
||||
int ci;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_color_deconverter));
|
||||
cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
|
||||
cinfo->cconvert = (struct jpeg_color_deconverter *)cconvert;
|
||||
cconvert->pub.start_pass = start_pass_dcolor;
|
||||
|
||||
/* Make sure num_components agrees with jpeg_color_space */
|
||||
|
||||
130
jdct.h
130
jdct.h
@@ -90,64 +90,64 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
|
||||
|
||||
/* Extern declarations for the forward and inverse DCT routines. */
|
||||
|
||||
EXTERN(void) jpeg_fdct_islow (DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_ifast (DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_float (FAST_FLOAT *data);
|
||||
EXTERN(void) jpeg_fdct_islow(DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_ifast(DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_float(FAST_FLOAT *data);
|
||||
|
||||
EXTERN(void) jpeg_idct_islow
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_ifast
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_float
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_7x7
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_6x6
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_5x5
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_4x4
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_3x3
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_2x2
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_1x1
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_9x9
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_10x10
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_11x11
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_12x12
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_13x13
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_14x14
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_15x15
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_16x16
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_islow(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_ifast(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_float(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_7x7(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_6x6(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_5x5(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_4x4(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_3x3(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_2x2(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_1x1(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_9x9(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_10x10(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_11x11(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_12x12(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_13x13(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_14x14(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_15x15(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_16x16(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
|
||||
|
||||
/*
|
||||
@@ -160,7 +160,7 @@ EXTERN(void) jpeg_idct_16x16
|
||||
* and may differ from one module to the next.
|
||||
*/
|
||||
|
||||
#define ONE ((JLONG) 1)
|
||||
#define ONE ((JLONG)1)
|
||||
#define CONST_SCALE (ONE << CONST_BITS)
|
||||
|
||||
/* Convert a positive real constant to an integer scaled by CONST_SCALE.
|
||||
@@ -168,14 +168,14 @@ EXTERN(void) jpeg_idct_16x16
|
||||
* thus causing a lot of useless floating-point operations at run time.
|
||||
*/
|
||||
|
||||
#define FIX(x) ((JLONG) ((x) * CONST_SCALE + 0.5))
|
||||
#define FIX(x) ((JLONG)((x) * CONST_SCALE + 0.5))
|
||||
|
||||
/* Descale and correctly round a JLONG value that's scaled by N bits.
|
||||
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
|
||||
* the fudge factor is correct for either sign of X.
|
||||
*/
|
||||
|
||||
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
|
||||
#define DESCALE(x, n) RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
|
||||
|
||||
/* Multiply a JLONG variable by a JLONG constant to yield a JLONG result.
|
||||
* This macro is used only when the two inputs will actually be no more than
|
||||
@@ -187,22 +187,22 @@ EXTERN(void) jpeg_idct_16x16
|
||||
*/
|
||||
|
||||
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
|
||||
#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const)))
|
||||
#define MULTIPLY16C16(var, const) (((INT16)(var)) * ((INT16)(const)))
|
||||
#endif
|
||||
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
|
||||
#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((JLONG) (const)))
|
||||
#define MULTIPLY16C16(var, const) (((INT16)(var)) * ((JLONG)(const)))
|
||||
#endif
|
||||
|
||||
#ifndef MULTIPLY16C16 /* default definition */
|
||||
#define MULTIPLY16C16(var,const) ((var) * (const))
|
||||
#define MULTIPLY16C16(var, const) ((var) * (const))
|
||||
#endif
|
||||
|
||||
/* Same except both inputs are variables. */
|
||||
|
||||
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
|
||||
#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2)))
|
||||
#define MULTIPLY16V16(var1, var2) (((INT16)(var1)) * ((INT16)(var2)))
|
||||
#endif
|
||||
|
||||
#ifndef MULTIPLY16V16 /* default definition */
|
||||
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
|
||||
#define MULTIPLY16V16(var1, var2) ((var1) * (var2))
|
||||
#endif
|
||||
|
||||
30
jddctmgr.c
30
jddctmgr.c
@@ -94,9 +94,9 @@ typedef union {
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass (j_decompress_ptr cinfo)
|
||||
start_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_idct_ptr idct = (my_idct_ptr) cinfo->idct;
|
||||
my_idct_ptr idct = (my_idct_ptr)cinfo->idct;
|
||||
int ci, i;
|
||||
jpeg_component_info *compptr;
|
||||
int method = 0;
|
||||
@@ -233,7 +233,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* multiplier table all-zero; we'll be reading zeroes from the
|
||||
* coefficient controller's buffer anyway.
|
||||
*/
|
||||
if (! compptr->component_needed || idct->cur_method[ci] == method)
|
||||
if (!compptr->component_needed || idct->cur_method[ci] == method)
|
||||
continue;
|
||||
qtbl = compptr->quant_table;
|
||||
if (qtbl == NULL) /* happens if no data yet for component */
|
||||
@@ -246,9 +246,9 @@ start_pass (j_decompress_ptr cinfo)
|
||||
/* For LL&M IDCT method, multipliers are equal to raw quantization
|
||||
* coefficients, but are stored as ints to ensure access efficiency.
|
||||
*/
|
||||
ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i];
|
||||
ismtbl[i] = (ISLOW_MULT_TYPE)qtbl->quantval[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -263,7 +263,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* For integer operation, the multiplier table is to be scaled by
|
||||
* IFAST_SCALE_BITS.
|
||||
*/
|
||||
IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table;
|
||||
IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *)compptr->dct_table;
|
||||
#define CONST_BITS 14
|
||||
static const INT16 aanscales[DCTSIZE2] = {
|
||||
/* precomputed values scaled up by 14 bits */
|
||||
@@ -280,9 +280,9 @@ start_pass (j_decompress_ptr cinfo)
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
ifmtbl[i] = (IFAST_MULT_TYPE)
|
||||
DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],
|
||||
(JLONG) aanscales[i]),
|
||||
CONST_BITS-IFAST_SCALE_BITS);
|
||||
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
|
||||
(JLONG)aanscales[i]),
|
||||
CONST_BITS - IFAST_SCALE_BITS);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -295,7 +295,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* scalefactor[0] = 1
|
||||
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
|
||||
*/
|
||||
FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;
|
||||
FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *)compptr->dct_table;
|
||||
int row, col;
|
||||
static const double aanscalefactor[DCTSIZE] = {
|
||||
1.0, 1.387039845, 1.306562965, 1.175875602,
|
||||
@@ -306,7 +306,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
for (row = 0; row < DCTSIZE; row++) {
|
||||
for (col = 0; col < DCTSIZE; col++) {
|
||||
fmtbl[i] = (FLOAT_MULT_TYPE)
|
||||
((double) qtbl->quantval[i] *
|
||||
((double)qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col]);
|
||||
i++;
|
||||
}
|
||||
@@ -327,23 +327,23 @@ start_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_inverse_dct (j_decompress_ptr cinfo)
|
||||
jinit_inverse_dct(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_idct_ptr idct;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
idct = (my_idct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_idct_controller));
|
||||
cinfo->idct = (struct jpeg_inverse_dct *) idct;
|
||||
cinfo->idct = (struct jpeg_inverse_dct *)idct;
|
||||
idct->pub.start_pass = start_pass;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Allocate and pre-zero a multiplier table for each component */
|
||||
compptr->dct_table =
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(multiplier_table));
|
||||
MEMZERO(compptr->dct_table, sizeof(multiplier_table));
|
||||
/* Mark multiplier table not yet set up for any method */
|
||||
|
||||
134
jdhuff.c
134
jdhuff.c
@@ -42,10 +42,10 @@ typedef struct {
|
||||
*/
|
||||
|
||||
#ifndef NO_STRUCT_ASSIGN
|
||||
#define ASSIGN_STATE(dest,src) ((dest) = (src))
|
||||
#define ASSIGN_STATE(dest, src) ((dest) = (src))
|
||||
#else
|
||||
#if MAX_COMPS_IN_SCAN == 4
|
||||
#define ASSIGN_STATE(dest,src) \
|
||||
#define ASSIGN_STATE(dest, src) \
|
||||
((dest).last_dc_val[0] = (src).last_dc_val[0], \
|
||||
(dest).last_dc_val[1] = (src).last_dc_val[1], \
|
||||
(dest).last_dc_val[2] = (src).last_dc_val[2], \
|
||||
@@ -88,9 +88,9 @@ typedef huff_entropy_decoder *huff_entropy_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
start_pass_huff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci, blkn, dctbl, actbl;
|
||||
d_derived_tbl **pdtbl;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -99,7 +99,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
* This ought to be an error condition, but we make it a warning because
|
||||
* there are some baseline files out there with all zeroes in these bytes.
|
||||
*/
|
||||
if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||
|
||||
if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2 - 1 ||
|
||||
cinfo->Ah != 0 || cinfo->Al != 0)
|
||||
WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
|
||||
|
||||
@@ -152,7 +152,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
d_derived_tbl **pdtbl)
|
||||
{
|
||||
JHUFF_TBL *htbl;
|
||||
@@ -178,7 +178,7 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (d_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(d_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
dtbl->pub = htbl; /* fill in back link */
|
||||
@@ -187,11 +187,11 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
|
||||
p = 0;
|
||||
for (l = 1; l <= 16; l++) {
|
||||
i = (int) htbl->bits[l];
|
||||
i = (int)htbl->bits[l];
|
||||
if (i < 0 || p + i > 256) /* protect against table overrun */
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
while (i--)
|
||||
huffsize[p++] = (char) l;
|
||||
huffsize[p++] = (char)l;
|
||||
}
|
||||
huffsize[p] = 0;
|
||||
numsymbols = p;
|
||||
@@ -203,14 +203,14 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
si = huffsize[0];
|
||||
p = 0;
|
||||
while (huffsize[p]) {
|
||||
while (((int) huffsize[p]) == si) {
|
||||
while (((int)huffsize[p]) == si) {
|
||||
huffcode[p++] = code;
|
||||
code++;
|
||||
}
|
||||
/* code is now 1 more than the last code used for codelength si; but
|
||||
* it must still fit in si bits, since no code is allowed to be all ones.
|
||||
*/
|
||||
if (((JLONG) code) >= (((JLONG) 1) << si))
|
||||
if (((JLONG)code) >= (((JLONG)1) << si))
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
code <<= 1;
|
||||
si++;
|
||||
@@ -224,9 +224,9 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* valoffset[l] = huffval[] index of 1st symbol of code length l,
|
||||
* minus the minimum code of length l
|
||||
*/
|
||||
dtbl->valoffset[l] = (JLONG) p - (JLONG) huffcode[p];
|
||||
dtbl->valoffset[l] = (JLONG)p - (JLONG)huffcode[p];
|
||||
p += htbl->bits[l];
|
||||
dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */
|
||||
dtbl->maxcode[l] = huffcode[p - 1]; /* maximum code of length l */
|
||||
} else {
|
||||
dtbl->maxcode[l] = -1; /* -1 if no codes of this length */
|
||||
}
|
||||
@@ -246,11 +246,11 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
|
||||
p = 0;
|
||||
for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
|
||||
for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {
|
||||
for (i = 1; i <= (int)htbl->bits[l]; i++, p++) {
|
||||
/* l = current code's length, p = its index in huffcode[] & huffval[]. */
|
||||
/* Generate left-justified code followed by all possible bit sequences */
|
||||
lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
|
||||
for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
|
||||
lookbits = huffcode[p] << (HUFF_LOOKAHEAD - l);
|
||||
for (ctr = 1 << (HUFF_LOOKAHEAD - l); ctr > 0; ctr--) {
|
||||
dtbl->lookup[lookbits] = (l << HUFF_LOOKAHEAD) | htbl->huffval[p];
|
||||
lookbits++;
|
||||
}
|
||||
@@ -291,12 +291,12 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
#ifdef SLOW_SHIFT_32
|
||||
#define MIN_GET_BITS 15 /* minimum allowable value */
|
||||
#else
|
||||
#define MIN_GET_BITS (BIT_BUF_SIZE-7)
|
||||
#define MIN_GET_BITS (BIT_BUF_SIZE - 7)
|
||||
#endif
|
||||
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
jpeg_fill_bit_buffer(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
int nbits)
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
@@ -316,7 +316,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
|
||||
/* Attempt to read a byte */
|
||||
if (bytes_in_buffer == 0) {
|
||||
if (! (*cinfo->src->fill_input_buffer) (cinfo))
|
||||
if (!(*cinfo->src->fill_input_buffer) (cinfo))
|
||||
return FALSE;
|
||||
next_input_byte = cinfo->src->next_input_byte;
|
||||
bytes_in_buffer = cinfo->src->bytes_in_buffer;
|
||||
@@ -333,7 +333,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
*/
|
||||
do {
|
||||
if (bytes_in_buffer == 0) {
|
||||
if (! (*cinfo->src->fill_input_buffer) (cinfo))
|
||||
if (!(*cinfo->src->fill_input_buffer) (cinfo))
|
||||
return FALSE;
|
||||
next_input_byte = cinfo->src->next_input_byte;
|
||||
bytes_in_buffer = cinfo->src->bytes_in_buffer;
|
||||
@@ -365,7 +365,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
bits_left += 8;
|
||||
} /* end while */
|
||||
} else {
|
||||
no_more_bytes:
|
||||
no_more_bytes:
|
||||
/* We get here if we've read the marker that terminates the compressed
|
||||
* data segment. There should be enough bits in the buffer register
|
||||
* to satisfy the request; if so, no problem.
|
||||
@@ -376,7 +376,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
* We use a nonvolatile flag to ensure that only one warning message
|
||||
* appears per data segment.
|
||||
*/
|
||||
if (! cinfo->entropy->insufficient_data) {
|
||||
if (!cinfo->entropy->insufficient_data) {
|
||||
WARNMS(cinfo, JWRN_HIT_MARKER);
|
||||
cinfo->entropy->insufficient_data = TRUE;
|
||||
}
|
||||
@@ -400,8 +400,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
handle markers. We have to hand off any blocks with markers to the
|
||||
slower routines. */
|
||||
|
||||
#define GET_BYTE \
|
||||
{ \
|
||||
#define GET_BYTE { \
|
||||
register int c0, c1; \
|
||||
c0 = GETJOCTET(*buffer++); \
|
||||
c1 = GETJOCTET(*buffer); \
|
||||
@@ -421,7 +420,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
} \
|
||||
}
|
||||
|
||||
#if SIZEOF_SIZE_T==8 || defined(_WIN64)
|
||||
#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
|
||||
|
||||
/* Pre-fetch 48 bytes, because the holding register is 64-bit */
|
||||
#define FILL_BIT_BUFFER_FAST \
|
||||
@@ -446,7 +445,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
*/
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_huff_decode (bitread_working_state *state,
|
||||
jpeg_huff_decode(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
d_derived_tbl *htbl, int min_bits)
|
||||
{
|
||||
@@ -480,7 +479,7 @@ jpeg_huff_decode (bitread_working_state *state,
|
||||
return 0; /* fake a zero as the safest result */
|
||||
}
|
||||
|
||||
return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ];
|
||||
return htbl->pub->huffval[(int)(code + htbl->valoffset[l])];
|
||||
}
|
||||
|
||||
|
||||
@@ -493,21 +492,25 @@ jpeg_huff_decode (bitread_working_state *state,
|
||||
#ifdef AVOID_TABLES
|
||||
|
||||
#define NEG_1 ((unsigned int)-1)
|
||||
#define HUFF_EXTEND(x,s) ((x) + ((((x) - (1<<((s)-1))) >> 31) & (((NEG_1)<<(s)) + 1)))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
|
||||
|
||||
#else
|
||||
|
||||
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
|
||||
static const int extend_test[16] = /* entry n is 2**(n-1) */
|
||||
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
|
||||
static const int extend_test[16] = { /* entry n is 2**(n-1) */
|
||||
0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
|
||||
};
|
||||
|
||||
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
{ 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
|
||||
((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
|
||||
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
|
||||
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
|
||||
static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
|
||||
0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
|
||||
((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
|
||||
((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
|
||||
((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
|
||||
};
|
||||
|
||||
#endif /* AVOID_TABLES */
|
||||
|
||||
@@ -518,9 +521,9 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
process_restart (j_decompress_ptr cinfo)
|
||||
process_restart(j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
|
||||
/* Throw away any unused bits remaining in bit buffer; */
|
||||
@@ -529,7 +532,7 @@ process_restart (j_decompress_ptr cinfo)
|
||||
entropy->bitstate.bits_left = 0;
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
if (!(*cinfo->marker->read_restart_marker) (cinfo))
|
||||
return FALSE;
|
||||
|
||||
/* Re-initialize DC predictions to 0 */
|
||||
@@ -552,16 +555,16 @@ process_restart (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
BITREAD_STATE_VARS;
|
||||
int blkn;
|
||||
savable_state state;
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
@@ -587,7 +590,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
state.last_dc_val[ci] = s;
|
||||
if (block) {
|
||||
/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
|
||||
(*block)[0] = (JCOEF) s;
|
||||
(*block)[0] = (JCOEF)s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +613,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* Note: the extra entries in jpeg_natural_order[] will save us
|
||||
* if k >= DCTSIZE2, which could happen if the data is corrupted.
|
||||
*/
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) s;
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)s;
|
||||
} else {
|
||||
if (r != 15)
|
||||
break;
|
||||
@@ -642,16 +645,16 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
BITREAD_STATE_VARS;
|
||||
JOCTET *buffer;
|
||||
int blkn;
|
||||
@@ -659,8 +662,8 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
buffer = (JOCTET *) br_state.next_input_byte;
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
buffer = (JOCTET *)br_state.next_input_byte;
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
@@ -681,7 +684,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
if (block)
|
||||
(*block)[0] = (JCOEF) s;
|
||||
(*block)[0] = (JCOEF)s;
|
||||
}
|
||||
|
||||
if (entropy->ac_needed[blkn] && block) {
|
||||
@@ -696,7 +699,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
FILL_BIT_BUFFER_FAST
|
||||
r = GET_BITS(s);
|
||||
s = HUFF_EXTEND(r, s);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) s;
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)s;
|
||||
} else {
|
||||
if (r != 15) break;
|
||||
k += 15;
|
||||
@@ -729,7 +732,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
|
||||
br_state.next_input_byte = buffer;
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -753,33 +756,32 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
#define BUFSIZE (DCTSIZE2 * 8)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int usefast = 1;
|
||||
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
usefast = 0;
|
||||
}
|
||||
|
||||
if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU
|
||||
|| cinfo->unread_marker != 0)
|
||||
if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU ||
|
||||
cinfo->unread_marker != 0)
|
||||
usefast = 0;
|
||||
|
||||
/* If we've run out of data, just leave the MCU set to zeroes.
|
||||
* This way, we return uniform gray for the remainder of the segment.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
if (usefast) {
|
||||
if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
|
||||
}
|
||||
else {
|
||||
use_slow:
|
||||
} else {
|
||||
use_slow:
|
||||
if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
|
||||
}
|
||||
|
||||
@@ -797,7 +799,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
jinit_huff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
@@ -806,12 +808,12 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
are the default tables. Thus, if the tables are not set by the time
|
||||
the Huffman decoder is initialized (usually within the body of
|
||||
jpeg_start_decompress()), we set them to default values. */
|
||||
std_huff_tables((j_common_ptr) cinfo);
|
||||
std_huff_tables((j_common_ptr)cinfo);
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(huff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_huff_decoder;
|
||||
entropy->pub.decode_mcu = decode_mcu;
|
||||
|
||||
|
||||
54
jdhuff.h
54
jdhuff.h
@@ -43,13 +43,12 @@ typedef struct {
|
||||
* if too long. The next 8 bits of each entry contain the
|
||||
* symbol.
|
||||
*/
|
||||
int lookup[1<<HUFF_LOOKAHEAD];
|
||||
int lookup[1 << HUFF_LOOKAHEAD];
|
||||
} d_derived_tbl;
|
||||
|
||||
/* Expand a Huffman table definition into the derived format */
|
||||
EXTERN(void) jpeg_make_d_derived_tbl
|
||||
(j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
d_derived_tbl ** pdtbl);
|
||||
EXTERN(void) jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC,
|
||||
int tblno, d_derived_tbl **pdtbl);
|
||||
|
||||
|
||||
/*
|
||||
@@ -74,7 +73,7 @@ EXTERN(void) jpeg_make_d_derived_tbl
|
||||
#error Cannot determine word size
|
||||
#endif
|
||||
|
||||
#if SIZEOF_SIZE_T==8 || defined(_WIN64)
|
||||
#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
|
||||
|
||||
typedef size_t bit_buf_type; /* type of bit-extraction buffer */
|
||||
#define BIT_BUF_SIZE 64 /* size of buffer in bits */
|
||||
@@ -118,14 +117,14 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
register int bits_left; \
|
||||
bitread_working_state br_state
|
||||
|
||||
#define BITREAD_LOAD_STATE(cinfop,permstate) \
|
||||
#define BITREAD_LOAD_STATE(cinfop, permstate) \
|
||||
br_state.cinfo = cinfop; \
|
||||
br_state.next_input_byte = cinfop->src->next_input_byte; \
|
||||
br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
|
||||
get_buffer = permstate.get_buffer; \
|
||||
bits_left = permstate.bits_left;
|
||||
|
||||
#define BITREAD_SAVE_STATE(cinfop,permstate) \
|
||||
#define BITREAD_SAVE_STATE(cinfop, permstate) \
|
||||
cinfop->src->next_input_byte = br_state.next_input_byte; \
|
||||
cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
|
||||
permstate.get_buffer = get_buffer; \
|
||||
@@ -137,7 +136,7 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
* before using GET_BITS, PEEK_BITS, or DROP_BITS.
|
||||
* The variables get_buffer and bits_left are assumed to be locals,
|
||||
* but the state struct might not be (jpeg_huff_decode needs this).
|
||||
* CHECK_BIT_BUFFER(state,n,action);
|
||||
* CHECK_BIT_BUFFER(state, n, action);
|
||||
* Ensure there are N bits in get_buffer; if suspend, take action.
|
||||
* val = GET_BITS(n);
|
||||
* Fetch next N bits.
|
||||
@@ -149,24 +148,26 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
* is evaluated multiple times.
|
||||
*/
|
||||
|
||||
#define CHECK_BIT_BUFFER(state,nbits,action) \
|
||||
{ if (bits_left < (nbits)) { \
|
||||
if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
|
||||
#define CHECK_BIT_BUFFER(state, nbits, action) { \
|
||||
if (bits_left < (nbits)) { \
|
||||
if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
|
||||
{ action; } \
|
||||
get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
|
||||
get_buffer = (state).get_buffer; bits_left = (state).bits_left; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GET_BITS(nbits) \
|
||||
(((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1))
|
||||
(((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
|
||||
|
||||
#define PEEK_BITS(nbits) \
|
||||
(((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1))
|
||||
(((int)(get_buffer >> (bits_left - (nbits)))) & ((1 << (nbits)) - 1))
|
||||
|
||||
#define DROP_BITS(nbits) \
|
||||
(bits_left -= (nbits))
|
||||
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
(bitread_working_state *state, register bit_buf_type get_buffer,
|
||||
EXTERN(boolean) jpeg_fill_bit_buffer(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer,
|
||||
register int bits_left, int nbits);
|
||||
|
||||
|
||||
@@ -187,10 +188,11 @@ EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
* 3. jpeg_huff_decode returns -1 if forced to suspend.
|
||||
*/
|
||||
|
||||
#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
|
||||
{ register int nb, look; \
|
||||
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
|
||||
register int nb, look; \
|
||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||
if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
|
||||
if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
|
||||
{ failaction; } \
|
||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||
nb = 1; goto slowlabel; \
|
||||
@@ -202,13 +204,14 @@ EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
|
||||
} else { \
|
||||
slowlabel: \
|
||||
if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
|
||||
if ((result = \
|
||||
jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
|
||||
{ failaction; } \
|
||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define HUFF_DECODE_FAST(s,nb,htbl) \
|
||||
#define HUFF_DECODE_FAST(s, nb, htbl) \
|
||||
FILL_BIT_BUFFER_FAST; \
|
||||
s = PEEK_BITS(HUFF_LOOKAHEAD); \
|
||||
s = htbl->lookup[s]; \
|
||||
@@ -225,10 +228,11 @@ slowlabel: \
|
||||
s |= GET_BITS(1); \
|
||||
nb++; \
|
||||
} \
|
||||
s = htbl->pub->huffval[ (int) (s + htbl->valoffset[nb]) & 0xFF ]; \
|
||||
s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
|
||||
}
|
||||
|
||||
/* Out-of-line case for Huffman code fetching */
|
||||
EXTERN(int) jpeg_huff_decode
|
||||
(bitread_working_state *state, register bit_buf_type get_buffer,
|
||||
register int bits_left, d_derived_tbl *htbl, int min_bits);
|
||||
EXTERN(int) jpeg_huff_decode(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer,
|
||||
register int bits_left, d_derived_tbl *htbl,
|
||||
int min_bits);
|
||||
|
||||
14
jdicc.c
14
jdicc.c
@@ -19,7 +19,7 @@
|
||||
#include "jerror.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void *malloc(size_t size);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ extern void *malloc (size_t size);
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
marker_is_icc (jpeg_saved_marker_ptr marker)
|
||||
marker_is_icc(jpeg_saved_marker_ptr marker)
|
||||
{
|
||||
return
|
||||
marker->marker == ICC_MARKER &&
|
||||
@@ -71,7 +71,7 @@ marker_is_icc (jpeg_saved_marker_ptr marker)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_read_icc_profile (j_decompress_ptr cinfo, JOCTET **icc_data_ptr,
|
||||
jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr,
|
||||
unsigned int *icc_data_len)
|
||||
{
|
||||
jpeg_saved_marker_ptr marker;
|
||||
@@ -80,9 +80,9 @@ jpeg_read_icc_profile (j_decompress_ptr cinfo, JOCTET **icc_data_ptr,
|
||||
JOCTET *icc_data;
|
||||
unsigned int total_length;
|
||||
#define MAX_SEQ_NO 255 /* sufficient since marker numbers are bytes */
|
||||
char marker_present[MAX_SEQ_NO+1]; /* 1 if marker found */
|
||||
unsigned int data_length[MAX_SEQ_NO+1]; /* size of profile data in marker */
|
||||
unsigned int data_offset[MAX_SEQ_NO+1]; /* offset for data in marker */
|
||||
char marker_present[MAX_SEQ_NO + 1]; /* 1 if marker found */
|
||||
unsigned int data_length[MAX_SEQ_NO + 1]; /* size of profile data in marker */
|
||||
unsigned int data_offset[MAX_SEQ_NO + 1]; /* offset for data in marker */
|
||||
|
||||
if (icc_data_ptr == NULL || icc_data_len == NULL)
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
@@ -144,7 +144,7 @@ jpeg_read_icc_profile (j_decompress_ptr cinfo, JOCTET **icc_data_ptr,
|
||||
}
|
||||
|
||||
/* Allocate space for assembled data */
|
||||
icc_data = (JOCTET *) malloc(total_length * sizeof(JOCTET));
|
||||
icc_data = (JOCTET *)malloc(total_length * sizeof(JOCTET));
|
||||
if (icc_data == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11); /* oops, out of memory */
|
||||
|
||||
|
||||
85
jdinput.c
85
jdinput.c
@@ -33,7 +33,7 @@ typedef my_input_controller *my_inputctl_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(int) consume_markers (j_decompress_ptr cinfo);
|
||||
METHODDEF(int) consume_markers(j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@@ -41,16 +41,16 @@ METHODDEF(int) consume_markers (j_decompress_ptr cinfo);
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
initial_setup (j_decompress_ptr cinfo)
|
||||
initial_setup(j_decompress_ptr cinfo)
|
||||
/* Called once, when first SOS marker is reached */
|
||||
{
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
/* Make sure image isn't bigger than I can handle */
|
||||
if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
|
||||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
if ((long)cinfo->image_height > (long)JPEG_MAX_DIMENSION ||
|
||||
(long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||
@@ -66,8 +66,10 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
cinfo->max_v_samp_factor = 1;
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
||||
if (compptr->h_samp_factor <= 0 ||
|
||||
compptr->h_samp_factor > MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor <= 0 ||
|
||||
compptr->v_samp_factor > MAX_SAMP_FACTOR)
|
||||
ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
||||
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
||||
compptr->h_samp_factor);
|
||||
@@ -75,10 +77,10 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
compptr->v_samp_factor);
|
||||
}
|
||||
|
||||
#if JPEG_LIB_VERSION >=80
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
cinfo->block_size = DCTSIZE;
|
||||
cinfo->natural_order = jpeg_natural_order;
|
||||
cinfo->lim_Se = DCTSIZE2-1;
|
||||
cinfo->lim_Se = DCTSIZE2 - 1;
|
||||
#endif
|
||||
|
||||
/* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
|
||||
@@ -101,11 +103,11 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
#endif
|
||||
/* Size in DCT blocks */
|
||||
compptr->width_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
|
||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
compptr->height_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
|
||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
/* Set the first and last MCU columns to decompress from multi-scan images.
|
||||
* By default, decompress all of the MCU columns.
|
||||
*/
|
||||
@@ -117,11 +119,11 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
*/
|
||||
/* Size in samples */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
|
||||
(long) cinfo->max_h_samp_factor);
|
||||
jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
|
||||
(long)cinfo->max_h_samp_factor);
|
||||
compptr->downsampled_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
|
||||
(long) cinfo->max_v_samp_factor);
|
||||
jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
|
||||
(long)cinfo->max_v_samp_factor);
|
||||
/* Mark component needed, until color conversion says otherwise */
|
||||
compptr->component_needed = TRUE;
|
||||
/* Mark no quantization table yet saved for component */
|
||||
@@ -130,8 +132,8 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
|
||||
/* Compute number of fully interleaved MCU rows. */
|
||||
cinfo->total_iMCU_rows = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
|
||||
/* Decide whether file contains multiple scans */
|
||||
if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
|
||||
@@ -142,7 +144,7 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
per_scan_setup (j_decompress_ptr cinfo)
|
||||
per_scan_setup(j_decompress_ptr cinfo)
|
||||
/* Do computations that are needed before processing a JPEG scan */
|
||||
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */
|
||||
{
|
||||
@@ -167,7 +169,7 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
/* For noninterleaved scans, it is convenient to define last_row_height
|
||||
* as the number of block rows present in the last iMCU row.
|
||||
*/
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||
compptr->last_row_height = tmp;
|
||||
|
||||
@@ -184,11 +186,11 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
|
||||
/* Overall image size in MCUs */
|
||||
cinfo->MCUs_per_row = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width,
|
||||
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_width,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
|
||||
cinfo->blocks_in_MCU = 0;
|
||||
|
||||
@@ -198,12 +200,13 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
compptr->MCU_width = compptr->h_samp_factor;
|
||||
compptr->MCU_height = compptr->v_samp_factor;
|
||||
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
||||
compptr->MCU_sample_width = compptr->MCU_width * compptr->_DCT_scaled_size;
|
||||
compptr->MCU_sample_width = compptr->MCU_width *
|
||||
compptr->_DCT_scaled_size;
|
||||
/* Figure number of non-dummy blocks in last MCU column & row */
|
||||
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
|
||||
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
|
||||
if (tmp == 0) tmp = compptr->MCU_width;
|
||||
compptr->last_col_width = tmp;
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
|
||||
if (tmp == 0) tmp = compptr->MCU_height;
|
||||
compptr->last_row_height = tmp;
|
||||
/* Prepare array describing MCU composition */
|
||||
@@ -241,7 +244,7 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
latch_quant_tables (j_decompress_ptr cinfo)
|
||||
latch_quant_tables(j_decompress_ptr cinfo)
|
||||
{
|
||||
int ci, qtblno;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -259,7 +262,7 @@ latch_quant_tables (j_decompress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
||||
/* OK, save away the quantization table */
|
||||
qtbl = (JQUANT_TBL *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(JQUANT_TBL));
|
||||
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
|
||||
compptr->quant_table = qtbl;
|
||||
@@ -275,7 +278,7 @@ latch_quant_tables (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_input_pass (j_decompress_ptr cinfo)
|
||||
start_input_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
per_scan_setup(cinfo);
|
||||
latch_quant_tables(cinfo);
|
||||
@@ -292,7 +295,7 @@ start_input_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_input_pass (j_decompress_ptr cinfo)
|
||||
finish_input_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
cinfo->inputctl->consume_input = consume_markers;
|
||||
}
|
||||
@@ -309,9 +312,9 @@ finish_input_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
consume_markers (j_decompress_ptr cinfo)
|
||||
consume_markers(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
|
||||
int val;
|
||||
|
||||
if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
|
||||
@@ -329,7 +332,7 @@ consume_markers (j_decompress_ptr cinfo)
|
||||
* responsible for enforcing this sequencing.
|
||||
*/
|
||||
} else { /* 2nd or later SOS marker */
|
||||
if (! inputctl->pub.has_multiple_scans)
|
||||
if (!inputctl->pub.has_multiple_scans)
|
||||
ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
|
||||
start_input_pass(cinfo);
|
||||
}
|
||||
@@ -360,16 +363,16 @@ consume_markers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
reset_input_controller (j_decompress_ptr cinfo)
|
||||
reset_input_controller(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
|
||||
|
||||
inputctl->pub.consume_input = consume_markers;
|
||||
inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
|
||||
inputctl->pub.eoi_reached = FALSE;
|
||||
inputctl->inheaders = TRUE;
|
||||
/* Reset other modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->marker->reset_marker_reader) (cinfo);
|
||||
/* Reset progression state -- would be cleaner if entropy decoder did this */
|
||||
cinfo->coef_bits = NULL;
|
||||
@@ -382,15 +385,15 @@ reset_input_controller (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_input_controller (j_decompress_ptr cinfo)
|
||||
jinit_input_controller(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_inputctl_ptr inputctl;
|
||||
|
||||
/* Create subobject in permanent pool */
|
||||
inputctl = (my_inputctl_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_input_controller));
|
||||
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
|
||||
cinfo->inputctl = (struct jpeg_input_controller *)inputctl;
|
||||
/* Initialize method pointers */
|
||||
inputctl->pub.consume_input = consume_markers;
|
||||
inputctl->pub.reset_input_controller = reset_input_controller;
|
||||
|
||||
116
jdmainct.c
116
jdmainct.c
@@ -112,26 +112,29 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) process_data_simple_main
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_context_main
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_simple_main(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_context_main(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
METHODDEF(void) process_data_crank_post
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_crank_post(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
alloc_funny_pointers(j_decompress_ptr cinfo)
|
||||
/* Allocate space for the funny pointer lists.
|
||||
* This is done only once, not once per pass.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, rgroup;
|
||||
int M = cinfo->_min_DCT_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -141,7 +144,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
* We alloc both arrays with one call to save a few cycles.
|
||||
*/
|
||||
main_ptr->xbuffer[0] = (JSAMPIMAGE)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * 2 * sizeof(JSAMPARRAY));
|
||||
main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
|
||||
|
||||
@@ -153,7 +156,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
* We alloc both pointer lists with one call to save a few cycles.
|
||||
*/
|
||||
xbuf = (JSAMPARRAY)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
|
||||
xbuf += rgroup; /* want one row group at negative offsets */
|
||||
main_ptr->xbuffer[0][ci] = xbuf;
|
||||
@@ -164,7 +167,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
make_funny_pointers (j_decompress_ptr cinfo)
|
||||
make_funny_pointers(j_decompress_ptr cinfo)
|
||||
/* Create the funny pointer lists discussed in the comments above.
|
||||
* The actual workspace is already allocated (in main_ptr->buffer),
|
||||
* and the space for the pointer lists is allocated too.
|
||||
@@ -172,7 +175,7 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
* This will be repeated at the beginning of each pass.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, i, rgroup;
|
||||
int M = cinfo->_min_DCT_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -191,8 +194,8 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
}
|
||||
/* In the second list, put the last four row groups in swapped order */
|
||||
for (i = 0; i < rgroup * 2; i++) {
|
||||
xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];
|
||||
xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];
|
||||
xbuf1[rgroup * (M - 2) + i] = buf[rgroup * M + i];
|
||||
xbuf1[rgroup * M + i] = buf[rgroup * (M - 2) + i];
|
||||
}
|
||||
/* The wraparound pointers at top and bottom will be filled later
|
||||
* (see set_wraparound_pointers, below). Initially we want the "above"
|
||||
@@ -207,13 +210,13 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
set_bottom_pointers(j_decompress_ptr cinfo)
|
||||
/* Change the pointer lists to duplicate the last sample row at the bottom
|
||||
* of the image. whichptr indicates which xbuffer holds the final iMCU row.
|
||||
* Also sets rowgroups_avail to indicate number of nondummy row groups in row.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, i, rgroup, iMCUheight, rows_left;
|
||||
jpeg_component_info *compptr;
|
||||
JSAMPARRAY xbuf;
|
||||
@@ -224,20 +227,20 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
iMCUheight = compptr->v_samp_factor * compptr->_DCT_scaled_size;
|
||||
rgroup = iMCUheight / cinfo->_min_DCT_scaled_size;
|
||||
/* Count nondummy sample rows remaining for this component */
|
||||
rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
|
||||
rows_left = (int)(compptr->downsampled_height % (JDIMENSION)iMCUheight);
|
||||
if (rows_left == 0) rows_left = iMCUheight;
|
||||
/* Count nondummy row groups. Should get same answer for each component,
|
||||
* so we need only do it once.
|
||||
*/
|
||||
if (ci == 0) {
|
||||
main_ptr->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION)((rows_left - 1) / rgroup + 1);
|
||||
}
|
||||
/* Duplicate the last real sample row rgroup*2 times; this pads out the
|
||||
* last partial rowgroup and ensures at least one full rowgroup of context.
|
||||
*/
|
||||
xbuf = main_ptr->xbuffer[main_ptr->whichptr][ci];
|
||||
for (i = 0; i < rgroup * 2; i++) {
|
||||
xbuf[rows_left + i] = xbuf[rows_left-1];
|
||||
xbuf[rows_left + i] = xbuf[rows_left - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,9 +251,9 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
switch (pass_mode) {
|
||||
case JBUF_PASS_THRU:
|
||||
@@ -286,22 +289,21 @@ start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_simple_main (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
JDIMENSION rowgroups_avail;
|
||||
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (! main_ptr->buffer_full) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
|
||||
if (!main_ptr->buffer_full) {
|
||||
if (!(*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
|
||||
return; /* suspension forced, can do nothing more */
|
||||
main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
}
|
||||
|
||||
/* There are always min_DCT_scaled_size row groups in an iMCU row. */
|
||||
rowgroups_avail = (JDIMENSION) cinfo->_min_DCT_scaled_size;
|
||||
rowgroups_avail = (JDIMENSION)cinfo->_min_DCT_scaled_size;
|
||||
/* Note: at the bottom of the image, we may pass extra garbage row groups
|
||||
* to the postprocessor. The postprocessor has to check for bottom
|
||||
* of image anyway (at row resolution), so no point in us doing it too.
|
||||
@@ -326,15 +328,14 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_context_main (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (! main_ptr->buffer_full) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo,
|
||||
if (!main_ptr->buffer_full) {
|
||||
if (!(*cinfo->coef->decompress_data) (cinfo,
|
||||
main_ptr->xbuffer[main_ptr->whichptr]))
|
||||
return; /* suspension forced, can do nothing more */
|
||||
main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
@@ -349,9 +350,11 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
switch (main_ptr->context_state) {
|
||||
case CTX_POSTPONED_ROW:
|
||||
/* Call postprocessor using previously set pointers for postponed row */
|
||||
(*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
(*cinfo->post->post_process_data) (cinfo,
|
||||
main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr,
|
||||
main_ptr->rowgroups_avail, output_buf,
|
||||
out_row_ctr, out_rows_avail);
|
||||
if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
|
||||
return; /* Need to suspend */
|
||||
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
@@ -361,7 +364,7 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
case CTX_PREPARE_FOR_IMCU:
|
||||
/* Prepare to process first M-1 row groups of this iMCU row */
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size - 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION)(cinfo->_min_DCT_scaled_size - 1);
|
||||
/* Check for bottom of image: if so, tweak pointers to "duplicate"
|
||||
* the last sample row, and adjust rowgroups_avail to ignore padding rows.
|
||||
*/
|
||||
@@ -371,9 +374,11 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
/*FALLTHROUGH*/
|
||||
case CTX_PROCESS_IMCU:
|
||||
/* Call postprocessor using previously set pointers */
|
||||
(*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
(*cinfo->post->post_process_data) (cinfo,
|
||||
main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr,
|
||||
main_ptr->rowgroups_avail, output_buf,
|
||||
out_row_ctr, out_rows_avail);
|
||||
if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
|
||||
return; /* Need to suspend */
|
||||
/* After the first iMCU, change wraparound pointers to normal state */
|
||||
@@ -384,8 +389,8 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
main_ptr->buffer_full = FALSE;
|
||||
/* Still need to process last row group of this iMCU row, */
|
||||
/* which is saved at index M+1 of the other xbuffer */
|
||||
main_ptr->rowgroup_ctr = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 2);
|
||||
main_ptr->rowgroup_ctr = (JDIMENSION)(cinfo->_min_DCT_scaled_size + 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION)(cinfo->_min_DCT_scaled_size + 2);
|
||||
main_ptr->context_state = CTX_POSTPONED_ROW;
|
||||
}
|
||||
}
|
||||
@@ -400,12 +405,11 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_crank_post (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
process_data_crank_post(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,
|
||||
(JDIMENSION *) NULL, (JDIMENSION) 0,
|
||||
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE)NULL,
|
||||
(JDIMENSION *)NULL, (JDIMENSION)0,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
}
|
||||
|
||||
@@ -417,16 +421,16 @@ process_data_crank_post (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_main_ptr main_ptr;
|
||||
int ci, rgroup, ngroups;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
main_ptr = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_main_controller));
|
||||
cinfo->main = (struct jpeg_d_main_controller *) main_ptr;
|
||||
cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
|
||||
main_ptr->pub.start_pass = start_pass_main;
|
||||
|
||||
if (need_full_buffer) /* shouldn't happen */
|
||||
@@ -449,8 +453,8 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
|
||||
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
|
||||
main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
compptr->width_in_blocks * compptr->_DCT_scaled_size,
|
||||
(JDIMENSION) (rgroup * ngroups));
|
||||
(JDIMENSION)(rgroup * ngroups));
|
||||
}
|
||||
}
|
||||
|
||||
12
jdmainct.h
12
jdmainct.h
@@ -44,12 +44,12 @@ typedef my_main_controller *my_main_ptr;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
set_wraparound_pointers (j_decompress_ptr cinfo)
|
||||
set_wraparound_pointers(j_decompress_ptr cinfo)
|
||||
/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
|
||||
* This changes the pointer list state from top-of-image to the normal state.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, i, rgroup;
|
||||
int M = cinfo->_min_DCT_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@@ -62,10 +62,10 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
|
||||
xbuf0 = main_ptr->xbuffer[0][ci];
|
||||
xbuf1 = main_ptr->xbuffer[1][ci];
|
||||
for (i = 0; i < rgroup; i++) {
|
||||
xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];
|
||||
xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];
|
||||
xbuf0[rgroup*(M+2) + i] = xbuf0[i];
|
||||
xbuf1[rgroup*(M+2) + i] = xbuf1[i];
|
||||
xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];
|
||||
xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];
|
||||
xbuf0[rgroup * (M + 2) + i] = xbuf0[i];
|
||||
xbuf1[rgroup * (M + 2) + i] = xbuf1[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
248
jdmarker.c
248
jdmarker.c
@@ -138,9 +138,9 @@ typedef my_marker_reader *my_marker_ptr;
|
||||
* Note we do *not* do INPUT_SYNC before calling fill_input_buffer,
|
||||
* but we must reload the local copies after a successful fill.
|
||||
*/
|
||||
#define MAKE_BYTE_AVAIL(cinfo,action) \
|
||||
#define MAKE_BYTE_AVAIL(cinfo, action) \
|
||||
if (bytes_in_buffer == 0) { \
|
||||
if (! (*datasrc->fill_input_buffer) (cinfo)) \
|
||||
if (!(*datasrc->fill_input_buffer) (cinfo)) \
|
||||
{ action; } \
|
||||
INPUT_RELOAD(cinfo); \
|
||||
}
|
||||
@@ -148,19 +148,19 @@ typedef my_marker_reader *my_marker_ptr;
|
||||
/* Read a byte into variable V.
|
||||
* If must suspend, take the specified action (typically "return FALSE").
|
||||
*/
|
||||
#define INPUT_BYTE(cinfo,V,action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
|
||||
#define INPUT_BYTE(cinfo, V, action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
|
||||
bytes_in_buffer--; \
|
||||
V = GETJOCTET(*next_input_byte++); )
|
||||
|
||||
/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
|
||||
* V should be declared unsigned int or perhaps JLONG.
|
||||
*/
|
||||
#define INPUT_2BYTES(cinfo,V,action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
|
||||
#define INPUT_2BYTES(cinfo, V, action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
|
||||
bytes_in_buffer--; \
|
||||
V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
|
||||
MAKE_BYTE_AVAIL(cinfo,action); \
|
||||
V = ((unsigned int)GETJOCTET(*next_input_byte++)) << 8; \
|
||||
MAKE_BYTE_AVAIL(cinfo, action); \
|
||||
bytes_in_buffer--; \
|
||||
V += GETJOCTET(*next_input_byte++); )
|
||||
|
||||
@@ -197,7 +197,7 @@ typedef my_marker_reader *my_marker_ptr;
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_soi (j_decompress_ptr cinfo)
|
||||
get_soi(j_decompress_ptr cinfo)
|
||||
/* Process an SOI marker */
|
||||
{
|
||||
int i;
|
||||
@@ -237,7 +237,7 @@ get_soi (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
/* Process a SOFn marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -258,7 +258,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
length -= 8;
|
||||
|
||||
TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
|
||||
(int) cinfo->image_width, (int) cinfo->image_height,
|
||||
(int)cinfo->image_width, (int)cinfo->image_height,
|
||||
cinfo->num_components);
|
||||
|
||||
if (cinfo->marker->saw_SOF)
|
||||
@@ -267,16 +267,16 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
/* We don't support files in which the image height is initially specified */
|
||||
/* as 0 and is later redefined by DNL. As long as we have to check that, */
|
||||
/* might as well have a general sanity check. */
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0
|
||||
|| cinfo->num_components <= 0)
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|
||||
cinfo->num_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
if (length != (cinfo->num_components * 3))
|
||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||
|
||||
if (cinfo->comp_info == NULL) /* do only once, even if suspend */
|
||||
cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->comp_info = (jpeg_component_info *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * sizeof(jpeg_component_info));
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
@@ -301,7 +301,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_sos (j_decompress_ptr cinfo)
|
||||
get_sos(j_decompress_ptr cinfo)
|
||||
/* Process a SOS marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -309,7 +309,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
jpeg_component_info *compptr;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
if (! cinfo->marker->saw_SOF)
|
||||
if (!cinfo->marker->saw_SOF)
|
||||
ERREXIT(cinfo, JERR_SOS_NO_SOF);
|
||||
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
@@ -341,7 +341,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
|
||||
ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
|
||||
|
||||
id_found:
|
||||
id_found:
|
||||
|
||||
cinfo->cur_comp_info[i] = compptr;
|
||||
compptr->dc_tbl_no = (c >> 4) & 15;
|
||||
@@ -384,7 +384,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
#ifdef D_ARITH_CODING_SUPPORTED
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dac (j_decompress_ptr cinfo)
|
||||
get_dac(j_decompress_ptr cinfo)
|
||||
/* Process a DAC marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -402,14 +402,14 @@ get_dac (j_decompress_ptr cinfo)
|
||||
|
||||
TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
|
||||
|
||||
if (index < 0 || index >= (2*NUM_ARITH_TBLS))
|
||||
if (index < 0 || index >= (2 * NUM_ARITH_TBLS))
|
||||
ERREXIT1(cinfo, JERR_DAC_INDEX, index);
|
||||
|
||||
if (index >= NUM_ARITH_TBLS) { /* define AC table */
|
||||
cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;
|
||||
cinfo->arith_ac_K[index - NUM_ARITH_TBLS] = (UINT8)val;
|
||||
} else { /* define DC table */
|
||||
cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);
|
||||
cinfo->arith_dc_U[index] = (UINT8) (val >> 4);
|
||||
cinfo->arith_dc_L[index] = (UINT8)(val & 0x0F);
|
||||
cinfo->arith_dc_U[index] = (UINT8)(val >> 4);
|
||||
if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
|
||||
ERREXIT1(cinfo, JERR_DAC_VALUE, val);
|
||||
}
|
||||
@@ -422,7 +422,7 @@ get_dac (j_decompress_ptr cinfo)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else /* ! D_ARITH_CODING_SUPPORTED */
|
||||
#else /* !D_ARITH_CODING_SUPPORTED */
|
||||
|
||||
#define get_dac(cinfo) skip_variable(cinfo)
|
||||
|
||||
@@ -430,7 +430,7 @@ get_dac (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dht (j_decompress_ptr cinfo)
|
||||
get_dht(j_decompress_ptr cinfo)
|
||||
/* Process a DHT marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -467,7 +467,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
/* Here we just do minimal validation of the counts to avoid walking
|
||||
* off the end of our table space. jdhuff.c will check more carefully.
|
||||
*/
|
||||
if (count > 256 || ((JLONG) count) > length)
|
||||
if (count > 256 || ((JLONG)count) > length)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
@@ -489,7 +489,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
|
||||
MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
|
||||
@@ -504,7 +504,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dqt (j_decompress_ptr cinfo)
|
||||
get_dqt(j_decompress_ptr cinfo)
|
||||
/* Process a DQT marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -527,7 +527,7 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_DQT_INDEX, n);
|
||||
|
||||
if (cinfo->quant_tbl_ptrs[n] == NULL)
|
||||
cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
|
||||
cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr)cinfo);
|
||||
quant_ptr = cinfo->quant_tbl_ptrs[n];
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
@@ -536,20 +536,20 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
else
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
/* We convert the zigzag-order table to natural array order. */
|
||||
quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp;
|
||||
quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16)tmp;
|
||||
}
|
||||
|
||||
if (cinfo->err->trace_level >= 2) {
|
||||
for (i = 0; i < DCTSIZE2; i += 8) {
|
||||
TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
|
||||
quant_ptr->quantval[i], quant_ptr->quantval[i+1],
|
||||
quant_ptr->quantval[i+2], quant_ptr->quantval[i+3],
|
||||
quant_ptr->quantval[i+4], quant_ptr->quantval[i+5],
|
||||
quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]);
|
||||
quant_ptr->quantval[i], quant_ptr->quantval[i + 1],
|
||||
quant_ptr->quantval[i + 2], quant_ptr->quantval[i + 3],
|
||||
quant_ptr->quantval[i + 4], quant_ptr->quantval[i + 5],
|
||||
quant_ptr->quantval[i + 6], quant_ptr->quantval[i + 7]);
|
||||
}
|
||||
}
|
||||
|
||||
length -= DCTSIZE2+1;
|
||||
length -= DCTSIZE2 + 1;
|
||||
if (prec) length -= DCTSIZE2;
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dri (j_decompress_ptr cinfo)
|
||||
get_dri(j_decompress_ptr cinfo)
|
||||
/* Process a DRI marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -598,14 +598,14 @@ get_dri (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
unsigned int datalen, JLONG remaining)
|
||||
examine_app0(j_decompress_ptr cinfo, JOCTET *data, unsigned int datalen,
|
||||
JLONG remaining)
|
||||
/* Examine first few bytes from an APP0.
|
||||
* Take appropriate action if it is a JFIF marker.
|
||||
* datalen is # of bytes at data[], remaining is length of rest of marker data.
|
||||
*/
|
||||
{
|
||||
JLONG totallen = (JLONG) datalen + remaining;
|
||||
JLONG totallen = (JLONG)datalen + remaining;
|
||||
|
||||
if (datalen >= APP0_DATA_LEN &&
|
||||
GETJOCTET(data[0]) == 0x4A &&
|
||||
@@ -639,8 +639,8 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
GETJOCTET(data[12]), GETJOCTET(data[13]));
|
||||
totallen -= APP0_DATA_LEN;
|
||||
if (totallen !=
|
||||
((JLONG)GETJOCTET(data[12]) * (JLONG)GETJOCTET(data[13]) * (JLONG) 3))
|
||||
TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
|
||||
((JLONG)GETJOCTET(data[12]) * (JLONG)GETJOCTET(data[13]) * (JLONG)3))
|
||||
TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int)totallen);
|
||||
} else if (datalen >= 6 &&
|
||||
GETJOCTET(data[0]) == 0x4A &&
|
||||
GETJOCTET(data[1]) == 0x46 &&
|
||||
@@ -653,29 +653,29 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
*/
|
||||
switch (GETJOCTET(data[5])) {
|
||||
case 0x10:
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int)totallen);
|
||||
break;
|
||||
case 0x11:
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int)totallen);
|
||||
break;
|
||||
case 0x13:
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int)totallen);
|
||||
break;
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
|
||||
GETJOCTET(data[5]), (int) totallen);
|
||||
GETJOCTET(data[5]), (int)totallen);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Start of APP0 does not match "JFIF" or "JFXX", or too short */
|
||||
TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_APP0, (int)totallen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
examine_app14 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
unsigned int datalen, JLONG remaining)
|
||||
examine_app14(j_decompress_ptr cinfo, JOCTET *data, unsigned int datalen,
|
||||
JLONG remaining)
|
||||
/* Examine first few bytes from an APP14.
|
||||
* Take appropriate action if it is an Adobe marker.
|
||||
* datalen is # of bytes at data[], remaining is length of rest of marker data.
|
||||
@@ -696,16 +696,16 @@ examine_app14 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
transform = GETJOCTET(data[11]);
|
||||
TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
|
||||
cinfo->saw_Adobe_marker = TRUE;
|
||||
cinfo->Adobe_transform = (UINT8) transform;
|
||||
cinfo->Adobe_transform = (UINT8)transform;
|
||||
} else {
|
||||
/* Start of APP14 does not match "Adobe", or too short */
|
||||
TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
|
||||
TRACEMS1(cinfo, 1, JTRC_APP14, (int)(datalen + remaining));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(boolean)
|
||||
get_interesting_appn (j_decompress_ptr cinfo)
|
||||
get_interesting_appn(j_decompress_ptr cinfo)
|
||||
/* Process an APP0 or APP14 marker without saving it */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -720,7 +720,7 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
if (length >= APPN_DATA_LEN)
|
||||
numtoread = APPN_DATA_LEN;
|
||||
else if (length > 0)
|
||||
numtoread = (unsigned int) length;
|
||||
numtoread = (unsigned int)length;
|
||||
else
|
||||
numtoread = 0;
|
||||
for (i = 0; i < numtoread; i++)
|
||||
@@ -730,10 +730,10 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
/* process it */
|
||||
switch (cinfo->unread_marker) {
|
||||
case M_APP0:
|
||||
examine_app0(cinfo, (JOCTET *) b, numtoread, length);
|
||||
examine_app0(cinfo, (JOCTET *)b, numtoread, length);
|
||||
break;
|
||||
case M_APP14:
|
||||
examine_app14(cinfo, (JOCTET *) b, numtoread, length);
|
||||
examine_app14(cinfo, (JOCTET *)b, numtoread, length);
|
||||
break;
|
||||
default:
|
||||
/* can't get here unless jpeg_save_markers chooses wrong processor */
|
||||
@@ -744,7 +744,7 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
/* skip any remaining data -- could be lots */
|
||||
INPUT_SYNC(cinfo);
|
||||
if (length > 0)
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long) length);
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long)length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -753,10 +753,10 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
#ifdef SAVE_MARKERS_SUPPORTED
|
||||
|
||||
METHODDEF(boolean)
|
||||
save_marker (j_decompress_ptr cinfo)
|
||||
save_marker(j_decompress_ptr cinfo)
|
||||
/* Save an APPn or COM marker into the marker list */
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
|
||||
unsigned int bytes_read, data_length;
|
||||
JOCTET *data;
|
||||
@@ -770,22 +770,22 @@ save_marker (j_decompress_ptr cinfo)
|
||||
if (length >= 0) { /* watch out for bogus length word */
|
||||
/* figure out how much we want to save */
|
||||
unsigned int limit;
|
||||
if (cinfo->unread_marker == (int) M_COM)
|
||||
if (cinfo->unread_marker == (int)M_COM)
|
||||
limit = marker->length_limit_COM;
|
||||
else
|
||||
limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
|
||||
if ((unsigned int) length < limit)
|
||||
limit = (unsigned int) length;
|
||||
limit = marker->length_limit_APPn[cinfo->unread_marker - (int)M_APP0];
|
||||
if ((unsigned int)length < limit)
|
||||
limit = (unsigned int)length;
|
||||
/* allocate and initialize the marker item */
|
||||
cur_marker = (jpeg_saved_marker_ptr)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(struct jpeg_marker_struct) + limit);
|
||||
cur_marker->next = NULL;
|
||||
cur_marker->marker = (UINT8) cinfo->unread_marker;
|
||||
cur_marker->original_length = (unsigned int) length;
|
||||
cur_marker->marker = (UINT8)cinfo->unread_marker;
|
||||
cur_marker->original_length = (unsigned int)length;
|
||||
cur_marker->data_length = limit;
|
||||
/* data area is just beyond the jpeg_marker_struct */
|
||||
data = cur_marker->data = (JOCTET *) (cur_marker + 1);
|
||||
data = cur_marker->data = (JOCTET *)(cur_marker + 1);
|
||||
marker->cur_marker = cur_marker;
|
||||
marker->bytes_read = 0;
|
||||
bytes_read = 0;
|
||||
@@ -843,14 +843,14 @@ save_marker (j_decompress_ptr cinfo)
|
||||
break;
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
|
||||
(int) (data_length + length));
|
||||
(int)(data_length + length));
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip any remaining data -- could be lots */
|
||||
INPUT_SYNC(cinfo); /* do before skip_input_data */
|
||||
if (length > 0)
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long) length);
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long)length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -859,7 +859,7 @@ save_marker (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
METHODDEF(boolean)
|
||||
skip_variable (j_decompress_ptr cinfo)
|
||||
skip_variable(j_decompress_ptr cinfo)
|
||||
/* Skip over an unknown or uninteresting variable-length marker */
|
||||
{
|
||||
JLONG length;
|
||||
@@ -868,11 +868,11 @@ skip_variable (j_decompress_ptr cinfo)
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
length -= 2;
|
||||
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int)length);
|
||||
|
||||
INPUT_SYNC(cinfo); /* do before skip_input_data */
|
||||
if (length > 0)
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long) length);
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long)length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -888,7 +888,7 @@ skip_variable (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
next_marker (j_decompress_ptr cinfo)
|
||||
next_marker(j_decompress_ptr cinfo)
|
||||
{
|
||||
int c;
|
||||
INPUT_VARS(cinfo);
|
||||
@@ -935,7 +935,7 @@ next_marker (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
first_marker (j_decompress_ptr cinfo)
|
||||
first_marker(j_decompress_ptr cinfo)
|
||||
/* Like next_marker, but used to obtain the initial SOI marker. */
|
||||
/* For this marker, we do not allow preceding garbage or fill; otherwise,
|
||||
* we might well scan an entire input file before realizing it ain't JPEG.
|
||||
@@ -948,7 +948,7 @@ first_marker (j_decompress_ptr cinfo)
|
||||
|
||||
INPUT_BYTE(cinfo, c, return FALSE);
|
||||
INPUT_BYTE(cinfo, c2, return FALSE);
|
||||
if (c != 0xFF || c2 != (int) M_SOI)
|
||||
if (c != 0xFF || c2 != (int)M_SOI)
|
||||
ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
|
||||
|
||||
cinfo->unread_marker = c2;
|
||||
@@ -966,18 +966,18 @@ first_marker (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
read_markers (j_decompress_ptr cinfo)
|
||||
read_markers(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Outer loop repeats once for each marker. */
|
||||
for (;;) {
|
||||
/* Collect the marker proper, unless we already did. */
|
||||
/* NB: first_marker() enforces the requirement that SOI appear first. */
|
||||
if (cinfo->unread_marker == 0) {
|
||||
if (! cinfo->marker->saw_SOI) {
|
||||
if (! first_marker(cinfo))
|
||||
if (!cinfo->marker->saw_SOI) {
|
||||
if (!first_marker(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
} else {
|
||||
if (! next_marker(cinfo))
|
||||
if (!next_marker(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
}
|
||||
}
|
||||
@@ -987,28 +987,28 @@ read_markers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
switch (cinfo->unread_marker) {
|
||||
case M_SOI:
|
||||
if (! get_soi(cinfo))
|
||||
if (!get_soi(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF0: /* Baseline */
|
||||
case M_SOF1: /* Extended sequential, Huffman */
|
||||
if (! get_sof(cinfo, FALSE, FALSE))
|
||||
if (!get_sof(cinfo, FALSE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF2: /* Progressive, Huffman */
|
||||
if (! get_sof(cinfo, TRUE, FALSE))
|
||||
if (!get_sof(cinfo, TRUE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF9: /* Extended sequential, arithmetic */
|
||||
if (! get_sof(cinfo, FALSE, TRUE))
|
||||
if (!get_sof(cinfo, FALSE, TRUE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF10: /* Progressive, arithmetic */
|
||||
if (! get_sof(cinfo, TRUE, TRUE))
|
||||
if (!get_sof(cinfo, TRUE, TRUE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@@ -1026,7 +1026,7 @@ read_markers (j_decompress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case M_SOS:
|
||||
if (! get_sos(cinfo))
|
||||
if (!get_sos(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
cinfo->unread_marker = 0; /* processed the marker */
|
||||
return JPEG_REACHED_SOS;
|
||||
@@ -1037,22 +1037,22 @@ read_markers (j_decompress_ptr cinfo)
|
||||
return JPEG_REACHED_EOI;
|
||||
|
||||
case M_DAC:
|
||||
if (! get_dac(cinfo))
|
||||
if (!get_dac(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_DHT:
|
||||
if (! get_dht(cinfo))
|
||||
if (!get_dht(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_DQT:
|
||||
if (! get_dqt(cinfo))
|
||||
if (!get_dqt(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_DRI:
|
||||
if (! get_dri(cinfo))
|
||||
if (!get_dri(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@@ -1072,13 +1072,13 @@ read_markers (j_decompress_ptr cinfo)
|
||||
case M_APP13:
|
||||
case M_APP14:
|
||||
case M_APP15:
|
||||
if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[
|
||||
cinfo->unread_marker - (int) M_APP0]) (cinfo))
|
||||
if (!(*((my_marker_ptr)cinfo->marker)->process_APPn[
|
||||
cinfo->unread_marker - (int)M_APP0]) (cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_COM:
|
||||
if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
|
||||
if (!(*((my_marker_ptr)cinfo->marker)->process_COM) (cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@@ -1095,7 +1095,7 @@ read_markers (j_decompress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case M_DNL: /* Ignore DNL ... perhaps the wrong thing */
|
||||
if (! skip_variable(cinfo))
|
||||
if (!skip_variable(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@@ -1127,24 +1127,24 @@ read_markers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
read_restart_marker (j_decompress_ptr cinfo)
|
||||
read_restart_marker(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Obtain a marker unless we already did. */
|
||||
/* Note that next_marker will complain if it skips any data. */
|
||||
if (cinfo->unread_marker == 0) {
|
||||
if (! next_marker(cinfo))
|
||||
if (!next_marker(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (cinfo->unread_marker ==
|
||||
((int) M_RST0 + cinfo->marker->next_restart_num)) {
|
||||
((int)M_RST0 + cinfo->marker->next_restart_num)) {
|
||||
/* Normal case --- swallow the marker and let entropy decoder continue */
|
||||
TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
|
||||
cinfo->unread_marker = 0;
|
||||
} else {
|
||||
/* Uh-oh, the restart markers have been messed up. */
|
||||
/* Let the data source manager determine how to resync. */
|
||||
if (! (*cinfo->src->resync_to_restart) (cinfo,
|
||||
if (!(*cinfo->src->resync_to_restart) (cinfo,
|
||||
cinfo->marker->next_restart_num))
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1206,7 +1206,7 @@ read_restart_marker (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
|
||||
{
|
||||
int marker = cinfo->unread_marker;
|
||||
int action = 1;
|
||||
@@ -1216,16 +1216,16 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
|
||||
/* Outer loop handles repeated decision after scanning forward. */
|
||||
for (;;) {
|
||||
if (marker < (int) M_SOF0)
|
||||
if (marker < (int)M_SOF0)
|
||||
action = 2; /* invalid marker */
|
||||
else if (marker < (int) M_RST0 || marker > (int) M_RST7)
|
||||
else if (marker < (int)M_RST0 || marker > (int)M_RST7)
|
||||
action = 3; /* valid non-restart marker */
|
||||
else {
|
||||
if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||
|
||||
marker == ((int) M_RST0 + ((desired+2) & 7)))
|
||||
if (marker == ((int)M_RST0 + ((desired + 1) & 7)) ||
|
||||
marker == ((int)M_RST0 + ((desired + 2) & 7)))
|
||||
action = 3; /* one of the next two expected restarts */
|
||||
else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||
|
||||
marker == ((int) M_RST0 + ((desired-2) & 7)))
|
||||
else if (marker == ((int)M_RST0 + ((desired - 1) & 7)) ||
|
||||
marker == ((int)M_RST0 + ((desired - 2) & 7)))
|
||||
action = 2; /* a prior restart, so advance */
|
||||
else
|
||||
action = 1; /* desired restart or too far away */
|
||||
@@ -1238,7 +1238,7 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
return TRUE;
|
||||
case 2:
|
||||
/* Scan to the next marker, and repeat the decision loop. */
|
||||
if (! next_marker(cinfo))
|
||||
if (!next_marker(cinfo))
|
||||
return FALSE;
|
||||
marker = cinfo->unread_marker;
|
||||
break;
|
||||
@@ -1256,9 +1256,9 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
reset_marker_reader (j_decompress_ptr cinfo)
|
||||
reset_marker_reader(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
|
||||
cinfo->comp_info = NULL; /* until allocated by get_sof */
|
||||
cinfo->input_scan_number = 0; /* no SOS seen yet */
|
||||
@@ -1276,16 +1276,16 @@ reset_marker_reader (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
jinit_marker_reader(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker;
|
||||
int i;
|
||||
|
||||
/* Create subobject in permanent pool */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_marker_reader));
|
||||
cinfo->marker = (struct jpeg_marker_reader *) marker;
|
||||
cinfo->marker = (struct jpeg_marker_reader *)marker;
|
||||
/* Initialize public method pointers */
|
||||
marker->pub.reset_marker_reader = reset_marker_reader;
|
||||
marker->pub.read_markers = read_markers;
|
||||
@@ -1314,10 +1314,10 @@ jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
#ifdef SAVE_MARKERS_SUPPORTED
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
|
||||
unsigned int length_limit)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
long maxlength;
|
||||
jpeg_marker_parser_method processor;
|
||||
|
||||
@@ -1325,8 +1325,8 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
* (should only be a concern in a 16-bit environment).
|
||||
*/
|
||||
maxlength = cinfo->mem->max_alloc_chunk - sizeof(struct jpeg_marker_struct);
|
||||
if (((long) length_limit) > maxlength)
|
||||
length_limit = (unsigned int) maxlength;
|
||||
if (((long)length_limit) > maxlength)
|
||||
length_limit = (unsigned int)maxlength;
|
||||
|
||||
/* Choose processor routine to use.
|
||||
* APP0/APP14 have special requirements.
|
||||
@@ -1334,23 +1334,23 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
if (length_limit) {
|
||||
processor = save_marker;
|
||||
/* If saving APP0/APP14, save at least enough for our internal use. */
|
||||
if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN)
|
||||
if (marker_code == (int)M_APP0 && length_limit < APP0_DATA_LEN)
|
||||
length_limit = APP0_DATA_LEN;
|
||||
else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN)
|
||||
else if (marker_code == (int)M_APP14 && length_limit < APP14_DATA_LEN)
|
||||
length_limit = APP14_DATA_LEN;
|
||||
} else {
|
||||
processor = skip_variable;
|
||||
/* If discarding APP0/APP14, use our regular on-the-fly processor. */
|
||||
if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14)
|
||||
if (marker_code == (int)M_APP0 || marker_code == (int)M_APP14)
|
||||
processor = get_interesting_appn;
|
||||
}
|
||||
|
||||
if (marker_code == (int) M_COM) {
|
||||
if (marker_code == (int)M_COM) {
|
||||
marker->process_COM = processor;
|
||||
marker->length_limit_COM = length_limit;
|
||||
} else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) {
|
||||
marker->process_APPn[marker_code - (int) M_APP0] = processor;
|
||||
marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit;
|
||||
} else if (marker_code >= (int)M_APP0 && marker_code <= (int)M_APP15) {
|
||||
marker->process_APPn[marker_code - (int)M_APP0] = processor;
|
||||
marker->length_limit_APPn[marker_code - (int)M_APP0] = length_limit;
|
||||
} else
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
|
||||
}
|
||||
@@ -1363,15 +1363,15 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_marker_parser_method routine)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
|
||||
if (marker_code == (int) M_COM)
|
||||
if (marker_code == (int)M_COM)
|
||||
marker->process_COM = routine;
|
||||
else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15)
|
||||
marker->process_APPn[marker_code - (int) M_APP0] = routine;
|
||||
else if (marker_code >= (int)M_APP0 && marker_code <= (int)M_APP15)
|
||||
marker->process_APPn[marker_code - (int)M_APP0] = routine;
|
||||
else
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
|
||||
}
|
||||
|
||||
147
jdmaster.c
147
jdmaster.c
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
use_merged_upsample (j_decompress_ptr cinfo)
|
||||
use_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
/* Merging is the equivalent of plain box-filter upsampling */
|
||||
@@ -100,7 +100,7 @@ GLOBAL(void)
|
||||
#else
|
||||
LOCAL(void)
|
||||
#endif
|
||||
jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
jpeg_core_output_dimensions(j_decompress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase.
|
||||
* This function is used for transcoding and full decompression.
|
||||
*/
|
||||
@@ -113,129 +113,129 @@ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
|
||||
/* Provide 1/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 1;
|
||||
cinfo->_min_DCT_v_scaled_size = 1;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
|
||||
/* Provide 2/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 2L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 2L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 2;
|
||||
cinfo->_min_DCT_v_scaled_size = 2;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
|
||||
/* Provide 3/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 3L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 3L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 3;
|
||||
cinfo->_min_DCT_v_scaled_size = 3;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
|
||||
/* Provide 4/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 4L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 4L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 4;
|
||||
cinfo->_min_DCT_v_scaled_size = 4;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
|
||||
/* Provide 5/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 5L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 5L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 5;
|
||||
cinfo->_min_DCT_v_scaled_size = 5;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
|
||||
/* Provide 6/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 6L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 6L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 6;
|
||||
cinfo->_min_DCT_v_scaled_size = 6;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
|
||||
/* Provide 7/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 7L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 7L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 7;
|
||||
cinfo->_min_DCT_v_scaled_size = 7;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 8L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 8L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 8;
|
||||
cinfo->_min_DCT_v_scaled_size = 8;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
|
||||
/* Provide 9/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 9L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 9L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 9;
|
||||
cinfo->_min_DCT_v_scaled_size = 9;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
|
||||
/* Provide 10/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 10L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 10L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 10;
|
||||
cinfo->_min_DCT_v_scaled_size = 10;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
|
||||
/* Provide 11/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 11L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 11L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 11;
|
||||
cinfo->_min_DCT_v_scaled_size = 11;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
|
||||
/* Provide 12/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 12L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 12L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 12;
|
||||
cinfo->_min_DCT_v_scaled_size = 12;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
|
||||
/* Provide 13/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 13L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 13L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 13;
|
||||
cinfo->_min_DCT_v_scaled_size = 13;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
|
||||
/* Provide 14/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 14L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 14L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 14;
|
||||
cinfo->_min_DCT_v_scaled_size = 14;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
|
||||
/* Provide 15/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 15L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 15L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 15;
|
||||
cinfo->_min_DCT_v_scaled_size = 15;
|
||||
} else {
|
||||
/* Provide 16/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 16L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 16L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 16;
|
||||
cinfo->_min_DCT_v_scaled_size = 16;
|
||||
}
|
||||
@@ -268,7 +268,7 @@ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
#ifdef IDCT_SCALING_SUPPORTED
|
||||
@@ -314,13 +314,13 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
ci++, compptr++) {
|
||||
/* Size in samples, after IDCT scaling */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width *
|
||||
(long) (compptr->h_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_width *
|
||||
(long)(compptr->h_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
compptr->downsampled_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height *
|
||||
(long) (compptr->v_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height *
|
||||
(long)(compptr->v_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
}
|
||||
|
||||
#else /* !IDCT_SCALING_SUPPORTED */
|
||||
@@ -417,30 +417,30 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
prepare_range_limit_table(j_decompress_ptr cinfo)
|
||||
/* Allocate and fill in the sample_range_limit table */
|
||||
{
|
||||
JSAMPLE *table;
|
||||
int i;
|
||||
|
||||
table = (JSAMPLE *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
|
||||
cinfo->sample_range_limit = table;
|
||||
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
|
||||
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * sizeof(JSAMPLE));
|
||||
MEMZERO(table - (MAXJSAMPLE + 1), (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
|
||||
/* Main part of "simple" table: limit[x] = x */
|
||||
for (i = 0; i <= MAXJSAMPLE; i++)
|
||||
table[i] = (JSAMPLE) i;
|
||||
table[i] = (JSAMPLE)i;
|
||||
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
|
||||
/* End of simple table, rest of first half of post-IDCT table */
|
||||
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
|
||||
for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
|
||||
table[i] = MAXJSAMPLE;
|
||||
/* Second half of post-IDCT table */
|
||||
MEMZERO(table + (2 * (MAXJSAMPLE+1)),
|
||||
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
|
||||
MEMZERO(table + (2 * (MAXJSAMPLE + 1)),
|
||||
(2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
MEMCOPY(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
|
||||
cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
|
||||
}
|
||||
|
||||
@@ -457,9 +457,9 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
master_selection (j_decompress_ptr cinfo)
|
||||
master_selection(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
boolean use_c_buffer;
|
||||
long samplesperrow;
|
||||
JDIMENSION jd_samplesperrow;
|
||||
@@ -469,9 +469,10 @@ master_selection (j_decompress_ptr cinfo)
|
||||
prepare_range_limit_table(cinfo);
|
||||
|
||||
/* Width of an output scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
if ((long) jd_samplesperrow != samplesperrow)
|
||||
samplesperrow = (long)cinfo->output_width *
|
||||
(long)cinfo->out_color_components;
|
||||
jd_samplesperrow = (JDIMENSION)samplesperrow;
|
||||
if ((long)jd_samplesperrow != samplesperrow)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
|
||||
/* Initialize my private state */
|
||||
@@ -482,7 +483,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
master->quantizer_1pass = NULL;
|
||||
master->quantizer_2pass = NULL;
|
||||
/* No mode changes if not using buffered-image mode. */
|
||||
if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
|
||||
if (!cinfo->quantize_colors || !cinfo->buffered_image) {
|
||||
cinfo->enable_1pass_quant = FALSE;
|
||||
cinfo->enable_external_quant = FALSE;
|
||||
cinfo->enable_2pass_quant = FALSE;
|
||||
@@ -528,7 +529,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
/* Post-processing: in particular, color conversion first */
|
||||
if (! cinfo->raw_data_out) {
|
||||
if (!cinfo->raw_data_out) {
|
||||
if (master->using_merged_upsample) {
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
jinit_merged_upsampler(cinfo); /* does color conversion too */
|
||||
@@ -565,11 +566,11 @@ master_selection (j_decompress_ptr cinfo)
|
||||
use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
|
||||
jinit_d_coef_controller(cinfo, use_c_buffer);
|
||||
|
||||
if (! cinfo->raw_data_out)
|
||||
if (!cinfo->raw_data_out)
|
||||
jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Initialize input side of decompressor to consume first scan. */
|
||||
(*cinfo->inputctl->start_input_pass) (cinfo);
|
||||
@@ -585,7 +586,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
* progress monitoring appropriately. The input step is counted
|
||||
* as one pass.
|
||||
*/
|
||||
if (cinfo->progress != NULL && ! cinfo->buffered_image &&
|
||||
if (cinfo->progress != NULL && !cinfo->buffered_image &&
|
||||
cinfo->inputctl->has_multiple_scans) {
|
||||
int nscans;
|
||||
/* Estimate number of scans to set pass_limit. */
|
||||
@@ -597,7 +598,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
nscans = cinfo->num_components;
|
||||
}
|
||||
cinfo->progress->pass_counter = 0L;
|
||||
cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->completed_passes = 0;
|
||||
cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
|
||||
/* Count the input pass as done */
|
||||
@@ -617,9 +618,9 @@ master_selection (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
prepare_for_output_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
if (master->pub.is_dummy_pass) {
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
@@ -645,8 +646,8 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
}
|
||||
(*cinfo->idct->start_pass) (cinfo);
|
||||
(*cinfo->coef->start_output_pass) (cinfo);
|
||||
if (! cinfo->raw_data_out) {
|
||||
if (! master->using_merged_upsample)
|
||||
if (!cinfo->raw_data_out) {
|
||||
if (!master->using_merged_upsample)
|
||||
(*cinfo->cconvert->start_pass) (cinfo);
|
||||
(*cinfo->upsample->start_pass) (cinfo);
|
||||
if (cinfo->quantize_colors)
|
||||
@@ -665,7 +666,7 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
/* In buffered-image mode, we assume one more output pass if EOI not
|
||||
* yet reached, but no more passes if EOI has been reached.
|
||||
*/
|
||||
if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
|
||||
if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
|
||||
cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
|
||||
}
|
||||
}
|
||||
@@ -677,9 +678,9 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_output_pass (j_decompress_ptr cinfo)
|
||||
finish_output_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
if (cinfo->quantize_colors)
|
||||
(*cinfo->cquantize->finish_pass) (cinfo);
|
||||
@@ -694,9 +695,9 @@ finish_output_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_new_colormap (j_decompress_ptr cinfo)
|
||||
jpeg_new_colormap(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
/* Prevent application from calling me at wrong times */
|
||||
if (cinfo->global_state != DSTATE_BUFIMAGE)
|
||||
@@ -722,9 +723,9 @@ jpeg_new_colormap (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_master_decompress (j_decompress_ptr cinfo)
|
||||
jinit_master_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
||||
master->pub.finish_output_pass = finish_output_pass;
|
||||
|
||||
110
jdmerge.c
110
jdmerge.c
@@ -76,8 +76,8 @@ typedef struct {
|
||||
typedef my_upsampler *my_upsample_ptr;
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
@@ -187,25 +187,25 @@ typedef my_upsampler *my_upsample_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
upsample->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
upsample->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
upsample->Cr_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
upsample->Cb_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
@@ -217,10 +217,10 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
upsample->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
upsample->Cr_g_tab[i] = (-FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
upsample->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,9 +230,9 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_merged_upsample (j_decompress_ptr cinfo)
|
||||
start_pass_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the spare buffer empty */
|
||||
upsample->spare_full = FALSE;
|
||||
@@ -248,14 +248,13 @@ start_pass_merged_upsample (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 2:1 vertical sampling case: may need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JSAMPROW work_ptrs[2];
|
||||
JDIMENSION num_rows; /* number of rows returned to caller */
|
||||
|
||||
@@ -264,8 +263,8 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
JDIMENSION size = upsample->out_row_width;
|
||||
if (cinfo->out_color_space == JCS_RGB565)
|
||||
size = cinfo->output_width * 2;
|
||||
jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0,
|
||||
1, size);
|
||||
jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
|
||||
size);
|
||||
num_rows = 1;
|
||||
upsample->spare_full = FALSE;
|
||||
} else {
|
||||
@@ -294,20 +293,19 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
*out_row_ctr += num_rows;
|
||||
upsample->rows_to_go -= num_rows;
|
||||
/* When the buffer is emptied, declare this input row group consumed */
|
||||
if (! upsample->spare_full)
|
||||
if (!upsample->spare_full)
|
||||
(*in_row_group_ctr)++;
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
merged_1v_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 1:1 vertical sampling case: much easier, never need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Just do the upsampling. */
|
||||
(*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
|
||||
@@ -333,9 +331,8 @@ merged_1v_upsample (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -379,9 +376,8 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@@ -436,12 +432,12 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (INT16)(pixels); \
|
||||
((INT16*)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||
((INT16 *)(addr))[0] = (INT16)(pixels); \
|
||||
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||
}
|
||||
#define WRITE_TWO_PIXELS_BE(addr, pixels) { \
|
||||
((INT16*)(addr))[1] = (INT16)(pixels); \
|
||||
((INT16*)(addr))[0] = (INT16)((pixels) >> 16); \
|
||||
((INT16 *)(addr))[1] = (INT16)(pixels); \
|
||||
((INT16 *)(addr))[0] = (INT16)((pixels) >> 16); \
|
||||
}
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
@@ -510,9 +506,8 @@ static INLINE boolean is_big_endian(void)
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@@ -520,13 +515,12 @@ h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
else
|
||||
h2v1_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@@ -538,9 +532,8 @@ h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@@ -552,9 +545,8 @@ h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@@ -574,14 +566,14 @@ h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
jinit_merged_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
|
||||
@@ -602,8 +594,8 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
}
|
||||
/* Allocate a spare row buffer */
|
||||
upsample->spare_row = (JSAMPROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (upsample->out_row_width * sizeof(JSAMPLE)));
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(size_t)(upsample->out_row_width * sizeof(JSAMPLE)));
|
||||
} else {
|
||||
upsample->pub.upsample = merged_1v_upsample;
|
||||
if (jsimd_can_h2v1_merged_upsample())
|
||||
|
||||
94
jdmrg565.c
94
jdmrg565.c
@@ -15,23 +15,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
SHIFT_TEMPS
|
||||
@@ -47,7 +46,7 @@ h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
@@ -72,37 +71,37 @@ h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
}
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
@@ -119,7 +118,7 @@ h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
@@ -146,37 +145,36 @@ h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
SHIFT_TEMPS
|
||||
@@ -194,7 +192,7 @@ h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
@@ -234,7 +232,7 @@ h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
@@ -242,45 +240,45 @@ h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = (INT16)rgb;
|
||||
*(INT16 *)outptr0 = (INT16)rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = (INT16)rgb;
|
||||
*(INT16 *)outptr1 = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
JLONG d1 = dither_matrix[(cinfo->output_scanline+1) & DITHER_MASK];
|
||||
JLONG d1 = dither_matrix[(cinfo->output_scanline + 1) & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr*2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
|
||||
inptr00 = input_buf[0][in_row_group_ctr * 2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
@@ -292,7 +290,7 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
@@ -336,7 +334,7 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
@@ -344,13 +342,13 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = (INT16)rgb;
|
||||
*(INT16 *)outptr0 = (INT16)rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = (INT16)rgb;
|
||||
*(INT16 *)outptr1 = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
42
jdmrgext.c
42
jdmrgext.c
@@ -21,23 +21,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
@@ -50,7 +49,7 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
@@ -75,7 +74,7 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
outptr[RGB_RED] = range_limit[y + cred];
|
||||
@@ -94,27 +93,26 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr*2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
|
||||
inptr00 = input_buf[0][in_row_group_ctr * 2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
@@ -125,7 +123,7 @@ h2v2_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
@@ -166,7 +164,7 @@ h2v2_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
outptr0[RGB_RED] = range_limit[y + cred];
|
||||
|
||||
115
jdphuff.c
115
jdphuff.c
@@ -43,10 +43,10 @@ typedef struct {
|
||||
*/
|
||||
|
||||
#ifndef NO_STRUCT_ASSIGN
|
||||
#define ASSIGN_STATE(dest,src) ((dest) = (src))
|
||||
#define ASSIGN_STATE(dest, src) ((dest) = (src))
|
||||
#else
|
||||
#if MAX_COMPS_IN_SCAN == 4
|
||||
#define ASSIGN_STATE(dest,src) \
|
||||
#define ASSIGN_STATE(dest, src) \
|
||||
((dest).EOBRUN = (src).EOBRUN, \
|
||||
(dest).last_dc_val[0] = (src).last_dc_val[0], \
|
||||
(dest).last_dc_val[1] = (src).last_dc_val[1], \
|
||||
@@ -77,13 +77,13 @@ typedef struct {
|
||||
typedef phuff_entropy_decoder *phuff_entropy_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) decode_mcu_DC_first (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_DC_first(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_AC_first (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_AC_first(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_DC_refine (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_DC_refine(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_AC_refine (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_AC_refine(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
|
||||
|
||||
@@ -92,9 +92,9 @@ METHODDEF(boolean) decode_mcu_AC_refine (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
start_pass_phuff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
boolean is_DC_band, bad;
|
||||
int ci, coefi, tbl;
|
||||
d_derived_tbl **pdtbl;
|
||||
@@ -118,7 +118,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
}
|
||||
if (cinfo->Ah != 0) {
|
||||
/* Successive approximation refinement scan: must have Al = Ah-1. */
|
||||
if (cinfo->Al != cinfo->Ah-1)
|
||||
if (cinfo->Al != cinfo->Ah - 1)
|
||||
bad = TRUE;
|
||||
}
|
||||
if (cinfo->Al > 13) /* need not check for < 0 */
|
||||
@@ -138,7 +138,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
*/
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
int cindex = cinfo->cur_comp_info[ci]->component_index;
|
||||
coef_bit_ptr = & cinfo->coef_bits[cindex][0];
|
||||
coef_bit_ptr = &cinfo->coef_bits[cindex][0];
|
||||
if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
|
||||
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
|
||||
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
|
||||
@@ -206,21 +206,25 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
#ifdef AVOID_TABLES
|
||||
|
||||
#define NEG_1 ((unsigned)-1)
|
||||
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((NEG_1)<<(s)) + 1) : (x))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) < (1 << ((s) - 1)) ? (x) + (((NEG_1) << (s)) + 1) : (x))
|
||||
|
||||
#else
|
||||
|
||||
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
|
||||
static const int extend_test[16] = /* entry n is 2**(n-1) */
|
||||
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
|
||||
static const int extend_test[16] = { /* entry n is 2**(n-1) */
|
||||
0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
|
||||
};
|
||||
|
||||
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
{ 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
|
||||
((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
|
||||
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
|
||||
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
|
||||
static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
|
||||
0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
|
||||
((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
|
||||
((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
|
||||
((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
|
||||
};
|
||||
|
||||
#endif /* AVOID_TABLES */
|
||||
|
||||
@@ -231,9 +235,9 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
process_restart (j_decompress_ptr cinfo)
|
||||
process_restart(j_decompress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
|
||||
/* Throw away any unused bits remaining in bit buffer; */
|
||||
@@ -242,7 +246,7 @@ process_restart (j_decompress_ptr cinfo)
|
||||
entropy->bitstate.bits_left = 0;
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
if (!(*cinfo->marker->read_restart_marker) (cinfo))
|
||||
return FALSE;
|
||||
|
||||
/* Re-initialize DC predictions to 0 */
|
||||
@@ -289,9 +293,9 @@ process_restart (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int Al = cinfo->Al;
|
||||
register int s, r;
|
||||
int blkn, ci;
|
||||
@@ -304,17 +308,17 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we've run out of data, just leave the MCU set to zeroes.
|
||||
* This way, we return uniform gray for the remainder of the segment.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -339,11 +343,11 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(s, Al);
|
||||
(*block)[0] = (JCOEF)LEFT_SHIFT(s, Al);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
@@ -360,9 +364,9 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int Se = cinfo->Se;
|
||||
int Al = cinfo->Al;
|
||||
register int s, k, r;
|
||||
@@ -374,14 +378,14 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we've run out of data, just leave the MCU set to zeroes.
|
||||
* This way, we return uniform gray for the remainder of the segment.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
/* Load up working state.
|
||||
* We can avoid loading/saving bitread state if in an EOB run.
|
||||
@@ -393,7 +397,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (EOBRUN > 0) /* if it's a band of zeroes... */
|
||||
EOBRUN--; /* ...process it now (we do nothing) */
|
||||
else {
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
block = MCU_data[0];
|
||||
tbl = entropy->ac_derived_tbl;
|
||||
|
||||
@@ -407,7 +411,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
r = GET_BITS(s);
|
||||
s = HUFF_EXTEND(r, s);
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) LEFT_SHIFT(s, Al);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)LEFT_SHIFT(s, Al);
|
||||
} else {
|
||||
if (r == 15) { /* ZRL */
|
||||
k += 15; /* skip 15 zeroes in band */
|
||||
@@ -424,7 +428,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
@@ -445,9 +449,9 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
int blkn;
|
||||
JBLOCKROW block;
|
||||
@@ -456,7 +460,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -465,7 +469,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
@@ -480,7 +484,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
@@ -494,9 +498,9 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int Se = cinfo->Se;
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
int m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
@@ -512,16 +516,16 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we've run out of data, don't modify the MCU.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
|
||||
|
||||
/* There is always only one block per MCU */
|
||||
@@ -589,7 +593,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (s) {
|
||||
int pos = jpeg_natural_order[k];
|
||||
/* Output newly nonzero coefficient */
|
||||
(*block)[pos] = (JCOEF) s;
|
||||
(*block)[pos] = (JCOEF)s;
|
||||
/* Remember its position in case we have to suspend */
|
||||
newnz_pos[num_newnz++] = pos;
|
||||
}
|
||||
@@ -621,7 +625,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
|
||||
}
|
||||
|
||||
@@ -644,16 +648,16 @@ undoit:
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_phuff_decoder (j_decompress_ptr cinfo)
|
||||
jinit_phuff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy;
|
||||
int *coef_bit_ptr;
|
||||
int ci, i;
|
||||
|
||||
entropy = (phuff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(phuff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_phuff_decoder;
|
||||
|
||||
/* Mark derived tables unallocated */
|
||||
@@ -663,9 +667,10 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
|
||||
|
||||
/* Create progression status table */
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*sizeof(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 *
|
||||
sizeof(int));
|
||||
coef_bit_ptr = &cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
*coef_bit_ptr++ = -1;
|
||||
|
||||
116
jdpostct.c
116
jdpostct.c
@@ -46,21 +46,27 @@ typedef my_post_controller *my_post_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) post_process_1pass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
METHODDEF(void) post_process_1pass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
METHODDEF(void) post_process_prepass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
METHODDEF(void) post_process_prepass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) post_process_2pass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
METHODDEF(void) post_process_2pass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#endif
|
||||
|
||||
@@ -70,9 +76,9 @@ METHODDEF(void) post_process_2pass
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_dpost(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
|
||||
switch (pass_mode) {
|
||||
case JBUF_PASS_THRU:
|
||||
@@ -85,8 +91,8 @@ start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
if (post->buffer == NULL) {
|
||||
post->buffer = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, post->whole_image,
|
||||
(JDIMENSION) 0, post->strip_height, TRUE);
|
||||
((j_common_ptr)cinfo, post->whole_image,
|
||||
(JDIMENSION)0, post->strip_height, TRUE);
|
||||
}
|
||||
} else {
|
||||
/* For single-pass processing without color quantization,
|
||||
@@ -123,13 +129,12 @@ start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
post_process_1pass (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
post_process_1pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
JDIMENSION num_rows, max_rows;
|
||||
|
||||
/* Fill the buffer, but not more than what we can dump out in one go. */
|
||||
@@ -138,12 +143,13 @@ post_process_1pass (j_decompress_ptr cinfo,
|
||||
if (max_rows > post->strip_height)
|
||||
max_rows = post->strip_height;
|
||||
num_rows = 0;
|
||||
(*cinfo->upsample->upsample) (cinfo,
|
||||
input_buf, in_row_group_ctr, in_row_groups_avail,
|
||||
post->buffer, &num_rows, max_rows);
|
||||
(*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
|
||||
in_row_groups_avail, post->buffer, &num_rows,
|
||||
max_rows);
|
||||
/* Quantize and emit data. */
|
||||
(*cinfo->cquantize->color_quantize) (cinfo,
|
||||
post->buffer, output_buf + *out_row_ctr, (int) num_rows);
|
||||
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer,
|
||||
output_buf + *out_row_ctr,
|
||||
(int)num_rows);
|
||||
*out_row_ctr += num_rows;
|
||||
}
|
||||
|
||||
@@ -155,34 +161,33 @@ post_process_1pass (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
post_process_prepass (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
post_process_prepass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
JDIMENSION old_next_row, num_rows;
|
||||
|
||||
/* Reposition virtual buffer if at start of strip. */
|
||||
if (post->next_row == 0) {
|
||||
post->buffer = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, post->whole_image,
|
||||
((j_common_ptr)cinfo, post->whole_image,
|
||||
post->starting_row, post->strip_height, TRUE);
|
||||
}
|
||||
|
||||
/* Upsample some data (up to a strip height's worth). */
|
||||
old_next_row = post->next_row;
|
||||
(*cinfo->upsample->upsample) (cinfo,
|
||||
input_buf, in_row_group_ctr, in_row_groups_avail,
|
||||
post->buffer, &post->next_row, post->strip_height);
|
||||
(*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
|
||||
in_row_groups_avail, post->buffer,
|
||||
&post->next_row, post->strip_height);
|
||||
|
||||
/* Allow quantizer to scan new data. No data is emitted, */
|
||||
/* but we advance out_row_ctr so outer loop can tell when we're done. */
|
||||
if (post->next_row > old_next_row) {
|
||||
num_rows = post->next_row - old_next_row;
|
||||
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row,
|
||||
(JSAMPARRAY) NULL, (int) num_rows);
|
||||
(JSAMPARRAY)NULL, (int)num_rows);
|
||||
*out_row_ctr += num_rows;
|
||||
}
|
||||
|
||||
@@ -199,19 +204,18 @@ post_process_prepass (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
post_process_2pass (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
JDIMENSION num_rows, max_rows;
|
||||
|
||||
/* Reposition virtual buffer if at start of strip. */
|
||||
if (post->next_row == 0) {
|
||||
post->buffer = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, post->whole_image,
|
||||
((j_common_ptr)cinfo, post->whole_image,
|
||||
post->starting_row, post->strip_height, FALSE);
|
||||
}
|
||||
|
||||
@@ -226,9 +230,9 @@ post_process_2pass (j_decompress_ptr cinfo,
|
||||
num_rows = max_rows;
|
||||
|
||||
/* Quantize and emit data. */
|
||||
(*cinfo->cquantize->color_quantize) (cinfo,
|
||||
post->buffer + post->next_row, output_buf + *out_row_ctr,
|
||||
(int) num_rows);
|
||||
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer + post->next_row,
|
||||
output_buf + *out_row_ctr,
|
||||
(int)num_rows);
|
||||
*out_row_ctr += num_rows;
|
||||
|
||||
/* Advance if we filled the strip. */
|
||||
@@ -247,14 +251,14 @@ post_process_2pass (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_post_ptr post;
|
||||
|
||||
post = (my_post_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_post_controller));
|
||||
cinfo->post = (struct jpeg_d_post_controller *) post;
|
||||
cinfo->post = (struct jpeg_d_post_controller *)post;
|
||||
post->pub.start_pass = start_pass_dpost;
|
||||
post->whole_image = NULL; /* flag for no virtual arrays */
|
||||
post->buffer = NULL; /* flag for no strip buffer */
|
||||
@@ -265,16 +269,16 @@ jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
* an efficient number of rows for upsampling to return.
|
||||
* (In the presence of output rescaling, we might want to be smarter?)
|
||||
*/
|
||||
post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor;
|
||||
post->strip_height = (JDIMENSION)cinfo->max_v_samp_factor;
|
||||
if (need_full_buffer) {
|
||||
/* Two-pass color quantization: need full-image storage. */
|
||||
/* We round up the number of rows to a multiple of the strip height. */
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
post->whole_image = (*cinfo->mem->request_virt_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
||||
cinfo->output_width * cinfo->out_color_components,
|
||||
(JDIMENSION) jround_up((long) cinfo->output_height,
|
||||
(long) post->strip_height),
|
||||
(JDIMENSION)jround_up((long)cinfo->output_height,
|
||||
(long)post->strip_height),
|
||||
post->strip_height);
|
||||
#else
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@@ -282,7 +286,7 @@ jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
} else {
|
||||
/* One-pass color quantization: just make a strip buffer. */
|
||||
post->buffer = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->output_width * cinfo->out_color_components,
|
||||
post->strip_height);
|
||||
}
|
||||
|
||||
105
jdsample.c
105
jdsample.c
@@ -36,9 +36,9 @@
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_upsample (j_decompress_ptr cinfo)
|
||||
start_pass_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the conversion buffer empty */
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
@@ -56,13 +56,12 @@ start_pass_upsample (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
sep_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
JDIMENSION num_rows;
|
||||
@@ -84,7 +83,7 @@ sep_upsample (j_decompress_ptr cinfo,
|
||||
/* Color-convert and emit rows */
|
||||
|
||||
/* How many we have in the buffer: */
|
||||
num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);
|
||||
num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out);
|
||||
/* Not more than the distance to the end of the image. Need this test
|
||||
* in case the image height is not a multiple of max_v_samp_factor:
|
||||
*/
|
||||
@@ -96,9 +95,8 @@ sep_upsample (j_decompress_ptr cinfo,
|
||||
num_rows = out_rows_avail;
|
||||
|
||||
(*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
|
||||
(JDIMENSION) upsample->next_row_out,
|
||||
output_buf + *out_row_ctr,
|
||||
(int) num_rows);
|
||||
(JDIMENSION)upsample->next_row_out,
|
||||
output_buf + *out_row_ctr, (int)num_rows);
|
||||
|
||||
/* Adjust counts */
|
||||
*out_row_ctr += num_rows;
|
||||
@@ -124,7 +122,7 @@ sep_upsample (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
*output_data_ptr = input_data;
|
||||
@@ -137,7 +135,7 @@ fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
noop_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
*output_data_ptr = NULL; /* safety check */
|
||||
@@ -156,10 +154,10 @@ noop_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPLE invalue;
|
||||
@@ -185,8 +183,8 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
}
|
||||
/* Generate any additional output rows by duplicating the first one */
|
||||
if (v_expand > 1) {
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
|
||||
v_expand-1, cinfo->output_width);
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow + 1,
|
||||
v_expand - 1, cinfo->output_width);
|
||||
}
|
||||
inrow++;
|
||||
outrow += v_expand;
|
||||
@@ -200,7 +198,7 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@@ -228,7 +226,7 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@@ -247,8 +245,8 @@ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*outptr++ = invalue;
|
||||
*outptr++ = invalue;
|
||||
}
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
|
||||
1, cinfo->output_width);
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1,
|
||||
cinfo->output_width);
|
||||
inrow++;
|
||||
outrow += 2;
|
||||
}
|
||||
@@ -271,7 +269,7 @@ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@@ -285,20 +283,20 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
outptr = output_data[inrow];
|
||||
/* Special case for first column */
|
||||
invalue = GETJSAMPLE(*inptr++);
|
||||
*outptr++ = (JSAMPLE) invalue;
|
||||
*outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
*outptr++ = (JSAMPLE)invalue;
|
||||
*outptr++ = (JSAMPLE)((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
|
||||
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
|
||||
/* General case: 3/4 * nearer pixel + 1/4 * further pixel */
|
||||
invalue = GETJSAMPLE(*inptr++) * 3;
|
||||
*outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
*outptr++ = (JSAMPLE)((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE)((invalue + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
}
|
||||
|
||||
/* Special case for last column */
|
||||
invalue = GETJSAMPLE(*inptr);
|
||||
*outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE) invalue;
|
||||
*outptr++ = (JSAMPLE)((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE)invalue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +309,7 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@@ -330,14 +328,14 @@ h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* inptr0 points to nearest input row, inptr1 points to next nearest */
|
||||
inptr0 = input_data[inrow];
|
||||
if (v == 0) /* next nearest is row above */
|
||||
inptr1 = input_data[inrow-1];
|
||||
inptr1 = input_data[inrow - 1];
|
||||
else /* next nearest is row below */
|
||||
inptr1 = input_data[inrow+1];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
outptr = output_data[outrow++];
|
||||
|
||||
for(colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||
for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum + 1) >> 2);
|
||||
}
|
||||
}
|
||||
inrow++;
|
||||
@@ -354,7 +352,7 @@ h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@@ -373,30 +371,30 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* inptr0 points to nearest input row, inptr1 points to next nearest */
|
||||
inptr0 = input_data[inrow];
|
||||
if (v == 0) /* next nearest is row above */
|
||||
inptr1 = input_data[inrow-1];
|
||||
inptr1 = input_data[inrow - 1];
|
||||
else /* next nearest is row below */
|
||||
inptr1 = input_data[inrow+1];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
outptr = output_data[outrow++];
|
||||
|
||||
/* Special case for first column */
|
||||
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 4 + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
|
||||
|
||||
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
|
||||
/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
|
||||
/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
|
||||
nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
|
||||
}
|
||||
|
||||
/* Special case for last column */
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 4 + 7) >> 4);
|
||||
}
|
||||
inrow++;
|
||||
}
|
||||
@@ -408,7 +406,7 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_upsampler (j_decompress_ptr cinfo)
|
||||
jinit_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
int ci;
|
||||
@@ -418,14 +416,14 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
|
||||
if (!cinfo->master->jinit_upsampler_no_alloc) {
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_upsample;
|
||||
upsample->pub.upsample = sep_upsample;
|
||||
upsample->pub.need_context_rows = FALSE; /* until we find out differently */
|
||||
} else
|
||||
upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
if (cinfo->CCIR601_sampling) /* this isn't supported */
|
||||
ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
|
||||
@@ -451,7 +449,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
v_out_group = cinfo->max_v_samp_factor;
|
||||
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
|
||||
need_buffer = TRUE;
|
||||
if (! compptr->component_needed) {
|
||||
if (!compptr->component_needed) {
|
||||
/* Don't bother to upsample an uninteresting component. */
|
||||
upsample->methods[ci] = noop_upsample;
|
||||
need_buffer = FALSE;
|
||||
@@ -459,8 +457,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
/* Fullsize components can be processed without any work. */
|
||||
upsample->methods[ci] = fullsize_upsample;
|
||||
need_buffer = FALSE;
|
||||
} else if (h_in_group * 2 == h_out_group &&
|
||||
v_in_group == v_out_group) {
|
||||
} else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
|
||||
/* Special cases for 2h1v upsampling */
|
||||
if (do_fancy && compptr->downsampled_width > 2) {
|
||||
if (jsimd_can_h2v1_fancy_upsample())
|
||||
@@ -502,16 +499,16 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
else
|
||||
#endif
|
||||
upsample->methods[ci] = int_upsample;
|
||||
upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);
|
||||
upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
|
||||
upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group);
|
||||
upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group);
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
|
||||
if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
|
||||
upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) jround_up((long) cinfo->output_width,
|
||||
(long) cinfo->max_h_samp_factor),
|
||||
(JDIMENSION) cinfo->max_v_samp_factor);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)jround_up((long)cinfo->output_width,
|
||||
(long)cinfo->max_h_samp_factor),
|
||||
(JDIMENSION)cinfo->max_v_samp_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
jdtrans.c
14
jdtrans.c
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(void) transdecode_master_selection (j_decompress_ptr cinfo);
|
||||
LOCAL(void) transdecode_master_selection(j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@@ -45,7 +45,7 @@ LOCAL(void) transdecode_master_selection (j_decompress_ptr cinfo);
|
||||
*/
|
||||
|
||||
GLOBAL(jvirt_barray_ptr *)
|
||||
jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
jpeg_read_coefficients(j_decompress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state == DSTATE_READY) {
|
||||
/* First call: initialize active modules */
|
||||
@@ -58,7 +58,7 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
int retcode;
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL)
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
/* Absorb some more input */
|
||||
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
||||
if (retcode == JPEG_SUSPENDED)
|
||||
@@ -70,7 +70,7 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
|
||||
if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
|
||||
/* startup underestimated number of scans; ratchet up one scan */
|
||||
cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
|
||||
cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
transdecode_master_selection (j_decompress_ptr cinfo)
|
||||
transdecode_master_selection(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* This is effectively a buffered-image operation. */
|
||||
cinfo->buffered_image = TRUE;
|
||||
@@ -129,7 +129,7 @@ transdecode_master_selection (j_decompress_ptr cinfo)
|
||||
jinit_d_coef_controller(cinfo, TRUE);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Initialize input side of decompressor to consume first scan. */
|
||||
(*cinfo->inputctl->start_input_pass) (cinfo);
|
||||
@@ -148,7 +148,7 @@ transdecode_master_selection (j_decompress_ptr cinfo)
|
||||
nscans = 1;
|
||||
}
|
||||
cinfo->progress->pass_counter = 0L;
|
||||
cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->completed_passes = 0;
|
||||
cinfo->progress->total_passes = 1;
|
||||
}
|
||||
|
||||
16
jerror.c
16
jerror.c
@@ -44,7 +44,7 @@
|
||||
* want to refer to it directly.
|
||||
*/
|
||||
|
||||
#define JMESSAGE(code,string) string ,
|
||||
#define JMESSAGE(code, string) string,
|
||||
|
||||
const char * const jpeg_std_message_table[] = {
|
||||
#include "jerror.h"
|
||||
@@ -66,7 +66,7 @@ const char * const jpeg_std_message_table[] = {
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
error_exit (j_common_ptr cinfo)
|
||||
error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
/* Always display the message */
|
||||
(*cinfo->err->output_message) (cinfo);
|
||||
@@ -94,7 +94,7 @@ error_exit (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
output_message (j_common_ptr cinfo)
|
||||
output_message(j_common_ptr cinfo)
|
||||
{
|
||||
char buffer[JMSG_LENGTH_MAX];
|
||||
|
||||
@@ -124,7 +124,7 @@ output_message (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
emit_message (j_common_ptr cinfo, int msg_level)
|
||||
emit_message(j_common_ptr cinfo, int msg_level)
|
||||
{
|
||||
struct jpeg_error_mgr *err = cinfo->err;
|
||||
|
||||
@@ -153,7 +153,7 @@ emit_message (j_common_ptr cinfo, int msg_level)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
format_message (j_common_ptr cinfo, char *buffer)
|
||||
format_message(j_common_ptr cinfo, char *buffer)
|
||||
{
|
||||
struct jpeg_error_mgr *err = cinfo->err;
|
||||
int msg_code = err->msg_code;
|
||||
@@ -208,7 +208,7 @@ format_message (j_common_ptr cinfo, char *buffer)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
reset_error_mgr (j_common_ptr cinfo)
|
||||
reset_error_mgr(j_common_ptr cinfo)
|
||||
{
|
||||
cinfo->err->num_warnings = 0;
|
||||
/* trace_level is not reset since it is an application-supplied parameter */
|
||||
@@ -227,7 +227,7 @@ reset_error_mgr (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(struct jpeg_error_mgr *)
|
||||
jpeg_std_error (struct jpeg_error_mgr *err)
|
||||
jpeg_std_error(struct jpeg_error_mgr *err)
|
||||
{
|
||||
err->error_exit = error_exit;
|
||||
err->emit_message = emit_message;
|
||||
@@ -241,7 +241,7 @@ jpeg_std_error (struct jpeg_error_mgr *err)
|
||||
|
||||
/* Initialize message table pointers */
|
||||
err->jpeg_message_table = jpeg_std_message_table;
|
||||
err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;
|
||||
err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
|
||||
|
||||
err->addon_message_table = NULL;
|
||||
err->first_addon_message = 0; /* for safety */
|
||||
|
||||
86
jerror.h
86
jerror.h
@@ -28,7 +28,7 @@
|
||||
#define JMAKE_ENUM_LIST
|
||||
#else
|
||||
/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
|
||||
#define JMESSAGE(code,string)
|
||||
#define JMESSAGE(code, string)
|
||||
#endif /* JERROR_H */
|
||||
#endif /* JMESSAGE */
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
typedef enum {
|
||||
|
||||
#define JMESSAGE(code,string) code ,
|
||||
#define JMESSAGE(code, string) code,
|
||||
|
||||
#endif /* JMAKE_ENUM_LIST */
|
||||
|
||||
@@ -44,8 +44,7 @@ JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
|
||||
|
||||
/* For maintenance convenience, list is alphabetical by message code name */
|
||||
#if JPEG_LIB_VERSION < 70
|
||||
JMESSAGE(JERR_ARITH_NOTIMPL,
|
||||
"Sorry, arithmetic coding is not implemented")
|
||||
JMESSAGE(JERR_ARITH_NOTIMPL, "Sorry, arithmetic coding is not implemented")
|
||||
#endif
|
||||
JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
|
||||
JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
|
||||
@@ -154,8 +153,7 @@ JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
|
||||
JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
|
||||
JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
|
||||
"Warning: thumbnail image size does not match data length %u")
|
||||
JMESSAGE(JTRC_JFIF_EXTENSION,
|
||||
"JFIF extension marker: type 0x%02x, length %u")
|
||||
JMESSAGE(JTRC_JFIF_EXTENSION, "JFIF extension marker: type 0x%02x, length %u")
|
||||
JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
|
||||
JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
|
||||
JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
|
||||
@@ -229,90 +227,90 @@ JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
|
||||
/* The first parameter is either type of cinfo pointer */
|
||||
|
||||
/* Fatal errors (print message and exit) */
|
||||
#define ERREXIT(cinfo,code) \
|
||||
#define ERREXIT(cinfo, code) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT1(cinfo,code,p1) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT1(cinfo, code, p1) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT2(cinfo,code,p1,p2) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT2(cinfo, code, p1, p2) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT3(cinfo,code,p1,p2,p3) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT3(cinfo, code, p1, p2, p3) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(cinfo)->err->msg_parm.i[2] = (p3), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT4(cinfo, code, p1, p2, p3, p4) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(cinfo)->err->msg_parm.i[2] = (p3), \
|
||||
(cinfo)->err->msg_parm.i[3] = (p4), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXITS(cinfo,code,str) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXITS(cinfo, code, str) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
|
||||
#define MAKESTMT(stuff) do { stuff } while (0)
|
||||
|
||||
/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
|
||||
#define WARNMS(cinfo,code) \
|
||||
#define WARNMS(cinfo, code) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||
#define WARNMS1(cinfo,code,p1) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
||||
#define WARNMS1(cinfo, code, p1) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||
#define WARNMS2(cinfo,code,p1,p2) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
||||
#define WARNMS2(cinfo, code, p1, p2) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
||||
|
||||
/* Informational/debugging messages */
|
||||
#define TRACEMS(cinfo,lvl,code) \
|
||||
#define TRACEMS(cinfo, lvl, code) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
#define TRACEMS1(cinfo,lvl,code,p1) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
#define TRACEMS1(cinfo, lvl, code, p1) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
#define TRACEMS2(cinfo,lvl,code,p1,p2) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
#define TRACEMS2(cinfo, lvl, code, p1, p2) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||
_mp[4] = (p5); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||
_mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMSS(cinfo,lvl,code,str) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMSS(cinfo, lvl, code, str) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
|
||||
#endif /* JERROR_H */
|
||||
|
||||
58
jfdctflt.c
58
jfdctflt.c
@@ -57,7 +57,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_float (FAST_FLOAT *data)
|
||||
jpeg_fdct_float(FAST_FLOAT *data)
|
||||
{
|
||||
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
|
||||
@@ -68,7 +68,7 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
/* Pass 1: process rows. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[0] + dataptr[7];
|
||||
tmp7 = dataptr[0] - dataptr[7];
|
||||
tmp1 = dataptr[1] + dataptr[6];
|
||||
@@ -88,7 +88,7 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
dataptr[0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[4] = tmp10 - tmp11;
|
||||
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
dataptr[2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[6] = tmp13 - z1;
|
||||
|
||||
@@ -99,10 +99,10 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
tmp12 = tmp6 + tmp7;
|
||||
|
||||
/* The rotator is modified from fig 4-8 to avoid extra negations. */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT)0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT)0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT)1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
@@ -118,15 +118,15 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
/* Pass 2: process columns. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
|
||||
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
|
||||
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
|
||||
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
|
||||
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
|
||||
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
|
||||
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
|
||||
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
|
||||
tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
|
||||
tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
|
||||
tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
|
||||
tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
|
||||
tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
|
||||
tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
|
||||
tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
|
||||
|
||||
/* Even part */
|
||||
|
||||
@@ -135,12 +135,12 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE*4] = tmp10 - tmp11;
|
||||
dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE * 4] = tmp10 - tmp11;
|
||||
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE*6] = tmp13 - z1;
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE * 6] = tmp13 - z1;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@@ -149,18 +149,18 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
tmp12 = tmp6 + tmp7;
|
||||
|
||||
/* The rotator is modified from fig 4-8 to avoid extra negations. */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT)0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT)0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT)1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
|
||||
dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE*3] = z13 - z2;
|
||||
dataptr[DCTSIZE*1] = z11 + z4;
|
||||
dataptr[DCTSIZE*7] = z11 - z4;
|
||||
dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE * 3] = z13 - z2;
|
||||
dataptr[DCTSIZE * 1] = z11 + z4;
|
||||
dataptr[DCTSIZE * 7] = z11 - z4;
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
||||
50
jfdctfst.c
50
jfdctfst.c
@@ -79,10 +79,10 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 8
|
||||
#define FIX_0_382683433 ((JLONG) 98) /* FIX(0.382683433) */
|
||||
#define FIX_0_541196100 ((JLONG) 139) /* FIX(0.541196100) */
|
||||
#define FIX_0_707106781 ((JLONG) 181) /* FIX(0.707106781) */
|
||||
#define FIX_1_306562965 ((JLONG) 334) /* FIX(1.306562965) */
|
||||
#define FIX_0_382683433 ((JLONG)98) /* FIX(0.382683433) */
|
||||
#define FIX_0_541196100 ((JLONG)139) /* FIX(0.541196100) */
|
||||
#define FIX_0_707106781 ((JLONG)181) /* FIX(0.707106781) */
|
||||
#define FIX_1_306562965 ((JLONG)334) /* FIX(1.306562965) */
|
||||
#else
|
||||
#define FIX_0_382683433 FIX(0.382683433)
|
||||
#define FIX_0_541196100 FIX(0.541196100)
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
#ifndef USE_ACCURATE_ROUNDING
|
||||
#undef DESCALE
|
||||
#define DESCALE(x,n) RIGHT_SHIFT(x, n)
|
||||
#define DESCALE(x, n) RIGHT_SHIFT(x, n)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
* descale to yield a DCTELEM result.
|
||||
*/
|
||||
|
||||
#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
|
||||
#define MULTIPLY(var, const) ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
|
||||
|
||||
|
||||
/*
|
||||
@@ -114,7 +114,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_ifast (DCTELEM *data)
|
||||
jpeg_fdct_ifast(DCTELEM *data)
|
||||
{
|
||||
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
DCTELEM tmp10, tmp11, tmp12, tmp13;
|
||||
@@ -126,7 +126,7 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
/* Pass 1: process rows. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[0] + dataptr[7];
|
||||
tmp7 = dataptr[0] - dataptr[7];
|
||||
tmp1 = dataptr[1] + dataptr[6];
|
||||
@@ -176,15 +176,15 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
/* Pass 2: process columns. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
|
||||
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
|
||||
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
|
||||
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
|
||||
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
|
||||
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
|
||||
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
|
||||
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
|
||||
tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
|
||||
tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
|
||||
tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
|
||||
tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
|
||||
tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
|
||||
tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
|
||||
tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
|
||||
|
||||
/* Even part */
|
||||
|
||||
@@ -193,12 +193,12 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE*4] = tmp10 - tmp11;
|
||||
dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE * 4] = tmp10 - tmp11;
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
|
||||
dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE*6] = tmp13 - z1;
|
||||
dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE * 6] = tmp13 - z1;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@@ -215,10 +215,10 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
|
||||
dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE*3] = z13 - z2;
|
||||
dataptr[DCTSIZE*1] = z11 + z4;
|
||||
dataptr[DCTSIZE*7] = z11 - z4;
|
||||
dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE * 3] = z13 - z2;
|
||||
dataptr[DCTSIZE * 1] = z11 + z4;
|
||||
dataptr[DCTSIZE * 7] = z11 - z4;
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
||||
116
jfdctint.c
116
jfdctint.c
@@ -93,18 +93,18 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 13
|
||||
#define FIX_0_298631336 ((JLONG) 2446) /* FIX(0.298631336) */
|
||||
#define FIX_0_390180644 ((JLONG) 3196) /* FIX(0.390180644) */
|
||||
#define FIX_0_541196100 ((JLONG) 4433) /* FIX(0.541196100) */
|
||||
#define FIX_0_765366865 ((JLONG) 6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_899976223 ((JLONG) 7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_175875602 ((JLONG) 9633) /* FIX(1.175875602) */
|
||||
#define FIX_1_501321110 ((JLONG) 12299) /* FIX(1.501321110) */
|
||||
#define FIX_1_847759065 ((JLONG) 15137) /* FIX(1.847759065) */
|
||||
#define FIX_1_961570560 ((JLONG) 16069) /* FIX(1.961570560) */
|
||||
#define FIX_2_053119869 ((JLONG) 16819) /* FIX(2.053119869) */
|
||||
#define FIX_2_562915447 ((JLONG) 20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_072711026 ((JLONG) 25172) /* FIX(3.072711026) */
|
||||
#define FIX_0_298631336 ((JLONG)2446) /* FIX(0.298631336) */
|
||||
#define FIX_0_390180644 ((JLONG)3196) /* FIX(0.390180644) */
|
||||
#define FIX_0_541196100 ((JLONG)4433) /* FIX(0.541196100) */
|
||||
#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_175875602 ((JLONG)9633) /* FIX(1.175875602) */
|
||||
#define FIX_1_501321110 ((JLONG)12299) /* FIX(1.501321110) */
|
||||
#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
|
||||
#define FIX_1_961570560 ((JLONG)16069) /* FIX(1.961570560) */
|
||||
#define FIX_2_053119869 ((JLONG)16819) /* FIX(2.053119869) */
|
||||
#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_072711026 ((JLONG)25172) /* FIX(3.072711026) */
|
||||
#else
|
||||
#define FIX_0_298631336 FIX(0.298631336)
|
||||
#define FIX_0_390180644 FIX(0.390180644)
|
||||
@@ -129,9 +129,9 @@
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
|
||||
#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
|
||||
#else
|
||||
#define MULTIPLY(var,const) ((var) * (const))
|
||||
#define MULTIPLY(var, const) ((var) * (const))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_islow (DCTELEM *data)
|
||||
jpeg_fdct_islow(DCTELEM *data)
|
||||
{
|
||||
JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
JLONG tmp10, tmp11, tmp12, tmp13;
|
||||
@@ -154,7 +154,7 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
/* furthermore, we scale the results by 2**PASS1_BITS. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[0] + dataptr[7];
|
||||
tmp7 = dataptr[0] - dataptr[7];
|
||||
tmp1 = dataptr[1] + dataptr[6];
|
||||
@@ -173,14 +173,14 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[0] = (DCTELEM) LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[4] = (DCTELEM) LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
|
||||
dataptr[0] = (DCTELEM)LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[4] = (DCTELEM)LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
|
||||
dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS-PASS1_BITS);
|
||||
dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
|
||||
CONST_BITS-PASS1_BITS);
|
||||
dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS - PASS1_BITS);
|
||||
dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
|
||||
CONST_BITS - PASS1_BITS);
|
||||
|
||||
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
|
||||
* cK represents cos(K*pi/16).
|
||||
@@ -197,18 +197,18 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
|
||||
tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
|
||||
tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
|
||||
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
|
||||
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
|
||||
z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
|
||||
z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
|
||||
|
||||
z3 += z5;
|
||||
z4 += z5;
|
||||
|
||||
dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
|
||||
dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
|
||||
dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
|
||||
dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
|
||||
dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
|
||||
dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
|
||||
dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
|
||||
dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
|
||||
|
||||
dataptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
@@ -219,15 +219,15 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
*/
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
|
||||
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
|
||||
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
|
||||
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
|
||||
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
|
||||
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
|
||||
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
|
||||
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
|
||||
tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
|
||||
tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
|
||||
tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
|
||||
tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
|
||||
tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
|
||||
tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
|
||||
tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
|
||||
|
||||
/* Even part per LL&M figure 1 --- note that published figure is faulty;
|
||||
* rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
|
||||
@@ -238,14 +238,16 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
|
||||
dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
|
||||
dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE * 2] =
|
||||
(DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 6] =
|
||||
(DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
|
||||
CONST_BITS + PASS1_BITS);
|
||||
|
||||
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
|
||||
* cK represents cos(K*pi/16).
|
||||
@@ -262,22 +264,22 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
|
||||
tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
|
||||
tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
|
||||
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
|
||||
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
|
||||
z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
|
||||
z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
|
||||
|
||||
z3 += z5;
|
||||
z4 += z5;
|
||||
|
||||
dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
||||
110
jidctflt.c
110
jidctflt.c
@@ -61,7 +61,7 @@
|
||||
* entry; produce a float result.
|
||||
*/
|
||||
|
||||
#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval))
|
||||
#define DEQUANTIZE(coef, quantval) (((FAST_FLOAT)(coef)) * (quantval))
|
||||
|
||||
|
||||
/*
|
||||
@@ -69,9 +69,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
|
||||
@@ -83,12 +83,12 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int ctr;
|
||||
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
|
||||
#define _0_125 ((FLOAT_MULT_TYPE)0.125)
|
||||
#define _0_125 ((FLOAT_MULT_TYPE)0.125)
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (FLOAT_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; ctr--) {
|
||||
/* Due to quantization, we will usually find that many of the input
|
||||
@@ -100,22 +100,22 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* column DCT calculations can be simplified this way.
|
||||
*/
|
||||
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
||||
inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
|
||||
inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
|
||||
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
|
||||
inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero */
|
||||
FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0],
|
||||
quantptr[DCTSIZE*0] * _0_125);
|
||||
FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE * 0],
|
||||
quantptr[DCTSIZE * 0] * _0_125);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE*2] = dcval;
|
||||
wsptr[DCTSIZE*3] = dcval;
|
||||
wsptr[DCTSIZE*4] = dcval;
|
||||
wsptr[DCTSIZE*5] = dcval;
|
||||
wsptr[DCTSIZE*6] = dcval;
|
||||
wsptr[DCTSIZE*7] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
wsptr[DCTSIZE * 2] = dcval;
|
||||
wsptr[DCTSIZE * 3] = dcval;
|
||||
wsptr[DCTSIZE * 4] = dcval;
|
||||
wsptr[DCTSIZE * 5] = dcval;
|
||||
wsptr[DCTSIZE * 6] = dcval;
|
||||
wsptr[DCTSIZE * 7] = dcval;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@@ -125,16 +125,16 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0] * _0_125);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2] * _0_125);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4] * _0_125);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6] * _0_125);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0] * _0_125);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2] * _0_125);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4] * _0_125);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6] * _0_125);
|
||||
|
||||
tmp10 = tmp0 + tmp2; /* phase 3 */
|
||||
tmp11 = tmp0 - tmp2;
|
||||
|
||||
tmp13 = tmp1 + tmp3; /* phases 5-3 */
|
||||
tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
|
||||
tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT)1.414213562) - tmp13; /* 2*c4 */
|
||||
|
||||
tmp0 = tmp10 + tmp13; /* phase 2 */
|
||||
tmp3 = tmp10 - tmp13;
|
||||
@@ -143,10 +143,10 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1] * _0_125);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3] * _0_125);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5] * _0_125);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7] * _0_125);
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1] * _0_125);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3] * _0_125);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5] * _0_125);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7] * _0_125);
|
||||
|
||||
z13 = tmp6 + tmp5; /* phase 6 */
|
||||
z10 = tmp6 - tmp5;
|
||||
@@ -154,24 +154,24 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
z12 = tmp4 - tmp7;
|
||||
|
||||
tmp7 = z11 + z13; /* phase 5 */
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT)1.414213562); /* 2*c4 */
|
||||
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT)1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT)1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT)2.613125930); /* 2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
tmp4 = tmp10 - tmp5;
|
||||
|
||||
wsptr[DCTSIZE*0] = tmp0 + tmp7;
|
||||
wsptr[DCTSIZE*7] = tmp0 - tmp7;
|
||||
wsptr[DCTSIZE*1] = tmp1 + tmp6;
|
||||
wsptr[DCTSIZE*6] = tmp1 - tmp6;
|
||||
wsptr[DCTSIZE*2] = tmp2 + tmp5;
|
||||
wsptr[DCTSIZE*5] = tmp2 - tmp5;
|
||||
wsptr[DCTSIZE*3] = tmp3 + tmp4;
|
||||
wsptr[DCTSIZE*4] = tmp3 - tmp4;
|
||||
wsptr[DCTSIZE * 0] = tmp0 + tmp7;
|
||||
wsptr[DCTSIZE * 7] = tmp0 - tmp7;
|
||||
wsptr[DCTSIZE * 1] = tmp1 + tmp6;
|
||||
wsptr[DCTSIZE * 6] = tmp1 - tmp6;
|
||||
wsptr[DCTSIZE * 2] = tmp2 + tmp5;
|
||||
wsptr[DCTSIZE * 5] = tmp2 - tmp5;
|
||||
wsptr[DCTSIZE * 3] = tmp3 + tmp4;
|
||||
wsptr[DCTSIZE * 4] = tmp3 - tmp4;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@@ -192,12 +192,12 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* Even part */
|
||||
|
||||
/* Apply signed->unsigned and prepare float->int conversion */
|
||||
z5 = wsptr[0] + ((FAST_FLOAT) CENTERJSAMPLE + (FAST_FLOAT) 0.5);
|
||||
z5 = wsptr[0] + ((FAST_FLOAT)CENTERJSAMPLE + (FAST_FLOAT)0.5);
|
||||
tmp10 = z5 + wsptr[4];
|
||||
tmp11 = z5 - wsptr[4];
|
||||
|
||||
tmp13 = wsptr[2] + wsptr[6];
|
||||
tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;
|
||||
tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT)1.414213562) - tmp13;
|
||||
|
||||
tmp0 = tmp10 + tmp13;
|
||||
tmp3 = tmp10 - tmp13;
|
||||
@@ -212,11 +212,11 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
z12 = wsptr[1] - wsptr[7];
|
||||
|
||||
tmp7 = z11 + z13;
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT)1.414213562);
|
||||
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT)1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT)1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT)2.613125930); /* 2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7;
|
||||
tmp5 = tmp11 - tmp6;
|
||||
@@ -224,14 +224,14 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Final output stage: float->int conversion and range-limit */
|
||||
|
||||
outptr[0] = range_limit[((int) (tmp0 + tmp7)) & RANGE_MASK];
|
||||
outptr[7] = range_limit[((int) (tmp0 - tmp7)) & RANGE_MASK];
|
||||
outptr[1] = range_limit[((int) (tmp1 + tmp6)) & RANGE_MASK];
|
||||
outptr[6] = range_limit[((int) (tmp1 - tmp6)) & RANGE_MASK];
|
||||
outptr[2] = range_limit[((int) (tmp2 + tmp5)) & RANGE_MASK];
|
||||
outptr[5] = range_limit[((int) (tmp2 - tmp5)) & RANGE_MASK];
|
||||
outptr[3] = range_limit[((int) (tmp3 + tmp4)) & RANGE_MASK];
|
||||
outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK];
|
||||
outptr[0] = range_limit[((int)(tmp0 + tmp7)) & RANGE_MASK];
|
||||
outptr[7] = range_limit[((int)(tmp0 - tmp7)) & RANGE_MASK];
|
||||
outptr[1] = range_limit[((int)(tmp1 + tmp6)) & RANGE_MASK];
|
||||
outptr[6] = range_limit[((int)(tmp1 - tmp6)) & RANGE_MASK];
|
||||
outptr[2] = range_limit[((int)(tmp2 + tmp5)) & RANGE_MASK];
|
||||
outptr[5] = range_limit[((int)(tmp2 - tmp5)) & RANGE_MASK];
|
||||
outptr[3] = range_limit[((int)(tmp3 + tmp4)) & RANGE_MASK];
|
||||
outptr[4] = range_limit[((int)(tmp3 - tmp4)) & RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
|
||||
152
jidctfst.c
152
jidctfst.c
@@ -92,10 +92,10 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 8
|
||||
#define FIX_1_082392200 ((JLONG) 277) /* FIX(1.082392200) */
|
||||
#define FIX_1_414213562 ((JLONG) 362) /* FIX(1.414213562) */
|
||||
#define FIX_1_847759065 ((JLONG) 473) /* FIX(1.847759065) */
|
||||
#define FIX_2_613125930 ((JLONG) 669) /* FIX(2.613125930) */
|
||||
#define FIX_1_082392200 ((JLONG)277) /* FIX(1.082392200) */
|
||||
#define FIX_1_414213562 ((JLONG)362) /* FIX(1.414213562) */
|
||||
#define FIX_1_847759065 ((JLONG)473) /* FIX(1.847759065) */
|
||||
#define FIX_2_613125930 ((JLONG)669) /* FIX(2.613125930) */
|
||||
#else
|
||||
#define FIX_1_082392200 FIX(1.082392200)
|
||||
#define FIX_1_414213562 FIX(1.414213562)
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
#ifndef USE_ACCURATE_ROUNDING
|
||||
#undef DESCALE
|
||||
#define DESCALE(x,n) RIGHT_SHIFT(x, n)
|
||||
#define DESCALE(x, n) RIGHT_SHIFT(x, n)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
* descale to yield a DCTELEM result.
|
||||
*/
|
||||
|
||||
#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
|
||||
#define MULTIPLY(var, const) ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
|
||||
|
||||
|
||||
/* Dequantize a coefficient by multiplying it by the multiplier-table
|
||||
@@ -129,10 +129,10 @@
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval))
|
||||
#define DEQUANTIZE(coef, quantval) (((IFAST_MULT_TYPE)(coef)) * (quantval))
|
||||
#else
|
||||
#define DEQUANTIZE(coef,quantval) \
|
||||
DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)
|
||||
#define DEQUANTIZE(coef, quantval) \
|
||||
DESCALE((coef) * (quantval), IFAST_SCALE_BITS - PASS1_BITS)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -147,19 +147,19 @@
|
||||
#else
|
||||
#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
|
||||
#endif
|
||||
#define IRIGHT_SHIFT(x,shft) \
|
||||
#define IRIGHT_SHIFT(x, shft) \
|
||||
((ishift_temp = (x)) < 0 ? \
|
||||
(ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
|
||||
(ishift_temp >> (shft)) | ((~((DCTELEM)0)) << (DCTELEMBITS - (shft))) : \
|
||||
(ishift_temp >> (shft)))
|
||||
#else
|
||||
#define ISHIFT_TEMPS
|
||||
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
#ifdef USE_ACCURATE_ROUNDING
|
||||
#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))
|
||||
#define IDESCALE(x, n) ((int)IRIGHT_SHIFT((x) + (1 << ((n) - 1)), n))
|
||||
#else
|
||||
#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n))
|
||||
#define IDESCALE(x, n) ((int)IRIGHT_SHIFT(x, n))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -168,9 +168,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
DCTELEM tmp10, tmp11, tmp12, tmp13;
|
||||
@@ -188,7 +188,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (IFAST_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; ctr--) {
|
||||
/* Due to quantization, we will usually find that many of the input
|
||||
@@ -200,21 +200,21 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* column DCT calculations can be simplified this way.
|
||||
*/
|
||||
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
||||
inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
|
||||
inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
|
||||
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
|
||||
inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero */
|
||||
int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
int dcval = (int)DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE*2] = dcval;
|
||||
wsptr[DCTSIZE*3] = dcval;
|
||||
wsptr[DCTSIZE*4] = dcval;
|
||||
wsptr[DCTSIZE*5] = dcval;
|
||||
wsptr[DCTSIZE*6] = dcval;
|
||||
wsptr[DCTSIZE*7] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
wsptr[DCTSIZE * 2] = dcval;
|
||||
wsptr[DCTSIZE * 3] = dcval;
|
||||
wsptr[DCTSIZE * 4] = dcval;
|
||||
wsptr[DCTSIZE * 5] = dcval;
|
||||
wsptr[DCTSIZE * 6] = dcval;
|
||||
wsptr[DCTSIZE * 7] = dcval;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@@ -224,10 +224,10 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
|
||||
|
||||
tmp10 = tmp0 + tmp2; /* phase 3 */
|
||||
tmp11 = tmp0 - tmp2;
|
||||
@@ -242,10 +242,10 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
|
||||
|
||||
z13 = tmp6 + tmp5; /* phase 6 */
|
||||
z10 = tmp6 - tmp5;
|
||||
@@ -257,20 +257,20 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
||||
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
||||
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
tmp4 = tmp10 + tmp5;
|
||||
|
||||
wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
|
||||
wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
|
||||
wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6);
|
||||
wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
|
||||
wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
|
||||
wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
|
||||
wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
|
||||
wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);
|
||||
wsptr[DCTSIZE * 0] = (int)(tmp0 + tmp7);
|
||||
wsptr[DCTSIZE * 7] = (int)(tmp0 - tmp7);
|
||||
wsptr[DCTSIZE * 1] = (int)(tmp1 + tmp6);
|
||||
wsptr[DCTSIZE * 6] = (int)(tmp1 - tmp6);
|
||||
wsptr[DCTSIZE * 2] = (int)(tmp2 + tmp5);
|
||||
wsptr[DCTSIZE * 5] = (int)(tmp2 - tmp5);
|
||||
wsptr[DCTSIZE * 4] = (int)(tmp3 + tmp4);
|
||||
wsptr[DCTSIZE * 3] = (int)(tmp3 - tmp4);
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@@ -296,8 +296,8 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
|
||||
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
||||
/* AC terms all zero */
|
||||
JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
JSAMPLE dcval =
|
||||
range_limit[IDESCALE(wsptr[0], PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
outptr[0] = dcval;
|
||||
outptr[1] = dcval;
|
||||
@@ -315,12 +315,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
|
||||
tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
|
||||
tmp10 = ((DCTELEM)wsptr[0] + (DCTELEM)wsptr[4]);
|
||||
tmp11 = ((DCTELEM)wsptr[0] - (DCTELEM)wsptr[4]);
|
||||
|
||||
tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
|
||||
tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
|
||||
- tmp13;
|
||||
tmp13 = ((DCTELEM)wsptr[2] + (DCTELEM)wsptr[6]);
|
||||
tmp12 =
|
||||
MULTIPLY((DCTELEM)wsptr[2] - (DCTELEM)wsptr[6], FIX_1_414213562) - tmp13;
|
||||
|
||||
tmp0 = tmp10 + tmp13;
|
||||
tmp3 = tmp10 - tmp13;
|
||||
@@ -329,17 +329,17 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];
|
||||
z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];
|
||||
z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
|
||||
z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];
|
||||
z13 = (DCTELEM)wsptr[5] + (DCTELEM)wsptr[3];
|
||||
z10 = (DCTELEM)wsptr[5] - (DCTELEM)wsptr[3];
|
||||
z11 = (DCTELEM)wsptr[1] + (DCTELEM)wsptr[7];
|
||||
z12 = (DCTELEM)wsptr[1] - (DCTELEM)wsptr[7];
|
||||
|
||||
tmp7 = z11 + z13; /* phase 5 */
|
||||
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
||||
|
||||
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
||||
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
||||
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
@@ -347,22 +347,22 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Final output stage: scale down by a factor of 8 and range-limit */
|
||||
|
||||
outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[0] =
|
||||
range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[7] =
|
||||
range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[1] =
|
||||
range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[6] =
|
||||
range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[2] =
|
||||
range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[5] =
|
||||
range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[4] =
|
||||
range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[3] =
|
||||
range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
|
||||
1720
jidctint.c
1720
jidctint.c
File diff suppressed because it is too large
Load Diff
252
jidctred.c
252
jidctred.c
@@ -58,20 +58,20 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 13
|
||||
#define FIX_0_211164243 ((JLONG) 1730) /* FIX(0.211164243) */
|
||||
#define FIX_0_509795579 ((JLONG) 4176) /* FIX(0.509795579) */
|
||||
#define FIX_0_601344887 ((JLONG) 4926) /* FIX(0.601344887) */
|
||||
#define FIX_0_720959822 ((JLONG) 5906) /* FIX(0.720959822) */
|
||||
#define FIX_0_765366865 ((JLONG) 6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_850430095 ((JLONG) 6967) /* FIX(0.850430095) */
|
||||
#define FIX_0_899976223 ((JLONG) 7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_061594337 ((JLONG) 8697) /* FIX(1.061594337) */
|
||||
#define FIX_1_272758580 ((JLONG) 10426) /* FIX(1.272758580) */
|
||||
#define FIX_1_451774981 ((JLONG) 11893) /* FIX(1.451774981) */
|
||||
#define FIX_1_847759065 ((JLONG) 15137) /* FIX(1.847759065) */
|
||||
#define FIX_2_172734803 ((JLONG) 17799) /* FIX(2.172734803) */
|
||||
#define FIX_2_562915447 ((JLONG) 20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_624509785 ((JLONG) 29692) /* FIX(3.624509785) */
|
||||
#define FIX_0_211164243 ((JLONG)1730) /* FIX(0.211164243) */
|
||||
#define FIX_0_509795579 ((JLONG)4176) /* FIX(0.509795579) */
|
||||
#define FIX_0_601344887 ((JLONG)4926) /* FIX(0.601344887) */
|
||||
#define FIX_0_720959822 ((JLONG)5906) /* FIX(0.720959822) */
|
||||
#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_850430095 ((JLONG)6967) /* FIX(0.850430095) */
|
||||
#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_061594337 ((JLONG)8697) /* FIX(1.061594337) */
|
||||
#define FIX_1_272758580 ((JLONG)10426) /* FIX(1.272758580) */
|
||||
#define FIX_1_451774981 ((JLONG)11893) /* FIX(1.451774981) */
|
||||
#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
|
||||
#define FIX_2_172734803 ((JLONG)17799) /* FIX(2.172734803) */
|
||||
#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_624509785 ((JLONG)29692) /* FIX(3.624509785) */
|
||||
#else
|
||||
#define FIX_0_211164243 FIX(0.211164243)
|
||||
#define FIX_0_509795579 FIX(0.509795579)
|
||||
@@ -98,9 +98,9 @@
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
|
||||
#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
|
||||
#else
|
||||
#define MULTIPLY(var,const) ((var) * (const))
|
||||
#define MULTIPLY(var, const) ((var) * (const))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
* are 16 bits or less, so either int or short multiply will work.
|
||||
*/
|
||||
|
||||
#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval))
|
||||
#define DEQUANTIZE(coef, quantval) (((ISLOW_MULT_TYPE)(coef)) * (quantval))
|
||||
|
||||
|
||||
/*
|
||||
@@ -118,9 +118,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
JLONG tmp0, tmp2, tmp10, tmp12;
|
||||
JLONG z1, z2, z3, z4;
|
||||
@@ -130,69 +130,73 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPROW outptr;
|
||||
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
||||
int ctr;
|
||||
int workspace[DCTSIZE*4]; /* buffers data between passes */
|
||||
int workspace[DCTSIZE * 4]; /* buffers data between passes */
|
||||
SHIFT_TEMPS
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
|
||||
/* Don't bother to process column 4, because second pass won't use it */
|
||||
if (ctr == DCTSIZE-4)
|
||||
if (ctr == DCTSIZE - 4)
|
||||
continue;
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
|
||||
inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
|
||||
inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 5] == 0 &&
|
||||
inptr[DCTSIZE * 6] == 0 && inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero; we need not examine term 4 for 4x4 output */
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
|
||||
quantptr[DCTSIZE * 0]), PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE*2] = dcval;
|
||||
wsptr[DCTSIZE*3] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
wsptr[DCTSIZE * 2] = dcval;
|
||||
wsptr[DCTSIZE * 3] = dcval;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS+1);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS + 1);
|
||||
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
|
||||
|
||||
tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
|
||||
tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, -FIX_0_765366865);
|
||||
|
||||
tmp10 = tmp0 + tmp2;
|
||||
tmp12 = tmp0 - tmp2;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
|
||||
|
||||
tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
|
||||
+ MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
|
||||
+ MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
|
||||
+ MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
|
||||
tmp0 = MULTIPLY(z1, -FIX_0_211164243) + /* sqrt(2) * ( c3-c1) */
|
||||
MULTIPLY(z2, FIX_1_451774981) + /* sqrt(2) * ( c3+c7) */
|
||||
MULTIPLY(z3, -FIX_2_172734803) + /* sqrt(2) * (-c1-c5) */
|
||||
MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * ( c5+c7) */
|
||||
|
||||
tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
|
||||
+ MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
|
||||
+ MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
|
||||
+ MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
tmp2 = MULTIPLY(z1, -FIX_0_509795579) + /* sqrt(2) * (c7-c5) */
|
||||
MULTIPLY(z2, -FIX_0_601344887) + /* sqrt(2) * (c5-c1) */
|
||||
MULTIPLY(z3, FIX_0_899976223) + /* sqrt(2) * (c3-c7) */
|
||||
MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE * 0] =
|
||||
(int)DESCALE(tmp10 + tmp2, CONST_BITS - PASS1_BITS + 1);
|
||||
wsptr[DCTSIZE * 3] =
|
||||
(int)DESCALE(tmp10 - tmp2, CONST_BITS - PASS1_BITS + 1);
|
||||
wsptr[DCTSIZE * 1] =
|
||||
(int)DESCALE(tmp12 + tmp0, CONST_BITS - PASS1_BITS + 1);
|
||||
wsptr[DCTSIZE * 2] =
|
||||
(int)DESCALE(tmp12 - tmp0, CONST_BITS - PASS1_BITS + 1);
|
||||
}
|
||||
|
||||
/* Pass 2: process 4 rows from work array, store into output array. */
|
||||
@@ -206,8 +210,8 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
|
||||
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
||||
/* AC terms all zero */
|
||||
JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
|
||||
PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
outptr[0] = dcval;
|
||||
outptr[1] = dcval;
|
||||
@@ -221,45 +225,45 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+1);
|
||||
tmp0 = LEFT_SHIFT((JLONG)wsptr[0], CONST_BITS + 1);
|
||||
|
||||
tmp2 = MULTIPLY((JLONG) wsptr[2], FIX_1_847759065)
|
||||
+ MULTIPLY((JLONG) wsptr[6], - FIX_0_765366865);
|
||||
tmp2 = MULTIPLY((JLONG)wsptr[2], FIX_1_847759065) +
|
||||
MULTIPLY((JLONG)wsptr[6], -FIX_0_765366865);
|
||||
|
||||
tmp10 = tmp0 + tmp2;
|
||||
tmp12 = tmp0 - tmp2;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z1 = (JLONG) wsptr[7];
|
||||
z2 = (JLONG) wsptr[5];
|
||||
z3 = (JLONG) wsptr[3];
|
||||
z4 = (JLONG) wsptr[1];
|
||||
z1 = (JLONG)wsptr[7];
|
||||
z2 = (JLONG)wsptr[5];
|
||||
z3 = (JLONG)wsptr[3];
|
||||
z4 = (JLONG)wsptr[1];
|
||||
|
||||
tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
|
||||
+ MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
|
||||
+ MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
|
||||
+ MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
|
||||
tmp0 = MULTIPLY(z1, -FIX_0_211164243) + /* sqrt(2) * ( c3-c1) */
|
||||
MULTIPLY(z2, FIX_1_451774981) + /* sqrt(2) * ( c3+c7) */
|
||||
MULTIPLY(z3, -FIX_2_172734803) + /* sqrt(2) * (-c1-c5) */
|
||||
MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * ( c5+c7) */
|
||||
|
||||
tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
|
||||
+ MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
|
||||
+ MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
|
||||
+ MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
tmp2 = MULTIPLY(z1, -FIX_0_509795579) + /* sqrt(2) * (c7-c5) */
|
||||
MULTIPLY(z2, -FIX_0_601344887) + /* sqrt(2) * (c5-c1) */
|
||||
MULTIPLY(z3, FIX_0_899976223) + /* sqrt(2) * (c3-c7) */
|
||||
MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp2,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
outptr[3] = range_limit[(int)DESCALE(tmp10 - tmp2,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
outptr[1] = range_limit[(int)DESCALE(tmp12 + tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
outptr[2] = range_limit[(int)DESCALE(tmp12 - tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
@@ -272,9 +276,9 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
JLONG tmp0, tmp10, z1;
|
||||
JCOEFPTR inptr;
|
||||
@@ -283,50 +287,52 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPROW outptr;
|
||||
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
||||
int ctr;
|
||||
int workspace[DCTSIZE*2]; /* buffers data between passes */
|
||||
int workspace[DCTSIZE * 2]; /* buffers data between passes */
|
||||
SHIFT_TEMPS
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
|
||||
/* Don't bother to process columns 2,4,6 */
|
||||
if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
|
||||
if (ctr == DCTSIZE - 2 || ctr == DCTSIZE - 4 || ctr == DCTSIZE - 6)
|
||||
continue;
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 3] == 0 &&
|
||||
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
|
||||
quantptr[DCTSIZE * 0]), PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Even part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp10 = LEFT_SHIFT(z1, CONST_BITS+2);
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
tmp10 = LEFT_SHIFT(z1, CONST_BITS + 2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
|
||||
tmp0 = MULTIPLY(z1, -FIX_0_720959822); /* sqrt(2) * ( c7-c5+c3-c1) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
|
||||
tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
||||
tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
|
||||
tmp0 += MULTIPLY(z1, -FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
|
||||
tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * ( c1+c3+c5+c7) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
|
||||
wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
|
||||
wsptr[DCTSIZE * 0] =
|
||||
(int)DESCALE(tmp10 + tmp0, CONST_BITS - PASS1_BITS + 2);
|
||||
wsptr[DCTSIZE * 1] =
|
||||
(int)DESCALE(tmp10 - tmp0, CONST_BITS - PASS1_BITS + 2);
|
||||
}
|
||||
|
||||
/* Pass 2: process 2 rows from work array, store into output array. */
|
||||
@@ -339,8 +345,8 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
#ifndef NO_ZERO_ROW_TEST
|
||||
if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
|
||||
/* AC terms all zero */
|
||||
JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
|
||||
PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
outptr[0] = dcval;
|
||||
outptr[1] = dcval;
|
||||
@@ -352,23 +358,23 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp10 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+2);
|
||||
tmp10 = LEFT_SHIFT((JLONG)wsptr[0], CONST_BITS + 2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp0 = MULTIPLY((JLONG) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
|
||||
+ MULTIPLY((JLONG) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
|
||||
+ MULTIPLY((JLONG) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
+ MULTIPLY((JLONG) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
|
||||
tmp0 = MULTIPLY((JLONG)wsptr[7], -FIX_0_720959822) + /* sqrt(2) * ( c7-c5+c3-c1) */
|
||||
MULTIPLY((JLONG)wsptr[5], FIX_0_850430095) + /* sqrt(2) * (-c1+c3+c5+c7) */
|
||||
MULTIPLY((JLONG)wsptr[3], -FIX_1_272758580) + /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
MULTIPLY((JLONG)wsptr[1], FIX_3_624509785); /* sqrt(2) * ( c1+c3+c5+c7) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+2)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+2)
|
||||
& RANGE_MASK];
|
||||
outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 2) &
|
||||
RANGE_MASK];
|
||||
outptr[1] = range_limit[(int)DESCALE(tmp10 - tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 2) &
|
||||
RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
@@ -381,9 +387,9 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
int dcval;
|
||||
ISLOW_MULT_TYPE *quantptr;
|
||||
@@ -393,9 +399,9 @@ jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* We hardly need an inverse DCT routine for this: just take the
|
||||
* average pixel value, which is one-eighth of the DC coefficient.
|
||||
*/
|
||||
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
|
||||
dcval = (int) DESCALE((JLONG) dcval, 3);
|
||||
dcval = (int)DESCALE((JLONG)dcval, 3);
|
||||
|
||||
output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
|
||||
}
|
||||
|
||||
20
jinclude.h
20
jinclude.h
@@ -61,14 +61,18 @@
|
||||
#ifdef NEED_BSD_STRINGS
|
||||
|
||||
#include <strings.h>
|
||||
#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
|
||||
#define MEMZERO(target, size) \
|
||||
bzero((void *)(target), (size_t)(size))
|
||||
#define MEMCOPY(dest, src, size) \
|
||||
bcopy((const void *)(src), (void *)(dest), (size_t)(size))
|
||||
|
||||
#else /* not BSD, assume ANSI/SysV string lib */
|
||||
|
||||
#include <string.h>
|
||||
#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
|
||||
#define MEMZERO(target, size) \
|
||||
memset((void *)(target), 0, (size_t)(size))
|
||||
#define MEMCOPY(dest, src, size) \
|
||||
memcpy((void *)(dest), (const void *)(src), (size_t)(size))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -78,7 +82,7 @@
|
||||
* CAUTION: argument order is different from underlying functions!
|
||||
*/
|
||||
|
||||
#define JFREAD(file,buf,sizeofbuf) \
|
||||
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFWRITE(file,buf,sizeofbuf) \
|
||||
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFREAD(file, buf, sizeofbuf) \
|
||||
((size_t)fread((void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
|
||||
#define JFWRITE(file, buf, sizeofbuf) \
|
||||
((size_t)fwrite((const void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
|
||||
|
||||
270
jmemmgr.c
270
jmemmgr.c
@@ -39,13 +39,13 @@
|
||||
|
||||
#ifndef NO_GETENV
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
||||
extern char *getenv (const char *name);
|
||||
extern char *getenv(const char *name);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(size_t)
|
||||
round_up_pow2 (size_t a, size_t b)
|
||||
round_up_pow2(size_t a, size_t b)
|
||||
/* a rounded up to the next multiple of b, i.e. ceil(a/b)*b */
|
||||
/* Assumes a >= 0, b > 0, and b is a power of 2 */
|
||||
{
|
||||
@@ -193,9 +193,9 @@ struct jvirt_barray_control {
|
||||
#ifdef MEM_STATS /* optional extra stuff for statistics */
|
||||
|
||||
LOCAL(void)
|
||||
print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
print_mem_stats(j_common_ptr cinfo, int pool_id)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr shdr_ptr;
|
||||
large_pool_ptr lhdr_ptr;
|
||||
|
||||
@@ -208,15 +208,13 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
|
||||
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
|
||||
lhdr_ptr = lhdr_ptr->next) {
|
||||
fprintf(stderr, " Large chunk used %ld\n",
|
||||
(long) lhdr_ptr->bytes_used);
|
||||
fprintf(stderr, " Large chunk used %ld\n", (long)lhdr_ptr->bytes_used);
|
||||
}
|
||||
|
||||
for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL;
|
||||
shdr_ptr = shdr_ptr->next) {
|
||||
fprintf(stderr, " Small chunk used %ld free %ld\n",
|
||||
(long) shdr_ptr->bytes_used,
|
||||
(long) shdr_ptr->bytes_left);
|
||||
(long)shdr_ptr->bytes_used, (long)shdr_ptr->bytes_left);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +222,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
out_of_memory (j_common_ptr cinfo, int which)
|
||||
out_of_memory(j_common_ptr cinfo, int which)
|
||||
/* Report an out-of-memory error and stop execution */
|
||||
/* If we compiled MEM_STATS support, report alloc requests before dying */
|
||||
{
|
||||
@@ -252,14 +250,12 @@ out_of_memory (j_common_ptr cinfo, int which)
|
||||
* adjustment.
|
||||
*/
|
||||
|
||||
static const size_t first_pool_slop[JPOOL_NUMPOOLS] =
|
||||
{
|
||||
static const size_t first_pool_slop[JPOOL_NUMPOOLS] = {
|
||||
1600, /* first PERMANENT pool */
|
||||
16000 /* first IMAGE pool */
|
||||
};
|
||||
|
||||
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
|
||||
{
|
||||
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = {
|
||||
0, /* additional PERMANENT pools */
|
||||
5000 /* additional IMAGE pools */
|
||||
};
|
||||
@@ -268,10 +264,10 @@ static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
|
||||
|
||||
|
||||
METHODDEF(void *)
|
||||
alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
alloc_small(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* Allocate a "small" object */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr hdr_ptr, prev_hdr_ptr;
|
||||
char *data_ptr;
|
||||
size_t min_request, slop;
|
||||
@@ -315,11 +311,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
else
|
||||
slop = extra_pool_slop[pool_id];
|
||||
/* Don't ask for more than MAX_ALLOC_CHUNK */
|
||||
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))
|
||||
slop = (size_t) (MAX_ALLOC_CHUNK-min_request);
|
||||
if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
|
||||
slop = (size_t)(MAX_ALLOC_CHUNK - min_request);
|
||||
/* Try to get space, if fail reduce slop and try again */
|
||||
for (;;) {
|
||||
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
|
||||
hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
|
||||
if (hdr_ptr != NULL)
|
||||
break;
|
||||
slop /= 2;
|
||||
@@ -338,7 +334,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
}
|
||||
|
||||
/* OK, allocate the object from the current pool */
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
|
||||
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
|
||||
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
|
||||
@@ -346,7 +342,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
hdr_ptr->bytes_used += sizeofobject;
|
||||
hdr_ptr->bytes_left -= sizeofobject;
|
||||
|
||||
return (void *) data_ptr;
|
||||
return (void *)data_ptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -364,10 +360,10 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
METHODDEF(void *)
|
||||
alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
alloc_large(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* Allocate a "large" object */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
large_pool_ptr hdr_ptr;
|
||||
char *data_ptr;
|
||||
|
||||
@@ -392,7 +388,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject +
|
||||
hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
|
||||
sizeof(large_pool_hdr) +
|
||||
ALIGN_SIZE - 1);
|
||||
if (hdr_ptr == NULL)
|
||||
@@ -409,12 +405,12 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
hdr_ptr->bytes_left = 0;
|
||||
mem->large_list[pool_id] = hdr_ptr;
|
||||
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
|
||||
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
|
||||
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
|
||||
|
||||
return (void *) data_ptr;
|
||||
return (void *)data_ptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -435,11 +431,11 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
METHODDEF(JSAMPARRAY)
|
||||
alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows)
|
||||
alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
|
||||
JDIMENSION numrows)
|
||||
/* Allocate a 2-D sample array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
JSAMPARRAY result;
|
||||
JSAMPROW workspace;
|
||||
JDIMENSION rowsperchunk, currow, i;
|
||||
@@ -458,27 +454,27 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
sizeof(JSAMPLE));
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) samplesperrow * sizeof(JSAMPLE));
|
||||
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
|
||||
((long)samplesperrow * sizeof(JSAMPLE));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
rowsperchunk = (JDIMENSION) ltemp;
|
||||
if (ltemp < (long)numrows)
|
||||
rowsperchunk = (JDIMENSION)ltemp;
|
||||
else
|
||||
rowsperchunk = numrows;
|
||||
mem->last_rowsperchunk = rowsperchunk;
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * sizeof(JSAMPROW)));
|
||||
result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
|
||||
(size_t)(numrows * sizeof(JSAMPROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
|
||||
* sizeof(JSAMPLE)));
|
||||
workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
|
||||
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow *
|
||||
sizeof(JSAMPLE)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += samplesperrow;
|
||||
@@ -495,11 +491,11 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
*/
|
||||
|
||||
METHODDEF(JBLOCKARRAY)
|
||||
alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows)
|
||||
alloc_barray(j_common_ptr cinfo, int pool_id, JDIMENSION blocksperrow,
|
||||
JDIMENSION numrows)
|
||||
/* Allocate a 2-D coefficient-block array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
JBLOCKARRAY result;
|
||||
JBLOCKROW workspace;
|
||||
JDIMENSION rowsperchunk, currow, i;
|
||||
@@ -510,27 +506,27 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
out_of_memory(cinfo, 6); /* safety check */
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) blocksperrow * sizeof(JBLOCK));
|
||||
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
|
||||
((long)blocksperrow * sizeof(JBLOCK));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
rowsperchunk = (JDIMENSION) ltemp;
|
||||
if (ltemp < (long)numrows)
|
||||
rowsperchunk = (JDIMENSION)ltemp;
|
||||
else
|
||||
rowsperchunk = numrows;
|
||||
mem->last_rowsperchunk = rowsperchunk;
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * sizeof(JBLOCKROW)));
|
||||
result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
|
||||
(size_t)(numrows * sizeof(JBLOCKROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
|
||||
* sizeof(JBLOCK)));
|
||||
workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
|
||||
(size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
|
||||
sizeof(JBLOCK)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += blocksperrow;
|
||||
@@ -579,12 +575,12 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
|
||||
METHODDEF(jvirt_sarray_ptr)
|
||||
request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
request_virt_sarray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
/* Request a virtual 2-D sample array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
jvirt_sarray_ptr result;
|
||||
|
||||
/* Only IMAGE-lifetime virtual arrays are currently supported */
|
||||
@@ -592,7 +588,7 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,
|
||||
result = (jvirt_sarray_ptr)alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_sarray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
@@ -609,12 +605,12 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
|
||||
|
||||
METHODDEF(jvirt_barray_ptr)
|
||||
request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
request_virt_barray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
/* Request a virtual 2-D coefficient-block array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
jvirt_barray_ptr result;
|
||||
|
||||
/* Only IMAGE-lifetime virtual arrays are currently supported */
|
||||
@@ -622,7 +618,7 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,
|
||||
result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_barray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
@@ -639,10 +635,10 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
realize_virt_arrays (j_common_ptr cinfo)
|
||||
realize_virt_arrays(j_common_ptr cinfo)
|
||||
/* Allocate the in-memory buffers for any unrealized virtual arrays */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
size_t space_per_minheight, maximum_space, avail_mem;
|
||||
size_t minheights, max_minheights;
|
||||
jvirt_sarray_ptr sptr;
|
||||
@@ -656,11 +652,11 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
maximum_space = 0;
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
size_t new_space = (long)sptr->rows_in_array *
|
||||
(long)sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
space_per_minheight += (long)sptr->maxaccess *
|
||||
(long)sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 10);
|
||||
maximum_space += new_space;
|
||||
@@ -668,11 +664,11 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
size_t new_space = (long)bptr->rows_in_array *
|
||||
(long)bptr->blocksperrow * sizeof(JBLOCK);
|
||||
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
space_per_minheight += (long)bptr->maxaccess *
|
||||
(long)bptr->blocksperrow * sizeof(JBLOCK);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 11);
|
||||
maximum_space += new_space;
|
||||
@@ -705,17 +701,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
|
||||
minheights = ((long)sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
|
||||
if (minheights <= max_minheights) {
|
||||
/* This buffer fits in memory */
|
||||
sptr->rows_in_mem = sptr->rows_in_array;
|
||||
} else {
|
||||
/* It doesn't fit in memory, create backing store. */
|
||||
sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, & sptr->b_s_info,
|
||||
(long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow *
|
||||
(long) sizeof(JSAMPLE));
|
||||
sptr->rows_in_mem = (JDIMENSION)(max_minheights * sptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, &sptr->b_s_info,
|
||||
(long)sptr->rows_in_array *
|
||||
(long)sptr->samplesperrow *
|
||||
(long)sizeof(JSAMPLE));
|
||||
sptr->b_s_open = TRUE;
|
||||
}
|
||||
sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
|
||||
@@ -729,17 +725,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
|
||||
minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
|
||||
if (minheights <= max_minheights) {
|
||||
/* This buffer fits in memory */
|
||||
bptr->rows_in_mem = bptr->rows_in_array;
|
||||
} else {
|
||||
/* It doesn't fit in memory, create backing store. */
|
||||
bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, & bptr->b_s_info,
|
||||
(long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow *
|
||||
(long) sizeof(JBLOCK));
|
||||
bptr->rows_in_mem = (JDIMENSION)(max_minheights * bptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, &bptr->b_s_info,
|
||||
(long)bptr->rows_in_array *
|
||||
(long)bptr->blocksperrow *
|
||||
(long)sizeof(JBLOCK));
|
||||
bptr->b_s_open = TRUE;
|
||||
}
|
||||
bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
|
||||
@@ -754,32 +750,32 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
/* Do backing store read or write of a virtual sample array */
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
bytesperrow = (long)ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);
|
||||
rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
|
||||
/* Transfer no more than is currently defined */
|
||||
thisrow = (long) ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long) ptr->first_undef_row - thisrow);
|
||||
thisrow = (long)ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
|
||||
/* Transfer no more than fits in file */
|
||||
rows = MIN(rows, (long) ptr->rows_in_array - thisrow);
|
||||
rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
|
||||
if (rows <= 0) /* this chunk might be past end of file! */
|
||||
break;
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
@@ -787,32 +783,32 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
do_barray_io(j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
/* Do backing store read or write of a virtual coefficient-block array */
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
bytesperrow = (long)ptr->blocksperrow * sizeof(JBLOCK);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);
|
||||
rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
|
||||
/* Transfer no more than is currently defined */
|
||||
thisrow = (long) ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long) ptr->first_undef_row - thisrow);
|
||||
thisrow = (long)ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
|
||||
/* Transfer no more than fits in file */
|
||||
rows = MIN(rows, (long) ptr->rows_in_array - thisrow);
|
||||
rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
|
||||
if (rows <= 0) /* this chunk might be past end of file! */
|
||||
break;
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
@@ -820,9 +816,8 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
|
||||
|
||||
METHODDEF(JSAMPARRAY)
|
||||
access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable)
|
||||
access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
|
||||
/* Access the part of a virtual sample array starting at start_row */
|
||||
/* and extending for num_rows rows. writable is true if */
|
||||
/* caller intends to modify the accessed area. */
|
||||
@@ -837,8 +832,8 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (!ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
if (ptr->dirty) {
|
||||
@@ -858,10 +853,10 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
/* use long arithmetic here to avoid overflow & unsigned problems */
|
||||
long ltemp;
|
||||
|
||||
ltemp = (long) end_row - (long) ptr->rows_in_mem;
|
||||
ltemp = (long)end_row - (long)ptr->rows_in_mem;
|
||||
if (ltemp < 0)
|
||||
ltemp = 0; /* don't fall off front end of file */
|
||||
ptr->cur_start_row = (JDIMENSION) ltemp;
|
||||
ptr->cur_start_row = (JDIMENSION)ltemp;
|
||||
}
|
||||
/* Read in the selected part of the array.
|
||||
* During the initial write pass, we will do no actual read
|
||||
@@ -884,15 +879,15 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
size_t bytesperrow = (size_t)ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
if (! writable) /* reader looking at undefined data */
|
||||
if (!writable) /* reader looking at undefined data */
|
||||
ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
|
||||
}
|
||||
}
|
||||
@@ -905,9 +900,8 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
|
||||
|
||||
METHODDEF(JBLOCKARRAY)
|
||||
access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable)
|
||||
access_virt_barray(j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
|
||||
/* Access the part of a virtual block array starting at start_row */
|
||||
/* and extending for num_rows rows. writable is true if */
|
||||
/* caller intends to modify the accessed area. */
|
||||
@@ -922,8 +916,8 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (!ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
if (ptr->dirty) {
|
||||
@@ -943,10 +937,10 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
/* use long arithmetic here to avoid overflow & unsigned problems */
|
||||
long ltemp;
|
||||
|
||||
ltemp = (long) end_row - (long) ptr->rows_in_mem;
|
||||
ltemp = (long)end_row - (long)ptr->rows_in_mem;
|
||||
if (ltemp < 0)
|
||||
ltemp = 0; /* don't fall off front end of file */
|
||||
ptr->cur_start_row = (JDIMENSION) ltemp;
|
||||
ptr->cur_start_row = (JDIMENSION)ltemp;
|
||||
}
|
||||
/* Read in the selected part of the array.
|
||||
* During the initial write pass, we will do no actual read
|
||||
@@ -969,15 +963,15 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
size_t bytesperrow = (size_t)ptr->blocksperrow * sizeof(JBLOCK);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
if (! writable) /* reader looking at undefined data */
|
||||
if (!writable) /* reader looking at undefined data */
|
||||
ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
|
||||
}
|
||||
}
|
||||
@@ -994,9 +988,9 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
free_pool (j_common_ptr cinfo, int pool_id)
|
||||
free_pool(j_common_ptr cinfo, int pool_id)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr shdr_ptr;
|
||||
large_pool_ptr lhdr_ptr;
|
||||
size_t space_freed;
|
||||
@@ -1017,14 +1011,14 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->b_s_open) { /* there may be no backing store */
|
||||
sptr->b_s_open = FALSE; /* prevent recursive close if error */
|
||||
(*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info);
|
||||
(*sptr->b_s_info.close_backing_store) (cinfo, &sptr->b_s_info);
|
||||
}
|
||||
}
|
||||
mem->virt_sarray_list = NULL;
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->b_s_open) { /* there may be no backing store */
|
||||
bptr->b_s_open = FALSE; /* prevent recursive close if error */
|
||||
(*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info);
|
||||
(*bptr->b_s_info.close_backing_store) (cinfo, &bptr->b_s_info);
|
||||
}
|
||||
}
|
||||
mem->virt_barray_list = NULL;
|
||||
@@ -1039,7 +1033,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
space_freed = lhdr_ptr->bytes_used +
|
||||
lhdr_ptr->bytes_left +
|
||||
sizeof(large_pool_hdr);
|
||||
jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed);
|
||||
jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
lhdr_ptr = next_lhdr_ptr;
|
||||
}
|
||||
@@ -1050,10 +1044,9 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
|
||||
while (shdr_ptr != NULL) {
|
||||
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
|
||||
space_freed = shdr_ptr->bytes_used +
|
||||
shdr_ptr->bytes_left +
|
||||
space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
|
||||
sizeof(small_pool_hdr);
|
||||
jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);
|
||||
jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
shdr_ptr = next_shdr_ptr;
|
||||
}
|
||||
@@ -1066,7 +1059,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
self_destruct (j_common_ptr cinfo)
|
||||
self_destruct(j_common_ptr cinfo)
|
||||
{
|
||||
int pool;
|
||||
|
||||
@@ -1074,12 +1067,12 @@ self_destruct (j_common_ptr cinfo)
|
||||
* Releasing pools in reverse order might help avoid fragmentation
|
||||
* with some (brain-damaged) malloc libraries.
|
||||
*/
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
free_pool(cinfo, pool);
|
||||
}
|
||||
|
||||
/* Release the memory manager control block too. */
|
||||
jpeg_free_small(cinfo, (void *) cinfo->mem, sizeof(my_memory_mgr));
|
||||
jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
|
||||
cinfo->mem = NULL; /* ensures I will be called only once */
|
||||
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
@@ -1092,7 +1085,7 @@ self_destruct (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_memory_mgr (j_common_ptr cinfo)
|
||||
jinit_memory_mgr(j_common_ptr cinfo)
|
||||
{
|
||||
my_mem_ptr mem;
|
||||
long max_to_use;
|
||||
@@ -1108,22 +1101,22 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
* in common if and only if X is a power of 2, ie has only one one-bit.
|
||||
* Some compilers may give an "unreachable code" warning here; ignore it.
|
||||
*/
|
||||
if ((ALIGN_SIZE & (ALIGN_SIZE-1)) != 0)
|
||||
if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
|
||||
ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);
|
||||
/* MAX_ALLOC_CHUNK must be representable as type size_t, and must be
|
||||
* a multiple of ALIGN_SIZE.
|
||||
* Again, an "unreachable code" warning may be ignored here.
|
||||
* But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
|
||||
*/
|
||||
test_mac = (size_t) MAX_ALLOC_CHUNK;
|
||||
if ((long) test_mac != MAX_ALLOC_CHUNK ||
|
||||
test_mac = (size_t)MAX_ALLOC_CHUNK;
|
||||
if ((long)test_mac != MAX_ALLOC_CHUNK ||
|
||||
(MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
|
||||
ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
|
||||
|
||||
max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
|
||||
|
||||
/* Attempt to allocate memory manager's control block */
|
||||
mem = (my_mem_ptr) jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
|
||||
if (mem == NULL) {
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
@@ -1149,7 +1142,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
/* Initialize working state */
|
||||
mem->pub.max_memory_to_use = max_to_use;
|
||||
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
mem->small_list[pool] = NULL;
|
||||
mem->large_list[pool] = NULL;
|
||||
}
|
||||
@@ -1159,7 +1152,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
mem->total_space_allocated = sizeof(my_memory_mgr);
|
||||
|
||||
/* Declare ourselves open for business */
|
||||
cinfo->mem = & mem->pub;
|
||||
cinfo->mem = &mem->pub;
|
||||
|
||||
/* Check for an environment variable JPEGMEM; if found, override the
|
||||
* default max_memory setting from jpeg_mem_init. Note that the
|
||||
@@ -1168,7 +1161,8 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
* this feature.
|
||||
*/
|
||||
#ifndef NO_GETENV
|
||||
{ char *memenv;
|
||||
{
|
||||
char *memenv;
|
||||
|
||||
if ((memenv = getenv("JPEGMEM")) != NULL) {
|
||||
char ch = 'x';
|
||||
|
||||
24
jmemnobs.c
24
jmemnobs.c
@@ -23,8 +23,8 @@
|
||||
#include "jmemsys.h" /* import the system-dependent declarations */
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ extern void free (void *ptr);
|
||||
*/
|
||||
|
||||
GLOBAL(void *)
|
||||
jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
|
||||
jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject)
|
||||
{
|
||||
return (void *) malloc(sizeofobject);
|
||||
return (void *)malloc(sizeofobject);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_free_small (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
jpeg_free_small(j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
{
|
||||
free(object);
|
||||
}
|
||||
@@ -51,13 +51,13 @@ jpeg_free_small (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
GLOBAL(void *)
|
||||
jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
|
||||
jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject)
|
||||
{
|
||||
return (void *) malloc(sizeofobject);
|
||||
return (void *)malloc(sizeofobject);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
jpeg_free_large(j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
{
|
||||
free(object);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
GLOBAL(size_t)
|
||||
jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
size_t max_bytes_needed, size_t already_allocated)
|
||||
{
|
||||
if (cinfo->mem->max_memory_to_use) {
|
||||
@@ -90,7 +90,7 @@ jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
|
||||
jpeg_open_backing_store(j_common_ptr cinfo, backing_store_ptr info,
|
||||
long total_bytes_needed)
|
||||
{
|
||||
ERREXIT(cinfo, JERR_NO_BACKING_STORE);
|
||||
@@ -103,13 +103,13 @@ jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
|
||||
*/
|
||||
|
||||
GLOBAL(long)
|
||||
jpeg_mem_init (j_common_ptr cinfo)
|
||||
jpeg_mem_init(j_common_ptr cinfo)
|
||||
{
|
||||
return 0; /* just set max_memory_to_use to 0 */
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_term (j_common_ptr cinfo)
|
||||
jpeg_mem_term(j_common_ptr cinfo)
|
||||
{
|
||||
/* no work */
|
||||
}
|
||||
|
||||
16
jmemsys.h
16
jmemsys.h
@@ -31,8 +31,8 @@
|
||||
* size of the object being freed, just in case it's needed.
|
||||
*/
|
||||
|
||||
EXTERN(void *) jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_small (j_common_ptr cinfo, void *object,
|
||||
EXTERN(void *) jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_small(j_common_ptr cinfo, void *object,
|
||||
size_t sizeofobject);
|
||||
|
||||
/*
|
||||
@@ -43,8 +43,8 @@ EXTERN(void) jpeg_free_small (j_common_ptr cinfo, void *object,
|
||||
* large chunks.
|
||||
*/
|
||||
|
||||
EXTERN(void *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void *object,
|
||||
EXTERN(void *) jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_large(j_common_ptr cinfo, void *object,
|
||||
size_t sizeofobject);
|
||||
|
||||
/*
|
||||
@@ -84,7 +84,7 @@ EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void *object,
|
||||
* Conversely, zero may be returned to always use the minimum amount of memory.
|
||||
*/
|
||||
|
||||
EXTERN(size_t) jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
EXTERN(size_t) jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
size_t max_bytes_needed,
|
||||
size_t already_allocated);
|
||||
|
||||
@@ -157,7 +157,7 @@ typedef struct backing_store_struct {
|
||||
* just take an error exit.)
|
||||
*/
|
||||
|
||||
EXTERN(void) jpeg_open_backing_store (j_common_ptr cinfo,
|
||||
EXTERN(void) jpeg_open_backing_store(j_common_ptr cinfo,
|
||||
backing_store_ptr info,
|
||||
long total_bytes_needed);
|
||||
|
||||
@@ -174,5 +174,5 @@ EXTERN(void) jpeg_open_backing_store (j_common_ptr cinfo,
|
||||
* all opened backing-store objects have been closed.
|
||||
*/
|
||||
|
||||
EXTERN(long) jpeg_mem_init (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_mem_term (j_common_ptr cinfo);
|
||||
EXTERN(long) jpeg_mem_init(j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_mem_term(j_common_ptr cinfo);
|
||||
|
||||
10
jmorecfg.h
10
jmorecfg.h
@@ -49,15 +49,15 @@
|
||||
#ifdef HAVE_UNSIGNED_CHAR
|
||||
|
||||
typedef unsigned char JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
#define GETJSAMPLE(value) ((int)(value))
|
||||
|
||||
#else /* not HAVE_UNSIGNED_CHAR */
|
||||
|
||||
typedef char JSAMPLE;
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
#define GETJSAMPLE(value) ((int)(value))
|
||||
#else
|
||||
#define GETJSAMPLE(value) ((int) (value) & 0xFF)
|
||||
#define GETJSAMPLE(value) ((int)(value) & 0xFF)
|
||||
#endif /* __CHAR_UNSIGNED__ */
|
||||
|
||||
#endif /* HAVE_UNSIGNED_CHAR */
|
||||
@@ -74,7 +74,7 @@ typedef char JSAMPLE;
|
||||
*/
|
||||
|
||||
typedef short JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
#define GETJSAMPLE(value) ((int)(value))
|
||||
|
||||
#define MAXJSAMPLE 4095
|
||||
#define CENTERJSAMPLE 2048
|
||||
@@ -220,7 +220,7 @@ typedef unsigned int JDIMENSION;
|
||||
* software out there that uses it.
|
||||
*/
|
||||
|
||||
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
|
||||
#define JMETHOD(type, methodname, arglist) type (*methodname) arglist
|
||||
|
||||
|
||||
/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
|
||||
|
||||
76
jpegint.h
76
jpegint.h
@@ -274,9 +274,9 @@ struct jpeg_color_quantizer {
|
||||
/* Miscellaneous useful macros */
|
||||
|
||||
#undef MAX
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#undef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
|
||||
/* We assume that right shift corresponds to signed division by 2 with
|
||||
@@ -291,64 +291,64 @@ struct jpeg_color_quantizer {
|
||||
|
||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#define SHIFT_TEMPS JLONG shift_temp;
|
||||
#define RIGHT_SHIFT(x,shft) \
|
||||
#define RIGHT_SHIFT(x, shft) \
|
||||
((shift_temp = (x)) < 0 ? \
|
||||
(shift_temp >> (shft)) | ((~((JLONG) 0)) << (32-(shft))) : \
|
||||
(shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
|
||||
(shift_temp >> (shft)))
|
||||
#else
|
||||
#define SHIFT_TEMPS
|
||||
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
|
||||
/* Compression module initialization routines */
|
||||
EXTERN(void) jinit_compress_master (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_c_master_control (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
|
||||
boolean transcode_only);
|
||||
EXTERN(void) jinit_c_main_controller (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_c_prep_controller (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_c_coef_controller (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_color_converter (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_downsampler (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_forward_dct (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_writer (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
|
||||
/* Decompression module initialization routines */
|
||||
EXTERN(void) jinit_master_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_d_main_controller (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_d_coef_controller (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_d_post_controller (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_input_controller (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_reader (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_inverse_dct (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_upsampler (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_deconverter (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_1pass_quantizer (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_2pass_quantizer (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
|
||||
/* Memory manager initialization */
|
||||
EXTERN(void) jinit_memory_mgr (j_common_ptr cinfo);
|
||||
EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
|
||||
|
||||
/* Utility routines in jutils.c */
|
||||
EXTERN(long) jdiv_round_up (long a, long b);
|
||||
EXTERN(long) jround_up (long a, long b);
|
||||
EXTERN(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
EXTERN(long) jdiv_round_up(long a, long b);
|
||||
EXTERN(long) jround_up(long a, long b);
|
||||
EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row,
|
||||
int num_rows, JDIMENSION num_cols);
|
||||
EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks);
|
||||
EXTERN(void) jzero_far (void *target, size_t bytestozero);
|
||||
EXTERN(void) jzero_far(void *target, size_t bytestozero);
|
||||
/* Constant tables in jutils.c */
|
||||
#if 0 /* This table is not actually needed in v6a */
|
||||
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
||||
|
||||
131
jpeglib.h
131
jpeglib.h
@@ -268,11 +268,11 @@ typedef enum {
|
||||
/* Common fields between JPEG compression and decompression master structs. */
|
||||
|
||||
#define jpeg_common_fields \
|
||||
struct jpeg_error_mgr *err; /* Error handler module */\
|
||||
struct jpeg_memory_mgr *mem; /* Memory manager module */\
|
||||
struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */\
|
||||
void *client_data; /* Available for use by application */\
|
||||
boolean is_decompressor; /* So common code can tell which is which */\
|
||||
struct jpeg_error_mgr *err; /* Error handler module */ \
|
||||
struct jpeg_memory_mgr *mem; /* Memory manager module */ \
|
||||
struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */ \
|
||||
void *client_data; /* Available for use by application */ \
|
||||
boolean is_decompressor; /* So common code can tell which is which */ \
|
||||
int global_state /* For checking call sequence validity */
|
||||
|
||||
/* Routines that are to be used by both halves of the library are declared
|
||||
@@ -888,7 +888,7 @@ typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/* Default error-management setup */
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr *err);
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
|
||||
|
||||
/* Initialization of JPEG compression objects.
|
||||
* jpeg_create_compress() and jpeg_create_decompress() are the exported
|
||||
@@ -899,91 +899,90 @@ EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr *err);
|
||||
*/
|
||||
#define jpeg_create_compress(cinfo) \
|
||||
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
|
||||
(size_t) sizeof(struct jpeg_compress_struct))
|
||||
(size_t)sizeof(struct jpeg_compress_struct))
|
||||
#define jpeg_create_decompress(cinfo) \
|
||||
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
||||
(size_t) sizeof(struct jpeg_decompress_struct))
|
||||
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
|
||||
(size_t)sizeof(struct jpeg_decompress_struct))
|
||||
EXTERN(void) jpeg_CreateCompress(j_compress_ptr cinfo, int version,
|
||||
size_t structsize);
|
||||
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
|
||||
EXTERN(void) jpeg_CreateDecompress(j_decompress_ptr cinfo, int version,
|
||||
size_t structsize);
|
||||
/* Destruction of JPEG compression objects */
|
||||
EXTERN(void) jpeg_destroy_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_compress(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_decompress(j_decompress_ptr cinfo);
|
||||
|
||||
/* Standard data source and destination managers: stdio streams. */
|
||||
/* Caller is responsible for opening the file before and closing after. */
|
||||
EXTERN(void) jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile);
|
||||
EXTERN(void) jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile);
|
||||
EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
|
||||
EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
/* Data source and destination managers: memory buffers. */
|
||||
EXTERN(void) jpeg_mem_dest (j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
unsigned long *outsize);
|
||||
EXTERN(void) jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer,
|
||||
unsigned long insize);
|
||||
EXTERN(void) jpeg_mem_src(j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer, unsigned long insize);
|
||||
#endif
|
||||
|
||||
/* Default parameter setup for compression */
|
||||
EXTERN(void) jpeg_set_defaults (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_defaults(j_compress_ptr cinfo);
|
||||
/* Compression parameter setup aids */
|
||||
EXTERN(void) jpeg_set_colorspace (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_set_colorspace(j_compress_ptr cinfo,
|
||||
J_COLOR_SPACE colorspace);
|
||||
EXTERN(void) jpeg_default_colorspace (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_quality (j_compress_ptr cinfo, int quality,
|
||||
EXTERN(void) jpeg_default_colorspace(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_quality(j_compress_ptr cinfo, int quality,
|
||||
boolean force_baseline);
|
||||
EXTERN(void) jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
EXTERN(void) jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
|
||||
boolean force_baseline);
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
EXTERN(void) jpeg_default_qtables (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_default_qtables(j_compress_ptr cinfo,
|
||||
boolean force_baseline);
|
||||
#endif
|
||||
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
EXTERN(void) jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
||||
const unsigned int *basic_table,
|
||||
int scale_factor, boolean force_baseline);
|
||||
EXTERN(int) jpeg_quality_scaling (int quality);
|
||||
EXTERN(void) jpeg_simple_progression (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress);
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table (j_common_ptr cinfo);
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table (j_common_ptr cinfo);
|
||||
EXTERN(int) jpeg_quality_scaling(int quality);
|
||||
EXTERN(void) jpeg_simple_progression(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress);
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table(j_common_ptr cinfo);
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table(j_common_ptr cinfo);
|
||||
|
||||
/* Main entry points for compression */
|
||||
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
|
||||
boolean write_all_tables);
|
||||
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
|
||||
EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
|
||||
JSAMPARRAY scanlines,
|
||||
JDIMENSION num_lines);
|
||||
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
|
||||
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
/* Precalculate JPEG dimensions for current compression parameters. */
|
||||
EXTERN(void) jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
|
||||
#endif
|
||||
|
||||
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
|
||||
EXTERN(JDIMENSION) jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION num_lines);
|
||||
|
||||
/* Write a special marker. See libjpeg.txt concerning safe usage. */
|
||||
EXTERN(void) jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
|
||||
const JOCTET *dataptr, unsigned int datalen);
|
||||
/* Same, but piecemeal. */
|
||||
EXTERN(void) jpeg_write_m_header (j_compress_ptr cinfo, int marker,
|
||||
EXTERN(void) jpeg_write_m_header(j_compress_ptr cinfo, int marker,
|
||||
unsigned int datalen);
|
||||
EXTERN(void) jpeg_write_m_byte (j_compress_ptr cinfo, int val);
|
||||
EXTERN(void) jpeg_write_m_byte(j_compress_ptr cinfo, int val);
|
||||
|
||||
/* Alternate compression function: just write an abbreviated table file */
|
||||
EXTERN(void) jpeg_write_tables (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_tables(j_compress_ptr cinfo);
|
||||
|
||||
/* Write ICC profile. See libjpeg.txt for usage information. */
|
||||
EXTERN(void) jpeg_write_icc_profile (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
|
||||
const JOCTET *icc_data_ptr,
|
||||
unsigned int icc_data_len);
|
||||
|
||||
|
||||
/* Decompression startup: read start of JPEG datastream to see what's there */
|
||||
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||
EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
|
||||
/* Return value is one of: */
|
||||
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
||||
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
||||
@@ -995,27 +994,27 @@ EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||
*/
|
||||
|
||||
/* Main entry points for decompression */
|
||||
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
|
||||
EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
|
||||
EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY scanlines,
|
||||
JDIMENSION max_lines);
|
||||
EXTERN(JDIMENSION) jpeg_skip_scanlines (j_decompress_ptr cinfo,
|
||||
EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
|
||||
JDIMENSION num_lines);
|
||||
EXTERN(void) jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
JDIMENSION *width);
|
||||
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
|
||||
|
||||
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
|
||||
EXTERN(JDIMENSION) jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION max_lines);
|
||||
|
||||
/* Additional entry points for buffered-image mode. */
|
||||
EXTERN(boolean) jpeg_has_multiple_scans (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_start_output (j_decompress_ptr cinfo, int scan_number);
|
||||
EXTERN(boolean) jpeg_finish_output (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_input_complete (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
|
||||
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
|
||||
EXTERN(boolean) jpeg_finish_output(j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_input_complete(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_new_colormap(j_decompress_ptr cinfo);
|
||||
EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
|
||||
/* Return value is one of: */
|
||||
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
||||
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
||||
@@ -1025,24 +1024,24 @@ EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||
|
||||
/* Precalculate output dimensions for current decompression parameters. */
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
EXTERN(void) jpeg_core_output_dimensions (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_core_output_dimensions(j_decompress_ptr cinfo);
|
||||
#endif
|
||||
EXTERN(void) jpeg_calc_output_dimensions (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
|
||||
|
||||
/* Control saving of COM and APPn markers into marker_list. */
|
||||
EXTERN(void) jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
EXTERN(void) jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
|
||||
unsigned int length_limit);
|
||||
|
||||
/* Install a special processing method for COM or APPn markers. */
|
||||
EXTERN(void) jpeg_set_marker_processor (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jpeg_set_marker_processor(j_decompress_ptr cinfo,
|
||||
int marker_code,
|
||||
jpeg_marker_parser_method routine);
|
||||
|
||||
/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
|
||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_coefficients (j_compress_ptr cinfo,
|
||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_coefficients(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays);
|
||||
EXTERN(void) jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
|
||||
j_compress_ptr dstinfo);
|
||||
|
||||
/* If you choose to abort compression or decompression before completing
|
||||
@@ -1051,20 +1050,20 @@ EXTERN(void) jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
* if you're done with the JPEG object, but if you want to clean it up and
|
||||
* reuse it, call this:
|
||||
*/
|
||||
EXTERN(void) jpeg_abort_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_compress(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_decompress(j_decompress_ptr cinfo);
|
||||
|
||||
/* Generic versions of jpeg_abort and jpeg_destroy that work on either
|
||||
* flavor of JPEG object. These may be more convenient in some places.
|
||||
*/
|
||||
EXTERN(void) jpeg_abort (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort(j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy(j_common_ptr cinfo);
|
||||
|
||||
/* Default restart-marker-resync procedure for use by data source modules */
|
||||
EXTERN(boolean) jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired);
|
||||
EXTERN(boolean) jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
|
||||
|
||||
/* Read ICC profile. See libjpeg.txt for usage information. */
|
||||
EXTERN(boolean) jpeg_read_icc_profile (j_decompress_ptr cinfo,
|
||||
EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
|
||||
JOCTET **icc_data_ptr,
|
||||
unsigned int *icc_data_len);
|
||||
|
||||
|
||||
51
jpegtran.c
51
jpegtran.c
@@ -47,7 +47,7 @@ static jpeg_transform_info transformoption; /* image transformation options */
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
usage (void)
|
||||
usage(void)
|
||||
/* complain about bad command line */
|
||||
{
|
||||
fprintf(stderr, "usage: %s [switches] ", progname);
|
||||
@@ -99,7 +99,7 @@ usage (void)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
select_transform (JXFORM_CODE transform)
|
||||
select_transform(JXFORM_CODE transform)
|
||||
/* Silly little routine to detect multiple transform options,
|
||||
* which we can't handle.
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ select_transform (JXFORM_CODE transform)
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
||||
int last_file_arg_seen, boolean for_real)
|
||||
/* Parse optional switches.
|
||||
* Returns argv[] index of first file-name argument (== argc if none).
|
||||
@@ -193,7 +193,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
usage();
|
||||
if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
|
||||
if (!jtransform_parse_crop_spec(&transformoption, argv[argn])) {
|
||||
fprintf(stderr, "%s: bogus -crop argument '%s'\n",
|
||||
progname, argv[argn]);
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -207,7 +207,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
/* On first -d, print version identification */
|
||||
static boolean printed_version = FALSE;
|
||||
|
||||
if (! printed_version) {
|
||||
if (!printed_version) {
|
||||
fprintf(stderr, "%s version %s (build %s)\n",
|
||||
PACKAGE_NAME, VERSION, BUILD);
|
||||
fprintf(stderr, "%s\n\n", JCOPYRIGHT);
|
||||
@@ -233,7 +233,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
else
|
||||
usage();
|
||||
|
||||
} else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) {
|
||||
} else if (keymatch(arg, "grayscale", 1) ||
|
||||
keymatch(arg, "greyscale", 1)) {
|
||||
/* Force to grayscale. */
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
transformoption.force_grayscale = TRUE;
|
||||
@@ -304,10 +305,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
if (lval < 0 || lval > 65535L)
|
||||
usage();
|
||||
if (ch == 'b' || ch == 'B') {
|
||||
cinfo->restart_interval = (unsigned int) lval;
|
||||
cinfo->restart_interval = (unsigned int)lval;
|
||||
cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */
|
||||
} else {
|
||||
cinfo->restart_in_rows = (int) lval;
|
||||
cinfo->restart_in_rows = (int)lval;
|
||||
/* restart_interval will be computed during startup */
|
||||
}
|
||||
|
||||
@@ -365,7 +366,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
if (scansarg != NULL) /* process -scans if it was present */
|
||||
if (! read_scan_script(cinfo, scansarg))
|
||||
if (!read_scan_script(cinfo, scansarg))
|
||||
usage();
|
||||
#endif
|
||||
}
|
||||
@@ -379,7 +380,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct jpeg_decompress_struct srcinfo;
|
||||
struct jpeg_compress_struct dstinfo;
|
||||
@@ -429,14 +430,14 @@ main (int argc, char **argv)
|
||||
#ifdef TWO_FILE_COMMANDLINE
|
||||
/* Must have either -outfile switch or explicit output file name */
|
||||
if (outfilename == NULL) {
|
||||
if (file_index != argc-2) {
|
||||
if (file_index != argc - 2) {
|
||||
fprintf(stderr, "%s: must name one input and one output file\n",
|
||||
progname);
|
||||
usage();
|
||||
}
|
||||
outfilename = argv[file_index+1];
|
||||
outfilename = argv[file_index + 1];
|
||||
} else {
|
||||
if (file_index != argc-1) {
|
||||
if (file_index != argc - 1) {
|
||||
fprintf(stderr, "%s: must name one input and one output file\n",
|
||||
progname);
|
||||
usage();
|
||||
@@ -444,7 +445,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
#else
|
||||
/* Unix style: expect zero or one file name */
|
||||
if (file_index < argc-1) {
|
||||
if (file_index < argc - 1) {
|
||||
fprintf(stderr, "%s: only one input file\n", progname);
|
||||
usage();
|
||||
}
|
||||
@@ -453,7 +454,8 @@ main (int argc, char **argv)
|
||||
/* Open the input file. */
|
||||
if (file_index < argc) {
|
||||
if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) {
|
||||
fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_index]);
|
||||
fprintf(stderr, "%s: can't open %s for reading\n", progname,
|
||||
argv[file_index]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
@@ -491,7 +493,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
start_progress_monitor((j_common_ptr) &dstinfo, &progress);
|
||||
start_progress_monitor((j_common_ptr)&dstinfo, &progress);
|
||||
#endif
|
||||
|
||||
/* Specify data source for decompression */
|
||||
@@ -501,7 +503,7 @@ main (int argc, char **argv)
|
||||
jcopy_markers_setup(&srcinfo, copyoption);
|
||||
|
||||
/* Read file header */
|
||||
(void) jpeg_read_header(&srcinfo, TRUE);
|
||||
(void)jpeg_read_header(&srcinfo, TRUE);
|
||||
|
||||
/* Any space needed by a transform option must be requested before
|
||||
* jpeg_read_coefficients so that memory allocation will be done right.
|
||||
@@ -535,7 +537,7 @@ main (int argc, char **argv)
|
||||
/* Close input file, if we opened it.
|
||||
* Note: we assume that jpeg_read_coefficients consumed all input
|
||||
* until JPEG_REACHED_EOI, and that jpeg_finish_decompress will
|
||||
* only consume more while (! cinfo->inputctl->eoi_reached).
|
||||
* only consume more while (!cinfo->inputctl->eoi_reached).
|
||||
* We cannot call jpeg_finish_decompress here since we still need the
|
||||
* virtual arrays allocated from the source object for processing.
|
||||
*/
|
||||
@@ -545,7 +547,8 @@ main (int argc, char **argv)
|
||||
/* Open the output file. */
|
||||
if (outfilename != NULL) {
|
||||
if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {
|
||||
fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename);
|
||||
fprintf(stderr, "%s: can't open %s for writing\n", progname,
|
||||
outfilename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
@@ -570,15 +573,14 @@ main (int argc, char **argv)
|
||||
|
||||
/* Execute image transformation, if any */
|
||||
#if TRANSFORMS_SUPPORTED
|
||||
jtransform_execute_transformation(&srcinfo, &dstinfo,
|
||||
src_coef_arrays,
|
||||
jtransform_execute_transformation(&srcinfo, &dstinfo, src_coef_arrays,
|
||||
&transformoption);
|
||||
#endif
|
||||
|
||||
/* Finish compression and release memory */
|
||||
jpeg_finish_compress(&dstinfo);
|
||||
jpeg_destroy_compress(&dstinfo);
|
||||
(void) jpeg_finish_decompress(&srcinfo);
|
||||
(void)jpeg_finish_decompress(&srcinfo);
|
||||
jpeg_destroy_decompress(&srcinfo);
|
||||
|
||||
/* Close output file, if we opened it */
|
||||
@@ -586,13 +588,14 @@ main (int argc, char **argv)
|
||||
fclose(fp);
|
||||
|
||||
#ifdef PROGRESS_REPORT
|
||||
end_progress_monitor((j_common_ptr) &dstinfo);
|
||||
end_progress_monitor((j_common_ptr)&dstinfo);
|
||||
#endif
|
||||
|
||||
if (icc_profile != NULL)
|
||||
free(icc_profile);
|
||||
|
||||
/* All done. */
|
||||
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);
|
||||
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?
|
||||
EXIT_WARNING : EXIT_SUCCESS);
|
||||
return 0; /* suppress no-return-value warnings */
|
||||
}
|
||||
|
||||
175
jquant1.c
175
jquant1.c
@@ -73,8 +73,8 @@
|
||||
|
||||
#define ODITHER_SIZE 16 /* dimension of dither matrix */
|
||||
/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */
|
||||
#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */
|
||||
#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */
|
||||
#define ODITHER_CELLS (ODITHER_SIZE * ODITHER_SIZE) /* # cells in matrix */
|
||||
#define ODITHER_MASK (ODITHER_SIZE - 1) /* mask for wrapping around counters */
|
||||
|
||||
typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE];
|
||||
typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE];
|
||||
@@ -183,7 +183,7 @@ typedef my_cquantizer *my_cquantize_ptr;
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
select_ncolors(j_decompress_ptr cinfo, int Ncolors[])
|
||||
/* Determine allocation of desired colors to components, */
|
||||
/* and fill in Ncolors[] array to indicate choice. */
|
||||
/* Return value is total number of colors (product of Ncolors[] values). */
|
||||
@@ -206,12 +206,12 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
temp = iroot; /* set temp = iroot ** nc */
|
||||
for (i = 1; i < nc; i++)
|
||||
temp *= iroot;
|
||||
} while (temp <= (long) max_colors); /* repeat till iroot exceeds root */
|
||||
} while (temp <= (long)max_colors); /* repeat till iroot exceeds root */
|
||||
iroot--; /* now iroot = floor(root) */
|
||||
|
||||
/* Must have at least 2 color values per component */
|
||||
if (iroot < 2)
|
||||
ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp);
|
||||
ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int)temp);
|
||||
|
||||
/* Initialize to iroot color values for each component */
|
||||
total_colors = 1;
|
||||
@@ -231,11 +231,11 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i);
|
||||
/* calculate new total_colors if Ncolors[j] is incremented */
|
||||
temp = total_colors / Ncolors[j];
|
||||
temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */
|
||||
if (temp > (long) max_colors)
|
||||
temp *= Ncolors[j] + 1; /* done in long arith to avoid oflo */
|
||||
if (temp > (long)max_colors)
|
||||
break; /* won't fit, done with this pass */
|
||||
Ncolors[j]++; /* OK, apply the increment */
|
||||
total_colors = (int) temp;
|
||||
total_colors = (int)temp;
|
||||
changed = TRUE;
|
||||
}
|
||||
} while (changed);
|
||||
@@ -245,7 +245,7 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
output_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
/* Return j'th output value, where j will range from 0 to maxj */
|
||||
/* The output values must fall in 0..MAXJSAMPLE in increasing order */
|
||||
{
|
||||
@@ -254,17 +254,17 @@ output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
* (Forcing the upper and lower values to the limits ensures that
|
||||
* dithering can't produce a color outside the selected gamut.)
|
||||
*/
|
||||
return (int) (((JLONG) j * MAXJSAMPLE + maxj/2) / maxj);
|
||||
return (int)(((JLONG)j * MAXJSAMPLE + maxj / 2) / maxj);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
largest_input_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
/* Return largest input value that should map to j'th output value */
|
||||
/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
|
||||
{
|
||||
/* Breakpoints are halfway between values returned by output_value */
|
||||
return (int) (((JLONG) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj));
|
||||
return (int)(((JLONG)(2 * j + 1) * MAXJSAMPLE + maxj) / (2 * maxj));
|
||||
}
|
||||
|
||||
|
||||
@@ -273,21 +273,21 @@ largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_colormap (j_decompress_ptr cinfo)
|
||||
create_colormap(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
JSAMPARRAY colormap; /* Created colormap */
|
||||
int total_colors; /* Number of distinct output colors */
|
||||
int i,j,k, nci, blksize, blkdist, ptr, val;
|
||||
int i, j, k, nci, blksize, blkdist, ptr, val;
|
||||
|
||||
/* Select number of colors for each component */
|
||||
total_colors = select_ncolors(cinfo, cquantize->Ncolors);
|
||||
|
||||
/* Report selected color counts */
|
||||
if (cinfo->out_color_components == 3)
|
||||
TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS,
|
||||
total_colors, cquantize->Ncolors[0],
|
||||
cquantize->Ncolors[1], cquantize->Ncolors[2]);
|
||||
TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, total_colors,
|
||||
cquantize->Ncolors[0], cquantize->Ncolors[1],
|
||||
cquantize->Ncolors[2]);
|
||||
else
|
||||
TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors);
|
||||
|
||||
@@ -296,8 +296,8 @@ create_colormap (j_decompress_ptr cinfo)
|
||||
/* i.e. rightmost (highest-indexed) color changes most rapidly. */
|
||||
|
||||
colormap = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)total_colors, (JDIMENSION)cinfo->out_color_components);
|
||||
|
||||
/* blksize is number of adjacent repeated entries for a component */
|
||||
/* blkdist is distance between groups of identical entries for a component */
|
||||
@@ -309,12 +309,12 @@ create_colormap (j_decompress_ptr cinfo)
|
||||
blksize = blkdist / nci;
|
||||
for (j = 0; j < nci; j++) {
|
||||
/* Compute j'th output value (out of nci) for component */
|
||||
val = output_value(cinfo, i, j, nci-1);
|
||||
val = output_value(cinfo, i, j, nci - 1);
|
||||
/* Fill in all colormap entries that have this value of this component */
|
||||
for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) {
|
||||
/* fill in blksize entries beginning at ptr */
|
||||
for (k = 0; k < blksize; k++)
|
||||
colormap[i][ptr+k] = (JSAMPLE) val;
|
||||
colormap[i][ptr + k] = (JSAMPLE)val;
|
||||
}
|
||||
}
|
||||
blkdist = blksize; /* blksize of this color is blkdist of next */
|
||||
@@ -333,11 +333,11 @@ create_colormap (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_colorindex (j_decompress_ptr cinfo)
|
||||
create_colorindex(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
JSAMPROW indexptr;
|
||||
int i,j,k, nci, blksize, val, pad;
|
||||
int i, j, k, nci, blksize, val, pad;
|
||||
|
||||
/* For ordered dither, we pad the color index tables by MAXJSAMPLE in
|
||||
* each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE).
|
||||
@@ -345,7 +345,7 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
* flag whether it was done in case user changes dithering mode.
|
||||
*/
|
||||
if (cinfo->dither_mode == JDITHER_ORDERED) {
|
||||
pad = MAXJSAMPLE*2;
|
||||
pad = MAXJSAMPLE * 2;
|
||||
cquantize->is_padded = TRUE;
|
||||
} else {
|
||||
pad = 0;
|
||||
@@ -353,9 +353,9 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
cquantize->colorindex = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (MAXJSAMPLE+1 + pad),
|
||||
(JDIMENSION) cinfo->out_color_components);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(MAXJSAMPLE + 1 + pad),
|
||||
(JDIMENSION)cinfo->out_color_components);
|
||||
|
||||
/* blksize is number of adjacent repeated entries for a component */
|
||||
blksize = cquantize->sv_actual;
|
||||
@@ -373,18 +373,18 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
/* and k = largest j that maps to current val */
|
||||
indexptr = cquantize->colorindex[i];
|
||||
val = 0;
|
||||
k = largest_input_value(cinfo, i, 0, nci-1);
|
||||
k = largest_input_value(cinfo, i, 0, nci - 1);
|
||||
for (j = 0; j <= MAXJSAMPLE; j++) {
|
||||
while (j > k) /* advance val if past boundary */
|
||||
k = largest_input_value(cinfo, i, ++val, nci-1);
|
||||
k = largest_input_value(cinfo, i, ++val, nci - 1);
|
||||
/* premultiply so that no multiplication needed in main processing */
|
||||
indexptr[j] = (JSAMPLE) (val * blksize);
|
||||
indexptr[j] = (JSAMPLE)(val * blksize);
|
||||
}
|
||||
/* Pad at both ends if necessary */
|
||||
if (pad)
|
||||
for (j = 1; j <= MAXJSAMPLE; j++) {
|
||||
indexptr[-j] = indexptr[0];
|
||||
indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE];
|
||||
indexptr[MAXJSAMPLE + j] = indexptr[MAXJSAMPLE];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -396,29 +396,29 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(ODITHER_MATRIX_PTR)
|
||||
make_odither_array (j_decompress_ptr cinfo, int ncolors)
|
||||
make_odither_array(j_decompress_ptr cinfo, int ncolors)
|
||||
{
|
||||
ODITHER_MATRIX_PTR odither;
|
||||
int j,k;
|
||||
JLONG num,den;
|
||||
int j, k;
|
||||
JLONG num, den;
|
||||
|
||||
odither = (ODITHER_MATRIX_PTR)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(ODITHER_MATRIX));
|
||||
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
|
||||
* Hence the dither value for the matrix cell with fill order f
|
||||
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
|
||||
* On 16-bit-int machine, be careful to avoid overflow.
|
||||
*/
|
||||
den = 2 * ODITHER_CELLS * ((JLONG) (ncolors - 1));
|
||||
den = 2 * ODITHER_CELLS * ((JLONG)(ncolors - 1));
|
||||
for (j = 0; j < ODITHER_SIZE; j++) {
|
||||
for (k = 0; k < ODITHER_SIZE; k++) {
|
||||
num = ((JLONG) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k])))
|
||||
* MAXJSAMPLE;
|
||||
num = ((JLONG)(ODITHER_CELLS - 1 -
|
||||
2 * ((int)base_dither_matrix[j][k]))) * MAXJSAMPLE;
|
||||
/* Ensure round towards zero despite C's lack of consistency
|
||||
* about rounding negative values in integer division...
|
||||
*/
|
||||
odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den);
|
||||
odither[j][k] = (int)(num < 0 ? -((-num) / den) : num / den);
|
||||
}
|
||||
}
|
||||
return odither;
|
||||
@@ -432,9 +432,9 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_odither_tables (j_decompress_ptr cinfo)
|
||||
create_odither_tables(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
ODITHER_MATRIX_PTR odither;
|
||||
int i, j, nci;
|
||||
|
||||
@@ -459,11 +459,11 @@ create_odither_tables (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
color_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* General case, no dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
JSAMPARRAY colorindex = cquantize->colorindex;
|
||||
register int pixcode, ci;
|
||||
register JSAMPROW ptrin, ptrout;
|
||||
@@ -480,18 +480,18 @@ color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]);
|
||||
}
|
||||
*ptrout++ = (JSAMPLE) pixcode;
|
||||
*ptrout++ = (JSAMPLE)pixcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
color_quantize3(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* Fast path for out_color_components==3, no dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register int pixcode;
|
||||
register JSAMPROW ptrin, ptrout;
|
||||
JSAMPROW colorindex0 = cquantize->colorindex[0];
|
||||
@@ -508,18 +508,18 @@ color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]);
|
||||
pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]);
|
||||
pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]);
|
||||
*ptrout++ = (JSAMPLE) pixcode;
|
||||
*ptrout++ = (JSAMPLE)pixcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* General case, with ordered dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register JSAMPROW input_ptr;
|
||||
register JSAMPROW output_ptr;
|
||||
JSAMPROW colorindex_ci;
|
||||
@@ -533,7 +533,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
||||
jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
|
||||
row_index = cquantize->row_index;
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
@@ -550,7 +550,8 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
* inputs. The maximum dither is +- MAXJSAMPLE; this sets the
|
||||
* required amount of padding.
|
||||
*/
|
||||
*output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]];
|
||||
*output_ptr +=
|
||||
colorindex_ci[GETJSAMPLE(*input_ptr) + dither[col_index]];
|
||||
input_ptr += nc;
|
||||
output_ptr++;
|
||||
col_index = (col_index + 1) & ODITHER_MASK;
|
||||
@@ -564,11 +565,11 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
quantize3_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* Fast path for out_color_components==3, with ordered dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register int pixcode;
|
||||
register JSAMPROW input_ptr;
|
||||
register JSAMPROW output_ptr;
|
||||
@@ -593,13 +594,13 @@ quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
col_index = 0;
|
||||
|
||||
for (col = width; col > 0; col--) {
|
||||
pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) +
|
||||
dither0[col_index]]);
|
||||
pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) +
|
||||
dither1[col_index]]);
|
||||
pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) +
|
||||
dither2[col_index]]);
|
||||
*output_ptr++ = (JSAMPLE) pixcode;
|
||||
pixcode =
|
||||
GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + dither0[col_index]]);
|
||||
pixcode +=
|
||||
GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + dither1[col_index]]);
|
||||
pixcode +=
|
||||
GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + dither2[col_index]]);
|
||||
*output_ptr++ = (JSAMPLE)pixcode;
|
||||
col_index = (col_index + 1) & ODITHER_MASK;
|
||||
}
|
||||
row_index = (row_index + 1) & ODITHER_MASK;
|
||||
@@ -609,11 +610,11 @@ quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* General case, with Floyd-Steinberg dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register LOCFSERROR cur; /* current error or pixel value */
|
||||
LOCFSERROR belowerr; /* error for pixel below cur */
|
||||
LOCFSERROR bpreverr; /* error for below/prev col */
|
||||
@@ -637,17 +638,17 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
||||
jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
output_ptr = output_buf[row];
|
||||
if (cquantize->on_odd_row) {
|
||||
/* work right to left in this row */
|
||||
input_ptr += (width-1) * nc; /* so point to rightmost pixel */
|
||||
output_ptr += width-1;
|
||||
input_ptr += (width - 1) * nc; /* so point to rightmost pixel */
|
||||
output_ptr += width - 1;
|
||||
dir = -1;
|
||||
dirnc = -nc;
|
||||
errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */
|
||||
errorptr = cquantize->fserrors[ci] + (width + 1); /* => entry after last column */
|
||||
} else {
|
||||
/* work left to right in this row */
|
||||
dir = 1;
|
||||
@@ -679,7 +680,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
cur = GETJSAMPLE(range_limit[cur]);
|
||||
/* Select output value, accumulate into output code for this pixel */
|
||||
pixcode = GETJSAMPLE(colorindex_ci[cur]);
|
||||
*output_ptr += (JSAMPLE) pixcode;
|
||||
*output_ptr += (JSAMPLE)pixcode;
|
||||
/* Compute actual representation error at this pixel */
|
||||
/* Note: we can do this even though we don't have the final */
|
||||
/* pixel code, because the colormap is orthogonal. */
|
||||
@@ -691,7 +692,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
bnexterr = cur;
|
||||
delta = cur * 2;
|
||||
cur += delta; /* form error * 3 */
|
||||
errorptr[0] = (FSERROR) (bpreverr + cur);
|
||||
errorptr[0] = (FSERROR)(bpreverr + cur);
|
||||
cur += delta; /* form error * 5 */
|
||||
bpreverr = belowerr + cur;
|
||||
belowerr = bnexterr;
|
||||
@@ -708,7 +709,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
* final fserrors[] entry. Note we need not unload belowerr because
|
||||
* it is for the dummy column before or after the actual array.
|
||||
*/
|
||||
errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */
|
||||
errorptr[0] = (FSERROR)bpreverr; /* unload prev err into array */
|
||||
}
|
||||
cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE);
|
||||
}
|
||||
@@ -720,16 +721,16 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
alloc_fs_workspace (j_decompress_ptr cinfo)
|
||||
alloc_fs_workspace(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
size_t arraysize;
|
||||
int i;
|
||||
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
arraysize = (size_t)((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++) {
|
||||
cquantize->fserrors[i] = (FSERRPTR)
|
||||
(*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, arraysize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,9 +740,9 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
start_pass_1_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
size_t arraysize;
|
||||
int i;
|
||||
|
||||
@@ -767,7 +768,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
* we must recreate the color index table with padding.
|
||||
* This will cost extra space, but probably isn't very likely.
|
||||
*/
|
||||
if (! cquantize->is_padded)
|
||||
if (!cquantize->is_padded)
|
||||
create_colorindex(cinfo);
|
||||
/* Create ordered-dither tables if we didn't already. */
|
||||
if (cquantize->odither[0] == NULL)
|
||||
@@ -780,9 +781,9 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
if (cquantize->fserrors[0] == NULL)
|
||||
alloc_fs_workspace(cinfo);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
arraysize = (size_t)((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++)
|
||||
jzero_far((void *) cquantize->fserrors[i], arraysize);
|
||||
jzero_far((void *)cquantize->fserrors[i], arraysize);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||
@@ -796,7 +797,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_1_quant (j_decompress_ptr cinfo)
|
||||
finish_pass_1_quant(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work in 1-pass case */
|
||||
}
|
||||
@@ -808,7 +809,7 @@ finish_pass_1_quant (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
new_color_map_1_quant (j_decompress_ptr cinfo)
|
||||
new_color_map_1_quant(j_decompress_ptr cinfo)
|
||||
{
|
||||
ERREXIT(cinfo, JERR_MODE_CHANGE);
|
||||
}
|
||||
@@ -819,14 +820,14 @@ new_color_map_1_quant (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
||||
jinit_1pass_quantizer(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize;
|
||||
|
||||
cquantize = (my_cquantize_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_cquantizer));
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *)cquantize;
|
||||
cquantize->pub.start_pass = start_pass_1_quant;
|
||||
cquantize->pub.finish_pass = finish_pass_1_quant;
|
||||
cquantize->pub.new_color_map = new_color_map_1_quant;
|
||||
@@ -837,8 +838,8 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
||||
if (cinfo->out_color_components > MAX_Q_COMPS)
|
||||
ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS);
|
||||
/* Make sure colormap indexes can be represented by JSAMPLEs */
|
||||
if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1))
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1);
|
||||
if (cinfo->desired_number_of_colors > (MAXJSAMPLE + 1))
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE + 1);
|
||||
|
||||
/* Create the colormap and color index table. */
|
||||
create_colormap(cinfo);
|
||||
|
||||
313
jquant2.c
313
jquant2.c
@@ -77,7 +77,7 @@
|
||||
#define G_SCALE 3 /* scale G distances by this much */
|
||||
#define B_SCALE 1 /* and B by this much */
|
||||
|
||||
static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
static const int c_scales[3] = { R_SCALE, G_SCALE, B_SCALE };
|
||||
#define C0_SCALE c_scales[rgb_red[cinfo->out_color_space]]
|
||||
#define C1_SCALE c_scales[rgb_green[cinfo->out_color_space]]
|
||||
#define C2_SCALE c_scales[rgb_blue[cinfo->out_color_space]]
|
||||
@@ -106,7 +106,7 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
* each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.
|
||||
*/
|
||||
|
||||
#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */
|
||||
#define MAXNUMCOLORS (MAXJSAMPLE + 1) /* maximum size of colormap */
|
||||
|
||||
/* These will do the right thing for either R,G,B or B,G,R color order,
|
||||
* but you may not like the results for other color orders.
|
||||
@@ -116,14 +116,14 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */
|
||||
|
||||
/* Number of elements along histogram axes. */
|
||||
#define HIST_C0_ELEMS (1<<HIST_C0_BITS)
|
||||
#define HIST_C1_ELEMS (1<<HIST_C1_BITS)
|
||||
#define HIST_C2_ELEMS (1<<HIST_C2_BITS)
|
||||
#define HIST_C0_ELEMS (1 << HIST_C0_BITS)
|
||||
#define HIST_C1_ELEMS (1 << HIST_C1_BITS)
|
||||
#define HIST_C2_ELEMS (1 << HIST_C2_BITS)
|
||||
|
||||
/* These are the amounts to shift an input value to get a histogram index. */
|
||||
#define C0_SHIFT (BITS_IN_JSAMPLE-HIST_C0_BITS)
|
||||
#define C1_SHIFT (BITS_IN_JSAMPLE-HIST_C1_BITS)
|
||||
#define C2_SHIFT (BITS_IN_JSAMPLE-HIST_C2_BITS)
|
||||
#define C0_SHIFT (BITS_IN_JSAMPLE - HIST_C0_BITS)
|
||||
#define C1_SHIFT (BITS_IN_JSAMPLE - HIST_C1_BITS)
|
||||
#define C2_SHIFT (BITS_IN_JSAMPLE - HIST_C2_BITS)
|
||||
|
||||
|
||||
typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */
|
||||
@@ -200,10 +200,10 @@ typedef my_cquantizer *my_cquantize_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
prescan_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register JSAMPROW ptr;
|
||||
register histptr histp;
|
||||
register hist3d histogram = cquantize->histogram;
|
||||
@@ -215,7 +215,7 @@ prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
ptr = input_buf[row];
|
||||
for (col = width; col > 0; col--) {
|
||||
/* get pixel value and index into the histogram */
|
||||
histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]
|
||||
histp = &histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]
|
||||
[GETJSAMPLE(ptr[1]) >> C1_SHIFT]
|
||||
[GETJSAMPLE(ptr[2]) >> C2_SHIFT];
|
||||
/* increment, check for overflow and undo increment if so. */
|
||||
@@ -249,7 +249,7 @@ typedef box *boxptr;
|
||||
|
||||
|
||||
LOCAL(boxptr)
|
||||
find_biggest_color_pop (boxptr boxlist, int numboxes)
|
||||
find_biggest_color_pop(boxptr boxlist, int numboxes)
|
||||
/* Find the splittable box with the largest color population */
|
||||
/* Returns NULL if no splittable boxes remain */
|
||||
{
|
||||
@@ -269,7 +269,7 @@ find_biggest_color_pop (boxptr boxlist, int numboxes)
|
||||
|
||||
|
||||
LOCAL(boxptr)
|
||||
find_biggest_volume (boxptr boxlist, int numboxes)
|
||||
find_biggest_volume(boxptr boxlist, int numboxes)
|
||||
/* Find the splittable box with the largest (scaled) volume */
|
||||
/* Returns NULL if no splittable boxes remain */
|
||||
{
|
||||
@@ -289,16 +289,16 @@ find_biggest_volume (boxptr boxlist, int numboxes)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
update_box(j_decompress_ptr cinfo, boxptr boxp)
|
||||
/* Shrink the min/max bounds of a box to enclose only nonzero elements, */
|
||||
/* and recompute its volume and population */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
histptr histp;
|
||||
int c0,c1,c2;
|
||||
int c0min,c0max,c1min,c1max,c2min,c2max;
|
||||
JLONG dist0,dist1,dist2;
|
||||
int c0, c1, c2;
|
||||
int c0min, c0max, c1min, c1max, c2min, c2max;
|
||||
JLONG dist0, dist1, dist2;
|
||||
long ccount;
|
||||
|
||||
c0min = boxp->c0min; c0max = boxp->c0max;
|
||||
@@ -308,69 +308,69 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
if (c0max > c0min)
|
||||
for (c0 = c0min; c0 <= c0max; c0++)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c0min = c0min = c0;
|
||||
goto have_c0min;
|
||||
}
|
||||
}
|
||||
have_c0min:
|
||||
have_c0min:
|
||||
if (c0max > c0min)
|
||||
for (c0 = c0max; c0 >= c0min; c0--)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c0max = c0max = c0;
|
||||
goto have_c0max;
|
||||
}
|
||||
}
|
||||
have_c0max:
|
||||
have_c0max:
|
||||
if (c1max > c1min)
|
||||
for (c1 = c1min; c1 <= c1max; c1++)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c1min = c1min = c1;
|
||||
goto have_c1min;
|
||||
}
|
||||
}
|
||||
have_c1min:
|
||||
have_c1min:
|
||||
if (c1max > c1min)
|
||||
for (c1 = c1max; c1 >= c1min; c1--)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c1max = c1max = c1;
|
||||
goto have_c1max;
|
||||
}
|
||||
}
|
||||
have_c1max:
|
||||
have_c1max:
|
||||
if (c2max > c2min)
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1min][c2];
|
||||
histp = &histogram[c0][c1min][c2];
|
||||
for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
|
||||
if (*histp != 0) {
|
||||
boxp->c2min = c2min = c2;
|
||||
goto have_c2min;
|
||||
}
|
||||
}
|
||||
have_c2min:
|
||||
have_c2min:
|
||||
if (c2max > c2min)
|
||||
for (c2 = c2max; c2 >= c2min; c2--)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1min][c2];
|
||||
histp = &histogram[c0][c1min][c2];
|
||||
for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
|
||||
if (*histp != 0) {
|
||||
boxp->c2max = c2max = c2;
|
||||
goto have_c2max;
|
||||
}
|
||||
}
|
||||
have_c2max:
|
||||
have_c2max:
|
||||
|
||||
/* Update box volume.
|
||||
* We use 2-norm rather than real volume here; this biases the method
|
||||
@@ -383,13 +383,13 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE;
|
||||
dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
|
||||
dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
|
||||
boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
|
||||
boxp->volume = dist0 * dist0 + dist1 * dist1 + dist2 * dist2;
|
||||
|
||||
/* Now scan remaining volume of box and compute population */
|
||||
ccount = 0;
|
||||
for (c0 = c0min; c0 <= c0max; c0++)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++, histp++)
|
||||
if (*histp != 0) {
|
||||
ccount++;
|
||||
@@ -400,19 +400,19 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
median_cut(j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
int desired_colors)
|
||||
/* Repeatedly select and split the largest box until we have enough boxes */
|
||||
{
|
||||
int n,lb;
|
||||
int c0,c1,c2,cmax;
|
||||
register boxptr b1,b2;
|
||||
int n, lb;
|
||||
int c0, c1, c2, cmax;
|
||||
register boxptr b1, b2;
|
||||
|
||||
while (numboxes < desired_colors) {
|
||||
/* Select box to split.
|
||||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
if (numboxes*2 <= desired_colors) {
|
||||
if (numboxes * 2 <= desired_colors) {
|
||||
b1 = find_biggest_color_pop(boxlist, numboxes);
|
||||
} else {
|
||||
b1 = find_biggest_volume(boxlist, numboxes);
|
||||
@@ -437,8 +437,7 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
cmax = c1; n = 1;
|
||||
if (c0 > cmax) { cmax = c0; n = 0; }
|
||||
if (c2 > cmax) { n = 2; }
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
cmax = c1; n = 1;
|
||||
if (c2 > cmax) { cmax = c2; n = 2; }
|
||||
if (c0 > cmax) { n = 0; }
|
||||
@@ -453,17 +452,17 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
case 0:
|
||||
lb = (b1->c0max + b1->c0min) / 2;
|
||||
b1->c0max = lb;
|
||||
b2->c0min = lb+1;
|
||||
b2->c0min = lb + 1;
|
||||
break;
|
||||
case 1:
|
||||
lb = (b1->c1max + b1->c1min) / 2;
|
||||
b1->c1max = lb;
|
||||
b2->c1min = lb+1;
|
||||
b2->c1min = lb + 1;
|
||||
break;
|
||||
case 2:
|
||||
lb = (b1->c2max + b1->c2min) / 2;
|
||||
b1->c2max = lb;
|
||||
b2->c2min = lb+1;
|
||||
b2->c2min = lb + 1;
|
||||
break;
|
||||
}
|
||||
/* Update stats for boxes */
|
||||
@@ -476,16 +475,16 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
|
||||
compute_color(j_decompress_ptr cinfo, boxptr boxp, int icolor)
|
||||
/* Compute representative color for a box, put it in colormap[icolor] */
|
||||
{
|
||||
/* Current algorithm: mean weighted by pixels (not colors) */
|
||||
/* Note it is important to get the rounding correct! */
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
histptr histp;
|
||||
int c0,c1,c2;
|
||||
int c0min,c0max,c1min,c1max,c2min,c2max;
|
||||
int c0, c1, c2;
|
||||
int c0min, c0max, c1min, c1max, c2min, c2max;
|
||||
long count;
|
||||
long total = 0;
|
||||
long c0total = 0;
|
||||
@@ -498,25 +497,25 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
|
||||
|
||||
for (c0 = c0min; c0 <= c0max; c0++)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++) {
|
||||
if ((count = *histp++) != 0) {
|
||||
total += count;
|
||||
c0total += ((c0 << C0_SHIFT) + ((1<<C0_SHIFT)>>1)) * count;
|
||||
c1total += ((c1 << C1_SHIFT) + ((1<<C1_SHIFT)>>1)) * count;
|
||||
c2total += ((c2 << C2_SHIFT) + ((1<<C2_SHIFT)>>1)) * count;
|
||||
c0total += ((c0 << C0_SHIFT) + ((1 << C0_SHIFT) >> 1)) * count;
|
||||
c1total += ((c1 << C1_SHIFT) + ((1 << C1_SHIFT) >> 1)) * count;
|
||||
c2total += ((c2 << C2_SHIFT) + ((1 << C2_SHIFT) >> 1)) * count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
|
||||
cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
|
||||
cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
|
||||
cinfo->colormap[0][icolor] = (JSAMPLE)((c0total + (total >> 1)) / total);
|
||||
cinfo->colormap[1][icolor] = (JSAMPLE)((c1total + (total >> 1)) / total);
|
||||
cinfo->colormap[2][icolor] = (JSAMPLE)((c2total + (total >> 1)) / total);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
select_colors(j_decompress_ptr cinfo, int desired_colors)
|
||||
/* Master routine for color selection */
|
||||
{
|
||||
boxptr boxlist;
|
||||
@@ -524,8 +523,8 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
int i;
|
||||
|
||||
/* Allocate workspace for box list */
|
||||
boxlist = (boxptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
|
||||
boxlist = (boxptr)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
|
||||
/* Initialize one box containing whole space */
|
||||
numboxes = 1;
|
||||
boxlist[0].c0min = 0;
|
||||
@@ -535,12 +534,12 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
boxlist[0].c2min = 0;
|
||||
boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT;
|
||||
/* Shrink it to actually-used volume and set its statistics */
|
||||
update_box(cinfo, & boxlist[0]);
|
||||
update_box(cinfo, &boxlist[0]);
|
||||
/* Perform median-cut to produce final box list */
|
||||
numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors);
|
||||
/* Compute the representative color for each box, fill colormap */
|
||||
for (i = 0; i < numboxes; i++)
|
||||
compute_color(cinfo, & boxlist[i], i);
|
||||
compute_color(cinfo, &boxlist[i], i);
|
||||
cinfo->actual_number_of_colors = numboxes;
|
||||
TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes);
|
||||
}
|
||||
@@ -601,13 +600,13 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
|
||||
|
||||
/* log2(histogram cells in update box) for each axis; this can be adjusted */
|
||||
#define BOX_C0_LOG (HIST_C0_BITS-3)
|
||||
#define BOX_C1_LOG (HIST_C1_BITS-3)
|
||||
#define BOX_C2_LOG (HIST_C2_BITS-3)
|
||||
#define BOX_C0_LOG (HIST_C0_BITS - 3)
|
||||
#define BOX_C1_LOG (HIST_C1_BITS - 3)
|
||||
#define BOX_C2_LOG (HIST_C2_BITS - 3)
|
||||
|
||||
#define BOX_C0_ELEMS (1<<BOX_C0_LOG) /* # of hist cells in update box */
|
||||
#define BOX_C1_ELEMS (1<<BOX_C1_LOG)
|
||||
#define BOX_C2_ELEMS (1<<BOX_C2_LOG)
|
||||
#define BOX_C0_ELEMS (1 << BOX_C0_LOG) /* # of hist cells in update box */
|
||||
#define BOX_C1_ELEMS (1 << BOX_C1_LOG)
|
||||
#define BOX_C2_ELEMS (1 << BOX_C2_LOG)
|
||||
|
||||
#define BOX_C0_SHIFT (C0_SHIFT + BOX_C0_LOG)
|
||||
#define BOX_C1_SHIFT (C1_SHIFT + BOX_C1_LOG)
|
||||
@@ -623,7 +622,7 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
JSAMPLE colorlist[])
|
||||
/* Locate the colormap entries close enough to an update box to be candidates
|
||||
* for the nearest entry to some cell(s) in the update box. The update box
|
||||
@@ -669,67 +668,67 @@ find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
x = GETJSAMPLE(cinfo->colormap[0][i]);
|
||||
if (x < minc0) {
|
||||
tdist = (x - minc0) * C0_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
min_dist = tdist * tdist;
|
||||
tdist = (x - maxc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
} else if (x > maxc0) {
|
||||
tdist = (x - maxc0) * C0_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
min_dist = tdist * tdist;
|
||||
tdist = (x - minc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
min_dist = 0;
|
||||
if (x <= centerc0) {
|
||||
tdist = (x - maxc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
} else {
|
||||
tdist = (x - minc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = GETJSAMPLE(cinfo->colormap[1][i]);
|
||||
if (x < minc1) {
|
||||
tdist = (x - minc1) * C1_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - maxc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else if (x > maxc1) {
|
||||
tdist = (x - maxc1) * C1_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - minc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerc1) {
|
||||
tdist = (x - maxc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
tdist = (x - minc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = GETJSAMPLE(cinfo->colormap[2][i]);
|
||||
if (x < minc2) {
|
||||
tdist = (x - minc2) * C2_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - maxc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else if (x > maxc2) {
|
||||
tdist = (x - maxc2) * C2_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - minc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerc2) {
|
||||
tdist = (x - maxc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
tdist = (x - minc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,14 +744,14 @@ find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
ncolors = 0;
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
if (mindist[i] <= minmaxdist)
|
||||
colorlist[ncolors++] = (JSAMPLE) i;
|
||||
colorlist[ncolors++] = (JSAMPLE)i;
|
||||
}
|
||||
return ncolors;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])
|
||||
/* Find the closest colormap entry for each cell in the update box,
|
||||
* given the list of candidate colors prepared by find_nearby_colors.
|
||||
@@ -775,7 +774,7 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
|
||||
/* Initialize best-distance for each cell of the update box */
|
||||
bptr = bestdist;
|
||||
for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)
|
||||
for (i = BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS - 1; i >= 0; i--)
|
||||
*bptr++ = 0x7FFFFFFFL;
|
||||
|
||||
/* For each color selected by find_nearby_colors,
|
||||
@@ -792,11 +791,11 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
icolor = GETJSAMPLE(colorlist[i]);
|
||||
/* Compute (square of) distance from minc0/c1/c2 to this color */
|
||||
inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE;
|
||||
dist0 = inc0*inc0;
|
||||
dist0 = inc0 * inc0;
|
||||
inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE;
|
||||
dist0 += inc1*inc1;
|
||||
dist0 += inc1 * inc1;
|
||||
inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE;
|
||||
dist0 += inc2*inc2;
|
||||
dist0 += inc2 * inc2;
|
||||
/* Form the initial difference increments */
|
||||
inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0;
|
||||
inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1;
|
||||
@@ -805,16 +804,16 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
bptr = bestdist;
|
||||
cptr = bestcolor;
|
||||
xx0 = inc0;
|
||||
for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) {
|
||||
for (ic0 = BOX_C0_ELEMS - 1; ic0 >= 0; ic0--) {
|
||||
dist1 = dist0;
|
||||
xx1 = inc1;
|
||||
for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) {
|
||||
for (ic1 = BOX_C1_ELEMS - 1; ic1 >= 0; ic1--) {
|
||||
dist2 = dist1;
|
||||
xx2 = inc2;
|
||||
for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) {
|
||||
for (ic2 = BOX_C2_ELEMS - 1; ic2 >= 0; ic2--) {
|
||||
if (dist2 < *bptr) {
|
||||
*bptr = dist2;
|
||||
*cptr = (JSAMPLE) icolor;
|
||||
*cptr = (JSAMPLE)icolor;
|
||||
}
|
||||
dist2 += xx2;
|
||||
xx2 += 2 * STEP_C2 * STEP_C2;
|
||||
@@ -832,12 +831,12 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
fill_inverse_cmap(j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
/* Fill the inverse-colormap entries in the update box that contains */
|
||||
/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */
|
||||
/* we can fill as many others as we wish.) */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
int minc0, minc1, minc2; /* lower left corner of update box */
|
||||
int ic0, ic1, ic2;
|
||||
@@ -878,9 +877,9 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
cptr = bestcolor;
|
||||
for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) {
|
||||
for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) {
|
||||
cachep = & histogram[c0+ic0][c1+ic1][c2];
|
||||
cachep = &histogram[c0 + ic0][c1 + ic1][c2];
|
||||
for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) {
|
||||
*cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1);
|
||||
*cachep++ = (histcell)(GETJSAMPLE(*cptr++) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -892,11 +891,11 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pass2_no_dither (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
|
||||
pass2_no_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* This version performs no dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register histptr cachep;
|
||||
@@ -913,24 +912,24 @@ pass2_no_dither (j_decompress_ptr cinfo,
|
||||
c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT;
|
||||
c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT;
|
||||
c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT;
|
||||
cachep = & histogram[c0][c1][c2];
|
||||
cachep = &histogram[c0][c1][c2];
|
||||
/* If we have not seen this color before, find nearest colormap entry */
|
||||
/* and update the cache */
|
||||
if (*cachep == 0)
|
||||
fill_inverse_cmap(cinfo, c0,c1,c2);
|
||||
fill_inverse_cmap(cinfo, c0, c1, c2);
|
||||
/* Now emit the colormap index for this cell */
|
||||
*outptr++ = (JSAMPLE) (*cachep - 1);
|
||||
*outptr++ = (JSAMPLE)(*cachep - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
|
||||
pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* This version performs Floyd-Steinberg dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */
|
||||
LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */
|
||||
@@ -956,11 +955,11 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
outptr = output_buf[row];
|
||||
if (cquantize->on_odd_row) {
|
||||
/* work right to left in this row */
|
||||
inptr += (width-1) * 3; /* so point to rightmost pixel */
|
||||
outptr += width-1;
|
||||
inptr += (width - 1) * 3; /* so point to rightmost pixel */
|
||||
outptr += width - 1;
|
||||
dir = -1;
|
||||
dir3 = -3;
|
||||
errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */
|
||||
errorptr = cquantize->fserrors + (width + 1) * 3; /* => entry after last column */
|
||||
cquantize->on_odd_row = FALSE; /* flip for next time */
|
||||
} else {
|
||||
/* work left to right in this row */
|
||||
@@ -984,9 +983,9 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* for either sign of the error value.
|
||||
* Note: errorptr points to *previous* column's array entry.
|
||||
*/
|
||||
cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4);
|
||||
cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4);
|
||||
cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4);
|
||||
cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3 + 0] + 8, 4);
|
||||
cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3 + 1] + 8, 4);
|
||||
cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3 + 2] + 8, 4);
|
||||
/* Limit the error using transfer function set by init_error_limit.
|
||||
* See comments with init_error_limit for rationale.
|
||||
*/
|
||||
@@ -1004,14 +1003,17 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
cur1 = GETJSAMPLE(range_limit[cur1]);
|
||||
cur2 = GETJSAMPLE(range_limit[cur2]);
|
||||
/* Index into the cache with adjusted pixel value */
|
||||
cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT];
|
||||
cachep =
|
||||
&histogram[cur0 >> C0_SHIFT][cur1 >> C1_SHIFT][cur2 >> C2_SHIFT];
|
||||
/* If we have not seen this color before, find nearest colormap */
|
||||
/* entry and update the cache */
|
||||
if (*cachep == 0)
|
||||
fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT);
|
||||
fill_inverse_cmap(cinfo, cur0 >> C0_SHIFT, cur1 >> C1_SHIFT,
|
||||
cur2 >> C2_SHIFT);
|
||||
/* Now emit the colormap index for this cell */
|
||||
{ register int pixcode = *cachep - 1;
|
||||
*outptr = (JSAMPLE) pixcode;
|
||||
{
|
||||
register int pixcode = *cachep - 1;
|
||||
*outptr = (JSAMPLE)pixcode;
|
||||
/* Compute representation error for this pixel */
|
||||
cur0 -= GETJSAMPLE(colormap0[pixcode]);
|
||||
cur1 -= GETJSAMPLE(colormap1[pixcode]);
|
||||
@@ -1021,20 +1023,21 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* Add these into the running sums, and simultaneously shift the
|
||||
* next-line error sums left by 1 column.
|
||||
*/
|
||||
{ register LOCFSERROR bnexterr;
|
||||
{
|
||||
register LOCFSERROR bnexterr;
|
||||
|
||||
bnexterr = cur0; /* Process component 0 */
|
||||
errorptr[0] = (FSERROR) (bpreverr0 + cur0 * 3);
|
||||
errorptr[0] = (FSERROR)(bpreverr0 + cur0 * 3);
|
||||
bpreverr0 = belowerr0 + cur0 * 5;
|
||||
belowerr0 = bnexterr;
|
||||
cur0 *= 7;
|
||||
bnexterr = cur1; /* Process component 1 */
|
||||
errorptr[1] = (FSERROR) (bpreverr1 + cur1 * 3);
|
||||
errorptr[1] = (FSERROR)(bpreverr1 + cur1 * 3);
|
||||
bpreverr1 = belowerr1 + cur1 * 5;
|
||||
belowerr1 = bnexterr;
|
||||
cur1 *= 7;
|
||||
bnexterr = cur2; /* Process component 2 */
|
||||
errorptr[2] = (FSERROR) (bpreverr2 + cur2 * 3);
|
||||
errorptr[2] = (FSERROR)(bpreverr2 + cur2 * 3);
|
||||
bpreverr2 = belowerr2 + cur2 * 5;
|
||||
belowerr2 = bnexterr;
|
||||
cur2 *= 7;
|
||||
@@ -1051,9 +1054,9 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* final fserrors[] entry. Note we need not unload belowerrN because
|
||||
* it is for the dummy column before or after the actual array.
|
||||
*/
|
||||
errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */
|
||||
errorptr[1] = (FSERROR) bpreverr1;
|
||||
errorptr[2] = (FSERROR) bpreverr2;
|
||||
errorptr[0] = (FSERROR)bpreverr0; /* unload prev errs into array */
|
||||
errorptr[1] = (FSERROR)bpreverr1;
|
||||
errorptr[2] = (FSERROR)bpreverr2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1076,26 +1079,26 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
init_error_limit (j_decompress_ptr cinfo)
|
||||
init_error_limit(j_decompress_ptr cinfo)
|
||||
/* Allocate and fill in the error_limiter table */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
int *table;
|
||||
int in, out;
|
||||
|
||||
table = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * sizeof(int));
|
||||
table = (int *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, (MAXJSAMPLE * 2 + 1) * sizeof(int));
|
||||
table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
|
||||
cquantize->error_limiter = table;
|
||||
|
||||
#define STEPSIZE ((MAXJSAMPLE+1)/16)
|
||||
#define STEPSIZE ((MAXJSAMPLE + 1) / 16)
|
||||
/* Map errors 1:1 up to +- MAXJSAMPLE/16 */
|
||||
out = 0;
|
||||
for (in = 0; in < STEPSIZE; in++, out++) {
|
||||
table[in] = out; table[-in] = -out;
|
||||
}
|
||||
/* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */
|
||||
for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) {
|
||||
for (; in < STEPSIZE * 3; in++, out += (in & 1) ? 0 : 1) {
|
||||
table[in] = out; table[-in] = -out;
|
||||
}
|
||||
/* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */
|
||||
@@ -1111,9 +1114,9 @@ init_error_limit (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass1 (j_decompress_ptr cinfo)
|
||||
finish_pass1(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
|
||||
/* Select the representative colors and fill in cinfo->colormap */
|
||||
cinfo->colormap = cquantize->sv_colormap;
|
||||
@@ -1124,7 +1127,7 @@ finish_pass1 (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass2 (j_decompress_ptr cinfo)
|
||||
finish_pass2(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work */
|
||||
}
|
||||
@@ -1135,9 +1138,9 @@ finish_pass2 (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
start_pass_2_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
int i;
|
||||
|
||||
@@ -1167,14 +1170,14 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
||||
|
||||
if (cinfo->dither_mode == JDITHER_FS) {
|
||||
size_t arraysize = (size_t) ((cinfo->output_width + 2) *
|
||||
(3 * sizeof(FSERROR)));
|
||||
size_t arraysize =
|
||||
(size_t)((cinfo->output_width + 2) * (3 * sizeof(FSERROR)));
|
||||
/* Allocate Floyd-Steinberg workspace if we didn't already. */
|
||||
if (cquantize->fserrors == NULL)
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
cquantize->fserrors = (FSERRPTR)(*cinfo->mem->alloc_large)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, arraysize);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
jzero_far((void *) cquantize->fserrors, arraysize);
|
||||
jzero_far((void *)cquantize->fserrors, arraysize);
|
||||
/* Make the error-limit table if we didn't already. */
|
||||
if (cquantize->error_limiter == NULL)
|
||||
init_error_limit(cinfo);
|
||||
@@ -1185,8 +1188,8 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
/* Zero the histogram or inverse color map, if necessary */
|
||||
if (cquantize->needs_zeroed) {
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
jzero_far((void *) histogram[i],
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
|
||||
jzero_far((void *)histogram[i],
|
||||
HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = FALSE;
|
||||
}
|
||||
@@ -1198,9 +1201,9 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
new_color_map_2_quant (j_decompress_ptr cinfo)
|
||||
new_color_map_2_quant(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
|
||||
/* Reset the inverse color map */
|
||||
cquantize->needs_zeroed = TRUE;
|
||||
@@ -1212,15 +1215,15 @@ new_color_map_2_quant (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
jinit_2pass_quantizer(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize;
|
||||
int i;
|
||||
|
||||
cquantize = (my_cquantize_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_cquantizer));
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *)cquantize;
|
||||
cquantize->pub.start_pass = start_pass_2_quant;
|
||||
cquantize->pub.new_color_map = new_color_map_2_quant;
|
||||
cquantize->fserrors = NULL; /* flag optional arrays not allocated */
|
||||
@@ -1231,12 +1234,12 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_NOTIMPL);
|
||||
|
||||
/* Allocate the histogram/inverse colormap storage */
|
||||
cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
|
||||
cquantize->histogram = (hist3d)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
|
||||
cquantize->histogram[i] = (hist2d)(*cinfo->mem->alloc_large)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
|
||||
|
||||
@@ -1254,7 +1257,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
if (desired > MAXNUMCOLORS)
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
||||
cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)desired, (JDIMENSION)3);
|
||||
cquantize->desired = desired;
|
||||
} else
|
||||
cquantize->sv_colormap = NULL;
|
||||
@@ -1271,9 +1274,9 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
* dither_mode changes.
|
||||
*/
|
||||
if (cinfo->dither_mode == JDITHER_FS) {
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) ((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
|
||||
cquantize->fserrors = (FSERRPTR)(*cinfo->mem->alloc_large)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(size_t)((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
|
||||
/* Might as well create the error-limiting table too. */
|
||||
init_error_limit(cinfo);
|
||||
}
|
||||
|
||||
132
jsimd.h
132
jsimd.h
@@ -13,81 +13,93 @@
|
||||
|
||||
#include "jchuff.h" /* Declarations shared with jcphuff.c */
|
||||
|
||||
EXTERN(int) jsimd_can_rgb_ycc (void);
|
||||
EXTERN(int) jsimd_can_rgb_gray (void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb (void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb565 (void);
|
||||
EXTERN(int) jsimd_c_can_null_convert (void);
|
||||
EXTERN(int) jsimd_can_rgb_ycc(void);
|
||||
EXTERN(int) jsimd_can_rgb_gray(void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb(void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb565(void);
|
||||
EXTERN(int) jsimd_c_can_null_convert(void);
|
||||
|
||||
EXTERN(void) jsimd_rgb_ycc_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
EXTERN(void) jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_rgb_gray_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
EXTERN(void) jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_ycc_rgb_convert
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
EXTERN(void) jsimd_ycc_rgb_convert(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows);
|
||||
EXTERN(void) jsimd_ycc_rgb565_convert
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
EXTERN(void) jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows);
|
||||
EXTERN(void) jsimd_c_null_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_downsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_downsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
EXTERN(void) jsimd_h2v2_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_smooth_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_smooth_downsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_smooth_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
EXTERN(void) jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(void) jsimd_h2v1_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
EXTERN(void) jsimd_h2v1_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_upsample (void);
|
||||
EXTERN(int) jsimd_can_int_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_upsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_upsample(void);
|
||||
EXTERN(int) jsimd_can_int_upsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_int_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v2_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_int_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_fancy_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_fancy_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_fancy_upsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_fancy_upsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_fancy_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_fancy_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_merged_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_merged_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_merged_upsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_merged_upsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_merged_upsample
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
EXTERN(void) jsimd_h2v1_merged_upsample
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
EXTERN(void) jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf);
|
||||
EXTERN(void) jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf);
|
||||
|
||||
EXTERN(int) jsimd_can_huff_encode_one_block (void);
|
||||
EXTERN(int) jsimd_can_huff_encode_one_block(void);
|
||||
|
||||
EXTERN(JOCTET*) jsimd_huff_encode_one_block
|
||||
(void *state, JOCTET *buffer, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl, c_derived_tbl *actbl);
|
||||
EXTERN(JOCTET *) jsimd_huff_encode_one_block(void *state, JOCTET *buffer,
|
||||
JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl,
|
||||
c_derived_tbl *actbl);
|
||||
|
||||
167
jsimd_none.c
167
jsimd_none.c
@@ -20,383 +20,370 @@
|
||||
#include "jsimddct.h"
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_rgb_ycc (void)
|
||||
jsimd_can_rgb_ycc(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_rgb_gray (void)
|
||||
jsimd_can_rgb_gray(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_ycc_rgb (void)
|
||||
jsimd_can_ycc_rgb(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_ycc_rgb565 (void)
|
||||
jsimd_can_ycc_rgb565(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_c_can_null_convert (void)
|
||||
jsimd_c_can_null_convert(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_c_null_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_downsample (void)
|
||||
jsimd_can_h2v2_downsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_downsample (void)
|
||||
jsimd_can_h2v1_downsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_smooth_downsample (void)
|
||||
jsimd_can_h2v2_smooth_downsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_smooth_downsample (j_compress_ptr cinfo,
|
||||
jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_upsample (void)
|
||||
jsimd_can_h2v2_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_upsample (void)
|
||||
jsimd_can_h2v1_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_int_upsample (void)
|
||||
jsimd_can_int_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_fancy_upsample (void)
|
||||
jsimd_can_h2v2_fancy_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_fancy_upsample (void)
|
||||
jsimd_can_h2v1_fancy_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_merged_upsample (void)
|
||||
jsimd_can_h2v2_merged_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_merged_upsample (void)
|
||||
jsimd_can_h2v1_merged_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_convsamp (void)
|
||||
jsimd_can_convsamp(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_convsamp_float (void)
|
||||
jsimd_can_convsamp_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
DCTELEM *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_islow (void)
|
||||
jsimd_can_fdct_islow(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_ifast (void)
|
||||
jsimd_can_fdct_ifast(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_float (void)
|
||||
jsimd_can_fdct_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_islow (DCTELEM *data)
|
||||
jsimd_fdct_islow(DCTELEM *data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_ifast (DCTELEM *data)
|
||||
jsimd_fdct_ifast(DCTELEM *data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_float (FAST_FLOAT *data)
|
||||
jsimd_fdct_float(FAST_FLOAT *data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_quantize (void)
|
||||
jsimd_can_quantize(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_quantize_float (void)
|
||||
jsimd_can_quantize_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
|
||||
DCTELEM *workspace)
|
||||
jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_2x2 (void)
|
||||
jsimd_can_idct_2x2(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_4x4 (void)
|
||||
jsimd_can_idct_4x4(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_6x6 (void)
|
||||
jsimd_can_idct_6x6(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_12x12 (void)
|
||||
jsimd_can_idct_12x12(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_islow (void)
|
||||
jsimd_can_idct_islow(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_ifast (void)
|
||||
jsimd_can_idct_ifast(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_float (void)
|
||||
jsimd_can_idct_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_huff_encode_one_block (void)
|
||||
jsimd_can_huff_encode_one_block(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(JOCTET*)
|
||||
jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
|
||||
GLOBAL(JOCTET *)
|
||||
jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
|
||||
int last_dc_val, c_derived_tbl *dctbl,
|
||||
c_derived_tbl *actbl)
|
||||
{
|
||||
|
||||
72
jsimddct.h
72
jsimddct.h
@@ -9,66 +9,62 @@
|
||||
*
|
||||
*/
|
||||
|
||||
EXTERN(int) jsimd_can_convsamp (void);
|
||||
EXTERN(int) jsimd_can_convsamp_float (void);
|
||||
EXTERN(int) jsimd_can_convsamp(void);
|
||||
EXTERN(int) jsimd_can_convsamp_float(void);
|
||||
|
||||
EXTERN(void) jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
EXTERN(void) jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
DCTELEM *workspace);
|
||||
EXTERN(void) jsimd_convsamp_float (JSAMPARRAY sample_data,
|
||||
JDIMENSION start_col,
|
||||
EXTERN(void) jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT *workspace);
|
||||
|
||||
EXTERN(int) jsimd_can_fdct_islow (void);
|
||||
EXTERN(int) jsimd_can_fdct_ifast (void);
|
||||
EXTERN(int) jsimd_can_fdct_float (void);
|
||||
EXTERN(int) jsimd_can_fdct_islow(void);
|
||||
EXTERN(int) jsimd_can_fdct_ifast(void);
|
||||
EXTERN(int) jsimd_can_fdct_float(void);
|
||||
|
||||
EXTERN(void) jsimd_fdct_islow (DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_ifast (DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_float (FAST_FLOAT *data);
|
||||
EXTERN(void) jsimd_fdct_islow(DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_ifast(DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_float(FAST_FLOAT *data);
|
||||
|
||||
EXTERN(int) jsimd_can_quantize (void);
|
||||
EXTERN(int) jsimd_can_quantize_float (void);
|
||||
EXTERN(int) jsimd_can_quantize(void);
|
||||
EXTERN(int) jsimd_can_quantize_float(void);
|
||||
|
||||
EXTERN(void) jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
|
||||
EXTERN(void) jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors,
|
||||
DCTELEM *workspace);
|
||||
EXTERN(void) jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
EXTERN(void) jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace);
|
||||
|
||||
EXTERN(int) jsimd_can_idct_2x2 (void);
|
||||
EXTERN(int) jsimd_can_idct_4x4 (void);
|
||||
EXTERN(int) jsimd_can_idct_6x6 (void);
|
||||
EXTERN(int) jsimd_can_idct_12x12 (void);
|
||||
EXTERN(int) jsimd_can_idct_2x2(void);
|
||||
EXTERN(int) jsimd_can_idct_4x4(void);
|
||||
EXTERN(int) jsimd_can_idct_6x6(void);
|
||||
EXTERN(int) jsimd_can_idct_12x12(void);
|
||||
|
||||
EXTERN(void) jsimd_idct_2x2 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_4x4 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_6x6 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_12x12 (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_2x2(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_4x4(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_6x6(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_12x12(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
|
||||
EXTERN(int) jsimd_can_idct_islow (void);
|
||||
EXTERN(int) jsimd_can_idct_ifast (void);
|
||||
EXTERN(int) jsimd_can_idct_float (void);
|
||||
EXTERN(int) jsimd_can_idct_islow(void);
|
||||
EXTERN(int) jsimd_can_idct_ifast(void);
|
||||
EXTERN(int) jsimd_can_idct_float(void);
|
||||
|
||||
EXTERN(void) jsimd_idct_islow (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_islow(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_ifast (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_ifast(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_float (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_float(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
|
||||
50
jstdhuff.c
50
jstdhuff.c
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
add_huff_table (j_common_ptr cinfo,
|
||||
JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
|
||||
add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
|
||||
const UINT8 *val)
|
||||
/* Define a Huffman table */
|
||||
{
|
||||
int nsymbols, len;
|
||||
@@ -50,26 +50,31 @@ add_huff_table (j_common_ptr cinfo,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
std_huff_tables (j_common_ptr cinfo)
|
||||
std_huff_tables(j_common_ptr cinfo)
|
||||
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
|
||||
/* IMPORTANT: these are only valid for 8-bit data precision! */
|
||||
{
|
||||
JHUFF_TBL **dc_huff_tbl_ptrs, **ac_huff_tbl_ptrs;
|
||||
|
||||
static const UINT8 bits_dc_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_luminance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
static const UINT8 bits_dc_luminance[17] = {
|
||||
/* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
static const UINT8 val_dc_luminance[] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
|
||||
};
|
||||
|
||||
static const UINT8 bits_dc_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_chrominance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
static const UINT8 bits_dc_chrominance[17] = {
|
||||
/* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
|
||||
};
|
||||
static const UINT8 val_dc_chrominance[] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
|
||||
};
|
||||
|
||||
static const UINT8 bits_ac_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
|
||||
static const UINT8 val_ac_luminance[] =
|
||||
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
static const UINT8 bits_ac_luminance[17] = {
|
||||
/* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
|
||||
};
|
||||
static const UINT8 val_ac_luminance[] = {
|
||||
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
@@ -89,12 +94,14 @@ std_huff_tables (j_common_ptr cinfo)
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
0xf9, 0xfa
|
||||
};
|
||||
|
||||
static const UINT8 bits_ac_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
|
||||
static const UINT8 val_ac_chrominance[] =
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
static const UINT8 bits_ac_chrominance[17] = {
|
||||
/* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
|
||||
};
|
||||
static const UINT8 val_ac_chrominance[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
@@ -114,7 +121,8 @@ std_huff_tables (j_common_ptr cinfo)
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
0xf9, 0xfa
|
||||
};
|
||||
|
||||
if (cinfo->is_decompressor) {
|
||||
dc_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->dc_huff_tbl_ptrs;
|
||||
|
||||
18
jutils.c
18
jutils.c
@@ -53,7 +53,7 @@ const int jpeg_zigzag_order[DCTSIZE2] = {
|
||||
* fake entries.
|
||||
*/
|
||||
|
||||
const int jpeg_natural_order[DCTSIZE2+16] = {
|
||||
const int jpeg_natural_order[DCTSIZE2 + 16] = {
|
||||
0, 1, 8, 16, 9, 2, 3, 10,
|
||||
17, 24, 32, 25, 18, 11, 4, 5,
|
||||
12, 19, 26, 33, 40, 48, 41, 34,
|
||||
@@ -72,7 +72,7 @@ const int jpeg_natural_order[DCTSIZE2+16] = {
|
||||
*/
|
||||
|
||||
GLOBAL(long)
|
||||
jdiv_round_up (long a, long b)
|
||||
jdiv_round_up(long a, long b)
|
||||
/* Compute a/b rounded up to next integer, ie, ceil(a/b) */
|
||||
/* Assumes a >= 0, b > 0 */
|
||||
{
|
||||
@@ -81,7 +81,7 @@ jdiv_round_up (long a, long b)
|
||||
|
||||
|
||||
GLOBAL(long)
|
||||
jround_up (long a, long b)
|
||||
jround_up(long a, long b)
|
||||
/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
|
||||
/* Assumes a >= 0, b > 0 */
|
||||
{
|
||||
@@ -91,9 +91,9 @@ jround_up (long a, long b)
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row,
|
||||
int num_rows, JDIMENSION num_cols)
|
||||
jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row, int num_rows,
|
||||
JDIMENSION num_cols)
|
||||
/* Copy some rows of samples from one place to another.
|
||||
* num_rows rows are copied from input_array[source_row++]
|
||||
* to output_array[dest_row++]; these areas may overlap for duplication.
|
||||
@@ -101,7 +101,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
*/
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register size_t count = (size_t) (num_cols * sizeof(JSAMPLE));
|
||||
register size_t count = (size_t)(num_cols * sizeof(JSAMPLE));
|
||||
register int row;
|
||||
|
||||
input_array += source_row;
|
||||
@@ -116,7 +116,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks)
|
||||
/* Copy a row of coefficient blocks from one place to another. */
|
||||
{
|
||||
@@ -125,7 +125,7 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jzero_far (void *target, size_t bytestozero)
|
||||
jzero_far(void *target, size_t bytestozero)
|
||||
/* Zero out a chunk of memory. */
|
||||
/* This might be sample-array data, block-array data, or alloc_large data. */
|
||||
{
|
||||
|
||||
@@ -45,6 +45,6 @@
|
||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||
"Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \
|
||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \
|
||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
|
||||
|
||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2017 The libjpeg-turbo Project and many others"
|
||||
|
||||
@@ -411,7 +411,7 @@ array containing 3-byte RGB pixels:
|
||||
row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */
|
||||
|
||||
while (cinfo.next_scanline < cinfo.image_height) {
|
||||
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
|
||||
row_pointer[0] = &image_buffer[cinfo.next_scanline * row_stride];
|
||||
jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
|
||||
@@ -1974,7 +1974,7 @@ and how to display each pass.
|
||||
The simplest approach to displaying progressive images is to do one display
|
||||
pass for each scan appearing in the input file. In this case the outer loop
|
||||
condition is typically
|
||||
while (! jpeg_input_complete(&cinfo))
|
||||
while (!jpeg_input_complete(&cinfo))
|
||||
and the start-output call should read
|
||||
jpeg_start_output(&cinfo, cinfo.input_scan_number);
|
||||
The second parameter to jpeg_start_output() indicates which scan of the input
|
||||
@@ -2095,7 +2095,7 @@ something like this:
|
||||
jpeg_start_output(&cinfo, cinfo.input_scan_number);
|
||||
...
|
||||
jpeg_finish_output()
|
||||
} while (! final_pass);
|
||||
} while (!final_pass);
|
||||
rather than quitting as soon as jpeg_input_complete() returns TRUE. This
|
||||
arrangement makes it simple to use higher-quality decoding parameters
|
||||
for the final pass. But if you don't want to use special parameters for
|
||||
@@ -2968,7 +2968,7 @@ object is destroyed. Most data is allocated "per image" and is freed by
|
||||
jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the
|
||||
memory manager yourself to allocate structures that will automatically be
|
||||
freed at these times. Typical code for this is
|
||||
ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size);
|
||||
ptr = (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, size);
|
||||
Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object.
|
||||
Use alloc_large instead of alloc_small for anything bigger than a few Kbytes.
|
||||
There are also alloc_sarray and alloc_barray routines that automatically
|
||||
|
||||
224
md5/md5.c
224
md5/md5.c
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
|
||||
*
|
||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
* rights reserved.
|
||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991.
|
||||
* All rights reserved.
|
||||
*
|
||||
* License to copy and use this software is granted provided that it
|
||||
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
@@ -61,8 +61,8 @@ static void MD5Transform(unsigned int [4], const unsigned char [64]);
|
||||
* a multiple of 4.
|
||||
*/
|
||||
|
||||
static void
|
||||
Encode (unsigned char *output, unsigned int *input, unsigned int len)
|
||||
static void Encode(unsigned char *output, unsigned int *input,
|
||||
unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int *op = (unsigned int *)output;
|
||||
@@ -76,8 +76,8 @@ Encode (unsigned char *output, unsigned int *input, unsigned int len)
|
||||
* a multiple of 4.
|
||||
*/
|
||||
|
||||
static void
|
||||
Decode (unsigned int *output, const unsigned char *input, unsigned int len)
|
||||
static void Decode(unsigned int *output, const unsigned char *input,
|
||||
unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
const unsigned int *ip = (const unsigned int *)input;
|
||||
@@ -100,40 +100,37 @@ static unsigned char PADDING[64] = {
|
||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits. */
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
|
||||
/*
|
||||
* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||
* Rotation is separate from addition to prevent recomputation.
|
||||
*/
|
||||
#define FF(a, b, c, d, x, s, ac) { \
|
||||
(a) += F ((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += F((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
}
|
||||
#define GG(a, b, c, d, x, s, ac) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += G((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
}
|
||||
#define HH(a, b, c, d, x, s, ac) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += H((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
}
|
||||
#define II(a, b, c, d, x, s, ac) { \
|
||||
(a) += I ((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += I((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
||||
(a) = ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
}
|
||||
|
||||
/* MD5 initialization. Begins an MD5 operation, writing a new context. */
|
||||
|
||||
void
|
||||
MD5Init (context)
|
||||
MD5_CTX *context;
|
||||
void MD5Init(MD5_CTX *context)
|
||||
{
|
||||
|
||||
context->count[0] = context->count[1] = 0;
|
||||
|
||||
/* Load magic initialization constants. */
|
||||
@@ -149,11 +146,7 @@ MD5Init (context)
|
||||
* context.
|
||||
*/
|
||||
|
||||
void
|
||||
MD5Update (context, in, inputLen)
|
||||
MD5_CTX *context;
|
||||
const void *in;
|
||||
unsigned int inputLen;
|
||||
void MD5Update(MD5_CTX *context, const void *in, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, idx, partLen;
|
||||
const unsigned char *input = in;
|
||||
@@ -162,8 +155,8 @@ MD5Update (context, in, inputLen)
|
||||
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((unsigned int)inputLen << 3))
|
||||
< ((unsigned int)inputLen << 3))
|
||||
if ((context->count[0] += ((unsigned int)inputLen << 3)) <
|
||||
((unsigned int)inputLen << 3))
|
||||
context->count[1]++;
|
||||
context->count[1] += ((unsigned int)inputLen >> 29);
|
||||
|
||||
@@ -171,44 +164,39 @@ MD5Update (context, in, inputLen)
|
||||
|
||||
/* Transform as many times as possible. */
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((void *)&context->buffer[idx], (const void *)input,
|
||||
partLen);
|
||||
MD5Transform (context->state, context->buffer);
|
||||
memcpy((void *)&context->buffer[idx], (const void *)input, partLen);
|
||||
MD5Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||
MD5Transform (context->state, &input[i]);
|
||||
MD5Transform(context->state, &input[i]);
|
||||
|
||||
idx = 0;
|
||||
}
|
||||
else
|
||||
} else
|
||||
i = 0;
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy ((void *)&context->buffer[idx], (const void *)&input[i],
|
||||
inputLen-i);
|
||||
memcpy((void *)&context->buffer[idx], (const void *)&input[i], inputLen - i);
|
||||
}
|
||||
|
||||
/*
|
||||
* MD5 padding. Adds padding followed by original length.
|
||||
*/
|
||||
|
||||
void
|
||||
MD5Pad (context)
|
||||
MD5_CTX *context;
|
||||
void MD5Pad(MD5_CTX *context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int idx, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
Encode (bits, context->count, 8);
|
||||
Encode(bits, context->count, 8);
|
||||
|
||||
/* Pad out to 56 mod 64. */
|
||||
idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (idx < 56) ? (56 - idx) : (120 - idx);
|
||||
MD5Update (context, PADDING, padLen);
|
||||
MD5Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
MD5Update (context, bits, 8);
|
||||
MD5Update(context, bits, 8);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -216,119 +204,113 @@ MD5Pad (context)
|
||||
* the message digest and zeroizing the context.
|
||||
*/
|
||||
|
||||
void
|
||||
MD5Final (digest, context)
|
||||
unsigned char digest[16];
|
||||
MD5_CTX *context;
|
||||
void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
||||
{
|
||||
/* Do padding. */
|
||||
MD5Pad (context);
|
||||
MD5Pad(context);
|
||||
|
||||
/* Store state in digest */
|
||||
Encode (digest, context->state, 16);
|
||||
Encode(digest, context->state, 16);
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset ((void *)context, 0, sizeof (*context));
|
||||
memset((void *)context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
/* MD5 basic transformation. Transforms state based on block. */
|
||||
|
||||
static void
|
||||
MD5Transform (state, block)
|
||||
unsigned int state[4];
|
||||
const unsigned char block[64];
|
||||
static void MD5Transform(unsigned int state[4], const unsigned char block[64])
|
||||
{
|
||||
unsigned int a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
|
||||
Decode (x, block, 64);
|
||||
Decode(x, block, 64);
|
||||
|
||||
/* Round 1 */
|
||||
#define S11 7
|
||||
#define S12 12
|
||||
#define S13 17
|
||||
#define S14 22
|
||||
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
|
||||
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
|
||||
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
|
||||
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
|
||||
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
|
||||
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
|
||||
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
|
||||
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
|
||||
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
|
||||
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
|
||||
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
||||
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
||||
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
||||
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
||||
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
||||
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
||||
FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
|
||||
FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
|
||||
FF(c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
|
||||
FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
|
||||
FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
|
||||
FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
|
||||
FF(c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
|
||||
FF(b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
|
||||
FF(a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
|
||||
FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
|
||||
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
||||
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
||||
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
||||
FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
||||
FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
||||
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
||||
|
||||
/* Round 2 */
|
||||
#define S21 5
|
||||
#define S22 9
|
||||
#define S23 14
|
||||
#define S24 20
|
||||
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
|
||||
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
|
||||
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
||||
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
|
||||
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
|
||||
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
||||
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
||||
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
|
||||
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
|
||||
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
||||
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
|
||||
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
|
||||
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
||||
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
|
||||
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
|
||||
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
|
||||
GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
|
||||
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
||||
GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
|
||||
GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
|
||||
GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
||||
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
||||
GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
|
||||
GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
|
||||
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
||||
GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
|
||||
GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
|
||||
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
||||
GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
|
||||
GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
|
||||
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
/* Round 3 */
|
||||
#define S31 4
|
||||
#define S32 11
|
||||
#define S33 16
|
||||
#define S34 23
|
||||
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
|
||||
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
|
||||
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
||||
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
||||
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
|
||||
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
|
||||
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
|
||||
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
||||
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
||||
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
|
||||
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
|
||||
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
|
||||
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
|
||||
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
||||
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
||||
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
|
||||
HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
|
||||
HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
|
||||
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
||||
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
||||
HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
|
||||
HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
|
||||
HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
|
||||
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
||||
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
||||
HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
|
||||
HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
|
||||
HH(b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
|
||||
HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
|
||||
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
||||
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
||||
HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
|
||||
|
||||
/* Round 4 */
|
||||
#define S41 6
|
||||
#define S42 10
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
|
||||
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
|
||||
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
||||
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
|
||||
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
||||
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
|
||||
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
||||
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
|
||||
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
|
||||
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
|
||||
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
||||
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
|
||||
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
||||
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
|
||||
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
|
||||
II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
|
||||
II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
|
||||
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
||||
II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
|
||||
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
||||
II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
|
||||
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
||||
II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
|
||||
II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
|
||||
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
|
||||
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
||||
II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
|
||||
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
||||
II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
|
||||
II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
@@ -336,5 +318,5 @@ MD5Transform (state, block)
|
||||
state[3] += d;
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset ((void *)x, 0, sizeof (x));
|
||||
memset((void *)x, 0, sizeof(x));
|
||||
}
|
||||
|
||||
18
md5/md5.h
18
md5/md5.h
@@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
/*-
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991.
|
||||
All rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
@@ -41,11 +41,11 @@ typedef struct MD5Context {
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} MD5_CTX;
|
||||
|
||||
void MD5Init (MD5_CTX *);
|
||||
void MD5Update (MD5_CTX *, const void *, unsigned int);
|
||||
void MD5Final (unsigned char [16], MD5_CTX *);
|
||||
char * MD5End(MD5_CTX *, char *);
|
||||
char * MD5File(const char *, char *);
|
||||
char * MD5FileChunk(const char *, char *, off_t, off_t);
|
||||
char * MD5Data(const void *, unsigned int, char *);
|
||||
void MD5Init(MD5_CTX *);
|
||||
void MD5Update(MD5_CTX *, const void *, unsigned int);
|
||||
void MD5Final(unsigned char [16], MD5_CTX *);
|
||||
char *MD5End(MD5_CTX *, char *);
|
||||
char *MD5File(const char *, char *);
|
||||
char *MD5FileChunk(const char *, char *, off_t, off_t);
|
||||
char *MD5Data(const void *, unsigned int, char *);
|
||||
#endif /* _SYS_MD5_H_ */
|
||||
|
||||
29
md5/md5hl.c
29
md5/md5hl.c
@@ -1,4 +1,5 @@
|
||||
/* mdXhl.c * ----------------------------------------------------------------------------
|
||||
/* mdXhl.c
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
@@ -32,34 +33,31 @@
|
||||
|
||||
#include "./md5.h"
|
||||
|
||||
char *
|
||||
MD5End(MD5_CTX *ctx, char *buf)
|
||||
char *MD5End(MD5_CTX *ctx, char *buf)
|
||||
{
|
||||
int i;
|
||||
unsigned char digest[LENGTH];
|
||||
static const char hex[]="0123456789abcdef";
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
|
||||
if (!buf)
|
||||
buf = malloc(2*LENGTH + 1);
|
||||
buf = malloc(2 * LENGTH + 1);
|
||||
if (!buf)
|
||||
return 0;
|
||||
MD5Final(digest, ctx);
|
||||
for (i = 0; i < LENGTH; i++) {
|
||||
buf[i+i] = hex[digest[i] >> 4];
|
||||
buf[i+i+1] = hex[digest[i] & 0x0f];
|
||||
buf[i + i] = hex[digest[i] >> 4];
|
||||
buf[i + i + 1] = hex[digest[i] & 0x0f];
|
||||
}
|
||||
buf[i+i] = '\0';
|
||||
buf[i + i] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *
|
||||
MD5File(const char *filename, char *buf)
|
||||
char *MD5File(const char *filename, char *buf)
|
||||
{
|
||||
return (MD5FileChunk(filename, buf, 0, 0));
|
||||
}
|
||||
|
||||
char *
|
||||
MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
||||
char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
||||
{
|
||||
unsigned char buffer[BUFSIZ];
|
||||
MD5_CTX ctx;
|
||||
@@ -69,7 +67,7 @@ MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
||||
|
||||
MD5Init(&ctx);
|
||||
#if _WIN32
|
||||
f = _open(filename, O_RDONLY|O_BINARY);
|
||||
f = _open(filename, O_RDONLY | O_BINARY);
|
||||
#else
|
||||
f = open(filename, O_RDONLY);
|
||||
#endif
|
||||
@@ -103,12 +101,11 @@ MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
||||
return (MD5End(&ctx, buf));
|
||||
}
|
||||
|
||||
char *
|
||||
MD5Data (const void *data, unsigned int len, char *buf)
|
||||
char *MD5Data(const void *data, unsigned int len, char *buf)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx,data,len);
|
||||
MD5Update(&ctx, data, len);
|
||||
return (MD5End(&ctx, buf));
|
||||
}
|
||||
|
||||
174
rdbmp.c
174
rdbmp.c
@@ -26,8 +26,8 @@
|
||||
* This code contributed by James Arthur Boucher.
|
||||
*/
|
||||
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "cmyk.h"
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
|
||||
#ifdef BMP_SUPPORTED
|
||||
|
||||
@@ -36,19 +36,20 @@
|
||||
|
||||
#ifdef HAVE_UNSIGNED_CHAR
|
||||
typedef unsigned char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#define UCH(x) ((int)(x))
|
||||
#else /* !HAVE_UNSIGNED_CHAR */
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#define UCH(x) ((int)(x))
|
||||
#else
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x) & 0xFF)
|
||||
#define UCH(x) ((int)(x) & 0xFF)
|
||||
#endif
|
||||
#endif /* HAVE_UNSIGNED_CHAR */
|
||||
|
||||
|
||||
#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
|
||||
#define ReadOK(file, buffer, len) \
|
||||
(JFREAD(file, buffer, len) == ((size_t)(len)))
|
||||
|
||||
static int alpha_index[JPEG_NUMCS] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
||||
@@ -86,7 +87,7 @@ typedef struct _bmp_source_struct {
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
read_byte (bmp_source_ptr sinfo)
|
||||
read_byte(bmp_source_ptr sinfo)
|
||||
/* Read next byte from BMP file */
|
||||
{
|
||||
register FILE *infile = sinfo->pub.input_file;
|
||||
@@ -99,7 +100,7 @@ read_byte (bmp_source_ptr sinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
|
||||
read_colormap(bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
|
||||
/* Read the colormap from a BMP file */
|
||||
{
|
||||
int i, gray = 1;
|
||||
@@ -108,9 +109,9 @@ read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
|
||||
case 3:
|
||||
/* BGR format (occurs in OS/2 files) */
|
||||
for (i = 0; i < cmaplen; i++) {
|
||||
sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);
|
||||
sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);
|
||||
sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);
|
||||
sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
|
||||
sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
|
||||
sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
|
||||
if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
|
||||
sinfo->colormap[1][i] != sinfo->colormap[0][i])
|
||||
gray = 0;
|
||||
@@ -119,10 +120,10 @@ read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
|
||||
case 4:
|
||||
/* BGR0 format (occurs in MS Windows files) */
|
||||
for (i = 0; i < cmaplen; i++) {
|
||||
sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);
|
||||
sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);
|
||||
sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);
|
||||
(void) read_byte(sinfo);
|
||||
sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
|
||||
sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
|
||||
sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
|
||||
(void)read_byte(sinfo);
|
||||
if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
|
||||
sinfo->colormap[1][i] != sinfo->colormap[0][i])
|
||||
gray = 0;
|
||||
@@ -149,10 +150,10 @@ read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
|
||||
*/
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading 8-bit colormap indexes */
|
||||
{
|
||||
bmp_source_ptr source = (bmp_source_ptr) sinfo;
|
||||
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
||||
register JSAMPARRAY colormap = source->colormap;
|
||||
JSAMPARRAY image_ptr;
|
||||
register int t;
|
||||
@@ -163,11 +164,11 @@ get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* Fetch next row from virtual array */
|
||||
source->source_row--;
|
||||
image_ptr = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, source->whole_image,
|
||||
source->source_row, (JDIMENSION) 1, FALSE);
|
||||
((j_common_ptr)cinfo, source->whole_image,
|
||||
source->source_row, (JDIMENSION)1, FALSE);
|
||||
inptr = image_ptr[0];
|
||||
} else {
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
inptr = source->iobuffer;
|
||||
}
|
||||
@@ -218,10 +219,10 @@ get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading 24-bit pixels */
|
||||
{
|
||||
bmp_source_ptr source = (bmp_source_ptr) sinfo;
|
||||
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
||||
JSAMPARRAY image_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -230,11 +231,11 @@ get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* Fetch next row from virtual array */
|
||||
source->source_row--;
|
||||
image_ptr = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, source->whole_image,
|
||||
source->source_row, (JDIMENSION) 1, FALSE);
|
||||
((j_common_ptr)cinfo, source->whole_image,
|
||||
source->source_row, (JDIMENSION)1, FALSE);
|
||||
inptr = image_ptr[0];
|
||||
} else {
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
inptr = source->iobuffer;
|
||||
}
|
||||
@@ -282,10 +283,10 @@ get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_32bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading 32-bit pixels */
|
||||
{
|
||||
bmp_source_ptr source = (bmp_source_ptr) sinfo;
|
||||
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
||||
JSAMPARRAY image_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -294,11 +295,11 @@ get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* Fetch next row from virtual array */
|
||||
source->source_row--;
|
||||
image_ptr = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, source->whole_image,
|
||||
source->source_row, (JDIMENSION) 1, FALSE);
|
||||
((j_common_ptr)cinfo, source->whole_image,
|
||||
source->source_row, (JDIMENSION)1, FALSE);
|
||||
inptr = image_ptr[0];
|
||||
} else {
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
inptr = source->iobuffer;
|
||||
}
|
||||
@@ -355,25 +356,24 @@ get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
preload_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
{
|
||||
bmp_source_ptr source = (bmp_source_ptr) sinfo;
|
||||
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
||||
register FILE *infile = source->pub.input_file;
|
||||
register JSAMPROW out_ptr;
|
||||
JSAMPARRAY image_ptr;
|
||||
JDIMENSION row;
|
||||
cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
|
||||
cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
|
||||
|
||||
/* Read the data into a virtual array in input-file row order. */
|
||||
for (row = 0; row < cinfo->image_height; row++) {
|
||||
if (progress != NULL) {
|
||||
progress->pub.pass_counter = (long) row;
|
||||
progress->pub.pass_limit = (long) cinfo->image_height;
|
||||
(*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
|
||||
progress->pub.pass_counter = (long)row;
|
||||
progress->pub.pass_limit = (long)cinfo->image_height;
|
||||
(*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
image_ptr = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, source->whole_image,
|
||||
row, (JDIMENSION) 1, TRUE);
|
||||
((j_common_ptr)cinfo, source->whole_image, row, (JDIMENSION)1, TRUE);
|
||||
out_ptr = image_ptr[0];
|
||||
if (fread(out_ptr, 1, source->row_width, infile) != source->row_width) {
|
||||
if (feof(infile))
|
||||
@@ -411,55 +411,59 @@ preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
{
|
||||
bmp_source_ptr source = (bmp_source_ptr) sinfo;
|
||||
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
||||
U_CHAR bmpfileheader[14];
|
||||
U_CHAR bmpinfoheader[64];
|
||||
#define GET_2B(array,offset) ((unsigned short) UCH(array[offset]) + \
|
||||
(((unsigned short) UCH(array[offset+1])) << 8))
|
||||
#define GET_4B(array,offset) ((unsigned int) UCH(array[offset]) + \
|
||||
(((unsigned int) UCH(array[offset+1])) << 8) + \
|
||||
(((unsigned int) UCH(array[offset+2])) << 16) + \
|
||||
(((unsigned int) UCH(array[offset+3])) << 24))
|
||||
|
||||
#define GET_2B(array, offset) \
|
||||
((unsigned short)UCH(array[offset]) + \
|
||||
(((unsigned short)UCH(array[offset + 1])) << 8))
|
||||
#define GET_4B(array, offset) \
|
||||
((unsigned int)UCH(array[offset]) + \
|
||||
(((unsigned int)UCH(array[offset + 1])) << 8) + \
|
||||
(((unsigned int)UCH(array[offset + 2])) << 16) + \
|
||||
(((unsigned int)UCH(array[offset + 3])) << 24))
|
||||
|
||||
unsigned int bfOffBits;
|
||||
unsigned int headerSize;
|
||||
int biWidth;
|
||||
int biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned int biCompression;
|
||||
int biXPelsPerMeter,biYPelsPerMeter;
|
||||
int biXPelsPerMeter, biYPelsPerMeter;
|
||||
unsigned int biClrUsed = 0;
|
||||
int mapentrysize = 0; /* 0 indicates no colormap */
|
||||
int bPad;
|
||||
JDIMENSION row_width = 0;
|
||||
|
||||
/* Read and verify the bitmap file header */
|
||||
if (! ReadOK(source->pub.input_file, bmpfileheader, 14))
|
||||
if (!ReadOK(source->pub.input_file, bmpfileheader, 14))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */
|
||||
if (GET_2B(bmpfileheader, 0) != 0x4D42) /* 'BM' */
|
||||
ERREXIT(cinfo, JERR_BMP_NOT);
|
||||
bfOffBits = GET_4B(bmpfileheader,10);
|
||||
bfOffBits = GET_4B(bmpfileheader, 10);
|
||||
/* We ignore the remaining fileheader fields */
|
||||
|
||||
/* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),
|
||||
* or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which.
|
||||
*/
|
||||
if (! ReadOK(source->pub.input_file, bmpinfoheader, 4))
|
||||
if (!ReadOK(source->pub.input_file, bmpinfoheader, 4))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
headerSize = GET_4B(bmpinfoheader,0);
|
||||
headerSize = GET_4B(bmpinfoheader, 0);
|
||||
if (headerSize < 12 || headerSize > 64)
|
||||
ERREXIT(cinfo, JERR_BMP_BADHEADER);
|
||||
if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4))
|
||||
if (!ReadOK(source->pub.input_file, bmpinfoheader + 4, headerSize - 4))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
|
||||
switch (headerSize) {
|
||||
case 12:
|
||||
/* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */
|
||||
biWidth = (int) GET_2B(bmpinfoheader,4);
|
||||
biHeight = (int) GET_2B(bmpinfoheader,6);
|
||||
biPlanes = GET_2B(bmpinfoheader,8);
|
||||
source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10);
|
||||
biWidth = (int)GET_2B(bmpinfoheader, 4);
|
||||
biHeight = (int)GET_2B(bmpinfoheader, 6);
|
||||
biPlanes = GET_2B(bmpinfoheader, 8);
|
||||
source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 10);
|
||||
|
||||
switch (source->bits_per_pixel) {
|
||||
case 8: /* colormapped image */
|
||||
@@ -478,14 +482,14 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
case 64:
|
||||
/* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */
|
||||
/* or OS/2 2.x header, which has additional fields that we ignore */
|
||||
biWidth = (int) GET_4B(bmpinfoheader,4);
|
||||
biHeight = (int) GET_4B(bmpinfoheader,8);
|
||||
biPlanes = GET_2B(bmpinfoheader,12);
|
||||
source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14);
|
||||
biCompression = GET_4B(bmpinfoheader,16);
|
||||
biXPelsPerMeter = (int) GET_4B(bmpinfoheader,24);
|
||||
biYPelsPerMeter = (int) GET_4B(bmpinfoheader,28);
|
||||
biClrUsed = GET_4B(bmpinfoheader,32);
|
||||
biWidth = (int)GET_4B(bmpinfoheader, 4);
|
||||
biHeight = (int)GET_4B(bmpinfoheader, 8);
|
||||
biPlanes = GET_2B(bmpinfoheader, 12);
|
||||
source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 14);
|
||||
biCompression = GET_4B(bmpinfoheader, 16);
|
||||
biXPelsPerMeter = (int)GET_4B(bmpinfoheader, 24);
|
||||
biYPelsPerMeter = (int)GET_4B(bmpinfoheader, 28);
|
||||
biClrUsed = GET_4B(bmpinfoheader, 32);
|
||||
/* biSizeImage, biClrImportant fields are ignored */
|
||||
|
||||
switch (source->bits_per_pixel) {
|
||||
@@ -508,8 +512,8 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) {
|
||||
/* Set JFIF density parameters from the BMP data */
|
||||
cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */
|
||||
cinfo->Y_density = (UINT16) (biYPelsPerMeter/100);
|
||||
cinfo->X_density = (UINT16)(biXPelsPerMeter / 100); /* 100 cm per meter */
|
||||
cinfo->Y_density = (UINT16)(biYPelsPerMeter / 100);
|
||||
cinfo->density_unit = 2; /* dots/cm */
|
||||
}
|
||||
break;
|
||||
@@ -534,10 +538,9 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
ERREXIT(cinfo, JERR_BMP_BADCMAP);
|
||||
/* Allocate space to store the colormap */
|
||||
source->colormap = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) biClrUsed, (JDIMENSION) 3);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)biClrUsed, (JDIMENSION)3);
|
||||
/* and read it from the file */
|
||||
read_colormap(source, (int) biClrUsed, mapentrysize);
|
||||
read_colormap(source, (int)biClrUsed, mapentrysize);
|
||||
/* account for size of colormap */
|
||||
bPad -= biClrUsed * mapentrysize;
|
||||
}
|
||||
@@ -546,7 +549,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
if (bPad < 0) /* incorrect bfOffBits value? */
|
||||
ERREXIT(cinfo, JERR_BMP_BADHEADER);
|
||||
while (--bPad >= 0) {
|
||||
(void) read_byte(source);
|
||||
(void)read_byte(source);
|
||||
}
|
||||
|
||||
/* Compute row width in file, including padding to 4-byte boundary */
|
||||
@@ -562,7 +565,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
cinfo->input_components = 4;
|
||||
else
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
row_width = (JDIMENSION) biWidth;
|
||||
row_width = (JDIMENSION)biWidth;
|
||||
break;
|
||||
case 24:
|
||||
if (cinfo->in_color_space == JCS_UNKNOWN)
|
||||
@@ -573,7 +576,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
cinfo->input_components = 4;
|
||||
else
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
row_width = (JDIMENSION) (biWidth * 3);
|
||||
row_width = (JDIMENSION)(biWidth * 3);
|
||||
break;
|
||||
case 32:
|
||||
if (cinfo->in_color_space == JCS_UNKNOWN)
|
||||
@@ -584,7 +587,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
cinfo->input_components = 4;
|
||||
else
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
row_width = (JDIMENSION) (biWidth * 4);
|
||||
row_width = (JDIMENSION)(biWidth * 4);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
|
||||
@@ -595,17 +598,16 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
if (source->use_inversion_array) {
|
||||
/* Allocate space for inversion array, prepare for preload pass */
|
||||
source->whole_image = (*cinfo->mem->request_virt_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||
row_width, (JDIMENSION) biHeight, (JDIMENSION) 1);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
||||
row_width, (JDIMENSION)biHeight, (JDIMENSION)1);
|
||||
source->pub.get_pixel_rows = preload_image;
|
||||
if (cinfo->progress != NULL) {
|
||||
cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
|
||||
cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
|
||||
progress->total_extra_passes++; /* count file input as separate pass */
|
||||
}
|
||||
} else {
|
||||
source->iobuffer = (U_CHAR *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
row_width);
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, row_width);
|
||||
switch (source->bits_per_pixel) {
|
||||
case 8:
|
||||
source->pub.get_pixel_rows = get_8bit_row;
|
||||
@@ -623,13 +625,13 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
/* Allocate one-row buffer for returned data */
|
||||
source->pub.buffer = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (biWidth * cinfo->input_components), (JDIMENSION) 1);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(biWidth * cinfo->input_components), (JDIMENSION)1);
|
||||
source->pub.buffer_height = 1;
|
||||
|
||||
cinfo->data_precision = 8;
|
||||
cinfo->image_width = (JDIMENSION) biWidth;
|
||||
cinfo->image_height = (JDIMENSION) biHeight;
|
||||
cinfo->image_width = (JDIMENSION)biWidth;
|
||||
cinfo->image_height = (JDIMENSION)biHeight;
|
||||
}
|
||||
|
||||
|
||||
@@ -638,7 +640,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
finish_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
{
|
||||
/* no work */
|
||||
}
|
||||
@@ -649,13 +651,13 @@ finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(cjpeg_source_ptr)
|
||||
jinit_read_bmp (j_compress_ptr cinfo, boolean use_inversion_array)
|
||||
jinit_read_bmp(j_compress_ptr cinfo, boolean use_inversion_array)
|
||||
{
|
||||
bmp_source_ptr source;
|
||||
|
||||
/* Create module interface object */
|
||||
source = (bmp_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(bmp_source_struct));
|
||||
source->cinfo = cinfo; /* make back link for subroutines */
|
||||
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
|
||||
@@ -664,7 +666,7 @@ jinit_read_bmp (j_compress_ptr cinfo, boolean use_inversion_array)
|
||||
|
||||
source->use_inversion_array = use_inversion_array;
|
||||
|
||||
return (cjpeg_source_ptr) source;
|
||||
return (cjpeg_source_ptr)source;
|
||||
}
|
||||
|
||||
#endif /* BMP_SUPPORTED */
|
||||
|
||||
34
rdcolmap.c
34
rdcolmap.c
@@ -44,7 +44,7 @@
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
add_map_entry (j_decompress_ptr cinfo, int R, int G, int B)
|
||||
add_map_entry(j_decompress_ptr cinfo, int R, int G, int B)
|
||||
{
|
||||
JSAMPROW colormap0 = cinfo->colormap[0];
|
||||
JSAMPROW colormap1 = cinfo->colormap[1];
|
||||
@@ -61,13 +61,13 @@ add_map_entry (j_decompress_ptr cinfo, int R, int G, int B)
|
||||
}
|
||||
|
||||
/* Check for map overflow. */
|
||||
if (ncolors >= (MAXJSAMPLE+1))
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1));
|
||||
if (ncolors >= (MAXJSAMPLE + 1))
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE + 1));
|
||||
|
||||
/* OK, add color to map. */
|
||||
colormap0[ncolors] = (JSAMPLE) R;
|
||||
colormap1[ncolors] = (JSAMPLE) G;
|
||||
colormap2[ncolors] = (JSAMPLE) B;
|
||||
colormap0[ncolors] = (JSAMPLE)R;
|
||||
colormap1[ncolors] = (JSAMPLE)G;
|
||||
colormap2[ncolors] = (JSAMPLE)B;
|
||||
cinfo->actual_number_of_colors++;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ add_map_entry (j_decompress_ptr cinfo, int R, int G, int B)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
read_gif_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
read_gif_map(j_decompress_ptr cinfo, FILE *infile)
|
||||
{
|
||||
int header[13];
|
||||
int i, colormaplen;
|
||||
@@ -108,9 +108,9 @@ read_gif_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
if (R == EOF || G == EOF || B == EOF)
|
||||
ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
|
||||
add_map_entry(cinfo,
|
||||
R << (BITS_IN_JSAMPLE-8),
|
||||
G << (BITS_IN_JSAMPLE-8),
|
||||
B << (BITS_IN_JSAMPLE-8));
|
||||
R << (BITS_IN_JSAMPLE - 8),
|
||||
G << (BITS_IN_JSAMPLE - 8),
|
||||
B << (BITS_IN_JSAMPLE - 8));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ read_gif_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
pbm_getc (FILE *infile)
|
||||
pbm_getc(FILE *infile)
|
||||
/* Read next char, skipping over any comments */
|
||||
/* A comment/newline sequence is returned as a newline */
|
||||
{
|
||||
@@ -136,7 +136,7 @@ pbm_getc (FILE *infile)
|
||||
|
||||
|
||||
LOCAL(unsigned int)
|
||||
read_pbm_integer (j_decompress_ptr cinfo, FILE *infile)
|
||||
read_pbm_integer(j_decompress_ptr cinfo, FILE *infile)
|
||||
/* Read an unsigned decimal integer from the PPM file */
|
||||
/* Swallows one trailing character after the integer */
|
||||
/* Note that on a 16-bit-int machine, only values up to 64k can be read. */
|
||||
@@ -169,7 +169,7 @@ read_pbm_integer (j_decompress_ptr cinfo, FILE *infile)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
read_ppm_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
read_ppm_map(j_decompress_ptr cinfo, FILE *infile)
|
||||
{
|
||||
int c;
|
||||
unsigned int w, h, maxval, row, col;
|
||||
@@ -187,7 +187,7 @@ read_ppm_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
|
||||
|
||||
/* For now, we don't support rescaling from an unusual maxval. */
|
||||
if (maxval != (unsigned int) MAXJSAMPLE)
|
||||
if (maxval != (unsigned int)MAXJSAMPLE)
|
||||
ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
|
||||
|
||||
switch (c) {
|
||||
@@ -229,12 +229,12 @@ read_ppm_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
read_color_map (j_decompress_ptr cinfo, FILE *infile)
|
||||
read_color_map(j_decompress_ptr cinfo, FILE *infile)
|
||||
{
|
||||
/* Allocate space for a color map of maximum supported size. */
|
||||
cinfo->colormap = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(MAXJSAMPLE + 1), (JDIMENSION)3);
|
||||
cinfo->actual_number_of_colors = 0; /* initialize map to empty */
|
||||
|
||||
/* Read first byte to determine file format */
|
||||
|
||||
2
rdgif.c
2
rdgif.c
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(cjpeg_source_ptr)
|
||||
jinit_read_gif (j_compress_ptr cinfo)
|
||||
jinit_read_gif(j_compress_ptr cinfo)
|
||||
{
|
||||
fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
38
rdjpgcom.c
38
rdjpgcom.c
@@ -69,7 +69,7 @@ static FILE *infile; /* input JPEG file */
|
||||
|
||||
/* Read one byte, testing for EOF */
|
||||
static int
|
||||
read_1_byte (void)
|
||||
read_1_byte(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -82,7 +82,7 @@ read_1_byte (void)
|
||||
/* Read 2 bytes, convert to unsigned int */
|
||||
/* All 2-byte quantities in JPEG markers are MSB first */
|
||||
static unsigned int
|
||||
read_2_bytes (void)
|
||||
read_2_bytes(void)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
@@ -92,7 +92,7 @@ read_2_bytes (void)
|
||||
c2 = NEXTBYTE();
|
||||
if (c2 == EOF)
|
||||
ERREXIT("Premature EOF in JPEG file");
|
||||
return (((unsigned int) c1) << 8) + ((unsigned int) c2);
|
||||
return (((unsigned int)c1) << 8) + ((unsigned int)c2);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ read_2_bytes (void)
|
||||
*/
|
||||
|
||||
static int
|
||||
next_marker (void)
|
||||
next_marker(void)
|
||||
{
|
||||
int c;
|
||||
int discarded_bytes = 0;
|
||||
@@ -169,7 +169,7 @@ next_marker (void)
|
||||
*/
|
||||
|
||||
static int
|
||||
first_marker (void)
|
||||
first_marker(void)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
@@ -191,7 +191,7 @@ first_marker (void)
|
||||
*/
|
||||
|
||||
static void
|
||||
skip_variable (void)
|
||||
skip_variable(void)
|
||||
/* Skip over an unknown or uninteresting variable-length marker */
|
||||
{
|
||||
unsigned int length;
|
||||
@@ -204,7 +204,7 @@ skip_variable (void)
|
||||
length -= 2;
|
||||
/* Skip over the remaining bytes */
|
||||
while (length > 0) {
|
||||
(void) read_1_byte();
|
||||
(void)read_1_byte();
|
||||
length--;
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ skip_variable (void)
|
||||
*/
|
||||
|
||||
static void
|
||||
process_COM (int raw)
|
||||
process_COM(int raw)
|
||||
{
|
||||
unsigned int length;
|
||||
int ch;
|
||||
@@ -274,7 +274,7 @@ process_COM (int raw)
|
||||
*/
|
||||
|
||||
static void
|
||||
process_SOFn (int marker)
|
||||
process_SOFn(int marker)
|
||||
{
|
||||
unsigned int length;
|
||||
unsigned int image_height, image_width;
|
||||
@@ -310,13 +310,13 @@ process_SOFn (int marker)
|
||||
image_width, image_height, num_components, data_precision);
|
||||
printf("JPEG process: %s\n", process);
|
||||
|
||||
if (length != (unsigned int) (8 + num_components * 3))
|
||||
if (length != (unsigned int)(8 + num_components * 3))
|
||||
ERREXIT("Bogus SOF marker length");
|
||||
|
||||
for (ci = 0; ci < num_components; ci++) {
|
||||
(void) read_1_byte(); /* Component ID code */
|
||||
(void) read_1_byte(); /* H, V sampling factors */
|
||||
(void) read_1_byte(); /* Quantization table number */
|
||||
(void)read_1_byte(); /* Component ID code */
|
||||
(void)read_1_byte(); /* H, V sampling factors */
|
||||
(void)read_1_byte(); /* Quantization table number */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ process_SOFn (int marker)
|
||||
*/
|
||||
|
||||
static int
|
||||
scan_JPEG_header (int verbose, int raw)
|
||||
scan_JPEG_header(int verbose, int raw)
|
||||
{
|
||||
int marker;
|
||||
|
||||
@@ -401,7 +401,7 @@ static const char *progname; /* program name for error messages */
|
||||
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
usage(void)
|
||||
/* complain about bad command line */
|
||||
{
|
||||
fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n");
|
||||
@@ -417,7 +417,7 @@ usage (void)
|
||||
|
||||
|
||||
static int
|
||||
keymatch (char *arg, const char *keyword, int minchars)
|
||||
keymatch(char *arg, const char *keyword, int minchars)
|
||||
/* Case-insensitive matching of (possibly abbreviated) keyword switches. */
|
||||
/* keyword is the constant keyword (must be lower case already), */
|
||||
/* minchars is length of minimum legal abbreviation. */
|
||||
@@ -446,7 +446,7 @@ keymatch (char *arg, const char *keyword, int minchars)
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int argn;
|
||||
char *arg;
|
||||
@@ -477,7 +477,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Open the input file. */
|
||||
/* Unix style: expect zero or one file name */
|
||||
if (argn < argc-1) {
|
||||
if (argn < argc - 1) {
|
||||
fprintf(stderr, "%s: only one input file\n", progname);
|
||||
usage();
|
||||
}
|
||||
@@ -502,7 +502,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Scan the JPEG headers. */
|
||||
(void) scan_JPEG_header(verbose, raw);
|
||||
(void)scan_JPEG_header(verbose, raw);
|
||||
|
||||
/* All done. */
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
121
rdppm.c
121
rdppm.c
@@ -22,8 +22,8 @@
|
||||
* the file is indeed PPM format).
|
||||
*/
|
||||
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "cmyk.h"
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
|
||||
#ifdef PPM_SUPPORTED
|
||||
|
||||
@@ -45,19 +45,20 @@
|
||||
|
||||
#ifdef HAVE_UNSIGNED_CHAR
|
||||
typedef unsigned char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#define UCH(x) ((int)(x))
|
||||
#else /* !HAVE_UNSIGNED_CHAR */
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#define UCH(x) ((int)(x))
|
||||
#else
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x) & 0xFF)
|
||||
#define UCH(x) ((int)(x) & 0xFF)
|
||||
#endif
|
||||
#endif /* HAVE_UNSIGNED_CHAR */
|
||||
|
||||
|
||||
#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
|
||||
#define ReadOK(file, buffer, len) \
|
||||
(JFREAD(file, buffer, len) == ((size_t)(len)))
|
||||
|
||||
static int alpha_index[JPEG_NUMCS] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
||||
@@ -81,7 +82,7 @@ typedef ppm_source_struct *ppm_source_ptr;
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
pbm_getc (FILE *infile)
|
||||
pbm_getc(FILE *infile)
|
||||
/* Read next char, skipping over any comments */
|
||||
/* A comment/newline sequence is returned as a newline */
|
||||
{
|
||||
@@ -98,7 +99,7 @@ pbm_getc (FILE *infile)
|
||||
|
||||
|
||||
LOCAL(unsigned int)
|
||||
read_pbm_integer (j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
|
||||
read_pbm_integer(j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
|
||||
/* Read an unsigned decimal integer from the PPM file */
|
||||
/* Swallows one trailing character after the integer */
|
||||
/* Note that on a 16-bit-int machine, only values up to 64k can be read. */
|
||||
@@ -142,10 +143,10 @@ read_pbm_integer (j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_text_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading text-format PGM files with any maxval */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
FILE *infile = source->pub.input_file;
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -169,11 +170,11 @@ get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
}
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_text_gray_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_text_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading text-format PGM files with any maxval and
|
||||
converting to extended RGB */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
FILE *infile = source->pub.input_file;
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -204,11 +205,11 @@ get_text_gray_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_text_gray_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_text_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading text-format PGM files with any maxval and
|
||||
converting to CMYK */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
FILE *infile = source->pub.input_file;
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -244,10 +245,10 @@ get_text_gray_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
}
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading text-format PPM files with any maxval */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
FILE *infile = source->pub.input_file;
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -278,11 +279,11 @@ get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_text_rgb_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_text_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading text-format PPM files with any maxval and
|
||||
converting to CMYK */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
FILE *infile = source->pub.input_file;
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -312,16 +313,16 @@ get_text_rgb_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_scaled_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-byte-format PGM files with any maxval */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -333,11 +334,11 @@ get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_gray_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-byte-format PGM files with any maxval
|
||||
and converting to extended RGB */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -349,7 +350,7 @@ get_gray_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register int aindex = alpha_index[cinfo->in_color_space];
|
||||
register int ps = rgb_pixelsize[cinfo->in_color_space];
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -369,18 +370,18 @@ get_gray_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_gray_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-byte-format PGM files with any maxval
|
||||
and converting to CMYK */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -402,10 +403,10 @@ get_gray_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-byte-format PPM files with any maxval */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
@@ -417,7 +418,7 @@ get_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register int aindex = alpha_index[cinfo->in_color_space];
|
||||
register int ps = rgb_pixelsize[cinfo->in_color_space];
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -437,18 +438,18 @@ get_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_rgb_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-byte-format PPM files with any maxval and
|
||||
converting to CMYK */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -474,32 +475,32 @@ get_rgb_cmyk_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_raw_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE.
|
||||
* In this case we just read right into the JSAMPLE buffer!
|
||||
* Note that same code works for PPM and PGM files.
|
||||
*/
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-word-format PGM files with any maxval */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -516,17 +517,17 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
|
||||
METHODDEF(JDIMENSION)
|
||||
get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* This version is for reading raw-word-format PPM files with any maxval */
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
register JSAMPROW ptr;
|
||||
register U_CHAR *bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
@@ -557,9 +558,9 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
{
|
||||
ppm_source_ptr source = (ppm_source_ptr) sinfo;
|
||||
ppm_source_ptr source = (ppm_source_ptr)sinfo;
|
||||
int c;
|
||||
unsigned int w, h, maxval;
|
||||
boolean need_iobuffer, use_raw_buffer, need_rescale;
|
||||
@@ -590,8 +591,8 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
ERREXIT(cinfo, JERR_PPM_NOT);
|
||||
|
||||
cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */
|
||||
cinfo->image_width = (JDIMENSION) w;
|
||||
cinfo->image_height = (JDIMENSION) h;
|
||||
cinfo->image_width = (JDIMENSION)w;
|
||||
cinfo->image_height = (JDIMENSION)h;
|
||||
source->maxval = maxval;
|
||||
|
||||
/* initialize flags to most common settings */
|
||||
@@ -687,13 +688,13 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
|
||||
if (need_iobuffer) {
|
||||
if (c == '6')
|
||||
source->buffer_width = (size_t) w * 3 *
|
||||
source->buffer_width = (size_t)w * 3 *
|
||||
((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
|
||||
else
|
||||
source->buffer_width = (size_t) w *
|
||||
source->buffer_width = (size_t)w *
|
||||
((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
|
||||
source->iobuffer = (U_CHAR *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
source->buffer_width);
|
||||
}
|
||||
|
||||
@@ -701,14 +702,14 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
if (use_raw_buffer) {
|
||||
/* For unscaled raw-input case, we can just map it onto the I/O buffer. */
|
||||
/* Synthesize a JSAMPARRAY pointer structure */
|
||||
source->pixrow = (JSAMPROW) source->iobuffer;
|
||||
source->pub.buffer = & source->pixrow;
|
||||
source->pixrow = (JSAMPROW)source->iobuffer;
|
||||
source->pub.buffer = &source->pixrow;
|
||||
source->pub.buffer_height = 1;
|
||||
} else {
|
||||
/* Need to translate anyway, so make a separate sample buffer. */
|
||||
source->pub.buffer = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
|
||||
source->pub.buffer_height = 1;
|
||||
}
|
||||
|
||||
@@ -718,13 +719,13 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
|
||||
/* On 16-bit-int machines we have to be careful of maxval = 65535 */
|
||||
source->rescale = (JSAMPLE *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (((long) maxval + 1L) *
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(size_t)(((long)maxval + 1L) *
|
||||
sizeof(JSAMPLE)));
|
||||
half_maxval = maxval / 2;
|
||||
for (val = 0; val <= (long) maxval; val++) {
|
||||
for (val = 0; val <= (long)maxval; val++) {
|
||||
/* The multiplication here must be done in 32 bits to avoid overflow */
|
||||
source->rescale[val] = (JSAMPLE) ((val * MAXJSAMPLE + half_maxval) /
|
||||
source->rescale[val] = (JSAMPLE)((val * MAXJSAMPLE + half_maxval) /
|
||||
maxval);
|
||||
}
|
||||
}
|
||||
@@ -736,7 +737,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
finish_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
{
|
||||
/* no work */
|
||||
}
|
||||
@@ -747,19 +748,19 @@ finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(cjpeg_source_ptr)
|
||||
jinit_read_ppm (j_compress_ptr cinfo)
|
||||
jinit_read_ppm(j_compress_ptr cinfo)
|
||||
{
|
||||
ppm_source_ptr source;
|
||||
|
||||
/* Create module interface object */
|
||||
source = (ppm_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(ppm_source_struct));
|
||||
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
|
||||
source->pub.start_input = start_input_ppm;
|
||||
source->pub.finish_input = finish_input_ppm;
|
||||
|
||||
return (cjpeg_source_ptr) source;
|
||||
return (cjpeg_source_ptr)source;
|
||||
}
|
||||
|
||||
#endif /* PPM_SUPPORTED */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user