Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH]lavc/cfhddata: Reduce required stack size
@ 2022-09-02 21:41 Carl Eugen Hoyos
  0 siblings, 0 replies; only message in thread
From: Carl Eugen Hoyos @ 2022-09-02 21:41 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- 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".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-02 21:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 21:41 [FFmpeg-devel] [PATCH]lavc/cfhddata: Reduce required stack size Carl Eugen Hoyos

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