---
doc/APIchanges | 3 +++
libavresample/avresample.h | 22 ++++++++++++++++++++++
libavresample/utils.c | 9 +++++++++
libavresample/version.h | 2 +-
4 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 89ad2ae..dd22711 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2013-04-xx - xxxxxxx - lavr 1.2.0 - avresample.h
+ Add avresample_get_out_size(), useful for calculating output buffer size.
+
2013-03-xx - xxxxxxx - lavc 55.2.0 - avcodec.h
Add CODEC_FLAG_UNALIGNED to allow decoders to produce unaligned output.
diff --git a/libavresample/avresample.h b/libavresample/avresample.h
index d26f2ca..de8d9bd 100644
--- a/libavresample/avresample.h
+++ b/libavresample/avresample.h
@@ -403,6 +403,28 @@ int avresample_available(AVAudioResampleContext *avr);
int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int
nb_samples);
/**
+ * Get the maximum number of output samples that will be available for reading
+ * if a given number of samples is passed in. This includes the internal FIFO
+ * and takes into account resampling.
+ *
+ * I.e if in_samples audio samples are passed in with NULL output, then
+ * avresample_available() will report less or equal than the return value of
+ * this function.
+ *
+ * Note that this function gives only the upper bound, the actual number of
+ * output samples may be less.
+ *
+ * @param avr audio resample context
+ * @param in_samples number of input samples to calculate output for. May be
+ * zero, then this function is equivalent to
+ * avresample_available().
+ *
+ * @return a non-negative upper bound on the number output samples on success,
a
+ * negative AVERROR on failure.
+ */
+int avresample_get_out_size(AVAudioResampleContext *avr, int in_samples);
+
+/**
* @}
*/
diff --git a/libavresample/utils.c b/libavresample/utils.c
index b79def9..e92f8ab 100644
--- a/libavresample/utils.c
+++ b/libavresample/utils.c
@@ -22,6 +22,7 @@
#include "libavutil/dict.h"
#include "libavutil/error.h"
#include "libavutil/log.h"
+#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
@@ -618,6 +619,14 @@ int avresample_read(AVAudioResampleContext *avr, uint8_t
**output, int nb_sample
return av_audio_fifo_read(avr->out_fifo, (void**)output, nb_samples);
}
+int avresample_get_out_size(AVAudioResampleContext *avr, int in_samples)
+{
+ int available = avresample_available(avr);
+ int delay = avresample_get_delay(avr);
+ return av_rescale_rnd(in_samples + delay, avr->out_sample_rate,
+ avr->in_sample_rate, AV_ROUND_UP) + available;
+}
+
unsigned avresample_version(void)
{
return LIBAVRESAMPLE_VERSION_INT;
diff --git a/libavresample/version.h b/libavresample/version.h
index 387d097..169a3d0 100644
--- a/libavresample/version.h
+++ b/libavresample/version.h
@@ -20,7 +20,7 @@
#define AVRESAMPLE_VERSION_H
#define LIBAVRESAMPLE_VERSION_MAJOR 1
-#define LIBAVRESAMPLE_VERSION_MINOR 1
+#define LIBAVRESAMPLE_VERSION_MINOR 2
#define LIBAVRESAMPLE_VERSION_MICRO 0
#define LIBAVRESAMPLE_VERSION_INT AV_VERSION_INT(LIBAVRESAMPLE_VERSION_MAJOR,
\
--
1.7.10.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel