FFmpeg
af_acrusher.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Markus Schmidt and Christian Holschuh
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/opt.h"
22 #include "avfilter.h"
23 #include "internal.h"
24 #include "audio.h"
25 
26 typedef struct LFOContext {
27  double freq;
28  double offset;
29  int srate;
30  double amount;
31  double pwidth;
32  double phase;
33 } LFOContext;
34 
35 typedef struct SRContext {
36  double target;
37  double real;
38  double samples;
39  double last;
40 } SRContext;
41 
42 typedef struct ACrusherContext {
43  const AVClass *class;
44 
45  double level_in;
46  double level_out;
47  double bits;
48  double mix;
49  int mode;
50  double dc;
51  double idc;
52  double aa;
53  double samples;
54  int is_lfo;
55  double lforange;
56  double lforate;
57 
58  double sqr;
59  double aa1;
60  double coeff;
61  int round;
62  double sov;
63  double smin;
64  double sdiff;
65 
69 
70 #define OFFSET(x) offsetof(ACrusherContext, x)
71 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
72 
73 static const AVOption acrusher_options[] = {
74  { "level_in", "set level in", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A },
75  { "level_out","set level out", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A },
76  { "bits", "set bit reduction", OFFSET(bits), AV_OPT_TYPE_DOUBLE, {.dbl=8}, 1, 64, A },
77  { "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=.5}, 0, 1, A },
78  { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A, "mode" },
79  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A, "mode" },
80  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A, "mode" },
81  { "dc", "set DC", OFFSET(dc), AV_OPT_TYPE_DOUBLE, {.dbl=1}, .25, 4, A },
82  { "aa", "set anti-aliasing", OFFSET(aa), AV_OPT_TYPE_DOUBLE, {.dbl=.5}, 0, 1, A },
83  { "samples", "set sample reduction", OFFSET(samples), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 1, 250, A },
84  { "lfo", "enable LFO", OFFSET(is_lfo), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A },
85  { "lforange", "set LFO depth", OFFSET(lforange), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 1, 250, A },
86  { "lforate", "set LFO rate", OFFSET(lforate), AV_OPT_TYPE_DOUBLE, {.dbl=.3}, .01, 200, A },
87  { NULL }
88 };
89 
90 AVFILTER_DEFINE_CLASS(acrusher);
91 
92 static double samplereduction(ACrusherContext *s, SRContext *sr, double in)
93 {
94  sr->samples++;
95  if (sr->samples >= s->round) {
96  sr->target += s->samples;
97  sr->real += s->round;
98  if (sr->target + s->samples >= sr->real + 1) {
99  sr->last = in;
100  sr->target = 0;
101  sr->real = 0;
102  }
103  sr->samples = 0;
104  }
105  return sr->last;
106 }
107 
108 static double add_dc(double s, double dc, double idc)
109 {
110  return s > 0 ? s * dc : s * idc;
111 }
112 
113 static double remove_dc(double s, double dc, double idc)
114 {
115  return s > 0 ? s * idc : s * dc;
116 }
117 
118 static inline double factor(double y, double k, double aa1, double aa)
119 {
120  return 0.5 * (sin(M_PI * (fabs(y - k) - aa1) / aa - M_PI_2) + 1);
121 }
122 
123 static double bitreduction(ACrusherContext *s, double in)
124 {
125  const double sqr = s->sqr;
126  const double coeff = s->coeff;
127  const double aa = s->aa;
128  const double aa1 = s->aa1;
129  double y, k;
130 
131  // add dc
132  in = add_dc(in, s->dc, s->idc);
133 
134  // main rounding calculation depending on mode
135 
136  // the idea for anti-aliasing:
137  // you need a function f which brings you to the scale, where
138  // you want to round and the function f_b (with f(f_b)=id) which
139  // brings you back to your original scale.
140  //
141  // then you can use the logic below in the following way:
142  // y = f(in) and k = roundf(y)
143  // if (y > k + aa1)
144  // k = f_b(k) + ( f_b(k+1) - f_b(k) ) * 0.5 * (sin(x - PI/2) + 1)
145  // if (y < k + aa1)
146  // k = f_b(k) - ( f_b(k+1) - f_b(k) ) * 0.5 * (sin(x - PI/2) + 1)
147  //
148  // whereas x = (fabs(f(in) - k) - aa1) * PI / aa
149  // for both cases.
150 
151  switch (s->mode) {
152  case 0:
153  default:
154  // linear
155  y = in * coeff;
156  k = roundf(y);
157  if (k - aa1 <= y && y <= k + aa1) {
158  k /= coeff;
159  } else if (y > k + aa1) {
160  k = k / coeff + ((k + 1) / coeff - k / coeff) *
161  factor(y, k, aa1, aa);
162  } else {
163  k = k / coeff - (k / coeff - (k - 1) / coeff) *
164  factor(y, k, aa1, aa);
165  }
166  break;
167  case 1:
168  // logarithmic
169  y = sqr * log(fabs(in)) + sqr * sqr;
170  k = roundf(y);
171  if(!in) {
172  k = 0;
173  } else if (k - aa1 <= y && y <= k + aa1) {
174  k = in / fabs(in) * exp(k / sqr - sqr);
175  } else if (y > k + aa1) {
176  double x = exp(k / sqr - sqr);
177  k = FFSIGN(in) * (x + (exp((k + 1) / sqr - sqr) - x) *
178  factor(y, k, aa1, aa));
179  } else {
180  double x = exp(k / sqr - sqr);
181  k = in / fabs(in) * (x - (x - exp((k - 1) / sqr - sqr)) *
182  factor(y, k, aa1, aa));
183  }
184  break;
185  }
186 
187  // mix between dry and wet signal
188  k += (in - k) * s->mix;
189 
190  // remove dc
191  k = remove_dc(k, s->dc, s->idc);
192 
193  return k;
194 }
195 
196 static double lfo_get(LFOContext *lfo)
197 {
198  double phs = FFMIN(100., lfo->phase / FFMIN(1.99, FFMAX(0.01, lfo->pwidth)) + lfo->offset);
199  double val;
200 
201  if (phs > 1)
202  phs = fmod(phs, 1.);
203 
204  val = sin((phs * 360.) * M_PI / 180);
205 
206  return val * lfo->amount;
207 }
208 
209 static void lfo_advance(LFOContext *lfo, unsigned count)
210 {
211  lfo->phase = fabs(lfo->phase + count * lfo->freq * (1. / lfo->srate));
212  if (lfo->phase >= 1.)
213  lfo->phase = fmod(lfo->phase, 1.);
214 }
215 
217 {
218  AVFilterContext *ctx = inlink->dst;
219  ACrusherContext *s = ctx->priv;
220  AVFilterLink *outlink = ctx->outputs[0];
221  AVFrame *out;
222  const double *src = (const double *)in->data[0];
223  double *dst;
224  const double level_in = s->level_in;
225  const double level_out = s->level_out;
226  const double mix = s->mix;
227  int n, c;
228 
230  out = in;
231  } else {
232  out = ff_get_audio_buffer(inlink, in->nb_samples);
233  if (!out) {
234  av_frame_free(&in);
235  return AVERROR(ENOMEM);
236  }
238  }
239 
240  dst = (double *)out->data[0];
241  for (n = 0; n < in->nb_samples; n++) {
242  if (s->is_lfo) {
243  s->samples = s->smin + s->sdiff * (lfo_get(&s->lfo) + 0.5);
244  s->round = round(s->samples);
245  }
246 
247  for (c = 0; c < inlink->channels; c++) {
248  double sample = src[c] * level_in;
249 
250  sample = mix * samplereduction(s, &s->sr[c], sample) + src[c] * (1. - mix) * level_in;
251  dst[c] = bitreduction(s, sample) * level_out;
252  }
253  src += c;
254  dst += c;
255 
256  if (s->is_lfo)
257  lfo_advance(&s->lfo, 1);
258  }
259 
260  if (in != out)
261  av_frame_free(&in);
262 
263  return ff_filter_frame(outlink, out);
264 }
265 
267 {
270  static const enum AVSampleFormat sample_fmts[] = {
273  };
274  int ret;
275 
277  if (!layouts)
278  return AVERROR(ENOMEM);
280  if (ret < 0)
281  return ret;
282 
284  if (!formats)
285  return AVERROR(ENOMEM);
287  if (ret < 0)
288  return ret;
289 
291  if (!formats)
292  return AVERROR(ENOMEM);
294 }
295 
297 {
298  ACrusherContext *s = ctx->priv;
299 
300  av_freep(&s->sr);
301 }
302 
304 {
305  AVFilterContext *ctx = inlink->dst;
306  ACrusherContext *s = ctx->priv;
307  double rad, sunder, smax, sover;
308 
309  s->idc = 1. / s->dc;
310  s->coeff = exp2(s->bits) - 1;
311  s->sqr = sqrt(s->coeff / 2);
312  s->aa1 = (1. - s->aa) / 2.;
313  s->round = round(s->samples);
314  rad = s->lforange / 2.;
315  s->smin = FFMAX(s->samples - rad, 1.);
316  sunder = s->samples - rad - s->smin;
317  smax = FFMIN(s->samples + rad, 250.);
318  sover = s->samples + rad - smax;
319  smax -= sunder;
320  s->smin -= sover;
321  s->sdiff = smax - s->smin;
322 
323  s->lfo.freq = s->lforate;
324  s->lfo.pwidth = 1.;
325  s->lfo.srate = inlink->sample_rate;
326  s->lfo.amount = .5;
327 
328  s->sr = av_calloc(inlink->channels, sizeof(*s->sr));
329  if (!s->sr)
330  return AVERROR(ENOMEM);
331 
332  return 0;
333 }
334 
336  {
337  .name = "default",
338  .type = AVMEDIA_TYPE_AUDIO,
339  .config_props = config_input,
340  .filter_frame = filter_frame,
341  },
342  { NULL }
343 };
344 
346  {
347  .name = "default",
348  .type = AVMEDIA_TYPE_AUDIO,
349  },
350  { NULL }
351 };
352 
354  .name = "acrusher",
355  .description = NULL_IF_CONFIG_SMALL("Reduce audio bit resolution."),
356  .priv_size = sizeof(ACrusherContext),
357  .priv_class = &acrusher_class,
358  .uninit = uninit,
362 };
formats
formats
Definition: signature.h:48
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:86
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
mix
static int mix(int c0, int c1)
Definition: 4xm.c:714
AVERROR
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
opt.h
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:300
out
FILE * out
Definition: movenc.c:54
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_acrusher.c:266
ff_set_common_channel_layouts
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates.
Definition: formats.c:586
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1075
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:716
factor
static double factor(double y, double k, double aa1, double aa)
Definition: af_acrusher.c:118
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
ACrusherContext::sov
double sov
Definition: af_acrusher.c:62
inlink
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
Definition: filter_design.txt:212
lfo_get
static double lfo_get(LFOContext *lfo)
Definition: af_acrusher.c:196
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:454
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
M_PI_2
#define M_PI_2
Definition: mathematics.h:55
AVOption
AVOption.
Definition: opt.h:246
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_acrusher.c:216
ACrusherContext::lforange
double lforange
Definition: af_acrusher.c:55
LFOContext::phase
double phase
Definition: af_acrusher.c:32
LFOContext::freq
double freq
Definition: af_acrusher.c:27
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
SRContext
Definition: af_acrusher.c:35
ACrusherContext::coeff
double coeff
Definition: af_acrusher.c:60
roundf
static av_always_inline av_const float roundf(float x)
Definition: libm.h:451
ACrusherContext::bits
double bits
Definition: af_acrusher.c:47
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
ACrusherContext::mix
double mix
Definition: af_acrusher.c:48
LFOContext::amount
double amount
Definition: af_acrusher.c:30
samplereduction
static double samplereduction(ACrusherContext *s, SRContext *sr, double in)
Definition: af_acrusher.c:92
FFSIGN
#define FFSIGN(a)
Definition: common.h:73
val
static double val(void *priv, double ch)
Definition: aeval.c:76
OFFSET
#define OFFSET(x)
Definition: af_acrusher.c:70
LFOContext::srate
int srate
Definition: af_acrusher.c:29
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
av_cold
#define av_cold
Definition: attributes.h:90
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:605
ACrusherContext::sdiff
double sdiff
Definition: af_acrusher.c:64
ACrusherContext::mode
int mode
Definition: af_acrusher.c:49
s
#define s(width, name)
Definition: cbs_vp9.c:257
ACrusherContext::round
int round
Definition: af_acrusher.c:61
ACrusherContext
Definition: af_acrusher.c:42
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:225
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
lfo_advance
static void lfo_advance(LFOContext *lfo, unsigned count)
Definition: af_acrusher.c:209
bits
uint8_t bits
Definition: vp3data.h:202
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ACrusherContext::lfo
LFOContext lfo
Definition: af_acrusher.c:66
LFOContext
Definition: af_acrusher.c:26
if
if(ret)
Definition: filter_design.txt:179
ACrusherContext::level_out
double level_out
Definition: af_acrusher.c:46
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
ACrusherContext::dc
double dc
Definition: af_acrusher.c:50
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:659
add_dc
static double add_dc(double s, double dc, double idc)
Definition: af_acrusher.c:108
SRContext::target
double target
Definition: af_acrusher.c:36
src
#define src
Definition: vp8dsp.c:254
ff_af_acrusher
AVFilter ff_af_acrusher
Definition: af_acrusher.c:353
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
exp
int8_t exp
Definition: eval.c:72
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_acrusher.c:296
dc
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
Definition: snow.txt:400
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:188
avfilter_af_acrusher_inputs
static const AVFilterPad avfilter_af_acrusher_inputs[]
Definition: af_acrusher.c:335
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
sample
#define sample
Definition: flacdsp_template.c:44
SRContext::last
double last
Definition: af_acrusher.c:39
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:595
ACrusherContext::smin
double smin
Definition: af_acrusher.c:63
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(acrusher)
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
ACrusherContext::lforate
double lforate
Definition: af_acrusher.c:56
M_PI
#define M_PI
Definition: mathematics.h:52
internal.h
ACrusherContext::samples
double samples
Definition: af_acrusher.c:53
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
ACrusherContext::sqr
double sqr
Definition: af_acrusher.c:58
avfilter_af_acrusher_outputs
static const AVFilterPad avfilter_af_acrusher_outputs[]
Definition: af_acrusher.c:345
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
LFOContext::offset
double offset
Definition: af_acrusher.c:28
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
exp2
#define exp2(x)
Definition: libm.h:288
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_acrusher.c:303
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
A
#define A
Definition: af_acrusher.c:71
AVFilter
Filter definition.
Definition: avfilter.h:144
ACrusherContext::aa1
double aa1
Definition: af_acrusher.c:59
ret
ret
Definition: filter_design.txt:187
acrusher_options
static const AVOption acrusher_options[]
Definition: af_acrusher.c:73
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:439
ACrusherContext::idc
double idc
Definition: af_acrusher.c:51
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
ACrusherContext::aa
double aa
Definition: af_acrusher.c:52
mode
mode
Definition: ebur128.h:83
ACrusherContext::is_lfo
int is_lfo
Definition: af_acrusher.c:54
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
avfilter.h
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
audio.h
bitreduction
static double bitreduction(ACrusherContext *s, double in)
Definition: af_acrusher.c:123
LFOContext::pwidth
double pwidth
Definition: af_acrusher.c:31
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
remove_dc
static double remove_dc(double s, double dc, double idc)
Definition: af_acrusher.c:113
ACrusherContext::sr
SRContext * sr
Definition: af_acrusher.c:67
coeff
static const double coeff[2][5]
Definition: vf_owdenoise.c:72
ff_set_common_samplerates
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:593
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:64
SRContext::samples
double samples
Definition: af_acrusher.c:38
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
ACrusherContext::level_in
double level_in
Definition: af_acrusher.c:45
SRContext::real
double real
Definition: af_acrusher.c:37