diff --git a/libswresample/dither.c b/libswresample/dither.c
index d70505c27ef4b8498276543bbe0a697eee9cbe66..d0193dda461f90daf6bf1d291682fde529a41558 100644
--- a/libswresample/dither.c
+++ b/libswresample/dither.c
@@ -94,6 +94,9 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo
 
     scale *= s->dither.scale;
 
+    if (out_fmt == AV_SAMPLE_FMT_S32 && s->dither.output_sample_bits)
+        scale *= 1<<(32-s->dither.output_sample_bits);
+
     s->dither.ns_pos = 0;
     s->dither.noise_scale=   scale;
     s->dither.ns_scale   =   scale;
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index f69e36eeaf98c6e8adf18f8b658ec7f26e9408bd..f85f88fea5a6168e608ba3e821c1c92e86043d77 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -127,6 +127,7 @@ static const AVOption options[]={
 
 { "kaiser_beta"         , "set swr Kaiser Window Beta"  , OFFSET(kaiser_beta)    , AV_OPT_TYPE_INT  , {.i64=9                     }, 2      , 16        , PARAM },
 
+{ "output_sample_bits"   , ""  , OFFSET(dither.output_sample_bits)               , AV_OPT_TYPE_INT  , {.i64=0                     }, 0      , 64        , 0 },
 {0}
 };
 
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index 3f8090481bfda85712b9b056a37f3a52b0bde9cd..17b85d52634323d87305a4aa66b9caa71aa40609 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -63,6 +63,7 @@ struct DitherContext {
     float ns_errors[SWR_CH_MAX][2*NS_TAPS];
     AudioData noise;                                ///< noise used for dithering
     AudioData temp;                                 ///< temporary storage when writing into the input buffer isnt possible
+    int output_sample_bits;                         ///< the number of used output bits, needed to scale dither correctly
 };
 
 struct SwrContext {