From patchwork Sun Mar 10 14:15:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46937 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dc95:b0:1a1:738b:6bc0 with SMTP id ky21csp742308pzb; Sun, 10 Mar 2024 07:15:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+QDPgbAOk0zO0l4QpOfWX8tUd8cFikt1QMhAlc7jfiiLMmD7Dgje3Ia+bu5nSQgzecAul509zILeKONvWuyhRDkD5IMMYgbKJkQ== X-Google-Smtp-Source: AGHT+IFH9cheWUf4OYOzzXvruPU+pCFd1Q7wrg0R6u6mTTzqK1RtQ4+OqdvcBvWhTiHJbjJnuwDl X-Received: by 2002:a05:6512:38a8:b0:513:9d80:f776 with SMTP id o8-20020a05651238a800b005139d80f776mr2242897lft.30.1710080147530; Sun, 10 Mar 2024 07:15:47 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t1-20020a170906a10100b00a45fefe5915si1567001ejy.899.2024.03.10.07.15.47; Sun, 10 Mar 2024 07:15:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b="OnxpkK8/"; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17FA168CF0F; Sun, 10 Mar 2024 16:15:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01olkn2047.outbound.protection.outlook.com [40.92.66.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5410E68CDB9 for ; Sun, 10 Mar 2024 16:15:29 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dmv4fnrNsFXNXlbDWgXbU1QUFMlZKPSF2p+UNU3OivNUXGHEdxOyynmEs4PayhYaUu7wbB2XPshDEKovbCwZ1Xg6DLuia+0GVst38a3AC7WLX+fiOVV02UeGzNxY/kSBrIIpC+iWkUbLOcwlHnR9L3Doh1HPNqwc3/G8auTAqEdeUpa05E0Xl6KD3Ucj00s8IObNGYeEfQ4lWZ7sw015I2Yt8rgXdTUpdoeKmQYXF0efH6hg6vBc8Mv7SK3MFVZA3CrjldmRqJxiZjOVFNUKws/gZda0iX9CB8YoE19Nqf355pkW5J866BH2hz4zYFMbh8WCI9nQJNPBVEvWPxsxEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ytIrNlDY3xXG9qZIw8TIOFoFgwojfb6DQLmnXSRN9JI=; b=hLIRDdaxv14uMqR0bKzO4C05kDf+d0ZcKW4cUpAJjOh0j5B+L7EOHtQF3DSz8DMyZv2GwUILWd7YM7AC6cpfuKjlB4v6WsAaudI+zni/tFLTpdvBR1gnOMnjmdPzU9y5uiYZ82k5QDhw5agoUvClOQn0/L5SRmKmTjgR51uJerfgCY2bnjavJkDrwQ22YpQWCWabRMY/6x4vMBqcxpM8kgHXitW1n/81ePQDN/oL3YSdDb0Fyb1lFUNQVkkmDywEme6uLLRo7qN6sp3tnqY2QxC2RE56gynIanGNVN4FJ4797Lfhj4EWZ2zAn5vdcdq5HdCY7smxRcJ9rguWgbqS2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ytIrNlDY3xXG9qZIw8TIOFoFgwojfb6DQLmnXSRN9JI=; b=OnxpkK8/154SuvdiDJhJkGJsM47C6tBZP/k2fQ675cDPrZgdaRBhWk5vxrnoHUOxOW4vqu28TD5LQFcvvoappUJQZAir3eg6WuJ26yapd6xRUH4iHhQcDhjt79bZZGPIG49+1lLOSmQp5rYThwDQckYwn0dycBO9+QC72Jw2ZFAiezVn9MiwvjseUJQO3vqXGU6aJaYKFIxL+xoear0u2gkEYMC1BZ1Ft8qmxxup0BaiK5Fv2ERzizU/JrOA1qvQx47Cu8YtLnzKf9hXfe7VRdtzLDIBvBWNg0D0iyxsghx669Ss8IfUA8rGzx0GsHTnkYvHr+zH7HN3Zxee7ISahg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AM8P250MB0089.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:36c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Sun, 10 Mar 2024 14:15:20 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::228d:8c6f:ed10:82eb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::228d:8c6f:ed10:82eb%7]) with mapi id 15.20.7362.031; Sun, 10 Mar 2024 14:15:20 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Mar 2024 15:15:03 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [vxPJ169FClP8Z5g8YjhKpUI0gsSvsGIXWSQeNe4z8HY=] X-ClientProxiedBy: FR3P281CA0002.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::12) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240310141504.440261-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AM8P250MB0089:EE_ X-MS-Office365-Filtering-Correlation-Id: 1be143af-7e5e-4e99-ef46-08dc410c84e9 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnrycYYMiKOh26ty8tiVyH4gSCrdflyrK4BWIVKywDnPldM/1eUDiy6FbO2J4Ix3fJnjmI5NxbuGBitsnDByQjQxhgIfaEyQiDQGqcm3QQ3mhfY/kpdjEEoitWD9/d1YXEksdFUAWbjPuMENcVgrCb5iLhHNOLRFRyQH0w0GYKmsHDGcVVCRXDvXhuw6sBXYbCUr6kf4QTXHrI/xsfhcKcafDfffPvaJyVc1ovOvm6b8VZ5yEukAh5oLHWkfBlFxPgGs/PNQok+NHK9RrY0R90WIBNzHLHxL1EiGWZkmr4+/GymPitudAOXg3dsoAfxbjrh06mswOSEsX6vpvzl0Eh9qmgeh72pqKEiWt9wWBCf7KKJq4aRsdhT6DbEOQ/ajhRSADpI/0y261uA0fblqnqKwRMeta1lv6RFxbdXOtOFGrSDwH2EtrTjf5tMKCE41MSjs9OaKqRCe2NvrNCPrqNlsudhOaam/em335QK9okguqWfzqa3+OUdEnoFPa3Q8YbxKAkFPIjxcfCi8aXf/rnrmtJRXyAU2T07fgmDh5+C/6PAclDLSLwhJGy46dgfhiKq+wsTHlK5HgoIm/4FfNwzcwN71CPdce3pCeNG1vMzPmTFRIPHivYnDX77tNfbBFUhPOojTIFP2+pDuNS/RkPt6OoC8yhshx6N/71qdCYYPRl5852C4M2A2vDbbJuqDNbymsOuT+uJI1aM3hfW/kkET8gUV1DEPGfsBDVAfrE9ccy0S5NlT7MqZTCKA1H5aYvg= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: awu/xegdEeCzWT0U163OrDo2gMynMRhS8EsB+Oftyfbadoe07OdmDd1Xoi3yBxvXFDEJKh2m9jMDUQbG2zzLQiYk50yVWuNHLbrp20z+jh60ZzpJ1IVM0t8SsymzQCyKd239HSQLuHaLEgUpC/Dshq8tRv8/ZBxSZhlE0tVqRYItLd6suj6RTiZr5HWKqCntcQKEB79NK2b1cwzZmdq/GJ4whB4D9f0Bmi73jZ6jntE/rT80kVqCXqXPDalDH+bWPP1aQYBNC6UTxbqt8fQW5vri7y2WaphSEFkONQMlaB2a6XNSeuf5Oj5bFsS9KLc0CkgjH3C7BKPpmxheJa73lZBPfiQZlXRos7hH4QlHpjvLzzWIekWSkqH7bpgfaMTti4DJ3iUz3rRtLoXEjK4M0e4hiYYHagBZSbz84pZ1xi92sFeV5Yht+Tq4sBoCqIV9bBw2IvOdCgvTcdqw3vhBZg5iPEZRuu4aHrTSwtGn+8CLhtT1hxTqSXa6W9A+LYJuz4t4B2K4Gqv3RjJavkMBeYE2q6xKdRkHK5h8r2nvFniRJuyKKA61QgtrrSoSVa826gEXFciJB/5l4nUCFv8C5JbWBF0Amb7GHtHrs21fPzoB7Ww42uKvJlUe44PylDCm X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CI4rsF8+yOBfNWLq6OZYj6JT302p1z9hKwhbXCgSKms+mKICo/rd4tYCKn+GChTn7e5+aGt4nlX+uUEmt+tV5F29f+9ErZfuNuSF8KU6OpzFOv53TMk163ydRbupQSPij45tD+BGyZIgTBGxm0ZzwRdbjK7zfYc+hrMDRIMYt+dVDH80vyd5WhxGCeWxQldEkHFsQjoG/o+M4tyHaHflVXMuRiongdf3H6zOvG5/+NExAXkQuiJkmhzySvneBtts5beufmrHkYkb3CNQaaN+Qx3vR2uorPvLVTNEUB8KktdbZuCColmRbxUDlgp1Yeo7jU1H5MzPTMq6IQILfN3+HIMwC1WPMoBXEdvqGamUCco6P4mLdVj9zBqfOTqTFjYPmj1eOSbPWDO7v/HBJGR+AZ7QayUUyIIknysgr2tRYVF6eTaY4VX6jbm2skZszMuvuPGhc8vowJPxx/qRE0G8kZev18K1KZKfXf+CH1jsQMV8W+APBqvWrnu8HRuBsP9ycBxaSVDg77jbiXTTwRFipZY3ZZFNelzFg2veKeKjfsq6o38WooXdxT1GQ9ZPQZnbknT4le25+sWCnUnRGw4KzLPrBq26EK3pt1+mm35VmC1dc9RooE/S2kdld/X2RStnkPnXBWegWbKMJM8uQRdn2DEUJX2n3lJKCqr5MGZTkmuCHK20V98pIiB4fovryDUdZAZGzb5sIm+MCTqrNQlY4bDQMbyqbCthI8JU+rIi3fDhniBlVScQxVqqxmrjMmIbkX/o6uo+m30kxycFgnUME01peE58fkv21Jqemp1iKvpo+Mbs5PsxGPCI8+MuX8+r1zOeUYln9oAwJQAVGnqKbkaq5H9UwJ4Ef77v6wYXs91qNUYYsBnHSO/5jpzMcwr4z3fgM5BtKv/7S+5cRPJdKILlTsHWdiD5GXRa25aQhC/nyALOMUCD1Oo3mcqwdEaqLWWdJ5yr95X95TD9qB5myN0yW6utbSDFpF7w5guf36VQklN6TWKQb07d7eTw43bA6MiZmLlwfHv+OExWBFfbFKxWKqJHVjAMiqB62O8Uqtkodro+L6bNWkUUSO9krlyeeD8fHUZI3pvsohNMLiXaTutuIWR4QUHCuVLKIJ+WR9vp5x+Vw2dPwOwy4dFe2/xAXkzi/7Ygh84yHdDvqYKijoB88++RQ7yCWZhKgMjaYX7KfwIURjLfe3jRnXFi+Ho+tHawoK6d7xJKExtGBdlE7EvXl4b8jOBsFfwunlCdEnHCgkFT7NfKBXY7FMnsGHMR8oBOZNngtzE2/oUXkqF/sw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1be143af-7e5e-4e99-ef46-08dc410c84e9 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2024 14:15:20.6736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P250MB0089 Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/tiff_data: Avoid relocations for TiffGeoTagNameType X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zTLHPHwo+Ilm Instead store all the strings in one continugous string (with internal \0) and use offsets to access the actual substrings. This replaces the pointers to the strings and therefore avoids relocations (and on x64, it actually shrinks TiffGeoTagNameType by reusing padding to store the offset field). This saves 720B of .data.rel.ro and 1080B of .rela.dyn (containing the relocation records) here while increasing .rodata by 384B. Signed-off-by: Andreas Rheinhardt --- I also have patches for the remaining tables, but am not satisfied with them yet. libavcodec/tiff.c | 28 +++++---- libavcodec/tiff.h | 5 -- libavcodec/tiff_data.h | 129 ++++++++++++++++++++++++----------------- 3 files changed, 92 insertions(+), 70 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 15e5edd93b..004db89c6b 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -139,27 +139,31 @@ static void free_geotags(TiffContext *const s) s->geotag_count = 0; } -#define RET_GEOKEY(TYPE, array, element)\ +static const char *get_geokey_name(int key) +{ +#define RET_GEOKEY_STR(TYPE, array)\ if (key >= TIFF_##TYPE##_KEY_ID_OFFSET &&\ key - TIFF_##TYPE##_KEY_ID_OFFSET < FF_ARRAY_ELEMS(tiff_##array##_name_type_map))\ - return tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].element; + return tiff_##array##_name_type_string + tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].offset; -static const char *get_geokey_name(int key) -{ - RET_GEOKEY(VERT, vert, name); - RET_GEOKEY(PROJ, proj, name); - RET_GEOKEY(GEOG, geog, name); - RET_GEOKEY(CONF, conf, name); + RET_GEOKEY_STR(VERT, vert); + RET_GEOKEY_STR(PROJ, proj); + RET_GEOKEY_STR(GEOG, geog); + RET_GEOKEY_STR(CONF, conf); return NULL; } static int get_geokey_type(int key) { - RET_GEOKEY(VERT, vert, type); - RET_GEOKEY(PROJ, proj, type); - RET_GEOKEY(GEOG, geog, type); - RET_GEOKEY(CONF, conf, type); +#define RET_GEOKEY_TYPE(TYPE, array)\ + if (key >= TIFF_##TYPE##_KEY_ID_OFFSET &&\ + key - TIFF_##TYPE##_KEY_ID_OFFSET < FF_ARRAY_ELEMS(tiff_##array##_name_type_map))\ + return tiff_##array##_name_type_map[key - TIFF_##TYPE##_KEY_ID_OFFSET].type; + RET_GEOKEY_TYPE(VERT, vert); + RET_GEOKEY_TYPE(PROJ, proj); + RET_GEOKEY_TYPE(GEOG, geog); + RET_GEOKEY_TYPE(CONF, conf); return AVERROR_INVALIDDATA; } diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h index 2dd21dea52..12afcfa6e5 100644 --- a/libavcodec/tiff.h +++ b/libavcodec/tiff.h @@ -222,9 +222,4 @@ typedef struct TiffGeoTagKeyName { const char *const name; } TiffGeoTagKeyName; -typedef struct TiffGeoTagNameType { - const char *const name; - const enum TiffGeoTagType type; -} TiffGeoTagNameType; - #endif /* AVCODEC_TIFF_H */ diff --git a/libavcodec/tiff_data.h b/libavcodec/tiff_data.h index 9b123ca8df..9ed46d31af 100644 --- a/libavcodec/tiff_data.h +++ b/libavcodec/tiff_data.h @@ -32,66 +32,89 @@ #include "tiff.h" +typedef struct TiffGeoTagNameType { + enum TiffGeoTagType type; + unsigned offset; +} TiffGeoTagNameType; + #define TIFF_CONF_KEY_ID_OFFSET 1024 -static const TiffGeoTagNameType tiff_conf_name_type_map[] = { - {"GTModelTypeGeoKey", GEOTIFF_SHORT }, - {"GTRasterTypeGeoKey", GEOTIFF_SHORT }, - {"GTCitationGeoKey", GEOTIFF_STRING} -}; +#define CONF_NAME_TYPE_MAP(KEY) \ + KEY(GTModelTypeGeoKey, SHORT ) \ + KEY(GTRasterTypeGeoKey, SHORT ) \ + KEY(GTCitationGeoKey, STRING) \ #define TIFF_GEOG_KEY_ID_OFFSET 2048 -static const TiffGeoTagNameType tiff_geog_name_type_map[] = { - {"GeographicTypeGeoKey", GEOTIFF_SHORT }, - {"GeogCitationGeoKey", GEOTIFF_STRING}, - {"GeogGeodeticDatumGeoKey", GEOTIFF_SHORT }, - {"GeogPrimeMeridianGeoKey", GEOTIFF_SHORT }, - {"GeogLinearUnitsGeoKey", GEOTIFF_SHORT }, - {"GeogLinearUnitSizeGeoKey", GEOTIFF_DOUBLE}, - {"GeogAngularUnitsGeoKey", GEOTIFF_SHORT }, - {"GeogAngularUnitSizeGeoKey", GEOTIFF_DOUBLE}, - {"GeogEllipsoidGeoKey", GEOTIFF_SHORT }, - {"GeogSemiMajorAxisGeoKey", GEOTIFF_DOUBLE}, - {"GeogSemiMinorAxisGeoKey", GEOTIFF_DOUBLE}, - {"GeogInvFlatteningGeoKey", GEOTIFF_DOUBLE}, - {"GeogAzimuthUnitsGeoKey", GEOTIFF_SHORT }, - {"GeogPrimeMeridianLongGeoKey", GEOTIFF_DOUBLE} -}; +#define GEOG_NAME_TYPE_MAP(KEY) \ + KEY(GeographicTypeGeoKey, SHORT ) \ + KEY(GeogCitationGeoKey, STRING) \ + KEY(GeogGeodeticDatumGeoKey, SHORT ) \ + KEY(GeogPrimeMeridianGeoKey, SHORT ) \ + KEY(GeogLinearUnitsGeoKey, SHORT ) \ + KEY(GeogLinearUnitSizeGeoKey, DOUBLE) \ + KEY(GeogAngularUnitsGeoKey, SHORT ) \ + KEY(GeogAngularUnitSizeGeoKey, DOUBLE) \ + KEY(GeogEllipsoidGeoKey, SHORT ) \ + KEY(GeogSemiMajorAxisGeoKey, DOUBLE) \ + KEY(GeogSemiMinorAxisGeoKey, DOUBLE) \ + KEY(GeogInvFlatteningGeoKey, DOUBLE) \ + KEY(GeogAzimuthUnitsGeoKey, SHORT ) \ + KEY(GeogPrimeMeridianLongGeoKey, DOUBLE) \ #define TIFF_PROJ_KEY_ID_OFFSET 3072 -static const TiffGeoTagNameType tiff_proj_name_type_map[] = { - {"ProjectedCSTypeGeoKey", GEOTIFF_SHORT }, - {"PCSCitationGeoKey", GEOTIFF_STRING}, - {"ProjectionGeoKey", GEOTIFF_SHORT }, - {"ProjCoordTransGeoKey", GEOTIFF_SHORT }, - {"ProjLinearUnitsGeoKey", GEOTIFF_SHORT }, - {"ProjLinearUnitSizeGeoKey", GEOTIFF_DOUBLE}, - {"ProjStdParallel1GeoKey", GEOTIFF_DOUBLE}, - {"ProjStdParallel2GeoKey", GEOTIFF_DOUBLE}, - {"ProjNatOriginLongGeoKey", GEOTIFF_DOUBLE}, - {"ProjNatOriginLatGeoKey", GEOTIFF_DOUBLE}, - {"ProjFalseEastingGeoKey", GEOTIFF_DOUBLE}, - {"ProjFalseNorthingGeoKey", GEOTIFF_DOUBLE}, - {"ProjFalseOriginLongGeoKey", GEOTIFF_DOUBLE}, - {"ProjFalseOriginLatGeoKey", GEOTIFF_DOUBLE}, - {"ProjFalseOriginEastingGeoKey", GEOTIFF_DOUBLE}, - {"ProjFalseOriginNorthingGeoKey", GEOTIFF_DOUBLE}, - {"ProjCenterLongGeoKey", GEOTIFF_DOUBLE}, - {"ProjCenterLatGeoKey", GEOTIFF_DOUBLE}, - {"ProjCenterEastingGeoKey", GEOTIFF_DOUBLE}, - {"ProjCenterNorthingGeoKey", GEOTIFF_DOUBLE}, - {"ProjScaleAtNatOriginGeoKey", GEOTIFF_DOUBLE}, - {"ProjScaleAtCenterGeoKey", GEOTIFF_DOUBLE}, - {"ProjAzimuthAngleGeoKey", GEOTIFF_DOUBLE}, - {"ProjStraightVertPoleLongGeoKey", GEOTIFF_DOUBLE} -}; +#define PROJ_NAME_TYPE_MAP(KEY) \ + KEY(ProjectedCSTypeGeoKey, SHORT ) \ + KEY(PCSCitationGeoKey, STRING) \ + KEY(ProjectionGeoKey, SHORT ) \ + KEY(ProjCoordTransGeoKey, SHORT ) \ + KEY(ProjLinearUnitsGeoKey, SHORT ) \ + KEY(ProjLinearUnitSizeGeoKey, DOUBLE) \ + KEY(ProjStdParallel1GeoKey, DOUBLE) \ + KEY(ProjStdParallel2GeoKey, DOUBLE) \ + KEY(ProjNatOriginLongGeoKey, DOUBLE) \ + KEY(ProjNatOriginLatGeoKey, DOUBLE) \ + KEY(ProjFalseEastingGeoKey, DOUBLE) \ + KEY(ProjFalseNorthingGeoKey, DOUBLE) \ + KEY(ProjFalseOriginLongGeoKey, DOUBLE) \ + KEY(ProjFalseOriginLatGeoKey, DOUBLE) \ + KEY(ProjFalseOriginEastingGeoKey, DOUBLE) \ + KEY(ProjFalseOriginNorthingGeoKey, DOUBLE) \ + KEY(ProjCenterLongGeoKey, DOUBLE) \ + KEY(ProjCenterLatGeoKey, DOUBLE) \ + KEY(ProjCenterEastingGeoKey, DOUBLE) \ + KEY(ProjCenterNorthingGeoKey, DOUBLE) \ + KEY(ProjScaleAtNatOriginGeoKey, DOUBLE) \ + KEY(ProjScaleAtCenterGeoKey, DOUBLE) \ + KEY(ProjAzimuthAngleGeoKey, DOUBLE) \ + KEY(ProjStraightVertPoleLongGeoKey, DOUBLE) \ #define TIFF_VERT_KEY_ID_OFFSET 4096 -static const TiffGeoTagNameType tiff_vert_name_type_map[] = { - {"VerticalCSTypeGeoKey", GEOTIFF_SHORT }, - {"VerticalCitationGeoKey", GEOTIFF_STRING}, - {"VerticalDatumGeoKey", GEOTIFF_SHORT }, - {"VerticalUnitsGeoKey", GEOTIFF_SHORT } -}; +#define VERT_NAME_TYPE_MAP(KEY) \ + KEY(VerticalCSTypeGeoKey, SHORT ) \ + KEY(VerticalCitationGeoKey, STRING) \ + KEY(VerticalDatumGeoKey, SHORT ) \ + KEY(VerticalUnitsGeoKey, SHORT ) \ + +#define ADD_OFFSET(NAME, TYPE) \ + NAME ## _OFFSET, \ + NAME ## _END = NAME ## _OFFSET + sizeof(#NAME) - 1, \ + +#define STRING(NAME, TYPE) #NAME "\0" + +#define ENTRY(NAME, TYPE) { .type = GEOTIFF_ ## TYPE, .offset = NAME ## _OFFSET }, +#define NAME_TYPE_MAP(NAME, name) \ + enum { \ + NAME ## _NAME_TYPE_MAP(ADD_OFFSET) \ + }; \ + static const TiffGeoTagNameType tiff_ ## name ## _name_type_map[] = { \ + NAME ## _NAME_TYPE_MAP(ENTRY) \ + }; \ + static const char *const tiff_ ## name ## _name_type_string = \ + NAME ## _NAME_TYPE_MAP(STRING) + +NAME_TYPE_MAP(CONF, conf); +NAME_TYPE_MAP(GEOG, geog); +NAME_TYPE_MAP(PROJ, proj); +NAME_TYPE_MAP(VERT, vert); #define TIFF_GEO_KEY_UNDEFINED 0 #define TIFF_GEO_KEY_USER_DEFINED 32767