1
/* $Xorg: mephoto.c,v 1.4 2001/02/09 02:04:24 xorgcvs Exp $ */
2
/**** module mephoto.c ****/
3
/******************************************************************************
5
Copyright 1993, 1994, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
30
This software is being provided by AGE Logic, Inc. under the
31
following license. By obtaining, using and/or copying this software,
32
you agree that you have read, understood, and will comply with these
35
Permission to use, copy, modify, distribute and sell this
36
software and its documentation for any purpose and without
37
fee or royalty and to grant others any or all rights granted
38
herein is hereby granted, provided that you agree to comply
39
with the following copyright notice and statements, including
40
the disclaimer, and that the same appears on all copies and
41
derivative works of the software and documentation you make.
43
"Copyright 1993, 1994 by AGE Logic, Inc."
45
THIS SOFTWARE IS PROVIDED "AS IS". AGE LOGIC MAKES NO
46
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way of
47
example, but not limitation, AGE LOGIC MAKE NO
48
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
49
FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
50
INFRINGE THIRD-PARTY PROPRIETARY RIGHTS. AGE LOGIC
51
SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE. IN NO
52
EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
53
INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
54
OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
55
ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
56
BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
57
HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
60
The name of AGE Logic, Inc. may not be used in
61
advertising or publicity pertaining to this software without
62
specific, written prior permission from AGE Logic.
64
Title to this software shall at all times remain with AGE
66
*****************************************************************************
68
mephoto.c -- DDXIE prototype export photomap element
70
Robert NC Shelley -- AGE Logic, Inc. June, 1993
71
Dean && Ben - various additions to handle different techniques
73
*****************************************************************************/
74
/* $XFree86: xc/programs/Xserver/XIE/mixie/export/mephoto.c,v 3.6 2001/12/14 19:58:20 dawes Exp $ */
94
* more X server includes.
97
#include <dixstruct.h>
103
#include <photomap.h>
107
#include <meuncomp.h>
111
* routines used internal to this module
113
static int CreateEPhotoUncom(floDefPtr flo, peDefPtr ped);
114
static int InitializeEPhotoBypass(floDefPtr flo, peDefPtr ped);
115
static int InitializeEPhotoUncomByPlane(floDefPtr flo, peDefPtr ped);
116
static int ActivateEPhotoUncomByPlane(floDefPtr flo, peDefPtr ped, peTexPtr pet);
117
static int ResetEPhoto(floDefPtr flo, peDefPtr ped);
118
static int DestroyEPhoto(floDefPtr flo, peDefPtr ped);
121
static int InitializeEPhotoUncomByPixel(floDefPtr flo, peDefPtr ped);
122
static int ActivateEPhotoUncomByPixel(floDefPtr flo, peDefPtr ped, peTexPtr pet);
123
#endif /* XIE_FULL */
127
* routines we need from somewhere else
130
extern int CreateEPhotoJPEGBaseline();
131
extern int InitializeEPhotoJPEGBaseline();
132
extern int ActivateEPhotoJPEGBaseline();
133
extern int ResetEPhotoJPEGBaseline();
134
extern int DestroyEPhotoJPEGBaseline();
136
extern int CreateEPhotoFAX();
137
extern int InitializeEPhotoFAX();
138
extern int ActivateEPhotoFAX();
139
extern int ResetEPhotoFAX();
140
extern int DestroyEPhotoFAX();
143
* DDXIE ExportPhotomap entry points
145
static ddElemVecRec EPhotoBypassVec = {
147
InitializeEPhotoBypass,
154
static ddElemVecRec EPhotoUncomByPlaneVec = {
156
InitializeEPhotoUncomByPlane,
157
ActivateEPhotoUncomByPlane,
163
static ddElemVecRec EPhotoFAXVec = {
173
static ddElemVecRec EPhotoUncomByPixelVec = {
175
InitializeEPhotoUncomByPixel,
176
ActivateEPhotoUncomByPixel,
182
static ddElemVecRec EPhotoJPEGBaselineVec = {
183
CreateEPhotoJPEGBaseline,
184
InitializeEPhotoJPEGBaseline,
185
ActivateEPhotoJPEGBaseline,
187
ResetEPhotoJPEGBaseline,
188
DestroyEPhotoJPEGBaseline
190
#endif /* XIE_FULL */
193
/*------------------------------------------------------------------------
194
------------------- see if we can handle this element --------------------
195
------------------------------------------------------------------------*/
196
int miAnalyzeEPhoto(floDefPtr flo, peDefPtr ped)
198
ePhotoDefPtr pvt = (ePhotoDefPtr)ped->elemPvt;
201
ped->ddVec = EPhotoBypassVec;
204
switch(pvt->encodeNumber) {
206
case xieValEncodeUncompressedSingle:
207
ped->ddVec = EPhotoUncomByPlaneVec;
210
case xieValEncodeG31D:
211
case xieValEncodeG32D:
212
case xieValEncodeG42D:
213
case xieValEncodeTIFF2:
214
case xieValEncodeTIFFPackBits:
215
ped->ddVec = EPhotoFAXVec;
219
case xieValEncodeUncompressedTriple:
221
xieTecEncodeUncompressedTriple *tecParms =
222
(xieTecEncodeUncompressedTriple *)pvt->encodeParms;
223
if(tecParms->interleave == xieValBandByPlane)
224
ped->ddVec = EPhotoUncomByPlaneVec;
226
ped->ddVec = EPhotoUncomByPixelVec;
229
case xieValEncodeJPEGBaseline:
230
{ /*** JPEG for SI can only handle 8 bit image depths ***/
231
inFloPtr inf = &ped->inFloLst[IMPORT];
232
outFloPtr src = &inf->srcDef->outFlo;
234
for (b=0; b< src->bands; ++b)
235
if(src->format[b].depth != 8) {
236
xieFloExportPhotomap *raw = (xieFloExportPhotomap *)ped->elemRaw;
238
TechniqueError(flo, ped, xieValEncode,
239
raw->encodeTechnique, raw->lenParams, return(FALSE));
242
ped->ddVec = EPhotoJPEGBaselineVec;
244
case xieValEncodeJPEGLossless:
245
#endif /* XIE_FULL */
246
default: ImplementationError(flo,ped, return(FALSE));
249
} /* end miAnalyzeEPhoto */
251
/*------------------------------------------------------------------------
252
---------------------------- create peTex . . . --------------------------
253
------------------------------------------------------------------------*/
254
static int CreateEPhotoUncom(floDefPtr flo, peDefPtr ped)
256
/* attach an execution context to the photo element definition */
257
return(MakePETex(flo, ped, xieValMaxBands * sizeof(meUncompRec),
259
} /* end CreateEPhotoUncom */
261
/*------------------------------------------------------------------------
262
---------------------------- initialize peTex . . . ----------------------
263
------------------------------------------------------------------------*/
264
static int InitializeEPhotoBypass(floDefPtr flo, peDefPtr ped)
266
/* Allows data manager to bypass element entirely */
267
return(InitReceptor(flo, ped, ped->peTex->receptor,
268
NO_DATAMAP, 1, NO_BANDS, ALL_BANDS));
269
} /* end InitializeEPhotoBypass */
271
/*------------------------------------------------------------------------
272
---------------------------- initialize peTex . . . ----------------------
273
------------------------------------------------------------------------*/
274
static int InitializeEPhotoUncomByPlane(floDefPtr flo, peDefPtr ped)
276
peTexPtr pet = ped->peTex;
277
meUncompPtr pvt = (meUncompPtr)pet->private;
278
formatPtr inf = ped->inFloLst[SRCtag].format;
279
bandPtr sbnd = pet->receptor->band;
280
CARD32 nbands = ped->outFlo.bands, b, s;
281
xieTypOrientation pixelOrder, fillOrder;
285
xieTecEncodeUncompressedSingle *tecParms =
286
(xieTecEncodeUncompressedSingle *)
287
((ePhotoDefPtr)ped->elemPvt)->encodeParms;
288
pixelOrder = tecParms->pixelOrder;
289
fillOrder = tecParms->fillOrder;
292
xieTecEncodeUncompressedTriple *tecParms =
293
(xieTecEncodeUncompressedTriple *)
294
((ePhotoDefPtr)ped->elemPvt)->encodeParms;
295
pixelOrder = tecParms->pixelOrder;
296
fillOrder = tecParms->fillOrder;
297
if(tecParms->bandOrder == xieValLSFirst)
298
for(b = 0; b < xieValMaxBands; ++b)
301
for(s = 0, b = xieValMaxBands; b--; ++s)
304
for (b = 0; b < nbands; b++, pvt++, inf++, sbnd++) {
305
bandPtr dbnd = &pet->emitter[pvt->bandMap];
306
formatPtr outf = &ped->outFlo.format[pvt->bandMap];
307
CARD8 class = inf->class;
308
if (class == BIT_PIXEL) {
309
pvt->width = inf->width;
310
#if (IMAGE_BYTE_ORDER == MSBFirst)
311
if (outf->stride != 1) {
312
pvt->action = (fillOrder == xieValMSFirst) ? btoIS: sbtoIS;
314
pvt->action = (fillOrder == xieValMSFirst) ?
315
(void (*)())NULL : sbtoS;
318
if (outf->stride != 1) {
319
pvt->action = (fillOrder == xieValLSFirst) ? btoIS: sbtoIS;
321
pvt->action = (fillOrder == xieValLSFirst) ?
322
(void (*)())NULL : sbtoS;
325
pvt->stride = outf->stride;
326
pvt->pitch = outf->pitch;
327
} else if (class == BYTE_PIXEL) {
328
pvt->width = inf->width;
329
if (!(outf->stride & 7)) {
330
if (outf->stride == 8)
334
pvt->Bstride = outf->stride >> 3;
336
pvt->mask = 0; /* Unused */
337
pvt->shift = 0; /* Unused */
338
pvt->clear_dst = FALSE;
340
if (pixelOrder == xieValLSFirst) {
341
if (fillOrder == xieValLSFirst)
342
pvt->action = BtoLLUB;
344
pvt->action = BtoLMUB;
346
if (fillOrder == xieValLSFirst)
347
pvt->action = BtoMLUB;
349
pvt->action = BtoMMUB;
351
pvt->bitOff = 0; /* Bit offset to first pixel on line */
352
pvt->leftOver = 0; /* Left over bits from last line */
353
pvt->depth = inf->depth;
354
pvt->stride = outf->stride;
355
pvt->pitch = outf->pitch;
357
} else if (class == PAIR_PIXEL) {
358
pvt->width = inf->width;
359
if (!(outf->stride & 15)) {
360
#if (IMAGE_BYTE_ORDER == LSBFirst)
361
if (outf->stride == 16)
362
pvt->action = (fillOrder == xieValLSFirst) ?
363
(void (*)())NULL : sPtoS;
365
pvt->action = (fillOrder == xieValLSFirst) ? PtoIS: sPtoIS;
367
if (outf->stride == 16)
368
pvt->action = (fillOrder == xieValMSFirst) ?
369
(void (*)())NULL : sPtoS;
371
pvt->action = (fillOrder == xieValMSFirst) ? PtoIS: sPtoIS;
373
pvt->Bstride = outf->stride >> 3;
375
pvt->mask = 0; /* Unused */
376
pvt->shift = 0; /* Unused */
377
pvt->clear_dst = FALSE;
379
if (pixelOrder == xieValLSFirst) {
380
if (fillOrder == xieValLSFirst)
381
pvt->action = PtoLLUP;
383
pvt->action = PtoLMUP;
385
if (fillOrder == xieValLSFirst)
386
pvt->action = PtoMLUP;
388
pvt->action = PtoMMUP;
390
pvt->bitOff = 0; /* Bit offset to first pixel on line */
391
pvt->leftOver = 0; /* Left over bits from last line */
392
pvt->depth = inf->depth;
393
pvt->stride = outf->stride;
394
pvt->pitch = outf->pitch;
396
} else if (class == QUAD_PIXEL) {
397
pvt->width = inf->width;
398
if (!(outf->stride & 31)) {
399
#if (IMAGE_BYTE_ORDER == LSBFirst)
400
if (outf->stride == 32)
401
pvt->action = (fillOrder == xieValLSFirst) ?
402
(void (*)())NULL : sQtoS;
404
pvt->action = (fillOrder == xieValLSFirst) ? QtoIS: sQtoIS;
406
if (outf->stride == 32)
407
pvt->action = (fillOrder == xieValMSFirst) ?
408
(void (*)())NULL : sQtoS;
410
pvt->action = (fillOrder == xieValMSFirst) ? QtoIS: sQtoIS;
412
pvt->Bstride = outf->stride >> 3;
414
pvt->mask = 0; /* Unused */
415
pvt->shift = 0; /* Unused */
416
pvt->clear_dst = FALSE;
418
if (pixelOrder == xieValLSFirst) {
419
if (fillOrder == xieValLSFirst)
420
pvt->action = QtoLLUQ;
422
pvt->action = QtoLMUQ;
424
if (fillOrder == xieValLSFirst)
425
pvt->action = QtoMLUQ;
427
pvt->action = QtoMMUQ;
431
ImplementationError(flo,ped, return(FALSE));
434
pvt->bitOff = 0; /* Bit offset to first pixel on line */
435
pvt->leftOver = 0; /* Left over bits from last line */
436
pvt->width = inf->width;
437
pvt->depth = inf->depth;
438
pvt->stride = outf->stride;
439
pvt->pitch = outf->pitch;
440
if(!InitBand(flo,ped,sbnd,NO_DATAMAP,(CARD32)1,NO_INPLACE) ||
441
!InitBand(flo,ped,dbnd,NO_DATAMAP,(CARD32)0,NO_INPLACE))
445
*outf = *inf; /* Pass data into photomap in native format */
446
sbnd->receptor->bypass |= 1<<b;
449
pet->bandSync = NO_SYNC;
451
return(inited ? TRUE :
452
/* Allows data manager to bypass element entirely */
453
InitReceptor(flo,ped,pet->receptor,NO_DATAMAP,1,NO_BANDS,ALL_BANDS));
454
} /* end InitializeEPhotoUncomByPlane */
456
/*------------------------------------------------------------------------
457
----------------------------- crank some data ----------------------------
458
------------------------------------------------------------------------*/
459
static int ActivateEPhotoUncomByPlane(floDefPtr flo, peDefPtr ped, peTexPtr pet)
461
meUncompPtr pvt = (meUncompPtr)pet->private;
462
receptorPtr rcp = pet->receptor;
463
CARD32 bands = rcp->inFlo->bands;
464
bandPtr sbnd = rcp->band, dbnd;
465
CARD32 b, olddlen, nextdlen, width, stride, pitch;
469
for(b = 0; b < bands; ++sbnd, ++b, ++pvt) {
470
dbnd = &pet->emitter[pvt->bandMap];
471
width = sbnd->format->width;
472
pitch = dbnd->format->pitch;
473
stride = dbnd->format->stride;
474
nextdlen = (pvt->bitOff + pitch + 7) >> 3;
476
if (!(pet->scheduled & 1<<b)) continue; /* This band is bypassed */
478
src = GetCurrentSrc(flo,pet,sbnd);
479
dst = (CARD8*)GetDstBytes(flo,pet,dbnd,dbnd->current,nextdlen,KEEP);
481
while(!ferrCode(flo) && src && dst) {
483
(*pvt->action)(src,dst,pvt);
485
src = GetNextSrc(flo,pet,sbnd,FLUSH);
486
pvt->bitOff = (pvt->bitOff + pitch) & 7; /* Set next */
487
olddlen = (pvt->bitOff) ? nextdlen - 1: nextdlen;
488
nextdlen = (pvt->bitOff + pitch + 7) >> 3;
489
dst = (CARD8*)GetDstBytes(flo,pet,dbnd,dbnd->current+olddlen,
492
FreeData(flo,pet,sbnd,sbnd->current);
494
if(!src && sbnd->final) {
495
if (pvt->bitOff) /* If we have any bits left, send them out now */
496
*(CARD8*)GetDstBytes(flo,pet,dbnd,dbnd->current,1,KEEP)=pvt->leftOver;
499
PutData(flo,pet,dbnd,dbnd->maxGlobal); /* write the remaining data */
503
} /* end ActivateEPhotoUncomByPlane */
507
/*------------------------------------------------------------------------
508
---------------------------- initialize peTex . . . ----------------------
509
------------------------------------------------------------------------*/
510
static int InitializeEPhotoUncomByPixel(floDefPtr flo, peDefPtr ped)
512
peTexPtr pet = ped->peTex;
513
meUncompPtr pvt = (meUncompPtr)pet->private;
514
xieTecEncodeUncompressedTriple *tec =
515
(xieTecEncodeUncompressedTriple *)
516
((ePhotoDefPtr)ped->elemPvt)->encodeParms;
517
formatPtr outf = pet->emitter[0].format;
518
bandPtr sbnd1,sbnd2,sbnd3;
519
CARD32 depth1,depth2,depth3,dstride;
522
pvt->unaligned = (tec->pixelStride[0] & 7) != 0;
524
if(tec->bandOrder == xieValLSFirst)
525
for(d = 0; d < xieValMaxBands; ++d)
528
for(s = 0, d = xieValMaxBands; d--; ++s)
531
sbnd1 = &pet->receptor[SRCtag].band[pvt[0].bandMap];
532
sbnd2 = &pet->receptor[SRCtag].band[pvt[1].bandMap];
533
sbnd3 = &pet->receptor[SRCtag].band[pvt[2].bandMap];
534
depth1 = pvt[0].depth = sbnd1->format->depth;
535
depth2 = pvt[1].depth = sbnd2->format->depth;
536
depth3 = pvt[2].depth = sbnd3->format->depth;
537
dstride = tec->pixelStride[0]>>3;
538
pvt[0].width = pvt[1].width = pvt[2].width = sbnd1->format->width;
540
if (!pvt->unaligned) {
541
/* Look for special cases */
542
if (depth1 == 16 && depth2 == 16 && depth3 == 16) {
543
#if (IMAGE_BYTE_ORDER == MSBFirst)
544
void (*pa)() = (tec->pixelOrder == xieValMSFirst) ? PtoIS : sPtoIS;
546
void (*pa)() = (tec->pixelOrder == xieValMSFirst) ? sPtoIS : PtoIS;
548
for(s = 0; s < xieValMaxBands; s++, pvt++) {
550
pvt->Bstride = dstride;
552
pvt->mask = 0; /* Unused */
553
pvt->shift = 0; /* Unused */
554
pvt->clear_dst = FALSE;
556
} else if (depth1 == 8 && depth2 == 8 && depth3 == 8) {
557
for(s = 0; s < xieValMaxBands; s++, pvt++) {
559
pvt->Bstride = dstride;
561
pvt->mask = 0; /* Unused */
562
pvt->shift = 0; /* Unused */
563
pvt->clear_dst = FALSE;
565
} else if (depth1 == 4 && depth2 == 4 && depth3 == 4) {
566
if (tec->fillOrder == xieValMSFirst) {
567
pvt->action = BtoISb;
568
pvt->Bstride = dstride;
571
pvt->clear_dst = FALSE;
573
pvt->action = BtoISb;
574
pvt->Bstride = dstride;
577
pvt->clear_dst = FALSE;
579
pvt->action = BtoISb;
580
pvt->Bstride = dstride;
583
pvt->clear_dst = FALSE;
585
} else { /* xieValLSFirst */
586
pvt->action = BtoISb;
587
pvt->Bstride = dstride;
589
pvt->clear_dst = FALSE;
592
pvt->action = BtoISb;
593
pvt->Bstride = dstride;
596
pvt->clear_dst = FALSE;
598
pvt->action = BtoISb;
599
pvt->Bstride = dstride;
602
pvt->clear_dst = FALSE;
605
} else if (depth1 + depth2 + depth3 <= 8) {
606
CARD8 ones = 0xff,smask1,smask2,smask3,shift1,shift2,shift3;
607
if (tec->fillOrder == xieValMSFirst) {
608
smask1 = ~(ones>>depth1);
609
smask2 = ~(ones>>(depth1 + depth2) | smask1);
610
smask3 = ~(ones>>(depth1 + depth2 + depth3) | smask1 | smask2);
612
shift2 = 8 - (depth1 + depth2);
613
shift3 = 8 - (depth1 + depth2 + depth3);
614
} else { /* fillOrder == xieValLSFirst */
615
smask3 = ~(ones<<depth3);
616
smask2 = ~(ones<<(depth2 + depth3) | smask3);
617
smask1 = ~(ones<<(depth1 + depth2 + depth3) | smask2 | smask3);
620
shift1 = depth2 + depth3;
622
pvt->action = (depth1 > 1) ? BtoISb : btoISb;
623
pvt->Bstride = dstride;
626
pvt->clear_dst = TRUE;
627
(pvt++)->shift = shift1;
628
pvt->action = (depth2 > 1) ? BtoISb : btoISb;
629
pvt->Bstride = dstride;
632
pvt->clear_dst = TRUE;
633
(pvt++)->shift = shift2;
634
pvt->action = (depth3 > 1) ? BtoISb : btoISb;
635
pvt->Bstride = dstride;
638
pvt->clear_dst = TRUE;
641
pvt->unaligned = TRUE;
643
pvt = (meUncompPtr)pet->private;
644
if (pvt->unaligned) {
645
/* No special cases, do it the hard way */
646
pvt[0].pitch = outf->pitch;
647
pvt->action = EncodeTripleFuncs[tec->pixelOrder == xieValLSFirst ? 0 : 1]
648
[tec->fillOrder == xieValLSFirst ? 0 : 1]
649
[depth1 <= 8 ? 0 : 1]
650
[depth2 <= 8 ? 0 : 1]
651
[depth3 <= 8 ? 0 : 1];
652
if((depth1 == 1 && !(pvt[0].buf = (pointer)XieMalloc(pvt[0].width+7))) ||
653
(depth2 == 1 && !(pvt[1].buf = (pointer)XieMalloc(pvt[1].width+7))) ||
654
(depth3 == 1 && !(pvt[2].buf = (pointer)XieMalloc(pvt[2].width+7))))
655
AllocError(flo,ped, return(FALSE));
657
pet->bandSync = SYNC;
659
return(InitReceptors(flo, ped, NO_DATAMAP, 1) &&
660
InitEmitter(flo, ped, NO_DATAMAP, NO_INPLACE));
661
} /* end InitializeEPhotoUncomByPixel */
664
/*------------------------------------------------------------------------
665
----------------------------- crank some data ----------------------------
666
------------------------------------------------------------------------*/
667
static int ActivateEPhotoUncomByPixel(floDefPtr flo, peDefPtr ped, peTexPtr pet)
669
meUncompPtr pvt = (meUncompPtr)pet->private;
670
bandPtr sb0 = &pet->receptor[SRCtag].band[pvt[0].bandMap];
671
bandPtr sb1 = &pet->receptor[SRCtag].band[pvt[1].bandMap];
672
bandPtr sb2 = &pet->receptor[SRCtag].band[pvt[2].bandMap];
673
bandPtr dbnd = &pet->emitter[0];
674
CARD32 pitch = dbnd->format->pitch;
675
pointer sp0 = (pointer )NULL, sp1 = (pointer )NULL, sp2 = (pointer )NULL;
679
if (pvt->unaligned) {
680
CARD32 stride = dbnd->format->stride;
681
CARD32 width = dbnd->format->width;
682
CARD32 nextdlen = (pvt->bitOff + pitch + 7) >> 3, olddlen;
683
if((sp0 = GetCurrentSrc(flo,pet,sb0)) &&
684
(sp1 = GetCurrentSrc(flo,pet,sb1)) &&
685
(sp2 = GetCurrentSrc(flo,pet,sb2)) &&
686
(dst = (BytePixel*)GetDstBytes(flo,pet,dbnd,dbnd->current,
689
if(pvt[0].buf) sp0 = bitexpand(sp0,pvt[0].buf,width,(char)0,(char)1);
690
if(pvt[1].buf) sp1 = bitexpand(sp1,pvt[1].buf,width,(char)0,(char)1);
691
if(pvt[2].buf) sp2 = bitexpand(sp2,pvt[2].buf,width,(char)0,(char)1);
693
(*pvt->action)(sp0,sp1,sp2,dst,stride,pvt);
695
sp0 = GetNextSrc(flo,pet,sb0,FLUSH);
696
sp1 = GetNextSrc(flo,pet,sb1,FLUSH);
697
sp2 = GetNextSrc(flo,pet,sb2,FLUSH);
698
pvt->bitOff = (pvt->bitOff + pitch) & 7; /* Set next */
699
olddlen = (pvt->bitOff) ? nextdlen - 1 : nextdlen;
700
nextdlen = (pvt->bitOff + pitch + 7) >> 3;
701
dst = (BytePixel*)GetDstBytes(flo,pet,dbnd,
702
dbnd->current+olddlen,nextdlen,KEEP);
703
} while(dst && sp0 && sp1 && sp2);
706
CARD32 dlen = pitch >> 3; /* For nicely aligned data */
707
if((sp0 = GetCurrentSrc(flo,pet,sb0)) &&
708
(sp1 = GetCurrentSrc(flo,pet,sb1)) &&
709
(sp2 = GetCurrentSrc(flo,pet,sb2)) &&
710
(dst = (BytePixel*)GetDstBytes(flo,pet,dbnd,dbnd->current,dlen,KEEP)))
714
if (pvt[0].clear_dst) bzero(dst,(int)dlen);
716
(*pvt[0].action)(sp0,dst,&pvt[0]);
717
(*pvt[1].action)(sp1,dst,&pvt[1]);
718
(*pvt[2].action)(sp2,dst,&pvt[2]);
720
sp0 = GetNextSrc(flo,pet,sb0,FLUSH);
721
sp1 = GetNextSrc(flo,pet,sb1,FLUSH);
722
sp2 = GetNextSrc(flo,pet,sb2,FLUSH);
723
dst = (BytePixel*)GetDstBytes(flo,pet,dbnd,dbnd->current+dlen,
725
} while(dst && sp0 && sp1 && sp2);
728
FreeData(flo,pet,sb0,sb0->current);
729
FreeData(flo,pet,sb1,sb1->current);
730
FreeData(flo,pet,sb2,sb2->current);
732
if(!sp0 && sb0->final && !sp1 && sb1->final && !sp2 && sb2->final) {
733
if (pvt->bitOff) /* If we have any bits left, send them out now */
734
*(CARD8*)GetDstBytes(flo,pet,dbnd,dbnd->current,1,KEEP) = pvt->leftOver;
737
PutData(flo,pet,dbnd,dbnd->maxGlobal); /* write the remaining data */
741
} /* end ActivateEPhotoUncomByPixel */
742
#endif /* XIE_FULL */
744
/*------------------------------------------------------------------------
745
------------------------ get rid of run-time stuff -----------------------
746
------------------------------------------------------------------------*/
747
static int ResetEPhoto(floDefPtr flo, peDefPtr ped)
749
meUncompPtr pvt = (meUncompPtr)ped->peTex->private;
752
for(i = 0; i < xieValMaxBands; ++i)
753
if(pvt[i].buf) pvt[i].buf = (pointer) XieFree(pvt[i].buf);
759
} /* end ResetEPhoto */
761
/*------------------------------------------------------------------------
762
-------------------------- get rid of this element -----------------------
763
------------------------------------------------------------------------*/
764
static int DestroyEPhoto(floDefPtr flo, peDefPtr ped)
766
/* get rid of the peTex structure */
767
ped->peTex = (peTexPtr) XieFree(ped->peTex);
769
/* zap this element's entry point vector */
770
ped->ddVec.create = (xieIntProc) NULL;
771
ped->ddVec.initialize = (xieIntProc) NULL;
772
ped->ddVec.activate = (xieIntProc) NULL;
773
ped->ddVec.reset = (xieIntProc) NULL;
774
ped->ddVec.destroy = (xieIntProc) NULL;
777
} /* end DestroyEPhoto */
779
/* end module mephoto.c */