From patchwork Wed Dec 15 12:35:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 32527 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp8176344iog; Wed, 15 Dec 2021 04:37:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJys4q/8sXEBjqvGSYUIVD2C3Wea3ZUAm0y8oK7v/h63sqWrEiOP63lxoyskGYnnw0vvLoQ9 X-Received: by 2002:a05:6402:516c:: with SMTP id d12mr14029031ede.391.1639571820125; Wed, 15 Dec 2021 04:37:00 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qf38si1301723ejc.831.2021.12.15.04.36.59; Wed, 15 Dec 2021 04:37:00 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=kZbhkaI6; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 11A3868B0E9; Wed, 15 Dec 2021 14:36:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-oln040092067080.outbound.protection.outlook.com [40.92.67.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 913EA68AF5B for ; Wed, 15 Dec 2021 14:36:09 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XxDnLnqp7c79V+rsbrx36ng9gLrtoB4y9irXBjGNa8Vw+hEiO9qUqdY0PCGsdOp6QK1UlGDHaynr/WcFlBpm6iQFejtkhhW93uGdvWIrWaFVdHE/8UxxCmklg0kSAmADgU1130ozNXw7oo5yGjwEIHK1EN6VL8Q6REJqH9Qs6C0NUFS06Fh/v/1QbrsONMqOZ1j/MRhBrScX6OVZM580RXkuffnMYnBWj8IPBVWbNIF5OS29xMXcajBM26e4yHEQn8b4ya85knU1OB8VetqkClkdL44vKGpKiMwXA0xkwGyXKQI572wRR5hSCY5DJNqAEnHH/8YfIDWCHo6YBjVpSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6c4rlmiSTezWgG1xdgDl54f6YnxhN2IOt5cmy8udbY0=; b=kKrH96CFOBuHdu9Q6wOS7gxnoeALjkhEmlGymWHdBpmwDmN7cx5ILkMgsLW9K/gPl0Ux2mYOfRueVU38npH7KEdH1Lv3QiDp3koM9Wv3oo+dDAZeFF08pSAOM9F57uUvoYlNzrp10muM44oFt/7X/ArxPpe6qwORY933vKNVJbfTYGFRn0mDZg3HMY4EECY8VsQb2Y83vWB3JB3zdOQtixPKx8Wx0JamDcHTP9TcU0L0C2TwGqwxqwQcIQaN+ySkUxit8TWxkrakC600s2Dy8rZDeoDE3O1nZzjComJVPvAEJU3B2hYRhS+JMEjqRIGMHBrdshlMtAgyTmtyMyab5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6c4rlmiSTezWgG1xdgDl54f6YnxhN2IOt5cmy8udbY0=; b=kZbhkaI66Jw68m1HmDcF1D3YjryE2xPg1XhB+jm3tJdCEsTFzP1fu6PJMMlMDiT/FQvPrVvz96sBMfVYZMi29lEhqFePAHtExmxVeiW4jyl9YUc6IjS17GcH7FFoDP84pVlkm/PubMaa4yQMGHzU4uGtRzgrF80YKp+WShlp9I5eTpQHA0JAvjQzBDGACaAj9idYyISgUXBVRMcr5BZi9R17PdBv19Fc+1TzsEY90rGhfoluRySp2J9kptrB7CdMrKT8HQDDpXRboyJSHOjf8hV03TQ7wlGxlvoZOiR71hged4lIFHQ8bM7r/bwHjGLXhvYnSrl2vo582a1blFK+5g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4952.eurprd03.prod.outlook.com (2603:10a6:20b:8a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.17; Wed, 15 Dec 2021 12:36:01 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca%6]) with mapi id 15.20.4778.018; Wed, 15 Dec 2021 12:36:01 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Dec 2021 13:35:38 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [2F39YqcvAbDvmXPiIBAbteA+VpBwer6D] X-ClientProxiedBy: AM0PR08CA0014.eurprd08.prod.outlook.com (2603:10a6:208:d2::27) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211215123541.5406-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3bcb505-6e91-4b5d-5e4f-08d9bfc773ae X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWm3GLoeUntTG6KfWWWbWhlGbOjvIzX7qlllizbKbI7Wx81Yodz/xd870MMHumcGcl4tG8SUetI6ELKC7F+Hqfk1yTQtck5kcOjpFD7hCj1IWGzB0QEc1ddFGOsfjRZrzqxGXg4oBB4hvsrqrvzEH7QqhW7oiE4va0cb0/yKXqnDjuEPIS2pJmK0s/fOuHUCT20hy6nW/8OX1HPiIGVUorUhtdfByE0hXLfG3bgkY25zLazLm/Ap+Z+7yyVx9DQtbXDWyuZTZFUstvbeeE8mUyb6mf7RT8r2sQUw9eZzobDiWfv7Y5LZwAweYE+lNkO7K1pZXD4ZR+SJ96uvS+uKaq65syqNpVkSTiAEknQskBKlcNq+TPwG8s2hg5rOV6JaizVGllJqw/D6G/tHrXCQBCHp5Rrz+9D2bPb82bbua1d5qpWLXiziVu5Eh4L8mNsXQrbmsRv0AyyWkQvGtgD7MWGWdcg2V5SFFum7zG8C6fN5LtF15P3Erv96l+0/EaOhatg+pT0cXXedFt7Ib2ESBHPttl3+kpHSSjIWTVDmd22W9URfg43FJFqyGCpxDurYWqtlJSzSDls5K3E//5EwUwXOT7IrtNdhep7XcmBlhbquds0Wo+eknDfFMYb6FnQhmgUzti4nk61bXIcCEPOIRkrwxxVQs17/QiW/lejmsgFJrUJi4sIoHESQEzyw6CIxtxGGaVKRW4/ptDv7f6YT1jh4IfPUAhtUzY= X-MS-TrafficTypeDiagnostic: AM6PR03MB4952:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /cARDVDQygiGJdTwkcKQZ2Qvvzy0kO3oNvRAypHDQmenVfkJmVXKHAS7ZDFJLieARxeisvbj8hY/WZXvau872Q8mM0ZiX6018yMYNKhQ/EcUqAf4F9fwz5Em/VqjvXh86k2mRzs9HKJzjSgbpmA8YvYXfxgmPikyn3hL7a1FKQlR8K7mE9nDExfippUbpvaI/5lgWkDOovlT7PdpRs99dHxtHScf4k/AN1gXoWQUEkQ3/CLahXAK/kYsiR261Fl+u9EEUVEtZ2cAxIAtD+n+/t3nceXtcqZcqvVWOAwfkKfjYTgxfGm7OCHF3IbJBnb12H5HiBhf9WvvwtBZUt6LdQxWzwSspMUyw/PAmuMXsOfWEfcE68CKZM5m8Uyd+3XxrMzlGqSz8UTQyUp3iHxc4m7DxUyTFSnAmPlmS8Clfqs9ynfJPQ5FYQpknRp0MbZJFodpcJLqYZ4X+uCoPkhckCjJ6xJYUtm6V159JluWNZwqZePicuh5Q3NA5U6L7+ihoxYggWa8bMCBGlhIVchOYxrMoWgLhho9tWNIx3Em+HL/aJXvYOkVo110QNGCrCraVDCi4r/JU3hzlDSD76GsAw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 34XuVHYxVSXyZ1M7KJ4/220Qyl2Tk87EC+3DL7G1Yc9ICut43UlZtOmOIvc9WJBzfM6+XLxBgokeUa4JkPamB/cDB3JvUbkYogYHlwc4234fKBK0AD6kxKY9v7wIKHE5Cjk2IFfFGFvS1pSQFyuCUcDA6K21n+6TM9MxSWtrW7wrIPY0jheVEhbPAOjOPy8GQdl9CVT5TcvnyqfV6aKVzc/CBQ0Nbhact4bG8vuW83dm16+UDC2hfrQGLULb1Y3KzFv434g0Ri1iVjEI+hUX1XnTtLIeFaEGs2dWFBWLULQM9Nkxzq0XYNTuLJkSI45WdTthp34mWLVUZKkmYZwv3xUmaGBccbICbEu9xZ1l8tp+QTqp+pKAY5eFAsWWs95eDXFirty7sCzszKwa1JKlaG//SSbFfogOh9epk0Hghlr4RgGIeosjl7Em8l0oPs40/gIIDNVhM2unpvPNP4IZJWa1OUF0I6jnP9RZbQJ1vYp6G580W13TnymPqMnn0Sdnw2ZdN+6pQVnJs0bbANuon+ZJMyVmZggvmkgE5Ke8xrZshf+X7YGRosQSH59gTKU6zz7fpzbCwwOiVAV62ylJq/7l/JuVHeTdYThuxmanu0nTvVG1eF0N0So4OOHnY6fkukNd+zkhKHxVcoXYH+Ug56B4mI1bDv1JcHSbvzvRPgNE6qavoKRMAch4eR/3oJii5XkexqGQpJinaNBnWT47DtOMD/dxRWtxFJWnXcNiusMQYQlPB4ZL+JI1Nz4yeQ1aRIx4AI/0cjDS9Elq19IvmWONQfT9Isx3khtZf4HZCDPwWazdyupiLIMTZk+ZhrPM+sz5i3U11Js/RDe0LinxPgJopP0RS5RwaPm1UpOMEcODP4/kCAeDsvqplJok4HXC6O/44G6id6CaA+SziF4BGuo9/yXynVDuh7Dm1mTt4e3HaAPbTVeFwnwFzMkHB8JKhd3+Xq6YMBiD8NpoxhAiPw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3bcb505-6e91-4b5d-5e4f-08d9bfc773ae X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2021 12:36:01.2339 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4952 Subject: [FFmpeg-devel] [PATCH 08/11] avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0Kdv/220MH2l avpriv_mpeg4audio_sample_rates has a size of 64B and it is currently avpriv; a clone of it exists in aacenctab.h and from there it is inlined in aacenc.c (which also uses the avpriv version) and in the FLV muxer. This means that despite it being avpriv both libavformat as well as libavcodec have copies already. This situation is clearly suboptimal. Given the overhead of exporting symbols (for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn, 8B .got, 4B hash + twice the size of the name (here 31B)) the object is unavprived, i.e. duplicated into libavformat when creating a shared build; but the duplicates in the AAC encoder and FLV muxer are removed. This involves splitting of the sample rate table into a file of its own; this allowed to break some spurious dependencies (e.g. both the AAC encoder as well as the Matroska demuxer actually don't need the mpeg4audio_get_config stuff). Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 14 +++++++------ libavcodec/aacenc.c | 4 ++-- libavcodec/aacenctab.h | 7 ------- libavcodec/adts_header.c | 4 ++-- libavcodec/mpeg4audio.c | 9 +------- libavcodec/mpeg4audio.h | 3 +-- libavcodec/mpeg4audio_sample_rates.c | 23 ++++++++++++++++++++ libavcodec/mpeg4audio_sample_rates.h | 30 +++++++++++++++++++++++++++ libavformat/Makefile | 5 ++++- libavformat/flvenc.c | 4 ++-- libavformat/matroskadec.c | 4 ++-- libavformat/mpeg4audio_sample_rates.c | 23 ++++++++++++++++++++ libavformat/sdp.c | 2 +- 13 files changed, 99 insertions(+), 33 deletions(-) create mode 100644 libavcodec/mpeg4audio_sample_rates.c create mode 100644 libavcodec/mpeg4audio_sample_rates.h create mode 100644 libavformat/mpeg4audio_sample_rates.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 026b558d32..42caa1d59c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -60,7 +60,7 @@ OBJS = ac3_parser.o \ # subsystems OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o -OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o +OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio_sample_rates.o OBJS-$(CONFIG_AMF) += amfenc.o OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o OBJS-$(CONFIG_ATSC_A53) += atsc_a53.o @@ -123,7 +123,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \ mpegaudiodsp_fixed.o \ mpegaudiodsp_float.o OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiodata.o -OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.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 @@ -172,7 +172,8 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \ aacenc_tns.o \ aacenc_ltp.o \ aacenc_pred.o \ - psymodel.o mpeg4audio.o kbdwin.o + psymodel.o kbdwin.o \ + mpeg4audio_sample_rates.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 \ @@ -989,17 +990,18 @@ SHLIBOBJS += log2_tab.o reverse.o OBJS-$(CONFIG_ISO_MEDIA) += mpegaudiodata.o OBJS-$(CONFIG_FITS_DEMUXER) += fits.o -OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o -OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o OBJS-$(CONFIG_TAK_DEMUXER) += tak.o # libavformat dependencies for static builds +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_RTPDEC) += jpegtables.o -STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o +STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o \ + mpeg4audio_sample_rates.o STLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o # libavfilter dependencies diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index e462566078..a1004c3e98 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -998,7 +998,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) /* Samplerate */ for (i = 0; i < 16; i++) - if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i]) + if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) break; s->samplerate_index = i; ERROR_IF(s->samplerate_index == 16 || @@ -1143,7 +1143,7 @@ const AVCodec ff_aac_encoder = { .encode2 = aac_encode_frame, .close = aac_encode_end, .defaults = aac_encode_defaults, - .supported_samplerates = mpeg4audio_sample_rates, + .supported_samplerates = ff_mpeg4audio_sample_rates, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h index f54dd16bed..33cb7ae95b 100644 --- a/libavcodec/aacenctab.h +++ b/libavcodec/aacenctab.h @@ -81,13 +81,6 @@ static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = { { 2, 0, 1, 6, 7, 4, 5, 3 }, }; -/* duplicated from avpriv_mpeg4audio_sample_rates to avoid shared build - * failures */ -static const int mpeg4audio_sample_rates[16] = { - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000, 7350 -}; - /** bits needed to code codebook run value for long windows */ static const uint8_t run_value_bits_long[64] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, diff --git a/libavcodec/adts_header.c b/libavcodec/adts_header.c index e4454529c4..ff4efafbf7 100644 --- a/libavcodec/adts_header.c +++ b/libavcodec/adts_header.c @@ -40,7 +40,7 @@ int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr) crc_abs = get_bits1(gbc); /* protection_absent */ aot = get_bits(gbc, 2); /* profile_objecttype */ sr = get_bits(gbc, 4); /* sample_frequency_index */ - if (!avpriv_mpeg4audio_sample_rates[sr]) + if (!ff_mpeg4audio_sample_rates[sr]) return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; skip_bits1(gbc); /* private_bit */ ch = get_bits(gbc, 3); /* channel_configuration */ @@ -63,7 +63,7 @@ int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr) hdr->crc_absent = crc_abs; hdr->num_aac_frames = rdb + 1; hdr->sampling_index = sr; - hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr]; + hdr->sample_rate = ff_mpeg4audio_sample_rates[sr]; hdr->samples = (rdb + 1) * 1024; hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; hdr->frame_length = size; diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index be50de9052..ed72a80f6d 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -57,13 +57,6 @@ static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c, void *logctx return 0; } -/* XXX: make sure to update the copies in the different encoders if you change - * this table */ -const int avpriv_mpeg4audio_sample_rates[16] = { - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000, 7350 -}; - const uint8_t ff_mpeg4audio_channels[14] = { 0, 1, // mono (1/0) @@ -93,7 +86,7 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) { *index = get_bits(gb, 4); return *index == 0x0f ? get_bits(gb, 24) : - avpriv_mpeg4audio_sample_rates[*index]; + ff_mpeg4audio_sample_rates[*index]; } int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb, diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index 3187df68d2..c486a3ddef 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -27,7 +27,6 @@ #include "libavutil/attributes.h" #include "get_bits.h" -#include "internal.h" #include "put_bits.h" typedef struct MPEG4AudioConfig { @@ -45,7 +44,7 @@ typedef struct MPEG4AudioConfig { int frame_length_short; } MPEG4AudioConfig; -extern av_export_avcodec const int avpriv_mpeg4audio_sample_rates[16]; +extern const int ff_mpeg4audio_sample_rates[16]; extern const uint8_t ff_mpeg4audio_channels[14]; /** diff --git a/libavcodec/mpeg4audio_sample_rates.c b/libavcodec/mpeg4audio_sample_rates.c new file mode 100644 index 0000000000..b5ceb59c6e --- /dev/null +++ b/libavcodec/mpeg4audio_sample_rates.c @@ -0,0 +1,23 @@ +/* + * MPEG-4 Audio sample rates + * Copyright (c) 2008 Baptiste Coudurier + * Copyright (c) 2009 Alex Converse + * + * 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 "mpeg4audio_sample_rates.h" diff --git a/libavcodec/mpeg4audio_sample_rates.h b/libavcodec/mpeg4audio_sample_rates.h new file mode 100644 index 0000000000..0b8caa6d76 --- /dev/null +++ b/libavcodec/mpeg4audio_sample_rates.h @@ -0,0 +1,30 @@ +/* + * MPEG-4 Audio sample rates + * Copyright (c) 2008 Baptiste Coudurier + * Copyright (c) 2009 Alex Converse + * + * 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_MPEG4AUDIO_SAMPLE_RATES_H +#define AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H + +const int ff_mpeg4audio_sample_rates[16] = { + 96000, 88200, 64000, 48000, 44100, 32000, + 24000, 22050, 16000, 12000, 11025, 8000, 7350 +}; +#endif diff --git a/libavformat/Makefile b/libavformat/Makefile index ee6a6370cd..c89e413dda 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -678,11 +678,14 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o # Objects duplicated from other libraries for shared builds SHLIBOBJS += log2_tab.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_MXF_MUXER) += golomb_tab.o SHLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o -SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o +SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o \ + mpeg4audio_sample_rates.o SHLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o # libavdevice dependencies diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 5130d429ad..f1ef15b1bb 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -24,6 +24,7 @@ #include "libavutil/intfloat.h" #include "libavutil/avassert.h" #include "libavutil/mathematics.h" +#include "libavcodec/mpeg4audio.h" #include "avio_internal.h" #include "avio.h" #include "avc.h" @@ -33,7 +34,6 @@ #include "metadata.h" #include "libavutil/opt.h" #include "libavcodec/put_bits.h" -#include "libavcodec/aacenctab.h" static const AVCodecTag flv_video_codec_ids[] = { @@ -514,7 +514,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i for (samplerate_index = 0; samplerate_index < 16; samplerate_index++) if (flv->audio_par->sample_rate - == mpeg4audio_sample_rates[samplerate_index]) + == ff_mpeg4audio_sample_rates[samplerate_index]) break; init_put_bits(&pbc, data, sizeof(data)); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index a4bbbe954e..f823fb96b8 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2011,8 +2011,8 @@ static int matroska_aac_sri(int samplerate) { int sri; - for (sri = 0; sri < FF_ARRAY_ELEMS(avpriv_mpeg4audio_sample_rates); sri++) - if (avpriv_mpeg4audio_sample_rates[sri] == samplerate) + for (sri = 0; sri < FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++) + if (ff_mpeg4audio_sample_rates[sri] == samplerate) break; return sri; } diff --git a/libavformat/mpeg4audio_sample_rates.c b/libavformat/mpeg4audio_sample_rates.c new file mode 100644 index 0000000000..212385f348 --- /dev/null +++ b/libavformat/mpeg4audio_sample_rates.c @@ -0,0 +1,23 @@ +/* + * MPEG-4 Audio sample rates + * Copyright (c) 2008 Baptiste Coudurier + * Copyright (c) 2009 Alex Converse + * + * 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/mpeg4audio_sample_rates.h" diff --git a/libavformat/sdp.c b/libavformat/sdp.c index e83616cfbe..e3617616c5 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -453,7 +453,7 @@ static char *latm_context2config(AVFormatContext *s, AVCodecParameters *par) char *config; for (rate_index = 0; rate_index < 16; rate_index++) - if (avpriv_mpeg4audio_sample_rates[rate_index] == par->sample_rate) + if (ff_mpeg4audio_sample_rates[rate_index] == par->sample_rate) break; if (rate_index == 16) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");