path: root/audio
diff options
authorwm4 <wm4@nowhere>2016-07-31 18:47:46 +0200
committerwm4 <wm4@nowhere>2016-07-31 18:51:05 +0200
commit48f60e182a61637a2c5d77839f0b174bb6fd7ccb (patch)
treec42a1a61954c84299cf2aaaac6933fe38fed624e /audio
parent98af572484dca052a0dbf276ac782f68f6bfbf44 (diff)
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.
Diffstat (limited to 'audio')
1 files changed, 3 insertions, 0 deletions
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);