aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-08-18 11:52:11 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-08-18 11:52:11 +0200
commit30b2611ed3102c53a8aa96c71acf5dadb69997c8 (patch)
tree85aff1f741c3d7901c25657ebb8f0a1045fcef55 /libswresample
parent946acacdcdff7eb9ac6430691ac6121516da9083 (diff)
downloadffmpeg-30b2611ed3102c53a8aa96c71acf5dadb69997c8.tar.gz
swresample: Skip over dither steps if dithering scale is 0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/dither.c5
-rw-r--r--libswresample/options.c2
-rw-r--r--libswresample/swresample.c2
-rw-r--r--libswresample/swresample_internal.h1
4 files changed, 9 insertions, 1 deletions
diff --git a/libswresample/dither.c b/libswresample/dither.c
index 76f8ccf2c6..64068d35b6 100644
--- a/libswresample/dither.c
+++ b/libswresample/dither.c
@@ -102,6 +102,11 @@ av_cold int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AV
if (out_fmt == AV_SAMPLE_FMT_S32 && s->dither.output_sample_bits)
scale *= 1<<(32-s->dither.output_sample_bits);
+ if (scale == 0) {
+ s->dither.method = 0;
+ return 0;
+ }
+
s->dither.ns_pos = 0;
s->dither.noise_scale= scale;
s->dither.ns_scale = scale;
diff --git a/libswresample/options.c b/libswresample/options.c
index 816ce47750..4abf5e0518 100644
--- a/libswresample/options.c
+++ b/libswresample/options.c
@@ -70,7 +70,7 @@ static const AVOption options[]={
{"dither_scale" , "set dither scale" , OFFSET(dither.scale ), AV_OPT_TYPE_FLOAT, {.dbl=1 }, 0 , INT_MAX , PARAM},
-{"dither_method" , "set dither method" , OFFSET(dither.method ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_DITHER_NB-1, PARAM, "dither_method"},
+{"dither_method" , "set dither method" , OFFSET(user_dither_method),AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_DITHER_NB-1, PARAM, "dither_method"},
{"rectangular" , "select rectangular dither" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_RECTANGULAR}, INT_MIN, INT_MAX , PARAM, "dither_method"},
{"triangular" , "select triangular dither" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_TRIANGULAR }, INT_MIN, INT_MAX , PARAM, "dither_method"},
{"triangular_hp" , "select triangular dither with high pass" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_TRIANGULAR_HIGHPASS }, INT_MIN, INT_MAX, PARAM, "dither_method"},
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index ade81efd2c..b8ad9486eb 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -176,6 +176,8 @@ av_cold int swr_init(struct SwrContext *s){
s->int_sample_fmt= s->user_int_sample_fmt;
+ s->dither.method = s->user_dither_method;
+
if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {
av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout);
s->in_ch_layout = 0;
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index 3828b722cc..88dbc863da 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -120,6 +120,7 @@ struct SwrContext {
int64_t user_in_ch_layout; ///< User set input channel layout
int64_t user_out_ch_layout; ///< User set output channel layout
enum AVSampleFormat user_int_sample_fmt; ///< User set internal sample format
+ int user_dither_method; ///< User set dither method
struct DitherContext dither;