Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Medium Block ADPCM (MBLKA1)
- * Mono or Joint Stereo
- * Yet another ADPCM Variant
- * Will not (yet) define a container format.
- ** The format it is used in can define the container specifics.
- ** This format is likely to be used in constructing some other format.
- Each block will begin with a 16-bit block header followed by the sample data for the block (encoded as 16 bit words).
- Encoded block size will be assumed to be a multiple of 4 samples (Mono) or 16 samples (Stereo).
- Nominally, a block may be assumed to contain a number of samples that is a power of two, however, storage for such a block will not be a power of two.
- Block Header:
- * (16:6): Initial Sample (S.E4.F5)
- * ( 5:0): Init Step Index, E4.F2
- Sample Decodes to PCM (S=Sign):
- * s1111xxxxx: 1xxxxx00000000000000 (524288)
- * s1110xxxxx: 01xxxxx0000000000000 (262144)
- * s1101xxxxx: 001xxxxx000000000000 (131072)
- * s1100xxxxx: 0001xxxxx00000000000 (65536)
- * s1011xxxxx: 00001xxxxx0000000000 (32768)
- * s1010xxxxx: 000001xxxxx000000000 (16384)
- * s1001xxxxx: 0000001xxxxx00000000 (8192)
- * s1000xxxxx: 00000001xxxxx0000000 (4096)
- * s0111xxxxx: 000000001xxxxx000000 (2048)
- * s0110xxxxx: 0000000001xxxxx00000 (1024)
- * s0101xxxxx: 00000000001xxxxx0000 (512)
- * s0100xxxxx: 000000000001xxxxx000 (256)
- * s0011xxxxx: 0000000000001xxxxx00 (128)
- * s0010xxxxx: 00000000000001xxxxx0 (64)
- * s0001xxxxx: 000000000000001xxxxx (32)
- * s0000xxxxx: 000000000000000xxxxx (0..31)
- * The s bit will encode the sign.
- Step Index Decodes to Step:
- * 1111xx: 0001xx00000000000000 (65536..114688)
- * 1110xx: 00001xx0000000000000 (32768..57344)
- * 1101xx: 000001xx000000000000 (16384..28672)
- * 1100xx: 0000001xx00000000000 (8192)
- * 1011xx: 00000001xx0000000000 (4096)
- * 1010xx: 000000001xx000000000 (2048)
- * 1001xx: 0000000001xx00000000 (1024)
- * 1000xx: 00000000001xx0000000 (512)
- * 0111xx: 000000000001xx000000 (256)
- * 0110xx: 0000000000001xx00000 (128)
- * 0101xx: 00000000000001xx0000 (64)
- * 0100xx: 000000000000001xx000 (32)
- * 0011xx: 0000000000000001xx00 (16/20/24/28)
- * 0010xx: 00000000000000001xx0 (8/ 10/12/14)
- * 0001xx: 000000000000000001xx (4..7)
- * 0000xx: 000000000000000000xx (0..3)
- ADPCM Sample Indices are 4-bits:
- * s111: Delta = (15/8)*Step*Sgn
- * s110: Delta = (13/8)*Step*Sgn
- * s101: Delta = (11/8)*Step*Sgn
- * s100: Delta = ( 9/8)*Step*Sgn
- * s011: Delta = ( 7/8)*Step*Sgn
- * s010: Delta = ( 5/8)*Step*Sgn
- * s001: Delta = ( 3/8)*Step*Sgn
- * s000: Delta = ( 1/8)*Step*Sgn
- * Where s encodes the sign of the value (0=Positive, 1=Negative)
- Alternately, the Delta could be interpreted as:
- * Delta = (Frac*StepLow) SHL StepExp ^ SgnMask
- * Pred1 = Pred + Delta + SgnBit
- * This can be used to reduce the multiply to a small table lookup and shift.
- ** The separate addition of the sign bit being for Twos Complement.
- For now, will assume that the adding the Delta to the Predictor will follow Twos Complement rules. The predictor will also encode three bits below the LSB of the encoded sample.
- Samples will be encoded into each 16-bit word starting at the LSB and working upward.
- Step Index Adjust (Low 3 bits of Sample Index):
- * -1, -1, 0, 0, 1, 2, 4, 8
- After each sample, the Step Index will be adjusted based on the the 4-bit sample word.
- This step index should not be allowed to go outside the Range 1..63.
- It will be in error for an encoder to produce output which takes the step index outside of its valid range. The decoder side behavior if StepIndex goes out of range is undefined.
- In this format, the ADPCM Encode and Decode process will not be range clamped, so while the input and output samples will be clamped to -32768..32767, the intermediate values are allowed to go slightly outside this range.
- Within the encoded blocks, there will be an implicit limit of around +/- 98K.
- * The Center channel should remain within +/- 32K.
- * The Side channel should remain within +/- 64K.
- === Joint Stereo ===
- Stereo will be encoded in a joint-stereo scheme:
- * Audio will be transformed into Center / Side;
- * Center channel will be encoded first;
- * Side channel will follow after center channel, 1/4 downsample.
- * Each channel will be encoded as a Mono block.
- So, for 256 strero samples, the block will be structured as:
- * Center Header Word
- * 64 Words, Center Samples
- * Side Header Word
- * 16 Words, Side Samples
- Transform:
- * C=(L+R)/2
- * S=R-L
- * L1=C-(S/2)
- * R1=L1+S
- During decoding, the side channel will be linearly interpolated, with each sample aligned with the center point of the group. The sample value from the header will be used to estimate for the value of the preceding sample. The last sample in the block will be repeated.
Advertisement
Add Comment
Please, Sign In to add comment