[MPlayer-dev-eng] MS-ADPCM/Stereo Works
Mike Melanson
melanson at pcisys.net
Fri Dec 28 05:20:41 CET 2001
On Fri, 28 Dec 2001, Michael Niedermayer wrote:
> sure iam allways interrested ...
> if i understand corrrectly than the imaadpcm decoder only stores
> the predictor (=last output sample)
> the index (0-88)
> the stepsize (which only depends on the index)
> allthough the predictor isnt really used except that it is added at the end
> so it might be possible to replace the whole decoder with a look up table ...
> assuming that i understand it correctly
> int delta= lut[input + index*16];
> predictor+= delta;
> clamp predictor
> output=predictor;
> index += adpcm_index[input];
> clamp index
It's late and I'm having trouble digesting all of this. Here's
what I have in my ADPCM document on the IMA algorithm (numbers are
big-endian):
The remaining 32 bytes, or 64 nibbles, are decoded into 64 16-bit PCM
samples. For each byte, the lower nibble is decoded first (bits 3-0), then
the upper nibble.
initialize:
predictor = (first 2 bytes of the chunk) & 0xFF80
sign extend number
clamp within signed 16-bit range
index = (first 2 bytes of chunk) & 0x7F
clamp between 0 and 88
step = step_table[index]
for each nibble:
index += index_table[(unsigned)nibble]
clamp index between 0..88 (table limits)
diff = ((signed)nibble + 0.5) * step / 4
[insert note about calculating diff]
predictor += diff
clamp predictor value within signed 16-bit range and output to
decompressed audio stream
step = step_table[index]
Again, rough draft. Also, I recalled that stereo IMA is stored as an
entire 0x22-byte block for the left channel followed by an entire
0x22-byte block for the right channel. However, MS ADPCM is stored
interleaved.
> after thinking about it again simd doesnt seem to be a that good choice :(
> ... but who knows, i doubt that a SIMD-adpcm decoder is a good beginers
> exercise
There may yet be some opportunity. Is there any efficient way to
rip apart nibbles and interleave them using SIMD instructions? Also,
where are some good references for SIMD stuff? I studied up on MMX a long
time ago, but could never find 3dnow or SSE stuff. Then, when I found
MPlayer, I realized there were second versions of each. I'm a little
behind and am constrained to thinking in terms of MMX v1 only.
Thanks...
--
-Mike Melanson
More information about the MPlayer-dev-eng
mailing list