summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-02-14 11:24:22 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-02-14 11:24:22 -0500
commitfe47fa92214284ff65e261415c8909dd185a9271 (patch)
tree75f656e5e8dffd4962da8a86997992d4d4df0f2b
parent5002369c4f75120593be1e97ba96013c30c1437f (diff)
downloadselphy_print-fe47fa92214284ff65e261415c8909dd185a9271.tar.gz
selphy_print-fe47fa92214284ff65e261415c8909dd185a9271.tar.bz2
selphy_print-fe47fa92214284ff65e261415c8909dd185a9271.zip
lib70x: Corrected errors in the 98xx gamma code.
* Figured out the in_r8 and in_r9 parameters (always set) * Fixed bad loop initializers in Gamma Table setup * Minor readability improvements
-rw-r--r--lib70x/libMitsuD70ImageReProcess.c60
1 files changed, 14 insertions, 46 deletions
diff --git a/lib70x/libMitsuD70ImageReProcess.c b/lib70x/libMitsuD70ImageReProcess.c
index 3fd4a74..d6fda63 100644
--- a/lib70x/libMitsuD70ImageReProcess.c
+++ b/lib70x/libMitsuD70ImageReProcess.c
@@ -1629,10 +1629,7 @@ static int CP98xx_DoCorrectGammaTbl(struct CP98xx_GammaParams *Gamma,
int end, start, cols, rows, step, bytesPerRow;
int i, j;
int64_t elements, max;
- int curCol, curRowBufOffset;
uint8_t *rowPtr;
- int in_r9 = 0; // XXX
-
if (KH->Step < 1 || KH->End < KH->Start)
return 1;
@@ -1648,19 +1645,9 @@ static int CP98xx_DoCorrectGammaTbl(struct CP98xx_GammaParams *Gamma,
bytesPerRow = img->bytes_per_row;
if (bytesPerRow < 0) {
- if (in_r9 == 0) {
- bytesPerRow = -bytesPerRow;
- rowPtr = img->imgbuf - -bytesPerRow * (rows - 1);
- } else {
- rowPtr = img->imgbuf;
- }
+ rowPtr = img->imgbuf;
} else {
- if (in_r9 != 0) {
- rowPtr = img->imgbuf - -bytesPerRow * (rows - 1);
- } else {
- bytesPerRow = -bytesPerRow;
- rowPtr = img->imgbuf;
- }
+ rowPtr = img->imgbuf + (bytesPerRow * (rows - 1));
}
step = KH->Step;
@@ -1677,8 +1664,8 @@ static int CP98xx_DoCorrectGammaTbl(struct CP98xx_GammaParams *Gamma,
sum6 = sum5 = sum4 = sum3 = sum2 = sum1 = 0;
for (k = 0 ; k < step ; k++) {
+ int curCol, curRowBufOffset;
curRowBufOffset = start * 3;
- curCol = start;
for (curCol = start ; curCol < (end + 1) ; curCol++) {
sum3 += rowPtr[curRowBufOffset];
sum2 += rowPtr[curRowBufOffset + 1];
@@ -1686,8 +1673,7 @@ static int CP98xx_DoCorrectGammaTbl(struct CP98xx_GammaParams *Gamma,
curRowBufOffset += 3;
}
curRowBufOffset = iVar4 * 3;
- curCol = iVar4;
- for (curCol = start ; curCol < (cols - start); curCol++) {
+ for (curCol = iVar4 ; curCol < (cols - start); curCol++) {
sum6 += rowPtr[curRowBufOffset];
sum5 += rowPtr[curRowBufOffset + 1];
sum4 += rowPtr[curRowBufOffset + 2];
@@ -1743,43 +1729,25 @@ static int CP98xx_DoGammaConv(struct CP98xx_GammaParams *Gamma,
struct BandImage *outImage,
int already_reversed)
{
- int cols, rows, inBytesPerRow, tmp, maxTank;
+ int cols, rows, inBytesPerRow, maxTank;
uint8_t *inRowPtr;
uint16_t *outRowPtr;
int pixelsPerRow;
- int in_r8 = 0; // XXXX figure this one out..
-
cols = inImage->cols - inImage->origin_cols;
rows = inImage->rows - inImage->origin_rows;
- tmp = inImage->bytes_per_row;
- if ((cols < 1) || (rows < 1) || (tmp == 0))
+ inBytesPerRow = inImage->bytes_per_row;
+ pixelsPerRow = outImage->bytes_per_row >> 1;
+
+ if ((cols < 1) || (rows < 1) || (inBytesPerRow == 0))
return 0;
- if (tmp < 0) {
- if (in_r8 == 0) {
- inBytesPerRow = -tmp;
- pixelsPerRow = -outImage->bytes_per_row >> 1;
- inRowPtr = ((rows + -1) * -tmp + inImage->imgbuf);
- outRowPtr = (pixelsPerRow * (rows * 2 + -2) + outImage->imgbuf);
- } else {
- inBytesPerRow = tmp;
- pixelsPerRow = outImage->bytes_per_row >> 1;
- inRowPtr = inImage->imgbuf;
- outRowPtr = outImage->imgbuf;
- }
+ if (inBytesPerRow < 0) {
+ inRowPtr = inImage->imgbuf;
+ outRowPtr = outImage->imgbuf;
} else {
- if (in_r8 != 0) {
- inBytesPerRow = tmp;
- pixelsPerRow = outImage->bytes_per_row >> 1;
- outRowPtr = (pixelsPerRow * (rows * 2 + -2) + outImage->imgbuf);
- inRowPtr = ((rows + -1) * inImage->bytes_per_row + inImage->imgbuf);
- } else {
- inBytesPerRow = -tmp;
- pixelsPerRow = (-outImage->bytes_per_row) >> 1;
- inRowPtr = inImage->imgbuf;
- outRowPtr = outImage->imgbuf;
- }
+ outRowPtr = (pixelsPerRow * (rows * 2 -2) + outImage->imgbuf);
+ inRowPtr = ((rows -1) * inBytesPerRow + inImage->imgbuf);
}
maxTank = cols * 255;