Improve decoder's ability to distinguish between a FLAC sync code and an MPEG one...
authorJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 7 Jan 2009 06:54:05 +0000 (06:54 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 7 Jan 2009 06:54:05 +0000 (06:54 +0000)
doc/html/changelog.html
doc/html/format.html
src/libFLAC/stream_decoder.c

index 9595085..db1229d 100644 (file)
                                <ul>
                                        <li>libFLAC encoder was defaulting to level 0 compression instead of 5 (<a href="https://sourceforge.net/tracker2/?func=detail&aid=1816825&group_id=13478&atid=113478">SF #1816825</a>).</li>
                                        <li>Fix bug in bitreader handling of read callback returning a short count (<a href="https://sourceforge.net/tracker2/?func=detail&aid=2490454&group_id=13478&atid=113478">SF #2490454</a>).</li>
+                                       <li>Improve decoder's ability to distinguish between a FLAC sync code and an MPEG one (<a href="https://sourceforge.net/tracker2/?func=detail&aid=2491433&group_id=13478&atid=113478">SF #2491433</a>).</li>
                                </ul>
                        </li>
                        <li>
index 98b30b0..a9294db 100644 (file)
                                &lt;1&gt;
                        </td>
                        <td>
-                               Reserved:<br />
+                               Reserved: <a href="#frame_header_notes">[1]</a><br />
                                <ul>
                                <li>
                                        <tt>0</tt> : mandatory value
                                &lt;1&gt;
                        </td>
                        <td>
-                               Blocking strategy:<br />
+                               Blocking strategy: <a href="#frame_header_notes">[2]</a> <a href="#frame_header_notes">[3]</a><br />
                                <ul>
                                <li>
                                        <tt>0</tt> : fixed-blocksize stream; frame header encodes the frame number
                        </td>
                        <td>
                                if(variable blocksize)<br />
-                               &nbsp;&nbsp;&nbsp;&lt;8-56&gt;:"UTF-8" coded sample number (decoded number is 36 bits)<br />
+                               &nbsp;&nbsp;&nbsp;&lt;8-56&gt;:"UTF-8" coded sample number (decoded number is 36 bits) <a href="#frame_header_notes">[4]</a><br />
                                else<br />
-                               &nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits)
+                               &nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits) <a href="#frame_header_notes">[4]</a>
                        </td>
                </tr>
                <tr>
                        <td>
                        </td>
                        <td bgcolor="#F4F4CC">
-                               <font size="+1">NOTES</font><br />
-                               <ul>
+                               <a name="frame_header_notes"><font size="+1">NOTES</font></a><br />
+                               <ol>
+                               <li>
+                                       This bit must remain reserved for <tt>0</tt> in order for a FLAC frame's initial 15 bits to be distinguishable from the start of an MPEG audio frame (<a href="http://lists.xiph.org/pipermail/flac-dev/2008-December/002607.html">see also</a>).
+                               </li>
                                <li>
                                        The "blocking strategy" bit must be the same throughout the entire stream.
                                </li>
                                <li>
                                        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.
                                </li>
-                               </ul>
+                               </ol>
                        </td>
                </tr>
        </table>
index 8756d6f..75f896a 100644 (file)
@@ -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;