Home | History | Annotate | Download | only in ocl
      1 /*
      2  * cl_post_image_processor.h - CL post image processor
      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  * Author: Yinhang Liu <yinhangx.liu (at) intel.com>
     20  */
     21 
     22 #ifndef XCAM_CL_POST_IMAGE_PROCESSOR_H
     23 #define XCAM_CL_POST_IMAGE_PROCESSOR_H
     24 
     25 #include <xcam_std.h>
     26 #include <base/xcam_3a_types.h>
     27 #include <ocl/cl_image_processor.h>
     28 #include <stats_callback_interface.h>
     29 #include <ocl/cl_blender.h>
     30 #include <ocl/cl_utils.h>
     31 
     32 namespace XCam {
     33 
     34 class CLTnrImageHandler;
     35 class CLRetinexImageHandler;
     36 class CLCscImageHandler;
     37 class CLDefogDcpImageHandler;
     38 class CLWaveletDenoiseImageHandler;
     39 class CLNewWaveletDenoiseImageHandler;
     40 class CL3DDenoiseImageHandler;
     41 class CLImageScaler;
     42 class CLWireFrameImageHandler;
     43 class CLImageWarpHandler;
     44 class CLImage360Stitch;
     45 class CLVideoStabilizer;
     46 
     47 class CLPostImageProcessor
     48     : public CLImageProcessor
     49 {
     50 public:
     51     enum OutSampleType {
     52         OutSampleYuv,
     53         OutSampleRGB,
     54         OutSampleBayer,
     55     };
     56 
     57     enum CLTnrMode {
     58         TnrDisable = 0,
     59         TnrYuv,
     60     };
     61 
     62     enum CLDefogMode {
     63         DefogDisabled = 0,
     64         DefogRetinex,
     65         DefogDarkChannelPrior,
     66     };
     67 
     68     enum CL3DDenoiseMode {
     69         Denoise3DDisabled = 0,
     70         Denoise3DYuv,
     71         Denoise3DUV,
     72     };
     73 
     74 public:
     75     explicit CLPostImageProcessor ();
     76     virtual ~CLPostImageProcessor ();
     77 
     78     bool set_output_format (uint32_t fourcc);
     79     void set_stats_callback (const SmartPtr<StatsCallback> &callback);
     80 
     81     bool set_scaler_factor (const double factor);
     82     double get_scaler_factor () const {
     83         return _scaler_factor;
     84     }
     85     bool is_scaled () {
     86         return _enable_scaler;
     87     }
     88 
     89     virtual bool set_tnr (CLTnrMode mode);
     90     virtual bool set_defog_mode (CLDefogMode mode);
     91     virtual bool set_wavelet (CLWaveletBasis basis, uint32_t channel, bool bayes_shrink);
     92     virtual bool set_3ddenoise_mode (CL3DDenoiseMode mode, uint8_t ref_frame_count);
     93     virtual bool set_scaler (bool enable);
     94     virtual bool set_wireframe (bool enable);
     95     virtual bool set_image_warp (bool enable);
     96     virtual bool set_image_stitch (
     97         bool enable_stitch, bool enable_seam, CLBlenderScaleMode scale_mode, bool enable_fisheye_map,
     98         bool lsc, bool fm_ocl, uint32_t stitch_width, uint32_t stitch_height, uint32_t res_mode);
     99 
    100 protected:
    101     virtual bool can_process_result (SmartPtr<X3aResult> &result);
    102     virtual XCamReturn apply_3a_results (X3aResultList &results);
    103     virtual XCamReturn apply_3a_result (SmartPtr<X3aResult> &result);
    104 
    105 private:
    106     virtual XCamReturn create_handlers ();
    107 
    108     XCAM_DEAD_COPY (CLPostImageProcessor);
    109 
    110 private:
    111     uint32_t                                  _output_fourcc;
    112     OutSampleType                             _out_sample_type;
    113     SmartPtr<StatsCallback>                   _stats_callback;
    114 
    115     SmartPtr<CLTnrImageHandler>               _tnr;
    116     SmartPtr<CLRetinexImageHandler>           _retinex;
    117     SmartPtr<CLDefogDcpImageHandler>          _defog_dcp;
    118     SmartPtr<CLWaveletDenoiseImageHandler>    _wavelet;
    119     SmartPtr<CLNewWaveletDenoiseImageHandler> _newwavelet;
    120     SmartPtr<CL3DDenoiseImageHandler>         _3d_denoise;
    121     SmartPtr<CLImageScaler>                   _scaler;
    122     SmartPtr<CLWireFrameImageHandler>         _wireframe;
    123     SmartPtr<CLCscImageHandler>               _csc;
    124     SmartPtr<CLImageWarpHandler>              _image_warp;
    125     SmartPtr<CLImage360Stitch>                _stitch;
    126     SmartPtr<CLVideoStabilizer>               _video_stab;
    127 
    128     double                                    _scaler_factor;
    129 
    130     CLTnrMode                                 _tnr_mode;
    131     CLDefogMode                               _defog_mode;
    132     CLWaveletBasis                            _wavelet_basis;
    133     uint32_t                                  _wavelet_channel;
    134     bool                                      _wavelet_bayes_shrink;
    135     CL3DDenoiseMode                           _3d_denoise_mode;
    136     uint8_t                                   _3d_denoise_ref_count;
    137     bool                                      _enable_scaler;
    138     bool                                      _enable_wireframe;
    139     bool                                      _enable_image_warp;
    140     bool                                      _enable_stitch;
    141     bool                                      _stitch_enable_seam;
    142     bool                                      _stitch_fisheye_map;
    143     bool                                      _stitch_lsc;
    144     bool                                      _stitch_fm_ocl;
    145     CLBlenderScaleMode                        _stitch_scale_mode;
    146     uint32_t                                  _stitch_width;
    147     uint32_t                                  _stitch_height;
    148     uint32_t                                  _stitch_res_mode;
    149     uint32_t                                  _surround_mode;
    150 };
    151 
    152 };
    153 #endif // XCAM_CL_POST_IMAGE_PROCESSOR_H
    154