summaryrefslogtreecommitdiffstats
path: root/libaf
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-07-11 09:46:58 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:14:43 +0200
commitf8509c52c02a59e604f0424f545c29fa9d8adb9e (patch)
tree84451a81ae70b6dc0d6660e60f3d2e86f0f1d78c /libaf
parent1bcb3fc805e4d6577ac41ab797d38b8bacc8ef89 (diff)
downloadmpv-f8509c52c02a59e604f0424f545c29fa9d8adb9e.tar.bz2
mpv-f8509c52c02a59e604f0424f545c29fa9d8adb9e.tar.xz
af_lavcresample: avoid multiple calls to av_resample_init
Avoid calling av_resample_init again when the values are the same as before. The init function can be called multiple times when e.g. additional format filters are inserted, so this speeds things up. Patch by Dan Oscarsson [Dan.Oscarsson tieto com]. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31698 b3059339-0415-0410-9bf9-f77b7e298cf2 Reindent. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31699 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf')
-rw-r--r--libaf/af_lavcresample.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/libaf/af_lavcresample.c b/libaf/af_lavcresample.c
index 49a284bba6..48fcd75ac5 100644
--- a/libaf/af_lavcresample.c
+++ b/libaf/af_lavcresample.c
@@ -39,6 +39,13 @@ typedef struct af_resample_s{
int linear;
int phase_shift;
double cutoff;
+
+ int ctx_out_rate;
+ int ctx_in_rate;
+ int ctx_filter_size;
+ int ctx_phase_shift;
+ int ctx_linear;
+ double ctx_cutoff;
}af_resample_t;
@@ -61,8 +68,17 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
af->mul = (double)af->data->rate / data->rate;
af->delay = af->data->nch * s->filter_length / min(af->mul, 1); // *bps*.5
- if(s->avrctx) av_resample_close(s->avrctx);
- s->avrctx= av_resample_init(af->data->rate, /*in_rate*/data->rate, s->filter_length, s->phase_shift, s->linear, s->cutoff);
+ if (s->ctx_out_rate != af->data->rate || s->ctx_in_rate != data->rate || s->ctx_filter_size != s->filter_length ||
+ s->ctx_phase_shift != s->phase_shift || s->ctx_linear != s->linear || s->ctx_cutoff != s->cutoff) {
+ if(s->avrctx) av_resample_close(s->avrctx);
+ s->avrctx= av_resample_init(af->data->rate, /*in_rate*/data->rate, s->filter_length, s->phase_shift, s->linear, s->cutoff);
+ s->ctx_out_rate = af->data->rate;
+ s->ctx_in_rate = data->rate;
+ s->ctx_filter_size = s->filter_length;
+ s->ctx_phase_shift = s->phase_shift;
+ s->ctx_linear = s->linear;
+ s->ctx_cutoff = s->cutoff;
+ }
// hack to make af_test_output ignore the samplerate change
out_rate = af->data->rate;