FFmpeg
Loading...
Searching...
No Matches
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)
 
#define clipd(x)
 
#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)
 

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 FFFilter 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; \
}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
cl_device_type type
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
int size

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)
Value:
(av_clipf(x, -1.f, 1.f))
#define av_clipf
Definition common.h:145

Definition at line 148 of file af_axcorrelate.c.

◆ clipd

#define clipd ( x)
Value:
(av_clipd(x, -1.0, 1.0))
#define av_clipd
Definition common.h:148

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)
Value:

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",
},
}
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 424 of file af_axcorrelate.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

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 }
}
#define AF
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 446 of file af_axcorrelate.c.

◆ ff_af_axcorrelate

const FFFilter ff_af_axcorrelate
Initial value:
= {
.p.name = "axcorrelate",
.p.description = NULL_IF_CONFIG_SMALL("Cross-correlate two audio streams."),
.p.priv_class = &axcorrelate_class,
.priv_size = sizeof(AudioXCorrelateContext),
}
static const AVFilterPad inputs[]
Definition af_aap.c:299
static const AVFilterPad outputs[]
Definition af_aap.c:310
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition samplefmt.h:67
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_SAMPLEFMTS(...)
Definition filters.h:252
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 457 of file af_axcorrelate.c.