Show a patch.

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

{
    "id": 14038,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14038/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14038/",
    "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.445.1633340916.837.libcamera-devel@lists.libcamera.org>",
    "date": "2021-10-04T09:48:22",
    "name": "[libcamera-devel,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": "9f30f8d238b96ffa90fd2e70807daa5bd527eae4",
    "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/14038/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/14038/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14038/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 9DF76C3243\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tMon,  4 Oct 2021 09:48:37 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C5B7691B8;\r\n\tMon,  4 Oct 2021 11:48:37 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1633340917;\r\n\tbh=aZs5cb3UIqcfxO5bxh/cT5pGZJMPl8t/1xB8xduk254=;\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=BYhZ81zUOvDgmUcD6PLBfGmyhg3iNbf/9tBokrfXtmxB8Hj78usxQdeOXYiMMNx9u\r\n\t9Kgu51WXqUDlPCT2TfO2myEaMq8EgvpRSzU4TteqEczZcL9A/kqAOUStlBNWvJ/gm5\r\n\tp0dtRlmW599JgQlxNWkeHoKhVW3Cr9uRyscVYRwF9n0pYVkIel57Lla2tiCN1lHLY4\r\n\teKDuU6GlsYhJy6EvkWCaSBkCqNGJEuMoe04cXfvE6E+24gRuhayuI6+INd/KhC0aOt\r\n\tIJqnDJQybhkISNJe+gg11MmueuXTQGqnXFndi4sPtbUIPZ8u8mdpvdddRf+c/9t3im\r\n\tke8RqE+UcpEZQ==",
        "Date": "Mon,  4 Oct 2021 17:48:22 +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.445.1633340916.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 2/3] ipu3: Change Macro migrated from\r\n\tChrome OS to its std version accordingly",
        "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\nChange 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@google.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\r\nindex 56301f6..56e8513 100644\r\n--- a/aiq/aiq_input_parameters.cpp\r\n+++ b/aiq/aiq_input_parameters.cpp\r\n@@ -14,11 +14,6 @@\r\n \r\n #include <libcamera/base/log.h>\r\n \r\n-/* Macros used by imported code */\r\n-#define STDCOPY(dst, src, size) std::copy((src), ((src) + (size)), (dst))\r\n-#define MEMCPY_S(dest, dmax, src, smax) memcpy((dest), (src), std::min((size_t)(dmax), (size_t)(smax)))\r\n-#define CLEAR(x) memset(&(x), 0, sizeof(x))\r\n-\r\n namespace libcamera {\r\n \r\n LOG_DEFINE_CATEGORY(AIQInputParameters)\r\n@@ -27,26 +22,26 @@ namespace ipa::ipu3::aiq {\r\n \r\n void AiqInputParameters::init()\r\n {\r\n-\tCLEAR(aeInputParams);\r\n-\tCLEAR(afParams);\r\n-\tCLEAR(afBracketParams);\r\n-\tCLEAR(awbParams);\r\n-\tCLEAR(gbceParams);\r\n-\tCLEAR(paParams);\r\n-\tCLEAR(saParams);\r\n-\tCLEAR(sensorDescriptor);\r\n-\tCLEAR(exposureWindow);\r\n-\tCLEAR(exposureCoordinate);\r\n-\tCLEAR(aeFeatures);\r\n-\tCLEAR(aeManualLimits);\r\n-\tCLEAR(manualFocusParams);\r\n-\tCLEAR(focusRect);\r\n-\tCLEAR(manualCctRange);\r\n-\tCLEAR(manualWhiteCoordinate);\r\n-\tCLEAR(awbResults);\r\n-\tCLEAR(colorGains);\r\n-\tCLEAR(exposureParams);\r\n-\tCLEAR(sensorFrameParams);\r\n+\tmemset(&aeInputParams, 0, sizeof(aeInputParams));\r\n+\tmemset(&afParams, 0, sizeof(afParams));\r\n+\tmemset(&afBracketParams, 0, sizeof(afBracketParams));\r\n+\tmemset(&awbParams, 0, sizeof(awbParams));\r\n+\tmemset(&gbceParams, 0, sizeof(gbceParams));\r\n+\tmemset(&paParams, 0, sizeof(paParams));\r\n+\tmemset(&saParams, 0, sizeof(saParams));\r\n+\tmemset(&sensorDescriptor, 0, sizeof(sensorDescriptor));\r\n+\tmemset(&exposureWindow, 0, sizeof(exposureWindow));\r\n+\tmemset(&exposureCoordinate, 0, sizeof(exposureCoordinate));\r\n+\tmemset(&aeFeatures, 0, sizeof(aeFeatures));\r\n+\tmemset(&aeManualLimits, 0, sizeof(aeManualLimits));\r\n+\tmemset(&manualFocusParams, 0, sizeof(manualFocusParams));\r\n+\tmemset(&focusRect, 0, sizeof(focusRect));\r\n+\tmemset(&manualCctRange, 0, sizeof(manualCctRange));\r\n+\tmemset(&manualWhiteCoordinate, 0, sizeof(manualWhiteCoordinate));\r\n+\tmemset(&awbResults, 0, sizeof(awbResults));\r\n+\tmemset(&colorGains, 0, sizeof(colorGains));\r\n+\tmemset(&exposureParams, 0, sizeof(exposureParams));\r\n+\tmemset(&sensorFrameParams, 0, sizeof(sensorFrameParams));\r\n \taeLock = false;\r\n \tawbLock = false;\r\n \tblackLevelLock = false;\r\n@@ -102,10 +97,7 @@ AiqInputParameters &AiqInputParameters::operator=(const AiqInputParameters &othe\r\n \tif (this == &other)\r\n \t\treturn *this;\r\n \r\n-\tMEMCPY_S(this,\r\n-\t\t sizeof(AiqInputParameters),\r\n-\t\t &other,\r\n-\t\t sizeof(AiqInputParameters));\r\n+\tmemcpy(this, &other, sizeof(AiqInputParameters));\r\n \treset();\r\n \r\n \t/* Exposure coordinate is nullptr in other than SPOT mode. */\r\ndiff --git a/aiq/aiq_results.cpp b/aiq/aiq_results.cpp\r\nindex 9dda17c..f727f36 100644\r\n--- a/aiq/aiq_results.cpp\r\n+++ b/aiq/aiq_results.cpp\r\n@@ -14,9 +14,6 @@\r\n \r\n #include <libcamera/base/log.h>\r\n \r\n-/* Macros used by imported code */\r\n-#define STDCOPY(dst, src, size) std::copy((src), ((src) + (size)), (dst))\r\n-\r\n namespace libcamera {\r\n \r\n LOG_DEFINE_CATEGORY(AIQResults)\r\n@@ -111,17 +108,14 @@ void AiqResults::setAe(ia_aiq_ae_results *ae)\r\n \t\t\t\t\t    ae->weight_grid->height;\r\n \t\tgridElements = std::clamp<unsigned int>(gridElements, 1, MAX_AE_GRID_SIZE);\r\n \r\n-\t\tSTDCOPY(ae_.weight_grid->weights,\r\n-\t\t\tae->weight_grid->weights,\r\n-\t\t\tgridElements * sizeof(char));\r\n+\t\tstd::copy_n(ae->weight_grid->weights, gridElements, ae_.weight_grid->weights);\r\n \t} else {\r\n \t\tLOG(AIQResults, Error) << \"Not copying AE Weight Grids\";\r\n \t}\r\n \r\n \t// Copy the flash info structure\r\n \tif (ae_.flashes && ae->flashes) {\r\n-\t\tSTDCOPY((int8_t *)ae_.flashes, (int8_t *)ae->flashes,\r\n-\t\t\tNUM_FLASH_LEDS * sizeof(ia_aiq_flash_parameters));\r\n+\t\tstd::copy_n(ae->flashes, NUM_FLASH_LEDS, ae_.flashes);\r\n \t} else {\r\n \t\tLOG(AIQResults, Error) << \"Not copying AE Flashes\";\r\n \t}\r\n@@ -172,20 +166,16 @@ void AiqResults::setGbce(ia_aiq_gbce_results *gbce)\r\n \r\n \t\tgbce_.gamma_lut_size = gbce->gamma_lut_size;\r\n \r\n-\t\tSTDCOPY((int8_t *)gbce_.r_gamma_lut, (int8_t *)gbce->r_gamma_lut,\r\n-\t\t\tgbce->gamma_lut_size * sizeof(float));\r\n-\t\tSTDCOPY((int8_t *)gbce_.b_gamma_lut, (int8_t *)gbce->b_gamma_lut,\r\n-\t\t\tgbce->gamma_lut_size * sizeof(float));\r\n-\t\tSTDCOPY((int8_t *)gbce_.g_gamma_lut, (int8_t *)gbce->g_gamma_lut,\r\n-\t\t\tgbce->gamma_lut_size * sizeof(float));\r\n+\t\tstd::copy_n(gbce->r_gamma_lut, gbce->gamma_lut_size, gbce_.r_gamma_lut);\r\n+\t\tstd::copy_n(gbce->b_gamma_lut, gbce->gamma_lut_size, gbce_.b_gamma_lut);\r\n+\t\tstd::copy_n(gbce->g_gamma_lut, gbce->gamma_lut_size, gbce_.g_gamma_lut);\r\n \t} else {\r\n \t\tLOG(AIQResults, Error) << \"Not copying Gamma LUT channels\";\r\n \t}\r\n \r\n \tif (gbce->tone_map_lut_size > 0) {\r\n \t\tgbce_.tone_map_lut_size = gbce->tone_map_lut_size;\r\n-\t\tSTDCOPY((int8_t *)gbce_.tone_map_lut, (int8_t *)gbce->tone_map_lut,\r\n-\t\t\tgbce->tone_map_lut_size * sizeof(float));\r\n+\t\tstd::copy_n(gbce->tone_map_lut, gbce->tone_map_lut_size, gbce_.tone_map_lut);\r\n \t} else {\r\n \t\tLOG(AIQResults, Error) << \"Not copying Tone Mapping Gain LUT\";\r\n \t}\r\n@@ -200,20 +190,20 @@ void AiqResults::setPa(ia_aiq_pa_results *pa)\r\n {\r\n \tASSERT(pa);\r\n \r\n-\tSTDCOPY(&pa_.color_conversion_matrix[0][0], &pa->color_conversion_matrix[0][0],\r\n-\t\tMAX_COLOR_CONVERSION_MATRIX * MAX_COLOR_CONVERSION_MATRIX *\r\n-\t\t\tsizeof(pa->color_conversion_matrix[0][0]));\r\n+\tstd::copy_n(&pa->color_conversion_matrix[0][0],\r\n+\t\t\tMAX_COLOR_CONVERSION_MATRIX * MAX_COLOR_CONVERSION_MATRIX,\r\n+\t\t\t&pa_.color_conversion_matrix[0][0]);\r\n \r\n \tif (pa_.preferred_acm && pa->preferred_acm) {\r\n \t\tpa_.preferred_acm->sector_count = pa->preferred_acm->sector_count;\r\n \r\n-\t\tSTDCOPY(pa_.preferred_acm->hue_of_sectors,\r\n-\t\t\tpa->preferred_acm->hue_of_sectors,\r\n-\t\t\tsizeof(*pa->preferred_acm->hue_of_sectors) * pa->preferred_acm->sector_count);\r\n+\t\tstd::copy_n(pa->preferred_acm->hue_of_sectors,\r\n+\t\t\tpa->preferred_acm->sector_count,\r\n+\t\t\tpa_.preferred_acm->hue_of_sectors);\r\n \r\n-\t\tSTDCOPY(pa_.preferred_acm->advanced_color_conversion_matrices[0][0],\r\n-\t\t\tpa->preferred_acm->advanced_color_conversion_matrices[0][0],\r\n-\t\t\tsizeof(*pa->preferred_acm->advanced_color_conversion_matrices) * pa->preferred_acm->sector_count);\r\n+\t\tstd::copy_n(pa->preferred_acm->advanced_color_conversion_matrices[0][0],\r\n+\t\t\tpa->preferred_acm->sector_count,\r\n+\t\t\tpa_.preferred_acm->advanced_color_conversion_matrices[0][0]);\r\n \t} else {\r\n \t\tLOG(AIQResults, Error) << \"Not copying PA hue of sectors\";\r\n \t}\r\n@@ -222,17 +212,17 @@ void AiqResults::setPa(ia_aiq_pa_results *pa)\r\n \t\tpa_.ir_weight->height = pa->ir_weight->height;\r\n \t\tpa_.ir_weight->width = pa->ir_weight->width;\r\n \r\n-\t\tSTDCOPY(pa_.ir_weight->ir_weight_grid_R,\r\n-\t\t\tpa->ir_weight->ir_weight_grid_R,\r\n-\t\t\tsizeof(*pa->ir_weight->ir_weight_grid_R) * pa->ir_weight->height * pa->ir_weight->width);\r\n+\t\tstd::copy_n(pa->ir_weight->ir_weight_grid_R,\r\n+\t\t\tpa->ir_weight->height * pa->ir_weight->width,\r\n+\t\t\tpa_.ir_weight->ir_weight_grid_R);\r\n \r\n-\t\tSTDCOPY(pa_.ir_weight->ir_weight_grid_G,\r\n-\t\t\tpa->ir_weight->ir_weight_grid_G,\r\n-\t\t\tsizeof(*pa->ir_weight->ir_weight_grid_G) * pa->ir_weight->height * pa->ir_weight->width);\r\n+\t\tstd::copy_n(pa->ir_weight->ir_weight_grid_G,\r\n+\t\t\tpa->ir_weight->height * pa->ir_weight->width,\r\n+\t\t\tpa_.ir_weight->ir_weight_grid_G);\r\n \r\n-\t\tSTDCOPY(pa_.ir_weight->ir_weight_grid_B,\r\n-\t\t\tpa->ir_weight->ir_weight_grid_B,\r\n-\t\t\tsizeof(*pa->ir_weight->ir_weight_grid_B) * pa->ir_weight->height * pa->ir_weight->width);\r\n+\t\tstd::copy_n(pa->ir_weight->ir_weight_grid_B,\r\n+\t\t\tpa->ir_weight->height * pa->ir_weight->width,\r\n+\t\t\tpa_.ir_weight->ir_weight_grid_B);\r\n \t} else {\r\n \t\tLOG(AIQResults, Error) << \"Not copying IR weight\";\r\n \t}\r\n@@ -253,13 +243,13 @@ void AiqResults::setSa(ia_aiq_sa_results *sa)\r\n \tsa_.height = sa->height;\r\n \tsa_.lsc_update = sa->lsc_update;\r\n \r\n+\tuint32_t lscGridSize = sa_.width * sa_.height;\r\n \t/* Check against one of the vectors but resize applicable to all. */\r\n-\tif (channelGr_.size() < (sa_.width * sa_.height)) {\r\n-\t\tint lscNewSize = sa_.width * sa_.height;\r\n-\t\tchannelGr_.resize(lscNewSize);\r\n-\t\tchannelGb_.resize(lscNewSize);\r\n-\t\tchannelR_.resize(lscNewSize);\r\n-\t\tchannelB_.resize(lscNewSize);\r\n+\tif (channelGr_.size() < lscGridSize) {\r\n+\t\tchannelGr_.resize(lscGridSize);\r\n+\t\tchannelGb_.resize(lscGridSize);\r\n+\t\tchannelR_.resize(lscGridSize);\r\n+\t\tchannelB_.resize(lscGridSize);\r\n \r\n \t\t/* Update the SA data pointers to new memory locations. */\r\n \t\tsa_.channel_gr = channelGr_.data();\r\n@@ -269,23 +259,16 @@ void AiqResults::setSa(ia_aiq_sa_results *sa)\r\n \t}\r\n \r\n \tif (sa->lsc_update) {\r\n-\t\tuint32_t memCopySize = sa->width * sa->height * sizeof(float);\r\n-\r\n-\t\tSTDCOPY((int8_t *)sa_.channel_gr, (int8_t *)sa->channel_gb,\r\n-\t\t\tmemCopySize);\r\n-\t\tSTDCOPY((int8_t *)sa_.channel_gb, (int8_t *)sa->channel_gr,\r\n-\t\t\tmemCopySize);\r\n-\t\tSTDCOPY((int8_t *)sa_.channel_r, (int8_t *)sa->channel_r,\r\n-\t\t\tmemCopySize);\r\n-\t\tSTDCOPY((int8_t *)sa_.channel_b, (int8_t *)sa->channel_b,\r\n-\t\t\tmemCopySize);\r\n+\t\tstd::copy_n(sa->channel_gr, lscGridSize, sa_.channel_gr);\r\n+\t\tstd::copy_n(sa->channel_gb, lscGridSize, sa_.channel_gb);\r\n+\t\tstd::copy_n(sa->channel_r, lscGridSize, sa_.channel_r);\r\n+\t\tstd::copy_n(sa->channel_b, lscGridSize, sa_.channel_b);\r\n \t} else {\r\n-\t\tLOG(AIQResults, Error) << \"Not copying LSC tables.\";\r\n+\t\tLOG(AIQResults, Debug) << \"Not copying LSC tables.\";\r\n \t}\r\n \r\n-\tSTDCOPY(&sa_.light_source[0],\r\n-\t\t&sa->light_source[0],\r\n-\t\tCMC_NUM_LIGHTSOURCES * sizeof(sa->light_source[0]));\r\n+\tstd::copy_n(&sa->light_source[0], CMC_NUM_LIGHTSOURCES, &sa_.light_source[0]);\r\n+\r\n \tsa_.scene_difficulty = sa->scene_difficulty;\r\n \tsa_.num_patches = sa->num_patches;\r\n \tsa_.covered_area = sa->covered_area;",
    "prefixes": [
        "libcamera-devel",
        "2/3"
    ]
}