mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs
These arrays have a size of 180 resp. six bytes. This does not make it worthwhile to export them due to the overhead this occurs; for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn, 8B .got, 4B hash + twice the size of the name (here 20+23B). Therefore these symbols are unavprived and duplicated for shared builds. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
49bf94536f
commit
33e6d57f01
@ -123,7 +123,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
|
||||
mpegaudiodsp_data.o \
|
||||
mpegaudiodsp_fixed.o \
|
||||
mpegaudiodsp_float.o
|
||||
OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiodata.o
|
||||
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 \
|
||||
@ -474,9 +474,11 @@ OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec_fixed.o
|
||||
OBJS-$(CONFIG_MP1FLOAT_DECODER) += mpegaudiodec_float.o
|
||||
OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec_fixed.o
|
||||
OBJS-$(CONFIG_MP2_ENCODER) += mpegaudioenc_float.o mpegaudio.o \
|
||||
mpegaudiodata.o mpegaudiodsp_data.o
|
||||
mpegaudiodata.o mpegaudiodsp_data.o \
|
||||
mpegaudiotabs.o
|
||||
OBJS-$(CONFIG_MP2FIXED_ENCODER) += mpegaudioenc_fixed.o mpegaudio.o \
|
||||
mpegaudiodata.o mpegaudiodsp_data.o
|
||||
mpegaudiodata.o mpegaudiodsp_data.o \
|
||||
mpegaudiotabs.o
|
||||
OBJS-$(CONFIG_MP2FLOAT_DECODER) += mpegaudiodec_float.o
|
||||
OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec_fixed.o
|
||||
OBJS-$(CONFIG_MP3_MF_ENCODER) += mfenc.o mf_utils.o
|
||||
@ -990,18 +992,18 @@ OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o
|
||||
SHLIBOBJS += log2_tab.o reverse.o
|
||||
|
||||
# General libavformat dependencies
|
||||
OBJS-$(CONFIG_ISO_MEDIA) += mpegaudiodata.o
|
||||
|
||||
OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
|
||||
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
|
||||
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
|
||||
|
||||
# libavformat dependencies for static builds
|
||||
STLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
|
||||
STLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
|
||||
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
|
||||
STLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
|
||||
STLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
|
||||
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
|
||||
STLIBOBJS-$(CONFIG_MP3_MUXER) += mpegaudiotabs.o
|
||||
STLIBOBJS-$(CONFIG_NUT_MUXER) += mpegaudiotabs.o
|
||||
STLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
|
||||
STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o \
|
||||
mpeg4audio_sample_rates.o
|
||||
@ -1171,7 +1173,7 @@ OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o
|
||||
OBJS-$(CONFIG_MPEG4_UNPACK_BFRAMES_BSF) += mpeg4_unpack_bframes_bsf.o
|
||||
OBJS-$(CONFIG_MOV2TEXTSUB_BSF) += movsub_bsf.o
|
||||
OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += mp3_header_decompress_bsf.o \
|
||||
mpegaudiodata.o
|
||||
mpegaudiotabs.o
|
||||
OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o
|
||||
OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o
|
||||
OBJS-$(CONFIG_NULL_BSF) += null_bsf.o
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "bsf.h"
|
||||
#include "bsf_internal.h"
|
||||
#include "defs.h"
|
||||
#include "mpegaudiodecheader.h"
|
||||
#include "mpegaudiodata.h"
|
||||
|
||||
@ -67,10 +68,10 @@ static int mp3_header_decompress(AVBSFContext *ctx, AVPacket *out)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off
|
||||
sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off
|
||||
|
||||
for(bitrate_index=2; bitrate_index<30; bitrate_index++){
|
||||
frame_size = avpriv_mpa_bitrate_tab[lsf][2][bitrate_index>>1];
|
||||
frame_size = ff_mpa_bitrate_tab[lsf][2][bitrate_index>>1];
|
||||
frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1);
|
||||
if(frame_size == buf_size + 4)
|
||||
break;
|
||||
|
@ -26,19 +26,6 @@
|
||||
|
||||
#include "mpegaudiodata.h"
|
||||
|
||||
|
||||
const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = {
|
||||
{ {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
|
||||
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
|
||||
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
|
||||
{ {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
|
||||
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
|
||||
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
|
||||
}
|
||||
};
|
||||
|
||||
const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 };
|
||||
|
||||
/*******************************************************/
|
||||
/* layer 2 tables */
|
||||
|
||||
|
@ -31,14 +31,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include "vlc.h"
|
||||
|
||||
#define MODE_EXT_MS_STEREO 2
|
||||
#define MODE_EXT_I_STEREO 1
|
||||
|
||||
extern av_export_avcodec const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
|
||||
extern av_export_avcodec const uint16_t avpriv_mpa_freq_tab[3];
|
||||
extern const uint16_t ff_mpa_bitrate_tab[2][3][15];
|
||||
extern const uint16_t ff_mpa_freq_tab[3];
|
||||
extern const int ff_mpa_sblimit_table[5];
|
||||
extern const int ff_mpa_quant_steps[17];
|
||||
extern const int ff_mpa_quant_bits[17];
|
||||
|
@ -52,9 +52,9 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
|
||||
s->layer = 4 - ((header >> 17) & 3);
|
||||
/* extract frequency */
|
||||
sample_rate_index = (header >> 10) & 3;
|
||||
if (sample_rate_index >= FF_ARRAY_ELEMS(avpriv_mpa_freq_tab))
|
||||
if (sample_rate_index >= FF_ARRAY_ELEMS(ff_mpa_freq_tab))
|
||||
sample_rate_index = 0;
|
||||
sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
|
||||
sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
|
||||
sample_rate_index += 3 * (s->lsf + mpeg25);
|
||||
s->sample_rate_index = sample_rate_index;
|
||||
s->error_protection = ((header >> 16) & 1) ^ 1;
|
||||
@ -75,7 +75,7 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
|
||||
s->nb_channels = 2;
|
||||
|
||||
if (bitrate_index != 0) {
|
||||
frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
|
||||
frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
|
||||
s->bit_rate = frame_size * 1000;
|
||||
switch(s->layer) {
|
||||
case 1:
|
||||
|
@ -95,9 +95,9 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
|
||||
/* encoding freq */
|
||||
s->lsf = 0;
|
||||
for(i=0;i<3;i++) {
|
||||
if (avpriv_mpa_freq_tab[i] == freq)
|
||||
if (ff_mpa_freq_tab[i] == freq)
|
||||
break;
|
||||
if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
|
||||
if ((ff_mpa_freq_tab[i] / 2) == freq) {
|
||||
s->lsf = 1;
|
||||
break;
|
||||
}
|
||||
@ -110,12 +110,12 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
|
||||
|
||||
/* encoding bitrate & frequency */
|
||||
for(i=1;i<15;i++) {
|
||||
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
|
||||
if (ff_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
|
||||
break;
|
||||
}
|
||||
if (i == 15 && !avctx->bit_rate) {
|
||||
i = 14;
|
||||
bitrate = avpriv_mpa_bitrate_tab[s->lsf][1][i];
|
||||
bitrate = ff_mpa_bitrate_tab[s->lsf][1][i];
|
||||
avctx->bit_rate = bitrate * 1000;
|
||||
}
|
||||
if (i == 15){
|
||||
|
22
libavcodec/mpegaudiotabs.c
Normal file
22
libavcodec/mpegaudiotabs.c
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* MPEG Audio common tables
|
||||
* copyright (c) 2002 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 "mpegaudiotabs.h"
|
39
libavcodec/mpegaudiotabs.h
Normal file
39
libavcodec/mpegaudiotabs.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* MPEG Audio common tables
|
||||
* copyright (c) 2002 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_MPEGAUDIOTABS_H
|
||||
#define AVCODEC_MPEGAUDIOTABS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
const uint16_t ff_mpa_bitrate_tab[2][3][15] = {
|
||||
{ { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
|
||||
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
|
||||
{ 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
|
||||
{ { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
|
||||
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
|
||||
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 }
|
||||
}
|
||||
};
|
||||
|
||||
const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 };
|
||||
|
||||
#endif
|
@ -681,11 +681,14 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o
|
||||
|
||||
# Objects duplicated from other libraries for shared builds
|
||||
SHLIBOBJS += log2_tab.o
|
||||
SHLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
|
||||
SHLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
|
||||
SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
|
||||
SHLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
|
||||
SHLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
|
||||
SHLIBOBJS-$(CONFIG_MP3_MUXER) += mpegaudiotabs.o
|
||||
SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
|
||||
SHLIBOBJS-$(CONFIG_NUT_MUXER) += mpegaudiotabs.o
|
||||
SHLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
|
||||
SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o \
|
||||
mpeg4audio_sample_rates.o
|
||||
|
@ -362,7 +362,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
|
||||
return ret;
|
||||
st->codecpar->channels = cfg.channels;
|
||||
if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
|
||||
st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
|
||||
st->codecpar->sample_rate = ff_mpa_freq_tab[cfg.sampling_index];
|
||||
else if (cfg.ext_sample_rate)
|
||||
st->codecpar->sample_rate = cfg.ext_sample_rate;
|
||||
else
|
||||
|
@ -159,8 +159,8 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) || !mp3->write_xing)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
|
||||
const uint16_t base_freq = avpriv_mpa_freq_tab[i];
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(ff_mpa_freq_tab); i++) {
|
||||
const uint16_t base_freq = ff_mpa_freq_tab[i];
|
||||
|
||||
if (par->sample_rate == base_freq) ver = 0x3; // MPEG 1
|
||||
else if (par->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
|
||||
@ -170,7 +170,7 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
srate_idx = i;
|
||||
break;
|
||||
}
|
||||
if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
|
||||
if (i == FF_ARRAY_ELEMS(ff_mpa_freq_tab)) {
|
||||
av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n");
|
||||
return -1;
|
||||
}
|
||||
@ -190,7 +190,7 @@ static int mp3_write_xing(AVFormatContext *s)
|
||||
header |= channels << 6;
|
||||
|
||||
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
|
||||
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
|
||||
int bit_rate = 1000 * ff_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
|
||||
int error = FFABS(bit_rate - par->bit_rate);
|
||||
|
||||
if (error < best_bitrate_error) {
|
||||
|
22
libavformat/mpegaudiotabs.c
Normal file
22
libavformat/mpegaudiotabs.c
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* MPEG Audio common tables
|
||||
* copyright (c) 2002 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/mpegaudiotabs.h"
|
@ -70,11 +70,11 @@ static int find_expected_header(AVCodecParameters *p, int size, int key_frame,
|
||||
else if (sample_rate < (44100 + 48000) / 2) sample_rate_index = 0;
|
||||
else sample_rate_index = 1;
|
||||
|
||||
sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25);
|
||||
sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25);
|
||||
|
||||
for (bitrate_index = 2; bitrate_index < 30; bitrate_index++) {
|
||||
frame_size =
|
||||
avpriv_mpa_bitrate_tab[lsf][layer - 1][bitrate_index >> 1];
|
||||
ff_mpa_bitrate_tab[lsf][layer - 1][bitrate_index >> 1];
|
||||
frame_size = (frame_size * 144000) / (sample_rate << lsf) +
|
||||
(bitrate_index & 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user