diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-29 01:18:17 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-29 01:23:22 +0200 |
commit | bdb2e80e88e76cc39c6d85a8f1c1712d36e18966 (patch) | |
tree | 230646af1610b055a198af67574b1d823fc50d76 /libavresample/utils.c | |
parent | a8499cbbe87d00456c391f41207e1981bd7f746a (diff) | |
parent | b2d45654220503224aa94e78cdff19ec624e9342 (diff) | |
download | ffmpeg-bdb2e80e88e76cc39c6d85a8f1c1712d36e18966.tar.gz |
Merge commit 'b2d45654220503224aa94e78cdff19ec624e9342'
* commit 'b2d45654220503224aa94e78cdff19ec624e9342':
avresample: Add avresample_get_out_samples
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavresample/utils.c')
-rw-r--r-- | libavresample/utils.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavresample/utils.c b/libavresample/utils.c index 3a335c0587..48874d6103 100644 --- a/libavresample/utils.c +++ b/libavresample/utils.c @@ -622,6 +622,25 @@ int avresample_available(AVAudioResampleContext *avr) return av_audio_fifo_size(avr->out_fifo); } +int avresample_get_out_samples(AVAudioResampleContext *avr, int in_nb_samples) +{ + int64_t samples = avresample_get_delay(avr) + (int64_t)in_nb_samples; + + if (avr->resample_needed) { + samples = av_rescale_rnd(samples, + avr->out_sample_rate, + avr->in_sample_rate, + AV_ROUND_UP); + } + + samples += avresample_available(avr); + + if (samples > INT_MAX) + return AVERROR(EINVAL); + + return samples; +} + int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples) { if (!output) |