Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 11/11] avcodec/utils: Unavpriv avpriv_toupper4()
Date: Wed, 15 Dec 2021 13:35:41 +0100
Message-ID: <AM7PR03MB66601EE5D15D0F32D43185E08F769@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <AM7PR03MB666072BE629D71EFF7053C138F769@AM7PR03MB6660.eurprd03.prod.outlook.com>

This function is quite small (96B with GCC 11.2 on x64 Ubuntu 21.10
at -O3), making it more economical to duplicate it into libavformat
instead of exporting it as avpriv: Doing so saves 2x24B in .dynsim,
2x16B in .dynstr, 2x2B .gnu.version, 24B in .rela.plt, 16B in .plt,
16B in .plt.sec (if enabled), 4B .gnu.hash; besides the actual
duplicated code this also adds 2x8B .eh_frame_hdr and 24B .eh_frame.

In other words: Duplicating is neutral size-wise (it is also presumed
neutral for other systems). Given that it avoids the runtime
overhead of dynamic symbols, it is advantageouos to duplicate the
function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/Makefile     |  4 +++-
 libavcodec/internal.h   |  2 +-
 libavcodec/mpeg12dec.c  |  2 +-
 libavcodec/mpegvideo.c  |  2 +-
 libavcodec/to_upper4.c  | 23 +++++++++++++++++++++++
 libavcodec/to_upper4.h  | 37 +++++++++++++++++++++++++++++++++++++
 libavcodec/utils.c      |  8 --------
 libavformat/Makefile    |  2 +-
 libavformat/movenc.c    |  2 +-
 libavformat/mux.c       |  2 +-
 libavformat/to_upper4.c | 23 +++++++++++++++++++++++
 libavformat/utils.c     |  2 +-
 12 files changed, 93 insertions(+), 16 deletions(-)
 create mode 100644 libavcodec/to_upper4.c
 create mode 100644 libavcodec/to_upper4.h
 create mode 100644 libavformat/to_upper4.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0b4aaf544e..292a105266 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -126,7 +126,8 @@ OBJS-$(CONFIG_MPEGAUDIOHEADER)         += mpegaudiodecheader.o mpegaudiotabs.o
 OBJS-$(CONFIG_MPEG4AUDIO)              += mpeg4audio.o mpeg4audio_sample_rates.o
 OBJS-$(CONFIG_MPEGVIDEO)               += mpegvideo.o mpegvideodsp.o rl.o \
                                           mpegvideo_motion.o mpegutils.o \
-                                          mpegvideodata.o mpegpicture.o
+                                          mpegvideodata.o mpegpicture.o  \
+                                          to_upper4.o
 OBJS-$(CONFIG_MPEGVIDEOENC)            += mpegvideo_enc.o mpeg12data.o  \
                                           motion_est.o ratecontrol.o    \
                                           mpegvideoencdsp.o
@@ -993,6 +994,7 @@ OBJS-$(CONFIG_FITS_DEMUXER)            += fits.o
 OBJS-$(CONFIG_TAK_DEMUXER)             += tak.o
 
 # libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_AVFORMAT)           += to_upper4.o
 STLIBOBJS-$(CONFIG_ISO_MEDIA)          += mpegaudiotabs.o
 STLIBOBJS-$(CONFIG_FLV_MUXER)          += mpeg4audio_sample_rates.o
 STLIBOBJS-$(CONFIG_HLS_DEMUXER)        += ac3_channel_layout_tab.o
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index d3ee0214c5..72ca1553f6 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -225,7 +225,7 @@ extern const uint8_t ff_log2_run[41];
  */
 int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
 
-unsigned int avpriv_toupper4(unsigned int x);
+unsigned int ff_toupper4(unsigned int x);
 
 void ff_color_frame(AVFrame *frame, const int color[4]);
 
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 09b2902bca..172ea92b16 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2831,7 +2831,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data,
     }
 #endif
 
-    s2->codec_tag = avpriv_toupper4(avctx->codec_tag);
+    s2->codec_tag = ff_toupper4(avctx->codec_tag);
     if (s->mpeg_enc_ctx_allocated == 0 && (   s2->codec_tag == AV_RL32("VCR2")
                                            || s2->codec_tag == AV_RL32("BW10")
                                           ))
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ba5b51955e..90d0a9fd50 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -707,7 +707,7 @@ void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
     s->workaround_bugs = avctx->workaround_bugs;
 
     /* convert fourcc to upper case */
