From: Carl Eugen Hoyos <ceffmpeg@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH]lavc/cfhddata: Reduce required stack size Date: Fri, 2 Sep 2022 23:41:44 +0200 Message-ID: <CAB0OVGofFx4ycJ2gZFuiMuTnm44hOJmvF8yNJ8veF_yCNKdyxQ@mail.gmail.com> (raw) [-- Attachment #1: Type: text/plain, Size: 120 bytes --] Hi! Attached patch reduces the stack size of an init function, fixes part of ticket #9399. Please comment, Carl Eugen [-- Attachment #2: 0001-lavc-cfhddata-Reduce-required-stack-size.patch.txt --] [-- Type: text/plain, Size: 2482 bytes --] From 0f034ebed2388e89e241d7e08bf59d335b5c4cee Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos <ceffmpeg@gmail.com> Date: Fri, 2 Sep 2022 23:36:29 +0200 Subject: [PATCH] lavc/cfhddata: Reduce required stack size. Fixes part of ticket #9399. --- libavcodec/cfhddata.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 55c8004bdd..17aa888c84 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -276,10 +276,20 @@ static const uint8_t table_18_vlc_level[NB_VLC_TABLE_18] = { av_cold int ff_cfhd_init_vlcs(CFHDContext *s) { int i, j, ret = 0; - uint32_t new_cfhd_vlc_bits[NB_VLC_TABLE_18 * 2]; - uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2]; - uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2]; - int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2]; + uint32_t *new_cfhd_vlc_bits; + uint8_t *new_cfhd_vlc_len; + uint16_t *new_cfhd_vlc_run; + int16_t *new_cfhd_vlc_level; + + new_cfhd_vlc_bits = av_malloc(NB_VLC_TABLE_18 * 2 * 4); + new_cfhd_vlc_len = av_malloc(NB_VLC_TABLE_18 * 2); + new_cfhd_vlc_run = av_malloc(NB_VLC_TABLE_18 * 2 * 2); + new_cfhd_vlc_level = av_malloc(NB_VLC_TABLE_18 * 2 * 2); + + if (!new_cfhd_vlc_bits || !new_cfhd_vlc_len || !new_cfhd_vlc_run || !new_cfhd_vlc_level) { + ret = AVERROR(ENOMEM); + goto end; + } /** Similar to dv.c, generate signed VLC tables **/ @@ -306,7 +316,7 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) ret = init_vlc(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len, 1, 1, new_cfhd_vlc_bits, 4, 4, 0); if (ret < 0) - return ret; + goto end; for (i = 0; i < s->vlc_9.table_size; i++) { int code = s->vlc_9.table[i].sym; int len = s->vlc_9.table[i].len; @@ -347,7 +357,7 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) ret = init_vlc(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len, 1, 1, new_cfhd_vlc_bits, 4, 4, 0); if (ret < 0) - return ret; + goto end; av_assert0(s->vlc_18.table_size == 4572); for (i = 0; i < s->vlc_18.table_size; i++) { @@ -367,5 +377,11 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) s->table_18_rl_vlc[i].run = run; } +end: + av_free(new_cfhd_vlc_bits); + av_free(new_cfhd_vlc_len); + av_free(new_cfhd_vlc_run); + av_free(new_cfhd_vlc_level); + return ret; } -- 2.17.1 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2022-09-02 21:48 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=CAB0OVGofFx4ycJ2gZFuiMuTnm44hOJmvF8yNJ8veF_yCNKdyxQ@mail.gmail.com \ --to=ceffmpeg@gmail.com \ --cc=ffmpeg-devel@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