| @@ -519,18 +519,22 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co · 518 unmodified lines |
| 519 | if(preout != out && out_count){ | 519 | if(preout != out && out_count){ |
| 520 | if(s->dither_method){ | 520 | if(s->dither_method){ |
| 521 | int ch; | 521 | int ch; |
| | 522 | int dither_count= FFMAX(out_count, 1<<16); |
| 522 | av_assert0(preout != in); | 523 | av_assert0(preout != in); |
| 523 | | 524 | |
| 524 | if((ret=realloc_audio(&s->dither, out_count))<0) | 525 | if((ret=realloc_audio(&s->dither, dither_count))<0) |
| 525 | return ret; | 526 | return ret; |
| 526 | if(ret) | 527 | if(ret) |
| 527 | for(ch=0; ch<s->dither.ch_count; ch++) | 528 | for(ch=0; ch<s->dither.ch_count; ch++) |
| 528 | swri_get_dither(s->dither.ch[ch], s->dither.count, 12345678913579<<ch, s->out_sample_fmt, s->int_sample_fmt, s->dither_method); | 529 | swri_get_dither(s->dither.ch[ch], s->dither.count, 12345678913579<<ch, s->out_sample_fmt, s->int_sample_fmt, s->dither_method); |
| 529 | av_assert0(s->dither.ch_count == preout->ch_count); | 530 | av_assert0(s->dither.ch_count == preout->ch_count); |
| 530 | | 531 | |
| 531 | for(ch=0; ch<preout->ch_count; ch++){ | 532 | if(s->dither_pos + out_count > s->dither.count) |
| 532 | swri_sum2(s->int_sample_fmt, preout->ch[ch], preout->ch[ch], s->dither.ch[ch], 1, 1, out_count); | 533 | s->dither_pos = 0; |
| 533 | } | 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; |
| 534 | } | 538 | } |
| 535 | //FIXME packed doesnt need more than 1 chan here! | 539 | //FIXME packed doesnt need more than 1 chan here! |
| 536 | swri_audio_convert(s->out_convert, out, preout, out_count); | 540 | swri_audio_convert(s->out_convert, out, preout, out_count); |