[libcamera-devel] [PATCH v3 0/8] Raspberry Pi IPA code refactor

Naushir Patuck naush at raspberrypi.com
Wed Jul 27 10:55:16 CEST 2022


Hi Laurent,

Providing and squashing fixup commits is not entirely trivial with this series
since you will get merge conflicts as each commit touches/renames the same
bunch of files.  So I though I'd save you some time and squash/fixup and provide
this version 3.

The actual delta from the previous revision (v2) is tiny, and addresses all the
points raised:

diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
index ad75d55f0976..f5898fc48eb6 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
@@ -406,7 +406,7 @@ double Awb::computeDelta2Sum(double gainR, double gainB)
                double deltaR = gainR * z.R - 1 - config_.whitepointR;
                double deltaB = gainB * z.B - 1 - config_.whitepointB;
                double delta2 = deltaR * deltaR + deltaB * deltaB;
-               /*LOG(RPiAwb, Debug) << "delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2; */
+               /* LOG(RPiAwb, Debug) << "delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2; */
                delta2 = std::min(delta2, config_.deltaLimit);
                delta2Sum += delta2;
        }
diff --git a/src/ipa/raspberrypi/controller/rpi/awb.h b/src/ipa/raspberrypi/controller/rpi/awb.h
index 9e075624c429..058f0d4cb091 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.h
+++ b/src/ipa/raspberrypi/controller/rpi/awb.h
@@ -41,10 +41,8 @@ struct AwbConfig {
        double speed; /* IIR filter speed applied to algorithm results */
        bool fast; /* "fast" mode uses a 16x16 rather than 32x32 grid */
        Pwl ctR; /* function maps CT to r (= R/G) */
-       Pwl ctB; /*
-       Pwl ctB;  * function maps CT to b (= B/G)
-        * table of illuminant priors at different lux levels
-        */
+       Pwl ctB; /* function maps CT to b (= B/G) */
+       /* table of illuminant priors at different lux levels */
        std::vector<AwbPrior> priors;
        /* AWB "modes" (determines the search range) */
        std::map<std::string, AwbMode> modes;
diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp
index 0799d7b9195a..def19ccb42a2 100644
--- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp
@@ -35,9 +35,9 @@ void BlackLevel::read(boost::property_tree::ptree const &params)
 {
        uint16_t blackLevel = params.get<uint16_t>(
                "black_level", 4096); /* 64 in 10 bits scaled to 16 bits */
-       blackLevelR_ = params.get<uint16_t>("blackLevelR", blackLevel);
-       blackLevelG_ = params.get<uint16_t>("blackLevelG", blackLevel);
-       blackLevelB_ = params.get<uint16_t>("blackLevelB", blackLevel);
+       blackLevelR_ = params.get<uint16_t>("black_level_r", blackLevel);
+       blackLevelG_ = params.get<uint16_t>("black_level_g", blackLevel);
+       blackLevelB_ = params.get<uint16_t>("black_level_b", blackLevel);
        LOG(RPiBlackLevel, Debug)
                << " Read black levels red " << blackLevelR_
                << " green " << blackLevelG_

Barring anything else that might be picked up, this should be ready for merging
with you R-B tag added to 1/8 if you are happy.

Regards,
Naush

Naushir Patuck (8):
  ipa: raspberrypi: Code refactoring to match style guidelines
  ipa: raspberrypi: Change to C style code comments
  ipa: raspberrypi: Remove extern "C" declarations
  ipa: raspberrypi: Rename header files from *.hpp to *.h
  raspberrypi: Update Copyright statement in all Raspberry Pi source
    files
  ipa: raspberryip: Remove all exception throw statements
  ipa: raspberrypi: Remove #define constants
  ipa: raspberrypi: agc: Fix log message prefixes

 .reuse/dep5                                   |    2 +-
 include/libcamera/color_space.h               |    2 +-
 include/libcamera/internal/bayer_format.h     |    2 +-
 include/libcamera/internal/delayed_controls.h |    2 +-
 include/libcamera/internal/v4l2_pixelformat.h |    2 +-
 include/libcamera/transform.h                 |    2 +-
 include/linux/bcm2835-isp.h                   |    2 +-
 src/cam/stream_options.cpp                    |    2 +-
 src/cam/stream_options.h                      |    2 +-
 src/ipa/libipa/histogram.cpp                  |    2 +-
 src/ipa/libipa/histogram.h                    |    2 +-
 src/ipa/raspberrypi/cam_helper.cpp            |   94 +-
 src/ipa/raspberrypi/cam_helper.h              |  127 ++
 src/ipa/raspberrypi/cam_helper.hpp            |  123 --
 src/ipa/raspberrypi/cam_helper_imx219.cpp     |   40 +-
 src/ipa/raspberrypi/cam_helper_imx290.cpp     |   36 +-
 src/ipa/raspberrypi/cam_helper_imx296.cpp     |   28 +-
 src/ipa/raspberrypi/cam_helper_imx477.cpp     |   78 +-
 src/ipa/raspberrypi/cam_helper_imx519.cpp     |   76 +-
 src/ipa/raspberrypi/cam_helper_ov5647.cpp     |   48 +-
 src/ipa/raspberrypi/cam_helper_ov9281.cpp     |   32 +-
 .../raspberrypi/controller/agc_algorithm.h    |   31 +
 .../raspberrypi/controller/agc_algorithm.hpp  |   32 -
 src/ipa/raspberrypi/controller/agc_status.h   |   48 +-
 src/ipa/raspberrypi/controller/algorithm.cpp  |   26 +-
 src/ipa/raspberrypi/controller/algorithm.h    |   64 +
 src/ipa/raspberrypi/controller/algorithm.hpp  |   60 -
 src/ipa/raspberrypi/controller/alsc_status.h  |   26 +-
 .../raspberrypi/controller/awb_algorithm.h    |   23 +
 .../raspberrypi/controller/awb_algorithm.hpp  |   23 -
 src/ipa/raspberrypi/controller/awb_status.h   |   24 +-
 .../controller/black_level_status.h           |   18 +-
 src/ipa/raspberrypi/controller/camera_mode.h  |   56 +-
 .../raspberrypi/controller/ccm_algorithm.h    |   21 +
 .../raspberrypi/controller/ccm_algorithm.hpp  |   21 -
 src/ipa/raspberrypi/controller/ccm_status.h   |   12 +-
 .../controller/contrast_algorithm.h           |   22 +
 .../controller/contrast_algorithm.hpp         |   22 -
 .../raspberrypi/controller/contrast_status.h  |   20 +-
 src/ipa/raspberrypi/controller/controller.cpp |   86 +-
 src/ipa/raspberrypi/controller/controller.h   |   58 +
 src/ipa/raspberrypi/controller/controller.hpp |   54 -
 ...oise_algorithm.hpp => denoise_algorithm.h} |   12 +-
 .../raspberrypi/controller/denoise_status.h   |   16 +-
 .../raspberrypi/controller/device_status.cpp  |   20 +-
 .../raspberrypi/controller/device_status.h    |   18 +-
 src/ipa/raspberrypi/controller/dpc_status.h   |   14 +-
 src/ipa/raspberrypi/controller/focus_status.h |   20 +-
 src/ipa/raspberrypi/controller/geq_status.h   |   12 +-
 src/ipa/raspberrypi/controller/histogram.cpp  |   46 +-
 src/ipa/raspberrypi/controller/histogram.h    |   48 +
 src/ipa/raspberrypi/controller/histogram.hpp  |   44 -
 src/ipa/raspberrypi/controller/lux_status.h   |   28 +-
 .../controller/{metadata.hpp => metadata.h}   |   40 +-
 src/ipa/raspberrypi/controller/noise_status.h |   16 +-
 src/ipa/raspberrypi/controller/pwl.cpp        |  174 +--
 src/ipa/raspberrypi/controller/pwl.h          |  126 ++
 src/ipa/raspberrypi/controller/pwl.hpp        |  112 --
 src/ipa/raspberrypi/controller/rpi/agc.cpp    | 1047 +++++++++--------
 src/ipa/raspberrypi/controller/rpi/agc.h      |  141 +++
 src/ipa/raspberrypi/controller/rpi/agc.hpp    |  139 ---
 src/ipa/raspberrypi/controller/rpi/alsc.cpp   |  860 +++++++-------
 src/ipa/raspberrypi/controller/rpi/alsc.h     |  110 ++
 src/ipa/raspberrypi/controller/rpi/alsc.hpp   |  106 --
 src/ipa/raspberrypi/controller/rpi/awb.cpp    |  770 ++++++------
 src/ipa/raspberrypi/controller/rpi/awb.h      |  191 +++
 src/ipa/raspberrypi/controller/rpi/awb.hpp    |  179 ---
 .../controller/rpi/black_level.cpp            |   46 +-
 .../raspberrypi/controller/rpi/black_level.h  |   30 +
 .../controller/rpi/black_level.hpp            |   30 -
 src/ipa/raspberrypi/controller/rpi/ccm.cpp    |  117 +-
 .../controller/rpi/{ccm.hpp => ccm.h}         |   24 +-
 .../raspberrypi/controller/rpi/contrast.cpp   |  206 ++--
 src/ipa/raspberrypi/controller/rpi/contrast.h |   52 +
 .../raspberrypi/controller/rpi/contrast.hpp   |   50 -
 src/ipa/raspberrypi/controller/rpi/dpc.cpp    |   34 +-
 src/ipa/raspberrypi/controller/rpi/dpc.h      |   32 +
 src/ipa/raspberrypi/controller/rpi/dpc.hpp    |   32 -
 src/ipa/raspberrypi/controller/rpi/focus.cpp  |   18 +-
 .../controller/rpi/{focus.hpp => focus.h}     |   12 +-
 src/ipa/raspberrypi/controller/rpi/geq.cpp    |   64 +-
 src/ipa/raspberrypi/controller/rpi/geq.h      |   34 +
 src/ipa/raspberrypi/controller/rpi/geq.hpp    |   34 -
 src/ipa/raspberrypi/controller/rpi/lux.cpp    |   90 +-
 src/ipa/raspberrypi/controller/rpi/lux.h      |   45 +
 src/ipa/raspberrypi/controller/rpi/lux.hpp    |   43 -
 src/ipa/raspberrypi/controller/rpi/noise.cpp  |   64 +-
 src/ipa/raspberrypi/controller/rpi/noise.h    |   32 +
 src/ipa/raspberrypi/controller/rpi/noise.hpp  |   32 -
 src/ipa/raspberrypi/controller/rpi/sdn.cpp    |   50 +-
 src/ipa/raspberrypi/controller/rpi/sdn.h      |   32 +
 src/ipa/raspberrypi/controller/rpi/sdn.hpp    |   32 -
 .../raspberrypi/controller/rpi/sharpen.cpp    |   72 +-
 src/ipa/raspberrypi/controller/rpi/sharpen.h  |   34 +
 .../raspberrypi/controller/rpi/sharpen.hpp    |   34 -
 .../controller/sharpen_algorithm.h            |   21 +
 .../controller/sharpen_algorithm.hpp          |   21 -
 .../raspberrypi/controller/sharpen_status.h   |   22 +-
 .../{md_parser.hpp => md_parser.h}            |   50 +-
 src/ipa/raspberrypi/md_parser_smia.cpp        |  112 +-
 src/ipa/raspberrypi/raspberrypi.cpp           |  294 ++---
 src/libcamera/bayer_format.cpp                |    2 +-
 src/libcamera/color_space.cpp                 |    2 +-
 src/libcamera/delayed_controls.cpp            |    2 +-
 .../pipeline/raspberrypi/dma_heaps.cpp        |    2 +-
 .../pipeline/raspberrypi/dma_heaps.h          |    2 +-
 .../pipeline/raspberrypi/raspberrypi.cpp      |    2 +-
 .../pipeline/raspberrypi/rpi_stream.cpp       |    2 +-
 .../pipeline/raspberrypi/rpi_stream.h         |    2 +-
 src/libcamera/transform.cpp                   |    2 +-
 src/libcamera/v4l2_pixelformat.cpp            |    2 +-
 src/qcam/dng_writer.cpp                       |    2 +-
 src/qcam/dng_writer.h                         |    2 +-
 utils/raspberrypi/ctt/ctt.py                  |    2 +-
 utils/raspberrypi/ctt/ctt_alsc.py             |    2 +-
 utils/raspberrypi/ctt/ctt_awb.py              |    2 +-
 utils/raspberrypi/ctt/ctt_ccm.py              |    2 +-
 utils/raspberrypi/ctt/ctt_geq.py              |    2 +-
 utils/raspberrypi/ctt/ctt_image_load.py       |    2 +-
 utils/raspberrypi/ctt/ctt_lux.py              |    2 +-
 utils/raspberrypi/ctt/ctt_macbeth_locator.py  |    2 +-
 utils/raspberrypi/ctt/ctt_noise.py            |    2 +-
 .../raspberrypi/ctt/ctt_pretty_print_json.py  |    2 +-
 utils/raspberrypi/ctt/ctt_ransac.py           |    2 +-
 utils/raspberrypi/ctt/ctt_tools.py            |    2 +-
 125 files changed, 3872 insertions(+), 3811 deletions(-)
 create mode 100644 src/ipa/raspberrypi/cam_helper.h
 delete mode 100644 src/ipa/raspberrypi/cam_helper.hpp
 create mode 100644 src/ipa/raspberrypi/controller/agc_algorithm.h
 delete mode 100644 src/ipa/raspberrypi/controller/agc_algorithm.hpp
 create mode 100644 src/ipa/raspberrypi/controller/algorithm.h
 delete mode 100644 src/ipa/raspberrypi/controller/algorithm.hpp
 create mode 100644 src/ipa/raspberrypi/controller/awb_algorithm.h
 delete mode 100644 src/ipa/raspberrypi/controller/awb_algorithm.hpp
 create mode 100644 src/ipa/raspberrypi/controller/ccm_algorithm.h
 delete mode 100644 src/ipa/raspberrypi/controller/ccm_algorithm.hpp
 create mode 100644 src/ipa/raspberrypi/controller/contrast_algorithm.h
 delete mode 100644 src/ipa/raspberrypi/controller/contrast_algorithm.hpp
 create mode 100644 src/ipa/raspberrypi/controller/controller.h
 delete mode 100644 src/ipa/raspberrypi/controller/controller.hpp
 rename src/ipa/raspberrypi/controller/{denoise_algorithm.hpp => denoise_algorithm.h} (53%)
 create mode 100644 src/ipa/raspberrypi/controller/histogram.h
 delete mode 100644 src/ipa/raspberrypi/controller/histogram.hpp
 rename src/ipa/raspberrypi/controller/{metadata.hpp => metadata.h} (61%)
 create mode 100644 src/ipa/raspberrypi/controller/pwl.h
 delete mode 100644 src/ipa/raspberrypi/controller/pwl.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/agc.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/agc.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/alsc.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/alsc.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/awb.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/awb.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/black_level.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/black_level.hpp
 rename src/ipa/raspberrypi/controller/rpi/{ccm.hpp => ccm.h} (68%)
 create mode 100644 src/ipa/raspberrypi/controller/rpi/contrast.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/contrast.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/dpc.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/dpc.hpp
 rename src/ipa/raspberrypi/controller/rpi/{focus.hpp => focus.h} (59%)
 create mode 100644 src/ipa/raspberrypi/controller/rpi/geq.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/geq.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/lux.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/lux.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/noise.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/noise.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/sdn.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/sdn.hpp
 create mode 100644 src/ipa/raspberrypi/controller/rpi/sharpen.h
 delete mode 100644 src/ipa/raspberrypi/controller/rpi/sharpen.hpp
 create mode 100644 src/ipa/raspberrypi/controller/sharpen_algorithm.h
 delete mode 100644 src/ipa/raspberrypi/controller/sharpen_algorithm.hpp
 rename src/ipa/raspberrypi/{md_parser.hpp => md_parser.h} (75%)

-- 
2.25.1



More information about the libcamera-devel mailing list