diff options
author | wm4 <wm4@nowhere> | 2015-01-15 20:10:55 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-15 20:13:14 +0100 |
commit | 388cf6dc9666be6c5a66332326180ef669171ad0 (patch) | |
tree | 327bb6f93d7e1a036da1f3c8fe5a5e5bdc219aaf /audio/filter/af_pan.c | |
parent | 87fe7d878843688a0f530fc9ce5a1a0775c77b9e (diff) | |
download | mpv-388cf6dc9666be6c5a66332326180ef669171ad0.tar.bz2 mpv-388cf6dc9666be6c5a66332326180ef669171ad0.tar.xz |
audio/filter: switch remaining filters to refcounting
All of these filters are very similar in frame management, and copy data
to a new frame during filtering.
Diffstat (limited to 'audio/filter/af_pan.c')
-rw-r--r-- | audio/filter/af_pan.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/audio/filter/af_pan.c b/audio/filter/af_pan.c index 65269a86e1..979e4721e1 100644 --- a/audio/filter/af_pan.c +++ b/audio/filter/af_pan.c @@ -107,11 +107,17 @@ static int control(struct af_instance* af, int cmd, void* arg) return AF_UNKNOWN; } -// Filter data through filter -static int filter(struct af_instance* af, struct mp_audio* data, int flags) +static int filter_frame(struct af_instance *af, struct mp_audio *c) { - struct mp_audio* c = data; // Current working data - struct mp_audio* l = af->data; // Local data + if (!c) + return 0; + struct mp_audio *l = mp_audio_pool_get(af->out_pool, &af->fmt_out, c->samples); + if (!l) { + talloc_free(c); + return -1; + } + mp_audio_copy_attributes(l, c); + af_pan_t* s = af->priv; // Setup for this instance float* in = c->planes[0]; // Input audio data float* out = NULL; // Output audio data @@ -120,8 +126,6 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags) int ncho = l->nch; // Number of output channels register int j,k; - mp_audio_realloc_min(af->data, data->samples); - out = l->planes[0]; // Execute panning // FIXME: Too slow @@ -137,17 +141,15 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags) in+= nchi; } - // Set output data - c->planes[0] = l->planes[0]; - set_channels(c, l->nch); - + talloc_free(c); + af_add_output_frame(af, l); return 0; } // Allocate memory and set function pointers static int af_open(struct af_instance* af){ af->control=control; - af->filter=filter; + af->filter_frame = filter_frame; af_pan_t *s = af->priv; int n = 0; int j,k; |