Show a patch.

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

{
    "id": 14068,
    "url": "https://patchwork.libcamera.org/api/patches/14068/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14068/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20211007072147.1289490-2-hanlinchen@chromium.org>",
    "date": "2021-10-07T07:21:46",
    "name": "[libcamera-devel,v2,2/3] ipu3: Change Macro migrated from Chrome OS to its std version accordingly",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "88b115b17322265c96aa89c7596a0d8c1fe9bc41",
    "submitter": {
        "id": 98,
        "url": "https://patchwork.libcamera.org/api/people/98/?format=api",
        "name": "Hanlin Chen",
        "email": "hanlinchen@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14068/mbox/",
    "series": [
        {
            "id": 2606,
            "url": "https://patchwork.libcamera.org/api/series/2606/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2606",
            "date": "2021-10-07T07:21:45",
            "name": "[libcamera-devel,v2,1/3] ipu3: Remove the usage of SharedItemPool",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2606/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14068/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14068/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\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 118B9C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Oct 2021 07:22:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CA650691C0;\n\tThu,  7 Oct 2021 09:22:15 +0200 (CEST)",
            "from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com\n\t[IPv6:2607:f8b0:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BCB4C691B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Oct 2021 09:22:14 +0200 (CEST)",
            "by mail-pf1-x42d.google.com with SMTP id k26so4575909pfi.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Oct 2021 00:22:14 -0700 (PDT)",
            "from localhost ([2401:fa00:1:10:db0a:f55:d7cb:95ae])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tw15sm12037750pfc.220.2021.10.07.00.22.11\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 07 Oct 2021 00:22:12 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Qm8cSoV6\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=zzpINsVDQqtol6mpAOE9QUl+unDwpbdAubYUqnR7CZo=;\n\tb=Qm8cSoV6f7GaJl0F8gvdSx3q0pEm/QK6Ycw6thgj97G01qUi/m2+EnxqEl0cDGstWj\n\tj0OaaduBnAaWMO5aP5stzebNIPdXXIKkJI+umqTpr7NvB6aM7WlL4X9bgeHrTxdiZcbI\n\t0lOLCu1d2WPZmP7dhOmIrEeAzhFe63TZluxJY=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=zzpINsVDQqtol6mpAOE9QUl+unDwpbdAubYUqnR7CZo=;\n\tb=vDaSSazTgJPSHjlbrpiNjPzaVSecJzrsFpWqaewiOUDG+cpVtloMvNVfNtaBjtQSgw\n\tqeGOdBfkMPp3ODm9/Esdo0dD/Cxm7lDLfD1UTl+0wOOayKvKZU3WEQvSLRcbZEkStssS\n\thiI2GBMHkiPDOhQxo7lEe0eXdPM/n/TQvk7PxI8XvWt/dNMaFkgQloMhmAnO3xNhBSr+\n\tuBidigk60svUXpcQ7nXt9I6/b4wNZqCQyeJVdd3mSQedFJT3ccNEpeJnK1cjV4oc7IN/\n\tj87FEEHNQULjQ0fL3RVhiyiSgyM1JNNkyLSjRT1saPVdtd3msEQFpuDrIP00UpFiBnoq\n\t1hXA==",
        "X-Gm-Message-State": "AOAM5339+9Nl6AfZq6efdVOOidHmQAVH1sd7F46uUEPcqdxsrqmzF6qK\n\tlpWQbl8WJ0b+WZRSkOO1VI/7+WWof6qQim/lAK0=",
        "X-Google-Smtp-Source": "ABdhPJwLAAvE7FhdCJ9aoGN0gxXcEdoffPk7WonBKfp+ukiFGj+KQ6T7Ay1duGctG8a+9Kr/w6/BLg==",
        "X-Received": "by 2002:a63:392:: with SMTP id 140mr2182448pgd.189.1633591332873;\n\tThu, 07 Oct 2021 00:22:12 -0700 (PDT)",
        "From": "Han-Lin Chen <hanlinchen@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  7 Oct 2021 15:21:46 +0800",
        "Message-Id": "<20211007072147.1289490-2-hanlinchen@chromium.org>",
        "X-Mailer": "git-send-email 2.33.0.882.g93a45727a2-goog",
        "In-Reply-To": "<20211007072147.1289490-1-hanlinchen@chromium.org>",
        "References": "<20211007072147.1289490-1-hanlinchen@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 2/3] ipu3: Change Macro migrated from\n\tChrome OS to its std version accordingly",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Change the Macro STDCOPY, MEMCPY_S and CLEAR to its std version to better\nsuit the style. The patch also fix misusage of STDCOPY as memcpy, which\nleads to copying overflown in PA and SA results.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n aiq/aiq_input_parameters.cpp | 50 +++++++++-----------\n aiq/aiq_results.cpp          | 91 +++++++++++++++---------------------\n 2 files changed, 58 insertions(+), 83 deletions(-)",
    "diff": "diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp\nindex 56301f6..8a53849 100644\n--- a/aiq/aiq_input_parameters.cpp\n+++ b/aiq/aiq_input_parameters.cpp\n@@ -14,11 +14,6 @@\n \n #include <libcamera/base/log.h>\n \n-/* Macros used by imported code */\n-#define STDCOPY(dst, src, size) std::copy((src), ((src) + (size)), (dst))\n-#define MEMCPY_S(dest, dmax, src, smax) memcpy((dest), (src), std::min((size_t)(dmax), (size_t)(smax)))\n-#define CLEAR(x) memset(&(x), 0, sizeof(x))\n-\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(AIQInputParameters)\n@@ -27,26 +22,26 @@ namespace ipa::ipu3::aiq {\n \n void AiqInputParameters::init()\n {\n-\tCLEAR(aeInputParams);\n-\tCLEAR(afParams);\n-\tCLEAR(afBracketParams);\n-\tCLEAR(awbParams);\n-\tCLEAR(gbceParams);\n-\tCLEAR(paParams);\n-\tCLEAR(saParams);\n-\tCLEAR(sensorDescriptor);\n-\tCLEAR(exposureWindow);\n-\tCLEAR(exposureCoordinate);\n-\tCLEAR(aeFeatures);\n-\tCLEAR(aeManualLimits);\n-\tCLEAR(manualFocusParams);\n-\tCLEAR(focusRect);\n-\tCLEAR(manualCctRange);\n-\tCLEAR(manualWhiteCoordinate);\n-\tCLEAR(awbResults);\n-\tCLEAR(colorGains);\n-\tCLEAR(exposureParams);\n-\tCLEAR(sensorFrameParams);\n+\taeInputParams = {};\n+\tafParams = {};\n+\tafBracketParams = {};\n+\tawbParams = {};\n+\tgbceParams = {};\n+\tpaParams = {};\n+\tsaParams = {};\n+\tsensorDescriptor = {};\n+\texposureWindow = {};\n+\texposureCoordinate = {};\n+\taeFeatures = {};\n+\taeManualLimits = {};\n+\tmanualFocusParams = {};\n+\tfocusRect = {};\n+\tmanualCctRange = {};\n+\tmanualWhiteCoordinate = {};\n+\tawbResults = {};\n+\tcolorGains = {};\n+\texposureParams = {};\n+\tsensorFrameParams = {};\n \taeLock = false;\n \tawbLock = false;\n \tblackLevelLock = false;\n@@ -102,10 +97,7 @@ AiqInputParameters &AiqInputParameters::operator=(const AiqInputParameters &othe\n \tif (this == &other)\n \t\treturn *this;\n \n-\tMEMCPY_S(this,\n-\t\t sizeof(AiqInputParameters),\n-\t\t &other,\n-\t\t sizeof(AiqInputParameters));\n+\tmemcpy(this, &other, sizeof(AiqInputParameters));\n \treset();\n \n \t/* Exposure coordinate is nullptr in other than SPOT mode. */\ndiff --git a/aiq/aiq_results.cpp b/aiq/aiq_results.cpp\nindex 9dda17c..f727f36 100644\n--- a/aiq/aiq_results.cpp\n+++ b/aiq/aiq_results.cpp\n@@ -14,9 +14,6 @@\n \n #include <libcamera/base/log.h>\n \n-/* Macros used by imported code */\n-#define STDCOPY(dst, src, size) std::copy((src), ((src) + (size)), (dst))\n-\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(AIQResults)\n@@ -111,17 +108,14 @@ void AiqResults::setAe(ia_aiq_ae_results *ae)\n \t\t\t\t\t    ae->weight_grid->height;\n \t\tgridElements = std::clamp<unsigned int>(gridElements, 1, MAX_AE_GRID_SIZE);\n \n-\t\tSTDCOPY(ae_.weight_grid->weights,\n-\t\t\tae->weight_grid->weights,\n-\t\t\tgridElements * sizeof(char));\n+\t\tstd::copy_n(ae->weight_grid->weights, gridElements, ae_.weight_grid->weights);\n \t} else {\n \t\tLOG(AIQResults, Error) << \"Not copying AE Weight Grids\";\n \t}\n \n \t// Copy the flash info structure\n \tif (ae_.flashes && ae->flashes) {\n-\t\tSTDCOPY((int8_t *)ae_.flashes, (int8_t *)ae->flashes,\n-\t\t\tNUM_FLASH_LEDS * sizeof(ia_aiq_flash_parameters));\n+\t\tstd::copy_n(ae->flashes, NUM_FLASH_LEDS, ae_.flashes);\n \t} else {\n \t\tLOG(AIQResults, Error) << \"Not copying AE Flashes\";\n \t}\n@@ -172,20 +166,16 @@ void AiqResults::setGbce(ia_aiq_gbce_results *gbce)\n \n \t\tgbce_.gamma_lut_size = gbce->gamma_lut_size;\n \n-\t\tSTDCOPY((int8_t *)gbce_.r_gamma_lut, (int8_t *)gbce->r_gamma_lut,\n-\t\t\tgbce->gamma_lut_size * sizeof(float));\n-\t\tSTDCOPY((int8_t *)gbce_.b_gamma_lut, (int8_t *)gbce->b_gamma_lut,\n-\t\t\tgbce->gamma_lut_size * sizeof(float));\n-\t\tSTDCOPY((int8_t *)gbce_.g_gamma_lut, (int8_t *)gbce->g_gamma_lut,\n-\t\t\tgbce->gamma_lut_size * sizeof(float));\n+\t\tstd::copy_n(gbce->r_gamma_lut, gbce->gamma_lut_size, gbce_.r_gamma_lut);\n+\t\tstd::copy_n(gbce->b_gamma_lut, gbce->gamma_lut_size, gbce_.b_gamma_lut);\n+\t\tstd::copy_n(gbce->g_gamma_lut, gbce->gamma_lut_size, gbce_.g_gamma_lut);\n \t} else {\n \t\tLOG(AIQResults, Error) << \"Not copying Gamma LUT channels\";\n \t}\n \n \tif (gbce->tone_map_lut_size > 0) {\n \t\tgbce_.tone_map_lut_size = gbce->tone_map_lut_size;\n-\t\tSTDCOPY((int8_t *)gbce_.tone_map_lut, (int8_t *)gbce->tone_map_lut,\n-\t\t\tgbce->tone_map_lut_size * sizeof(float));\n+\t\tstd::copy_n(gbce->tone_map_lut, gbce->tone_map_lut_size, gbce_.tone_map_lut);\n \t} else {\n \t\tLOG(AIQResults, Error) << \"Not copying Tone Mapping Gain LUT\";\n \t}\n@@ -200,20 +190,20 @@ void AiqResults::setPa(ia_aiq_pa_results *pa)\n {\n \tASSERT(pa);\n \n-\tSTDCOPY(&pa_.color_conversion_matrix[0][0], &pa->color_conversion_matrix[0][0],\n-\t\tMAX_COLOR_CONVERSION_MATRIX * MAX_COLOR_CONVERSION_MATRIX *\n-\t\t\tsizeof(pa->color_conversion_matrix[0][0]));\n+\tstd::copy_n(&pa->color_conversion_matrix[0][0],\n+\t\t\tMAX_COLOR_CONVERSION_MATRIX * MAX_COLOR_CONVERSION_MATRIX,\n+\t\t\t&pa_.color_conversion_matrix[0][0]);\n \n \tif (pa_.preferred_acm && pa->preferred_acm) {\n \t\tpa_.preferred_acm->sector_count = pa->preferred_acm->sector_count;\n \n-\t\tSTDCOPY(pa_.preferred_acm->hue_of_sectors,\n-\t\t\tpa->preferred_acm->hue_of_sectors,\n-\t\t\tsizeof(*pa->preferred_acm->hue_of_sectors) * pa->preferred_acm->sector_count);\n+\t\tstd::copy_n(pa->preferred_acm->hue_of_sectors,\n+\t\t\tpa->preferred_acm->sector_count,\n+\t\t\tpa_.preferred_acm->hue_of_sectors);\n \n-\t\tSTDCOPY(pa_.preferred_acm->advanced_color_conversion_matrices[0][0],\n-\t\t\tpa->preferred_acm->advanced_color_conversion_matrices[0][0],\n-\t\t\tsizeof(*pa->preferred_acm->advanced_color_conversion_matrices) * pa->preferred_acm->sector_count);\n+\t\tstd::copy_n(pa->preferred_acm->advanced_color_conversion_matrices[0][0],\n+\t\t\tpa->preferred_acm->sector_count,\n+\t\t\tpa_.preferred_acm->advanced_color_conversion_matrices[0][0]);\n \t} else {\n \t\tLOG(AIQResults, Error) << \"Not copying PA hue of sectors\";\n \t}\n@@ -222,17 +212,17 @@ void AiqResults::setPa(ia_aiq_pa_results *pa)\n \t\tpa_.ir_weight->height = pa->ir_weight->height;\n \t\tpa_.ir_weight->width = pa->ir_weight->width;\n \n-\t\tSTDCOPY(pa_.ir_weight->ir_weight_grid_R,\n-\t\t\tpa->ir_weight->ir_weight_grid_R,\n-\t\t\tsizeof(*pa->ir_weight->ir_weight_grid_R) * pa->ir_weight->height * pa->ir_weight->width);\n+\t\tstd::copy_n(pa->ir_weight->ir_weight_grid_R,\n+\t\t\tpa->ir_weight->height * pa->ir_weight->width,\n+\t\t\tpa_.ir_weight->ir_weight_grid_R);\n \n-\t\tSTDCOPY(pa_.ir_weight->ir_weight_grid_G,\n-\t\t\tpa->ir_weight->ir_weight_grid_G,\n-\t\t\tsizeof(*pa->ir_weight->ir_weight_grid_G) * pa->ir_weight->height * pa->ir_weight->width);\n+\t\tstd::copy_n(pa->ir_weight->ir_weight_grid_G,\n+\t\t\tpa->ir_weight->height * pa->ir_weight->width,\n+\t\t\tpa_.ir_weight->ir_weight_grid_G);\n \n-\t\tSTDCOPY(pa_.ir_weight->ir_weight_grid_B,\n-\t\t\tpa->ir_weight->ir_weight_grid_B,\n-\t\t\tsizeof(*pa->ir_weight->ir_weight_grid_B) * pa->ir_weight->height * pa->ir_weight->width);\n+\t\tstd::copy_n(pa->ir_weight->ir_weight_grid_B,\n+\t\t\tpa->ir_weight->height * pa->ir_weight->width,\n+\t\t\tpa_.ir_weight->ir_weight_grid_B);\n \t} else {\n \t\tLOG(AIQResults, Error) << \"Not copying IR weight\";\n \t}\n@@ -253,13 +243,13 @@ void AiqResults::setSa(ia_aiq_sa_results *sa)\n \tsa_.height = sa->height;\n \tsa_.lsc_update = sa->lsc_update;\n \n+\tuint32_t lscGridSize = sa_.width * sa_.height;\n \t/* Check against one of the vectors but resize applicable to all. */\n-\tif (channelGr_.size() < (sa_.width * sa_.height)) {\n-\t\tint lscNewSize = sa_.width * sa_.height;\n-\t\tchannelGr_.resize(lscNewSize);\n-\t\tchannelGb_.resize(lscNewSize);\n-\t\tchannelR_.resize(lscNewSize);\n-\t\tchannelB_.resize(lscNewSize);\n+\tif (channelGr_.size() < lscGridSize) {\n+\t\tchannelGr_.resize(lscGridSize);\n+\t\tchannelGb_.resize(lscGridSize);\n+\t\tchannelR_.resize(lscGridSize);\n+\t\tchannelB_.resize(lscGridSize);\n \n \t\t/* Update the SA data pointers to new memory locations. */\n \t\tsa_.channel_gr = channelGr_.data();\n@@ -269,23 +259,16 @@ void AiqResults::setSa(ia_aiq_sa_results *sa)\n \t}\n \n \tif (sa->lsc_update) {\n-\t\tuint32_t memCopySize = sa->width * sa->height * sizeof(float);\n-\n-\t\tSTDCOPY((int8_t *)sa_.channel_gr, (int8_t *)sa->channel_gb,\n-\t\t\tmemCopySize);\n-\t\tSTDCOPY((int8_t *)sa_.channel_gb, (int8_t *)sa->channel_gr,\n-\t\t\tmemCopySize);\n-\t\tSTDCOPY((int8_t *)sa_.channel_r, (int8_t *)sa->channel_r,\n-\t\t\tmemCopySize);\n-\t\tSTDCOPY((int8_t *)sa_.channel_b, (int8_t *)sa->channel_b,\n-\t\t\tmemCopySize);\n+\t\tstd::copy_n(sa->channel_gr, lscGridSize, sa_.channel_gr);\n+\t\tstd::copy_n(sa->channel_gb, lscGridSize, sa_.channel_gb);\n+\t\tstd::copy_n(sa->channel_r, lscGridSize, sa_.channel_r);\n+\t\tstd::copy_n(sa->channel_b, lscGridSize, sa_.channel_b);\n \t} else {\n-\t\tLOG(AIQResults, Error) << \"Not copying LSC tables.\";\n+\t\tLOG(AIQResults, Debug) << \"Not copying LSC tables.\";\n \t}\n \n-\tSTDCOPY(&sa_.light_source[0],\n-\t\t&sa->light_source[0],\n-\t\tCMC_NUM_LIGHTSOURCES * sizeof(sa->light_source[0]));\n+\tstd::copy_n(&sa->light_source[0], CMC_NUM_LIGHTSOURCES, &sa_.light_source[0]);\n+\n \tsa_.scene_difficulty = sa->scene_difficulty;\n \tsa_.num_patches = sa->num_patches;\n \tsa_.covered_area = sa->covered_area;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/3"
    ]
}