aboutsummaryrefslogtreecommitdiff
path: root/src/jpeg.c
diff options
context:
space:
mode:
authorWayne Xia <xiawenc@linux.vnet.ibm.com>2011-07-08 11:03:16 +0800
committerKevin O'Connor <kevin@koconnor.net>2011-07-09 09:50:26 -0400
commit8031efa935657cd7957ec927a1c3e37519d3d5a0 (patch)
tree96e7b5d0e56edbc249057a7849e1aa7443e6fb90 /src/jpeg.c
parent5042ca50f4dd808957d5550615e6c469147c9cf2 (diff)
downloadseabios-hppa-8031efa935657cd7957ec927a1c3e37519d3d5a0.zip
seabios-hppa-8031efa935657cd7957ec927a1c3e37519d3d5a0.tar.gz
seabios-hppa-8031efa935657cd7957ec927a1c3e37519d3d5a0.tar.bz2
Fix jpeg decoder problem when it is used in 24 BPP mode.
Signed-off-by: Wayne Xia <xiawenc@linux.vnet.ibm.com>
Diffstat (limited to 'src/jpeg.c')
-rw-r--r--src/jpeg.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/jpeg.c b/src/jpeg.c
index 1068291..a96a9d7 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -394,10 +394,10 @@ void jpeg_get_size(struct jpeg_decdata *jpeg, int *width, int *height)
*height = jpeg->height;
}
-int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic
- , int width, int height, int depth)
+int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic, int width
+ , int height, int depth, int bytes_per_line_dest)
{
- int m, mcusx, mcusy, mx, my;
+ int m, mcusx, mcusy, mx, my, mloffset, jpgbpl;
int max[6];
if (jpeg->height != height)
@@ -405,6 +405,9 @@ int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic
if (jpeg->width != width)
return ERR_WIDTH_MISMATCH;
+ jpgbpl = width * depth / 8;
+ mloffset = bytes_per_line_dest > jpgbpl ? bytes_per_line_dest : jpgbpl;
+
mcusx = jpeg->width >> 4;
mcusy = jpeg->height >> 4;
@@ -434,18 +437,18 @@ int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic
switch (depth) {
case 32:
col221111_32(jpeg->out,
- pic + (my * 16 * mcusx + mx) * 16 * 4,
- mcusx * 16 * 4);
+ pic + (my * 16 * mloffset + mx * 16 * 4),
+ mloffset);
break;
case 24:
col221111(jpeg->out,
- pic + (my * 16 * mcusx + mx) * 16 * 3,
- mcusx * 16 * 3);
+ pic + (my * 16 * mloffset + mx * 16 * 3),
+ mloffset);
break;
case 16:
col221111_16(jpeg->out,
- pic + (my * 16 * mcusx + mx) * (16 * 2),
- mcusx * (16 * 2));
+ pic + (my * 16 * mloffset + mx * 16 * 2),
+ mloffset);
break;
default:
return ERR_DEPTH_MISMATCH;
@@ -887,6 +890,15 @@ static void initcol(PREC q[][64])
#endif
+#ifdef __LITTLE_ENDIAN
+#define PIC(yin, xin, p, xout) \
+( \
+ y = outy[(yin) * 8 + xin], \
+ STORECLAMP(p[(xout) * 3 + 2], y + cr), \
+ STORECLAMP(p[(xout) * 3 + 1], y - cg), \
+ STORECLAMP(p[(xout) * 3 + 0], y + cb) \
+)
+#else
#define PIC(yin, xin, p, xout) \
( \
y = outy[(yin) * 8 + xin], \
@@ -894,6 +906,7 @@ static void initcol(PREC q[][64])
STORECLAMP(p[(xout) * 3 + 1], y - cg), \
STORECLAMP(p[(xout) * 3 + 2], y + cb) \
)
+#endif
#ifdef __LITTLE_ENDIAN
#define PIC_16(yin, xin, p, xout, add) \