diff options
Diffstat (limited to 'libswresample/rematrix.c')
-rw-r--r-- | libswresample/rematrix.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 48aff3be7f..33e2966fd3 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -120,6 +120,7 @@ av_cold static int auto_matrix(SwrContext *s) double maxcoef=0; char buf[128]; const int matrix_encoding = s->matrix_encoding; + float maxval; in_ch_layout = clean_layout(s, s->in_ch_layout); if(!sane_layout(in_ch_layout)){ @@ -304,8 +305,16 @@ av_cold static int auto_matrix(SwrContext *s) if(s->rematrix_volume < 0) maxcoef = -s->rematrix_volume; - if(( av_get_packed_sample_fmt(s->out_sample_fmt) < AV_SAMPLE_FMT_FLT - || av_get_packed_sample_fmt(s->int_sample_fmt) < AV_SAMPLE_FMT_FLT) && maxcoef > 1.0){ + if (s->rematrix_maxval > 0) { + maxval = s->rematrix_maxval; + } else if ( av_get_packed_sample_fmt(s->out_sample_fmt) < AV_SAMPLE_FMT_FLT + || av_get_packed_sample_fmt(s->int_sample_fmt) < AV_SAMPLE_FMT_FLT) { + maxval = 1.0; + } else + maxval = INT_MAX; + + if(maxcoef > maxval){ + maxcoef /= maxval; for(i=0; i<SWR_CH_MAX; i++) for(j=0; j<SWR_CH_MAX; j++){ s->matrix[i][j] /= maxcoef; |