123 double *
i1,
double *
i2,
double *
o1,
double *
o2,
176 #define BIQUAD_FILTER(name, type, min, max, need_clipping) \ 177 static void biquad_## name (BiquadsContext *s, \ 178 const void *input, void *output, int len, \ 179 double *in1, double *in2, \ 180 double *out1, double *out2, \ 181 double b0, double b1, double b2, \ 182 double a1, double a2, int *clippings, \ 185 const type *ibuf = input; \ 186 type *obuf = output; \ 191 double wet = s->mix; \ 192 double dry = 1. - wet; \ 198 for (i = 0; i+1 < len; i++) { \ 199 o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \ 201 out = o2 * wet + i2 * dry; \ 204 } else if (need_clipping && out < min) { \ 207 } else if (need_clipping && out > max) { \ 214 o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \ 216 out = o1 * wet + i1 * dry; \ 219 } else if (need_clipping && out < min) { \ 222 } else if (need_clipping && out > max) { \ 230 double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 + o1 * a1 + o2 * a2; \ 235 out = o0 * wet + i1 * dry; \ 238 } else if (need_clipping && out < min) { \ 241 } else if (need_clipping && out > max) { \ 270 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
286 alpha = sin(w0) * sinh(log(2.) / 2 * s->
width * w0 / sin(w0));
289 alpha = sin(w0) / (2 * s->
width);
292 alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / s->
width - 1) + 2);
304 s->
a0 = 1 + alpha /
A;
305 s->
a1 = -2 * cos(w0);
306 s->
a2 = 1 - alpha /
A;
307 s->
b0 = 1 + alpha *
A;
308 s->
b1 = -2 * cos(w0);
309 s->
b2 = 1 - alpha *
A;
312 beta = sqrt((A * A + 1) - (A - 1) * (A - 1));
314 s->
a0 = (A + 1) + (A - 1) * cos(w0) + beta *
alpha;
315 s->
a1 = -2 * ((A - 1) + (A + 1) * cos(w0));
316 s->
a2 = (A + 1) + (A - 1) * cos(w0) - beta *
alpha;
317 s->
b0 = A * ((A + 1) - (A - 1) * cos(w0) + beta *
alpha);
318 s->
b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
319 s->
b2 = A * ((A + 1) - (A - 1) * cos(w0) - beta *
alpha);
322 beta = sqrt((A * A + 1) - (A - 1) * (A - 1));
324 s->
a0 = (A + 1) - (A - 1) * cos(w0) + beta *
alpha;
325 s->
a1 = 2 * ((A - 1) - (A + 1) * cos(w0));
326 s->
a2 = (A + 1) - (A - 1) * cos(w0) - beta *
alpha;
327 s->
b0 = A * ((A + 1) + (A - 1) * cos(w0) + beta *
alpha);
328 s->
b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
329 s->
b2 = A * ((A + 1) + (A - 1) * cos(w0) - beta *
alpha);
334 s->
a1 = -2 * cos(w0);
338 s->
b2 = -sin(w0) / 2;
341 s->
a1 = -2 * cos(w0);
350 s->
a1 = -2 * cos(w0);
353 s->
b1 = -2 * cos(w0);
366 s->
a1 = -2 * cos(w0);
368 s->
b0 = (1 - cos(w0)) / 2;
370 s->
b2 = (1 - cos(w0)) / 2;
378 s->
b0 = (1 - s->
a1) / 2;
383 s->
a1 = -2 * cos(w0);
385 s->
b0 = (1 + cos(w0)) / 2;
386 s->
b1 = -(1 + cos(w0));
387 s->
b2 = (1 + cos(w0)) / 2;
392 s->
a1 = -2 * cos(w0);
395 s->
b1 = -2 * cos(w0);
447 const int end = (buf->
channels * (jobnr+1)) / nb_jobs;
450 for (ch = start; ch <
end; ch++) {
490 for (ch = 0; ch < outlink->
channels; ch++) {
504 char *res,
int res_len,
int flags)
509 if ((!strcmp(cmd,
"frequency") || !strcmp(cmd,
"f")) &&
522 if (sscanf(args,
"%lf", &freq) != 1) {
528 }
else if ((!strcmp(cmd,
"gain") || !strcmp(cmd,
"g")) &&
536 if (sscanf(args,
"%lf", &gain) != 1) {
541 s->
gain = av_clipd(gain, -900, 900);
542 }
else if (!strcmp(cmd,
"mix") || !strcmp(cmd,
"m")) {
545 if (sscanf(args,
"%lf", &mix) != 1) {
550 s->
mix = av_clipd(mix, 0, 1);
551 }
else if ((!strcmp(cmd,
"width") || !strcmp(cmd,
"w")) &&
564 if (sscanf(args,
"%lf", &width) != 1) {
570 }
else if ((!strcmp(cmd,
"width_type") || !strcmp(cmd,
"t")) &&
583 if (sscanf(args,
"%c", &width_type) != 1) {
588 switch (width_type) {
589 case 'h': width_type =
HERTZ;
break;
590 case 'q': width_type =
QFACTOR;
break;
591 case 'o': width_type =
OCTAVE;
break;
592 case 's': width_type =
SLOPE;
break;
593 case 'k': width_type =
KHERTZ;
break;
600 }
else if ((!strcmp(cmd,
"a0") ||
601 !strcmp(cmd,
"a1") ||
602 !strcmp(cmd,
"a2") ||
603 !strcmp(cmd,
"b0") ||
604 !strcmp(cmd,
"b1") ||
605 !strcmp(cmd,
"b2")) &&
609 if (sscanf(args,
"%lf", &value) != 1) {
614 if (!strcmp(cmd,
"a0"))
616 else if (!strcmp(cmd,
"a1"))
618 else if (!strcmp(cmd,
"a2"))
620 else if (!strcmp(cmd,
"b0"))
622 else if (!strcmp(cmd,
"b1"))
624 else if (!strcmp(cmd,
"b2"))
656 #define OFFSET(x) offsetof(BiquadsContext, x) 657 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 659 #define DEFINE_BIQUAD_FILTER(name_, description_) \ 660 AVFILTER_DEFINE_CLASS(name_); \ 661 static av_cold int name_##_init(AVFilterContext *ctx) \ 663 BiquadsContext *s = ctx->priv; \ 664 s->class = &name_##_class; \ 665 s->filter_type = name_; \ 669 AVFilter ff_af_##name_ = { \ 671 .description = NULL_IF_CONFIG_SMALL(description_), \ 672 .priv_size = sizeof(BiquadsContext), \ 673 .init = name_##_init, \ 675 .query_formats = query_formats, \ 677 .outputs = outputs, \ 678 .priv_class = &name_##_class, \ 679 .process_command = process_command, \ 680 .flags = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, \ 683 #if CONFIG_EQUALIZER_FILTER 684 static const AVOption equalizer_options[] = {
707 #if CONFIG_BASS_FILTER 708 static const AVOption bass_options[] = {
731 #if CONFIG_TREBLE_FILTER 732 static const AVOption treble_options[] = {
755 #if CONFIG_BANDPASS_FILTER 756 static const AVOption bandpass_options[] = {
778 #if CONFIG_BANDREJECT_FILTER 779 static const AVOption bandreject_options[] = {
800 #if CONFIG_LOWPASS_FILTER 801 static const AVOption lowpass_options[] = {
824 #if CONFIG_HIGHPASS_FILTER 825 static const AVOption highpass_options[] = {
848 #if CONFIG_ALLPASS_FILTER 849 static const AVOption allpass_options[] = {
870 #if CONFIG_LOWSHELF_FILTER 871 static const AVOption lowshelf_options[] = {
894 #if CONFIG_HIGHSHELF_FILTER 895 static const AVOption highshelf_options[] = {
918 #if CONFIG_BIQUAD_FILTER 919 static const AVOption biquad_options[] = {
This structure describes decoded (raw) audio or video data.
#define av_realloc_f(p, o, n)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static const AVFilterPad inputs[]
int is_disabled
the enabled state from the last expression evaluation
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
static av_cold int end(AVCodecContext *avctx)
void(* filter)(struct BiquadsContext *s, const void *ibuf, void *obuf, int len, double *i1, double *i2, double *o1, double *o2, double b0, double b1, double b2, double a1, double a2, int *clippings, int disabled)
#define AV_LOG_VERBOSE
Detailed information.
static const AVFilterPad outputs[]
A filter pad used for either input or output.
static av_cold int init(AVFilterContext *ctx)
A link between two filters.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void * priv
private data for use by the filter
simple assert() macros that are a bit more flexible than ISO C assert().
int channels
number of audio channels, only used for audio.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
const char AVS_Value args
int format
agreed upon media format
A list of supported channel layouts.
static int mix(int c0, int c1)
#define BIQUAD_FILTER(name, type, min, max, need_clipping)
AVSampleFormat
Audio sample formats.
typedef void(RENAME(mix_any_func_type))
static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Used for passing data between threads.
static int config_output(AVFilterLink *outlink)
static const int16_t alpha[]
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
#define DEFINE_BIQUAD_FILTER(name_, description_)
static int query_formats(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
#define flags(name, subs,...)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
static av_cold void uninit(AVFilterContext *ctx)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
internal math functions header
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
Get the channel with the given index in channel_layout.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
avfilter_execute_func * execute
static int config_filter(AVFilterLink *outlink, int reset)
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
AVFilterContext * dst
dest filter
static enum AVSampleFormat sample_fmts[]
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
uint8_t ** extended_data
pointers to the data planes/channels.
enum FilterType filter_type
int nb_samples
number of audio samples (per channel) described by this frame
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.