[FFmpeg-cvslog] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab

Andreas Rheinhardt git at videolan.org
Tue Jan 4 15:27:49 EET 2022


ffmpeg | branch: release/5.0 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Feb  9 18:25:13 2021 +0100| [d7a75d21635eab4f4a1efea22945933059c2e36f] | committer: Andreas Rheinhardt

avcodec/ac3tab: Unavpriv ac3_channel_layout_tab

It is small (16 B) and therefore the overhead of exporting it more
than outweighs the size savings from not having duplicated symbols:
When the symbol is no longer avpriv, one saves twice the size of
the string containing the symbols name (2x30 byte), two entries
in .dynsym (24 bytes each on x64), one entry in the importing libraries
.got and .rela.dyn (8 + 24 bytes on x64) and two entries for the
symbol version (2 bytes each) and one hash value in the exporting
library (4 bytes).
(The exact numbers are of course different for other platforms
(e.g. when using dlls), but given that the strings saved alone
more than outweigh the array size it can be presumed that this
is beneficial for all platforms.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d7a75d21635eab4f4a1efea22945933059c2e36f
---

 libavcodec/Makefile                  | 12 +++++++----
 libavcodec/ac3_channel_layout_tab.c  | 22 +++++++++++++++++++
 libavcodec/ac3_channel_layout_tab.h  | 41 ++++++++++++++++++++++++++++++++++++
 libavcodec/ac3_parser.c              |  2 +-
 libavcodec/ac3dec.c                  |  4 ++--
 libavcodec/ac3enc.h                  |  1 +
 libavcodec/ac3tab.c                  | 14 ------------
 libavcodec/ac3tab.h                  |  4 +---
 libavcodec/eac3_data.c               |  2 ++
 libavformat/Makefile                 |  2 ++
 libavformat/ac3_channel_layout_tab.c | 22 +++++++++++++++++++
 libavformat/hls_sample_encryption.c  |  4 +++-
 libavformat/mov.c                    |  4 ++--
 13 files changed, 107 insertions(+), 27 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e048a1c377..68a9075911 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -175,8 +175,10 @@ OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o aacenctab.o    \
                                           psymodel.o mpeg4audio.o kbdwin.o
 OBJS-$(CONFIG_AAC_MF_ENCODER)          += mfenc.o mf_utils.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
-OBJS-$(CONFIG_AC3_DECODER)             += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o
-OBJS-$(CONFIG_AC3_FIXED_DECODER)       += ac3dec_fixed.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o
+OBJS-$(CONFIG_AC3_DECODER)             += ac3dec_float.o ac3dec_data.o ac3.o \
+                                          kbdwin.o ac3tab.o ac3_channel_layout_tab.o
+OBJS-$(CONFIG_AC3_FIXED_DECODER)       += ac3dec_fixed.o ac3dec_data.o ac3.o \
+                                          kbdwin.o ac3tab.o ac3_channel_layout_tab.o
 OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3enc.o ac3tab.o \
                                           ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o kbdwin.o
@@ -992,7 +994,6 @@ OBJS-$(CONFIG_FITS_DEMUXER)            += fits.o
 OBJS-$(CONFIG_LATM_MUXER)              += mpeg4audio.o
 OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += mpeg4audio.o
 OBJS-$(CONFIG_MATROSKA_MUXER)          += mpeg4audio.o
-OBJS-$(CONFIG_MOV_DEMUXER)             += ac3tab.o
 OBJS-$(CONFIG_MATROSKA_DEMUXER)        += mpeg4audio.o
 OBJS-$(CONFIG_NUT_MUXER)               += mpegaudiodata.o
 OBJS-$(CONFIG_RTP_MUXER)               += mpeg4audio.o
@@ -1001,6 +1002,8 @@ OBJS-$(CONFIG_TAK_DEMUXER)             += tak.o
 OBJS-$(CONFIG_WEBM_MUXER)              += mpeg4audio.o
 
 # libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_HLS_DEMUXER)        += ac3_channel_layout_tab.o
+STLIBOBJS-$(CONFIG_MOV_DEMUXER)        += ac3_channel_layout_tab.o
 STLIBOBJS-$(CONFIG_MXF_MUXER)          += golomb.o
 STLIBOBJS-$(CONFIG_RTP_MUXER)          += golomb.o
 
@@ -1087,7 +1090,8 @@ OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
 OBJS-$(CONFIG_AAC_LATM_PARSER)         += latm_parser.o
 OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o \
                                           mpeg4audio.o
-OBJS-$(CONFIG_AC3_PARSER)              += ac3tab.o aac_ac3_parser.o
+OBJS-$(CONFIG_AC3_PARSER)              += aac_ac3_parser.o ac3tab.o \
+                                          ac3_channel_layout_tab.o
 OBJS-$(CONFIG_ADX_PARSER)              += adx_parser.o adx.o
 OBJS-$(CONFIG_AMR_PARSER)              += amr_parser.o
 OBJS-$(CONFIG_AV1_PARSER)              += av1_parser.o
diff --git a/libavcodec/ac3_channel_layout_tab.c b/libavcodec/ac3_channel_layout_tab.c
new file mode 100644
index 0000000000..4fed46b6e7
--- /dev/null
+++ b/libavcodec/ac3_channel_layout_tab.c
@@ -0,0 +1,22 @@
+/*
+ * AC-3 channel layout table
+ * copyright (c) 2001 Fabrice Bellard
+ *
+ * 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 "ac3_channel_layout_tab.h"
diff --git a/libavcodec/ac3_channel_layout_tab.h b/libavcodec/ac3_channel_layout_tab.h
new file mode 100644
index 0000000000..46fa9ecdfe
--- /dev/null
+++ b/libavcodec/ac3_channel_layout_tab.h
@@ -0,0 +1,41 @@
+/*
+ * AC-3 channel layout table
+ * copyright (c) 2001 Fabrice Bellard
+ *
+ * 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_AC3_CHANNEL_LAYOUT_TAB_H
+#define AVCODEC_AC3_CHANNEL_LAYOUT_TAB_H
+
+#include <stdint.h>
+#include "libavutil/channel_layout.h"
+
+/**
+ * Map audio coding mode (acmod) to channel layout mask.
+ */
+const uint16_t ff_ac3_channel_layout_tab[8] = {
+    AV_CH_LAYOUT_STEREO,
+    AV_CH_LAYOUT_MONO,
+    AV_CH_LAYOUT_STEREO,
+    AV_CH_LAYOUT_SURROUND,
+    AV_CH_LAYOUT_2_1,
+    AV_CH_LAYOUT_4POINT0,
+    AV_CH_LAYOUT_2_2,
+    AV_CH_LAYOUT_5POINT0
+};
+#endif
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 9ed6ede5c3..f3c7d27d59 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -141,7 +141,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
                         (hdr->num_blocks * 256);
         hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
     }
