diff --git a/sys/src/cmd/jpg/readjpg.c b/sys/src/cmd/jpg/readjpg.c index 676ce2afb..c6df3ecea 100644 --- a/sys/src/cmd/jpg/readjpg.c +++ b/sys/src/cmd/jpg/readjpg.c @@ -632,7 +632,7 @@ baselinescan(Header *h, int colorspace) ss = h->ss; Ns = ss[0]; if((Ns!=3 && Ns!=1) || Ns!=h->Nf) - jpgerror(h, "ReadJPG: can't handle scan not 3 components"); + jpgerror(h, "ReadJPG: can't handle scan not 1 or 3 components"); image = jpgmalloc(h, sizeof(Rawimage), 1); h->image = image; @@ -843,7 +843,7 @@ progressiveinit(Header *h, int colorspace) ss = h->ss; Ns = ss[0]; Nf = h->Nf; - if((Ns!=3 && Ns!=1) || Ns!=Nf) + if(Ns!=3 && Ns!=1) jpgerror(h, "ReadJPG: image must have 1 or 3 components"); image = jpgmalloc(h, sizeof(Rawimage), 1); @@ -897,25 +897,26 @@ progressivedc(Header *h, int comp, int Ah, int Al) int block, t, diff, qt, *dc, bn; Huffman *dcht; uchar *ss; - int Td[3], DC[3], blockno[3]; + int i, Td[3], DC[3], blockno[3]; ss= h->ss; Ns = ss[0]; - if(Ns!=h->Nf) - jpgerror(h, "ReadJPG: can't handle progressive with Nf!=Ns in DC scan"); + if(Ns!=1 && Ns!=h->Nf) + jpgerror(h, "ReadJPG: can't handle progressive with Ns!=1 and Nf!=Ns in DC scan"); /* initialize data structures */ h->cnt = 0; h->sr = 0; h->peek = -1; - for(comp=0; compri; @@ -923,31 +924,33 @@ progressivedc(Header *h, int comp, int Ah, int Al) nmcu = h->nacross*h->ndown; memset(blockno, 0, sizeof blockno); for(mcu=0; mcudcht[Td[comp]]; + for(i=0; idcht[Td[i]]; qt = h->qt[h->comp[comp].Tq][0]; dc = h->dccoeff[comp]; - bn = blockno[comp]; + bn = blockno[i]; for(block=0; blocknblock[comp]; block++){ if(Ah == 0){ t = decode(h, dcht); diff = receive(h, t); - DC[comp] += diff; - dc[bn] = qt*DC[comp]<0 && mcu