Home | History | Annotate | Download | only in xcore
      1 /*
      2  * dynamic_analyzer.h - dynamic analyzer
      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  *         Jia Meng <jia.meng (at) intel.com>
     20  */
     21 #ifndef XCAM_DYNAMIC_ANALYZER_H
     22 #define XCAM_DYNAMIC_ANALYZER_H
     23 
     24 #include <xcam_std.h>
     25 #include <base/xcam_3a_description.h>
     26 #include <x3a_analyzer.h>
     27 #include <x3a_stats_pool.h>
     28 #include <handler_interface.h>
     29 #include <x3a_result_factory.h>
     30 #include <analyzer_loader.h>
     31 
     32 namespace XCam {
     33 
     34 class DynamicAeHandler;
     35 class DynamicAwbHandler;
     36 class DynamicAfHandler;
     37 class DynamicCommonHandler;
     38 
     39 class DynamicAnalyzer
     40     : public X3aAnalyzer
     41 {
     42 public:
     43     DynamicAnalyzer (XCam3ADescription *desc, SmartPtr<AnalyzerLoader> &loader, const char *name = "DynamicAnalyzer");
     44     ~DynamicAnalyzer ();
     45 
     46     virtual XCamReturn configure_3a ();
     47     virtual XCamReturn analyze_ae (XCamAeParam &param);
     48     virtual XCamReturn analyze_awb (XCamAwbParam &param);
     49     virtual XCamReturn analyze_af (XCamAfParam &param);
     50 
     51 protected:
     52     virtual SmartPtr<AeHandler> create_ae_handler ();
     53     virtual SmartPtr<AwbHandler> create_awb_handler ();
     54     virtual SmartPtr<AfHandler> create_af_handler ();
     55     virtual SmartPtr<CommonHandler> create_common_handler ();
     56     virtual XCamReturn internal_init (uint32_t width, uint32_t height, double framerate);
     57     virtual XCamReturn internal_deinit ();
     58 
     59     virtual XCamReturn pre_3a_analyze (SmartPtr<X3aStats> &stats);
     60     virtual XCamReturn post_3a_analyze (X3aResultList &results);
     61 
     62     XCamReturn create_context ();
     63     void destroy_context ();
     64 
     65     const XCamCommonParam get_common_params ();
     66     SmartPtr<X3aStats> get_cur_stats () const {
     67         return _cur_stats;
     68     }
     69     XCamReturn convert_results (XCam3aResultHead *from[], uint32_t from_count, X3aResultList &to);
     70 
     71 private:
     72     XCAM_DEAD_COPY (DynamicAnalyzer);
     73 
     74 private:
     75     XCam3ADescription                  *_desc;
     76     XCam3AContext                      *_context;
     77     SmartPtr<X3aStats>                 _cur_stats;
     78     SmartPtr<DynamicCommonHandler>     _common_handler;
     79     SmartPtr<AnalyzerLoader>           _loader;
     80 };
     81 
     82 class DynamicAeHandler
     83     : public AeHandler
     84 {
     85 public:
     86     explicit DynamicAeHandler (DynamicAnalyzer *analyzer)
     87         : _analyzer (analyzer)
     88     {}
     89     virtual XCamReturn analyze (X3aResultList &output) {
     90         XCAM_UNUSED (output);
     91         AnalyzerHandler::HandlerLock lock(this);
     92         XCamAeParam param = this->get_params_unlock ();
     93         return _analyzer->analyze_ae (param);
     94     }
     95 
     96 private:
     97     DynamicAnalyzer *_analyzer;
     98 };
     99 
    100 class DynamicAwbHandler
    101     : public AwbHandler
    102 {
    103 public:
    104     explicit DynamicAwbHandler (DynamicAnalyzer *analyzer)
    105         : _analyzer (analyzer)
    106     {}
    107     virtual XCamReturn analyze (X3aResultList &output) {
    108         XCAM_UNUSED (output);
    109         AnalyzerHandler::HandlerLock lock(this);
    110         XCamAwbParam param = this->get_params_unlock ();
    111         return _analyzer->analyze_awb (param);
    112     }
    113 
    114 private:
    115     DynamicAnalyzer *_analyzer;
    116 };
    117 
    118 class DynamicAfHandler
    119     : public AfHandler
    120 {
    121 public:
    122     explicit DynamicAfHandler (DynamicAnalyzer *analyzer)
    123         : _analyzer (analyzer)
    124     {}
    125     virtual XCamReturn analyze (X3aResultList &output) {
    126         XCAM_UNUSED (output);
    127         AnalyzerHandler::HandlerLock lock(this);
    128         XCamAfParam param = this->get_params_unlock ();
    129         return _analyzer->analyze_af (param);
    130     }
    131 
    132 private:
    133     DynamicAnalyzer *_analyzer;
    134 };
    135 
    136 class DynamicCommonHandler
    137     : public CommonHandler
    138 {
    139     friend class DynamicAnalyzer;
    140 public:
    141     explicit DynamicCommonHandler (DynamicAnalyzer *analyzer)
    142         : _analyzer (analyzer)
    143     {}
    144     virtual XCamReturn analyze (X3aResultList &output) {
    145         XCAM_UNUSED (output);
    146         AnalyzerHandler::HandlerLock lock(this);
    147         return XCAM_RETURN_NO_ERROR;
    148     }
    149 
    150 private:
    151     DynamicAnalyzer *_analyzer;
    152 };
    153 }
    154 
    155 #endif //XCAM_DYNAMIC_ANALYZER_H
    156