path: root/stream/stream_radio.h
diff options
authorPhilip Langdale <>2022-11-29 11:15:16 -0800
committerPhilip Langdale <>2022-12-03 14:44:18 -0800
commit4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c (patch)
tree680ea541592dea8e356809e5dbdd5265781d72fe /stream/stream_radio.h
parent77e7f5de2c01361a88c501fcd78b51c2fe2d9df0 (diff)
ffmpeg: update to handle deprecation of `av_init_packet`HEADmaster
This has been a long standing annoyance - ffmpeg is removing sizeof(AVPacket) from the API which means you cannot stack-allocate AVPacket anymore. However, that is something we take advantage of because we use short-lived AVPackets to bridge from native mpv packets in our main decoding paths. We don't think that switching these to `av_packet_alloc` is desirable, given the cost of heap allocation, so this change takes a different approach - allocating a single packet in the relevant context and reusing it over and over. That's fairly straight-forward, with the main caveat being that re-initialising the packet is unintuitive. There is no function that does exactly what we need (what `av_init_packet` did). The closest is `av_packet_unref`, which additionally frees buffers and side-data. However, we don't copy those things - we just assign them in from our own packet, so we have to explicitly clear the pointers before calling `av_packet_unref`. But at least we can make a wrapper function for that. The weirdest part of the change is the handling of the vtt subtitle conversion. This requires two packets, so I had to pre-allocate two in the context struct. That sounds excessive, but if allocating the primary packet is too expensive, then allocating the secondary one for vtt subtitles must also be too expensive. This change is not conditional as heap allocated AVPackets were available for years and years before the deprecation.
Diffstat (limited to 'stream/stream_radio.h')
0 files changed, 0 insertions, 0 deletions