#include <icy/av/audioresampler.h>Converts audio samples between different formats, sample rates, and channel layouts.
| Return | Name | Description |
|---|---|---|
SwrContext * | ctx | the conversion context |
AudioCodec | iparams | input audio parameters |
AudioCodec | oparams | output audio parameters |
uint8_t ** | outSamples | the output samples buffer |
int | outNumSamples | the number of samples currently in the output buffer |
int | outBufferSize | the number of bytes currently in the buffer |
int | maxNumSamples | the maximum number of samples that can be stored in |
enum AVSampleFormat | inSampleFmt | input sample format |
enum AVSampleFormat | outSampleFmt | output sample format |
SwrContext * ctxthe conversion context
AudioCodec iparamsinput audio parameters
AudioCodec oparamsoutput audio parameters
uint8_t ** outSamplesthe output samples buffer
int outNumSamplesthe number of samples currently in the output buffer
int outBufferSizethe number of bytes currently in the buffer
int maxNumSamplesthe maximum number of samples that can be stored in
enum AVSampleFormat inSampleFmtinput sample format
enum AVSampleFormat outSampleFmtoutput sample format
| Return | Name | Description |
|---|---|---|
AudioResampler | ||
AudioResampler | Deleted constructor. | |
AudioResampler | Deleted constructor. | |
void | open | Initialise the libswresample context using iparams and oparams. Throws std::runtime_error if the context is already open or if required parameters (channels, sample rate, format) are missing. |
void | close | Free the libswresample context and release the output sample buffer. |
int | resample | Convert the input samples to the output format. NOTE: Input buffers must be contiguous, therefore only interleaved input formats are accepted at this point. |
AudioResampler(const AudioCodec & iparams, const AudioCodec & oparams)AudioResampler(const AudioResampler &) = deleteDeleted constructor.
AudioResampler(AudioResampler &&) = deleteDeleted constructor.
void open()Initialise the libswresample context using iparams and oparams. Throws std::runtime_error if the context is already open or if required parameters (channels, sample rate, format) are missing.
void close()Free the libswresample context and release the output sample buffer.
int resample(uint8_t ** inSamples, int inNumSamples)Convert the input samples to the output format. NOTE: Input buffers must be contiguous, therefore only interleaved input formats are accepted at this point.
Converted samples are accessible via the outSamples class member.
inSamples Pointer to the input sample buffer array.
inNumSamples The number of input samples per channel.
The number of converted samples, or zero if samples were internally buffered.