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 | AudioFFTDeNoiseContext *s = ctx->priv; | 1164 | AudioFFTDeNoiseContext *s = ctx->priv; |
| 1165 | const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode; | 1165 | const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode; |
| 1166 | const int offset = s->window_length - s->sample_advance; | 1166 | const int offset = s->window_length - s->sample_advance; |
| 1167 | AVFrame *out = NULL; | 1167 | AVFrame *out; |
| 1168 | ThreadData td; | 1168 | ThreadData td; |
| 1169 | int ret = 0; | ||
| 1170 | 1169 | ||
| 1171 | for (int ch = 0; ch < s->channels; ch++) { | 1170 | for (int ch = 0; ch < s->channels; ch++) { |
| 1172 | float *src = (float *)s->winframe->extended_data[ch]; | 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 | ff_filter_execute(ctx, filter_channel, &td, NULL, | 1224 | ff_filter_execute(ctx, filter_channel, &td, NULL, |
| 1226 | FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx))); | 1225 | FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx))); |
| 1227 | 1226 | ||
| 1228 | out = ff_get_audio_buffer(outlink, in->nb_samples); | 1227 | if (av_frame_is_writable(in)) { |
| 1229 | if (!out) { | 1228 | out = in; |
| 1230 | ret = AVERROR(ENOMEM); | 1229 | } else { |
| 1231 | goto end; | 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 | for (int ch = 0; ch < inlink->channels; ch++) { | 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 | dst[m] = orig[m] - src[m]; | 1256 | dst[m] = orig[m] - src[m]; |
| 1252 | break; | 1257 | break; |
| 1253 | default: | 1258 | default: |
| 1259 | if (in != out) | ||
| 1260 | av_frame_free(&in); | ||
| 1254 | av_frame_free(&out); | 1261 | av_frame_free(&out); |
| 1255 | ret = AVERROR_BUG; | 1262 | return AVERROR_BUG; |
| 1256 | goto end; | ||
| 1257 | } | 1263 | } |
| 1258 | memmove(src, src + s->sample_advance, (s->window_length - s->sample_advance) * sizeof(*src)); | 1264 | memmove(src, src + s->sample_advance, (s->window_length - s->sample_advance) * sizeof(*src)); |
| 1259 | memset(src + (s->window_length - s->sample_advance), 0, s->sample_advance * sizeof(*src)); | 1265 | memset(src + (s->window_length - s->sample_advance), 0, s->sample_advance * sizeof(*src)); |
| 1260 | } | 1266 | } |
| 1261 | 1267 | ||
| 1262 | out->pts = in->pts; | 1268 | if (out != in) |
| 1263 | 1269 | av_frame_free(&in); | |
| 1264 | ret = ff_filter_frame(outlink, out); | 1270 | return ff_filter_frame(outlink, out); |
| 1265 | if (ret < 0) | ||
| 1266 | goto end; | ||
| 1267 | end: | ||
| 1268 | av_frame_free(&in); | ||
| 1269 | |||
| 1270 | return ret; | ||
| 1271 | } | 1271 | } |
| 1272 | 1272 | ||
| 1273 | static int activate(AVFilterContext *ctx) | 1273 | static int activate(AVFilterContext *ctx) |