Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/jxr/image/sys/strTransform.c
4393 views
1
//*@@@+++@@@@******************************************************************
2
//
3
// Copyright © Microsoft Corp.
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
//
9
// • Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// • Redistributions in binary form must reproduce the above copyright notice,
12
// this list of conditions and the following disclaimer in the documentation
13
// and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
// POSSIBILITY OF SUCH DAMAGE.
26
//
27
//*@@@---@@@@******************************************************************
28
29
#include "strTransform.h"
30
31
/** need to swap b and c **/
32
/** rounding behavior: [0 0 0 0] <-> [+ - - -]
33
[+ + + +] <-> [+3/4 - - -]
34
[- - - -] <-> [- - - -] **/
35
Void strDCT2x2dn(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
36
{
37
PixelI a, b, c, d, C, t;
38
a = *pa;
39
b = *pb;
40
C = *pc;
41
d = *pd;
42
43
a += d;
44
b -= C;
45
t = ((a - b) >> 1);
46
c = t - d;
47
d = t - C;
48
a -= d;
49
b += c;
50
51
*pa = a;
52
*pb = b;
53
*pc = c;
54
*pd = d;
55
}
56
57
Void strDCT2x2up(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
58
{
59
PixelI a, b, c, d, C, t;
60
a = *pa;
61
b = *pb;
62
C = *pc;
63
d = *pd;
64
65
a += d;
66
b -= C;
67
t = ((a - b + 1) >> 1);
68
c = t - d;
69
d = t - C;
70
a -= d;
71
b += c;
72
73
*pa = a;
74
*pb = b;
75
*pc = c;
76
*pd = d;
77
}
78
79
Void FOURBUTTERFLY_HARDCODED1(PixelI *p)
80
{
81
strDCT2x2dn(&p[0], &p[4], &p[8], &p[12]);
82
strDCT2x2dn(&p[1], &p[5], &p[9], &p[13]);
83
strDCT2x2dn(&p[2], &p[6], &p[10], &p[14]);
84
strDCT2x2dn(&p[3], &p[7], &p[11], &p[15]);
85
}
86
87