Showing the changes to libavfilter (1 of 1 file). Show all
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) { | |
| 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; | |
| 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 | 647 | perform_compression(s, frame); |
| 642 | − } | |
| 643 | 648 | |
| 644 | 649 | if (s->channels_coupled) { |
| 645 | 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 | 658 | for (c = 0; c < s->channels; c++) |
| 654 | 659 | update_gain_history(s, c, get_max_local_gain(s, frame, c)); |
| 655 | 660 | } |
| 661 | + | |
| 662 | + return 0; | |
| 656 | 663 | } |
| 657 | 664 | |
| 658 | 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 | 691 | AVFilterContext *ctx = inlink->dst; |
| 685 | 692 | DynamicAudioNormalizerContext *s = ctx->priv; |
| 686 | 693 | AVFilterLink *outlink = ctx->outputs[0]; |
| 687 | − int ret = 1; | |
| 694 | + int ret; | |
| 688 | 695 | |
| 689 | 696 | while (((s->queue.available >= s->filter_size) || |
| 690 | 697 | (s->eof && s->queue.available)) && |
| @@ -712,9 +719,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 21 unmodified lines | ||
| 712 | 719 | if (out != in) |
| 713 | 720 | av_frame_free(&in); |
| 714 | 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 | 729 | if (!s->eof) { |
| 719 | 730 | ff_bufqueue_add(ctx, &s->queue, in); |
| 720 | 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 | 733 | av_frame_free(&in); |
| 723 | 734 | } |
| 724 | 735 | |
| 725 | − return ret; | |
| 736 | + return 1; | |
| 726 | 737 | } |
| 727 | 738 | |
| 728 | 739 | static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink, |