FFmpeg
Functions
Samples manipulation

Functions that manipulate audio samples. More...

Functions

int av_samples_fill_arrays (uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
 Fill plane data pointers and linesize for samples with sample format sample_fmt. More...
 
int av_samples_alloc (uint8_t **audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
 Allocate a samples buffer for nb_samples samples, and fill data pointers and linesize accordingly. More...
 
int av_samples_alloc_array_and_samples (uint8_t ***audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
 Allocate a data pointers array, samples buffer for nb_samples samples, and fill data pointers and linesize accordingly. More...
 
int av_samples_copy (uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
 Copy samples from src to dst. More...
 
int av_samples_set_silence (uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
 Fill an audio buffer with silence. More...
 

Detailed Description

Functions that manipulate audio samples.

Function Documentation

int av_samples_fill_arrays ( uint8_t **  audio_data,
int linesize,
const uint8_t buf,
int  nb_channels,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
int  align 
)

Fill plane data pointers and linesize for samples with sample format sample_fmt.

The audio_data array is filled with the pointers to the samples data planes: for planar, set the start point of each channel's data within the buffer, for packed, set the start point of the entire buffer only.

The value pointed to by linesize is set to the aligned size of each channel's data buffer for planar layout, or to the aligned size of the buffer for all channels for packed layout.

The buffer in buf must be big enough to contain all the samples (use av_samples_get_buffer_size() to compute its minimum size), otherwise the audio_data pointers will point to invalid data.

See also
enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.
Parameters
[out]audio_dataarray to be filled with the pointer for each channel
[out]linesizecalculated linesize, may be NULL
bufthe pointer to a buffer containing the samples
nb_channelsthe number of channels
nb_samplesthe number of samples in a single channel
sample_fmtthe sample format
alignbuffer size alignment (0 = default, 1 = no alignment)
Returns
>=0 on success or a negative error code on failure
Todo:
return minimum size in bytes required for the buffer in case of success at the next bump

Definition at line 151 of file samplefmt.c.

Referenced by allocate_buffers(), av_samples_alloc(), avcodec_fill_audio_frame(), ff_audio_data_realloc(), main(), and tak_decode_frame().

int av_samples_alloc ( uint8_t **  audio_data,
int linesize,
int  nb_channels,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
int  align 
)

Allocate a samples buffer for nb_samples samples, and fill data pointers and linesize accordingly.

The allocated samples buffer can be freed by using av_freep(&audio_data[0]) Allocated data will be initialized to silence.

See also
enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.
Parameters
[out]audio_dataarray to be filled with the pointer for each channel
[out]linesizealigned size for audio buffer(s), may be NULL
nb_channelsnumber of audio channels
nb_samplesnumber of samples per channel
alignbuffer size alignment (0 = default, 1 = no alignment)
Returns
>=0 on success or a negative error code on failure
Todo:
return the size of the allocated buffer in case of success at the next bump
See also
av_samples_fill_arrays()
av_samples_alloc_array_and_samples()

Definition at line 173 of file samplefmt.c.

Referenced by av_samples_alloc_array_and_samples(), ff_audio_data_realloc(), init_converted_samples(), and main().

int av_samples_alloc_array_and_samples ( uint8_t ***  audio_data,
int linesize,
int  nb_channels,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
int  align 
)

Allocate a data pointers array, samples buffer for nb_samples samples, and fill data pointers and linesize accordingly.

This is the same as av_samples_alloc(), but also allocates the data pointers array.

See also
av_samples_alloc()

Definition at line 198 of file samplefmt.c.

Referenced by config_input(), config_output(), and main().

int av_samples_copy ( uint8_t **  dst,
uint8_t *const *  src,
int  dst_offset,
int  src_offset,
int  nb_samples,
int  nb_channels,
enum AVSampleFormat  sample_fmt 
)

Copy samples from src to dst.

Parameters
dstdestination array of pointers to data planes
srcsource array of pointers to data planes
dst_offsetoffset in samples at which the data will be written to dst
src_offsetoffset in samples at which the data will be read from src
nb_samplesnumber of samples to be copied
nb_channelsnumber of audio channels
sample_fmtaudio sample format

Definition at line 213 of file samplefmt.c.

Referenced by activate(), decode_simple_internal(), ff_inlink_make_frame_writable(), frame_copy_audio(), pad_last_frame(), return_audio_frame(), and take_samples().

int av_samples_set_silence ( uint8_t **  audio_data,
int  offset,
int  nb_samples,
int  nb_channels,
enum AVSampleFormat  sample_fmt 
)

Fill an audio buffer with silence.

Parameters
audio_dataarray of pointers to data planes
offsetoffset in samples at which to start filling
nb_samplesnumber of samples to fill
nb_channelsnumber of audio channels
sample_fmtaudio sample format

Definition at line 237 of file samplefmt.c.

Referenced by activate(), av_samples_alloc(), config_output(), ff_audio_data_copy(), ff_audio_mix(), ff_default_get_audio_buffer(), if(), pad_last_frame(), request_frame(), return_audio_frame(), and send_silence().