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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//! Encoder and decoder configuration types.
/// What the encoder is being asked to optimise for, fixed when it is created.
///
/// This is the one setting that cannot be changed afterwards, because it
/// decides which coding layers the encoder is allowed to use at all. It biases
/// the SILK/CELT decision rather than dictating it: [`Audio`](Self::Audio) and
/// [`Voip`](Self::Voip) both reach all three modes, and speech still codes as
/// SILK under `Audio` when the content analysis says so.
///
/// The discriminants are libopus's `OPUS_APPLICATION_*` values, so a caller
/// bridging to a C API can cast between the two.
/// How the encoder is allowed to vary the size of each packet.
///
/// Opus is a variable-rate codec, and the bitrate a caller sets is an average
/// the encoder spends around rather than a size it emits every time. This
/// chooses how much it is allowed to deviate.
///
/// [`ConstrainedVbr`](Self::ConstrainedVbr) is the default, and matches
/// libopus. The difference from [`Vbr`](Self::Vbr) only shows up on content
/// whose difficulty changes quickly: constrained VBR keeps a reservoir so that
/// any window of packets stays near the target, which is what a network with a
/// fixed budget needs, while unconstrained VBR spends whatever a frame is
/// worth. For encoding a file, where nothing downstream is metering the rate,
/// unconstrained is usually the better picture per byte โ it is what `opusenc`
/// uses by default.
/// OPUS_SET_SIGNAL hint: bias mode selection toward speech or music. `None` =
/// OPUS_AUTO (let the analysis decide).
///
/// Setting this pins the answer the content analysis would otherwise reach, so
/// it also makes the analysis cheap to skip. That matters for
/// [`encode_parallel`](crate::encode_parallel), where every worker would
/// otherwise have to re-derive it from its own warm-up audio.
/// The audio bandwidth a packet carries, which is what Opus varies instead of
/// the sample rate.
///
/// An Opus decoder always produces audio at the rate it was created with; a
/// narrowband packet is not a slower stream, it is one whose upper spectrum was
/// never coded. Each name gives the audio bandwidth, and the sample rate that
/// would be needed to represent it: 4 kHz of audio needs 8 kHz of sampling.
///
/// The encoder chooses this per packet from the bitrate, and a caller normally
/// leaves it alone. To constrain it, prefer
/// [`max_bandwidth`](crate::OpusEncoder::max_bandwidth), which caps the
/// automatic choice, over
/// [`force_bandwidth`](crate::OpusEncoder::force_bandwidth), which overrides it
/// and can spend bits on spectrum the rate cannot afford.
///
/// The discriminants are libopus's `OPUS_BANDWIDTH_*` values.
/// Which coding layers a packet actually used.
///
/// Opus is two codecs behind one bitstream, and the TOC byte says which of them
/// coded a given packet. A caller normally does not care โ the decoder handles
/// all three โ but the layer decides what some other operations mean. In-band
/// FEC, in particular, only exists in SILK and hybrid packets, so
/// [`OpusDecoder::decode_fec`](crate::OpusDecoder::decode_fec) on a
/// [`CeltOnly`](Self::CeltOnly) packet can only conceal.
///
/// RFC 6716 ยง3.1 fixes these three, so the set will not grow.