mirror of
https://github.com/mpv-player/mpv
synced 2025-03-04 05:07:51 +00:00
audio: fix AVFrame allocation (crash with opus encoding)
AVFrame doesn't have public code for pool allocation, so mpv does it manually. AVFrame allocation is very tricky, so we added a bug. This crashed with libopus encoding, but not some other audio codecs, because the libopus libavcodec wrapper accesses AVFrame.data. Most code tries to avoid accessing AVFrame.data and uses AVFrame.extended_data, because using the former would subtly corrupt memory on more than 8 channels. The fact that this problem manifested only now shows that most AVFrame consuming FFmpeg code indeed uses extended_data for audio.
This commit is contained in:
parent
d96e2c7313
commit
99cd22af01
@ -645,6 +645,8 @@ int mp_aframe_pool_allocate(struct mp_aframe_pool *pool, struct mp_aframe *frame
|
||||
av_frame->linesize[0] = samples * sstride;
|
||||
for (int n = 0; n < planes; n++)
|
||||
av_frame->extended_data[n] = av_frame->buf[0]->data + n * plane_size;
|
||||
for (int n = 0; n < MPMIN(planes, AV_NUM_DATA_POINTERS); n++)
|
||||
av_frame->data[n] = av_frame->extended_data[n];
|
||||
av_frame->nb_samples = samples;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user