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 "filters.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 clipf(x)   (av_clipf(x, -1.f, 1.f))
 
#define clipd(x)   (av_clipd(x, -1.0, 1.0))
 
#define XCORRELATE_FAST(suffix, type, zero, small, sqrtfun, CLIP)
 
#define XCORRELATE_BEST(suffix, type, zero, small, sqrtfun, FMAX, CLIP)
 
#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 48 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 63 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 79 of file af_axcorrelate.c.

◆ XCORRELATE_SLOW

#define XCORRELATE_SLOW (   suffix,
  type 
)

Definition at line 106 of file af_axcorrelate.c.

◆ clipf

#define clipf (   x)    (av_clipf(x, -1.f, 1.f))

Definition at line 148 of file af_axcorrelate.c.

◆ clipd

#define clipd (   x)    (av_clipd(x, -1.0, 1.0))

Definition at line 149 of file af_axcorrelate.c.

◆ XCORRELATE_FAST

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

Definition at line 151 of file af_axcorrelate.c.

◆ XCORRELATE_BEST

#define XCORRELATE_BEST (   suffix,
  type,
  zero,
  small,
  sqrtfun,
  FMAX,
  CLIP 
)

Definition at line 201 of file af_axcorrelate.c.

◆ AF

Definition at line 443 of file af_axcorrelate.c.

◆ OFFSET

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

Definition at line 444 of file af_axcorrelate.c.

Function Documentation

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 262 of file af_axcorrelate.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 371 of file af_axcorrelate.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 409 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 424 of file af_axcorrelate.c.

◆ outputs

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

Definition at line 435 of file af_axcorrelate.c.

◆ axcorrelate_options

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

Definition at line 446 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 457 of file af_axcorrelate.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
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
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: filters.h:250
OFFSET
#define OFFSET(x)
Definition: af_axcorrelate.c:444
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_axcorrelate.c:371
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AudioXCorrelateContext
Definition: af_axcorrelate.c:30
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:94
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AF
#define AF
Definition: af_axcorrelate.c:443
size
int size
Definition: twinvq_data.h:10344
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_axcorrelate.c:409
zero
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:121
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
algo
Definition: dct.c:56
inputs
static const AVFilterPad inputs[]
Definition: af_axcorrelate.c:424
activate
static int activate(AVFilterContext *ctx)
Definition: af_axcorrelate.c:262
suffix
const char * suffix
Definition: checkasm.c:304
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
outputs
static const AVFilterPad outputs[]
Definition: af_axcorrelate.c:435