-    hdr->channel_layout = avpriv_ac3_channel_layout_tab[hdr->channel_mode];
+    hdr->channel_layout = ff_ac3_channel_layout_tab[hdr->channel_mode];
     if (hdr->lfe_on)
         hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
 
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index c7deb56e1c..ae00373dcb 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1616,7 +1616,7 @@ dependent_frame:
         return AVERROR_INVALIDDATA;
     }
     avctx->channels = s->out_channels;
-    avctx->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
+    avctx->channel_layout = ff_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
     if (s->output_mode & AC3_OUTPUT_LFEON)
         avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
 
@@ -1700,7 +1700,7 @@ skip:
         extended_channel_map[ch] = ch;
 
     if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
-        uint64_t ich_layout = avpriv_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON];
+        uint64_t ich_layout = ff_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON];
         int channel_map_size = ff_ac3_channels_tab[s->output_mode & ~AC3_OUTPUT_LFEON] + s->lfe_on;
         uint64_t channel_layout;
         int extend = 0;
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index ec9ead8a4e..39a41fe0b0 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -35,6 +35,7 @@
 #include "ac3dsp.h"
 #include "avcodec.h"
 #include "fft.h"
+#include "internal.h"
 #include "mathops.h"
 #include "me_cmp.h"
 #include "put_bits.h"
diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
index 5c5ea7e27e..766e293a1d 100644
--- a/libavcodec/ac3tab.c
+++ b/libavcodec/ac3tab.c
@@ -82,20 +82,6 @@ const uint8_t ff_ac3_channels_tab[8] = {
     2, 1, 2, 3, 3, 4, 4, 5
 };
 
