diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2014-04-30 19:56:05 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2014-05-28 22:04:56 +0200 |
commit | b2d45654220503224aa94e78cdff19ec624e9342 (patch) | |
tree | 7aa8f0cd4eed0bef5865ea8b58c0267ac89032ec /libavresample/utils.c | |
parent | c94e2e85cb6af8a570d8542a830556243bd32873 (diff) | |
download | ffmpeg-b2d45654220503224aa94e78cdff19ec624e9342.tar.gz |
avresample: Add avresample_get_out_samples
Utility function to get the upper bound on the number of samples the
resampler would output.
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 35bee42b50..8c5a9e2ec2 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) |