libswresample/swresample.c File Reference

#include "libavutil/opt.h"
#include "swresample_internal.h"
#include "audioconvert.h"
#include "libavutil/avassert.h"
#include "libavutil/audioconvert.h"

Go to the source code of this file.

Defines

#define C30DB   M_SQRT2
#define C15DB   1.189207115
#define C__0DB   1.0
#define C_15DB   0.840896415
#define C_30DB   M_SQRT1_2
#define C_45DB   0.594603558
#define C_60DB   0.5
#define OFFSET(x)   offsetof(SwrContext,x)
#define LICENSE_PREFIX   "libswresample license: "
#define RSC   1

Functions

static const char * context_to_name (void *ptr)
unsigned swresample_version (void)
 Return the LIBSWRESAMPLE_VERSION_INT constant.
const char * swresample_configuration (void)
 Return the swr build-time configuration.
const char * swresample_license (void)
 Return the swr license.
int swr_set_channel_mapping (struct SwrContext *s, const int *channel_map)
 Set a customized input channel mapping.
struct SwrContextswr_alloc (void)
 Allocate SwrContext.
struct SwrContextswr_alloc_set_opts (struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
 Allocate SwrContext if needed and set/reset common parameters.
static void free_temp (AudioData *a)
void swr_free (SwrContext **ss)
 Free the given SwrContext and set the pointer to NULL.
int swr_init (struct SwrContext *s)
 Initialize context after user parameters have been set.
static int realloc_audio (AudioData *a, int count)
static void copy (AudioData *out, AudioData *in, int count)
static void fill_audiodata (AudioData *out, uint8_t *in_arg[SWR_CH_MAX])
static void buf_set (AudioData *out, AudioData *in, int count)
 out may be equal in.
static int resample (SwrContext *s, AudioData *out_param, int out_count, const AudioData *in_param, int in_count)
int swr_convert (struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg[SWR_CH_MAX], int in_count)
 Convert audio.

Variables

static const AVOption options []
static const AVClass av_class


Define Documentation

#define C15DB   1.189207115

Definition at line 28 of file swresample.c.

#define C30DB   M_SQRT2

Definition at line 27 of file swresample.c.

#define C_15DB   0.840896415

Definition at line 30 of file swresample.c.

#define C_30DB   M_SQRT1_2

Definition at line 31 of file swresample.c.

#define C_45DB   0.594603558

Definition at line 32 of file swresample.c.

#define C_60DB   0.5

Definition at line 33 of file swresample.c.

#define C__0DB   1.0

Definition at line 29 of file swresample.c.

#define LICENSE_PREFIX   "libswresample license: "

#define OFFSET (  )     offsetof(SwrContext,x)

Definition at line 37 of file swresample.c.

#define RSC   1

Referenced by swr_init().


Function Documentation

static void buf_set ( AudioData out,
AudioData in,
int  count 
) [static]

out may be equal in.

Definition at line 329 of file swresample.c.

Referenced by resample().

static const char* context_to_name ( void *  ptr  )  [static]

Definition at line 60 of file swresample.c.

static void copy ( AudioData out,
AudioData in,
int  count 
) [static]

Definition at line 301 of file swresample.c.

static void fill_audiodata ( AudioData out,
uint8_t *  in_arg[SWR_CH_MAX] 
) [static]

Definition at line 314 of file swresample.c.

Referenced by swr_convert().

static void free_temp ( AudioData a  )  [static]

Definition at line 130 of file swresample.c.

Referenced by swr_free(), and swr_init().

static int realloc_audio ( AudioData a,
int  count 
) [static]

Definition at line 272 of file swresample.c.

Referenced by resample(), and swr_convert().

static int resample ( SwrContext s,
AudioData out_param,
int  out_count,
const AudioData in_param,
int  in_count 
) [static]

Returns:
number of samples output per channel

Definition at line 342 of file swresample.c.

Referenced by swr_convert().

struct SwrContext* swr_alloc ( void   )  [read]

Allocate SwrContext.

If you use this function you will need to set the parameters (manually or with swr_alloc_set_opts()) before calling swr_init().

See also:
swr_alloc_set_opts(), swr_init(), swr_free()
Returns:
NULL on error, allocated context otherwise

Definition at line 97 of file swresample.c.

Referenced by swr_alloc_set_opts().

struct SwrContext* swr_alloc_set_opts ( struct SwrContext s,
int64_t  out_ch_layout,
enum AVSampleFormat  out_sample_fmt,
int  out_sample_rate,
int64_t  in_ch_layout,
enum AVSampleFormat  in_sample_fmt,
int  in_sample_rate,
int  log_offset,
void *  log_ctx 
) [read]

Allocate SwrContext if needed and set/reset common parameters.

This function does not require s to be allocated with swr_alloc(). On the other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters on the allocated context.

Parameters:
s Swr context, can be NULL
out_ch_layout output channel layout (AV_CH_LAYOUT_*)
out_sample_fmt output sample format (AV_SAMPLE_FMT_*).
out_sample_rate output sample rate (frequency in Hz)
in_ch_layout input channel layout (AV_CH_LAYOUT_*)
in_sample_fmt input sample format (AV_SAMPLE_FMT_*).
in_sample_rate input sample rate (frequency in Hz)
log_offset logging level offset
log_ctx parent logging context, can be NULL
See also:
swr_init(), swr_free()
Returns:
NULL on error, allocated context otherwise

Definition at line 106 of file swresample.c.

Referenced by audio_decode_frame(), config_props(), do_audio_out(), and main().

int swr_convert ( struct SwrContext s,
uint8_t *  out[SWR_CH_MAX],
int  out_count,
const uint8_t *  in[SWR_CH_MAX],
int  in_count 
)

Convert audio.

in and in_count can be set to 0 to flush the last few samples out at the end.

Parameters:
s allocated Swr context, with parameters set
out output buffers, only the first one need be set in case of packed audio
out_count amount of space available for output in samples per channel
in input buffers, only the first one need to be set in case of packed audio
in_count number of input samples available in one channel
Returns:
number of samples output per channel

Definition at line 416 of file swresample.c.

Referenced by audio_decode_frame(), do_audio_out(), filter_samples_channel_mapping(), and main().

void swr_free ( SwrContext **  ss  ) 

Free the given SwrContext and set the pointer to NULL.

Definition at line 135 of file swresample.c.

Referenced by audio_decode_frame(), do_audio_out(), stream_component_close(), transcode(), and uninit().

int swr_init ( struct SwrContext s  ) 

Initialize context after user parameters have been set.

Returns:
AVERROR error code in case of failure.

Definition at line 151 of file swresample.c.

Referenced by audio_decode_frame(), config_props(), do_audio_out(), main(), and swr_set_compensation().

int swr_set_channel_mapping ( struct SwrContext s,
const int *  channel_map 
)

Set a customized input channel mapping.

Parameters:
s allocated Swr context, not yet initialized
channel_map customized input channel mapping (array of channel indexes, -1 for a muted channel)
Returns:
AVERROR error code in case of failure.

Definition at line 90 of file swresample.c.

Referenced by config_props(), and do_audio_out().

const char* swresample_configuration ( void   ) 

Return the swr build-time configuration.

Definition at line 79 of file swresample.c.

const char* swresample_license ( void   ) 

Return the swr license.

Definition at line 84 of file swresample.c.

unsigned swresample_version ( void   ) 

Return the LIBSWRESAMPLE_VERSION_INT constant.

Definition at line 73 of file swresample.c.


Variable Documentation

const AVClass av_class [static]

Initial value:

 {
    .class_name                = "SwrContext",
    .item_name                 = context_to_name,
    .option                    = options,
    .version                   = LIBAVUTIL_VERSION_INT,
    .log_level_offset_offset   = OFFSET(log_level_offset),
    .parent_log_context_offset = OFFSET(log_ctx),
}

Definition at line 64 of file swresample.c.

const AVOption options[] [static]

Initial value:

{
{"ich",  "input channel count", OFFSET( in.ch_count   ), AV_OPT_TYPE_INT, {.dbl=2}, 0, SWR_CH_MAX, 0},
{"och", "output channel count", OFFSET(out.ch_count   ), AV_OPT_TYPE_INT, {.dbl=2}, 0, SWR_CH_MAX, 0},
{"uch",   "used channel count", OFFSET(used_ch_count  ), AV_OPT_TYPE_INT, {.dbl=0}, 0, SWR_CH_MAX, 0},
{"isr",  "input sample rate"  , OFFSET( in_sample_rate), AV_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0},
{"osr", "output sample rate"  , OFFSET(out_sample_rate), AV_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0},


{"isf",  "input sample format", OFFSET( in_sample_fmt ), AV_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0},
{"osf", "output sample format", OFFSET(out_sample_fmt ), AV_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0},
{"tsf", "internal sample format", OFFSET(int_sample_fmt ), AV_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_FLT, 0},
{"icl",  "input channel layout" , OFFSET( in_ch_layout), AV_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"},
{"ocl",  "output channel layout", OFFSET(out_ch_layout), AV_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"},
{"clev", "center mix level"     , OFFSET(clev)         , AV_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0},
{"slev", "sourround mix level"  , OFFSET(slev)         , AV_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0},
{"rmvol", "rematrix volume"     , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, -1000, 1000, 0},
{"flags", NULL                  , OFFSET(flags)        , AV_OPT_TYPE_FLAGS, {.dbl=0}, 0,  UINT_MAX, 0, "flags"},
{"res", "force resampling", 0, AV_OPT_TYPE_CONST, {.dbl=SWR_FLAG_RESAMPLE}, INT_MIN, INT_MAX, 0, "flags"},

{0}
}

Definition at line 38 of file swresample.c.


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