optimizations

This commit is contained in:
chudov
2010-11-18 06:06:12 +00:00
parent 884e30e01a
commit 76762f2e16
4 changed files with 73 additions and 34 deletions

View File

@@ -56,6 +56,21 @@ namespace CUETools.Codecs
writebits(8, c);
}
public unsafe void writeints(int len, byte* buf)
{
int old_pos = BitLength;
int start = old_pos / 8;
int end = (old_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);
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)));
}
public void write(params char [] chars)
{
foreach (char c in chars)
@@ -343,5 +358,13 @@ namespace CUETools.Codecs
buf_ptr = buf_start + value;
}
}
public int BitLength
{
get
{
return buf_ptr * 8 + 32 - bit_left;
}
}
}
}