[FFmpeg-cvslog] avfilter/af_dynaudnorm: make frame writable if it may be changed
Paul B Mahol
git at videolan.org
Sun Feb 27 19:47:30 EET 2022
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Feb 27 18:46:03 2022 +0100| [b9f91a7cbcf12564ea5205af0bd462dc3541ce40] | committer: Paul B Mahol
avfilter/af_dynaudnorm: make frame writable if it may be changed
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9f91a7cbcf12564ea5205af0bd462dc3541ce40
---
libavfilter/af_dynaudnorm.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 121a3ef5d7..4935b09d08 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -631,15 +631,20 @@ static void perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame
}
}
-static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
+static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
{
- if (s->dc_correction) {
- perform_dc_correction(s, frame);
+ if (s->dc_correction || s->compress_factor > DBL_EPSILON) {
+ int ret;
+
+ if ((ret = av_frame_make_writable(frame)) < 0)
+ return ret;
}
- if (s->compress_factor > DBL_EPSILON) {
+ if (s->dc_correction)
+ perform_dc_correction(s, frame);
+
+ if (s->compress_factor > DBL_EPSILON)
perform_compression(s, frame);
- }
if (s->channels_coupled) {
const local_gain gain = get_max_local_gain(s, frame, -1);
@@ -653,6 +658,8 @@ static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
for (c = 0; c < s->channels; c++)
update_gain_history(s, c, get_max_local_gain(s, frame, c));
}
+
+ return 0;
}
static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *in,
@@ -684,7 +691,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterContext *ctx = inlink->dst;
DynamicAudioNormalizerContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
- int ret = 1;
+ int ret;
while (((s->queue.available >= s->filter_size) ||
(s->eof && s->queue.available)) &&
@@ -712,9 +719,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if (out != in)
av_frame_free(&in);
ret = ff_filter_frame(outlink, out);
+ if (ret < 0)
+ return ret;
}
- analyze_frame(s, in);
+ ret = analyze_frame(s, in);
+ if (ret < 0)
+ return ret;
if (!s->eof) {
ff_bufqueue_add(ctx, &s->queue, in);
cqueue_enqueue(s->is_enabled, !ctx->is_disabled);
@@ -722,7 +733,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
av_frame_free(&in);
}
- return ret;
+ return 1;
}
static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink,
More information about the ffmpeg-cvslog
mailing list