}
let mut ch = 0;
let flip_ch = if channels == 2 { 1 } else { 0 };
- for _ in 1..self.blk_align {
+ for _ in channels..self.blk_align*channels {
let b = br.read_byte()? as usize;
if (b & 0x80) != 0 {
pred[ch] -= SOL_AUD_STEPS16[b & 0x7F] as i32;
fmt = SND_U8_FORMAT;
self.is16bit = false;
self.blk_size = ainfo.get_block_len();
+ self.blk_align = ainfo.get_block_len() / (ainfo.get_channels() as usize);
} else {
fmt = SND_S16P_FORMAT;
self.is16bit = true;
self.blk_size = (ainfo.get_block_len() + 1) * (ainfo.get_channels() as usize);
+ self.blk_align = ainfo.get_block_len();
};
- self.blk_align = ainfo.get_block_len() / (ainfo.get_channels() as usize);
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), ainfo.get_channels(), fmt, ainfo.get_block_len());
self.chmap = NAChannelMap::from_str(if ainfo.get_channels() == 1 { "C" } else { "L,R" }).unwrap();
Ok(())
for i in 0..self.blk_align * channels {
dst[doff + i] = 0;
}
- } else {
- for i in 0..self.blk_align * channels {
+ } else if channels == 1 {
+ for i in 0..self.blk_size {
dst[doff + i] = br.read_byte()?;
}
+ } else {
+ for i in 0..self.blk_size {
+ let val = br.read_byte()?;
+ if val < 128 {
+ dst[doff + i] = 127 - val;
+ } else {
+ dst[doff + i] = val;
+ }
+ }
}
- doff += self.blk_align;
+ doff += self.blk_align * channels;
mask >>= 1;
}
}
// let file = "assets/1491.VMD";
let file = "assets/128.vmd";
+// let file = "assets/1000.VMD";
+// let file = "assets/235.VMD";
test_decode_audio("vmd", file, None, "vmd", &dmx_reg, &dec_reg);
}
}
self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, 12)).unwrap();
let srate = read_u16le(&header[804..])? as u32;
+ let block_size;
if srate > 0 {
let bsize = read_u16le(&header[806..])? as usize;
- let channels = if (header[811] & 0x80) != 0 { 2 } else { 1 };
+ let channels = if (header[811] & 0x8F) != 0 { 2 } else { 1 };
let is16bit;
- let block_size;
if (bsize & 0x8000) != 0 {
is16bit = true;
block_size = 0x10000 - bsize;
let ahdr = NAAudioInfo::new(srate, channels, if is16bit { SND_S16P_FORMAT } else { SND_U8_FORMAT }, block_size);
let ainfo = NACodecInfo::new("vmd-audio", NACodecTypeInfo::Audio(ahdr), None);
self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, srate)).unwrap();
+ } else {
+ block_size = 0;
}
let adelay = read_u16le(&header[808..])? as u32;
for _ in 0..fpb {
let chtype = src.read_byte()?;
src.read_skip(1)?;
- let size = src.read_u32le()?;
+ let mut size = src.read_u32le()?;
let mut hdr: [u8; FRAME_HDR_SIZE] = [0; FRAME_HDR_SIZE];
src.read_buf(&mut hdr)?;
+ if (i == 0) && (chtype == CHTYPE_AUDIO) && (size > 4) && ((size as usize) < block_size/2) {
+ size += 0x10000;
+ }
if (chtype == CHTYPE_VIDEO || chtype == CHTYPE_AUDIO) && (size > 0) {
let ts = if (i == 0) || (chtype != CHTYPE_AUDIO) {
i as u32