1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Safe RAII ownership of an `AVSubtitle` and its decoder-allocated rects.
//!
//! `avcodec_decode_subtitle2` fills a caller-provided `AVSubtitle` with heap
//! allocations — the `rects` array and, per rect, its `data` / `text` / `ass` —
//! which the caller must release with `avsubtitle_free`. That "output struct you
//! must remember to free" is a leak surface: any `?` or early return between the
//! decode call and the free leaks the rects.
//!
//! [`Subtitle`] owns the `AVSubtitle` and frees it on [`Drop`], so it is freed
//! exactly once on every path. It mirrors the other `crate::raw` owners with one
//! twist: it owns the struct **by value**, not a pointer — FFmpeg fills it in
//! place and `avsubtitle_free` frees the inner allocations. A zeroed struct
//! (`num_rects = 0`, `rects = null`) is a valid empty state that
//! `avsubtitle_free` treats as a no-op; that is both the freshly-constructed
//! state and the state left behind after the contents are moved into a frame
//! buffer (`av_memdup` of the struct + zeroing the source).
//!
//! Naming follows the raw-module convention (drop the `AV` prefix, like
//! [`crate::raw::FormatContext`]); consumers refer to it path-qualified as
//! `raw::Subtitle`.
use ;
/// Sole owner of an `AVSubtitle`'s decoder-allocated contents.
///
/// Move-only (no `Clone`/`Copy`): one owner ⇒ one [`Drop`] ⇒ the rects are
/// freed exactly once. Ownership of the contents can be handed off by moving the
/// bytes out (`av_memdup`) and zeroing the struct through
/// [`as_mut_ptr`](Self::as_mut_ptr); this owner then holds an empty struct and
/// its `Drop` becomes a no-op.
pub