1 /*
2  * cl_yuv_pipe_handler.h - CL Yuv Pipe handler
3  *
4  *  Copyright (c) 2015 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: Wangfei <feix.w.wang@intel.com>
19  * Author: Wind Yuan <feng.yuan@intel.com>
20  */
21 
22 #ifndef XCAM_CL_YUV_PIPE_HANLDER_H
23 #define XCAM_CL_YUV_PIPE_HANLDER_H
24 
25 #include <xcam_std.h>
26 #include <ocl/cl_image_handler.h>
27 #include <base/xcam_3a_result.h>
28 
29 namespace XCam {
30 
31 class CLYuvPipeImageKernel
32     : public CLImageKernel
33 {
34 
35 public:
36     explicit CLYuvPipeImageKernel (const SmartPtr<CLContext> &context);
37 };
38 
39 class CLYuvPipeImageHandler
40     : public CLImageHandler
41 {
42 public:
43     explicit CLYuvPipeImageHandler (const SmartPtr<CLContext> &context, const char *name);
44     bool set_yuv_pipe_kernel(SmartPtr<CLYuvPipeImageKernel> &kernel);
45     bool set_macc_table (const XCam3aResultMaccMatrix &macc);
46     bool set_rgbtoyuv_matrix (const XCam3aResultColorMatrix &matrix);
47     bool set_tnr_yuv_config (const XCam3aResultTemporalNoiseReduction& config);
48     bool set_tnr_enable (bool enable_tnr_yuv);
49 
50 protected:
51     virtual XCamReturn prepare_buffer_pool_video_info (
52         const VideoBufferInfo &input, VideoBufferInfo &output);
53     virtual XCamReturn prepare_parameters (
54         SmartPtr<VideoBuffer> &input, SmartPtr<VideoBuffer> &output);
55 
56 private:
57     XCAM_DEAD_COPY (CLYuvPipeImageHandler);
58     SmartPtr<CLYuvPipeImageKernel> _yuv_pipe_kernel;
59     uint32_t                       _output_format;
60 
61     float                          _macc_table[XCAM_CHROMA_AXIS_SIZE * XCAM_CHROMA_MATRIX_SIZE];
62     float                          _rgbtoyuv_matrix[XCAM_COLOR_MATRIX_SIZE];
63 
64     //TNR
65     uint32_t                       _enable_tnr_yuv;
66     float                          _gain_yuv;
67     float                          _thr_y;
68     float                          _thr_uv;
69 
70     uint32_t                       _enable_tnr_yuv_state;
71     SmartPtr<CLMemory>             _buffer_out_prev;
72     SmartPtr<CLMemory>             _buffer_out_prev_UV;
73 };
74 
75 SmartPtr<CLImageHandler>
76 create_cl_yuv_pipe_image_handler (const SmartPtr<CLContext> &context);
77 
78 };
79 
80 #endif //XCAM_CL_YUV_PIPE_HANLDER_H
81