Show a patch.

GET /api/1.1/patches/14037/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14037,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14037/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14037/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<mailman.444.1633340913.837.libcamera-devel@lists.libcamera.org>",
    "date": "2021-10-04T09:48:21",
    "name": "[libcamera-devel,1/3] ipu3: Remove the usage of SharedItemPool",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b36e3305a6dfa0d48d038cc16b0c3e1caf5c71cb",
    "submitter": {
        "id": 72,
        "url": "https://patchwork.libcamera.org/api/1.1/people/72/?format=api",
        "name": "Han-lin Chen",
        "email": "hanlinchen@google.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14037/mbox/",
    "series": [
        {
            "id": 2597,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2597/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2597",
            "date": "2021-10-04T09:48:20",
            "name": "Fix dark caputred image with close sourced IPU3 IPA",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2597/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14037/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14037/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\r\n\t[92.243.16.209])\r\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4C12CC3243\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tMon,  4 Oct 2021 09:48:34 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 11D96691BE;\r\n\tMon,  4 Oct 2021 11:48:34 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1633340914;\r\n\tbh=neqq77iJV8bLuFmcGciceErKBHn2+dmG7Xu3ReNiHVI=;\r\n\th=Date:In-Reply-To:References:To:List-Id:List-Post:From:\r\n\tList-Subscribe:List-Unsubscribe:List-Archive:Reply-To:List-Help:\r\n\tSubject:From;\r\n\tb=a/yPMdRVEArbK+AWS+jPml6B8Ad7eiVHvr3YHO/gfkAPeEqiFHVrXMDsfvsx0euUR\r\n\t8lGI2W8CUz2dUzxtIFwDZbZ/sjTtvtR7SXBppUJvz+u0lo5fwWMZY0bb25b742B5yr\r\n\tSM8JCnaHXnS9h+x7BHkxNqeheX/XXzyWrWYRUzCEzUJGojhuxTLHid+3GeK1FmTCCt\r\n\tQ+XP1POc0dgYBP6l4aHN8Fxqm2yprx2qUx0vk6QQO34a5LYi8gN4ix2nhCov+Cmi9Y\r\n\tttsJYx2sjcJQd1SyjtqTeeblpXHcx3Yd5tAp6JkD8+F/xiJ4yFDv44C/k9bWYLI6yE\r\n\tm91lCPK1hWjnw==",
        "Date": "Mon,  4 Oct 2021 17:48:21 +0800",
        "In-Reply-To": "<20211004094823.260789-1-hanlinchen@google.com>",
        "References": "<20211004094823.260789-1-hanlinchen@google.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "MIME-Version": "1.0",
        "Message-ID": "<mailman.444.1633340913.837.libcamera-devel@lists.libcamera.org>",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "From": "Han-Lin Chen via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Precedence": "list",
        "X-Mailman-Version": "2.1.29",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "Reply-To": "Han-Lin Chen <hanlinchen@google.com>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "Subject": "[libcamera-devel] [PATCH 1/3] ipu3: Remove the usage of\r\n\tSharedItemPool",
        "Content-Type": "message/rfc822",
        "Content-Disposition": "inline",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: hanlinchen <hanlinchen@google.com>\n\nThe SharedItemPool was migrated from Chrome OS to maintain RGBS and AF\ngrids in IPAIPU3Stats. The orginal reason is to reserve the validness\nunitl the grids are processed in a different thread. However, it leads\nto a subtle bug which recycles the buffer before sending into AIQ\nlibraries. Since the IPU3 IPA (Unlike Chrome OS) process IPAIPU3Stats\nin a single thread, It would be simpler to maintain the grids as the\nmembers of IPAIPU3Stats, and remove the usage of SharedItemPool.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@google.com>\n---\n stats/ipa_ipu3_stats.cpp   | 145 ++++++-------------------------------\n stats/ipa_ipu3_stats.h     |  41 +++++++----\n stats/meson.build          |   1 -\n stats/shared_item_pool.cpp | 129 ---------------------------------\n stats/shared_item_pool.h   | 114 -----------------------------\n 5 files changed, 47 insertions(+), 383 deletions(-)\n delete mode 100644 stats/shared_item_pool.cpp\n delete mode 100644 stats/shared_item_pool.h",
    "diff": "diff --git a/stats/ipa_ipu3_stats.cpp b/stats/ipa_ipu3_stats.cpp\r\nindex c14bd7e..6697c9b 100644\r\n--- a/stats/ipa_ipu3_stats.cpp\r\n+++ b/stats/ipa_ipu3_stats.cpp\r\n@@ -15,30 +15,22 @@ namespace libcamera::ipa::ipu3 {\r\n \r\n LOG_DEFINE_CATEGORY(IPAIPU3Stats)\r\n \r\n-IPAIPU3Stats::IPAIPU3Stats()\r\n-{\r\n-\taiqStatsInputParams_ = {};\r\n-\r\n-\t/* \\todo: Is this fine here or we need separate helper? */\r\n-\trgbsGridBuffPool_ = std::make_shared<SharedItemPool<ia_aiq_rgbs_grid>>(\"RgbsGridBuffPool\");\r\n-\tafFilterBuffPool_ = std::make_shared<SharedItemPool<ia_aiq_af_grid>>(\"AfFilterBuffPool\");\r\n-#define PUBLIC_STATS_POOL_SIZE 9 /* comes from CrOS */\r\n-\tint ret = allocateStatBufferPools(PUBLIC_STATS_POOL_SIZE);\r\n-\tif (ret < 0)\r\n-\t\tLOG(IPAIPU3Stats, Error) << \"Failed to allocate stats grid buffers\";\r\n-}\r\n-\r\n-IPAIPU3Stats::~IPAIPU3Stats()\r\n-{\r\n-\tfreeStatBufferPools();\r\n-\trgbsGridBuffPool_.reset();\r\n-\tafFilterBuffPool_.reset();\r\n-}\r\n-\r\n ia_aiq_statistics_input_params *\r\n IPAIPU3Stats::getInputStatsParams(int frame, aiq::AiqResults *results,\r\n \t\t\t\t  const ipu3_uapi_stats_3a *stats)\r\n {\r\n+\tIPU3AllStats::ipu3_stats_all_stats outStats = {};\r\n+\tIPU3AllStats::ipu3_stats_get_3a(&outStats, stats);\r\n+\r\n+\trgbsGrid_.blocks_ptr = rgbsGridBlock_;\r\n+\r\n+\tafGrid_.filter_response_1 = filterResponse1_;\r\n+\tafGrid_.filter_response_2 = filterResponse2_;\r\n+\r\n+\tIPU3AllStats::intel_skycam_statistics_convert(\r\n+\t\t\toutStats.ia_css_4a_statistics, &rgbsGrid_, &afGrid_);\r\n+\r\n+\taiqStatsInputParams_ = {};\r\n \taiqStatsInputParams_.frame_id = frame;\r\n \taiqStatsInputParams_.frame_ae_parameters = results->ae();\r\n \taiqStatsInputParams_.frame_af_parameters = results->af();\r\n@@ -47,117 +39,24 @@ IPAIPU3Stats::getInputStatsParams(int frame, aiq::AiqResults *results,\r\n \taiqStatsInputParams_.frame_sa_parameters = results->sa();\r\n \taiqStatsInputParams_.camera_orientation = ia_aiq_camera_orientation_unknown;\r\n \r\n-\tIPU3AllStats::ipu3_stats_all_stats outStats;\r\n-\tmemset(&outStats, 0, sizeof(IPU3AllStats::ipu3_stats_all_stats));\r\n-\tIPU3AllStats::ipu3_stats_get_3a(&outStats, stats);\r\n-\r\n-\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\r\n-\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\r\n-\tint ret = afFilterBuffPool_->acquireItem(afGrid);\r\n-\tret |= rgbsGridBuffPool_->acquireItem(rgbsGrid);\r\n-\tif (ret != 0 || afGrid.get() == nullptr || rgbsGrid.get() == nullptr) {\r\n-\t\tLOG(IPAIPU3Stats, Error) << \"Failed to acquire 3A buffers from pools\";\r\n-\t\treturn nullptr;\r\n-\t}\r\n-\r\n-\tIPU3AllStats::intel_skycam_statistics_convert(outStats.ia_css_4a_statistics,\r\n-\t\t\t\t\t\t      rgbsGrid.get(), afGrid.get());\r\n-\r\n-\tconst ia_aiq_rgbs_grid *rgbsGridPtr = rgbsGrid.get();\r\n-\tconst ia_aiq_af_grid *afGridPtr = afGrid.get();\r\n-\r\n+\trgbsGridPtr_ = &rgbsGrid_;\r\n \taiqStatsInputParams_.num_rgbs_grids = 1;\r\n-\taiqStatsInputParams_.rgbs_grids = &rgbsGridPtr;\r\n+\taiqStatsInputParams_.rgbs_grids = &rgbsGridPtr_;\r\n+\r\n+\tafGridPtr_ = &afGrid_;\r\n \taiqStatsInputParams_.num_af_grids = 1;\r\n-\taiqStatsInputParams_.af_grids = &afGridPtr;\r\n+\taiqStatsInputParams_.af_grids = &afGridPtr_;\r\n \r\n \taiqStatsInputParams_.hdr_rgbs_grid = nullptr;\r\n \taiqStatsInputParams_.depth_grids = nullptr;\r\n \r\n-\treturn &aiqStatsInputParams_;\r\n-}\r\n+\taiqStatsInputParams_.num_external_histograms = 0;\r\n+\taiqStatsInputParams_.external_histograms = nullptr;\r\n \r\n-int IPAIPU3Stats::allocateStatBufferPools(int numBufs)\r\n-{\r\n-\tint ret = afFilterBuffPool_->init(numBufs);\r\n-\tret |= rgbsGridBuffPool_->init(numBufs);\r\n-\tif (ret != 0) {\r\n-\t\tLOG(IPAIPU3Stats, Error) << \"Failed to initialize 3A statistics pools\";\r\n-\t\tfreeStatBufferPools();\r\n-\t\treturn -ENOMEM;\r\n-\t}\r\n-#define IPU3_MAX_STATISTICS_WIDTH 80\r\n-#define IPU3_MAX_STATISTICS_HEIGHT 60\r\n-\tint maxGridSize = IPU3_MAX_STATISTICS_WIDTH * IPU3_MAX_STATISTICS_HEIGHT;\r\n-\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\r\n-\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\r\n-\r\n-\tfor (int allocated = 0; allocated < numBufs; allocated++) {\r\n-\t\tret = afFilterBuffPool_->acquireItem(afGrid);\r\n-\t\tret |= rgbsGridBuffPool_->acquireItem(rgbsGrid);\r\n-\r\n-\t\tif (ret != 0 || afGrid.get() == nullptr ||\r\n-\t\t    rgbsGrid.get() == nullptr) {\r\n-\t\t\tLOG(IPAIPU3Stats, Error) << \"Failed to acquire memory from pools\";\r\n-\t\t\tfreeStatBufferPools();\r\n-\t\t\treturn -ENOMEM;\r\n-\t\t}\r\n-\r\n-\t\trgbsGrid->blocks_ptr = new rgbs_grid_block[maxGridSize];\r\n-\t\trgbsGrid->grid_height = 0;\r\n-\t\trgbsGrid->grid_width = 0;\r\n-\r\n-\t\tafGrid->filter_response_1 = new int[maxGridSize];\r\n-\t\tafGrid->filter_response_2 = new int[maxGridSize];\r\n-\t\tafGrid->block_height = 0;\r\n-\t\tafGrid->block_width = 0;\r\n-\t\tafGrid->grid_height = 0;\r\n-\t\tafGrid->grid_width = 0;\r\n-\t}\r\n-\r\n-\treturn 0;\r\n-}\r\n+\t/* \\todo: Fill the face state after the integration of face detection. */\r\n+\taiqStatsInputParams_.faces = nullptr;\r\n \r\n-void IPAIPU3Stats::freeStatBufferPools()\r\n-{\r\n-\tif (!afFilterBuffPool_->isFull() || !rgbsGridBuffPool_->isFull()) {\r\n-\t\t/* We will leak if we errored out in allocateStatBufferPools*/\r\n-\t\tif (!afFilterBuffPool_->isFull())\r\n-\t\t\tLOG(IPAIPU3Stats, Warning) << \"AfFilterBuffPool is leaking\";\r\n-\t\tif (!rgbsGridBuffPool_->isFull())\r\n-\t\t\tLOG(IPAIPU3Stats, Warning) << \"RgbsGridBuffPool is leaking\";\r\n-\t}\r\n-\r\n-\tint ret;\r\n-\tsize_t availableItems = afFilterBuffPool_->availableItems();\r\n-\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\r\n-\tfor (size_t i = 0; i < availableItems; i++) {\r\n-\t\tret = afFilterBuffPool_->acquireItem(afGrid);\r\n-\t\tif (ret == 0 && afGrid.get() != nullptr) {\r\n-\t\t\tdelete[] afGrid->filter_response_1;\r\n-\t\t\tafGrid->filter_response_1 = nullptr;\r\n-\t\t\tdelete[] afGrid->filter_response_2;\r\n-\t\t\tafGrid->filter_response_2 = nullptr;\r\n-\t\t} else {\r\n-\t\t\tLOG(IPAIPU3Stats, Warning)\r\n-\t\t\t\t<< \"Could not acquire AF filter response \"\r\n-\t\t\t\t<< i << \"for deletion - leak?\";\r\n-\t\t}\r\n-\t}\r\n-\r\n-\tavailableItems = rgbsGridBuffPool_->availableItems();\r\n-\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\r\n-\tfor (size_t i = 0; i < availableItems; i++) {\r\n-\t\tret = rgbsGridBuffPool_->acquireItem(rgbsGrid);\r\n-\t\tif (ret == 0 && rgbsGrid.get() != nullptr) {\r\n-\t\t\tdelete[] rgbsGrid->blocks_ptr;\r\n-\t\t\trgbsGrid->blocks_ptr = nullptr;\r\n-\t\t} else {\r\n-\t\t\tLOG(IPAIPU3Stats, Warning)\r\n-\t\t\t\t<< \"Could not acquire RGBS grid \" << i\r\n-\t\t\t\t<< \"for deletion - leak?\";\r\n-\t\t}\r\n-\t}\r\n+\treturn &aiqStatsInputParams_;\r\n }\r\n \r\n } /* namespace libcamera::ipa::ipu3 */\r\ndiff --git a/stats/ipa_ipu3_stats.h b/stats/ipa_ipu3_stats.h\r\nindex 4320024..5f59558 100644\r\n--- a/stats/ipa_ipu3_stats.h\r\n+++ b/stats/ipa_ipu3_stats.h\r\n@@ -5,38 +5,47 @@\r\n  * IPAIPU3Stats.cpp: Generate statistics in IA AIQ consumable format.\r\n  */\r\n \r\n-#include \"aiq/aiq_results.h\"\r\n-\r\n #ifndef IPA_IPU3_STATS_H\r\n #define IPA_IPU3_STATS_H\r\n \r\n-#include <ia_imaging/ia_aiq_types.h>\r\n #include <linux/intel-ipu3.h>\r\n-\r\n-#include \"shared_item_pool.h\"\r\n+#include \"aiq/aiq_results.h\"\r\n \r\n namespace libcamera::ipa::ipu3 {\r\n \r\n+constexpr uint32_t IPU3MaxStatisticsWidth = 80;\r\n+constexpr uint32_t IPU3MaxStatisticsHeight = 60;\r\n+constexpr uint32_t IPU3MaxStatisticsGridSize =\r\n+\tIPU3MaxStatisticsWidth * IPU3MaxStatisticsHeight;\r\n+\r\n struct AiqResults;\r\n \r\n class IPAIPU3Stats\r\n {\r\n public:\r\n-\tIPAIPU3Stats();\r\n-\t~IPAIPU3Stats();\r\n+\tIPAIPU3Stats() = default;\r\n+\t~IPAIPU3Stats() = default;\r\n \r\n-\tia_aiq_statistics_input_params *\r\n-\tgetInputStatsParams(int frame,\r\n-\t\t\t    aiq::AiqResults *results,\r\n-\t\t\t    const ipu3_uapi_stats_3a *stats);\r\n+\tia_aiq_statistics_input_params* getInputStatsParams(\r\n+\t\t\tint frame,\r\n+\t\t\taiq::AiqResults *results,\r\n+\t\t\tconst ipu3_uapi_stats_3a *stats);\r\n \r\n private:\r\n-\tvoid freeStatBufferPools();\r\n-\tint allocateStatBufferPools(int numBufs);\r\n+\tia_aiq_statistics_input_params aiqStatsInputParams_ = {};\r\n+\r\n+\t/*!< ia_aiq_statistics_input_params pointer contents */\r\n+\tconst ia_aiq_rgbs_grid* rgbsGridPtr_ = nullptr;\r\n+\tconst ia_aiq_af_grid* afGridPtr_ = nullptr;\r\n+\tia_aiq_rgbs_grid rgbsGrid_ = {};\r\n+\tia_aiq_af_grid afGrid_ = {};\r\n+\r\n+\t/*!< ia_aiq_rgbs_grid pointer contents */\r\n+\trgbs_grid_block rgbsGridBlock_[IPU3MaxStatisticsGridSize] = {};\r\n \r\n-\tia_aiq_statistics_input_params aiqStatsInputParams_;\r\n-\tstd::shared_ptr<SharedItemPool<ia_aiq_af_grid>> afFilterBuffPool_;\r\n-\tstd::shared_ptr<SharedItemPool<ia_aiq_rgbs_grid>> rgbsGridBuffPool_;\r\n+\t/*!< ia_aiq_af_grid pointer contents */\r\n+\tint filterResponse1_[IPU3MaxStatisticsGridSize] = {};\r\n+\tint filterResponse2_[IPU3MaxStatisticsGridSize] = {};\r\n };\r\n \r\n } /* namespace libcamera::ipa::ipu3 */\r\ndiff --git a/stats/meson.build b/stats/meson.build\r\nindex 74ce657..e28a6b9 100644\r\n--- a/stats/meson.build\r\n+++ b/stats/meson.build\r\n@@ -3,6 +3,5 @@\r\n ipu3_ipa_files += files([\r\n     'ipa_ipu3_stats.cpp',\r\n     'ipu3_all_stats.cpp',\r\n-    'shared_item_pool.cpp',\r\n ])\r\n \r\ndiff --git a/stats/shared_item_pool.cpp b/stats/shared_item_pool.cpp\r\ndeleted file mode 100644\r\nindex 326a400..0000000\r\n--- a/stats/shared_item_pool.cpp\r\n+++ /dev/null\r\n@@ -1,129 +0,0 @@\r\n-/* SPDX-License-Identifier: Apache-2.0 */\r\n-/*\r\n- * Copyright (C) 2014-2018 Intel Corporation\r\n- *\r\n- * This implementation is highly derived from ChromeOS:\r\n- *   platform2/camera/hal/intel/ipu3/common/SharedItemPool.cpp\r\n- */\r\n-\r\n-#include <ia_imaging/ia_aiq_types.h>\r\n-\r\n-#include <libcamera/base/log.h>\r\n-\r\n-#include \"shared_item_pool.h\"\r\n-\r\n-namespace libcamera {\r\n-\r\n-LOG_DEFINE_CATEGORY(SharedItemPool)\r\n-\r\n-template<class ItemType>\r\n-SharedItemPool<ItemType>::SharedItemPool(const char *name)\r\n-\t: allocated_(nullptr), capacity_(0), deleter_(this), poolName_(name),\r\n-\t  resetter_(nullptr)\r\n-{\r\n-}\r\n-\r\n-template<class ItemType>\r\n-SharedItemPool<ItemType>::~SharedItemPool()\r\n-{\r\n-\tdeInit();\r\n-}\r\n-\r\n-template<class ItemType>\r\n-int SharedItemPool<ItemType>::init(int32_t capacity, void (*resetter)(ItemType *))\r\n-{\r\n-\tif (capacity_ != 0) {\r\n-\t\tLOG(SharedItemPool, Error) << \"Pool initialized already\";\r\n-\t\treturn -ENOSYS;\r\n-\t}\r\n-\tstd::lock_guard<std::mutex> l(mutex_);\r\n-\tresetter_ = resetter;\r\n-\tcapacity_ = capacity;\r\n-\tavailable_.reserve(capacity);\r\n-\tallocated_ = new ItemType[capacity];\r\n-\r\n-\tfor (int32_t i = 0; i < capacity; i++)\r\n-\t\tavailable_.push_back(&allocated_[i]);\r\n-\r\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_ << \"init with \" << capacity << \" items\";\r\n-\r\n-\treturn 0;\r\n-}\r\n-\r\n-template<class ItemType>\r\n-bool SharedItemPool<ItemType>::isFull()\r\n-{\r\n-\tstd::lock_guard<std::mutex> l(mutex_);\r\n-\tbool ret = (available_.size() == capacity_);\r\n-\treturn ret;\r\n-}\r\n-\r\n-template<class ItemType>\r\n-int SharedItemPool<ItemType>::deInit()\r\n-{\r\n-\tstd::lock_guard<std::mutex> l(mutex_);\r\n-\tif (capacity_ == 0) {\r\n-\t\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\r\n-\t\t\t\t\t   << \" isn't initialized or already de-initialized\";\r\n-\t\treturn 0;\r\n-\t}\r\n-\tif (available_.size() != capacity_) {\r\n-\t\tLOG(SharedItemPool, Error) << \"Not all items are returned \"\r\n-\t\t\t\t\t   << \"when destroying pool \" << poolName_\r\n-\t\t\t\t\t   << \"(\" << available_.size() << \"/\" << capacity_ << \")\";\r\n-\t}\r\n-\r\n-\tdelete[] allocated_;\r\n-\tallocated_ = nullptr;\r\n-\tavailable_.clear();\r\n-\tcapacity_ = 0;\r\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\r\n-\t\t\t\t   << \" deinit done\";\r\n-\r\n-\treturn 0;\r\n-}\r\n-\r\n-template<class ItemType>\r\n-int SharedItemPool<ItemType>::acquireItem(std::shared_ptr<ItemType> &item)\r\n-{\r\n-\titem.reset();\r\n-\tstd::lock_guard<std::mutex> l(mutex_);\r\n-\tif (available_.empty()) {\r\n-\t\tLOG(SharedItemPool, Error) << \"Shared pool \" << poolName_\r\n-\t\t\t\t\t   << \"is empty\";\r\n-\t\treturn -ENOSYS;\r\n-\t}\r\n-\r\n-\tstd::shared_ptr<ItemType> sh(available_[0], deleter_);\r\n-\tavailable_.erase(available_.begin());\r\n-\titem = sh;\r\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\r\n-\t\t\t\t   << \"acquire items \" << sh.get();\r\n-\treturn 0;\r\n-}\r\n-\r\n-template<class ItemType>\r\n-size_t SharedItemPool<ItemType>::availableItems()\r\n-{\r\n-\tstd::lock_guard<std::mutex> l(mutex_);\r\n-\tsize_t ret = available_.size();\r\n-\treturn ret;\r\n-}\r\n-\r\n-template<class ItemType>\r\n-int SharedItemPool<ItemType>::_releaseItem(ItemType *item)\r\n-{\r\n-\tstd::lock_guard<std::mutex> l(mutex_);\r\n-\tif (resetter_)\r\n-\t\tresetter_(item);\r\n-\r\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\r\n-\t\t\t\t   << \"returning item \" << item;\r\n-\r\n-\tavailable_.push_back(item);\r\n-\treturn 0;\r\n-}\r\n-\r\n-template class SharedItemPool<ia_aiq_rgbs_grid>;\r\n-template class SharedItemPool<ia_aiq_af_grid>;\r\n-} /* namespace libcamera */\r\ndiff --git a/stats/shared_item_pool.h b/stats/shared_item_pool.h\r\ndeleted file mode 100644\r\nindex 89dc9b3..0000000\r\n--- a/stats/shared_item_pool.h\r\n+++ /dev/null\r\n@@ -1,114 +0,0 @@\r\n-/* SPDX-License-Identifier: Apache-2.0 */\r\n-/*\r\n- * Copyright (C) 2014-2018 Intel Corporation\r\n- *\r\n- * This implementation is highly derived from ChromeOS:\r\n- *   platform2/camera/hal/intel/ipu3/common/SharedItemPool.h\r\n- */\r\n-\r\n-#ifndef SHARED_ITEM_POOL_H\r\n-#define SHARED_ITEM_POOL_H\r\n-\r\n-#include <memory>\r\n-#include <mutex>\r\n-#include <pthread.h>\r\n-#include <vector>\r\n-\r\n-/**\r\n- * \\class SharedItemPool\r\n- *\r\n- * Pool of ref counted items. This class creates a pool of items and manages\r\n- * the acquisition of them. When all references to this item have disappeared\r\n- * The item is returned to the pool.\r\n- *\r\n- * This class is thread safe, i.e. it can be called from  multiple threads.\r\n- * When the element is recycled to the pool it can be reset via a client\r\n- * provided method.\r\n- *\r\n- */\r\n-\r\n-namespace libcamera {\r\n-\r\n-template<class ItemType>\r\n-class SharedItemPool\r\n-{\r\n-public:\r\n-\tSharedItemPool(const char *name = \"Unnamed\");\r\n-\t~SharedItemPool();\r\n-\r\n-\t/**\r\n-\t * Initializes the capacity of the pool. It allocates the objects.\r\n-\t * optionally it will take function to reset the item before recycling\r\n-\t * it to the pool.\r\n-\t * This method is thread safe.\r\n-\t *\r\n-\t * \\param capacity[IN]: Number of items the pool will hold\r\n-\t * \\param resetter[IN]: Function to reset the item before recycling to the\r\n-\t *                      pool.\r\n-\t * \\return -ENOSYS if trying to initialize twice\r\n-\t * \\return 0 If everything went ok.\r\n-\t */\r\n-\tint init(int32_t capacity, void (*resetter)(ItemType *) = nullptr);\r\n-\r\n-\tbool isFull();\r\n-\r\n-\t/**\r\n-\t * Free the resources of the pool\r\n-\t *\r\n-\t * \\return 0 on success\r\n-\t */\r\n-\tint deInit();\r\n-\r\n-\t/**\r\n-\t * Acquire an item from the pool.\r\n-\t * This method is thread safe. Access to the internal acquire/release\r\n-\t * methods are protected.\r\n-\t * BUT the thread-safety for the utilization of the item after it has been\r\n-\t * acquired is the user's responsibility.\r\n-\t * Be careful not to provide the same item to multiple threads that write\r\n-\t * into it.\r\n-\t *\r\n-\t * \\param item[OUT] shared pointer to an item.\r\n-\t * \\return 0 on success\r\n-\t */\r\n-\tint acquireItem(std::shared_ptr<ItemType> &item);\r\n-\r\n-\t/**\r\n-\t * Returns the number of currently available items\r\n-\t * It there would be issues acquiring the lock the method returns 0\r\n-\t * available items.\r\n-\t *\r\n-\t * \\return item count\r\n-\t */\r\n-\tsize_t availableItems();\r\n-\r\n-private:\r\n-\tint _releaseItem(ItemType *item);\r\n-\r\n-\tclass ItemDeleter\r\n-\t{\r\n-\tpublic:\r\n-\t\tItemDeleter(SharedItemPool *pool)\r\n-\t\t\t: mPool(pool) {}\r\n-\t\tvoid operator()(ItemType *item) const\r\n-\t\t{\r\n-\t\t\tmPool->_releaseItem(item);\r\n-\t\t}\r\n-\r\n-\tprivate:\r\n-\t\tSharedItemPool *mPool;\r\n-\t};\r\n-\r\n-\tstd::vector<ItemType *> available_; /* SharedItemPool doesn't have ownership */\r\n-\tItemType *allocated_;\r\n-\tsize_t capacity_;\r\n-\tItemDeleter deleter_;\r\n-\tstd::mutex mutex_; /* protects available_, allocated_, capacity_ */\r\n-\tconst char *poolName_;\r\n-\tvoid (*resetter_)(ItemType *);\r\n-};\r\n-\r\n-} /* namespace libcamera */\r\n-\r\n-#endif /* SHARED_ITEM_POOL_H */\r\n-",
    "prefixes": [
        "libcamera-devel",
        "1/3"
    ]
}