diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-09 16:12:26 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-14 20:37:03 +0100 |
commit | 282812d6dc90ff0a2c85f90507a0a78c4a112cf9 (patch) | |
tree | 1ea368e47a2b8537c0b90ca747229425cfdb6923 /libavcodec/tiff.c | |
parent | ad6347fc3797a8deca29630fa26ac343c7539463 (diff) | |
download | ffmpeg-282812d6dc90ff0a2c85f90507a0a78c4a112cf9.tar.gz |
avcodec/tiff_data: Avoid relocations for TiffGeoTagNameType
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 <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/tiff.c')
-rw-r--r-- | libavcodec/tiff.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 3238b208d8..7ce1ab32f6 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; } |