mirror of https://github.com/mpv-player/mpv
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:
parent
98af572484
commit
48f60e182a
|
@ -232,6 +232,9 @@ static bool fill_buffer(struct af_instance *af)
|
||||||
af->delay = 0;
|
af->delay = 0;
|
||||||
|
|
||||||
if (s->pending) {
|
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);
|
int copy = MPMIN(s->in_samples - s->input->samples, s->pending->samples);
|
||||||
s->input->samples += copy;
|
s->input->samples += copy;
|
||||||
mp_audio_copy(s->input, s->input->samples - copy, s->pending, 0, copy);
|
mp_audio_copy(s->input, s->input->samples - copy, s->pending, 0, copy);
|
||||||
|
|
Loading…
Reference in New Issue