Skip to content

Commit 47b8051

Browse files
authored
Add a way of specifying blockSize and compressLevel to FLAC encoder
* This fixes #595. Add a way of specifying frame duration to FLAC encoder config
1 parent cd72b11 commit 47b8051

File tree

1 file changed

+61
-6
lines changed

1 file changed

+61
-6
lines changed

flac_codec_registration.src.html

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
(2) the codec-specific {{EncodedAudioChunk}}
1717
[=EncodedAudioChunk/[[internal data]]=] bytes, (3) the
1818
{{AudioDecoderConfig.description}} bytes, and (4) the values of
19-
{{EncodedAudioChunk}} [=EncodedAudioChunk/[[type]]=].
19+
{{EncodedAudioChunk}} [=EncodedAudioChunk/[[type]]=], and (5) the
20+
codec-specific extensions to {{AudioEncoderConfig}}.
2021

2122
The registration is not intended to include any information on whether a
2223
codec format is encumbered by intellectual property claims. Implementers and
@@ -46,14 +47,15 @@
4647
text: EncodedAudioChunk; url: encodedaudiochunk
4748
type: dictionary
4849
text: AudioDecoderConfig; url: dictdef-audiodecoderconfig
50+
text: AudioEncoderConfig; url: dictdef-audioencoderconfig
4951
</pre>
5052

5153
<pre class='biblio'>
5254
{
5355
"FLAC": {
54-
"href": "https://xiph.org/flac/format.html",
55-
"title": "FLAC - format",
56-
"publisher": "Xiph.Org Foundation"
56+
"href": "https://datatracker.ietf.org/doc/draft-ietf-cellar-flac",
57+
"title": "Free Lossless Audio Codec",
58+
"publisher": "IETF"
5759
}
5860
}
5961
</pre>
@@ -75,8 +77,8 @@
7577
{{AudioDecoderConfig.description}} is required, and has to be the following:
7678

7779
- The bytes `0x66 0x4C 0x61 0x43` ("`fLaC`" in ASCII)
78-
- A `METADATA_BLOCK` of type `STEAMINFO` as described in [[FLAC]]
79-
- Optionaly other `METADATA_BLOCK`, that are not used by the specification
80+
- A `metadata block` (called the STREAMINFO block) as described in section 7 of [[FLAC]]
81+
- Optionaly other metadata blocks, that are not used by the specification
8082

8183
The {{AudioDecoderConfig.sampleRate}} and {{AudioDecoderConfig.numberOfChannels}}
8284
members are overridden by what the decoder finds in the
@@ -94,6 +96,59 @@
9496
NOTE: Once the initialization has succeeded, any FLAC packet can be decoded at
9597
any time without error, but this might not result in the expected audio output.
9698

99+
AudioEncoderConfig extensions {#audioencoderconfig-extensions}
100+
=============================================================
101+
102+
<pre class='idl'>
103+
<xmp>
104+
partial dictionary AudioEncoderConfig {
105+
FlacEncoderConfig flac;
106+
};
107+
</xmp>
108+
</pre>
109+
110+
<dl>
111+
<dt><dfn dict-member for=AudioEncoderConfig>flac</dfn></dt>
112+
<dd>
113+
Contains codec specific configuration options for the FLAC codec.
114+
</dd>
115+
</dl>
116+
117+
118+
FlacEncoderConfig {#flac-encoder-config}
119+
--------------------------------------
120+
121+
<pre class='idl'>
122+
<xmp>
123+
dictionary FlacEncoderConfig {
124+
[EnforceRange] unsigned long blockSize = 0;
125+
[EnforceRange] unsigned long compressLevel = 5;
126+
};
127+
</xmp>
128+
</pre>
129+
130+
To check if an {{FlacEncoderConfig}} is valid, run these steps:
131+
1. If {{FlacEncoderConfig/blockSize}} is not a valid block size,
132+
which is described section 5.1 of [[FLAC]], return `false`.
133+
1. If {{FlacEncoderConfig/compressLevel}} is specified and not within the range of
134+
`0` (fastest, least compression) and `8` (slowest, most compression) inclusively, return `false`.
135+
2. Return `true`.
136+
137+
<dl>
138+
<dt><dfn dict-member for=FlacEncoderConfig>blockSize</dfn></dt>
139+
<dd>
140+
Configures the number of samples to use per frame, of output {{EncodedAudioChunk}}s.
141+
142+
NOTE: Use 0 to let the encoder estimate a blocksize by default.
143+
</dd>
144+
145+
<dt><dfn dict-member for=FlacEncoderConfig>compressLevel</dfn></dt>
146+
<dd>
147+
Configures the compression level to use while encoding.
148+
</dd>
149+
150+
</dl>
151+
97152
Privacy Considerations {#privacy-considerations}
98153
==========================================================================
99154

0 commit comments

Comments
 (0)