X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fjpeg.c;h=a96a9d7fd5c3e9245b5e87ffc2d5db3a4db9fd34;hb=184705fc8c7d8ef75a6cfca4d61cbf35c0df0334;hp=0831c5b0e71e66356b9205877bccf686ac29f880;hpb=bbc4722277845fbe190fc997f3a2eb2408f6152e;p=seabios.git diff --git a/src/jpeg.c b/src/jpeg.c index 0831c5b..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; @@ -422,30 +425,30 @@ int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic 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; @@ -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) \