From 2420b5d3aecb9aa286436215f975513f83828fc5 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 11 Jul 2010 16:02:39 +0200 Subject: Refactor image pixel unpacking. --- fitz/dev_draw.c | 2 +- fitz/fitz.h | 12 ++++-------- fitz/res_colorspace.c | 30 ++++++++++++++++++------------ 3 files changed, 23 insertions(+), 21 deletions(-) (limited to 'fitz') diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index 9dfa58fc..e769f10a 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -578,7 +578,7 @@ fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm) if (image->colorspace != dev->model) { converted = fz_newpixmap(dev->model, image->x, image->y, image->w, image->h); - fz_convertpixmap(image->colorspace, image, dev->model, converted); + fz_convertpixmap(image, converted); image = converted; } diff --git a/fitz/fitz.h b/fitz/fitz.h index 8ad72322..2d64d63a 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -729,7 +729,7 @@ fz_colorspace *fz_keepcolorspace(fz_colorspace *cs); void fz_dropcolorspace(fz_colorspace *cs); void fz_convertcolor(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv); -void fz_convertpixmap(fz_colorspace *srcs, fz_pixmap *srcv, fz_colorspace *dsts, fz_pixmap *dstv); +void fz_convertpixmap(fz_pixmap *src, fz_pixmap *dst); /* * Fonts come in two variants: @@ -1113,6 +1113,9 @@ void fz_executedisplaylist(fz_displaylist *list, fz_device *dev, fz_matrix ctm); extern void fz_accelerate(void); extern void fz_acceleratearch(void); +extern void fz_decodetile(fz_pixmap *pix, float *decode, int scale); +extern void fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride); + extern void (*fz_duff_ni1on)(unsigned char*restrict,int,int,unsigned char*restrict,int,unsigned char*restrict,int,int,int); extern void (*fz_duff_1i1o1)(unsigned char*restrict,int,unsigned char*restrict,int,unsigned char*restrict,int,int,int); extern void (*fz_duff_2i1o2)(unsigned char*restrict,int,unsigned char*restrict,int,unsigned char*restrict,int,int,int); @@ -1133,13 +1136,6 @@ extern void (*fz_img_2o2)(unsigned char*restrict,unsigned char,int,unsigned char extern void (*fz_img_w2i1o2)(unsigned char*,unsigned char*restrict,unsigned char,int,unsigned char*restrict,fz_pixmap*,int u, int v, int fa, int fb); extern void (*fz_img_w4i1o4)(unsigned char*,unsigned char*restrict,unsigned char,int,unsigned char*restrict,fz_pixmap*,int u, int v, int fa, int fb); -extern void (*fz_decodetile)(fz_pixmap *pix, int skip, float *decode); -extern void (*fz_loadtile1)(unsigned char*restrict, int sw, unsigned char*restrict, int dw, int w, int h, int pad); -extern void (*fz_loadtile2)(unsigned char*restrict, int sw, unsigned char*restrict, int dw, int w, int h, int pad); -extern void (*fz_loadtile4)(unsigned char*restrict, int sw, unsigned char*restrict, int dw, int w, int h, int pad); -extern void (*fz_loadtile8)(unsigned char*restrict, int sw, unsigned char*restrict, int dw, int w, int h, int pad); -extern void (*fz_loadtile16)(unsigned char*restrict, int sw, unsigned char*restrict, int dw, int w, int h, int pad); - extern void (*fz_srown)(unsigned char *restrict, unsigned char *restrict, int w, int denom, int n); extern void (*fz_srow1)(unsigned char *restrict, unsigned char *restrict, int w, int denom); extern void (*fz_srow2)(unsigned char *restrict, unsigned char *restrict, int w, int denom); diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c index 6cad3f16..3e8660ab 100644 --- a/fitz/res_colorspace.c +++ b/fitz/res_colorspace.c @@ -286,18 +286,21 @@ static void fastrgbtobgr(fz_pixmap *src, fz_pixmap *dst) } static void -fz_stdconvpixmap(fz_colorspace *srcs, fz_pixmap *src, fz_colorspace *dsts, fz_pixmap *dst) +fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) { float srcv[FZ_MAXCOLORS]; float dstv[FZ_MAXCOLORS]; int y, x, k; + fz_colorspace *ss = src->colorspace; + fz_colorspace *ds = dst->colorspace; + unsigned char *s = src->samples; unsigned char *d = dst->samples; assert(src->w == dst->w && src->h == dst->h); - assert(src->n == srcs->n + 1); - assert(dst->n == dsts->n + 1); + assert(src->n == ss->n + 1); + assert(dst->n == ds->n + 1); for (y = 0; y < src->h; y++) { @@ -306,7 +309,7 @@ fz_stdconvpixmap(fz_colorspace *srcs, fz_pixmap *src, fz_colorspace *dsts, fz_pi for (k = 0; k < src->n - 1; k++) srcv[k] = *s++ / 255.0f; - fz_convertcolor(srcs, srcv, dsts, dstv); + fz_convertcolor(ss, srcv, ds, dstv); for (k = 0; k < dst->n - 1; k++) *d++ = dstv[k] * 255; @@ -317,14 +320,19 @@ fz_stdconvpixmap(fz_colorspace *srcs, fz_pixmap *src, fz_colorspace *dsts, fz_pi } void -fz_convertpixmap(fz_colorspace *ss, fz_pixmap *sp, fz_colorspace *ds, fz_pixmap *dp) +fz_convertpixmap(fz_pixmap *sp, fz_pixmap *dp) { + fz_colorspace *ss = sp->colorspace; + fz_colorspace *ds = dp->colorspace; + + assert(ss && ds); + if (ss == pdf_devicegray) { if (ds == pdf_devicergb) fastgraytorgb(sp, dp); else if (ds == pdf_devicebgr) fastgraytorgb(sp, dp); /* bgr == rgb here */ else if (ds == pdf_devicecmyk) fastgraytocmyk(sp, dp); - else fz_stdconvpixmap(ss, sp, ds, dp); + else fz_stdconvpixmap(sp, dp); } else if (ss == pdf_devicergb) @@ -332,8 +340,7 @@ fz_convertpixmap(fz_colorspace *ss, fz_pixmap *sp, fz_colorspace *ds, fz_pixmap if (ds == pdf_devicegray) fastrgbtogray(sp, dp); else if (ds == pdf_devicebgr) fastrgbtobgr(sp, dp); else if (ds == pdf_devicecmyk) fastrgbtocmyk(sp, dp); - else fz_stdconvpixmap(ss, sp, ds, dp); - + else fz_stdconvpixmap(sp, dp); } else if (ss == pdf_devicebgr) @@ -341,8 +348,7 @@ fz_convertpixmap(fz_colorspace *ss, fz_pixmap *sp, fz_colorspace *ds, fz_pixmap if (ds == pdf_devicegray) fastbgrtogray(sp, dp); else if (ds == pdf_devicergb) fastrgbtobgr(sp, dp); /* bgr = rgb here */ else if (ds == pdf_devicecmyk) fastbgrtocmyk(sp, dp); - else fz_stdconvpixmap(ss, sp, ds, dp); - + else fz_stdconvpixmap(sp, dp); } else if (ss == pdf_devicecmyk) @@ -350,10 +356,10 @@ fz_convertpixmap(fz_colorspace *ss, fz_pixmap *sp, fz_colorspace *ds, fz_pixmap if (ds == pdf_devicegray) fastcmyktogray(sp, dp); else if (ds == pdf_devicebgr) fastcmyktobgr(sp, dp); else if (ds == pdf_devicergb) fastcmyktorgb(sp, dp); - else fz_stdconvpixmap(ss, sp, ds, dp); + else fz_stdconvpixmap(sp, dp); } - else fz_stdconvpixmap(ss, sp, ds, dp); + else fz_stdconvpixmap(sp, dp); } /* -- cgit v1.2.3