[MPlayer-cvslog] r31698 - trunk/libaf/af_lavcresample.c

reimar subversion at mplayerhq.hu
Sun Jul 11 11:46:58 CEST 2010


Author: reimar
Date: Sun Jul 11 11:46:58 2010
New Revision: 31698

Log:
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.

Modified:
   trunk/libaf/af_lavcresample.c

Modified: trunk/libaf/af_lavcresample.c
==============================================================================
--- trunk/libaf/af_lavcresample.c	Sun Jul 11 11:40:46 2010	(r31697)
+++ trunk/libaf/af_lavcresample.c	Sun Jul 11 11:46:58 2010	(r31698)
@@ -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->mul = (double)af->data->rate / data->rate;
     af->delay = af->data->nch * s->filter_length / min(af->mul, 1); // *bps*.5
 
+    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;


More information about the MPlayer-cvslog mailing list