FFmpeg
Data Structures | Macros | Functions | Variables
af_asdr.c File Reference
#include <float.h>
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "avfilter.h"
#include "filters.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  ChanStats
 
struct  AudioSDRContext
 

Macros

#define SDR_FILTER(name, type)
 
#define SISDR_FILTER(name, type)
 
#define PSNR_FILTER(name, type)
 

Functions

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

Variables

static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const AVFilter ff_af_asdr
 
const AVFilter ff_af_apsnr
 
const AVFilter ff_af_asisdr
 

Macro Definition Documentation

◆ SDR_FILTER

#define SDR_FILTER (   name,
  type 
)
Value:
static int sdr_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)\
{ \
AudioSDRContext *s = ctx->priv; \
AVFrame *u = s->cache[0]; \
AVFrame *v = s->cache[1]; \
const int channels = u->ch_layout.nb_channels; \
const int start = (channels * jobnr) / nb_jobs; \
const int end = (channels * (jobnr+1)) / nb_jobs; \
const int nb_samples = u->nb_samples; \
for (int ch = start; ch < end; ch++) { \
ChanStats *chs = &s->chs[ch]; \
const type *const us = (type *)u->extended_data[ch]; \
const type *const vs = (type *)v->extended_data[ch]; \
double sum_uv = 0.; \
double sum_u = 0.; \
for (int n = 0; n < nb_samples; n++) { \
sum_u += us[n] * us[n]; \
sum_uv += (us[n] - vs[n]) * (us[n] - vs[n]); \
} \
\
chs->uv += sum_uv; \
chs->u += sum_u; \
} \
\
return 0; \
}

Definition at line 48 of file af_asdr.c.

◆ SISDR_FILTER

#define SISDR_FILTER (   name,
  type 
)

Definition at line 81 of file af_asdr.c.

◆ PSNR_FILTER

#define PSNR_FILTER (   name,
  type 
)
Value:
static int psnr_##name(AVFilterContext *ctx, void *arg, int jobnr,int nb_jobs)\
{ \
AudioSDRContext *s = ctx->priv; \
AVFrame *u = s->cache[0]; \
AVFrame *v = s->cache[1]; \
const int channels = u->ch_layout.nb_channels; \
const int start = (channels * jobnr) / nb_jobs; \
const int end = (channels * (jobnr+1)) / nb_jobs; \
const int nb_samples = u->nb_samples; \
for (int ch = start; ch < end; ch++) { \
ChanStats *chs = &s->chs[ch]; \
const type *const us = (type *)u->extended_data[ch]; \
const type *const vs = (type *)v->extended_data[ch]; \
double sum_uv = 0.; \
for (int n = 0; n < nb_samples; n++) \
sum_uv += (us[n] - vs[n]) * (us[n] - vs[n]); \
\
chs->uv += sum_uv; \
} \
\
return 0; \
}

Definition at line 117 of file af_asdr.c.

Function Documentation

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 146 of file af_asdr.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 199 of file af_asdr.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 222 of file af_asdr.c.

Variable Documentation

◆ inputs

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

Definition at line 250 of file af_asdr.c.

◆ outputs

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

Definition at line 261 of file af_asdr.c.

◆ ff_af_asdr

const AVFilter ff_af_asdr
Initial value:

Definition at line 269 of file af_asdr.c.

◆ ff_af_apsnr

const AVFilter ff_af_apsnr
Initial value:

Definition at line 284 of file af_asdr.c.

◆ ff_af_asisdr

const AVFilter ff_af_asisdr
Initial value:

Definition at line 299 of file af_asdr.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
name
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 default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:250
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_asdr.c:199
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
us
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:262
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
activate
static int activate(AVFilterContext *ctx)
Definition: af_asdr.c:146
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:31
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
arg
const char * arg
Definition: jacosubdec.c:67
AudioSDRContext
Definition: af_asdr.c:36
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
outputs
static const AVFilterPad outputs[]
Definition: af_asdr.c:261
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_asdr.c:222
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:133
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:155
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
inputs
static const AVFilterPad inputs[]
Definition: af_asdr.c:250
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: internal.h:170