📄 wavec.htm
字号:
the following section on the dvi adpcm wave type for a full description.</font></p>
<p><font size="2" face="arial"><b># define wave_format_ima_adpcm (0x0011)</b></font></p>
<p><font size="2" face="arial"><b>dvi adpcm wave type</b></font></p>
<blockquote>
<p><font size="2" face="arial">added: 12/16/92<br>
author: intel</font></p>
</blockquote>
<p><font size="2" face="arial">please note that dvi adpcm wave type is identical to ima
adpcm wave type.</font></p>
<p><font size="2" face="arial"><b>fact chunk</b></font></p>
<p><font size="2" face="arial">this chunk is required for all wave formats other than
wave_format_pcm. it stores file dependent information about the contents of the wave data.
it currently specifies the time length of the data in samples.</font></p>
<p><font size="2" face="arial"><b>wave format header</b></font></p>
<p><font size="2" face="arial"><b># define wave_format_dvi_adpcm (0x0011)</b></font></p>
<blockquote>
<p><font size="2" face="arial">typedef struct dvi_adpcmwaveformat_tag {<br>
waveformatex wfx;</font></p>
<p><font size="2" face="arial">word wsamplesperblock;<br>
} dviadpcmwaveformat;</font></p>
</blockquote>
<table border="1" cellpadding="7" width="576">
<tr>
<td width="25%"><font size="2" face="arial">wformattag</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">this must be set to
wave_format_dvi_adpcm.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">nchannels</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">number of channels in the wave, 1
for mono, 2 for stereo...</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">nsamplespersec</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">sample rate of the wave file. this
should be 8000, 11025, 22050 or 44100. other sample rates are allowed.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">navgbytespersec</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">total average data rate.<br>
playback software can estimate the buffer size for a selected amount of time by using the <!--webbot
bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup" endspan -->navgbytespersec>
value.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">nblockalign</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">this is dependent upon the number
of bits per sample.</font></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="23%"><font size="2" face="arial">wbitspersample</font></td>
<td width="52%"><font size="2" face="arial">nblockalign</font></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="23%"><font size="2" face="arial">3</font></td>
<td width="52%"><font size="2" face="arial">(( n * 3 ) + 1 ) * 4 * nchannels</font></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="23%"><font size="2" face="arial">4</font></td>
<td width="52%"><font size="2" face="arial">(n + 1) * 4 * nchannels</font></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="23%"> </td>
<td width="52%"><font size="2" face="arial">where n = 0, 1, 2, 3 . . .</font></td>
</tr>
<tr>
<td width="25%"> </td>
<td colspan="2" width="75%"><font size="2" face="arial">the recommended block size for
coding is<br>
256 * <!--webbot bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup" endspan -->nchannels>
bytes* min(1, (<b><nsamplespersecond>/ </b>11 khz))<br>
smaller values cause the block header to become a more significant storage overhead. but,
it is up to the implementation of the coding portion of the algorithm to decide the
optimal value for <!--webbot bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup"
endspan -->nblockalign> within the given constraints (see above). the decoding portion
of the algorithm must be able to handle any valid block size. playback software needs to
process a multiple of <!--webbot bot="htmlmarkup" startspan --><<b><!--webbot
bot="htmlmarkup" endspan -->nblockalign> bytes of data at a time, so the value of <!--webbot
bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup" endspan -->nblockalign> can
be used for allocating buffers.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">wbitspersample</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">this is the number of bits per
sample of data. dvi adpcm supports 3 or 4 bits per sample.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">cbsize</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">the size in bytes of the extra
information in the extended wave 'fmt' header. this should be 2.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">wsamplesperblock</font></td>
<td colspan="2" width="75%"><font size="2" face="arial">count of the number of samples per
channel per block.</font></td>
</tr>
</table>
<p><font size="2" face="arial"><b>block</b></font></p>
<p><font size="2" face="arial">the block is defined to be <!--webbot bot="htmlmarkup"
startspan --><<b><!--webbot bot="htmlmarkup" endspan -->nblockalign> bytes in length. for
dvi adpcm this must be a multiple of 4 bytes since all information in the block is divided
on 32 bit word boundaries. </font></p>
<p><font size="2" face="arial">the block has two parts, the header and the data. the two
together are <!--webbot bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup"
endspan -->nblockalign> bytes in length. the following diagram shows the header and
data parts of one block.</font></p>
<p><font size="2" face="arial">where:</font></p>
<p><font size="2" face="arial">m = <nchannels></font></p>
<p><font size="2" face="arial"><b>header</b></font></p>
<p><font size="2" face="arial">this is a c structure that defines the dvi adpcm block
header.</font></p>
<blockquote>
<p><font size="2" face="arial">typedef struct dvi_adpcmblockheader_tag {</font></p>
<p><font size="2" face="arial">int isamp0;</font></p>
<p><font size="2" face="arial">byte bsteptableindex;</font></p>
<p><font size="2" face="arial">byte breserved;</font></p>
<p><font size="2" face="arial">} dvi_adpcmblockheader;</font></p>
</blockquote>
<table border="1" cellpadding="7" width="576">
<tr>
<td width="25%"><font size="2" face="arial"><b>field</b></font></td>
<td width="75%"><font size="2" face="arial"><b>description</b></font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">isamp0</font></td>
<td width="75%"><font size="2" face="arial">the first sample value of the block. when
decoding, this will be used as the previous sample to start decoding with.</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">bsteptableindex</font></td>
<td width="75%"><font size="2" face="arial">the current index into the step table array.
(0 - 88)</font></td>
</tr>
<tr>
<td width="25%"><font size="2" face="arial">breserved</font></td>
<td width="75%"><font size="2" face="arial">this byte is reserved for future use.</font></td>
</tr>
</table>
<p><font size="2" face="arial">a block contains an array of <!--webbot bot="htmlmarkup"
startspan --><<b><!--webbot bot="htmlmarkup" endspan -->nchannels> header structures as
defined above. this diagram gives a byte level description of the contents of each header
word.</font></p>
<p><font size="2" face="arial"><b>data</b></font></p>
<p><font size="2" face="arial">the data words are interpreted differently depending on the
number of bits per sample selected.</font></p>
<p><font size="2" face="arial">for 4 bit dvi adpcm (where <!--webbot bot="htmlmarkup"
startspan --><<b><!--webbot bot="htmlmarkup" endspan -->wbitspersample> is equal to four)
each data word contains eight sample codes as shown in the following diagram.</font></p>
<p> </p>
<p><font size="2" face="arial">where:</font></p>
<blockquote>
<p><font size="2" face="helvetica">n</font><font size="2" face="courier new"> = a data
word for a given channel, in the range of 0 to </font></p>
<p><font size="2" face="courier new"><!--webbot bot="htmlmarkup" startspan --><</font><!--webbot
bot="htmlmarkup" endspan --><font size="2" face="helvetica">nblockalign</font><font
size="2" face="courier new">> / ( 4 * <!--webbot bot="htmlmarkup" startspan --><</font><!--webbot
bot="htmlmarkup" endspan --><font size="2" face="helvetica">nchannels</font><font size="2"
face="courier new">> ) - <!--webbot bot="htmlmarkup" startspan --><</font><!--webbot
bot="htmlmarkup" endspan --><font size="2" face="helvetica">nchannels</font><font size="2"
face="courier new">> - 1</font></p>
<p><font size="2" face="helvetica">p</font><font size="2" face="courier new"> = ( </font><font
size="2" face="helvetica">n</font><font size="2" face="courier new"> * 8 ) + 1</font></p>
</blockquote>
<p><font size="2" face="arial">sample 0 is always included in the block header for the
channel.</font></p>
<p><font size="2" face="arial">each sample is 4 bits in length. each block contains a
total of <!--webbot bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup" endspan
-->wsamplesperblock> samples for each channel.</font></p>
<p><font size="2" face="arial">for 3 bit dvi adpcm (where <!--webbot bot="htmlmarkup"
startspan --><<b><!--webbot bot="htmlmarkup" endspan -->wbitspersample> is equal to
three) each data word contains 10.667 sample codes. it takes three words to hold an
integral number of sample codes at 3 bits per code. so for 3 bit dvi adpcm, the number of
data words is required to be a multiple of three words (12 bytes). these three words
contain 32 sample codes as shown in the following diagram.</font></p>
<p> </p>
<p><font size="2">where:</font></p>
<blockquote>
<p><font size="2" face="courier new">m = one of the channels, in the range of 1 to <!--webbot
bot="htmlmarkup" startspan --><</font><!--webbot bot="htmlmarkup" endspan --><font size="2"
face="helvetica">nchannels</font><font size="2" face="courier new">></font></p>
<p><font size="2" face="courier new">n = the first data word in a group of three data
words for channelm, in the </font></p>
<p><font size="2" face="courier new">range of 0 to <!--webbot bot="htmlmarkup" startspan --><</font><!--webbot
bot="htmlmarkup" endspan --><font size="2" face="helvetica">nblockalign</font><font
size="2" face="courier new">> / ( 4 * <!--webbot bot="htmlmarkup" startspan --><</font><!--webbot
bot="htmlmarkup" endspan --><font size="2" face="helvetica">nchannels</font><font size="2"
face="courier new">> ) - <!--webbot bot="htmlmarkup" startspan --><</font><!--webbot
bot="htmlmarkup" endspan --><font size="2" face="helvetica">nchannels</font><font size="2"
face="courier new">> - 1</font></p>
<p><font size="2" face="courier new">p = ( ( n / 3 ) * 32 ) + 1</font></p>
</blockquote>
<p><font size="2" face="arial">sample 0 is always included in the block header for the
channel.</font></p>
<p><font size="2" face="arial">each sample is 3 bits in length. each block contains a
total of <!--webbot bot="htmlmarkup" startspan --><<b><!--webbot bot="htmlmarkup" endspan
-->wsamplesperblock> samples for each channel.</font></p>
<p><font size="2" face="arial"><b>dvi adpcm algorithm</b></font></p>
<p><font size="2" face="arial">each channel of the dvi adpcm file can be encoded/decoded
independently. since the channels are encoded/decoded independently, this document is
written as if only one channel is being decoded. since the channels are interleaved,
multiple channels may be encoded/decoded in parallel using independent local storage and
temporaries.</font></p>
<p><font size="2" face="arial">note that the process for encoding/decoding one block is
independent from the process for the next block. therefore the process is described for
one block only, and may be repeated for other blocks.</font></p>
<p><font size="2" face="arial">the processes for encoding and decoding is discussed below.</font></p>
<p><font size="2" face="arial"><b>tables</b></font></p>
<p><font size="2" face="arial">the dvi adpcm algorithm relies on two tables to encode and
decode audio samples. these are the step table and the index table. the contents of these
tables are fixed for this algorithm. the 3 and 4 bit versions of the dvi adpcm algorithm
use the same step table, which is:</font></p>
<blockquote>
<p><font size="2" face="courier new">const int steptab[ 89 ] = {</font></p>
<p><font size="2" face="courier new">7, 8, 9, 10, 11, 12, 13, 14,</font></p>
<p><font size="2" face="courier new">16, 17, 19, 21, 23, 25, 28, 31,</font></p>
<p><font size="2" face="courier new">34, 37, 41, 45, 50, 55, 60, 66,</font></p>
<p><font size="2" face="courier new">73, 80, 88, 97, 107, 118, 130, 143,</font></p>
<p><font size="2" face="courier new">157, 173, 190, 209, 230, 253, 279, 307,</font></p>
<p><font size="2" face="courier new">337, 371, 408, 449, 494, 544, 598, 658,</font></p>
<p><font size="2" face="courier new">724, 796, 876, 963, 1060, 1166, 1282, 1411,</font></p>
<p><font size="2" face="courier new">1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024,</font></p>
<p><font size="2" face="courier new">3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484,</font></p>
<p><font size="2" face="co
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -