From 94015b89675cf4431c7e4953a597b70cfde03bcc Mon Sep 17 00:00:00 2001 From: malaterre Date: Tue, 7 Jun 2005 21:03:24 +0000 Subject: [PATCH] COMP: Tons of warnings fix...cannot believe how poorly written this was --- src/gdcmjpegls/Decoder/bitio.c | 14 ++++++++------ src/gdcmjpegls/Decoder/decoder.c | 22 +++++++++++++--------- src/gdcmjpegls/Decoder/global.c | 12 ++++++++---- src/gdcmjpegls/Decoder/global.h | 16 ++++++++++++++++ src/gdcmjpegls/Decoder/initialize.c | 1 - src/gdcmjpegls/Decoder/jpegmark.c | 5 ++--- src/gdcmjpegls/Decoder/jpegmark.h | 2 ++ src/gdcmjpegls/Decoder/lossless_d.c | 4 ++-- src/gdcmjpegls/Decoder/lossy_d.c | 7 +++---- src/gdcmjpegls/Decoder/melcode.c | 7 ++++--- 10 files changed, 58 insertions(+), 32 deletions(-) diff --git a/src/gdcmjpegls/Decoder/bitio.c b/src/gdcmjpegls/Decoder/bitio.c index 8353b108..13d9f459 100644 --- a/src/gdcmjpegls/Decoder/bitio.c +++ b/src/gdcmjpegls/Decoder/bitio.c @@ -88,6 +88,7 @@ int bits; /* number of bits free in bit buffer (on output) */ void bufiinit(FILE *fil) { /* argument is ignored */ + (void)fil; fp = BUFSIZE; truebufsize = 0; foundeof = 0; @@ -141,7 +142,8 @@ void bitiflush() { int filled, discard, dbytes, - i, k, treg; + i, k; + unsigned int treg; byte *bp; filled = 24 - bits; /* how many bits at the MS part of reg @@ -179,16 +181,16 @@ void bitiflush() { } /* check consistency */ if ( filled-k > 7 ) { - fprintf(stderr,"bitiflush: inconsistent bits=%d filled=%d k=%d\n",bits,filled,k); - exit(10); + fprintf(stderr,"bitiflush: inconsistent bits=%d filled=%d k=%d\n",bits,filled,k); + exit(10); } discard = filled-k; if ( treg != (reg<1) { fprintf(stderr,"\nERROR: Cannot use -P (PPM output) with plane intereleaved mode\n"); exit(10); + } } else multi=1; @@ -570,7 +572,7 @@ int initialize(int argc, char *argv[]) { } if ((multi) && (out_files) && (out_files!=components)) { - fprintf(stderr,"ERROR: Number of files, %d%, for output must be equal to number of image components, %d\n",out_files,components); + fprintf(stderr,"ERROR: Number of files, %d, for output must be equal to number of image components, %d\n",out_files,components); exit(10); } @@ -613,6 +615,8 @@ int initialize(int argc, char *argv[]) { } + /* msgfile seems to start being used here, let's initialize it here */ + if ( !msgfile ) msgfile = stdout; /* Open out file */ if ( outfilename == NULL ) { usage(); @@ -865,7 +869,7 @@ int initialize(int argc, char *argv[]) { int main (int argc, char *argv[]) { int n,n_c,n_r,my_i,n_s,mk,seek_return; int found_EOF = 0; - double t0, t1, get_utime(); + double t0, t1; /*, get_utime();*/ long pos0, pos1, tot_in = 0, tot_out = 0; @@ -875,7 +879,7 @@ int main (int argc, char *argv[]) { /* Parse the parameters, initialize */ /* Not yet fully implemented */ - bufiinit(); + bufiinit(NULL); pos0 = initialize(argc, argv); @@ -1474,7 +1478,7 @@ int main (int argc, char *argv[]) { -usage() +void usage() { fprintf(stderr,"Usage: %s [flags] [infile] [outfile1 [outfile2, ...]]\n\ DEFAULTS:\n\ @@ -1500,7 +1504,7 @@ outfile2, ... : Multiple output specification for plane or line int. mode.\n\ } -bad_flag(char *s) +void bad_flag(char *s) { fprintf(stderr,"Bad flag %s\n",s); usage(); diff --git a/src/gdcmjpegls/Decoder/global.c b/src/gdcmjpegls/Decoder/global.c index 62922b4f..55d1ddc7 100644 --- a/src/gdcmjpegls/Decoder/global.c +++ b/src/gdcmjpegls/Decoder/global.c @@ -51,6 +51,7 @@ */ #include +#include #include "global.h" @@ -69,7 +70,7 @@ without the written permission of the copyright holder.\n\ FILE *in, *out; FILE *c_in[MAX_COMPONENTS]; FILE *c_out[MAX_COMPONENTS]; -FILE *msgfile = stdout; +FILE *msgfile = NULL; // = stdout; /* Context quantization thresholds - initially unset */ int T3 = -1, @@ -141,13 +142,14 @@ void *safecalloc(size_t numels, size_t size) { double get_utime() { clock_t c; + (void)c; return (double)clock()/CLOCKS_PER_SEC; } /* Set thresholds to default unless specified by header: */ -set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p) +int set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p) { int lambda, ilambda = 256/alfa, @@ -155,6 +157,8 @@ set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p) T1 = *T1p, T2 = *T2p, T3 = *T3p; + /* Unused */ + (void)quant; if (alfa<4096) lambda = (alfa+127)/256; @@ -220,7 +224,7 @@ set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p) /* We first check compatibility with JPEG-LS, then with this implementation */ -void check_compatibility(jpeg_ls_header *head_frame, jpeg_ls_header *head_scan, int n_s) +void check_compatibility(jpeg_ls_header *head_frame, jpeg_ls_header *head_scan, int n_s) { int number_of_scans,i; @@ -322,7 +326,7 @@ char *ttyfilename = "CON"; #define PAUSE 20 -fprint_disclaimer(FILE *fp, int nopause) +void fprint_disclaimer(FILE *fp, int nopause) { char *p0, *p1; FILE *ttyf; diff --git a/src/gdcmjpegls/Decoder/global.h b/src/gdcmjpegls/Decoder/global.h index 8f80731f..9277ea54 100644 --- a/src/gdcmjpegls/Decoder/global.h +++ b/src/gdcmjpegls/Decoder/global.h @@ -95,7 +95,9 @@ extern char *plane_int_string, *pixel_int_string; +#ifndef BIG_ENDIAN #define BIG_ENDIAN 1 +#endif typedef struct jpeg_ls { @@ -334,6 +336,9 @@ extern int N[TOT_CONTEXTS], void error(char *msg); void *safealloc(size_t size); void *safecalloc(size_t numels, size_t size); +double get_utime(); +int set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p); +void check_compatibility(jpeg_ls_header *head_frame, jpeg_ls_header *head_scan, int n_s); /* scanline.c */ void prepareLUTs(); @@ -348,6 +353,8 @@ void bitiinit(); void bitflush(); void createzeroLUT(); void buffinit(FILE *); +void bufiinit(FILE *fil); +void bitiflush(); /* melcode.c */ void init_process_run(int); @@ -359,6 +366,15 @@ void prepareLUTs(); void prepare_qtables(int, int); void init_stats(int); +/* lossless_d.c */ +int lossless_undoscanline( pixel *psl, pixel *sl, int no, int color); +int lossless_undoscanline_pixel(pixel *psl, pixel *sl, int no); + +/* lossy_d.c */ +int lossy_undoscanline( pixel *psl, pixel *sl, int no, int color); +int lossy_undoscanline_pixel( pixel *psl, pixel *sl, int no); + + #ifdef BIG_ENDIAN # define ENDIAN8(x) (x) # define ENDIAN16(x) (x) diff --git a/src/gdcmjpegls/Decoder/initialize.c b/src/gdcmjpegls/Decoder/initialize.c index 6fe30cce..ad887540 100644 --- a/src/gdcmjpegls/Decoder/initialize.c +++ b/src/gdcmjpegls/Decoder/initialize.c @@ -77,7 +77,6 @@ int N[TOT_CONTEXTS], void prepareLUTs() { int i, j, idx, lmax; - byte k; lmax = min(alpha,lutmax); diff --git a/src/gdcmjpegls/Decoder/jpegmark.c b/src/gdcmjpegls/Decoder/jpegmark.c index 64dcc88b..c6c092bc 100644 --- a/src/gdcmjpegls/Decoder/jpegmark.c +++ b/src/gdcmjpegls/Decoder/jpegmark.c @@ -211,7 +211,7 @@ write_jpegls_scan(FILE *out, jpeg_ls_header *jp) int write_jpegls_extmarker(FILE *out, jpeg_ls_header *jp) { - int marker_len, ct=0; + int ct=0; ct += write_marker(out, LSE); /* write JPEG-LS extended marker id */ @@ -270,7 +270,7 @@ int read_marker(FILE *in, int *mkp) /* reads a marker from the next two bytes in the input stream */ { - unsigned int m, ct=0; + unsigned int m; m = read_n_bytes(in, 2); if ( feof(in) ) return EOF; @@ -434,7 +434,6 @@ int read_jpegls_extmarker(FILE *in, jpeg_ls_header *jp) { int marker_len, /* marker length */ maxval, /* max value */ - T1, T2, T3, /* thresholds */ ct = 0; int IDtype; /* LSE type */ int TID; /* table ID */ diff --git a/src/gdcmjpegls/Decoder/jpegmark.h b/src/gdcmjpegls/Decoder/jpegmark.h index 2b1a02be..fe48d2f1 100644 --- a/src/gdcmjpegls/Decoder/jpegmark.h +++ b/src/gdcmjpegls/Decoder/jpegmark.h @@ -94,3 +94,5 @@ int seek_marker(FILE *in, int *mkp); int read_jpegls_frame(FILE *in, jpeg_ls_header *jp); int read_jpegls_scan(FILE *in, jpeg_ls_header *jp); int read_jpegls_extmarker(FILE *in, jpeg_ls_header *jp); + +int read_jpegls_restartmarker(FILE *in, jpeg_ls_header *jp); diff --git a/src/gdcmjpegls/Decoder/lossless_d.c b/src/gdcmjpegls/Decoder/lossless_d.c index a99a73e9..3887127b 100644 --- a/src/gdcmjpegls/Decoder/lossless_d.c +++ b/src/gdcmjpegls/Decoder/lossless_d.c @@ -73,7 +73,7 @@ inline int lossless_regular_mode_d(int Q, int SIGN, int Px) At = A[Q]; { /* Estimate k */ - register nst = Nt; + register int nst = Nt; for(k=0; nst < At; nst *=2, k++); } @@ -542,7 +542,7 @@ int lossless_undoscanline_pixel(pixel *psl, /* previous scanline */ /*** watch it! actual pixels in the scan line are numbered 1 to no . pixels with indices < 1 or > no are dummy "border" pixels */ { - int i, psfix, n_c, color, enter_run=0, break_run, was_in_run = 0, + int i, psfix, n_c, color, enter_run=0, was_in_run = 0, test_run; pixel Ra, Rb, Rc, Rd; pixel c_aa[MAX_COMPONENTS], diff --git a/src/gdcmjpegls/Decoder/lossy_d.c b/src/gdcmjpegls/Decoder/lossy_d.c index 7046e3ee..11308014 100644 --- a/src/gdcmjpegls/Decoder/lossy_d.c +++ b/src/gdcmjpegls/Decoder/lossy_d.c @@ -72,7 +72,7 @@ inline int lossy_regular_mode_d(int Q, int SIGN, int Px) At = A[Q]; /* Estimate k */ { - register nst = Nt; + register int nst = Nt; for(k=0; nst < At; nst *=2, k++); } @@ -195,8 +195,7 @@ inline int lossy_regular_mode_d(int Q, int SIGN, int Px) /* Do end of run DECODING for LOSSY images */ inline pixel lossy_end_of_run_d(pixel Ra, pixel Rb, int RItype) { - int xpr, - Ix, + int Ix, Errval, absErrval, MErrval, @@ -518,7 +517,7 @@ int lossy_undoscanline_pixel( pixel *psl, /* previous scanline */ /*** watch it! actual pixels in the scan line are numbered 1 to no . pixels with indices < 1 or > no are dummy "border" pixels */ { - int i, psfix, n_c, color, enter_run=0, break_run, was_in_run = 0, + int i, psfix, n_c, color, enter_run=0, was_in_run = 0, test_run; pixel Ra, Rb, Rc, Rd; pixel c_aa[MAX_COMPONENTS], diff --git a/src/gdcmjpegls/Decoder/melcode.c b/src/gdcmjpegls/Decoder/melcode.c index 82e5cbc0..0c70528b 100644 --- a/src/gdcmjpegls/Decoder/melcode.c +++ b/src/gdcmjpegls/Decoder/melcode.c @@ -57,7 +57,7 @@ #define MELCSTATES 32 /* number of melcode states */ -static J[MELCSTATES] = { +static int J[MELCSTATES] = { 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,6,6,7, 7,8,9,10,11,12,13,14,15 }; @@ -78,6 +78,7 @@ void init_process_run(int maxrun) /* maxrun is ignoreed when using MELCODE, kept here for function compatibility */ { int n_c; + (void)maxrun; for (n_c=0;n_c> 24))]; /* number of leading ones in the input stream, up to 8 */ for ( hits = 1; hits<=temp; hits++ ) @@ -131,7 +132,7 @@ int process_run_dec(int lineleft, int color) /* read the length of the remainder */ if ( melclen[color] ) { - register temp; + register int temp; GETBITS(temp, melclen[color]); /*** GETBITS is a macro, not a function */ runlen += temp; } -- 2.46.1