-    s->codec_tag          = avpriv_toupper4(avctx->codec_tag);
+    s->codec_tag       = ff_toupper4(avctx->codec_tag);
 }
 
 /**
diff --git a/libavcodec/to_upper4.c b/libavcodec/to_upper4.c
new file mode 100644
index 0000000000..29f65bf5c3
--- /dev/null
+++ b/libavcodec/to_upper4.c
@@ -0,0 +1,23 @@
+/*
+ * Converting FOURCCs to uppercase
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "to_upper4.h"
diff --git a/libavcodec/to_upper4.h b/libavcodec/to_upper4.h
new file mode 100644
index 0000000000..d9648b5ef6
--- /dev/null
+++ b/libavcodec/to_upper4.h
@@ -0,0 +1,37 @@
+/*
+ * Converting FOURCCs to uppercase
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_TO_UPPER4_H
+#define AVCODEC_TO_UPPER4_H
+
+#include "libavutil/avstring.h"
+#include "internal.h"
+
+unsigned int ff_toupper4(unsigned int x)
+{
+    return av_toupper(x & 0xFF) |
+          (av_toupper((x >>  8) & 0xFF) << 8)  |
+          (av_toupper((x >> 16) & 0xFF) << 16) |
+((unsigned)av_toupper((x >> 24) & 0xFF) << 24);
+}
+
+#endif
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4d236ff1cd..b19befef21 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -863,14 +863,6 @@ const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index)
     return &codec->hw_configs[index]->public;
 }
 
-unsigned int avpriv_toupper4(unsigned int x)
-{
-    return av_toupper(x & 0xFF) +
-          (av_toupper((x >>  8) & 0xFF) << 8)  +
-          (av_toupper((x >> 16) & 0xFF) << 16) +
-((unsigned)av_toupper((x >> 24) & 0xFF) << 24);
-}
-
 int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
 {
     int ret;
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6e93d082d9..c5c9e78fa8 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -677,7 +677,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL)           += libssh.o
 OBJS-$(CONFIG_LIBZMQ_PROTOCOL)           += libzmq.o
 
 # Objects duplicated from other libraries for shared builds
-SHLIBOBJS                                += log2_tab.o
+SHLIBOBJS                                += log2_tab.o to_upper4.o
 SHLIBOBJS-$(CONFIG_ISO_MEDIA)            += mpegaudiotabs.o
 SHLIBOBJS-$(CONFIG_FLV_MUXER)            += mpeg4audio_sample_rates.o
 SHLIBOBJS-$(CONFIG_HLS_DEMUXER)          += ac3_channel_layout_tab.o
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7216331fa1..fc309fb416 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1716,7 +1716,7 @@ static unsigned int validate_codec_tag(const AVCodecTag *const *tags,
     for (i = 0; tags && tags[i]; i++) {
         const AVCodecTag *codec_tags = tags[i];
         while (codec_tags->id != AV_CODEC_ID_NONE) {
-            if (avpriv_toupper4(codec_tags->tag) == avpriv_toupper4(tag) &&
+            if (ff_toupper4(codec_tags->tag) == ff_toupper4(tag) &&
                 codec_tags->id == codec_id)
                 return codec_tags->tag;
             codec_tags++;
diff --git a/libavformat/mux.c b/libavformat/mux.c
index d93dc73f8e..b9c4abb9cf 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -204,7 +204,7 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
     for (int n = 0; s->oformat->codec_tag[n]; n++) {
         avctag = s->oformat->codec_tag[n];
         while (avctag->id != AV_CODEC_ID_NONE) {
-            if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codecpar->codec_tag)) {
+            if (ff_toupper4(avctag->tag) == ff_toupper4(st->codecpar->codec_tag)) {
                 id = avctag->id;
                 if (id == st->codecpar->codec_id)
                     return 1;
diff --git a/libavformat/to_upper4.c b/libavformat/to_upper4.c
new file mode 100644
index 0000000000..e84c803675
--- /dev/null
+++ b/libavformat/to_upper4.c
@@ -0,0 +1,23 @@
+/*
+ * Converting FOURCCs to uppercase
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/to_upper4.h"
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b5a4a09ae8..bd076d532b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -361,7 +361,7 @@ enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
         if (tag == tags[i].tag)
             return tags[i].id;
     for (int i = 0; tags[i].id != AV_CODEC_ID_NONE; i++)
-        if (avpriv_toupper4(tag) == avpriv_toupper4(tags[i].tag))
+        if (ff_toupper4(tag) == ff_toupper4(tags[i].tag))
             return tags[i].id;
     return AV_CODEC_ID_NONE;
 }
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2021-12-15 12:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols Andreas Rheinhardt
2021-12-20 15:03   ` Andreas Rheinhardt
2021-12-30  9:55   ` Anton Khirnov
2022-01-03  5:33     ` Andreas Rheinhardt
2022-01-03 10:38   ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 03/11] Makefile: Redo duplicating object files in shared builds Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab Andreas Rheinhardt
2021-12-30 10:12   ` Anton Khirnov
2021-12-31 13:28     ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 05/11] avcodec/dca: Unavpriv dca_sample_rates Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 06/11] avcodec/jpegtables: Unavpriv MJPEG-tables Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 07/11] configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA group Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 08/11] avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 09/11] avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 10/11] avcodec/internal: Remove unused av_export_avcodec Andreas Rheinhardt
2021-12-15 12:35 ` Andreas Rheinhardt [this message]
2021-12-16  1:29 ` [FFmpeg-devel] [PATCH 12/15] avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references Andreas Rheinhardt
2021-12-16  1:29 ` [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket) Andreas Rheinhardt
2021-12-21 13:52   ` Tomas Härdin
2021-12-16  1:29 ` [FFmpeg-devel] [PATCH 14/15] avcodec/packet_internal: Add proper PacketList struct Andreas Rheinhardt
2021-12-16  1:29 ` [FFmpeg-devel] [PATCH 15/15] avformat/movenc: Use dedicated pointer for access to MOVTrack Andreas Rheinhardt
2021-12-17 22:52 ` [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM7PR03MB66601EE5D15D0F32D43185E08F769@AM7PR03MB6660.eurprd03.prod.outlook.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git