Cycles Denoising: Add more robust outlier heuristic to avoid artifacts
[blender.git] / intern / cycles / kernel / kernels / cpu / filter_cpu.h
1 /*
2  * Copyright 2011-2017 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /* Templated common declaration part of all CPU kernels. */
18
19 void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample,
20                                                      TilesInfo *tiles,
21                                                      int x,
22                                                      int y,
23                                                      float *unfilteredA,
24                                                      float *unfilteredB,
25                                                      float *sampleV,
26                                                      float *sampleVV,
27                                                      float *bufferV,
28                                                      int* prefilter_rect,
29                                                      int buffer_pass_stride,
30                                                      int buffer_denoising_offset,
31                                                      bool use_split_variance);
32
33 void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample,
34                                                    TilesInfo *tiles,
35                                                    int m_offset,
36                                                    int v_offset,
37                                                    int x,
38                                                    int y,
39                                                    float *mean,
40                                                    float *variance,
41                                                    int* prefilter_rect,
42                                                    int buffer_pass_stride,
43                                                    int buffer_denoising_offset,
44                                                    bool use_split_variance);
45
46 void KERNEL_FUNCTION_FULL_NAME(filter_detect_outliers)(int x, int y,
47                                                        ccl_global float *image,
48                                                        ccl_global float *variance,
49                                                        ccl_global float *depth,
50                                                        ccl_global float *output,
51                                                        int *rect,
52                                                        int pass_stride);
53
54 void KERNEL_FUNCTION_FULL_NAME(filter_combine_halves)(int x, int y,
55                                                       float *mean,
56                                                       float *variance,
57                                                       float *a,
58                                                       float *b,
59                                                       int* prefilter_rect,
60                                                       int r);
61
62 void KERNEL_FUNCTION_FULL_NAME(filter_construct_transform)(float* buffer,
63                                                            int x,
64                                                            int y,
65                                                            int storage_ofs,
66                                                            float *transform,
67                                                            int *rank,
68                                                            int* rect,
69                                                            int pass_stride,
70                                                            int radius,
71                                                            float pca_threshold);
72
73 void KERNEL_FUNCTION_FULL_NAME(filter_nlm_calc_difference)(int dx,
74                                                            int dy,
75                                                            float *weightImage,
76                                                            float *variance,
77                                                            float *differenceImage,
78                                                            int* rect,
79                                                            int w,
80                                                            int channel_offset,
81                                                            float a,
82                                                            float k_2);
83
84 void KERNEL_FUNCTION_FULL_NAME(filter_nlm_blur)(float *differenceImage,
85                                                 float *outImage,
86                                                 int* rect,
87                                                 int w,
88                                                 int f);
89
90 void KERNEL_FUNCTION_FULL_NAME(filter_nlm_calc_weight)(float *differenceImage,
91                                                        float *outImage,
92                                                        int* rect,
93                                                        int w,
94                                                        int f);
95
96 void KERNEL_FUNCTION_FULL_NAME(filter_nlm_update_output)(int dx,
97                                                          int dy,
98                                                          float *differenceImage,
99                                                          float *image,
100                                                          float *outImage,
101                                                          float *accumImage,
102                                                          int* rect,
103                                                          int w,
104                                                          int f);
105
106 void KERNEL_FUNCTION_FULL_NAME(filter_nlm_construct_gramian)(int dx,
107                                                              int dy,
108                                                              float *differenceImage,
109                                                              float *buffer,
110                                                              float *color_pass,
111                                                              float *variance_pass,
112                                                              float *transform,
113                                                              int *rank,
114                                                              float *XtWX,
115                                                              float3 *XtWY,
116                                                              int *rect,
117                                                              int *filter_rect,
118                                                              int w,
119                                                              int h,
120                                                              int f,
121                                                              int pass_stride);
122
123 void KERNEL_FUNCTION_FULL_NAME(filter_nlm_normalize)(float *outImage,
124                                                      float *accumImage,
125                                                      int* rect,
126                                                      int w);
127
128 void KERNEL_FUNCTION_FULL_NAME(filter_finalize)(int x,
129                                                 int y,
130                                                 int storage_ofs,
131                                                 int w,
132                                                 int h,
133                                                 float *buffer,
134                                                 int *rank,
135                                                 float *XtWX,
136                                                 float3 *XtWY,
137                                                 int *buffer_params,
138                                                 int sample);
139
140 #undef KERNEL_ARCH