FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
audio_data.c File Reference
#include <stdint.h>
#include <string.h>
#include "libavutil/mem.h"
#include "audio_data.h"

Go to the source code of this file.

Functions

static void calc_ptr_alignment (AudioData *a)
 
int ff_sample_fmt_is_planar (enum AVSampleFormat sample_fmt, int channels)
 
int ff_audio_data_set_channels (AudioData *a, int channels)
 
int ff_audio_data_init (AudioData *a, uint8_t *const *src, int plane_size, int channels, int nb_samples, enum AVSampleFormat sample_fmt, int read_only, const char *name)
 Initialize AudioData using a given source. More...
 
AudioDataff_audio_data_alloc (int channels, int nb_samples, enum AVSampleFormat sample_fmt, const char *name)
 Allocate AudioData. More...
 
int ff_audio_data_realloc (AudioData *a, int nb_samples)
 Reallocate AudioData. More...
 
void ff_audio_data_free (AudioData **a)
 Free AudioData. More...
 
int ff_audio_data_copy (AudioData *dst, AudioData *src, ChannelMapInfo *map)
 Copy data from one AudioData to another. More...
 
int ff_audio_data_combine (AudioData *dst, int dst_offset, AudioData *src, int src_offset, int nb_samples)
 Append data from one AudioData to the end of another. More...
 
void ff_audio_data_drain (AudioData *a, int nb_samples)
 Drain samples from the start of the AudioData. More...
 
int ff_audio_data_add_to_fifo (AVAudioFifo *af, AudioData *a, int offset, int nb_samples)
 Add samples in AudioData to an AVAudioFifo. More...
 
int ff_audio_data_read_from_fifo (AVAudioFifo *af, AudioData *a, int nb_samples)
 Read samples from an AVAudioFifo to AudioData. More...
 

Variables

static const AVClass audio_data_class
 

Function Documentation

static void calc_ptr_alignment ( AudioData a)
static
int ff_sample_fmt_is_planar ( enum AVSampleFormat  sample_fmt,
int  channels 
)

Definition at line 51 of file audio_data.c.

Referenced by avresample_open(), ff_audio_data_alloc(), and ff_audio_data_init().

int ff_audio_data_set_channels ( AudioData a,
int  channels 
)

Definition at line 59 of file audio_data.c.

Referenced by avresample_convert(), and ff_audio_mix().

int ff_audio_data_init ( AudioData a,
uint8_t *const *  src,
int  plane_size,
int  channels,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
int  read_only,
const char *  name 
)

Initialize AudioData using a given source.

This does not allocate an internal buffer. It only sets the data pointers and audio parameters.

Parameters
aAudioData struct
srcsource data pointers
plane_sizeplane size, in bytes. This can be 0 if unknown, but that will lead to optimized functions not being used in many cases, which could slow down some conversions.
channelschannel count
nb_samplesnumber of samples in the source data
sample_fmtsample format
read_onlyindicates if buffer is read only or read/write
namename for debug logging (can be NULL)
Returns
0 on success, negative AVERROR value on error

Definition at line 73 of file audio_data.c.

Referenced by avresample_convert().

AudioData* ff_audio_data_alloc ( int  channels,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
const char *  name 
)

Allocate AudioData.

This allocates an internal buffer and sets audio parameters.

Parameters
channelschannel count
nb_samplesnumber of samples to allocate space for
sample_fmtsample format
namename for debug logging (can be NULL)
Returns
newly allocated AudioData struct, or NULL on error

Definition at line 119 of file audio_data.c.

Referenced by avresample_open(), ff_audio_resample_init(), and ff_dither_alloc().

int ff_audio_data_realloc ( AudioData a,
int  nb_samples 
)

Reallocate AudioData.

The AudioData must have been previously allocated with ff_audio_data_alloc().

Parameters
aAudioData struct
nb_samplesnumber of samples to allocate space for
Returns
0 on success, negative AVERROR value on error

Definition at line 162 of file audio_data.c.

Referenced by avresample_convert(), ff_audio_data_alloc(), ff_audio_data_combine(), ff_audio_data_copy(), ff_audio_data_read_from_fifo(), ff_audio_resample(), and ff_convert_dither().

void ff_audio_data_free ( AudioData **  a)

Free AudioData.

The AudioData must have been previously allocated with ff_audio_data_alloc().

Parameters
aAudioData struct

Definition at line 217 of file audio_data.c.

Referenced by avresample_close(), ff_audio_resample_free(), ff_audio_resample_init(), and ff_dither_free().

int ff_audio_data_copy ( AudioData out,
AudioData in,
ChannelMapInfo map 
)

Copy data from one AudioData to another.

Parameters
outoutput AudioData
ininput AudioData
mapchannel map, NULL if not remapping
Returns
0 on success, negative AVERROR value on error

Definition at line 225 of file audio_data.c.

Referenced by avresample_convert(), ff_convert_dither(), and handle_buffered_output().

int ff_audio_data_combine ( AudioData dst,
int  dst_offset,
AudioData src,
int  src_offset,
int  nb_samples 
)

Append data from one AudioData to the end of another.

Parameters
dstdestination AudioData
dst_offsetoffset, in samples, to start writing, relative to the start of dst
srcsource AudioData
src_offsetoffset, in samples, to start copying, relative to the start of the src
nb_samplesnumber of samples to copy
Returns
0 on success, negative AVERROR value on error

Definition at line 278 of file audio_data.c.

Referenced by ff_audio_resample().

void ff_audio_data_drain ( AudioData a,
int  nb_samples 
)

Drain samples from the start of the AudioData.

Remaining samples are shifted to the start of the AudioData.

Parameters
aAudioData struct
nb_samplesnumber of samples to drain

Definition at line 334 of file audio_data.c.

Referenced by ff_audio_resample().

int ff_audio_data_add_to_fifo ( AVAudioFifo af,
AudioData a,
int  offset,
int  nb_samples 
)

Add samples in AudioData to an AVAudioFifo.

Parameters
afAudio FIFO Buffer
aAudioData struct
offsetnumber of samples to skip from the start of the data
nb_samplesnumber of samples to add to the FIFO
Returns
number of samples actually added to the FIFO, or negative AVERROR code on error

Definition at line 351 of file audio_data.c.

Referenced by handle_buffered_output().

int ff_audio_data_read_from_fifo ( AVAudioFifo af,
AudioData a,
int  nb_samples 
)

Read samples from an AVAudioFifo to AudioData.

Parameters
afAudio FIFO Buffer
aAudioData struct
nb_samplesnumber of samples to read from the FIFO
Returns
number of samples actually read from the FIFO, or negative AVERROR code on error

Definition at line 366 of file audio_data.c.

Referenced by handle_buffered_output().

Variable Documentation

const AVClass audio_data_class
static
Initial value:
= {
.class_name = "AudioData",
.item_name = av_default_item_name,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
av_default_item_name

Definition at line 27 of file audio_data.c.

Referenced by ff_audio_data_alloc(), and ff_audio_data_init().