@@ -34,6 +34,7 @@ constexpr int32_t kPanelInfoFeature = 9;
3434constexpr int32_t kMainPanelStageFeature = 0x22 ;
3535constexpr int32_t kDefaultPanelStage = 4 ;
3636constexpr auto kCwbWeightsPath = " /odm/etc/display/cwb_weightspos.json" ;
37+ constexpr auto kDefaultScreenshotPeriod = 250ms;
3738
3839bool ReadNumber (const Json::Value& value, double & result) {
3940 if (value.isString ()) {
@@ -377,15 +378,27 @@ bool ParseV21Model(const Json::Value& root, FusionConfig& config, std::string& e
377378 !ParseRanges (root[" IRBrightness_V2_1" ], " BrightnessMin" , " BrightnessMax" ,
378379 config.ir_brightness ) ||
379380 !ParseRanges (root[" IRThreshold_V2_1" ], " IR_Ratio_Min" , " IR_Ratio_Max" ,
380- config.ir_thresholds ) ||
381- !ParseChannelModels (root[" LinearityCompensation" ], config.linearity ) ||
382- !ParseChannelModels (root[" LightLeakageCalculation" ], config.leakage ) ||
383- !ParseChannelModels (root[" LightLeakageRatio" ], config.leakage_ratio ) ||
384- !ParseGolden (root[" LightLeakageGolden" ], config.leakage_golden )) {
381+ config.ir_thresholds )) {
385382 error = " invalid V2.1 model" ;
386383 return false ;
387384 }
388385
386+ // Profiles may omit the leakage model entirely. Stock then keeps zeroed
387+ // tables, which leaves the raw channels uncompensated.
388+ constexpr const char * kLeakageTables [] = {" LinearityCompensation" , " LightLeakageCalculation" ,
389+ " LightLeakageRatio" , " LightLeakageGolden" };
390+ const bool has_leakage_model =
391+ std::any_of (std::begin (kLeakageTables ), std::end (kLeakageTables ),
392+ [&](const char * name) { return !root[name].isNull (); });
393+ if (has_leakage_model &&
394+ (!ParseChannelModels (root[" LinearityCompensation" ], config.linearity ) ||
395+ !ParseChannelModels (root[" LightLeakageCalculation" ], config.leakage ) ||
396+ !ParseChannelModels (root[" LightLeakageRatio" ], config.leakage_ratio ) ||
397+ !ParseGolden (root[" LightLeakageGolden" ], config.leakage_golden ))) {
398+ error = " invalid V2.1 leakage model" ;
399+ return false ;
400+ }
401+
389402 constexpr std::array<const char *, kIrBandCount > kDefaultTables = {
390403 " LuxCoeffLIR_V2_1" , " LuxCoeffHIR_V2_1" , " LuxCoeffSuperHIR_V2_1" };
391404 for (int band = 0 ; band < kIrBandCount ; ++band) {
@@ -396,8 +409,9 @@ bool ParseV21Model(const Json::Value& root, FusionConfig& config, std::string& e
396409 }
397410
398411 const size_t levels = config.linearity_brightness .size ();
399- if (config.linearity .size () != levels || config.leakage .size () != levels ||
400- config.leakage_ratio .size () != levels || config.leakage_golden .size () != levels ||
412+ if ((has_leakage_model &&
413+ (config.linearity .size () != levels || config.leakage .size () != levels ||
414+ config.leakage_ratio .size () != levels || config.leakage_golden .size () != levels)) ||
401415 config.ir_brightness .empty ()) {
402416 error = " inconsistent V2.1 model dimensions" ;
403417 return false ;
@@ -412,18 +426,6 @@ bool ParseV21Model(const Json::Value& root, FusionConfig& config, std::string& e
412426}
413427
414428bool ParseViewModel (const Json::Value& root, FusionConfig& config, std::string& error) {
415- const auto & common = root[" CommonConfig" ];
416- int32_t ir_ratio_formula = 0 ;
417- if (common.isMember (" IRRatioFormulaType" ) &&
418- !ReadInt (common[" IRRatioFormulaType" ], ir_ratio_formula)) {
419- error = " invalid IRRatioFormulaType" ;
420- return false ;
421- }
422- if (ir_ratio_formula != 0 ) {
423- error = " unsupported IR ratio formula " + std::to_string (ir_ratio_formula);
424- return false ;
425- }
426-
427429 if (!ParseRanges (root[" LinearityBrightnessRange" ], " BrightnessMin" , " BrightnessMax" ,
428430 config.linearity_brightness ) ||
429431 !ParseRanges (root[" IRThreshold" ], " IR_Ratio_Min" , " IR_Ratio_Max" , config.ir_thresholds ) ||
@@ -478,17 +480,28 @@ bool ParseConfig(std::istream& stream, FusionConfig& config, std::string& error)
478480 !ReadRequiredInt (crop, " RightBottomY" , config.cwb .crop_bottom ) ||
479481 !ReadRequiredInt (resolution, " Width" , config.cwb .reference_width ) ||
480482 !ReadRequiredInt (resolution, " Height" , config.cwb .reference_height ) ||
481- !ReadRequiredDuration (common, " CWBScreenshotPeriod" , config.cwb .screenshot_period ) ||
483+ (common.isMember (" CWBScreenshotPeriod" ) &&
484+ !ReadRequiredDuration (common, " CWBScreenshotPeriod" , config.cwb .screenshot_period )) ||
485+ (common.isMember (" IRRatioFormulaType" ) &&
486+ !ReadInt (common[" IRRatioFormulaType" ], config.ir_ratio_formula )) ||
482487 (common.isMember (" LowLightAccuracy" ) &&
483488 !ReadNumber (common[" LowLightAccuracy" ], config.low_light_accuracy )) ||
484489 (common[" SensorModule" ].isMember (" SensorModuleId" ) &&
485490 !ReadInt (common[" SensorModule" ][" SensorModuleId" ], config.sensor_module_id ))) {
486491 error = " invalid CommonConfig" ;
487492 return false ;
488493 }
494+ if (!common.isMember (" CWBScreenshotPeriod" )) {
495+ config.cwb .screenshot_period = kDefaultScreenshotPeriod ;
496+ }
497+ if (config.ir_ratio_formula != 0 && config.ir_ratio_formula != 2 ) {
498+ error = " unsupported IR ratio formula " + std::to_string (config.ir_ratio_formula );
499+ return false ;
500+ }
489501
490502 config.fusion_rgb_supported = common[" FusionRGBSupported" ].asBool ();
491503 config.cwb_supported = common[" CWBSupported" ].asBool ();
504+ config.black_frame_supported = common[" BlackFrame30Support" ].asBool ();
492505 config.cwb .screenshot_weighted = common[" SupportCWBScreenshotWeighted" ].asBool ();
493506 config.screenshot_v2_1_supported = common[" SupportScreenshotAlgorithm_V2_1" ].asBool ();
494507 config.screen_off_lux_supported = common[" ScreenOffCalLuxSupported" ].asBool ();
0 commit comments