From 2f86566a31e4c20816e1fc70ca747aa1fddc09c3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 26 Oct 2011 00:44:35 +0200 Subject: rematrix: add parameter to tune volume Signed-off-by: Michael Niedermayer --- libswresample/rematrix.c | 12 ++++++++++++ libswresample/swresample.c | 3 ++- libswresample/swresample_internal.h | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'libswresample') diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 9dcfecbd80..130bb7416a 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -210,6 +210,9 @@ int swr_rematrix_init(SwrContext *s){ if(s->out_ch_layout & (1ULL<rematrix_volume < 0) + maxcoef = -s->rematrix_volume; + if(( s->out_sample_fmt < AV_SAMPLE_FMT_FLT || s->int_sample_fmt < AV_SAMPLE_FMT_FLT) && maxcoef > 1.0){ for(i=0; imatrix32[i][j]= lrintf(s->matrix[i][j] * 32768); } } + + if(s->rematrix_volume > 0){ + for(i=0; imatrix[i][j] *= s->rematrix_volume; + s->matrix32[i][j]= lrintf(s->matrix[i][j] * 32768); + } + } + for(i=0; iout_ch_layout); i++){ for(j=0; jin_ch_layout); j++){ av_log(NULL, AV_LOG_DEBUG, "%f ", s->matrix[i][j]); diff --git a/libswresample/swresample.c b/libswresample/swresample.c index a03d531d0f..d0fb96e008 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -49,6 +49,7 @@ static const AVOption options[]={ {"ocl", "output channel layout", OFFSET(out_ch_layout), AV_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"}, {"clev", "center mix level" , OFFSET(clev) , AV_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0}, {"slev", "sourround mix level" , OFFSET(slev) , AV_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0}, +{"rmvol", "rematrix volume" , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, -1000, 1000, 0}, {"flags", NULL , OFFSET(flags) , AV_OPT_TYPE_FLAGS, {.dbl=0}, 0, UINT_MAX, 0, "flags"}, {"res", "force resampling", 0, AV_OPT_TYPE_CONST, {.dbl=SWR_FLAG_RESAMPLE}, INT_MIN, INT_MAX, 0, "flags"}, @@ -176,7 +177,7 @@ int swr_init(SwrContext *s){ if(!s->out_ch_layout) s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count); - s->rematrix= s->out_ch_layout !=s->in_ch_layout; + s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0; #define RSC 1 //FIXME finetune if(!s-> in.ch_count) diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index fc5f25c4a3..4678886bdb 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -44,7 +44,7 @@ typedef struct SwrContext { //FIXME find unused fields int in_sample_rate; int out_sample_rate; int flags; - float slev, clev; + float slev, clev, rematrix_volume; //below are private int int_bps; -- cgit v1.2.3