Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release > by-pkgid > 1b812d1b0e765bcc0430721ff58676d2 > files > 262

libid3_3.8_3-devel-3.8.3-19.mga1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>id3lib: src/mp3_parse.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="id3lib.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>src/mp3_parse.cpp</h1><a href="mp3__parse_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- C++ -*-</span>
<a name="l00002"></a>00002 <span class="comment">// $Id: mp3_parse.cpp,v 1.6 2002/11/02 17:48:51 t1mpy Exp $</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment">// id3lib: a C++ library for creating and manipulating id3v1/v2 tags</span>
<a name="l00005"></a>00005 <span class="comment">// Copyright 2002, Thijmen Klok (thijmen@id3lib.org)</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">// This library is free software; you can redistribute it and/or modify it</span>
<a name="l00008"></a>00008 <span class="comment">// under the terms of the GNU Library General Public License as published by</span>
<a name="l00009"></a>00009 <span class="comment">// the Free Software Foundation; either version 2 of the License, or (at your</span>
<a name="l00010"></a>00010 <span class="comment">// option) any later version.</span>
<a name="l00011"></a>00011 <span class="comment">//</span>
<a name="l00012"></a>00012 <span class="comment">// This library is distributed in the hope that it will be useful, but WITHOUT</span>
<a name="l00013"></a>00013 <span class="comment">// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
<a name="l00014"></a>00014 <span class="comment">// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public</span>
<a name="l00015"></a>00015 <span class="comment">// License for more details.</span>
<a name="l00016"></a>00016 <span class="comment">//</span>
<a name="l00017"></a>00017 <span class="comment">// You should have received a copy of the GNU Library General Public License</span>
<a name="l00018"></a>00018 <span class="comment">// along with this library; if not, write to the Free Software Foundation,</span>
<a name="l00019"></a>00019 <span class="comment">// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="comment">// The id3lib authors encourage improvements and optimisations to be sent to</span>
<a name="l00022"></a>00022 <span class="comment">// the id3lib coordinator.  Please see the README file for details on where to</span>
<a name="l00023"></a>00023 <span class="comment">// send such submissions.  See the AUTHORS file for a list of people who have</span>
<a name="l00024"></a>00024 <span class="comment">// contributed to id3lib.  See the ChangeLog file for a list of changes to</span>
<a name="l00025"></a>00025 <span class="comment">// id3lib.  These files are distributed with id3lib at</span>
<a name="l00026"></a>00026 <span class="comment">// http://download.sourceforge.net/id3lib/</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;<a class="code" href="mp3__header_8h.html">mp3_header.h</a>&quot;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a><a class="code" href="mp3__parse_8cpp.html#a99bc450005a5df27b410a9d7739e11bd">00030</a> <span class="preprocessor">#define FRAMES_FLAG     0x0001</span>
<a name="l00031"></a><a class="code" href="mp3__parse_8cpp.html#a07630cfeb2869eee8904d48ef7cc344d">00031</a> <span class="preprocessor"></span><span class="preprocessor">#define BYTES_FLAG      0x0002</span>
<a name="l00032"></a><a class="code" href="mp3__parse_8cpp.html#aea6153256089264f1b9af3484f07afb7">00032</a> <span class="preprocessor"></span><span class="preprocessor">#define TOC_FLAG        0x0004</span>
<a name="l00033"></a><a class="code" href="mp3__parse_8cpp.html#ab1e14bd903aa2ff3c830aaa32ad0c4fa">00033</a> <span class="preprocessor"></span><span class="preprocessor">#define SCALE_FLAG      0x0008</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="keyword">static</span> <span class="keywordtype">int</span> ExtractI4(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf)
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037   <span class="keywordtype">int</span> x;
<a name="l00038"></a>00038   <span class="comment">// big endian extract</span>
<a name="l00039"></a>00039 
<a name="l00040"></a>00040   x = buf[0];
<a name="l00041"></a>00041   x &lt;&lt;= 8;
<a name="l00042"></a>00042   x |= buf[1];
<a name="l00043"></a>00043   x &lt;&lt;= 8;
<a name="l00044"></a>00044   x |= buf[2];
<a name="l00045"></a>00045   x &lt;&lt;= 8;
<a name="l00046"></a>00046   x |= buf[3];
<a name="l00047"></a>00047 
<a name="l00048"></a>00048   <span class="keywordflow">return</span> x;
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050 
<a name="l00051"></a><a class="code" href="mp3__parse_8cpp.html#ad49f76141cc7ebc2c3ab30827b8359a4">00051</a> uint32 <a class="code" href="mp3__parse_8cpp.html#ad49f76141cc7ebc2c3ab30827b8359a4">fto_nearest_i</a>(<span class="keywordtype">float</span> f)
<a name="l00052"></a>00052 {
<a name="l00053"></a>00053   uint32 i;
<a name="l00054"></a>00054 
<a name="l00055"></a>00055   i = (uint32)f;
<a name="l00056"></a>00056   <span class="keywordflow">if</span> (i &lt; f)
<a name="l00057"></a>00057   {
<a name="l00058"></a>00058     f -= i;
<a name="l00059"></a>00059       <span class="keywordflow">if</span> (f &gt;= 0.5)
<a name="l00060"></a>00060       <span class="keywordflow">return</span> i+1;
<a name="l00061"></a>00061     <span class="keywordflow">else</span>
<a name="l00062"></a>00062       <span class="keywordflow">return</span> i;
<a name="l00063"></a>00063   }
<a name="l00064"></a>00064   <span class="keywordflow">else</span>
<a name="l00065"></a>00065     <span class="keywordflow">return</span> i;
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="mp3__parse_8cpp.html#a2cab9eb351e331aff2f8b6ab92d73be2">00068</a> uint16 <a class="code" href="mp3__parse_8cpp.html#a2cab9eb351e331aff2f8b6ab92d73be2">calcCRC</a>(<span class="keywordtype">char</span> *pFrame, <span class="keywordtype">size_t</span> audiodatasize)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070   <span class="keywordtype">size_t</span> icounter;
<a name="l00071"></a>00071   <span class="keywordtype">int</span> tmpchar, crcmask, tmpi;
<a name="l00072"></a>00072   uint16 crc = 0xffff;
<a name="l00073"></a>00073 
<a name="l00074"></a>00074   <span class="keywordflow">for</span> (icounter = 2;  icounter &lt; audiodatasize;  ++icounter)
<a name="l00075"></a>00075   {
<a name="l00076"></a>00076     <span class="keywordflow">if</span> (icounter != 4  &amp;&amp;  icounter != 5) <span class="comment">//skip the 2 chars of the crc itself</span>
<a name="l00077"></a>00077     {
<a name="l00078"></a>00078       crcmask = 1 &lt;&lt; 8;
<a name="l00079"></a>00079       tmpchar = pFrame[icounter];
<a name="l00080"></a>00080       <span class="keywordflow">while</span> (crcmask &gt;&gt;= 1)
<a name="l00081"></a>00081       {
<a name="l00082"></a>00082         tmpi = crc &amp; 0x8000;
<a name="l00083"></a>00083         crc &lt;&lt;= 1;
<a name="l00084"></a>00084         <span class="keywordflow">if</span> (!tmpi ^ !(tmpchar &amp; crcmask))
<a name="l00085"></a>00085           crc ^= 0x8005;
<a name="l00086"></a>00086       }
<a name="l00087"></a>00087     }
<a name="l00088"></a>00088   }
<a name="l00089"></a>00089   crc &amp;= 0xffff;
<a name="l00090"></a>00090   <span class="keywordflow">return</span> crc;
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092 
<a name="l00093"></a><a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">00093</a> <span class="keywordtype">void</span> <a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Mp3Info::Clean</a>()
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095   <span class="keywordflow">if</span> (_mp3_header_output != <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00096"></a>00096     <span class="keyword">delete</span> _mp3_header_output;
<a name="l00097"></a>00097   _mp3_header_output = <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <span class="keyword">using namespace </span>dami;
<a name="l00101"></a>00101 
<a name="l00102"></a><a class="code" href="class_mp3_info.html#afd960ec47e798fb1e7d9988d038ed176">00102</a> <span class="keywordtype">bool</span> <a class="code" href="class_mp3_info.html#afd960ec47e798fb1e7d9988d038ed176">Mp3Info::Parse</a>(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, <span class="keywordtype">size_t</span> mp3size)
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104   <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97">MP3_BitRates</a> _mp3_bitrates[2][3][16] =
<a name="l00105"></a>00105   {
<a name="l00106"></a>00106     {
<a name="l00107"></a>00107       { <span class="comment">//MPEG 1, LAYER I</span>
<a name="l00108"></a>00108         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a>,
<a name="l00109"></a>00109         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae7edf10d4fa632d04b2e646fd1359e99">MP3BITRATE_32K</a>,
<a name="l00110"></a>00110         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aebb485aa008ad9231305534eb75645b0">MP3BITRATE_64K</a>,
<a name="l00111"></a>00111         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a772ac065539192e2c063c3c52a7ac755">MP3BITRATE_96K</a>,
<a name="l00112"></a>00112         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f1d1694a146e3d8457883112577326b">MP3BITRATE_128K</a>,
<a name="l00113"></a>00113         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a457a1962733e010eafdc7f4120c02c67">MP3BITRATE_160K</a>,
<a name="l00114"></a>00114         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ab727ff391b19516ae7711c532a50071f">MP3BITRATE_192K</a>,
<a name="l00115"></a>00115         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a67922457d07dab9207a1e2146f4f266a">MP3BITRATE_224K</a>,
<a name="l00116"></a>00116         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97adf0969f154c8a003adcc6b2ba3a1615b">MP3BITRATE_256K</a>,
<a name="l00117"></a>00117         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a4901fa4993505c9db7bc57cd1ae88e70">MP3BITRATE_288K</a>,
<a name="l00118"></a>00118         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97afdab0fc0d3d5319489ba697f841b2c77">MP3BITRATE_320K</a>,
<a name="l00119"></a>00119         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a8f4910c75f7b2f7e74175dec10bb312c">MP3BITRATE_352K</a>,
<a name="l00120"></a>00120         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae8283ab0f851dcc9217b0f2d4be7c619">MP3BITRATE_384K</a>,
<a name="l00121"></a>00121         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a300439da9a2d643ff06e815d98a2544c">MP3BITRATE_416K</a>,
<a name="l00122"></a>00122         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a2a6d31bd8e1f44d006b48a8dfa868d3a">MP3BITRATE_448K</a>,
<a name="l00123"></a>00123         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>
<a name="l00124"></a>00124       },
<a name="l00125"></a>00125       { <span class="comment">//MPEG 1, LAYER II</span>
<a name="l00126"></a>00126         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a>,
<a name="l00127"></a>00127         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae7edf10d4fa632d04b2e646fd1359e99">MP3BITRATE_32K</a>,
<a name="l00128"></a>00128         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a7fa482ba0df513db9b59c3e6bf364371">MP3BITRATE_48K</a>,
<a name="l00129"></a>00129         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acfcc3c66143e3bbe7e82adb6f4ccd3f5">MP3BITRATE_56K</a>,
<a name="l00130"></a>00130         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aebb485aa008ad9231305534eb75645b0">MP3BITRATE_64K</a>,
<a name="l00131"></a>00131         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a2397efce3faa20130085cfdc4b06a850">MP3BITRATE_80K</a>,
<a name="l00132"></a>00132         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a772ac065539192e2c063c3c52a7ac755">MP3BITRATE_96K</a>,
<a name="l00133"></a>00133         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97abea16981be673e96e481374bfad1207b">MP3BITRATE_112K</a>,
<a name="l00134"></a>00134         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f1d1694a146e3d8457883112577326b">MP3BITRATE_128K</a>,
<a name="l00135"></a>00135         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a457a1962733e010eafdc7f4120c02c67">MP3BITRATE_160K</a>,
<a name="l00136"></a>00136         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ab727ff391b19516ae7711c532a50071f">MP3BITRATE_192K</a>,
<a name="l00137"></a>00137         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a67922457d07dab9207a1e2146f4f266a">MP3BITRATE_224K</a>,
<a name="l00138"></a>00138         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97adf0969f154c8a003adcc6b2ba3a1615b">MP3BITRATE_256K</a>,
<a name="l00139"></a>00139         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97afdab0fc0d3d5319489ba697f841b2c77">MP3BITRATE_320K</a>,
<a name="l00140"></a>00140         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae8283ab0f851dcc9217b0f2d4be7c619">MP3BITRATE_384K</a>,
<a name="l00141"></a>00141         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>
<a name="l00142"></a>00142       },
<a name="l00143"></a>00143       { <span class="comment">//MPEG 1, LAYER III</span>
<a name="l00144"></a>00144         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a>,
<a name="l00145"></a>00145         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae7edf10d4fa632d04b2e646fd1359e99">MP3BITRATE_32K</a>,
<a name="l00146"></a>00146         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a8ffaa7fc92c110b215c78444db563be8">MP3BITRATE_40K</a>,
<a name="l00147"></a>00147         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a7fa482ba0df513db9b59c3e6bf364371">MP3BITRATE_48K</a>,
<a name="l00148"></a>00148         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acfcc3c66143e3bbe7e82adb6f4ccd3f5">MP3BITRATE_56K</a>,
<a name="l00149"></a>00149         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aebb485aa008ad9231305534eb75645b0">MP3BITRATE_64K</a>,
<a name="l00150"></a>00150         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a2397efce3faa20130085cfdc4b06a850">MP3BITRATE_80K</a>,
<a name="l00151"></a>00151         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a772ac065539192e2c063c3c52a7ac755">MP3BITRATE_96K</a>,
<a name="l00152"></a>00152         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97abea16981be673e96e481374bfad1207b">MP3BITRATE_112K</a>,
<a name="l00153"></a>00153         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f1d1694a146e3d8457883112577326b">MP3BITRATE_128K</a>,
<a name="l00154"></a>00154         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a457a1962733e010eafdc7f4120c02c67">MP3BITRATE_160K</a>,
<a name="l00155"></a>00155         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ab727ff391b19516ae7711c532a50071f">MP3BITRATE_192K</a>,
<a name="l00156"></a>00156         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a67922457d07dab9207a1e2146f4f266a">MP3BITRATE_224K</a>,
<a name="l00157"></a>00157         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97adf0969f154c8a003adcc6b2ba3a1615b">MP3BITRATE_256K</a>,
<a name="l00158"></a>00158         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97afdab0fc0d3d5319489ba697f841b2c77">MP3BITRATE_320K</a>,
<a name="l00159"></a>00159         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>
<a name="l00160"></a>00160       }
<a name="l00161"></a>00161     },
<a name="l00162"></a>00162     {
<a name="l00163"></a>00163       { <span class="comment">//MPEG 2 or 2.5, LAYER I</span>
<a name="l00164"></a>00164         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a>,
<a name="l00165"></a>00165         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae7edf10d4fa632d04b2e646fd1359e99">MP3BITRATE_32K</a>,
<a name="l00166"></a>00166         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a7fa482ba0df513db9b59c3e6bf364371">MP3BITRATE_48K</a>,
<a name="l00167"></a>00167         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acfcc3c66143e3bbe7e82adb6f4ccd3f5">MP3BITRATE_56K</a>,
<a name="l00168"></a>00168         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aebb485aa008ad9231305534eb75645b0">MP3BITRATE_64K</a>,
<a name="l00169"></a>00169         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a2397efce3faa20130085cfdc4b06a850">MP3BITRATE_80K</a>,
<a name="l00170"></a>00170         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a772ac065539192e2c063c3c52a7ac755">MP3BITRATE_96K</a>,
<a name="l00171"></a>00171         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97abea16981be673e96e481374bfad1207b">MP3BITRATE_112K</a>,
<a name="l00172"></a>00172         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f1d1694a146e3d8457883112577326b">MP3BITRATE_128K</a>,
<a name="l00173"></a>00173         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aee3af5db3f861e50a76bd3dc7f5eb7b9">MP3BITRATE_144K</a>,
<a name="l00174"></a>00174         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a457a1962733e010eafdc7f4120c02c67">MP3BITRATE_160K</a>,
<a name="l00175"></a>00175         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f8d3dec567ae0a8774a751d36c4f59f">MP3BITRATE_176K</a>,
<a name="l00176"></a>00176         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ab727ff391b19516ae7711c532a50071f">MP3BITRATE_192K</a>,
<a name="l00177"></a>00177         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a67922457d07dab9207a1e2146f4f266a">MP3BITRATE_224K</a>,
<a name="l00178"></a>00178         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97adf0969f154c8a003adcc6b2ba3a1615b">MP3BITRATE_256K</a>,
<a name="l00179"></a>00179         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>
<a name="l00180"></a>00180       },
<a name="l00181"></a>00181       { <span class="comment">//MPEG 2 or 2.5, LAYER II</span>
<a name="l00182"></a>00182         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a>,
<a name="l00183"></a>00183         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a6cc0c2b843f71ae70fbcc233d10def32">MP3BITRATE_8K</a>,
<a name="l00184"></a>00184         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a8d8cd733797471837cb91b163ea10b70">MP3BITRATE_16K</a>,
<a name="l00185"></a>00185         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acf85905460ee508b0667a31d67a55e5b">MP3BITRATE_24K</a>,
<a name="l00186"></a>00186         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae7edf10d4fa632d04b2e646fd1359e99">MP3BITRATE_32K</a>,
<a name="l00187"></a>00187         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a8ffaa7fc92c110b215c78444db563be8">MP3BITRATE_40K</a>,
<a name="l00188"></a>00188         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a7fa482ba0df513db9b59c3e6bf364371">MP3BITRATE_48K</a>,
<a name="l00189"></a>00189         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acfcc3c66143e3bbe7e82adb6f4ccd3f5">MP3BITRATE_56K</a>,
<a name="l00190"></a>00190         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aebb485aa008ad9231305534eb75645b0">MP3BITRATE_64K</a>,
<a name="l00191"></a>00191         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a2397efce3faa20130085cfdc4b06a850">MP3BITRATE_80K</a>,
<a name="l00192"></a>00192         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a772ac065539192e2c063c3c52a7ac755">MP3BITRATE_96K</a>,
<a name="l00193"></a>00193         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97abea16981be673e96e481374bfad1207b">MP3BITRATE_112K</a>,
<a name="l00194"></a>00194         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f1d1694a146e3d8457883112577326b">MP3BITRATE_128K</a>,
<a name="l00195"></a>00195         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aee3af5db3f861e50a76bd3dc7f5eb7b9">MP3BITRATE_144K</a>,
<a name="l00196"></a>00196         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a457a1962733e010eafdc7f4120c02c67">MP3BITRATE_160K</a>,
<a name="l00197"></a>00197         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>
<a name="l00198"></a>00198       },
<a name="l00199"></a>00199       { <span class="comment">//MPEG 2 or 2.5, LAYER III</span>
<a name="l00200"></a>00200         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a>,
<a name="l00201"></a>00201         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a6cc0c2b843f71ae70fbcc233d10def32">MP3BITRATE_8K</a>,
<a name="l00202"></a>00202         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a8d8cd733797471837cb91b163ea10b70">MP3BITRATE_16K</a>,
<a name="l00203"></a>00203         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acf85905460ee508b0667a31d67a55e5b">MP3BITRATE_24K</a>,
<a name="l00204"></a>00204         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ae7edf10d4fa632d04b2e646fd1359e99">MP3BITRATE_32K</a>,
<a name="l00205"></a>00205         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a8ffaa7fc92c110b215c78444db563be8">MP3BITRATE_40K</a>,
<a name="l00206"></a>00206         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a7fa482ba0df513db9b59c3e6bf364371">MP3BITRATE_48K</a>,
<a name="l00207"></a>00207         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97acfcc3c66143e3bbe7e82adb6f4ccd3f5">MP3BITRATE_56K</a>,
<a name="l00208"></a>00208         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aebb485aa008ad9231305534eb75645b0">MP3BITRATE_64K</a>,
<a name="l00209"></a>00209         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a2397efce3faa20130085cfdc4b06a850">MP3BITRATE_80K</a>,
<a name="l00210"></a>00210         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a772ac065539192e2c063c3c52a7ac755">MP3BITRATE_96K</a>,
<a name="l00211"></a>00211         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97abea16981be673e96e481374bfad1207b">MP3BITRATE_112K</a>,
<a name="l00212"></a>00212         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a5f1d1694a146e3d8457883112577326b">MP3BITRATE_128K</a>,
<a name="l00213"></a>00213         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97aee3af5db3f861e50a76bd3dc7f5eb7b9">MP3BITRATE_144K</a>,
<a name="l00214"></a>00214         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a457a1962733e010eafdc7f4120c02c67">MP3BITRATE_160K</a>,
<a name="l00215"></a>00215         <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>
<a name="l00216"></a>00216       }
<a name="l00217"></a>00217     }
<a name="l00218"></a>00218   };
<a name="l00219"></a>00219 
<a name="l00220"></a>00220   <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6">Mp3_Frequencies</a> _mp3_frequencies[4][4] =
<a name="l00221"></a>00221   {
<a name="l00222"></a>00222     { <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a2f8182cfc3beac34d1caf1c10f95becf">MP3FREQUENCIES_11025HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6aaf59bfbc4b67e675b40c6ce77eb89aa5">MP3FREQUENCIES_12000HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6aa77f556c7ffb1e7fb83d5c481201524b">MP3FREQUENCIES_8000HZ</a>,<a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6abc265e38f6cc7935d01061733cc62886">MP3FREQUENCIES_Reserved</a> },  <span class="comment">//MPEGVERSION_2_5</span>
<a name="l00223"></a>00223     { <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6abc265e38f6cc7935d01061733cc62886">MP3FREQUENCIES_Reserved</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6abc265e38f6cc7935d01061733cc62886">MP3FREQUENCIES_Reserved</a>, MP3FREQUENCIES_Reserved, MP3FREQUENCIES_Reserved},          <span class="comment">//MPEGVERSION_Reserved</span>
<a name="l00224"></a>00224     { <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a8099063fa4f7467c1ba5963c98d20e53">MP3FREQUENCIES_22050HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a10a8a39a579425424240ae360acd11de">MP3FREQUENCIES_24000HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a8caa4d809d60af133ec72254c5cec093">MP3FREQUENCIES_16000HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6abc265e38f6cc7935d01061733cc62886">MP3FREQUENCIES_Reserved</a> }, <span class="comment">//MPEGVERSION_2</span>
<a name="l00225"></a>00225     { <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a221ea7aa219e71062530e78f3abb12e3">MP3FREQUENCIES_44100HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a0eada4d77abbf101dd3ac7b7cf913e5c">MP3FREQUENCIES_48000HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6a319141f7510f0463b3a052632e410065">MP3FREQUENCIES_32000HZ</a>, <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6abc265e38f6cc7935d01061733cc62886">MP3FREQUENCIES_Reserved</a> }  <span class="comment">//MPEGVERSION_1</span>
<a name="l00226"></a>00226   };
<a name="l00227"></a>00227 
<a name="l00228"></a>00228   _mp3_header_internal *_tmpheader;
<a name="l00229"></a>00229 
<a name="l00230"></a>00230   <span class="keyword">const</span> <span class="keywordtype">size_t</span> HEADERSIZE = 4;<span class="comment">//</span>
<a name="l00231"></a>00231   <span class="keywordtype">char</span> buf[HEADERSIZE+1]; <span class="comment">//+1 to hold the \0 char</span>
<a name="l00232"></a>00232   <a class="code" href="class_i_d3___reader.html#a83194ea4d4e04e81302b095e9aa2275a">ID3_Reader::pos_type</a> beg = reader.<a class="code" href="class_i_d3___reader.html#a232935e138e44ea49e5a289fb8d7ac94" title="Return the current position in the reader.">getCur</a>() ;
<a name="l00233"></a>00233   <a class="code" href="class_i_d3___reader.html#a83194ea4d4e04e81302b095e9aa2275a">ID3_Reader::pos_type</a> end = beg + HEADERSIZE ;
<a name="l00234"></a>00234   reader.<a class="code" href="class_i_d3___reader.html#a1630f369cc7aa65a2279542715e9f483" title="Set the value of the current position for reading.">setCur</a>(beg);
<a name="l00235"></a>00235   <span class="keywordtype">int</span> bitrate_index;
<a name="l00236"></a>00236 
<a name="l00237"></a>00237   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a124b86252f64e7c86e24dd0f96ceb0ca">layer</a> = <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6ea78b389bf3127608b91a1c01de3c2eb94">MPEGLAYER_FALSE</a>;
<a name="l00238"></a>00238   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ada63433940a2cebe60a2e50703830a9a">version</a> = <a class="code" href="globals_8h.html#ad06786abcdc3df5e30a1f3dac64cf8c9aedcefbc9bb4045c7ef9b838797688441">MPEGVERSION_FALSE</a>;
<a name="l00239"></a>00239   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> = <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>;
<a name="l00240"></a>00240   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> = <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07aa99cd401a8b9405b9c482a682707f107">MP3CHANNELMODE_FALSE</a>;
<a name="l00241"></a>00241   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ae9f6b7b5a9fe89d3ae2ce16f03e07afd">modeext</a> = <a class="code" href="globals_8h.html#a1c603c7c1023d96b7df745034afc05c6aeb904179110516a02e838c2c8b6d90dc">MP3MODEEXT_FALSE</a>;
<a name="l00242"></a>00242   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a946c46893e47554bad33dd44b40173a7">emphasis</a> = <a class="code" href="globals_8h.html#a21cf2b3e12eb5da50f4a4f1bf55d6dfba9d32f476e0db523f5554d57b492c4384">MP3EMPHASIS_FALSE</a>;
<a name="l00243"></a>00243   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> = <a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3ea8eae0d93d3e7d61f547bfd3753dad584">MP3CRC_MISMATCH</a>;
<a name="l00244"></a>00244   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> = 0;
<a name="l00245"></a>00245   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> = 0;
<a name="l00246"></a>00246   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aaf5a59236a3ebd94aef870bcd3668465">frames</a> = 0;
<a name="l00247"></a>00247   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a6dd9d91121205de5b080b0435e21821a">time</a> = 0;
<a name="l00248"></a>00248   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad0fb1f3fa6e70eda74e10b7c9be66802">vbr_bitrate</a> = 0;
<a name="l00249"></a>00249 
<a name="l00250"></a>00250   reader.<a class="code" href="class_i_d3___reader.html#a271015a0481e80ca63bfea9ff9320a50" title="Read up to len characters into buf and advance the internal position accordingly...">readChars</a>(buf, HEADERSIZE);
<a name="l00251"></a>00251   buf[HEADERSIZE]=<span class="charliteral">&#39;\0&#39;</span>;
<a name="l00252"></a>00252   <span class="comment">// copy the pointer to the struct</span>
<a name="l00253"></a>00253 
<a name="l00254"></a>00254   <span class="keywordflow">if</span> (((buf[0] &amp; 0xFF) != 0xFF) || ((buf[1] &amp; 0xE0) != 0xE0)) <span class="comment">//first 11 bits should be 1</span>
<a name="l00255"></a>00255   {
<a name="l00256"></a>00256     this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00257"></a>00257     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00258"></a>00258   }
<a name="l00259"></a>00259 
<a name="l00260"></a>00260   _tmpheader = <span class="keyword">reinterpret_cast&lt;</span>_mp3_header_internal *<span class="keyword">&gt;</span>(buf);
<a name="l00261"></a>00261 
<a name="l00262"></a>00262   bitrate_index = 0;
<a name="l00263"></a>00263   <span class="keywordflow">switch</span> (_tmpheader-&gt;id)
<a name="l00264"></a>00264   {
<a name="l00265"></a>00265     <span class="keywordflow">case</span> 3:
<a name="l00266"></a>00266       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ada63433940a2cebe60a2e50703830a9a">version</a> = <a class="code" href="globals_8h.html#ad06786abcdc3df5e30a1f3dac64cf8c9af97f43ccf6d8807643e2aba54275bb48">MPEGVERSION_1</a>;
<a name="l00267"></a>00267       bitrate_index = 0;
<a name="l00268"></a>00268       <span class="keywordflow">break</span>;
<a name="l00269"></a>00269     <span class="keywordflow">case</span> 2:
<a name="l00270"></a>00270       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ada63433940a2cebe60a2e50703830a9a">version</a> = <a class="code" href="globals_8h.html#ad06786abcdc3df5e30a1f3dac64cf8c9af5fc9d059430784e71fb181e492ee834">MPEGVERSION_2</a>;
<a name="l00271"></a>00271       bitrate_index = 1;
<a name="l00272"></a>00272       <span class="keywordflow">break</span>;
<a name="l00273"></a>00273     <span class="keywordflow">case</span> 1:
<a name="l00274"></a>00274       this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00275"></a>00275       <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//wouldn&#39;t know how to handle it</span>
<a name="l00276"></a>00276       <span class="keywordflow">break</span>;
<a name="l00277"></a>00277     <span class="keywordflow">case</span> 0:
<a name="l00278"></a>00278       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ada63433940a2cebe60a2e50703830a9a">version</a> = <a class="code" href="globals_8h.html#ad06786abcdc3df5e30a1f3dac64cf8c9a162a1cf9dfd793a6a3edd2d1f4b7d752">MPEGVERSION_2_5</a>;
<a name="l00279"></a>00279       bitrate_index = 1;
<a name="l00280"></a>00280       <span class="keywordflow">break</span>;
<a name="l00281"></a>00281     <span class="keywordflow">default</span>:
<a name="l00282"></a>00282       this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00283"></a>00283       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00284"></a>00284       <span class="keywordflow">break</span>;
<a name="l00285"></a>00285   };
<a name="l00286"></a>00286 
<a name="l00287"></a>00287   <span class="keywordflow">switch</span> (_tmpheader-&gt;layer)
<a name="l00288"></a>00288   {
<a name="l00289"></a>00289     <span class="keywordflow">case</span> 3:
<a name="l00290"></a>00290       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a124b86252f64e7c86e24dd0f96ceb0ca">layer</a> = <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6ea2690f357d5dee4c64513812c074c8f3b">MPEGLAYER_I</a>;
<a name="l00291"></a>00291       <span class="keywordflow">break</span>;
<a name="l00292"></a>00292     <span class="keywordflow">case</span> 2:
<a name="l00293"></a>00293       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a124b86252f64e7c86e24dd0f96ceb0ca">layer</a> = <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6ea4cd8c7ba12fe7f630bd842c37b279238">MPEGLAYER_II</a>;
<a name="l00294"></a>00294       <span class="keywordflow">break</span>;
<a name="l00295"></a>00295     <span class="keywordflow">case</span> 1:
<a name="l00296"></a>00296       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a124b86252f64e7c86e24dd0f96ceb0ca">layer</a> = <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6eaad643e5e3bd7df824d18da945960e5d0">MPEGLAYER_III</a>;
<a name="l00297"></a>00297       <span class="keywordflow">break</span>;
<a name="l00298"></a>00298     <span class="keywordflow">case</span> 0:
<a name="l00299"></a>00299       this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00300"></a>00300       <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//wouldn&#39;t know how to handle it</span>
<a name="l00301"></a>00301       <span class="keywordflow">break</span>;
<a name="l00302"></a>00302     <span class="keywordflow">default</span>:
<a name="l00303"></a>00303       this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00304"></a>00304       <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//how can two unsigned bits be something else??</span>
<a name="l00305"></a>00305       <span class="keywordflow">break</span>;
<a name="l00306"></a>00306   };
<a name="l00307"></a>00307 
<a name="l00308"></a>00308   <span class="comment">// mpegversion, layer and bitrate are all valid</span>
<a name="l00309"></a>00309   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> = _mp3_bitrates[bitrate_index][3-_tmpheader-&gt;layer][_tmpheader-&gt;bitrate_index];
<a name="l00310"></a>00310   <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> == <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97ad10d51d201c771304933fd538302a247">MP3BITRATE_FALSE</a>)
<a name="l00311"></a>00311   {
<a name="l00312"></a>00312     this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00313"></a>00313     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00314"></a>00314   }
<a name="l00315"></a>00315   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> = _mp3_frequencies[_tmpheader-&gt;id][_tmpheader-&gt;frequency];
<a name="l00316"></a>00316   <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> == <a class="code" href="globals_8h.html#a1f210b81be389d1c12b8cef2f26932e6abc265e38f6cc7935d01061733cc62886">MP3FREQUENCIES_Reserved</a>)
<a name="l00317"></a>00317   {
<a name="l00318"></a>00318     this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00319"></a>00319     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00320"></a>00320   }
<a name="l00321"></a>00321 
<a name="l00322"></a>00322   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ade126b2e5e31d3723fe92e492a1ef175">privatebit</a> = (bool)_tmpheader-&gt;private_bit;
<a name="l00323"></a>00323   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a9c028ccefef818faf7f62714f409366e">copyrighted</a> = (<span class="keywordtype">bool</span>)_tmpheader-&gt;copyright;
<a name="l00324"></a>00324   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a55eaa9108bff1b8628d0851966affb57">original</a> = (bool)_tmpheader-&gt;original;
<a name="l00325"></a>00325   _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> = (<a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3e">Mp3_Crc</a>)!(bool)_tmpheader-&gt;protection_bit;
<a name="l00326"></a>00326 
<a name="l00327"></a>00327   switch (_tmpheader-&gt;mode)
<a name="l00328"></a>00328   {
<a name="l00329"></a>00329   <span class="keywordflow">case</span> 3:
<a name="l00330"></a>00330     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> = <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07a946c1df7a89038069c21ca2faeacd0b1">MP3CHANNELMODE_SINGLE_CHANNEL</a>;
<a name="l00331"></a>00331     <span class="keywordflow">break</span>;
<a name="l00332"></a>00332   <span class="keywordflow">case</span> 2:
<a name="l00333"></a>00333     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> = <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07a0cd87319f39f3b69b570edf63b74c574">MP3CHANNELMODE_DUAL_CHANNEL</a>;
<a name="l00334"></a>00334     <span class="keywordflow">break</span>;
<a name="l00335"></a>00335   <span class="keywordflow">case</span> 1:
<a name="l00336"></a>00336     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> = <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07ad86a81dc791d34c4a9c7658e9956b3d7">MP3CHANNELMODE_JOINT_STEREO</a>;
<a name="l00337"></a>00337     <span class="keywordflow">break</span>;
<a name="l00338"></a>00338   <span class="keywordflow">case</span> 0:
<a name="l00339"></a>00339     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> = <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07a1be4ddbb0ca743e64e9b024bf1a288fa">MP3CHANNELMODE_STEREO</a>;
<a name="l00340"></a>00340     <span class="keywordflow">break</span>;
<a name="l00341"></a>00341   <span class="keywordflow">default</span>:
<a name="l00342"></a>00342     this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00343"></a>00343     <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//wouldn&#39;t know how to handle it</span>
<a name="l00344"></a>00344     <span class="keywordflow">break</span>;
<a name="l00345"></a>00345   }
<a name="l00346"></a>00346 
<a name="l00347"></a>00347   <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> == <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07ad86a81dc791d34c4a9c7658e9956b3d7">MP3CHANNELMODE_JOINT_STEREO</a>)
<a name="l00348"></a>00348   {
<a name="l00349"></a>00349     <span class="comment">// these have a different meaning for different layers, better give them a generic name in the enum</span>
<a name="l00350"></a>00350     <span class="keywordflow">switch</span> (_tmpheader-&gt;mode_ext)
<a name="l00351"></a>00351     {
<a name="l00352"></a>00352     <span class="keywordflow">case</span> 3:
<a name="l00353"></a>00353       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ae9f6b7b5a9fe89d3ae2ce16f03e07afd">modeext</a> = <a class="code" href="globals_8h.html#a1c603c7c1023d96b7df745034afc05c6a1ba744c4af8f3fa39655754323c9bc84">MP3MODEEXT_3</a>;
<a name="l00354"></a>00354       <span class="keywordflow">break</span>;
<a name="l00355"></a>00355     <span class="keywordflow">case</span> 2:
<a name="l00356"></a>00356       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ae9f6b7b5a9fe89d3ae2ce16f03e07afd">modeext</a> = <a class="code" href="globals_8h.html#a1c603c7c1023d96b7df745034afc05c6ac0f6d0950398954d0a79e7aa18e711ef">MP3MODEEXT_2</a>;
<a name="l00357"></a>00357       <span class="keywordflow">break</span>;
<a name="l00358"></a>00358     <span class="keywordflow">case</span> 1:
<a name="l00359"></a>00359       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ae9f6b7b5a9fe89d3ae2ce16f03e07afd">modeext</a> = <a class="code" href="globals_8h.html#a1c603c7c1023d96b7df745034afc05c6adf83e4ff77ed561f2d114bd63da8e7dc">MP3MODEEXT_1</a>;
<a name="l00360"></a>00360       <span class="keywordflow">break</span>;
<a name="l00361"></a>00361     <span class="keywordflow">case</span> 0:
<a name="l00362"></a>00362       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ae9f6b7b5a9fe89d3ae2ce16f03e07afd">modeext</a> = <a class="code" href="globals_8h.html#a1c603c7c1023d96b7df745034afc05c6a2f75e2938f9ce8f21a21cee498c53000">MP3MODEEXT_0</a>;
<a name="l00363"></a>00363       <span class="keywordflow">break</span>;
<a name="l00364"></a>00364     <span class="keywordflow">default</span>:
<a name="l00365"></a>00365       this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00366"></a>00366       <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//wouldn&#39;t know how to handle it</span>
<a name="l00367"></a>00367       <span class="keywordflow">break</span>;
<a name="l00368"></a>00368     }
<a name="l00369"></a>00369   }
<a name="l00370"></a>00370   <span class="keywordflow">else</span> <span class="comment">//it&#39;s valid to have a valid false one in this case, since it&#39;s only used with joint stereo</span>
<a name="l00371"></a>00371     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ae9f6b7b5a9fe89d3ae2ce16f03e07afd">modeext</a> = <a class="code" href="globals_8h.html#a1c603c7c1023d96b7df745034afc05c6aeb904179110516a02e838c2c8b6d90dc">MP3MODEEXT_FALSE</a>;
<a name="l00372"></a>00372 
<a name="l00373"></a>00373   <span class="keywordflow">switch</span> (_tmpheader-&gt;emphasis)
<a name="l00374"></a>00374   {
<a name="l00375"></a>00375   <span class="keywordflow">case</span> 3:
<a name="l00376"></a>00376     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a946c46893e47554bad33dd44b40173a7">emphasis</a> = <a class="code" href="globals_8h.html#a21cf2b3e12eb5da50f4a4f1bf55d6dfba14886bd663e6c95bd1ef9fd3f57dd5a9">MP3EMPHASIS_CCIT_J17</a>;
<a name="l00377"></a>00377     <span class="keywordflow">break</span>;
<a name="l00378"></a>00378   <span class="keywordflow">case</span> 2:
<a name="l00379"></a>00379     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a946c46893e47554bad33dd44b40173a7">emphasis</a> = <a class="code" href="globals_8h.html#a21cf2b3e12eb5da50f4a4f1bf55d6dfbadedc998d4c9e32c5ed243e7834348691">MP3EMPHASIS_Reserved</a>;
<a name="l00380"></a>00380     <span class="keywordflow">break</span>;
<a name="l00381"></a>00381   <span class="keywordflow">case</span> 1:
<a name="l00382"></a>00382     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a946c46893e47554bad33dd44b40173a7">emphasis</a> = <a class="code" href="globals_8h.html#a21cf2b3e12eb5da50f4a4f1bf55d6dfba08a4c17e01f3537931082e305a0d0d2a">MP3EMPHASIS_50_15MS</a>;
<a name="l00383"></a>00383     <span class="keywordflow">break</span>;
<a name="l00384"></a>00384   <span class="keywordflow">case</span> 0:
<a name="l00385"></a>00385     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a946c46893e47554bad33dd44b40173a7">emphasis</a> = <a class="code" href="globals_8h.html#a21cf2b3e12eb5da50f4a4f1bf55d6dfbac24413e0bdcc2a0ea6ed19fa0e765ec3">MP3EMPHASIS_NONE</a>;
<a name="l00386"></a>00386     <span class="keywordflow">break</span>;
<a name="l00387"></a>00387   <span class="keywordflow">default</span>:
<a name="l00388"></a>00388     this-&gt;<a class="code" href="class_mp3_info.html#ad47fa646d152045fc473c54a8b252672">Clean</a>();
<a name="l00389"></a>00389     <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">//wouldn&#39;t know how to handle it</span>
<a name="l00390"></a>00390     <span class="keywordflow">break</span>;
<a name="l00391"></a>00391   }
<a name="l00392"></a>00392 
<a name="l00393"></a>00393 <span class="comment">//http://www.mp3-tech.org/programmer/frame_header.html</span>
<a name="l00394"></a>00394   <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> != <a class="code" href="globals_8h.html#a9f7780a5d40c597dab61864c9b7dcb97a078d898aa2a74ba8b9e2e9fce85188dd">MP3BITRATE_NONE</a> &amp;&amp; _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> &gt; 0)
<a name="l00395"></a>00395   {
<a name="l00396"></a>00396 
<a name="l00397"></a>00397     <span class="keywordflow">switch</span>(_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a124b86252f64e7c86e24dd0f96ceb0ca">layer</a>)
<a name="l00398"></a>00398     {
<a name="l00399"></a>00399       <span class="keywordflow">case</span> <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6ea2690f357d5dee4c64513812c074c8f3b">MPEGLAYER_I</a>: <span class="comment">// Layer 1</span>
<a name="l00400"></a>00400         _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> = 4 * (12 * _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> / _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> + (_tmpheader-&gt;padding_bit ? 1 : 0));
<a name="l00401"></a>00401         <span class="keywordflow">break</span>;
<a name="l00402"></a>00402       <span class="keywordflow">case</span> <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6ea4cd8c7ba12fe7f630bd842c37b279238">MPEGLAYER_II</a>: <span class="comment">// Layer 2</span>
<a name="l00403"></a>00403         _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> = 144 * _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> / _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> + (_tmpheader-&gt;padding_bit ? 1 : 0);
<a name="l00404"></a>00404         <span class="keywordflow">break</span>;
<a name="l00405"></a>00405       <span class="keywordflow">case</span> <a class="code" href="globals_8h.html#a52c49c7c4c67c4391cc3c97ba2cb3e6eaad643e5e3bd7df824d18da945960e5d0">MPEGLAYER_III</a>: <span class="comment">// Layer 3</span>
<a name="l00406"></a>00406         <span class="keywordflow">if</span>(_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ada63433940a2cebe60a2e50703830a9a">version</a> == <a class="code" href="globals_8h.html#ad06786abcdc3df5e30a1f3dac64cf8c9a162a1cf9dfd793a6a3edd2d1f4b7d752">MPEGVERSION_2_5</a>)
<a name="l00407"></a>00407           _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> = 144 * _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> / _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> + (_tmpheader-&gt;padding_bit ? 1 : 0); <span class="comment">//Mpeg1</span>
<a name="l00408"></a>00408         <span class="keywordflow">else</span>
<a name="l00409"></a>00409           _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> =  72000 * _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> / _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> + (_tmpheader-&gt;padding_bit ? 1 : 0); <span class="comment">//Mpeg2 + Mpeg2.5</span>
<a name="l00410"></a>00410         <span class="keywordflow">break</span>;
<a name="l00411"></a>00411     }
<a name="l00412"></a>00412 <span class="comment">//    if (_mp3_header_output-&gt;layer == MPEGLAYER_I)</span>
<a name="l00413"></a>00413 <span class="comment">//      _mp3_header_output-&gt;framesize = fto_nearest_i((float)((48 * (float)_mp3_header_output-&gt;bitrate) / _mp3_header_output-&gt;frequency)) + (_tmpheader-&gt;padding_bit ? 4 : 0);</span>
<a name="l00414"></a>00414 <span class="comment">//    else</span>
<a name="l00415"></a>00415 <span class="comment">//      _mp3_header_output-&gt;framesize = fto_nearest_i((float)((144 * (float)_mp3_header_output-&gt;bitrate) / _mp3_header_output-&gt;frequency)) + (_tmpheader-&gt;padding_bit ? 1 : 0);</span>
<a name="l00416"></a>00416   }
<a name="l00417"></a>00417   <span class="keywordflow">else</span>
<a name="l00418"></a>00418     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> = 0; <span class="comment">//unable to determine</span>
<a name="l00419"></a>00419 
<a name="l00420"></a>00420   <span class="keyword">const</span> <span class="keywordtype">size_t</span> CRCSIZE = 2;
<a name="l00421"></a>00421   <span class="keywordtype">size_t</span> sideinfo_len;
<a name="l00422"></a>00422 
<a name="l00423"></a>00423   <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ada63433940a2cebe60a2e50703830a9a">version</a> == <a class="code" href="globals_8h.html#ad06786abcdc3df5e30a1f3dac64cf8c9af97f43ccf6d8807643e2aba54275bb48">MPEGVERSION_1</a>) <span class="comment">/* MPEG 1 */</span>
<a name="l00424"></a>00424     sideinfo_len = (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> == <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07a946c1df7a89038069c21ca2faeacd0b1">MP3CHANNELMODE_SINGLE_CHANNEL</a>) ? 4 + 17 : 4 + 32;
<a name="l00425"></a>00425   <span class="keywordflow">else</span>                <span class="comment">/* MPEG 2 */</span>
<a name="l00426"></a>00426     sideinfo_len = (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a176b706f112528ff03a2ab8ab722b3f6">channelmode</a> == <a class="code" href="globals_8h.html#a56da27326370a3bb7647dd351f920c07a946c1df7a89038069c21ca2faeacd0b1">MP3CHANNELMODE_SINGLE_CHANNEL</a>) ? 4 + 9 : 4 + 17;
<a name="l00427"></a>00427 
<a name="l00428"></a>00428   <span class="keywordtype">int</span> vbr_header_offest = beg + sideinfo_len;
<a name="l00429"></a>00429   <span class="keywordtype">int</span> vbr_frames = 0;
<a name="l00430"></a>00430 
<a name="l00431"></a>00431   sideinfo_len += 2; <span class="comment">// add two for the crc itself</span>
<a name="l00432"></a>00432 
<a name="l00433"></a>00433   <span class="keywordflow">if</span> ((_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> == <a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3eaa3bf6050228ce540525bd857939aa43b">MP3CRC_OK</a>) &amp;&amp; mp3size &lt; sideinfo_len)
<a name="l00434"></a>00434     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> = <a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3ea8efebd674bf8c756a4945fb8c3198401">MP3CRC_ERROR_SIZE</a>;
<a name="l00435"></a>00435 
<a name="l00436"></a>00436   if (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> == <a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3eaa3bf6050228ce540525bd857939aa43b">MP3CRC_OK</a>)
<a name="l00437"></a>00437   {
<a name="l00438"></a>00438     <span class="keywordtype">char</span> audiodata[38 + 1]; <span class="comment">//+1 to hold the 0 char</span>
<a name="l00439"></a>00439     uint16 crc16;
<a name="l00440"></a>00440     uint16 crcstored;
<a name="l00441"></a>00441 
<a name="l00442"></a>00442     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> = <a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3ea8eae0d93d3e7d61f547bfd3753dad584">MP3CRC_MISMATCH</a>; <span class="comment">//as a starting point, we assume the worst</span>
<a name="l00443"></a>00443 
<a name="l00444"></a>00444     reader.<a class="code" href="class_i_d3___reader.html#a1630f369cc7aa65a2279542715e9f483" title="Set the value of the current position for reading.">setCur</a>(beg);
<a name="l00445"></a>00445 
<a name="l00446"></a>00446     reader.<a class="code" href="class_i_d3___reader.html#a271015a0481e80ca63bfea9ff9320a50" title="Read up to len characters into buf and advance the internal position accordingly...">readChars</a>(audiodata, sideinfo_len);
<a name="l00447"></a>00447     audiodata[sideinfo_len] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00448"></a>00448 
<a name="l00449"></a>00449     crc16 = <a class="code" href="mp3__parse_8cpp.html#a2cab9eb351e331aff2f8b6ab92d73be2">calcCRC</a>(audiodata, sideinfo_len);
<a name="l00450"></a>00450 
<a name="l00451"></a>00451     beg = end;
<a name="l00452"></a>00452     end = beg + CRCSIZE;
<a name="l00453"></a>00453 
<a name="l00454"></a>00454     reader.<a class="code" href="class_i_d3___reader.html#a1630f369cc7aa65a2279542715e9f483" title="Set the value of the current position for reading.">setCur</a>(beg);
<a name="l00455"></a>00455     crcstored = (uint16)<a class="code" href="namespacedami_1_1io.html#a4795dfc73c82683365f2738567c1d805">io::readBENumber</a>(reader, CRCSIZE);
<a name="l00456"></a>00456 
<a name="l00457"></a>00457     <span class="comment">// a mismatch doesn&#39;t mean the file is unusable</span>
<a name="l00458"></a>00458     <span class="comment">// it has just some bits in the wrong place</span>
<a name="l00459"></a>00459     <span class="keywordflow">if</span> (crcstored == crc16)
<a name="l00460"></a>00460       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aca1b9332d647355f19eb461383724589">crc</a> = <a class="code" href="globals_8h.html#a9831efb25494946ce3d7326f2ec04f3eaa3bf6050228ce540525bd857939aa43b">MP3CRC_OK</a>;
<a name="l00461"></a>00461   }
<a name="l00462"></a>00462 
<a name="l00463"></a>00463   <span class="comment">// read xing/vbr header if present</span>
<a name="l00464"></a>00464   <span class="comment">// derived from code in vbrheadersdk.zip </span>
<a name="l00465"></a>00465   <span class="comment">// from http://www.xingtech.com/developer/mp3/</span>
<a name="l00466"></a>00466 
<a name="l00467"></a>00467   <span class="keyword">const</span> <span class="keywordtype">size_t</span> VBR_HEADER_MIN_SIZE = 8;     <span class="comment">// &quot;xing&quot; + flags are fixed</span>
<a name="l00468"></a>00468   <span class="keyword">const</span> <span class="keywordtype">size_t</span> VBR_HEADER_MAX_SIZE = 116;   <span class="comment">// frames, bytes, toc and scale are optional</span>
<a name="l00469"></a>00469 
<a name="l00470"></a>00470   <span class="keywordflow">if</span> (mp3size &gt;= vbr_header_offest + VBR_HEADER_MIN_SIZE) 
<a name="l00471"></a>00471   {
<a name="l00472"></a>00472     <span class="keywordtype">char</span> vbrheaderdata[VBR_HEADER_MAX_SIZE+1]; <span class="comment">//+1 to hold the 0 char</span>
<a name="l00473"></a>00473     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *pvbrdata = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)vbrheaderdata;
<a name="l00474"></a>00474     <span class="keywordtype">int</span> vbr_filesize = 0;
<a name="l00475"></a>00475     <span class="keywordtype">int</span> vbr_scale = 0;
<a name="l00476"></a>00476     <span class="keywordtype">int</span> vbr_flags = 0;
<a name="l00477"></a>00477 
<a name="l00478"></a>00478     <span class="comment">// get fixed part of vbr header </span>
<a name="l00479"></a>00479     <span class="comment">// and check if valid</span>
<a name="l00480"></a>00480 
<a name="l00481"></a>00481     beg = vbr_header_offest;
<a name="l00482"></a>00482     reader.<a class="code" href="class_i_d3___reader.html#a1630f369cc7aa65a2279542715e9f483" title="Set the value of the current position for reading.">setCur</a>(beg);
<a name="l00483"></a>00483     reader.<a class="code" href="class_i_d3___reader.html#a271015a0481e80ca63bfea9ff9320a50" title="Read up to len characters into buf and advance the internal position accordingly...">readChars</a>(vbrheaderdata, VBR_HEADER_MIN_SIZE);
<a name="l00484"></a>00484     vbrheaderdata[VBR_HEADER_MIN_SIZE] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00485"></a>00485 
<a name="l00486"></a>00486     <span class="keywordflow">if</span> (pvbrdata[0] == <span class="charliteral">&#39;X&#39;</span> &amp;&amp;
<a name="l00487"></a>00487         pvbrdata[1] == <span class="charliteral">&#39;i&#39;</span> &amp;&amp;
<a name="l00488"></a>00488         pvbrdata[2] == <span class="charliteral">&#39;n&#39;</span> &amp;&amp;
<a name="l00489"></a>00489         pvbrdata[3] == <span class="charliteral">&#39;g&#39;</span>)
<a name="l00490"></a>00490     {
<a name="l00491"></a>00491       <span class="comment">// get vbr flags</span>
<a name="l00492"></a>00492       pvbrdata += 4;
<a name="l00493"></a>00493       vbr_flags = ExtractI4(pvbrdata);
<a name="l00494"></a>00494       pvbrdata += 4;
<a name="l00495"></a>00495 
<a name="l00496"></a>00496       <span class="comment">//  read entire vbr header</span>
<a name="l00497"></a>00497       <span class="keywordtype">int</span> vbr_header_size = VBR_HEADER_MIN_SIZE
<a name="l00498"></a>00498                            + ((vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#a99bc450005a5df27b410a9d7739e11bd">FRAMES_FLAG</a>)? 4:0)
<a name="l00499"></a>00499                            + ((vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#a07630cfeb2869eee8904d48ef7cc344d">BYTES_FLAG</a>)? 4:0)
<a name="l00500"></a>00500                            + ((vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#aea6153256089264f1b9af3484f07afb7">TOC_FLAG</a>)? 100:0)
<a name="l00501"></a>00501                            + ((vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#ab1e14bd903aa2ff3c830aaa32ad0c4fa">SCALE_FLAG</a>)? 4:0);
<a name="l00502"></a>00502 
<a name="l00503"></a>00503       <span class="keywordflow">if</span> (mp3size &gt;= vbr_header_offest + vbr_header_size) 
<a name="l00504"></a>00504       {
<a name="l00505"></a>00505         reader.<a class="code" href="class_i_d3___reader.html#a271015a0481e80ca63bfea9ff9320a50" title="Read up to len characters into buf and advance the internal position accordingly...">readChars</a>(&amp;vbrheaderdata[VBR_HEADER_MIN_SIZE], vbr_header_size - VBR_HEADER_MIN_SIZE); 
<a name="l00506"></a>00506         vbrheaderdata[vbr_header_size] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00507"></a>00507 
<a name="l00508"></a>00508         <span class="comment">// get frames, bytes, toc and scale</span>
<a name="l00509"></a>00509 
<a name="l00510"></a>00510         <span class="keywordflow">if</span> (vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#a99bc450005a5df27b410a9d7739e11bd">FRAMES_FLAG</a>)
<a name="l00511"></a>00511         {
<a name="l00512"></a>00512           vbr_frames = ExtractI4(pvbrdata); 
<a name="l00513"></a>00513           pvbrdata +=4;
<a name="l00514"></a>00514         }
<a name="l00515"></a>00515 
<a name="l00516"></a>00516         <span class="keywordflow">if</span> (vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#a07630cfeb2869eee8904d48ef7cc344d">BYTES_FLAG</a>)
<a name="l00517"></a>00517         {
<a name="l00518"></a>00518           vbr_filesize = ExtractI4(pvbrdata); 
<a name="l00519"></a>00519           pvbrdata +=4;
<a name="l00520"></a>00520         }
<a name="l00521"></a>00521 
<a name="l00522"></a>00522         <span class="keywordflow">if</span> (vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#aea6153256089264f1b9af3484f07afb7">TOC_FLAG</a>)
<a name="l00523"></a>00523         {
<a name="l00524"></a>00524           <span class="comment">// seek offsets</span>
<a name="l00525"></a>00525           <span class="comment">// we are not using</span>
<a name="l00526"></a>00526           <span class="comment">// for(i=0;i&lt;100;i++) seek_offsets[i] = pvbrdata[i];</span>
<a name="l00527"></a>00527 
<a name="l00528"></a>00528           pvbrdata +=100;
<a name="l00529"></a>00529         }
<a name="l00530"></a>00530 
<a name="l00531"></a>00531         <span class="keywordflow">if</span> (vbr_flags &amp; <a class="code" href="mp3__parse_8cpp.html#ab1e14bd903aa2ff3c830aaa32ad0c4fa">SCALE_FLAG</a>)
<a name="l00532"></a>00532         {
<a name="l00533"></a>00533           vbr_scale = ExtractI4(pvbrdata); 
<a name="l00534"></a>00534           pvbrdata +=4;
<a name="l00535"></a>00535         }
<a name="l00536"></a>00536 
<a name="l00537"></a>00537         <span class="keywordflow">if</span> (vbr_frames &gt; 0)
<a name="l00538"></a>00538         {
<a name="l00539"></a>00539           _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad0fb1f3fa6e70eda74e10b7c9be66802">vbr_bitrate</a> = (((vbr_filesize!=0) ? vbr_filesize : mp3size) / vbr_frames) * _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#afb7789a0c15105a2c7268725ebbac249">frequency</a> / 144;
<a name="l00540"></a>00540           _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad0fb1f3fa6e70eda74e10b7c9be66802">vbr_bitrate</a> -= _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad0fb1f3fa6e70eda74e10b7c9be66802">vbr_bitrate</a>%1000;   <span class="comment">// round the bitrate:</span>
<a name="l00541"></a>00541         }
<a name="l00542"></a>00542       }
<a name="l00543"></a>00543     }
<a name="l00544"></a>00544   }
<a name="l00545"></a>00545 
<a name="l00546"></a>00546   <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a> &gt; 0 &amp;&amp; mp3size &gt;= _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a>) <span class="comment">// this means bitrate is not none too</span>
<a name="l00547"></a>00547   {
<a name="l00548"></a>00548     <span class="keywordflow">if</span> (vbr_frames == 0)
<a name="l00549"></a>00549       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aaf5a59236a3ebd94aef870bcd3668465">frames</a> = <a class="code" href="mp3__parse_8cpp.html#ad49f76141cc7ebc2c3ab30827b8359a4">fto_nearest_i</a>((<span class="keywordtype">float</span>)mp3size / _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad9498e8d22e5b518a81b72e5a06623a2">framesize</a>);
<a name="l00550"></a>00550     <span class="keywordflow">else</span>
<a name="l00551"></a>00551       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aaf5a59236a3ebd94aef870bcd3668465">frames</a> = vbr_frames;
<a name="l00552"></a>00552 
<a name="l00553"></a>00553     <span class="comment">// bitrate becomes byterate (per second) if divided by 8</span>
<a name="l00554"></a>00554     <span class="keywordflow">if</span> (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad0fb1f3fa6e70eda74e10b7c9be66802">vbr_bitrate</a> == 0)
<a name="l00555"></a>00555       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a6dd9d91121205de5b080b0435e21821a">time</a> = <a class="code" href="mp3__parse_8cpp.html#ad49f76141cc7ebc2c3ab30827b8359a4">fto_nearest_i</a>( (<span class="keywordtype">float</span>)mp3size / (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a0e45f14a28cf30ba0a72a2a9b486747b">bitrate</a> / 8) );
<a name="l00556"></a>00556     <span class="keywordflow">else</span>
<a name="l00557"></a>00557       _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a6dd9d91121205de5b080b0435e21821a">time</a> = <a class="code" href="mp3__parse_8cpp.html#ad49f76141cc7ebc2c3ab30827b8359a4">fto_nearest_i</a>( (<span class="keywordtype">float</span>)mp3size / (_mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#ad0fb1f3fa6e70eda74e10b7c9be66802">vbr_bitrate</a> / 8) );
<a name="l00558"></a>00558   }
<a name="l00559"></a>00559   <span class="keywordflow">else</span>
<a name="l00560"></a>00560   {
<a name="l00561"></a>00561     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#aaf5a59236a3ebd94aef870bcd3668465">frames</a> = 0;
<a name="l00562"></a>00562     _mp3_header_output-&gt;<a class="code" href="struct_mp3___headerinfo.html#a6dd9d91121205de5b080b0435e21821a">time</a> = 0;
<a name="l00563"></a>00563   }
<a name="l00564"></a>00564   <span class="comment">//if we got to here it&#39;s okay</span>
<a name="l00565"></a>00565   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00566"></a>00566 }
<a name="l00567"></a>00567 
<a name="l00568"></a>00568 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Jan 12 23:46:35 2011 for id3lib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>