Minor doc

This commit is contained in:
bnnm 2018-07-22 00:47:31 +02:00
parent 907a0af3df
commit 4439047fd1
2 changed files with 10 additions and 8 deletions

View File

@ -1,13 +1,13 @@
#include "coding.h"
/* Decodec Argonaut's ASF ADPCM codec. Algorithm follows Croc2_asf2raw.exe, and the waveform
/* Decodes Argonaut's ASF ADPCM codec. Algorithm follows Croc2_asf2raw.exe, and the waveform
* looks almost correct, but should reverse engineer asfcodec.adl (DLL) for accuracy. */
void decode_asf(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
off_t frame_offset;
int i, frames_in, sample_count = 0;
size_t bytes_per_frame, samples_per_frame;
uint32_t shift, mode;
uint8_t shift, mode;
int32_t hist1 = stream->adpcm_history1_32;
int32_t hist2 = stream->adpcm_history2_32;
@ -17,12 +17,12 @@ void decode_asf(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing,
frames_in = first_sample / samples_per_frame;
first_sample = first_sample % samples_per_frame;
/* parse header */
/* parse frame header */
frame_offset = stream->offset + bytes_per_frame*frames_in;
shift = (read_8bit(frame_offset+0x00,stream->streamfile) >> 4) & 0xf;
mode = (read_8bit(frame_offset+0x00,stream->streamfile) >> 0) & 0xf;
shift = ((uint8_t)read_8bit(frame_offset+0x00,stream->streamfile) >> 4) & 0xf;
mode = ((uint8_t)read_8bit(frame_offset+0x00,stream->streamfile) >> 0) & 0xf;
/* decoder nibbles */
/* decode nibbles */
for (i = first_sample; i < first_sample + samples_to_do; i++) {
int32_t new_sample;
uint8_t nibbles = (uint8_t)read_8bit(frame_offset+0x01 + i/2,stream->streamfile);
@ -50,7 +50,7 @@ void decode_asf(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing,
}
//new_sample = clamp16(new_sample); /* must not */
new_sample = new_sample & 0xFFFF; /* probably unnecessary */
new_sample = new_sample & 0xFFFF; /* probably unnecessary and only casting is needed */
outbuf[sample_count] = new_sample;
sample_count += channelspacing;

View File

@ -3,7 +3,7 @@
// todo this is based on Kazzuya's old code; different emus (PCSX, Mame, Mednafen, etc) do
// XA coefs int math in different ways (see comments below), not be 100% accurate.
// May be implemented like the SNES/SPC700 BRR (see BSNES' brr.cpp, hardware-tested).
// May be implemented like the SNES/SPC700 BRR.
/* XA ADPCM gain values */
static const double K0[4] = { 0.0, 0.9375, 1.796875, 1.53125 };
@ -35,6 +35,8 @@ static int IK1(int fid) { return ((int)((-K1[fid]) * (1 << 10))); }
* PS1 XA is apparently upsampled and interpolated to 44100, vgmstream doesn't simulate this.
*
* Info (Green Book): https://www.lscdweb.com/data/downloadables/2/8/cdi_may94_r2.pdf
* BRR info (no$sns): http://problemkaputt.de/fullsnes.htm#snesapudspbrrsamples
* (bsnes): https://gitlab.com/higan/higan/blob/master/higan/sfc/dsp/brr.cpp
*/
void decode_xa(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel) {
static int head_table[8] = {0,2,8,10};