aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-03-01 18:34:26 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-01-04 13:16:49 +0100
commit3d53cefb49289e5e27b652e13623017b05ace452 (patch)
treeef23d66d26d7ecf833cd1feb29259c5819c2ca67 /libavformat
parente84d8ba44141b55f2b28e0ad3b597d2e7d422336 (diff)
downloadffmpeg-3d53cefb49289e5e27b652e13623017b05ace452.tar.gz
avcodec/raw: Reduce number of avpriv symbols
libavcodec currently exports four avpriv symbols that deal with PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt, avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are lists of PixelFormatTags, the former returns such a list and the second searches a list for a pixel format that matches a given fourcc; only one of the aforementioned three lists is ever searched. Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and avpriv_find_pix_fmt the overhead of exporting these functions actually exceeds the size of said objects (at least for ELF; the following numbers are for x64 Ubuntu 20.10): The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B), yet exporting it adds a 20B string for the name alone to the exporting as well as to each importing library; there is more: Four bytes in the exporting libraries .gnu.hash; two bytes each for the exporting as well as each importing libraries .gnu.version; 24B in the exporting as well as each importing libraries .dynsym; 16B+24B for an entry in .plt as well as the accompanying relocation entry in .rela.plt for each importing library. The overhead for the lists is similar: The strings are 23B and the .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and a relocation entry in .rela.dyn. These lists have a size of 80 resp. 72 bytes. Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to duplicating it into libavformat and potentially libavdevice. Therefore this commit replaces all library uses of the four symbols with a single function that is exported for shared builds. It has an enum parameter to choose the desired list besides the parameter for the fourcc. New lists can be supported with new enum values. Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this function remains. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avienc.c2
-rw-r--r--libavformat/demux.c2
-rw-r--r--libavformat/movenc.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 3fbde0be1e..be2493ce55 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -448,7 +448,7 @@ static int avi_write_header(AVFormatContext *s)
par->bits_per_coded_sample = 16;
avist->pal_offset = avio_tell(pb) + 40;
ff_put_bmp_header(pb, par, 0, 0, avi->flipped_raw_rgb);
- pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
+ pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
par->bits_per_coded_sample);
if ( !par->codec_tag
&& par->codec_id == AV_CODEC_ID_RAWVIDEO
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 3f35b3860e..4770e5517f 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2790,7 +2790,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
if (avctx->codec_id == AV_CODEC_ID_RAWVIDEO && !avctx->codec_tag && !avctx->bits_per_coded_sample) {
uint32_t tag= avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
- if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == avctx->pix_fmt)
+ if (avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, tag) == avctx->pix_fmt)
avctx->codec_tag= tag;
}
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 24965c89c2..bc6abcfcaa 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1637,7 +1637,7 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
}
}
- pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
+ pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
track->par->bits_per_coded_sample);
if (tag == MKTAG('r','a','w',' ') &&
track->par->format != pix_fmt &&