Skip to content

Commit

Permalink
perf: minor performance improvement in grayscale mode to 24-bit output
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Jan 7, 2022
1 parent 4c6b3b6 commit 0694208
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/common/tmap16bit.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: tmap16bit.c,v 1.10 2011/05/20 02:06:38 greg Exp $";
static const char RCSid[] = "$Id: tmap16bit.c,v 1.11 2022/01/07 23:01:01 greg Exp $";
#endif
/*
* Routines for tone-mapping 16-bit/primary pixels
Expand Down Expand Up @@ -257,7 +257,9 @@ tmCvRGB48(TMstruct *tms, TMbright *ls, uby8 *cs,
cmon[BLU] = slum + pf*cmon[BLU];
}
} else if (tms->flags & TM_F_BW) {
cmon[RED] = cmon[GRN] = cmon[BLU] = lum;
int j = 3;
while (j--) cs[3*i+j] = tms->cdiv[j]/(TM_BRES>>8);
continue;
}
bi = (double)MONGAMTSZ*tms->clf[RED]*cmon[RED]/lum;
cs[3*i ] = bi>=MONGAMTSZ ? 255 : mongamtab[bi];
Expand Down
6 changes: 4 additions & 2 deletions src/common/tmapcolrs.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: tmapcolrs.c,v 3.35 2020/10/13 00:08:46 greg Exp $";
static const char RCSid[] = "$Id: tmapcolrs.c,v 3.36 2022/01/07 23:01:01 greg Exp $";
#endif
/*
* Routines for tone mapping on Radiance RGBE and XYZE pictures.
Expand Down Expand Up @@ -122,7 +122,9 @@ int len
}
}
} else if (tms->flags & TM_F_BW) {
cmon[RED] = cmon[GRN] = cmon[BLU] = li;
for (j = 3; j--; )
cs[3*i+j] = tms->cdiv[j]/(TM_BRES>>8);
continue;
} else {
for (j = 3; j--; )
cmon[j] *= (cmon[j] > 0);
Expand Down
6 changes: 4 additions & 2 deletions src/common/tonemap.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: tonemap.c,v 3.52 2021/05/26 17:50:26 greg Exp $";
static const char RCSid[] = "$Id: tonemap.c,v 3.53 2022/01/07 23:01:01 greg Exp $";
#endif
/*
* Tone mapping functions.
Expand Down Expand Up @@ -321,7 +321,9 @@ int len
cmon[BLU] += d;
}
} else if (tms->flags & TM_F_BW) {
cmon[RED] = cmon[GRN] = cmon[BLU] = lum;
int j = 3;
while (j--) cs[3*i+j] = tms->cdiv[j]/(TM_BRES>>8);
continue;
}
d = tms->clf[RED]*cmon[RED]/lum;
cs[3*i ] = d>=.999f ? 255 : gamtab[(int)(1024.f*d)];
Expand Down

0 comments on commit 0694208

Please sign in to comment.