From c866583e1e31e6f648f2346fb9c5394d8d080587 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 23 Mar 2013 13:05:32 +0100 Subject: af: use af_lavrresample for format conversions, if possible Refactor to remove the duplicated format filter insertion code. Allow other format converting filters to be inserted on format mismatches. af_info.test_conversion checks whether conversion between two formats would work with the given filter; do this to avoid having to insert multiple conversion filters at once and such things. (Although this isn't ideal: what if we want to avoid af_format for some conversions? What if we want to split af_format in endian-swapping filters etc.?) Prefer af_lavrresample for conversions that it supports natively, otherwise let af_format handle the full conversion. --- audio/filter/af_lavrresample.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'audio/filter/af_lavrresample.c') diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index aed60f7078..b95c3e5f69 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -104,6 +104,12 @@ static bool needs_lavrctx_reconfigure(struct af_resample *s, } +static bool test_conversion(int src_format, int dst_format) +{ + return af_to_avformat(src_format) != AV_SAMPLE_FMT_NONE && + af_to_avformat(dst_format) != AV_SAMPLE_FMT_NONE; +} + #define ctx_opt_set_int(a,b) av_opt_set_int(s->avrctx, (a), (b), 0) #define ctx_opt_set_dbl(a,b) av_opt_set_double(s->avrctx, (a), (b), 0) @@ -304,5 +310,6 @@ struct af_info af_info_lavrresample = { "Stefano Pigozzi (based on Michael Niedermayer's lavcresample)", "", AF_FLAGS_REENTRANT, - af_open + af_open, + .test_conversion = test_conversion, }; -- cgit v1.2.3