libavutil/samplefmt.c File Reference

#include "samplefmt.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  SampleFmtInfo

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.
enum AVSampleFormat av_get_alt_sample_fmt (enum AVSampleFormat sample_fmt, int planar)
 Return the planar<->packed alternative form of the given sample format, 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.
int av_get_bytes_per_sample (enum AVSampleFormat sample_fmt)
 Return number of bytes per sample.
int av_get_bits_per_sample_fmt (enum AVSampleFormat sample_fmt)
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.

Variables

static const SampleFmtInfo sample_fmt_info [AV_SAMPLE_FMT_NB]
 this table gives more information about formats


Function Documentation

enum AVSampleFormat av_get_alt_sample_fmt ( enum AVSampleFormat  sample_fmt,
int  planar 
)

Return the planar<->packed alternative form of the given sample format, or AV_SAMPLE_FMT_NONE on error.

If the passed sample_fmt is already in the requested planar/packed format, the format returned is the same as the input.

Definition at line 63 of file samplefmt.c.

Referenced by avfilter_default_get_audio_buffer(), get(), main(), set(), and swr_init().

int av_get_bits_per_sample_fmt ( enum AVSampleFormat  sample_fmt  ) 

Deprecated:
Use av_get_bytes_per_sample() instead.

Definition at line 92 of file samplefmt.c.

int av_get_bytes_per_sample ( enum AVSampleFormat  sample_fmt  ) 

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 53 of file samplefmt.c.

Referenced by avcodec_get_sample_fmt(), ff_parse_sample_format(), and new_audio_stream().

const char* av_get_sample_fmt_name ( enum AVSampleFormat  sample_fmt  ) 

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:
buf the buffer where to write the string
buf_size the size of buf
sample_fmt the 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 72 of file samplefmt.c.

Referenced by avcodec_sample_fmt_string(), and show_sample_fmts().

int av_sample_fmt_is_planar ( enum AVSampleFormat  sample_fmt  ) 

Check if the sample format is planar.

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

Definition at line 99 of file samplefmt.c.

Referenced by av_samples_fill_arrays(), av_samples_get_buffer_size(), avcodec_decode_audio3(), avcodec_fill_audio_frame(), get(), set(), setup_array(), and swr_init().

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_data array to be filled with the pointer for each channel
[out] linesize aligned size for audio buffer(s)
nb_channels number of audio channels
nb_samples number of samples per channel
align buffer size alignment (1 = no alignment required)
Returns:
0 on success or a negative error code on failure
See also:
av_samples_fill_arrays()

Definition at line 149 of file samplefmt.c.

Referenced by avfilter_default_get_audio_buffer(), and init_buffers().

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_data array to be filled with the pointer for each channel
[out] linesize calculated linesize
buf the pointer to a buffer containing the samples
nb_channels the number of channels
nb_samples the number of samples in a single channel
sample_fmt the sample format
align buffer size alignment (1 = no alignment required)
Returns:
0 on success or a negative error code on failure

Definition at line 130 of file samplefmt.c.

Referenced by av_asrc_buffer_add_buffer(), 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] linesize calculated linesize, may be NULL
nb_channels the number of channels
nb_samples the number of samples in a single channel
sample_fmt the sample format
Returns:
required buffer size, or negative error code on failure

Definition at line 106 of file samplefmt.c.

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


Variable Documentation

const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] [static]

Initial value:

 {
    [AV_SAMPLE_FMT_U8]   = { .name =   "u8", .bits =  8, .planar = 0, .altform = AV_SAMPLE_FMT_U8P  },
    [AV_SAMPLE_FMT_S16]  = { .name =  "s16", .bits = 16, .planar = 0, .altform = AV_SAMPLE_FMT_S16P },
    [AV_SAMPLE_FMT_S32]  = { .name =  "s32", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_S32P },
    [AV_SAMPLE_FMT_FLT]  = { .name =  "flt", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_FLTP },
    [AV_SAMPLE_FMT_DBL]  = { .name =  "dbl", .bits = 64, .planar = 0, .altform = AV_SAMPLE_FMT_DBLP },
    [AV_SAMPLE_FMT_U8P]  = { .name =  "u8p", .bits =  8, .planar = 1, .altform = AV_SAMPLE_FMT_U8   },
    [AV_SAMPLE_FMT_S16P] = { .name = "s16p", .bits = 16, .planar = 1, .altform = AV_SAMPLE_FMT_S16  },
    [AV_SAMPLE_FMT_S32P] = { .name = "s32p", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_S32  },
    [AV_SAMPLE_FMT_FLTP] = { .name = "fltp", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_FLT  },
    [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1, .altform = AV_SAMPLE_FMT_DBL  },
}
this table gives more information about formats

Definition at line 33 of file samplefmt.c.


Generated on Fri Oct 26 02:46:14 2012 for FFmpeg by  doxygen 1.5.8