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 29namespace XCam { 30 31class X3aResult 32{ 33protected: 34 explicit X3aResult ( 35 uint32_t type, 36 XCamImageProcessType process_type = XCAM_IMAGE_PROCESS_ALWAYS, 37 int64_t timestamp = XCam::InvalidTimestamp 38 ) 39 : _type (type) 40 , _process_type (process_type) 41 , _timestamp (timestamp) 42 , _ptr (NULL) 43 , _processed (false) 44 {} 45 46public: 47 virtual ~X3aResult() {} 48 49 void *get_ptr () const { 50 return _ptr; 51 } 52 bool is_done() const { 53 return _processed; 54 } 55 void set_done (bool flag) { 56 _processed = flag; 57 } 58 void set_timestamp (int64_t timestamp) { 59 _timestamp = timestamp; 60 } 61 int64_t get_timestamp () const { 62 return _timestamp; 63 } 64 uint32_t get_type () const { 65 return _type; 66 } 67 68 void set_process_type (XCamImageProcessType process) { 69 _process_type = process; 70 } 71 XCamImageProcessType get_process_type () const { 72 return _process_type; 73 } 74 75protected: 76 void set_ptr (void *ptr) { 77 _ptr = ptr; 78 } 79 80 //virtual bool to_isp_config (SmartPtr<X3aIspConfig> &config) = 0; 81 82private: 83 XCAM_DEAD_COPY (X3aResult); 84 85protected: 86 //XCam3aResultType _type; 87 uint32_t _type; // XCam3aResultType 88 XCamImageProcessType _process_type; 89 int64_t _timestamp; 90 void *_ptr; 91 bool _processed; 92}; 93 94typedef std::list<SmartPtr<X3aResult>> X3aResultList; 95 96void x3a_list_remove_result (X3aResultList &list, uint32_t type); 97 98/* ! 99 * \template StandardResult must inherited from XCam3aResultHead 100 */ 101template <typename StandardResult> 102class X3aStandardResultT 103 : public X3aResult 104{ 105public: 106 explicit X3aStandardResultT (uint32_t type, XCamImageProcessType process_type = XCAM_IMAGE_PROCESS_ALWAYS, uint32_t extra_size = 0) 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 } 118 ~X3aStandardResultT () { 119 xcam_free (_result); 120 } 121 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 133 StandardResult &get_standard_result () { 134 return *_result; 135 } 136 const StandardResult &get_standard_result () const { 137 return *_result; 138 } 139 StandardResult *get_standard_result_ptr () { 140 return _result; 141 } 142 143private: 144 StandardResult *_result; 145 uint32_t _extra_size; 146}; 147 148typedef X3aStandardResultT<XCam3aResultWhiteBalance> X3aWhiteBalanceResult; 149typedef X3aStandardResultT<XCam3aResultBlackLevel> X3aBlackLevelResult; 150typedef X3aStandardResultT<XCam3aResultColorMatrix> X3aColorMatrixResult; 151typedef X3aStandardResultT<XCam3aResultExposure> X3aExposureResult; 152typedef X3aStandardResultT<XCam3aResultFocus> X3aFocusResult; 153typedef X3aStandardResultT<XCam3aResultDemosaic> X3aDemosaicResult; 154typedef X3aStandardResultT<XCam3aResultDefectPixel> X3aDefectPixelResult; 155typedef X3aStandardResultT<XCam3aResultNoiseReduction> X3aNoiseReductionResult; 156typedef X3aStandardResultT<XCam3aResultEdgeEnhancement> X3aEdgeEnhancementResult; 157typedef X3aStandardResultT<XCam3aResultGammaTable> X3aGammaTableResult; 158typedef X3aStandardResultT<XCam3aResultMaccMatrix> X3aMaccMatrixResult; 159typedef X3aStandardResultT<XCam3aResultChromaToneControl> X3aChromaToneControlResult; 160typedef X3aStandardResultT<XCam3aResultBayerNoiseReduction> X3aBayerNoiseReduction; 161typedef X3aStandardResultT<XCam3aResultBrightness> X3aBrightnessResult; 162typedef X3aStandardResultT<XCam3aResultTemporalNoiseReduction> X3aTemporalNoiseReduction; 163typedef X3aStandardResultT<XCam3aResultWaveletNoiseReduction> X3aWaveletNoiseReduction; 164typedef X3aStandardResultT<XCamFDResult> X3aFaceDetectionResult; 165typedef X3aStandardResultT<XCamDVSResult> X3aDVSResult; 166}; 167 168#endif //XCAM_3A_RESULT_H 169