Unified · Split
| @@ -631,15 +631,20 @@ static void perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame · 630 unmodified lines | |||
| 631 | } | 631 | } |
| 632 | } | 632 | } |
| 633 | 633 | ||
| 634 | static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame) | 634 | static 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 | ||
| 658 | static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *in, | 665 | static 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 | ||
| 728 | static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink, | 739 | static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink, |