void bufiinit(FILE *fil) {
/* argument is ignored */
+ (void)fil;
fp = BUFSIZE;
truebufsize = 0;
foundeof = 0;
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
}
/* 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<<discard) ) {
- fprintf(stderr,"bitiflush: inconsistent bits=%d discard=%d reg=%08x treg=%08x\n",bits, discard, reg, treg);
- exit(10);
+ fprintf(stderr,"bitiflush: inconsistent bits=%d discard=%d reg=%08x treg=%08x\n",bits, discard, reg, treg);
+ exit(10);
}
if ( reg & (((1<<discard)-1)<<(BITBUFSIZE-discard)) )
- fprintf(stderr,"bitiflush: Warning: discarding nonzero bits; reg=%08x bits=%d discard=%d\n",reg,bits,discard);
+ fprintf(stderr,"bitiflush: Warning: discarding nonzero bits; reg=%08x bits=%d discard=%d\n",reg,bits,discard);
fp -= dbytes; /* do the unget */
if ( buff[fp-1]==0xff && buff[fp]==0 ) fp++;
int highmask;
#endif
+void usage();
}
-swaplines()
+void swaplines()
{
pixel *temp;
temp = pscanl0;
cscanline = cscanl0 + components*(LEFTMARGIN-1);
}
-c_swaplines(int i)
+void c_swaplines(int i)
{
pixel *temp;
temp = c_pscanl0[i];
int initialize(int argc, char *argv[]) {
- char line[256],tmp_char[1],
- *infilename = NULL,
+ char *infilename = NULL,
*outfilename = OUTFILE ".out",
*c_outfilename[MAX_COMPONENTS],
*color_mode_string;
}
if ((!multi) && (color_mode==PLANE_INT))
+ {
if (components>1) {
fprintf(stderr,"\nERROR: Cannot use -P (PPM output) with plane intereleaved mode\n");
exit(10);
+ }
}
else multi=1;
}
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);
}
}
+ /* msgfile seems to start being used here, let's initialize it here */
+ if ( !msgfile ) msgfile = stdout;
/* Open out file */
if ( outfilename == NULL ) {
usage();
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;
/* Parse the parameters, initialize */
/* Not yet fully implemented */
- bufiinit();
+ bufiinit(NULL);
pos0 = initialize(argc, argv);
-usage()
+void usage()
{
fprintf(stderr,"Usage: %s [flags] [infile] [outfile1 [outfile2, ...]]\n\
DEFAULTS:\n\
}
-bad_flag(char *s)
+void bad_flag(char *s)
{
fprintf(stderr,"Bad flag %s\n",s);
usage();
*/
#include <time.h>
+#include <unistd.h>
#include "global.h"
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,
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,
T1 = *T1p,
T2 = *T2p,
T3 = *T3p;
+ /* Unused */
+ (void)quant;
if (alfa<4096)
lambda = (alfa+127)/256;
/* 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;
#define PAUSE 20
-fprint_disclaimer(FILE *fp, int nopause)
+void fprint_disclaimer(FILE *fp, int nopause)
{
char *p0, *p1;
FILE *ttyf;
*pixel_int_string;
+#ifndef BIG_ENDIAN
#define BIG_ENDIAN 1
+#endif
typedef struct jpeg_ls {
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();
void bitflush();
void createzeroLUT();
void buffinit(FILE *);
+void bufiinit(FILE *fil);
+void bitiflush();
/* melcode.c */
void init_process_run(int);
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)
void prepareLUTs()
{
int i, j, idx, lmax;
- byte k;
lmax = min(alpha,lutmax);
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 */
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;
{
int marker_len, /* marker length */
maxval, /* max value */
- T1, T2, T3, /* thresholds */
ct = 0;
int IDtype; /* LSE type */
int TID; /* table ID */
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);
At = A[Q];
{
/* Estimate k */
- register nst = Nt;
+ register int nst = Nt;
for(k=0; nst < At; nst *=2, k++);
}
/*** 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],
At = A[Q];
/* Estimate k */
{
- register nst = Nt;
+ register int nst = Nt;
for(k=0; nst < At; nst *=2, k++);
}
/* 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,
/*** 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],
#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
};
kept here for function compatibility */
{
int n_c;
+ (void)maxrun;
for (n_c=0;n_c<components;n_c++)
{
int runlen = 0;
do {
- register temp, hits;
+ register int temp, hits;
temp = zeroLUT[(byte)(~(reg >> 24))]; /* number of leading ones in the
input stream, up to 8 */
for ( hits = 1; hits<=temp; hits++ )
/* 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;
}