libswresample/swresample.h File Reference

libswresample public header More...

#include <inttypes.h>
#include "libavutil/samplefmt.h"

Go to the source code of this file.

Defines

#define LIBSWRESAMPLE_VERSION_MAJOR   0
#define LIBSWRESAMPLE_VERSION_MINOR   15
#define LIBSWRESAMPLE_VERSION_MICRO   100
#define LIBSWRESAMPLE_VERSION_INT
#define SWR_CH_MAX   32
 Maximum number of channels.
#define SWR_FLAG_RESAMPLE   1
 Force resampling even if equal sample rate.

Typedefs

typedef struct SwrContext SwrContext

Enumerations

enum  SwrDitherType {
  SWR_DITHER_NONE = 0, SWR_DITHER_RECTANGULAR, SWR_DITHER_TRIANGULAR, SWR_DITHER_TRIANGULAR_HIGHPASS,
  SWR_DITHER_NB
}
enum  SwrFilterType { SWR_FILTER_TYPE_CUBIC, SWR_FILTER_TYPE_BLACKMAN_NUTTALL, SWR_FILTER_TYPE_KAISER }
 Resampling Filter Types. More...

Functions

const AVClassswr_get_class (void)
 Get the AVClass for swrContext.
struct SwrContextswr_alloc (void)
 Allocate SwrContext.
int swr_init (struct SwrContext *s)
 Initialize context after user parameters have been set.
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.
void swr_free (struct SwrContext **s)
 Free the given SwrContext and set the pointer to NULL.
int swr_convert (struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in, int in_count)
 Convert audio.
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.
int swr_set_compensation (struct SwrContext *s, int sample_delta, int compensation_distance)
 Activate resampling compensation.
int swr_set_channel_mapping (struct SwrContext *s, const int *channel_map)
 Set a customized input channel mapping.
int swr_set_matrix (struct SwrContext *s, const double *matrix, int stride)
 Set a customized remix matrix.
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_get_delay (struct SwrContext *s, int64_t base)
 Gets the delay the next input sample will experience relative to the next output sample.
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.


Detailed Description

libswresample public header

Definition in file swresample.h.


Define Documentation

#define LIBSWRESAMPLE_VERSION_INT

#define LIBSWRESAMPLE_VERSION_MAJOR   0

Definition at line 32 of file swresample.h.

#define LIBSWRESAMPLE_VERSION_MICRO   100

Definition at line 34 of file swresample.h.

Referenced by swresample_version().

#define LIBSWRESAMPLE_VERSION_MINOR   15

Definition at line 33 of file swresample.h.

#define SWR_CH_MAX   32

#define SWR_FLAG_RESAMPLE   1

Force resampling even if equal sample rate.

Definition at line 44 of file swresample.h.

Referenced by swr_init(), and swr_set_compensation().


Typedef Documentation

typedef struct SwrContext SwrContext

Definition at line 63 of file swresample.h.


Enumeration Type Documentation

Enumerator:
SWR_DITHER_NONE 
SWR_DITHER_RECTANGULAR 
SWR_DITHER_TRIANGULAR 
SWR_DITHER_TRIANGULAR_HIGHPASS 
SWR_DITHER_NB  not part of API/ABI

Definition at line 48 of file swresample.h.

Resampling Filter Types.

Enumerator:
SWR_FILTER_TYPE_CUBIC  Cubic.
SWR_FILTER_TYPE_BLACKMAN_NUTTALL  Blackman Nuttall Windowed Sinc.
SWR_FILTER_TYPE_KAISER  Kaiser Windowed Sinc.

Definition at line 57 of file swresample.h.


Function Documentation

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

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

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

Convert audio.

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

If more input is provided than output space then the input will be buffered. You can avoid this buffering by providing more output space than input. Convertion will run directly without copying whenever possible.

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, negative value on error

int swr_drop_output ( struct SwrContext s,
int  count 
)

Drops the specified number of output samples.

Definition at line 732 of file swresample.c.

Referenced by swr_next_pts().

void swr_free ( struct SwrContext **  s  ) 

Free the given SwrContext and set the pointer to NULL.

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

Referenced by opt_default(), and show_help_default().

int64_t swr_get_delay ( struct SwrContext s,
int64_t  base 
)

Gets the delay the next input sample will experience relative to the next output sample.

Swresample can buffer data if more input has been provided than available output space, also converting between sample rates needs a delay. This function returns the sum of all such delays.

Parameters:
s swr context
base timebase in which the returned delay will be if its set to 1 the returned delay is in seconds if its set to 1000 the returned delay is in milli seconds if its set to the input sample rate then the returned delay is in input samples if its set to the output sample rate then the returned delay is in output samples an exact rounding free delay can be found by using LCM(in_sample_rate, out_sample_rate)
Returns:
the delay in 1/base units.

Definition at line 446 of file resample.c.

Referenced by swr_next_pts().

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 208 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 742 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 767 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 135 of file swresample.c.

Referenced by config_props().

int swr_set_compensation ( struct SwrContext s,
int  sample_delta,
int  compensation_distance 
)

Activate resampling compensation.

Definition at line 269 of file resample.c.

Referenced by audio_decode_frame(), and swr_next_pts().

int swr_set_matrix ( struct SwrContext s,
const double *  matrix,
int  stride 
)

Set a customized remix matrix.

Parameters:
s allocated Swr context, not yet initialized
matrix remix coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o
stride offset between lines of the matrix
Returns:
AVERROR error code in case of failure.

Definition at line 81 of file rematrix.c.

Referenced by config_props().

const char* swresample_configuration ( void   ) 

Return the swr build-time configuration.

Definition at line 124 of file swresample.c.

const char* swresample_license ( void   ) 

Return the swr license.

Definition at line 129 of file swresample.c.

unsigned swresample_version ( void   ) 

Return the LIBSWRESAMPLE_VERSION_INT constant.

Definition at line 118 of file swresample.c.


Generated on Fri Oct 26 02:50:12 2012 for FFmpeg by  doxygen 1.5.8