History

avfilter/af_afir: split input frames from impulse response frames

Paul B Mahol committed 6 years ago

Commit e364fe41 parent 929e5152 files · +15 −14Browse files

Showing the changes to libavfilter (2 of 2 files). Show all

Unified · Split

2 files
  1. libavfilter/af_afir.c +13 −13
  2. libavfilter/af_afir.h +2 −1
libavfilter/af_afir.c+13−13
@@ -59,7 +59,7 @@ static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t le · 58 unmodified lines
5959 static int fir_quantum(AVFilterContext *ctx, AVFrame *out, int ch, int offset)
6060 {
6161 AudioFIRContext *s = ctx->priv;
62− const float *in = (const float *)s->in[0]->extended_data[ch] + offset;
62+ const float *in = (const float *)s->in->extended_data[ch] + offset;
6363 float *block, *buf, *ptr = (float *)out->extended_data[ch] + offset;
6464 const int nb_samples = FFMIN(s->min_part_size, out->nb_samples - offset);
6565 int n, i, j;
@@ -175,7 +175,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) · 109 unmodified lines
175175
176176 if (s->pts == AV_NOPTS_VALUE)
177177 s->pts = in->pts;
178− s->in[0] = in;
178+ s->in = in;
179179 ctx->internal->execute(ctx, fir_channels, out, NULL, FFMIN(outlink->channels,
180180 ff_filter_get_nb_threads(ctx)));
181181
@@ -184,7 +184,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) · 2 unmodified lines
184184 s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
185185
186186 av_frame_free(&in);
187− s->in[0] = NULL;
187+ s->in = NULL;
188188
189189 return ff_filter_frame(outlink, out);
190190 }
@@ -255,9 +255,9 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out) · 64 unmodified lines
255255 if (!mag || !phase || !delay)
256256 goto end;
257257
258− channel = av_clip(s->ir_channel, 0, s->in[1]->channels - 1);
258+ channel = av_clip(s->ir_channel, 0, s->ir[0]->channels - 1);
259259 for (i = 0; i < s->w; i++) {
260− const float *src = (const float *)s->in[1]->extended_data[channel];
260+ const float *src = (const float *)s->ir[0]->extended_data[channel];
261261 double w = i * M_PI / (s->w - 1);
262262 double div, real_num = 0., imag_num = 0., real = 0., imag = 0.;
263263
@@ -404,7 +404,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 140 unmodified lines
404404 part_size = FFMIN(part_size, max_part_size);
405405 }
406406
407− ret = ff_inlink_consume_samples(ctx->inputs[1], s->nb_taps, s->nb_taps, &s->in[1]);
407+ ret = ff_inlink_consume_samples(ctx->inputs[1], s->nb_taps, s->nb_taps, &s->ir[0]);
408408 if (ret < 0)
409409 return ret;
410410 if (ret == 0)
@@ -421,7 +421,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 10 unmodified lines
421421 break;
422422 case 0:
423423 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
424− float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
424+ float *time = (float *)s->ir[0]->extended_data[!s->one2many * ch];
425425
426426 for (i = 0; i < s->nb_taps; i++)
427427 power += FFABS(time[i]);
@@ -430,7 +430,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 2 unmodified lines
430430 break;
431431 case 1:
432432 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
433− float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
433+ float *time = (float *)s->ir[0]->extended_data[!s->one2many * ch];
434434
435435 for (i = 0; i < s->nb_taps; i++)
436436 power += time[i];
@@ -439,7 +439,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 2 unmodified lines
439439 break;
440440 case 2:
441441 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
442− float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
442+ float *time = (float *)s->ir[0]->extended_data[!s->one2many * ch];
443443
444444 for (i = 0; i < s->nb_taps; i++)
445445 power += time[i] * time[i];
@@ -453,7 +453,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 7 unmodified lines
453453 s->gain = FFMIN(s->gain * s->ir_gain, 1.f);
454454 av_log(ctx, AV_LOG_DEBUG, "power %f, gain %f\n", power, s->gain);
455455 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
456− float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
456+ float *time = (float *)s->ir[0]->extended_data[!s->one2many * ch];
457457
458458 s->fdsp->vector_fmul_scalar(time, time, s->gain, FFALIGN(s->nb_taps, 4));
459459 }
@@ -462,7 +462,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 2 unmodified lines
462462 av_log(ctx, AV_LOG_DEBUG, "nb_segments: %d\n", s->nb_segments);
463463
464464 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {
465− float *time = (float *)s->in[1]->extended_data[!s->one2many * ch];
465+ float *time = (float *)s->ir[0]->extended_data[!s->one2many * ch];
466466 int toffset = 0;
467467
468468 for (i = FFMAX(1, s->length * s->nb_taps); i < s->nb_taps; i++)
@@ -510,7 +510,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 41 unmodified lines
510510 }
511511 }
512512
513− av_frame_free(&s->in[1]);
513+ av_frame_free(&s->ir[0]);
514514 s->have_coeffs = 1;
515515
516516 return 0;
@@ -727,7 +727,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 210 unmodified lines
727727 }
728728
729729 av_freep(&s->fdsp);
730− av_frame_free(&s->in[1]);
730+ av_frame_free(&s->ir[0]);
731731
732732 for (int i = 0; i < ctx->nb_outputs; i++)
733733 av_freep(&ctx->output_pads[i].name);
libavfilter/af_afir.h+2−1
@@ -87,7 +87,8 @@ typedef struct AudioFIRContext { · 86 unmodified lines
8787 AudioFIRSegment seg[1024];
8888 int nb_segments;
8989
90− AVFrame *in[2];
90+ AVFrame *in;
91+ AVFrame *ir[32];
9192 AVFrame *video;
9293 int min_part_size;
9394 int64_t pts;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t