samplefmt.h File Reference
#include "avutil.h"

Go to the source code of this file.

Enumerations

enum  AVSampleFormat {
  AV_SAMPLE_FMT_NONE = -1, AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
  AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P,
  AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NB
}
 all in native-endian format More...

Functions

const char * av_get_sample_fmt_name (enum AVSampleFormat sample_fmt)
 Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
enum AVSampleFormat av_get_sample_fmt (const char *name)
 Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
char * av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt)
 Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is negative.
attribute_deprecated int av_get_bits_per_sample_fmt (enum AVSampleFormat sample_fmt)
int av_get_bytes_per_sample (enum AVSampleFormat sample_fmt)
 Return number of bytes per sample.
int av_sample_fmt_is_planar (enum AVSampleFormat sample_fmt)
 Check if the sample format is planar.
int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
 Get the required buffer size for the given audio parameters.
int av_samples_fill_arrays (uint8_t **audio_data, int *linesize, uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
 Fill channel data pointers and linesize for samples with sample format sample_fmt.
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.

Enumeration Type Documentation

all in native-endian format

Enumerator:
AV_SAMPLE_FMT_NONE 
AV_SAMPLE_FMT_U8 

unsigned 8 bits

AV_SAMPLE_FMT_S16 

signed 16 bits

AV_SAMPLE_FMT_S32 

signed 32 bits

AV_SAMPLE_FMT_FLT 

float

AV_SAMPLE_FMT_DBL 

double

AV_SAMPLE_FMT_U8P 

unsigned 8 bits, planar

AV_SAMPLE_FMT_S16P 

signed 16 bits, planar

AV_SAMPLE_FMT_S32P 

signed 32 bits, planar

AV_SAMPLE_FMT_FLTP 

float, planar

AV_SAMPLE_FMT_DBLP 

double, planar

AV_SAMPLE_FMT_NB 

Number of sample formats. DO NOT USE if linking dynamically.

Definition at line 27 of file samplefmt.h.

Function Documentation

attribute_deprecated int av_get_bits_per_sample_fmt ( enum AVSampleFormat  sample_fmt)
int av_get_bytes_per_sample ( enum AVSampleFormat  sample_fmt)

Return number of bytes per sample.

Parameters
sample_fmtthe sample format
Returns
number of bytes per sample or zero if unknown for the given sample format

Definition at line 75 of file samplefmt.c.

Referenced by audio_decode_frame(), av_audio_resample_init(), av_samples_get_buffer_size(), avfilter_default_get_audio_buffer(), decode_frame(), decode_init(), do_audio_out(), encode_audio_frame(), flush_encoders(), mkv_write_tracks(), output_packet(), transcode_audio(), vmdaudio_decode_init(), and wavpack_decode_block().

enum AVSampleFormat av_get_sample_fmt ( const char *  name)

Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.

Definition at line 52 of file samplefmt.c.

Referenced by new_audio_stream(), and opt_audio_sample_fmt().

const char* av_get_sample_fmt_name ( enum AVSampleFormat  sample_fmt)

Return the name of sample_fmt, or NULL if sample_fmt is not recognized.

Definition at line 45 of file samplefmt.c.

Referenced by audio_decode_frame(), av_audio_resample_init(), avcodec_string(), choose_sample_fmt(), do_audio_out(), dprint_options(), ff_dlog_link(), print_digraph(), and transcode_audio().

char* av_get_sample_fmt_string ( char *  buf,
int  buf_size,
enum AVSampleFormat  sample_fmt 
)

Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is negative.

Parameters
bufthe buffer where to write the string
buf_sizethe size of buf
sample_fmtthe number of the sample format to print the corresponding info string, or a negative value to print the corresponding header.
Returns
the pointer to the filled buffer or NULL if sample_fmt is unknown or in case of other errors

Definition at line 62 of file samplefmt.c.

Referenced by opt_audio_sample_fmt(), and show_sample_fmts().

int av_sample_fmt_is_planar ( enum AVSampleFormat  sample_fmt)

Check if the sample format is planar.

Parameters
sample_fmtthe sample format to inspect
Returns
1 if the sample format is planar, 0 if it is interleaved

Definition at line 89 of file samplefmt.c.

Referenced by av_samples_fill_arrays(), av_samples_get_buffer_size(), and avcodec_fill_audio_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])

Parameters
[out]audio_dataarray to be filled with the pointer for each channel
[out]linesizealigned size for audio buffer(s)
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
See Also
av_samples_fill_arrays()

Definition at line 146 of file samplefmt.c.

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

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

The pointers array is filled with the pointers to the samples data: 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 linesize array is filled with the aligned size of each channel's data buffer for planar layout, or the aligned size of the buffer for all channels for packed layout.

Parameters
[out]audio_dataarray to be filled with the pointer for each channel
[out]linesizecalculated linesize
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

Definition at line 127 of file samplefmt.c.

Referenced by av_samples_alloc(), and avcodec_fill_audio_frame().

int av_samples_get_buffer_size ( int *  linesize,
int  nb_channels,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
int  align 
)

Get the required buffer size for the given audio parameters.

Parameters
[out]linesizecalculated linesize, may be NULL
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
required buffer size, or negative error code on failure

Definition at line 96 of file samplefmt.c.

Referenced by audio_decode_example(), audio_decode_frame(), audio_get_buffer(), av_samples_alloc(), av_samples_fill_arrays(), and avcodec_fill_audio_frame().