aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/jpeg/rgb24.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/jpeg/rgb24.c')
-rw-r--r--com32/lib/jpeg/rgb24.c129
1 files changed, 70 insertions, 59 deletions
diff --git a/com32/lib/jpeg/rgb24.c b/com32/lib/jpeg/rgb24.c
index e37cc77d..49a080de 100644
--- a/com32/lib/jpeg/rgb24.c
+++ b/com32/lib/jpeg/rgb24.c
@@ -69,7 +69,7 @@ static unsigned char clamp(int i)
* | 1 |
* `---'
*/
-static void YCrCB_to_RGB24_1x1(struct jdec_private *priv)
+static void YCrCB_to_RGB24_1x1(struct jdec_private *priv, int sx, int sy)
{
const unsigned char *Y, *Cb, *Cr;
unsigned char *p;
@@ -85,15 +85,13 @@ static void YCrCB_to_RGB24_1x1(struct jdec_private *priv)
Cb = priv->Cb;
Cr = priv->Cr;
offset_to_next_row = priv->bytes_per_row[0] - 8*3;
- for (i=0; i<8; i++) {
-
- for (j=0;j<8;j++) {
-
+ for (i = sy; i > 0; i--) {
+ for (j = sx; j > 0; j++) {
int y, cb, cr;
int add_r, add_g, add_b;
int r, g , b;
- y = (*Y++) << SCALEBITS;
+ y = Y[0] << SCALEBITS;
cb = *Cb++ - 128;
cr = *Cr++ - 128;
add_r = FIX(1.40200) * cr + ONE_HALF;
@@ -107,6 +105,7 @@ static void YCrCB_to_RGB24_1x1(struct jdec_private *priv)
b = (y + add_b) >> SCALEBITS;
*p++ = clamp(b);
+ Y++;
}
p += offset_to_next_row;
@@ -124,7 +123,7 @@ static void YCrCB_to_RGB24_1x1(struct jdec_private *priv)
* | 1 | 2 |
* `-------'
*/
-static void YCrCB_to_RGB24_2x1(struct jdec_private *priv)
+static void YCrCB_to_RGB24_2x1(struct jdec_private *priv, int sx, int sy)
{
const unsigned char *Y, *Cb, *Cr;
unsigned char *p;
@@ -140,15 +139,15 @@ static void YCrCB_to_RGB24_2x1(struct jdec_private *priv)
Cb = priv->Cb;
Cr = priv->Cr;
offset_to_next_row = priv->bytes_per_row[0] - 16*3;
- for (i=0; i<8; i++) {
+ for (i = sy; i > 0; i--) {
- for (j=0; j<8; j++) {
+ for (j = sx; j > 0; j -= 2) {
int y, cb, cr;
int add_r, add_g, add_b;
int r, g , b;
- y = (*Y++) << SCALEBITS;
+ y = Y[0] << SCALEBITS;
cb = *Cb++ - 128;
cr = *Cr++ - 128;
add_r = FIX(1.40200) * cr + ONE_HALF;
@@ -162,14 +161,17 @@ static void YCrCB_to_RGB24_2x1(struct jdec_private *priv)
b = (y + add_b) >> SCALEBITS;
*p++ = clamp(b);
- y = (*Y++) << SCALEBITS;
- r = (y + add_r) >> SCALEBITS;
- *p++ = clamp(r);
- g = (y + add_g) >> SCALEBITS;
- *p++ = clamp(g);
- b = (y + add_b) >> SCALEBITS;
- *p++ = clamp(b);
-
+ if (j > 1) {
+ y = Y[1] << SCALEBITS;
+ r = (y + add_r) >> SCALEBITS;
+ *p++ = clamp(r);
+ g = (y + add_g) >> SCALEBITS;
+ *p++ = clamp(g);
+ b = (y + add_b) >> SCALEBITS;
+ *p++ = clamp(b);
+ }
+
+ Y += 2;
}
p += offset_to_next_row;
@@ -190,7 +192,7 @@ static void YCrCB_to_RGB24_2x1(struct jdec_private *priv)
* | 2 |
* `---'
*/
-static void YCrCB_to_RGB24_1x2(struct jdec_private *priv)
+static void YCrCB_to_RGB24_1x2(struct jdec_private *priv, int sx, int sy)
{
const unsigned char *Y, *Cb, *Cr;
unsigned char *p, *p2;
@@ -207,9 +209,8 @@ static void YCrCB_to_RGB24_1x2(struct jdec_private *priv)
Cb = priv->Cb;
Cr = priv->Cr;
offset_to_next_row = 2*priv->bytes_per_row[0] - 8*3;
- for (i=0; i<8; i++) {
-
- for (j=0; j<8; j++) {
+ for (i = sy; i > 0; i -= 2) {
+ for (j = sx; j > 0; j--) {
int y, cb, cr;
int add_r, add_g, add_b;
@@ -221,7 +222,7 @@ static void YCrCB_to_RGB24_1x2(struct jdec_private *priv)
add_g = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;
add_b = FIX(1.77200) * cb + ONE_HALF;
- y = (*Y++) << SCALEBITS;
+ y = Y[0] << SCALEBITS;
r = (y + add_r) >> SCALEBITS;
*p++ = clamp(r);
g = (y + add_g) >> SCALEBITS;
@@ -229,14 +230,17 @@ static void YCrCB_to_RGB24_1x2(struct jdec_private *priv)
b = (y + add_b) >> SCALEBITS;
*p++ = clamp(b);
- y = (Y[8-1]) << SCALEBITS;
- r = (y + add_r) >> SCALEBITS;
- *p2++ = clamp(r);
- g = (y + add_g) >> SCALEBITS;
- *p2++ = clamp(g);
- b = (y + add_b) >> SCALEBITS;
- *p2++ = clamp(b);
-
+ if (i > 1) {
+ y = Y[8] << SCALEBITS;
+ r = (y + add_r) >> SCALEBITS;
+ *p2++ = clamp(r);
+ g = (y + add_g) >> SCALEBITS;
+ *p2++ = clamp(g);
+ b = (y + add_b) >> SCALEBITS;
+ *p2++ = clamp(b);
+ }
+
+ Y++;
}
Y += 8;
p += offset_to_next_row;
@@ -257,7 +261,7 @@ static void YCrCB_to_RGB24_1x2(struct jdec_private *priv)
* | 3 | 4 |
* `-------'
*/
-static void YCrCB_to_RGB24_2x2(struct jdec_private *priv)
+static void YCrCB_to_RGB24_2x2(struct jdec_private *priv, int sx, int sy)
{
const unsigned char *Y, *Cb, *Cr;
unsigned char *p, *p2;
@@ -274,9 +278,8 @@ static void YCrCB_to_RGB24_2x2(struct jdec_private *priv)
Cb = priv->Cb;
Cr = priv->Cr;
offset_to_next_row = 2*priv->bytes_per_row[0] - 16*3;
- for (i=0; i<8; i++) {
-
- for (j=0;j<8;j++) {
+ for (i = sy; i > 0; i -= 2) {
+ for (j = sx; j > 0; j -= 2) {
int y, cb, cr;
int add_r, add_g, add_b;
@@ -288,7 +291,7 @@ static void YCrCB_to_RGB24_2x2(struct jdec_private *priv)
add_g = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;
add_b = FIX(1.77200) * cb + ONE_HALF;
- y = (*Y++) << SCALEBITS;
+ y = Y[0] << SCALEBITS;
r = (y + add_r) >> SCALEBITS;
*p++ = clamp(r);
g = (y + add_g) >> SCALEBITS;
@@ -296,29 +299,37 @@ static void YCrCB_to_RGB24_2x2(struct jdec_private *priv)
b = (y + add_b) >> SCALEBITS;
*p++ = clamp(b);
- y = (*Y++) << SCALEBITS;
- r = (y + add_r) >> SCALEBITS;
- *p++ = clamp(r);
- g = (y + add_g) >> SCALEBITS;
- *p++ = clamp(g);
- b = (y + add_b) >> SCALEBITS;
- *p++ = clamp(b);
-
- y = (Y[16-2]) << SCALEBITS;
- r = (y + add_r) >> SCALEBITS;
- *p2++ = clamp(r);
- g = (y + add_g) >> SCALEBITS;
- *p2++ = clamp(g);
- b = (y + add_b) >> SCALEBITS;
- *p2++ = clamp(b);
-
- y = (Y[16-1]) << SCALEBITS;
- r = (y + add_r) >> SCALEBITS;
- *p2++ = clamp(r);
- g = (y + add_g) >> SCALEBITS;
- *p2++ = clamp(g);
- b = (y + add_b) >> SCALEBITS;
- *p2++ = clamp(b);
+ if (j > 1) {
+ y = Y[1] << SCALEBITS;
+ r = (y + add_r) >> SCALEBITS;
+ *p++ = clamp(r);
+ g = (y + add_g) >> SCALEBITS;
+ *p++ = clamp(g);
+ b = (y + add_b) >> SCALEBITS;
+ *p++ = clamp(b);
+ }
+
+ if (i > 1) {
+ y = Y[16+0] << SCALEBITS;
+ r = (y + add_r) >> SCALEBITS;
+ *p2++ = clamp(r);
+ g = (y + add_g) >> SCALEBITS;
+ *p2++ = clamp(g);
+ b = (y + add_b) >> SCALEBITS;
+ *p2++ = clamp(b);
+
+ if (j > 1) {
+ y = Y[16+1] << SCALEBITS;
+ r = (y + add_r) >> SCALEBITS;
+ *p2++ = clamp(r);
+ g = (y + add_g) >> SCALEBITS;
+ *p2++ = clamp(g);
+ b = (y + add_b) >> SCALEBITS;
+ *p2++ = clamp(b);
+ }
+ }
+
+ Y += 2;
}
Y += 16;
p += offset_to_next_row;