summaryrefslogtreecommitdiff
path: root/libavresample/avresample.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-10 18:20:37 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-10 18:20:37 +0200
commit78eaaa857e95fa5542dc008c8ad3664e6ab6801a (patch)
tree41bed9cbaefc6147bd6acbb8018e9e1dd33544ca /libavresample/avresample.h
parent0d0d24af0159ff08f396ad04cd63ce5655b1fc60 (diff)
parentfb1ddcdc8f51b9d261ae8e9c26b91e81f7b6bf45 (diff)
downloadffmpeg-78eaaa857e95fa5542dc008c8ad3664e6ab6801a.tar.gz
Merge commit 'fb1ddcdc8f51b9d261ae8e9c26b91e81f7b6bf45'
* commit 'fb1ddcdc8f51b9d261ae8e9c26b91e81f7b6bf45': avresample: Introduce AVFrame-based API Conflicts: libavresample/utils.c libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavresample/avresample.h')
-rw-r--r--libavresample/avresample.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/libavresample/avresample.h b/libavresample/avresample.h
index 6e3cf35fd4..5eb55cb6db 100644
--- a/libavresample/avresample.h
+++ b/libavresample/avresample.h
@@ -95,6 +95,7 @@
#include "libavutil/avutil.h"
#include "libavutil/channel_layout.h"
#include "libavutil/dict.h"
+#include "libavutil/frame.h"
#include "libavutil/log.h"
#include "libavutil/mathematics.h"
@@ -165,6 +166,10 @@ AVAudioResampleContext *avresample_alloc_context(void);
/**
* Initialize AVAudioResampleContext.
+ * @note The context must be configured using the AVOption API.
+ *
+ * @see av_opt_set_int()
+ * @see av_opt_set_dict()
*
* @param avr audio resample context
* @return 0 on success, negative AVERROR code on failure
@@ -423,6 +428,70 @@ int avresample_available(AVAudioResampleContext *avr);
int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples);
/**
+ * Convert the samples in the input AVFrame and write them to the output AVFrame.
+ *
+ * Input and output AVFrames must have channel_layout, sample_rate and format set.
+ *
+ * The upper bound on the number of output samples is obtained through
+ * avresample_get_out_samples().
+ *
+ * If the output AVFrame does not have the data pointers allocated the nb_samples
+ * field will be set using avresample_get_out_samples() and av_frame_get_buffer()
+ * is called to allocate the frame.
+ *
+ * The output AVFrame can be NULL or have fewer allocated samples than required.
+ * In this case, any remaining samples not written to the output will be added
+ * to an internal FIFO buffer, to be returned at the next call to this function
+ * or to avresample_convert() or to avresample_read().
+ *
+ * If converting sample rate, there may be data remaining in the internal
+ * resampling delay buffer. avresample_get_delay() tells the number of
+ * remaining samples. To get this data as output, call this function or
+ * avresample_convert() with NULL input.
+ *
+ * At the end of the conversion process, there may be data remaining in the
+ * internal FIFO buffer. avresample_available() tells the number of remaining
+ * samples. To get this data as output, either call this function or
+ * avresample_convert() with NULL input or call avresample_read().
+ *
+ * If the AVAudioResampleContext configuration does not match the output and
+ * input AVFrame settings the conversion does not take place and depending on
+ * which AVFrame is not matching AVERROR_OUTPUT_CHANGED, AVERROR_INPUT_CHANGED
+ * or AVERROR_OUTPUT_CHANGED|AVERROR_INPUT_CHANGED is returned.
+ *
+ * @see avresample_get_out_samples()
+ * @see avresample_available()
+ * @see avresample_convert()
+ * @see avresample_read()
+ * @see avresample_get_delay()
+ *
+ * @param avr audio resample context
+ * @param output output AVFrame
+ * @param input input AVFrame
+ * @return 0 on success, AVERROR on failure or nonmatching
+ * configuration.
+ */
+int avresample_convert_frame(AVAudioResampleContext *avr,
+ AVFrame *output, AVFrame *input);
+
+/**
+ * Configure or reconfigure the AVAudioResampleContext using the information
+ * provided by the AVFrames.
+ *
+ * The original resampling context is reset even on failure.
+ * The function calls avresample_close() internally if the context is open.
+ *
+ * @see avresample_open();
+ * @see avresample_close();
+ *
+ * @param avr audio resample context
+ * @param output output AVFrame
+ * @param input input AVFrame
+ * @return 0 on success, AVERROR on failure.
+ */
+int avresample_config(AVAudioResampleContext *avr, AVFrame *out, AVFrame *in);
+
+/**
* @}
*/