From patchwork Mon Apr 8 07:36:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 47911 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp2318570pzd; Mon, 8 Apr 2024 00:36:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUH3bh/1XudzwnFJMNjnRab/yCLLZJOSDIUYX7Gj3cnspXs5Mu1zcEd+bpVWKrzqkjkQytFPH0qvgPlwAcZIET8nd8lDWPpC2E5Zg== X-Google-Smtp-Source: AGHT+IG4cOGlyO4vMTtMG3qttsezB347xEmklY4pA4pskDmJQeXZ0bEGD6yPt/KKhu4W42RHzMj2 X-Received: by 2002:a17:907:20b7:b0:a4a:aaa9:8b3b with SMTP id pw23-20020a17090720b700b00a4aaaa98b3bmr4319573ejb.77.1712561786109; Mon, 08 Apr 2024 00:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712561786; cv=none; d=google.com; s=arc-20160816; b=VJoOlf52a54BJ5l0n4nQ6QJmKPZV3/Bvwyx9RuLJEtvqYhoATCbQYjWi3Y0TRsA2iD yvAgrorHE8p8JJnvx/DG4OoBx2aeZnS4nQ3Y+eQZyRq/BpErXoX8bwIt66nopTzYIenh uTGob7yB+Pb4uXJaO+bPzDDX3c2bgbprVK39Tkdirl+Eb/6AxW705qUFmslBuhIGgdUT Cl0qIBrGzsdBrEmLxSBur6L72v6SMnLFw4QL23U24jGtq5r9LcD0O93w23ayl/JMuWAY Pb/03LCHlOcMvP9SqyBsG4+Xv2l2GkVAP74wJuKuhawaFFolr64yit+vfqjKoAux8pzR u/aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:to:from:date:dkim-signature:delivered-to; bh=tU50UkG5m33gCx7aJcoeqh9N/PPioToGbFSJ59xo+UQ=; fh=Q46kXK7oI5D1Jhi90JBr53c7NIaTxGaU4KPeRZyM/hI=; b=VLYSYlM5knPiaZE3Sq57wQpWXnoQTDe6oqPn3Zcm5ujeyYJdv7EqYRAI/sEeFfVupT SuzqaT5mKrunNrmg4p2+GH1Ns9PLTVCayqviSC4uOJnIP/2KSb/Ytz88VX+fnqVc6Ds/ gWv1s3UN8RME68JFkL64NGD7q61CaLxUg3438rF6neB738nxhDeJDldMsqtGnny4vAc7 pNfpvAlof2cGhs55eLHG3ojd5eNXf4YHcRQ7vx0jO9HSEtg7BW5cNmngWCrlfkWNIHu8 6EEC5bVt9MxzBr+5hlV2JyWqzjwxcZidv6SCt5R0QRn87F3SqeOk5P1wA5SkzPo6R/9G kA2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=VMNsGK3n; 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=NONE dis=NONE) header.from=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dp9-20020a170906c14900b00a4e5c249b14si3501535ejc.881.2024.04.08.00.36.25; Mon, 08 Apr 2024 00:36:26 -0700 (PDT) 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=@lynne.ee header.s=s1 header.b=VMNsGK3n; 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=NONE dis=NONE) header.from=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D7B7468D1DA; Mon, 8 Apr 2024 10:36:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6577168C81B for ; Mon, 8 Apr 2024 10:36:12 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id CF13210602CB for ; Mon, 8 Apr 2024 07:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1712561771; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=0iTF1YWQOvrwZ1t7M+46vtoUCGF+gyCMlEmsr7bzV+w=; b=VMNsGK3nTfK9zaiBMgW0IzTuP8VUYp+72tLyxqAOID7WiX00A2vq5ifw/gh32pAe 7dXXwcuI0Pu2jMxhh+S97tluMJndzGHxDXqnFcB5bBnjWQ/WuKQtxE1nSeCNOV8t51q nHXS93nko5i684qcupq3DWCbLfxATY1Yr22alLkhLbHRhCT65FkzHVOhmMKJgd9I+c3 bDjC/CX+kSx5OO8atHqou9Ypf4/S4ASfMzm1QvAyKgASzuTEGNIhAgajgKaLPmhqaxh FUQ6nbkDe6ndxRQpZWl2eo2/vCgQk5p/Aa4vZwuhTXTE+SHqoXK+dO+aaAX7Lg4Nz/A 5umGqZns3g== Date: Mon, 8 Apr 2024 09:36:11 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCHSET] AAC decoder refactor 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 22/1kxYs9xSp The following patchset refactors the AAC decoder step by step, removing all large-scale templating and abstracting away typed DSP functions from symbol parsing. This series saves 110Kib of binary data from libavcodec.so when compiled with Clang 18 with -O3, after stripping. The patchset can also be viewed here: https://github.com/cyanreg/FFmpeg/tree/aac_cleanup Fate passes on each step, and I've been running this patchset for a week with no issues. This also prepares the decoder for USAC support. From d3dac825a1ea0c82a9a799ff9415a5a8a598d47e Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 29 Feb 2024 04:52:58 +0100 Subject: [PATCH 01/38] aacdec: move aacdec_common to aac/aacdec_tab Start to clean up the decoder. Also renames a confusingly named file. --- libavcodec/Makefile | 5 +++-- libavcodec/aac/Makefile | 5 +++++ libavcodec/{aacdec_common.c => aac/aacdec_tab.c} | 11 ++++++----- libavcodec/{aacdectab.h => aac/aacdec_tab.h} | 8 ++++---- libavcodec/aacdec.c | 2 +- libavcodec/aacdec_fixed.c | 2 +- libavcodec/aacsbr_template.c | 2 +- 7 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 libavcodec/aac/Makefile rename libavcodec/{aacdec_common.c => aac/aacdec_tab.c} (99%) rename libavcodec/{aacdectab.h => aac/aacdec_tab.h} (91%) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 708434ac76..71bef865f5 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -63,6 +63,7 @@ OBJS = ac3_parser.o \ xiph.o \ # subsystems +include $(SRC_PATH)/libavcodec/aac/Makefile include $(SRC_PATH)/libavcodec/vvc/Makefile -include $(SRC_PATH)/libavcodec/$(ARCH)/vvc/Makefile OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o @@ -177,11 +178,11 @@ OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o -OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aacdec_common.o aactab.o \ +OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o \ aacsbr.o aacps_common.o aacps_float.o \ kbdwin.o \ sbrdsp.o aacpsdsp_float.o cbrt_data.o -OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aacdec_common.o aactab.o \ +OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o \ aacsbr_fixed.o aacps_common.o aacps_fixed.o \ kbdwin.o \ sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile new file mode 100644 index 0000000000..52facdf4cf --- /dev/null +++ b/libavcodec/aac/Makefile @@ -0,0 +1,5 @@ +clean:: + $(RM) $(CLEANSUFFIXES:%=libavcodec/aac/%) + +OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec_tab.o +OBJS-$(CONFIG_AAC_FIXED_DECODER) += aac/aacdec_tab.o diff --git a/libavcodec/aacdec_common.c b/libavcodec/aac/aacdec_tab.c similarity index 99% rename from libavcodec/aacdec_common.c rename to libavcodec/aac/aacdec_tab.c index 145c718047..45a84a9a72 100644 --- a/libavcodec/aacdec_common.c +++ b/libavcodec/aac/aacdec_tab.c @@ -25,11 +25,12 @@ * Common code and tables of the AAC fixed- and floating-point decoders */ -#include "aac.h" -#include "aacdectab.h" -#include "aacps.h" -#include "aactab.h" -#include "vlc.h" +#include "aacdec_tab.h" + +#include "libavcodec/aac.h" +#include "libavcodec/aacps.h" +#include "libavcodec/aactab.h" +#include "libavcodec/vlc.h" #include "libavutil/attributes.h" #include "libavutil/thread.h" diff --git a/libavcodec/aacdectab.h b/libavcodec/aac/aacdec_tab.h similarity index 91% rename from libavcodec/aacdectab.h rename to libavcodec/aac/aacdec_tab.h index 184508f2f3..70e49af202 100644 --- a/libavcodec/aacdectab.h +++ b/libavcodec/aac/aacdec_tab.h @@ -25,12 +25,12 @@ * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) */ -#ifndef AVCODEC_AACDECTAB_H -#define AVCODEC_AACDECTAB_H +#ifndef AVCODEC_AAC_AACDEC_TAB_H +#define AVCODEC_AAC_AACDEC_TAB_H #include -#include "vlc.h" +#include "libavcodec/vlc.h" #include "libavutil/attributes_internal.h" #include "libavutil/channel_layout.h" @@ -52,4 +52,4 @@ extern const int16_t ff_aac_channel_map[3][4][6]; extern const AVChannelLayout ff_aac_ch_layout[]; FF_VISIBILITY_POP_HIDDEN -#endif /* AVCODEC_AACDECTAB_H */ +#endif /* AVCODEC_AAC_AACDEC_TAB_H */ diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 97e51dd72a..0a9ff1bfaf 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -46,7 +46,7 @@ #include "aac.h" #include "aacdec.h" #include "aactab.h" -#include "aacdectab.h" +#include "aac/aacdec_tab.h" #include "adts_header.h" #include "cbrt_data.h" #include "sbr.h" diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index 305bb0ba9a..681e502e42 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -72,7 +72,7 @@ #include "aac.h" #include "aacdec.h" #include "aactab.h" -#include "aacdectab.h" +#include "aac/aacdec_tab.h" #include "adts_header.h" #include "cbrt_data.h" #include "sbr.h" diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index cdfaed636b..eadd6fa2d3 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -33,7 +33,7 @@ */ #include "aacdec.h" -#include "aacdectab.h" +#include "aac/aacdec_tab.h" #include "avcodec.h" #include "libavutil/qsort.h" -- 2.43.0.381.gb435a96ce8