From: yibofang via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: yibofang <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] avcodec/cbrt_table: use dynamic buffer instead of static array (PR #20392) Message-ID: <175677656322.25.7054494836745946690@463a07221176> (raw) PR #20392 opened by yibofang URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20392 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20392.patch The cbrt table generator previously used a 128 KiB static buffer in .bss. Replace it with a temporary av_malloc()/av_free() buffer used only at init. This saves ~128 KiB permanent bss, which is valuable on resource-constrained platforms. >From ae007d38ba0a8979339803e4db41a732de8d9238 Mon Sep 17 00:00:00 2001 From: YiboFang <blueybf777@outlook.com> Date: Tue, 26 Aug 2025 16:51:58 +0800 Subject: [PATCH] avcodec/cbrt_table: use dynamic buffer instead of static array The cbrt table generator previously used a 128 KiB static buffer in .bss. Replace it with a temporary av_malloc()/av_free() buffer used only at init. This saves ~128 KiB permanent bss, which is valuable on resource-constrained platforms. Build cmd: ./configure --arch=arm --target-os=linux \ --enable-cross-compile \ --cross-prefix=arm-linux-gnueabihf- \ --extra-cflags='-march=armv7-a -mfpu=neon-vfpv3 -mfloat-abi=hard -fPIC' On ARM cross build (armv7-a, NEON): before: text=15445946, data=750736, bss=23495660 after : text=15446058 (+112 B), data=750736, bss=23364588 (-128 KiB) overall image size reduced by ~128 KiB. Signed-off-by: Yibo Fang <fangyibo@xiaomi.com> Signed-off-by: YiboFang <fangyibo@xiaomi.com> --- libavcodec/cbrt_tablegen.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h index 9af18d8ab5..70eccd8a73 100644 --- a/libavcodec/cbrt_tablegen.h +++ b/libavcodec/cbrt_tablegen.h @@ -25,6 +25,8 @@ #include <stdint.h> #include <math.h> +#include "libavutil/log.h" +#include "libavutil/mem.h" #include "libavutil/attributes.h" #include "libavutil/intfloat.h" #include "libavcodec/aac_defines.h" @@ -39,11 +41,18 @@ uint32_t AAC_RENAME(ff_cbrt_tab)[1 << 13]; av_cold void AAC_RENAME(ff_cbrt_tableinit)(void) { - static double cbrt_tab_dbl[1 << 13]; if (!AAC_RENAME(ff_cbrt_tab)[(1<<13) - 1]) { + double *cbrt_tab_dbl; int i, j, k; double cbrt_val; + cbrt_tab_dbl = av_malloc((1 << 13) * sizeof(double)); + if (!cbrt_tab_dbl) { + av_log(NULL, AV_LOG_ERROR, "cbrt_tableinit malloc failed %zu\n", + (1 << 13) * sizeof(double)); + return; + } + for (i = 1; i < 1<<13; i++) cbrt_tab_dbl[i] = 1; @@ -67,6 +76,8 @@ av_cold void AAC_RENAME(ff_cbrt_tableinit)(void) for (i = 0; i < 1<<13; i++) AAC_RENAME(ff_cbrt_tab)[i] = CBRT(cbrt_tab_dbl[i]); + + av_free(cbrt_tab_dbl); } } -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-09-02 1:29 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=175677656322.25.7054494836745946690@463a07221176 \ --to=ffmpeg-devel@ffmpeg.org \ --cc=code@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