• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * x3a_result.h - 3A calculation result
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_RESULT_H
22 #define XCAM_3A_RESULT_H
23 
24 #include <xcam_std.h>
25 #include <base/xcam_3a_result.h>
26 #include <base/xcam_smart_result.h>
27 #include <list>
28 
29 namespace XCam {
30 
31 class X3aResult
32 {
33 protected:
34     explicit X3aResult (
35         uint32_t type,
36         XCamImageProcessType process_type = XCAM_IMAGE_PROCESS_ALWAYS,
37         int64_t timestamp = XCam::InvalidTimestamp
38     )
_type(type)39         : _type (type)
40         , _process_type (process_type)
41         , _timestamp (timestamp)
42         , _ptr (NULL)
43         , _processed (false)
44     {}
45 
46 public:
~X3aResult()47     virtual ~X3aResult() {}
48 
get_ptr()49     void *get_ptr () const {
50         return _ptr;
51     }
is_done()52     bool is_done() const {
53         return _processed;
54     }
set_done(bool flag)55     void set_done (bool flag) {
56         _processed = flag;
57     }
set_timestamp(int64_t timestamp)58     void set_timestamp (int64_t timestamp) {
59         _timestamp = timestamp;
60     }
get_timestamp()61     int64_t get_timestamp () const {
62         return _timestamp;
63     }
get_type()64     uint32_t get_type () const {
65         return _type;
66     }
67 
set_process_type(XCamImageProcessType process)68     void set_process_type (XCamImageProcessType process) {
69         _process_type = process;
70     }
get_process_type()71     XCamImageProcessType get_process_type () const {
72         return _process_type;
73     }
74 
75 protected:
set_ptr(void * ptr)76     void set_ptr (void *ptr) {
77         _ptr = ptr;
78     }
79 
80     //virtual bool to_isp_config (SmartPtr<X3aIspConfig>  &config) = 0;
81 
82 private:
83     XCAM_DEAD_COPY (X3aResult);
84 
85 protected:
86     //XCam3aResultType      _type;
87     uint32_t              _type;  // XCam3aResultType
88     XCamImageProcessType  _process_type;
89     int64_t               _timestamp;
90     void                 *_ptr;
91     bool                  _processed;
92 };
93 
94 typedef std::list<SmartPtr<X3aResult>>  X3aResultList;
95 
96 void x3a_list_remove_result (X3aResultList &list, uint32_t type);
97 
98 /* !
99  * \template StandardResult must inherited from XCam3aResultHead
100  */
101 template <typename StandardResult>
102 class X3aStandardResultT
103     : public X3aResult
104 {
105 public:
106     explicit X3aStandardResultT (uint32_t type, XCamImageProcessType process_type = XCAM_IMAGE_PROCESS_ALWAYS, uint32_t extra_size = 0)
X3aResult(type,process_type)107         : X3aResult (type, process_type)
108         , _result (NULL)
109         , _extra_size (extra_size)
110     {
111         _result = (StandardResult *) xcam_malloc0 (sizeof (StandardResult) + _extra_size);
112         XCAM_ASSERT (_result);
113         set_ptr ((void*) _result);
114         _result->head.type = (XCam3aResultType) type;
115         _result->head.process_type = _process_type;
116         _result->head.version = xcam_version ();
117     }
~X3aStandardResultT()118     ~X3aStandardResultT () {
119         xcam_free (_result);
120     }
121 
set_standard_result(StandardResult & res)122     void set_standard_result (StandardResult &res) {
123         uint32_t offset = sizeof (XCam3aResultHead);
124         XCAM_ASSERT (sizeof (StandardResult) >= offset);
125 
126         if (_extra_size > 0) {
127             memcpy ((uint8_t*)(_result) + offset, (uint8_t*)(&res) + offset, _extra_size);
128         } else {
129             memcpy ((uint8_t*)(_result) + offset, (uint8_t*)(&res) + offset, sizeof (StandardResult) - offset);
130         }
131     }
132 
get_standard_result()133     StandardResult &get_standard_result () {
134         return *_result;
135     }
get_standard_result()136     const StandardResult &get_standard_result () const {
137         return *_result;
138     }
get_standard_result_ptr()139     StandardResult *get_standard_result_ptr () {
140         return _result;
141     }
142 
143 private:
144     StandardResult *_result;
145     uint32_t        _extra_size;
146 };
147 
148 typedef X3aStandardResultT<XCam3aResultWhiteBalance>   X3aWhiteBalanceResult;
149 typedef X3aStandardResultT<XCam3aResultBlackLevel>     X3aBlackLevelResult;
150 typedef X3aStandardResultT<XCam3aResultColorMatrix>    X3aColorMatrixResult;
151 typedef X3aStandardResultT<XCam3aResultExposure>       X3aExposureResult;
152 typedef X3aStandardResultT<XCam3aResultFocus>          X3aFocusResult;
153 typedef X3aStandardResultT<XCam3aResultDemosaic>       X3aDemosaicResult;
154 typedef X3aStandardResultT<XCam3aResultDefectPixel>    X3aDefectPixelResult;
155 typedef X3aStandardResultT<XCam3aResultNoiseReduction> X3aNoiseReductionResult;
156 typedef X3aStandardResultT<XCam3aResultEdgeEnhancement>  X3aEdgeEnhancementResult;
157 typedef X3aStandardResultT<XCam3aResultGammaTable>     X3aGammaTableResult;
158 typedef X3aStandardResultT<XCam3aResultMaccMatrix>     X3aMaccMatrixResult;
159 typedef X3aStandardResultT<XCam3aResultChromaToneControl> X3aChromaToneControlResult;
160 typedef X3aStandardResultT<XCam3aResultBayerNoiseReduction> X3aBayerNoiseReduction;
161 typedef X3aStandardResultT<XCam3aResultBrightness>      X3aBrightnessResult;
162 typedef X3aStandardResultT<XCam3aResultTemporalNoiseReduction> X3aTemporalNoiseReduction;
163 typedef X3aStandardResultT<XCam3aResultWaveletNoiseReduction> X3aWaveletNoiseReduction;
164 typedef X3aStandardResultT<XCamFDResult>               X3aFaceDetectionResult;
165 typedef X3aStandardResultT<XCamDVSResult>              X3aDVSResult;
166 };
167 
168 #endif //XCAM_3A_RESULT_H
169