[FFmpeg-devel] [PATCH 3/4] libswresample: Avoid needlessly large on-stack array.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed Sep 3 00:01:54 CEST 2014


We only actually use a tiny part of it.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libswresample/rematrix.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index bf2abcf..60b8caf 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -56,6 +56,7 @@
 #define TOP_BACK_LEFT          15
 #define TOP_BACK_CENTER        16
 #define TOP_BACK_RIGHT         17
+#define NUM_NAMED_CHANNELS     18
 
 int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
 {
@@ -112,7 +113,7 @@ static int sane_layout(int64_t layout){
 av_cold static int auto_matrix(SwrContext *s)
 {
     int i, j, out_i;
-    double matrix[64][64]={{0}};
+    double matrix[NUM_NAMED_CHANNELS][NUM_NAMED_CHANNELS]={{0}};
     int64_t unaccounted, in_ch_layout, out_ch_layout;
     double maxcoef=0;
     char buf[128];
@@ -295,10 +296,10 @@ av_cold static int auto_matrix(SwrContext *s)
             av_assert0(0);
     }
 
-    for(out_i=i=0; i<64; i++){
+    for(out_i=i=0; i<FF_ARRAY_ELEMS(matrix); i++){
         double sum=0;
         int in_i=0;
-        for(j=0; j<64; j++){
+        for(j=0; j<FF_ARRAY_ELEMS(matrix[0]); j++){
             s->matrix[out_i][in_i]= matrix[i][j];
             if(matrix[i][j]){
                 sum += fabs(matrix[i][j]);
-- 
2.1.0



More information about the ffmpeg-devel mailing list