Go to the documentation of this file.
36 soxr_datatype_t
type =
46 soxr_io_spec_t io_spec = soxr_io_spec(
type,
type);
48 soxr_quality_spec_t q_spec = soxr_quality_spec((
int)((precision-2)/4), (SOXR_HI_PREC_CLOCK|SOXR_ROLLOFF_NONE)*!!cheby);
49 q_spec.precision = precision;
50 #if !defined SOXR_VERSION
51 q_spec.bw_pc = cutoff?
FFMAX(
FFMIN(cutoff,.995),.8)*100 : q_spec.bw_pc;
53 q_spec.passband_end = cutoff?
FFMAX(
FFMIN(cutoff,.995),.8) : q_spec.passband_end;
56 soxr_delete((soxr_t)
c);
58 soxr_create(in_rate, out_rate, 0, &
error, &io_spec, &q_spec, 0);
65 soxr_delete((soxr_t)*
c);
70 s->delayed_samples_fixup = soxr_delay((soxr_t)
s->resample);
77 soxr_process((soxr_t)
s->resample, &
f, 0, &idone, &
f, 0, &odone);
78 s->delayed_samples_fixup -= soxr_delay((soxr_t)
s->resample);
88 soxr_error_t
error = soxr_set_error((soxr_t)
c, soxr_set_num_channels((soxr_t)
c,
src->ch_count));
90 error = soxr_process((soxr_t)
c,
src->ch, (
size_t)src_size,
91 &idone, dst->
ch, (
size_t)dst_size, &odone);
95 *consumed = (
int)idone;
96 return error? -1 : odone;
100 double delayed_samples = soxr_delay((soxr_t)
s->resample);
104 delayed_samples +=
s->delayed_samples_fixup;
106 delay_s = delayed_samples /
s->out_sample_rate;
108 return (int64_t)(delay_s *
base + .5);
112 int in_count,
int *out_idx,
int *out_sz){
117 double out_samples = (double)
s->out_sample_rate /
s->in_sample_rate * in_samples;
118 double delayed_samples = soxr_delay((soxr_t)
s->resample);
121 delayed_samples +=
s->delayed_samples_fixup;
123 return (int64_t)(out_samples + delayed_samples + 1 + .5);
static int64_t get_delay(struct SwrContext *s, int64_t base)
@ AV_SAMPLE_FMT_FLTP
float, planar
static void destroy(struct ResampleContext **c)
static float kaiser_beta(float att, float tr_bw)
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
static int linear(InterplayACMContext *s, unsigned ind, unsigned col)
Audio buffer used for intermediate storage between conversion phases.
static int flush(struct SwrContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static int64_t get_out_samples(struct SwrContext *s, int in_samples)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
The libswresample context.
uint8_t * ch[SWR_CH_MAX]
samples buffer per channel
SwrFilterType
Resampling Filter Types.
static struct ResampleContext * create(struct ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational)
struct Resampler const swri_soxr_resampler
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void error(const char *err)
static int process(struct ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed)
static int invert_initial_buffer(struct ResampleContext *c, AudioData *dst, const AudioData *src, int in_count, int *out_idx, int *out_sz)
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
enum AVResampleFilterType filter_type
@ AV_SAMPLE_FMT_DBLP
double, planar
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S32
signed 32 bits