History

swr: generate more dither noise to improve quality.

Michael Niedermayer committed 14 years ago

Commit 1fc4ff21 parent 22057e82 files · +9 −4Browse files

Showing the changes to libswresample (2 of 2 files). Show all

Unified · Split

2 files
  1. libswresample/swresample.c +8 −4
  2. libswresample/swresample_internal.h +1 −0
libswresample/swresample.c+8−4
@@ -519,18 +519,22 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co · 518 unmodified lines
519519 if(preout != out && out_count){
520520 if(s->dither_method){
521521 int ch;
522+ int dither_count= FFMAX(out_count, 1<<16);
522523 av_assert0(preout != in);
523524
524− if((ret=realloc_audio(&s->dither, out_count))<0)
525+ if((ret=realloc_audio(&s->dither, dither_count))<0)
525526 return ret;
526527 if(ret)
527528 for(ch=0; ch<s->dither.ch_count; ch++)
528529 swri_get_dither(s->dither.ch[ch], s->dither.count, 12345678913579<<ch, s->out_sample_fmt, s->int_sample_fmt, s->dither_method);
529530 av_assert0(s->dither.ch_count == preout->ch_count);
530531
531− for(ch=0; ch<preout->ch_count; ch++){
532− swri_sum2(s->int_sample_fmt, preout->ch[ch], preout->ch[ch], s->dither.ch[ch], 1, 1, out_count);
533− }
532+ if(s->dither_pos + out_count > s->dither.count)
533+ s->dither_pos = 0;
534+ for(ch=0; ch<preout->ch_count; ch++)
535+ swri_sum2(s->int_sample_fmt, preout->ch[ch], preout->ch[ch], s->dither.ch[ch] + s->dither.bps * s->dither_pos, 1, 1, out_count);
536+
537+ s->dither_pos += out_count;
534538 }
535539 //FIXME packed doesnt need more than 1 chan here!
536540 swri_audio_convert(s->out_convert, out, preout, out_count);
libswresample/swresample_internal.h+1−0
@@ -50,6 +50,7 @@ struct SwrContext { · 49 unmodified lines
5050 const int *channel_map; ///< channel index (or -1 if muted channel) map
5151 int used_ch_count; ///< number of used input channels (mapped channel count if channel_map, otherwise in.ch_count)
5252 enum SwrDitherType dither_method;
53+ int dither_pos;
5354
5455 int int_bps; ///< internal bytes per sample
5556 int resample_first; ///< 1 if resampling must come first, 0 if rematrixing

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t