Also, document who sets these fields and when.
Showing the changes to libavfilter (7 of 7 files). Show all
Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | #include "libavutil/avassert.h" | 26 | #include "libavutil/avassert.h" |
| 27 | #include "libavutil/tx.h" | 27 | #include "libavutil/tx.h" |
| 28 | #include "avfilter.h" | 28 | #include "avfilter.h" |
| 29 | #include "filters.h" | ||
| 29 | #include "internal.h" | 30 | #include "internal.h" |
| 30 | #include "audio.h" | 31 | #include "audio.h" |
| 31 | 32 | ||
| @@ -725,6 +726,7 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g · 693 unmodified lines | |||
| 725 | 726 | ||
| 726 | static int config_input(AVFilterLink *inlink) | 727 | static int config_input(AVFilterLink *inlink) |
| 727 | { | 728 | { |
| 729 | FilterLink *l = ff_filter_link(inlink); | ||
| 728 | AVFilterContext *ctx = inlink->dst; | 730 | AVFilterContext *ctx = inlink->dst; |
| 729 | FIREqualizerContext *s = ctx->priv; | 731 | FIREqualizerContext *s = ctx->priv; |
| 730 | float iscale, scale = 1.f; | 732 | float iscale, scale = 1.f; |
| @@ -824,7 +826,7 @@ static int config_input(AVFilterLink *inlink) · 93 unmodified lines | |||
| 824 | inlink->sample_rate, inlink->ch_layout.nb_channels, s->analysis_rdft_len, s->rdft_len, s->fir_len, s->nsamples_max); | 826 | inlink->sample_rate, inlink->ch_layout.nb_channels, s->analysis_rdft_len, s->rdft_len, s->fir_len, s->nsamples_max); |
| 825 | 827 | ||
| 826 | if (s->fixed) | 828 | if (s->fixed) |
| 827 | inlink->min_samples = inlink->max_samples = s->nsamples_max; | 829 | l->min_samples = l->max_samples = s->nsamples_max; |
| 828 | 830 | ||
| 829 | return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s)); | 831 | return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s)); |
| 830 | } | 832 | } |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | |||
| 34 | #include "libavutil/opt.h" | 34 | #include "libavutil/opt.h" |
| 35 | #include "audio.h" | 35 | #include "audio.h" |
| 36 | #include "avfilter.h" | 36 | #include "avfilter.h" |
| 37 | #include "filters.h" | ||
| 37 | #include "formats.h" | 38 | #include "formats.h" |
| 38 | #include "internal.h" | 39 | #include "internal.h" |
| 39 | 40 | ||
| @@ -381,7 +382,7 @@ static int config_output(AVFilterLink *outlink) · 341 unmodified lines | |||
| 381 | (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength) || | 382 | (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength) || |
| 382 | lilv_plugin_has_feature(s->plugin, s->fixedBlockLength) || | 383 | lilv_plugin_has_feature(s->plugin, s->fixedBlockLength) || |
| 383 | lilv_plugin_has_feature(s->plugin, s->boundedBlockLength))) { | 384 | lilv_plugin_has_feature(s->plugin, s->boundedBlockLength))) { |
| 384 | AVFilterLink *inlink = ctx->inputs[0]; | 385 | FilterLink *inlink = ff_filter_link(ctx->inputs[0]); |
| 385 | 386 | ||
| 386 | inlink->min_samples = inlink->max_samples = 4096; | 387 | inlink->min_samples = inlink->max_samples = 4096; |
| 387 | } | 388 | } |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | |||
| 30 | #include "libavutil/opt.h" | 30 | #include "libavutil/opt.h" |
| 31 | #include "audio.h" | 31 | #include "audio.h" |
| 32 | #include "avfilter.h" | 32 | #include "avfilter.h" |
| 33 | #include "filters.h" | ||
| 33 | #include "formats.h" | 34 | #include "formats.h" |
| 34 | #include "internal.h" | 35 | #include "internal.h" |
| 35 | 36 | ||
| @@ -349,6 +350,7 @@ static int query_formats(AVFilterContext *ctx) · 313 unmodified lines | |||
| 349 | 350 | ||
| 350 | static int config_input(AVFilterLink *inlink) | 351 | static int config_input(AVFilterLink *inlink) |
| 351 | { | 352 | { |
| 353 | FilterLink *l = ff_filter_link(inlink); | ||
| 352 | AVFilterContext *ctx = inlink->dst; | 354 | AVFilterContext *ctx = inlink->dst; |
| 353 | ReplayGainContext *s = ctx->priv; | 355 | ReplayGainContext *s = ctx->priv; |
| 354 | int i; | 356 | int i; |
| @@ -366,8 +368,8 @@ static int config_input(AVFilterLink *inlink) · 11 unmodified lines | |||
| 366 | 368 | ||
| 367 | s->yule_hist_i = 20; | 369 | s->yule_hist_i = 20; |
| 368 | s->butter_hist_i = 4; | 370 | s->butter_hist_i = 4; |
| 369 | inlink->min_samples = | 371 | l->min_samples = |
| 370 | inlink->max_samples = inlink->sample_rate / 20; | 372 | l->max_samples = inlink->sample_rate / 20; |
| 371 | 373 | ||
| 372 | return 0; | 374 | return 0; |
| 373 | } | 375 | } |
| @@ -1077,14 +1077,15 @@ static int samples_ready(FilterLinkInternal *link, unsigned min) · 1076 unmodified lines | |||
| 1077 | static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max, | 1077 | static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max, |
| 1078 | AVFrame **rframe) | 1078 | AVFrame **rframe) |
| 1079 | { | 1079 | { |
| 1080 | AVFilterLink *link = &li->l.pub; | 1080 | FilterLink *l = &li->l; |
| 1081 | AVFilterLink *link = &l->pub; | ||
| 1081 | AVFrame *frame0, *frame, *buf; | 1082 | AVFrame *frame0, *frame, *buf; |
| 1082 | unsigned nb_samples, nb_frames, i, p; | 1083 | unsigned nb_samples, nb_frames, i, p; |
| 1083 | int ret; | 1084 | int ret; |
| 1084 | 1085 | ||
| 1085 | /* Note: this function relies on no format changes and must only be | 1086 | /* Note: this function relies on no format changes and must only be |
| 1086 | called with enough samples. */ | 1087 | called with enough samples. */ |
| 1087 | av_assert1(samples_ready(li, link->min_samples)); | 1088 | av_assert1(samples_ready(li, l->min_samples)); |
| 1088 | frame0 = frame = ff_framequeue_peek(&li->fifo, 0); | 1089 | frame0 = frame = ff_framequeue_peek(&li->fifo, 0); |
| 1089 | if (!li->fifo.samples_skipped && frame->nb_samples >= min && frame->nb_samples <= max) { | 1090 | if (!li->fifo.samples_skipped && frame->nb_samples >= min && frame->nb_samples <= max) { |
| 1090 | *rframe = ff_framequeue_take(&li->fifo); | 1091 | *rframe = ff_framequeue_take(&li->fifo); |
| @@ -1142,8 +1143,8 @@ static int ff_filter_frame_to_filter(AVFilterLink *link) · 51 unmodified lines | |||
| 1142 | int ret; | 1143 | int ret; |
| 1143 | 1144 | ||
| 1144 | av_assert1(ff_framequeue_queued_frames(&li->fifo)); | 1145 | av_assert1(ff_framequeue_queued_frames(&li->fifo)); |
| 1145 | ret = link->min_samples ? | 1146 | ret = li->l.min_samples ? |
| 1146 | ff_inlink_consume_samples(link, link->min_samples, link->max_samples, &frame) : | 1147 | ff_inlink_consume_samples(link, li->l.min_samples, li->l.max_samples, &frame) : |
| 1147 | ff_inlink_consume_frame(link, &frame); | 1148 | ff_inlink_consume_frame(link, &frame); |
| 1148 | av_assert1(ret); | 1149 | av_assert1(ret); |
| 1149 | if (ret < 0) { | 1150 | if (ret < 0) { |
| @@ -1218,8 +1219,8 @@ static int ff_filter_activate_default(AVFilterContext *filter) · 68 unmodified lines | |||
| 1218 | } | 1219 | } |
| 1219 | 1220 | ||
| 1220 | for (i = 0; i < filter->nb_inputs; i++) { | 1221 | for (i = 0; i < filter->nb_inputs; i++) { |
| 1221 | if (samples_ready(ff_link_internal(filter->inputs[i]), | 1222 | FilterLinkInternal *li = ff_link_internal(filter->inputs[i]); |
| 1222 | filter->inputs[i]->min_samples)) { | 1223 | if (samples_ready(li, li->l.min_samples)) { |
| 1223 | return ff_filter_frame_to_filter(filter->inputs[i]); | 1224 | return ff_filter_frame_to_filter(filter->inputs[i]); |
| 1224 | } | 1225 | } |
| 1225 | } | 1226 | } |
| @@ -625,21 +625,6 @@ struct AVFilterLink { · 624 unmodified lines | |||
| 625 | */ | 625 | */ |
| 626 | AVRational frame_rate; | 626 | AVRational frame_rate; |
| 627 | 627 | ||
| 628 | /** | ||
| 629 | * Minimum number of samples to filter at once. If filter_frame() is | ||
| 630 | * called with fewer samples, it will accumulate them in fifo. | ||
| 631 | * This field and the related ones must not be changed after filtering | ||
| 632 | * has started. | ||
| 633 | * If 0, all related fields are ignored. | ||
| 634 | */ | ||
| 635 | int min_samples; | ||
| 636 | |||
| 637 | /** | ||
| 638 | * Maximum number of samples to filter at once. If filter_frame() is | ||
| 639 | * called with more samples, it will split them. | ||
| 640 | */ | ||
| 641 | int max_samples; | ||
| 642 | |||
| 643 | /** | 628 | /** |
| 644 | * Number of past frames sent through the link. | 629 | * Number of past frames sent through the link. |
| 645 | */ | 630 | */ |
| @@ -119,7 +119,8 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i · 118 unmodified lines | |||
| 119 | 119 | ||
| 120 | int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags) | 120 | int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags) |
| 121 | { | 121 | { |
| 122 | return get_frame_internal(ctx, frame, flags, ctx->inputs[0]->min_samples); | 122 | return get_frame_internal(ctx, frame, flags, |
| 123 | ff_filter_link(ctx->inputs[0])->min_samples); | ||
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx, | 126 | int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx, |
| @@ -163,7 +164,7 @@ static int activate(AVFilterContext *ctx) · 37 unmodified lines | |||
| 163 | 164 | ||
| 164 | void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size) | 165 | void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size) |
| 165 | { | 166 | { |
| 166 | AVFilterLink *inlink = ctx->inputs[0]; | 167 | FilterLink *inlink = ff_filter_link(ctx->inputs[0]); |
| 167 | 168 | ||
| 168 | inlink->min_samples = inlink->max_samples = frame_size; | 169 | inlink->min_samples = inlink->max_samples = frame_size; |
| 169 | } | 170 | } |
| @@ -41,8 +41,29 @@ · 40 unmodified lines | |||
| 41 | */ | 41 | */ |
| 42 | typedef struct FilterLink { | 42 | typedef struct FilterLink { |
| 43 | AVFilterLink pub; | 43 | AVFilterLink pub; |
| 44 | |||
| 45 | /** | ||
| 46 | * Minimum number of samples to filter at once. | ||
| 47 | * | ||
| 48 | * May be set by the link destination filter in its config_props(). | ||
| 49 | * If 0, all related fields are ignored. | ||
| 50 | */ | ||
| 51 | int min_samples; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Maximum number of samples to filter at once. If filter_frame() is | ||
| 55 | * called with more samples, it will split them. | ||
| 56 | * | ||
| 57 | * May be set by the link destination filter in its config_props(). | ||
| 58 | */ | ||
| 59 | int max_samples; | ||
| 44 | } FilterLink; | 60 | } FilterLink; |
| 45 | 61 | ||
| 62 | static inline FilterLink* ff_filter_link(AVFilterLink *link) | ||
| 63 | { | ||
| 64 | return (FilterLink*)link; | ||
| 65 | } | ||
| 66 | |||
| 46 | /** | 67 | /** |
| 47 | * Mark a filter ready and schedule it for activation. | 68 | * Mark a filter ready and schedule it for activation. |
| 48 | * | 69 | * |