• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_utils.h - CL Utilities
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_UTILS_H
22 #define XCAM_CL_UTILS_H
23 
24 #include "xcam_utils.h"
25 #include "interface/data_types.h"
26 #include "ocl/cl_context.h"
27 #include "ocl/cl_memory.h"
28 #include "ocl/cl_video_buffer.h"
29 #if HAVE_LIBDRM
30 #include "drm_bo_buffer.h"
31 #endif
32 
33 #define XCAM_CL_IMAGE_ALIGNMENT_X 4
34 
35 namespace XCam {
36 
37 enum CLWaveletBasis {
38     CL_WAVELET_DISABLED = 0,
39     CL_WAVELET_HAT,
40     CL_WAVELET_HAAR,
41 };
42 
43 enum CLImageChannel {
44     CL_IMAGE_CHANNEL_Y = 1,
45     CL_IMAGE_CHANNEL_UV = 1 << 1,
46 };
47 
48 bool dump_image (SmartPtr<CLImage> image, const char *file_name);
49 
50 SmartPtr<CLBuffer> convert_to_clbuffer (
51     const SmartPtr<CLContext> &context,
52     const SmartPtr<VideoBuffer> &buf);
53 
54 SmartPtr<CLImage> convert_to_climage (
55     const SmartPtr<CLContext> &context,
56     SmartPtr<VideoBuffer> &buf,
57     const CLImageDesc &desc,
58     uint32_t offset = 0,
59     cl_mem_flags flags = CL_MEM_READ_WRITE);
60 
61 XCamReturn convert_nv12_mem_to_video_buffer (
62     void *nv12_mem, uint32_t width, uint32_t height, uint32_t row_pitch, uint32_t offset_uv,
63     SmartPtr<VideoBuffer> &buf);
64 
65 XCamReturn
66 generate_topview_map_table (
67     const VideoBufferInfo &stitch_info,
68     const BowlDataConfig &config,
69     std::vector<PointFloat2> &map_table,
70     int width, int height);
71 
72 XCamReturn
73 generate_rectifiedview_map_table (
74     const VideoBufferInfo &stitch_info,
75     const BowlDataConfig &config,
76     std::vector<PointFloat2> &map_table,
77     float angle_start, float angle_end,
78     int width, int height);
79 
80 XCamReturn sample_generate_top_view (
81     SmartPtr<VideoBuffer> &stitch_buf,
82     SmartPtr<VideoBuffer> top_view_buf,
83     const BowlDataConfig &config,
84     std::vector<PointFloat2> &map_table);
85 
86 XCamReturn sample_generate_rectified_view (
87     SmartPtr<VideoBuffer> &stitch_buf,
88     SmartPtr<VideoBuffer> rectified_view_buf,
89     const BowlDataConfig &config,
90     float angle_start, float angle_end,
91     std::vector<PointFloat2> &map_table);
92 }
93 
94 #endif //XCAM_CL_UTILS_H
95 
96