From 48f60e182a61637a2c5d77839f0b174bb6fd7ccb Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 31 Jul 2016 18:47:46 +0200 Subject: af_lavcac3enc: fix aspects of AVFrame handling We send a refcounted frame to the encoder, but then disrespect refcounting rules and write to the frame data without making sure the buffer is really writeable. In theory this can lead to reallocation on every frame is the encoder really keeps a reference. If we really cared, we could fix this by providing a buffer pool. But then again, we don't care. --- audio/filter/af_lavcac3enc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'audio/filter/af_lavcac3enc.c') diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index 31b84e1528..44a2231836 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -232,6 +232,9 @@ static bool fill_buffer(struct af_instance *af) af->delay = 0; if (s->pending) { + if (!mp_audio_is_writeable(s->input)) + assert(s->input->samples == 0); // we can't have sent a partial frame + mp_audio_realloc_min(s->input, s->in_samples); int copy = MPMIN(s->in_samples - s->input->samples, s->pending->samples); s->input->samples += copy; mp_audio_copy(s->input, s->input->samples - copy, s->pending, 0, copy); -- cgit v1.2.3