diff options
author | Paul B Mahol <onemda@gmail.com> | 2022-02-27 19:58:06 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2022-02-27 20:05:57 +0100 |
commit | a2dbd1778848c260fc9ef9c903ebc7a3cb67968e (patch) | |
tree | 876657b1ad06a45657af503ca2072f23c8e4784a /libavfilter/af_dynaudnorm.c | |
parent | a9124a75b0a2bce3c810bc5dfd5c2360764c92dd (diff) | |
download | ffmpeg-a2dbd1778848c260fc9ef9c903ebc7a3cb67968e.tar.gz |
avfilter/af_dynaudnorm: allocate new frame instead of making it writable
Later case does not use frame pool at all.
Diffstat (limited to 'libavfilter/af_dynaudnorm.c')
-rw-r--r-- | libavfilter/af_dynaudnorm.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c index 7d779856a8..8015c8429c 100644 --- a/libavfilter/af_dynaudnorm.c +++ b/libavfilter/af_dynaudnorm.c @@ -647,23 +647,42 @@ static void perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame } } -static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame) +static int analyze_frame(DynamicAudioNormalizerContext *s, AVFilterLink *outlink, AVFrame **frame) { if (s->dc_correction || s->compress_factor > DBL_EPSILON) { int ret; - if ((ret = av_frame_make_writable(frame)) < 0) - return ret; + if (!av_frame_is_writable(*frame)) { + AVFrame *out = ff_get_audio_buffer(outlink, (*frame)->nb_samples); + + if (!out) { + av_frame_free(frame); + return AVERROR(ENOMEM); + } + ret = av_frame_copy_props(out, *frame); + if (ret < 0) { + av_frame_free(&out); + return ret; + } + ret = av_frame_copy(out, *frame); + if (ret < 0) { + av_frame_free(&out); + return ret; + } + + av_frame_free(frame); + *frame = out; + } } if (s->dc_correction) - perform_dc_correction(s, frame); + perform_dc_correction(s, *frame); if (s->compress_factor > DBL_EPSILON) - perform_compression(s, frame); + perform_compression(s, *frame); if (s->channels_coupled) { - const local_gain gain = get_max_local_gain(s, frame, -1); + const local_gain gain = get_max_local_gain(s, *frame, -1); int c; for (c = 0; c < s->channels; c++) @@ -672,7 +691,7 @@ static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame) int c; for (c = 0; c < s->channels; c++) - update_gain_history(s, c, get_max_local_gain(s, frame, c)); + update_gain_history(s, c, get_max_local_gain(s, *frame, c)); } return 0; @@ -740,7 +759,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ret; } - ret = analyze_frame(s, in); + ret = analyze_frame(s, outlink, &in); if (ret < 0) return ret; if (!s->eof) { |