Go to the documentation of this file.
48 #define SDR_FILTER(name, type) \
49 static int sdr_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)\
51 AudioSDRContext *s = ctx->priv; \
52 AVFrame *u = s->cache[0]; \
53 AVFrame *v = s->cache[1]; \
54 const int channels = u->ch_layout.nb_channels; \
55 const int start = (channels * jobnr) / nb_jobs; \
56 const int end = (channels * (jobnr+1)) / nb_jobs; \
57 const int nb_samples = u->nb_samples; \
59 for (int ch = start; ch < end; ch++) { \
60 ChanStats *chs = &s->chs[ch]; \
61 const type *const us = (type *)u->extended_data[ch]; \
62 const type *const vs = (type *)v->extended_data[ch]; \
66 for (int n = 0; n < nb_samples; n++) { \
67 sum_u += us[n] * us[n]; \
68 sum_uv += (us[n] - vs[n]) * (us[n] - vs[n]); \
81 #define SISDR_FILTER(name, type) \
82 static int sisdr_##name(AVFilterContext *ctx, void *arg,int jobnr,int nb_jobs)\
84 AudioSDRContext *s = ctx->priv; \
85 AVFrame *u = s->cache[0]; \
86 AVFrame *v = s->cache[1]; \
87 const int channels = u->ch_layout.nb_channels; \
88 const int start = (channels * jobnr) / nb_jobs; \
89 const int end = (channels * (jobnr+1)) / nb_jobs; \
90 const int nb_samples = u->nb_samples; \
92 for (int ch = start; ch < end; ch++) { \
93 ChanStats *chs = &s->chs[ch]; \
94 const type *const us = (type *)u->extended_data[ch]; \
95 const type *const vs = (type *)v->extended_data[ch]; \
100 for (int n = 0; n < nb_samples; n++) { \
101 sum_u += us[n] * us[n]; \
102 sum_v += vs[n] * vs[n]; \
103 sum_uv += us[n] * vs[n]; \
117 #define PSNR_FILTER(name, type) \
118 static int psnr_##name(AVFilterContext *ctx, void *arg, int jobnr,int nb_jobs)\
120 AudioSDRContext *s = ctx->priv; \
121 AVFrame *u = s->cache[0]; \
122 AVFrame *v = s->cache[1]; \
123 const int channels = u->ch_layout.nb_channels; \
124 const int start = (channels * jobnr) / nb_jobs; \
125 const int end = (channels * (jobnr+1)) / nb_jobs; \
126 const int nb_samples = u->nb_samples; \
128 for (int ch = start; ch < end; ch++) { \
129 ChanStats *chs = &s->chs[ch]; \
130 const type *const us = (type *)u->extended_data[ch]; \
131 const type *const vs = (type *)v->extended_data[ch]; \
132 double sum_uv = 0.; \
134 for (int n = 0; n < nb_samples; n++) \
135 sum_uv += (us[n] - vs[n]) * (us[n] - vs[n]); \
159 for (
int i = 0;
i < 2;
i++) {
168 if (!
ctx->is_disabled)
180 for (
int i = 0;
i < 2;
i++) {
188 for (
int i = 0;
i < 2;
i++) {
205 s->channels =
inlink->ch_layout.nb_channels;
207 if (!strcmp(
ctx->filter->name,
"asdr"))
209 else if (!strcmp(
ctx->filter->name,
"asisdr"))
226 if (!strcmp(
ctx->filter->name,
"asdr")) {
227 for (
int ch = 0; ch <
s->channels; ch++)
229 }
else if (!strcmp(
ctx->filter->name,
"asisdr")) {
230 for (
int ch = 0; ch <
s->channels; ch++) {
231 double scale =
s->chs[ch].uv /
s->chs[ch].v;
237 for (
int ch = 0; ch <
s->channels; ch++) {
301 .description =
NULL_IF_CONFIG_SMALL(
"Measure Audio Scale-Invariant Signal-to-Distortion Ratio."),
@ AV_SAMPLE_FMT_FLTP
float, planar
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
int(* filter)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
static double psnr(double d)
A link between two filters.
static int config_output(AVFilterLink *outlink)
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
A filter pad used for either input or output.
#define SDR_FILTER(name, type)
#define PSNR_FILTER(name, type)
#define FILTER_SAMPLEFMTS(...)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static int activate(AVFilterContext *ctx)
#define FILTER_OUTPUTS(array)
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFilterContext * src
source filter
#define AV_LOG_INFO
Standard information.
#define i(width, name, range_min, range_max)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
const AVFilter ff_af_asisdr
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
void * av_calloc(size_t nmemb, size_t size)
static const AVFilterPad outputs[]
#define SISDR_FILTER(name, type)
double fmax(double, double)
static av_cold void uninit(AVFilterContext *ctx)
const AVFilter ff_af_asdr
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
@ AV_SAMPLE_FMT_DBLP
double, planar
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)
static const AVFilterPad inputs[]
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
const AVFilter ff_af_apsnr