diff options
author | wm4 <wm4@nowhere> | 2013-11-10 23:20:06 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-12 23:27:03 +0100 |
commit | d115fb3b0eed9145817a20bc0070590f7428bddd (patch) | |
tree | 00aab1420c5ab64f77b777214b92ba51793ea589 /audio/filter/af_format.c | |
parent | e763d528e2b9370521b1e28450f48e65af33ca7f (diff) | |
download | mpv-d115fb3b0eed9145817a20bc0070590f7428bddd.tar.bz2 mpv-d115fb3b0eed9145817a20bc0070590f7428bddd.tar.xz |
af: don't require filters to allocate af_instance->data, redo buffers
Allocate af_instance->data in generic code before filter initialization.
Every filter needs af->data (since it contains the output
configuration), so there's no reason why every filter should allocate
and free it.
Remove RESIZE_LOCAL_BUFFER(), and replace it with mp_audio_realloc_min().
Interestingly, most code becomes simpler, because the new function takes
the size in samples, and not in bytes. There are larger change in
af_scaletempo.c and af_lavcac3enc.c, because these had copied and
modified versions of the RESIZE_LOCAL_BUFFER macro/function.
Diffstat (limited to 'audio/filter/af_format.c')
-rw-r--r-- | audio/filter/af_format.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/audio/filter/af_format.c b/audio/filter/af_format.c index b551ddba42..58f311735e 100644 --- a/audio/filter/af_format.c +++ b/audio/filter/af_format.c @@ -35,9 +35,6 @@ struct priv { struct mp_chmap out_channels; int fail; - - struct mp_audio data; - struct mp_audio temp; }; static void force_in_params(struct af_instance *af, struct mp_audio *in) @@ -101,15 +98,8 @@ static int control(struct af_instance *af, int cmd, void *arg) static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) { - struct priv *priv = af->priv; - struct mp_audio *r = &priv->temp; - - *r = *af->data; - for (int n = 0; n < r->nch; n++) - r->planes[n] = data->planes[n]; - r->samples = data->samples; - - return r; + mp_audio_copy_config(data, af->data); + return data; } static int af_open(struct af_instance *af) @@ -117,8 +107,6 @@ static int af_open(struct af_instance *af) af->control = control; af->play = play; af->mul = 1; - struct priv *priv = af->priv; - af->data = &priv->data; force_in_params(af, af->data); force_out_params(af, af->data); |