diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-05-19 18:39:12 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-05-19 19:23:37 +0200 |
commit | 7a59964ba9c2e39ccf500ae3e57e77abc9afdfa2 (patch) | |
tree | 322225b056325c0bc885671cb9e82aa79c135572 /libswresample/swresample.c | |
parent | 72872d020144d9684312e4c3b212a4ff139599ca (diff) | |
download | ffmpeg-7a59964ba9c2e39ccf500ae3e57e77abc9afdfa2.tar.gz |
swr: add swr_inject_silence()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/swresample.c')
-rw-r--r-- | libswresample/swresample.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 4718ce8615..086c421bad 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -676,3 +676,27 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun } } +int swr_inject_silence(struct SwrContext *s, int count){ + int ret, i; + AudioData silence = s->out; + uint8_t *tmp_arg[SWR_CH_MAX]; + + if(count <= 0) + return 0; + + silence.count = 0; + silence.data = NULL; + if((ret=realloc_audio(&silence, count))<0) + return ret; + + if(silence.planar) for(i=0; i<silence.ch_count; i++) { + memset(silence.ch[i], silence.bps==1 ? 0x80 : 0, count*silence.bps); + } else + memset(silence.ch[0], silence.bps==1 ? 0x80 : 0, count*silence.bps*silence.ch_count); + + reversefill_audiodata(&silence, tmp_arg); + av_log(s, AV_LOG_VERBOSE, "adding %d audio samples of silence\n", count); + ret = swr_convert(s, NULL, 0, (const uint8_t**)tmp_arg, count); + av_freep(&silence.data); + return ret; +} |