Home | History | Annotate | Download | only in ocl
      1 /*
      2  * cl_bayer_basic_handler.h - CL bayer copy 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: Wind Yuan <feng.yuan (at) intel.com>
     19  */
     20 
     21 #ifndef XCAM_CL_BAYER_BASIC_HANLDER_H
     22 #define XCAM_CL_BAYER_BASIC_HANLDER_H
     23 
     24 #include <xcam_std.h>
     25 #include <ocl/cl_image_handler.h>
     26 #include <ocl/cl_memory.h>
     27 #include <ocl/cl_3a_stats_context.h>
     28 #include <stats_callback_interface.h>
     29 
     30 namespace XCam {
     31 
     32 class CLBayerBasicImageHandler;
     33 class CLBayer3AStatsThread;
     34 
     35 #define XCAM_CL_BLC_DEFAULT_LEVEL 0.06
     36 
     37 /*  Black level correction configuration  */
     38 typedef struct  {
     39     float     level_gr;  /* Black level for GR pixels */
     40     float     level_r;   /* Black level for R pixels */
     41     float     level_b;   /* Black level for B pixels */
     42     float     level_gb;  /* Black level for GB pixels */
     43     uint32_t  color_bits;
     44 } CLBLCConfig;
     45 
     46 typedef struct {
     47     float           r_gain;
     48     float           gr_gain;
     49     float           gb_gain;
     50     float           b_gain;
     51 } CLWBConfig;
     52 
     53 class CLBayerBasicImageKernel
     54     : public CLImageKernel
     55 {
     56 public:
     57     explicit CLBayerBasicImageKernel (const SmartPtr<CLContext> &context);
     58 };
     59 
     60 class CLBayerBasicImageHandler
     61     : public CLImageHandler
     62 {
     63     friend class CLBayer3AStatsThread;
     64 public:
     65     explicit CLBayerBasicImageHandler (const SmartPtr<CLContext> &context, const char *name);
     66     ~CLBayerBasicImageHandler ();
     67 
     68     void set_stats_callback (SmartPtr<StatsCallback> &callback) {
     69         _stats_callback = callback;
     70     }
     71     bool set_bayer_kernel (SmartPtr<CLBayerBasicImageKernel> &kernel);
     72 
     73     bool set_blc_config (const XCam3aResultBlackLevel &blc);
     74     bool set_wb_config (const XCam3aResultWhiteBalance &wb);
     75     bool set_gamma_table (const XCam3aResultGammaTable &gamma);
     76     void set_stats_bits (uint32_t stats_bits);
     77 
     78     virtual void emit_stop ();
     79     XCamReturn post_stats (const SmartPtr<X3aStats> &stats);
     80     XCamReturn process_stats_buffer (SmartPtr<VideoBuffer> &buffer, SmartPtr<CLBuffer> &cl_stats);
     81 
     82 protected:
     83     virtual XCamReturn prepare_buffer_pool_video_info (
     84         const VideoBufferInfo &input, VideoBufferInfo &output);
     85     virtual XCamReturn prepare_parameters (
     86         SmartPtr<VideoBuffer> &input, SmartPtr<VideoBuffer> &output);
     87     virtual XCamReturn execute_done (SmartPtr<VideoBuffer> &output);
     88 
     89 private:
     90     SmartPtr<CLBayerBasicImageKernel>     _bayer_kernel;
     91     bool                                  _is_first_buf;
     92     CLBLCConfig                           _blc_config;
     93     CLWBConfig                            _wb_config;
     94     float                                 _gamma_table[XCAM_GAMMA_TABLE_SIZE + 1];
     95 
     96     SmartPtr<CL3AStatsCalculatorContext>  _3a_stats_context;
     97     SmartPtr<CLBayer3AStatsThread>        _3a_stats_thread;
     98     SmartPtr<CLBuffer>                    _stats_cl_buffer;
     99 
    100     SmartPtr<StatsCallback>               _stats_callback;
    101 
    102     XCAM_OBJ_PROFILING_DEFINES;
    103 };
    104 
    105 SmartPtr<CLImageHandler>
    106 create_cl_bayer_basic_image_handler (
    107     const SmartPtr<CLContext> &context,
    108     bool enable_gamma = true,
    109     uint32_t stats_bits = 8);
    110 
    111 };
    112 
    113 #endif //XCAM_CL_BAYER_BASIC_HANLDER_H
    114