| @@ -217,6 +217,7 @@ av_cold void swr_free(SwrContext **ss){ · 216 unmodified lines |
| 217 | 217 | free_temp(&s->midbuf); |
| 218 | 218 | free_temp(&s->preout); |
| 219 | 219 | free_temp(&s->in_buffer); |
| 220 | + free_temp(&s->silence); |
| 220 | 221 | free_temp(&s->drop_temp); |
| 221 | 222 | free_temp(&s->dither.noise); |
| 222 | 223 | free_temp(&s->dither.temp); |
| @@ -240,6 +241,7 @@ av_cold int swr_init(struct SwrContext *s){ · 17 unmodified lines |
| 240 | 241 | free_temp(&s->midbuf); |
| 241 | 242 | free_temp(&s->preout); |
| 242 | 243 | free_temp(&s->in_buffer); |
| 244 | + free_temp(&s->silence); |
| 243 | 245 | free_temp(&s->drop_temp); |
| 244 | 246 | free_temp(&s->dither.noise); |
| 245 | 247 | free_temp(&s->dither.temp); |
| @@ -359,6 +361,7 @@ av_assert0(s->out.ch_count); · 113 unmodified lines |
| 359 | 361 | s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0; |
| 360 | 362 | |
| 361 | 363 | s->in_buffer= s->in; |
| 364 | + s->silence = s->in; |
| 362 | 365 | s->drop_temp= s->out; |
| 363 | 366 | |
| 364 | 367 | if(!s->resample && !s->rematrix && !s->channel_map && !s->dither.method){ |
| @@ -807,26 +810,22 @@ int swr_drop_output(struct SwrContext *s, int count){ · 442 unmodified lines |
| 807 | 810 | |
| 808 | 811 | int swr_inject_silence(struct SwrContext *s, int count){ |
| 809 | 812 | int ret, i; |
| 810 | | − AudioData silence = s->in; |
| 811 | 813 | uint8_t *tmp_arg[SWR_CH_MAX]; |
| 812 | 814 | |
| 813 | 815 | if(count <= 0) |
| 814 | 816 | return 0; |
| 815 | 817 | |
| 816 | | − silence.count = 0; |
| 817 | | − silence.data = NULL; |
| 818 | | − if((ret=swri_realloc_audio(&silence, count))<0) |
| 818 | + if((ret=swri_realloc_audio(&s->silence, count))<0) |
| 819 | 819 | return ret; |
| 820 | 820 | |
| 821 | | − if(silence.planar) for(i=0; i<silence.ch_count; i++) { |
| 822 | | − memset(silence.ch[i], silence.bps==1 ? 0x80 : 0, count*silence.bps); |
| 821 | + if(s->silence.planar) for(i=0; i<s->silence.ch_count; i++) { |
| 822 | + memset(s->silence.ch[i], s->silence.bps==1 ? 0x80 : 0, count*s->silence.bps); |
| 823 | 823 | } else |
| 824 | | − memset(silence.ch[0], silence.bps==1 ? 0x80 : 0, count*silence.bps*silence.ch_count); |
| 824 | + memset(s->silence.ch[0], s->silence.bps==1 ? 0x80 : 0, count*s->silence.bps*s->silence.ch_count); |
| 825 | 825 | |
| 826 | | − reversefill_audiodata(&silence, tmp_arg); |
| 826 | + reversefill_audiodata(&s->silence, tmp_arg); |
| 827 | 827 | av_log(s, AV_LOG_VERBOSE, "adding %d audio samples of silence\n", count); |
| 828 | 828 | ret = swr_convert(s, NULL, 0, (const uint8_t**)tmp_arg, count); |
| 829 | | − av_freep(&silence.data); |
| 830 | 829 | return ret; |
| 831 | 830 | } |
| 832 | 831 | |