FFmpeg
Data Structures | Macros | Functions | Variables
af_axcorrelate.c File Reference
#include "libavutil/audio_fifo.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "formats.h"
#include "filters.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  AudioXCorrelateContext
 

Macros

#define MEAN_SUM(suffix, type, zero)
 
#define SQUARE_SUM(suffix, type, zero)
 
#define XCORRELATE(suffix, type, zero, small, sqrtfun)
 
#define XCORRELATE_SLOW(suffix, type)
 
#define XCORRELATE_FAST(suffix, type, zero, small, sqrtfun)
 
#define AF   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define OFFSET(x)   offsetof(AudioXCorrelateContext, x)
 

Functions

static int activate (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (axcorrelate)
 

Variables

static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
static const AVOption axcorrelate_options []
 
const AVFilter ff_af_axcorrelate
 

Macro Definition Documentation

◆ MEAN_SUM

#define MEAN_SUM (   suffix,
  type,
  zero 
)
Value:
static type mean_sum_##suffix(const type *in, \
int size) \
{ \
type mean_sum = zero; \
for (int i = 0; i < size; i++) \
mean_sum += in[i]; \
\
return mean_sum; \
}

Definition at line 50 of file af_axcorrelate.c.

◆ SQUARE_SUM

#define SQUARE_SUM (   suffix,
  type,
  zero 
)
Value:
static type square_sum_##suffix(const type *x, \
const type *y, \
int size) \
{ \
type square_sum = zero; \
for (int i = 0; i < size; i++) \
square_sum += x[i] * y[i]; \
\
return square_sum; \
}

Definition at line 65 of file af_axcorrelate.c.

◆ XCORRELATE

#define XCORRELATE (   suffix,
  type,
  zero,
  small,
  sqrtfun 
)
Value:
static type xcorrelate_##suffix(const type *x, \
const type *y, \
type sumx, \
type sumy, int size) \
{ \
const type xm = sumx / size, ym = sumy / size; \
type num = zero, den, den0 = zero, den1 = zero; \
for (int i = 0; i < size; i++) { \
type xd = x[i] - xm; \
type yd = y[i] - ym; \
\
num += xd * yd; \
den0 += xd * xd; \
den1 += yd * yd; \
} \
\
num /= size; \
den = sqrtfun((den0 * den1) / size / size); \
\
return den <= small ? zero : num / den; \
}

Definition at line 81 of file af_axcorrelate.c.

◆ XCORRELATE_SLOW

#define XCORRELATE_SLOW (   suffix,
  type 
)

Definition at line 108 of file af_axcorrelate.c.

◆ XCORRELATE_FAST

#define XCORRELATE_FAST (   suffix,
  type,
  zero,
  small,
  sqrtfun 
)

Definition at line 150 of file af_axcorrelate.c.

◆ AF

Definition at line 365 of file af_axcorrelate.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(AudioXCorrelateContext, x)

Definition at line 366 of file af_axcorrelate.c.

Function Documentation

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 200 of file af_axcorrelate.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 295 of file af_axcorrelate.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 331 of file af_axcorrelate.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( axcorrelate  )

Variable Documentation

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "axcorrelate0",
},
{
.name = "axcorrelate1",
},
}

Definition at line 346 of file af_axcorrelate.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 357 of file af_axcorrelate.c.

◆ axcorrelate_options

const AVOption axcorrelate_options[]
static
Initial value:
= {
{ "size", "set segment size", OFFSET(size), AV_OPT_TYPE_INT, {.i64=256}, 2, 131072, AF },
{ "algo", "set algorithm", OFFSET(algo), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AF, "algo" },
{ "slow", "slow algorithm", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "algo" },
{ "fast", "fast algorithm", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "algo" },
{ NULL }
}

Definition at line 368 of file af_axcorrelate.c.

◆ ff_af_axcorrelate

const AVFilter ff_af_axcorrelate
Initial value:
= {
.name = "axcorrelate",
.description = NULL_IF_CONFIG_SMALL("Cross-correlate two audio streams."),
.priv_size = sizeof(AudioXCorrelateContext),
.priv_class = &axcorrelate_class,
}

Definition at line 378 of file af_axcorrelate.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
type
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
Definition: writing_filters.txt:86
OFFSET
#define OFFSET(x)
Definition: af_axcorrelate.c:366
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_axcorrelate.c:295
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AudioXCorrelateContext
Definition: af_axcorrelate.c:32
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
NULL
#define NULL
Definition: coverity.c:32
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AF
#define AF
Definition: af_axcorrelate.c:365
size
int size
Definition: twinvq_data.h:10344
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_axcorrelate.c:331
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
algo
Definition: dct.c:54
inputs
static const AVFilterPad inputs[]
Definition: af_axcorrelate.c:346
activate
static int activate(AVFilterContext *ctx)
Definition: af_axcorrelate.c:200
suffix
const char * suffix
Definition: checkasm.c:211
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
zero
#define zero
Definition: regdef.h:64
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: internal.h:178
outputs
static const AVFilterPad outputs[]
Definition: af_axcorrelate.c:357