Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "libavutil/opt.h" |
| 24 | 24 | #include "avfilter.h" |
| 25 | +#include "filters.h" | |
| 25 | 26 | #include "internal.h" |
| 26 | 27 | #include "audio.h" |
| 27 | 28 | #include "ebur128.h" |
| @@ -502,9 +503,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 474 unmodified lines | ||
| 502 | 503 | ff_ebur128_add_frames_double(s->r128_out, dst, subframe_length); |
| 503 | 504 | |
| 504 | 505 | s->pts += |
| 505 | − out->nb_samples = | |
| 506 | − inlink->min_samples = | |
| 507 | − inlink->max_samples = subframe_length; | |
| 506 | + out->nb_samples = subframe_length; | |
| 508 | 507 | |
| 509 | 508 | s->frame_type = INNER_FRAME; |
| 510 | 509 | break; |
| @@ -636,15 +635,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 125 unmodified lines | ||
| 636 | 635 | return ff_filter_frame(outlink, out); |
| 637 | 636 | } |
| 638 | 637 | |
| 639 | −static int request_frame(AVFilterLink *outlink) | |
| 638 | +static int flush_frame(AVFilterLink *outlink) | |
| 640 | 639 | { |
| 641 | − int ret; | |
| 642 | 640 | AVFilterContext *ctx = outlink->src; |
| 643 | 641 | AVFilterLink *inlink = ctx->inputs[0]; |
| 644 | 642 | LoudNormContext *s = ctx->priv; |
| 643 | + int ret = 0; | |
| 645 | 644 | |
| 646 | − ret = ff_request_frame(inlink); | |
| 647 | − if (ret == AVERROR_EOF && s->frame_type == INNER_FRAME) { | |
| 645 | + if (s->frame_type == INNER_FRAME) { | |
| 648 | 646 | double *src; |
| 649 | 647 | double *buf; |
| 650 | 648 | int nb_samples, n, c, offset; |
| @@ -681,6 +679,48 @@ static int request_frame(AVFilterLink *outlink) · 30 unmodified lines | ||
| 681 | 679 | return ret; |
| 682 | 680 | } |
| 683 | 681 | |
| 682 | +static int activate(AVFilterContext *ctx) | |
| 683 | +{ | |
| 684 | + AVFilterLink *inlink = ctx->inputs[0]; | |
| 685 | + AVFilterLink *outlink = ctx->outputs[0]; | |
| 686 | + LoudNormContext *s = ctx->priv; | |
| 687 | + AVFrame *in = NULL; | |
| 688 | + int ret = 0, status; | |
| 689 | + int64_t pts; | |
| 690 | + | |
| 691 | + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); | |
| 692 | + | |
| 693 | + if (s->frame_type != LINEAR_MODE) { | |
| 694 | + int nb_samples; | |
| 695 | + | |
| 696 | + if (s->frame_type == FIRST_FRAME) { | |
| 697 | + nb_samples = frame_size(inlink->sample_rate, 3000); | |
| 698 | + } else { | |
| 699 | + nb_samples = frame_size(inlink->sample_rate, 100); | |
| 700 | + } | |
| 701 | + | |
| 702 | + ret = ff_inlink_consume_samples(inlink, nb_samples, nb_samples, &in); | |
| 703 | + } else { | |
| 704 | + ret = ff_inlink_consume_frame(inlink, &in); | |
| 705 | + } | |
| 706 | + | |
| 707 | + if (ret < 0) | |
| 708 | + return ret; | |
| 709 | + if (ret > 0) | |
| 710 | + ret = filter_frame(inlink, in); | |
| 711 | + if (ret < 0) | |
| 712 | + return ret; | |
| 713 | + | |
| 714 | + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { | |
| 715 | + ff_outlink_set_status(outlink, status, pts); | |
| 716 | + return flush_frame(outlink); | |
| 717 | + } | |
| 718 | + | |
| 719 | + FF_FILTER_FORWARD_WANTED(outlink, inlink); | |
| 720 | + | |
| 721 | + return FFERROR_NOT_READY; | |
| 722 | +} | |
| 723 | + | |
| 684 | 724 | static int query_formats(AVFilterContext *ctx) |
| 685 | 725 | { |
| 686 | 726 | LoudNormContext *s = ctx->priv; |
| @@ -749,11 +789,6 @@ static int config_input(AVFilterLink *inlink) · 62 unmodified lines | ||
| 749 | 789 | |
| 750 | 790 | init_gaussian_filter(s); |
| 751 | 791 | |
| 752 | − if (s->frame_type != LINEAR_MODE) { | |
| 753 | − inlink->min_samples = | |
| 754 | − inlink->max_samples = frame_size(inlink->sample_rate, 3000); | |
| 755 | − } | |
| 756 | − | |
| 757 | 792 | s->pts = AV_NOPTS_VALUE; |
| 758 | 793 | s->buf_index = |
| 759 | 794 | s->prev_buf_index = |
| @@ -894,14 +929,12 @@ static const AVFilterPad avfilter_af_loudnorm_inputs[] = { · 134 unmodified lines | ||
| 894 | 929 | .name = "default", |
| 895 | 930 | .type = AVMEDIA_TYPE_AUDIO, |
| 896 | 931 | .config_props = config_input, |
| 897 | − .filter_frame = filter_frame, | |
| 898 | 932 | }, |
| 899 | 933 | }; |
| 900 | 934 | |
| 901 | 935 | static const AVFilterPad avfilter_af_loudnorm_outputs[] = { |
| 902 | 936 | { |
| 903 | 937 | .name = "default", |
| 904 | − .request_frame = request_frame, | |
| 905 | 938 | .type = AVMEDIA_TYPE_AUDIO, |
| 906 | 939 | }, |
| 907 | 940 | }; |
| @@ -912,6 +945,7 @@ const AVFilter ff_af_loudnorm = { · 4 unmodified lines | ||
| 912 | 945 | .priv_size = sizeof(LoudNormContext), |
| 913 | 946 | .priv_class = &loudnorm_class, |
| 914 | 947 | .init = init, |
| 948 | + .activate = activate, | |
| 915 | 949 | .uninit = uninit, |
| 916 | 950 | FILTER_INPUTS(avfilter_af_loudnorm_inputs), |
| 917 | 951 | FILTER_OUTPUTS(avfilter_af_loudnorm_outputs), |