avfilter/af_afftdn: add support for writable input frames
This commit is contained in:
parent
df272928ff
commit
2cb482aa74
@ -1164,9 +1164,8 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
AudioFFTDeNoiseContext *s = ctx->priv;
|
AudioFFTDeNoiseContext *s = ctx->priv;
|
||||||
const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode;
|
const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode;
|
||||||
const int offset = s->window_length - s->sample_advance;
|
const int offset = s->window_length - s->sample_advance;
|
||||||
AVFrame *out = NULL;
|
AVFrame *out;
|
||||||
ThreadData td;
|
ThreadData td;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (int ch = 0; ch < s->channels; ch++) {
|
for (int ch = 0; ch < s->channels; ch++) {
|
||||||
float *src = (float *)s->winframe->extended_data[ch];
|
float *src = (float *)s->winframe->extended_data[ch];
|
||||||
@ -1225,10 +1224,16 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
ff_filter_execute(ctx, filter_channel, &td, NULL,
|
ff_filter_execute(ctx, filter_channel, &td, NULL,
|
||||||
FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx)));
|
FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx)));
|
||||||
|
|
||||||
out = ff_get_audio_buffer(outlink, in->nb_samples);
|
if (av_frame_is_writable(in)) {
|
||||||
if (!out) {
|
out = in;
|
||||||
ret = AVERROR(ENOMEM);
|
} else {
|
||||||
goto end;
|
out = ff_get_audio_buffer(outlink, in->nb_samples);
|
||||||
|
if (!out) {
|
||||||
|
av_frame_free(&in);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
out->pts = in->pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ch = 0; ch < inlink->channels; ch++) {
|
for (int ch = 0; ch < inlink->channels; ch++) {
|
||||||
@ -1251,23 +1256,18 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
dst[m] = orig[m] - src[m];
|
dst[m] = orig[m] - src[m];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (in != out)
|
||||||
|
av_frame_free(&in);
|
||||||
av_frame_free(&out);
|
av_frame_free(&out);
|
||||||
ret = AVERROR_BUG;
|
return AVERROR_BUG;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
memmove(src, src + s->sample_advance, (s->window_length - s->sample_advance) * sizeof(*src));
|
memmove(src, src + s->sample_advance, (s->window_length - s->sample_advance) * sizeof(*src));
|
||||||
memset(src + (s->window_length - s->sample_advance), 0, s->sample_advance * sizeof(*src));
|
memset(src + (s->window_length - s->sample_advance), 0, s->sample_advance * sizeof(*src));
|
||||||
}
|
}
|
||||||
|
|
||||||
out->pts = in->pts;
|
if (out != in)
|
||||||
|
av_frame_free(&in);
|
||||||
ret = ff_filter_frame(outlink, out);
|
return ff_filter_frame(outlink, out);
|
||||||
if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
end:
|
|
||||||
av_frame_free(&in);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int activate(AVFilterContext *ctx)
|
static int activate(AVFilterContext *ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user