aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/jpg
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-04-01 19:24:03 +0000
committerrsc <devnull@localhost>2006-04-01 19:24:03 +0000
commitcbeb0b26e4c7caa8d1b47de791a7418dc20a4567 (patch)
treee0f7e445de1aa22a42ef873dc4b1118a8105ae93 /src/cmd/jpg
parent226d80b8213821af0cbf092d1507c52b504fd368 (diff)
downloadplan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.gz
plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.bz2
plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.zip
Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.
Diffstat (limited to 'src/cmd/jpg')
-rw-r--r--src/cmd/jpg/close.c34
-rw-r--r--src/cmd/jpg/ico.c6
-rw-r--r--src/cmd/jpg/imagefile.h2
-rw-r--r--src/cmd/jpg/jpegdump.c10
-rw-r--r--src/cmd/jpg/readjpg.c2
-rw-r--r--src/cmd/jpg/readpng.c26
-rw-r--r--src/cmd/jpg/readppm.c2
-rw-r--r--src/cmd/jpg/readyuv.c12
-rw-r--r--src/cmd/jpg/rgbycc.c20
-rw-r--r--src/cmd/jpg/toico.c2
-rw-r--r--src/cmd/jpg/totruecolor.c2
-rw-r--r--src/cmd/jpg/writegif.c2
-rw-r--r--src/cmd/jpg/writepng.c38
13 files changed, 79 insertions, 79 deletions
diff --git a/src/cmd/jpg/close.c b/src/cmd/jpg/close.c
index 7a260c10..2b833519 100644
--- a/src/cmd/jpg/close.c
+++ b/src/cmd/jpg/close.c
@@ -22,7 +22,7 @@ closest(int Y, int Cb, int Cr)
g = Y-c2*Cb-c3*Cr;
b = Y+c4*Cb;
-//print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b);
+/*print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b); */
min = 1000000.;
v = 1000;
@@ -32,23 +32,23 @@ closest(int Y, int Cb, int Cr)
G = (rgb >> 8) & 0xFF;
B = (rgb >> 0) & 0xFF;
diff = (R-r)*(R-r) + (G-g)*(G-g) + (B-b)*(B-b);
-// y1 = 0.5870*G + 0.114*B + 0.299*R;
-// cb1 = (B-y1)/1.772;
-// cr1 = (R-y1)/1.402;
+/* y1 = 0.5870*G + 0.114*B + 0.299*R; */
+/* cb1 = (B-y1)/1.772; */
+/* cr1 = (R-y1)/1.402; */
if(diff < min){
-// if(Y==0 && y1!=0)
-// continue;
-// if(Y==256-16 && y1<256-16)
-// continue;
-// if(Cb==0 && cb1!=0)
-// continue;
-// if(Cb==256-16 && cb1<256-16)
-// continue;
-// if(Cr==0 && cr1!=0)
-// continue;
-// if(Cr==256-16 && cr1<256-16)
-// continue;
-//print("%d %d %d\n", R, G, B);
+/* if(Y==0 && y1!=0) */
+/* continue; */
+/* if(Y==256-16 && y1<256-16) */
+/* continue; */
+/* if(Cb==0 && cb1!=0) */
+/* continue; */
+/* if(Cb==256-16 && cb1<256-16) */
+/* continue; */
+/* if(Cr==0 && cr1!=0) */
+/* continue; */
+/* if(Cr==256-16 && cr1<256-16) */
+/* continue; */
+/*print("%d %d %d\n", R, G, B); */
min = diff;
v = i;
}
diff --git a/src/cmd/jpg/ico.c b/src/cmd/jpg/ico.c
index aad715fe..bc7bee05 100644
--- a/src/cmd/jpg/ico.c
+++ b/src/cmd/jpg/ico.c
@@ -269,14 +269,14 @@ enum
Mexit,
Up= 1,
- Down= 0,
+ Down= 0
};
char *menu3str[] = {
"write image",
"write mask",
"exit",
- 0,
+ 0
};
Menu menu3 = {
@@ -409,7 +409,7 @@ mousemoved(void)
enum
{
- BORDER= 1,
+ BORDER= 1
};
void
diff --git a/src/cmd/jpg/imagefile.h b/src/cmd/jpg/imagefile.h
index 592c5a2e..5f5a4873 100644
--- a/src/cmd/jpg/imagefile.h
+++ b/src/cmd/jpg/imagefile.h
@@ -39,7 +39,7 @@ enum
enum{ /* PNG flags */
II_GAMMA = 1 << 0,
- II_COMMENT = 1 << 1,
+ II_COMMENT = 1 << 1
};
typedef struct ImageInfo {
diff --git a/src/cmd/jpg/jpegdump.c b/src/cmd/jpg/jpegdump.c
index 0b132cb7..ee94d07f 100644
--- a/src/cmd/jpg/jpegdump.c
+++ b/src/cmd/jpg/jpegdump.c
@@ -113,7 +113,7 @@ char *sofName[16] = {
"c is otherwise used",
"Sequential DCT - differential arithmetic coding",
"Progressive DCT - differential arithmetic coding",
- "Lossless - differential arithmetic coding",
+ "Lossless - differential arithmetic coding"
};
void get_sof (int kind) {
@@ -272,10 +272,10 @@ main (int argc, char *argv[]) {
if (infile == NULL)
quit ("can't open %s\n", fname);
Start:
-// if (get1() != 0xff || get1() != 0xd8)
-// quit ("not JFIF");
-// printf ("SOI\n");
-// get_app (0xe0);
+/* if (get1() != 0xff || get1() != 0xd8) */
+/* quit ("not JFIF"); */
+/* printf ("SOI\n"); */
+/* get_app (0xe0); */
for (;;) {
c = get1();
if (c != 0xff)
diff --git a/src/cmd/jpg/readjpg.c b/src/cmd/jpg/readjpg.c
index b154e75b..f3ad802e 100644
--- a/src/cmd/jpg/readjpg.c
+++ b/src/cmd/jpg/readjpg.c
@@ -1192,7 +1192,7 @@ enum {
c1 = 2871, /* 1.402 * 2048 */
c2 = 705, /* 0.34414 * 2048 */
c3 = 1463, /* 0.71414 * 2048 */
- c4 = 3629, /* 1.772 * 2048 */
+ c4 = 3629 /* 1.772 * 2048 */
};
static
diff --git a/src/cmd/jpg/readpng.c b/src/cmd/jpg/readpng.c
index f6e8e9d1..2985c5ff 100644
--- a/src/cmd/jpg/readpng.c
+++ b/src/cmd/jpg/readpng.c
@@ -16,31 +16,31 @@ enum{ IDATSIZE=1000000,
FilterAvg = 3, /* new[x][y] = buf[x][y] + (new[x-1][y]+new[x][y-1])/2 */
FilterPaeth= 4, /* new[x][y] = buf[x][y] + paeth(new[x-1][y],new[x][y-1],new[x-1][y-1]) */
FilterLast = 5,
- PropertyBit = 1<<5,
+ PropertyBit = 1<<5
};
typedef struct ZlibW{
- uchar *chan[4]; // Rawimage channels
- uchar *scan; // new scanline
- uchar *pscan; // previous scanline
- int scanl; // scan len
- int scanp; // scan pos
- int nchan; // number of input chans
- int npix; // pixels read so far
- int chanl; // number of bytes allocated to chan[x]
+ uchar *chan[4]; /* Rawimage channels */
+ uchar *scan; /* new scanline */
+ uchar *pscan; /* previous scanline */
+ int scanl; /* scan len */
+ int scanp; /* scan pos */
+ int nchan; /* number of input chans */
+ int npix; /* pixels read so far */
+ int chanl; /* number of bytes allocated to chan[x] */
int scanpix;
- int bpp; // bits per sample
+ int bpp; /* bits per sample */
int palsize;
- int row; // current scanline number
+ int row; /* current scanline number */
uchar palette[3*256];
} ZlibW;
typedef struct ZlibR{
Biobuf *bi;
uchar *buf;
- uchar *b; // next byte to decompress
- uchar *e; // past end of buf
+ uchar *b; /* next byte to decompress */
+ uchar *e; /* past end of buf */
ZlibW *w;
} ZlibR;
diff --git a/src/cmd/jpg/readppm.c b/src/cmd/jpg/readppm.c
index 569025fd..073f4436 100644
--- a/src/cmd/jpg/readppm.c
+++ b/src/cmd/jpg/readppm.c
@@ -155,7 +155,7 @@ static Pix pix[] = {
{ '5', 0, Bgetc, 1, CY, 0, 0 }, /* raw portable greymap */
{ '3', 0, Bgetint, 3, CRGB, 0, 0 }, /* portable pixmap */
{ '6', 0, Bgetc, 3, CRGB, 0, 0 }, /* raw portable pixmap */
- { 0 },
+ { 0 }
};
Rawimage*
diff --git a/src/cmd/jpg/readyuv.c b/src/cmd/jpg/readyuv.c
index eae2764e..f90bc237 100644
--- a/src/cmd/jpg/readyuv.c
+++ b/src/cmd/jpg/readyuv.c
@@ -76,19 +76,19 @@ Breadyuv(Biobuf *bp, int colourspace)
}
switch (sz) {
- case 720 * PAL * 2: // 625 x 8bit
+ case 720 * PAL * 2: /* 625 x 8bit */
bits = 8;
lines = PAL;
break;
- case 720 * NTSC * 2: // 525 x 8bit
+ case 720 * NTSC * 2: /* 525 x 8bit */
bits = 8;
lines = NTSC;
break;
- case 720 * PAL * 2 + (720 * PAL / 2) : // 625 x 10bit
+ case 720 * PAL * 2 + (720 * PAL / 2) : /* 625 x 10bit */
bits = 10;
lines = PAL;
break;
- case 720 * NTSC * 2 + (720 * NTSC / 2) : // 525 x 10bit
+ case 720 * NTSC * 2 + (720 * NTSC / 2) : /* 525 x 10bit */
bits = 10;
lines = NTSC;
break;
@@ -97,8 +97,8 @@ Breadyuv(Biobuf *bp, int colourspace)
goto Error;
}
- // print("bits=%d pixels=%d lines=%d\n", bits, 720, lines);
- //
+ /* print("bits=%d pixels=%d lines=%d\n", bits, 720, lines); */
+ /* */
a->nchans = 3;
a->chandesc = CRGB;
a->chanlen = 720 * lines;
diff --git a/src/cmd/jpg/rgbycc.c b/src/cmd/jpg/rgbycc.c
index 3654a2d2..d20cc789 100644
--- a/src/cmd/jpg/rgbycc.c
+++ b/src/cmd/jpg/rgbycc.c
@@ -21,7 +21,7 @@ closest(int Y, int Cb, int Cr)
g = Y-c2*Cb-c3*Cr;
b = Y+c4*Cb;
-//print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b);
+/*print("YCbCr: %d %d %d, RGB: %g %g %g\n", Y, Cb, Cr, r, g, b); */
min = 1000000.;
v = 1000;
@@ -35,19 +35,19 @@ closest(int Y, int Cb, int Cr)
cb1 = (B-y1)/1.772;
cr1 = (R-y1)/1.402;
if(diff < min){
-// if(Y==0 && y1!=0)
-// continue;
+/* if(Y==0 && y1!=0) */
+/* continue; */
if(Y==256-16 && y1<256-16)
continue;
-// if(Cb==0 && cb1!=0)
-// continue;
+/* if(Cb==0 && cb1!=0) */
+/* continue; */
if(Cb==256-16 && cb1<256-16)
continue;
-// if(Cr==0 && cr1!=0)
-// continue;
+/* if(Cr==0 && cr1!=0) */
+/* continue; */
if(Cr==256-16 && cr1<256-16)
continue;
-//print("%d %d %d\n", R, G, B);
+/*print("%d %d %d\n", R, G, B); */
min = diff;
v = i;
}
@@ -66,8 +66,8 @@ main(int argc, char *argv[])
int y, cb, cr;
uchar close[16*16*16];
-//print("%d\n", closest(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])));
-//exits("X");
+/*print("%d\n", closest(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]))); */
+/*exits("X"); */
/* ycbcrmap */
print("uint ycbcrmap[256] = {\n");
diff --git a/src/cmd/jpg/toico.c b/src/cmd/jpg/toico.c
index 536b64ff..51332623 100644
--- a/src/cmd/jpg/toico.c
+++ b/src/cmd/jpg/toico.c
@@ -7,7 +7,7 @@ enum
{
FileHdrLen= 6,
IconDescrLen= 16,
- IconHdrLen= 40,
+ IconHdrLen= 40
};
typedef struct Icon Icon;
diff --git a/src/cmd/jpg/totruecolor.c b/src/cmd/jpg/totruecolor.c
index 0da5d9a3..d30a6843 100644
--- a/src/cmd/jpg/totruecolor.c
+++ b/src/cmd/jpg/totruecolor.c
@@ -8,7 +8,7 @@ enum {
c1 = 2871, /* 1.402 * 2048 */
c2 = 705, /* 0.34414 * 2048 */
c3 = 1463, /* 0.71414 * 2048 */
- c4 = 3629, /* 1.772 * 2048 */
+ c4 = 3629 /* 1.772 * 2048 */
};
Rawimage*
diff --git a/src/cmd/jpg/writegif.c b/src/cmd/jpg/writegif.c
index 4bb018b3..08fc4801 100644
--- a/src/cmd/jpg/writegif.c
+++ b/src/cmd/jpg/writegif.c
@@ -8,7 +8,7 @@
enum
{
Nhash = 4001,
- Nbuf = 300,
+ Nbuf = 300
};
typedef struct Entry Entry;
diff --git a/src/cmd/jpg/writepng.c b/src/cmd/jpg/writepng.c
index e280a9cc..3b63bb7f 100644
--- a/src/cmd/jpg/writepng.c
+++ b/src/cmd/jpg/writepng.c
@@ -1,7 +1,7 @@
-// based on PNG 1.2 specification, July 1999 (see also rfc2083)
-// Alpha is not supported yet because of lack of industry acceptance and
-// because Plan9 Image uses premultiplied alpha, so png can't be lossless.
-// Only 24bit color supported, because 8bit may as well use GIF.
+/* based on PNG 1.2 specification, July 1999 (see also rfc2083) */
+/* Alpha is not supported yet because of lack of industry acceptance and */
+/* because Plan9 Image uses premultiplied alpha, so png can't be lossless. */
+/* Only 24bit color supported, because 8bit may as well use GIF. */
#include <u.h>
#include <libc.h>
@@ -13,22 +13,22 @@
#include "imagefile.h"
enum{ IDATSIZE = 20000,
- FilterNone = 0,
+ FilterNone = 0
};
typedef struct ZlibR{
uchar *data;
int width;
int nrow, ncol;
- int row, col; // next pixel to send
+ int row, col; /* next pixel to send */
int pixwid;
} ZlibR;
typedef struct ZlibW{
Biobuf *bo;
uchar *buf;
- uchar *b; // next place to write
- uchar *e; // past end of buf
+ uchar *b; /* next place to write */
+ uchar *e; /* past end of buf */
} ZlibW;
static ulong *crctab;
@@ -68,11 +68,11 @@ zread(void *va, void *buf, int n)
int nrow = z->nrow;
int ncol = z->ncol;
uchar *b = buf, *e = b+n, *img;
- int pixels; // number of pixels in row that can be sent now
+ int pixels; /* number of pixels in row that can be sent now */
int i, a, pixwid;
pixwid = z->pixwid;
- while(b+pixwid <= e){ // loop over image rows
+ while(b+pixwid <= e){ /* loop over image rows */
if(z->row >= nrow)
break;
if(z->col==0)
@@ -129,7 +129,7 @@ zwrite(void *va, void *buf, int n)
uchar *b = buf, *e = b+n;
int m;
- while(b < e){ // loop over IDAT chunks
+ while(b < e){ /* loop over IDAT chunks */
m = z->e - z->b;
if(m > e - b)
m = e - b;
@@ -190,15 +190,15 @@ memwritepng(Biobuf *bo, Memimage *r, ImageInfo *II)
deflateinit();
Bwrite(bo, PNGmagic, sizeof PNGmagic);
- // IHDR chunk
+ /* IHDR chunk */
h = buf;
put4(h, ncol); h += 4;
put4(h, nrow); h += 4;
- *h++ = 8; // bit depth = 24 bit per pixel
- *h++ = rgb->chan==BGR24 ? 2 : 6; // color type = rgb
- *h++ = 0; // compression method = deflate
- *h++ = 0; // filter method
- *h++ = 0; // interlace method = no interlace
+ *h++ = 8; /* bit depth = 24 bit per pixel */
+ *h++ = rgb->chan==BGR24 ? 2 : 6; /* color type = rgb */
+ *h++ = 0; /* compression method = deflate */
+ *h++ = 0; /* filter method */
+ *h++ = 0; /* interlace method = no interlace */
chunk(bo, "IHDR", buf, h-buf);
tm = gmtime(time(0));
@@ -220,12 +220,12 @@ memwritepng(Biobuf *bo, Memimage *r, ImageInfo *II)
if(II->fields_set & II_COMMENT){
strncpy((char*)buf, "Comment", sizeof buf);
- n = strlen((char*)buf)+1; // leave null between Comment and text
+ n = strlen((char*)buf)+1; /* leave null between Comment and text */
strncpy((char*)(buf+n), II->comment, sizeof buf - n);
chunk(bo, "tEXt", buf, n+strlen((char*)buf+n));
}
- // image chunks
+ /* image chunks */
zr.nrow = nrow;
zr.ncol = ncol;
zr.width = rgb->width * sizeof(ulong);