mpv/sub
Philip Langdale 4574dd5dc6 ffmpeg: update to handle deprecation of `av_init_packet`
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.
2022-12-03 14:44:18 -08:00
..
ass_mp.c sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA 2022-01-11 23:45:08 +02:00
ass_mp.h command: extend osd-overlay command with bounds reporting 2020-03-06 18:20:11 +01:00
dec_sub.c options: only apply sub-visibility to primary subs 2022-01-22 16:22:25 +00:00
dec_sub.h options: only apply sub-visibility to primary subs 2022-01-22 16:22:25 +00:00
draw_bmp.c draw_bmp: fix out of bounds access in mark_rect 2022-10-11 17:11:07 +00:00
draw_bmp.h draw_bmp: make another small guarantee to users 2020-05-13 22:46:29 +02:00
filter_jsre.c sub: jsre filter: abort init early on empty filter list 2022-06-09 14:38:24 +03:00
filter_regex.c sub: sub-filter-regex and jsre: support ass-to-plaintext 2021-08-05 21:32:22 +03:00
filter_sdh.c various: remove trailing whitespace 2022-05-14 14:51:34 +00:00
img_convert.c
img_convert.h
lavc_conv.c ffmpeg: update to handle deprecation of `av_init_packet` 2022-12-03 14:44:18 -08:00
osd.c sub/osd: use atomic for osd_state.force_video_pts 2022-04-02 21:41:58 +03:00
osd.h sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA 2022-01-11 23:45:08 +02:00
osd_font.otf osc: use custom symbols for window controls 2019-12-11 13:53:10 -08:00
osd_libass.c sub: use Unicode linebreaking for non-ASS subs and OSD 2022-09-19 15:56:38 +02:00
osd_state.h sub/osd: use atomic for osd_state.force_video_pts 2022-04-02 21:41:58 +03:00
sd.h sub: sub-filter-regex and jsre: support ass-to-plaintext 2021-08-05 21:32:22 +03:00
sd_ass.c sd_ass: never mangle colours on RGB video 2022-11-05 09:32:05 -04:00
sd_lavc.c ffmpeg: update to handle deprecation of `av_init_packet` 2022-12-03 14:44:18 -08:00