1 /* 2 * Copyright (c) 2019 Rockchip Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #ifndef __IQCONVERTER_H__ 19 #define __IQCONVERTER_H__ 20 21 #include "RkAiqCalibDb.h" 22 #include "RkAiqCalibDbV2.h" 23 24 #include "aec_xml2json.h" 25 #include "awb_xml2json.h" 26 #include "bayernr_xml2json_v1.h" 27 #include "mfnr_xml2json_v1.h" 28 #include "uvnr_xml2json_v1.h" 29 #include "ynr_xml2json_v1.h" 30 #include "sharp_xml2json_v1.h" 31 #include "edgefilter_xml2json_v1.h" 32 #include "ccm_xml2json.h" 33 #include "adrc_xml2json.h" 34 #include "af_xml2json.h" 35 #include "adehaze_xml2json.h" 36 37 #include "bayernr_xml2json_v2.h" 38 #include "cnr_xml2json_v1.h" 39 #include "ynr_xml2json_v2.h" 40 #include "sharp_xml2json_v3.h" 41 #include "lut3d_xml2json.h" 42 43 44 45 #define DEF_NEW_CONVERTER(module) \ 46 class CalibConverter##module : public CalibConverter { \ 47 public: \ 48 CalibConverter##module() { printf("[%s] processing...\n", #module); } \ 49 virtual ~CalibConverter##module() {}; \ 50 virtual void convert(CamCalibDbV2Context_t *calibv2, \ 51 CamCalibDbContext_t *calibv1); \ 52 } 53 54 /* 55 * 1. create object 56 * 2. call object->convert(newcalib, oldcalib) 57 * 3. delete object 58 * */ 59 #define ADD_NEW_CONVERTER(module) \ 60 CalibConverter##module *module##_converter = new CalibConverter##module(); \ 61 module##_converter->convert(calibv2, calibv1); \ 62 delete module##_converter; 63 64 namespace RkCam { 65 66 class CalibConverter; 67 68 class CalibConverter { 69 public: 70 CalibConverter() = default; 71 virtual ~CalibConverter() = default; 72 73 public: 74 virtual void convert(CamCalibDbV2Context_t *calibv2, 75 CamCalibDbContext_t *calibv1) = 0; 76 }; 77 78 // define you module here 79 DEF_NEW_CONVERTER(AE); 80 DEF_NEW_CONVERTER(AWB); 81 DEF_NEW_CONVERTER(Ablc); 82 DEF_NEW_CONVERTER(Adegamma); 83 DEF_NEW_CONVERTER(Agic); 84 DEF_NEW_CONVERTER(Adehaze); 85 DEF_NEW_CONVERTER(Adpcc); 86 DEF_NEW_CONVERTER(Amerge); 87 DEF_NEW_CONVERTER(Atmo); 88 DEF_NEW_CONVERTER(Agamma); 89 DEF_NEW_CONVERTER(Cpsl); 90 DEF_NEW_CONVERTER(BAYERNRV1); 91 DEF_NEW_CONVERTER(MFNRV1); 92 DEF_NEW_CONVERTER(UVNRV1); 93 DEF_NEW_CONVERTER(YNRV1); 94 DEF_NEW_CONVERTER(SHARPV1); 95 DEF_NEW_CONVERTER(EDGEFILTERV1); 96 DEF_NEW_CONVERTER(Debayer); 97 DEF_NEW_CONVERTER(Cproc); 98 DEF_NEW_CONVERTER(IE); 99 DEF_NEW_CONVERTER(ALSC); 100 DEF_NEW_CONVERTER(Aldch); 101 DEF_NEW_CONVERTER(Afec); 102 DEF_NEW_CONVERTER(LumaDetect); 103 DEF_NEW_CONVERTER(ColorAsGrey); 104 DEF_NEW_CONVERTER(CCM); 105 DEF_NEW_CONVERTER(LUT3D); 106 DEF_NEW_CONVERTER(Af); 107 DEF_NEW_CONVERTER(Thumbnails); 108 DEF_NEW_CONVERTER(BAYERNRV2); 109 DEF_NEW_CONVERTER(CNRV1); 110 DEF_NEW_CONVERTER(YNRV2); 111 DEF_NEW_CONVERTER(SHARPV3); 112 DEF_NEW_CONVERTER(Adrc); 113 114 115 class IQConverter { 116 public: 117 explicit IQConverter(const char *xml, const char *json); 118 ~IQConverter() = default; 119 120 public: 121 int convert(); 122 123 private: 124 std::string ifile; 125 std::string ofile; 126 CamCalibDbContext_t *calibv1; 127 CamCalibDbV2Context_t *calibv2; 128 CamCalibDbProj_t calibproj; 129 130 static int addToScene(CamCalibDbProj_t* calibpj, const char* main_scene, 131 const char* sub_scene, CamCalibDbV2Context_t *calibv2); 132 doConvert()133 void doConvert() { 134 // add you converter here 135 ADD_NEW_CONVERTER(AE); 136 ADD_NEW_CONVERTER(AWB); 137 ADD_NEW_CONVERTER(Ablc); 138 ADD_NEW_CONVERTER(Adegamma); 139 ADD_NEW_CONVERTER(Agic); 140 ADD_NEW_CONVERTER(Adehaze); 141 ADD_NEW_CONVERTER(Adpcc); 142 ADD_NEW_CONVERTER(Amerge); 143 ADD_NEW_CONVERTER(Atmo); 144 ADD_NEW_CONVERTER(Agamma); 145 ADD_NEW_CONVERTER(Cpsl); 146 ADD_NEW_CONVERTER(BAYERNRV1); 147 ADD_NEW_CONVERTER(MFNRV1); 148 ADD_NEW_CONVERTER(UVNRV1); 149 ADD_NEW_CONVERTER(YNRV1); 150 ADD_NEW_CONVERTER(SHARPV1); 151 ADD_NEW_CONVERTER(EDGEFILTERV1); 152 ADD_NEW_CONVERTER(Debayer); 153 ADD_NEW_CONVERTER(Cproc); 154 ADD_NEW_CONVERTER(IE); 155 ADD_NEW_CONVERTER(ALSC); 156 ADD_NEW_CONVERTER(Afec); 157 ADD_NEW_CONVERTER(Aldch); 158 ADD_NEW_CONVERTER(LumaDetect); 159 ADD_NEW_CONVERTER(ColorAsGrey); 160 ADD_NEW_CONVERTER(CCM); 161 ADD_NEW_CONVERTER(LUT3D); 162 ADD_NEW_CONVERTER(Af); 163 ADD_NEW_CONVERTER(Thumbnails); 164 ADD_NEW_CONVERTER(BAYERNRV2); 165 ADD_NEW_CONVERTER(CNRV1); 166 ADD_NEW_CONVERTER(YNRV2); 167 ADD_NEW_CONVERTER(SHARPV3); 168 ADD_NEW_CONVERTER(Adrc); 169 }; 170 }; 171 172 } // namespace RkCam 173 174 #endif /*__IQCONVERTER_H__*/ 175