diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-08-05 11:55:26 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-08-05 11:55:26 -0700 |
commit | d97602903c76f7f65b78d8536e8b6732a2da877e (patch) | |
tree | 53850c654aa78375501c1efce2b0002e8714df2b /com32 | |
parent | 288ce63dee16f80dac282c020b3ed7f4470e9265 (diff) | |
download | syslinux.git-d97602903c76f7f65b78d8536e8b6732a2da877e.tar.gz syslinux.git-d97602903c76f7f65b78d8536e8b6732a2da877e.tar.xz syslinux.git-d97602903c76f7f65b78d8536e8b6732a2da877e.zip |
tinyjpeg: modify to handle partial image blocks
A lot of common resolutions, e.g. 800x600, include partial blocks at
the side of the image. Implement that properly.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32')
-rw-r--r-- | com32/lib/Makefile | 3 | ||||
-rw-r--r-- | com32/lib/jpeg/bgr24.c | 129 | ||||
-rw-r--r-- | com32/lib/jpeg/bgra32.c | 152 | ||||
-rw-r--r-- | com32/lib/jpeg/grey.c | 83 | ||||
-rw-r--r-- | com32/lib/jpeg/rgb24.c | 129 | ||||
-rw-r--r-- | com32/lib/jpeg/rgba32.c | 149 | ||||
-rw-r--r-- | com32/lib/jpeg/tinyjpeg-internal.h | 12 | ||||
-rw-r--r-- | com32/lib/jpeg/tinyjpeg.c | 64 | ||||
-rw-r--r-- | com32/lib/jpeg/yuv420p.c | 10 |
9 files changed, 374 insertions, 357 deletions
diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 5e0e15ae..1fb30cd7 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -74,7 +74,8 @@ LIBOBJS = \ libpng/pngerror.o libpng/pngpread.o \ \ jpeg/tinyjpeg.o jpeg/jidctflt.o jpeg/decode1.o jpeg/decode3.o \ - jpeg/rgb24.o jpeg/bgr24.o jpeg/yuv420p.o jpeg/grey.o \ + jpeg/grey.o \ + jpeg/rgb24.o jpeg/bgr24.o \ jpeg/rgba32.o jpeg/bgra32.o \ \ sys/x86_init_fpu.o math/pow.o math/strtod.o \ diff --git a/com32/lib/jpeg/bgr24.c b/com32/lib/jpeg/bgr24.c index ffdcbdf9..d72e29b2 100644 --- a/com32/lib/jpeg/bgr24.c +++ b/com32/lib/jpeg/bgr24.c @@ -69,7 +69,7 @@ static unsigned char clamp(int i) * | 1 | * `---' */ -static void YCrCB_to_BGR24_1x1(struct jdec_private *priv) +static void YCrCB_to_BGR24_1x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p; @@ -85,15 +85,14 @@ static void YCrCB_to_BGR24_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 +106,7 @@ static void YCrCB_to_BGR24_1x1(struct jdec_private *priv) r = (y + add_r) >> SCALEBITS; *p++ = clamp(r); + Y++; } p += offset_to_next_row; @@ -125,7 +125,7 @@ static void YCrCB_to_BGR24_1x1(struct jdec_private *priv) * | 1 | 2 | * `-------' */ -static void YCrCB_to_BGR24_2x1(struct jdec_private *priv) +static void YCrCB_to_BGR24_2x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p; @@ -141,9 +141,8 @@ static void YCrCB_to_BGR24_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 (j=0; j<8; j++) { + for (i = sy; i > 0; i--) { + for (j = sx; j > 0; j -= 2) { int y, cb, cr; int add_r, add_g, add_b; @@ -155,15 +154,7 @@ static void YCrCB_to_BGR24_2x1(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; - b = (y + add_b) >> SCALEBITS; - *p++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p++ = clamp(r); - - y = (*Y++) << SCALEBITS; + y = Y[0] << SCALEBITS; b = (y + add_b) >> SCALEBITS; *p++ = clamp(b); g = (y + add_g) >> SCALEBITS; @@ -171,6 +162,17 @@ static void YCrCB_to_BGR24_2x1(struct jdec_private *priv) r = (y + add_r) >> SCALEBITS; *p++ = clamp(r); + if (j > 1) { + y = Y[1] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p++ = clamp(r); + } + + Y += 2; } p += offset_to_next_row; @@ -190,7 +192,7 @@ static void YCrCB_to_BGR24_2x1(struct jdec_private *priv) * | 2 | * `---' */ -static void YCrCB_to_BGR24_1x2(struct jdec_private *priv) +static void YCrCB_to_BGR24_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_BGR24_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_BGR24_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; b = (y + add_b) >> SCALEBITS; *p++ = clamp(b); g = (y + add_g) >> SCALEBITS; @@ -229,14 +230,17 @@ static void YCrCB_to_BGR24_1x2(struct jdec_private *priv) r = (y + add_r) >> SCALEBITS; *p++ = clamp(r); - y = (Y[8-1]) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p2++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p2++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p2++ = clamp(r); - + if (i > 1) { + y = Y[8] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p2++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p2++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p2++ = clamp(r); + } + + Y++; } Y += 8; p += offset_to_next_row; @@ -258,7 +262,7 @@ static void YCrCB_to_BGR24_1x2(struct jdec_private *priv) * | 3 | 4 | * `-------' */ -static void YCrCB_to_BGR24_2x2(struct jdec_private *priv) +static void YCrCB_to_BGR24_2x2(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p, *p2; @@ -275,9 +279,8 @@ static void YCrCB_to_BGR24_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; @@ -289,7 +292,7 @@ static void YCrCB_to_BGR24_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; b = (y + add_b) >> SCALEBITS; *p++ = clamp(b); g = (y + add_g) >> SCALEBITS; @@ -297,29 +300,37 @@ static void YCrCB_to_BGR24_2x2(struct jdec_private *priv) r = (y + add_r) >> SCALEBITS; *p++ = clamp(r); - y = (*Y++) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p++ = clamp(r); - - y = (Y[16-2]) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p2++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p2++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p2++ = clamp(r); - - y = (Y[16-1]) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p2++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p2++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p2++ = clamp(r); + if (j > 1) { + y = Y[1] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p++ = clamp(r); + } + + if (i > 1) { + y = Y[16+0] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p2++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p2++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p2++ = clamp(r); + + if (j > 1) { + y = Y[16+1] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p2++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p2++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p2++ = clamp(r); + } + } + + Y += 2; } Y += 16; p += offset_to_next_row; diff --git a/com32/lib/jpeg/bgra32.c b/com32/lib/jpeg/bgra32.c index 7e2c72bc..1aa1835b 100644 --- a/com32/lib/jpeg/bgra32.c +++ b/com32/lib/jpeg/bgra32.c @@ -69,7 +69,7 @@ static unsigned char clamp(int i) * | 1 | * `---' */ -static void YCrCB_to_BGRA32_1x1(struct jdec_private *priv) +static void YCrCB_to_BGRA32_1x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p; @@ -85,15 +85,14 @@ static void YCrCB_to_BGRA32_1x1(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = priv->bytes_per_row[0] - 8*4; - 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, a; - y = (*Y++) << SCALEBITS; + y = Y[0] << SCALEBITS; cb = *Cb++ - 128; cr = *Cr++ - 128; add_r = FIX(1.40200) * cr + ONE_HALF; @@ -109,6 +108,7 @@ static void YCrCB_to_BGRA32_1x1(struct jdec_private *priv) a = 255; *p++ = a; + Y++; } p += offset_to_next_row; @@ -127,7 +127,7 @@ static void YCrCB_to_BGRA32_1x1(struct jdec_private *priv) * | 1 | 2 | * `-------' */ -static void YCrCB_to_BGRA32_2x1(struct jdec_private *priv) +static void YCrCB_to_BGRA32_2x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p; @@ -143,10 +143,8 @@ static void YCrCB_to_BGRA32_2x1(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = priv->bytes_per_row[0] - 16*4; - for (i=0; i<8; i++) { - - for (j=0; j<8; j++) { - + for (i = sy; i > 0; i--) { + for (j = sx; j > 0; j -= 2) { int y, cb, cr; int add_r, add_g, add_b; int r, g , b, a; @@ -157,7 +155,7 @@ static void YCrCB_to_BGRA32_2x1(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; b = (y + add_b) >> SCALEBITS; *p++ = clamp(b); g = (y + add_g) >> SCALEBITS; @@ -166,17 +164,20 @@ static void YCrCB_to_BGRA32_2x1(struct jdec_private *priv) *p++ = clamp(r); a = 255; *p++ = a; - - y = (*Y++) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p++ = clamp(r); - a = 255; - *p++ = a; - + + if (j > 1) { + y = Y[1] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p++ = clamp(r); + a = 255; + *p++ = a; + } + + Y += 2; } p += offset_to_next_row; @@ -196,7 +197,7 @@ static void YCrCB_to_BGRA32_2x1(struct jdec_private *priv) * | 2 | * `---' */ -static void YCrCB_to_BGRA32_1x2(struct jdec_private *priv) +static void YCrCB_to_BGRA32_1x2(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p, *p2; @@ -213,9 +214,8 @@ static void YCrCB_to_BGRA32_1x2(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = 2*priv->bytes_per_row[0] - 8*4; - 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; @@ -227,7 +227,7 @@ static void YCrCB_to_BGRA32_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; b = (y + add_b) >> SCALEBITS; *p++ = clamp(b); g = (y + add_g) >> SCALEBITS; @@ -237,16 +237,19 @@ static void YCrCB_to_BGRA32_1x2(struct jdec_private *priv) a = 255; *p++ = a; - y = (Y[8-1]) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p2++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p2++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p2++ = clamp(r); - a = 255; - *p2++ = a; - + if (i > 1) { + y = Y[8] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p2++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p2++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p2++ = clamp(r); + a = 255; + *p2++ = a; + } + + Y++; } Y += 8; p += offset_to_next_row; @@ -268,7 +271,7 @@ static void YCrCB_to_BGRA32_1x2(struct jdec_private *priv) * | 3 | 4 | * `-------' */ -static void YCrCB_to_BGRA32_2x2(struct jdec_private *priv) +static void YCrCB_to_BGRA32_2x2(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p, *p2; @@ -285,9 +288,8 @@ static void YCrCB_to_BGRA32_2x2(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = 2*priv->bytes_per_row[0] - 16*4; - 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; @@ -299,17 +301,7 @@ static void YCrCB_to_BGRA32_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; - b = (y + add_b) >> SCALEBITS; - *p++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p++ = clamp(r); - a = 255; - *p++ = a; - - y = (*Y++) << SCALEBITS; + y = Y[0] << SCALEBITS; b = (y + add_b) >> SCALEBITS; *p++ = clamp(b); g = (y + add_g) >> SCALEBITS; @@ -319,25 +311,43 @@ static void YCrCB_to_BGRA32_2x2(struct jdec_private *priv) a = 255; *p++ = a; - y = (Y[16-2]) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p2++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p2++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p2++ = clamp(r); - a = 255; - *p2++ = a; - - y = (Y[16-1]) << SCALEBITS; - b = (y + add_b) >> SCALEBITS; - *p2++ = clamp(b); - g = (y + add_g) >> SCALEBITS; - *p2++ = clamp(g); - r = (y + add_r) >> SCALEBITS; - *p2++ = clamp(r); - a = 255; - *p2++ = a; + if (j > 1) { + y = Y[1] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p++ = clamp(r); + a = 255; + *p++ = a; + } + + if (i > 1) { + y = Y[16+0] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p2++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p2++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p2++ = clamp(r); + a = 255; + *p2++ = a; + + if (j > 1) { + y = Y[16+1] << SCALEBITS; + b = (y + add_b) >> SCALEBITS; + *p2++ = clamp(b); + g = (y + add_g) >> SCALEBITS; + *p2++ = clamp(g); + r = (y + add_r) >> SCALEBITS; + *p2++ = clamp(r); + a = 255; + *p2++ = a; + } + } + + Y += 2; } Y += 16; p += offset_to_next_row; diff --git a/com32/lib/jpeg/grey.c b/com32/lib/jpeg/grey.c index 0034ce2b..2f114744 100644 --- a/com32/lib/jpeg/grey.c +++ b/com32/lib/jpeg/grey.c @@ -40,12 +40,12 @@ #include "tinyjpeg-internal.h" /** - * YCrCb -> Grey (1x1) + * YCrCb -> Grey (1x1, 1x2) * .---. * | 1 | * `---' */ -static void YCrCB_to_Grey_1x1(struct jdec_private *priv) +static void YCrCB_to_Grey_1xN(struct jdec_private *priv, int sx, int sy) { const unsigned char *y; unsigned char *p; @@ -56,73 +56,20 @@ static void YCrCB_to_Grey_1x1(struct jdec_private *priv) y = priv->Y; offset_to_next_row = priv->bytes_per_row[0]; - for (i=0; i<8; i++) { - memcpy(p, y, 8); - y+=8; - p += offset_to_next_row; - } -} - -/** - * YCrCb -> Grey (2x1) - * .-------. - * | 1 | 2 | - * `-------' - */ -static void YCrCB_to_Grey_2x1(struct jdec_private *priv) -{ - const unsigned char *y; - unsigned char *p; - unsigned int i; - int offset_to_next_row; - - p = priv->plane[0]; - y = priv->Y; - offset_to_next_row = priv->bytes_per_row[0]; - - for (i=0; i<8; i++) { - memcpy(p, y, 16); - y += 16; - p += offset_to_next_row; - } -} - - -/** - * YCrCb -> Grey (1x2) - * .---. - * | 1 | - * |---| - * | 2 | - * `---' - */ -static void YCrCB_to_Grey_1x2(struct jdec_private *priv) -{ - const unsigned char *y; - unsigned char *p; - unsigned int i; - int offset_to_next_row; - - p = priv->plane[0]; - y = priv->Y; - offset_to_next_row = priv->bytes_per_row[0]; - - for (i=0; i<16; i++) { - memcpy(p, y, 8); + for (i = sy; i > 0; i--) { + memcpy(p, y, sx); y += 8; p += offset_to_next_row; } } /** - * YCrCb -> Grey (2x2) + * YCrCb -> Grey (2x1, 2x2) * .-------. * | 1 | 2 | - * |---+---| - * | 3 | 4 | * `-------' */ -static void YCrCB_to_Grey_2x2(struct jdec_private *priv) +static void YCrCB_to_Grey_2xN(struct jdec_private *priv, int sx, int sy) { const unsigned char *y; unsigned char *p; @@ -133,8 +80,8 @@ static void YCrCB_to_Grey_2x2(struct jdec_private *priv) y = priv->Y; offset_to_next_row = priv->bytes_per_row[0]; - for (i=0; i<16; i++) { - memcpy(p, y, 16); + for (i = sy; i > 0; i--) { + memcpy(p, y, sx); y += 16; p += offset_to_next_row; } @@ -145,12 +92,12 @@ static int initialize_grey(struct jdec_private *priv, unsigned int *bytes_per_mcu) { if (priv->components[0] == NULL) - priv->components[0] = (uint8_t *)malloc(priv->width * priv->height * 3); + priv->components[0] = (uint8_t *)malloc(priv->width * priv->height); if (!priv->bytes_per_row[0]) - priv->bytes_per_row[0] = priv->width * 3; + priv->bytes_per_row[0] = priv->width; bytes_per_blocklines[0] = priv->bytes_per_row[0]; - bytes_per_mcu[0] = 3*8; + bytes_per_mcu[0] = 8; return !priv->components[0]; } @@ -158,10 +105,10 @@ static int initialize_grey(struct jdec_private *priv, static const struct tinyjpeg_colorspace format_grey = { { - YCrCB_to_Grey_1x1, - YCrCB_to_Grey_1x2, - YCrCB_to_Grey_2x1, - YCrCB_to_Grey_2x2, + YCrCB_to_Grey_1xN, + YCrCB_to_Grey_1xN, + YCrCB_to_Grey_2xN, + YCrCB_to_Grey_2xN, }, tinyjpeg_decode_mcu_1comp_table, initialize_grey 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; diff --git a/com32/lib/jpeg/rgba32.c b/com32/lib/jpeg/rgba32.c index 5fcbe992..da08344d 100644 --- a/com32/lib/jpeg/rgba32.c +++ b/com32/lib/jpeg/rgba32.c @@ -69,7 +69,7 @@ static unsigned char clamp(int i) * | 1 | * `---' */ -static void YCrCB_to_RGBA32_1x1(struct jdec_private *priv) +static void YCrCB_to_RGBA32_1x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p; @@ -85,15 +85,14 @@ static void YCrCB_to_RGBA32_1x1(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = priv->bytes_per_row[0] - 8*4; - 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, a; - y = (*Y++) << SCALEBITS; + y = Y[0] << SCALEBITS; cb = *Cb++ - 128; cr = *Cr++ - 128; add_r = FIX(1.40200) * cr + ONE_HALF; @@ -108,6 +107,8 @@ static void YCrCB_to_RGBA32_1x1(struct jdec_private *priv) *p++ = clamp(b); a = 255; *p++ = a; + + Y++; } p += offset_to_next_row; @@ -125,7 +126,7 @@ static void YCrCB_to_RGBA32_1x1(struct jdec_private *priv) * | 1 | 2 | * `-------' */ -static void YCrCB_to_RGBA32_2x1(struct jdec_private *priv) +static void YCrCB_to_RGBA32_2x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p; @@ -141,15 +142,14 @@ static void YCrCB_to_RGBA32_2x1(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = priv->bytes_per_row[0] - 16*4; - for (i=0; i<8; i++) { - - for (j=0; j<8; j++) { + for (i = sy; i > 0; i--) { + for (j = sx; j > 0; j -= 2) { int y, cb, cr; int add_r, add_g, add_b; int r, g , b, a; - y = (*Y++) << SCALEBITS; + y = Y[0] << SCALEBITS; cb = *Cb++ - 128; cr = *Cr++ - 128; add_r = FIX(1.40200) * cr + ONE_HALF; @@ -165,15 +165,19 @@ static void YCrCB_to_RGBA32_2x1(struct jdec_private *priv) a = 255; *p++ = a; - 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); - a = 255; - *p++ = a; + 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); + a = 255; + *p++ = a; + } + + Y += 2; } p += offset_to_next_row; @@ -194,7 +198,7 @@ static void YCrCB_to_RGBA32_2x1(struct jdec_private *priv) * | 2 | * `---' */ -static void YCrCB_to_RGBA32_1x2(struct jdec_private *priv) +static void YCrCB_to_RGBA32_1x2(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p, *p2; @@ -211,9 +215,8 @@ static void YCrCB_to_RGBA32_1x2(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = 2*priv->bytes_per_row[0] - 8*4; - 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; @@ -225,7 +228,7 @@ static void YCrCB_to_RGBA32_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; @@ -235,16 +238,19 @@ static void YCrCB_to_RGBA32_1x2(struct jdec_private *priv) a = 255; *p++ = a; - 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); - a = 255; - *p2++ = a; - + 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); + a = 255; + *p2++ = a; + } + + Y++; } Y += 8; p += offset_to_next_row; @@ -265,7 +271,7 @@ static void YCrCB_to_RGBA32_1x2(struct jdec_private *priv) * | 3 | 4 | * `-------' */ -static void YCrCB_to_RGBA32_2x2(struct jdec_private *priv) +static void YCrCB_to_RGBA32_2x2(struct jdec_private *priv, int sx, int sy) { const unsigned char *Y, *Cb, *Cr; unsigned char *p, *p2; @@ -282,9 +288,8 @@ static void YCrCB_to_RGBA32_2x2(struct jdec_private *priv) Cb = priv->Cb; Cr = priv->Cr; offset_to_next_row = 2*priv->bytes_per_row[0] - 16*4; - for (i=0; i<8; i++) { - - for (j=0;j<8;j++) { + for (i = sy; i > 0; i -= 2) { + for (j = sx; i > 0; j -= 2) { int y, cb, cr; int add_r, add_g, add_b; @@ -296,7 +301,7 @@ static void YCrCB_to_RGBA32_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; @@ -306,35 +311,43 @@ static void YCrCB_to_RGBA32_2x2(struct jdec_private *priv) a = 255; *p++ = a; - 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); - a = 255; - *p++ = a; - - 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); - a = 255; - *p2++ = a; - - 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); - a = 255; - *p2++ = a; + 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); + a = 255; + *p++ = a; + } + + 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); + a = 255; + *p2++ = a; + + 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); + a = 255; + *p2++ = a; + } + } + + Y += 2; } Y += 16; p += offset_to_next_row; diff --git a/com32/lib/jpeg/tinyjpeg-internal.h b/com32/lib/jpeg/tinyjpeg-internal.h index bd0e58da..bb5c6707 100644 --- a/com32/lib/jpeg/tinyjpeg-internal.h +++ b/com32/lib/jpeg/tinyjpeg-internal.h @@ -80,7 +80,7 @@ struct component typedef void (*decode_MCU_fct) (struct jdec_private *priv); -typedef void (*convert_colorspace_fct) (struct jdec_private *priv); +typedef void (*convert_colorspace_fct) (struct jdec_private *priv, int, int); struct jdec_private { @@ -167,6 +167,16 @@ enum std_markers { #define trace(fmt, args...) do { } while (0) #endif +#ifndef __likely +# define __likely(x) (!!(x)) +#endif +#ifndef __unlikely +# define __unlikely(x) (!!(x)) +#endif + +#define min(x, y) ((x) < (y) ? (x) : (y)) +#define max(x, y) ((x) > (y) ? (x) : (y)) + #if 0 static char *print_bits(unsigned int value, char *bitstr) { diff --git a/com32/lib/jpeg/tinyjpeg.c b/com32/lib/jpeg/tinyjpeg.c index 657ff6e1..a9395a5d 100644 --- a/com32/lib/jpeg/tinyjpeg.c +++ b/com32/lib/jpeg/tinyjpeg.c @@ -546,12 +546,6 @@ static int parse_SOF(struct jdec_private *priv, const unsigned char *stream) error("Width and Height (%dx%d) seems suspicious\n", width, height); if (nr_components != 3) error("We only support YUV images\n"); -#if 0 - if (height%16) - error("Height need to be a multiple of 16 (current height is %d)\n", height); - if (width%16) - error("Width need to be a multiple of 16 (current Width is %d)\n", width); -#endif #endif stream += 8; for (i=0; i<nr_components; i++) { @@ -883,18 +877,21 @@ int tinyjpeg_parse_header(struct jdec_private *priv, const unsigned char *buf, u int tinyjpeg_decode(struct jdec_private *priv, const struct tinyjpeg_colorspace *pixfmt) { - unsigned int x, y, xstride_by_mcu, ystride_by_mcu; + int x, y, sx, sy; + int xshift_by_mcu, yshift_by_mcu; + int xstride_by_mcu, ystride_by_mcu; unsigned int bytes_per_blocklines[3], bytes_per_mcu[3]; decode_MCU_fct decode_MCU; const decode_MCU_fct *decode_mcu_table; convert_colorspace_fct convert_to_pixfmt; + uint8_t *pptr[3]; decode_mcu_table = pixfmt->decode_mcu_table; /* Fix: check return value */ pixfmt->initialize(priv, bytes_per_blocklines, bytes_per_mcu); - xstride_by_mcu = ystride_by_mcu = 8; + xshift_by_mcu = yshift_by_mcu = 3; if ((priv->component_infos[cY].Hfactor | priv->component_infos[cY].Vfactor) == 1) { decode_MCU = decode_mcu_table[0]; convert_to_pixfmt = pixfmt->convert_colorspace[0]; @@ -902,43 +899,58 @@ int tinyjpeg_decode(struct jdec_private *priv, } else if (priv->component_infos[cY].Hfactor == 1) { decode_MCU = decode_mcu_table[1]; convert_to_pixfmt = pixfmt->convert_colorspace[1]; - ystride_by_mcu = 16; + yshift_by_mcu = 4; trace("Use decode 1x2 sampling (not supported)\n"); } else if (priv->component_infos[cY].Vfactor == 2) { decode_MCU = decode_mcu_table[3]; convert_to_pixfmt = pixfmt->convert_colorspace[3]; - xstride_by_mcu = 16; - ystride_by_mcu = 16; + xshift_by_mcu = 4; + yshift_by_mcu = 4; trace("Use decode 2x2 sampling\n"); } else { decode_MCU = decode_mcu_table[2]; convert_to_pixfmt = pixfmt->convert_colorspace[2]; - xstride_by_mcu = 16; + xshift_by_mcu = 4; trace("Use decode 2x1 sampling\n"); } resync(priv); /* Don't forget to that block can be either 8 or 16 lines */ - bytes_per_blocklines[0] *= ystride_by_mcu; - bytes_per_blocklines[1] *= ystride_by_mcu; - bytes_per_blocklines[2] *= ystride_by_mcu; + bytes_per_blocklines[0] <<= yshift_by_mcu; + bytes_per_blocklines[1] <<= yshift_by_mcu; + bytes_per_blocklines[2] <<= yshift_by_mcu; + + bytes_per_mcu[0] <<= xshift_by_mcu-3; + bytes_per_mcu[1] <<= xshift_by_mcu-3; + bytes_per_mcu[2] <<= xshift_by_mcu-3; + + xstride_by_mcu = 1 << xshift_by_mcu; + ystride_by_mcu = 1 << yshift_by_mcu; + + pptr[0] = priv->components[0]; + pptr[1] = priv->components[1]; + pptr[2] = priv->components[2]; - bytes_per_mcu[0] *= xstride_by_mcu/8; - bytes_per_mcu[1] *= xstride_by_mcu/8; - bytes_per_mcu[2] *= xstride_by_mcu/8; + trace("bpbl = %d, bpmcu = %d\n", + bytes_per_blocklines[0], bytes_per_mcu[0]); - /* Just the decode the image by macroblock (size is 8x8, 8x16, or 16x16) */ - for (y=0; y < priv->height/ystride_by_mcu; y++) + for (y = priv->height; y > 0; y -= ystride_by_mcu) { - //trace("Decoding row %d\n", y); - priv->plane[0] = priv->components[0] + (y * bytes_per_blocklines[0]); - priv->plane[1] = priv->components[1] + (y * bytes_per_blocklines[1]); - priv->plane[2] = priv->components[2] + (y * bytes_per_blocklines[2]); - for (x=0; x < priv->width; x+=xstride_by_mcu) + trace("Decoding row %d\n", priv->height-y); + priv->plane[0] = pptr[0]; pptr[0] += bytes_per_blocklines[0]; + priv->plane[1] = pptr[1]; pptr[1] += bytes_per_blocklines[1]; + priv->plane[2] = pptr[2]; pptr[2] += bytes_per_blocklines[2]; + + sy = min(y, ystride_by_mcu); + + for (x = priv->width; x > 0; x -= xstride_by_mcu) { + sx = min(x, xstride_by_mcu); + trace("Block size: %dx%d\n", sx, sy); + decode_MCU(priv); - convert_to_pixfmt(priv); + convert_to_pixfmt(priv, sx, sy); priv->plane[0] += bytes_per_mcu[0]; priv->plane[1] += bytes_per_mcu[1]; priv->plane[2] += bytes_per_mcu[2]; diff --git a/com32/lib/jpeg/yuv420p.c b/com32/lib/jpeg/yuv420p.c index f8aeb447..0c84cada 100644 --- a/com32/lib/jpeg/yuv420p.c +++ b/com32/lib/jpeg/yuv420p.c @@ -35,6 +35,8 @@ * yuv420p.c */ +/**** XXXX: THIS IS NOT YET CONVERTED TO HANDLE PARTIAL MCUS ****/ + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -64,7 +66,7 @@ * | 1 | * `---' */ -static void YCrCB_to_YUV420P_1x1(struct jdec_private *priv) +static void YCrCB_to_YUV420P_1x1(struct jdec_private *priv, int sx, int sy) { const unsigned char *s, *y; unsigned char *p; @@ -106,7 +108,7 @@ static void YCrCB_to_YUV420P_1x1(struct jdec_private *priv) * | 1 | 2 | * `-------' */ -static void YCrCB_to_YUV420P_2x1(struct jdec_private *priv) +static void YCrCB_to_YUV420P_2x1(struct jdec_private *priv, int sx, int sy) { unsigned char *p; const unsigned char *s, *y1; @@ -149,7 +151,7 @@ static void YCrCB_to_YUV420P_2x1(struct jdec_private *priv) * | 2 | * `---' */ -static void YCrCB_to_YUV420P_1x2(struct jdec_private *priv) +static void YCrCB_to_YUV420P_1x2(struct jdec_private *priv, int sx, int sy) { const unsigned char *s, *y; unsigned char *p; @@ -191,7 +193,7 @@ static void YCrCB_to_YUV420P_1x2(struct jdec_private *priv) * | 3 | 4 | * `-------' */ -static void YCrCB_to_YUV420P_2x2(struct jdec_private *priv) +static void YCrCB_to_YUV420P_2x2(struct jdec_private *priv, int sx, int sy) { unsigned char *p; const unsigned char *s, *y1; |