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
631 }631 }
632}632}
633 633
634static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)634static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
635{635{
636 if (s->dc_correction) {636 if (s->dc_correction || s->compress_factor > DBL_EPSILON) {
637 perform_dc_correction(s, frame);637 int ret;
638
639 if ((ret = av_frame_make_writable(frame)) < 0)
640 return ret;
638 }641 }
639 642
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)
641 perform_compression(s, frame);647 perform_compression(s, frame);
642 }
643 648
644 if (s->channels_coupled) {649 if (s->channels_coupled) {
645 const local_gain gain = get_max_local_gain(s, frame, -1);650 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
653 for (c = 0; c < s->channels; c++)658 for (c = 0; c < s->channels; c++)
654 update_gain_history(s, c, get_max_local_gain(s, frame, c));659 update_gain_history(s, c, get_max_local_gain(s, frame, c));
655 }660 }
661
662 return 0;
656}663}
657 664
658static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *in,665static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *in,
@@ -684,7 +691,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 25 unmodified lines
684 AVFilterContext *ctx = inlink->dst;691 AVFilterContext *ctx = inlink->dst;
685 DynamicAudioNormalizerContext *s = ctx->priv;692 DynamicAudioNormalizerContext *s = ctx->priv;
686 AVFilterLink *outlink = ctx->outputs[0];693 AVFilterLink *outlink = ctx->outputs[0];
687 int ret = 1;694 int ret;
688 695
689 while (((s->queue.available >= s->filter_size) ||696 while (((s->queue.available >= s->filter_size) ||
690 (s->eof && s->queue.available)) &&697 (s->eof && s->queue.available)) &&
@@ -712,9 +719,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 21 unmodified lines
712 if (out != in)719 if (out != in)
713 av_frame_free(&in);720 av_frame_free(&in);
714 ret = ff_filter_frame(outlink, out);721 ret = ff_filter_frame(outlink, out);
722 if (ret < 0)
723 return ret;
715 }724 }
716 725
717 analyze_frame(s, in);726 ret = analyze_frame(s, in);
727 if (ret < 0)
728 return ret;
718 if (!s->eof) {729 if (!s->eof) {
719 ff_bufqueue_add(ctx, &s->queue, in);730 ff_bufqueue_add(ctx, &s->queue, in);
720 cqueue_enqueue(s->is_enabled, !ctx->is_disabled);731 cqueue_enqueue(s->is_enabled, !ctx->is_disabled);
@@ -722,7 +733,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 1 unmodified line
722 av_frame_free(&in);733 av_frame_free(&in);
723 }734 }
724 735
725 return ret;736 return 1;
726}737}
727 738
728static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink,739static 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