1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
*
* Copyright (c) 2025 Lynne <dev@lynne.ee>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define LD(xo, yo) \
(imageLoad(input_img[0], pos + ivec2((xo), (yo))).r)
void debayer_bilinear(void)
{
ivec2 pos = ivec2(gl_GlobalInvocationID.xy) << 1;
/* R basis */
vec4 tl = vec4(LD(0, 0),
(LD(1, 0) + LD(-1, 0) + LD(0, 1) + LD(0, -1)) / 4.0f,
(LD(-1, -1) + LD(1, 1) + LD(-1, 1) + LD(1, -1)) / 4.0f,
1.0f);
imageStore(output_img[0], pos, tl);
/* G1 basis */
vec4 tr = vec4((LD(2, 0) + LD(0, 0)) / 2.0f,
LD(1, 0),
(LD(1, 1) + LD(1, -1)) / 2.0f,
1.0f);
imageStore(output_img[0], pos + ivec2(1, 0), tr);
/* G2 basis */
vec4 bl = vec4((LD(0, 2) + LD(0, 0)) / 2.0f,
LD(0, 1),
(LD(1, 1) + LD(-1, 1)) / 2.0f,
1.0f);
imageStore(output_img[0], pos + ivec2(0, 1), bl);
/* B basis */
vec4 br = vec4((LD(0, 0) + LD(2, 2) + LD(0, 2) + LD(2, 0)) / 4.0f,
(LD(2, 1) + LD(0, 1) + LD(1, 2) + LD(1, 0)) / 4.0f,
LD(1, 1),
1.0f);
imageStore(output_img[0], pos + ivec2(1, 1), br);
}
void debayer_bilinear_hq(void)
{
ivec2 pos = ivec2(gl_GlobalInvocationID.xy) << 1;
/* R basis */
vec4 tl = vec4(LD(0, 0),
(4.0f*LD(0, 0) + 2.0f*(LD(0, -1) + LD(0, 1) + LD(-1, 0) + LD(1, 0)) -
(LD(0, -2) + LD(0, 2) + LD(-2, 0) + LD(2, 0))) / 8.0f,
(12.0f*LD(0, 0) + 4.0f*(LD(-1, -1) + LD(-1, 1) + LD(1, -1) + LD(1, 1)) -
3.0f*(LD(0, -2) + LD(0, 2) + LD(-2, 0) + LD(2, 0))) / 16.0f,
1.0f);
imageStore(output_img[0], pos, tl);
/* G1 basis */
vec4 tr = vec4((10.0f*LD(1, 0) + 8.0f*(LD(0, 0) + LD(2, 0)) -
2.0f*(LD(0, -1) + LD(2, 1) + LD(0, 1) + LD(2, -1) + LD(-1, 0) + LD(3, 0)) +
LD(1, -2) + LD(1, 2)) / 16.0f,
LD(1, 0),
(10.0f*LD(1, 0) + 8.0f*(LD(1, -1) + LD(1, 1)) -
2.0f*(LD(0, -1) + LD(0, 1) + LD(2, -1) + LD(2, 1) + LD(1, -2) + LD(1, 2)) +
LD(-1, 0) + LD(3, 0)) / 16.0f,
1.0f);
imageStore(output_img[0], pos + ivec2(1, 0), tr);
/* G2 basis */
vec4 bl = vec4((10.0f*LD(0, 1) + 8.0f*(LD(0, 0) + LD(0, 2)) -
2.0f*(LD(-1, 0) + LD(-1, 2) + LD(1, 0) + LD(1, 2) + LD(0, -1) + LD(0, 3)) +
LD(-2, 1) + LD(2, 1)) / 16.0f,
LD(0, 1),
(10.0f*LD(0, 1) + 8.0f*(LD(-1, 1) + LD(1, 1)) -
2.0f*(LD(-1, 0) + LD(1, 2) + LD(-1, 2) + LD(1, 0) + LD(-2, 1) + LD(2, 1)) +
LD(0, -1) + LD(0, 3)) / 16.0f,
1.0f);
imageStore(output_img[0], pos + ivec2(0, 1), bl);
/* B basis */
vec4 br = vec4((12.0f*LD(1, 1) + 4.0f*(LD(0, 0) + LD(0, 2) + LD(2, 0) + LD(2, 2)) -
3.0f*(LD(1, -1) + LD(1, 3) + LD(-1, 1) + LD(3, 1))) / 16.0f,
(4.0f*LD(1, 1) + 2.0f*(LD(1, 0) + LD(1, 2) + LD(0, 1) + LD(2, 1)) -
(LD(1, -1) + LD(1, 3) + LD(-1, 1) + LD(3, 1))) / 8.0f,
LD(1, 1),
1.0f);
imageStore(output_img[0], pos + ivec2(1, 1), br);
}
|