History

avfilter/af_dynaudnorm: make frame writable if it may be changed

Paul B Mahol committed 4 years ago

Commit b9f91a71 parent b15c26a1 file · +19 −8Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/af_dynaudnorm.c+19−8
@@ -631,15 +631,20 @@ static void perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame · 630 unmodified lines
631631 }
632632 }
633633
634−static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
634+static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
635635 {
636− if (s->dc_correction) {
637− perform_dc_correction(s, frame);
636+ if (s->dc_correction || s->compress_factor > DBL_EPSILON) {
637+ int ret;
638+
639+ if ((ret = av_frame_make_writable(frame)) < 0)
640+ return ret;
638641 }
639642
640− if (s->compress_factor > DBL_EPSILON) {
643+ if (s->dc_correction)
644+ perform_dc_correction(s, frame);
645+
646+ if (s->compress_factor > DBL_EPSILON)
641647 perform_compression(s, frame);
642− }
643648
644649 if (s->channels_coupled) {
645650 const local_gain gain = get_max_local_gain(s, frame, -1);
@@ -653,6 +658,8 @@ static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame) · 7 unmodified lines
653658 for (c = 0; c < s->channels; c++)
654659 update_gain_history(s, c, get_max_local_gain(s, frame, c));
655660 }
661+
662+ return 0;
656663 }
657664
658665 static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *in,
@@ -684,7 +691,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 25 unmodified lines
684691 AVFilterContext *ctx = inlink->dst;
685692 DynamicAudioNormalizerContext *s = ctx->priv;
686693 AVFilterLink *outlink = ctx->outputs[0];
687− int ret = 1;
694+ int ret;
688695
689696 while (((s->queue.available >= s->filter_size) ||
690697 (s->eof && s->queue.available)) &&
@@ -712,9 +719,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 21 unmodified lines
712719 if (out != in)
713720 av_frame_free(&in);
714721 ret = ff_filter_frame(outlink, out);
722+ if (ret < 0)
723+ return ret;
715724 }
716725
717− analyze_frame(s, in);
726+ ret = analyze_frame(s, in);
727+ if (ret < 0)
728+ return ret;
718729 if (!s->eof) {
719730 ff_bufqueue_add(ctx, &s->queue, in);
720731 cqueue_enqueue(s->is_enabled, !ctx->is_disabled);
@@ -722,7 +733,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 1 unmodified line
722733 av_frame_free(&in);
723734 }
724735
725− return ret;
736+ return 1;
726737 }
727738
728739 static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t