diff --git a/doc/html/changelog.html b/doc/html/changelog.html
index 9595085f..db1229da 100644
--- a/doc/html/changelog.html
+++ b/doc/html/changelog.html
@@ -121,6 +121,7 @@
- libFLAC encoder was defaulting to level 0 compression instead of 5 (SF #1816825).
- Fix bug in bitreader handling of read callback returning a short count (SF #2490454).
+ - Improve decoder's ability to distinguish between a FLAC sync code and an MPEG one (SF #2491433).
diff --git a/doc/html/format.html b/doc/html/format.html
index 98b30b0a..a9294dba 100644
--- a/doc/html/format.html
+++ b/doc/html/format.html
@@ -1121,7 +1121,7 @@
<1>
- Reserved:
+ Reserved: [1]
-
0 : mandatory value
@@ -1137,7 +1137,7 @@
<1>
|
- Blocking strategy:
+ Blocking strategy: [2] [3]
-
0 : fixed-blocksize stream; frame header encodes the frame number
@@ -1325,9 +1325,9 @@
|
if(variable blocksize)
- <8-56>:"UTF-8" coded sample number (decoded number is 36 bits)
+ <8-56>:"UTF-8" coded sample number (decoded number is 36 bits) [4]
else
- <8-48>:"UTF-8" coded frame number (decoded number is 31 bits)
+ <8-48>:"UTF-8" coded frame number (decoded number is 31 bits) [4]
|
@@ -1360,8 +1360,11 @@
|
|
- NOTES
-
+ NOTES
+
+ -
+ This bit must remain reserved for 0 in order for a FLAC frame's initial 15 bits to be distinguishable from the start of an MPEG audio frame (see also).
+
-
The "blocking strategy" bit must be the same throughout the entire stream.
@@ -1371,7 +1374,7 @@
-
The "UTF-8" coding used for the sample/frame number is the same variable length code used to store compressed UCS-2, extended to handle larger input.
-
+
|
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c
index 8756d6f1..75f896a3 100644
--- a/src/libFLAC/stream_decoder.c
+++ b/src/libFLAC/stream_decoder.c
@@ -1407,7 +1407,7 @@ FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder)
decoder->private_->lookahead = (FLAC__byte)x;
decoder->private_->cached = true;
}
- else if(x >> 2 == 0x3e) { /* MAGIC NUMBER for the last 6 sync bits */
+ else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */
decoder->private_->header_warmup[1] = (FLAC__byte)x;
decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME;
return true;
@@ -1977,7 +1977,7 @@ FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder)
decoder->private_->lookahead = (FLAC__byte)x;
decoder->private_->cached = true;
}
- else if(x >> 2 == 0x3e) { /* MAGIC NUMBER for the last 6 sync bits */
+ else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */
decoder->private_->header_warmup[1] = (FLAC__byte)x;
decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME;
return true;