4 extern int RGB_LOW_BITS_MASK
;
7 void _2xSaILine (u8
*srcPtr
, u8
*deltaPtr
, u32 srcPitch
,
8 u32 width
, u8
*dstPtr
, u32 dstPitch
);
9 void _2xSaISuperEagleLine (u8
*srcPtr
, u8
*deltaPtr
,
10 u32 srcPitch
, u32 width
,
11 u8
*dstPtr
, u32 dstPitch
);
12 void _2xSaISuper2xSaILine (u8
*srcPtr
, u8
*deltaPtr
,
13 u32 srcPitch
, u32 width
,
14 u8
*dstPtr
, u32 dstPitch
);
15 void Init_2xSaIMMX (u32 BitFormat
);
16 void BilinearMMX (u16
* A
, u16
* B
, u16
* C
, u16
* D
,
17 u16
* dx
, u16
* dy
, u8
*dP
);
18 void BilinearMMXGrid0 (u16
* A
, u16
* B
, u16
* C
, u16
* D
,
19 u16
* dx
, u16
* dy
, u8
*dP
);
20 void BilinearMMXGrid1 (u16
* A
, u16
* B
, u16
* C
, u16
* D
,
21 u16
* dx
, u16
* dy
, u8
*dP
);
26 static u32 colorMask
= 0xF7DEF7DE;
27 static u32 lowPixelMask
= 0x08210821;
28 static u32 qcolorMask
= 0xE79CE79C;
29 static u32 qlowpixelMask
= 0x18631863;
30 static u32 redblueMask
= 0xF81F;
31 static u32 greenMask
= 0x7E0;
33 u32 qRGB_COLOR_MASK
[2] = { 0xF7DEF7DE, 0xF7DEF7DE };
35 extern void hq2x_init(unsigned);
37 int Init_2xSaI(u32 BitFormat
)
39 if(systemColorDepth
== 16) {
40 if (BitFormat
== 565) {
41 colorMask
= 0xF7DEF7DE;
42 lowPixelMask
= 0x08210821;
43 qcolorMask
= 0xE79CE79C;
44 qlowpixelMask
= 0x18631863;
47 qRGB_COLOR_MASK
[0] = qRGB_COLOR_MASK
[1] = 0xF7DEF7DE;
49 RGB_LOW_BITS_MASK
= 0x0821;
50 } else if (BitFormat
== 555) {
51 colorMask
= 0x7BDE7BDE;
52 lowPixelMask
= 0x04210421;
53 qcolorMask
= 0x739C739C;
54 qlowpixelMask
= 0x0C630C63;
57 qRGB_COLOR_MASK
[0] = qRGB_COLOR_MASK
[1] = 0x7BDE7BDE;
59 RGB_LOW_BITS_MASK
= 0x0421;
63 } else if(systemColorDepth
== 32) {
65 lowPixelMask
= 0x010101;
66 qcolorMask
= 0xfcfcfc;
67 qlowpixelMask
= 0x030303;
68 qRGB_COLOR_MASK
[0] = qRGB_COLOR_MASK
[1] = 0xfefefe;
70 RGB_LOW_BITS_MASK
= 0x010101;
75 Init_2xSaIMMX (BitFormat
);
81 static inline int GetResult1 (u32 A
, u32 B
, u32 C
, u32 D
,
103 static inline int GetResult2 (u32 A
, u32 B
, u32 C
, u32 D
,
125 static inline int GetResult (u32 A
, u32 B
, u32 C
, u32 D
)
146 static inline u32
INTERPOLATE (u32 A
, u32 B
)
149 return (((A
& colorMask
) >> 1) + ((B
& colorMask
) >> 1) +
150 (A
& B
& lowPixelMask
));
155 static inline u32
Q_INTERPOLATE (u32 A
, u32 B
, u32 C
, u32 D
)
157 register u32 x
= ((A
& qcolorMask
) >> 2) +
158 ((B
& qcolorMask
) >> 2) +
159 ((C
& qcolorMask
) >> 2) + ((D
& qcolorMask
) >> 2);
160 register u32 y
= (A
& qlowpixelMask
) +
161 (B
& qlowpixelMask
) + (C
& qlowpixelMask
) + (D
& qlowpixelMask
);
163 y
= (y
>> 2) & qlowpixelMask
;
167 static inline int GetResult1_32 (u32 A
, u32 B
, u32 C
, u32 D
,
189 static inline int GetResult2_32 (u32 A
, u32 B
, u32 C
, u32 D
,
211 #define BLUE_MASK565 0x001F001F
212 #define RED_MASK565 0xF800F800
213 #define GREEN_MASK565 0x07E007E0
215 #define BLUE_MASK555 0x001F001F
216 #define RED_MASK555 0x7C007C00
217 #define GREEN_MASK555 0x03E003E0
219 void Super2xSaI (u8
*srcPtr
, u32 srcPitch
,
220 u8
*deltaPtr
, u8
*dstPtr
, u32 dstPitch
,
221 int width
, int height
)
226 u32 Nextline
= srcPitch
>> 1;
229 for (; height
; height
--) {
230 _2xSaISuper2xSaILine (srcPtr
, deltaPtr
, srcPitch
, width
,
233 dstPtr
+= dstPitch
* 2;
234 deltaPtr
+= srcPitch
;
241 for (; height
; height
--) {
245 for (u32 finish
= width
; finish
; finish
-= inc_bP
) {
246 u32 color4
, color5
, color6
;
247 u32 color1
, color2
, color3
;
248 u32 colorA0
, colorA1
, colorA2
, colorA3
,
249 colorB0
, colorB1
, colorB2
, colorB3
, colorS1
, colorS2
;
250 u32 product1a
, product1b
, product2a
, product2b
;
252 //--------------------------------------- B1 B2
257 colorB0
= *(bP
- Nextline
- 1);
258 colorB1
= *(bP
- Nextline
);
259 colorB2
= *(bP
- Nextline
+ 1);
260 colorB3
= *(bP
- Nextline
+ 2);
267 color1
= *(bP
+ Nextline
- 1);
268 color2
= *(bP
+ Nextline
);
269 color3
= *(bP
+ Nextline
+ 1);
270 colorS1
= *(bP
+ Nextline
+ 2);
272 colorA0
= *(bP
+ Nextline
+ Nextline
- 1);
273 colorA1
= *(bP
+ Nextline
+ Nextline
);
274 colorA2
= *(bP
+ Nextline
+ Nextline
+ 1);
275 colorA3
= *(bP
+ Nextline
+ Nextline
+ 2);
277 //--------------------------------------
278 if (color2
== color6
&& color5
!= color3
) {
279 product2b
= product1b
= color2
;
280 } else if (color5
== color3
&& color2
!= color6
) {
281 product2b
= product1b
= color5
;
282 } else if (color5
== color3
&& color2
== color6
) {
285 r
+= GetResult (color6
, color5
, color1
, colorA1
);
286 r
+= GetResult (color6
, color5
, color4
, colorB1
);
287 r
+= GetResult (color6
, color5
, colorA2
, colorS1
);
288 r
+= GetResult (color6
, color5
, colorB2
, colorS2
);
291 product2b
= product1b
= color6
;
293 product2b
= product1b
= color5
;
295 product2b
= product1b
= INTERPOLATE (color5
, color6
);
298 if (color6
== color3
&& color3
== colorA1
299 && color2
!= colorA2
&& color3
!= colorA0
)
301 Q_INTERPOLATE (color3
, color3
, color3
, color2
);
302 else if (color5
== color2
&& color2
== colorA2
303 && colorA1
!= color3
&& color2
!= colorA3
)
305 Q_INTERPOLATE (color2
, color2
, color2
, color3
);
307 product2b
= INTERPOLATE (color2
, color3
);
309 if (color6
== color3
&& color6
== colorB1
310 && color5
!= colorB2
&& color6
!= colorB0
)
312 Q_INTERPOLATE (color6
, color6
, color6
, color5
);
313 else if (color5
== color2
&& color5
== colorB2
314 && colorB1
!= color6
&& color5
!= colorB3
)
316 Q_INTERPOLATE (color6
, color5
, color5
, color5
);
318 product1b
= INTERPOLATE (color5
, color6
);
321 if (color5
== color3
&& color2
!= color6
&& color4
== color5
322 && color5
!= colorA2
)
323 product2a
= INTERPOLATE (color2
, color5
);
325 if (color5
== color1
&& color6
== color5
326 && color4
!= color2
&& color5
!= colorA0
)
327 product2a
= INTERPOLATE (color2
, color5
);
331 if (color2
== color6
&& color5
!= color3
&& color1
== color2
332 && color2
!= colorB2
)
333 product1a
= INTERPOLATE (color2
, color5
);
335 if (color4
== color2
&& color3
== color2
336 && color1
!= color5
&& color2
!= colorB0
)
337 product1a
= INTERPOLATE (color2
, color5
);
341 #ifdef WORDS_BIGENDIAN
342 product1a
= (product1a
<< 16) | product1b
;
343 product2a
= (product2a
<< 16) | product2b
;
345 product1a
= product1a
| (product1b
<< 16);
346 product2a
= product2a
| (product2b
<< 16);
349 *((u32
*) dP
) = product1a
;
350 *((u32
*) (dP
+ dstPitch
)) = product2a
;
354 } // end of for ( finish= width etc..)
357 dstPtr
+= dstPitch
<< 1;
358 deltaPtr
+= srcPitch
;
359 } // endof: for (; height; height--)
363 void Super2xSaI32 (u8
*srcPtr
, u32 srcPitch
,
364 u8
* unused
/* deltaPtr */, u8
*dstPtr
, u32 dstPitch
,
365 int width
, int height
)
370 u32 Nextline
= srcPitch
>> 2;
373 for (; height
; height
--) {
377 for (u32 finish
= width
; finish
; finish
-= inc_bP
) {
378 u32 color4
, color5
, color6
;
379 u32 color1
, color2
, color3
;
380 u32 colorA0
, colorA1
, colorA2
, colorA3
,
381 colorB0
, colorB1
, colorB2
, colorB3
, colorS1
, colorS2
;
382 u32 product1a
, product1b
, product2a
, product2b
;
384 //--------------------------------------- B1 B2
389 colorB0
= *(bP
- Nextline
- 1);
390 colorB1
= *(bP
- Nextline
);
391 colorB2
= *(bP
- Nextline
+ 1);
392 colorB3
= *(bP
- Nextline
+ 2);
399 color1
= *(bP
+ Nextline
- 1);
400 color2
= *(bP
+ Nextline
);
401 color3
= *(bP
+ Nextline
+ 1);
402 colorS1
= *(bP
+ Nextline
+ 2);
404 colorA0
= *(bP
+ Nextline
+ Nextline
- 1);
405 colorA1
= *(bP
+ Nextline
+ Nextline
);
406 colorA2
= *(bP
+ Nextline
+ Nextline
+ 1);
407 colorA3
= *(bP
+ Nextline
+ Nextline
+ 2);
409 //--------------------------------------
410 if (color2
== color6
&& color5
!= color3
) {
411 product2b
= product1b
= color2
;
412 } else if (color5
== color3
&& color2
!= color6
) {
413 product2b
= product1b
= color5
;
414 } else if (color5
== color3
&& color2
== color6
) {
417 r
+= GetResult (color6
, color5
, color1
, colorA1
);
418 r
+= GetResult (color6
, color5
, color4
, colorB1
);
419 r
+= GetResult (color6
, color5
, colorA2
, colorS1
);
420 r
+= GetResult (color6
, color5
, colorB2
, colorS2
);
423 product2b
= product1b
= color6
;
425 product2b
= product1b
= color5
;
427 product2b
= product1b
= INTERPOLATE (color5
, color6
);
430 if (color6
== color3
&& color3
== colorA1
431 && color2
!= colorA2
&& color3
!= colorA0
)
433 Q_INTERPOLATE (color3
, color3
, color3
, color2
);
434 else if (color5
== color2
&& color2
== colorA2
435 && colorA1
!= color3
&& color2
!= colorA3
)
437 Q_INTERPOLATE (color2
, color2
, color2
, color3
);
439 product2b
= INTERPOLATE (color2
, color3
);
441 if (color6
== color3
&& color6
== colorB1
442 && color5
!= colorB2
&& color6
!= colorB0
)
444 Q_INTERPOLATE (color6
, color6
, color6
, color5
);
445 else if (color5
== color2
&& color5
== colorB2
446 && colorB1
!= color6
&& color5
!= colorB3
)
448 Q_INTERPOLATE (color6
, color5
, color5
, color5
);
450 product1b
= INTERPOLATE (color5
, color6
);
453 if (color5
== color3
&& color2
!= color6
&& color4
== color5
454 && color5
!= colorA2
)
455 product2a
= INTERPOLATE (color2
, color5
);
457 if (color5
== color1
&& color6
== color5
458 && color4
!= color2
&& color5
!= colorA0
)
459 product2a
= INTERPOLATE (color2
, color5
);
463 if (color2
== color6
&& color5
!= color3
&& color1
== color2
464 && color2
!= colorB2
)
465 product1a
= INTERPOLATE (color2
, color5
);
467 if (color4
== color2
&& color3
== color2
468 && color1
!= color5
&& color2
!= colorB0
)
469 product1a
= INTERPOLATE (color2
, color5
);
474 *(dP
+ (dstPitch
>> 2)) = product2a
;
475 *(dP
+ (dstPitch
>> 2) + 1) = product2b
;
479 } // end of for ( finish= width etc..)
482 dstPtr
+= dstPitch
<< 1;
483 // deltaPtr += srcPitch;
484 } // endof: for (; height; height--)
487 void SuperEagle (u8
*srcPtr
, u32 srcPitch
, u8
*deltaPtr
,
488 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
497 for (; height
; height
--) {
498 _2xSaISuperEagleLine (srcPtr
, deltaPtr
, srcPitch
, width
,
501 dstPtr
+= dstPitch
* 2;
502 deltaPtr
+= srcPitch
;
509 u32 Nextline
= srcPitch
>> 1;
511 for (; height
; height
--) {
513 xP
= (u16
*) deltaPtr
;
515 for (u32 finish
= width
; finish
; finish
-= inc_bP
) {
516 u32 color4
, color5
, color6
;
517 u32 color1
, color2
, color3
;
518 u32 colorA1
, colorA2
, colorB1
, colorB2
, colorS1
, colorS2
;
519 u32 product1a
, product1b
, product2a
, product2b
;
521 colorB1
= *(bP
- Nextline
);
522 colorB2
= *(bP
- Nextline
+ 1);
529 color1
= *(bP
+ Nextline
- 1);
530 color2
= *(bP
+ Nextline
);
531 color3
= *(bP
+ Nextline
+ 1);
532 colorS1
= *(bP
+ Nextline
+ 2);
534 colorA1
= *(bP
+ Nextline
+ Nextline
);
535 colorA2
= *(bP
+ Nextline
+ Nextline
+ 1);
537 // --------------------------------------
538 if (color2
== color6
&& color5
!= color3
) {
539 product1b
= product2a
= color2
;
540 if ((color1
== color2
) || (color6
== colorB2
)) {
541 product1a
= INTERPOLATE (color2
, color5
);
542 product1a
= INTERPOLATE (color2
, product1a
);
543 // product1a = color2;
545 product1a
= INTERPOLATE (color5
, color6
);
548 if ((color6
== colorS2
) || (color2
== colorA1
)) {
549 product2b
= INTERPOLATE (color2
, color3
);
550 product2b
= INTERPOLATE (color2
, product2b
);
551 // product2b = color2;
553 product2b
= INTERPOLATE (color2
, color3
);
555 } else if (color5
== color3
&& color2
!= color6
) {
556 product2b
= product1a
= color5
;
558 if ((colorB1
== color5
) || (color3
== colorS1
)) {
559 product1b
= INTERPOLATE (color5
, color6
);
560 product1b
= INTERPOLATE (color5
, product1b
);
561 // product1b = color5;
563 product1b
= INTERPOLATE (color5
, color6
);
566 if ((color3
== colorA2
) || (color4
== color5
)) {
567 product2a
= INTERPOLATE (color5
, color2
);
568 product2a
= INTERPOLATE (color5
, product2a
);
569 // product2a = color5;
571 product2a
= INTERPOLATE (color2
, color3
);
574 } else if (color5
== color3
&& color2
== color6
) {
577 r
+= GetResult (color6
, color5
, color1
, colorA1
);
578 r
+= GetResult (color6
, color5
, color4
, colorB1
);
579 r
+= GetResult (color6
, color5
, colorA2
, colorS1
);
580 r
+= GetResult (color6
, color5
, colorB2
, colorS2
);
583 product1b
= product2a
= color2
;
584 product1a
= product2b
= INTERPOLATE (color5
, color6
);
586 product2b
= product1a
= color5
;
587 product1b
= product2a
= INTERPOLATE (color5
, color6
);
589 product2b
= product1a
= color5
;
590 product1b
= product2a
= color2
;
593 product2b
= product1a
= INTERPOLATE (color2
, color6
);
595 Q_INTERPOLATE (color3
, color3
, color3
, product2b
);
597 Q_INTERPOLATE (color5
, color5
, color5
, product1a
);
599 product2a
= product1b
= INTERPOLATE (color5
, color3
);
601 Q_INTERPOLATE (color2
, color2
, color2
, product2a
);
603 Q_INTERPOLATE (color6
, color6
, color6
, product1b
);
605 // product1a = color5;
606 // product1b = color6;
607 // product2a = color2;
608 // product2b = color3;
610 #ifdef WORDS_BIGENDIAN
611 product1a
= (product1a
<< 16) | product1b
;
612 product2a
= (product2a
<< 16) | product2b
;
614 product1a
= product1a
| (product1b
<< 16);
615 product2a
= product2a
| (product2b
<< 16);
618 *((u32
*) dP
) = product1a
;
619 *((u32
*) (dP
+ dstPitch
)) = product2a
;
625 } // end of for ( finish= width etc..)
628 dstPtr
+= dstPitch
<< 1;
629 deltaPtr
+= srcPitch
;
630 } // endof: for (height; height; height--)
634 void SuperEagle32 (u8
*srcPtr
, u32 srcPitch
, u8
*deltaPtr
,
635 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
644 u32 Nextline
= srcPitch
>> 2;
646 for (; height
; height
--) {
648 xP
= (u32
*) deltaPtr
;
650 for (u32 finish
= width
; finish
; finish
-= inc_bP
) {
651 u32 color4
, color5
, color6
;
652 u32 color1
, color2
, color3
;
653 u32 colorA1
, colorA2
, colorB1
, colorB2
, colorS1
, colorS2
;
654 u32 product1a
, product1b
, product2a
, product2b
;
656 colorB1
= *(bP
- Nextline
);
657 colorB2
= *(bP
- Nextline
+ 1);
664 color1
= *(bP
+ Nextline
- 1);
665 color2
= *(bP
+ Nextline
);
666 color3
= *(bP
+ Nextline
+ 1);
667 colorS1
= *(bP
+ Nextline
+ 2);
669 colorA1
= *(bP
+ Nextline
+ Nextline
);
670 colorA2
= *(bP
+ Nextline
+ Nextline
+ 1);
672 // --------------------------------------
673 if (color2
== color6
&& color5
!= color3
) {
674 product1b
= product2a
= color2
;
675 if ((color1
== color2
) || (color6
== colorB2
)) {
676 product1a
= INTERPOLATE (color2
, color5
);
677 product1a
= INTERPOLATE (color2
, product1a
);
678 // product1a = color2;
680 product1a
= INTERPOLATE (color5
, color6
);
683 if ((color6
== colorS2
) || (color2
== colorA1
)) {
684 product2b
= INTERPOLATE (color2
, color3
);
685 product2b
= INTERPOLATE (color2
, product2b
);
686 // product2b = color2;
688 product2b
= INTERPOLATE (color2
, color3
);
690 } else if (color5
== color3
&& color2
!= color6
) {
691 product2b
= product1a
= color5
;
693 if ((colorB1
== color5
) || (color3
== colorS1
)) {
694 product1b
= INTERPOLATE (color5
, color6
);
695 product1b
= INTERPOLATE (color5
, product1b
);
696 // product1b = color5;
698 product1b
= INTERPOLATE (color5
, color6
);
701 if ((color3
== colorA2
) || (color4
== color5
)) {
702 product2a
= INTERPOLATE (color5
, color2
);
703 product2a
= INTERPOLATE (color5
, product2a
);
704 // product2a = color5;
706 product2a
= INTERPOLATE (color2
, color3
);
709 } else if (color5
== color3
&& color2
== color6
) {
712 r
+= GetResult (color6
, color5
, color1
, colorA1
);
713 r
+= GetResult (color6
, color5
, color4
, colorB1
);
714 r
+= GetResult (color6
, color5
, colorA2
, colorS1
);
715 r
+= GetResult (color6
, color5
, colorB2
, colorS2
);
718 product1b
= product2a
= color2
;
719 product1a
= product2b
= INTERPOLATE (color5
, color6
);
721 product2b
= product1a
= color5
;
722 product1b
= product2a
= INTERPOLATE (color5
, color6
);
724 product2b
= product1a
= color5
;
725 product1b
= product2a
= color2
;
728 product2b
= product1a
= INTERPOLATE (color2
, color6
);
730 Q_INTERPOLATE (color3
, color3
, color3
, product2b
);
732 Q_INTERPOLATE (color5
, color5
, color5
, product1a
);
734 product2a
= product1b
= INTERPOLATE (color5
, color3
);
736 Q_INTERPOLATE (color2
, color2
, color2
, product2a
);
738 Q_INTERPOLATE (color6
, color6
, color6
, product1b
);
740 // product1a = color5;
741 // product1b = color6;
742 // product2a = color2;
743 // product2b = color3;
747 *(dP
+ (dstPitch
>> 2)) = product2a
;
748 *(dP
+ (dstPitch
>> 2) +1) = product2b
;
754 } // end of for ( finish= width etc..)
757 dstPtr
+= dstPitch
<< 1;
758 deltaPtr
+= srcPitch
;
759 } // endof: for (height; height; height--)
762 void _2xSaI (u8
*srcPtr
, u32 srcPitch
, u8
*deltaPtr
,
763 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
771 for (; height
; height
-= 1) {
772 _2xSaILine (srcPtr
, deltaPtr
, srcPitch
, width
, dstPtr
, dstPitch
);
774 dstPtr
+= dstPitch
* 2;
775 deltaPtr
+= srcPitch
;
782 u32 Nextline
= srcPitch
>> 1;
784 for (; height
; height
--) {
788 for (u32 finish
= width
; finish
; finish
-= inc_bP
) {
790 register u32 colorA
, colorB
;
792 colorE
, colorF
, colorG
, colorH
,
793 colorI
, colorJ
, colorK
, colorL
,
795 colorM
, colorN
, colorO
, colorP
;
796 u32 product
, product1
, product2
;
798 //---------------------------------------
799 // Map of the pixels: I|E F|J
803 colorI
= *(bP
- Nextline
- 1);
804 colorE
= *(bP
- Nextline
);
805 colorF
= *(bP
- Nextline
+ 1);
806 colorJ
= *(bP
- Nextline
+ 2);
813 colorH
= *(bP
+ Nextline
- 1);
814 colorC
= *(bP
+ Nextline
);
815 colorD
= *(bP
+ Nextline
+ 1);
816 colorL
= *(bP
+ Nextline
+ 2);
818 colorM
= *(bP
+ Nextline
+ Nextline
- 1);
819 colorN
= *(bP
+ Nextline
+ Nextline
);
820 colorO
= *(bP
+ Nextline
+ Nextline
+ 1);
821 colorP
= *(bP
+ Nextline
+ Nextline
+ 2);
823 if ((colorA
== colorD
) && (colorB
!= colorC
)) {
824 if (((colorA
== colorE
) && (colorB
== colorL
)) ||
825 ((colorA
== colorC
) && (colorA
== colorF
)
826 && (colorB
!= colorE
) && (colorB
== colorJ
))) {
829 product
= INTERPOLATE (colorA
, colorB
);
832 if (((colorA
== colorG
) && (colorC
== colorO
)) ||
833 ((colorA
== colorB
) && (colorA
== colorH
)
834 && (colorG
!= colorC
) && (colorC
== colorM
))) {
837 product1
= INTERPOLATE (colorA
, colorC
);
840 } else if ((colorB
== colorC
) && (colorA
!= colorD
)) {
841 if (((colorB
== colorF
) && (colorA
== colorH
)) ||
842 ((colorB
== colorE
) && (colorB
== colorD
)
843 && (colorA
!= colorF
) && (colorA
== colorI
))) {
846 product
= INTERPOLATE (colorA
, colorB
);
849 if (((colorC
== colorH
) && (colorA
== colorF
)) ||
850 ((colorC
== colorG
) && (colorC
== colorD
)
851 && (colorA
!= colorH
) && (colorA
== colorI
))) {
854 product1
= INTERPOLATE (colorA
, colorC
);
857 } else if ((colorA
== colorD
) && (colorB
== colorC
)) {
858 if (colorA
== colorB
) {
865 product1
= INTERPOLATE (colorA
, colorC
);
866 product
= INTERPOLATE (colorA
, colorB
);
869 GetResult1 (colorA
, colorB
, colorG
, colorE
,
872 GetResult2 (colorB
, colorA
, colorK
, colorF
,
875 GetResult2 (colorB
, colorA
, colorH
, colorN
,
878 GetResult1 (colorA
, colorB
, colorL
, colorO
,
887 Q_INTERPOLATE (colorA
, colorB
, colorC
,
892 product2
= Q_INTERPOLATE (colorA
, colorB
, colorC
, colorD
);
894 if ((colorA
== colorC
) && (colorA
== colorF
)
895 && (colorB
!= colorE
) && (colorB
== colorJ
)) {
897 } else if ((colorB
== colorE
) && (colorB
== colorD
)
898 && (colorA
!= colorF
) && (colorA
== colorI
)) {
901 product
= INTERPOLATE (colorA
, colorB
);
904 if ((colorA
== colorB
) && (colorA
== colorH
)
905 && (colorG
!= colorC
) && (colorC
== colorM
)) {
907 } else if ((colorC
== colorG
) && (colorC
== colorD
)
908 && (colorA
!= colorH
) && (colorA
== colorI
)) {
911 product1
= INTERPOLATE (colorA
, colorC
);
915 #ifdef WORDS_BIGENDIAN
916 product
= (colorA
<< 16) | product
;
917 product1
= (product1
<< 16) | product2
;
919 product
= colorA
| (product
<< 16);
920 product1
= product1
| (product2
<< 16);
922 *((s32
*) dP
) = product
;
923 *((u32
*) (dP
+ dstPitch
)) = product1
;
927 } // end of for ( finish= width etc..)
930 dstPtr
+= dstPitch
<< 1;
931 deltaPtr
+= srcPitch
;
932 } // endof: for (height; height; height--)
936 void _2xSaI32 (u8
*srcPtr
, u32 srcPitch
, u8
* unused
/* deltaPtr */,
937 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
943 u32 Nextline
= srcPitch
>> 2;
945 for (; height
; height
--) {
949 for (u32 finish
= width
; finish
; finish
-= inc_bP
) {
950 register u32 colorA
, colorB
;
952 colorE
, colorF
, colorG
, colorH
,
953 colorI
, colorJ
, colorK
, colorL
,
955 colorM
, colorN
, colorO
, colorP
;
956 u32 product
, product1
, product2
;
958 //---------------------------------------
959 // Map of the pixels: I|E F|J
963 colorI
= *(bP
- Nextline
- 1);
964 colorE
= *(bP
- Nextline
);
965 colorF
= *(bP
- Nextline
+ 1);
966 colorJ
= *(bP
- Nextline
+ 2);
973 colorH
= *(bP
+ Nextline
- 1);
974 colorC
= *(bP
+ Nextline
);
975 colorD
= *(bP
+ Nextline
+ 1);
976 colorL
= *(bP
+ Nextline
+ 2);
978 colorM
= *(bP
+ Nextline
+ Nextline
- 1);
979 colorN
= *(bP
+ Nextline
+ Nextline
);
980 colorO
= *(bP
+ Nextline
+ Nextline
+ 1);
981 colorP
= *(bP
+ Nextline
+ Nextline
+ 2);
983 if ((colorA
== colorD
) && (colorB
!= colorC
)) {
984 if (((colorA
== colorE
) && (colorB
== colorL
)) ||
985 ((colorA
== colorC
) && (colorA
== colorF
)
986 && (colorB
!= colorE
) && (colorB
== colorJ
))) {
989 product
= INTERPOLATE (colorA
, colorB
);
992 if (((colorA
== colorG
) && (colorC
== colorO
)) ||
993 ((colorA
== colorB
) && (colorA
== colorH
)
994 && (colorG
!= colorC
) && (colorC
== colorM
))) {
997 product1
= INTERPOLATE (colorA
, colorC
);
1000 } else if ((colorB
== colorC
) && (colorA
!= colorD
)) {
1001 if (((colorB
== colorF
) && (colorA
== colorH
)) ||
1002 ((colorB
== colorE
) && (colorB
== colorD
)
1003 && (colorA
!= colorF
) && (colorA
== colorI
))) {
1006 product
= INTERPOLATE (colorA
, colorB
);
1009 if (((colorC
== colorH
) && (colorA
== colorF
)) ||
1010 ((colorC
== colorG
) && (colorC
== colorD
)
1011 && (colorA
!= colorH
) && (colorA
== colorI
))) {
1014 product1
= INTERPOLATE (colorA
, colorC
);
1017 } else if ((colorA
== colorD
) && (colorB
== colorC
)) {
1018 if (colorA
== colorB
) {
1025 product1
= INTERPOLATE (colorA
, colorC
);
1026 product
= INTERPOLATE (colorA
, colorB
);
1029 GetResult1 (colorA
, colorB
, colorG
, colorE
,
1032 GetResult2 (colorB
, colorA
, colorK
, colorF
,
1035 GetResult2 (colorB
, colorA
, colorH
, colorN
,
1038 GetResult1 (colorA
, colorB
, colorL
, colorO
,
1047 Q_INTERPOLATE (colorA
, colorB
, colorC
,
1052 product2
= Q_INTERPOLATE (colorA
, colorB
, colorC
, colorD
);
1054 if ((colorA
== colorC
) && (colorA
== colorF
)
1055 && (colorB
!= colorE
) && (colorB
== colorJ
)) {
1057 } else if ((colorB
== colorE
) && (colorB
== colorD
)
1058 && (colorA
!= colorF
) && (colorA
== colorI
)) {
1061 product
= INTERPOLATE (colorA
, colorB
);
1064 if ((colorA
== colorB
) && (colorA
== colorH
)
1065 && (colorG
!= colorC
) && (colorC
== colorM
)) {
1067 } else if ((colorC
== colorG
) && (colorC
== colorD
)
1068 && (colorA
!= colorH
) && (colorA
== colorI
)) {
1071 product1
= INTERPOLATE (colorA
, colorC
);
1075 *(dP
+ 1) = product
;
1076 *(dP
+ (dstPitch
>> 2)) = product1
;
1077 *(dP
+ (dstPitch
>> 2) + 1) = product2
;
1081 } // end of for ( finish= width etc..)
1084 dstPtr
+= dstPitch
<< 1;
1085 // deltaPtr += srcPitch;
1086 } // endof: for (height; height; height--)
1089 static u32
Bilinear (u32 A
, u32 B
, u32 x
)
1091 unsigned long areaA
, areaB
;
1092 unsigned long result
;
1097 areaB
= (x
>> 11) & 0x1f; // reduce 16 bit fraction to 5 bits
1098 areaA
= 0x20 - areaB
;
1100 A
= (A
& redblueMask
) | ((A
& greenMask
) << 16);
1101 B
= (B
& redblueMask
) | ((B
& greenMask
) << 16);
1103 result
= ((areaA
* A
) + (areaB
* B
)) >> 5;
1105 return (result
& redblueMask
) | ((result
>> 16) & greenMask
);
1108 static u32
Bilinear4 (u32 A
, u32 B
, u32 C
, u32 D
, u32 x
,
1111 unsigned long areaA
, areaB
, areaC
, areaD
;
1112 unsigned long result
, xy
;
1114 x
= (x
>> 11) & 0x1f;
1115 y
= (y
>> 11) & 0x1f;
1118 A
= (A
& redblueMask
) | ((A
& greenMask
) << 16);
1119 B
= (B
& redblueMask
) | ((B
& greenMask
) << 16);
1120 C
= (C
& redblueMask
) | ((C
& greenMask
) << 16);
1121 D
= (D
& redblueMask
) | ((D
& greenMask
) << 16);
1123 areaA
= 0x20 + xy
- x
- y
;
1128 result
= ((areaA
* A
) + (areaB
* B
) + (areaC
* C
) + (areaD
* D
)) >> 5;
1130 return (result
& redblueMask
) | ((result
>> 16) & greenMask
);
1133 void Scale_2xSaI (u8
*srcPtr
, u32 srcPitch
, u8
* unused
/* deltaPtr */,
1134 u8
*dstPtr
, u32 dstPitch
,
1135 u32 dstWidth
, u32 dstHeight
, int width
, int height
)
1147 u32 Nextline
= srcPitch
>> 1;
1149 wfinish
= (width
- 1) << 16; // convert to fixed point
1150 dw
= wfinish
/ (dstWidth
- 1);
1151 hfinish
= (height
- 1) << 16; // convert to fixed point
1152 dh
= hfinish
/ (dstHeight
- 1);
1154 for (h
= 0; h
< hfinish
; h
+= dh
) {
1157 y1
= h
& 0xffff; // fraction part of fixed point
1158 bP
= (u16
*) (srcPtr
+ ((h
>> 16) * srcPitch
));
1164 for (; w
< wfinish
;) {
1168 u32 x1
, x2
, a1
, f1
, f2
;
1169 u32 position
, product1
;
1172 A
= bP
[position
]; // current pixel
1173 B
= bP
[position
+ 1]; // next pixel
1174 C
= bP
[position
+ Nextline
];
1175 D
= bP
[position
+ Nextline
+ 1];
1176 E
= bP
[position
- Nextline
];
1177 F
= bP
[position
- Nextline
+ 1];
1178 G
= bP
[position
- 1];
1179 H
= bP
[position
+ Nextline
- 1];
1180 I
= bP
[position
+ 2];
1181 J
= bP
[position
+ Nextline
+ 2];
1182 K
= bP
[position
+ Nextline
+ Nextline
];
1183 L
= bP
[position
+ Nextline
+ Nextline
+ 1];
1185 x1
= w
& 0xffff; // fraction part of fixed point
1189 if (A
== B
&& C
== D
&& A
== C
)
1191 else /*1*/ if (A
== D
&& B
!= C
) {
1192 f1
= (x1
>> 1) + (0x10000 >> 2);
1193 f2
= (y1
>> 1) + (0x10000 >> 2);
1194 if (y1
<= f1
&& A
== J
&& A
!= E
) // close to B
1197 product1
= Bilinear (A
, B
, a1
);
1198 } else if (y1
>= f1
&& A
== G
&& A
!= L
) // close to C
1201 product1
= Bilinear (A
, C
, a1
);
1203 else if (x1
>= f2
&& A
== E
&& A
!= J
) // close to B
1206 product1
= Bilinear (A
, B
, a1
);
1208 else if (x1
<= f2
&& A
== L
&& A
!= G
) // close to C
1211 product1
= Bilinear (A
, C
, a1
);
1213 else if (y1
>= x1
) // close to C
1216 product1
= Bilinear (A
, C
, a1
);
1218 else if (y1
<= x1
) // close to B
1221 product1
= Bilinear (A
, B
, a1
);
1226 if (B
== C
&& A
!= D
)
1228 f1
= (x1
>> 1) + (0x10000 >> 2);
1229 f2
= (y1
>> 1) + (0x10000 >> 2);
1230 if (y2
>= f1
&& B
== H
&& B
!= F
) // close to A
1233 product1
= Bilinear (B
, A
, a1
);
1235 else if (y2
<= f1
&& B
== I
&& B
!= K
) // close to D
1238 product1
= Bilinear (B
, D
, a1
);
1240 else if (x2
>= f2
&& B
== F
&& B
!= H
) // close to A
1243 product1
= Bilinear (B
, A
, a1
);
1245 else if (x2
<= f2
&& B
== K
&& B
!= I
) // close to D
1248 product1
= Bilinear (B
, D
, a1
);
1250 else if (y2
>= x1
) // close to A
1253 product1
= Bilinear (B
, A
, a1
);
1255 else if (y2
<= x1
) // close to D
1258 product1
= Bilinear (B
, D
, a1
);
1264 product1
= Bilinear4 (A
, B
, C
, D
, x1
, y1
);
1268 *(u32
*) dP
= product1
;