• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_defog_dcp_handler.h - CL defog dark channel prior handler
3  *
4  *  Copyright (c) 2016 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Wind Yuan <feng.yuan@intel.com>
19  */
20 
21 #ifndef XCAM_CL_DEFOG_DCP_HANLDER_H
22 #define XCAM_CL_DEFOG_DCP_HANLDER_H
23 
24 #include <xcam_std.h>
25 #include <base/xcam_3a_result.h>
26 #include <x3a_stats_pool.h>
27 #include <ocl/cl_image_handler.h>
28 
29 #define XCAM_DEFOG_DC_ORIGINAL      0
30 #define XCAM_DEFOG_DC_MIN_FILTER_V  1
31 #define XCAM_DEFOG_DC_MIN_FILTER_H  2
32 #define XCAM_DEFOG_DC_BI_FILTER     3
33 #define XCAM_DEFOG_DC_REFINED       4
34 #define XCAM_DEFOG_DC_MAX_BUF       5
35 
36 
37 #define XCAM_DEFOG_R_CHANNEL    0
38 #define XCAM_DEFOG_G_CHANNEL    1
39 #define XCAM_DEFOG_B_CHANNEL    2
40 #define XCAM_DEFOG_MAX_CHANNELS 3
41 
42 namespace XCam {
43 
44 class CLDefogDcpImageHandler;
45 
46 class CLDarkChannelKernel
47     : public CLImageKernel
48 {
49 public:
50     explicit CLDarkChannelKernel (
51         const SmartPtr<CLContext> &context, SmartPtr<CLDefogDcpImageHandler> &defog_handler);
52 
53 protected:
54     virtual XCamReturn prepare_arguments (CLArgList &args, CLWorkSize &work_size);
55 
56 private:
57     SmartPtr<CLDefogDcpImageHandler>   _defog_handler;
58 };
59 
60 class CLMinFilterKernel
61     : public CLImageKernel
62 {
63 public:
64     explicit CLMinFilterKernel (
65         const SmartPtr<CLContext> &context, SmartPtr<CLDefogDcpImageHandler> &defog_handler, int index);
66 
67 protected:
68     virtual XCamReturn prepare_arguments (CLArgList &args, CLWorkSize &work_size);
69 
70     SmartPtr<CLDefogDcpImageHandler>   _defog_handler;
71     uint32_t                           _buf_index;
72 };
73 
74 class CLBiFilterKernel
75     : public CLImageKernel
76 {
77 public:
78     explicit CLBiFilterKernel (
79         const SmartPtr<CLContext> &context, SmartPtr<CLDefogDcpImageHandler> &defog_handler);
80 
81 protected:
82     virtual XCamReturn prepare_arguments (CLArgList &args, CLWorkSize &work_size);
83 
84 private:
85     XCAM_DEAD_COPY (CLBiFilterKernel);
86 
87 private:
88     SmartPtr<CLDefogDcpImageHandler>   _defog_handler;
89 };
90 
91 class CLDefogRecoverKernel
92     : public CLImageKernel
93 {
94 public:
95     explicit CLDefogRecoverKernel (
96         const SmartPtr<CLContext> &context, SmartPtr<CLDefogDcpImageHandler> &defog_handler);
97 
98 protected:
99     virtual XCamReturn prepare_arguments (CLArgList &args, CLWorkSize &work_size);
100 
101 private:
102     float get_max_value (SmartPtr<VideoBuffer> &buf);
103 
104     XCAM_DEAD_COPY (CLDefogRecoverKernel);
105 
106 private:
107     SmartPtr<CLDefogDcpImageHandler>   _defog_handler;
108     float                              _max_r;
109     float                              _max_g;
110     float                              _max_b;
111     float                              _max_i;
112 };
113 
114 class CLDefogDcpImageHandler
115     : public CLImageHandler
116 {
117 public:
118     explicit CLDefogDcpImageHandler (
119         const SmartPtr<CLContext> &context, const char *name);
120 
get_dark_map(uint index)121     SmartPtr<CLImage> &get_dark_map (uint index) {
122         XCAM_ASSERT (index < XCAM_DEFOG_DC_MAX_BUF);
123         return _dark_channel_buf[index];
124     };
get_rgb_channel(uint index)125     SmartPtr<CLImage> &get_rgb_channel (uint index) {
126         XCAM_ASSERT (index < XCAM_DEFOG_MAX_CHANNELS);
127         return _rgb_buf[index];
128     };
129 
130 protected:
131     virtual XCamReturn prepare_parameters (SmartPtr<VideoBuffer> &input, SmartPtr<VideoBuffer> &output);
132     virtual XCamReturn execute_done (SmartPtr<VideoBuffer> &output);
133 
134 private:
135     XCamReturn allocate_transmit_bufs (const VideoBufferInfo &video_info);
136     void dump_buffer();
137 
138     XCAM_DEAD_COPY (CLDefogDcpImageHandler);
139 
140 private:
141     SmartPtr<CLImage>                 _dark_channel_buf[XCAM_DEFOG_DC_MAX_BUF];
142     SmartPtr<CLImage>                 _rgb_buf[XCAM_DEFOG_MAX_CHANNELS];
143 };
144 
145 SmartPtr<CLImageHandler>
146 create_cl_defog_dcp_image_handler (const SmartPtr<CLContext> &context);
147 
148 };
149 
150 #endif //XCAM_CL_DEFOG_DCP_HANLDER_H
151