Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-09-06 23:22:36 +0400
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-09-07 13:31:34 +0400
commit2c5c37ade115b5efa3f77ce11bc2c4e46b384959 (patch)
tree2d374a9075ffb00842df8d2ad33f5d7c6cc9e2ed /libswresample
parent284123d7fd8e78a7daa948b662e65eda3b33fce2 (diff)
libswresample: move condition to start of loop.
This avoids several issue like calculating sum/maxcoef incorrectly due to adding up matrix entries that will be overwritten, as well as out-of-range writes to s->matrix if the maximum allowed number of channels is used. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/rematrix.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 5da3056ecc..6552a2fea2 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -299,18 +299,20 @@ av_cold static int auto_matrix(SwrContext *s)
for(out_i=i=0; i<64; i++){
double sum=0;
int in_i=0;
+ if((out_ch_layout & (1ULL<<i)) == 0)
+ continue;
for(j=0; j<64; j++){
+ if((in_ch_layout & (1ULL<<j)) == 0)
+ continue;
if (i < FF_ARRAY_ELEMS(matrix) && j < FF_ARRAY_ELEMS(matrix[0]))
s->matrix[out_i][in_i]= matrix[i][j];
else
s->matrix[out_i][in_i]= i == j && (in_ch_layout & out_ch_layout & (1ULL<<i));
sum += fabs(s->matrix[out_i][in_i]);
- if(in_ch_layout & (1ULL<<j))
- in_i++;
+ in_i++;
}
maxcoef= FFMAX(maxcoef, sum);
- if(out_ch_layout & (1ULL<<i))
- out_i++;
+ out_i++;
}
if(s->rematrix_volume < 0)
maxcoef = -s->rematrix_volume;