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.
This commit is contained in:
wm4 2016-07-31 18:47:46 +02:00
parent 98af572484
commit 48f60e182a
1 changed files with 3 additions and 0 deletions

View File

@ -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);