In this case switching to .formats.samples even allows to avoid the runtime check for which filter is currently used.
Unified · Split
| @@ -27,29 +27,6 @@ typedef struct ADerivativeContext { · 26 unmodified lines | ||
| 27 | 27 | int nb_samples, int channels); |
| 28 | 28 | } ADerivativeContext; |
| 29 | 29 | |
| 30 | −static int query_formats(AVFilterContext *ctx) | |
| 31 | −{ | |
| 32 | − static const enum AVSampleFormat derivative_sample_fmts[] = { | |
| 33 | − AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLTP, | |
| 34 | − AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_DBLP, | |
| 35 | − AV_SAMPLE_FMT_NONE | |
| 36 | − }; | |
| 37 | − static const enum AVSampleFormat integral_sample_fmts[] = { | |
| 38 | − AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, | |
| 39 | − AV_SAMPLE_FMT_NONE | |
| 40 | − }; | |
| 41 | − int ret = ff_set_common_formats_from_list(ctx, strcmp(ctx->filter->name, "aintegral") ? | |
| 42 | − derivative_sample_fmts : integral_sample_fmts); | |
| 43 | − if (ret < 0) | |
| 44 | − return ret; | |
| 45 | − | |
| 46 | − ret = ff_set_common_all_channel_counts(ctx); | |
| 47 | − if (ret < 0) | |
| 48 | − return ret; | |
| 49 | − | |
| 50 | − return ff_set_common_all_samplerates(ctx); | |
| 51 | −} | |
| 52 | − | |
| 53 | 30 | #define DERIVATIVE(name, type) \ |
| 54 | 31 | static void aderivative_## name ##p(void **d, void **p, const void **s, \ |
| 55 | 32 | int nb_samples, int channels) \ |
| @@ -179,7 +156,8 @@ const AVFilter ff_af_aderivative = { · 123 unmodified lines | ||
| 179 | 156 | .uninit = uninit, |
| 180 | 157 | FILTER_INPUTS(aderivative_inputs), |
| 181 | 158 | FILTER_OUTPUTS(aderivative_outputs), |
| 182 | − FILTER_QUERY_FUNC(query_formats), | |
| 159 | + FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLTP, | |
| 160 | + AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_DBLP), | |
| 183 | 161 | }; |
| 184 | 162 | |
| 185 | 163 | const AVFilter ff_af_aintegral = { |
| @@ -189,5 +167,5 @@ const AVFilter ff_af_aintegral = { · 3 unmodified lines | ||
| 189 | 167 | .uninit = uninit, |
| 190 | 168 | FILTER_INPUTS(aderivative_inputs), |
| 191 | 169 | FILTER_OUTPUTS(aderivative_outputs), |
| 192 | − FILTER_QUERY_FUNC(query_formats), | |
| 170 | + FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP), | |
| 193 | 171 | }; |