optimizations

This commit is contained in:
chudov
2010-11-25 09:11:07 +00:00
parent 8857259a5f
commit a38c14f15c
2 changed files with 39 additions and 6 deletions

View File

@@ -56,19 +56,21 @@ namespace CUETools.Codecs
writebits(8, c);
}
public unsafe void writeints(int len, byte* buf)
public unsafe void writeints(int len, int pos, byte* buf)
{
int old_pos = BitLength;
int start = old_pos / 8;
int start1 = pos / 8;
int end = (old_pos + len) / 8;
int end1 = (pos + len) / 8;
flush();
byte start_val = old_pos % 8 != 0 ? buffer[start] : (byte)0;
fixed (byte* buf1 = &buffer[0])
AudioSamples.MemCpy(buf1 + start, buf + start, end - start);
AudioSamples.MemCpy(buf1 + start, buf + start1, end - start);
buffer[start] |= start_val;
buf_ptr = end;
if ((old_pos + len) % 8 != 0)
writebits((old_pos + len) % 8, buf[end] >> (8 - ((old_pos + len) % 8)));
writebits((old_pos + len) % 8, buf[end1] >> (8 - ((old_pos + len) % 8)));
}
public void write(params char [] chars)