diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-11 01:43:26 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-16 20:39:37 +0200 |
commit | b7d5e016a3f3b2c60f8dc6725ab9628ef58a7644 (patch) | |
tree | 38141862e08783af9834cbde6c110339a5b87ab5 /libswresample/swresample.h | |
parent | 3574d34aca9dfac28d61bd783a7aa9b4c2d736f0 (diff) | |
download | ffmpeg-b7d5e016a3f3b2c60f8dc6725ab9628ef58a7644.tar.gz |
swresample: Add AVFrame based API
Based on commit fb1ddcdc8f51b9d261ae8e9c26b91e81f7b6bf45 by Luca Barbato <lu_zero@gentoo.org>
Adapted for libswresample by Michael Niedermayer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/swresample.h')
-rw-r--r-- | libswresample/swresample.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libswresample/swresample.h b/libswresample/swresample.h index 4b8b0451ee..37656a667d 100644 --- a/libswresample/swresample.h +++ b/libswresample/swresample.h @@ -121,6 +121,7 @@ */ #include <stdint.h> +#include "libavutil/frame.h" #include "libavutil/samplefmt.h" #include "libswresample/version.h" @@ -467,6 +468,66 @@ const char *swresample_license(void); /** * @} + * + * @name AVFrame based API + * @{ + */ + +/** + * 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. + * + * If the output AVFrame does not have the data pointers allocated the nb_samples + * field will be set using 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 swr_convert(). + * + * If converting sample rate, there may be data remaining in the internal + * resampling delay buffer. swr_get_delay() tells the number of + * remaining samples. To get this data as output, call this function or + * swr_convert() with NULL input. + * + * If the SwrContext 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 the result of a bitwise-OR of them is returned. + * + * @see swr_delay() + * @see swr_convert() + * @see swr_get_delay() + * + * @param swr audio resample context + * @param output output AVFrame + * @param input input AVFrame + * @return 0 on success, AVERROR on failure or nonmatching + * configuration. + */ +int swr_convert_frame(SwrContext *swr, + AVFrame *output, const AVFrame *input); + +/** + * Configure or reconfigure the SwrContext using the information + * provided by the AVFrames. + * + * The original resampling context is reset even on failure. + * The function calls swr_close() internally if the context is open. + * + * @see swr_close(); + * + * @param swr audio resample context + * @param output output AVFrame + * @param input input AVFrame + * @return 0 on success, AVERROR on failure. + */ +int swr_config_frame(SwrContext *swr, const AVFrame *out, const AVFrame *in); + +/** + * @} * @} */ |