[FFmpeg-cvslog] swresample: Skip over dither steps if dithering scale is 0
Michael Niedermayer
git at videolan.org
Thu Aug 18 13:16:06 EEST 2016
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Thu Aug 18 11:52:11 2016 +0200| [30b2611ed3102c53a8aa96c71acf5dadb69997c8] | committer: Michael Niedermayer
swresample: Skip over dither steps if dithering scale is 0
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30b2611ed3102c53a8aa96c71acf5dadb69997c8
---
libswresample/dither.c | 5 +++++
libswresample/options.c | 2 +-
libswresample/swresample.c | 2 ++
libswresample/swresample_internal.h | 1 +
4 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libswresample/dither.c b/libswresample/dither.c
index 76f8ccf..64068d3 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 816ce47..4abf5e0 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 ade81ef..b8ad948 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 3828b72..88dbc86 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;
More information about the ffmpeg-cvslog
mailing list