Browse Source

swresample: Skip over dither steps if dithering scale is 0

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n3.2
Michael Niedermayer 8 years ago
parent
commit
30b2611ed3
4 changed files with 9 additions and 1 deletions
  1. +5
    -0
      libswresample/dither.c
  2. +1
    -1
      libswresample/options.c
  3. +2
    -0
      libswresample/swresample.c
  4. +1
    -0
      libswresample/swresample_internal.h

+ 5
- 0
libswresample/dither.c View File

@@ -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) if (out_fmt == AV_SAMPLE_FMT_S32 && s->dither.output_sample_bits)
scale *= 1<<(32-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.ns_pos = 0;
s->dither.noise_scale= scale; s->dither.noise_scale= scale;
s->dither.ns_scale = scale; s->dither.ns_scale = scale;


+ 1
- 1
libswresample/options.c View File

@@ -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_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"}, {"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" , "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"}, {"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"},


+ 2
- 0
libswresample/swresample.c View File

@@ -176,6 +176,8 @@ av_cold int swr_init(struct SwrContext *s){


s->int_sample_fmt= s->user_int_sample_fmt; 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) { 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); 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; s->in_ch_layout = 0;


+ 1
- 0
libswresample/swresample_internal.h View File

@@ -120,6 +120,7 @@ struct SwrContext {
int64_t user_in_ch_layout; ///< User set input channel layout int64_t user_in_ch_layout; ///< User set input channel layout
int64_t user_out_ch_layout; ///< User set output channel layout int64_t user_out_ch_layout; ///< User set output channel layout
enum AVSampleFormat user_int_sample_fmt; ///< User set internal sample format enum AVSampleFormat user_int_sample_fmt; ///< User set internal sample format
int user_dither_method; ///< User set dither method


struct DitherContext dither; struct DitherContext dither;




Loading…
Cancel
Save