• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_image_warp_handler.h - CL image warping 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: Zong Wei <wei.zong@intel.com>
19  */
20 
21 #ifndef XCAM_CL_IMAGE_WARP_H
22 #define XCAM_CL_IMAGE_WARP_H
23 
24 #include <xcam_std.h>
25 #include <ocl/cl_image_handler.h>
26 #include <ocl/cl_memory.h>
27 
28 namespace XCam {
29 
30 #define CL_IMAGE_WARP_WRITE_UINT 1
31 
32 enum {
33 #if CL_IMAGE_WARP_WRITE_UINT
34     KernelImageWarp   = 0,
35 #else
36     KernelImageWarp   = 1,
37 #endif
38 };
39 
40 struct CLWarpConfig {
41     int frame_id;
42     int width;
43     int height;
44     float trim_ratio;
45     float proj_mat[9];
46 
CLWarpConfigCLWarpConfig47     CLWarpConfig ()
48         : frame_id (-1)
49         , width (-1)
50         , height (-1)
51         , trim_ratio (0.05f)
52     {
53         proj_mat[0] = 1.0f;
54         proj_mat[1] = 0.0f;
55         proj_mat[2] = 0.0f;
56         proj_mat[3] = 0.0f;
57         proj_mat[4] = 1.0f;
58         proj_mat[5] = 0.0f;
59         proj_mat[6] = 0.0f;
60         proj_mat[7] = 0.0f;
61         proj_mat[8] = 1.0f;
62     };
63 };
64 
65 class CLImageWarpHandler;
66 
67 class CLImageWarpKernel
68     : public CLImageKernel
69 {
70 public:
71     explicit CLImageWarpKernel (
72         const SmartPtr<CLContext> &context,
73         const char *name,
74         uint32_t channel,
75         SmartPtr<CLImageHandler> &handler);
76 
~CLImageWarpKernel()77     virtual ~CLImageWarpKernel () {};
78 
79 protected:
80     virtual XCamReturn prepare_arguments (
81         CLArgList &args, CLWorkSize &work_size);
82 
83 private:
84     XCAM_DEAD_COPY (CLImageWarpKernel);
85 
86     uint32_t                     _channel;
87     SmartPtr<CLImageWarpHandler> _handler;
88 };
89 
90 class CLImageWarpHandler
91     : public CLImageHandler
92 {
93     typedef std::list<CLWarpConfig> CLWarpConfigList;
94 
95 public:
96     explicit CLImageWarpHandler (const SmartPtr<CLContext> &context, const char *name = "CLImageWarpHandler");
~CLImageWarpHandler()97     virtual ~CLImageWarpHandler () {
98         _warp_config_list.clear ();
99     }
100 
101     virtual SmartPtr<VideoBuffer> get_warp_input_buf ();
102 
103     bool set_warp_config (const XCamDVSResult& config);
104     CLWarpConfig get_warp_config ();
105 
106     virtual bool is_ready ();
107 
108 protected:
109     virtual XCamReturn execute_done (SmartPtr<VideoBuffer> &output);
110 
111 private:
112     XCAM_DEAD_COPY (CLImageWarpHandler);
113 
114     CLWarpConfigList _warp_config_list;
115 
116 };
117 
118 SmartPtr<CLImageHandler>
119 create_cl_image_warp_handler (const SmartPtr<CLContext> &context);
120 
121 };
122 
123 #endif // XCAM_CL_IMAGE_WARP_H
124