AudioResampler
AudioResampler
#include <icy/av/audioresampler.h>Converts audio samples between different formats, sample rates, and channel layouts.
Public Attributes
| 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 |
ctx
SwrContext * ctxthe conversion context
iparams
AudioCodec iparamsinput audio parameters
oparams
AudioCodec oparamsoutput audio parameters
outSamples
uint8_t ** outSamplesthe output samples buffer
outNumSamples
int outNumSamplesthe number of samples currently in the output buffer
outBufferSize
int outBufferSizethe number of bytes currently in the buffer
maxNumSamples
int maxNumSamplesthe maximum number of samples that can be stored in
inSampleFmt
enum AVSampleFormat inSampleFmtinput sample format
outSampleFmt
enum AVSampleFormat outSampleFmtoutput sample format
Public Methods
| 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
AudioResampler(const AudioCodec & iparams, const AudioCodec & oparams)AudioResampler
AudioResampler(const AudioResampler &) = deleteDeleted constructor.
AudioResampler
AudioResampler(AudioResampler &&) = deleteDeleted constructor.
open
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.
close
void close()Free the libswresample context and release the output sample buffer.
resample
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.
Parameters
inSamplesPointer to the input sample buffer array.inNumSamplesThe number of input samples per channel.
Returns
The number of converted samples, or zero if samples were internally buffered.
