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"
#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 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 49 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 64 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 80 of file af_axcorrelate.c.

◆ XCORRELATE_SLOW

#define XCORRELATE_SLOW (   suffix,
  type 
)

Definition at line 107 of file af_axcorrelate.c.

◆ clipf

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

Definition at line 149 of file af_axcorrelate.c.

◆ clipd

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

Definition at line 150 of file af_axcorrelate.c.

◆ XCORRELATE_FAST

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

Definition at line 152 of file af_axcorrelate.c.

◆ XCORRELATE_BEST

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

Definition at line 202 of file af_axcorrelate.c.

◆ AF

Definition at line 444 of file af_axcorrelate.c.

◆ OFFSET

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

Definition at line 445 of file af_axcorrelate.c.

Function Documentation

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 263 of file af_axcorrelate.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 372 of file af_axcorrelate.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

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

◆ outputs

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

Definition at line 436 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 447 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 458 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:445
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_axcorrelate.c:372
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AudioXCorrelateContext
Definition: af_axcorrelate.c:31
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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:106
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AF
#define AF
Definition: af_axcorrelate.c:444
size
int size
Definition: twinvq_data.h:10344
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_axcorrelate.c:410
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
algo
Definition: dct.c:56
inputs
static const AVFilterPad inputs[]
Definition: af_axcorrelate.c:425
activate
static int activate(AVFilterContext *ctx)
Definition: af_axcorrelate.c:263
suffix
const char * suffix
Definition: checkasm.c:252
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
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:183
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: internal.h:170
outputs
static const AVFilterPad outputs[]
Definition: af_axcorrelate.c:436