diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-03 01:22:25 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-04 05:37:32 +0200 |
commit | cc17b43d8dd324fbae98407124618e746a390a76 (patch) | |
tree | d13f812cc871e1a338819af23ac4dc20e33ea7ea /libswresample/swresample.h | |
parent | da7c8fd91761dff3f9202e813bb5a5963a2d657c (diff) | |
download | ffmpeg-cc17b43d8dd324fbae98407124618e746a390a76.tar.gz |
swresample: Add swr_get_out_samples()
Previous version reviewed-by: Pavel Koshevoy <pkoshevoy@gmail.com>
Previous version reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/swresample.h')
-rw-r--r-- | libswresample/swresample.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libswresample/swresample.h b/libswresample/swresample.h index 37656a667d..e1617f472f 100644 --- a/libswresample/swresample.h +++ b/libswresample/swresample.h @@ -294,9 +294,10 @@ void swr_close(struct SwrContext *s); * in and in_count can be set to 0 to flush the last few samples out at the * end. * - * If more input is provided than output space then the input will be buffered. - * You can avoid this buffering by providing more output space than input. - * Conversion will run directly without copying whenever possible. + * If more input is provided than output space, then the input will be buffered. + * You can avoid this buffering by using swr_get_out_samples() to retrieve an + * upper bound on the required number of output samples for the given number of + * input samples. Conversion will run directly without copying whenever possible. * * @param s allocated Swr context, with parameters set * @param out output buffers, only the first one need be set in case of packed audio @@ -436,6 +437,24 @@ int swr_inject_silence(struct SwrContext *s, int count); int64_t swr_get_delay(struct SwrContext *s, int64_t base); /** + * Find an upper bound on the number of samples that the next swr_convert + * call will output, if called with in_samples of input samples. This + * depends on the internal state, and anything changing the internal state + * (like further swr_convert() calls) will may change the number of samples + * swr_get_out_samples() returns for the same number of input samples. + * + * @param in_samples number of input samples. + * @note any call to swr_inject_silence(), swr_convert(), swr_next_pts() + * or swr_set_compensation() invalidates this limit + * @note it is recommended to pass the correct available buffer size + * to all functions like swr_convert() even if swr_get_out_samples() + * indicates that less would be used. + * @returns an upper bound on the number of samples that the next swr_convert + * will output or a negative value to indicate an error + */ +int swr_get_out_samples(struct SwrContext *s, int in_samples); + +/** * @} * * @name Configuration accessors |