Backed out changeset: 883e51ca8287

This commit is contained in:
Grigory Chudov
2014-09-19 01:17:23 -04:00
parent 7a4763300b
commit 3572745968
3 changed files with 22 additions and 73 deletions

View File

@@ -1363,14 +1363,7 @@ namespace CUETools.Codecs.FLACCL
fixed (int* coefs = task.frame.subframes[ch].best.coefs)
{
if (Settings.PCM.BitsPerSample > 16)
{
if (!lpc.encode_residual_long(task.frame.subframes[ch].best.residual, task.frame.subframes[ch].samples, task.frame.blocksize, task.frame.subframes[ch].best.order, coefs, task.frame.subframes[ch].best.shift))
{
task.frame.subframes[ch].best.type = SubframeType.Verbatim;
task.frame.subframes[ch].best.size = (uint)(task.frame.subframes[ch].obits * task.frame.blocksize);
return;
}
}
lpc.encode_residual_long(task.frame.subframes[ch].best.residual, task.frame.subframes[ch].samples, task.frame.blocksize, task.frame.subframes[ch].best.order, coefs, task.frame.subframes[ch].best.shift);
else
lpc.encode_residual(task.frame.subframes[ch].best.residual, task.frame.subframes[ch].samples, task.frame.blocksize, task.frame.subframes[ch].best.order, coefs, task.frame.subframes[ch].best.shift);
}

View File

@@ -1156,10 +1156,7 @@ new int[] { // 30
fixed (int* coefs = frame.current.coefs)
{
if ((csum << frame.subframes[ch].obits) >= 1UL << 32)
{
if (!lpc.encode_residual_long(frame.current.residual, frame.subframes[ch].samples, frame.blocksize, frame.current.order, coefs, frame.current.shift))
continue;
}
lpc.encode_residual_long(frame.current.residual, frame.subframes[ch].samples, frame.blocksize, frame.current.order, coefs, frame.current.shift);
else
lpc.encode_residual(frame.current.residual, frame.subframes[ch].samples, frame.blocksize, frame.current.order, coefs, frame.current.shift);
}
@@ -1277,10 +1274,7 @@ new int[] { // 30
csum += (ulong)Math.Abs(coefs[i - 1]);
if ((csum << frame.subframes[ch].obits) >= 1UL << 32)
{
if (!lpc.encode_residual_long(frame.current.residual, frame.subframes[ch].samples, frame.blocksize, frame.current.order, coefs, frame.current.shift))
continue;
}
lpc.encode_residual_long(frame.current.residual, frame.subframes[ch].samples, frame.blocksize, frame.current.order, coefs, frame.current.shift);
else
lpc.encode_residual(frame.current.residual, frame.subframes[ch].samples, frame.blocksize, frame.current.order, coefs, frame.current.shift);
@@ -2276,33 +2270,15 @@ new int[] { // 30
if (verify != null)
{
try
{
int decoded = verify.DecodeFrame(frame_buffer, 0, fs);
if (decoded != fs || verify.Remaining != bs)
throw new Exception(Properties.Resources.ExceptionValidationFailed);
fixed (int* s = verifyBuffer, r = verify.Samples)
{
for (int ch = 0; ch < channels; ch++)
if (AudioSamples.MemCmp(s + ch * Flake.MAX_BLOCKSIZE, r + ch * Flake.MAX_BLOCKSIZE, bs))
throw new Exception(Properties.Resources.ExceptionValidationFailed);
}
}
catch (Exception ex)
{
//if (channels == 2)
//{
// var sw = new WAVWriter("verify.wav", new WAVWriterSettings(this.Settings.PCM));
// sw.FinalSampleCount = this.frame.blocksize;
// var ab = new AudioBuffer(this.Settings.PCM, this.frame.blocksize);
// ab.Prepare(this.frame.blocksize);
// fixed (int* abs = ab.Samples, s = verifyBuffer)
// AudioSamples.Interlace(abs, s, s + Flake.MAX_BLOCKSIZE, this.frame.blocksize);
// sw.Write(ab);
// sw.Close();
//}
throw ex;
}
int decoded = verify.DecodeFrame(frame_buffer, 0, fs);
if (decoded != fs || verify.Remaining != bs)
throw new Exception(Properties.Resources.ExceptionValidationFailed);
fixed (int* s = verifyBuffer, r = verify.Samples)
{
for (int ch = 0; ch < channels; ch++)
if (AudioSamples.MemCmp(s + ch * Flake.MAX_BLOCKSIZE, r + ch * Flake.MAX_BLOCKSIZE, bs))
throw new Exception(Properties.Resources.ExceptionValidationFailed);
}
}
if (bs < m_blockSize)

View File

@@ -693,7 +693,7 @@ namespace CUETools.Codecs
}
}
public static unsafe bool
public static unsafe void
encode_residual_long(int* res, int* smp, int n, int order,
int* coefs, int shift)
{
@@ -704,16 +704,13 @@ namespace CUETools.Codecs
int* r = res + order;
int c0 = coefs[0];
int c1 = coefs[1];
long overflows = 0L;
switch (order)
{
case 1:
for (int i = n - order; i > 0; i--)
{
long pred = c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
}
break;
case 2:
@@ -721,9 +718,7 @@ namespace CUETools.Codecs
{
long pred = c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *(s--) - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *(s--) - (int)(pred >> shift);
}
break;
case 3:
@@ -732,9 +727,7 @@ namespace CUETools.Codecs
long pred = coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
s -= 2;
}
break;
@@ -745,9 +738,7 @@ namespace CUETools.Codecs
pred += coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
s -= 3;
}
break;
@@ -759,9 +750,7 @@ namespace CUETools.Codecs
pred += coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
s -= 4;
}
break;
@@ -774,9 +763,7 @@ namespace CUETools.Codecs
pred += coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
s -= 5;
}
break;
@@ -790,9 +777,7 @@ namespace CUETools.Codecs
pred += coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
s -= 6;
}
break;
@@ -807,9 +792,7 @@ namespace CUETools.Codecs
pred += coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
s -= 7;
}
break;
@@ -830,13 +813,10 @@ namespace CUETools.Codecs
pred += coefs[2] * (long)*(s++);
pred += c1 * (long)*(s++);
pred += c0 * (long)*(s++);
pred = *s - (pred >> shift);
overflows += (pred ^ (pred >> 63)) >> 30;
*(r++) = (int)pred;
*(r++) = *s - (int)(pred >> shift);
}
break;
}
return overflows == 0;
}
public static unsafe void