libswresample/swresample.c File Reference

#include "libavutil/opt.h"
#include "swresample_internal.h"
#include "audioconvert.h"
#include "libavutil/avassert.h"
#include "libavutil/audioconvert.h"
#include <float.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 ALIGN   32
#define OFFSET(x)   offsetof(SwrContext,x)
#define PARAM   AV_OPT_FLAG_AUDIO_PARAM
#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.
const AVClassswr_get_class (void)
 Get the AVClass for swrContext.
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 set_audiodata_fmt (AudioData *a, enum AVSampleFormat fmt)
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 reversefill_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)
static int swr_convert_internal (struct SwrContext *s, AudioData *out, int out_count, AudioData *in, 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)
int swr_drop_output (struct SwrContext *s, int count)
 Drops the specified number of output samples.
int swr_inject_silence (struct SwrContext *s, int count)
 Injects the specified number of silence samples.
int64_t swr_next_pts (struct SwrContext *s, int64_t pts)
 Convert the next timestamp from input to output timestampe are in 1/(in_sample_rate * out_sample_rate) units.

Variables

static const AVOption options []
static const AVClass av_class


Define Documentation

#define ALIGN   32

Definition at line 37 of file swresample.c.

#define C15DB   1.189207115

Definition at line 30 of file swresample.c.

#define C30DB   M_SQRT2

Definition at line 29 of file swresample.c.

#define C_15DB   0.840896415

Definition at line 32 of file swresample.c.

#define C_30DB   M_SQRT1_2

Definition at line 33 of file swresample.c.

#define C_45DB   0.594603558

Definition at line 34 of file swresample.c.

#define C_60DB   0.5

Definition at line 35 of file swresample.c.

#define C__0DB   1.0

Definition at line 31 of file swresample.c.

#define LICENSE_PREFIX   "libswresample license: "

#define OFFSET (  )     offsetof(SwrContext,x)

Definition at line 40 of file swresample.c.

#define PARAM   AV_OPT_FLAG_AUDIO_PARAM

Definition at line 41 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 415 of file swresample.c.

Referenced by resample(), and swr_convert().

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

Definition at line 95 of file swresample.c.

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

Definition at line 375 of file swresample.c.

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

Definition at line 388 of file swresample.c.

Referenced by swr_convert().

static void free_temp ( AudioData a  )  [static]

Definition at line 175 of file swresample.c.

Referenced by swr_free(), and swr_init().

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

Definition at line 343 of file swresample.c.

Referenced by resample(), swr_convert(), swr_convert_internal(), and swr_inject_silence().

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 430 of file swresample.c.

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

Definition at line 401 of file swresample.c.

Referenced by swr_convert(), and swr_inject_silence().

static void set_audiodata_fmt ( AudioData a,
enum AVSampleFormat  fmt 
) [static]

Definition at line 169 of file swresample.c.

Referenced by swr_init().

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 137 of file swresample.c.

Referenced by init(), init_opts(), and 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 146 of file swresample.c.

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

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 
)

static int swr_convert_internal ( struct SwrContext s,
AudioData out,
int  out_count,
AudioData in,
int  in_count 
) [static]

Definition at line 508 of file swresample.c.

Referenced by swr_convert().

int swr_drop_output ( struct SwrContext s,
int  count 
)

Drops the specified number of output samples.

Definition at line 720 of file swresample.c.

Referenced by swr_next_pts().

void swr_free ( SwrContext **  ss  ) 

Free the given SwrContext and set the pointer to NULL.

Definition at line 180 of file swresample.c.

Referenced by audio_decode_frame(), stream_component_close(), uninit(), and uninit_opts().

const AVClass* swr_get_class ( void   ) 

Get the AVClass for swrContext.

It can be used in combination with AV_OPT_SEARCH_FAKE_OBJ for examining options.

See also:
av_opt_find().

Definition at line 132 of file swresample.c.

Referenced by opt_default().

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 198 of file swresample.c.

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

int swr_inject_silence ( struct SwrContext s,
int  count 
)

Injects the specified number of silence samples.

Definition at line 730 of file swresample.c.

Referenced by swr_next_pts().

int64_t swr_next_pts ( struct SwrContext s,
int64_t  pts 
)

Convert the next timestamp from input to output timestampe are in 1/(in_sample_rate * out_sample_rate) units.

Note:
There are 2 slightly differently behaving modes. First is when automatic timestamp compensation is not used, (min_compensation >= FLT_MAX) in this case timestamps will be passed through with delays compensated Second is when automatic timestamp compensation is used, (min_compensation < FLT_MAX) in this case the output timestamps will match output sample numbers
Parameters:
pts timstamp for the next input sample, INT64_MIN if unknown
Returns:
the output timestamp for the next output sample

Definition at line 755 of file swresample.c.

Referenced by filter_samples(), and request_frame().

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 125 of file swresample.c.

Referenced by config_props().

const char* swresample_configuration ( void   ) 

Return the swr build-time configuration.

Definition at line 114 of file swresample.c.

const char* swresample_license ( void   ) 

Return the swr license.

Definition at line 119 of file swresample.c.

unsigned swresample_version ( void   ) 

Return the LIBSWRESAMPLE_VERSION_INT constant.

Definition at line 108 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 99 of file swresample.c.

const AVOption options[] [static]

Definition at line 43 of file swresample.c.


Generated on Fri Oct 26 02:48:03 2012 for FFmpeg by  doxygen 1.5.8