annotate libmpcodecs/vf_2xsai.c @ 25861:5442946cade2

Fix illegal identifiers, names starting with __ are reserved for the system.
author diego
date Sun, 27 Jan 2008 18:01:19 +0000
parents 7d5b292b8ade
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
1 #include <stdio.h>
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
2 #include <stdlib.h>
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
3 #include <string.h>
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
4 #include <inttypes.h>
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
5
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
7 #include "mp_msg.h"
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
8
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
9 #include "img_format.h"
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
10 #include "mp_image.h"
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
11 #include "vf.h"
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
12
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
13 //===========================================================================//
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
14
24785
230123782da0 reminder that this filter has broken global vars
rfelker
parents: 17906
diff changeset
15 /* FIXME: these all belong in the context, not as globals! */
230123782da0 reminder that this filter has broken global vars
rfelker
parents: 17906
diff changeset
16
25003
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
17 static uint32_t colorMask = 0xF7DEF7DE;
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
18 static uint32_t lowPixelMask = 0x08210821;
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
19 static uint32_t qcolorMask = 0xE79CE79C;
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
20 static uint32_t qlowpixelMask = 0x18631863;
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
21 static uint32_t redblueMask = 0xF81F;
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
22 static uint32_t greenMask = 0x7E0;
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
23 static int PixelsPerMask = 2;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
24
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
25 #define makecol(r,g,b) (r+(g<<8)+(b<<16))
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
26 #define makecol_depth(d,r,g,b) (r+(g<<8)+(b<<16))
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
27
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
28 int Init_2xSaI(int d)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
29 {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
30
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
31 int minr = 0, ming = 0, minb = 0;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
32 int i;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
33
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
34 // if (d != 15 && d != 16 && d != 24 && d != 32)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
35 // return -1;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
36
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
37 /* Get lowest color bit */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
38 for (i = 0; i < 255; i++) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
39 if (!minr)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
40 minr = makecol(i, 0, 0);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
41 if (!ming)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
42 ming = makecol(0, i, 0);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
43 if (!minb)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
44 minb = makecol(0, 0, i);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
45 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
46
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
47 colorMask = (makecol_depth(d, 255, 0, 0) - minr) | (makecol_depth(d, 0, 255, 0) - ming) | (makecol_depth(d, 0, 0, 255) - minb);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
48 lowPixelMask = minr | ming | minb;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
49 qcolorMask = (makecol_depth(d, 255, 0, 0) - 3 * minr) | (makecol_depth(d, 0, 255, 0) - 3 * ming) | (makecol_depth(d, 0, 0, 255) - 3 * minb);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
50 qlowpixelMask = (minr * 3) | (ming * 3) | (minb * 3);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
51 redblueMask = makecol_depth(d, 255, 0, 255);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
52 greenMask = makecol_depth(d, 0, 255, 0);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
53
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
54 PixelsPerMask = (d <= 16) ? 2 : 1;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
55
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
56 if (PixelsPerMask == 2) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
57 colorMask |= (colorMask << 16);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
58 qcolorMask |= (qcolorMask << 16);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
59 lowPixelMask |= (lowPixelMask << 16);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
60 qlowpixelMask |= (qlowpixelMask << 16);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
61 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
62
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
63 // TRACE("Color Mask: 0x%lX\n", colorMask);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
64 // TRACE("Low Pixel Mask: 0x%lX\n", lowPixelMask);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
65 // TRACE("QColor Mask: 0x%lX\n", qcolorMask);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
66 // TRACE("QLow Pixel Mask: 0x%lX\n", qlowpixelMask);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
67
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
68 return 0;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
69 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
70
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
71
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
72 #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D))
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
73
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
74 #define INTERPOLATE(A, B) (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + (A & B & lowPixelMask))
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
75
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
76 #define Q_INTERPOLATE(A, B, C, D) ((A & qcolorMask) >> 2) + ((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2) \
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
77 + ((((A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask)) >> 2) & qlowpixelMask)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
78
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
79
25003
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
80 void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch,
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
81 uint8_t *dst, uint32_t dst_pitch,
c79fa5c75d4e Use proper inttypes.h types instead of broken uint32 etc. defines
reimar
parents: 24863
diff changeset
82 uint32_t width, uint32_t height, int sbpp) {
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
83
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
84 unsigned int x, y;
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
85 uint32_t color[16];
25669
f38acc6feffe Move uselessly global variables
reimar
parents: 25221
diff changeset
86 unsigned char *src_line[4];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
87
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
88 /* Point to the first 3 lines. */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
89 src_line[0] = src;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
90 src_line[1] = src;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
91 src_line[2] = src + src_pitch;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
92 src_line[3] = src + src_pitch * 2;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
93
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
94 x = 0, y = 0;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
95
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
96 if (PixelsPerMask == 2) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
97 unsigned short *sbp;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
98 sbp = (unsigned short*)src_line[0];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
99 color[0] = *sbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
100 color[4] = color[0]; color[5] = color[0]; color[6] = *(sbp + 1); color[7] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
101 sbp = (unsigned short*)src_line[2];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
102 color[8] = *sbp; color[9] = color[8]; color[10] = *(sbp + 1); color[11] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
103 sbp = (unsigned short*)src_line[3];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
104 color[12] = *sbp; color[13] = color[12]; color[14] = *(sbp + 1); color[15] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
105 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
106 else {
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
107 uint32_t *lbp;
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
108 lbp = (uint32_t*)src_line[0];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
109 color[0] = *lbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
110 color[4] = color[0]; color[5] = color[0]; color[6] = *(lbp + 1); color[7] = *(lbp + 2);
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
111 lbp = (uint32_t*)src_line[2];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
112 color[8] = *lbp; color[9] = color[8]; color[10] = *(lbp + 1); color[11] = *(lbp + 2);
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
113 lbp = (uint32_t*)src_line[3];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
114 color[12] = *lbp; color[13] = color[12]; color[14] = *(lbp + 1); color[15] = *(lbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
115 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
116
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
117 for (y = 0; y < height; y++) {
25669
f38acc6feffe Move uselessly global variables
reimar
parents: 25221
diff changeset
118 unsigned char *dst_line[2];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
119
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
120 dst_line[0] = dst + dst_pitch*2*y;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
121 dst_line[1] = dst + dst_pitch*(2*y+1);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
122
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
123 /* Todo: x = width - 2, x = width - 1 */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
124
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
125 for (x = 0; x < width; x++) {
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
126 uint32_t product1a, product1b, product2a, product2b;
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
127
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
128 //--------------------------------------- B0 B1 B2 B3 0 1 2 3
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
129 // 4 5* 6 S2 -> 4 5* 6 7
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
130 // 1 2 3 S1 8 9 10 11
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
131 // A0 A1 A2 A3 12 13 14 15
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
132 //--------------------------------------
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
133 if (color[9] == color[6] && color[5] != color[10]) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
134 product2b = color[9];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
135 product1b = product2b;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
136 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
137 else if (color[5] == color[10] && color[9] != color[6]) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
138 product2b = color[5];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
139 product1b = product2b;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
140 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
141 else if (color[5] == color[10] && color[9] == color[6]) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
142 int r = 0;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
143
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
144 r += GET_RESULT(color[6], color[5], color[8], color[13]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
145 r += GET_RESULT(color[6], color[5], color[4], color[1]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
146 r += GET_RESULT(color[6], color[5], color[14], color[11]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
147 r += GET_RESULT(color[6], color[5], color[2], color[7]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
148
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
149 if (r > 0)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
150 product1b = color[6];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
151 else if (r < 0)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
152 product1b = color[5];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
153 else
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
154 product1b = INTERPOLATE(color[5], color[6]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
155
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
156 product2b = product1b;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
157
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
158 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
159 else {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
160 if (color[6] == color[10] && color[10] == color[13] && color[9] != color[14] && color[10] != color[12])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
161 product2b = Q_INTERPOLATE(color[10], color[10], color[10], color[9]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
162 else if (color[5] == color[9] && color[9] == color[14] && color[13] != color[10] && color[9] != color[15])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
163 product2b = Q_INTERPOLATE(color[9], color[9], color[9], color[10]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
164 else
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
165 product2b = INTERPOLATE(color[9], color[10]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
166
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
167 if (color[6] == color[10] && color[6] == color[1] && color[5] != color[2] && color[6] != color[0])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
168 product1b = Q_INTERPOLATE(color[6], color[6], color[6], color[5]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
169 else if (color[5] == color[9] && color[5] == color[2] && color[1] != color[6] && color[5] != color[3])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
170 product1b = Q_INTERPOLATE(color[6], color[5], color[5], color[5]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
171 else
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
172 product1b = INTERPOLATE(color[5], color[6]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
173 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
174
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
175 if (color[5] == color[10] && color[9] != color[6] && color[4] == color[5] && color[5] != color[14])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
176 product2a = INTERPOLATE(color[9], color[5]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
177 else if (color[5] == color[8] && color[6] == color[5] && color[4] != color[9] && color[5] != color[12])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
178 product2a = INTERPOLATE(color[9], color[5]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
179 else
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
180 product2a = color[9];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
181
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
182 if (color[9] == color[6] && color[5] != color[10] && color[8] == color[9] && color[9] != color[2])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
183 product1a = INTERPOLATE(color[9], color[5]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
184 else if (color[4] == color[9] && color[10] == color[9] && color[8] != color[5] && color[9] != color[0])
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
185 product1a = INTERPOLATE(color[9], color[5]);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
186 else
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
187 product1a = color[5];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
188
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
189 if (PixelsPerMask == 2) {
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
190 *((uint32_t *) (&dst_line[0][x * 4])) = product1a | (product1b << 16);
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
191 *((uint32_t *) (&dst_line[1][x * 4])) = product2a | (product2b << 16);
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
192 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
193 else {
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
194 *((uint32_t *) (&dst_line[0][x * 8])) = product1a;
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
195 *((uint32_t *) (&dst_line[0][x * 8 + 4])) = product1b;
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
196 *((uint32_t *) (&dst_line[1][x * 8])) = product2a;
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
197 *((uint32_t *) (&dst_line[1][x * 8 + 4])) = product2b;
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
198 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
199
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
200 /* Move color matrix forward */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
201 color[0] = color[1]; color[4] = color[5]; color[8] = color[9]; color[12] = color[13];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
202 color[1] = color[2]; color[5] = color[6]; color[9] = color[10]; color[13] = color[14];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
203 color[2] = color[3]; color[6] = color[7]; color[10] = color[11]; color[14] = color[15];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
204
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
205 if (x < width - 3) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
206 x += 3;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
207 if (PixelsPerMask == 2) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
208 color[3] = *(((unsigned short*)src_line[0]) + x);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
209 color[7] = *(((unsigned short*)src_line[1]) + x);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
210 color[11] = *(((unsigned short*)src_line[2]) + x);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
211 color[15] = *(((unsigned short*)src_line[3]) + x);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
212 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
213 else {
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
214 color[3] = *(((uint32_t*)src_line[0]) + x);
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
215 color[7] = *(((uint32_t*)src_line[1]) + x);
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
216 color[11] = *(((uint32_t*)src_line[2]) + x);
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
217 color[15] = *(((uint32_t*)src_line[3]) + x);
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
218 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
219 x -= 3;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
220 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
221 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
222
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
223 /* We're done with one line, so we shift the source lines up */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
224 src_line[0] = src_line[1];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
225 src_line[1] = src_line[2];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
226 src_line[2] = src_line[3];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
227
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
228 /* Read next line */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
229 if (y + 3 >= height)
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
230 src_line[3] = src_line[2];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
231 else
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
232 src_line[3] = src_line[2] + src_pitch;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
233
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
234 /* Then shift the color matrix up */
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
235 if (PixelsPerMask == 2) {
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
236 unsigned short *sbp;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
237 sbp = (unsigned short*)src_line[0];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
238 color[0] = *sbp; color[1] = color[0]; color[2] = *(sbp + 1); color[3] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
239 sbp = (unsigned short*)src_line[1];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
240 color[4] = *sbp; color[5] = color[4]; color[6] = *(sbp + 1); color[7] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
241 sbp = (unsigned short*)src_line[2];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
242 color[8] = *sbp; color[9] = color[9]; color[10] = *(sbp + 1); color[11] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
243 sbp = (unsigned short*)src_line[3];
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
244 color[12] = *sbp; color[13] = color[12]; color[14] = *(sbp + 1); color[15] = *(sbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
245 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
246 else {
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
247 uint32_t *lbp;
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
248 lbp = (uint32_t*)src_line[0];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
249 color[0] = *lbp; color[1] = color[0]; color[2] = *(lbp + 1); color[3] = *(lbp + 2);
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
250 lbp = (uint32_t*)src_line[1];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
251 color[4] = *lbp; color[5] = color[4]; color[6] = *(lbp + 1); color[7] = *(lbp + 2);
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
252 lbp = (uint32_t*)src_line[2];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
253 color[8] = *lbp; color[9] = color[9]; color[10] = *(lbp + 1); color[11] = *(lbp + 2);
25004
98ca15113cc6 Replace stupid "unsigned long" by the correct uint32_t.
reimar
parents: 25003
diff changeset
254 lbp = (uint32_t*)src_line[3];
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
255 color[12] = *lbp; color[13] = color[12]; color[14] = *(lbp + 1); color[15] = *(lbp + 2);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
256 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
257
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
258 } // y loop
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
259
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
260 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
261
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
262
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
263 //===========================================================================//
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
264
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
265 static int config(struct vf_instance_s* vf,
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
266 int width, int height, int d_width, int d_height,
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
267 unsigned int flags, unsigned int outfmt){
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
268
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
269 Init_2xSaI(outfmt&255);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
270
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
271 return vf_next_config(vf,2*width,2*height,2*d_width,2*d_height,flags,outfmt);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
272 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
273
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
274 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
275 mp_image_t *dmpi;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
276
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
277 // hope we'll get DR buffer:
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
278 dmpi=vf_get_image(vf->next,mpi->imgfmt,
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
279 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
280 2*mpi->w, 2*mpi->h);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
281
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
282 Super2xSaI_ex(mpi->planes[0], mpi->stride[0],
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
283 dmpi->planes[0], dmpi->stride[0],
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
284 mpi->w, mpi->h, mpi->bpp/8);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
285
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
286 return vf_next_put_image(vf,dmpi, pts);
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
287 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
288
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
289 //===========================================================================//
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
290
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
291 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
292 switch(fmt){
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
293 // case IMGFMT_BGR15:
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
294 // case IMGFMT_BGR16:
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
295 case IMGFMT_BGR32:
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
296 return vf_next_query_format(vf,fmt);
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
297 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
298 return 0;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
299 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
300
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
301 static int open(vf_instance_t *vf, char* args){
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
302 vf->config=config;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
303 vf->put_image=put_image;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
304 vf->query_format=query_format;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
305 return 1;
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
306 }
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
307
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 25004
diff changeset
308 const vf_info_t vf_info_2xsai = {
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
309 "2xSai BGR bitmap 2x scaler",
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
310 "2xsai",
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
311 "A'rpi",
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
312 "http://elektron.its.tudelft.nl/~dalikifa/",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8123
diff changeset
313 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8123
diff changeset
314 NULL
7919
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
315 };
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
316
b8acdbfd0882 2xSai filter... just for fun, imho useless
arpi
parents:
diff changeset
317 //===========================================================================//