• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * x3a_analyzer.h - 3a analyzer
3  *
4  *  Copyright (c) 2014-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@intel.com>
19  */
20 
21 #ifndef XCAM_3A_ANALYZER_H
22 #define XCAM_3A_ANALYZER_H
23 
24 #include <xcam_std.h>
25 #include <xcam_analyzer.h>
26 #include <handler_interface.h>
27 
28 namespace XCam {
29 
30 class X3aStats;
31 class AnalyzerThread;
32 class VideoBuffer;
33 
34 class X3aAnalyzer
35     : public XAnalyzer
36 {
37     friend class AnalyzerThread;
38 public:
39     explicit X3aAnalyzer (const char *name = NULL);
40     virtual ~X3aAnalyzer ();
41 
42     /* analyze 3A statistics */
43     XCamReturn push_3a_stats (const SmartPtr<X3aStats> &stats);
44 
45     /* AWB */
46     bool set_awb_mode (XCamAwbMode mode);
47     bool set_awb_speed (double speed);
48     bool set_awb_color_temperature_range (uint32_t cct_min, uint32_t cct_max);
49     bool set_awb_manual_gain (double gr, double r, double b, double gb);
50 
51     /* AE */
52     bool set_ae_mode (XCamAeMode mode);
53     bool set_ae_metering_mode (XCamAeMeteringMode mode);
54     bool set_ae_window (XCam3AWindow *window, uint8_t count = 1);
55     bool set_ae_ev_shift (double ev_shift);
56     bool set_ae_speed (double speed);
57     bool set_ae_flicker_mode (XCamFlickerMode flicker);
58 
59     XCamFlickerMode get_ae_flicker_mode ();
60     uint64_t get_ae_current_exposure_time ();
61     double get_ae_current_analog_gain ();
62 
63     bool set_ae_manual_exposure_time (int64_t time_in_us);
64     bool set_ae_manual_analog_gain (double gain);
65     bool set_ae_aperture (double fn);
66     bool set_ae_max_analog_gain (double max_gain);
67     double get_ae_max_analog_gain ();
68     bool set_ae_exposure_time_range (int64_t min_time_in_us, int64_t max_time_in_us);
69     bool get_ae_exposure_time_range (int64_t *min_time_in_us, int64_t *max_time_in_us);
70 
71     /* DVS */
72     bool set_dvs (bool enable);
73     bool set_gbce (bool enable);
74     bool set_night_mode (bool enable);
75 
76     /* Picture quality */
77     bool set_noise_reduction_level (double level);
78     bool set_temporal_noise_reduction_level (double level);
79     bool set_manual_brightness (double level);
80     bool set_manual_contrast (double level);
81     bool set_manual_hue (double level);
82     bool set_manual_saturation (double level);
83     bool set_manual_sharpness (double level);
84     bool set_gamma_table (double *r_table, double *g_table, double *b_table);
85     bool set_color_effect(XCamColorEffect effect);
86     bool set_parameter_brightness (double level);
87 
88     // whole update of parameters
89     bool update_awb_parameters (const XCamAwbParam &params);
90     bool update_ae_parameters (const XCamAeParam &params);
91     bool update_af_parameters (const XCamAfParam &params);
92     bool update_common_parameters (const XCamCommonParam &params);
93 
get_ae_handler()94     SmartPtr<AeHandler> get_ae_handler () {
95         return _ae_handler;
96     }
get_awb_handler()97     SmartPtr<AwbHandler> get_awb_handler () {
98         return _awb_handler;
99     }
get_af_handler()100     SmartPtr<AfHandler> get_af_handler () {
101         return _af_handler;
102     }
get_common_handler()103     SmartPtr<CommonHandler> get_common_handler () {
104         return _common_handler;
105     }
106 
107 protected:
108     /* virtual function list */
109     virtual XCamReturn create_handlers ();
110     virtual XCamReturn release_handlers ();
111     virtual XCamReturn configure ();
112     virtual XCamReturn analyze (const SmartPtr<VideoBuffer> &buffer);
113 
114     virtual SmartPtr<AeHandler> create_ae_handler () = 0;
115     virtual SmartPtr<AwbHandler> create_awb_handler () = 0;
116     virtual SmartPtr<AfHandler> create_af_handler () = 0;
117     virtual SmartPtr<CommonHandler> create_common_handler () = 0;
118     virtual XCamReturn internal_init (uint32_t width, uint32_t height, double framerate) = 0;
119     virtual XCamReturn internal_deinit () = 0;
120 
121     // in 3a stats thread
122     virtual XCamReturn configure_3a () = 0;
123     // @param[in]   stats,  3a statistics prepared
124     virtual XCamReturn pre_3a_analyze (SmartPtr<X3aStats> &stats) = 0;
125     // @param[out]  results,   new 3a results merged into \c results
126     virtual XCamReturn post_3a_analyze (X3aResultList &results) = 0;
127 
128 private:
129     XCamReturn analyze_3a_statistics (SmartPtr<X3aStats> &stats);
130 
131     XCAM_DEAD_COPY (X3aAnalyzer);
132 
133 protected:
134     double                   _brightness_level_param;
135 
136 private:
137     SmartPtr<AeHandler>      _ae_handler;
138     SmartPtr<AwbHandler>     _awb_handler;
139     SmartPtr<AfHandler>      _af_handler;
140     SmartPtr<CommonHandler>  _common_handler;
141 };
142 
143 }
144 #endif //XCAM_3A_ANALYZER_H
145