*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)
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;
IFIX(128.5), max[0]);
idct(jpeg->dcts + 64, jpeg->out + 64, jpeg->dquant[0],
IFIX(128.5), max[1]);
- idct(jpeg->dcts + 128, jpeg->out + 128,
- jpeg->dquant[0], IFIX(128.5), max[2]);
- idct(jpeg->dcts + 192, jpeg->out + 192,
- jpeg->dquant[0], IFIX(128.5), max[3]);
- idct(jpeg->dcts + 256, jpeg->out + 256,
- jpeg->dquant[1], IFIX(0.5), max[4]);
- idct(jpeg->dcts + 320, jpeg->out + 320,
- jpeg->dquant[2], IFIX(0.5), max[5]);
+ idct(jpeg->dcts + 128, jpeg->out + 128, jpeg->dquant[0],
+ IFIX(128.5), max[2]);
+ idct(jpeg->dcts + 192, jpeg->out + 192, jpeg->dquant[0],
+ IFIX(128.5), max[3]);
+ idct(jpeg->dcts + 256, jpeg->out + 256, jpeg->dquant[1],
+ IFIX(0.5), max[4]);
+ idct(jpeg->dcts + 320, jpeg->out + 320, jpeg->dquant[2],
+ IFIX(0.5), max[5]);
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;
#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], \
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) \