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
59static int fir_quantum(AVFilterContext *ctx, AVFrame *out, int ch, int offset)59static int fir_quantum(AVFilterContext *ctx, AVFrame *out, int ch, int offset)
60{60{
61 AudioFIRContext *s = ctx->priv;61 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;
63 float *block, *buf, *ptr = (float *)out->extended_data[ch] + offset;63 float *block, *buf, *ptr = (float *)out->extended_data[ch] + offset;
64 const int nb_samples = FFMIN(s->min_part_size, out->nb_samples - offset);64 const int nb_samples = FFMIN(s->min_part_size, out->nb_samples - offset);
65 int n, i, j;65 int n, i, j;
@@ -175,7 +175,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) · 109 unmodified lines
175 175
176 if (s->pts == AV_NOPTS_VALUE)176 if (s->pts == AV_NOPTS_VALUE)
177 s->pts = in->pts;177 s->pts = in->pts;
178 s->in[0] = in;178 s->in = in;
179 ctx->internal->execute(ctx, fir_channels, out, NULL, FFMIN(outlink->channels,179 ctx->internal->execute(ctx, fir_channels, out, NULL, FFMIN(outlink->channels,
180 ff_filter_get_nb_threads(ctx)));180 ff_filter_get_nb_threads(ctx)));
181 181
@@ -184,7 +184,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) · 2 unmodified lines
184 s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);184 s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
185 185
186 av_frame_free(&in);186 av_frame_free(&in);
187 s->in[0] = NULL;187 s->in = NULL;
188 188
189 return ff_filter_frame(outlink, out);189 return ff_filter_frame(outlink, out);
190}190}
@@ -255,9 +255,9 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out) · 64 unmodified lines
255 if (!mag || !phase || !delay)255 if (!mag || !phase || !delay)
256 goto end;256 goto end;
257 257
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);
259 for (i = 0; i < s->w; i++) {259 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];
261 double w = i * M_PI / (s->w - 1);261 double w = i * M_PI / (s->w - 1);
262 double div, real_num = 0., imag_num = 0., real = 0., imag = 0.;262 double div, real_num = 0., imag_num = 0., real = 0., imag = 0.;
263 263
@@ -404,7 +404,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 140 unmodified lines
404 part_size = FFMIN(part_size, max_part_size);404 part_size = FFMIN(part_size, max_part_size);
405 }405 }
406 406
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]);
408 if (ret < 0)408 if (ret < 0)
409 return ret;409 return ret;
410 if (ret == 0)410 if (ret == 0)
@@ -421,7 +421,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 10 unmodified lines
421 break;421 break;
422 case 0:422 case 0:
423 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {423 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];
425 425
426 for (i = 0; i < s->nb_taps; i++)426 for (i = 0; i < s->nb_taps; i++)
427 power += FFABS(time[i]);427 power += FFABS(time[i]);
@@ -430,7 +430,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 2 unmodified lines
430 break;430 break;
431 case 1:431 case 1:
432 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {432 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];
434 434
435 for (i = 0; i < s->nb_taps; i++)435 for (i = 0; i < s->nb_taps; i++)
436 power += time[i];436 power += time[i];
@@ -439,7 +439,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 2 unmodified lines
439 break;439 break;
440 case 2:440 case 2:
441 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {441 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];
443 443
444 for (i = 0; i < s->nb_taps; i++)444 for (i = 0; i < s->nb_taps; i++)
445 power += time[i] * time[i];445 power += time[i] * time[i];
@@ -453,7 +453,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 7 unmodified lines
453 s->gain = FFMIN(s->gain * s->ir_gain, 1.f);453 s->gain = FFMIN(s->gain * s->ir_gain, 1.f);
454 av_log(ctx, AV_LOG_DEBUG, "power %f, gain %f\n", power, s->gain);454 av_log(ctx, AV_LOG_DEBUG, "power %f, gain %f\n", power, s->gain);
455 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {455 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];
457 457
458 s->fdsp->vector_fmul_scalar(time, time, s->gain, FFALIGN(s->nb_taps, 4));458 s->fdsp->vector_fmul_scalar(time, time, s->gain, FFALIGN(s->nb_taps, 4));
459 }459 }
@@ -462,7 +462,7 @@ static int convert_coeffs(AVFilterContext *ctx) · 2 unmodified lines
462 av_log(ctx, AV_LOG_DEBUG, "nb_segments: %d\n", s->nb_segments);462 av_log(ctx, AV_LOG_DEBUG, "nb_segments: %d\n", s->nb_segments);
463 463
464 for (ch = 0; ch < ctx->inputs[1]->channels; ch++) {464 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];
466 int toffset = 0;466 int toffset = 0;
467 467
468 for (i = FFMAX(1, s->length * s->nb_taps); i < s->nb_taps; i++)468 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
510 }510 }
511 }511 }
512 512
513 av_frame_free(&s->in[1]);513 av_frame_free(&s->ir[0]);
514 s->have_coeffs = 1;514 s->have_coeffs = 1;
515 515
516 return 0;516 return 0;
@@ -727,7 +727,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 210 unmodified lines
727 }727 }
728 728
729 av_freep(&s->fdsp);729 av_freep(&s->fdsp);
730 av_frame_free(&s->in[1]);730 av_frame_free(&s->ir[0]);
731 731
732 for (int i = 0; i < ctx->nb_outputs; i++)732 for (int i = 0; i < ctx->nb_outputs; i++)
733 av_freep(&ctx->output_pads[i].name);733 av_freep(&ctx->output_pads[i].name);
libavfilter/af_afir.h+2−1
@@ -87,7 +87,8 @@ typedef struct AudioFIRContext { · 86 unmodified lines
87 AudioFIRSegment seg[1024];87 AudioFIRSegment seg[1024];
88 int nb_segments;88 int nb_segments;
89 89
90 AVFrame *in[2];90 AVFrame *in;
91 AVFrame *ir[32];
91 AVFrame *video;92 AVFrame *video;
92 int min_part_size;93 int min_part_size;
93 int64_t pts;94 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