From ba22027b2fb5ac13e0384d4916537d93a5a5d434 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Fri, 9 Mar 2018 20:18:37 +0100 Subject: [PATCH] Get pdaf data from camconst.json --- rtengine/camconst.cc | 43 ++++++++++++++++++++++++++++++++++++- rtengine/camconst.h | 6 +++++- rtengine/camconst.json | 25 +++++++++++++++++++-- rtengine/pdaflinesfilter.cc | 37 ++++++++----------------------- 4 files changed, 79 insertions(+), 32 deletions(-) diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index 469d18571..09a9e55ab 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -19,7 +19,7 @@ namespace rtengine extern const Settings* settings; -CameraConst::CameraConst() +CameraConst::CameraConst() : pdafOffset(0) { memset(dcraw_matrix, 0, sizeof(dcraw_matrix)); memset(raw_crop, 0, sizeof(raw_crop)); @@ -310,6 +310,35 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model) } } + ji = cJSON_GetObjectItem(js, "pdafPattern"); + + if (ji) { + if (ji->type != cJSON_Array) { + fprintf(stderr, "\"pdafPattern\" must be an array\n"); + goto parse_error; + } + + for (ji = ji->child; ji != nullptr; ji = ji->next) { + if (ji->type != cJSON_Number) { + fprintf(stderr, "\"pdafPattern\" array must contain numbers\n"); + goto parse_error; + } + + cc->pdafPattern.push_back(ji->valueint); + } + } + + ji = cJSON_GetObjectItem(js, "pdafOffset"); + + if (ji) { + if (ji->type != cJSON_Number) { + fprintf(stderr, "\"pdafOffset\" must contain a number\n"); + goto parse_error; + } + + cc->pdafOffset = ji->valueint; + } + return cc; parse_error: @@ -345,6 +374,18 @@ CameraConst::get_dcrawMatrix() return dcraw_matrix; } +bool +CameraConst::has_pdafPattern() +{ + return pdafPattern.size() > 0; +} + +void +CameraConst::get_pdafPattern(std::vector &pattern) +{ + pattern = pdafPattern; +} + bool CameraConst::has_rawCrop() { diff --git a/rtengine/camconst.h b/rtengine/camconst.h index 47c8d8bee..0f5d5d2ba 100644 --- a/rtengine/camconst.h +++ b/rtengine/camconst.h @@ -24,7 +24,8 @@ private: int white_max; std::map mLevels[2]; std::map mApertureScaling; - + std::vector pdafPattern; + int pdafOffset; CameraConst(); static bool parseLevels(CameraConst *cc, int bw, void *ji); static bool parseApertureScaling(CameraConst *cc, void *ji); @@ -33,8 +34,11 @@ private: public: static CameraConst *parseEntry(void *cJSON, const char *make_model); bool has_dcrawMatrix(void); + bool has_pdafPattern(void); void update_dcrawMatrix(const short *other); const short *get_dcrawMatrix(void); + void get_pdafPattern(std::vector &pattern); + int get_pdafOffset() {return pdafOffset;} bool has_rawCrop(void); void get_rawCrop(int& left_margin, int& top_margin, int& width, int& height); bool has_rawMask(int idx); diff --git a/rtengine/camconst.json b/rtengine/camconst.json index 8709c16c7..7809171cd 100644 --- a/rtengine/camconst.json +++ b/rtengine/camconst.json @@ -2235,7 +2235,11 @@ Camera constants: "make_model": "Sony ILCE-6000", "dcraw_matrix": [ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 ], // adobe dcp d65 "raw_crop": [ 0, 0, 6024, 4024 ], - "ranges": { "black": 512, "white": 16300 } + "ranges": { "black": 512, "white": 16300 }, + // detected by hand, using the picture from https://www.dpreview.com/forums/thread/3923513 + // P 11 P 23 P 17 P 17 P 17 P 23 P 11 P 17 P 17 P 17 P 23 P 11 P 23 P 11 P 17 P 23 P 11 P 17 P 17 P 23 P 17 P 11 P 17 P 17 P 17 P 23 P 17 P 11 P 17 P 17 P 23 P 11 P 17 P 11 P 23 + "pdafPattern" : [ 0,12,36,54,72,90,114,126,144,162,180,204,216,240,252,270,294,306,324,342,366,384,396,414,432,450,474,492,504,522,540,564,576,594,606,630 ], + "pdafOffset" : 3 }, { // Quality A @@ -2251,6 +2255,18 @@ Camera constants: "ranges": { "black": 512, "white": 16300 } }, + { // Quality C, only pdaf data + "make_model": "Sony ILCE-7M3", + // A7III, from https://www.dpreview.com/forums/post/60843139 + // in the original post: + // P 5 P 17 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 17 P 5 P 11 P 17 P 5 P 17 P 5 P 11 P 11 P 11 P 17 P 5 P 11 P 11 P 11 P 5 P 17 P 5 P 17 P 11 + // + // rotated to match the start of the frame + // P 11 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 17 P 5 P 11 P 17 P 5 P 17 P 5 P 11 P 11 P 11 P 17 P 5 P 11 P 11 P 11 P 5 P 17 P 5 P 17 P 11 P 5 P 17 P 11 P 11 P 17 P 11 P 5 + "pdafPattern" : [ 0,12,24,36,54,66,72,84,96,114,120,132,150,156,174,180,192,204,216,234,240,252,264,276,282,300,306,324,336,342,360,372,384,402,414,420], + "pdafOffset" : 9 + }, + { // Quality A, correction for frame width "make_model": "Sony ILCE-7R", "dcraw_matrix": [ 4913,-541,-202,-6130,13513,2906,-1564,2151,7183 ], @@ -2269,7 +2285,12 @@ Camera constants: "make_model": "Sony ILCE-9", "dcraw_matrix": [ 6389,-1703,-378,-4562,12265,2587,-670,1489,6550 ], // DNG_v9.12 D65 "raw_crop": [ 8, 8, 6008, 4008 ], // full raw frame 6048x4024 Dcraw auto identify 6024x4024, jpeg 12,12,6000x4000 - "ranges": { "black": 512, "white": 16300 } + "ranges": { "black": 512, "white": 16300 }, + // the A9 is the same as the A7III, rotated of 1 position + // source: https://www.dpreview.com/forums/post/60857788 + // P 11 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 17 P 5 P 11 P 17 P 5 P 17 P 5 P 11 P 11 P 11 P 17 P 5 P 11 P 11 P 11 P 5 P 17 P 5 P 17 P 11 P 5 P 17 P 11 P 11 P 17 P 11 P 5 + "pdafPattern" : [ 0,12,24,36,54,66,72,84,96,114,120,132,150,156,174,180,192,204,216,234,240,252,264,276,282,300,306,324,336,342,360,372,384,402,414,420 ], + "pdafOffset" : -7 }, { // Quality B, correction for frame width diff --git a/rtengine/pdaflinesfilter.cc b/rtengine/pdaflinesfilter.cc index 4fd229a99..72dbb1915 100644 --- a/rtengine/pdaflinesfilter.cc +++ b/rtengine/pdaflinesfilter.cc @@ -21,6 +21,7 @@ #include "pdaflinesfilter.h" #include "settings.h" #include +#include "camconst.h" namespace rtengine { @@ -128,34 +129,14 @@ PDAFLinesFilter::PDAFLinesFilter(RawImage *ri): H_(ri->get_height()) { gthresh_ = new PDAFGreenEqulibrateThreshold(W_, H_); - - if (ri_->get_maker() == "Sony") { - if (ri_->get_model() == "ILCE-7M3") { - // A7III, from https://www.dpreview.com/forums/post/60843139 - // in the original post: - // P 5 P 17 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 17 P 5 P 11 P 17 P 5 P 17 P 5 P 11 P 11 P 11 P 17 P 5 P 11 P 11 P 11 P 5 P 17 P 5 P 17 P 11 - // - // rotated to match the start of the frame - // P 11 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 17 P 5 P 11 P 17 P 5 P 17 P 5 P 11 P 11 P 11 P 17 P 5 P 11 P 11 P 11 P 5 P 17 P 5 P 17 P 11 P 5 P 17 P 11 P 11 P 17 P 11 P 5 - pattern_ = { - 0, 12, 24, 36, 54, 66, 72, 84, 96, 114, 120, 132, 150, 156, 174, 180, 192, 204, 216, 234, 240, 252, 264, 276, 282, 300, 306, 324, 336, 342, 360, 372, 384, 402, 414, 420 - }; - offset_ = 9; - } else if (ri_->get_model() == "ILCE-6000") { - // detected by hand, using the picture from https://www.dpreview.com/forums/thread/3923513 - // P 11 P 23 P 17 P 17 P 17 P 23 P 11 P 17 P 17 P 17 P 23 P 11 P 23 P 11 P 17 P 23 P 11 P 17 P 17 P 23 P 17 P 11 P 17 P 17 P 17 P 23 P 17 P 11 P 17 P 17 P 23 P 11 P 17 P 11 P 23 - pattern_ = { - 0, 12, 36, 54, 72, 90, 114, 126, 144, 162, 180, 204, 216, 240, 252, 270, 294, 306, 324, 342, 366, 384, 396, 414, 432, 450, 474, 492, 504, 522, 540, 564, 576, 594, 606, 630 - }; - offset_ = 3; - } else if (ri_->get_model() == "ILCE-9") { - // the A9 is the same as the A7III, rotated of 1 position - // source: https://www.dpreview.com/forums/post/60857788 - // P 11 P 11 P 11 P 17 P 11 P 5 P 11 P 11 P 17 P 5 P 11 P 17 P 5 P 17 P 5 P 11 P 11 P 11 P 17 P 5 P 11 P 11 P 11 P 5 P 17 P 5 P 17 P 11 P 5 P 17 P 11 P 11 P 17 P 11 P 5 - pattern_ = { - 0, 12, 24, 36, 54, 66, 72, 84, 96, 114, 120, 132, 150, 156, 174, 180, 192, 204, 216, 234, 240, 252, 264, 276, 282, 300, 306, 324, 336, 342, 360, 372, 384, 402, 414, 420 - }; - offset_ = -7; + + CameraConstantsStore* ccs = CameraConstantsStore::getInstance(); + CameraConst *cc = ccs->get(ri_->get_maker().c_str(), ri_->get_model().c_str()); + + if (cc) { + cc->get_pdafPattern(pattern_); + if(!pattern_.empty()) { + offset_ = cc->get_pdafOffset(); } } }