Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -1164,9 +1164,8 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in) · 1163 unmodified lines | ||
| 1164 | 1164 | AudioFFTDeNoiseContext *s = ctx->priv; |
| 1165 | 1165 | const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode; |
| 1166 | 1166 | const int offset = s->window_length - s->sample_advance; |
| 1167 | − AVFrame *out = NULL; | |
| 1167 | + AVFrame *out; | |
| 1168 | 1168 | ThreadData td; |
| 1169 | − int ret = 0; | |
| 1170 | 1169 | |
| 1171 | 1170 | for (int ch = 0; ch < s->channels; ch++) { |
| 1172 | 1171 | float *src = (float *)s->winframe->extended_data[ch]; |
| @@ -1225,10 +1224,16 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in) · 52 unmodified lines | ||
| 1225 | 1224 | ff_filter_execute(ctx, filter_channel, &td, NULL, |
| 1226 | 1225 | FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx))); |
| 1227 | 1226 | |
| 1228 | − out = ff_get_audio_buffer(outlink, in->nb_samples); | |
| 1229 | − if (!out) { | |
| 1230 | − ret = AVERROR(ENOMEM); | |
| 1231 | − goto end; | |
| 1227 | + if (av_frame_is_writable(in)) { | |
| 1228 | + out = in; | |
| 1229 | + } else { | |
| 1230 | + out = ff_get_audio_buffer(outlink, in->nb_samples); | |
| 1231 | + if (!out) { | |
| 1232 | + av_frame_free(&in); | |
| 1233 | + return AVERROR(ENOMEM); | |
| 1234 | + } | |
| 1235 | + | |
| 1236 | + out->pts = in->pts; | |
| 1232 | 1237 | } |
| 1233 | 1238 | |
| 1234 | 1239 | for (int ch = 0; ch < inlink->channels; ch++) { |
| @@ -1251,23 +1256,18 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in) · 16 unmodified lines | ||
| 1251 | 1256 | dst[m] = orig[m] - src[m]; |
| 1252 | 1257 | break; |
| 1253 | 1258 | default: |
| 1259 | + if (in != out) | |
| 1260 | + av_frame_free(&in); | |
| 1254 | 1261 | av_frame_free(&out); |
| 1255 | − ret = AVERROR_BUG; | |
| 1256 | − goto end; | |
| 1262 | + return AVERROR_BUG; | |
| 1257 | 1263 | } |
| 1258 | 1264 | memmove(src, src + s->sample_advance, (s->window_length - s->sample_advance) * sizeof(*src)); |
| 1259 | 1265 | memset(src + (s->window_length - s->sample_advance), 0, s->sample_advance * sizeof(*src)); |
| 1260 | 1266 | } |
| 1261 | 1267 | |
| 1262 | − out->pts = in->pts; | |
| 1263 | − | |
| 1264 | − ret = ff_filter_frame(outlink, out); | |
| 1265 | − if (ret < 0) | |
| 1266 | − goto end; | |
| 1267 | −end: | |
| 1268 | − av_frame_free(&in); | |
| 1269 | − | |
| 1270 | − return ret; | |
| 1268 | + if (out != in) | |
| 1269 | + av_frame_free(&in); | |
| 1270 | + return ff_filter_frame(outlink, out); | |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | static int activate(AVFilterContext *ctx) |