2 * This file is part of the Advance project.
4 * Copyright (C) 2003 Andrea Mazzoleni
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * In addition, as a special exception, Andrea Mazzoleni
21 * gives permission to link the code of this program with
22 * the MAME library (or with modified versions of MAME that use the
23 * same license as MAME), and distribute linked combinations including
24 * the two. You must obey the GNU General Public License in all
25 * respects for all of the code used other than MAME. If you modify
26 * this file, you may extend this exception to your version of the
27 * file, but you are not obligated to do so. If you do not wish to
28 * do so, delete this exception statement from your version.
33 /***************************************************************************/
34 /* HQ2x C implementation */
37 * This effect is a rewritten implementation of the hq2x effect made by Maxim Stepin
40 static void hq2x_16_def(u16
* dst0
, u16
* dst1
, const u16
* src0
, const u16
* src1
, const u16
* src2
, unsigned count
)
44 for(i
=0;i
<count
;++i
) {
75 if (interp_16_diff(c
[0], c
[4]))
77 if (interp_16_diff(c
[1], c
[4]))
79 if (interp_16_diff(c
[2], c
[4]))
81 if (interp_16_diff(c
[3], c
[4]))
83 if (interp_16_diff(c
[5], c
[4]))
85 if (interp_16_diff(c
[6], c
[4]))
87 if (interp_16_diff(c
[7], c
[4]))
89 if (interp_16_diff(c
[8], c
[4]))
96 #define MUR interp_16_diff(c[1], c[5])
97 #define MDR interp_16_diff(c[5], c[7])
98 #define MDL interp_16_diff(c[7], c[3])
99 #define MUL interp_16_diff(c[3], c[1])
101 #define I11(p0,p1) interp_16_11(c[p0], c[p1])
102 #define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2])
103 #define I31(p0,p1) interp_16_31(c[p0], c[p1])
104 #define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2])
105 #define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2])
106 #define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2])
107 #define I53(p0,p1) interp_16_53(c[p0], c[p1])
108 #define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2])
109 #define I71(p0,p1) interp_16_71(c[p0], c[p1])
110 #define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2])
111 #define I97(p0,p1) interp_16_97(c[p0], c[p1])
112 #define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2])
113 #define I151(p0,p1) interp_16_151(c[p0], c[p1])
150 static void hq2x_32_def(u32
* dst0
, u32
* dst1
, const u32
* src0
, const u32
* src1
, const u32
* src2
, unsigned count
)
154 for(i
=0;i
<count
;++i
) {
185 if (interp_32_diff(c
[0], c
[4]))
187 if (interp_32_diff(c
[1], c
[4]))
189 if (interp_32_diff(c
[2], c
[4]))
191 if (interp_32_diff(c
[3], c
[4]))
193 if (interp_32_diff(c
[5], c
[4]))
195 if (interp_32_diff(c
[6], c
[4]))
197 if (interp_32_diff(c
[7], c
[4]))
199 if (interp_32_diff(c
[8], c
[4]))
206 #define MUR interp_32_diff(c[1], c[5])
207 #define MDR interp_32_diff(c[5], c[7])
208 #define MDL interp_32_diff(c[7], c[3])
209 #define MUL interp_32_diff(c[3], c[1])
211 #define I11(p0,p1) interp_32_11(c[p0], c[p1])
212 #define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
213 #define I31(p0,p1) interp_32_31(c[p0], c[p1])
214 #define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
215 #define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
216 #define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
217 #define I53(p0,p1) interp_32_53(c[p0], c[p1])
218 #define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
219 #define I71(p0,p1) interp_32_71(c[p0], c[p1])
220 #define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
221 #define I97(p0,p1) interp_32_97(c[p0], c[p1])
222 #define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
223 #define I151(p0,p1) interp_32_151(c[p0], c[p1])
260 /***************************************************************************/
261 /* LQ2x C implementation */
264 * This effect is derived from the hq2x effect made by Maxim Stepin
267 static void lq2x_16_def(u16
* dst0
, u16
* dst1
, const u16
* src0
, const u16
* src1
, const u16
* src2
, unsigned count
)
271 for(i
=0;i
<count
;++i
) {
323 #define MUR (c[1] != c[5])
324 #define MDR (c[5] != c[7])
325 #define MDL (c[7] != c[3])
326 #define MUL (c[3] != c[1])
328 #define I11(p0,p1) interp_16_11(c[p0], c[p1])
329 #define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2])
330 #define I31(p0,p1) interp_16_31(c[p0], c[p1])
331 #define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2])
332 #define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2])
333 #define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2])
334 #define I53(p0,p1) interp_16_53(c[p0], c[p1])
335 #define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2])
336 #define I71(p0,p1) interp_16_71(c[p0], c[p1])
337 #define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2])
338 #define I97(p0,p1) interp_16_97(c[p0], c[p1])
339 #define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2])
340 #define I151(p0,p1) interp_16_151(c[p0], c[p1])
377 static void lq2x_32_def(u32
* dst0
, u32
* dst1
, const u32
* src0
, const u32
* src1
, const u32
* src2
, unsigned count
)
381 for(i
=0;i
<count
;++i
) {
433 #define MUR (c[1] != c[5])
434 #define MDR (c[5] != c[7])
435 #define MDL (c[7] != c[3])
436 #define MUL (c[3] != c[1])
438 #define I11(p0,p1) interp_32_11(c[p0], c[p1])
439 #define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
440 #define I31(p0,p1) interp_32_31(c[p0], c[p1])
441 #define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
442 #define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
443 #define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
444 #define I53(p0,p1) interp_32_53(c[p0], c[p1])
445 #define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
446 #define I71(p0,p1) interp_32_71(c[p0], c[p1])
447 #define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
448 #define I97(p0,p1) interp_32_97(c[p0], c[p1])
449 #define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
450 #define I151(p0,p1) interp_32_151(c[p0], c[p1])
487 void hq2x(u8
*srcPtr
, u32 srcPitch
, u8
* /* deltaPtr */,
488 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
490 u16
*dst0
= (u16
*)dstPtr
;
491 u16
*dst1
= dst0
+ (dstPitch
>> 1);
493 u16
*src0
= (u16
*)srcPtr
;
494 u16
*src1
= src0
+ (srcPitch
>> 1);
495 u16
*src2
= src1
+ (srcPitch
>> 1);
497 hq2x_16_def(dst0
, dst1
, src0
, src0
, src1
, width
);
505 hq2x_16_def(dst0
, dst1
, src0
, src1
, src2
, width
);
508 src2
+= srcPitch
>> 1;
513 hq2x_16_def(dst0
, dst1
, src0
, src1
, src1
, width
);
516 void hq2x32(u8
*srcPtr
, u32 srcPitch
, u8
* /* deltaPtr */,
517 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
519 u32
*dst0
= (u32
*)dstPtr
;
520 u32
*dst1
= dst0
+ (dstPitch
>> 2);
522 u32
*src0
= (u32
*)srcPtr
;
523 u32
*src1
= src0
+ (srcPitch
>> 2);
524 u32
*src2
= src1
+ (srcPitch
>> 2);
525 hq2x_32_def(dst0
, dst1
, src0
, src0
, src1
, width
);
531 dst0
+= dstPitch
>> 1;
532 dst1
+= dstPitch
>> 1;
533 hq2x_32_def(dst0
, dst1
, src0
, src1
, src2
, width
);
536 src2
+= srcPitch
>> 2;
539 dst0
+= dstPitch
>> 1;
540 dst1
+= dstPitch
>> 1;
541 hq2x_32_def(dst0
, dst1
, src0
, src1
, src1
, width
);
544 void lq2x(u8
*srcPtr
, u32 srcPitch
, u8
* /* deltaPtr */,
545 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
547 u16
*dst0
= (u16
*)dstPtr
;
548 u16
*dst1
= dst0
+ (dstPitch
>> 1);
550 u16
*src0
= (u16
*)srcPtr
;
551 u16
*src1
= src0
+ (srcPitch
>> 1);
552 u16
*src2
= src1
+ (srcPitch
>> 1);
554 lq2x_16_def(dst0
, dst1
, src0
, src0
, src1
, width
);
562 lq2x_16_def(dst0
, dst1
, src0
, src1
, src2
, width
);
565 src2
+= srcPitch
>> 1;
570 lq2x_16_def(dst0
, dst1
, src0
, src1
, src1
, width
);
573 void lq2x32(u8
*srcPtr
, u32 srcPitch
, u8
* /* deltaPtr */,
574 u8
*dstPtr
, u32 dstPitch
, int width
, int height
)
576 u32
*dst0
= (u32
*)dstPtr
;
577 u32
*dst1
= dst0
+ (dstPitch
>> 2);
579 u32
*src0
= (u32
*)srcPtr
;
580 u32
*src1
= src0
+ (srcPitch
>> 2);
581 u32
*src2
= src1
+ (srcPitch
>> 2);
582 lq2x_32_def(dst0
, dst1
, src0
, src0
, src1
, width
);
588 dst0
+= dstPitch
>> 1;
589 dst1
+= dstPitch
>> 1;
590 lq2x_32_def(dst0
, dst1
, src0
, src1
, src2
, width
);
593 src2
+= srcPitch
>> 2;
596 dst0
+= dstPitch
>> 1;
597 dst1
+= dstPitch
>> 1;
598 lq2x_32_def(dst0
, dst1
, src0
, src1
, src1
, width
);
601 void hq2x_init(unsigned bits_per_pixel
)
603 interp_set(bits_per_pixel
);