-/**
- * Map audio coding mode (acmod) to channel layout mask.
- */
-const uint16_t avpriv_ac3_channel_layout_tab[8] = {
-    AV_CH_LAYOUT_STEREO,
-    AV_CH_LAYOUT_MONO,
-    AV_CH_LAYOUT_STEREO,
-    AV_CH_LAYOUT_SURROUND,
-    AV_CH_LAYOUT_2_1,
-    AV_CH_LAYOUT_4POINT0,
-    AV_CH_LAYOUT_2_2,
-    AV_CH_LAYOUT_5POINT0
-};
-
 /**
  * Table to remap channels from AC-3 order to SMPTE order.
  * [channel_mode][lfe][ch]
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index ea8e3340c7..bc470204fe 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -24,13 +24,11 @@
 
 #include <stdint.h>
 
-#include "libavutil/internal.h"
 #include "ac3.h"
-#include "internal.h"
 
 extern const uint16_t ff_ac3_frame_size_tab[38][3];
 extern const uint8_t  ff_ac3_channels_tab[8];
-extern av_export_avcodec const uint16_t avpriv_ac3_channel_layout_tab[8];
+extern const uint16_t ff_ac3_channel_layout_tab[8];
 extern const uint8_t  ff_ac3_dec_channel_map[8][2][6];
 extern const int      ff_ac3_sample_rate_tab[];
 extern const uint16_t ff_ac3_bitrate_tab[19];
diff --git a/libavcodec/eac3_data.c b/libavcodec/eac3_data.c
index b159e1682f..2ef0e2053c 100644
--- a/libavcodec/eac3_data.c
+++ b/libavcodec/eac3_data.c
@@ -24,6 +24,8 @@
  * Tables taken directly from the E-AC-3 spec.
  */
 
+#include <stddef.h>
+
 #include "eac3_data.h"
 #include "ac3.h"
 
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 37281d5ca8..df95c34046 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -681,6 +681,8 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL)           += libzmq.o
 
 # Objects duplicated from other libraries for shared builds
 SHLIBOBJS                                += log2_tab.o
+SHLIBOBJS-$(CONFIG_HLS_DEMUXER)          += ac3_channel_layout_tab.o
+SHLIBOBJS-$(CONFIG_MOV_DEMUXER)          += ac3_channel_layout_tab.o
 SHLIBOBJS-$(CONFIG_MXF_MUXER)            += golomb_tab.o
 SHLIBOBJS-$(CONFIG_RTP_MUXER)            += golomb_tab.o
 
diff --git a/libavformat/ac3_channel_layout_tab.c b/libavformat/ac3_channel_layout_tab.c
new file mode 100644
index 0000000000..cba198ccc5
--- /dev/null
+++ b/libavformat/ac3_channel_layout_tab.c
@@ -0,0 +1,22 @@
+/*
+ * AC-3 channel layout table
+ * copyright (c) 2001 Fabrice Bellard
+ *
+ * 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/ac3_channel_layout_tab.h"
diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c
index 38795c7fb0..3dbaff717e 100644
--- a/libavformat/hls_sample_encryption.c
+++ b/libavformat/hls_sample_encryption.c
@@ -26,6 +26,8 @@
  * https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
  */
 
+#include "libavutil/channel_layout.h"
+
 #include "hls_sample_encryption.h"
 
 #include "libavcodec/adts_header.h"
@@ -129,7 +131,7 @@ int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info)
 
         st->codecpar->sample_rate = eac3_sample_rate_tab[fscod];
 
-        st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+        st->codecpar->channel_layout = ff_ac3_channel_layout_tab[acmod];
         if (lfeon)
             st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index ad5ab6b491..e401cd39b5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -813,7 +813,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     acmod = (ac3info >> 11) & 0x7;
     lfeon = (ac3info >> 10) & 0x1;
     st->codecpar->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
-    st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+    st->codecpar->channel_layout = ff_ac3_channel_layout_tab[acmod];
     if (lfeon)
         st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
     *ast = bsmod;
@@ -846,7 +846,7 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     bsmod = (eac3info >> 12) & 0x1f;
     acmod = (eac3info >>  9) & 0x7;
     lfeon = (eac3info >>  8) & 0x1;
-    st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+    st->codecpar->channel_layout = ff_ac3_channel_layout_tab[acmod];
     if (lfeon)
         st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
     st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout);



More information about the ffmpeg-cvslog mailing list